mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 09:20:26 -05:00
Created GuiISWAComponent
This commit is contained in:
@@ -64,12 +64,12 @@ DataPlane::DataPlane(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_dataOptions);
|
||||
|
||||
if(_data->groupId < 0){
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useLog);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_normValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_backgroundValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_transferFunctionsFile);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_dataOptions);
|
||||
OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
OsEng.gui()._iswa.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iswa.registerProperty(&_normValues);
|
||||
OsEng.gui()._iswa.registerProperty(&_backgroundValues);
|
||||
OsEng.gui()._iswa.registerProperty(&_transferFunctionsFile);
|
||||
OsEng.gui()._iswa.registerProperty(&_dataOptions);
|
||||
}
|
||||
|
||||
_normValues.onChange([this](){
|
||||
|
||||
@@ -207,12 +207,12 @@ bool ISWACygnet::destroyShader(){
|
||||
}
|
||||
|
||||
void ISWACygnet::registerProperties(){
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_delete);
|
||||
OsEng.gui()._iswa.registerProperty(&_enabled);
|
||||
OsEng.gui()._iswa.registerProperty(&_delete);
|
||||
}
|
||||
|
||||
void ISWACygnet::unregisterProperties(){
|
||||
OsEng.gui()._iSWAproperty.unregisterProperties(name());
|
||||
OsEng.gui()._iswa.unregisterProperties(name());
|
||||
}
|
||||
|
||||
void ISWACygnet::initializeTime(){
|
||||
|
||||
@@ -119,7 +119,7 @@ bool ISWAGroup::checkType(ISWAManager::CygnetType type){
|
||||
}
|
||||
|
||||
void ISWAGroup::registerProperties(){
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_enabled);
|
||||
OsEng.gui()._iswa.registerProperty(&_enabled);
|
||||
|
||||
_enabled.onChange([this]{
|
||||
for(auto cygnet : _cygnets)
|
||||
@@ -128,12 +128,12 @@ void ISWAGroup::registerProperties(){
|
||||
|
||||
|
||||
if(_type == ISWAManager::CygnetType::Data){
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useLog);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_normValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_backgroundValues);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_transferFunctionsFile);
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_dataOptions);
|
||||
OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
OsEng.gui()._iswa.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iswa.registerProperty(&_normValues);
|
||||
OsEng.gui()._iswa.registerProperty(&_backgroundValues);
|
||||
OsEng.gui()._iswa.registerProperty(&_transferFunctionsFile);
|
||||
OsEng.gui()._iswa.registerProperty(&_dataOptions);
|
||||
|
||||
_useLog.onChange([this]{
|
||||
for(auto cygnet : _cygnets)
|
||||
@@ -168,21 +168,25 @@ void ISWAGroup::registerProperties(){
|
||||
|
||||
}
|
||||
|
||||
OsEng.gui()._iSWAproperty.registerProperty(&_delete);
|
||||
OsEng.gui()._iswa.registerProperty(&_delete);
|
||||
_delete.onChange([this]{
|
||||
for(auto it = _cygnets.begin(); it != _cygnets.end();){
|
||||
ISWAManager::ref().deleteISWACygnet((*it)->name());
|
||||
it = _cygnets.erase(it);
|
||||
}
|
||||
clearGroup();
|
||||
// ISWAManager::ref().unregisterGroup(_id);
|
||||
unregisterProperties();
|
||||
});
|
||||
}
|
||||
|
||||
void ISWAGroup::unregisterProperties(){
|
||||
_dataOptions.removeOptions();
|
||||
OsEng.gui()._iSWAproperty.unregisterProperties(name());
|
||||
OsEng.gui()._iswa.unregisterProperties(name());
|
||||
_type = ISWAManager::CygnetType::NoType;
|
||||
}
|
||||
|
||||
void ISWAGroup::clearGroup(){
|
||||
for(auto it = _cygnets.begin(); it != _cygnets.end();){
|
||||
ISWAManager::ref().deleteISWACygnet((*it)->name());
|
||||
it = _cygnets.erase(it);
|
||||
}
|
||||
unregisterProperties();
|
||||
}
|
||||
|
||||
} //namespace openspace
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
void unregisterCygnet(ISWACygnet* cygnet);
|
||||
void registerOptions(const std::vector<properties::SelectionProperty::Option>& options);
|
||||
bool checkType(ISWAManager::CygnetType type);
|
||||
void clearGroup();
|
||||
private:
|
||||
void registerProperties();
|
||||
void unregisterProperties();
|
||||
|
||||
@@ -417,7 +417,12 @@ std::string ISWAManager::parseKWToLuaTable(std::string kwPath, int group){
|
||||
|
||||
void ISWAManager::registerGroup(int id){
|
||||
_groups.insert(std::pair<int, std::shared_ptr<ISWAGroup>>(id, std::make_shared<ISWAGroup>(id)));
|
||||
}
|
||||
}
|
||||
|
||||
void ISWAManager::unregisterGroup(int id){
|
||||
if(_groups.find(id) != _groups.end())
|
||||
_groups[id]->clearGroup();
|
||||
}
|
||||
|
||||
void ISWAManager::registerToGroup(int id, CygnetType type, ISWACygnet* cygnet){
|
||||
if(_groups.find(id) == _groups.end()){
|
||||
@@ -449,20 +454,6 @@ std::shared_ptr<ISWAGroup> ISWAManager::iSWAGroup(std::string name){
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary ISWAManager::luaLibrary() {
|
||||
return {
|
||||
"iswa",
|
||||
{
|
||||
{
|
||||
"addCygnet",
|
||||
&luascriptfunctions::iswa_addCygnet,
|
||||
"string",
|
||||
"Adds a ISWACygnet",
|
||||
true
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
glm::dmat3 ISWAManager::getTransform(std::string from, std::string to, double et){
|
||||
std::set<std::string> _diopoleFrames = {"GSM", "SM", "MAG"};
|
||||
@@ -533,4 +524,26 @@ glm::dmat3 ISWAManager::getTransform(std::string from, std::string to, double et
|
||||
}
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary ISWAManager::luaLibrary() {
|
||||
return {
|
||||
"iswa",
|
||||
{
|
||||
{
|
||||
"addCygnet",
|
||||
&luascriptfunctions::iswa_addCygnet,
|
||||
"string",
|
||||
"Adds a ISWACygnet",
|
||||
true
|
||||
},
|
||||
{
|
||||
"removeGroup",
|
||||
&luascriptfunctions::iswa_removeGroup,
|
||||
"int",
|
||||
"Remove a group of Cygnets",
|
||||
true
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}// namsepace openspace
|
||||
@@ -77,6 +77,7 @@ public:
|
||||
|
||||
|
||||
void registerGroup(int id);
|
||||
void unregisterGroup(int id);
|
||||
void registerToGroup(int id, CygnetType type, ISWACygnet* cygnet);
|
||||
void unregisterFromGroup(int id, ISWACygnet* cygnet);
|
||||
void registerOptionsToGroup(int id, const std::vector<properties::SelectionProperty::Option>& options);
|
||||
|
||||
@@ -28,12 +28,16 @@ namespace luascriptfunctions {
|
||||
|
||||
int iswa_addCygnet(lua_State* L) {
|
||||
std::string s = luaL_checkstring(L, -1);
|
||||
// LERROR("String" << s);
|
||||
// std::cout << "String is: " << s << std::endl;
|
||||
ISWAManager::ref().addISWACygnet(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iswa_removeGroup(lua_State* L){
|
||||
int id = lua_tonumber(L, 1);
|
||||
ISWAManager::ref().unregisterGroup(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}// namespace luascriptfunctions
|
||||
|
||||
}// namespace openspace
|
||||
@@ -32,6 +32,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guiperformancecomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guipropertycomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guitimecomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guiiswacomponent.h
|
||||
)
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
@@ -43,6 +44,8 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guiperformancecomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guipropertycomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guitimecomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guiiswacomponent.cpp
|
||||
|
||||
)
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <modules/onscreengui/include/guipropertycomponent.h>
|
||||
#include <modules/onscreengui/include/guiorigincomponent.h>
|
||||
#include <modules/onscreengui/include/guitimecomponent.h>
|
||||
#include <modules/onscreengui/include/guiiswacomponent.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
#include <openspace/util/keys.h>
|
||||
@@ -71,9 +72,10 @@ public:
|
||||
GuiOriginComponent _origin;
|
||||
GuiPerformanceComponent _performance;
|
||||
GuiPropertyComponent _property;
|
||||
GuiPropertyComponent _iSWAproperty;
|
||||
// GuiPropertyComponent _iSWAproperty;
|
||||
GuiPropertyComponent _screenSpaceProperty;
|
||||
GuiTimeComponent _time;
|
||||
GuiISWAComponent _iswa;
|
||||
|
||||
bool _isEnabled;
|
||||
|
||||
|
||||
@@ -26,15 +26,23 @@
|
||||
#define __GUIISWACOMPONENT_H__
|
||||
|
||||
#include <modules/onscreengui/include/guicomponent.h>
|
||||
#include <modules/onscreengui/include/guipropertycomponent.h>
|
||||
|
||||
|
||||
namespace openspace {
|
||||
namespace gui {
|
||||
|
||||
class GuiISWAComponent : public GuiComponent {
|
||||
class GuiISWAComponent : public GuiPropertyComponent {
|
||||
public:
|
||||
void render();
|
||||
virtual void render() override;
|
||||
|
||||
private:
|
||||
bool gmdata;
|
||||
bool gmimage;
|
||||
bool iondata;
|
||||
};
|
||||
|
||||
|
||||
} // namespace gui
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
@@ -205,10 +205,10 @@ void GUI::initialize() {
|
||||
//io.GetClipboardTextFn = ImImpl_GetClipboardTextFn; // @TODO implement? ---abock
|
||||
|
||||
_property.initialize();
|
||||
_iSWAproperty.initialize();
|
||||
_screenSpaceProperty.initialize();
|
||||
_performance.initialize();
|
||||
_help.initialize();
|
||||
_iswa.initialize();
|
||||
}
|
||||
|
||||
void GUI::initializeGL() {
|
||||
@@ -253,10 +253,10 @@ void GUI::initializeGL() {
|
||||
|
||||
|
||||
_property.initializeGL();
|
||||
_iSWAproperty.initializeGL();
|
||||
_screenSpaceProperty.initializeGL();
|
||||
_performance.initializeGL();
|
||||
_help.initializeGL();
|
||||
_iswa.initializeGL();
|
||||
}
|
||||
|
||||
void GUI::deinitializeGL() {
|
||||
@@ -266,10 +266,10 @@ void GUI::deinitializeGL() {
|
||||
glDeleteBuffers(1, &vbo);
|
||||
|
||||
_property.deinitializeGL();
|
||||
_iSWAproperty.deinitializeGL();
|
||||
_screenSpaceProperty.deinitializeGL();
|
||||
_performance.deinitializeGL();
|
||||
_help.deinitializeGL();
|
||||
_iswa.deinitializeGL();
|
||||
}
|
||||
|
||||
void GUI::startFrame(float deltaTime, const glm::vec2& windowSize,
|
||||
@@ -298,12 +298,12 @@ void GUI::endFrame() {
|
||||
_property.render();
|
||||
if (_screenSpaceProperty.isEnabled())
|
||||
_screenSpaceProperty.render();
|
||||
if (_iSWAproperty.isEnabled())
|
||||
_iSWAproperty.render();
|
||||
if (_performance.isEnabled())
|
||||
_performance.render();
|
||||
if (_help.isEnabled())
|
||||
_help.render();
|
||||
if (_iswa.isEnabled())
|
||||
_iswa.render();
|
||||
|
||||
ImGui::Render();
|
||||
}
|
||||
@@ -401,7 +401,7 @@ void GUI::renderMainWindow() {
|
||||
ImGui::Checkbox("Scene Graph Properties", &_property._isEnabled);
|
||||
ImGui::Checkbox("ScreenSpace Properties", &_screenSpaceProperty._isEnabled);
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
ImGui::Checkbox("iSWA Properties", &_iSWAproperty._isEnabled);
|
||||
ImGui::Checkbox("iSWA", &_iswa._isEnabled);
|
||||
#endif
|
||||
ImGui::Checkbox("Performance", &_performance._isEnabled);
|
||||
_origin.render();
|
||||
@@ -432,15 +432,15 @@ void GUI::renderMainWindow() {
|
||||
addScreenSpaceRenderable(std::string(addImageBuffer));
|
||||
}
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
static const int addCygnetBufferSize = 256;
|
||||
static char addCygnetBuffer[addCygnetBufferSize];
|
||||
ImGui::InputText("addCynget", addCygnetBuffer, addCygnetBufferSize);
|
||||
// #ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
// static const int addCygnetBufferSize = 256;
|
||||
// static char addCygnetBuffer[addCygnetBufferSize];
|
||||
// ImGui::InputText("addCynget", addCygnetBuffer, addCygnetBufferSize);
|
||||
|
||||
if(ImGui::SmallButton("Add Cygnet"))
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addCygnet('"+std::string(addCygnetBuffer)+"');");
|
||||
// if(ImGui::SmallButton("Add Cygnet"))
|
||||
// OsEng.scriptEngine().queueScript("openspace.iswa.addCygnet('"+std::string(addCygnetBuffer)+"');");
|
||||
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
@@ -24,18 +24,299 @@
|
||||
|
||||
#include <modules/onscreengui/include/guiiswacomponent.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/selectionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
namespace {
|
||||
// const ImVec2 size = ImVec2(350, 200);
|
||||
const std::string _loggerCat = "iSWAComponent";
|
||||
const ImVec2 size = ImVec2(350, 500);
|
||||
|
||||
using namespace openspace::properties;
|
||||
|
||||
void executeScript(const std::string& id, const std::string& value) {
|
||||
std::string script =
|
||||
"openspace.setPropertyValue('" + id + "', " + value + ");";
|
||||
OsEng.scriptEngine().queueScript(script);
|
||||
}
|
||||
|
||||
void renderBoolProperty(Property* prop, const std::string& ownerName) {
|
||||
BoolProperty* p = static_cast<BoolProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
BoolProperty::ValueType value = *p;
|
||||
ImGui::Checkbox((ownerName + "." + name).c_str(), &value);
|
||||
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(), value ? "true": "false");
|
||||
}
|
||||
|
||||
void renderOptionProperty(Property* prop, const std::string& ownerName) {
|
||||
OptionProperty* p = static_cast<OptionProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
int value = *p;
|
||||
std::vector<OptionProperty::Option> options = p->options();
|
||||
for (const OptionProperty::Option& o : options) {
|
||||
ImGui::RadioButton((ownerName + "." + name).c_str(), &value, o.value);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text(o.description.c_str());
|
||||
}
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value));
|
||||
}
|
||||
|
||||
void renderSelectionProperty(Property* prop, const std::string& ownerName) {
|
||||
SelectionProperty* p = static_cast<SelectionProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
if (ImGui::CollapsingHeader((ownerName + "." + name).c_str())) {
|
||||
const std::vector<SelectionProperty::Option>& options = p->options();
|
||||
std::vector<int> newSelectedIndices;
|
||||
|
||||
std::vector<int> selectedIndices = p->value();
|
||||
|
||||
for (int i = 0; i < options.size(); ++i) {
|
||||
std::string description = options[i].description;
|
||||
bool selected = std::find(selectedIndices.begin(), selectedIndices.end(), i) != selectedIndices.end();
|
||||
ImGui::Checkbox(description.c_str(), &selected);
|
||||
|
||||
if (selected)
|
||||
newSelectedIndices.push_back(i);
|
||||
}
|
||||
|
||||
if (newSelectedIndices != p->value()) {
|
||||
std::string parameters = "{";
|
||||
for (int i : newSelectedIndices)
|
||||
parameters += std::to_string(i) + ",";
|
||||
parameters += "}";
|
||||
executeScript(p->fullyQualifiedIdentifier(), parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void renderStringProperty(Property* prop, const std::string& ownerName) {
|
||||
StringProperty* p = static_cast<StringProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
static const int bufferSize = 256;
|
||||
static char buffer[bufferSize];
|
||||
#ifdef _MSC_VER
|
||||
strcpy_s(buffer, p->value().length() + 1, p->value().c_str());
|
||||
#else
|
||||
strcpy(buffer, p->value().c_str());
|
||||
#endif
|
||||
ImGui::InputText((ownerName + "." + name).c_str(), buffer, bufferSize);
|
||||
std::string newValue(buffer);
|
||||
|
||||
if (newValue != p->value() && FileSys.fileExists(newValue))
|
||||
executeScript(p->fullyQualifiedIdentifier(), "'" + newValue + "'");
|
||||
}
|
||||
|
||||
void renderIntProperty(Property* prop, const std::string& ownerName) {
|
||||
IntProperty* p = static_cast<IntProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
IntProperty::ValueType value = *p;
|
||||
ImGui::SliderInt((ownerName + "." + name).c_str(), &value, p->minValue(), p->maxValue());
|
||||
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value));
|
||||
}
|
||||
|
||||
void renderFloatProperty(Property* prop, const std::string& ownerName) {
|
||||
FloatProperty* p = static_cast<FloatProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
FloatProperty::ValueType value = *p;
|
||||
ImGui::SliderFloat((ownerName + "." + name).c_str(), &value, p->minValue(), p->maxValue());
|
||||
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(), std::to_string(value));
|
||||
|
||||
}
|
||||
|
||||
void renderVec2Property(Property* prop, const std::string& ownerName) {
|
||||
Vec2Property* p = static_cast<Vec2Property*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
Vec2Property::ValueType value = *p;
|
||||
|
||||
ImGui::SliderFloat2((ownerName + "." + name).c_str(), &value.x, std::min(p->minValue().x, p->minValue().y), std::max(p->maxValue().x, p->maxValue().y));
|
||||
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(),
|
||||
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}");
|
||||
}
|
||||
|
||||
void renderVec3Property(Property* prop, const std::string& ownerName) {
|
||||
Vec3Property* p = static_cast<Vec3Property*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
Vec3Property::ValueType value = *p;
|
||||
|
||||
ImGui::SliderFloat3((ownerName + "." + name).c_str(), &value.x, p->minValue().x, p->maxValue().x);
|
||||
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(),
|
||||
"{" + std::to_string(value.x) + "," +
|
||||
std::to_string(value.y) + "," +
|
||||
std::to_string(value.z) + "}");
|
||||
}
|
||||
|
||||
void renderVec4Property(Property* prop, const std::string& ownerName) {
|
||||
Vec4Property* p = static_cast<Vec4Property*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
Vec4Property::ValueType value = *p;
|
||||
|
||||
ImGui::SliderFloat4((ownerName + "." + name).c_str(), &value.x, p->minValue().x, p->maxValue().x);
|
||||
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(),
|
||||
"{" + std::to_string(value.x) + "," +
|
||||
std::to_string(value.y) + "," +
|
||||
std::to_string(value.z) + "," +
|
||||
std::to_string(value.w) + "}");
|
||||
}
|
||||
|
||||
void renderTriggerProperty(Property* prop, const std::string& ownerName) {
|
||||
std::string name = prop->guiName();
|
||||
bool pressed = ImGui::Button((ownerName + "." + name).c_str());
|
||||
if (pressed)
|
||||
executeScript(prop->fullyQualifiedIdentifier(), "nil");
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
namespace gui {
|
||||
|
||||
void GuiHelpComponent::render() {
|
||||
void GuiISWAComponent::render() {
|
||||
bool gmdatavalue = gmdata;
|
||||
bool gmimagevalue = gmimage;
|
||||
bool iondatavalue = iondata;
|
||||
|
||||
ImGui::Begin("ISWA", &_isEnabled, size, 0.5f);
|
||||
ImGui::ShowUserGuide();
|
||||
ImGui::Text("Global Magnetosphere");
|
||||
ImGui::Checkbox("Gm From Data", &gmdata); ImGui::SameLine();
|
||||
ImGui::Checkbox("Gm From Images", &gmimage);
|
||||
|
||||
ImGui::Text("Ionosphere");
|
||||
ImGui::Checkbox("Ion From Data", &iondata);
|
||||
|
||||
ImGui::Spacing();
|
||||
static const int addCygnetBufferSize = 256;
|
||||
static char addCygnetBuffer[addCygnetBufferSize];
|
||||
ImGui::InputText("addCynget", addCygnetBuffer, addCygnetBufferSize);
|
||||
|
||||
if(ImGui::SmallButton("Add Cygnet"))
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addCygnet('"+std::string(addCygnetBuffer)+"');");
|
||||
|
||||
if(gmdata != gmdatavalue){
|
||||
if(gmdata){
|
||||
std::string x = "openspace.iswa.addCygnet('-1,Data,1');";
|
||||
std::string y = "openspace.iswa.addCygnet('-2,Data,1');";
|
||||
std::string z = "openspace.iswa.addCygnet('-3,Data,1');";
|
||||
OsEng.scriptEngine().queueScript(x+y+z);
|
||||
}else{
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup(1);");
|
||||
}
|
||||
}
|
||||
|
||||
if(gmimage != gmimagevalue){
|
||||
if(gmimage){
|
||||
std::string x = "openspace.iswa.addCygnet('-1,Texture,2');";
|
||||
std::string y = "openspace.iswa.addCygnet('-2,Texture,2');";
|
||||
std::string z = "openspace.iswa.addCygnet('-3,Texture,2');";
|
||||
OsEng.scriptEngine().queueScript(x+y+z);
|
||||
}else{
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup(2);");
|
||||
}
|
||||
}
|
||||
|
||||
if(iondata != iondatavalue){
|
||||
if(iondata){
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.addCygnet('0,Data,3');");
|
||||
}else{
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup(3);");
|
||||
}
|
||||
}
|
||||
// bool gmdata = ImGui::Button("Create Global Magnetosphere from data");
|
||||
// bool gmtext = ImGui::Button("Create Global Magnetosphere from images");
|
||||
// bool iodata = ImGui::Button("Create Ionosphere from data");
|
||||
// ImGui::ShowUserGuide();
|
||||
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
for (const auto& p : _propertiesByOwner) {
|
||||
if (ImGui::CollapsingHeader(p.first.c_str())) {
|
||||
for (properties::Property* prop : p.second) {
|
||||
if (_boolProperties.find(prop) != _boolProperties.end()) {
|
||||
renderBoolProperty(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_intProperties.find(prop) != _intProperties.end()) {
|
||||
renderIntProperty(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_floatProperties.find(prop) != _floatProperties.end()) {
|
||||
renderFloatProperty(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_vec2Properties.find(prop) != _vec2Properties.end()) {
|
||||
renderVec2Property(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_vec3Properties.find(prop) != _vec3Properties.end()) {
|
||||
renderVec3Property(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_vec4Properties.find(prop) != _vec4Properties.end()) {
|
||||
renderVec4Property(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_optionProperties.find(prop) != _optionProperties.end()) {
|
||||
renderOptionProperty(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_triggerProperties.find(prop) != _triggerProperties.end()) {
|
||||
renderTriggerProperty(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_selectionProperties.find(prop) != _selectionProperties.end()) {
|
||||
renderSelectionProperty(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_stringProperties.find(prop) != _stringProperties.end()) {
|
||||
renderStringProperty(prop, p.first);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user