Sfoglia il codice sorgente

Basic convenience routines for incoming data

Ivo Wolf 13 anni fa
parent
commit
718df65608

+ 1 - 0
Plugins/org.commontk.dah.core/CMakeLists.txt

@@ -28,6 +28,7 @@ SET(PLUGIN_SRCS
 
 # Files which should be processed by Qts moc
 SET(PLUGIN_MOC_SRCS
+  ctkDicomAbstractExchangeCache.h
   ctkDicomAppHostingCorePlugin_p.h
   ctkSimpleSoapClient.h
   ctkSimpleSoapServer.h

+ 36 - 3
Plugins/org.commontk.dah.core/ctkDicomAbstractExchangeCache.cpp

@@ -22,6 +22,7 @@
 // CTK includes
 #include "ctkDicomAbstractExchangeCache.h"
 #include "ctkDicomAppHostingTypesHelper.h"
+#include "ctkDicomAvailableDataHelper.h"
 #include <ctkDicomObjectLocatorCache.h>
 
 class ctkDicomAbstractExchangeCachePrivate
@@ -32,13 +33,16 @@ public:
   ~ctkDicomAbstractExchangeCachePrivate();
 
   ctkDicomObjectLocatorCache ObjectLocatorCache;
+
+  ctkDicomAppHosting::AvailableData IncomingAvailableData;
+  bool lastIncomingData ;
 };
 
 //----------------------------------------------------------------------------
 // ctkDicomAbstractExchangeCachePrivate methods
 
 //----------------------------------------------------------------------------
-ctkDicomAbstractExchangeCachePrivate::ctkDicomAbstractExchangeCachePrivate()
+ctkDicomAbstractExchangeCachePrivate::ctkDicomAbstractExchangeCachePrivate() : lastIncomingData(false)
 {
 
 }
@@ -56,7 +60,7 @@ ctkDicomAbstractExchangeCachePrivate::~ctkDicomAbstractExchangeCachePrivate()
 ctkDicomAbstractExchangeCache::ctkDicomAbstractExchangeCache() :
   d_ptr(new ctkDicomAbstractExchangeCachePrivate)
 {
-
+  connect(this, SIGNAL(internalDataAvailable()), this, SLOT(forwardDataAvailable()), Qt::QueuedConnection);
 }
 
 //----------------------------------------------------------------------------
@@ -76,7 +80,7 @@ QList<ctkDicomAppHosting::ObjectLocator> ctkDicomAbstractExchangeCache::getData(
 }
 
 //----------------------------------------------------------------------------
-ctkDicomObjectLocatorCache* ctkDicomAbstractExchangeCache::objectLocatorCache()const
+ctkDicomObjectLocatorCache* ctkDicomAbstractExchangeCache::objectLocatorCache() const
 {
   Q_D(const ctkDicomAbstractExchangeCache);
   return const_cast<ctkDicomObjectLocatorCache*>(&d->ObjectLocatorCache);
@@ -103,3 +107,32 @@ void ctkDicomAbstractExchangeCache::releaseData(const QList<QUuid>& objectUUIDs)
   Q_UNUSED(objectUUIDs)
 }
 
+//----------------------------------------------------------------------------
+const ctkDicomAppHosting::AvailableData& ctkDicomAbstractExchangeCache::getIncomingAvailableData() const
+{
+  Q_D(const ctkDicomAbstractExchangeCache);
+  return d->IncomingAvailableData;
+}
+
+//----------------------------------------------------------------------------
+bool ctkDicomAbstractExchangeCache::lastIncomingData() const
+{
+  Q_D(const ctkDicomAbstractExchangeCache);
+  return d->lastIncomingData;
+}
+
+//----------------------------------------------------------------------------
+bool ctkDicomAbstractExchangeCache::notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData)
+{
+  Q_D(ctkDicomAbstractExchangeCache);
+  ctkDicomAvailableDataHelper::appendToAvailableData(d->IncomingAvailableData, data);
+  d->lastIncomingData = lastData;
+  emit internalDataAvailable();
+  return true;
+}
+
+//----------------------------------------------------------------------------
+void ctkDicomAbstractExchangeCache::forwardDataAvailable()
+{
+  emit dataAvailable();
+}

+ 31 - 3
Plugins/org.commontk.dah.core/ctkDicomAbstractExchangeCache.h

@@ -37,7 +37,7 @@ class ctkDicomObjectLocatorCache;
 */
 class org_commontk_dah_core_EXPORT ctkDicomAbstractExchangeCache : public QObject, public virtual ctkDicomExchangeInterface
 {
- //Q_OBJECT
+ Q_OBJECT
  Q_INTERFACES(ctkDicomExchangeInterface)
 
 public:
@@ -83,14 +83,14 @@ public:
   void releaseData(const QList<QUuid>& objectUUIDs);
 
   /**
-   * @brief
+   * @brief Return the cache for outgoing data.
    *
    * @return ctkDicomObjectLocatorCache *
   */
   ctkDicomObjectLocatorCache* objectLocatorCache() const;
 
   /**
-   * @brief
+   * @brief Publish data to other side
    *
    * @param availableData
    * @param lastData
@@ -98,6 +98,34 @@ public:
   */
   bool publishData(const ctkDicomAppHosting::AvailableData& availableData, bool lastData);
 
+  // Methods to support receiving data
+  /**
+   * @brief Return the incoming available data.
+   *
+   * @return AvailableData *
+  */
+  const ctkDicomAppHosting::AvailableData& getIncomingAvailableData() const;
+
+  /**
+   * @brief Return whether the incoming data was marked as @a lastData.
+   *
+   * @return bool value of @a lastData in incoming notifyDataAvailable call
+  */
+  bool ctkDicomAbstractExchangeCache::lastIncomingData() const;
+
+  /**
+   * @brief Receive notification from other side.
+   *
+  */
+  bool notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData);
+
+signals:
+  void dataAvailable();
+private:
+signals:
+  void internalDataAvailable();
+private slots:
+  void forwardDataAvailable();
 private:
 
   Q_DECLARE_PRIVATE(ctkDicomAbstractExchangeCache)

+ 13 - 3
Plugins/org.commontk.dah.core/ctkDicomAvailableDataHelper.cpp

@@ -185,9 +185,9 @@ bool addNonDICOMToAvailableData(ctkDicomAppHosting::AvailableData& data,
   else
 	   objectDescriptor.mimeType = "text/plain"; //default
 
-  ctkDicomAppHosting::Patient* ppatient;
-  ctkDicomAppHosting::Study* pstudy;
-  ctkDicomAppHosting::Series* pseries;
+  //ctkDicomAppHosting::Patient* ppatient;
+  //ctkDicomAppHosting::Study* pstudy;
+  //ctkDicomAppHosting::Series* pseries;
 
   data.objectDescriptors.append(objectDescriptor);
 
@@ -309,4 +309,14 @@ bool addToAvailableData(ctkDicomAppHosting::AvailableData& data,
   return addToAvailableData(data, objectLocatorCache, ctkdataset, fileinfo.size(), 0, uri);
 
 }
+
+//----------------------------------------------------------------------------
+bool appendToAvailableData(ctkDicomAppHosting::AvailableData& dest,
+                        const ctkDicomAppHosting::AvailableData& src)
+{
+  dest.objectDescriptors.append(src.objectDescriptors);
+  dest.patients.append(src.patients);
+  return true;
 }
+
+} //end namespace ctkDicomAvailableDataHelper

+ 7 - 2
Plugins/org.commontk.dah.core/ctkDicomAvailableDataHelper.h

@@ -90,8 +90,6 @@ bool org_commontk_dah_core_EXPORT addToAvailableData(ctkDicomAppHosting::Availab
                         ctkDicomObjectLocatorCache* objectLocatorCache, 
                         const QString& filename);
 
-}
-
 //----------------------------------------------------------------------------
 bool org_commontk_dah_core_EXPORT addNonDICOMToAvailableData(ctkDicomAppHosting::AvailableData& data, 
                         ctkDicomObjectLocatorCache* objectLocatorCache, 
@@ -100,4 +98,11 @@ bool org_commontk_dah_core_EXPORT addNonDICOMToAvailableData(ctkDicomAppHosting:
                         long offset, 
                         const QString& uri);
 
+//----------------------------------------------------------------------------
+bool appendToAvailableData(ctkDicomAppHosting::AvailableData& dest,
+                        const ctkDicomAppHosting::AvailableData& src);
+
+
+} //end namespace ctkDicomAvailableDataHelper
+
 #endif // CTKDICOMAVAILABLEDATAHELPER_H

+ 4 - 4
Plugins/org.commontk.dah.exampleapp/ctkExampleDicomAppLogic.cpp

@@ -52,6 +52,7 @@ ctkDicomAbstractApp(ctkExampleDicomAppPlugin::getPluginContext()), AppWidget(0)
   connect(this, SIGNAL(suspendProgress()), this, SLOT(onSuspendProgress()), Qt::QueuedConnection);
   connect(this, SIGNAL(cancelProgress()), this, SLOT(onCancelProgress()), Qt::QueuedConnection);
   connect(this, SIGNAL(exitHostedApp()), this, SLOT(onExitHostedApp()), Qt::QueuedConnection);
+  connect(this, SIGNAL(dataAvailable()), this, SLOT(onDataAvailable()));
 
   //notify Host we are ready.
   try {
@@ -185,14 +186,14 @@ void ctkExampleDicomAppLogic::onReleaseResources()
 
 
 //----------------------------------------------------------------------------
-bool ctkExampleDicomAppLogic::notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData)
+void ctkExampleDicomAppLogic::onDataAvailable()
 {
-  Q_UNUSED(lastData)
   QString s;
+  const ctkDicomAppHosting::AvailableData& data = getIncomingAvailableData();
   if(this->AppWidget == 0)
     {
     qCritical() << "Button is null!";
-    return false;
+    return;
     }
   s = "Received notifyDataAvailable with patients.count()= " + QString().setNum(data.patients.count());
   if(data.patients.count()>0)
@@ -212,7 +213,6 @@ bool ctkExampleDicomAppLogic::notifyDataAvailable(const ctkDicomAppHosting::Avai
   }
   ui.ReceivedDataInformation->setText(s);
   ui.LoadDataButton->setEnabled(true);
-  return false;
 }
 
 

+ 2 - 10
Plugins/org.commontk.dah.exampleapp/ctkExampleDicomAppLogic_p.h

@@ -58,16 +58,6 @@ public:
    */
   virtual bool bringToFront(const QRect& requestedScreenArea);
 
-  // ctkDicomExchangeInterface
-
-  /**
-   * The source of the data calls this method with descriptions of the available data that it can provide to the
-   * recipient. If the source of the data expects that additional data will become available, it shall pass FALSE
-   * in the lastData parameter. Otherwise, it shall pass TRUE.
-   * \return TRUE if the recipient of the data successfully received the AvailableData list.
-   */
-  virtual bool notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData);
-
   // some logic
   /** Test function for checking */
   void do_something();
@@ -84,6 +74,8 @@ protected slots:
 
   void onLoadDataClicked();
   void onCreateSecondaryCapture();
+
+  void onDataAvailable();
 private:
   QWidget * AppWidget;
   Ui::ctkExampleDicomAppWidget ui;

+ 0 - 9
Plugins/org.commontk.dah.examplehost/ctkExampleDicomHost.cpp

@@ -101,15 +101,6 @@ ctkExampleDicomHost::~ctkExampleDicomHost()
   this->AppProcess.kill();
 }
 
-
-//----------------------------------------------------------------------------
-bool ctkExampleDicomHost::notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData)
-{
-  Q_UNUSED(data)
-  Q_UNUSED(lastData)
-  return false;
-}
-
 //----------------------------------------------------------------------------
 void ctkExampleDicomHost::onAppReady()
 {

+ 0 - 9
Plugins/org.commontk.dah.examplehost/ctkExampleDicomHost.h

@@ -70,15 +70,6 @@ public:
    */
   virtual void notifyStatus(const ctkDicomAppHosting::Status& status);
 
-  // exchange methods
-  /**
-   * The source of the data calls this method with descriptions of the available data that it can provide to the
-   * recipient. If the source of the data expects that additional data will become available, it shall pass FALSE
-   * in the lastData parameter. Otherwise, it shall pass TRUE.
-   * \return TRUE if the recipient of the data successfully received the AvailableData list.
-   */
-  virtual bool notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData);
-
   ctkDicomAppHosting::State getApplicationState() const;
 
   const QProcess& getAppProcess() const { return this->AppProcess; }