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_TOPPASSCENE_H
00036 #define OPENMS_VISUAL_TOPPASSCENE_H
00037
00038 #include <OpenMS/config.h>
00039 #include <OpenMS/VISUAL/TOPPASEdge.h>
00040 #include <OpenMS/DATASTRUCTURES/String.h>
00041 #include <OpenMS/VISUAL/TOPPASToolVertex.h>
00042
00043 #include <QtGui/QGraphicsScene>
00044 #include <QtCore/QProcess>
00045
00046 namespace OpenMS
00047 {
00048 class TOPPASVertex;
00049 class TOPPASToolVertex;
00050 class TOPPASMergerVertex;
00051 class TOPPASOutputFileListVertex;
00052 class TOPPASEdge;
00053 class TOPPASResources;
00054
00058 class FakeProcess :
00059 public QProcess
00060 {
00061 Q_OBJECT
00062
00063 public:
00064 virtual void start(const QString & program, const QStringList & arguments, OpenMode mode = ReadWrite);
00065 };
00066
00084 class OPENMS_GUI_DLLAPI TOPPASScene :
00085 public QGraphicsScene
00086 {
00087 Q_OBJECT
00088
00089 public:
00090
00092 struct TOPPProcess
00093 {
00095 TOPPProcess(QProcess * p, const QString & cmd, const QStringList & arg, TOPPASToolVertex * const tool) :
00096 proc(p),
00097 command(cmd),
00098 args(arg),
00099 tv(tool)
00100 {
00101 }
00102
00104 QProcess * proc;
00106 QString command;
00108 QStringList args;
00110 TOPPASToolVertex * tv;
00111 };
00112
00114 enum ActionMode
00115 {
00116 AM_NEW_EDGE,
00117 AM_MOVE
00118 };
00119
00120
00122 enum RefreshStatus
00123 {
00124 ST_REFRESH_NOCHANGE,
00125 ST_REFRESH_CHANGED,
00126 ST_REFRESH_CHANGEINVALID
00127 };
00128
00129
00131 typedef QList<TOPPASEdge *> EdgeContainer;
00133 typedef EdgeContainer::iterator EdgeIterator;
00135 typedef EdgeContainer::const_iterator ConstEdgeIterator;
00137 typedef QList<TOPPASVertex *> VertexContainer;
00139 typedef VertexContainer::iterator VertexIterator;
00141 typedef VertexContainer::const_iterator ConstVertexIterator;
00142
00144 TOPPASScene(QObject * parent, const QString & tmp_path, bool gui = true);
00145
00147 virtual ~TOPPASScene();
00148
00150 void addVertex(TOPPASVertex * tv);
00152 void addEdge(TOPPASEdge * te);
00154 void setActionMode(ActionMode mode);
00156 ActionMode getActionMode();
00158 VertexIterator verticesBegin();
00160 VertexIterator verticesEnd();
00162 EdgeIterator edgesBegin();
00164 EdgeIterator edgesEnd();
00166 void copySelected();
00168 void paste(QPointF pos = QPointF());
00170 void removeSelected();
00172 void unselectAll();
00174 void updateEdgeColors();
00176 void resetDownstream(TOPPASVertex * vertex);
00178 void runPipeline();
00180 bool store(const String & file);
00182 void load(const String & file);
00184 void include(TOPPASScene * new_scene, QPointF pos = QPointF());
00186 const String & getSaveFileName();
00188 void setSaveFileName(const String & name);
00190 void topoSort();
00192 const QString & getOutDir();
00194 const QString & getTempDir();
00196 void setOutDir(const QString & dir);
00198 bool saveIfChanged();
00200 void setChanged(bool b);
00202 bool isPipelineRunning();
00204 bool askForOutputDir(bool always_ask = true);
00206 void enqueueProcess(const TOPPProcess & process);
00208 void runNextProcess();
00210 void resetProcessesQueue();
00212 void setClipboard(TOPPASScene * clipboard);
00214 void connectVertexSignals(TOPPASVertex * tv);
00216 void connectToolVertexSignals(TOPPASToolVertex * ttv);
00218 void connectOutputVertexSignals(TOPPASOutputFileListVertex * oflv);
00220 void connectMergerVertexSignals(TOPPASMergerVertex * tmv);
00222 void connectEdgeSignals(TOPPASEdge * e);
00224 void loadResources(const TOPPASResources & resources);
00226 void createResources(TOPPASResources & resources);
00228 bool wasChanged();
00230 RefreshStatus refreshParameters();
00232 bool isDryRun() const;
00234 QString getDescription() const;
00236 void setDescription(const QString & desc);
00238 void setAllowedThreads(int num_threads);
00240 TOPPASEdge* getHoveringEdge();
00242 void checkIfWeAreDone();
00243
00244
00245 public slots:
00246
00248 void abortPipeline();
00250 void itemClicked();
00252 void itemReleased();
00254 void updateHoveringEdgePos(const QPointF & new_pos);
00256 void addHoveringEdge(const QPointF & pos);
00258 void finishHoveringEdge();
00260 void pipelineErrorSlot(const QString msg = "");
00262 void moveSelectedItems(qreal dx, qreal dy);
00264 void snapToGrid();
00267 void setPipelineRunning(bool b = true);
00269 void changedParameter(const bool invalidates_running_pipeline);
00271 void processFinished();
00273 void quitWithError();
00274
00275
00277
00278
00279 void logTOPPOutput(const QString & out);
00281 void logToolStarted();
00283 void logToolFinished();
00285 void logToolFailed();
00287 void logToolCrashed();
00289 void logOutputFileWritten(const String & file);
00291
00292 signals:
00293
00295 void entirePipelineFinished();
00297 void pipelineExecutionFailed();
00299 void saveMe();
00301 void terminateCurrentPipeline();
00303 void selectionCopied(TOPPASScene * ts);
00305 void requestClipboardContent();
00307 void mainWindowNeedsUpdate();
00309 void openInTOPPView(QStringList all_files);
00311 void dryRunFinished(int, QProcess::ExitStatus);
00313 void messageReady(const QString & msg);
00314
00315
00316 protected:
00317
00319 ActionMode action_mode_;
00321 VertexContainer vertices_;
00323 EdgeContainer edges_;
00325 TOPPASEdge * hover_edge_;
00327 TOPPASVertex * potential_target_;
00329 String file_name_;
00331 QString tmp_path_;
00333 bool gui_;
00335 QString out_dir_;
00337 bool changed_;
00339 bool running_;
00341 bool error_occured_;
00343 bool user_specified_out_dir_;
00345 QList<TOPPProcess> topp_processes_queue_;
00347 TOPPASScene * clipboard_;
00349 bool dry_run_;
00351 int threads_active_;
00353 QString description_text_;
00355 int allowed_threads_;
00357 TOPPASToolVertex* resume_source_;
00358
00360 TOPPASVertex * getVertexAt_(const QPointF & pos);
00362 bool isEdgeAllowed_(TOPPASVertex * u, TOPPASVertex * v);
00364 bool dfsVisit_(TOPPASVertex * vertex);
00367 bool sanityCheck_(bool allowUserOverride);
00368
00370
00371 void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
00373
00375 void writeToLogFile_(const QString & text);
00376 };
00377
00378 }
00379
00380 #endif