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-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_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_ << "] " << __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_ << "] " << __PRETTY_FUNCTION__ << std::endl; \
64  }
65 #else
66 #define __DEBUG_BEGIN_METHOD__ {}
67 #define __DEBUG_END_METHOD__ {}
68 #endif
69 
70 // ----------------------------------------
71 
74 
75 #include <QtGui/QPainter>
76 #include <QtGui/QPainterPath>
77 #include <QtGui/QGraphicsSceneMouseEvent>
78 #include <QtGui/QGraphicsSceneContextMenuEvent>
79 #include <QtGui/QGraphicsItem>
80 #include <QtCore/QProcess>
81 #include <QtGui/QMenu>
82 
83 namespace OpenMS
84 {
85  class TOPPASEdge;
86 
98  class OPENMS_GUI_DLLAPI TOPPASVertex :
99  public QObject,
100  public QGraphicsItem
101  {
102  Q_OBJECT
103  //Q_INTERFACES(QGraphicsItem) // works only >Qt4.6
104 
105 public:
106 
108  typedef QList<TOPPASEdge *> EdgeContainer;
110  typedef EdgeContainer::iterator EdgeIterator;
112  typedef EdgeContainer::const_iterator ConstEdgeIterator;
115  {
117  filenames(),
118  edge(0)
119  {
120  }
121 
122  QStringList filenames; //< filenames passed from upstream node in this round
123  TOPPASEdge * edge; //< edge that connects the upstream node to the current one
124  };
125 
130  typedef std::map<Int, VertexRoundPackage> RoundPackage;
131  typedef RoundPackage::const_iterator RoundPackageConstIt;
132  typedef RoundPackage::iterator RoundPackageIt;
133 
135  typedef std::vector<RoundPackage> RoundPackages;
136 
139  {
142  DFS_BLACK
143  };
144 
147  {
148  TV_ALLFINISHED, // all downstream nodes are done (including the ones which are feed by a parallel subtree)
149  TV_UNFINISHED, // some direct downstream node is not done
150  TV_UNFINISHED_INBRANCH // a parallel subtree which merged with some downstream node A was not done (which prevented processing of the node A)
151  };
152 
154  TOPPASVertex();
156  TOPPASVertex(const TOPPASVertex & rhs);
158  virtual ~TOPPASVertex();
160  TOPPASVertex & operator=(const TOPPASVertex & rhs);
161 
165  bool buildRoundPackages(RoundPackages & pkg, String & error_msg);
166 
168  bool isUpstreamFinished() const;
169 
171  virtual QRectF boundingRect() const = 0;
173  virtual QPainterPath shape() const = 0;
175  virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) = 0;
177  ConstEdgeIterator outEdgesBegin() const;
179  ConstEdgeIterator outEdgesEnd() const;
181  ConstEdgeIterator inEdgesBegin() const;
183  ConstEdgeIterator inEdgesEnd() const;
185  Size incomingEdgesCount();
187  Size outgoingEdgesCount();
189  void addInEdge(TOPPASEdge * edge);
191  void addOutEdge(TOPPASEdge * edge);
193  void removeInEdge(TOPPASEdge * edge);
195  void removeOutEdge(TOPPASEdge * edge);
197  DFS_COLOR getDFSColor();
199  void setDFSColor(DFS_COLOR color);
201  TOPPASVertex * getDFSParent();
203  void setDFSParent(TOPPASVertex * parent);
205  TOPPASVertex::SUBSTREESTATUS getSubtreeStatus() const;
207  bool isTopoSortMarked();
209  void setTopoSortMarked(bool b);
211  UInt getTopoNr();
213  virtual void setTopoNr(UInt nr);
215  virtual void reset(bool reset_all_files = false);
217  virtual void markUnreachable();
219  bool isReachable();
221  bool isFinished() const;
224  virtual void run();
226  virtual bool invertRecylingMode();
228  bool isRecyclingEnabled() const;
230  void setRecycling(const bool is_enabled);
231 
232  // get the name of the vertex (to be overridden by derived classes)
233  virtual String getName() const = 0;
234 
240  QStringList getFileNames(int param_index, int round) const;
241 
243  QStringList getFileNames() const;
244 
245  // get the output structure directly
246  const RoundPackages & getOutputFiles() const;
247 
248 
250  bool allInputsReady();
251 
252 
253 public slots:
254 
256  virtual void inEdgeHasChanged();
258  virtual void outEdgeHasChanged();
259 
260 signals:
261 
263  void clicked();
265  void released();
267  void hoveringEdgePosChanged(const QPointF & new_pos);
269  void newHoveringEdge(const QPointF & pos);
271  void finishHoveringEdge();
273  void somethingHasChanged();
275  void itemDragged(qreal dx, qreal dy);
278  void parameterChanged(const bool invalidates_running_pipeline);
279 
280 protected:
281 
289  QColor pen_color_;
291  QColor brush_color_;
307  bool finished_;
312 
313 
314 #ifdef TOPPAS_DEBUG
315  // Indentation level for nicer debug output
316  static int global_debug_indent_;
317 #endif
318 
320 
321  void mouseReleaseEvent(QGraphicsSceneMouseEvent * e);
322  void mousePressEvent(QGraphicsSceneMouseEvent * e);
323  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * e);
324  void mouseMoveEvent(QGraphicsSceneMouseEvent * e);
325  void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
327 
329  virtual void moveNewEdgeTo_(const QPointF & pos);
331  String get3CharsNumber_(UInt number) const;
332 
334  void debugOut_(const String &
335 #ifdef TOPPAS_DEBUG
336  message
337 #endif
338  ) const
339  {
340 #ifdef TOPPAS_DEBUG
341  for (int i = 0; i < global_debug_indent_; ++i)
342  {
343  std::cout << " ";
344  }
345  std::cout << "[" << topo_nr_ << "] " << message << std::endl;
346 #endif
347  }
348 
349  };
350 }
351 
352 #endif
TOPPASEdge * edge
Definition: TOPPASVertex.h:123
bool edge_being_created_
Indicates whether a new out edge is currently being created.
Definition: TOPPASVertex.h:287
QColor pen_color_
The color of the pen.
Definition: TOPPASVertex.h:289
DFS_COLOR
The color of a vertex during depth-first search.
Definition: TOPPASVertex.h:138
RoundPackage::iterator RoundPackageIt
Definition: TOPPASVertex.h:132
A more convenient string class.
Definition: String.h:56
RoundPackage::const_iterator RoundPackageConstIt
Definition: TOPPASVertex.h:131
bool finished_
Stores whether this node has already been processed during the current pipeline execution.
Definition: TOPPASVertex.h:307
Definition: TOPPASVertex.h:149
The base class of the different vertex classes.
Definition: TOPPASVertex.h:98
std::map< Int, VertexRoundPackage > RoundPackage
Definition: TOPPASVertex.h:130
Info for one edge and round, to be passed to next node.
Definition: TOPPASVertex.h:114
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:311
TOPPASVertex * dfs_parent_
The DFS parent of this node.
Definition: TOPPASVertex.h:295
DFS_COLOR dfs_color_
The DFS color of this node.
Definition: TOPPASVertex.h:293
QStringList filenames
Definition: TOPPASVertex.h:122
An edge representing a data flow in TOPPAS.
Definition: TOPPASEdge.h:58
SUBSTREESTATUS
The color of a vertex during depth-first search.
Definition: TOPPASVertex.h:146
T round(T x)
Rounds the value.
Definition: MathFunctions.h:135
EdgeContainer::iterator EdgeIterator
A mutable iterator for in/out edges.
Definition: TOPPASVertex.h:110
EdgeContainer out_edges_
The list of outgoing edges.
Definition: TOPPASVertex.h:285
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:303
Definition: TOPPASVertex.h:140
void debugOut_(const String &) const
Displays the debug output message, if TOPPAS_DEBUG is defined.
Definition: TOPPASVertex.h:334
Definition: TOPPASVertex.h:148
bool reachable_
Indicates whether this node is reachable (i.e. there is an input node somewhere further upstream) ...
Definition: TOPPASVertex.h:309
std::vector< RoundPackage > RoundPackages
all information a node needs to process all rounds
Definition: TOPPASVertex.h:135
EdgeContainer in_edges_
The list of incoming edges.
Definition: TOPPASVertex.h:283
RoundPackages output_files_
Stores the current output file names for each output parameter.
Definition: TOPPASVertex.h:301
QList< TOPPASEdge * > EdgeContainer
The container for in/out edges.
Definition: TOPPASVertex.h:108
Definition: TOPPASVertex.h:141
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
VertexRoundPackage()
Definition: TOPPASVertex.h:116
QColor brush_color_
The color of the brush.
Definition: TOPPASVertex.h:291
EdgeContainer::const_iterator ConstEdgeIterator
A const iterator for in/out edges.
Definition: TOPPASVertex.h:112
bool topo_sort_marked_
&quot;marked&quot; flag for topological sort
Definition: TOPPASVertex.h:297
UInt topo_nr_
The number in a topological sort of the entire graph.
Definition: TOPPASVertex.h:299
int round_counter_
currently finished number of rounds (TODO: do we need that?)
Definition: TOPPASVertex.h:305

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