00001
00002
00003
00004
00005
00006
00007
00008 #ifndef PIPELINE_H
00009 #define PIPELINE_H
00010
00011
00012
00013 #include <QtGui>
00014 #include "PipelineEdit.h"
00015
00016
00017
00018 class Tool;
00019 class IrisGui;
00020 class ToolAlias;
00021 class ToolFlag;
00022 class AliasType;
00023
00024 class Pipeline : public QObject
00025 {
00026 Q_OBJECT
00027
00028 public:
00029 Pipeline();
00030 ~Pipeline();
00031
00032 void LoadDefaultPipeline();
00033 void LoadPipeline( QXmlStreamReader& xml );
00034 void SavePipeline( QXmlStreamWriter& xml );
00035
00036 int Append( Tool* tool, QHash<QString, ToolFlag *> *flags = NULL, int idx = 0, bool checkValid = true );
00037 void Remove( int idx );
00038 void Move( int oldIdx, int newIdx );
00039
00040 void Run( bool userRequest, bool runOnAllSlices = true );
00041 QStringList PreviousOutputList( int idx );
00042 void AddToLayout();
00043 void UpdateScrollWidth();
00044 void RemoveAllFromLayout();
00045 void SwapWidget( QWidget *oldWidget, QWidget *newWidget );
00046
00047 ToolAlias *GetAt( int idx );
00048 bool HasAlias( ToolAlias *alias );
00049 int IndexOf( AliasType type ) const;
00050 QList<ToolAlias *> GetAllAliasesOfType( AliasType type );
00051 int Count() { return aliasList.count(); }
00052 static QWidget *NewLabel( int type, Tool *tool, ToolAlias *alias = NULL );
00053
00054 public slots:
00055 void RefreshProgress();
00056
00057 public:
00058
00059 class const_iterator
00060 {
00061 private:
00062 int index;
00063 const Pipeline* pipeline;
00064 public:
00065 enum Type { START, END };
00066 const_iterator( const Pipeline* pipeline, Type type )
00067 {
00068 this->pipeline = pipeline;
00069 if ( type == START )
00070 index = 0;
00071 if ( type == END )
00072 index = pipeline->aliasList.size();
00073 }
00074 const ToolAlias* operator*() { return pipeline->aliasList[index]; }
00075 bool operator!=( const const_iterator& it ) const { return ( index != it.index ); }
00076 const_iterator& operator++() { index++; return *this; }
00077 };
00078 const_iterator constBegin() const { return const_iterator(this, const_iterator::START); };
00079 const_iterator constEnd() const { return const_iterator(this, const_iterator::END); };
00080
00081 class iterator
00082 {
00083 private:
00084 int index;
00085 const Pipeline* pipeline;
00086 public:
00087 enum Type { START, END };
00088 iterator( const Pipeline* pipeline, Type type )
00089 {
00090 this->pipeline = pipeline;
00091 if ( type == START )
00092 index = 0;
00093 if ( type == END )
00094 index = pipeline->aliasList.size();
00095 }
00096 ToolAlias* operator*() { return pipeline->aliasList[index]; }
00097 bool operator!=( const iterator& it ) const { return ( index != it.index ); }
00098 iterator& operator++() { index++; return *this; }
00099 };
00100 iterator begin() const { return iterator(this, iterator::START); };
00101 iterator end() const { return iterator(this, iterator::END); };
00102
00103 private:
00104 QList<ToolAlias *> aliasList;
00105 QList<QWidget *> aliasWidgets;
00106 QHash<Tool *, int> toolCounter;
00107 int current;
00108 };
00109
00110 #endif