00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef INTERNAL_TOOL_H
00010 #define INTERNAL_TOOL_H
00011
00012
00013
00014 #include <QtGui>
00015 #include "Tool.h"
00016
00017 class InternalTool : public QThread
00018 {
00019 Q_OBJECT
00020
00021 public:
00022 InternalTool();
00023 virtual void Start( ReadiedProcess *process ) { this->process = process; start(); }
00024 virtual void run() = 0;
00025
00026 static InternalTool *GetInternalToolByType( const QString &type );
00027
00028 public slots:
00029 void ToolFinished() { emit ProcessFinished(0, (failure) ? QProcess::CrashExit : QProcess::NormalExit); }
00030
00031 signals:
00032 void ProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
00033 void RefreshDropdownDialogs();
00034
00035 void QueueProcess( const QString &prog, const QStringList &args, const QString &shortName,
00036 ToolAlias *alias, const QList<VolumeIndex *> &indicesToUpdate,
00037 const QHash<QString, QStringList> &outputFiles );
00038 void QueueFunction( InternalTool *internalTool, const QStringList &args, const QString &shortName,
00039 ToolAlias *alias, const QList<VolumeIndex *> &indicesToUpdate );
00040 void OutputMessage( const QString &str );
00041 void Dirty();
00042 void AddDownsamples( const QStringList &downsamples );
00043 void AddChannels( const QStringList &channels );
00044 void SetToolProgress( double percent, bool failure );
00045
00046 protected:
00047 ReadiedProcess *process;
00048 bool failure;
00049 };
00050
00051 class Snapshot : public InternalTool
00052 {
00053 public:
00054 bool TakeSliceSnapshot( ReadiedProcess *process );
00055
00056 protected:
00057 void run() { TakeSliceSnapshot( process ); }
00058 };
00059
00060 class PyramidTool : public InternalTool
00061 {
00062 public:
00063 PyramidTool();
00064 void run() { failure = !BuildPyramid( process ); }
00065
00066 bool BuildPyramid( ReadiedProcess *process );
00067 bool CreatePyramid( VolumeIndex* slice, const QString &channelName, ToolAlias* alias );
00068 };
00069
00070 class ChannelSelect : public InternalTool
00071 {
00072 Q_OBJECT
00073
00074 public:
00075 ChannelSelect();
00076 void run();
00077
00078 signals:
00079 void DownsampleChanged( const QString &downsample );
00080 void ChannelsChanged( const QStringList &channels );
00081 };
00082
00083 class WriteVikingXml : public InternalTool
00084 {
00085 Q_OBJECT
00086
00087 public:
00088 void run() { failure = !GenerateVikingXML(); }
00089
00090 bool GenerateVikingXML();
00091 void GenerateVolumeXML(const QString &fileName);
00092 void WriteSliceXML(QXmlStreamWriter &xmlWriter, int sectionId, int sliceId, Slice &slice );
00093 void WriteStosXML(QXmlStreamWriter &xmlWriter, int sectionId, int sliceId, const QHash<int, int> §ionNumHash);
00094 void WritePyramidXML(QXmlStreamWriter &xmlWriter);
00095 bool WriteTilesetXml(QXmlStreamWriter &xmlWriter, Slice &slice, const QString &assembleFile, bool isFirst );
00096
00097 private:
00098 Volume *volume;
00099 QDir volumeDir;
00100 QList<ToolAlias *> aliases;
00101 QList<ToolAlias *> tiledAliases;
00102
00103 QString volumeHttpPath;
00104 QString volumeName;
00105 QStringList channels;
00106 };
00107
00108
00109 class ExportResults : public InternalTool
00110 {
00111 Q_OBJECT
00112
00113 public:
00114 void run() { ExportBoth(); }
00115
00116 void ExportBoth();
00117 void Export( Tool* tool, const QList<VolumeIndex *> &indices, const QString &destName );
00118 void ExportTool( Tool* tool, VolumeIndex* index, const QDir &dest, bool multipleTools );
00119 void ExportSlice();
00120 void ExportVolume();
00121
00122 private:
00123 QString stomPath;
00124 QString assemblePath;
00125 QStringList channels;
00126
00127 bool first;
00128 };
00129
00130
00131
00132 class VolumeImporter : public InternalTool
00133 {
00134 Q_OBJECT
00135
00136 public:
00137 VolumeImporter( bool importExisting = false );
00138 void run();
00139
00140 void SmartImport();
00141 bool ImportFromExistingStructure( const QString &pipelinePath );
00142
00143 bool ImportAdoc(const QDir &dir);
00144 bool ImportAssembledImages(const QDir &dir);
00145 bool ImportZeissFormat(const QDir &dir, bool mosaicOnly = false);
00146 bool ImportZeissFormatSingleXML(const QDir &dir, const QString &baseType);
00147 bool ImportA1RFormat(const QDir &dir, bool importMaxProjectionSlices = false,
00148 bool mosaicOnly = false);
00149 QStringList ImportChannels(const QString &path = "");
00150 QStringList ImportDownsamples(const QString &channel, const QString &path = "");
00151 void AppendToVolumeInfo(const QDir &sliceDir);
00152
00153 static QStringList GetImportDirs(const QString &desc);
00154 static QStringList GetVolumeInfo( Volume *volume );
00155
00156 signals:
00157 void RefreshProgress();
00158 void ImportControlCombos();
00159 void ResizeColumnsToContents();
00160
00161 private:
00162 QDir GetPrimarySliceFromDisk();
00163 bool importExisting;
00164 QString errString;
00165
00166 Volume *volume;
00167
00168 float overrideScaleFactorX;
00169 float overrideScaleFactorY;
00170 };
00171
00172 #endif