MorphoGraphX  2.0-1-227
MeshProcessAttributes.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 PROCESS_DOCS_DIALOG_HPP
12 #define PROCESS_DOCS_DIALOG_HPP
13 
14 #include <Config.hpp>
15 #include <Process.hpp>
16 
17 #include <QDialog>
18 #include <QFileDialog>
19 
20 #include <memory>
21 #include <QMessageBox>
22 #include <QCheckBox>
23 
24 #include <GraphUtils.hpp>
25 #include <MeshProcessExport.hpp>
26 #include <ui_ManageAttrDlg.h>
27 
28 #include <ui_PlyCellGraphDlg.h>
29 
30 class QTreeWidget;
31 class QTreeWidgetItem;
32 
33 namespace mgx
34 {
35  class mgxBase_EXPORT ManageAttributes : public Process
36  {
37  Q_OBJECT
38  Ui_ManageAttrDlg ui;
39  public:
40  ManageAttributes(const Process &process) : Process(process)
41  {
42  setName("Mesh/Attributes/Manage Attributes");
43  setDesc("Manage Mesh Attributes");
44  setIcon(QIcon(":/images/Manage.png"));
45 
46  addParm("Mesh number","Mesh number","-1");
47  }
48 
49  bool initialize(QWidget *parent);
50  bool run() { return true; }
51 
52  bool setUpTree(const QStringList &attr);
53 
54  protected slots:
55  void on_attrTreeWidget_itemClicked(QTreeWidgetItem *, int);
56  void on_clearPushButton_clicked();
57  void on_clearAllPushButton_clicked();
58  void on_savePushButton_clicked();
59 
60  protected:
62  };
63 
64 
65  class mgxBase_EXPORT SaveAttributesCSV : public Process
66  {
67  Q_OBJECT
68  public:
69 
70  Ui_PlyCellGraphDlg ui;
71 
72  QStringList attrMapsToBeSaved;
73 
74  SaveAttributesCSV(const Process& process) : Process(process)
75  {
76  setName("Mesh/Attributes/Save to CSV");
77  setDesc("Save Measure Attribute Maps to a csv file. Labels and parent labels will always be saved in the first two columns.");
78  setIcon(QIcon(":/images/MakeHeatMap.png"));
79 
80  addParm("File Name","Name of the file to save to (if empty Dialog will be opened)","");
81  addParm("Attribute Name","Attribute name. Comma separated list of attribute names (if empty Dialog will be opened)","");
82  }
83 
84  bool processParms();
85 
86  bool initialize(QWidget* parent);
87 
88  bool run()
89  {
90  if(!checkState().mesh(MESH_ANY))
91  return false;
92  Mesh *mesh = currentMesh();
93  return run(mesh, parm("File Name"));
94  }
95 
96  bool run(Mesh* mesh, QString filename);
97 
98  public slots:
99 
100  void selectAll();
101  void unselectAll();
102  };
103 
104  class mgxBase_EXPORT SaveAttributesCSVExtended : public Process
105  {
106  Q_OBJECT
107  public:
108 
109  Ui_PlyCellGraphDlg ui;
110 
111  QStringList attrMapsToBeSaved;
112 
113  SaveAttributesCSVExtended(const Process& process) : Process(process)
114  {
115  setName("Mesh/Attributes/Save to CSV Extended");
116  setDesc("Save Measure Attribute Maps to a csv file. Labels and parent labels will always be saved in the first two columns.\n"
117  "Extended process that includes extra columns to facilitate the data import into R and other platforms.");
118  setIcon(QIcon(":/images/MakeHeatMap.png"));
119 
120  addParm("File Name","File name (if empty Dialog will be opened)","");
121  addParm("Missing Data Handling","Missing Data Handling","Empty", QStringList() << "Empty" << "0" << "NA");
122  addParm("Genotype","Add a genotype name column. Leave empty to ignore","");
123  addParm("Sample Name","Add a sample name column. Leave empty to ignore","");
124  addParm("Time Point","Add a time point column. Leave empty to ignore","");
125  addParm("Stage","Add a stage column. Leave empty to ignore","");
126  }
127 
128  bool processParms();
129 
130  bool initialize(QWidget* parent);
131 
132  bool run()
133  {
134  if(!checkState().mesh(MESH_ANY))
135  return false;
136  Mesh *mesh = currentMesh();
137  return run(mesh, parm("File Name"), parm("Missing Data Handling"), parm("Genotype"), parm("Sample Name"), parm("Time Point"), parm("Stage"));
138  }
139 
140  bool run(Mesh* mesh, QString filename, QString missingData, QString genotype, QString sample, QString timepoint, QString stage);
141 
142  void setAttrs(QStringList attrList)
143  {
144  attrMapsToBeSaved = attrList;
145  }
146 
147  public slots:
148 
149  void selectAll();
150  void unselectAll();
151  };
152 
153  class mgxBase_EXPORT ClearAttrMap : public Process
154  {
155  public:
156  ClearAttrMap(const Process& process) : Process(process)
157  {
158  setName("Mesh/Attributes/Clear Attr Map");
159  setDesc("Create an empty attribute map of the specified type");
160  setIcon(QIcon(":/images/Clear.png"));
161 
162  addParm("Type","","Double", QStringList() << "Double" << "Int" << "Vector" << "Tensor"); // 0
163  addParm("Name","","EmptyAttrMap"); // 1
164  }
165 
166  bool run()
167  {
168  if(!checkState().mesh(MESH_ANY))
169  return false;
170  Mesh *mesh = currentMesh();
171  return run(mesh, parm("Type"), parm("Name"));
172  }
173 
174  bool run(Mesh* mesh, QString type, QString name);
175 
176  };
177 
178 
179 }
180 #endif
Process.hpp
mgx::Attributes
Holds a set of attributes.
Definition: Attributes.hpp:917
mgx::SaveAttributesCSV::attrMapsToBeSaved
QStringList attrMapsToBeSaved
Definition: MeshProcessAttributes.hpp:72
mgx::SaveAttributesCSV
Definition: MeshProcessAttributes.hpp:65
GraphUtils.hpp
mgx::ManageAttributes
Definition: MeshProcessAttributes.hpp:35
mgx::SaveAttributesCSVExtended::run
bool run()
Runs the process.
Definition: MeshProcessAttributes.hpp:132
mgx::SaveAttributesCSVExtended::setAttrs
void setAttrs(QStringList attrList)
Definition: MeshProcessAttributes.hpp:142
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::SaveAttributesCSVExtended::ui
Ui_PlyCellGraphDlg ui
Definition: MeshProcessAttributes.hpp:109
mgx::ManageAttributes::ManageAttributes
ManageAttributes(const Process &process)
Definition: MeshProcessAttributes.hpp:40
mgx::SaveAttributesCSV::run
bool run()
Runs the process.
Definition: MeshProcessAttributes.hpp:88
mgx::Process
Definition: Process.hpp:219
mgx::ClearAttrMap::run
bool run()
Runs the process.
Definition: MeshProcessAttributes.hpp:166
mgx::ClearAttrMap::ClearAttrMap
ClearAttrMap(const Process &process)
Definition: MeshProcessAttributes.hpp:156
mgx::SaveAttributesCSVExtended::SaveAttributesCSVExtended
SaveAttributesCSVExtended(const Process &process)
Definition: MeshProcessAttributes.hpp:113
mgx::ManageAttributes::run
bool run()
Runs the process.
Definition: MeshProcessAttributes.hpp:50
mgx::SaveAttributesCSV::SaveAttributesCSV
SaveAttributesCSV(const Process &process)
Definition: MeshProcessAttributes.hpp:74
mgx::Mesh
Definition: Mesh.hpp:54
mgx::ClearAttrMap
Definition: MeshProcessAttributes.hpp:153
mgx::SaveAttributesCSVExtended::attrMapsToBeSaved
QStringList attrMapsToBeSaved
Definition: MeshProcessAttributes.hpp:111
MeshProcessExport.hpp
mgx::ManageAttributes::attributes
Attributes * attributes
Definition: MeshProcessAttributes.hpp:61
mgx::SaveAttributesCSV::ui
Ui_PlyCellGraphDlg ui
Definition: MeshProcessAttributes.hpp:70
mgx::SaveAttributesCSVExtended
Definition: MeshProcessAttributes.hpp:104