00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IRISGUI_H
00009 #define IRISGUI_H
00010
00011
00012
00013 class IrisGui;
00014 class ImageHistogram;
00015 class PipelineEdit;
00016 class Image;
00017 class Slice;
00018 class Section;
00019 class SliceIconProvider;
00020 class SliceModel;
00021 class Tool;
00022 class Volume;
00023 class QNetworkReply;
00024
00025
00026
00027 #include "ui_iris.h"
00028 #include "GlobalDefines.h"
00029 #include "Pipeline.h"
00030 #include "ProcessSettings.h"
00031
00032 #include <QFileInfo>
00033 #include <QtGui>
00034
00035
00036
00037 class VolumeIndex;
00038 class InternalTool;
00039 namespace Iris { class IrisTests; }
00040 namespace Ui { class IrisPreferences; }
00041
00042 struct ReadiedProcess
00043 {
00044
00045 QString prog;
00046 QStringList args;
00047 QProcess *proc;
00048 QString shortName;
00049 QHash<QString, QStringList> outputFiles;
00050 QTime timer;
00051
00052
00053 bool isInternalTool;
00054 InternalTool *internalTool;
00055
00056
00057 QList<VolumeIndex *> indicesToUpdate;
00058 ToolAlias *alias;
00059 QStringList channels;
00060 };
00061
00062 struct UserPreferences
00063 {
00064 static QString defaultLocation;
00065 static int defaultMethod;
00066 static QStringList recentList;
00067 static bool toolsInPath;
00068 static QString pathToTools;
00069 static int cleanType;
00070 static QHash<QString, QVariant> lastDirHash;
00071 static bool searchDiskForInput;
00072 static bool sectionIsSlice;
00073 static bool flatVolume;
00074 static int testingMode;
00075 static bool debug;
00076 static QString debugLocation;
00077 static int downsampleLevels;
00078 };
00079
00080 class IrisGui : public QMainWindow, protected Ui::IrisMainWindow
00081 {
00082 Q_OBJECT
00083
00084 friend class Iris::IrisTests;
00085 friend void Pipeline::UpdateScrollWidth();
00086 friend void OutputInformation::Toggle();
00087 friend void OutputInformation::ToggleVerbose( bool enabled );
00088
00089 public:
00090 IrisGui(QWidget *parent = 0);
00091 ~IrisGui();
00092
00093 static IrisGui& instance();
00094 static void OutputError(QWidget *parent, const QString &title, const QString &name);
00095
00096 void Initialize();
00097 void DefaultMethodChanged();
00098 void BuildToolList();
00099
00100 QList<VolumeIndex *> GetSelectedVolumeIndices( bool runOnSections, bool runOnAllSlices );
00101 QList<Slice*> GetSelectedSlices( bool getAllSlices = false );
00102 QList<Section*> GetSelectedSections( bool getAllSections = false );
00103 QList<Image*> GetSelectedImages( bool getAllImages = false );
00104 QStringList GetSelectedChannels( bool forceRefresh = false );
00105
00106 void RunFrontProcess();
00107 bool IsToolRunning() { return numRunningThreads > 0; }
00108
00109 void Clean( Tool* tool );
00110
00111 void contextMenuEvent(QContextMenuEvent *event);
00112
00113 Volume *GetVolume() { return volume; }
00114 PipelineEdit *GetToolbox() { return toolboxFrame; }
00115 PipelineEdit *GetPipelineEdit() { return pipelineFrame; }
00116 QBoxLayout *GetInnerPipelineLayout() { return innerPipelineLayout; }
00117 QGridLayout *GetInnerToolboxLayout() { return toolGrabber; }
00118 QMenu *GetMenu( bool isPipeline, QAction *&before, int groupId = 0 );
00119 QListWidget *GetVolumeInfoListWidget() { return importedList; }
00120
00121 void EnableSetDefaultButton( bool enabled = true ) { this->setAsDefault_pb->setDisabled( !enabled ); }
00122 void RefreshVolumeInformation();
00123 void SetControlSections( const QModelIndex &index, const QStringList &controlNames, int idx );
00124
00125 void SetEnabled( bool enabled );
00126 static QString HtmlText( int ptSize, const QString &color, int weight, const QString &text );
00127
00128 enum
00129 {
00130 STEP1_INPUTDIR = 0,
00131 STEP2_RUNTOOLS,
00132 STEP2_RUNNING,
00133 STEP3_EXPORT,
00134 };
00135
00136 private:
00137 void RunReadiedProcess( const ReadiedProcess &readiedProcess );
00138 void WriteSettings();
00139 void ReadSettings();
00140
00141 protected:
00142 void closeEvent(QCloseEvent *event);
00143
00144 public slots:
00145
00146 void AddImage_Clicked();
00147 void RemoveImage_Clicked();
00148 void AddSlice_Clicked();
00149 void RefreshDropdownDialogs();
00150 void PreferencesDialog();
00151 void About();
00152 void CheckForUpdates();
00153 void UpdateCheckFinished( QNetworkReply* reply );
00154 void ViewSlice( const QModelIndex & );
00155
00156 void KillProcess( bool killAll = false );
00157 void KillAllProcesses() { return KillProcess( true ); }
00158
00159 void RunBatchBuild();
00160
00161 void OutputMessageFromProcess();
00162 void ProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
00163
00164 void PathComboBoxChanged(int idx);
00165 void ToolComboBoxChanged(int idx);
00166
00167 void SelectAll();
00168 void SetAsDefault();
00169 void SetSelectedChannels( const QStringList &channels );
00170 void SetDownsample( const QString &downsample );
00171
00172 void QueueProcess( const QString &prog, const QStringList &args, const QString &shortName,
00173 ToolAlias *alias, const QList<VolumeIndex *> &indicesToUpdate,
00174 const QHash<QString, QStringList> &outputFiles );
00175 void QueueFunction( InternalTool *internalTool, const QStringList &args, const QString &shortName,
00176 ToolAlias *alias, const QList<VolumeIndex *> &indicesToUpdate );
00177 void OutputMessage(const QString &str, int lines = -1);
00178 void ResizeColumnsToContents();
00179 void SetToolProgress( double percent, bool failure );
00180 void SetTitle(const QString &);
00181
00182 private:
00183 static IrisGui *instance_;
00184 Volume *volume;
00185
00186
00187 QString selectedSlice_str;
00188 QString selectedImage_str;
00189
00190 bool slicesUpToDate;
00191 bool imagesUpToDate;
00192 int lastDecision;
00193
00194
00195 QList<QProcess *> runningProcesses;
00196 QHash<QObject *, ReadiedProcess> runningHash;
00197 int numRunningThreads;
00198 QQueue<ReadiedProcess> procQueue;
00199
00200 bool cancelledProcess;
00201
00202 QString logName;
00203
00204 double lastMajorPercentage;
00205 Ui::IrisPreferences *preferences;
00206
00207 bool validSelectedChannels;
00208 QStringList selectedChannels;
00209
00210 int currentTool;
00211 int outOfTool;
00212 };
00213
00214 #endif