Merge branch 'develop' of openspace.itn.liu.se:/openspace into develop

This commit is contained in:
Jonas Strandstedt
2014-12-12 14:55:48 +01:00
6 changed files with 57 additions and 115 deletions

105
GUI.diff
View File

@@ -1,105 +0,0 @@
diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h
index c3d8c9e..8f70641 100644
--- a/include/openspace/rendering/renderengine.h
+++ b/include/openspace/rendering/renderengine.h
@@ -36,6 +36,7 @@ class SceneGraph;
class ABuffer;
class ABufferVisualizer;
class ScreenLog;
+class GUI;
class RenderEngine {
public:
@@ -78,6 +79,7 @@ private:
SceneGraph* _sceneGraph;
ABuffer* _abuffer;
ScreenLog* _log;
+ GUI* _gui;
bool _showInfo;
bool _showScreenLog;
diff --git a/scripts/bind_keys.lua b/scripts/bind_keys.lua
index a0f9442..08a3254 100644
--- a/scripts/bind_keys.lua
+++ b/scripts/bind_keys.lua
@@ -17,5 +17,6 @@ openspace.bindKey("f5", "loadKeyBindings()")
openspace.bindKey("U", "openspace.distance(-interaction_speed * openspace.dt(), 13.0)")
openspace.bindKey("J", "openspace.distance(interaction_speed * openspace.dt(), 13.0)")
+openspace.bindKey("K", "openspace.distance(interaction_speed * openspace.dt(), 20.0)")
openspace.bindKey("PRINT_SCREEN", "openspace.takeScreenshot()")
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0dc32c8..4be7f7a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -130,6 +130,11 @@ source_group(Interface FILES ${INTERFACE_SOURCE} ${INTERFACE_HEADER})
include_directories(${HEADER_ROOT_DIR})
include_directories(${GHOUL_ROOT_DIR}/ext/boost)
+include_directories(${CMAKE_SOURCE_DIR}/ext/imgui)
+set(OPENSPACE_HEADER ${OPENSPACE_HEADER} ${CMAKE_SOURCE_DIR}/ext/imgui/imgui.h)
+set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${CMAKE_SOURCE_DIR}/ext/imgui/imgui.cpp)
+source_group(ext\\imgui FILES ${CMAKE_SOURCE_DIR}/ext/imgui/imgui.h ${CMAKE_SOURCE_DIR}/ext/imgui/imgui.cpp)
+
if (APPLE)
add_definitions(-D__APPLE__)
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp
index 9317b0e..93735eb 100644
--- a/src/rendering/renderengine.cpp
+++ b/src/rendering/renderengine.cpp
@@ -30,6 +30,7 @@
#include <openspace/abuffer/abufferSingleLinked.h>
#include <openspace/abuffer/abufferfixed.h>
#include <openspace/abuffer/abufferdynamic.h>
+#include <openspace/engine/gui.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/scenegraph/scenegraph.h>
#include <openspace/util/camera.h>
@@ -38,7 +39,6 @@
#include <openspace/util/screenlog.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/syncbuffer.h>
-
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/lua/lua_helper.h>
@@ -111,6 +111,7 @@ RenderEngine::RenderEngine()
, _sceneGraph(nullptr)
, _abuffer(nullptr)
, _log(nullptr)
+ , _gui(nullptr)
, _showInfo(true)
, _showScreenLog(true)
, _takeScreenshot(false)
@@ -241,6 +242,11 @@ bool RenderEngine::initializeGL()
_visualizer = new ABufferVisualizer();
+ int x,y;
+ sgct::Engine::instance()->getActiveViewportSize(x, y);
+ _gui = new GUI(glm::vec2(glm::ivec2(x,y)));
+ _gui->initializeGL();
+
// successful init
return true;
}
@@ -330,6 +336,16 @@ void RenderEngine::render()
else {
_visualizer->render();
}
+
+ double posX, posY;
+ sgct::Engine::instance()->getMousePos(0, &posX, &posY);
+
+ int button0 = sgct::Engine::instance()->getMouseButton(0, 0);
+ int button1 = sgct::Engine::instance()->getMouseButton(0, 1);
+ bool buttons[2] = { button0 != 0, button1 != 0 };
+
+ double dt = std::max(sgct::Engine::instance()->getDt(), 1.0/60.0);
+ _gui->render(dt, glm::vec2(posX, posY), buttons);
#if 1

View File

@@ -15,7 +15,7 @@
<!-- <Size x="960" y="540" /> -->
<!-- <Size x="640" y="360" /> -->
<!--<Size x="640" y="310" />-->
<Pos x="500" y="500.0" />
<Pos x="500" y="100.0" />
<Viewport>
<Pos x="0.0" y="0.0" />
<Size x="1.0" y="1.0" />

View File

@@ -205,10 +205,10 @@ public:
* required for creating a GUI representation. The format of the description is a
* valid Lua table, i.e., it is surrounded by a pair of <code>{</code> and
* <code>}</code> with key,value pairs between. Each value can either be a number, a
* string, a bool, or another table. The general values that every Property must set
* string, a bool, or another table. The general values set by this base function
* are: <code>Identifier</code>, <code>Name</code>, <code>Type</code>. All other
* values are specific to the type. If a Property does not override this method, an
* empty string is returned.
* values are specific to the type and are added in a specific subclass, which require
* the subclass to call this method first.
* \return The descriptive text for the Property that can be used for constructing a
* GUI representation
*/
@@ -293,6 +293,16 @@ protected:
static const std::string TypeKey;
static const std::string MetaDataKey;
/**
* Creates the information that is general to every Property and adds the
* <code>Identifier</code>, <code>Name</code>, <code>Type</code>, and
* <code>MetaData</code> keys and their values. The meta data is handles by the
* generateMetaDataDescription method, which has to be overloaded if a concrete base
* class wants to add meta data that is not curated by the Property class
* \return The base description common to all Property classes
*/
std::string generateBaseDescription() const;
/**
* Creates the information for the <code>MetaData</code> key-part of the Lua
* description for the Property. The result can be included as one key-value pair in
@@ -300,7 +310,20 @@ protected:
* Property class is used in this method.
* \return The metadata information text for the property
*/
std::string generateMetaDataDescription() const;
virtual std::string generateMetaDataDescription() const;
/**
* Creates the information that is specific to each subclass of Property%s. If a
* subclass needs to add additional information into the description, it has to
* override this method and return the string containing all of the additional
* information. The base implementation of the #description method will return the Lua
* script:
* <code>return { generateBaseDescription(), generateMetaDataDescription(),</code>
* <code>generateAdditionalDescription()}</code>, which #generateMetaDataDescription
* and this method being the override points to customize the behavior.
* \return The information specific to each subclass of Property
*/
virtual std::string generateAdditionalDescription() const;
/**
* This method must be called by all subclasses whenever the encapsulated value has

View File

@@ -127,6 +127,13 @@ public:
/// \see Property::typeLua
int typeLua() const override;
/**
* Returns the description for this TemplateProperty as a Lua script that returns a
* table on execution
* \return The description for this TemplateProperty
*/
//virtual std::string description() override;
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as

View File

@@ -126,6 +126,11 @@ std::string TemplateProperty<T>::className() const {
return PropertyDelegate<TemplateProperty<T>>::className();
}
//template <typename T>
//std::string TemplateProperty<T>::description() {
// return
//}
template <typename T>
TemplateProperty<T>::operator T() {
return _value;

View File

@@ -110,7 +110,7 @@ std::string Property::guiName() const {
}
std::string Property::description() const {
return "";
return "return {" + generateBaseDescription() + "}";
}
void Property::setGroupIdentifier(std::string groupId) {
@@ -158,6 +158,15 @@ void Property::notifyListener() {
_onChangeCallback();
}
std::string Property::generateBaseDescription() const {
return
TypeKey + " = \"" + className() + "\", " +
IdentifierKey + " = \"" + identifier() + "\", " +
NameKey + " = \"" + guiName() + "\", " +
generateMetaDataDescription() + ", " +
generateAdditionalDescription();
}
std::string Property::generateMetaDataDescription() const {
bool isVisible, isReadOnly;
_metaData.getValue(_metaDataKeyVisible, isVisible);
@@ -165,10 +174,13 @@ std::string Property::generateMetaDataDescription() const {
return
MetaDataKey + " = {" +
_metaDataKeyGroup + " = '" + groupIdentifier() + "',\n" +
_metaDataKeyVisible + " = '" + (isVisible ? "true" : "false") + "',\n" +
_metaDataKeyReadOnly +" = ;" + (isReadOnly ? "true" : "false") + "'\n" +
"},";
_metaDataKeyGroup + " = '" + groupIdentifier() + "'," +
_metaDataKeyVisible + " = " + (isVisible ? "true" : "false") + "," +
_metaDataKeyReadOnly +" = " + (isReadOnly ? "true" : "false") + "}";
}
std::string Property::generateAdditionalDescription() const {
return "";
}
} // namespace properties