Pārlūkot izejas kodu

Added DicomHostService. Added helper for UID and changed the status one.

ivmartel 14 gadi atpakaļ
vecāks
revīzija
2e632c6da5

+ 3 - 0
Plugins/org.commontk.dicom.wg23.app/CMakeLists.txt

@@ -12,12 +12,15 @@ SET(PLUGIN_SRCS
   ctkDicomAppServerPrivate.cpp
   ctkDicomWG23AppPlugin.cpp
   ctkDicomAbstractApp.cpp
+  ctkDicomHostService.cpp
+  ctkDicomHostServicePrivate.cpp
 )
 
 # Files which should be processed by Qts moc
 SET(PLUGIN_MOC_SRCS
   ctkDicomAppServerPrivate.h
   ctkDicomWG23AppPlugin_p.h
+  ctkDicomHostServicePrivate.h
 )
 
 # Qt Designer files which should be processed by Qts uic

+ 33 - 0
Plugins/org.commontk.dicom.wg23.app/ctkDicomHostService.cpp

@@ -0,0 +1,33 @@
+/*=============================================================================
+
+  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 "ctkDicomHostService.h"
+
+#include "ctkDicomHostServicePrivate.h"
+
+ctkDicomHostService::ctkDicomHostService()
+  : d_ptr(new ctkDicomHostServicePrivate())
+{
+
+}
+ctkDicomHostService::~ctkDicomHostService()
+{
+}

+ 43 - 0
Plugins/org.commontk.dicom.wg23.app/ctkDicomHostService.h

@@ -0,0 +1,43 @@
+/*=============================================================================
+
+  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 CTKDICOMHOSTSERVICE_H
+#define CTKDICOMHOSTSERVICE_H
+
+#include <QScopedPointer>
+
+class ctkDicomHostServicePrivate;
+
+class ctkDicomHostService
+{
+
+public:
+  ctkDicomHostService();
+  ~ctkDicomHostService();
+
+private:
+  Q_DECLARE_PRIVATE(ctkDicomHostService)
+
+  const QScopedPointer<ctkDicomHostServicePrivate> d_ptr;
+};
+
+#endif // CTKDICOMHOSTSERVICE_H

+ 37 - 34
Plugins/org.commontk.dicom.wg23.app/ctkDicomHostServicePrivate.cpp

@@ -19,8 +19,8 @@
 
 =============================================================================*/
 
-
 #include "ctkDicomHostServicePrivate.h"
+#include "ctkDicomWG23TypesHelper.h"
 
 #include <QApplication>
 #include <QCursor>
@@ -28,37 +28,28 @@
 
 #include <stdexcept>
 
-ctkDicomHostService::ctkDicomHostService()
+ctkDicomHostServicePrivate::ctkDicomHostServicePrivate()
 {
   connect(&http, SIGNAL(responseReady()), this, SLOT(responseReady()));
 
   http.setHost("127.0.0.1", false, 8080);
 }
 
-void ctkDicomHostService::responseReady()
+void ctkDicomHostServicePrivate::responseReady()
 {
   blockingLoop.exit();
 }
 
-QString ctkDicomHostService::generateUID()
-{
-  return QString();
-}
-
-QRect ctkDicomHostService::getAvailableScreen(const QRect& preferredScreen)
+QtSoapType ctkDicomHostServicePrivate::askHost(const QString& methodName, QtSoapType* soapType )
 {
-  http.setAction("GetAvailableScreen");
+  http.setAction(methodName);
 
   QtSoapMessage request;
-  request.setMethod("GetAvailableScreen");
-
-  QtSoapStruct* preferredScreenType = new QtSoapStruct(QtSoapQName("preferredScreen"));
-  preferredScreenType->insert(new QtSoapSimpleType(QtSoapQName("Height"), preferredScreen.height()));
-  preferredScreenType->insert(new QtSoapSimpleType(QtSoapQName("Width"), preferredScreen.width()));
-  preferredScreenType->insert(new QtSoapSimpleType(QtSoapQName("RefPointX"), preferredScreen.x()));
-  preferredScreenType->insert(new QtSoapSimpleType(QtSoapQName("RefPointY"), preferredScreen.y()));
-
-  request.addMethodArgument(preferredScreenType);
+  request.setMethod(methodName);
+  if( soapType != NULL )
+  {
+    request.addMethodArgument(soapType);
+  }
 
   http.submitRequest(request, "/IHostService");
 
@@ -97,33 +88,45 @@ QRect ctkDicomHostService::getAvailableScreen(const QRect& preferredScreen)
     //throw std::runtime_error("invalid return value");
     qDebug() << response.errorString() << response.faultString().toString();
     qDebug() << response.toXmlString();
-    return QRect();
   }
+  else
+  {
+    qDebug() << screenResult.count();
+  }  
 
-  qDebug() << screenResult.count() << screenResult["Height"].typeName();
-  QRect resultRect;
-  resultRect.setHeight(screenResult["Height"].toInt());
-  resultRect.setWidth(screenResult["Width"].toInt());
-  resultRect.setX(screenResult["RefPointX"].toInt());
-  resultRect.setY(screenResult["RefPointY"].toInt());
-
-  qDebug() << "x:" << resultRect.x() << " y:" << resultRect.y();
+  return screenResult;
+}
 
-  return resultRect;
+QString ctkDicomHostServicePrivate::generateUID()
+{
+  const QtSoapType& result = askHost("generateUID", NULL);
+  QString resultUID = ctkDicomSoapUID::getUID(result);
+  return resultUID;
 }
 
-QString ctkDicomHostService::getOutputLocation(const QStringList& preferredProtocols)
+QString ctkDicomHostServicePrivate::getOutputLocation(const QStringList& preferredProtocols)
 {
   Q_UNUSED(preferredProtocols)
   return QString();
 }
 
-void ctkDicomHostService::notifyStateChanged(ctkDicomWG23::State state)
+QRect ctkDicomHostServicePrivate::getAvailableScreen(const QRect& preferredScreen)
+{
+  QtSoapStruct* input = new ctkDicomSoapRectangle("preferredScreen", preferredScreen);
+  const QtSoapType& result = askHost("getAvailableScreen", input);
+  QRect resultRect = ctkDicomSoapRectangle::getQRect(result);
+  qDebug() << "x:" << resultRect.x() << " y:" << resultRect.y();
+  return resultRect;
+}
+
+void ctkDicomHostServicePrivate::notifyStateChanged(ctkDicomWG23::State state)
 {
-  Q_UNUSED(state)
+  QtSoapType* input = new ctkDicomSoapState("stateChanged", state);
+  askHost("notifyStateChanged", input);
 }
 
-void ctkDicomHostService::notifyStatus(const ctkDicomWG23::Status& status)
+void ctkDicomHostServicePrivate::notifyStatus(const ctkDicomWG23::Status& status)
 {
-  Q_UNUSED(status)
+  QtSoapStruct* input = new ctkDicomSoapStatus("status", status);
+  askHost("notifyStatus", input);
 }

+ 16 - 14
Plugins/org.commontk.dicom.wg23.app/ctkDicomHostServicePrivate.h

@@ -19,36 +19,38 @@
 
 =============================================================================*/
 
+#ifndef CTKDICOMHOSTSERVICEPRIVATE_H
+#define CTKDICOMHOSTSERVICEPRIVATE_H
 
-#ifndef DICOMHOSTINTERFACEIMPL_P_H
-#define DICOMHOSTINTERFACEIMPL_P_H
-
+#include <ctkDicomWG23Types.h>
 #include <ctkDicomHostInterface.h>
 
 #include <QEventLoop>
 #include <QtSoapHttpTransport>
 
-class ctkDicomHostService : public ctkDicomHostInterface
+class ctkDicomHostServicePrivate : public ctkDicomHostInterface
 {
   Q_OBJECT
 
 public:
-    ctkDicomHostService();
+  ctkDicomHostServicePrivate();
 
-    virtual QString generateUID();
-    virtual QRect getAvailableScreen(const QRect& preferredScreen);
-    virtual QString getOutputLocation(const QStringList& preferredProtocols);
-    virtual void notifyStateChanged(ctkDicomWG23::State state);
-    virtual void notifyStatus(const ctkDicomWG23::Status& status);
+  QString generateUID();
+  QRect getAvailableScreen(const QRect& preferredScreen);
+  QString getOutputLocation(const QStringList& preferredProtocols);
+  void notifyStateChanged(ctkDicomWG23::State state);
+  void notifyStatus(const ctkDicomWG23::Status& status);
 
 private slots:
 
-    void responseReady();
+  void responseReady();
 
 private:
 
-    QEventLoop blockingLoop;
-    QtSoapHttpTransport http;
+  QtSoapType askHost(const QString& methodName, QtSoapType* soapStruct);
+    
+  QEventLoop blockingLoop;
+  QtSoapHttpTransport http;
 };
 
-#endif // DICOMHOSTINTERFACEIMPL_P_H
+#endif // CTKDICOMHOSTSERVICEPRIVATE_H

+ 16 - 5
Plugins/org.commontk.dicom.wg23.core/ctkDicomWG23TypesHelper.h

@@ -63,19 +63,19 @@ class ctkDicomSoapState : public QtSoapSimpleType{
 class ctkDicomSoapStatus : public QtSoapStruct{
     public: 
     ctkDicomSoapStatus ( const QString & name,
-            const ctkDicomWG23::Status* s ):
+            const ctkDicomWG23::Status& s ):
        QtSoapStruct ( QtSoapQName(name) ){
         this->insert(new QtSoapSimpleType(QtSoapQName("StatusType"), 
-                    s->statusType) );
+                    s.statusType) );
         this->insert(new QtSoapSimpleType(
                     QtSoapQName("CodingSchemeDesignator"), 
-                    s->codingSchemeDesignator) );
+                    s.codingSchemeDesignator) );
         this->insert(new QtSoapSimpleType(
                     QtSoapQName("CodeValue"), 
-                    s->codeValue) );
+                    s.codeValue) );
         this->insert(new QtSoapSimpleType(
                     QtSoapQName("CodeMeaning"), 
-                    s->codeMeaning) );
+                    s.codeMeaning) );
     };
    static ctkDicomWG23::Status getStatus(const QtSoapType& type){
         ctkDicomWG23::Status s;
@@ -92,6 +92,17 @@ class ctkDicomSoapStatus : public QtSoapStruct{
    };
 };
 
+class ctkDicomSoapUID : public QtSoapSimpleType{
+public:
+ctkDicomSoapUID ( const QString & name, const QString& uid ):
+   QtSoapSimpleType ( QtSoapQName(name), uid ){};
+
+static QString getUID(const QtSoapType& type){
+	return static_cast<QString> (type.value().toString());
+};
+
+};
+
 
 
 #endif