VAPoR  3.0.0
vizwinmgr.h
Go to the documentation of this file.
1 //************************************************************************
2 // *tab
3 // Copyright (C) 2004 *
4 // University Corporation for Atmospheric Research *
5 // All Rights Reserved *
6 // *
7 //************************************************************************/
8 //
9 // File: vizwinmgr.h
10 //
11 // Author: Alan Norton
12 // National Center for Atmospheric Research
13 // PO 3000, Boulder, Colorado
14 //
15 // Date: Sept 2004
16 //
17 
18 
19 #ifndef VIZWINMGR_H
20 #define VIZWINMGR_H
21 
22 class QMdiArea;
23 class QMdiSubWindow;
24 class QWidget;
25 class QDesktopWidget;
26 class QMainWidget;
27 class QTimer;
28 
29 #include "vapor/ControlExecutive.h"
30 #include <qobject.h>
31 
32 #include "viewpointparams.h"
33 #include "regionparams.h"
34 #include "animationparams.h"
35 #include <vapor/common.h>
36 
37 
38 #include "params.h"
39 
40 namespace VAPoR{
41 
42 class AnimationParams;
43 class EventRouter;
44 class TabManager;
45 class MainForm;
46 class ViewpointParams;
47 class RegionParams;
48 
49 class VizWin;
50 class AnimationEventRouter;
51 class RegionEventRouter;
52 class ViewpointEventRouter;
53 
55 
68 //
69 class VizWinMgr : public QObject
70 {
71  Q_OBJECT
72 
73 public:
74 
81  void forceRender(Params* p, bool always=false);
82 
87  static void InstallTab(const std::string tag, EventRouterCreateFcn fcn);
88 
92  static EventRouter* getEventRouter(const std::string& tag);
93 
95  void SetToDefaults();
96 
105  static void UndoRedo(bool isUndo, int /*instance*/, Params* beforeP, Params* afterP, Params* aux1 = 0, Params* aux2 = 0);
106 
109  int getNumVisualizers();
110 
114  int activeViz = ControlExec::GetActiveVizIndex();
115  assert(activeViz >= 0);
116  //Use an iterator so we don't insert if the viz is not there
117  std::map<int, VizWin*>::iterator it;
118  it = _vizWindow.find(activeViz);
119  if (it == _vizWindow.end()) return 0;
120  return _vizWindow[activeViz];
121  }
122 
126  int activeViz = ControlExec::GetActiveVizIndex();
127  assert(activeViz >= 0);
128  return ControlExec::GetVisualizer(activeViz);
129  }
132  RegionEventRouter* getRegionRouter();
133 
136  AnimationEventRouter* getAnimationRouter();
137 
140  ViewpointEventRouter* getViewpointRouter();
141 
145  VizWin* getVizWin(int i) {return _vizWindow[i];}
146 
147  //Following methods notify all params that are associated with a
148  //specific window.
151  void refreshViewpoint(ViewpointParams* vParams);
152 
155  void refreshRegion(RegionParams* rParams);
156 
159  static VizWinMgr* getInstance() {
160  if (!_vizWinMgr)
161  _vizWinMgr = new VizWinMgr();
162  return _vizWinMgr;
163  }
164 
173  void createAllDefaultTabs();
174 
177  void vizAboutToDisappear(int i);
178 
183  int launchVisualizer();
184 
190  int addVisualizer(int viznum);
191 
195  void removeVisualizer(int viznum);
196 
202  int attachVisualizer(int useViznum);
203 
206  void setActiveViz(int vizNum);
207 
210  void updateActiveParams();
211 
214  void createDefaultParams(int winnum);
215 
218  void refreshRenderData();
219 
224  void disableRenderers(const vector<string>& vars2D, const vector<string>& vars3D);
225 
227  void disableAllRenderers();
228 
232  void resetViews(ViewpointParams* vp);
233 
235  void resetTrackball();
236 
237  ~VizWinMgr();
238 
239 
240 public slots:
242  void cascade();
243 
245  void fitSpace();
246 
248  void home();
249 
251  void sethome();
252 
254  void winActivated(int);
255 
257  void killViz(int viznum);
258 
259  //Slots that set viewpoint:
260 
262  void viewAll();
263 
265  void viewRegion();
266 
269  void alignView(int axis);
270 
273  void setVpLocalGlobal(int val);
274 
277  void setRgLocalGlobal(int val);
278 
281  void setAnimationLocalGlobal(int val);
283 #ifndef DOXYGEN_SKIP_THIS
284 signals:
285  //Turn on/off multiple viz options:
286  void enableMultiViz(bool onOff);
287  //Respond to user setting the vizselectorcombo:
288  void newViz(QString&, int);
289  void removeViz(int);
290  void activateViz(int);
291  void changeName(QString&, int);
292 
293 private:
294 
295  static void RegisterEventRouter(const std::string tag, EventRouter* router);
296 
297  // map tags to eventrouters
298  static std::map<string, EventRouter*> _eventRouterMap;
299 
300 
301  VizWinMgr();
302 
303  //Find the previous active visualizer, by looking at the last one
304  //that corresponds to a valid visualizer
305  int getLastActive(){
306  int lastActivation = -1; int prevActiveVis = -1;
307  //Use an iterator to loop over activation orders
308  std::map<int, int>::iterator it;
309  std::map<int, VizWin*>::iterator it2;
310  for (it = _activationOrder.begin(); it != _activationOrder.end(); it++){
311  int order = it->second;
312  int vis = it->first;
313  //Check if vis is a valid visualizer
314  it2 = _vizWindow.find(vis);
315  if (it2 == _vizWindow.end()) continue;
316 
317  if (order >lastActivation){
318  lastActivation = order;
319  prevActiveVis = vis;
320  }
321  }
322  return prevActiveVis;
323  }
324  static VizWinMgr* _vizWinMgr;
325  //Map visualizer id to vizwin
326  std::map<int, VizWin*> _vizWindow;
327  std::map<int,QMdiSubWindow*> _vizMdiWin;
328  //Activation order is a history of all the active visualizer indices.
329  //It is a mapping from visualizer indices to the activation order.
330  //When a visualizer is closed, the most recently active visualizer is re-activated.
331  std::map<int,int> _activationOrder;
332 
333  //Remember the activation order:
334  int _activationCount;
335  MainForm* _mainForm;
336  static TabManager* _tabManager;
337 
338  QMdiArea* _mdiArea;
339 
340 
341 #endif //DOXYGEN_SKIP_THIS
342 
343 };
344 };
345 #endif // VIZWINMGR_H
346 
void createAllDefaultTabs()
void refreshRegion(RegionParams *rParams)
A pure virtual class for managing parameters used in visualization.
Definition: params.h:129
void alignView(int axis)
void cascade()
Arrange the Visualizers in a cascading sequence.
VizWin * getVizWin(int i)
Definition: vizwinmgr.h:145
void killViz(int viznum)
Close the VizWin associated with a Visualizer index.
void setActiveViz(int vizNum)
void disableAllRenderers()
Disable all enabled renderers.
void setRgLocalGlobal(int val)
static int GetActiveVizIndex()
A class for describing a 3D axis-aligned region in user space.
Definition: regionparams.h:53
VizWin * getActiveVizWin()
Definition: vizwinmgr.h:113
void home()
Change viewpoint to the current home viewpoint.
void SetToDefaults()
Reset the GUI to its default state, either due to New Session, or in preparation for loading a sessio...
void viewRegion()
Move camera in or out to make current region visible.
A pure virtual class specifying the common properties of all the parameter tabs in the VAPOR GUI...
Definition: eventrouter.h:101
void resetTrackball()
Reset the trackball for a new dataset.
EventRouter *( EventRouterCreateFcn)()
Definition: vizwinmgr.h:54
ViewpointEventRouter * getViewpointRouter()
int addVisualizer(int viznum)
Visualizer * getActiveVisualizer()
Definition: vizwinmgr.h:125
void resetViews(ViewpointParams *vp)
static void InstallTab(const std::string tag, EventRouterCreateFcn fcn)
void winActivated(int)
Respond to user request to activate a window:
void fitSpace()
Arrange the visualizers to tile the available space.
void forceRender(Params *p, bool always=false)
A class for describing the viewpoint and lights in a 3D VAPOR scene.
RegionEventRouter * getRegionRouter()
void createDefaultParams(int winnum)
A class for managing all visualizers.
Definition: vizwinmgr.h:69
void setVpLocalGlobal(int val)
void refreshRenderData()
static EventRouter * getEventRouter(const std::string &tag)
void refreshViewpoint(ViewpointParams *vParams)
void removeVisualizer(int viznum)
static VizWinMgr * getInstance()
Definition: vizwinmgr.h:159
void sethome()
Set the current home viewpoint based on current viewpoint.
void updateActiveParams()
A class for performing OpenGL rendering in VAPOR GUI Window.
Definition: visualizer.h:61
int attachVisualizer(int useViznum)
void vizAboutToDisappear(int i)
void viewAll()
Move camera in or out to make entire volume visible.
Definition: DC.h:10
AnimationEventRouter * getAnimationRouter()
static void UndoRedo(bool isUndo, int, Params *beforeP, Params *afterP, Params *aux1=0, Params *aux2=0)
A QGLWidget that supports display based on GL methods invoked in a Visualizer.
Definition: vizwin.h:51
void setAnimationLocalGlobal(int val)
void disableRenderers(const vector< string > &vars2D, const vector< string > &vars3D)
static Visualizer * GetVisualizer(int viz)