From e45a00585f7b477fe44f2e5550bc7db0d79a9044 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Sun, 27 May 2007 16:37:28 +0000 Subject: [PATCH] Ui modify with multi/single file export choose Export SVG changed --- src/meshlabplugins/editslice/editslice.cpp | 124 +++++++++------- src/meshlabplugins/editslice/editslice.h | 16 +- src/meshlabplugins/editslice/slicedialog.cpp | 20 ++- src/meshlabplugins/editslice/slicedialog.h | 12 +- src/meshlabplugins/editslice/slicedialog.ui | 147 ++++++++++++------- 5 files changed, 196 insertions(+), 123 deletions(-) diff --git a/src/meshlabplugins/editslice/editslice.cpp b/src/meshlabplugins/editslice/editslice.cpp index d870cf622..20e060173 100644 --- a/src/meshlabplugins/editslice/editslice.cpp +++ b/src/meshlabplugins/editslice/editslice.cpp @@ -43,7 +43,11 @@ ExtraMeshSlidePlugin::ExtraMeshSlidePlugin() { } ExtraMeshSlidePlugin::~ExtraMeshSlidePlugin() { - +if ( dialogsliceobj!=0) { + delete dialogsliceobj; + + dialogsliceobj=0; + } } QList ExtraMeshSlidePlugin::actions() const { @@ -91,10 +95,7 @@ void ExtraMeshSlidePlugin::restoreDefault(){ trackball_slice.ButtonUp(QT2VCG(Qt::NoButton, Qt::ShiftModifier ) ); trackball_slice.ButtonUp(QT2VCG(Qt::NoButton, Qt::AltModifier ) ); - /*if (((e->modifiers() & Qt::ShiftModifier) && (e->modifiers() & Qt::ControlModifier) && - (e->button()==Qt::LeftButton))){ - - }*/ + if (((e->modifiers() & Qt::ControlModifier) && (e->button()==Qt::LeftButton)&& @@ -138,53 +139,70 @@ void ExtraMeshSlidePlugin::restoreDefault(){ gla->update(); } void ExtraMeshSlidePlugin::SlotExportButton(){ - - fileName = QFileDialog::getSaveFileName(gla->window(), tr("Save polyline File"),"/",tr("Mesh (*.svg)")); - - Matrix44f mat_trac_rotation ; - trackball_slice.track.rot.ToMatrix( mat_trac_rotation ); //Matrice di rotazione della trackball dei piani - - Point3f* dir=new Point3f(1,0,0); //inizializzo la normale del piano a 1, 0, 0 - (*dir)= mat_trac_rotation * (*dir); // moltiplico la matrice di rotazione per la normale del piano - - Point3f translation_plans=trackball_slice.track.tra; //vettore di translazione dei piani - for(int i=0; igetExportOption()){ + QFileDialog saveF; + dirName=saveF.getExistingDirectory(gla->window(),tr("Save polyline in one or more file, one each pane"), "Choose a directory",QFileDialog::Option::ShowDirsOnly ); + } + else + { + QFileDialog saveF; + fileName = saveF.getSaveFileName(gla->window(), tr("Save polyline in sigle File"),"/",tr("Mesh (*.svg)")); + } + + Matrix44f mat_trac_rotation ; + trackball_slice.track.rot.ToMatrix( mat_trac_rotation ); //rotation Matrix of the plans' trackball + Point3f* dir=new Point3f(1,0,0); //the plans' normal vector init + (*dir)= mat_trac_rotation * (*dir); //rotation of the directions vector + Point3f translation_plans=trackball_slice.track.tra; //vettore di translazione dei piani + for(int i=0; iX=x - dir->Y=y - dir->Z=z - a,b,c coordinata centro di rotazione del piano -*/ - Point3f off= mat_trac_rotation * (translation_plans+po); //definisco il vettore di translazione - + /* Equazione del piano ax+by+cz=distance + dir->X=x + dir->Y=y + dir->Z=z + a,b,c coordinata centro di rotazione del piano + */ + Point3f off= mat_trac_rotation * (translation_plans+po); //translation vector p.SetOffset( (rotationCenter.X()*dir->X() )+ (rotationCenter.Y()*dir->Y()) +(rotationCenter.Z()*dir->Z())+ (off*(*dir)) ); - double avg_length; //lunghezza media edge + double avg_length; mesh_grid.Set(m.cm.face.begin() ,m.cm.face.end()); std::vector intersected_cells; n_EdgeMesh edge_mesh; n_Mesh trimesh; vcg::Intersection(p , edge_mesh, avg_length, &mesh_grid, intersected_cells); vcg::edge::UpdateBounding::Box(edge_mesh); + + + + if (!dialogsliceobj->getExportOption()){ + QString index; + index.setNum(i); + fileN=dirName+"slice_"+index+".svg"; + vcg::edge::io::SVGProperties pr; + pr.setPlane(0,Point3d((*dir).X(),(*dir).Y(), (*dir).Z() )); + vcg::edge::io::ExporterSVG::Save(&edge_mesh, fileN.toLatin1().data(), pr ); + } + else{ + vcg::edge::io::SVGProperties pr; + pr.setPlane(0,Point3d((*dir).X(),(*dir).Y(), (*dir).Z() )); - //Export in svg - vcg::edge::io::SVGProperties pr; - pr.setPlane(0,Point3d((*dir).X(),(*dir).Y(), (*dir).Z() )); - - //fileName.insert(fileName.find( QRegExp(".svg"), 0 ),"_01"); - QString index; - index.setNum(i); - index="_"+index; - QString fn=fileName; - fn.insert(fileName.length()-4, index); - vcg::edge::io::ExporterSVG::Save(&edge_mesh, fn.toLatin1().data(), pr ); - } - + } + } } + + + + + + + + + + void ExtraMeshSlidePlugin::mouseReleaseEvent (QAction *,QMouseEvent * e, MeshModel &/*m*/, GLArea * gla) { @@ -205,23 +223,25 @@ void ExtraMeshSlidePlugin::restoreDefault(){ } void ExtraMeshSlidePlugin::EndEdit(QAction * , MeshModel &m, GLArea *gla ){ - dialogsliceobj->close(); + //if ( dialogsliceobj!=0) { + // delete dialogsliceobj; + + // dialogsliceobj=0; + // + // } } void ExtraMeshSlidePlugin::StartEdit(QAction * , MeshModel &m, GLArea *gla ){ if(!first){ dialogsliceobj=new dialogslice(gla->window()); - - - first=true;} - dialogsliceobj->show(); - this->m=m; - - - QObject::connect(dialogsliceobj, SIGNAL(exportMesh()), this,SLOT(SlotExportButton())); - QObject::connect(dialogsliceobj, SIGNAL(Update_glArea()), this, SLOT(upGlA())); - QObject::connect(dialogsliceobj, SIGNAL(RestoreDefault()), this, SLOT(RestoreDefault())); - } + dialogsliceobj->show(); + first=true; + this->m=m; + QObject::connect(dialogsliceobj, SIGNAL(exportMesh()), this,SLOT(SlotExportButton())); + QObject::connect(dialogsliceobj, SIGNAL(Update_glArea()), this, SLOT(upGlA())); + QObject::connect(dialogsliceobj, SIGNAL(RestoreDefault()), this, SLOT(RestoreDefault())); + } + } void ExtraMeshSlidePlugin::upGlA(){ gla->update(); diff --git a/src/meshlabplugins/editslice/editslice.h b/src/meshlabplugins/editslice/editslice.h index a2137d075..bf9d9984e 100644 --- a/src/meshlabplugins/editslice/editslice.h +++ b/src/meshlabplugins/editslice/editslice.h @@ -12,13 +12,11 @@ #include #include -// VCG Vertex + #include -//#include -//#include -//#include + #include -//#include + #include typedef CMeshO n_Mesh; @@ -28,13 +26,13 @@ class n_Edge; class n_Vertex : public Vertex {}; class n_Edge : public vcg::Edge {}; -//class n_Mesh : public vcg::tri::TriMesh< vector, vector > {}; + class n_EdgeMesh: public vcg::edge::EdgeMesh< vector, vector > {}; typedef vcg::GridStaticPtr TriMeshGrid; typedef vcg::edge::EdgeMesh,vector > Edge_Mesh; -//class MyFace : public FaceAFAV< CVertexO, CEdge, CFaceO > {}; + class ExtraMeshSlidePlugin : public QObject, public MeshEditInterface @@ -61,10 +59,8 @@ public: private: TriMeshGrid mesh_grid; - - vector point_Vector; - QString fileName; + QString fileName, dirName, fileN; bool isDragging; GLArea * gla; MeshModel m; diff --git a/src/meshlabplugins/editslice/slicedialog.cpp b/src/meshlabplugins/editslice/slicedialog.cpp index e8715ce0b..3434d2d61 100644 --- a/src/meshlabplugins/editslice/slicedialog.cpp +++ b/src/meshlabplugins/editslice/slicedialog.cpp @@ -11,8 +11,8 @@ dialogslice::dialogslice(QWidget *parent) restoreDefalut=false; QPoint p=parent->mapToGlobal(QPoint(0,0)); this->setGeometry(p.x()+parent->width()-width(),p.y()+30,width(),height() ); - this->setFloating(true); + multi_sigleExportFile=false; } @@ -54,13 +54,14 @@ void dialogslice::on_diasbledistance_toggled(bool f) if (f){ this->ui.SliderPlaneDistance->setEnabled(false); - + ui.Distnace_edit_group->setEnabled(false); distanceDefault=true; } else { this->ui.SliderPlaneDistance->setEnabled(true); + ui.Distnace_edit_group->setEnabled(true); this->ui.SliderPlaneDistance->setValue(defaultdistance/distanceRange); this->distance=defaultdistance/distanceRange; distanceDefault=false; @@ -98,4 +99,19 @@ distance=x; QString c; ui.DistanceEdit->setText(c.setNum(distance*distanceRange)); emit Update_glArea(); +} + + + + + + +void dialogslice::on_Exporter_singleFile_clicked() +{//not implemented yet +//this->multi_sigleExportFile=true; +} + +void dialogslice::on_Exporter_MultiFile_clicked() +{ +this->multi_sigleExportFile=false; } \ No newline at end of file diff --git a/src/meshlabplugins/editslice/slicedialog.h b/src/meshlabplugins/editslice/slicedialog.h index 85a55f2b7..408e7eb66 100644 --- a/src/meshlabplugins/editslice/slicedialog.h +++ b/src/meshlabplugins/editslice/slicedialog.h @@ -20,6 +20,9 @@ public: inline bool getRestoreDefalut(){return restoreDefalut;} inline void setRestoreDefalut(bool in){ restoreDefalut=in;} + inline bool getExportOption(){ + return multi_sigleExportFile; + } inline void setDefaultDistance(float f){ defaultdistance=f; } @@ -37,15 +40,20 @@ Q_SIGNALS: private: Ui::dialogsliceClass ui; int numPlane; //numeber of plane - float distance; //distance of plane + float distance; float distanceRange; float defaultdistance; QWidget* parent; bool distanceDefault; // enable/disable distance + bool multi_sigleExportFile; bool defaultTrackball; bool restoreDefalut; private slots: + void on_Exporter_MultiFile_clicked(); + void on_Exporter_singleFile_clicked(); + + void on_SliderPlaneDistance_sliderMoved(int); void on_Update_Val_clicked(); void on_diasbledistance_toggled(bool); @@ -53,8 +61,6 @@ private slots: void on_DefultButton_clicked(); - //void on_SliderPlaneDistance_valueChanged(int); - //void on_spinBoxDistance_valueChanged(int); void on_spinBoxPlane_valueChanged(int); void on_on_slideTrackBall_clicked(bool); diff --git a/src/meshlabplugins/editslice/slicedialog.ui b/src/meshlabplugins/editslice/slicedialog.ui index 0c341ee54..2792fdfcb 100644 --- a/src/meshlabplugins/editslice/slicedialog.ui +++ b/src/meshlabplugins/editslice/slicedialog.ui @@ -85,10 +85,10 @@ - 130 + 120 250 - 201 - 51 + 211 + 61 @@ -103,24 +103,11 @@ 16777215 - - - - 10 - 10 - 80 - 30 - - - - Default - - - 100 - 10 + 110 + 20 96 30 @@ -132,6 +119,38 @@ QToolButton::InstantPopup + + + + 10 + 10 + 83 + 18 + + + + Single file + + + false + + + + + + 10 + 30 + 83 + 18 + + + + Multi file + + + true + + @@ -182,6 +201,19 @@ + + + + 0 + 280 + 80 + 30 + + + + Default + + @@ -206,19 +238,6 @@ Trackball mode - - - - 10 - 40 - 83 - 18 - - - - Default - - @@ -235,6 +254,19 @@ true + + + + 10 + 40 + 83 + 18 + + + + Default + + @@ -293,16 +325,6 @@ - - - - 10 - 70 - 291 - 21 - - - false @@ -346,15 +368,41 @@ 1 - + - 179 + 10 + 70 + 291 + 21 + + + + + + false + + + + 170 20 121 71 + + + + 60 + 40 + 51 + 23 + + + + Updade + + @@ -377,19 +425,6 @@ Qt::AlignHCenter - - - - 60 - 40 - 51 - 23 - - - - Updade - -