VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
commonFixutres.h
Go to the documentation of this file.
1 #ifndef commonFixutres_h_
2 #define commonFixutres_h_
3 
5 #include <vrvCore/DtDe.h>
6 #include <vrvCore/DtChannel.h>
9 #include <vrvOsg/vrvOsg.h>
10 #include <vrvOsgQt/vrvOsgQt.h>
12 #include <vrvCore/DtDeMainWindow.h>
13 
14 using namespace makVrv;
15 
16 namespace
17 {
18 
19 // // A initialized DtDe instance created with the default values for itself and it's initializer.
20 // // No windows are created.
21 // struct DtIgBare
22 // {
23 // DtIgBare()
24 // : de()
25 // {
26 // init();
27 // }
28 //
29 // void init()
30 // {
31 // //de.setDeInitializer(speedTreeAuthorizationTestInitializer());
32 // de.initialize();
33 // }
34 //
35 // DtDe de;
36 // };
37 
38  // A uninitialized DtDe instance created with the default values for itself and it's initializer.
39  // No windows are created.
40  struct DtIgBareUninitialized
41  {
42  DtIgBareUninitialized()
43  : de()
44  {
45  }
46 
47  DtDe de;
48  };
49 
50  // A initialized DtDe instance created with the default values for itself and it's initializer.
51  // vrvOsg is init'd.
52  // No windows are created.
53  struct DtIgDefault
54  {
55  DtIgDefault()
56  : de()
57  {
58  init();
59  }
60 
61  void init()
62  {
63  //de.setDeInitializer(speedTreeAuthorizationTestInitializer());
64 
65  vrvOsg::init(de);
66  de.initialize();
67  }
68 
69  DtDe de;
70  };
71 
72  // A uninitialized DtDe instance created with the default values for itself and it's initializer.
73  // No windows are created.
74  // vrvOsg is init'd.
75  struct DtIgDefaultUninitialized
76  {
77  DtIgDefaultUninitialized()
78  : de()
79  {
80  }
81 
82  void init()
83  {
84  //de.setDeInitializer(speedTreeAuthorizationTestInitializer());
85 
86  vrvOsg::init(de);
87  de.initialize();
88  }
89 
90  DtDe de;
91  };
92 
93 // // A DtDe instance created with the default values for itself and it's initializer that
94 // // also loads plugins via the plugin manager.
95 // struct DtDefaultIgInstanceWithPlugins
96 // {
97 // DtDefaultIgInstanceWithPlugins()
98 // : de()
99 // , pluginManager(de)
100 // {
101 // init();
102 // }
103 //
104 // void init()
105 // {
106 // de.setDeInitializer(speedTreeAuthorizationTestInitializer());
107 // pluginManager.initializePlugins();
108 // de.initialize();
109 // }
110 //
111 // DtDe de;
112 // DtPluginManager pluginManager;
113 // };
114 
115  // Struct for creating a DtDe instance without loading plugins.
116  struct DtIgEmbeddedNoPlugins
117  {
118  DtIgEmbeddedNoPlugins()
119  : de()
120  {
121  DtDeInitializer initializer = testInitializer();
123  de.setDeInitializer(initializer);
124 
125  init();
126  }
127 
128  DtIgEmbeddedNoPlugins(DtDeConfiguration deConfig)
129  : de()
130  {
131  DtDeInitializer initializer = testInitializer();
132  initializer.setDeConfiguration(deConfig);
133  de.setDeInitializer(initializer);
134 
135  init();
136  }
137 
138  void init()
139  {
140  // Manually setup creators.
141  vrvOsg::init(de);
142  vrvOsgQt::init(de);
143 
144  de.initialize();
145  }
146 
147  DtDe de;
148  };
149 
150 
151  // Struct for creating a DtDe and loads plugins using the plugin manager
152  struct DtIgEmbeddedWithPlugins
153  {
154  DtIgEmbeddedWithPlugins()
155  : de()
156  , pluginManager(de)
157  {
158  DtDeInitializer initializer = testInitializer();
160  de.setDeInitializer(initializer);
161 
162  init();
163  }
164 
165  DtIgEmbeddedWithPlugins(DtDeConfiguration deConfig)
166  : de()
167  , pluginManager(de)
168  {
169  DtDeInitializer initializer = testInitializer();
170  initializer.setDeConfiguration(deConfig);
171  de.setDeInitializer(initializer);
172 
173  init();
174  }
175 
176  void init()
177  {
178  pluginManager.initializePlugins();
179  de.initialize();
180  }
181 
182  DtDe de;
183  DtPluginManager pluginManager;
184  };
185 
186  // Struct for creating a DtDe and loads plugins using the plugin manager
187  struct DtIgEmbeddedWithPluginsUninitialized
188  {
189  DtIgEmbeddedWithPluginsUninitialized(DtDeInitializer& initr)
190  : de()
191  , igInit(initr)
192  , pluginManager(de)
193  {
195  de.setDeInitializer(initr);
196 
197  init();
198  }
199 
200  void init()
201  {
202  pluginManager.initializePlugins();
203  de.initialize();
204  }
205 
206  DtDeInitializer igInit;
207  DtDe de;
208  DtPluginManager pluginManager;
209  };
210 
211 
212  // Struct for creating a DtDe instance without loading plugins and without a user interface.
213  struct DtIgWindowUninitialized
214  {
215  DtIgWindowUninitialized()
216  : de()
217  {
218  DtDeInitializer initializer = testInitializer();
219  DtDeConfiguration deConfiguration;
221  initializer.setDeConfiguration(deConfiguration);
222  de.setDeInitializer(initializer);
223  }
224 
225  void init()
226  {
227  // Manually setup creators.
228  vrvOsg::init(de);
229 
230  de.initialize();
231  }
232 
233  DtDe de;
234  };
235 
236 
237  // Struct for creating a DtDe instance without loading plugins and without a user interface.
238  struct DtIgWindow
239  {
240  DtIgWindow()
241  : de()
242  {
243  DtDeInitializer initializer = testInitializer();
244  DtDeConfiguration deConfiguration;
246  initializer.setDeConfiguration(deConfiguration);
247  de.setDeInitializer(initializer);
248 
249  // Manually setup creators.
250  vrvOsg::init(de);
251 
252  de.initialize();
253  }
254 
255  DtDe de;
256  };
257 
258  // Struct for creating a DtDe instance with plugins but without a user interface.
259  struct DtIgSimpleDisplayWithPlugins
260  {
261  DtIgSimpleDisplayWithPlugins()
262  : de()
263  , pluginManager(de)
264  {
266  DtDeConfiguration deConfiguration;
268  initializer.setDeConfiguration(deConfiguration);
269  de.setDeInitializer(initializer);
270 
271  init();
272  }
273 
274  void init()
275  {
276  pluginManager.initializePlugins();
277  de.initialize();
278  }
279 
280  DtDe de;
281  DtPluginManager pluginManager;
282  };
283 
284 // struct DtSimpleDisplayWithSlot : public DtIgSimpleDisplayWithPlugins
285 // {
286 // DtSimpleDisplayWithSlot()
287 // {
288 // called = false;
289 // }
290 //
291 // bool called;
292 //
293 // void on_slot()
294 // {
295 // called = true;
296 // }
297 //
298 // };
299 
300  //The example channel that will get registered by the exampleChannelPlugin.
301  class DtMockChannel : public DtChannel
302  {
303 
304  public:
305 
307  friend class DtMockChannelCreator;
308 
310  virtual ~DtMockChannel()
311  {
312  }
313 
314 
315  virtual void setClearColor(float r,float g,float b, float a)
316  {
317  }
318 
319  virtual void setViewport(int x,int y,int width, int height)
320  {
321  }
322 
323  virtual void getViewport(int& x,int& y, int& width,int& height) const
324  {
325  }
326 
327 
328  virtual void setWindow(DtWindow*)
329  {
330  }
331 
332  virtual void setCameraPosition(double x, double y, double z)
333  {
334  }
335 
336  virtual const DtWindow* window() const
337  {
338  return 0;
339  }
340 
341  virtual void update()
342  {
343  }
344 
345  virtual void setCameraObject(DtCameraObject* cameraObject)
346  {
347 
348  }
349 
350 
351  virtual void setParentCameraObject(DtCameraObject* cameraObject)
352  {
353 
354  }
355 
356 
357  virtual void updateProjection()
358  {
359 
360  }
361 
362  virtual void setDynamicNearFar(bool enable)
363  {
364 
365  }
366 
367  virtual void setNearFarRatio(double ratio)
368  {
369 
370  }
371 
372  virtual bool processMouseEvent( const DtMouseEvent& ev)
373  {
374  return true;
375  }
376 
377  virtual bool processKeyboardEvent( const DtKeyEvent& ev)
378  {
379  return true;
380  }
381 
382  virtual void projectToScreen( double dbX, double dbY, double dbZ,
383  double& screenX, double& screenY, double& screenZ )
384  {
385  }
386 
387  virtual void projectToWorld( double screenX, double screenY,
388  double& dbX, double& dbY, double& dbZ )
389  {
390  }
391 
392  virtual void warpMouse( float pixelX, float pixelY )
393  {
394  }
395 
396  virtual void connectToObserver()
397  {
398  }
399 
400  protected:
401 
402 
403  virtual void setProjectionMatrixAsPerspective(double fovy, double aspectRatio, double zNear, double zFar)
404  {
405  }
406 
407 
408  virtual void setProjectionMatrixAsFrustum (double left, double right, double bottom, double top,
409  double zNear, double zFar)
410  {
411  }
412 
413 
415  DtMockChannel(DtDe& de, DtWindow* window, DtChannelConfiguration& channelConfig)
416  : DtChannel(de, window, channelConfig)
417  {
418  // Do nothing.
419  }
420 
421  };
422 
424  class DtMockChannelCreator : public DtChannelCreator
425  {
426 
427  public:
428 
430  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config)
431  {
432  return new DtMockChannel(de, window, config);
433  }
434 
435  };
436 
437  // Struct for creating a DtDe instance without loading plugins and without a user interface and with
438  // a mock channel that doesn't render.
439  struct DtMockChannelUninitializedDisplayEngine
440  {
441  DtMockChannelUninitializedDisplayEngine()
442  : de()
443  {
444  // Manually setup creators.
445  vrvOsg::init(de);
446 
447  // Setup the channel creator.
448  DtChannelCreator::registerInstance(de, new DtMockChannelCreator);
449 
450  de.initialize();
451  }
452 
453  DtDe de;
454  };
455 
456 
457  // Struct for creating a DtDe instance without loading plugins and with
458  // a mock channel that doesn't render.
459  struct DtMockChannelDisplayEngine
460  {
461  DtMockChannelDisplayEngine()
462  : de()
463  {
464  DtDeInitializer initializer = testInitializer();
465  DtDeConfiguration deConfiguration;
467  initializer.setDeConfiguration(deConfiguration);
468  de.setDeInitializer(initializer);
469 
470  // Manually setup creators.
471  vrvOsg::init(de);
472 
473  // Setup the channel creator.
474  DtChannelCreator::registerInstance(de, new DtMockChannelCreator);
475 
476  de.initialize();
477  }
478 
479  DtDe de;
480  };
481 
482  // Struct for creating a DtDe instance that loads plugins and with
483  // a mock channel that doesn't render.
484  struct DtMockChannelDisplayEngineWithPlugins
485  {
486  DtMockChannelDisplayEngineWithPlugins()
487  : de()
488  , pluginManager(de)
489  {
490  init();
491  }
492 
493  void init()
494  {
495  de.setDeInitializer(speedTreeAuthorizationTestInitializer());
496  pluginManager.initializePlugins();
497 
498  // Setup the channel creator.
499  DtChannelCreator::registerInstance(de, new DtMockChannelCreator);
500 
501  de.initialize();
502  }
503 
504  DtDe de;
505  DtPluginManager pluginManager;
506  };
507 
508  struct DtMockChannelDisplayEngineWithSlot : public DtMockChannelDisplayEngine
509  {
510  DtMockChannelDisplayEngineWithSlot()
511  {
512  called = false;
513  }
514 
515  bool called;
516 
517  void on_slot()
518  {
519  called = true;
520  }
521 
522  };
523 
524  // Struct for creating a DtDe instance without loading plugins and without a user interface and with
525  // a mock channel that doesn't render.
526  struct DtDisplayEngineNoGui
527  {
528  DtDisplayEngineNoGui()
529  : de()
530  {
531  DtDeInitializer initializer = testInitializer();
532  DtDeConfiguration deConfiguration;
534  initializer.setDeConfiguration(deConfiguration);
535  de.setDeInitializer(initializer);
536 
537  // Manually setup creators.
538  vrvOsg::init(de);
539 
540  //Set the main window provider instance to create no main window
542 
543  // Setup the channel creator.
544  DtChannelCreator::registerInstance(de, new DtMockChannelCreator);
545 
546  de.initialize();
547  }
548 
549  DtDe de;
550  };
551 
552  struct DtDisplayEngineNoGuiWithPlugins
553  {
554  DtDisplayEngineNoGuiWithPlugins()
555  : de()
556  , pluginManager(de)
557  {
558  init();
559  }
560 
561  void init()
562  {
563  de.setDeInitializer(speedTreeAuthorizationTestInitializer());
564  pluginManager.initializePlugins();
565 
566  //Set the main window provider instance to create no main window
568 
569  // Setup the channel creator.
570  DtChannelCreator::registerInstance(de, new DtMockChannelCreator);
571 
572  de.initialize();
573  }
574 
575  DtDe de;
576  DtPluginManager pluginManager;
577  };
578 
579  struct DtDisplayEngineNoGuiWithPluginsWithSlot : public DtDisplayEngineNoGuiWithPlugins
580  {
581  DtDisplayEngineNoGuiWithPluginsWithSlot()
582  {
583  called = false;
584  }
585 
586  bool called;
587 
588  void on_slot()
589  {
590  called = true;
591  }
592 
593  };
594 
595 
596 }
597 
598 #endif

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)