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 : SoWinExaminerViewer(parent, (char *)NULL, false), viewerType(type), simu(_simu)
57 #elif defined(VISP_HAVE_SOQT)
59 : SoQtExaminerViewer(parent, (char *)NULL, false), viewerType(type), simu(_simu)
60 #elif defined(VISP_HAVE_SOXT)
62 : SoXtExaminerViewer(parent, (char *)NULL, false), viewerType(type), simu(_simu)
68 this->setClearBeforeRender(FALSE, TRUE);
79 const SbViewportRegion
vp = this->getViewportRegion();
80 SbVec2s origin = vp.getViewportOriginPixels();
81 SbVec2s size = vp.getViewportSizePixels();
82 glViewport(origin[0], origin[1], size[0], size[1]);
84 const SbColor col = this->getBackgroundColor();
85 glClearColor(col[0], col[1], col[2], 0.0f);
86 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
91 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
99 glEnable(GL_DEPTH_TEST);
100 glClear(GL_DEPTH_BUFFER_BIT);
104 #if defined(VISP_HAVE_SOWIN) 105 SoWinExaminerViewer::actualRedraw();
106 #elif defined(VISP_HAVE_SOQT) 107 SoQtExaminerViewer::actualRedraw();
108 #elif defined(VISP_HAVE_SOXT) 109 SoXtExaminerViewer::actualRedraw();
129 #if defined(VISP_HAVE_SOWIN) || defined(VISP_HAVE_SOQT) 139 #if defined(VISP_HAVE_SOWIN) 140 HWND parent = getParentWidget();
142 RECT rcClient, rcWindow;
144 GetClientRect(parent, &rcClient);
145 GetWindowRect(parent, &rcWindow);
146 ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
147 ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
148 MoveWindow(parent, rcWindow.left, rcWindow.top, x + ptDiff.x, y + ptDiff.y, TRUE);
150 DWORD dwStyle = GetWindowLong(parent, GWL_STYLE);
151 dwStyle &= ~(WS_SIZEBOX);
152 SetWindowLong(parent, GWL_STYLE, dwStyle);
154 #elif defined(VISP_HAVE_SOQT) 156 QWidget *parent = getParentWidget();
157 parent->setFixedSize(x, y);
170 SbBool vpViewer::processSoEvent(
const SoEvent *
const event)
172 if (this->isViewing() && event->getTypeId() == SoKeyboardEvent::getClassTypeId()) {
173 SoKeyboardEvent *kbevent = (SoKeyboardEvent *)event;
174 switch (kbevent->getKey()) {
175 case SoKeyboardEvent::H:
176 if (kbevent->getState() == SoButtonEvent::DOWN) {
177 std::cout <<
"H : this help " << std::endl;
178 std::cout <<
"M : get and save the external camera location (matrix)" << std::endl;
179 std::cout <<
"V : get and save the external camera location (vector)" << std::endl;
180 std::cout <<
"M : load camera location (vector)" << std::endl;
181 std::cout <<
"P : get external camera location and set the internal one" << std::endl;
185 case SoKeyboardEvent::M:
186 if (kbevent->getState() == SoButtonEvent::DOWN) {
189 std::ofstream f(
"cMf.dat");
194 case SoKeyboardEvent::V:
195 if (kbevent->getState() == SoButtonEvent::DOWN) {
199 std::ofstream f(
"vcMf.dat");
204 case SoKeyboardEvent::L:
205 if (kbevent->getState() == SoButtonEvent::DOWN) {
207 std::ifstream f(
"vcMf.dat");
215 case SoKeyboardEvent::P:
216 if (kbevent->getState() == SoButtonEvent::DOWN) {
229 #if defined(VISP_HAVE_SOWIN) 230 return SoWinExaminerViewer::processSoEvent(event);
231 #elif defined(VISP_HAVE_SOQT) 232 return SoQtExaminerViewer::processSoEvent(event);
233 #elif defined(VISP_HAVE_SOXT) 234 return SoXtExaminerViewer::processSoEvent(event);
238 #elif !defined(VISP_BUILD_SHARED_LIBS) 240 void dummy_vpViewer(){};
void load(std::ifstream &f)
void resize(int x, int y, bool fixed=false)
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
void save(std::ofstream &f) const
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.
vpViewer(HWND parent, vpSimulator *simu, vpViewerType type)
unsigned int getInternalWidth() const