Ui modify with multi/single file export choose

Export SVG changed
This commit is contained in:
Paolo Cignoni cignoni 2007-05-27 16:37:28 +00:00
parent a0f61cf79c
commit e45a00585f
5 changed files with 196 additions and 123 deletions

View File

@ -43,7 +43,11 @@ ExtraMeshSlidePlugin::ExtraMeshSlidePlugin() {
}
ExtraMeshSlidePlugin::~ExtraMeshSlidePlugin() {
if ( dialogsliceobj!=0) {
delete dialogsliceobj;
dialogsliceobj=0;
}
}
QList<QAction *> 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; i<point_Vector.size(); i++){
Point3f rotationCenter=m.cm.bbox.Center();
if (!dialogsliceobj->getExportOption()){
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; i<point_Vector.size(); i++){
Point3f rotationCenter=m.cm.bbox.Center(); //the point where the plans rotate
Point3f po=point_Vector[i];
Plane3f p;
p.SetDirection(*dir);
/* 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); //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<TriMeshGrid::Cell *> intersected_cells;
n_EdgeMesh edge_mesh;
n_Mesh trimesh;
vcg::Intersection<n_Mesh, n_EdgeMesh, n_Mesh::ScalarType, TriMeshGrid>(p , edge_mesh, avg_length, &mesh_grid, intersected_cells);
vcg::edge::UpdateBounding<n_EdgeMesh>::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<n_EdgeMesh>::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<n_EdgeMesh>::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();

View File

@ -12,13 +12,11 @@
#include <wrap/gui/trackball.h>
#include <vcg/space/index/grid_static_ptr.h>
// VCG Vertex
#include <vcg/simplex/vertex/vertex.h>
//#include <vcg/simplex/vertex/with/afvn.h>
//#include <vcg/simplex/face/base.h>
//#include <vcg/simplex/face/with/afav.h>
#include <vcg/complex/edgemesh/base.h>
//#include <vcg/complex/trimesh/base.h>
#include <vcg/simplex/edge/edge.h>
typedef CMeshO n_Mesh;
@ -28,13 +26,13 @@ class n_Edge;
class n_Vertex : public Vertex<float, n_Edge, n_Face> {};
class n_Edge : public vcg::Edge<n_Edge, n_Vertex> {};
//class n_Mesh : public vcg::tri::TriMesh< vector<n_Vertex>, vector<CFaceO> > {};
class n_EdgeMesh: public vcg::edge::EdgeMesh< vector<n_Vertex>, vector<n_Edge> > {};
typedef vcg::GridStaticPtr<CMeshO::FaceType, CMeshO::ScalarType> TriMeshGrid;
typedef vcg::edge::EdgeMesh<vector<n_Vertex>,vector<n_Edge> > 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<Point3f> point_Vector;
QString fileName;
QString fileName, dirName, fileN;
bool isDragging;
GLArea * gla;
MeshModel m;

View File

@ -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;
}

View File

@ -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);

View File

@ -85,10 +85,10 @@
<widget class="QGroupBox" name="groupBox_4" >
<property name="geometry" >
<rect>
<x>130</x>
<x>120</x>
<y>250</y>
<width>201</width>
<height>51</height>
<width>211</width>
<height>61</height>
</rect>
</property>
<property name="minimumSize" >
@ -103,24 +103,11 @@
<height>16777215</height>
</size>
</property>
<widget class="QToolButton" name="DefultButton" >
<property name="geometry" >
<rect>
<x>10</x>
<y>10</y>
<width>80</width>
<height>30</height>
</rect>
</property>
<property name="text" >
<string>Default</string>
</property>
</widget>
<widget class="QToolButton" name="ExportButton" >
<property name="geometry" >
<rect>
<x>100</x>
<y>10</y>
<x>110</x>
<y>20</y>
<width>96</width>
<height>30</height>
</rect>
@ -132,6 +119,38 @@
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
<widget class="QRadioButton" name="Exporter_singleFile" >
<property name="geometry" >
<rect>
<x>10</x>
<y>10</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>Single file</string>
</property>
<property name="checkable" >
<bool>false</bool>
</property>
</widget>
<widget class="QRadioButton" name="Exporter_MultiFile" >
<property name="geometry" >
<rect>
<x>10</x>
<y>30</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>Multi file</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox" >
<property name="geometry" >
@ -182,6 +201,19 @@
</property>
</widget>
</widget>
<widget class="QToolButton" name="DefultButton" >
<property name="geometry" >
<rect>
<x>0</x>
<y>280</y>
<width>80</width>
<height>30</height>
</rect>
</property>
<property name="text" >
<string>Default</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_3" >
<property name="geometry" >
<rect>
@ -206,19 +238,6 @@
<property name="title" >
<string>Trackball mode</string>
</property>
<widget class="QRadioButton" name="DefaultTrackball" >
<property name="geometry" >
<rect>
<x>10</x>
<y>40</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>Default</string>
</property>
</widget>
<widget class="QRadioButton" name="on_slideTrackBall" >
<property name="geometry" >
<rect>
@ -235,6 +254,19 @@
<bool>true</bool>
</property>
</widget>
<widget class="QRadioButton" name="DefaultTrackball" >
<property name="geometry" >
<rect>
<x>10</x>
<y>40</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>Default</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2" >
<property name="geometry" >
@ -293,16 +325,6 @@
</property>
</widget>
</widget>
<widget class="QLabel" name="labelDistanceRange" >
<property name="geometry" >
<rect>
<x>10</x>
<y>70</y>
<width>291</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QSlider" name="SliderPlaneDistance" >
<property name="enabled" >
<bool>false</bool>
@ -346,15 +368,41 @@
<number>1</number>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_5" >
<widget class="QLabel" name="labelDistanceRange" >
<property name="geometry" >
<rect>
<x>179</x>
<x>10</x>
<y>70</y>
<width>291</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QGroupBox" name="Distnace_edit_group" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="geometry" >
<rect>
<x>170</x>
<y>20</y>
<width>121</width>
<height>71</height>
</rect>
</property>
<widget class="QPushButton" name="Update_Val" >
<property name="geometry" >
<rect>
<x>60</x>
<y>40</y>
<width>51</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>Updade</string>
</property>
</widget>
<widget class="QLineEdit" name="DistanceEdit" >
<property name="geometry" >
<rect>
@ -377,19 +425,6 @@
<set>Qt::AlignHCenter</set>
</property>
</widget>
<widget class="QPushButton" name="Update_Val" >
<property name="geometry" >
<rect>
<x>60</x>
<y>40</y>
<width>51</width>
<height>23</height>
</rect>
</property>
<property name="text" >
<string>Updade</string>
</property>
</widget>
</widget>
</widget>
</widget>