Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
TOPPASScene.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2015.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Johannes Junker $
32 // $Authors: Johannes Junker, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_VISUAL_TOPPASSCENE_H
36 #define OPENMS_VISUAL_TOPPASSCENE_H
37 
38 // OpenMS_GUI config
40 
44 
45 #include <QtGui/QGraphicsScene>
46 #include <QtCore/QProcess>
47 
48 namespace OpenMS
49 {
50  class TOPPASVertex;
51  class TOPPASToolVertex;
52  class TOPPASMergerVertex;
53  class TOPPASOutputFileListVertex;
54  class TOPPASEdge;
55  class TOPPASResources;
56 
60  class FakeProcess :
61  public QProcess
62  {
63  Q_OBJECT
64 
65 public:
66  virtual void start(const QString & program, const QStringList & arguments, OpenMode mode = ReadWrite);
67  };
68 
86  class OPENMS_GUI_DLLAPI TOPPASScene :
87  public QGraphicsScene
88  {
89  Q_OBJECT
90 
91 public:
92 
94  struct TOPPProcess
95  {
97  TOPPProcess(QProcess * p, const QString & cmd, const QStringList & arg, TOPPASToolVertex * const tool) :
98  proc(p),
99  command(cmd),
100  args(arg),
101  tv(tool)
102  {
103  }
104 
108  QString command;
110  QStringList args;
113  };
114 
117  {
119  AM_MOVE
120  };
121 
122 
125  {
126  ST_REFRESH_NOCHANGE, //< no updates required
127  ST_REFRESH_CHANGED, //< some parameters were updated, but pipeline is ok
128  ST_REFRESH_CHANGEINVALID, //< updating made pipeline invalid
129  ST_REFRESH_REMAINSINVALID //< pipeline was not valid before and is invalid afterwards
130  };
131 
132 
134  typedef QList<TOPPASEdge *> EdgeContainer;
136  typedef EdgeContainer::iterator EdgeIterator;
138  typedef EdgeContainer::const_iterator ConstEdgeIterator;
140  typedef QList<TOPPASVertex *> VertexContainer;
142  typedef VertexContainer::iterator VertexIterator;
144  typedef VertexContainer::const_iterator ConstVertexIterator;
145 
147  TOPPASScene(QObject * parent, const QString & tmp_path, bool gui = true);
148 
150  virtual ~TOPPASScene();
151 
153  void addVertex(TOPPASVertex * tv);
155  void addEdge(TOPPASEdge * te);
157  void setActionMode(ActionMode mode);
159  ActionMode getActionMode();
161  VertexIterator verticesBegin();
163  VertexIterator verticesEnd();
165  EdgeIterator edgesBegin();
167  EdgeIterator edgesEnd();
169  void copySelected();
171  void paste(QPointF pos = QPointF());
173  void removeSelected();
175  void unselectAll();
177  void updateEdgeColors();
179  void resetDownstream(TOPPASVertex * vertex);
181  void runPipeline();
183  bool store(const String & file);
185  void load(const String & file);
187  void include(TOPPASScene * new_scene, QPointF pos = QPointF());
189  const String & getSaveFileName();
191  void setSaveFileName(const String & name);
193  void topoSort();
195  const QString & getOutDir();
197  const QString & getTempDir();
199  void setOutDir(const QString & dir);
201  bool saveIfChanged();
203  void setChanged(bool b);
205  bool isPipelineRunning();
207  bool askForOutputDir(bool always_ask = true);
209  void enqueueProcess(const TOPPProcess & process);
211  void runNextProcess();
213  void resetProcessesQueue();
215  void setClipboard(TOPPASScene * clipboard);
217  void connectVertexSignals(TOPPASVertex * tv);
219  void connectToolVertexSignals(TOPPASToolVertex * ttv);
221  void connectOutputVertexSignals(TOPPASOutputFileListVertex * oflv);
223  void connectMergerVertexSignals(TOPPASMergerVertex * tmv);
225  void connectEdgeSignals(TOPPASEdge * e);
227  void loadResources(const TOPPASResources & resources);
229  void createResources(TOPPASResources & resources);
231  bool wasChanged();
233  RefreshStatus refreshParameters();
235  bool isDryRun() const;
237  QString getDescription() const;
239  void setDescription(const QString & desc);
241  void setAllowedThreads(int num_threads);
243  TOPPASEdge* getHoveringEdge();
245  void checkIfWeAreDone();
246 
247 
248 public slots:
249 
251  void abortPipeline();
253  void itemClicked();
255  void itemReleased();
257  void updateHoveringEdgePos(const QPointF & new_pos);
259  void addHoveringEdge(const QPointF & pos);
261  void finishHoveringEdge();
263  void pipelineErrorSlot(const QString msg = "");
265  void moveSelectedItems(qreal dx, qreal dy);
267  void snapToGrid();
270  void setPipelineRunning(bool b = true);
272  void changedParameter(const bool invalidates_running_pipeline);
274  void changedOutputFolder();
276  void processFinished();
278  void quitWithError();
279 
280 
282 
283  void logTOPPOutput(const QString & out);
286  void logToolStarted();
288  void logToolFinished();
290  void logToolFailed();
292  void logToolCrashed();
294  void logOutputFileWritten(const String & file);
296 
297 signals:
298 
300  void entirePipelineFinished();
302  void pipelineExecutionFailed();
304  void saveMe();
306  void terminateCurrentPipeline();
308  void selectionCopied(TOPPASScene * ts);
310  void requestClipboardContent();
312  void mainWindowNeedsUpdate();
314  void openInTOPPView(QStringList all_files);
316  void dryRunFinished(int, QProcess::ExitStatus);
318  void messageReady(const QString & msg);
319 
320 
321 protected:
322 
326  VertexContainer vertices_;
328  EdgeContainer edges_;
336  QString tmp_path_;
338  bool gui_;
340  QString out_dir_;
342  bool changed_;
344  bool running_;
350  QList<TOPPProcess> topp_processes_queue_;
354  bool dry_run_;
363 
365  TOPPASVertex * getVertexAt_(const QPointF & pos);
367  bool isEdgeAllowed_(TOPPASVertex * u, TOPPASVertex * v);
369  bool dfsVisit_(TOPPASVertex * vertex);
372  bool sanityCheck_(bool allowUserOverride);
373 
375 
376  void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
378 
380  void writeToLogFile_(const QString & text);
381  };
382 
383 }
384 
385 #endif
bool user_specified_out_dir_
Indicates if the output directory has been specified by the user already.
Definition: TOPPASScene.h:348
A container for all visual items of a TOPPAS workflow.
Definition: TOPPASScene.h:86
Definition: TOPPASScene.h:118
A more convenient string class.
Definition: String.h:57
A vertex representing a TOPP tool.
Definition: TOPPASToolVertex.h:58
RefreshStatus
Pipeline status after refreshParameters() was called.
Definition: TOPPASScene.h:124
QProcess * proc
The process.
Definition: TOPPASScene.h:106
Definition: TOPPASScene.h:127
bool changed_
Flag that indicates if the pipeline has been changed since the last save.
Definition: TOPPASScene.h:342
QList< TOPPASVertex * > VertexContainer
The container for vertices.
Definition: TOPPASScene.h:140
A dictionary mapping string keys to lists of TOPPASResource objects.
Definition: TOPPASResources.h:56
The base class of the different vertex classes.
Definition: TOPPASVertex.h:101
int threads_active_
currently running processes...
Definition: TOPPASScene.h:356
TOPPASVertex * potential_target_
The current potential target vertex of the hovering edge.
Definition: TOPPASScene.h:332
QString out_dir_
The directory where the output files will be written.
Definition: TOPPASScene.h:340
bool error_occured_
true if an error occurred during pipeline execution
Definition: TOPPASScene.h:346
A FakeProcess class.
Definition: TOPPASScene.h:60
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
QList< TOPPASEdge * > EdgeContainer
The container for edges.
Definition: TOPPASScene.h:134
An edge representing a data flow in TOPPAS.
Definition: TOPPASEdge.h:59
bool dry_run_
dry run mode (no tools are actually called)
Definition: TOPPASScene.h:354
Stores the information for a TOPP process.
Definition: TOPPASScene.h:94
TOPPASToolVertex * tv
The tool which is started (used to call its slots)
Definition: TOPPASScene.h:112
QStringList args
The arguments.
Definition: TOPPASScene.h:110
QList< TOPPProcess > topp_processes_queue_
The queue of pending TOPP processes.
Definition: TOPPASScene.h:350
TOPPProcess(QProcess *p, const QString &cmd, const QStringList &arg, TOPPASToolVertex *const tool)
Constructor.
Definition: TOPPASScene.h:97
String file_name_
The file name of this pipeline.
Definition: TOPPASScene.h:334
int allowed_threads_
maximum number of allowed threads
Definition: TOPPASScene.h:360
virtual void start(const QString &program, const QStringList &arguments, OpenMode mode=ReadWrite)
VertexContainer::const_iterator ConstVertexIterator
A const iterator for vertices.
Definition: TOPPASScene.h:144
TOPPASEdge * hover_edge_
The hovering edge which is currently being created.
Definition: TOPPASScene.h:330
A vertex representing an output file list.
Definition: TOPPASOutputFileListVertex.h:50
TOPPASToolVertex * resume_source_
last node where 'resume' was started
Definition: TOPPASScene.h:362
VertexContainer vertices_
The list of all vertices.
Definition: TOPPASScene.h:326
bool running_
Indicates if a pipeline is currently running.
Definition: TOPPASScene.h:344
A special vertex that allows to merge several inputs.
Definition: TOPPASMergerVertex.h:59
VertexContainer::iterator VertexIterator
A mutable iterator for vertices.
Definition: TOPPASScene.h:142
QString command
The command.
Definition: TOPPASScene.h:108
EdgeContainer edges_
The list of all edges.
Definition: TOPPASScene.h:328
EdgeContainer::iterator EdgeIterator
A mutable iterator for edges.
Definition: TOPPASScene.h:136
bool gui_
Are we in a GUI or is the scene used by ExecutePipeline (at the command line)?
Definition: TOPPASScene.h:338
EdgeContainer::const_iterator ConstEdgeIterator
A const iterator for edges.
Definition: TOPPASScene.h:138
TOPPASScene * clipboard_
Stores the clipboard content when requested from TOPPASBase.
Definition: TOPPASScene.h:352
Definition: TOPPASScene.h:126
QString description_text_
description text
Definition: TOPPASScene.h:358
ActionMode action_mode_
The current action mode.
Definition: TOPPASScene.h:324
ActionMode
The current action mode (creation of a new edge, or panning of the widget)
Definition: TOPPASScene.h:116
QString tmp_path_
The path for temporary files.
Definition: TOPPASScene.h:336

OpenMS / TOPP release 2.0.0 Documentation generated on Thu Aug 20 2015 01:44:30 using doxygen 1.8.9.1