Commit e702ed14 authored by Matthias Möller's avatar Matthias Möller
Browse files

updates boundingBox after creating planeNode

closes #1894

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17988 383ad7c9-94d9-4d36-a494-682f7c89f535
parent fecf07ca
......@@ -141,51 +141,25 @@ void QtPlaneSelect::slotMouseEvent(QMouseEvent* event)
if ( planeNode_ == 0 ) {
planeNode_ = new PlaneNode(plane_,PluginFunctions::getRootNode(),"PolyLine generation Plane" );
planeNode_->hide();
}
ACG::Vec3d sourcePoint3Dd(sourcePoint3D);
plane_.setPlane(sourcePoint3Dd,ACG::Vec3d(1.0,0.0,0.0));
plane_.setSize(PluginFunctions::sceneRadius(),PluginFunctions::sceneRadius());
setPlaneAndSize(sourcePoint3D,ACG::Vec3d(event->pos().x(), height-event->pos().y()-1.0, 0.0));
emit updateViewProxy( );
planeNode_->show();
emit nodeVisChangedProxy(planeNode_->id());
nodeIdx_ = node_idx;
targetIdx_ = target_idx;
}
} break;
emit updateViewProxy( );
}
}break;
case QEvent::MouseMove:
{
if( isDragging )
{
ACG::Vec3d source2D = glState.project( sourcePoint3D );
ACG::Vec3d target2D(event->pos().x(), height-event->pos().y()-1, 0);
source2D[2] = 0;
ACG::Vec3d diff = source2D - target2D;
//diff.normalize( ); <- this is bad
ACG::Vec3d ortho(-diff[1], diff[0], 0 );
ACG::Vec3d left = glState.unproject( source2D+ortho*10 + ACG::Vec3d(0,0,0) );
ACG::Vec3d right= glState.unproject( source2D-ortho*10 + ACG::Vec3d(0,0,0) );
ACG::Vec3d leftvec = left-sourcePoint3D;
leftvec.normalize( );
ACG::Vec3d rightvec = right-sourcePoint3D;
rightvec.normalize( );
normal = cross( rightvec, leftvec );
normal.normalize( );
ACG::Vec3d sourcePoint3Df(sourcePoint3D);
ACG::Vec3d normald(normal);
plane_.setPlane(sourcePoint3Df,normald);
plane_.setSize(PluginFunctions::sceneRadius(),PluginFunctions::sceneRadius());
planeNode_->show();
setPlaneAndSize(sourcePoint3D,ACG::Vec3d(event->pos().x(), height-event->pos().y()-1.0, 0.0));
emit updateViewProxy( );
}
......@@ -217,5 +191,35 @@ void QtPlaneSelect::slotMouseEvent(QMouseEvent* event)
}
void QtPlaneSelect::setPlaneAndSize(const ACG::Vec3d& _sourcePoint3D,const ACG::Vec3d& _target2D)
{
ACG::Vec3d source2D = glState.project( _sourcePoint3D );
source2D[2] = 0;
ACG::Vec3d diff = source2D - _target2D;
//diff.normalize( ); <- this is bad
ACG::Vec3d ortho(-diff[1], diff[0], 0 );
ACG::Vec3d left = glState.unproject( source2D+ortho*10 + ACG::Vec3d(0,0,0) );
ACG::Vec3d right= glState.unproject( source2D-ortho*10 + ACG::Vec3d(0,0,0) );
ACG::Vec3d leftvec = left-sourcePoint3D;
leftvec.normalize( );
ACG::Vec3d rightvec = right-sourcePoint3D;
rightvec.normalize( );
normal = cross( rightvec, leftvec );
normal.normalize( );
ACG::Vec3d sourcePoint3Df(sourcePoint3D);
ACG::Vec3d normald(normal);
plane_.setPlane(sourcePoint3Df,normald);
plane_.setSize(PluginFunctions::sceneRadius(),PluginFunctions::sceneRadius());
}
......@@ -90,6 +90,7 @@ class DLLEXPORT QtPlaneSelect : public QObject
signals:
void signalTriggerCut( );
void updateViewProxy();
void nodeVisChangedProxy(int _id);
/*******************************************************************************
......@@ -117,6 +118,7 @@ class DLLEXPORT QtPlaneSelect : public QObject
private:
Plane plane_;
void setPlaneAndSize(const ACG::Vec3d& _sourcePoint3D,const ACG::Vec3d& _target2D);
};
......
......@@ -398,6 +398,7 @@ pluginsInitialized()
planeSelect_ = new QtPlaneSelect( PluginFunctions::viewerProperties().glState() );
connect( planeSelect_, SIGNAL( signalTriggerCut( ) ), this, SLOT( slotTriggerCutPlaneSelect() ) );
connect( planeSelect_, SIGNAL( updateViewProxy( ) ), this, SIGNAL( updateView() ) );
connect( planeSelect_, SIGNAL( nodeVisChangedProxy(int) ), this, SIGNAL(nodeVisibilityChanged(int) ) );
//create copy paste action in context menu
copyPaste_Action_ = new QAction("Duplicate", 0);
......
......@@ -90,6 +90,7 @@ signals:
// BaseInterface
void updateView();
void updatedObject(int _identifier, const UpdateType& _type);
void nodeVisibilityChanged(int _id);
// PickingInterface
void addPickMode( const std::string& _mode );
......
Supports Markdown
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