42 #include <visp3/core/vpConfig.h>
44 #ifdef VISP_HAVE_COIN3D_AND_GUI
45 #include <visp3/ar/vpSimulator.h>
46 #include <visp3/ar/vpViewer.h>
48 #include <Inventor/events/SoKeyboardEvent.h>
49 #include <Inventor/nodes/SoEventCallback.h>
51 #if defined(VISP_HAVE_SOWIN)
53 : SoWinExaminerViewer(parent, (char *)NULL, false), viewerType(type), simu(_simu)
54 #elif defined(VISP_HAVE_SOQT)
56 : SoQtExaminerViewer(parent, (char *)NULL, false), viewerType(type), simu(_simu)
57 #elif defined(VISP_HAVE_SOXT)
59 : SoXtExaminerViewer(parent, (char *)NULL, false), viewerType(type), simu(_simu)
65 this->setClearBeforeRender(FALSE, TRUE);
76 const SbViewportRegion
vp = this->getViewportRegion();
77 SbVec2s origin =
vp.getViewportOriginPixels();
78 SbVec2s size =
vp.getViewportSizePixels();
79 glViewport(origin[0], origin[1], size[0], size[1]);
81 const SbColor col = this->getBackgroundColor();
82 glClearColor(col[0], col[1], col[2], 0.0f);
83 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
88 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
96 glEnable(GL_DEPTH_TEST);
97 glClear(GL_DEPTH_BUFFER_BIT);
101 #if defined(VISP_HAVE_SOWIN)
102 SoWinExaminerViewer::actualRedraw();
103 #elif defined(VISP_HAVE_SOQT)
104 SoQtExaminerViewer::actualRedraw();
105 #elif defined(VISP_HAVE_SOXT)
106 SoXtExaminerViewer::actualRedraw();
126 #if defined(VISP_HAVE_SOWIN) || defined(VISP_HAVE_SOQT)
136 #if defined(VISP_HAVE_SOWIN)
137 HWND parent = getParentWidget();
139 RECT rcClient, rcWindow;
141 GetClientRect(parent, &rcClient);
142 GetWindowRect(parent, &rcWindow);
143 ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
144 ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
145 MoveWindow(parent, rcWindow.left, rcWindow.top, x + ptDiff.x, y + ptDiff.y, TRUE);
147 DWORD dwStyle = GetWindowLong(parent, GWL_STYLE);
148 dwStyle &= ~(WS_SIZEBOX);
149 SetWindowLong(parent, GWL_STYLE, dwStyle);
151 #elif defined(VISP_HAVE_SOQT)
153 QWidget *parent = getParentWidget();
154 parent->setFixedSize(x, y);
167 SbBool vpViewer::processSoEvent(
const SoEvent *
const event)
169 if (this->isViewing() && event->getTypeId() == SoKeyboardEvent::getClassTypeId()) {
170 SoKeyboardEvent *kbevent = (SoKeyboardEvent *)event;
171 switch (kbevent->getKey()) {
172 case SoKeyboardEvent::H:
173 if (kbevent->getState() == SoButtonEvent::DOWN) {
174 std::cout <<
"H : this help " << std::endl;
175 std::cout <<
"M : get and save the external camera location (matrix)" << std::endl;
176 std::cout <<
"V : get and save the external camera location (vector)" << std::endl;
177 std::cout <<
"M : load camera location (vector)" << std::endl;
178 std::cout <<
"P : get external camera location and set the internal one" << std::endl;
182 case SoKeyboardEvent::M:
183 if (kbevent->getState() == SoButtonEvent::DOWN) {
186 std::ofstream f(
"cMf.dat");
191 case SoKeyboardEvent::V:
192 if (kbevent->getState() == SoButtonEvent::DOWN) {
196 std::ofstream f(
"vcMf.dat");
201 case SoKeyboardEvent::L:
202 if (kbevent->getState() == SoButtonEvent::DOWN) {
204 std::ifstream f(
"vcMf.dat");
212 case SoKeyboardEvent::P:
213 if (kbevent->getState() == SoButtonEvent::DOWN) {
226 #if defined(VISP_HAVE_SOWIN)
227 return SoWinExaminerViewer::processSoEvent(event);
228 #elif defined(VISP_HAVE_SOQT)
229 return SoQtExaminerViewer::processSoEvent(event);
230 #elif defined(VISP_HAVE_SOXT)
231 return SoXtExaminerViewer::processSoEvent(event);
235 #elif !defined(VISP_BUILD_SHARED_LIBS)
237 void dummy_vpViewer(){};
Implementation of an homogeneous matrix and operations on such kind of matrices.
void save(std::ofstream &f) const
Implementation of a pose vector and operations on poses.
void load(std::ifstream &f)
Implementation of a simulator based on Coin3d (www.coin3d.org).
unsigned int getInternalWidth() const
GLubyte * image_background
unsigned char * bufferView
image of the internal view
void moveInternalCamera(vpHomogeneousMatrix &cMf)
modify the position of the camera in the scene graph
void getExternalCameraPosition(vpHomogeneousMatrix &cMf)
get the external camera position
void setCameraPosition(vpHomogeneousMatrix &cMf)
set the camera position (from an homogeneous matrix)
unsigned int getInternalHeight() const
Viewer used by the simulator.
void resize(int x, int y, bool fixed=false)
virtual void actualRedraw(void)
vpViewer(HWND parent, vpSimulator *simu, vpViewerType type)