void TweakDemEditor::updateBar(TwBar *bar) { EditorHandler *e = dynamic_cast<EditorHandler*>(eventHandler.get()); if (e == NULL) { return; } // Adding the list of edited graphs TwEnumVal *editModes= new TwEnumVal[2]; editModes[0].Value = ADD; editModes[0].Label = "ADD"; editModes[1].Value = MAX; editModes[1].Label = "MAX"; TwType editType = TwDefineEnum("EditType", editModes, 2); TwAddVarCB(bar, "EditMode", editType, SetDemEditModeCallback, GetDemEditModeCallback, NULL, " label='Edit Mode' group='DemEditor' key='e' "); TwAddVarRW(bar, "demBrushRadius", TW_TYPE_FLOAT, &(e->relativeRadius), " group=DemEditor label='Brush Radius' help='Size of the Dem Editor Brush' min=0.0 step=0.01 "); TwAddVarRW(bar, "demBrushColor", TW_TYPE_FLOAT, &(e->brushColor[0]), " group=DemEditor label='Brush altitude' help='Altitude applied to the texture' step='0.1' "); TwAddButton(bar, "demReset", ResetDemCB, NULL, " group=DemEditor label='Reset' help='Cancels all editing operations performed on active editors' "); char def[200]; sprintf(def, "%s/DemEditor label='Dem Edition'", TwGetBarName(bar)); char name[20]; TwDefine(def); set<string> groupNames; for (int i = 0; i < e->getEditorCount(); i++) { string n = e->getEditor(i)->getGroup(); if (groupNames.find(n) == groupNames.end()) { groupNames.insert(n); sprintf(name, "demEditorGroup%d", i); sprintf(def, " group=%s label='Activate %s' help='Activate or Deactivate the selected Editor' ", n.c_str(), n.c_str()); TwAddVarCB(bar, name, TW_TYPE_BOOLCPP, SetDemEditorGroupStateCallback, GetDemEditorGroupStateCallback, e->getEditor(i), def); sprintf(def, " group=%s ", n.c_str()); TwAddSeparator(bar, NULL, def); sprintf(def, "%s/%s label='%s' group=DemEditor ", TwGetBarName(bar), n.c_str(), n.c_str()); TwDefine(def); } } for (int i = 0; i < e->getEditorCount(); i++) { sprintf(name, "DemEditor%d", i); sprintf(def, " group=%s label='%s' help='Activate or Deactivate the selected Editor' ", e->getEditor(i)->getName().c_str(), e->getEditor(i)->getName().c_str()); TwAddVarCB(bar, name, TW_TYPE_BOOLCPP, SetDemEditorStateCallback, GetDemEditorStateCallback, e->getEditor(i), def); } delete[] editModes; }
void InterfaceGl::setOptions( const std::string &name, const std::string &optionsStr ) { std::string target = "`" + (std::string)TwGetBarName( mBar.get() ) + "`"; if( !( name.empty() ) ) target += "/`" + name + "`"; TwDefine( ( target + " " + optionsStr ).c_str() ); }
void Toolbar::unregisterTweakBar(TwBar* tweakBar) { TwBar* toolTweakBar = TwGetBarByName(toolbarTitle); if(toolTweakBar == nullptr) return; TwRemoveVar(toolTweakBar, TwGetBarName(tweakBar)); }
bool OGLIndexedDraw::InitGUI() { auto tweakBar = atbApp->GetBarByIndex(0); auto barName = TwGetBarName(tweakBar); std::stringstream format; format << barName << " " << " label='Draw instanced Example' help='This example use instance IDs & billboarding.' "; TwAddVarRW(tweakBar, "Div", TW_TYPE_FLOAT, &heightDivider, " label='Height divider' min='1' step='0.5' "); return true; }
void GLFW_App::setBarTitle(const std::string &theTitle, TwBar *theBar) { if(!theBar) { if(m_tweakBars.empty()) return; theBar = m_tweakBars.front(); } std::stringstream ss; ss << TwGetBarName(theBar) << " label='" << theTitle <<"'"; TwDefine(ss.str().c_str()); }
bool OGLMultipleLights::InitGUI() { auto tweakBar = atbApp->GetBarByIndex(0); auto barName = TwGetBarName(tweakBar); std::stringstream format; format << barName << " " << " label='Multiple Lights' "; TwDefine(format.str().c_str()); return true; }
void GLFW_App::setBarSize(const glm::ivec2 &theSize, TwBar *theBar) { if(!theBar) { if(m_tweakBars.empty()) return; theBar = m_tweakBars.front(); } std::stringstream ss; ss << TwGetBarName(theBar) << " size='" <<theSize.x <<" " << theSize.y <<"'"; TwDefine(ss.str().c_str()); }
void GLFW_App::setBarColor(const glm::vec4 &theColor, TwBar *theBar) { if(!theBar) { if(m_tweakBars.empty()) return; theBar = m_tweakBars.front(); } std::stringstream ss; glm::ivec4 color(theColor * 255.f); ss << TwGetBarName(theBar) << " color='" <<color.r <<" " << color.g << " " << color.b <<"' alpha="<<color.a; TwDefine(ss.str().c_str()); }
void TweakOrthoEditor::updateBar(TwBar *bar) { EditorHandler *e = dynamic_cast<EditorHandler*>(eventHandler.get()); if (e == NULL) { return; } TwAddVarRW(bar, "orthoBrushRadius", TW_TYPE_FLOAT, &(e->relativeRadius), " group=OrthoEditor label='Brush Radius' help='Size of the Ortho Editor Brush' min=0.0 step=0.01 "); TwAddVarRW(bar, "orthoBrushColor", TW_TYPE_COLOR4F, &(e->brushColor), " group=OrthoEditor label='Brush Color' help='Color applied to the texture' "); TwAddButton(bar, "orthoReset", ResetOrthoCB, NULL, " group=OrthoEditor label='Reset' help='Cancels all editing operations performed on active editors' "); char def[200]; char name[20]; sprintf(def, "%s/OrthoEditor label='Ortho Edition'", TwGetBarName(bar)); TwDefine(def); set<string> groupNames; for (int i = 0; i < e->getEditorCount(); i++) { string n = e->getEditor(i)->getGroup(); if (groupNames.find(n) == groupNames.end()) { groupNames.insert(n); sprintf(name, "orthoEditorGroup%d", i); sprintf(def, " group=%s label='Activate %s' help='Activate or Deactivate the selected Editor' ", n.c_str(), n.c_str()); TwAddVarCB(bar, name, TW_TYPE_BOOLCPP, SetOrthoEditorGroupStateCallback, GetOrthoEditorGroupStateCallback, e->getEditor(i), def); sprintf(def, " group=%s ", n.c_str()); TwAddSeparator(bar, NULL, def); sprintf(def, "%s/%s label='%s' group=OrthoEditor ", TwGetBarName(bar), n.c_str(), n.c_str()); TwDefine(def); } } for (int i = 0; i < e->getEditorCount(); i++) { sprintf(name, "orthoEditor%d", i); sprintf(def, " group=%s label='%s' help='Activate or Deactivate the selected Editor' ", e->getEditor(i)->getGroup().c_str(), e->getEditor(i)->getName().c_str()); TwAddVarCB(bar, name, TW_TYPE_BOOLCPP, SetOrthoEditorStateCallback, GetOrthoEditorStateCallback, e->getEditor(i), def); } }
bool OGLSimpleLighting::InitGUI() { auto tweakBar = atbApp->GetBarByIndex(0); auto barName = TwGetBarName(tweakBar); std::stringstream format; format << barName << " " << " label='Lighting Example' "; TwAddVarRW(tweakBar, "lightDir", TW_TYPE_DIR3F, &light.direction, "label='Direction' group='Light'"); TwAddVarRW(tweakBar, "lightSpec", TW_TYPE_COLOR3F, &light.specularColor, "label='Specular Intensity' group='Light'"); TwAddVarRW(tweakBar, "lightDiff", TW_TYPE_COLOR3F, &light.diffuseColor, "label='Diffuse Intensity' group='Light'"); TwDefine(format.str().c_str()); return true; }
bool OGLFrustumCulling::InitGUI() { auto tweakBar = atbApp->GetBarByIndex(0); auto barName = TwGetBarName(tweakBar); std::stringstream format; format << barName << " " << " label='Frustum Culling Example' "; TwAddVarRW(tweakBar, "waveAmpl", TW_TYPE_FLOAT, &waveAmplitude, "label='Wave Amplitude' step='0.5'"); TwAddVarRW(tweakBar, "useExtCam", TW_TYPE_BOOLCPP, &useExternalCamera, "label='External camera'"); TwDefine(format.str().c_str()); return true; }
void Toolbar::registerTweakBar(TwBar *tweakBar) { TwBar* toolTweakBar = TwGetBarByName(toolbarTitle); Q_ASSERT(toolTweakBar != nullptr); if(toolTweakBar == nullptr) return; TwAddVarCB(toolTweakBar, TwGetBarName(tweakBar), TW_TYPE_BOOLCPP, reinterpret_cast<TwSetVarCallback>(setBarVisibility), reinterpret_cast<TwGetVarCallback>(getBarVisibility), tweakBar, ""); }
bool OGLSpotLight::InitGUI() { auto tweakBar = atbApp->GetBarByIndex(0); auto barName = TwGetBarName(tweakBar); std::stringstream format; format << barName << " " << " label='Material Interactions' "; TwAddVarRW(tweakBar, "lightInner", TW_TYPE_FLOAT, &light.innerCutOff, "label='Spotlight radius' step='0.5' group='Light'"); TwAddVarRW(tweakBar, "lightOut", TW_TYPE_FLOAT, &light.outerCutOff, "label='Spotlight radius' step='0.5' group='Light'"); TwAddVarRW(tweakBar, "lightAmb", TW_TYPE_COLOR3F, &light.ambientColor, "label='Ambient Intensity' group='Light'"); TwAddVarRW(tweakBar, "lightSpec", TW_TYPE_COLOR3F, &light.specularColor, "label='Specular Intensity' group='Light'"); TwAddVarRW(tweakBar, "lightDiffus", TW_TYPE_COLOR3F, &light.diffuseColor, "label='Diffuse Intensity' group='Light'"); TwDefine(format.str().c_str()); return true; }