浏览代码

Merge branch 'dah' of http://github.com/commontk/CTK into dah

ymartelli 14 年之前
父节点
当前提交
a78ad65266

+ 20 - 19
Applications/ctkExampleHost/ctkExampleHostMain.cpp

@@ -28,6 +28,7 @@
 #include <QStringList>
 #include <QDirIterator>
 #include <QWidget>
+#include <QUrl>
 
 int main(int argv, char** argc)
 {
@@ -57,25 +58,25 @@ int main(int argv, char** argc)
 
   qApp->addLibraryPath(pluginPath);
 
-//  QStringList libFilter;
-//  libFilter << "*.dll" << "*.so" << "*.dylib";
-//  QDirIterator dirIter(pluginPath, libFilter, QDir::Files);
-//  while(dirIter.hasNext())
-//  {
-//    try
-//    {
-//      QString fileLocation = dirIter.next();
-//      if (fileLocation.contains("org_commontk_dicom_wg23"))
-//      {
-//        ctkPlugin* plugin = framework->getPluginContext()->installPlugin(QUrl::fromLocalFile(fileLocation));
-//        plugin->start(ctkPlugin::START_TRANSIENT);
-//      }
-//    }
-//    catch (const ctkPluginException& e)
-//    {
-//      qCritical() << e.what();
-//    }
-//  }
+  QStringList libFilter;
+  libFilter << "*.dll" << "*.so" << "*.dylib";
+  QDirIterator dirIter(pluginPath, libFilter, QDir::Files);
+  while(dirIter.hasNext())
+  {
+    try
+    {
+      QString fileLocation = dirIter.next();
+      if (fileLocation.contains("org_commontk_dicom_wg23"))
+      {
+        ctkPlugin* plugin = framework->getPluginContext()->installPlugin(QUrl::fromLocalFile(fileLocation));
+        plugin->start(ctkPlugin::START_TRANSIENT);
+      }
+    }
+    catch (const ctkPluginException& e)
+    {
+      qCritical() << e.what();
+    }
+  }
 
   framework->start();
 

+ 33 - 0
Plugins/org.commontk.dicom.examplehost/CMakeLists.txt

@@ -0,0 +1,33 @@
+PROJECT(org_commontk_dicom_examplehost)
+
+SET(PLUGIN_export_directive "org_commontk_dicom_examplehost_EXPORT")
+
+SET(PLUGIN_SRCS
+  ctkDicomExampleHostPlugin.cpp
+)
+
+# Files which should be processed by Qts moc
+SET(PLUGIN_MOC_SRCS
+  ctkDicomExampleHostPlugin_p.h
+)
+
+# Qt Designer files which should be processed by Qts uic
+SET(PLUGIN_UI_FORMS
+)
+
+# QRC Files which should be compiled into the plugin
+SET(PLUGIN_resources
+)
+
+#Compute the plugin dependencies
+ctkMacroGetTargetLibraries(PLUGIN_target_libraries)
+
+ctkMacroBuildPlugin(
+  NAME ${PROJECT_NAME}
+  EXPORT_DIRECTIVE ${PLUGIN_export_directive}
+  SRCS ${PLUGIN_SRCS}
+  MOC_SRCS ${PLUGIN_MOC_SRCS}
+  UI_FORMS ${PLUGIN_UI_FORMS}
+  RESOURCES ${PLUGIN_resources}
+  TARGET_LIBRARIES ${PLUGIN_target_libraries}
+)

+ 61 - 0
Plugins/org.commontk.dicom.examplehost/ctkDicomExampleHostPlugin.cpp

@@ -0,0 +1,61 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) 2010 German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  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
+
+  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.
+
+=============================================================================*/
+
+
+#include "ctkDicomExampleHostPlugin_p.h"
+#include <QtPlugin>
+
+ctkDicomExampleHostPlugin* ctkDicomExampleHostPlugin::instance = 0;
+
+ctkDicomExampleHostPlugin::ctkDicomExampleHostPlugin()
+  : context(0)
+{
+}
+
+ctkDicomExampleHostPlugin::~ctkDicomExampleHostPlugin()
+{
+  
+}
+
+void ctkDicomExampleHostPlugin::start(ctkPluginContext* context)
+{
+  instance = this;
+  this->context = context;
+}
+
+void ctkDicomExampleHostPlugin::stop(ctkPluginContext* context)
+{
+  Q_UNUSED(context)
+}
+
+ctkDicomExampleHostPlugin* ctkDicomExampleHostPlugin::getInstance()
+{
+  return instance;
+}
+
+ctkPluginContext* ctkDicomExampleHostPlugin::getPluginContext() const
+{
+  return context;
+}
+
+Q_EXPORT_PLUGIN2(org_commontk_dicom_examplehost, ctkDicomExampleHostPlugin)
+
+

+ 55 - 0
Plugins/org.commontk.dicom.examplehost/ctkDicomExampleHostPlugin_p.h

@@ -0,0 +1,55 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) 2010 German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  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
+
+  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 CTKDICOMEXAMPLEHOSTPLUGIN_P_H
+#define CTKDICOMEXAMPLEHOSTPLUGIN_P_H
+
+#include <ctkPluginActivator.h>
+
+class ctkDicomExampleHostPlugin :
+  public QObject, public ctkPluginActivator
+{
+  Q_OBJECT
+  Q_INTERFACES(ctkPluginActivator)
+
+public:
+
+  ctkDicomExampleHostPlugin();
+  ~ctkDicomExampleHostPlugin();
+
+  void start(ctkPluginContext* context);
+  void stop(ctkPluginContext* context);
+
+  static ctkDicomExampleHostPlugin* getInstance();
+
+  ctkPluginContext* getPluginContext() const;
+
+
+private:
+
+  static ctkDicomExampleHostPlugin* instance;
+  ctkPluginContext* context;
+
+
+}; // ctkDicomExampleHostPlugin
+
+#endif // CTKDICOMEXAMPLEHOSTPLUGIN_P_H

+ 9 - 0
Plugins/org.commontk.dicom.examplehost/target_libraries.cmake

@@ -0,0 +1,9 @@
+# See CMake/ctkMacroGetTargetLibraries.cmake
+#
+# This file should list the libraries required to build the current CTK plugin.
+# For specifying required plugins, see the manifest_headers.cmake file.
+#
+
+SET(target_libraries
+  CTKPluginFramework
+)

+ 2 - 0
Plugins/org.commontk.dicom.wg23.core/CMakeLists.txt

@@ -19,6 +19,8 @@ SET(PLUGIN_SRCS
   ctkDicomWG23CorePlugin.cpp
   ctkSimpleSoapServer.cpp
   ctkSoapConnectionRunnable.cpp
+  ctkDicomWG23Types.h
+  ctkDicomWG23TypesHelper.h
 )
 
 # Files which should be processed by Qts moc

+ 2 - 2
Plugins/org.commontk.dicom.wg23.core/ctkDicomExchangeInterface.h

@@ -39,8 +39,8 @@ public:
   // Data exchange interface methods
   //
 
-  virtual bool notifyDataAvailable(ctkDicomWG23::AvailableData data, bool lastData) = 0;
-  virtual QVector<ctkDicomWG23::ObjectLocator> getData(QVector<QUuid> objectUUIDs, QVector<QString> acceptableTransferSyntaxUIDs, bool includeBulkData) = 0;
+  //virtual bool notifyDataAvailable(ctkDicomWG23::AvailableData data, bool lastData) = 0;
+  //virtual QList<ctkDicomWG23::ObjectLocator> getData(QList<QUuid> objectUUIDs, QList<QString> acceptableTransferSyntaxUIDs, bool includeBulkData) = 0;
 
   //    8.3.3 getAsModels(objectUUIDs : ArrayOfUUID, classUID : UID, supportedInfosetTypes : ArrayOfMimeType) : ModelSetDescriptor	33
 //    8.3.4 queryModel(models : ArrayOfUUID, xpaths : ArrayOfString) : ArrayOfQueryResult	34

+ 8 - 8
Plugins/org.commontk.dicom.wg23.core/ctkDicomWG23Types.h

@@ -20,7 +20,7 @@
 =============================================================================*/
 
 #include <QString>
-#include <QVector>
+#include <QList>
 #include <QUuid>
 
 #ifndef CTKDICOMWG23TYPES_H
@@ -74,13 +74,13 @@ namespace ctkDicomWG23 {
 
   struct Series {
     QString seriesUID;
-    QVector<ObjectDescriptor> objectDescriptors;
+    QList<ObjectDescriptor> objectDescriptors;
   };
 
   struct Study {
     QString studyUID;
-    QVector<ObjectDescriptor> objectDescriptors;
-    QVector<Series> series;
+    QList<ObjectDescriptor> objectDescriptors;
+    QList<Series> series;
   };
 
   struct Patient {
@@ -89,13 +89,13 @@ namespace ctkDicomWG23 {
     QString assigningAuthority;
     QString sex;
     QString birthDate;
-    QVector<ObjectDescriptor> objectDescriptors;
-    QVector<Study> studies;
+    QList<ObjectDescriptor> objectDescriptors;
+    QList<Study> studies;
   };
 
   struct AvailableData {
-    QVector<ObjectDescriptor> objectDescriptors;
-    QVector<Patient> patients;
+    QList<ObjectDescriptor> objectDescriptors;
+    QList<Patient> patients;
   };
 
 }

+ 97 - 0
Plugins/org.commontk.dicom.wg23.core/ctkDicomWG23TypesHelper.h

@@ -0,0 +1,97 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) 2010 German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  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
+
+  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 CTKDICOM23TYPESHELPER_H
+#define CTKDICOM23TYPESHELPER_H
+
+#include <QtSoapStruct>
+#include <QtSoapQName>
+#include <QRect>
+
+class ctkDicomSoapRectangle :public QtSoapStruct {
+    public: 
+    ctkDicomSoapRectangle(const QString & name,const QRect& rect):
+        QtSoapStruct(QtSoapQName(name)){
+        this->insert(new QtSoapSimpleType(QtSoapQName("Height"), 
+                    rect.height()));
+        this->insert(new QtSoapSimpleType(QtSoapQName("Width"), 
+                    rect.width()));
+        this->insert(new QtSoapSimpleType(QtSoapQName("RefPointX"),
+                    rect.x()));
+        this->insert(new QtSoapSimpleType(QtSoapQName("RefPointY"), 
+                    rect.y()));
+    };
+
+    static QRect getQRect (const QtSoapType& type){
+        return QRect (type["RefPointX"].value().toInt(),
+                        type["RefPointY"].value().toInt(),
+                        type["Width"].value().toInt(),
+                        type["Height"].value().toInt());
+    };
+};
+
+class ctkDicomSoapState : public QtSoapSimpleType{
+    public:
+   ctkDicomSoapState ( const QString & name, ctkDicomWG23::State s ):
+       QtSoapSimpleType ( QtSoapQName(name), s ){};
+
+   static ctkDicomWG23::State getState(const QtSoapType& type){
+        return  static_cast<ctkDicomWG23::State> (type.value().toInt());
+   };
+};
+
+
+class ctkDicomSoapStatus : public QtSoapStruct{
+    public: 
+    ctkDicomSoapStatus ( const QString & name,
+            const ctkDicomWG23::Status* s ):
+       QtSoapStruct ( QtSoapQName(name) ){
+        this->insert(new QtSoapSimpleType(QtSoapQName("StatusType"), 
+                    s->statusType) );
+        this->insert(new QtSoapSimpleType(
+                    QtSoapQName("CodingSchemeDesignator"), 
+                    s->codingSchemeDesignator) );
+        this->insert(new QtSoapSimpleType(
+                    QtSoapQName("CodeValue"), 
+                    s->codeValue) );
+        this->insert(new QtSoapSimpleType(
+                    QtSoapQName("CodeMeaning"), 
+                    s->codeMeaning) );
+    };
+   static ctkDicomWG23::Status getStatus(const QtSoapType& type){
+        ctkDicomWG23::Status s;
+        
+        s.statusType = static_cast<ctkDicomWG23::StatusType>
+            (type["StatusType"].value().toInt());
+        s.codingSchemeDesignator = 
+            type["CodingSchemeDesignator"].value().toString();
+        s.codeValue = 
+            type["CodeValue"].value().toString();
+        s.codeMeaning = 
+            type["CodeMeaning"].value().toString();
+        return s;
+   };
+};
+
+
+
+#endif

+ 1 - 0
Plugins/org.commontk.dicom.wg23.core/ctkSimpleSoapServer.h

@@ -28,6 +28,7 @@
 #include <qtsoap.h>
 
 #include <org_commontk_dicom_wg23_core_Export.h>
+#include <ctkDicomWG23Types.h>
 
 class org_commontk_dicom_wg23_core_EXPORT ctkSimpleSoapServer : public QTcpServer
 {

+ 27 - 10
Plugins/org.commontk.dicom.wg23.host/ctkDicomHostServerPrivate.cpp

@@ -29,6 +29,7 @@
 #include <QHostAddress>
 
 #include <stdexcept>
+#include <ctkDicomWG23TypesHelper.h>
 
 ctkDicomHostServerPrivate::ctkDicomHostServerPrivate(QObject *parent) :
     QObject(parent)
@@ -64,24 +65,40 @@ void ctkDicomHostServerPrivate::incomingSoapMessage(const QtSoapMessage& message
   {
     processGetAvailableScreen(message, reply);
   }
+  if (methodName == "notifyStateChanged")
+  {
+    processNotifyStateChanged(message, reply);
+  }
+  if (methodName == "notifyStatus")
+  {
+    processNotifyStatus(message, reply);
+  }
 }
 
 void ctkDicomHostServerPrivate::processGetAvailableScreen(
     const QtSoapMessage &message, QtSoapMessage *reply)
 {
   const QtSoapType& preferredScreenType = message.method()["preferredScreen"];
-  QRect preferredScreen(preferredScreenType["RefPointX"].value().toInt(),
-                        preferredScreenType["RefPointY"].value().toInt(),
-                        preferredScreenType["Width"].value().toInt(),
-                        preferredScreenType["Height"].value().toInt());
+  const QRect preferredScreen = ctkDicomSoapRectangle::getQRect(preferredScreenType);
 
-  QRect result = serviceBinding->getAvailableScreen(preferredScreen);
+  const QRect result = serviceBinding->getAvailableScreen(preferredScreen);
 
   reply->setMethod("GetAvailableScreenResponse");
-  QtSoapStruct* availableScreenType = new QtSoapStruct(QtSoapQName("availableScreen"));
-  availableScreenType->insert(new QtSoapSimpleType(QtSoapQName("Height"), result.height()));
-  availableScreenType->insert(new QtSoapSimpleType(QtSoapQName("Width"), result.width()));
-  availableScreenType->insert(new QtSoapSimpleType(QtSoapQName("RefPointX"), result.x()));
-  availableScreenType->insert(new QtSoapSimpleType(QtSoapQName("RefPointY"), result.y()));
+  QtSoapStruct* availableScreenType = new ctkDicomSoapRectangle("availableScreen",result);
   reply->addMethodArgument(availableScreenType);
 }
+
+void ctkDicomHostServerPrivate::processNotifyStateChanged(
+    const QtSoapMessage &message, QtSoapMessage *reply)
+{
+    const QtSoapType& stateType = message.method()["state"];
+    serviceBinding->notifyStateChanged(ctkDicomSoapState::getState(stateType));
+}
+
+void ctkDicomHostServerPrivate::processNotifyStatus(
+    const QtSoapMessage &message, QtSoapMessage *reply)
+{
+    const QtSoapType& status = message.method()["status"];
+    serviceBinding->notifyStatus(ctkDicomSoapStatus::getStatus(status));
+
+}

+ 6 - 0
Plugins/org.commontk.dicom.wg23.host/ctkDicomHostServerPrivate.h

@@ -48,6 +48,12 @@ private:
 
   void processGetAvailableScreen(const QtSoapMessage& message,
                                  QtSoapMessage* reply);
+  void processNotifyStateChanged(const QtSoapMessage& message,
+                                 QtSoapMessage* reply);
+  void processNotifyStatus(const QtSoapMessage& message,
+                                 QtSoapMessage* reply);
+  //void processGenerateUID(const QtSoapMessage& message,
+  //                               QtSoapMessage* reply);
 
   ctkDicomHostInterface* serviceBinding;