SVGPro dialog allow to modify the main properies of SVG documents

This commit is contained in:
Paolo Cignoni cignoni 2007-06-13 09:16:34 +00:00
parent 9591dddab8
commit fac74e818f
8 changed files with 767 additions and 360 deletions

View File

@ -5,6 +5,7 @@
#include "editslice.h"
#include <qstring.h>
#include <wrap/gl/pick.h>
#include <vcg/complex/trimesh/create/platonic.h>
#include <vcg/simplex/vertexplus/base.h>
#include <vcg/simplex/vertexplus/component_ocf.h>
@ -18,7 +19,7 @@
#include<limits>
#include <vcg/complex/edgemesh/update/bounding.h>
#include <wrap/io_trimesh/import.h>
#include <wrap/io_edgemesh/export_svg.h>
#include <vcg/complex/trimesh/update/position.h>
#include <vcg/complex/trimesh/update/bounding.h>
#include <vcg/complex/trimesh/update/normal.h>
@ -83,41 +84,27 @@ const PluginInfo &ExtraMeshSlidePlugin::Info()
}
void ExtraMeshSlidePlugin::restoreDefault(){
trackball_slice.Reset();
}
void ExtraMeshSlidePlugin::mouseReleaseEvent (QAction *,QMouseEvent * e, MeshModel &/*m*/, GLArea * gla)
{
if(dialogsliceobj->getDefaultTrackball())
gla->trackball.MouseUp(e->x(),gla->height()-e->y(),QT2VCG(e->button(), e->modifiers()));
else trackball_slice.MouseUp(e->x(),gla->height()-e->y(),QT2VCG(e->button(), e->modifiers()));
{
trackball_slice.MouseUp(e->x(),gla->height()-e->y(),QT2VCG(e->button(), e->modifiers()));
}
void ExtraMeshSlidePlugin::mousePressEvent (QAction *, QMouseEvent * e, MeshModel &m, GLArea * gla)
{
if ( (dialogsliceobj->getDefaultTrackball()) &&
!(e->modifiers() & Qt::ShiftModifier) &&
(e->button()==Qt::LeftButton) &&
!(e->modifiers() & Qt::ControlModifier))
gla->trackball.MouseDown(e->x(),(gla->height()-e->y()),QT2VCG(e->button(), e->modifiers()) );
if ( (!dialogsliceobj->getDefaultTrackball())&&
(e->button()==Qt::LeftButton) &&
!(e->modifiers() & Qt::ShiftModifier) )
trackball_slice.MouseDown(e->x(),gla->height()-e->y(),QT2VCG(e->button(), e->modifiers()) );
if ( (e->button()==Qt::LeftButton) &&
!(e->modifiers() & Qt::ShiftModifier) )
trackball_slice.MouseDown(e->x(),gla->height()-e->y(),QT2VCG(e->button(), e->modifiers()) );
gla->update();
}
void ExtraMeshSlidePlugin::mouseMoveEvent (QAction *,QMouseEvent * e, MeshModel &/*m*/, GLArea * gla)
{
if( (e->buttons()| Qt::LeftButton) &&
(dialogsliceobj->getDefaultTrackball()) &&
!(e->modifiers() & Qt::ShiftModifier) &&
!(e->modifiers() & Qt::ControlModifier))
gla->trackball.MouseMove(e->x(),gla->height()-e->y());
if( (e->buttons()| Qt::LeftButton) &&
!(dialogsliceobj->getDefaultTrackball()) &&
!(e->modifiers() & Qt::ShiftModifier))
trackball_slice.MouseMove(e->x(),gla->height()-e->y());
if( (e->buttons()| Qt::LeftButton) &&
!(e->modifiers() & Qt::ShiftModifier))
trackball_slice.MouseMove(e->x(),gla->height()-e->y());
gla->update();
}
void ExtraMeshSlidePlugin::RestoreDefault(){
@ -125,60 +112,103 @@ void ExtraMeshSlidePlugin::mouseReleaseEvent (QAction *,QMouseEvent * e, MeshMo
gla->trackball.Reset();
gla->update();
}
void ExtraMeshSlidePlugin::SlotExportButton(){
void ExtraMeshSlidePlugin::SlotExportButton()
{
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::ShowDirsOnly );
}
else
{
QFileDialog saveF;
fileName = saveF.getSaveFileName(gla->window(), tr("Save polyline in sigle File"),"/",tr("Mesh (*.svg)"));
}
QFileDialog saveF;
fileName = saveF.getSaveFileName(gla->window(), tr("Saving..."),"/",tr("Mesh (*.svg)"));
if (fileName==0) return;
dialogsliceobj->hide();
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
a,b,c coordinata centro di rotazione del piano
x,y,z vettore di rotazione del pinao
*/
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;
mesh_grid.Set(m.cm.face.begin() ,m.cm.face.end());
edge_mesh.Clear();
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);
Box3f b= edge_mesh.bbox;
if (!dialogsliceobj->getExportOption()){
bool EvportVector=false; //variabile used after
vector<n_EdgeMesh*> ev;
ev.clear();
Point3d d((*dir).X(),(*dir).Y(), (*dir).Z());
pr.setPlane(0, d);
svgpro= new SVGPro(gla->window(), point_Vector.size(), dialogsliceobj->getExportOption());
svgpro->Init(pr.getWidth(), pr.getHeight(), pr.getViewBox()[0], pr.getViewBox()[1], pr.getScale());
if ( svgpro->exec() == QDialog::Accepted )
{
UpdateVal(svgpro, &pr);
if (!dialogsliceobj->getExportOption())
pr.numCol=1;
else
pr.numCol=point_Vector.size();
pr.numRow=1;
mesh_grid = new TriMeshGrid();
mesh_grid->Set(m.cm.face.begin() ,m.cm.face.end());
float scale = (pr.getViewBox().V(0)/pr.numCol) /edgeMax ;
pr.setScale(scale);
pr.setTextDetails( svgpro->showText );
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
/ a,b,c coordinata centro di rotazione del piano
/ x,y,z vettore di rotazione del pinao
*/
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;
edge_mesh = new n_EdgeMesh();
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;
Point3d d((*dir).X(),(*dir).Y(), (*dir).Z());
pr.setPlane(0, d);
vcg::edge::io::ExporterSVG<n_EdgeMesh>::Save(&edge_mesh, fileN.toLatin1().data(), pr );
fileN=fileName.left( fileName.length ()- 4 )+"_"+index+".svg";
pr.setPosition(Point2d(0,0));
pr.numCol=1;
pr.numRow=1;
vcg::edge::io::ExporterSVG<n_EdgeMesh>::Save(edge_mesh, fileN.toLatin1().data(), pr );
}
else{
ev.push_back(edge_mesh);
EvportVector=true;
}
}
else{
vcg::edge::io::SVGProperties pr;
Point3d d((*dir).X(),(*dir).Y(), (*dir).Z());
pr.setPlane(0, d);
}
}
if(EvportVector){
vcg::edge::io::ExporterSVG<n_EdgeMesh>::Save(&ev, fileName.toLatin1().data(),pr);
//Free memory allocated
vector<n_EdgeMesh*>::iterator it;
for(it=ev.begin(); it!=ev.end(); it++){
delete *it;}
}
}
dialogsliceobj->show();
}
void ExtraMeshSlidePlugin::UpdateVal(SVGPro* sv, SVGProperties * pr){
bool ok;
pr->setDimension(sv->getImageWidth(),sv->getImageHeight());
pr->setViewBox(Point2d(sv->getViewBoxWidth(), sv->getViewBoxHeight()));
}
void ExtraMeshSlidePlugin::Decorate(QAction * ac, MeshModel &m, GLArea * gla)
{
@ -199,11 +229,12 @@ void ExtraMeshSlidePlugin::mouseReleaseEvent (QAction *,QMouseEvent * e, MeshMo
// }
}
void ExtraMeshSlidePlugin::StartEdit(QAction * , MeshModel &m, GLArea *gla ){
gla->update();
if(!first){
dialogsliceobj=new dialogslice(gla->window());
dialogsliceobj->show();
first=true;
this->m=m;
QObject::connect(dialogsliceobj, SIGNAL(exportMesh()), this,SLOT(SlotExportButton()));
QObject::connect(dialogsliceobj, SIGNAL(Update_glArea()), this, SLOT(upGlA()));
@ -214,20 +245,19 @@ void ExtraMeshSlidePlugin::mouseReleaseEvent (QAction *,QMouseEvent * e, MeshMo
gla->update();
}
}
void ExtraMeshSlidePlugin::DrawPlane(GLArea * gla, MeshModel &m){
b=m.cm.bbox; //Boundig Box
Point3f mi=b.min;
Point3f ma=b.max;
Point3f centre=b.Center() ;
float edgeMax=0;
edgeMax=0;
float LX= ma[0]-mi[0];
float LY= ma[1]-mi[1];
float LZ= ma[2]-mi[2];
edgeMax= max(LX, LY);
edgeMax=max(edgeMax, LZ); //edgeMax è il lato maggiore della BBox
edgeMax=max(edgeMax, LZ); //edgeMax: the longest side of BBox
dialogsliceobj->setDistanceRange(edgeMax);
glPushMatrix();
glPushAttrib(GL_COLOR_BUFFER_BIT|GL_LIGHTING_BIT);

View File

@ -5,7 +5,7 @@
#include <QObject>
#include <QStringList>
#include <QList>
#include "svgpro.h"
#include "slicedialog.h"
#include <meshlab/meshmodel.h>
#include <meshlab/interfaces.h>
@ -19,6 +19,8 @@
#include <vcg/simplex/edge/edge.h>
#include <wrap/io_edgemesh/export_svg.h>
typedef CMeshO n_Mesh;
class n_Face;
@ -31,7 +33,7 @@ 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;
typedef vcg::edge::io::SVGProperties SVGProperties;
@ -55,11 +57,11 @@ public:
virtual void mouseMoveEvent (QAction *,QMouseEvent *event, MeshModel &/*m*/, GLArea * );
virtual void mouseReleaseEvent (QAction *,QMouseEvent *event, MeshModel &/*m*/, GLArea * );
virtual QList<QAction *> actions() const ;
void restoreDefault();
private:
TriMeshGrid mesh_grid;
n_EdgeMesh edge_mesh;
TriMeshGrid* mesh_grid;
n_EdgeMesh* edge_mesh;
n_Mesh trimesh;
std::vector<typename TriMeshGrid::Cell *> intersected_cells;
vector<Point3f> point_Vector;
@ -69,10 +71,15 @@ private:
MeshModel m;
bool first;
Box3f b;
SVGPro *svgpro;
float edgeMax;
SVGProperties pr;
dialogslice *dialogsliceobj;
void DrawPlane(GLArea * gla,MeshModel &m);
void UpdateVal(SVGPro * sv, SVGProperties * pr);
bool activeDefaultTrackball;
bool disableTransision;
public Q_SLOTS:
void RestoreDefault();
void SlotExportButton();

View File

@ -4,37 +4,20 @@ dialogslice::dialogslice(QWidget *parent)
: QDockWidget(parent)
{
ui.setupUi(this);
numPlane=1;
distance=1;
numPlane=1; //number of plans
distance=1;
defaultTrackball=false;
//defaultTrackball=false;
restoreDefalut=false;
QPoint p=parent->mapToGlobal(QPoint(0,0));
this->setGeometry(p.x()+parent->width()-width(),p.y()+30,width(),height() );
this->setGeometry(p.x()+(parent->width()-width()),p.y()+40,width(),height() );
this->setFloating(true);
multi_sigleExportFile=false;
multi_sigleExportFile=false; //Multi/Single file choose
}
dialogslice::~dialogslice()
{
}
void dialogslice::on_DefaultTrackball_clicked(bool f)
{
defaultTrackball=f;
}
void dialogslice::on_on_slideTrackBall_clicked(bool f)
{
defaultTrackball=!f;
}
void dialogslice::on_spinBoxPlane_valueChanged(int x)
{emit Update_glArea();
numPlane=x;
dialogslice::~dialogslice(){
}
void dialogslice::on_DefultButton_clicked()
{
@ -44,7 +27,7 @@ void dialogslice::on_DefultButton_clicked()
numPlane=1;
distance=1;
this->ui.SliderPlaneDistance->setValue(1);
this->ui.spinBoxPlane->setValue(1);
}
@ -58,8 +41,28 @@ emit exportMesh();
void dialogslice::on_Update_Val_clicked()
void dialogslice::on_SliderPlaneDistance_sliderMoved(int x)
{
distanceDefault=false;
distance=x;
QString c;
ui.DistanceEdit->setText(c.setNum(distance*distanceRange));
emit Update_glArea();
}
void dialogslice::on_Exporter_singleFile_clicked()
{
this->multi_sigleExportFile=true;
}
void dialogslice::on_Exporter_MultiFile_clicked()
{
this->multi_sigleExportFile=false;
}
void dialogslice::on_DistanceEdit_returnPressed()
{
distanceDefault=false;
bool ok;
float val=this->ui.DistanceEdit->text().toFloat(&ok);
if (ok)
@ -74,46 +77,19 @@ float val=this->ui.DistanceEdit->text().toFloat(&ok);
emit Update_glArea();
}
void dialogslice::on_SliderPlaneDistance_sliderMoved(int x)
{
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;
}
void dialogslice::on_EditDistanceCheck_stateChanged(int i)
{
if (i==0){
this->ui.SliderPlaneDistance->setEnabled(false);
ui.Distnace_edit_group->setEnabled(false);
distanceDefault=true;
void dialogslice::on_spinBox_valueChanged(int x)
{numPlane=x;
if(x>1){
ui.DistanceEdit->setEnabled(true);
ui.SliderPlaneDistance->setEnabled(true);
ui.SliderPlaneDistance->setValue(defaultdistance/distanceRange);
}
else
{
ui.DistanceEdit->setEnabled(false);
ui.SliderPlaneDistance->setEnabled(false);
}
}
else {
this->ui.SliderPlaneDistance->setEnabled(true);
ui.Distnace_edit_group->setEnabled(true);
this->ui.SliderPlaneDistance->setValue(defaultdistance/distanceRange);
this->distance=defaultdistance/distanceRange;
distanceDefault=false;
}
emit Update_glArea();
emit Update_glArea();
}
}

View File

@ -28,7 +28,7 @@ public:
}
inline void setDistanceRange(float dRange){
this->distanceRange=dRange/100;
this->distanceRange=dRange/100; // Scale of values in slider rappresent the value in px of any tick
ui.labelDistanceRange->setText(QString("Distance range from 0 to "+ QString::number(dRange)));
}
@ -49,26 +49,17 @@ private:
bool defaultTrackball;
bool restoreDefalut;
private slots:
void on_EditDistanceCheck_stateChanged(int);
void on_spinBox_valueChanged(int);
void on_DistanceEdit_returnPressed();
void on_Exporter_MultiFile_clicked();
void on_Exporter_singleFile_clicked();
void on_SliderPlaneDistance_sliderMoved(int);
void on_Update_Val_clicked();
void on_ExportButton_clicked();
void on_DefultButton_clicked();
void on_spinBoxPlane_valueChanged(int);
void on_on_slideTrackBall_clicked(bool);
void on_DefaultTrackball_clicked(bool);
};
#endif

View File

@ -45,7 +45,7 @@
<x>20</x>
<y>30</y>
<width>331</width>
<height>341</height>
<height>330</height>
</rect>
</property>
<property name="minimumSize" >
@ -94,77 +94,38 @@
<property name="title" >
<string>Distance between plans</string>
</property>
<widget class="QLineEdit" name="DistanceEdit" >
<property name="geometry" >
<rect>
<x>190</x>
<y>30</y>
<width>101</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>1</string>
</property>
<property name="echoMode" >
<enum>QLineEdit::Normal</enum>
</property>
<property name="cursorPosition" >
<number>1</number>
</property>
<property name="alignment" >
<set>Qt::AlignHCenter</set>
</property>
</widget>
<widget class="QLabel" name="labelDistanceRange" >
<property name="geometry" >
<rect>
<x>10</x>
<y>70</y>
<width>291</width>
<width>241</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>180</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>
<x>10</x>
<y>10</y>
<width>101</width>
<height>21</height>
</rect>
</property>
<property name="text" >
<string>1</string>
</property>
<property name="echoMode" >
<enum>QLineEdit::Normal</enum>
</property>
<property name="cursorPosition" >
<number>1</number>
</property>
<property name="alignment" >
<set>Qt::AlignHCenter</set>
</property>
</widget>
</widget>
<widget class="QCheckBox" name="EditDistanceCheck" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>141</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>Manualy edit distance</string>
</property>
</widget>
<widget class="QSlider" name="SliderPlaneDistance" >
<property name="enabled" >
<bool>false</bool>
@ -208,36 +169,103 @@
<number>1</number>
</property>
</widget>
<widget class="QToolButton" name="DefultButton" >
<property name="geometry" >
<rect>
<x>20</x>
<y>20</y>
<width>91</width>
<height>30</height>
</rect>
</property>
<property name="text" >
<string>Restore Default</string>
</property>
</widget>
</widget>
<widget class="QToolButton" name="DefultButton" >
<widget class="QGroupBox" name="groupBox_4" >
<property name="geometry" >
<rect>
<x>10</x>
<y>280</y>
<width>91</width>
<height>30</height>
<x>120</x>
<y>200</y>
<width>211</width>
<height>51</height>
</rect>
</property>
<property name="text" >
<string>Restore Default</string>
<property name="minimumSize" >
<size>
<width>200</width>
<height>30</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<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 class="QToolButton" name="ExportButton" >
<property name="geometry" >
<rect>
<x>110</x>
<y>10</y>
<width>96</width>
<height>30</height>
</rect>
</property>
<property name="text" >
<string>Export Polyline...</string>
</property>
<property name="popupMode" >
<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>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox" >
<property name="geometry" >
<rect>
<x>10</x>
<y>0</y>
<width>99</width>
<width>321</width>
<height>51</height>
</rect>
</property>
<property name="title" >
<string>Number of plans</string>
</property>
<widget class="QSpinBox" name="spinBoxPlane" >
<widget class="QSpinBox" name="spinBox" >
<property name="geometry" >
<rect>
<x>10</x>
<x>30</x>
<y>20</y>
<width>50</width>
<height>18</height>
@ -271,139 +299,12 @@
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_3" >
<property name="geometry" >
<rect>
<x>10</x>
<y>200</y>
<width>100</width>
<height>61</height>
</rect>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="title" >
<string>Trackball mode</string>
</property>
<widget class="QRadioButton" name="on_slideTrackBall" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>151</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>only Plane</string>
</property>
<property name="checked" >
<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_4" >
<property name="geometry" >
<rect>
<x>120</x>
<y>250</y>
<width>211</width>
<height>61</height>
</rect>
</property>
<property name="minimumSize" >
<size>
<width>200</width>
<height>30</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<widget class="QToolButton" name="ExportButton" >
<property name="geometry" >
<rect>
<x>110</x>
<y>20</y>
<width>96</width>
<height>30</height>
</rect>
</property>
<property name="text" >
<string>Export Polyline...</string>
</property>
<property name="popupMode" >
<enum>QToolButton::InstantPopup</enum>
</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 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>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11" />
<tabstops>
<tabstop>spinBoxPlane</tabstop>
<tabstop>SliderPlaneDistance</tabstop>
<tabstop>on_slideTrackBall</tabstop>
<tabstop>DefaultTrackball</tabstop>
<tabstop>DefultButton</tabstop>
<tabstop>ExportButton</tabstop>
</tabstops>

View File

@ -0,0 +1,115 @@
#include "svgpro.h"
SVGPro::SVGPro(QWidget *parent, int numPlans, bool ExportMode )
: QDialog(parent)
{ QString c;
ui.setupUi(this);
this->ExportMode=ExportMode;
ui.numPlane->setText(c.setNum(numPlans));
if(ExportMode){
numRow=1;
numCol=numPlans;
ui.TitleLabel->setText("Exporting in single file");
//ui.ImageWidth->setText(
}
else{
numRow=1;
numCol=1;
ui.TitleLabel->setText("Exporting in Multi file");
}
mesureUnit="cm";
}
SVGPro::~SVGPro()
{
}
void SVGPro::Init(int image_width, int image_height, int viewBox_width, int viewBox_height, float scale){
QString c;
if( /*ExportMode &&*/((image_width*numCol)!=(image_height*numRow)))
ui.ImageWidth->setText(c.setNum(image_height*numCol));
else
ui.ImageWidth->setText(c.setNum(image_width));
if(/*ExportMode &&*/((viewBox_width*numCol)!=(viewBox_height*numRow)))
ui.viewBox_Width->setText(c.setNum(viewBox_height*numCol));
else
ui.viewBox_Width->setText(c.setNum(viewBox_width));
ui.ImageHeight->setText(c.setNum(image_height));
ui.viewBox_Height->setText(c.setNum(viewBox_height));
}
void SVGPro::on_ImageWidth_textChanged(const QString c)
{
bool ok;
QString q;
int num=c.toInt(&ok, 10)/numCol;
if(ok) ui.WidthLabel->setText(q.setNum(num)+" "+mesureUnit);
}
void SVGPro::on_ImageHeight_textChanged(const QString c)
{
bool ok;
QString q;
int num=c.toInt(&ok, 10)/numRow;
if(ok) ui.HeightLabel->setText(q.setNum(num)+" "+mesureUnit);
}
void SVGPro::on_cm_choose_clicked()
{
mesureUnit="cm";
}
void SVGPro::on_pixel_choose_clicked()
{
mesureUnit="px";
}
void SVGPro::on_viewBox_Width_textChanged(const QString c)
{
bool ok;
QString q;
int num=c.toInt(&ok, 10)/numCol;
if(ok) ui.WidthLabelViewBox->setText(q.setNum(num)+" px");
}
void SVGPro::on_viewBox_Height_textChanged(const QString c)
{
bool ok;
QString q;
int num=c.toInt(&ok, 10)/numRow;
if(ok) ui.HeightLabelViewBox->setText(q.setNum(num)+" px");
}
void SVGPro::on_buttonBox_accepted()
{
accept();
}
void SVGPro::on_buttonBox_rejected()
{
reject ();
}
void SVGPro::on_view_text_stateChanged(int i)
{
if(i==0){
showText=false;
}
else{
showText=true;
}
}

View File

@ -0,0 +1,43 @@
#ifndef SVGPRO_H
#define SVGPRO_H
#include <QDialog>
#include "ui_svgpro.h"
class SVGPro : public QDialog
{
Q_OBJECT
public:
SVGPro(QWidget *parent, int numPlans, bool ExportMode);
~SVGPro();
void Init(int image_width, int image_height, int viewBox_width, int viewBox_height, float scale);
inline int getImageWidth(){ bool ok; return ui.ImageWidth->text().toInt(&ok, 10);}
inline int getImageHeight(){ bool ok; return ui.ImageHeight->text().toInt(&ok, 10);}
inline int getViewBoxWidth(){ bool ok; return ui.viewBox_Width->text().toInt(&ok, 10);}
inline int getViewBoxHeight(){ bool ok; return ui.viewBox_Height->text().toInt(&ok, 10);}
bool showText;
int numCol;
int numRow;
bool ExportMode;
private:
Ui::SVGProClass ui;
QString mesureUnit;
private slots:
void on_view_text_stateChanged(int);
void on_buttonBox_rejected();
void on_buttonBox_accepted();
void on_viewBox_Height_textChanged(const QString c);
void on_viewBox_Width_textChanged(const QString c);
void on_pixel_choose_clicked();
void on_cm_choose_clicked();
void on_ImageHeight_textChanged(const QString c);
void on_ImageWidth_textChanged(const QString c);
};
#endif // SVGPRO_H

View File

@ -0,0 +1,344 @@
<ui version="4.0" >
<class>SVGProClass</class>
<widget class="QDialog" name="SVGProClass" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>366</height>
</rect>
</property>
<property name="windowTitle" >
<string>SVGPro</string>
</property>
<widget class="QGroupBox" name="groupBox_3" >
<property name="geometry" >
<rect>
<x>280</x>
<y>50</y>
<width>120</width>
<height>61</height>
</rect>
</property>
<widget class="QRadioButton" name="pixel_choose" >
<property name="geometry" >
<rect>
<x>10</x>
<y>30</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>Pixel</string>
</property>
</widget>
<widget class="QRadioButton" name="cm_choose" >
<property name="geometry" >
<rect>
<x>10</x>
<y>10</y>
<width>83</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>Cm</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QLabel" name="TitleLabel" >
<property name="geometry" >
<rect>
<x>10</x>
<y>10</y>
<width>181</width>
<height>21</height>
</rect>
</property>
<property name="font" >
<font>
<family>MS Shell Dlg 2</family>
<pointsize>13</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
</widget>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="geometry" >
<rect>
<x>240</x>
<y>340</y>
<width>156</width>
<height>23</height>
</rect>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QGroupBox" name="groupBox" >
<property name="geometry" >
<rect>
<x>40</x>
<y>30</y>
<width>241</width>
<height>131</height>
</rect>
</property>
<property name="title" >
<string>Image Size</string>
</property>
<widget class="QLabel" name="label_3" >
<property name="geometry" >
<rect>
<x>140</x>
<y>20</y>
<width>46</width>
<height>14</height>
</rect>
</property>
<property name="text" >
<string>Height</string>
</property>
</widget>
<widget class="QLabel" name="label_2" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>46</width>
<height>14</height>
</rect>
</property>
<property name="text" >
<string>Width</string>
</property>
</widget>
<widget class="QLabel" name="HeightLabel" >
<property name="geometry" >
<rect>
<x>100</x>
<y>110</y>
<width>46</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="ImageHeight" >
<property name="geometry" >
<rect>
<x>140</x>
<y>40</y>
<width>80</width>
<height>18</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="ImageWidth" >
<property name="geometry" >
<rect>
<x>10</x>
<y>40</y>
<width>81</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="numPlane" >
<property name="geometry" >
<rect>
<x>100</x>
<y>70</y>
<width>46</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>20</x>
<y>70</y>
<width>82</width>
<height>16</height>
</rect>
</property>
<property name="text" >
<string>Number of Item:</string>
</property>
</widget>
<widget class="QLabel" name="label_7" >
<property name="geometry" >
<rect>
<x>20</x>
<y>90</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text" >
<string>Width of Items:</string>
</property>
</widget>
<widget class="QLabel" name="label_8" >
<property name="geometry" >
<rect>
<x>20</x>
<y>110</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text" >
<string>Height of Items:</string>
</property>
</widget>
<widget class="QLabel" name="WidthLabel" >
<property name="geometry" >
<rect>
<x>100</x>
<y>90</y>
<width>46</width>
<height>21</height>
</rect>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2" >
<property name="geometry" >
<rect>
<x>40</x>
<y>170</y>
<width>241</width>
<height>131</height>
</rect>
</property>
<property name="title" >
<string>View Box Resolution</string>
</property>
<widget class="QLabel" name="label_5" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>46</width>
<height>14</height>
</rect>
</property>
<property name="text" >
<string>Width</string>
</property>
</widget>
<widget class="QLabel" name="label_6" >
<property name="geometry" >
<rect>
<x>140</x>
<y>20</y>
<width>46</width>
<height>14</height>
</rect>
</property>
<property name="text" >
<string>Height</string>
</property>
</widget>
<widget class="QLineEdit" name="viewBox_Width" >
<property name="geometry" >
<rect>
<x>10</x>
<y>40</y>
<width>81</width>
<height>18</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="viewBox_Height" >
<property name="geometry" >
<rect>
<x>140</x>
<y>40</y>
<width>80</width>
<height>18</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="HeightLabelViewBox" >
<property name="geometry" >
<rect>
<x>100</x>
<y>110</y>
<width>46</width>
<height>16</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_10" >
<property name="geometry" >
<rect>
<x>10</x>
<y>110</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text" >
<string>Height of Items:</string>
</property>
</widget>
<widget class="QLabel" name="label_9" >
<property name="geometry" >
<rect>
<x>10</x>
<y>80</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text" >
<string>Width of Items:</string>
</property>
</widget>
<widget class="QLabel" name="WidthLabelViewBox" >
<property name="geometry" >
<rect>
<x>100</x>
<y>80</y>
<width>46</width>
<height>16</height>
</rect>
</property>
</widget>
</widget>
<widget class="QCheckBox" name="view_text" >
<property name="geometry" >
<rect>
<x>300</x>
<y>180</y>
<width>71</width>
<height>18</height>
</rect>
</property>
<property name="text" >
<string>view text</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11" />
<resources/>
<connections/>
</ui>