-
Notifications
You must be signed in to change notification settings - Fork 3
/
FieldViewer.h
161 lines (129 loc) · 5.54 KB
/
FieldViewer.h
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*******************************************************************************
FieldViewer: 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/>.
*******************************************************************************/
#ifndef FIELD_VIEWER_H
#define FIELD_VIEWER_H
// Vrui includes
//
#include <Vrui/Vrui>
// STL includes
//
#include <map>
#include <list>
#include <vector>
#include <string>
#include <iostream>
// Project includes
//
#include "DTSTools"
#include "Dynamics/BaseModel.h"
#include "DataItem.h"
#include "Vrui/TransformTool.h"
#include "PositionDialog.h"
#include "FrameRateDialog.h"
// External includes
//
#include "VruiStreamManip.h"
extern DynamicsFactory factory;
/** The main Vrui application class.
*/
class Viewer: public Vrui::Application, public GLObject
{
public:
/* Embedded classes */
typedef AbstractDynamicsTool ADT;
typedef std::vector<ADT*> ToolList;
typedef std::vector<GLMotif::ToggleButton*> ToggleArray;
typedef std::vector<CaveDialog*> DialogArray;
/* Interface */
Viewer(int &argc, char** argv, char** appDefaults);
virtual ~Viewer();
void initContext(GLContextData& contextData) const;
virtual void display(GLContextData& contextData) const;
virtual void frame();
/** Update the tool toggle buttons.
*
* Iterates over tools and sets the toggle state to false if the tool
* is current disabled.
*/
void updateToolToggles();
/** Switch the options dialog to the one associated with the current tool.
*
* Only one tool options dialog is displayed at a time. When a tool is
* changed the dialog is updated to reflect this change.
*/
void updateCurrentOptionsDialog();
/* Callbacks */
virtual void toolCreationCallback(Vrui::ToolManager::ToolCreationCallbackData* cbData);
virtual void toolDestructionCallback(Vrui::ToolManager::ToolDestructionCallbackData* cbData);
void resetNavigationCallback(Misc::CallbackData* cbData);
void mainMenuTogglesCallback(GLMotif::ToggleButton::ValueChangedCallbackData *cbData);
void dynamicsMenuCallback(GLMotif::ToggleButton::ValueChangedCallbackData *cbData);
void toolsMenuCallback(GLMotif::ToggleButton::ValueChangedCallbackData *cbData);
private:
ToolList tools; ///< Array of all tools currently being used.
Integrator* model; ///< Dynamical system.
FrameRateDialog* frameRateDialog; ///< Dialog for throttling the frame rate.
PositionDialog* positionDialog; ///< Dialog for displaying cursor position.
CaveDialog* parameterDialog; ///< Parameter dialog associated with current dynamical system.
CaveDialog* currentOptionsDialog; ///< Options dialog associated with the current tool.
DialogArray optionsDialogs; ///< Array of all tool options dialogs.
/* User interface methods (see FieldViewer_ui.cpp for implementation) */
GLMotif::PopupMenu* mainMenu;
GLMotif::PopupMenu* createMainMenu();
GLMotif::Popup* createDynamicsTogglesMenu();
GLMotif::Popup* createToolsTogglesMenu();
GLMotif::ToggleButton* showParameterDialogToggle;
ToggleArray toolsToggleButtons;
ToggleArray dynamicsToggleButtons;
std::map<std::string, AbstractDynamicsTool*> toolmap;
typedef std::list<void*> DLList;
DLList dl_list; ///< Dynamic library (plugin) list.
std::vector<std::string> model_names; ///< Names of all models (obtained from plugins).
double elapsedTime; // Cummulative time between frames
/** Mediator members.
*
* In order for the DynamicsModel and Integrator to communicate changes
* to the tools (such as the StaticSolverTool), it is neccessary to
* keep track of the model versions and the step size versions.
*/
unsigned int stepSizeVersion;
unsigned int modelVersion;
bool hasGLSL;
/* Output streams */
master::filter masterout;
node::filter nodeout;
debug::filter debugout;
/* Internal methods */
/** Internal method for faking radio-button behavior.
*
* Iterates through array of toggle buttons and sets the state to
* false unless the toggle button name matches the one given.
*
* \param toggles Array of toggle buttons.
* \param name Name of toggle to set to true (all others will be set to false).
*/
void setRadioToggles(ToggleArray& toggles, const std::string& name);
/** Internal method for loading plugins (dlls).
*
* Searches the plugins directory for dynamic libraries. Each library
* that is found is then loaded into memory. An exception is thrown
* if a library fails to load.
*
* \return An array of the names of all plugins.
*/
std::vector<std::string> loadPlugins() throw(std::runtime_error);
};
#endif