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-2017.
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 Veit $
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
39 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
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() const;
197  const QString & getTempDir() const;
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();
234 
236  bool isGUIMode() const;
237 
239  bool isDryRun() const;
241  QString getDescription() const;
243  void setDescription(const QString & desc);
245  void setAllowedThreads(int num_threads);
247  TOPPASEdge* getHoveringEdge();
249  void checkIfWeAreDone();
250 
251 
252 public slots:
253 
255  void abortPipeline();
257  void itemClicked();
259  void itemReleased();
261  void updateHoveringEdgePos(const QPointF & new_pos);
263  void addHoveringEdge(const QPointF & pos);
265  void finishHoveringEdge();
267  void pipelineErrorSlot(const QString msg = "");
269  void moveSelectedItems(qreal dx, qreal dy);
271  void snapToGrid();
274  void setPipelineRunning(bool b = true);
276  void changedParameter(const bool invalidates_running_pipeline);
278  void changedOutputFolder();
280  void processFinished();
282  void quitWithError();
283 
284 
286 
287  void logTOPPOutput(const QString & out);
290  void logToolStarted();
292  void logToolFinished();
294  void logToolFailed();
296  void logToolCrashed();
298  void logOutputFileWritten(const String & file);
300 
301 signals:
302 
304  void entirePipelineFinished();
306  void pipelineExecutionFailed();
308  void saveMe();
310  void terminateCurrentPipeline();
312  void selectionCopied(TOPPASScene * ts);
314  void requestClipboardContent();
316  void mainWindowNeedsUpdate();
318  void openInTOPPView(QStringList all_files);
320  void dryRunFinished(int, QProcess::ExitStatus);
322  void messageReady(const QString & msg);
323 
324 
325 protected:
326 
330  VertexContainer vertices_;
332  EdgeContainer edges_;
340  QString tmp_path_;
342  bool gui_;
344  QString out_dir_;
346  bool changed_;
348  bool running_;
354  QList<TOPPProcess> topp_processes_queue_;
358  bool dry_run_;
367 
369  TOPPASVertex * getVertexAt_(const QPointF & pos);
371  bool isEdgeAllowed_(TOPPASVertex * u, TOPPASVertex * v);
373  bool dfsVisit_(TOPPASVertex * vertex);
376  bool sanityCheck_(bool allowUserOverride);
377 
379 
380  void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
382 
384  void writeToLogFile_(const QString & text);
385  };
386 
387 }
388 
389 #endif
bool user_specified_out_dir_
Indicates if the output directory has been specified by the user already.
Definition: TOPPASScene.h:352
A container for all visual items of a TOPPAS workflow.
Definition: TOPPASScene.h:86
A more convenient string class.
Definition: String.h:57
A vertex representing a TOPP tool.
Definition: TOPPASToolVertex.h:60
QProcess * proc
The process.
Definition: TOPPASScene.h:106
bool changed_
Flag that indicates if the pipeline has been changed since the last save.
Definition: TOPPASScene.h:346
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:360
TOPPASVertex * potential_target_
The current potential target vertex of the hovering edge.
Definition: TOPPASScene.h:336
QString out_dir_
The directory where the output files will be written.
Definition: TOPPASScene.h:344
bool error_occured_
true if an error occurred during pipeline execution
Definition: TOPPASScene.h:350
A FakeProcess class.
Definition: TOPPASScene.h:60
ActionMode
The current action mode (creation of a new edge, or panning of the widget)
Definition: TOPPASScene.h:116
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:60
bool dry_run_
dry run mode (no tools are actually called)
Definition: TOPPASScene.h:358
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:354
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:338
int allowed_threads_
maximum number of allowed threads
Definition: TOPPASScene.h:364
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
Definition: TOPPASScene.h:126
RefreshStatus
Pipeline status after refreshParameters() was called.
Definition: TOPPASScene.h:124
TOPPASEdge * hover_edge_
The hovering edge which is currently being created.
Definition: TOPPASScene.h:334
A vertex representing an output file list.
Definition: TOPPASOutputFileListVertex.h:50
TOPPASToolVertex * resume_source_
last node where &#39;resume&#39; was started
Definition: TOPPASScene.h:366
VertexContainer vertices_
The list of all vertices.
Definition: TOPPASScene.h:330
Definition: TOPPASScene.h:127
bool running_
Indicates if a pipeline is currently running.
Definition: TOPPASScene.h:348
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
Definition: TOPPASScene.h:118
QString command
The command.
Definition: TOPPASScene.h:108
EdgeContainer edges_
The list of all edges.
Definition: TOPPASScene.h:332
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:342
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:356
QString description_text_
description text
Definition: TOPPASScene.h:362
ActionMode action_mode_
The current action mode.
Definition: TOPPASScene.h:328
QString tmp_path_
The path for temporary files.
Definition: TOPPASScene.h:340

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:04 using doxygen 1.8.13