MorphoGraphX
SystemProcessSave.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef SYSTEMPROCESSSAVE_HPP
12 #define SYSTEMPROCESSSAVE_HPP
13 
14 #include <Process.hpp>
15 
16 #include <QObject>
17 #include <QRegExp>
18 #include <Version.hpp>
19 
25 class QDialog;
26 class Ui_SaveMeshDialog;
27 class Ui_ExportMeshDialog;
28 class Ui_ExportStackDialog;
29 
30 namespace mgx { namespace process {
31 
86  class mgx_EXPORT StackSave : public StackProcess {
87  public:
88  StackSave(const StackProcess& proc) : Process(proc), StackProcess(proc) {}
89 
90  bool initialize(QStringList& parms, QWidget* parent);
91 
92  bool operator()(const QStringList& parms);
100  bool operator()(Stack* stack, Store* store, const QString& filename, int compressionLevel = 0);
101  QString folder() const { return "System"; }
102  QString name() const { return "Save"; }
103  QString description() const { return "Save a stack into a known 3D image format"; }
104  QStringList parmNames() const { return QStringList()
105  << "Filename" << "Store" << "Stack number" << "Compression Level (0-9)"; }
106  QStringList parmDescs() const { return QStringList()
107  << "Filename" << "Store" << "Stack number" << "Compression Level (0-9)"; }
108  QStringList parmDefaults() const { return QStringList() << "" << "Main" << "0" << "5"; }
110  {
111  ParmChoiceMap map;
112  map[1] = storeChoice();
113  return map;
114  }
115  QIcon icon() const { return QIcon(":/images/save.png"); }
116  };
117 
125  class mgx_EXPORT StackExport : public QObject, public StackProcess {
126  Q_OBJECT
127  public:
128  StackExport(const StackProcess& proc) : Process(proc), QObject(), StackProcess(proc) {}
129 
130  bool initialize(QStringList& parms, QWidget* parent);
131 
132  bool operator()(const QStringList& parms);
146  bool operator()(Stack* stack, Store* store, const QString& filename, const QString& type,
147  unsigned int nb_digit, bool generate_voxel_spacing);
148  QString folder() const { return "System"; }
149  QString name() const { return "Export"; }
150  QString description() const { return "Export a stack into an image sequence."; }
151  QStringList parmNames() const { return QStringList()
152  << "Filename" << "Store" << "Format" << "Generate Voxel Spacing" << "Stack number" << "NbDigits"; }
153  QStringList parmDescs() const { return QStringList()
154  << "Filename" << "Store" << "Format" << "Generate Voxel Spacing" << "Stack number" << "NbDigits"; }
156  << "" << "Main" << "CImg Auto" << "No" << "0" << "0"; }
158  {
159  ParmChoiceMap map;
160  map[1] = storeChoice();
161  map[3] = booleanChoice();
162  return map;
163  }
164  QIcon icon() const { return QIcon(":/images/save.png"); }
165 
166  protected slots:
167  void selectImageFile();
168  void setImageType(const QString& type);
169 
170  protected:
171  Ui_ExportStackDialog* ui;
172  QDialog* dlg;
173  };
174 
244  class mgx_EXPORT MeshSave : public QObject, public MeshProcess {
245  Q_OBJECT
246  public:
247  MeshSave(const MeshProcess& proc) : Process(proc), QObject(), MeshProcess(proc) {}
248 
249  bool operator()(const QStringList& parms);
256  bool operator()(Mesh* mesh, const QString& filename, bool transform);
257  QString folder() const { return "System"; }
258  QString name() const { return "Save"; }
259  QString description() const { return "Save a mesh into a known mesh format"; }
260  QStringList parmNames() const { return QStringList() << "Filename" << "Transform" << "Mesh number"; }
261  QStringList parmDescs() const { return QStringList() << "Filename" << "Transform" << "Mesh number"; }
262  QIcon icon() const { return QIcon(":/images/save.png"); }
263  QStringList parmDefaults() const { return QStringList() << "" << "No" << "0"; }
265  {
266  ParmChoiceMap map;
267  map[1] = map[2] = booleanChoice();
268  return map;
269  }
270  bool initialize(QStringList& parms, QWidget* parent);
271 
272  protected slots:
273  void selectMeshFile();
274 
275  protected:
276  QString properFile(QString filename) const;
277  void setMeshFile(const QString& filename);
278  Point3f savedPos(Point3f pos, bool transform, const Stack* stack);
279 
280  bool saveMesh(Mesh* mesh, const QString& filename, bool transform);
281 
282  QDialog* dlg;
283  Ui_SaveMeshDialog* ui;
284  };
285 
439  class mgx_EXPORT MeshExport : public QObject, public MeshProcess {
440  Q_OBJECT
441  public:
442  MeshExport(const MeshProcess& proc) : Process(proc), QObject(), MeshProcess(proc) {}
443 
444  bool operator()(const QStringList& parms);
452  bool operator()(Mesh* mesh, const QString& filename, const QString& type, bool transform);
453  QString folder() const { return "System"; }
454  QString name() const { return "Export"; }
455  QString description() const { return "Export a mesh into a known mesh format"; }
456  QStringList parmNames() const { return QStringList() << "Filename" << "Kind" << "Transform" << "Mesh number"; }
457  QStringList parmDescs() const { return QStringList() << "Filename" << "Kind" << "Transform" << "Mesh number"; }
458  QIcon icon() const { return QIcon(":/images/save.png"); }
459  QStringList parmDefaults() const { return QStringList() << "" << "Text" << "no" << "0"; }
461  {
462  ParmChoiceMap map;
463  map[1] = QStringList() << "PLY Binary" << "PLY Ascii" << "VTK Mesh Binary" << "VTK Mesh Ascii"
464  << "Text" << "Cells" << "MeshEdit" << "STL" << "OBJ";
465  map[2] = map[3] = booleanChoice();
466  return map;
467  }
468  bool initialize(QStringList& parms, QWidget* parent);
469 
470  protected slots:
471  void selectMeshFile();
472  void selectMeshType(const QString& type);
473 
474  protected:
475  QString properFile(QString filename, const QString& type) const;
476  void setMeshFile(const QString& filename);
477  Point3f savedPos(Point3f pos, bool transform, const Stack* stack);
478 
479  bool saveText(Mesh* mesh, const QString& filename, bool transform);
480  bool saveCells(Mesh* mesh, const QString& filename, bool transform);
481  bool saveMeshEdit(Mesh* mesh, const QString& filename, bool transform);
482  bool saveMeshSTL(Mesh* mesh, const QString& filename, bool transform);
483  bool saveVTU(Mesh* mesh, const QString& filename, bool transform, bool binary = false);
484  bool saveOBJ(Mesh* mesh, const QString& filename, bool transform);
485  bool savePLY(Mesh* mesh, const QString& filename, bool transform, bool binary = false);
486 
487  QDialog* dlg;
488  Ui_ExportMeshDialog* ui;
489  };
490 
498  class mgx_EXPORT SaveViewFile : public GlobalProcess {
499  public:
500  SaveViewFile(const GlobalProcess& proc) : Process(proc), GlobalProcess(proc) {}
501 
502  bool operator()(const QStringList& parms);
507  bool operator()(const QString& filename);
508 
509  bool initialize(QStringList& parms, QWidget* parent);
510 
511  QString folder() const { return "System"; }
512  QString name() const { return "Save View"; }
513  QString description() const { return "Save the view file for the current configuration."; }
514  QStringList parmNames() const { return QStringList() << "Filename"; }
515  QStringList parmDescs() const { return QStringList() << "Filename"; }
516  QStringList parmDefaults() const { return QStringList() << ""; }
517  QIcon icon() const { return QIcon(":/images/save.png"); }
518  };
519 
542  class mgx_EXPORT TakeSnapshot : public GlobalProcess {
543  public:
544  TakeSnapshot(const GlobalProcess& proc) : Process(proc), GlobalProcess(proc) {}
545 
546  bool operator()(const QStringList& parms)
547  {
548  QString filename = parms[0];
549  if(filename.isEmpty())
550  return setErrorMessage("Error, no file name specified.");
551  int width = parms[2].toInt();
552  int height = parms[3].toInt();
553  float overSampling = parms[4].toFloat();
554  int quality = parms[5].toInt();
555  bool expand_frustum = stringToBool(parms[1]);
556  return (*this)(filename, overSampling, width, height, quality, expand_frustum);
557  }
558 
559  bool operator()(QString filename, float overSampling, int width, int height, int quality, bool expand_frustum);
560 
561  QString folder() const { return "System"; }
562  QString name() const { return "Snapshot"; }
563  QString description() const { return "Take a snapshot of the current view"; }
564  QStringList parmNames() const { return QStringList()
565  << "Filename" << "Expand Frustum" << "Width" << "Height" << "Oversampling" << "Quality"; }
566  QStringList parmDescs() const { return QStringList()
567  << "Filename" << "Expand Frustum" << "Width" << "Height" << "Oversampling" << "Quality"; }
569  << "" << "false" << "0" << "0" << "1.0" << "95"; }
570  QIcon icon() const { return QIcon(":/images/SaveScreenshot.png"); }
571  };
572 
573 }}
574 
575 #endif
Export the stack data into a stack of images.
Definition: SystemProcessSave.hpp:125
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:101
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:514
This process allows scripts and other processes to take snapshots of the current result.
Definition: SystemProcessSave.hpp:542
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:459
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:260
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: SystemProcessSave.hpp:157
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:164
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:570
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:263
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:153
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:516
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:103
Export a mesh on various formats: PLY format, VTK format, "text" format, "cells" format, MeshEdit format, STL format or OBJ format.
Definition: SystemProcessSave.hpp:439
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:148
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:453
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:102
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: SystemProcessSave.hpp:546
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:513
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:563
The Store class holds the actual 3D data and properties specific to it.
Definition: Store.hpp:35
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:517
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:177
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: SystemProcessSave.hpp:109
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:454
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:151
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:150
Save the view file.
Definition: SystemProcessSave.hpp:498
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:457
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:257
File containing the definition of a Process.
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:155
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:149
Save the data into a MGXS or INRIA format.
Definition: SystemProcessSave.hpp:86
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:35
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:566
This is the main process class, the one all process inherit from.
Definition: Process.hpp:258
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:456
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:261
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:511
Global processes have full mutable access to all properties of the process.
Definition: Process.hpp:904
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
This namespace contains all the classes needed to define processes.
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:115
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:568
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: SystemProcessSave.hpp:264
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:564
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:259
QStringList parmDefaults() const
List of default parms.
Definition: SystemProcessSave.hpp:108
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:106
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:512
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:562
QStringList parmNames() const
List of named parameters.
Definition: SystemProcessSave.hpp:104
Stack processes have non-mutable access to meshes and mutable access to stacks.
Definition: Process.hpp:829
QStringList parmDescs() const
List of parameters descriptions.
Definition: SystemProcessSave.hpp:515
QString description() const
Returns a description of the process for the GUI.
Definition: SystemProcessSave.hpp:455
QString folder() const
Folder in which to place the process.
Definition: SystemProcessSave.hpp:561
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: SystemProcessSave.hpp:460
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:262
Save a mesh into a INRIA or MGXM file.
Definition: SystemProcessSave.hpp:244
Mesh processes have mutable access to meshes and non-mutable access to stacks.
Definition: Process.hpp:865
QString name() const
Returns the name of the process.
Definition: SystemProcessSave.hpp:258
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: SystemProcessSave.hpp:458