diff --git a/src/meshlabplugins/meshfilter/meshfilter.cpp b/src/meshlabplugins/meshfilter/meshfilter.cpp index b9429535e..4f74c73eb 100644 --- a/src/meshlabplugins/meshfilter/meshfilter.cpp +++ b/src/meshlabplugins/meshfilter/meshfilter.cpp @@ -22,6 +22,9 @@ /**************************************************************************** History $Log$ +Revision 1.97 2007/07/24 07:20:20 cignoni +Added Freeze transform and improved transformation dialog + Revision 1.96 2007/04/20 10:09:56 cignoni issue on vertex selection from face selection @@ -232,7 +235,8 @@ ExtraMeshFilterPlugin::ExtraMeshFilterPlugin() FP_REMOVE_NON_MANIFOLD<< FP_NORMAL_EXTRAPOLATION<< FP_CLOSE_HOLES<< - FP_TRANSFORM; + FP_FREEZE_TRANSFORM<< + FP_TRANSFORM; FilterType tt; @@ -295,6 +299,7 @@ const QString ExtraMeshFilterPlugin::ST(FilterType filter) case FP_REORIENT : return QString("Re-orient"); case FP_INVERT_FACES: return QString("Invert Faces"); case FP_TRANSFORM: return QString("Apply Transform"); + case FP_FREEZE_TRANSFORM: return QString("Freeze Current Matrix"); case FP_REMOVE_NON_MANIFOLD: return QString("Remove Non Manifold Faces"); case FP_NORMAL_EXTRAPOLATION: return QString("Compute normals for point sets"); case FP_CLOSE_HOLES: return QString("Close Holes"); @@ -338,6 +343,7 @@ const QString ExtraMeshFilterPlugin::Info(FilterType filterID) case FP_REORIENT : return tr("Re-orient in a consistent way all the faces of the mesh"); case FP_INVERT_FACES : return tr("Invert faces orientation, flip the normal of the mesh"); case FP_TRANSFORM : return tr("Apply transformation, you can rotate, translate or scale the mesh"); + case FP_FREEZE_TRANSFORM : return tr("Freeze the current transformation matrix into the coords of the vertices of the mesh"); case FP_NORMAL_EXTRAPOLATION : return tr("Compute the normals of the vertices of a mesh without exploiting the triangle connectivity, useful for dataset with no faces"); case FP_CLOSE_HOLES : return tr("Close holes smaller than a given threshold"); default : assert(0); @@ -375,6 +381,7 @@ const int ExtraMeshFilterPlugin::getRequirements(QAction *action) case FP_REMOVE_FACES_BY_EDGE: case FP_CLUSTERING: case FP_TRANSFORM: + case FP_FREEZE_TRANSFORM: case FP_NORMAL_EXTRAPOLATION: case FP_INVERT_FACES: return 0; case FP_QUADRIC_SIMPLIFICATION: @@ -460,7 +467,10 @@ bool ExtraMeshFilterPlugin::getParameters(QAction *action, QWidget *parent, Mesh { case FP_TRANSFORM: { - transformDialog->setMesh(&m.cm); + transformDialog->setMesh(m); + transformDialog->show(); + transformDialog->resize(transformDialog->size()); + int continueValue = transformDialog->exec(); if (continueValue == QDialog::Rejected) return false; @@ -477,6 +487,7 @@ bool ExtraMeshFilterPlugin::getParameters(QAction *action, QWidget *parent, Mesh case FP_LAPLACIAN_SMOOTH: case FP_REMOVE_NON_MANIFOLD: case FP_NORMAL_EXTRAPOLATION: + case FP_FREEZE_TRANSFORM: return true; // no parameters default :assert(0); } @@ -604,15 +615,16 @@ bool ExtraMeshFilterPlugin::applyFilter(QAction *filter, MeshModel &m, FilterPar m.clearDataMask(MeshModel::MM_FACETOPO | MeshModel::MM_BORDERFLAG); } - if (filter->text() == ST(FP_TRANSFORM) ) { - Matrix44f matrix= par.getMatrix44("Transform"); - - Log(GLLogStream::Info, - transformDialog->getLog().toAscii().data()); - - vcg::tri::UpdatePosition::Matrix(m.cm, matrix); + if (filter->text() == ST(FP_FREEZE_TRANSFORM) ) { + vcg::tri::UpdatePosition::Matrix(m.cm, m.cm.Tr); vcg::tri::UpdateNormals::PerVertexNormalizedPerFace(m.cm); vcg::tri::UpdateBounding::Box(m.cm); + m.cm.Tr.SetIdentity(); + } + if (filter->text() == ST(FP_TRANSFORM) ) { + Matrix44f matrix= par.getMatrix44("Transform"); + Log(GLLogStream::Info, qPrintable(transformDialog->getLog()) ); + m.cm.Tr=matrix; } diff --git a/src/meshlabplugins/meshfilter/meshfilter.h b/src/meshlabplugins/meshfilter/meshfilter.h index 479ceba74..e2514d7ce 100644 --- a/src/meshlabplugins/meshfilter/meshfilter.h +++ b/src/meshlabplugins/meshfilter/meshfilter.h @@ -22,6 +22,9 @@ ****************************************************************************/ /* History $Log$ +Revision 1.44 2007/07/24 07:20:18 cignoni +Added Freeze transform and improved transformation dialog + Revision 1.43 2007/04/16 09:25:29 cignoni ** big change ** Added Layers managemnt. @@ -110,6 +113,7 @@ class ExtraMeshFilterPlugin : public QObject, public MeshFilterInterface FP_REORIENT , FP_INVERT_FACES, FP_TRANSFORM, + FP_FREEZE_TRANSFORM, FP_CLOSE_HOLES_TRIVIAL, FP_CLOSE_HOLES } ; @@ -133,8 +137,6 @@ class ExtraMeshFilterPlugin : public QObject, public MeshFilterInterface protected: -// RefineDialog *refineDialog; -// DecimatorDialog *decimatorDialog; TransformDialog *transformDialog; GenericELDialog *genericELD; diff --git a/src/meshlabplugins/meshfilter/transformDialog.cpp b/src/meshlabplugins/meshfilter/transformDialog.cpp index e66b055f0..85619314a 100644 --- a/src/meshlabplugins/meshfilter/transformDialog.cpp +++ b/src/meshlabplugins/meshfilter/transformDialog.cpp @@ -26,6 +26,9 @@ /* $Log$ +Revision 1.4 2007/07/24 07:20:20 cignoni +Added Freeze transform and improved transformation dialog + Revision 1.3 2006/03/29 07:30:54 zifnab1974 use fabs instead of abs for floats, needed for gcc 3.4.5 @@ -61,7 +64,7 @@ Revision 1.7 2006/01/22 16:40:38 mariolatronico #include #include #include - +#include TransformDialog::TransformDialog() : QDialog() { setupUi(this); @@ -97,6 +100,7 @@ TransformDialog::TransformDialog() : QDialog() { connect(zScaleLE, SIGNAL(returnPressed()), this, SLOT(on_okButton_pressed()) ); connect(rotateLE, SIGNAL(returnPressed()), this, SLOT(on_okButton_pressed()) ); +// connect(freezeButton, SIGNAL(buttonClicked()), this, SLOT(freeze()) ); // default to AXIS_X for rotation and Move transformation rotateAxis = AXIS_X; @@ -106,8 +110,34 @@ TransformDialog::TransformDialog() : QDialog() { setScale(); setRotate(); + tableWidget->setColumnCount(4); + tableWidget->setRowCount(4); + tableWidget->horizontalHeader()->hide(); + tableWidget->verticalHeader()->hide(); + for(int i=0;i<4;i++) + { + tableWidget->setColumnWidth(i,40); + tableWidget->setRowHeight(i,18); + } +} +void TransformDialog::showEvent ( QShowEvent * event ) +{ + for(int i=0;i<4;i++) + { + tableWidget->setColumnWidth(i,tableWidget->width()/4 - 2); + tableWidget->setRowHeight(i,tableWidget->height()/4 - 2); + } } +void TransformDialog::resizeEvent ( QResizeEvent * event ) +{ + for(int i=0;i<4;i++) + { + tableWidget->setColumnWidth(i,tableWidget->width()/4 - 2); + tableWidget->setRowHeight(i,tableWidget->height()/4 - 2); + } +} + TransformDialog::~TransformDialog() { delete whichTransformBG; delete rotateBG; @@ -117,14 +147,21 @@ vcg::Matrix44f& TransformDialog::getTransformation() { return matrix; } -void TransformDialog::setMesh(CMeshO *mesh) { - +void TransformDialog::setMesh(MeshModel &m) { + matrix=m.cm.Tr; + CMeshO *mesh=&m.cm; this->mesh = mesh; this->bbox = mesh->bbox; vcg::tri::UpdateBounding::Box(*mesh); minBbox = mesh->bbox.min; maxBbox = mesh->bbox.max; + + for(int ii=0;ii<4;++ii) + for(int jj=0;jj<4;++jj) + tableWidget->setItem(ii,jj,new QTableWidgetItem(QString::number(m.cm.Tr[ii][jj])) ); + + } QString& TransformDialog::getLog() { @@ -329,7 +366,8 @@ void TransformDialog::on_okButton_pressed() { //matrix = matrix * currentMatrix; // store the current matrix as matrix because we left // the values in the line edit widgets - matrix = currentMatrix; + if(absoluteRB->isChecked()) matrix = currentMatrix; + else matrix=matrix*currentMatrix; accept(); } @@ -371,3 +409,8 @@ void TransformDialog::on_rotateZUpPB_clicked() rotateDial->setValue(90); xAxisRB->setChecked(true); } + +// Freezing means that +void TransformDialog::freeze ( ) +{ +} diff --git a/src/meshlabplugins/meshfilter/transformDialog.h b/src/meshlabplugins/meshfilter/transformDialog.h index 7446c2387..48523ba5f 100644 --- a/src/meshlabplugins/meshfilter/transformDialog.h +++ b/src/meshlabplugins/meshfilter/transformDialog.h @@ -26,6 +26,9 @@ /* $Log$ +Revision 1.2 2007/07/24 07:20:24 cignoni +Added Freeze transform and improved transformation dialog + Revision 1.1 2006/01/30 20:43:57 giec Added filter dialog files @@ -115,6 +118,7 @@ private slots: // Rotate X / Z Up push buttons: simply fill Rotate fields void on_rotateZUpPB_clicked(); void on_rotateXUpPB_clicked(); + void freeze(); public: @@ -123,9 +127,8 @@ public: // used to compute transformation on meshfilter.cpp Matrix44f& getTransformation(); - void setMesh(CMeshO *mesh); + void setMesh(MeshModel &m); QString& getLog(); - private: // members CMeshO *mesh; Point3f minBbox, maxBbox; // min and max of bounding box @@ -146,6 +149,9 @@ private: // functions void setRotate(int value = 180); // void setScale(QString x = "1.0", QString y = "1.0", QString z = "1.0"); + void resizeEvent ( QResizeEvent * event ); + void showEvent ( QShowEvent * event ); + }; diff --git a/src/meshlabplugins/meshfilter/ui/transformDialog.ui b/src/meshlabplugins/meshfilter/ui/transformDialog.ui index 31df9e61f..63301523a 100644 --- a/src/meshlabplugins/meshfilter/ui/transformDialog.ui +++ b/src/meshlabplugins/meshfilter/ui/transformDialog.ui @@ -1,15 +1,12 @@ - - - TransformDialog 0 0 - 598 - 526 + 672 + 666 @@ -18,287 +15,520 @@ ../../../meshlab/images/eye128.png - + 9 6 - - - - Scale + + + + 0 - - - 9 - - - 6 - - - - - Scale to unit box - - - - - - - 0 - - - 6 - - - - - Z - - - zScaleLE - - - - - - - - - - - - - Y - - - yScaleLE - - - - - - - X - - - xScaleLE - - - - - - - - - - Uniform - - - - - - - + + 6 + + + + + Rotate + + + + + + + Move + + + + + + + Scale + + + + - - - - Rotate + + + + 0 - - - 9 - - - 6 - - - - - 359 - - - 180 - - - Qt::Vertical - - - true - - - true - - - true - - - false - - - - - - - Rotate Z Up - - - - - - - Rotate X Up - - - - - - - Center - - + + 6 + + + + + 0 + + + 6 + + + + + Rotate + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + 0 + + + 6 + + + + + X + + + + + + + Y + + + + + + + Z + + + + + + + + + 359 + + + 180 + + + Qt::Vertical + + + true + + + true + + + true + + + false + + + + + + + + + 0.0 + + + 10 + + + + + + + Rotation Center + + + + 9 + + + 6 + + + + + Origin + + + + + + + Mesh Center + + + + + + + + + + Rotate X Up + + + + + + + Rotate Z Up + + + + + + + Qt::Vertical + + + + 16 + 56 + + + + + + + + + + + Transformation mode + + + + 9 + + + 6 + + + + + Absolute + + + true + + + + + + + Relative + + + + + + + + + + + + 0 + + + 6 + + + - 9 + 0 6 - - - - Mesh Center + + + + Move + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + + + + + + + Z + + + zMoveLE + + + + + + + + + + Y + + + yMoveLE + + + + + + + X + + + xMoveLE + + + + + + + + + Move center to origin + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - - - - Origin + + + + Scale + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + Z + + + zScaleLE + + + + + + + + + + + + + Y + + + yScaleLE + + + + + + + X + + + xScaleLE + + + + + + + + + + Uniform + + + + + + + + + Scale to unit box + + + + - - - - - - 0.0 - - - 10 - - - - - - - 0 - - - 6 - - - - - X + + + + + + + + Current Transformation Matrix + + + + 4 - - - - - - Y + + 3 - - - - - - Z - - - - - - - + + + + + 9 + + + + + + + + + + + 0 + + + 6 + + + + + + 5 + 5 + 1 + 0 + + + + Bounding Box Max + + + + + + + bboxValueMinLBL + + + + + + + Bounding Box Min + + + + + + + + 5 + 5 + 2 + 0 + + + + bboxValueMaxLBL + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + - - - - Move - - - - 9 - - - 6 - - - - - Move center to origin - - - - - - - 0 - - - 6 - - - - - - - - - - - Z - - - zMoveLE - - - - - - - - - - Y - - - yMoveLE - - - - - - - X - - - xMoveLE - - - - - - - - - + 0 @@ -320,93 +550,44 @@ - + - OK + Apply - + - Cancel + Close - - - - 0 + + + + + 11 + - - 6 + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:11pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:13pt;"><span style=" font-size:11pt;">MeshLab keeps for each layer/mesh a current trasformation matrix </span><span style=" font-size:11pt; font-weight:600; font-style:italic;">T</span><span style=" font-size:11pt;">: </span><span style=" font-size:11pt; font-weight:600; font-style:italic;">T</span><span style=" font-size:11pt;"> is used in rendering and alignment. The </span><span style=" font-size:11pt; font-weight:600; font-style:italic;">T</span><span style=" font-size:11pt;"> matrix is usually </span><span style=" font-size:11pt; font-weight:600; font-style:italic;">NOT</span><span style=" font-size:11pt;"> saved when you export the mesh into a generic format.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">With this dialog you can change <span style=" font-weight:600; font-style:italic;">T</span> </p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">When the transformation mode is set to relative all the computations involves the <span style=" font-weight:600; font-style:italic;">T</span> Matrix (e.g. the </p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To actually change the coords of the mesh and baking the matrix into the mesh itself you have to use the <span style=" font-weight:600; font-style:italic;">freeze</span> filter (in that case <span style=" font-weight:600; font-style:italic;">T</span> become the Identity).</p></body></html> - - - - Bounding Box Max - - - - - - - Bounding Box Min - - - - - - - bboxValueMaxLBL - - - - - - - bboxValueMinLBL - - - - - - - - - 0 - - - 6 - - - - - Move - - - - - - - Rotate - - - - - - - Scale - - - - + - isMoveRB isRotateRB @@ -418,7 +599,7 @@ - cancelButton + closeButton clicked() TransformDialog reject()