MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SystemProcessSave.hpp
Go to the documentation of this file.
1 #ifndef SYSTEMPROCESSSAVE_HPP
2 #define SYSTEMPROCESSSAVE_HPP
3 
4 #include <Process.hpp>
5 
6 #include <QObject>
7 #include <QRegExp>
8 #include <Version.hpp>
9 
15 class QDialog;
16 class Ui_SaveMeshDialog;
17 class Ui_ExportMeshDialog;
18 class Ui_ExportStackDialog;
19 
20 namespace mgx { namespace process {
21 
76  class mgx_EXPORT StackSave : public StackProcess {
77  public:
78  StackSave(const StackProcess& proc) : Process(proc), StackProcess(proc) {}
79 
80  bool initialize(QStringList& parms, QWidget* parent);
81 
82  bool operator()(const QStringList& parms);
90  bool operator()(Stack* stack, Store* store, const QString& filename, int compressionLevel = 0);
91  QString folder() const { return "System"; }
92  QString name() const { return "Save"; }
93  QString description() const { return "Save a stack into a known 3D image format"; }
94  QStringList parmNames() const { return QStringList()
95  << "Filename" << "Store" << "Stack number" << "Compression Level (0-9)"; }
96  QStringList parmDescs() const { return QStringList()
97  << "Filename" << "Store" << "Stack number" << "Compression Level (0-9)"; }
98  QStringList parmDefaults() const { return QStringList() << "" << "Main" << "0" << "5"; }
100  {
101  ParmChoiceMap map;
102  map[1] = storeChoice();
103  return map;
104  }
105  QIcon icon() const { return QIcon(":/images/save.png"); }
106  };
107 
115  class mgx_EXPORT StackExport : public QObject, public StackProcess {
116  Q_OBJECT
117  public:
118  StackExport(const StackProcess& proc) : Process(proc), QObject(), StackProcess(proc) {}
119 
120  bool initialize(QStringList& parms, QWidget* parent);
121 
122  bool operator()(const QStringList& parms);
136  bool operator()(Stack* stack, Store* store, const QString& filename, const QString& type,
137  unsigned int nb_digit, bool generate_voxel_spacing);
138  QString folder() const { return "System"; }
139  QString name() const { return "Export"; }
140  QString description() const { return "Export a stack into an image sequence."; }
141  QStringList parmNames() const { return QStringList()
142  << "Filename" << "Store" << "Format" << "Generate Voxel Spacing" << "Stack number" << "NbDigits"; }
143  QStringList parmDescs() const { return QStringList()
144  << "Filename" << "Store" << "Format" << "Generate Voxel Spacing" << "Stack number" << "NbDigits"; }
146  << "" << "Main" << "CImg Auto" << "No" << "0" << "0"; }
148  {
149  ParmChoiceMap map;
150  map[1] = storeChoice();
151  map[3] = booleanChoice();
152  return map;
153  }
154  QIcon icon() const { return QIcon(":/images/save.png"); }
155 
156  protected slots:
157  void selectImageFile();
158  void setImageType(const QString& type);
159 
160  protected:
161  Ui_ExportStackDialog* ui;
162  QDialog* dlg;
163  };
164 
234  class mgx_EXPORT MeshSave : public QObject, public MeshProcess {
235  Q_OBJECT
236  public:
237  MeshSave(const MeshProcess& proc) : Process(proc), QObject(), MeshProcess(proc) {}
238 
239  bool operator()(const QStringList& parms);
246  bool operator()(Mesh* mesh, const QString& filename, bool transform);
247  QString folder() const { return "System"; }
248  QString name() const { return "Save"; }
249  QString description() const { return "Save a mesh into a known mesh format"; }
250  QStringList parmNames() const { return QStringList() << "Filename" << "Transform" << "Mesh number"; }
251  QStringList parmDescs() const { return QStringList() << "Filename" << "Transform" << "Mesh number"; }
252  QIcon icon() const { return QIcon(":/images/save.png"); }
253  QStringList parmDefaults() const { return QStringList() << "" << "No" << "0"; }
255  {
256  ParmChoiceMap map;
257  map[1] = map[2] = booleanChoice();
258  return map;
259  }
260  bool initialize(QStringList& parms, QWidget* parent);
261 
262  protected slots:
263  void selectMeshFile();
264 
265  protected:
266  QString properFile(QString filename) const;
267  void setMeshFile(const QString& filename);
268  Point3f savedPos(Point3f pos, bool transform, const Stack* stack);
269 
270  bool saveMesh(Mesh* mesh, const QString& filename, bool transform);
271 
272  QDialog* dlg;
273  Ui_SaveMeshDialog* ui;
274  };
275 
429  class mgx_EXPORT MeshExport : public QObject, public MeshProcess {
430  Q_OBJECT
431  public:
432  MeshExport(const MeshProcess& proc) : Process(proc), QObject(), MeshProcess(proc) {}
433 
434  bool operator()(const QStringList& parms);
442  bool operator()(Mesh* mesh, const QString& filename, const QString& type, bool transform);
443  QString folder() const { return "System"; }
444  QString name() const { return "Export"; }
445  QString description() const { return "Export a mesh into a known mesh format"; }
446  QStringList parmNames() const { return QStringList() << "Filename" << "Kind" << "Transform" << "Mesh number"; }
447  QStringList parmDescs() const { return QStringList() << "Filename" << "Kind" << "Transform" << "Mesh number"; }
448  QIcon icon() const { return QIcon(":/images/save.png"); }
449  QStringList parmDefaults() const { return QStringList() << "" << "Text" << "no" << "0"; }
451  {
452  ParmChoiceMap map;
453  map[1] = QStringList() << "PLY Binary" << "PLY Ascii" << "VTK Mesh Binary" << "VTK Mesh Ascii"
454  << "Text" << "Cells" << "MeshEdit" << "STL" << "OBJ";
455  map[2] = map[3] = booleanChoice();
456  return map;
457  }
458  bool initialize(QStringList& parms, QWidget* parent);
459 
460  protected slots:
461  void selectMeshFile();
462  void selectMeshType(const QString& type);
463 
464  protected:
465  QString properFile(QString filename, const QString& type) const;
466  void setMeshFile(const QString& filename);
467  Point3f savedPos(Point3f pos, bool transform, const Stack* stack);
468 
469  bool saveText(Mesh* mesh, const QString& filename, bool transform);
470  bool saveCells(Mesh* mesh, const QString& filename, bool transform);
471  bool saveMeshEdit(Mesh* mesh, const QString& filename, bool transform);
472  bool saveMeshSTL(Mesh* mesh, const QString& filename, bool transform);
473  bool saveVTU(Mesh* mesh, const QString& filename, bool transform, bool binary = false);
474  bool saveOBJ(Mesh* mesh, const QString& filename, bool transform);
475  bool savePLY(Mesh* mesh, const QString& filename, bool transform, bool binary = false);
476 
477  QDialog* dlg;
478  Ui_ExportMeshDialog* ui;
479  };
480 
488  class mgx_EXPORT SaveViewFile : public GlobalProcess {
489  public:
490  SaveViewFile(const GlobalProcess& proc) : Process(proc), GlobalProcess(proc) {}
491 
492  bool operator()(const QStringList& parms);
497  bool operator()(const QString& filename);
498 
499  bool initialize(QStringList& parms, QWidget* parent);
500 
501  QString folder() const { return "System"; }
502  QString name() const { return "Save View"; }
503  QString description() const { return "Save the view file for the current configuration."; }
504  QStringList parmNames() const { return QStringList() << "Filename"; }
505  QStringList parmDescs() const { return QStringList() << "Filename"; }
506  QStringList parmDefaults() const { return QStringList() << ""; }
507  QIcon icon() const { return QIcon(":/images/save.png"); }
508  };
509 
532  class mgx_EXPORT TakeSnapshot : public GlobalProcess {
533  public:
534  TakeSnapshot(const GlobalProcess& proc) : Process(proc), GlobalProcess(proc) {}
535 
536  bool operator()(const QStringList& parms)
537  {
538  QString filename = parms[0];
539  if(filename.isEmpty())
540  return setErrorMessage("Error, no file name specified.");
541  int width = parms[2].toInt();
542  int height = parms[3].toInt();
543  float overSampling = parms[4].toFloat();
544  int quality = parms[5].toInt();
545  bool expand_frustum = stringToBool(parms[1]);
546  return (*this)(filename, overSampling, width, height, quality, expand_frustum);
547  }
548 
549  bool operator()(QString filename, float overSampling, int width, int height, int quality, bool expand_frustum);
550 
551  QString folder() const { return "System"; }
552  QString name() const { return "Snapshot"; }
553  QString description() const { return "Take a snapshot of the current view"; }
554  QStringList parmNames() const { return QStringList()
555  << "Filename" << "Expand Frustum" << "Width" << "Height" << "Oversampling" << "Quality"; }
556  QStringList parmDescs() const { return QStringList()
557  << "Filename" << "Expand Frustum" << "Width" << "Height" << "Oversampling" << "Quality"; }
559  << "" << "false" << "0" << "0" << "1.0" << "95"; }
560  QIcon icon() const { return QIcon(":/images/SaveScreenshot.png"); }
561  };
562 
563 }}
564 
565 #endif
Export the stack data into a stack of images.
Definition: SystemProcessSave.hpp:115
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:91
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:504
This process allows scripts and other processes to take snapshots of the current result.
Definition: SystemProcessSave.hpp:532
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:449
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:250
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: SystemProcessSave.hpp:147
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:154
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:560
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:253
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:143
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:506
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:93
Export a mesh on various formats: PLY format, VTK format, "text" format, "cells" format, MeshEdit format, STL format or OBJ format.
Definition: SystemProcessSave.hpp:429
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:138
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:443
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:92
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: SystemProcessSave.hpp:536
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:503
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:553
The Store class holds the actual 3D data and properties specific to it.
Definition: Store.hpp:25
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:507
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:167
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: SystemProcessSave.hpp:99
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:444
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:141
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:140
Save the view file.
Definition: SystemProcessSave.hpp:488
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:447
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:247
File containing the definition of a Process.
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:145
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:139
Save the data into a MGXS or INRIA format.
Definition: SystemProcessSave.hpp:76
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:25
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:556
This is the main process class, the one all process inherit from.
Definition: Process.hpp:248
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:446
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:251
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:501
Global processes have full mutable access to all properties of the process.
Definition: Process.hpp:894
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:105
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:558
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: SystemProcessSave.hpp:254
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:554
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:249
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:98
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:96
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:502
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:552
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:94
Stack processes have non-mutable access to meshes and mutable access to stacks.
Definition: Process.hpp:819
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:505
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:445
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:551
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: SystemProcessSave.hpp:450
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:252
Save a mesh into a INRIA or MGXM file.
Definition: SystemProcessSave.hpp:234
Mesh processes have mutable access to meshes and non-mutable access to stacks.
Definition: Process.hpp:855
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:248
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:448