Commit 00dd9461 authored by Mike Kremer's avatar Mike Kremer

Seperate trackball setting from scene center setting

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7149 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e72a7865
...@@ -256,7 +256,7 @@ void glViewer::swapBuffers() { ...@@ -256,7 +256,7 @@ void glViewer::swapBuffers() {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root, const bool _setCenter) void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root, const bool _resetTrackBall)
{ {
sceneGraphRoot_ = _root; sceneGraphRoot_ = _root;
...@@ -272,11 +272,11 @@ void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root, const bool _setCente ...@@ -272,11 +272,11 @@ void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root, const bool _setCente
if ( ( bbmin[0] > bbmax[0] ) || if ( ( bbmin[0] > bbmax[0] ) ||
( bbmin[1] > bbmax[1] ) || ( bbmin[1] > bbmax[1] ) ||
( bbmin[2] > bbmax[2] ) ) ( bbmin[2] > bbmax[2] ) )
setScenePos( ACG::Vec3d( 0.0,0.0,0.0 ) , 1.0, _setCenter ); setScenePos( ACG::Vec3d( 0.0,0.0,0.0 ) , 1.0, _resetTrackBall );
else else
setScenePos( ( bbmin + bbmax ) * 0.5, setScenePos( ( bbmin + bbmax ) * 0.5,
( bbmax - bbmin ).norm() * 0.5, ( bbmax - bbmin ).norm() * 0.5,
_setCenter); _resetTrackBall);
} }
updateGL(); updateGL();
...@@ -329,7 +329,7 @@ void glViewer::projectionMode(ProjectionMode _p) ...@@ -329,7 +329,7 @@ void glViewer::projectionMode(ProjectionMode _p)
emit projectionModeChanged( false ); emit projectionModeChanged( false );
updateProjectionMatrix(); updateProjectionMatrix();
emit viewChanged(); emit viewChanged();
} }
...@@ -386,19 +386,21 @@ void glViewer::updateProjectionMatrix() ...@@ -386,19 +386,21 @@ void glViewer::updateProjectionMatrix()
-orthoWidth_/aspect, orthoWidth_/aspect, -orthoWidth_/aspect, orthoWidth_/aspect,
near_, far_ ); near_, far_ );
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void glViewer::setScenePos(const ACG::Vec3d& _center, double _radius, const bool _setCenter) void glViewer::setScenePos(const ACG::Vec3d& _center, double _radius, const bool _resetTrackBall)
{ {
if(_setCenter) { if(_resetTrackBall) {
scene_center_ = trackball_center_ = _center; trackball_center_ = _center;
} }
scene_center_ = _center;
scene_radius_ = trackball_radius_ = _radius; scene_radius_ = trackball_radius_ = _radius;
ACG::Vec3d c = glstate_->modelview().transform_point(scene_center_); ACG::Vec3d c = glstate_->modelview().transform_point(scene_center_);
...@@ -433,7 +435,7 @@ void glViewer::viewingDirection( const ACG::Vec3d& _dir, const ACG::Vec3d& _up ) ...@@ -433,7 +435,7 @@ void glViewer::viewingDirection( const ACG::Vec3d& _dir, const ACG::Vec3d& _up )
glstate_->reset_modelview(); glstate_->reset_modelview();
glstate_->lookAt((ACG::Vec3d)eye, (ACG::Vec3d)scene_center_, (ACG::Vec3d)_up); glstate_->lookAt((ACG::Vec3d)eye, (ACG::Vec3d)scene_center_, (ACG::Vec3d)_up);
emit viewChanged(); emit viewChanged();
} }
...@@ -747,7 +749,7 @@ void glViewer::home() ...@@ -747,7 +749,7 @@ void glViewer::home()
trackball_radius_ = home_radius_; trackball_radius_ = home_radius_;
updateProjectionMatrix(); updateProjectionMatrix();
updateGL(); updateGL();
emit viewChanged(); emit viewChanged();
} }
...@@ -777,8 +779,8 @@ void glViewer::viewAll() ...@@ -777,8 +779,8 @@ void glViewer::viewAll()
properties_.unLockUpdate(); properties_.unLockUpdate();
updateProjectionMatrix(); updateProjectionMatrix();
updateGL(); updateGL();
emit viewChanged(); emit viewChanged();
} }
...@@ -818,7 +820,7 @@ void glViewer::flyTo(const QPoint& _pos, bool _move_back) ...@@ -818,7 +820,7 @@ void glViewer::flyTo(const QPoint& _pos, bool _move_back)
// Redraw scene // Redraw scene
updateGL(); updateGL();
emit viewChanged(); emit viewChanged();
} }
...@@ -907,7 +909,7 @@ void glViewer::setView(const ACG::GLMatrixd& _modelview, ...@@ -907,7 +909,7 @@ void glViewer::setView(const ACG::GLMatrixd& _modelview,
makeCurrent(); makeCurrent();
glstate_->set_modelview(_modelview, _inverse_modelview); glstate_->set_modelview(_modelview, _inverse_modelview);
updateGL(); updateGL();
emit viewChanged(); emit viewChanged();
} }
...@@ -1139,7 +1141,7 @@ void glViewer::resizeEvent(QGraphicsSceneResizeEvent *) ...@@ -1139,7 +1141,7 @@ void glViewer::resizeEvent(QGraphicsSceneResizeEvent *)
size().width (), size().height (), size().width (), size().height (),
scene()->width (), scene()->height ()); scene()->width (), scene()->height ());
update(); update();
emit viewChanged(); emit viewChanged();
} }
...@@ -1150,7 +1152,7 @@ void glViewer::moveEvent (QGraphicsSceneMoveEvent *) ...@@ -1150,7 +1152,7 @@ void glViewer::moveEvent (QGraphicsSceneMoveEvent *)
size().width (), size().height (), size().width (), size().height (),
scene()->width (), scene()->height ()); scene()->width (), scene()->height ());
update(); update();
emit viewChanged(); emit viewChanged();
} }
...@@ -1360,7 +1362,7 @@ void glViewer::translate(const ACG::Vec3d& _trans) ...@@ -1360,7 +1362,7 @@ void glViewer::translate(const ACG::Vec3d& _trans)
{ {
makeCurrent(); makeCurrent();
glstate_->translate(_trans[0], _trans[1], _trans[2], ACG::MULT_FROM_LEFT); glstate_->translate(_trans[0], _trans[1], _trans[2], ACG::MULT_FROM_LEFT);
emit viewChanged(); emit viewChanged();
} }
...@@ -1387,7 +1389,7 @@ void glViewer::rotate(const ACG::Vec3d& _axis, ...@@ -1387,7 +1389,7 @@ void glViewer::rotate(const ACG::Vec3d& _axis,
glstate_->translate(-t[0], -t[1], -t[2], ACG::MULT_FROM_LEFT); glstate_->translate(-t[0], -t[1], -t[2], ACG::MULT_FROM_LEFT);
glstate_->rotate(_angle, _axis[0], _axis[1], _axis[2], ACG::MULT_FROM_LEFT); glstate_->rotate(_angle, _axis[0], _axis[1], _axis[2], ACG::MULT_FROM_LEFT);
glstate_->translate( t[0], t[1], t[2], ACG::MULT_FROM_LEFT); glstate_->translate( t[0], t[1], t[2], ACG::MULT_FROM_LEFT);
emit viewChanged(); emit viewChanged();
} }
...@@ -1793,7 +1795,7 @@ void glViewer::handleFirstPersonNavigation( QMouseEvent* _event) { ...@@ -1793,7 +1795,7 @@ void glViewer::handleFirstPersonNavigation( QMouseEvent* _event) {
lastMoveTime_.restart(); lastMoveTime_.restart();
emit viewChanged(); emit viewChanged();
break; break;
} }
...@@ -1816,7 +1818,7 @@ void glViewer::handleNormalNavigation( QMouseEvent* _event ) { ...@@ -1816,7 +1818,7 @@ void glViewer::handleNormalNavigation( QMouseEvent* _event ) {
QPoint pos(f.x(), f.y()); QPoint pos(f.x(), f.y());
switch (_event->type()) { switch (_event->type()) {
case QEvent::MouseButtonPress: { case QEvent::MouseButtonPress: {
// shift key -> set rotation center // shift key -> set rotation center
if (_event->modifiers() & Qt::ShiftModifier) { if (_event->modifiers() & Qt::ShiftModifier) {
...@@ -2286,7 +2288,7 @@ void glViewer::moveForward() { ...@@ -2286,7 +2288,7 @@ void glViewer::moveForward() {
updateGL(); updateGL();
lastMoveTime_.restart(); lastMoveTime_.restart();
emit viewChanged(); emit viewChanged();
} }
} }
...@@ -2301,7 +2303,7 @@ void glViewer::moveBack() { ...@@ -2301,7 +2303,7 @@ void glViewer::moveBack() {
updateGL(); updateGL();
lastMoveTime_.restart(); lastMoveTime_.restart();
emit viewChanged(); emit viewChanged();
} }
} }
...@@ -2316,7 +2318,7 @@ void glViewer::strafeLeft() { ...@@ -2316,7 +2318,7 @@ void glViewer::strafeLeft() {
updateGL(); updateGL();
lastMoveTime_.restart(); lastMoveTime_.restart();
emit viewChanged(); emit viewChanged();
} }
} }
...@@ -2331,7 +2333,7 @@ void glViewer::strafeRight() { ...@@ -2331,7 +2333,7 @@ void glViewer::strafeRight() {
updateGL(); updateGL();
lastMoveTime_.restart(); lastMoveTime_.restart();
emit viewChanged(); emit viewChanged();
} }
} }
......
...@@ -177,12 +177,11 @@ public: ...@@ -177,12 +177,11 @@ public:
/** Set scene graph. /** Set scene graph.
Sets the scene graph to the the graph rooted at \c _root. Sets the scene graph to the the graph rooted at \c _root.
The available draw modes in the scene graph will be collected Recomputes Scene center and resets the trackball center if specified.
and the popup menu will be updated.<br>
The \c sceneGraphToched() signal will be emitted (even if The \c sceneGraphToched() signal will be emitted (even if
\c _root does not actually change). \c _root does not actually change).
*/ */
void sceneGraph(ACG::SceneGraph::BaseNode* _root, const bool _setCenter = false); void sceneGraph(ACG::SceneGraph::BaseNode* _root, const bool _resetTrackBall = false);
/// projection mode /// projection mode
...@@ -211,7 +210,7 @@ public: ...@@ -211,7 +210,7 @@ public:
used as fixpoint for rotations and to set the eye point far used as fixpoint for rotations and to set the eye point far
enough from the scene so that the whole scene is visible. enough from the scene so that the whole scene is visible.
*/ */
void setScenePos( const ACG::Vec3d& _center, double _radius, const bool _setCenter = false ); void setScenePos( const ACG::Vec3d& _center, double _radius, const bool _resetTrackBall = false );
/** /**
* Set new center point of scene * Set new center point of scene
...@@ -629,7 +628,7 @@ private: ...@@ -629,7 +628,7 @@ private:
signals: signals:
/// This signal is emitted when the scene is repainted due to any event. /// This signal is emitted when the scene is repainted due to any event.
void viewUpdated(); void viewUpdated();
/// This signal is emitted whenever the view is changed by the user /// This signal is emitted whenever the view is changed by the user
void viewChanged(); void viewChanged();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment