-
Notifications
You must be signed in to change notification settings - Fork 3
/
FieldViewer_ui.cpp
133 lines (98 loc) · 5.89 KB
/
FieldViewer_ui.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*******************************************************************************
FieldViewer_ui: User interface for the Dynamics Toolset application class.
Copyright (c) 2006-2008 Jordan Van Aalsburg
This file is part of the Dynamics Toolset.
The Dynamics Toolset is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
The Dynamics Toolset is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License
along with the Dynamics Toolset. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "FieldViewer.h"
// Vrui includes
//
#include "GLMotif/WidgetFactory.h"
GLMotif::PopupMenu* Viewer::createMainMenu()
{
WidgetFactory factory;
// create the top-level shell
GLMotif::PopupMenu* mainMenuPopup=factory.createPopupMenu("MainPopupMenu", "Viewer Options");
// create button array inside top-level shell
GLMotif::Menu* mainMenu=factory.createMenu("MainMenu");
// add buttons and assign callbacks
// create a cascade button for selecting the dynamical system
GLMotif::CascadeButton* dynamicsTogglesCascade=factory.createCascadeButton("DynamicsTogglesCascade", "Dynamics");
dynamicsTogglesCascade->setPopup(createDynamicsTogglesMenu());
// create a cascade button for selecting the dynamical analysis tool
GLMotif::CascadeButton* toolsTogglesCascade=factory.createCascadeButton("ToolTogglesCascade", "Tools");
toolsTogglesCascade->setPopup(createToolsTogglesMenu());
// create a toggle button for showing/hiding the frame rate dialog
GLMotif::ToggleButton* showFrameRateDialog=factory.createToggleButton("ShowFrameRateDialogToggle", "Show Frame Rate Dialog");
showFrameRateDialog->getSelectCallbacks().add(this, &Viewer::mainMenuTogglesCallback);
// create a toggle button for showing/hiding the position dialog
GLMotif::ToggleButton* showPositionDialog=factory.createToggleButton("ShowPositionDialog", "Show Position Dialog");
showPositionDialog->getSelectCallbacks().add(this, &Viewer::mainMenuTogglesCallback);
// create a toggle button for showing/hiding the dynamical parameter interface dialog
showParameterDialogToggle=factory.createToggleButton("ShowParameterDialogToggle", "Show Parameter Dialog");
showParameterDialogToggle->getSelectCallbacks().add(this, &Viewer::mainMenuTogglesCallback);
// create a toggle for showing/hiding the tool option dialogs
GLMotif::ToggleButton* showOptionsDialogs=factory.createToggleButton("ShowOptionsDialogsToggle", "Show Options Dialogs");
showOptionsDialogs->getSelectCallbacks().add(this, &Viewer::mainMenuTogglesCallback);
// create a push button for reseting the view
GLMotif::Button* resetNavigationButton=factory.createButton("ResetNavigationButton", "Reset Navigation");
resetNavigationButton->getSelectCallbacks().add(this, &Viewer::resetNavigationCallback);
mainMenu->manageChild();
return mainMenuPopup;
}
GLMotif::Popup* Viewer::createDynamicsTogglesMenu()
{
WidgetFactory factory;
// create the top-level shell
GLMotif::Popup* dynamicsTogglesMenuPopup=factory.createPopupMenu("DynamicsTogglesMenuPopup");
// create button array inside top-level shell
GLMotif::RowColumn* dynamicsTogglesMenu=factory.createMenu("DynamicsTogglesMenu");
// for each of the model names
for (std::vector<std::string>::const_iterator name=model_names.begin(); name!=model_names.end(); ++name)
{
// create toggle button
std::string toggle_name=(*name) + "toggle";
GLMotif::ToggleButton* toggle=factory.createToggleButton(const_cast<char*> (toggle_name.c_str()), const_cast<char*> ((*name).c_str()));
// turn on the first toggle
if (name == model_names.begin())
toggle->setToggle(true);
toggle->getValueChangedCallbacks().add(this, &Viewer::dynamicsMenuCallback);
dynamicsToggleButtons.push_back(toggle);
}
dynamicsTogglesMenu->manageChild();
return dynamicsTogglesMenuPopup;
}
GLMotif::Popup* Viewer::createToolsTogglesMenu()
{
WidgetFactory factory;
// create the top-level shell
GLMotif::Popup* toolsTogglesMenuPopup=factory.createPopupMenu("ToolsTogglesMenuPopup");
// create array of buttons inside top-level shell
GLMotif::RowColumn* toolsTogglesMenu=factory.createMenu("VisualizationTogglesMenu");
// add toggle buttons for various analysis tools
GLMotif::ToggleButton* particleSprayerToggle=factory.createToggleButton("ParticleSprayerToggle", "Particle Sprayer", true);
GLMotif::ToggleButton* dotSpreaderToggle=factory.createToggleButton("DotSpreaderToggle", "Dot Spreader", true);
GLMotif::ToggleButton* staticSolverToggle=factory.createToggleButton("StaticSolverToggle", "Static Solver", true);
GLMotif::ToggleButton* dynamicSolverToggle=factory.createToggleButton("DynamicSolverToggle", "Dynamic Solver", true);
// assign callbacks for each toggle button
particleSprayerToggle->getValueChangedCallbacks().add(this, &Viewer::toolsMenuCallback);
dotSpreaderToggle->getValueChangedCallbacks().add(this, &Viewer::toolsMenuCallback);
staticSolverToggle->getValueChangedCallbacks().add(this, &Viewer::toolsMenuCallback);
dynamicSolverToggle->getValueChangedCallbacks().add(this, &Viewer::toolsMenuCallback);
// add toggle button pointers to vector for radio-button behavior
toolsToggleButtons.push_back(particleSprayerToggle);
toolsToggleButtons.push_back(dotSpreaderToggle);
toolsToggleButtons.push_back(staticSolverToggle);
toolsToggleButtons.push_back(dynamicSolverToggle);
toolsTogglesMenu->manageChild();
return toolsTogglesMenuPopup;
}