45 #include <visp3/core/vpConfig.h> 47 #ifdef VISP_HAVE_COIN3D_AND_GUI 48 #include <visp3/ar/vpSimulator.h> 49 #include <visp3/ar/vpViewer.h> 51 #include <Inventor/events/SoKeyboardEvent.h> 52 #include <Inventor/nodes/SoEventCallback.h> 54 #if defined(VISP_HAVE_SOWIN) 56 : viewerType(type), SoWinExaminerViewer(parent, (char *)NULL, false)
57 #elif defined(VISP_HAVE_SOQT)
59 : viewerType(type), SoQtExaminerViewer(parent, (char *)NULL, false)
60 #elif defined(VISP_HAVE_SOXT)
62 : viewerType(type), SoXtExaminerViewer(parent, (char *)NULL, false)
69 this->setClearBeforeRender(FALSE, TRUE);
80 const SbViewportRegion
vp = this->getViewportRegion();
81 SbVec2s origin = vp.getViewportOriginPixels();
82 SbVec2s size = vp.getViewportSizePixels();
83 glViewport(origin[0], origin[1], size[0], size[1]);
85 const SbColor col = this->getBackgroundColor();
86 glClearColor(col[0], col[1], col[2], 0.0f);
87 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
92 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
100 glEnable(GL_DEPTH_TEST);
101 glClear(GL_DEPTH_BUFFER_BIT);
105 #if defined(VISP_HAVE_SOWIN) 106 SoWinExaminerViewer::actualRedraw();
107 #elif defined(VISP_HAVE_SOQT) 108 SoQtExaminerViewer::actualRedraw();
109 #elif defined(VISP_HAVE_SOXT) 110 SoXtExaminerViewer::actualRedraw();
130 #if defined(VISP_HAVE_SOWIN) || defined(VISP_HAVE_SOQT) 140 #if defined(VISP_HAVE_SOWIN) 141 HWND parent = getParentWidget();
143 RECT rcClient, rcWindow;
145 GetClientRect(parent, &rcClient);
146 GetWindowRect(parent, &rcWindow);
147 ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
148 ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
149 MoveWindow(parent, rcWindow.left, rcWindow.top, x + ptDiff.x, y + ptDiff.y, TRUE);
151 DWORD dwStyle = GetWindowLong(parent, GWL_STYLE);
152 dwStyle &= ~(WS_SIZEBOX);
153 SetWindowLong(parent, GWL_STYLE, dwStyle);
155 #elif defined(VISP_HAVE_SOQT) 157 QWidget *parent = getParentWidget();
158 parent->setFixedSize(x, y);
171 SbBool vpViewer::processSoEvent(
const SoEvent *
const event)
173 if (this->isViewing() && event->getTypeId() == SoKeyboardEvent::getClassTypeId()) {
174 SoKeyboardEvent *kbevent = (SoKeyboardEvent *)event;
175 switch (kbevent->getKey()) {
176 case SoKeyboardEvent::H:
177 if (kbevent->getState() == SoButtonEvent::DOWN) {
178 std::cout <<
"H : this help " << std::endl;
179 std::cout <<
"M : get and save the external camera location (matrix)" << std::endl;
180 std::cout <<
"V : get and save the external camera location (vector)" << std::endl;
181 std::cout <<
"M : load camera location (vector)" << std::endl;
182 std::cout <<
"P : get external camera location and set the internal one" << std::endl;
186 case SoKeyboardEvent::M:
187 if (kbevent->getState() == SoButtonEvent::DOWN) {
190 std::ofstream f(
"cMf.dat");
195 case SoKeyboardEvent::V:
196 if (kbevent->getState() == SoButtonEvent::DOWN) {
200 std::ofstream f(
"vcMf.dat");
205 case SoKeyboardEvent::L:
206 if (kbevent->getState() == SoButtonEvent::DOWN) {
208 std::ifstream f(
"vcMf.dat");
216 case SoKeyboardEvent::P:
217 if (kbevent->getState() == SoButtonEvent::DOWN) {
230 #if defined(VISP_HAVE_SOWIN) 231 return SoWinExaminerViewer::processSoEvent(event);
232 #elif defined(VISP_HAVE_SOQT) 233 return SoQtExaminerViewer::processSoEvent(event);
234 #elif defined(VISP_HAVE_SOXT) 235 return SoXtExaminerViewer::processSoEvent(event);
239 #elif !defined(VISP_BUILD_SHARED_LIBS) 241 void dummy_vpViewer(){};
void load(std::ifstream &f)
void resize(int x, int y, bool fixed=false)
void save(std::ofstream &f) const
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).
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)
vpHomogeneousMatrix cMf
internal camera position
unsigned int getInternalHeight() const
unsigned char * bufferView
image of the internal view
Implementation of a pose vector and operations on poses.
vpViewer(HWND parent, vpSimulator *simu, vpViewerType type)
void save(std::ofstream &f) const
unsigned int getInternalWidth() const