Visual Servoing Platform  version 3.2.1 under development (2019-08-19)
vpViewer.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Simulator based on Coin3d.
33  *
34  * Authors:
35  * Eric Marchand
36  *
37  *****************************************************************************/
38 
39 #ifndef vpViewer_HH
40 #define vpViewer_HH
41 
53 #include <visp3/core/vpConfig.h>
54 
55 #ifdef VISP_HAVE_COIN3D_AND_GUI
56 
57 #if defined(VISP_HAVE_SOWIN)
58 
59 #include <Inventor/Win/SoWin.h>
60 #include <Inventor/Win/viewers/SoWinExaminerViewer.h>
61 
62 #elif defined(VISP_HAVE_SOQT)
63 
64 #include <Inventor/Qt/SoQt.h>
65 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
66 
67 #elif defined(VISP_HAVE_SOXT)
68 
69 #include <Inventor/Xt/SoXt.h>
70 #include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
71 
72 #endif
73 
74 // Coin stuff
75 
76 #include <Inventor/nodes/SoBaseColor.h>
77 #include <Inventor/nodes/SoCone.h>
78 #include <Inventor/nodes/SoCube.h>
79 #include <Inventor/nodes/SoImage.h>
80 #include <Inventor/nodes/SoLightModel.h>
81 #include <Inventor/nodes/SoPerspectiveCamera.h>
82 #include <Inventor/nodes/SoRotationXYZ.h>
83 #include <Inventor/nodes/SoSeparator.h>
84 #include <Inventor/nodes/SoTranslation.h>
85 #include <Inventor/sensors/SoTimerSensor.h>
86 
87 #if defined(VISP_HAVE_SOWIN)
88 #include <GL/gl.h>
89 #elif defined(VISP_HAVE_SOQT)
90 #include <qgl.h>
91 #elif defined(VISP_HAVE_SOXT)
92 #include <GL/gl.h>
93 #endif
94 
95 // visp
96 #include <visp3/core/vpCameraParameters.h>
97 #include <visp3/core/vpDebug.h>
98 #include <visp3/core/vpHomogeneousMatrix.h>
99 
114 class vpSimulator;
115 
116 #if defined(VISP_HAVE_SOWIN)
117 class VISP_EXPORT vpViewer : public SoWinExaminerViewer
118 #elif defined(VISP_HAVE_SOQT)
119 class VISP_EXPORT vpViewer : public SoQtExaminerViewer
120 #elif defined(VISP_HAVE_SOXT)
121 class VISP_EXPORT vpViewer : public SoXtExaminerViewer
122 #endif
123 {
124 
125  friend class vpSimulator;
126 
127 public:
129 #if defined(VISP_HAVE_SOWIN)
130  vpViewer(HWND parent, vpSimulator *simu, vpViewerType type);
131 #elif defined(VISP_HAVE_SOQT)
132  vpViewer(QWidget *parent, vpSimulator *simu, vpViewerType type);
133 #elif defined(VISP_HAVE_SOXT)
134  vpViewer(Widget parent, vpSimulator *simu, vpViewerType type);
135 #endif
136 
137  virtual ~vpViewer();
138  void resize(int x, int y, bool fixed = false);
139  virtual void actualRedraw(void);
140 
141 private:
142  vpViewerType viewerType;
143  vpSimulator *simu;
144  SbBool processSoEvent(const SoEvent *const event);
145 #if defined(VISP_HAVE_SOWIN)
146  static HWND init(const char *appname) { return SoWin::init(appname); };
147  static void mainLoop() { SoWin::mainLoop(); };
148  static void exitMainLoop() { SoWin::exitMainLoop(); };
149 #elif defined(VISP_HAVE_SOQT)
150  static QWidget *init(const char *appname) { return SoQt::init(appname); };
151  static void mainLoop() { SoQt::mainLoop(); };
152  static void exitMainLoop() { SoQt::exitMainLoop(); };
153 #elif defined(VISP_HAVE_SOXT)
154  static Widget init(const char *appname) { return SoXt::init(appname); };
155  static void mainLoop() { SoXt::mainLoop(); };
156  static void exitMainLoop() { SoXt::exitMainLoop(); };
157 #endif
158 };
159 
160 #endif // VISP_HAVE_COIN3D_AND_GUI
161 
162 #endif
virtual ~vpViewer()
Definition: vpViewer.cpp:73
void resize(int x, int y, bool fixed=false)
Definition: vpViewer.cpp:130
Implementation of a simulator based on Coin3d (www.coin3d.org).
Definition: vpSimulator.h:99
void init()
perform some initialization
virtual void mainLoop()
activate the mainloop
vpViewerType
Definition: vpViewer.h:128
Viewer used by the simulator.
Definition: vpViewer.h:117
virtual void actualRedraw(void)
Definition: vpViewer.cpp:75
vpViewer * externalView
view from an external camera
Definition: vpSimulator.h:139
vpViewer(HWND parent, vpSimulator *simu, vpViewerType type)
Definition: vpViewer.cpp:55