Commit c3763ae3 authored by Mike Kremer's avatar Mike Kremer

Updated core such that rotation center only is calculated after a file has...

Updated core such that rotation center only is calculated after a file has been loaded. Especially not when switching from some picking mode back to examiner mode. This leads to beeing forced to calculate rotation center after having moved an object via the move manipulator since its rotation center stays on the previous position unless its not updated explicitly.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6139 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 45ef298b
......@@ -400,29 +400,72 @@ void viewingDirection(const ACG::Vec3d &_dir, const ACG::Vec3d &_up , int _viewe
}
void setScenePos(const ACG::Vec3d& _center,const double _radius, int _viewer ) {
if ( _viewer == ACTIVE_VIEWER ) {
examiner_widgets_[activeExaminer_]->setScenePos( _center, _radius );
} else if ( _viewer == ALL_VIEWERS )
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
examiner_widgets_[i]->setScenePos( _center, _radius );
else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
examiner_widgets_[_viewer]->setScenePos( _center, _radius );
else
std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl;
examiner_widgets_[activeExaminer_];
void setScenePos(const double _radius, int _viewer ) {
if (_viewer == ACTIVE_VIEWER) {
examiner_widgets_[activeExaminer_]->setScenePos(_radius);
}
else if (_viewer == ALL_VIEWERS) {
for (uint i = 0; i < examiner_widgets_.size(); ++i) {
examiner_widgets_[i]->setScenePos( _radius);
}
}
else if ((_viewer >= 0) && _viewer < (int) examiner_widgets_.size()) {
examiner_widgets_[_viewer]->setScenePos(_radius);
}
else {
std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl;
}
examiner_widgets_[activeExaminer_];
}
void setScenePos(const ACG::Vec3d& _center, int _viewer ) {
if ( _viewer == ACTIVE_VIEWER ) {
examiner_widgets_[activeExaminer_]->setScenePos( _center, examiner_widgets_[activeExaminer_]->scene_radius() );
} else if ( _viewer == ALL_VIEWERS )
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
examiner_widgets_[i]->setScenePos( _center, examiner_widgets_[i]->scene_radius() );
else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
examiner_widgets_[_viewer]->setScenePos( _center, examiner_widgets_[_viewer]->scene_radius() );
else
std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl;
void setScenePos(int _viewer) {
if (_viewer == ACTIVE_VIEWER) {
examiner_widgets_[activeExaminer_]->setScenePos(examiner_widgets_[activeExaminer_]->scene_radius());
}
else if (_viewer == ALL_VIEWERS) {
for (uint i = 0; i < examiner_widgets_.size(); ++i) {
examiner_widgets_[i]->setScenePos(examiner_widgets_[i]->scene_radius());
}
}
else if ((_viewer >= 0) && _viewer < (int) examiner_widgets_.size()) {
examiner_widgets_[_viewer]->setScenePos(examiner_widgets_[_viewer]->scene_radius());
}
else {
std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl;
}
}
void setSceneCenter(const ACG::Vec3d& _center, int _viewer ) {
if (_viewer == ACTIVE_VIEWER) {
examiner_widgets_[activeExaminer_]->setSceneCenter(_center);
}
else if (_viewer == ALL_VIEWERS) {
for (uint i = 0; i < examiner_widgets_.size(); ++i) {
examiner_widgets_[i]->setSceneCenter(_center);
}
}
else if ((_viewer >= 0) && _viewer < (int) examiner_widgets_.size()) {
examiner_widgets_[_viewer]->setSceneCenter(_center);
}
else {
std::cerr << "Requested illegal viewer for setSceneCenter!!" << std::endl;
}
}
const ACG::Vec3d& sceneCenter( int _viewer ) {
......
......@@ -263,6 +263,21 @@ Viewer::ActionMode actionMode();
DLLEXPORT
void allowRotation(bool _mode);
/**
* Set eye position of scene
*/
void setScenePos(const double _radius, int _viewer );
/**
* Calculate and set eye position of scene
*/
void setScenePos(int _viewer);
/**
* Set center of scene
*/
void setSceneCenter(const ACG::Vec3d& _center, int _viewer );
/** \brief Map coordinates of GL Widget to global coordinates
*
*/
......
......@@ -389,7 +389,7 @@ private:
int loadObject ( QString _filename );
/// Do a reset of the scenegraph (bounding box update,...)
void resetScenegraph();
void resetScenegraph(bool _updateCenter = false);
public :
......
......@@ -45,13 +45,13 @@
#include <time.h>
void Core::resetScenegraph() {
void Core::resetScenegraph(bool _updateCenter) {
if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() ) {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
// update scene graph (get new bounding box and set projection right, including near and far plane)
PluginFunctions::viewerProperties(i).lockUpdate();
coreWidget_->examiner_widgets_[i]->sceneGraph(root_node_scenegraph_);
coreWidget_->examiner_widgets_[i]->sceneGraph(root_node_scenegraph_, _updateCenter);
PluginFunctions::viewerProperties(i).unLockUpdate();
coreWidget_->examiner_widgets_[i]->updateGL();
}
......@@ -231,8 +231,9 @@ void Core::slotLoad(QString _filename, DataType _type, int& _id) {
if ( _id < 0 )
_id = -1;
else
if ( OpenFlipper::Options::gui() )
if ( OpenFlipper::Options::gui() ) {
coreWidget_->addRecent(_filename,_type);
}
}
/// Slot gets called after a file-plugin has opened an object
......@@ -292,7 +293,7 @@ void Core::slotObjectOpened ( int _id ) {
// ================================================================================
// Recompute bounding box and scenegraph info
// ================================================================================
resetScenegraph();
resetScenegraph(true);
// ================================================================================
// Tell plugins, that a file has been opened
......
......@@ -244,7 +244,7 @@ void glViewer::swapBuffers() {
//-----------------------------------------------------------------------------
void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root)
void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root, bool _updateCenter)
{
// if (sceneGraphRoot_ == _root)
// return;
......@@ -262,11 +262,21 @@ void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root)
if ( ( bbmin[0] > bbmax[0] ) ||
( bbmin[1] > bbmax[1] ) ||
( bbmin[2] > bbmax[2] ) )
setScenePos( ACG::Vec3d( 0.0,0.0,0.0 ) , 1.0 );
else
setScenePos( ( bbmin + bbmax ) * 0.5,
( bbmax - bbmin ).norm() * 0.5 );
( bbmin[2] > bbmax[2] ) ) {
setScenePos( 1.0 );
if(_updateCenter) {
setSceneCenter( ACG::Vec3d( 0.0,0.0,0.0 ) );
}
} else {
setScenePos( (bbmax - bbmin).norm() * 0.5 );
if(_updateCenter) {
setSceneCenter( (bbmin + bbmax)* 0.5);
}
}
}
updateGL();
......@@ -362,22 +372,33 @@ void glViewer::updateProjectionMatrix()
//-----------------------------------------------------------------------------
void glViewer::setScenePos(const ACG::Vec3d& _center, double _radius)
void glViewer::setScenePos(double _radius)
{
scene_center_ = trackball_center_ = _center;
scene_radius_ = trackball_radius_ = _radius;
scene_radius_ = trackball_radius_ = _radius;
orthoWidth_ = 2.0 * scene_radius_;
near_ = 0.001 * scene_radius_;
far_ = 10.0 * scene_radius_;
orthoWidth_ = 2.0 * scene_radius_;
near_ = 0.001 * scene_radius_;
far_ = 10.0 * scene_radius_;
updateProjectionMatrix();
updateGL();
updateProjectionMatrix();
updateGL();
}
//----------------------------------------------------------------------------
void glViewer::setSceneCenter(const ACG::Vec3d& _center)
{
scene_center_ = trackball_center_ = _center;
updateProjectionMatrix();
updateGL();
}
//----------------------------------------------------------------------------
void glViewer::viewingDirection( const ACG::Vec3d& _dir, const ACG::Vec3d& _up )
{
......
......@@ -178,7 +178,7 @@ public:
The \c sceneGraphToched() signal will be emitted (even if
\c _root does not actually change).
*/
void sceneGraph(ACG::SceneGraph::BaseNode* _root);
void sceneGraph(ACG::SceneGraph::BaseNode* _root, bool _updateCenter = false);
/// projection mode
......@@ -193,11 +193,16 @@ public:
ProjectionMode projectionMode() const { return projectionMode_; }
/** Sets the center and dimension of the whole scene. This point is
used as fixpoint for rotations and to set the eye point far
/** Sets the dimension of the whole scene. It sets the eye point far
enough from the scene so that the whole scene is visible.
*/
void setScenePos( const ACG::Vec3d& _center, double _radius );
void setScenePos( double _radius );
/** Sets the center of the whole scene. This point is
used as fixpoint for rotation.
*/
void setSceneCenter( const ACG::Vec3d& _center );
/** Get scene's center
\see setScenePos()
*/
......
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