Browse Source

Add next and previous buttons for image previewer

nherlambang 14 years ago
parent
commit
8c549d0617

+ 252 - 1
Libs/DICOM/Widgets/Resources/UI/ctkDICOMAppWidget.ui

@@ -121,6 +121,12 @@
       <layout class="QHBoxLayout" name="viewerLayout">
       <layout class="QHBoxLayout" name="viewerLayout">
        <item>
        <item>
         <widget class="ctkDICOMThumbnailListWidget" name="thumbnailsWidget" native="true">
         <widget class="ctkDICOMThumbnailListWidget" name="thumbnailsWidget" native="true">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
            <width>0</width>
            <width>0</width>
@@ -139,7 +145,150 @@
          </property>
          </property>
          <layout class="QVBoxLayout" name="verticalLayout_3">
          <layout class="QVBoxLayout" name="verticalLayout_3">
           <item>
           <item>
-           <widget class="ctkDICOMDatasetView" name="imagePreview" native="true"/>
+           <layout class="QHBoxLayout" name="horizontalLayout">
+            <item>
+             <widget class="QPushButton" name="prevStudyButton">
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>32</horstretch>
+                <verstretch>32</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>40</width>
+                <height>32</height>
+               </size>
+              </property>
+              <property name="toolTip">
+               <string>Previous study</string>
+              </property>
+              <property name="text">
+               <string>&lt;&lt;&lt;</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QPushButton" name="prevSeriesButton">
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>32</horstretch>
+                <verstretch>32</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>40</width>
+                <height>32</height>
+               </size>
+              </property>
+              <property name="toolTip">
+               <string>Previous series</string>
+              </property>
+              <property name="text">
+               <string>&lt;&lt;</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QPushButton" name="prevImageButton">
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>32</horstretch>
+                <verstretch>32</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>40</width>
+                <height>32</height>
+               </size>
+              </property>
+              <property name="toolTip">
+               <string>Previous image</string>
+              </property>
+              <property name="text">
+               <string>&lt;</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QPushButton" name="nextImageButton">
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>32</horstretch>
+                <verstretch>32</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>40</width>
+                <height>32</height>
+               </size>
+              </property>
+              <property name="toolTip">
+               <string>Next image</string>
+              </property>
+              <property name="text">
+               <string>&gt;</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QPushButton" name="nextSeriesButton">
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>32</horstretch>
+                <verstretch>32</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>40</width>
+                <height>32</height>
+               </size>
+              </property>
+              <property name="toolTip">
+               <string>Next series</string>
+              </property>
+              <property name="text">
+               <string>&gt;&gt;</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QPushButton" name="nextStudyButton">
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>32</horstretch>
+                <verstretch>32</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>40</width>
+                <height>32</height>
+               </size>
+              </property>
+              <property name="toolTip">
+               <string>Next study</string>
+              </property>
+              <property name="text">
+               <string>&gt;&gt;&gt;</string>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <widget class="ctkDICOMDatasetView" name="imagePreview" native="true">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+           </widget>
           </item>
           </item>
          </layout>
          </layout>
         </widget>
         </widget>
@@ -267,6 +416,102 @@
     </hint>
     </hint>
    </hints>
    </hints>
   </connection>
   </connection>
+  <connection>
+   <sender>nextImageButton</sender>
+   <signal>clicked()</signal>
+   <receiver>ctkDICOMAppWidget</receiver>
+   <slot>onNextImage()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>608</x>
+     <y>395</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>369</x>
+     <y>318</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>prevImageButton</sender>
+   <signal>clicked()</signal>
+   <receiver>ctkDICOMAppWidget</receiver>
+   <slot>onPreviousImage()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>566</x>
+     <y>395</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>369</x>
+     <y>318</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>nextSeriesButton</sender>
+   <signal>clicked()</signal>
+   <receiver>ctkDICOMAppWidget</receiver>
+   <slot>onNextSeries()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>650</x>
+     <y>395</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>369</x>
+     <y>318</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>prevSeriesButton</sender>
+   <signal>clicked()</signal>
+   <receiver>ctkDICOMAppWidget</receiver>
+   <slot>onPreviousSeries()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>524</x>
+     <y>395</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>369</x>
+     <y>318</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>nextStudyButton</sender>
+   <signal>clicked()</signal>
+   <receiver>ctkDICOMAppWidget</receiver>
+   <slot>onNextStudy()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>692</x>
+     <y>395</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>369</x>
+     <y>318</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>prevStudyButton</sender>
+   <signal>clicked()</signal>
+   <receiver>ctkDICOMAppWidget</receiver>
+   <slot>onPreviousStudy()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>482</x>
+     <y>395</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>369</x>
+     <y>318</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  </connections>
  <slots>
  <slots>
   <signal>signal1()</signal>
   <signal>signal1()</signal>
@@ -274,5 +519,11 @@
   <slot>openExportDialog()</slot>
   <slot>openExportDialog()</slot>
   <slot>openQueryDialog()</slot>
   <slot>openQueryDialog()</slot>
   <slot>onDatabaseDirectoryChaged(QString)</slot>
   <slot>onDatabaseDirectoryChaged(QString)</slot>
+  <slot>onNextImage()</slot>
+  <slot>onPreviousImage()</slot>
+  <slot>onNextSeries()</slot>
+  <slot>onPreviousSeries()</slot>
+  <slot>onNextStudy()</slot>
+  <slot>onPreviousStudy()</slot>
  </slots>
  </slots>
 </ui>
 </ui>

+ 87 - 0
Libs/DICOM/Widgets/ctkDICOMAppWidget.cpp

@@ -68,6 +68,14 @@ ctkDICOMAppWidget::ctkDICOMAppWidget(QWidget* _parent):Superclass(_parent),
 
 
   d->setupUi(this);
   d->setupUi(this);
 
 
+  //Hide image previewer buttons
+  d->nextImageButton->hide();
+  d->prevImageButton->hide();
+  d->nextSeriesButton->hide();
+  d->prevSeriesButton->hide();
+  d->nextStudyButton->hide();
+  d->prevStudyButton->hide();
+
   //Enable sorting in tree view
   //Enable sorting in tree view
   d->treeView->setSortingEnabled(true);
   d->treeView->setSortingEnabled(true);
   d->treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
   d->treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -105,6 +113,7 @@ ctkDICOMAppWidget::ctkDICOMAppWidget(QWidget* _parent):Superclass(_parent),
   //connect signal and slots
   //connect signal and slots
   connect(d->treeView, SIGNAL(clicked(const QModelIndex&)), d->thumbnailsWidget, SLOT(onModelSelected(const QModelIndex &)));
   connect(d->treeView, SIGNAL(clicked(const QModelIndex&)), d->thumbnailsWidget, SLOT(onModelSelected(const QModelIndex &)));
   connect(d->treeView, SIGNAL(clicked(const QModelIndex&)), d->imagePreview, SLOT(onModelSelected(const QModelIndex &)));
   connect(d->treeView, SIGNAL(clicked(const QModelIndex&)), d->imagePreview, SLOT(onModelSelected(const QModelIndex &)));
+  connect(d->treeView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(onModelSelected(const QModelIndex &)));
 
 
   connect(d->thumbnailsWidget, SIGNAL(selected(const ctkDICOMThumbnailWidget&)), this, SLOT(onThumbnailSelected(const ctkDICOMThumbnailWidget&)));
   connect(d->thumbnailsWidget, SIGNAL(selected(const ctkDICOMThumbnailWidget&)), this, SLOT(onThumbnailSelected(const ctkDICOMThumbnailWidget&)));
   connect(d->ImportDialog, SIGNAL(fileSelected(QString)),this,SLOT(onImportDirectory(QString)));
   connect(d->ImportDialog, SIGNAL(fileSelected(QString)),this,SLOT(onImportDirectory(QString)));
@@ -223,3 +232,81 @@ void ctkDICOMAppWidget::onImportDirectory(QString directory)
     d->DICOMModel.reset();
     d->DICOMModel.reset();
   }
   }
 }
 }
+
+//----------------------------------------------------------------------------
+void ctkDICOMAppWidget::onModelSelected(const QModelIndex &index){
+     Q_D(ctkDICOMAppWidget);
+
+    ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(index.model()));
+
+    if(model){
+        QModelIndex index0 = index.sibling(index.row(), 0);
+
+        if ( model->data(index0,ctkDICOMModel::TypeRole) == ctkDICOMModel::PatientType ){
+            d->nextImageButton->show();
+            d->prevImageButton->show();
+            d->nextSeriesButton->show();
+            d->prevSeriesButton->show();
+            d->nextStudyButton->show();
+            d->prevStudyButton->show();
+        }else if ( model->data(index0,ctkDICOMModel::TypeRole) == ctkDICOMModel::StudyType ){
+            d->nextImageButton->show();
+            d->prevImageButton->show();
+            d->nextSeriesButton->show();
+            d->prevSeriesButton->show();
+            d->nextStudyButton->hide();
+            d->prevStudyButton->hide();
+        }else if ( model->data(index0,ctkDICOMModel::TypeRole) == ctkDICOMModel::SeriesType ){
+            d->nextImageButton->show();
+            d->prevImageButton->show();
+            d->nextSeriesButton->hide();
+            d->prevSeriesButton->hide();
+            d->nextStudyButton->hide();
+            d->prevStudyButton->hide();
+        }else{
+            d->nextImageButton->hide();
+            d->prevImageButton->hide();
+            d->nextSeriesButton->hide();
+            d->prevSeriesButton->hide();
+            d->nextStudyButton->hide();
+            d->prevStudyButton->hide();
+        }
+    }else{
+        d->nextImageButton->hide();
+        d->prevImageButton->hide();
+        d->nextSeriesButton->hide();
+        d->prevSeriesButton->hide();
+        d->nextStudyButton->hide();
+        d->prevStudyButton->hide();
+    }
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMAppWidget::onNextImage(){
+
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMAppWidget::onPreviousImage(){
+
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMAppWidget::onNextSeries(){
+
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMAppWidget::onPreviousSeries(){
+
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMAppWidget::onNextStudy(){
+
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMAppWidget::onPreviousStudy(){
+
+}

+ 8 - 0
Libs/DICOM/Widgets/ctkDICOMAppWidget.h

@@ -61,6 +61,14 @@ protected:
 protected slots:
 protected slots:
     void onImportDirectory(QString directory);
     void onImportDirectory(QString directory);
 
 
+    void onModelSelected(const QModelIndex& index);
+
+    void onNextImage();
+    void onPreviousImage();
+    void onNextSeries();
+    void onPreviousSeries();
+    void onNextStudy();
+    void onPreviousStudy();
 
 
 private:
 private:
   Q_DECLARE_PRIVATE(ctkDICOMAppWidget);
   Q_DECLARE_PRIVATE(ctkDICOMAppWidget);

+ 22 - 0
Libs/DICOM/Widgets/ctkDICOMThumbnailListWidget.cpp

@@ -211,6 +211,26 @@ void ctkDICOMThumbnailListWidget::setDatabaseDirectory(const QString &directory)
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
+void ctkDICOMThumbnailListWidget::selectThumbnail(int index){
+    Q_D(ctkDICOMThumbnailListWidget);
+
+    int count = d->scrollAreaContentWidget->layout()->count();
+
+    logger.debug("Select thumbnail " + QVariant(index).toString() + " of " + QVariant(count).toString());
+
+    if(index >= count)return;
+
+    for(int i=0; i<count; i++){
+        ctkDICOMThumbnailWidget* thumbnailWidget = qobject_cast<ctkDICOMThumbnailWidget*>(d->scrollAreaContentWidget->layout()->itemAt(i)->widget());
+        if(i == index){
+            thumbnailWidget->setSelected(true);
+        }else{
+            thumbnailWidget->setSelected(false);
+        }
+    }
+}
+
+//----------------------------------------------------------------------------
 void ctkDICOMThumbnailListWidget::onModelSelected(const QModelIndex &index){
 void ctkDICOMThumbnailListWidget::onModelSelected(const QModelIndex &index){
     Q_D(ctkDICOMThumbnailListWidget);
     Q_D(ctkDICOMThumbnailListWidget);
 
 
@@ -229,6 +249,8 @@ void ctkDICOMThumbnailListWidget::onModelSelected(const QModelIndex &index){
             d->onSeriesModelSelected(index0);
             d->onSeriesModelSelected(index0);
         }
         }
     }
     }
+
+    this->selectThumbnail(1);
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------

+ 2 - 0
Libs/DICOM/Widgets/ctkDICOMThumbnailListWidget.h

@@ -40,6 +40,8 @@ public:
 
 
   void setDatabaseDirectory(const QString& directory);
   void setDatabaseDirectory(const QString& directory);
 
 
+  void selectThumbnail(int index);
+
 protected:
 protected:
   QScopedPointer<ctkDICOMThumbnailListWidgetPrivate> d_ptr;
   QScopedPointer<ctkDICOMThumbnailListWidgetPrivate> d_ptr;
 
 

+ 7 - 5
Libs/DICOM/Widgets/ctkDICOMThumbnailWidget.cpp

@@ -28,6 +28,10 @@
 // Qt includes
 // Qt includes
 #include <QColor>
 #include <QColor>
 
 
+// logger includes
+#include "ctkLogger.h"
+static ctkLogger logger("org.commontk.DICOM.Widgets.ctkDICOMThumbnailListWidget");
+
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 class ctkDICOMThumbnailWidgetPrivate: public Ui_ctkDICOMThumbnailWidget
 class ctkDICOMThumbnailWidgetPrivate: public Ui_ctkDICOMThumbnailWidget
 {
 {
@@ -119,12 +123,10 @@ QModelIndex ctkDICOMThumbnailWidget::sourceIndex() const{
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
-void ctkDICOMThumbnailWidget::setSelected(bool selected){
+void ctkDICOMThumbnailWidget::setSelected(bool flag){
     Q_D(ctkDICOMThumbnailWidget);
     Q_D(ctkDICOMThumbnailWidget);
 
 
-    if(selected == d->selectedFlag)return;
-
-    if(selected){
+    if(flag){
         QPalette p(this->palette());
         QPalette p(this->palette());
         p.setColor(QPalette::Window, d->backgroundColor);
         p.setColor(QPalette::Window, d->backgroundColor);
         this->setPalette(p);
         this->setPalette(p);
@@ -133,7 +135,7 @@ void ctkDICOMThumbnailWidget::setSelected(bool selected){
         this->setAutoFillBackground(false);
         this->setAutoFillBackground(false);
     }
     }
 
 
-    d->selectedFlag = selected;
+    d->selectedFlag = flag;
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------