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 #include "cmtkQtTriplanarViewer.h"
00034
00035 #include <qmenu.h>
00036 #include <qmenubar.h>
00037 #include <qapplication.h>
00038 #include <qfiledialog.h>
00039 #include <qlayout.h>
00040 #include <QVBoxLayout>
00041
00042 #include <Qt/cmtkQtImageOperators.h>
00043 #include <Base/cmtkAnatomicalOrientation.h>
00044 #include <IO/cmtkStudy.h>
00045
00046 namespace
00047 cmtk
00048 {
00049
00052
00053 QtTriplanarViewer::QtTriplanarViewer()
00054 : WindowLevel( NULL )
00055 {
00056 this->setWindowTitle( "Triplanar Image Viewer" );
00057
00058 QMenu* StudyMenu = new QMenu();
00059 StudyMenu->setTitle( "&Study" );
00060 StudyMenu->addAction( "&Load...", this, SLOT( slotLoadFile() ) );
00061 StudyMenu->addAction( "&Reload Data...", this, SLOT( slotReloadData() ) );
00062 StudyMenu->addSeparator();
00063 StudyMenu->addAction( "&Save" );
00064 StudyMenu->addAction( "Save &as..." );
00065 StudyMenu->addAction( "&Export landmarks..." );
00066 StudyMenu->addSeparator();
00067 StudyMenu->addAction( "&Quit", qApp, SLOT( quit() ) );
00068
00069 QtImageOperators* imageOperators = new QtImageOperators( &this->m_Study, this, NULL );
00070 QObject::connect( imageOperators, SIGNAL( dataChanged( Study::SmartPtr& ) ), this, SLOT( slotDataChanged( Study::SmartPtr& ) ) );
00071
00072
00073 MenuBar->insertMenu( this->ViewMenu->menuAction(), StudyMenu );
00074
00075 MenuBar->addMenu( imageOperators->CreatePopupMenu() );
00076 MenuBar->show();
00077
00078 this->m_ImagesTab = new QWidget( this->m_ControlsTab );
00079 this->m_ControlsTab->addTab( this->m_ImagesTab, "Images" );
00080 this->m_ControlsTab->setTabEnabled( this->m_ControlsTab->indexOf( this->m_ImagesTab ), false );
00081
00082 this->m_StudiesListBox = new QListWidget( this->m_ImagesTab );
00083 this->m_StudiesListBox->setSelectionMode( QAbstractItemView::SingleSelection );
00084
00085 QObject::connect( this->m_StudiesListBox, SIGNAL( currentTextChanged( const QString& ) ), this, SLOT( slotSwitchStudy( const QString& ) ) );
00086
00087 QVBoxLayout* studiesLayout = new QVBoxLayout( this->m_ImagesTab );
00088 studiesLayout->setContentsMargins( 5, 5, 5, 5 );
00089 studiesLayout->setSpacing( 5 );
00090
00091 studiesLayout->addWidget( this->m_StudiesListBox );
00092
00093 QPushButton* copyColormapButton = new QPushButton( this->m_ImagesTab );
00094 copyColormapButton->setText( "Copy Colormap to Other Images" );
00095 studiesLayout->addWidget( copyColormapButton );
00096
00097 QObject::connect( copyColormapButton, SIGNAL( clicked() ), this, SLOT( slotCopyColormapToOtherImages() ) );
00098 }
00099
00100 void
00101 QtTriplanarViewer::slotAddStudy( const char* fname )
00102 {
00103 Study::SmartPtr newStudy( new Study( fname ) );
00104 this->m_StudiesListBox->addItem( QString( newStudy->GetFileSystemPath() ) );
00105
00106 this->m_Studies.push_back( newStudy );
00107 this->m_ControlsTab->setTabEnabled( this->m_ControlsTab->indexOf( this->m_ImagesTab ), this->m_Studies.size() > 1 );
00108
00109 this->slotSwitchToStudy( newStudy );
00110 this->slotCenter();
00111 }
00112
00113 void
00114 QtTriplanarViewer::slotLoadFile()
00115 {
00116 #ifdef CMTK_BUILD_NRRD
00117 QString path = QFileDialog::getOpenFileName( this, "Load File", QString(), "All image files (*.hdr *.nii *.nii.gz *.nrrd *.nhdr *.pic);; NIfTI / Analyze (*.hdr *.nii *.nii.gz);; Nrrd (*.nhdr *.nrrd);; BIORAD (*.pic)" );
00118 #else
00119 QString path = QFileDialog::getOpenFileName( this, "Load File", QString(), "All image files (*.hdr *.nii *.nii.gz *.pic);; NIfTI / Analyze (*.hdr *.nii *.nii.gz);; BIORAD (*.pic)" );
00120 #endif
00121
00122 if ( ! (path.isEmpty() || path.isNull() ) )
00123 {
00124 Study::SmartPtr newStudy( new Study( path.toLatin1() ) );
00125
00126 this->m_Studies.push_back( newStudy );
00127 this->m_ControlsTab->setTabEnabled( this->m_ControlsTab->indexOf( this->m_ImagesTab ), this->m_Studies.size() > 1 );
00128
00129 this->m_StudiesListBox->addItem( QString( newStudy->GetFileSystemPath() ) );
00130 this->m_StudiesListBox->setCurrentItem( this->m_StudiesListBox->item( this->m_StudiesListBox->count()-1 ) );
00131
00132 this->slotSwitchToStudy( newStudy );
00133 this->slotCenter();
00134 }
00135 }
00136
00137 void
00138 QtTriplanarViewer::slotReloadData()
00139 {
00140 if ( this->m_Study )
00141 {
00142 this->m_Study->ReadVolume( true , AnatomicalOrientation::ORIENTATION_STANDARD );
00143 }
00144 }
00145
00146 void
00147 QtTriplanarViewer::slotSwitchStudy( const QString& study )
00148 {
00149 for ( size_t idx = 0; idx < this->m_Studies.size(); ++idx )
00150 {
00151 if ( study == QString( this->m_Studies[idx]->GetFileSystemPath() ) )
00152 {
00153 this->slotSwitchToStudyInternal( this->m_Studies[idx] );
00154 return;
00155 }
00156 }
00157 }
00158
00159 void
00160 QtTriplanarViewer::slotCopyColormapToOtherImages()
00161 {
00162 if ( this->m_Study )
00163 {
00164 for ( size_t i = 0; i < this->m_Studies.size(); ++i )
00165 {
00166 if ( this->m_Studies[i] != this->m_Study )
00167 {
00168 this->m_Studies[i]->CopyColormap( this->m_Study );
00169 }
00170 }
00171 }
00172 }
00173
00174 }