43 #include <visp3/core/vpConfig.h>
45 #ifdef VISP_HAVE_COIN3D_AND_GUI
46 #include <visp3/ar/vpViewer.h>
47 #include <visp3/ar/vpSimulator.h>
50 #include <Inventor/events/SoKeyboardEvent.h>
51 #include <Inventor/nodes/SoEventCallback.h>
54 #if defined(VISP_HAVE_SOWIN)
56 SoWinExaminerViewer(parent,(char *)NULL,false)
57 #elif defined(VISP_HAVE_SOQT)
59 SoQtExaminerViewer(parent,(char *)NULL,false)
60 #elif defined(VISP_HAVE_SOXT)
62 SoXtExaminerViewer(parent,(char *)NULL,false)
66 this->viewerType = viewerType;
70 this->setClearBeforeRender(FALSE, TRUE);
85 const SbViewportRegion vp = this->getViewportRegion();
86 SbVec2s origin = vp.getViewportOriginPixels();
87 SbVec2s size = vp.getViewportSizePixels();
88 glViewport(origin[0], origin[1], size[0], size[1]);
90 const SbColor col = this->getBackgroundColor();
91 glClearColor(col[0], col[1], col[2], 0.0f);
92 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
98 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
101 (GLenum)GL_LUMINANCE,
110 glEnable(GL_DEPTH_TEST);
111 glClear(GL_DEPTH_BUFFER_BIT);
115 #if defined(VISP_HAVE_SOWIN)
116 SoWinExaminerViewer::actualRedraw();
117 #elif defined(VISP_HAVE_SOQT)
118 SoQtExaminerViewer::actualRedraw();
119 #elif defined(VISP_HAVE_SOXT)
120 SoXtExaminerViewer::actualRedraw();
143 #if defined(VISP_HAVE_SOWIN) || defined (VISP_HAVE_SOQT)
153 #if defined(VISP_HAVE_SOWIN)
154 HWND parent = getParentWidget();
156 RECT rcClient, rcWindow;
158 GetClientRect(parent, &rcClient);
159 GetWindowRect(parent, &rcWindow);
160 ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
161 ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
162 MoveWindow(parent,rcWindow.left, rcWindow.top,
163 x + ptDiff.x, y + ptDiff.y, TRUE);
165 DWORD dwStyle = GetWindowLong(parent, GWL_STYLE);
166 dwStyle &= ~(WS_SIZEBOX);
167 SetWindowLong(parent, GWL_STYLE,dwStyle);
169 #elif defined(VISP_HAVE_SOQT)
171 QWidget * parent = getParentWidget();
172 parent->setFixedSize(x, y);
186 vpViewer::processSoEvent(
const SoEvent *
const event)
188 if ( this->isViewing() &&
189 event->getTypeId() == SoKeyboardEvent::getClassTypeId() )
191 SoKeyboardEvent * kbevent = (SoKeyboardEvent *) event;
192 switch ( kbevent->getKey() ) {
193 case SoKeyboardEvent::H:
194 if ( kbevent->getState() == SoButtonEvent::DOWN )
196 std::cout <<
"H : this help "<<std::endl ;
197 std::cout <<
"M : get and save the external camera location (matrix)"<<std::endl;
198 std::cout <<
"V : get and save the external camera location (vector)"<<std::endl;
199 std::cout <<
"M : load camera location (vector)"<<std::endl;
200 std::cout <<
"P : get external camera location and set the internal one"<<std::endl;
204 case SoKeyboardEvent::M:
205 if ( kbevent->getState() == SoButtonEvent::DOWN )
209 std::ofstream f(
"cMf.dat") ;
214 case SoKeyboardEvent::V:
215 if ( kbevent->getState() == SoButtonEvent::DOWN )
220 std::ofstream f(
"vcMf.dat") ;
225 case SoKeyboardEvent::L:
226 if ( kbevent->getState() == SoButtonEvent::DOWN )
229 std::ifstream f(
"vcMf.dat") ;
237 case SoKeyboardEvent::P:
238 if ( kbevent->getState() == SoButtonEvent::DOWN )
252 #if defined(VISP_HAVE_SOWIN)
253 return SoWinExaminerViewer::processSoEvent(event);
254 #elif defined(VISP_HAVE_SOQT)
255 return SoQtExaminerViewer::processSoEvent(event);
256 #elif defined(VISP_HAVE_SOXT)
257 return SoXtExaminerViewer::processSoEvent(event);
262 #elif !defined(VISP_BUILD_SHARED_LIBS)
264 void dummy_vpViewer() {};
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)
Implementation of an homogeneous matrix and operations on such kind of matrices.
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
vpHomogeneousMatrix cMf
internal camera position
unsigned char * bufferView
image of the internal view
Implementation of a pose vector and operations on poses.
unsigned int getInternalWidth() const
vpViewer(HWND parent, vpSimulator *simu, vpViewerType viewerType)