Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_VISUAL_TOPPASVERTEX_H
00036 #define OPENMS_VISUAL_TOPPASVERTEX_H
00037
00038
00039
00040
00041
00042
00043
00044 #ifdef TOPPAS_DEBUG
00045 #define __DEBUG_BEGIN_METHOD__ \
00046 { \
00047 for (int dbg_indnt_cntr = 0; dbg_indnt_cntr < global_debug_indent_; ++dbg_indnt_cntr) \
00048 { \
00049 std::cout << " "; \
00050 } \
00051 std::cout << "BEGIN [" << topo_nr_ << "] " << __PRETTY_FUNCTION__ << std::endl; \
00052 ++global_debug_indent_; \
00053 }
00054
00055 #define __DEBUG_END_METHOD__ \
00056 { \
00057 --global_debug_indent_; \
00058 if (global_debug_indent_ < 0) global_debug_indent_ = 0; \
00059 for (int dbg_indnt_cntr = 0; dbg_indnt_cntr < global_debug_indent_; ++dbg_indnt_cntr) \
00060 { \
00061 std::cout << " "; \
00062 } \
00063 std::cout << "END [" << topo_nr_ << "] " << __PRETTY_FUNCTION__ << std::endl; \
00064 }
00065 #else
00066 #define __DEBUG_BEGIN_METHOD__ {}
00067 #define __DEBUG_END_METHOD__ {}
00068 #endif
00069
00070
00071
00072 #include <OpenMS/DATASTRUCTURES/String.h>
00073 #include <OpenMS/DATASTRUCTURES/Map.h>
00074
00075 #include <QtGui/QPainter>
00076 #include <QtGui/QPainterPath>
00077 #include <QtGui/QGraphicsSceneMouseEvent>
00078 #include <QtGui/QGraphicsSceneContextMenuEvent>
00079 #include <QtGui/QGraphicsItem>
00080 #include <QtCore/QProcess>
00081 #include <QtGui/QMenu>
00082
00083 namespace OpenMS
00084 {
00085 class TOPPASEdge;
00086
00098 class OPENMS_GUI_DLLAPI TOPPASVertex :
00099 public QObject,
00100 public QGraphicsItem
00101 {
00102 Q_OBJECT
00103
00104
00105 public:
00106
00108 typedef QList<TOPPASEdge *> EdgeContainer;
00110 typedef EdgeContainer::iterator EdgeIterator;
00112 typedef EdgeContainer::const_iterator ConstEdgeIterator;
00114 struct VertexRoundPackage
00115 {
00116 VertexRoundPackage() :
00117 filenames(),
00118 edge(0)
00119 {
00120 }
00121
00122 QStringList filenames;
00123 TOPPASEdge * edge;
00124 };
00125
00130 typedef std::map<Int, VertexRoundPackage> RoundPackage;
00131 typedef RoundPackage::const_iterator RoundPackageConstIt;
00132 typedef RoundPackage::iterator RoundPackageIt;
00133
00135 typedef std::vector<RoundPackage> RoundPackages;
00136
00138 enum DFS_COLOR
00139 {
00140 DFS_WHITE,
00141 DFS_GRAY,
00142 DFS_BLACK
00143 };
00144
00146 enum SUBSTREESTATUS
00147 {
00148 TV_ALLFINISHED,
00149 TV_UNFINISHED,
00150 TV_UNFINISHED_INBRANCH
00151 };
00152
00154 TOPPASVertex();
00156 TOPPASVertex(const TOPPASVertex & rhs);
00158 virtual ~TOPPASVertex();
00160 TOPPASVertex & operator=(const TOPPASVertex & rhs);
00161
00165 bool buildRoundPackages(RoundPackages & pkg, String & error_msg);
00166
00168 bool isUpstreamFinished() const;
00169
00171 virtual QRectF boundingRect() const = 0;
00173 virtual QPainterPath shape() const = 0;
00175 virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) = 0;
00177 ConstEdgeIterator outEdgesBegin() const;
00179 ConstEdgeIterator outEdgesEnd() const;
00181 ConstEdgeIterator inEdgesBegin() const;
00183 ConstEdgeIterator inEdgesEnd() const;
00185 Size incomingEdgesCount();
00187 Size outgoingEdgesCount();
00189 void addInEdge(TOPPASEdge * edge);
00191 void addOutEdge(TOPPASEdge * edge);
00193 void removeInEdge(TOPPASEdge * edge);
00195 void removeOutEdge(TOPPASEdge * edge);
00197 DFS_COLOR getDFSColor();
00199 void setDFSColor(DFS_COLOR color);
00201 TOPPASVertex * getDFSParent();
00203 void setDFSParent(TOPPASVertex * parent);
00205 TOPPASVertex::SUBSTREESTATUS getSubtreeStatus() const;
00207 bool isTopoSortMarked();
00209 void setTopoSortMarked(bool b);
00211 UInt getTopoNr();
00213 virtual void setTopoNr(UInt nr);
00215 virtual void reset(bool reset_all_files = false);
00217 virtual void markUnreachable();
00219 bool isReachable();
00221 bool isFinished() const;
00224 virtual void run();
00226 virtual bool invertRecylingMode();
00228 bool isRecyclingEnabled() const;
00230 void setRecycling(const bool is_enabled);
00231
00232
00233 virtual String getName() const = 0;
00234
00240 QStringList getFileNames(int param_index, int round) const;
00241
00243 QStringList getFileNames() const;
00244
00245
00246 const RoundPackages & getOutputFiles() const;
00247
00248
00250 bool allInputsReady();
00251
00252
00253 public slots:
00254
00256 virtual void inEdgeHasChanged();
00258 virtual void outEdgeHasChanged();
00259
00260 signals:
00261
00263 void clicked();
00265 void released();
00267 void hoveringEdgePosChanged(const QPointF & new_pos);
00269 void newHoveringEdge(const QPointF & pos);
00271 void finishHoveringEdge();
00273 void somethingHasChanged();
00275 void itemDragged(qreal dx, qreal dy);
00278 void parameterChanged(const bool invalidates_running_pipeline);
00279
00280 protected:
00281
00283 EdgeContainer in_edges_;
00285 EdgeContainer out_edges_;
00287 bool edge_being_created_;
00289 QColor pen_color_;
00291 QColor brush_color_;
00293 DFS_COLOR dfs_color_;
00295 TOPPASVertex * dfs_parent_;
00297 bool topo_sort_marked_;
00299 UInt topo_nr_;
00301 RoundPackages output_files_;
00303 int round_total_;
00305 int round_counter_;
00307 bool finished_;
00309 bool reachable_;
00311 bool allow_output_recycling_;
00312
00313
00314 #ifdef TOPPAS_DEBUG
00315
00316 static int global_debug_indent_;
00317 #endif
00318
00320
00321 void mouseReleaseEvent(QGraphicsSceneMouseEvent * e);
00322 void mousePressEvent(QGraphicsSceneMouseEvent * e);
00323 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * e);
00324 void mouseMoveEvent(QGraphicsSceneMouseEvent * e);
00325 void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
00327
00329 virtual void moveNewEdgeTo_(const QPointF & pos);
00331 String get3CharsNumber_(UInt number) const;
00332
00334 void debugOut_(const String &
00335 #ifdef TOPPAS_DEBUG
00336 message
00337 #endif
00338 ) const
00339 {
00340 #ifdef TOPPAS_DEBUG
00341 for (int i = 0; i < global_debug_indent_; ++i)
00342 {
00343 std::cout << " ";
00344 }
00345 std::cout << "[" << topo_nr_ << "] " << message << std::endl;
00346 #endif
00347 }
00348
00349 };
00350 }
00351
00352 #endif