Visual Servoing Platform  version 3.6.1 under development (2024-05-28)
vpViewer.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 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 https://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 *****************************************************************************/
35 
36 #ifndef vpViewer_HH
37 #define vpViewer_HH
50 #include <visp3/core/vpConfig.h>
51 
52 #ifdef VISP_HAVE_COIN3D_AND_GUI
53 
54 #if defined(VISP_HAVE_SOWIN)
55 
56 #include <Inventor/Win/SoWin.h>
57 #include <Inventor/Win/viewers/SoWinExaminerViewer.h>
58 
59 #elif defined(VISP_HAVE_SOQT)
60 
61 #include <Inventor/Qt/SoQt.h>
62 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
63 
64 #elif defined(VISP_HAVE_SOXT)
65 
66 #include <Inventor/Xt/SoXt.h>
67 #include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
68 
69 #endif
70 
71 // Coin stuff
72 
73 #include <Inventor/nodes/SoBaseColor.h>
74 #include <Inventor/nodes/SoCone.h>
75 #include <Inventor/nodes/SoCube.h>
76 #include <Inventor/nodes/SoImage.h>
77 #include <Inventor/nodes/SoLightModel.h>
78 #include <Inventor/nodes/SoPerspectiveCamera.h>
79 #include <Inventor/nodes/SoRotationXYZ.h>
80 #include <Inventor/nodes/SoSeparator.h>
81 #include <Inventor/nodes/SoTranslation.h>
82 #include <Inventor/sensors/SoTimerSensor.h>
83 
84 #if defined(VISP_HAVE_SOWIN)
85 #include <GL/gl.h>
86 #elif defined(VISP_HAVE_SOQT)
87 #include <qgl.h>
88 #elif defined(VISP_HAVE_SOXT)
89 #include <GL/gl.h>
90 #endif
91 
92 // visp
93 #include <visp3/core/vpCameraParameters.h>
94 #include <visp3/core/vpDebug.h>
95 #include <visp3/core/vpHomogeneousMatrix.h>
96 
111 class vpSimulator;
112 
113 #if defined(VISP_HAVE_SOWIN)
114 class VISP_EXPORT vpViewer : public SoWinExaminerViewer
115 #elif defined(VISP_HAVE_SOQT)
116 class VISP_EXPORT vpViewer : public SoQtExaminerViewer
117 #elif defined(VISP_HAVE_SOXT)
118 class VISP_EXPORT vpViewer : public SoXtExaminerViewer
119 #endif
120 {
121 
122  friend class vpSimulator;
123 
124 public:
126 #if defined(VISP_HAVE_SOWIN)
127  vpViewer(HWND parent, vpSimulator *simu, vpViewerType type);
128 #elif defined(VISP_HAVE_SOQT)
129  vpViewer(QWidget *parent, vpSimulator *simu, vpViewerType type);
130 #elif defined(VISP_HAVE_SOXT)
131  vpViewer(Widget parent, vpSimulator *simu, vpViewerType type);
132 #endif
133 
134  virtual ~vpViewer();
135  void resize(int x, int y, bool fixed = false);
136  virtual void actualRedraw(void);
137 
138 private:
139  vpViewerType viewerType;
140  vpSimulator *simu;
141  SbBool processSoEvent(const SoEvent *const event);
142 #if defined(VISP_HAVE_SOWIN)
143  static HWND init(const char *appname) { return SoWin::init(appname); };
144  static void mainLoop() { SoWin::mainLoop(); };
145  static void exitMainLoop() { SoWin::exitMainLoop(); };
146 #elif defined(VISP_HAVE_SOQT)
147  static QWidget *init(const char *appname) { return SoQt::init(appname); };
148  static void mainLoop() { SoQt::mainLoop(); };
149  static void exitMainLoop() { SoQt::exitMainLoop(); };
150 #elif defined(VISP_HAVE_SOXT)
151  static Widget init(const char *appname) { return SoXt::init(appname); };
152  static void mainLoop() { SoXt::mainLoop(); };
153  static void exitMainLoop() { SoXt::exitMainLoop(); };
154 #endif
155 };
156 
157 #endif // VISP_HAVE_COIN3D_AND_GUI
158 
159 #endif
Implementation of a simulator based on Coin3d (www.coin3d.org).
Definition: vpSimulator.h:99
virtual void mainLoop()
activate the mainloop
void init()
perform some initialization
vpViewer * externalView
view from an external camera
Definition: vpSimulator.h:138
Viewer used by the simulator.
Definition: vpViewer.h:120
void resize(int x, int y, bool fixed=false)
Definition: vpViewer.cpp:127
vpViewerType
Definition: vpViewer.h:125
@ internalView
Definition: vpViewer.h:125
virtual ~vpViewer()
Definition: vpViewer.cpp:70
virtual void actualRedraw(void)
Definition: vpViewer.cpp:72
vpViewer(HWND parent, vpSimulator *simu, vpViewerType type)
Definition: vpViewer.cpp:52