Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
TOPPASVertex.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_TOPPASVERTEX_H
36 #define OPENMS_VISUAL_TOPPASVERTEX_H
37 
38 // ------------- DEBUGGING ----------------
39 
40 // ---- Uncomment to enable debug mode ----
41 //#define TOPPAS_DEBUG
42 // ----------------------------------------
43 
44 #ifdef TOPPAS_DEBUG
45 #define __DEBUG_BEGIN_METHOD__ \
46  { \
47  for (int dbg_indnt_cntr = 0; dbg_indnt_cntr < global_debug_indent_; ++dbg_indnt_cntr) \
48  { \
49  std::cout << " "; \
50  } \
51  std::cout << "BEGIN [" << topo_nr_ << "] " << OPENMS_PRETTY_FUNCTION << std::endl; \
52  ++global_debug_indent_; \
53  }
54 
55 #define __DEBUG_END_METHOD__ \
56  { \
57  --global_debug_indent_; \
58  if (global_debug_indent_ < 0) global_debug_indent_ = 0; \
59  for (int dbg_indnt_cntr = 0; dbg_indnt_cntr < global_debug_indent_; ++dbg_indnt_cntr) \
60  { \
61  std::cout << " "; \
62  } \
63  std::cout << "END [" << topo_nr_ << "] " << OPENMS_PRETTY_FUNCTION << std::endl; \
64  }
65 #else
66 #define __DEBUG_BEGIN_METHOD__ {}
67 #define __DEBUG_END_METHOD__ {}
68 #endif
69 
70 // ----------------------------------------
71 
72 // OpenMS_GUI config
73 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
74 
77 
78 #include <QtGui/QPainter>
79 #include <QtGui/QPainterPath>
80 #include <QtGui/QGraphicsSceneMouseEvent>
81 #include <QtGui/QGraphicsSceneContextMenuEvent>
82 #include <QtGui/QGraphicsItem>
83 #include <QtCore/QProcess>
84 #include <QtGui/QMenu>
85 
86 namespace OpenMS
87 {
88  class TOPPASEdge;
89 
101  class OPENMS_GUI_DLLAPI TOPPASVertex :
102  public QObject,
103  public QGraphicsItem
104  {
105  Q_OBJECT
106  Q_INTERFACES(QGraphicsItem)
107 
108 public:
109 
111  typedef QList<TOPPASEdge *> EdgeContainer;
113  typedef EdgeContainer::iterator EdgeIterator;
115  typedef EdgeContainer::const_iterator ConstEdgeIterator;
120  {
121  public:
123  {
124  }
125 
126  int size() const;
127  const QStringList& get() const;
128  const QString& operator[](int i) const;
129 
131 
132  void set(const QStringList& filenames);
133  void set(const QString& filename, int i);
134  void push_back(const QString& filename);
135  void append(const QStringList& filenames);
137 
138  private:
139  /*
140  @brief Check length of filename and throw Exception::FileNotWritable() if too long
141 
142  @param filename Full path to file (using relative paths will circumvent the effectiveness)
143  @throw Exception::FileNotWritable() if too long (>=255 chars)
144  */
145  void check_(const QString& filename);
146  QStringList filenames_; //< filenames passed from upstream node in this round
147  };
150  {
152  filenames(),
153  edge(0)
154  {
155  }
156 
157  TOPPASFilenames filenames; //< filenames passed from upstream node in this round
158  TOPPASEdge* edge; //< edge that connects the upstream node to the current one
159  };
160 
161 
162 
163 
168  typedef std::map<Int, VertexRoundPackage> RoundPackage;
169  typedef RoundPackage::const_iterator RoundPackageConstIt;
170  typedef RoundPackage::iterator RoundPackageIt;
171 
173  typedef std::vector<RoundPackage> RoundPackages;
174 
177  {
180  DFS_BLACK
181  };
182 
185  {
186  TV_ALLFINISHED, // all downstream nodes are done (including the ones which are feed by a parallel subtree)
187  TV_UNFINISHED, // some direct downstream node is not done
188  TV_UNFINISHED_INBRANCH // a parallel subtree which merged with some downstream node A was not done (which prevented processing of the node A)
189  };
190 
192  TOPPASVertex();
194  TOPPASVertex(const TOPPASVertex & rhs);
196  virtual ~TOPPASVertex();
198  TOPPASVertex & operator=(const TOPPASVertex & rhs);
199 
203  bool buildRoundPackages(RoundPackages & pkg, String & error_msg);
204 
206  bool isUpstreamFinished() const;
207 
209  virtual QRectF boundingRect() const = 0;
211  virtual QPainterPath shape() const = 0;
213  virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) = 0;
215  ConstEdgeIterator outEdgesBegin() const;
217  ConstEdgeIterator outEdgesEnd() const;
219  ConstEdgeIterator inEdgesBegin() const;
221  ConstEdgeIterator inEdgesEnd() const;
223  Size incomingEdgesCount();
225  Size outgoingEdgesCount();
227  void addInEdge(TOPPASEdge * edge);
229  void addOutEdge(TOPPASEdge * edge);
231  void removeInEdge(TOPPASEdge * edge);
233  void removeOutEdge(TOPPASEdge * edge);
235  DFS_COLOR getDFSColor();
237  void setDFSColor(DFS_COLOR color);
239  TOPPASVertex * getDFSParent();
241  void setDFSParent(TOPPASVertex * parent);
243  TOPPASVertex::SUBSTREESTATUS getSubtreeStatus() const;
245  bool isTopoSortMarked();
247  void setTopoSortMarked(bool b);
249  UInt getTopoNr();
251  virtual void setTopoNr(UInt nr);
254  virtual void reset(bool reset_all_files = false);
256  virtual void markUnreachable();
258  bool isReachable();
260  bool isFinished() const;
263  virtual void run();
265  virtual bool invertRecylingMode();
267  bool isRecyclingEnabled() const;
269  void setRecycling(const bool is_enabled);
270 
271  // get the name of the vertex (to be overridden by derived classes)
272  virtual String getName() const = 0;
273 
279  QStringList getFileNames(int param_index, int round) const;
280 
282  QStringList getFileNames() const;
283 
284  // get the output structure directly
285  const RoundPackages & getOutputFiles() const;
286 
287 
289  bool allInputsReady();
290 
291 
292 public slots:
293 
295  virtual void inEdgeHasChanged();
297  virtual void outEdgeHasChanged();
298 
299 signals:
300 
302  void clicked();
304  void released();
306  void hoveringEdgePosChanged(const QPointF & new_pos);
308  void newHoveringEdge(const QPointF & pos);
310  void finishHoveringEdge();
312  void somethingHasChanged();
314  void itemDragged(qreal dx, qreal dy);
317  void parameterChanged(const bool invalidates_running_pipeline);
318 
319 protected:
320 
322  EdgeContainer in_edges_;
324  EdgeContainer out_edges_;
328  QColor pen_color_;
330  QColor brush_color_;
340  RoundPackages output_files_;
346  bool finished_;
351 
352 
353 #ifdef TOPPAS_DEBUG
354  // Indentation level for nicer debug output
355  static int global_debug_indent_;
356 #endif
357 
359 
360  void mouseReleaseEvent(QGraphicsSceneMouseEvent * e);
361  void mousePressEvent(QGraphicsSceneMouseEvent * e);
362  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * e);
363  void mouseMoveEvent(QGraphicsSceneMouseEvent * e);
364  void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
366 
368  virtual void moveNewEdgeTo_(const QPointF & pos);
370  String get3CharsNumber_(UInt number) const;
371 
373  void debugOut_(const String &
374 #ifdef TOPPAS_DEBUG
375  message
376 #endif
377  ) const
378  {
379 #ifdef TOPPAS_DEBUG
380  for (int i = 0; i < global_debug_indent_; ++i)
381  {
382  std::cout << " ";
383  }
384  std::cout << "[" << topo_nr_ << "] " << message << std::endl;
385 #endif
386  }
387 
388  };
389 }
390 
391 #endif
TOPPASEdge * edge
Definition: TOPPASVertex.h:158
Definition: TOPPASVertex.h:119
TOPPASFilenames filenames
Definition: TOPPASVertex.h:157
bool edge_being_created_
Indicates whether a new out edge is currently being created.
Definition: TOPPASVertex.h:326
QColor pen_color_
The color of the pen.
Definition: TOPPASVertex.h:328
DFS_COLOR
The color of a vertex during depth-first search.
Definition: TOPPASVertex.h:176
RoundPackage::iterator RoundPackageIt
Definition: TOPPASVertex.h:170
A more convenient string class.
Definition: String.h:57
RoundPackage::const_iterator RoundPackageConstIt
Definition: TOPPASVertex.h:169
bool finished_
Stores whether this node has already been processed during the current pipeline execution.
Definition: TOPPASVertex.h:346
Definition: TOPPASVertex.h:187
void debugOut_(const String &) const
Displays the debug output message, if TOPPAS_DEBUG is defined.
Definition: TOPPASVertex.h:373
The base class of the different vertex classes.
Definition: TOPPASVertex.h:101
std::map< Int, VertexRoundPackage > RoundPackage
Definition: TOPPASVertex.h:168
Info for one edge and round, to be passed to next node.
Definition: TOPPASVertex.h:149
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
bool allow_output_recycling_
shall subsequent tools be allowed to recycle the output of this node to match the number of rounds im...
Definition: TOPPASVertex.h:350
TOPPASVertex * dfs_parent_
The DFS parent of this node.
Definition: TOPPASVertex.h:334
DFS_COLOR dfs_color_
The DFS color of this node.
Definition: TOPPASVertex.h:332
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
An edge representing a data flow in TOPPAS.
Definition: TOPPASEdge.h:60
SUBSTREESTATUS
The color of a vertex during depth-first search.
Definition: TOPPASVertex.h:184
T round(T x)
Rounds the value.
Definition: MathFunctions.h:138
EdgeContainer::iterator EdgeIterator
A mutable iterator for in/out edges.
Definition: TOPPASVertex.h:113
EdgeContainer out_edges_
The list of outgoing edges.
Definition: TOPPASVertex.h:324
int round_total_
number of rounds this node will do (&#39;Merge All&#39; nodes will pass everything, thus do only one round) ...
Definition: TOPPASVertex.h:342
Definition: TOPPASVertex.h:178
Definition: TOPPASVertex.h:186
bool reachable_
Indicates whether this node is reachable (i.e. there is an input node somewhere further upstream) ...
Definition: TOPPASVertex.h:348
std::vector< RoundPackage > RoundPackages
all information a node needs to process all rounds
Definition: TOPPASVertex.h:173
QStringList filenames_
Definition: TOPPASVertex.h:146
EdgeContainer in_edges_
The list of incoming edges.
Definition: TOPPASVertex.h:322
RoundPackages output_files_
Stores the current output file names for each output parameter.
Definition: TOPPASVertex.h:340
TOPPASFilenames()
Definition: TOPPASVertex.h:122
QList< TOPPASEdge * > EdgeContainer
The container for in/out edges.
Definition: TOPPASVertex.h:111
Definition: TOPPASVertex.h:179
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
VertexRoundPackage()
Definition: TOPPASVertex.h:151
QColor brush_color_
The color of the brush.
Definition: TOPPASVertex.h:330
EdgeContainer::const_iterator ConstEdgeIterator
A const iterator for in/out edges.
Definition: TOPPASVertex.h:115
bool topo_sort_marked_
"marked" flag for topological sort
Definition: TOPPASVertex.h:336
UInt topo_nr_
The number in a topological sort of the entire graph.
Definition: TOPPASVertex.h:338
int round_counter_
currently finished number of rounds (TODO: do we need that?)
Definition: TOPPASVertex.h:344

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