61 #include <ACG/GL/acg_glew.hh> 63 #include "QtBaseViewer.hh" 64 #include "QtGLGraphicsScene.hh" 65 #include "QtGLGraphicsView.hh" 66 #include "QtSceneGraphWidget.hh" 70 #include <QToolButton> 73 #include <QApplication> 74 #include <QPushButton> 76 #include <QColorDialog> 77 #include <QFileDialog> 80 #include <QDesktopWidget> 81 #include <QButtonGroup> 83 #include <QGraphicsWidget> 84 #include <QGraphicsGridLayout> 85 #include <QGraphicsProxyWidget> 91 #include "set_home.xpm" 92 #include "viewall.xpm" 96 #include "scenegraph.xpm" 100 #define homeIcon home_xpm 101 #define sethomeIcon set_home_xpm 102 #define moveIcon move_xpm 103 #define lightIcon light_xpm 104 #define questionIcon info_xpm 105 #define viewallIcon viewall_xpm 106 #define pickIcon pick_xpm 107 #define perspectiveIcon persp_xpm 108 #define orthoIcon ortho_xpm 109 #define sceneGraphIcon scenegraph_xpm 110 #define monoIcon mono_xpm 125 namespace QtWidgets {
130 static const char VIEW_MAGIC[] =
131 "ACG::QtWidgets::QGLViewerWidget encoded view";
138 QStatusBar *_statusBar,
139 const QGLFormat* _format,
144 glareaGrabbed_(false),
145 updateLocked_(false),
146 projectionUpdateLocked_(false),
148 sceneGraphDialog_(0),
150 privateStatusBar_(0),
151 disableKeyHandling_(false),
152 externalDrag_(false),
153 snapshotName_(
"snap.png"),
158 renderPicking_(false),
163 if ( !QGLFormat::hasOpenGL() )
165 std::cerr <<
"This system has no OpenGL support.\n";
171 createWidgets(_format,_statusBar,_share);
198 backFaceCulling_ =
false;
199 twoSidedLighting_ =
false;
208 popupEnabled_ =
true;
232 for (
int i=6666; i<6676; ++i)
235 std::cout <<
"listen on port " << i <<
"\n";
249 action_.insert(
"Background",
new QAction(
"Background color",
this ) );
250 action_.insert(
"Snapshot",
new QAction(
"Snapshot",
this ) );
251 action_.insert(
"SnapshotName",
new QAction(
"Set snapshot name",
this ) );
252 action_.insert(
"SnapshotSavesView",
new QAction(
"Snapshot saves view",
this ) );
253 action_.insert(
"CopyView",
new QAction(
"Copy view",
this ) );
254 action_.insert(
"PasteView",
new QAction(
"Paste view",
this ) );
255 action_.insert(
"PasteDropSize",
new QAction(
"Paste/Drop effects size",
this ) );
256 action_.insert(
"Synchronize",
new QAction(
"Synchronize",
this ) );
257 action_.insert(
"Animation",
new QAction(
"Animation",
this ) );
258 action_.insert(
"BackfaceCulling",
new QAction(
"Backface culling",
this ) );
259 action_.insert(
"TwoSidedLighting",
new QAction(
"Two-sided lighting",
this ) );
261 connect( action_[
"Background"], SIGNAL( triggered() ),
262 this, SLOT( actionBackground() ) );
263 connect( action_[
"Snapshot"], SIGNAL( triggered() ),
265 connect( action_[
"SnapshotName"], SIGNAL( triggered() ),
267 connect( action_[
"SnapshotSavesView"], SIGNAL( triggered() ),
269 connect( action_[
"CopyView"], SIGNAL( triggered() ),
270 this, SLOT( actionCopyView() ) );
271 connect( action_[
"PasteView"], SIGNAL( triggered() ),
272 this, SLOT( actionPasteView() ) );
273 connect( action_[
"PasteDropSize"], SIGNAL( triggered() ),
274 this, SLOT( actionPasteDropSize() ) );
275 connect( action_[
"Synchronize"], SIGNAL( triggered() ),
276 this, SLOT( actionSynchronize() ) );
277 connect( action_[
"Animation"], SIGNAL( triggered() ),
278 this, SLOT( actionAnimation() ) );
279 connect( action_[
"BackfaceCulling"], SIGNAL( triggered() ),
280 this, SLOT( actionBackfaceCulling() ) );
281 connect( action_[
"TwoSidedLighting"], SIGNAL( triggered() ),
282 this, SLOT( actionTwoSidedLighting() ) );
284 action_[
"SnapshotSavesView"]->setCheckable(
true );
285 action_[
"PasteDropSize"]->setCheckable(
true );
286 action_[
"Synchronize"]->setCheckable(
true );
287 action_[
"Animation"]->setCheckable(
true );
288 action_[
"BackfaceCulling"]->setCheckable(
true );
289 action_[
"TwoSidedLighting"]->setCheckable(
true );
292 QSizePolicy sp = sizePolicy();
293 sp.setHorizontalPolicy( QSizePolicy::Expanding );
294 sp.setVerticalPolicy( QSizePolicy::Expanding );
295 sp.setHorizontalStretch( 1 );
296 sp.setVerticalStretch( 1 );
299 redrawTime_.start ();
309 delete privateStatusBar_;
312 delete sceneGraphDialog_;
322 QtBaseViewer::sizeHint()
const 324 return QSize( 600, 600 );
335 if (privateStatusBar_==0)
336 privateStatusBar_=
new QStatusBar(
this);
337 statusbar_=privateStatusBar_;
339 privateStatusBar_->show();
341 privateStatusBar_->hide();
356 else if (privateStatusBar_!=0)
357 privateStatusBar_->hide();
360 else buttonBar_->hide();
362 else pickButton_->hide();
364 else questionButton_->hide();
366 else wheelX_->hide();
368 else wheelY_->hide();
370 else wheelZ_->hide();
378 glWidget_->makeCurrent();
382 glWidget_->swapBuffers();
391 sceneGraphRoot_ = _root;
408 if ( ( bbmin[0] > bbmax[0] ) ||
409 ( bbmin[1] > bbmax[1] ) ||
410 ( bbmin[2] > bbmax[2] ) )
414 ( bbmax - bbmin ).norm() * 0.5 );
428 updateLocked_ =
true;
436 updateLocked_ =
false;
452 trackMouse_ = _track;
461 popupEnabled_ = _enable;
463 if ( popupEnabled_ ) {
464 glView_->setContextMenuPolicy( Qt::DefaultContextMenu );
466 glView_->setContextMenuPolicy( Qt::CustomContextMenu );
507 projectionButton_->setIcon( QPixmap(orthoIcon) );
509 projectionButton_->setIcon( QPixmap(perspectiveIcon) );
526 emit navigationModeChanged(
true );
528 emit navigationModeChanged(
false );
534 if( projectionUpdateLocked_ )
563 glstate_->
ortho( -orthoWidth_, orthoWidth_,
564 -orthoWidth_/aspect, orthoWidth_/aspect,
577 scene_center_ = trackball_center_ = _center;
580 scene_radius_ = trackball_radius_ = _radius;
582 orthoWidth_ = 2.0 * scene_radius_;
587 far_ = std::max(0.0002f * scene_radius_, -(c[2] - scene_radius_));
590 near_ = std::max(0.0001f * scene_radius_, -(c[2] + scene_radius_));
601 scene_center_ = trackball_center_ = _center;
610 ACG::Vec3d eye = scene_center_ - _dir*(3.0*scene_radius_);
633 moveButton_->setDown(
false);
634 lightButton_->setDown(
false);
635 pickButton_->setDown(
false);
636 questionButton_->setDown(
false);
641 if (_am != actionMode_)
643 lastActionMode_ = actionMode_;
652 glView_->setCursor(Qt::PointingHandCursor);
653 glBase_->setCursor(Qt::PointingHandCursor);
654 moveButton_->setDown(
true);
661 glView_->setCursor(Qt::PointingHandCursor);
662 glBase_->setCursor(Qt::PointingHandCursor);
663 lightButton_->setDown(
true);
670 glView_->setCursor(Qt::ArrowCursor);
671 glBase_->setCursor(Qt::ArrowCursor);
672 pickButton_->setDown(
true);
685 glView_->setCursor(Qt::WhatsThisCursor);
686 glBase_->setCursor(Qt::WhatsThisCursor);
687 questionButton_->setDown(
true);
710 switch ( faceOrientation_ = _ori ) {
712 glFrontFace( GL_CCW );
716 glFrontFace( GL_CW );
730 if (funcMenu_==0) updatePopupMenu();
731 if ( (backFaceCulling_ = _b) )
736 action_[
"BackfaceCulling"]->setChecked( backFaceCulling_ );
744 if (funcMenu_==0) updatePopupMenu();
746 action_[
"TwoSidedLighting"]->setChecked(twoSidedLighting_);
754 if (funcMenu_==0) updatePopupMenu();
756 action_[
"Animation"]->setChecked( animation_ );
768 switch(normalsMode_ = _mode)
788 unsigned int ,
unsigned int ,
789 unsigned int ,
unsigned int ,
793 _image = glWidget_->grabFrameBuffer(
true);
821 void QtBaseViewer::drawScene()
834 far_ = std::max(0.0002f * scene_radius_, -(c[2] - scene_radius_));
837 near_ = std::max(0.0001f * scene_radius_, -(c[2] + scene_radius_));
847 if (
stereo_) drawScene_stereo();
848 else drawScene_mono();
852 frame_time_ = timer.elapsed();
859 void QtBaseViewer::drawScene_mono()
880 glClear(GL_DEPTH_BUFFER_BIT);
896 QtBaseViewer::drawScene_stereo()
898 double l, r, t, b, w, h, a, radians, wd2, ndfl;
904 radians = fovy_ * 0.5 / 180.0 * M_PI;
905 wd2 = near_ * tan(radians);
914 double offset2 = offset * ndfl;
919 glMatrixMode(GL_PROJECTION);
921 glFrustum(l+offset2, r+offset2, b, t, near_, far_);
922 glTranslatef(-offset, 0.0, 0.0);
923 glMatrixMode(GL_MODELVIEW);
925 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
930 glMatrixMode(GL_PROJECTION);
932 glFrustum(l-offset2, r-offset2, b, t, near_, far_);
933 glTranslatef(offset, 0.0, 0.0);
934 glMatrixMode(GL_MODELVIEW);
936 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
950 homeOrthoWidth_ = orthoWidth_;
951 home_center_ = trackball_center_;
952 home_radius_ = trackball_radius_;
959 glstate_->
set_modelview(home_modelview_, home_inverse_modelview_);
960 orthoWidth_ = homeOrthoWidth_;
961 trackball_center_ = home_center_;
962 trackball_radius_ = home_radius_;
982 -
Vec3d(0.0, 0.0, 3.0*scene_radius_ ));
984 orthoWidth_ = 1.1*scene_radius_;
986 if (aspect > 1.0) orthoWidth_ *= aspect;
1004 unsigned int nodeIdx, targetIdx;
1012 Vec3d t = hitPoint - eye;
1013 Vec3d e = eye + t * (_move_back ? -0.5f : 0.5f);
1014 flyTo(e, hitPoint, 300);
1019 orthoWidth_ *= _move_back ? 2.0 : 0.5;
1023 trackball_center_ = hitPoint;
1043 const Vec3d& _center,
1051 Vec3d view =(p-c).normalize();
1053 Vec3d axis = (z % -view).normalize();
1054 double angle = acos(std::max(-1.0,
1056 (z | view)))) / M_PI * 180.0;
1059 axis =
Vec3d(0,1,0);
1064 Vec3d trans ( -target[0],
1066 -target[2] - (_position-_center).norm() );
1071 unsigned int frames = (
unsigned int)(_time / frame_time_);
1072 if (frames > 1000) frames=1000;
1080 Vec3d t = trans / (double)frames;
1081 double a = angle / (double)frames;
1083 for (
unsigned int i=0; i<frames; ++i)
1086 if (fabs(a) > FLT_MIN)
1087 rotate(axis, a, _center);
1098 if (fabs(angle) > FLT_MIN)
1099 rotate(axis, angle, _center);
1105 trackball_center_ = _center;
1106 trackball_radius_ = std::max(scene_radius_,
1107 (_center-_position).norm()*0.9f);
1161 scene_center_ = trackball_center_ =
Vec3d( 0.0, 0.0, 0.0 );
1162 scene_radius_ = trackball_radius_ = 1.0;
1172 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
1173 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
1174 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
1175 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1176 glPixelStorei(GL_PACK_ROW_LENGTH, 0);
1177 glPixelStorei(GL_PACK_SKIP_ROWS, 0);
1178 glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
1179 glPixelStorei(GL_PACK_ALIGNMENT, 1);
1198 glMatrixMode(GL_MODELVIEW);
1201 glMultMatrixd(light_matrix_.data());
1203 GLfloat pos[4], col[4];
1205 col[0] = col[1] = col[2] = 0.7f;
1206 pos[3] = col[3] = 0.0f;
1208 #define SET_LIGHT(i,x,y,z) { \ 1209 pos[0]=x; pos[1]=y; pos[2]=z; \ 1210 glLightfv(GL_LIGHT##i, GL_POSITION, pos); \ 1211 glLightfv(GL_LIGHT##i, GL_DIFFUSE, col); \ 1212 glLightfv(GL_LIGHT##i, GL_SPECULAR, col); \ 1213 ACG::GLState::enable(GL_LIGHT##i); \ 1216 SET_LIGHT(0, 0.0f, 0.0f, 1.0f);
1217 SET_LIGHT(1, -1.0f, 1.0f, 0.7f);
1218 SET_LIGHT(2, 1.0f, 1.0f, 0.7f);
1220 col[0] = col[1] = col[2] = 0.3f; col[3] = 1.0f;
1221 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
1229 light_matrix_.
rotate(_angle, _axis[0], _axis[1], _axis[2], MULT_FROM_LEFT);
1239 static bool initialized =
false;
1258 scene_center_ = trackball_center_ =
Vec3d( 0.0, 0.0, 0.0 );
1259 scene_radius_ = trackball_radius_ = 1.0;
1267 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
1268 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
1269 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
1270 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1271 glPixelStorei(GL_PACK_ROW_LENGTH, 0);
1272 glPixelStorei(GL_PACK_SKIP_ROWS, 0);
1273 glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
1274 glPixelStorei(GL_PACK_ALIGNMENT, 1);
1289 glPushAttrib (GL_ALL_ATTRIB_BITS);
1296 glMatrixMode(GL_PROJECTION);
1299 glMatrixMode(GL_MODELVIEW);
1312 glColor4f(1.0,0.0,0.0,1.0);
1316 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1325 glMatrixMode(GL_PROJECTION);
1353 _view += QString(VIEW_MAGIC) +
"\n";
1354 _view += QString::number(m(0,0)) +
" " + QString::number(m(0,1)) +
" " + QString::number(m(0,2)) +
" " + QString::number(m(0,3)) +
"\n";
1355 _view += QString::number(m(1,0)) +
" " + QString::number(m(1,1)) +
" " + QString::number(m(1,2)) +
" " + QString::number(m(1,3)) +
"\n";
1356 _view += QString::number(m(2,0)) +
" " + QString::number(m(2,1)) +
" " + QString::number(m(2,2)) +
" " + QString::number(m(2,3)) +
"\n";
1357 _view += QString::number(m(3,0)) +
" " + QString::number(m(3,1)) +
" " + QString::number(m(3,2)) +
" " + QString::number(m(3,3)) +
"\n";
1360 _view += QString::number(p(0,0)) +
" " + QString::number(p(0,1)) +
" " + QString::number(p(0,2)) +
" " + QString::number(p(0,3)) +
"\n";
1361 _view += QString::number(p(1,0)) +
" " + QString::number(p(1,1)) +
" " + QString::number(p(1,2)) +
" " + QString::number(p(1,3)) +
"\n";
1362 _view += QString::number(p(2,0)) +
" " + QString::number(p(2,1)) +
" " + QString::number(p(2,2)) +
" " + QString::number(p(2,3)) +
"\n";
1363 _view += QString::number(p(3,0)) +
" " + QString::number(p(3,1)) +
" " + QString::number(p(3,2)) +
" " + QString::number(p(3,3)) +
"\n";
1366 _view += QString::number(
glWidth()) +
" " + QString::number(
glHeight()) +
" " + QString::number(projectionMode_) +
" " + QString::number(orthoWidth_) +
"\n";
1375 if (_view.left(
sizeof(VIEW_MAGIC)-1) != QString(VIEW_MAGIC))
1379 QString temp = _view;
1380 temp.remove(0,
sizeof(VIEW_MAGIC));
1383 QStringList split = temp.split(QRegExp(
"[\\n\\s]"),QString::SkipEmptyParts);
1389 if ( split.size() != 36 ) {
1390 std::cerr <<
"Unable to paste view ... wrong parameter count!! is" << split.size() << std::endl;
1397 m(0,0) = split[0].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1398 m(0,1) = split[1].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1399 m(0,2) = split[2].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1400 m(0,3) = split[3].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1401 m(1,0) = split[4].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1402 m(1,1) = split[5].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1403 m(1,2) = split[6].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1404 m(1,3) = split[7].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1405 m(2,0) = split[8].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1406 m(2,1) = split[9].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1407 m(2,2) = split[10].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1408 m(2,3) = split[11].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1409 m(3,0) = split[12].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1410 m(3,1) = split[13].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1411 m(3,2) = split[14].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1412 m(3,3) = split[15].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1413 p(0,0) = split[16].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1414 p(0,1) = split[17].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1415 p(0,2) = split[18].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1416 p(0,3) = split[19].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1417 p(1,0) = split[20].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1418 p(1,1) = split[21].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1419 p(1,2) = split[22].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1420 p(1,3) = split[23].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1421 p(2,0) = split[24].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1422 p(2,1) = split[25].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1423 p(2,2) = split[26].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1424 p(2,3) = split[27].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1425 p(3,0) = split[28].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1426 p(3,1) = split[29].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1427 p(3,2) = split[30].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1428 p(3,3) = split[31].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1430 w = split[32].toInt(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1431 h = split[33].toInt(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1432 pMode = split[34].toInt(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1433 orthoWidth_ = split[35].toDouble(&ok);
if ( !ok ) { std::cerr <<
"Error in decoding View!" << std::endl;
return false; }
1447 action_[
"PasteDropSize"]->isChecked() )
1450 glView_->setFixedSize(w,h);
1465 void QtBaseViewer::actionDrawMenu( QAction * _action )
1470 if (qApp->keyboardModifiers() & Qt::ShiftModifier)
1482 std::vector< QAction * >::iterator aIter, aEnd;
1484 aEnd = drawMenuActions_.end();
1485 for( aIter = drawMenuActions_.begin();
1490 (*aIter)->setChecked(
false );
1504 void QtBaseViewer::actionBackground()
1507 QColor backCol((
int)bc[0], (
int)bc[1], (
int)bc[2]);
1508 QColor c = QColorDialog::getColor(backCol,
this);
1509 if (c != backCol && c.isValid())
1511 ((
double) c.green()) / 255.0,
1512 ((
double) c.blue()) / 255.0,
1520 void QtBaseViewer::actionCopyView()
1523 QApplication::clipboard()->setText(view);
1530 void QtBaseViewer::actionPasteView()
1532 QString view; view=QApplication::clipboard()->text();
1540 void QtBaseViewer::actionPasteDropSize()
1547 void QtBaseViewer::actionSynchronize()
1554 void QtBaseViewer::actionSynchronize(
bool _enable)
1565 void QtBaseViewer::actionAnimation()
1572 void QtBaseViewer::actionAnimation(
bool _enable)
1579 void QtBaseViewer::actionBackfaceCulling()
1586 void QtBaseViewer::actionBackfaceCulling(
bool _enable)
1593 void QtBaseViewer::actionTwoSidedLighting()
1600 void QtBaseViewer::actionTwoSidedLighting(
bool _enable)
1608 QtBaseViewer::createWidgets(
const QGLFormat* _format,
1612 statusbar_=privateStatusBar_=0;
1621 QVBoxLayout* layout=
new QVBoxLayout(
this);
1622 layout->setSpacing( 0 );
1623 layout->setMargin( 0 );
1628 QFrame* work=
new QFrame(
this);
1630 layout->addWidget(work,1);
1634 assert(statusbar_!=0);
1635 if (privateStatusBar_!=0)
1636 layout->addWidget(privateStatusBar_,0);
1640 QGLWidget* share = 0;
1641 if (_share) share = _share->glWidget_;
1644 format.setAlpha(
true);
1645 if (_format!=0) format = *_format;
1647 glWidget_ =
new QGLWidget(format, 0, share);
1651 glView_->setViewport(glWidget_);
1652 glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
1653 glView_->setScene(glScene_);
1654 glView_->setFrameStyle(QFrame::NoFrame);
1656 wheelZ_=
new QtWheel( 0,
"wheel-z",QtWheel::Vertical);
1657 wheelZ_->setMinimumSize(wheelZ_->
sizeHint());
1658 wheelZ_->setMaximumSize(wheelZ_->
sizeHint());
1659 connect(wheelZ_,SIGNAL(angleChangedBy(
double)),
1661 wheelZ_->setToolTip(
"Translate along <b>z-axis</b>.");
1662 wheelZ_->setWhatsThis(
"Translate along <b>z-axis</b>.");
1666 wheelY_=
new QtWheel( 0,
"wheel-y",QtWheel::Horizontal);
1667 wheelY_->setMinimumSize(wheelY_->
sizeHint());
1668 wheelY_->setMaximumSize(wheelY_->
sizeHint());
1669 connect(wheelY_,SIGNAL(angleChangedBy(
double)),
1671 wheelY_->setToolTip(
"Rotate around <b>y-axis</b>.");
1672 wheelY_->setWhatsThis(
"Rotate around <b>y-axis</b>.");
1676 wheelX_=
new QtWheel( 0,
"wheel-x",QtWheel::Vertical);
1677 wheelX_->setMinimumSize(wheelX_->
sizeHint());
1678 wheelX_->setMaximumSize(wheelX_->
sizeHint());
1679 connect(wheelX_,SIGNAL(angleChangedBy(
double)),
1681 wheelX_->setToolTip(
"Rotate around <b>x-axis</b>.");
1682 wheelX_->setWhatsThis(
"Rotate around <b>x-axis</b>.");
1687 QGraphicsWidget *wheelX = glScene_->addWidget (wheelX_);
1688 QGraphicsWidget *wheelY = glScene_->addWidget (wheelY_);
1689 QGraphicsWidget *wheelZ = glScene_->addWidget (wheelZ_);
1691 wheelX_->setWindowOpacity (0.5);
1692 wheelY_->setWindowOpacity (0.5);
1693 wheelZ_->setWindowOpacity (0.5);
1695 wheelX->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
1696 wheelY->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
1697 wheelZ->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
1699 glBaseLayout_ =
new QGraphicsGridLayout;
1700 glBaseLayout_->addItem(wheelX, 1, 0);
1701 glBaseLayout_->addItem(wheelY, 2, 1);
1702 glBaseLayout_->addItem(wheelZ, 1, 3);
1704 glBaseLayout_->setColumnStretchFactor(0,0);
1705 glBaseLayout_->setColumnStretchFactor(1,0);
1706 glBaseLayout_->setColumnStretchFactor(2,1);
1707 glBaseLayout_->setColumnStretchFactor(3,0);
1709 glBaseLayout_->setRowStretchFactor(0,1);
1710 glBaseLayout_->setRowStretchFactor(1,0);
1711 glBaseLayout_->setRowStretchFactor(2,0);
1713 glBase_ =
new QGraphicsWidget;
1714 glBase_->setLayout(glBaseLayout_);
1715 glScene_->addItem(glBase_);
1716 glBase_->setGeometry (glScene_->sceneRect ());
1725 connect( glView_ , SIGNAL( customContextMenuRequested(
const QPoint& ) ) ,
1729 if (format.stereo())
1730 std::cerr <<
"Stereo buffer requested: " 1731 << (glWidget_->format().stereo() ?
"ok\n" :
"failed\n");
1735 buttonBar_=
new QToolBar(
"Viewer Toolbar", work );
1736 buttonBar_->setOrientation(Qt::Vertical);
1738 moveButton_ =
new QToolButton( buttonBar_ );
1739 moveButton_->setIcon( QPixmap(moveIcon) );
1740 moveButton_->setMinimumSize( 16, 16 );
1741 moveButton_->setMaximumSize( 32, 32 );
1742 moveButton_->setToolTip(
"Switch to <b>move</b> mode." );
1743 moveButton_->setWhatsThis(
1744 "Switch to <b>move</b> mode.<br>" 1745 "<ul><li><b>Rotate</b> using <b>left</b> mouse button.</li>" 1746 "<li><b>Translate</b> using <b>middle</b> mouse button.</li>" 1747 "<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" );
1748 QObject::connect( moveButton_, SIGNAL( clicked() ),
1751 buttonBar_->addWidget( moveButton_)->setText(
"Move");
1753 lightButton_ =
new QToolButton( buttonBar_ );
1754 lightButton_->setIcon( QPixmap(lightIcon) );
1755 lightButton_->setMinimumSize( 16, 16 );
1756 lightButton_->setMaximumSize( 32, 32 );
1757 lightButton_->setToolTip(
"Switch to <b>light</b> mode.");
1758 lightButton_->setWhatsThis(
1759 "Switch to <b>light</b> mode.<br>" 1760 "Rotate lights using left mouse button.");
1761 QObject::connect( lightButton_, SIGNAL( clicked() ),
1763 buttonBar_->addWidget( lightButton_)->setText(
"Light");
1766 pickButton_ =
new QToolButton( buttonBar_ );
1767 pickButton_->setIcon( QPixmap(pickIcon) );
1768 pickButton_->setMinimumSize( 16, 16 );
1769 pickButton_->setMaximumSize( 32, 32 );
1770 pickButton_->setToolTip(
"Switch to <b>picking</b> mode.");
1771 pickButton_->setWhatsThis(
1772 "Switch to <b>picking</b> mode.<br>" 1773 "Use picking functions like flipping edges.<br>" 1774 "To change the mode use the right click<br>" 1775 "context menu in the viewer.");
1776 QObject::connect( pickButton_, SIGNAL( clicked() ),
1778 buttonBar_->addWidget( pickButton_)->setText(
"Pick");
1781 questionButton_ =
new QToolButton( buttonBar_ );
1782 questionButton_->setIcon( QPixmap(questionIcon) );
1783 questionButton_->setMinimumSize( 16, 16 );
1784 questionButton_->setMaximumSize( 32, 32 );
1785 questionButton_->setToolTip(
"Switch to <b>identification</b> mode.");
1786 questionButton_->setWhatsThis(
1787 "Switch to <b>identification</b> mode.<br>" 1788 "Use identification mode to get information " 1789 "about objects. Click on an object and see " 1790 "the log output for information about the " 1792 QObject::connect( questionButton_, SIGNAL( clicked() ),
1794 buttonBar_->addWidget( questionButton_)->setText(
"Question");
1796 buttonBar_->addSeparator();
1798 homeButton_ =
new QToolButton( buttonBar_ );
1799 homeButton_->setIcon( QPixmap(homeIcon) );
1800 homeButton_->setMinimumSize( 16, 16 );
1801 homeButton_->setMaximumSize( 32, 32 );
1802 homeButton_->setCheckable(
false );
1803 homeButton_->setToolTip(
"Restore <b>home</b> view.");
1804 homeButton_->setWhatsThis(
1805 "Restore home view<br><br>" 1806 "Resets the view to the home view");
1807 QObject::connect( homeButton_, SIGNAL( clicked() ),
1808 this, SLOT(
home() ) );
1809 buttonBar_->addWidget( homeButton_)->setText(
"Home");
1812 setHomeButton_ =
new QToolButton( buttonBar_ );
1813 setHomeButton_->setIcon( QPixmap(sethomeIcon) );
1814 setHomeButton_->setMinimumSize( 16, 16 );
1815 setHomeButton_->setMaximumSize( 32, 32 );
1816 setHomeButton_->setCheckable(
false );
1817 setHomeButton_->setToolTip(
"Set <b>home</b> view");
1818 setHomeButton_->setWhatsThis(
1819 "Store home view<br><br>" 1820 "Stores the current view as the home view");
1821 QObject::connect( setHomeButton_, SIGNAL( clicked() ),
1823 buttonBar_->addWidget( setHomeButton_)->setText(
"Set Home");
1826 viewAllButton_ =
new QToolButton( buttonBar_ );
1827 viewAllButton_->setIcon( QPixmap(viewallIcon) );
1828 viewAllButton_->setMinimumSize( 16, 16 );
1829 viewAllButton_->setMaximumSize( 32, 32 );
1830 viewAllButton_->setCheckable(
false );
1831 viewAllButton_->setToolTip(
"View all.");
1832 viewAllButton_->setWhatsThis(
1834 "Move the objects in the scene so that" 1835 " the whole scene is visible.");
1836 QObject::connect( viewAllButton_, SIGNAL( clicked() ),
1838 buttonBar_->addWidget( viewAllButton_)->setText(
"View all");
1841 projectionButton_ =
new QToolButton( buttonBar_ );
1842 projectionButton_->setIcon( QPixmap(perspectiveIcon) );
1843 projectionButton_->setMinimumSize( 16, 16 );
1844 projectionButton_->setMaximumSize( 32, 32 );
1845 projectionButton_->setCheckable(
false );
1846 projectionButton_->setToolTip(
1847 "Switch between <b>perspective</b> and " 1848 "<b>parrallel</b> projection mode.");
1849 projectionButton_->setWhatsThis(
1850 "Switch projection modes<br><br>" 1851 "Switch between <b>perspective</b> and " 1852 "<b>parrallel</b> projection mode.");
1853 QObject::connect( projectionButton_, SIGNAL( clicked() ),
1855 buttonBar_->addWidget( projectionButton_)->setText(
"Projection" );
1858 if (glWidget_->format().stereo())
1860 stereoButton_ =
new QToolButton( buttonBar_ );
1861 stereoButton_->setIcon( QPixmap(monoIcon) );
1862 stereoButton_->setMinimumSize( 16, 16 );
1863 stereoButton_->setMaximumSize( 32, 32 );
1864 stereoButton_->setCheckable(
true );
1865 stereoButton_->setToolTip(
"Toggle stereo viewing");
1866 stereoButton_->setWhatsThis(
1867 "Toggle stereo mode<br><br>" 1868 "Use this button to switch between stereo " 1869 "and mono view. To use this feature you need " 1870 "a stereo capable graphics card and a stereo " 1871 "display/projection system.");
1872 QObject::connect( stereoButton_, SIGNAL( clicked() ),
1874 buttonBar_->addWidget( stereoButton_)->setText(
"Stereo");
1877 buttonBar_->addSeparator();
1879 sceneGraphButton_ =
new QToolButton( buttonBar_ );
1880 sceneGraphButton_->setIcon( QPixmap(sceneGraphIcon) );
1881 sceneGraphButton_->setMinimumSize( 16, 16 );
1882 sceneGraphButton_->setMaximumSize( 32, 32 );
1883 sceneGraphButton_->setCheckable(
false );
1884 sceneGraphButton_->setToolTip(
"Toggle scene graph viewer.");
1885 sceneGraphButton_->setWhatsThis(
1886 "Toggle scene graph viewer<br><br>" 1887 "The scene graph viewer enables you to examine the " 1888 "displayed scene graph and to modify certain nodes.<br><br>" 1889 "There are three modi for the scene graph viewer:" 1890 "<ul><li><b>hidden</b></li>" 1891 "<li><b>split</b>: share space</li>" 1892 "<li><b>dialog</b>: own dialog window</li></ul>" 1893 "This button toggles between these modi.");
1894 QObject::connect( sceneGraphButton_, SIGNAL( clicked() ),
1896 buttonBar_->addWidget( sceneGraphButton_)->setText(
"SceneGraph" );
1898 glLayout_ =
new QGridLayout(work);
1899 glLayout_->setSpacing( 0 );
1900 glLayout_->setMargin( 0 );
1902 glLayout_->addWidget(glView_, 0,0);
1903 glLayout_->addWidget(buttonBar_, 0,1);
1905 glLayout_->setColumnStretch(0,1);
1906 glLayout_->setColumnStretch(1,0);
1917 void QtBaseViewer::updatePopupMenu()
1925 drawMenu_ =
new QMenu(
this );
1926 connect( drawMenu_, SIGNAL( aboutToHide() ),
1927 this, SLOT( hidePopupMenus() ) );
1931 QActionGroup * drawGroup =
new QActionGroup(
this );
1932 drawGroup->setExclusive(
false );
1933 connect( drawGroup, SIGNAL( triggered( QAction * ) ),
1934 this, SLOT( actionDrawMenu( QAction * ) ) );
1938 drawMenuActions_.clear();
1940 std::vector< SceneGraph::DrawModes::DrawMode > draw_mode_id;
1944 for (
unsigned int i = 0; i < draw_mode_id.size(); ++i )
1947 std::string descr =
id.description();
1949 QAction * action =
new QAction( descr.c_str(), drawGroup );
1950 action->setData( QVariant( quint64(
id.getIndex() ) ) );
1951 action->setCheckable(
true );
1953 drawMenuActions_.push_back( action );
1958 drawMenu_->addActions( drawGroup->actions() );
1965 funcMenu_=
new QMenu(
this );
1967 funcMenu_->addAction( action_[
"Background" ] );
1968 funcMenu_->addSeparator();
1969 funcMenu_->addAction( action_[
"Snapshot" ] );
1970 funcMenu_->addAction( action_[
"SnapshotName" ] );
1971 funcMenu_->addAction( action_[
"SnapshotSavesView" ] );
1972 funcMenu_->addSeparator();
1973 funcMenu_->addAction( action_[
"CopyView" ] );
1974 funcMenu_->addAction( action_[
"PasteView" ] );
1975 funcMenu_->addAction( action_[
"PasteDropSize" ] );
1976 funcMenu_->addSeparator();
1977 funcMenu_->addAction( action_[
"Synchronize" ] );
1978 funcMenu_->addSeparator();
1979 funcMenu_->addAction( action_[
"Animation" ] );
1980 funcMenu_->addAction( action_[
"BackfaceCulling" ] );
1981 funcMenu_->addAction( action_[
"TwoSidedLighting" ] );
1983 connect( funcMenu_, SIGNAL( aboutToHide() ),
1984 this, SLOT( hidePopupMenus() ) );
1994 void QtBaseViewer::hidePopupMenus()
1998 drawMenu_->blockSignals(
true);
2000 drawMenu_->blockSignals(
false);
2005 funcMenu_->blockSignals(
true);
2007 funcMenu_->blockSignals(
false);
2012 pickMenu_->blockSignals(
true);
2014 pickMenu_->blockSignals(
false);
2025 glstate_->
translate(_trans[0], _trans[1], _trans[2], MULT_FROM_LEFT);
2044 const Vec3d& _center)
2048 glstate_->
translate(-t[0], -t[1], -t[2], MULT_FROM_LEFT);
2049 glstate_->
rotate(_angle, _axis[0], _axis[1], _axis[2], MULT_FROM_LEFT);
2050 glstate_->
translate( t[0], t[1], t[2], MULT_FROM_LEFT);
2060 return glView_->width();
2063 return glView_->height();
2066 return glView_->size();
2069 return glView_->mapFromGlobal(_pos);
2073 return glView_->mapToGlobal(_pos);
2083 if (sceneGraphRoot_)
2085 if (!sceneGraphDialog_)
2094 connect(sceneGraphDialog_,
2100 sceneGraphDialog_->show();
2143 double dz=_dist*0.5/M_PI*scene_radius_*2.0;
2158 glBase_->setGeometry (rect);
2164 void QtBaseViewer::grabGLArea()
2166 glareaGrabbed_ =
true;
2168 glView_->setCursor(Qt::BlankCursor);
2169 glBase_->setCursor(Qt::BlankCursor);
2170 glView_->grabMouse();
2171 glView_->grabKeyboard();
2174 void QtBaseViewer::releaseGLArea()
2176 glareaGrabbed_ =
false;
2178 glView_->releaseMouse();
2179 glView_->releaseKeyboard();
2180 glView_->setCursor(Qt::ArrowCursor);
2181 glBase_->setCursor(Qt::ArrowCursor);
2193 QPoint cpos(QCursor::pos()), dpos, fpos, ppos;
2194 int offset = 10, dw, dh, fw, fh, pw, ph;
2195 int minx, maxx, miny, maxy;
2200 # define WIDTH width() 2201 # define HEIGHT height() 2203 # define WIDTH sizeHint().width() 2204 # define HEIGHT sizeHint().height() 2212 dw = drawMenu_->WIDTH;
2213 dh = drawMenu_->HEIGHT;
2214 dpos = cpos + QPoint(offset, offset);
2218 dpos = cpos; dw=dh=0;
2226 fw = funcMenu_->WIDTH;
2227 fh = funcMenu_->HEIGHT;
2228 fpos = cpos + QPoint(offset, -offset-fh);
2232 fpos = cpos; fw=fh=0;
2240 pw = pickMenu_->WIDTH;
2241 ph = pickMenu_->HEIGHT;
2242 ppos = cpos + QPoint(-offset-pw, -ph/2);
2246 ppos = cpos; pw=ph=0;
2252 minx = std::min(dpos.x(), std::min(fpos.x(), ppos.x()));
2253 maxx = std::max(dpos.x()+dw, std::max(fpos.x()+fw, ppos.x()+pw));
2254 miny = std::min(dpos.y(), std::min(fpos.y(), ppos.y()));
2255 maxy = std::max(dpos.y()+dh, std::max(fpos.y()+fh, ppos.y()+ph));
2262 else if (maxx >= qApp->desktop()->width())
2264 dx = qApp->desktop()->width() - maxx;
2271 else if (maxy >= qApp->desktop()->height())
2273 dy = qApp->desktop()->height() - maxy;
2277 dpos += QPoint(dx, dy);
2278 fpos += QPoint(dx, dy);
2279 ppos += QPoint(dx, dy);
2284 bool animate_menu = qApp->isEffectEnabled(Qt::UI_AnimateMenu);
2285 bool fade_menu = qApp->isEffectEnabled(Qt::UI_FadeMenu);
2286 if (animate_menu) qApp->setEffectEnabled(Qt::UI_AnimateMenu,
false);
2287 if (fade_menu) qApp->setEffectEnabled(Qt::UI_FadeMenu,
false);
2295 drawMenu_->popup(dpos);
2299 funcMenu_->popup(fpos);
2302 pickMenu_->popup(ppos);
2306 if (animate_menu) qApp->setEffectEnabled(Qt::UI_AnimateMenu,
true);
2307 if (fade_menu) qApp->setEffectEnabled(Qt::UI_FadeMenu,
true);
2321 if (_event->button() == Qt::RightButton && popupEnabled_)
2327 switch (actionMode_)
2330 if ((_event->modifiers() & Qt::ControlModifier))
2362 switch (actionMode_)
2389 switch ( actionMode_ )
2402 if ((_event->buttons() & (Qt::LeftButton | Qt::MidButton | Qt::RightButton))
2428 if (_event->button() != Qt::RightButton ||
2431 switch ( actionMode_ )
2455 isRotating_ =
false;
2464 switch ( actionMode_ )
2478 isRotating_ =
false;
2488 pickMenu_ =
new QMenu( 0 );
2489 connect( pickMenu_, SIGNAL( aboutToHide() ),
2490 this, SLOT( hidePopupMenus() ) );
2492 QActionGroup * ag =
new QActionGroup( pickMenu_ );
2493 ag->setExclusive(
true );
2495 for (
unsigned int i=0; i<
pick_modes_.size(); ++i) {
2502 pickMenu_->addSeparator();
2506 QAction * ac =
new QAction(
pick_modes_[i].name.c_str(), ag );
2507 ac->setData( QVariant( i ) );
2508 ac->setCheckable(
true );
2511 ac->setChecked(
true );
2513 pickMenu_->addAction( ac );
2517 connect( ag, SIGNAL( triggered( QAction * ) ),
2518 this, SLOT( actionPickMenu( QAction * ) ));
2524 void QtBaseViewer::actionPickMenu( QAction * _action )
2526 int _id = _action->data().toInt();
2544 glLayout_->removeWidget( buttonBar_ );
2558 glstate_->
translate(dir[0], dir[1], dir[2]);
2572 glstate_->
translate(dir[0], dir[1], dir[2]);
2586 glstate_->
translate(dir[0], dir[1], dir[2]);
2600 glstate_->
translate(dir[0], dir[1], dir[2]);
static void enable(GLenum _cap)
replaces glEnable, but supports locking
void sync_send(const GLMatrixd &_modelview, const GLMatrixd &_inverse_modelview)
synchronized with different viewer?
virtual void viewWheelEvent(QWheelEvent *_event)=0
specialized viewer: handle wheel events
Vec4f backgroundColor()
get background color
std::vector< PickMode > pick_modes_
void viewChanged()
This signal is emitted whenever the view is changed by the user.
const Vec4f & clear_color() const
get background color
QToolBar * getToolBar()
Returns a pointer to the Toolbar.
GLState & glState()
get OpenGL state
virtual void toggleNavigationMode()
toggle navigation mode
void strafeLeft()
First person navigation: Strafe left.
void setState()
set the whole stored gl state
virtual void perspectiveProjection()
set perspective view (projectionMode(PERSPECTIVE_PROJECTION))
bool isUpdateLocked() const
VectorT< T, 3 > transform_point(const VectorT< T, 3 > &_v) const
transform point (x',y',z',1) = M * (x,y,z,1)
double eyeDist_
Set eye distance for stereo.
ProjectionMode
projection mode
QPoint glMapToGlobal(const QPoint &_pos) const
map glarea coords to global coords
void initModelviewMatrix()
initialize modelview matrix to identity
void set_twosided_lighting(bool _b)
set whether transparent or solid objects should be drawn
virtual void showSceneGraphDialog()
show scenegraph widget
virtual void questionMode()
calls actionMode() with QuestionMode (cf. ActionMode)
void lookAt(const Vec3d &_eye, const Vec3d &_center, const Vec3d &_up)
set camera by lookAt
VectorT< float, 4 > Vec4f
virtual void sceneRectChanged(const QRectF &rect)
process graphics scene size changes
bool backFaceCulling() const
is backface culling enabled?
virtual void toggleStereoMode()
toggle stereo mode
void signalPickModeChanged(const std::string &)
void setScenePos(const ACG::Vec3d &_center, double _radius, const bool _setCenter=true)
void signalWheelEvent(QWheelEvent *, const std::string &)
Emitted in Pick mode. Uses pick mode.
void actionSnapshotSavesView()
NormalsMode
Automatically normalize normals?
void updateProjectionMatrix()
updates projection matrix
virtual void startDrag()
drag & drop for modelview copying
void encodeView(QString &_view)
convert current view to text representation
void translate(const Vec3d &trans)
translate the scene and update modelview matrix
void signalActionModeChanged(ACG::QtWidgets::QtBaseViewer::ActionMode _m)
action mode was changed
virtual void lockUpdate()
std::vector< DrawMode > getAtomicDrawModes() const
Separates this drawMode into a list of all separate atomic draw modes.
virtual void setSynchronization(bool _b)
toggle global synchronization
virtual void home()
go to home pos
virtual void glMouseWheelEvent(QWheelEvent *_event)
handle mouse wheel events
void perspective(double _fovY, double _aspect, double _near_plane, double _far_plane)
perspective projection
virtual void toggleProjectionMode()
toggle projection mode
void rotate_lights(Vec3d &_axis, double _angle)
rotete light sources
void strafeRight()
First person navigation: Strafe Right.
void enablePopupMenu(bool _enable)
Enable/disable right button draw mode menu (default: enabled)
use provided normals as is
virtual void resizeGL(int _w, int _h)
handle resize events
void viewingDirection(const ACG::Vec3d &_dir, const ACG::Vec3d &_up)
set the viewing direction
virtual void swapBuffers()
Swaps the screen contents with the off-screen buffer.
bool synchronized_
synchronized with different viewer?
QSize glSize() const
get size of QGLWIdget
bool twoSidedLighting() const
is 2-sided lighing enabled?
void actionSnapshotName()
unsigned int glHeight() const
get height of QGLWidget
void setFovy(double _fovy)
set field of view y
unsigned int glWidth() const
get width of QGLWidget
virtual void initializeGL()
initialize OpenGL states
const Vec3d & bbMin() const
Returns minimum point of the bounding box.
void ortho(double _left, double _right, double _bottom, double _top, double _near_plane, double _far_plane)
orthographic projection
virtual void glMouseMoveEvent(QMouseEvent *_event)
handle mouse move events
ProjectionMode projectionMode() const
get current projection mode
void signalInitializeGL()
emitted when OpenGL stuff can be initialized
void viewport(int _left, int _bottom, int _width, int _height, int _glwidth=0, int _glheight=0)
set viewport (lower left corner, width, height, glcontext width, height)
void signalNodeChanged(ACG::SceneGraph::BaseNode *_node)
scene graph has changed
ACG::SceneGraph::PickTarget pickRendererMode_
void rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
const GLMatrixd & inverse_modelview() const
get inverse modelview matrix
void identity()
setup an identity matrix
virtual void unlockAndUpdate()
void applyOptions(int _options)
Apply ORed Options _options.
Show pick button? Effect only if ShowToolBar!
void moveForward()
First person navigation: Move forward.
virtual void setHome()
set home position
static double deg(double _angle)
maps _angle from radiants to degrees (works also for clip()ped angles)
void signalMouseEvent(QMouseEvent *, const std::string &)
QtBaseViewer(QWidget *_parent=0, const char *_name=0, QStatusBar *_statusBar=0, const QGLFormat *_format=0, const QtBaseViewer *_share=0, Options _options=DefaultOptions)
NavigationMode navigationMode() const
get current navigation mode
virtual void viewMouseEvent(QMouseEvent *_event)=0
specialized viewer: hande mouse events
virtual void updateGL()
Redraw scene. Triggers paint event for updating the view (cf. drawNow()).
void translate(double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
translate by (_x, _y, _z)
QPoint glMapFromGlobal(const QPoint &_pos) const
map global to glarea coords
void signalCustomContextMenuRequested(const QPoint &)
void set_msSinceLastRedraw(unsigned int _ms)
set time passed since last redraw in milliseconds
DrawModes::DrawMode drawModes() const
Get the collected draw modes.
bool animation() const
Is animation enabled?
virtual void glMouseDoubleClickEvent(QMouseEvent *_event)
handle mouse double click events
QToolBar * removeToolBar()
Returns a pointer to the toolbar and removes it from the default position in the examiner widget...
virtual void slotWheelZ(double _dist)
process signals from wheelZ_
void set_modelview(const GLMatrixd &_m)
set modelview
void startDragEvent(QMouseEvent *_event)
virtual void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
connected to scenegraph widget
void setSceneCenter(const ACG::Vec3d &_center)
virtual void slotWheelX(double _dAngle)
process signals from wheelX_
static double clip(double _angle)
void traverse(BaseNode *_node, Action &_action)
virtual void glMouseReleaseEvent(QMouseEvent *_event)
handle mouse release events
virtual void orthographicProjection()
set orthographic view (projectionMode(ORTHOGRAPHIC_PROJECTION))
virtual void unlockUpdate()
Unlock display locked by updateLock().
virtual void lightMouseEvent(QMouseEvent *)
optional: hande mouse events to rotate light
Namespace providing different geometric functions concerning angles.
bool pick(SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, Vec3d *_hitPointPtr=0)
bool synchronization()
synchronized with different viewer?
Show wheel for rotation around x-axis (left)?
virtual void glMousePressEvent(QMouseEvent *_event)
handle mouse press events
virtual void lightMode()
calls actionMode() with LightMode (cf. ActionMode)
void set_projection(const GLMatrixd &_m)
set projection
void rotate(double _angle, double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
rotate around axis (_x, _y, _z) by _angle
static void disable(GLenum _cap)
replaces glDisable, but supports locking
DrawMode NONE
not a valid draw mode
virtual void flyTo(const QPoint &_pos, bool _move_back)
Fly to. Get closer if _move_back=false, get more distant else.
void reset_projection()
reset projection matrix (load identity)
void signalDrawScene(ACG::GLState *_state)
render callback
std::string pick_mode_name_
const Vec3d & bbMax() const
Returns maximum point of the bounding box.
virtual void makeCurrent()
Makes this widget the current widget for OpenGL operations.
void signalMouseEventIdentify(QMouseEvent *)
const GLMatrixd & projection() const
get projection matrix
FaceOrientation
orientation of the faces
ActionMode actionMode() const
get action mode
const std::string & pickMode() const
bool containsAtomicDrawMode(DrawMode _atomicDrawMode) const
Check whether an Atomic DrawMode is active in this draw Mode.
bool add_sync_host(const QString &_name)
add host to synchronize with, given by its name
Show wheel for rotation around y-axis (bottom)?
const GLMatrixd & modelview() const
get modelview matrix
FaceOrientation faceOrientation() const
get face orientation
virtual QSize sizeHint() const
reimplemented
virtual void pickingMode()
void moveBack()
First person navigation: Move back.
QUdpSocket * socket_
socket used for synchronization
bool decodeView(const QString &_view)
virtual void viewAll()
view the whole scene
void rotate(const Vec3d &axis, double angle)
rotate the scene (around its center) and update modelview matrix
SceneGraph::BaseNode * sceneGraph()
Returns: root node of scene graph.
bool stereo_
Set eye distance for stereo.
void updatePickMenu()
update pick mode menu
pick any of the prior targets (should be implemented for all nodes)
void signalSceneGraphChanged(ACG::SceneGraph::BaseNode *_root)
scene graph has changed
NavigationMode
Navigation mode.
void copyToImage(QImage &_image, GLenum _buffer=GL_BACK)
copy current framebuffer to an QImage
NormalsMode normalsMode() const
get treatment of normals
virtual ~QtBaseViewer()
Destructor.
ACG::SceneGraph::DrawModes::DrawMode drawMode()
get current draw mode
Vec3d right() const
get right-vector w.r.t. camera coordinates
void initialize()
initialize all state variables (called by constructor)
virtual void glContextMenuEvent(QContextMenuEvent *_event)
handle mouse press events
void update_lights()
update light position
static void drawBuffer(GLenum _mode)
replaces glDrawBuffer, supports locking
virtual void examineMode()
calls actionMode() with ExamineMode (cf. ActionMode)
virtual void setView(const GLMatrixd &_modelview, const GLMatrixd &_inverse_modelview)
set view, used for synchronizing
void trackMouse(bool _track)
Enable/disable mouse tracking (move events with no button press)
counter clockwise (default)
void setStatusBar(QStatusBar *_sb)
VectorT< double, 3 > Vec3d
Show question button? Effect only if ShowToolBar!
void signalSetView(const GLMatrixd &_modelview, const GLMatrixd &_inverse_modelview)
set view, used for synchronizing (cf. slotSetView())
double focalDist_
Set eye distance for stereo.
void reset_modelview()
reset modelview matrix (load identity)
bool skipNextSync_
Skips the next synch event.
virtual void slotWheelY(double _dAngle)
process signals from wheelX_
virtual void paintGL()
draw the scene. Triggered by updateGL().
Vec3d viewing_direction() const
get viewing ray
ActionMode
How to react on mouse events?
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking