Commit 19400372 authored by Mike Kremer's avatar Mike Kremer

Fixed some memory and consistency issues in Move-Plugin.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6989 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 7ec63ba5
...@@ -91,7 +91,7 @@ void MovePlugin::showProps(){ ...@@ -91,7 +91,7 @@ void MovePlugin::showProps(){
BaseObjectData* object; BaseObjectData* object;
if ( PluginFunctions::getObject(lastActiveManipulator_ , object) ) { if ( PluginFunctions::getObject(lastActiveManipulator_ , object) ) {
if ( object->manipulatorNode()->visible() ) { if ( object->manipulatorNode()->visible() ) {
const TriMesh::Point pos = object->manipulatorNode()->center(); const OpenMesh::Vec3d pos = object->manipulatorNode()->center();
QString num; QString num;
...@@ -99,7 +99,7 @@ void MovePlugin::showProps(){ ...@@ -99,7 +99,7 @@ void MovePlugin::showProps(){
num = QString::number(pos[1]); pW->posy->setText(num); num = QString::number(pos[1]); pW->posy->setText(num);
num = QString::number(pos[2]); pW->posz->setText(num); num = QString::number(pos[2]); pW->posz->setText(num);
TriMesh::Point direction = object->manipulatorNode()->directionX(); OpenMesh::Vec3d direction = object->manipulatorNode()->directionX();
num = QString::number(direction[0]); pW->dirxx->setText(num); num = QString::number(direction[0]); pW->dirxx->setText(num);
num = QString::number(direction[1]); pW->dirxy->setText(num); num = QString::number(direction[1]); pW->dirxy->setText(num);
num = QString::number(direction[2]); pW->dirxz->setText(num); num = QString::number(direction[2]); pW->dirxz->setText(num);
......
...@@ -86,6 +86,28 @@ MovePlugin::MovePlugin() : ...@@ -86,6 +86,28 @@ MovePlugin::MovePlugin() :
allTargets_ = false; allTargets_ = false;
} }
/** \brief Deconstructor
*
*/
MovePlugin::~MovePlugin() {
if(contextAction_) {
delete contextAction_;
}
if(toAllTargets_) {
delete toAllTargets_;
}
for(QList<movePropsWidget*>::iterator it = propsWindows_.begin();
it != propsWindows_.end(); ++it) {
if(*it) {
delete *it;
}
}
}
/******************************************************************************* /*******************************************************************************
BaseInterface implementation BaseInterface implementation
...@@ -164,12 +186,12 @@ void MovePlugin::pluginsInitialized() { ...@@ -164,12 +186,12 @@ void MovePlugin::pluginsInitialized() {
pickToolbar_->addSeparator (); pickToolbar_->addSeparator ();
ratateTranslateAction_ = new QAction(tr("Rotate/Translate object"), pickToolBarActions_); rotateTranslateAction_ = new QAction(tr("Rotate/Translate object"), pickToolBarActions_);
ratateTranslateAction_->setStatusTip(tr("Rotate/Translate object.")); rotateTranslateAction_->setStatusTip(tr("Rotate/Translate object."));
ratateTranslateAction_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"move-translaterotate.png") ); rotateTranslateAction_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"move-translaterotate.png") );
ratateTranslateAction_->setCheckable(true); rotateTranslateAction_->setCheckable(true);
ratateTranslateAction_->setChecked(true); rotateTranslateAction_->setChecked(true);
pickToolbar_->addAction(ratateTranslateAction_); pickToolbar_->addAction(rotateTranslateAction_);
resizeAction_ = new QAction(tr("Resize object"), pickToolBarActions_); resizeAction_ = new QAction(tr("Resize object"), pickToolBarActions_);
resizeAction_->setStatusTip(tr("Resize object. <Control>")); resizeAction_->setStatusTip(tr("Resize object. <Control>"));
...@@ -179,11 +201,11 @@ void MovePlugin::pluginsInitialized() { ...@@ -179,11 +201,11 @@ void MovePlugin::pluginsInitialized() {
pickToolbar_->addSeparator (); pickToolbar_->addSeparator ();
ratateManipAction_ = new QAction(tr("Rotate manipulator"), pickToolBarActions_); rotateManipAction_ = new QAction(tr("Rotate manipulator"), pickToolBarActions_);
ratateManipAction_->setStatusTip(tr("Rotate manipulator. <Shift>")); rotateManipAction_->setStatusTip(tr("Rotate manipulator. <Shift>"));
ratateManipAction_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"move-maniprotate.png") ); rotateManipAction_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"move-maniprotate.png") );
ratateManipAction_->setCheckable(true); rotateManipAction_->setCheckable(true);
pickToolbar_->addAction(ratateManipAction_); pickToolbar_->addAction(rotateManipAction_);
smallerManipAction_ = new QAction(tr("Decrease size of manipulator"), pickToolBarActions_); smallerManipAction_ = new QAction(tr("Decrease size of manipulator"), pickToolBarActions_);
smallerManipAction_->setStatusTip(tr("Make manipulator smaller. <Mouse wheel up>")); smallerManipAction_->setStatusTip(tr("Make manipulator smaller. <Mouse wheel up>"));
...@@ -438,18 +460,18 @@ void MovePlugin::setManipMode (QtTranslationManipulatorNode::ManipulatorMode _mo ...@@ -438,18 +460,18 @@ void MovePlugin::setManipMode (QtTranslationManipulatorNode::ManipulatorMode _mo
{ {
case QtTranslationManipulatorNode::Resize: case QtTranslationManipulatorNode::Resize:
resizeAction_->setChecked (true); resizeAction_->setChecked (true);
ratateManipAction_->setChecked (false); rotateManipAction_->setChecked (false);
ratateTranslateAction_->setChecked (false); rotateTranslateAction_->setChecked (false);
break; break;
case QtTranslationManipulatorNode::LocalRotation: case QtTranslationManipulatorNode::LocalRotation:
resizeAction_->setChecked (false); resizeAction_->setChecked (false);
ratateManipAction_->setChecked (true); rotateManipAction_->setChecked (true);
ratateTranslateAction_->setChecked (false); rotateTranslateAction_->setChecked (false);
break; break;
case QtTranslationManipulatorNode::TranslationRotation: case QtTranslationManipulatorNode::TranslationRotation:
resizeAction_->setChecked (false); resizeAction_->setChecked (false);
ratateManipAction_->setChecked (false); rotateManipAction_->setChecked (false);
ratateTranslateAction_->setChecked (true); rotateTranslateAction_->setChecked (true);
break; break;
} }
} }
...@@ -1105,16 +1127,16 @@ void MovePlugin::slotMoveToOrigin() { ...@@ -1105,16 +1127,16 @@ void MovePlugin::slotMoveToOrigin() {
bool useCommonCOG = false; bool useCommonCOG = false;
ACG::Vec3d cog = ACG::Vec3d(0.0,0.0,0.0); ACG::Vec3d cog = ACG::Vec3d(0.0,0.0,0.0);
if ( PluginFunctions::targetCount() > 1 ) { if ( PluginFunctions::targetCount() > 1 ) {
QMessageBox::StandardButton button = QMessageBox::question( 0, tr("Use common COG?"), tr("Should the targets be moved depending on their common cog?"),QMessageBox::Yes|QMessageBox::No); QMessageBox::StandardButton button = QMessageBox::question( 0, tr("Use common COG?"), tr("Should the targets be moved depending on their common cog?"),QMessageBox::Yes|QMessageBox::No);
useCommonCOG = ( button == QMessageBox::Yes ); useCommonCOG = ( button == QMessageBox::Yes );
double vertexCount = 0.0; double vertexCount = 0.0;
if ( useCommonCOG ) { if ( useCommonCOG ) {
// Compute cog for all objects // Compute cog for all objects
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) { for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH )) { if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
...@@ -1129,17 +1151,17 @@ void MovePlugin::slotMoveToOrigin() { ...@@ -1129,17 +1151,17 @@ void MovePlugin::slotMoveToOrigin() {
vertexCount += double(mesh.n_vertices()); vertexCount += double(mesh.n_vertices());
} }
} }
cog = cog / vertexCount; cog = cog / vertexCount;
} }
} }
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) { for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH )) { if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
TriMesh& mesh = *PluginFunctions::triMesh(*o_it); TriMesh& mesh = *PluginFunctions::triMesh(*o_it);
if ( !useCommonCOG ) if ( !useCommonCOG )
cog = MeshInfo::cog(mesh); cog = MeshInfo::cog(mesh);
for ( TriMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end() ; ++v_it) for ( TriMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end() ; ++v_it)
...@@ -1150,8 +1172,8 @@ void MovePlugin::slotMoveToOrigin() { ...@@ -1150,8 +1172,8 @@ void MovePlugin::slotMoveToOrigin() {
if ( o_it->dataType( DATA_POLY_MESH )) { if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it); PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it);
if ( !useCommonCOG ) if ( !useCommonCOG )
cog = MeshInfo::cog(mesh); cog = MeshInfo::cog(mesh);
for ( PolyMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end() ; ++v_it) for ( PolyMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end() ; ++v_it)
...@@ -1183,21 +1205,21 @@ void MovePlugin::slotUnifyBoundingBoxDiagonal() ...@@ -1183,21 +1205,21 @@ void MovePlugin::slotUnifyBoundingBoxDiagonal()
bool useCommonBB = false; bool useCommonBB = false;
ACG::Vec3d bb_min = ACG::Vec3d(FLT_MAX,FLT_MAX,FLT_MAX); ACG::Vec3d bb_min = ACG::Vec3d(FLT_MAX,FLT_MAX,FLT_MAX);
ACG::Vec3d bb_max = ACG::Vec3d(FLT_MIN,FLT_MIN,FLT_MIN); ACG::Vec3d bb_max = ACG::Vec3d(FLT_MIN,FLT_MIN,FLT_MIN);
if ( PluginFunctions::targetCount() > 1 ) { if ( PluginFunctions::targetCount() > 1 ) {
QMessageBox::StandardButton button = QMessageBox::question( 0, tr("Use common BB?"), tr("Should the targets be scaled depending on their common Bounding Box?"),QMessageBox::Yes|QMessageBox::No); QMessageBox::StandardButton button = QMessageBox::question( 0, tr("Use common BB?"), tr("Should the targets be scaled depending on their common Bounding Box?"),QMessageBox::Yes|QMessageBox::No);
useCommonBB = ( button == QMessageBox::Yes ); useCommonBB = ( button == QMessageBox::Yes );
double count = 0.0; double count = 0.0;
if ( useCommonBB ) { if ( useCommonBB ) {
// Compute cog for all objects // Compute cog for all objects
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) { for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
ACG::Vec3d bb_min_tmp(0.0,0.0,0.0); ACG::Vec3d bb_min_tmp(0.0,0.0,0.0);
ACG::Vec3d bb_max_tmp(0.0,0.0,0.0); ACG::Vec3d bb_max_tmp(0.0,0.0,0.0);
if ( o_it->dataType( DATA_TRIANGLE_MESH )) { if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
TriMesh& mesh = *PluginFunctions::triMesh(*o_it); TriMesh& mesh = *PluginFunctions::triMesh(*o_it);
getBB(mesh,bb_min_tmp,bb_max_tmp); getBB(mesh,bb_min_tmp,bb_max_tmp);
...@@ -1209,13 +1231,13 @@ void MovePlugin::slotUnifyBoundingBoxDiagonal() ...@@ -1209,13 +1231,13 @@ void MovePlugin::slotUnifyBoundingBoxDiagonal()
PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it); PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it);
getBB(mesh,bb_min_tmp,bb_max_tmp); getBB(mesh,bb_min_tmp,bb_max_tmp);
bb_min.minimize(bb_min_tmp); bb_min.minimize(bb_min_tmp);
bb_max.maximize(bb_max_tmp); bb_max.maximize(bb_max_tmp);
} }
} }
} }
} }
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) { for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( useCommonBB ) { if ( useCommonBB ) {
if ( o_it->dataType( DATA_TRIANGLE_MESH ) ) if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
...@@ -1226,13 +1248,13 @@ void MovePlugin::slotUnifyBoundingBoxDiagonal() ...@@ -1226,13 +1248,13 @@ void MovePlugin::slotUnifyBoundingBoxDiagonal()
if ( o_it->dataType( DATA_TRIANGLE_MESH ) ) if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
unifyBBDiag(*PluginFunctions::triMesh(*o_it)); unifyBBDiag(*PluginFunctions::triMesh(*o_it));
else if ( o_it->dataType( DATA_POLY_MESH ) ) else if ( o_it->dataType( DATA_POLY_MESH ) )
unifyBBDiag(*PluginFunctions::polyMesh(*o_it)); unifyBBDiag(*PluginFunctions::polyMesh(*o_it));
} }
emit updatedObject( o_it->id() ); emit updatedObject( o_it->id() );
} }
emit updateView(); emit updateView();
} }
...@@ -1335,12 +1357,12 @@ void MovePlugin::slotSetMoveMode(QAction* _action) { ...@@ -1335,12 +1357,12 @@ void MovePlugin::slotSetMoveMode(QAction* _action) {
void MovePlugin::slotPickToolbarAction(QAction* _action) void MovePlugin::slotPickToolbarAction(QAction* _action)
{ {
if (_action == ratateTranslateAction_) if (_action == rotateTranslateAction_)
{ {
setManipMode (QtTranslationManipulatorNode::TranslationRotation); setManipMode (QtTranslationManipulatorNode::TranslationRotation);
} }
if (_action == ratateManipAction_) if (_action == rotateManipAction_)
{ {
setManipMode (QtTranslationManipulatorNode::LocalRotation); setManipMode (QtTranslationManipulatorNode::LocalRotation);
} }
...@@ -1507,7 +1529,7 @@ void MovePlugin::getBB( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb_max ...@@ -1507,7 +1529,7 @@ void MovePlugin::getBB( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb_max
template< typename MeshT > template< typename MeshT >
void MovePlugin::unifyBBDiag( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb_max ) void MovePlugin::unifyBBDiag( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb_max )
{ {
typename MeshT::VertexIter v_it = _mesh.vertices_begin(); typename MeshT::VertexIter v_it = _mesh.vertices_begin();
typename MeshT::VertexIter v_end = _mesh.vertices_end(); typename MeshT::VertexIter v_end = _mesh.vertices_end();
......
...@@ -143,7 +143,7 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -143,7 +143,7 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
MovePlugin(); MovePlugin();
/// Destructor /// Destructor
~MovePlugin() {}; ~MovePlugin();
/// Initialize the toolbar (create a widget in the right side toolbox) /// Initialize the toolbar (create a widget in the right side toolbox)
bool initializeToolbox(QWidget*& _widget); bool initializeToolbox(QWidget*& _widget);
...@@ -239,8 +239,8 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -239,8 +239,8 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
QToolBar *pickToolbar_; QToolBar *pickToolbar_;
QAction* placeAction_; QAction* placeAction_;
QAction* ratateTranslateAction_; QAction* rotateTranslateAction_;
QAction* ratateManipAction_; QAction* rotateManipAction_;
QAction* resizeAction_; QAction* resizeAction_;
QAction* biggerManipAction_; QAction* biggerManipAction_;
...@@ -296,11 +296,11 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -296,11 +296,11 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
/// scale mesh to have a boundingboxdiagonal of one /// scale mesh to have a boundingboxdiagonal of one
template< typename MeshT > template< typename MeshT >
void unifyBBDiag(MeshT& _mesh ); void unifyBBDiag(MeshT& _mesh );
/// get bounding box diagonal of a mesh /// get bounding box diagonal of a mesh
template< typename MeshT > template< typename MeshT >
void getBB( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb_max ); void getBB( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb_max );
/// Scales object such that bounding box diagonal has unit length /// Scales object such that bounding box diagonal has unit length
template< typename MeshT > template< typename MeshT >
void unifyBBDiag( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb_max ); void unifyBBDiag( MeshT& _mesh, ACG::Vec3d& _bb_min, ACG::Vec3d& _bb_max );
...@@ -381,9 +381,6 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, ...@@ -381,9 +381,6 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface,
void slotUpdateContextMenuNode( int _nodeId ); void slotUpdateContextMenuNode( int _nodeId );
private: private:
/// Move context menu
QMenu* contextMenu_;
/// List of properties dialogs (each corresponding to one manipulator) /// List of properties dialogs (each corresponding to one manipulator)
QList<movePropsWidget*> propsWindows_; QList<movePropsWidget*> propsWindows_;
......
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