40 #include <visp3/core/vpConfig.h>
42 #ifdef VISP_HAVE_COIN3D_AND_GUI
43 #include <visp3/ar/vpSimulator.h>
44 #include <visp3/ar/vpViewer.h>
46 #include <Inventor/events/SoKeyboardEvent.h>
47 #include <Inventor/nodes/SoEventCallback.h>
50 #if defined(VISP_HAVE_SOWIN)
52 : SoWinExaminerViewer(parent, (char *)nullptr, false), viewerType(type), simu(_simu)
53 #elif defined(VISP_HAVE_SOQT)
55 : SoQtExaminerViewer(parent, (char *)nullptr, false), viewerType(type), simu(_simu)
56 #elif defined(VISP_HAVE_SOXT)
58 : SoXtExaminerViewer(parent, (char *)nullptr, false), viewerType(type), simu(_simu)
64 this->setClearBeforeRender(FALSE, TRUE);
75 const SbViewportRegion vp = this->getViewportRegion();
76 SbVec2s origin = vp.getViewportOriginPixels();
77 SbVec2s size = vp.getViewportSizePixels();
78 glViewport(origin[0], origin[1], size[0], size[1]);
80 const SbColor col = this->getBackgroundColor();
81 glClearColor(col[0], col[1], col[2], 0.0f);
82 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
87 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
95 glEnable(GL_DEPTH_TEST);
96 glClear(GL_DEPTH_BUFFER_BIT);
100 #if defined(VISP_HAVE_SOWIN)
101 SoWinExaminerViewer::actualRedraw();
102 #elif defined(VISP_HAVE_SOQT)
103 SoQtExaminerViewer::actualRedraw();
104 #elif defined(VISP_HAVE_SOXT)
105 SoXtExaminerViewer::actualRedraw();
125 #if defined(VISP_HAVE_SOWIN) || defined(VISP_HAVE_SOQT)
135 #if defined(VISP_HAVE_SOWIN)
136 HWND parent = getParentWidget();
138 RECT rcClient, rcWindow;
140 GetClientRect(parent, &rcClient);
141 GetWindowRect(parent, &rcWindow);
142 ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
143 ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
144 MoveWindow(parent, rcWindow.left, rcWindow.top, x + ptDiff.x, y + ptDiff.y, TRUE);
146 DWORD dwStyle = GetWindowLong(parent, GWL_STYLE);
147 dwStyle &= ~(WS_SIZEBOX);
148 SetWindowLong(parent, GWL_STYLE, dwStyle);
150 #elif defined(VISP_HAVE_SOQT)
152 QWidget *parent = getParentWidget();
153 parent->setFixedSize(x, y);
166 SbBool vpViewer::processSoEvent(
const SoEvent *
const event)
168 if (this->isViewing() && event->getTypeId() == SoKeyboardEvent::getClassTypeId()) {
169 SoKeyboardEvent *kbevent = (SoKeyboardEvent *)event;
170 switch (kbevent->getKey()) {
171 case SoKeyboardEvent::H:
172 if (kbevent->getState() == SoButtonEvent::DOWN) {
173 std::cout <<
"H : this help " << std::endl;
174 std::cout <<
"M : get and save the external camera location (matrix)" << std::endl;
175 std::cout <<
"V : get and save the external camera location (vector)" << std::endl;
176 std::cout <<
"M : load camera location (vector)" << std::endl;
177 std::cout <<
"P : get external camera location and set the internal one" << std::endl;
181 case SoKeyboardEvent::M:
182 if (kbevent->getState() == SoButtonEvent::DOWN) {
185 std::ofstream f(
"cMf.dat");
190 case SoKeyboardEvent::V:
191 if (kbevent->getState() == SoButtonEvent::DOWN) {
195 std::ofstream f(
"vcMf.dat");
200 case SoKeyboardEvent::L:
201 if (kbevent->getState() == SoButtonEvent::DOWN) {
203 std::ifstream f(
"vcMf.dat");
211 case SoKeyboardEvent::P:
212 if (kbevent->getState() == SoButtonEvent::DOWN) {
225 #if defined(VISP_HAVE_SOWIN)
226 return SoWinExaminerViewer::processSoEvent(event);
227 #elif defined(VISP_HAVE_SOQT)
228 return SoQtExaminerViewer::processSoEvent(event);
229 #elif defined(VISP_HAVE_SOXT)
230 return SoXtExaminerViewer::processSoEvent(event);
234 #elif !defined(VISP_BUILD_SHARED_LIBS)
236 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)
vpViewer(HWND parent, vpSimulator *simu, vpViewerType type)
virtual void actualRedraw(void)