47 #include <visp/vpConfig.h>
49 #ifdef VISP_HAVE_COIN_AND_GUI
50 #include <visp/vpViewer.h>
51 #include <visp/vpSimulator.h>
54 #include <Inventor/events/SoKeyboardEvent.h>
55 #include <Inventor/nodes/SoEventCallback.h>
58 #if defined(VISP_HAVE_SOWIN)
60 SoWinExaminerViewer(parent,(char *)NULL,false)
61 #elif defined(VISP_HAVE_SOQT)
63 SoQtExaminerViewer(parent,(char *)NULL,false)
64 #elif defined(VISP_HAVE_SOXT)
66 SoXtExaminerViewer(parent,(char *)NULL,false)
70 this->viewerType = viewerType;
74 this->setClearBeforeRender(FALSE, TRUE);
89 const SbViewportRegion vp = this->getViewportRegion();
90 SbVec2s origin = vp.getViewportOriginPixels();
91 SbVec2s size = vp.getViewportSizePixels();
92 glViewport(origin[0], origin[1], size[0], size[1]);
94 const SbColor col = this->getBackgroundColor();
95 glClearColor(col[0], col[1], col[2], 0.0f);
96 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
102 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
105 (GLenum)GL_LUMINANCE,
114 glEnable(GL_DEPTH_TEST);
115 glClear(GL_DEPTH_BUFFER_BIT);
119 #if defined(VISP_HAVE_SOWIN)
120 SoWinExaminerViewer::actualRedraw();
121 #elif defined(VISP_HAVE_SOQT)
122 SoQtExaminerViewer::actualRedraw();
123 #elif defined(VISP_HAVE_SOXT)
124 SoXtExaminerViewer::actualRedraw();
147 #if defined(VISP_HAVE_SOWIN) || defined (VISP_HAVE_SOQT)
157 #if defined(VISP_HAVE_SOWIN)
158 HWND parent = getParentWidget();
160 RECT rcClient, rcWindow;
162 GetClientRect(parent, &rcClient);
163 GetWindowRect(parent, &rcWindow);
164 ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
165 ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
166 MoveWindow(parent,rcWindow.left, rcWindow.top,
167 x + ptDiff.x, y + ptDiff.y, TRUE);
169 DWORD dwStyle = GetWindowLong(parent, GWL_STYLE);
170 dwStyle &= ~(WS_SIZEBOX);
171 SetWindowLong(parent, GWL_STYLE,dwStyle);
173 #elif defined(VISP_HAVE_SOQT)
175 QWidget * parent = getParentWidget();
176 parent->setFixedSize(x, y);
190 vpViewer::processSoEvent(
const SoEvent *
const event)
192 if ( this->isViewing() &&
193 event->getTypeId() == SoKeyboardEvent::getClassTypeId() )
195 SoKeyboardEvent * kbevent = (SoKeyboardEvent *) event;
196 switch ( kbevent->getKey() ) {
197 case SoKeyboardEvent::H:
198 if ( kbevent->getState() == SoButtonEvent::DOWN )
200 std::cout <<
"H : this help "<<std::endl ;
201 std::cout <<
"M : get and save the external camera location (matrix)"<<std::endl;
202 std::cout <<
"V : get and save the external camera location (vector)"<<std::endl;
203 std::cout <<
"M : load camera location (vector)"<<std::endl;
204 std::cout <<
"P : get external camera location and set the internal one"<<std::endl;
208 case SoKeyboardEvent::M:
209 if ( kbevent->getState() == SoButtonEvent::DOWN )
213 std::ofstream f(
"cMf.dat") ;
218 case SoKeyboardEvent::V:
219 if ( kbevent->getState() == SoButtonEvent::DOWN )
224 std::ofstream f(
"vcMf.dat") ;
229 case SoKeyboardEvent::L:
230 if ( kbevent->getState() == SoButtonEvent::DOWN )
233 std::ifstream f(
"vcMf.dat") ;
241 case SoKeyboardEvent::P:
242 if ( kbevent->getState() == SoButtonEvent::DOWN )
256 #if defined(VISP_HAVE_SOWIN)
257 return SoWinExaminerViewer::processSoEvent(event);
258 #elif defined(VISP_HAVE_SOQT)
259 return SoQtExaminerViewer::processSoEvent(event);
260 #elif defined(VISP_HAVE_SOXT)
261 return SoXtExaminerViewer::processSoEvent(event);
void load(std::ifstream &f)
void resize(int x, int y, bool fixed=false)
int get
Flag to protect the read and write of the framebuffer (between the simulator and the viewer)...
void setCameraPosition(vpHomogeneousMatrix &cMf)
set the camera position (from an homogeneous matrix)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Implementation of a simulator based on Coin3d (www.coin3d.org).
unsigned int getInternalHeight() const
void getExternalCameraPosition(vpHomogeneousMatrix &cMf)
get the external camera position
void moveInternalCamera(vpHomogeneousMatrix &cMf)
modify the position of the camera in the scene graph
GLubyte * image_background
Viewer used by the simulator.
virtual void actualRedraw(void)
void save(std::ofstream &f) const
unsigned char * bufferView
image of the internal view
The pose is a complete representation of every rigid motion in the euclidian space.
unsigned int getInternalWidth() const
vpViewer(HWND parent, vpSimulator *simu, vpViewerType viewerType)