Browse Source

ctkDICOMObjectListWidget Created

Alireza Mehrtash 11 years ago
parent
commit
61699808e9

+ 1 - 0
Libs/DICOM/Core/CMakeLists.txt

@@ -73,6 +73,7 @@ set(KIT_MOC_SRCS
   ctkDICOMIndexer_p.h
   ctkDICOMFilterProxyModel.h
   ctkDICOMModel.h
+  ctkDICOMObjectModel.h
   ctkDICOMQuery.h
   ctkDICOMRetrieve.h
   ctkDICOMTester.h

+ 3 - 3
Libs/DICOM/Core/Testing/Cpp/ctkDICOMObjectModelTest1.cpp

@@ -40,11 +40,11 @@ int ctkDICOMObjectModelTest1( int argc, char * argv [] )
   //TODO: Add the option for reading the test file from argv
   fileName = QFileDialog::getOpenFileName( 0,
     "Choose a DCM File", ".","DCM (*)" );
-  ctkDICOMObjectModel dcmInfoModel;
-  dcmInfoModel.setFile(fileName);
+  ctkDICOMObjectModel dcmObjModel;
+  dcmObjModel.setFile(fileName);
 
   QTreeView *viewer = new QTreeView();
-  viewer->setModel( &dcmInfoModel);
+  viewer->setModel( &dcmObjModel);
   viewer->expandAll();
   viewer->resizeColumnToContents(0);
   viewer->resizeColumnToContents(1);

+ 3 - 1
Libs/DICOM/Core/ctkDICOMObjectModel.h

@@ -40,14 +40,16 @@ class ctkDICOMObjectModelPrivate;
 class CTK_DICOM_CORE_EXPORT ctkDICOMObjectModel
 	: public QStandardItemModel
 {
+  Q_OBJECT
   typedef QStandardItemModel Superclass;
+  //Q_PROPERTY(setFile);
 
 public:
 
   explicit ctkDICOMObjectModel(QObject* parent = 0);
   ctkDICOMObjectModel(const ctkDICOMObjectModel& other);
   virtual ~ctkDICOMObjectModel();
-  void setFile (const QString& fileName);
+  Q_INVOKABLE void setFile (const QString& fileName);
 
 protected:
   QScopedPointer<ctkDICOMObjectModelPrivate> d_ptr;

+ 4 - 0
Libs/DICOM/Widgets/CMakeLists.txt

@@ -29,6 +29,8 @@ set(KIT_SRCS
   ctkDICOMQueryRetrieveWidget.h
   ctkDICOMQueryWidget.cpp
   ctkDICOMQueryWidget.h
+  ctkDICOMObjectListWidget.cpp
+  ctkDICOMObjectListWidget.h
   ctkDICOMServerNodeWidget.cpp
   ctkDICOMServerNodeWidget.h
   ctkDICOMThumbnailGenerator.cpp
@@ -45,6 +47,7 @@ set(KIT_MOC_SRCS
   ctkDICOMDirectoryListWidget.h
   ctkDICOMImage.h
   ctkDICOMImportWidget.h
+  ctkDICOMObjectListWidget.h
   ctkDICOMQueryRetrieveWidget.h
   ctkDICOMQueryWidget.h
   ctkDICOMServerNodeWidget.h
@@ -61,6 +64,7 @@ set(KIT_UI_FORMS
   Resources/UI/ctkDICOMListenerWidget.ui
   Resources/UI/ctkDICOMQueryRetrieveWidget.ui
   Resources/UI/ctkDICOMQueryWidget.ui
+  Resources/UI/ctkDICOMObjectListWidget.ui 
   Resources/UI/ctkDICOMServerNodeWidget.ui
 )
 

+ 55 - 0
Libs/DICOM/Widgets/Resources/UI/ctkDICOMObjectListWidget.ui

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ctkDICOMObjectListWidget</class>
+ <widget class="QWidget" name="ctkDICOMObjectListWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>359</width>
+    <height>225</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <layout class="QFormLayout" name="formLayout">
+     <property name="fieldGrowthPolicy">
+      <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+     </property>
+     <item row="1" column="0">
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>File Paht:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QLineEdit" name="currentPathLineEdit"/>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="0">
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <property name="bottomMargin">
+      <number>0</number>
+     </property>
+     <item>
+      <widget class="QSlider" name="fileSlider">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QTreeView" name="dcmObjectTreeView"/>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 130 - 0
Libs/DICOM/Widgets/ctkDICOMObjectListWidget.cpp

@@ -0,0 +1,130 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Brigham and Women's Hospital (BWH).
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0.txt
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// ctkDICOMWidgets includes
+#include "ctkDICOMObjectListWidget.h"
+#include "ui_ctkDICOMObjectListWidget.h"
+
+// STD includes
+#include <iostream>
+
+// Qt includes
+#include <QString>
+#include <QStringList>
+#include <QTimer>
+
+//CTK includes
+#include <ctkDICOMObjectModel.h>
+#include <ctkLogger.h>
+static ctkLogger logger("org.commontk.DICOM.Widgets.ctkDICOMObjectListWidget");
+
+
+//----------------------------------------------------------------------------
+class ctkDICOMObjectListWidgetPrivate: public Ui_ctkDICOMObjectListWidget
+{
+public:
+  ctkDICOMObjectListWidgetPrivate();
+  ~ctkDICOMObjectListWidgetPrivate();
+  void populateDICOMObjectTreeView(const QString& fileName);
+
+QString currentFile;
+QStringList fileList;
+
+};
+
+//----------------------------------------------------------------------------
+// ctkDICOMObjectListWidgetPrivate methods
+
+//----------------------------------------------------------------------------
+ctkDICOMObjectListWidgetPrivate::ctkDICOMObjectListWidgetPrivate(){
+    
+}
+
+//----------------------------------------------------------------------------
+ctkDICOMObjectListWidgetPrivate::~ctkDICOMObjectListWidgetPrivate(){
+
+}
+//----------------------------------------------------------------------------
+void ctkDICOMObjectListWidgetPrivate::populateDICOMObjectTreeView(const QString& fileName){
+  //memory management??
+  ctkDICOMObjectModel* dcmObjModel = new ctkDICOMObjectModel;
+  dcmObjModel->setFile(fileName);
+  std::cerr << "fileName is =" << fileName.toUtf8().constData() << "\n";
+  this->dcmObjectTreeView->reset();
+  this->dcmObjectTreeView->setModel( dcmObjModel);
+}
+//----------------------------------------------------------------------------
+// ctkDICOMObjectListWidget methods
+
+//----------------------------------------------------------------------------
+ctkDICOMObjectListWidget::ctkDICOMObjectListWidget(QWidget* _parent):Superclass(_parent), 
+  d_ptr(new ctkDICOMObjectListWidgetPrivate)
+{
+  Q_D(ctkDICOMObjectListWidget);
+  
+  d->setupUi(this);
+  connect(d->fileSlider, SIGNAL(valueChanged(int)), this, SLOT(updateWidget()));
+  
+}
+
+//----------------------------------------------------------------------------
+ctkDICOMObjectListWidget::~ctkDICOMObjectListWidget()
+{
+}
+//----------------------------------------------------------------------------
+void ctkDICOMObjectListWidget::setCurrentFile(const QString& newFileName)
+{
+Q_D(ctkDICOMObjectListWidget);
+d->currentPathLineEdit->setText(newFileName);
+}
+// --------------------------------------------------------------------------
+void ctkDICOMObjectListWidget::setFileList(const QStringList& fileList)
+{
+  Q_D(ctkDICOMObjectListWidget);
+  d->fileList = fileList;
+  if (d-> fileList.size()> 0)
+  {
+    d->currentFile =d->fileList[0];
+    d->currentPathLineEdit->setText(d->currentFile );
+    d->populateDICOMObjectTreeView(d->currentFile );
+    d->fileSlider->setMaximum(d->fileList.size()-1);
+  }
+}
+// --------------------------------------------------------------------------
+QString ctkDICOMObjectListWidget::currentFile()const
+{
+  Q_D(const ctkDICOMObjectListWidget);
+  return d->currentFile;
+}
+// --------------------------------------------------------------------------
+QStringList ctkDICOMObjectListWidget::fileList()const
+{
+  Q_D(const ctkDICOMObjectListWidget);
+  return d->fileList;
+}
+// --------------------------------------------------------------------------
+void ctkDICOMObjectListWidget::updateWidget()
+{
+  Q_D(ctkDICOMObjectListWidget);
+  int fileNumber = d->fileSlider->value();
+  d->currentFile = d->fileList[fileNumber];
+  d->currentPathLineEdit->setText(d->currentFile);
+  d->populateDICOMObjectTreeView(d->currentFile);
+}

+ 68 - 0
Libs/DICOM/Widgets/ctkDICOMObjectListWidget.h

@@ -0,0 +1,68 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c)  Brigham and Women's Hospital (BWH)..
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0.txt
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+#ifndef __ctkDICOMObjectListWidget_h
+#define __ctkDICOMObjectListWidget_h
+
+// Qt includes 
+#include <QWidget>
+
+#include "ctkDICOMWidgetsExport.h"
+
+class ctkDICOMObjectListWidgetPrivate;
+
+/// \ingroup DICOM_Widgets
+class CTK_DICOM_WIDGETS_EXPORT ctkDICOMObjectListWidget : public QWidget
+{
+    Q_OBJECT
+    Q_PROPERTY(QString currentFile READ currentFile WRITE setCurrentFile)
+    Q_PROPERTY(QStringList fileList READ fileList WRITE setFileList)
+
+public:
+  typedef QWidget Superclass;
+  explicit ctkDICOMObjectListWidget(QWidget* parent=0);
+  virtual ~ctkDICOMObjectListWidget();
+  
+  /// 
+
+  QString ctkDICOMObjectListWidget::currentFile()const;
+  QStringList ctkDICOMObjectListWidget::fileList()const;
+
+protected:
+  QScopedPointer<ctkDICOMObjectListWidgetPrivate> d_ptr;
+
+private:
+  Q_DECLARE_PRIVATE(ctkDICOMObjectListWidget);
+  Q_DISABLE_COPY(ctkDICOMObjectListWidget);
+
+Q_SIGNALS:
+  /// 
+
+
+public Q_SLOTS:
+  void setCurrentFile(const QString& newFileName);
+  void setFileList(const QStringList& fileList);
+
+protected Q_SLOTS:
+  void updateWidget();
+
+};
+
+#endif