00001
00002
00003
00004
00005
00006
00007
00008 #ifndef VOLUMETREE_H
00009 #define VOLUMETREE_H
00010
00011
00012
00013 #include <QtGui>
00014 #include "Tool.h"
00015
00016
00017
00018 class IrisGui;
00019 class Tool;
00020 class Slice;
00021 class Section;
00022 class Image;
00023 class Pipeline;
00024 class PyramidTool;
00025 struct ReadiedProcess;
00026 namespace Iris { class IrisTests; }
00027
00028 class Volume : public QAbstractItemModel
00029 {
00030 Q_OBJECT
00031
00032 friend class PyramidTool;
00033 friend class VolumeImporter;
00034 friend class Iris::IrisTests;
00035 friend void IrisGui::RefreshVolumeInformation();
00036
00037 public:
00038 static QHash<Tool::ToolType, QIcon> IconList;
00039
00040 Volume();
00041 Volume(const QString &dirName);
00042 ~Volume();
00043
00044
00045 bool Open( const QString &path );
00046 void ClearSections();
00047 void Save( QXmlStreamWriter &xmlWriter, const QString &pipelinePath );
00048 bool SafeToExit();
00049
00050
00051 QDir GetDir();
00052 QString GetAbsolutePath();
00053 QStringList GetChannels() { return channelList; }
00054 QStringList GetDownsamples() { return downsampleList; }
00055 QList<Image*> GetAllImages();
00056 QList<Slice*> GetAllSlices();
00057 QList<Section*> GetAllSections() { return sections; }
00058 unsigned GetNextSliceIdForImporting();
00059 QString Name() { return volumeName->text(); }
00060 void SetName( QLineEdit *name ) { volumeName = name; }
00061 int SliceCount();
00062
00063 Pipeline* GetPipeline() { return defaultPipeline; }
00064 QString GetSavePath() { return savePath; }
00065 QString GetVolumeInfoPath() { return GetDir().absoluteFilePath("VolumeInfo.xml"); }
00066
00067 Section * GetSection( int row );
00068
00069 static QDir GetExecutableDir( bool trueExecutableDirectory = false );
00070 static QDir GetToolsDirectory( bool trueExecutableDirectory = false );
00071 static QStringList GetAcceptableExtensions() { return Volume::validExtensions; }
00072 static QStringList GetAcceptableFilenames() { return Volume::validFileNames; }
00073 static QIcon GetIcon( Tool::ToolType type );
00074
00075 bool RecursivelyDelete(const QString &path);
00076
00077
00078 static int NextValidImageID(QDir dir);
00079 static bool CopyImage(QString &copiedPath, const QDir &dir, const QString &dir_str, int nextValidId, bool suppressOutput = false);
00080 static bool ValidExtension(const QFileInfo &fileInfo, bool checkExistance);
00081 static bool ValidExtension(const QString &imageName);
00082 static bool ValidImageDirectory(const QString &dirName);
00083 static bool ValidImageName(const QString &imageName);
00084
00085 static bool ValidateImageName(const QString &dir);
00086 static bool ValidateDirectoryName(const QString &dir);
00087
00088 void SetRecentVolumesMenu(QMenu *menuRecentVolumes);
00089 void RefreshRecentList();
00090 void RefreshControlCombos();
00091
00092
00093 Section * AddSection( const QString §ionName = "" );
00094 void AddSection( Section *section, const QString &parentSection, int idx = -1 );
00095 Section * AddSection( QXmlStreamReader &xmlReader );
00096
00097 void MoveSection( int oldRow, int newRow );
00098 void MoveSlice( Section *oldSection, int oldRow, Section *newSection, int newRow );
00099 void MoveImage( Slice *oldSlice, int oldRow, Slice *newSlice );
00100 void DeleteSection( Section *section, bool trueDelete );
00101 void CleanSelected( QList<VolumeIndex *> indices, ToolAlias *aliasToClean );
00102
00103 Slice * AddSlice( Section *section, const QString &requestedName = "" );
00104 void AddSlice( Section *section, Slice *slice, int idx = -1 );
00105 Slice * AddSlice( Section *section, QXmlStreamReader &xmlReader );
00106 void DeleteSlice( Slice *slice, bool trueDelete );
00107 void ToolFinished( const ReadiedProcess &finishedProcess, int runTime );
00108
00109 void AddImage( Slice *slice, Image *image, int idx = -1 );
00110 void DeleteImage( Image *image, bool trueDelete );
00111
00112
00113 virtual int columnCount( const QModelIndex &parent ) const;
00114 virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
00115 virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
00116 virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
00117 virtual QStringList mimeTypes() const;
00118 virtual QMimeData * mimeData(const QModelIndexList &indexes) const;
00119 virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
00120 virtual QModelIndex parent( const QModelIndex &parent ) const;
00121 virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
00122 QModelIndex index( Slice *slice ) const;
00123 QModelIndex index( Section *section ) const;
00124 QModelIndex index( VolumeIndex *vIndex ) const;
00125 QVariant headerData( int slice, Qt::Orientation orientation, int role ) const;
00126 bool setData(const QModelIndex & index, const QVariant & value, int role);
00127
00128 void NumToolRun( ToolAlias *alias, int &numRun, int &totPossible );
00129 float ToolProgress( ToolAlias *alias );
00130
00131 void ClearImages( Slice *slice );
00132 void RefreshImages( Slice *slice );
00133
00134 private:
00135 bool SetDir(const QFileInfo &fileInfo);
00136 void UpdateRecentList( const QString &path );
00137
00138 void Load( QXmlStreamReader &xmlReader );
00139 bool ValidateVolumeMetaData();
00140 void SavePipeline( const QString &pipelinePath );
00141
00142 public slots:
00143 bool New( const QString &path = "" );
00144 void Open();
00145 void OpenRecent();
00146 bool Save();
00147 bool SaveAs();
00148 void Relocate();
00149 void RunDefaultPipeline();
00150 void LoadPipeline( const QString &pipelinePath = "" );
00151 bool ImportPipeline( const QString &path = "" );
00152 bool ExportPipeline( const QString &path = "" );
00153
00154 void DownsampleChanged( const QString & ds );
00155 void ChannelChanged( const QString & ch = "" );
00156 void ControlChanged( int idx );
00157 void Dirty() { needsSave = true; }
00158 void AddDownsamples( const QStringList &downsamples );
00159 void AddChannels(const QStringList &channels);
00160 void ImportControlCombos();
00161 void RefreshImages();
00162
00163 Q_SIGNALS:
00164 void SetProgressRange( int min, int max );
00165 void SetProgressValue( int value );
00166
00167 private:
00168 QString savePath;
00169 QLineEdit *volumeName;
00170 QDir volumeDir;
00171
00172 bool needsSave;
00173 bool verified;
00174 QMenu *recentVolumesMenu;
00175
00176 float totalRuntime;
00177 int totalRuns;
00178 float recentRuntime;
00179 int recentNumRuns;
00180
00181 QList<Section *> sections;
00182 QHash<QString, Section *> sectionHash;
00183 QStringList channelList;
00184 QStringList downsampleList;
00185 QString prevChannel;
00186 QString prevDownsample;
00187
00188 void Initialize();
00189
00190 static QStringList validExtensions;
00191 static QStringList validFileNames;
00192
00193 Pipeline *defaultPipeline;
00194 QMutex volumeMutex;
00195 };
00196
00197
00198
00199 #endif