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-2013.
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 #include <OpenMS/config.h>
42 
43 #include <QtGui/QGraphicsScene>
44 #include <QtCore/QProcess>
45 
46 namespace OpenMS
47 {
48  class TOPPASVertex;
49  class TOPPASToolVertex;
50  class TOPPASMergerVertex;
51  class TOPPASOutputFileListVertex;
52  class TOPPASEdge;
53  class TOPPASResources;
54 
58  class FakeProcess :
59  public QProcess
60  {
61  Q_OBJECT
62 
63 public:
64  virtual void start(const QString & program, const QStringList & arguments, OpenMode mode = ReadWrite);
65  };
66 
84  class OPENMS_GUI_DLLAPI TOPPASScene :
85  public QGraphicsScene
86  {
87  Q_OBJECT
88 
89 public:
90 
92  struct TOPPProcess
93  {
95  TOPPProcess(QProcess * p, const QString & cmd, const QStringList & arg, TOPPASToolVertex * const tool) :
96  proc(p),
97  command(cmd),
98  args(arg),
99  tv(tool)
100  {
101  }
102 
106  QString command;
108  QStringList args;
111  };
112 
115  {
117  AM_MOVE
118  };
119 
120 
123  {
124  ST_REFRESH_NOCHANGE, //< no updates required
125  ST_REFRESH_CHANGED, //< some parameters were updated, but pipeline is ok
126  ST_REFRESH_CHANGEINVALID, //< updating made pipeline invalid
127  ST_REFRESH_REMAINSINVALID //< pipeline was not valid before and is invalid afterwards
128  };
129 
130 
132  typedef QList<TOPPASEdge *> EdgeContainer;
134  typedef EdgeContainer::iterator EdgeIterator;
136  typedef EdgeContainer::const_iterator ConstEdgeIterator;
138  typedef QList<TOPPASVertex *> VertexContainer;
140  typedef VertexContainer::iterator VertexIterator;
142  typedef VertexContainer::const_iterator ConstVertexIterator;
143 
145  TOPPASScene(QObject * parent, const QString & tmp_path, bool gui = true);
146 
148  virtual ~TOPPASScene();
149 
151  void addVertex(TOPPASVertex * tv);
153  void addEdge(TOPPASEdge * te);
155  void setActionMode(ActionMode mode);
157  ActionMode getActionMode();
159  VertexIterator verticesBegin();
161  VertexIterator verticesEnd();
163  EdgeIterator edgesBegin();
165  EdgeIterator edgesEnd();
167  void copySelected();
169  void paste(QPointF pos = QPointF());
171  void removeSelected();
173  void unselectAll();
175  void updateEdgeColors();
177  void resetDownstream(TOPPASVertex * vertex);
179  void runPipeline();
181  bool store(const String & file);
183  void load(const String & file);
185  void include(TOPPASScene * new_scene, QPointF pos = QPointF());
187  const String & getSaveFileName();
189  void setSaveFileName(const String & name);
191  void topoSort();
193  const QString & getOutDir();
195  const QString & getTempDir();
197  void setOutDir(const QString & dir);
199  bool saveIfChanged();
201  void setChanged(bool b);
203  bool isPipelineRunning();
205  bool askForOutputDir(bool always_ask = true);
207  void enqueueProcess(const TOPPProcess & process);
209  void runNextProcess();
211  void resetProcessesQueue();
213  void setClipboard(TOPPASScene * clipboard);
215  void connectVertexSignals(TOPPASVertex * tv);
217  void connectToolVertexSignals(TOPPASToolVertex * ttv);
219  void connectOutputVertexSignals(TOPPASOutputFileListVertex * oflv);
221  void connectMergerVertexSignals(TOPPASMergerVertex * tmv);
223  void connectEdgeSignals(TOPPASEdge * e);
225  void loadResources(const TOPPASResources & resources);
227  void createResources(TOPPASResources & resources);
229  bool wasChanged();
231  RefreshStatus refreshParameters();
233  bool isDryRun() const;
235  QString getDescription() const;
237  void setDescription(const QString & desc);
239  void setAllowedThreads(int num_threads);
241  TOPPASEdge* getHoveringEdge();
243  void checkIfWeAreDone();
244 
245 
246 public slots:
247 
249  void abortPipeline();
251  void itemClicked();
253  void itemReleased();
255  void updateHoveringEdgePos(const QPointF & new_pos);
257  void addHoveringEdge(const QPointF & pos);
259  void finishHoveringEdge();
261  void pipelineErrorSlot(const QString msg = "");
263  void moveSelectedItems(qreal dx, qreal dy);
265  void snapToGrid();
268  void setPipelineRunning(bool b = true);
270  void changedParameter(const bool invalidates_running_pipeline);
272  void processFinished();
274  void quitWithError();
275 
276 
278 
279  void logTOPPOutput(const QString & out);
282  void logToolStarted();
284  void logToolFinished();
286  void logToolFailed();
288  void logToolCrashed();
290  void logOutputFileWritten(const String & file);
292 
293 signals:
294 
296  void entirePipelineFinished();
298  void pipelineExecutionFailed();
300  void saveMe();
302  void terminateCurrentPipeline();
304  void selectionCopied(TOPPASScene * ts);
306  void requestClipboardContent();
308  void mainWindowNeedsUpdate();
310  void openInTOPPView(QStringList all_files);
312  void dryRunFinished(int, QProcess::ExitStatus);
314  void messageReady(const QString & msg);
315 
316 
317 protected:
318 
332  QString tmp_path_;
334  bool gui_;
336  QString out_dir_;
338  bool changed_;
340  bool running_;
346  QList<TOPPProcess> topp_processes_queue_;
350  bool dry_run_;
359 
361  TOPPASVertex * getVertexAt_(const QPointF & pos);
363  bool isEdgeAllowed_(TOPPASVertex * u, TOPPASVertex * v);
365  bool dfsVisit_(TOPPASVertex * vertex);
368  bool sanityCheck_(bool allowUserOverride);
369 
371 
372  void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
374 
376  void writeToLogFile_(const QString & text);
377  };
378 
379 }
380 
381 #endif
bool user_specified_out_dir_
Indicates if the output directory has been specified by the user already.
Definition: TOPPASScene.h:344
A container for all visual items of a TOPPAS workflow.
Definition: TOPPASScene.h:84
A more convenient string class.
Definition: String.h:56
A vertex representing a TOPP tool.
Definition: TOPPASToolVertex.h:55
QProcess * proc
The process.
Definition: TOPPASScene.h:104
bool changed_
Flag that indicates if the pipeline has been changed since the last save.
Definition: TOPPASScene.h:338
QList< TOPPASVertex * > VertexContainer
The container for vertices.
Definition: TOPPASScene.h:138
A dictionary mapping string keys to lists of TOPPASResource objects.
Definition: TOPPASResources.h:54
The base class of the different vertex classes.
Definition: TOPPASVertex.h:98
int threads_active_
currently running processes...
Definition: TOPPASScene.h:352
TOPPASVertex * potential_target_
The current potential target vertex of the hovering edge.
Definition: TOPPASScene.h:328
QString out_dir_
The directory where the output files will be written.
Definition: TOPPASScene.h:336
bool error_occured_
true if an error occurred during pipeline execution
Definition: TOPPASScene.h:342
A FakeProcess class.
Definition: TOPPASScene.h:58
ActionMode
The current action mode (creation of a new edge, or panning of the widget)
Definition: TOPPASScene.h:114
QList< TOPPASEdge * > EdgeContainer
The container for edges.
Definition: TOPPASScene.h:132
An edge representing a data flow in TOPPAS.
Definition: TOPPASEdge.h:58
bool dry_run_
dry run mode (no tools are actually called)
Definition: TOPPASScene.h:350
Stores the information for a TOPP process.
Definition: TOPPASScene.h:92
TOPPASToolVertex * tv
The tool which is started (used to call its slots)
Definition: TOPPASScene.h:110
QStringList args
The arguments.
Definition: TOPPASScene.h:108
QList< TOPPProcess > topp_processes_queue_
The queue of pending TOPP processes.
Definition: TOPPASScene.h:346
TOPPProcess(QProcess *p, const QString &cmd, const QStringList &arg, TOPPASToolVertex *const tool)
Constructor.
Definition: TOPPASScene.h:95
String file_name_
The file name of this pipeline.
Definition: TOPPASScene.h:330
int allowed_threads_
maximum number of allowed threads
Definition: TOPPASScene.h:356
virtual void start(const QString &program, const QStringList &arguments, OpenMode mode=ReadWrite)
VertexContainer::const_iterator ConstVertexIterator
A const iterator for vertices.
Definition: TOPPASScene.h:142
Definition: TOPPASScene.h:124
RefreshStatus
Pipeline status after refreshParameters() was called.
Definition: TOPPASScene.h:122
TOPPASEdge * hover_edge_
The hovering edge which is currently being created.
Definition: TOPPASScene.h:326
A vertex representing an output file list.
Definition: TOPPASOutputFileListVertex.h:47
TOPPASToolVertex * resume_source_
last node where &#39;resume&#39; was started
Definition: TOPPASScene.h:358
VertexContainer vertices_
The list of all vertices.
Definition: TOPPASScene.h:322
Definition: TOPPASScene.h:125
bool running_
Indicates if a pipeline is currently running.
Definition: TOPPASScene.h:340
A special vertex that allows to merge several inputs.
Definition: TOPPASMergerVertex.h:56
VertexContainer::iterator VertexIterator
A mutable iterator for vertices.
Definition: TOPPASScene.h:140
Definition: TOPPASScene.h:116
QString command
The command.
Definition: TOPPASScene.h:106
EdgeContainer edges_
The list of all edges.
Definition: TOPPASScene.h:324
EdgeContainer::iterator EdgeIterator
A mutable iterator for edges.
Definition: TOPPASScene.h:134
bool gui_
Are we in a GUI or is the scene used by ExecutePipeline (at the command line)?
Definition: TOPPASScene.h:334
EdgeContainer::const_iterator ConstEdgeIterator
A const iterator for edges.
Definition: TOPPASScene.h:136
TOPPASScene * clipboard_
Stores the clipboard content when requested from TOPPASBase.
Definition: TOPPASScene.h:348
QString description_text_
description text
Definition: TOPPASScene.h:354
ActionMode action_mode_
The current action mode.
Definition: TOPPASScene.h:320
QString tmp_path_
The path for temporary files.
Definition: TOPPASScene.h:332

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:22 using doxygen 1.8.5