瀏覽代碼

partly working stop button + redirected output

Benoit Bleuze 14 年之前
父節點
當前提交
eda02244a2

+ 17 - 4
Applications/ctkExampleHost/ctkHostAppExampleWidget.cpp

@@ -58,6 +58,8 @@ void ctkHostAppExampleWidget::startButtonClicked()
   if (host)
   {
     host->StartApplication(appFileName);
+    //forward output to textedit
+    connect(&this->host->getAppProcess(),SIGNAL(readyReadStandardOutput()),this,SLOT(outputMessage()));
   }
 }
 
@@ -74,7 +76,7 @@ void ctkHostAppExampleWidget::runButtonClicked()
 void ctkHostAppExampleWidget::stopButtonClicked()
 {
   qDebug() << "stop button clicked";
-  host->getDicomAppService ()->setState (ctkDicomAppHosting::SUSPENDED);
+  host->getDicomAppService ()->setState (ctkDicomAppHosting::CANCELED);
 }
 
 void ctkHostAppExampleWidget::loadButtonClicked()
@@ -152,10 +154,12 @@ void ctkHostAppExampleWidget::appStateChanged(ctkDicomAppHosting::State state)
   switch (state)
   {
   case ctkDicomAppHosting::IDLE:
-    //if (host->appInprogress)
-    //{
+    if (host->getApplicationState()!=ctkDicomAppHosting::IDLE)
+    {
+      qDebug()<<"state was not IDLE before -> setState EXIT ";
       host->getDicomAppService()->setState (ctkDicomAppHosting::EXIT);
-    //}
+
+    }
     break;
   case ctkDicomAppHosting::INPROGRESS:
 
@@ -179,6 +183,7 @@ void ctkHostAppExampleWidget::appStateChanged(ctkDicomAppHosting::State state)
     data.patients = QList<ctkDicomAppHosting::Patient>();
     data.patients.append (patient);
 
+    qDebug()<<"send dataDescriptors";
     reply = host->getDicomAppService()->notifyDataAvailable (data,true);
     qDebug() << "  notifyDataAvailable(1111) returned: " << reply;
     break;
@@ -186,8 +191,16 @@ void ctkHostAppExampleWidget::appStateChanged(ctkDicomAppHosting::State state)
   case ctkDicomAppHosting::SUSPENDED:
   case ctkDicomAppHosting::CANCELED:
   case ctkDicomAppHosting::EXIT:
+    //shouldn't happen, when exiting the application just dies
   default:
     //do nothing
     break;
   }
+  host->setApplicationState(state);
+}
+
+
+void ctkHostAppExampleWidget::outputMessage ()
+{
+  ui->messageOutput->append (host->processReadAll ());
 }

+ 1 - 1
Applications/ctkExampleHost/ctkHostAppExampleWidget.h

@@ -55,7 +55,7 @@ public slots:
   void appStateChanged(ctkDicomAppHosting::State state);
 
   void placeholderResized();
-
+  void outputMessage();
 protected:
 
   ctkExampleDicomHost* host;

+ 1 - 1
Applications/ctkExampleHostedApp/ctkExampleHostedAppMain.cpp

@@ -125,7 +125,7 @@ int main(int argv, char** argc)
     pluginName = parser.unparsedArguments().at(0);
     }
 
-  // try to find the plugin and install all plugins available in 
+  // try to find the plugin and install all plugins available in
   // pluginPath containing the string "org_commontk_dah" (but do not start them)
   QSharedPointer<ctkPlugin> appPlugin;
   QStringList libFilter;

+ 5 - 2
Plugins/org.commontk.dah.app/ctkDicomAppPlugin.cpp

@@ -28,7 +28,7 @@
 #include <QStringList>
 
 #include <stdexcept>
-
+#include <iostream>
 ctkPluginContext* ctkDicomAppPlugin::context = 0;
 
 ctkDicomAppPlugin::ctkDicomAppPlugin()
@@ -39,7 +39,10 @@ ctkDicomAppPlugin::ctkDicomAppPlugin()
 
 ctkDicomAppPlugin::~ctkDicomAppPlugin()
 {
-  
+  std::cout<<"in the destructor of the plugin"<<std::endl;
+  delete appServer;
+  delete hostInterface;
+  this->context=0;
 }
 
 void ctkDicomAppPlugin::start(ctkPluginContext* context)

+ 4 - 0
Plugins/org.commontk.dah.app/ctkDicomAppServer.cpp

@@ -51,6 +51,10 @@ ctkDicomAppServer::ctkDicomAppServer(int port)
     qCritical() << "Listening to 127.0.0.1:" << port << " failed.";
   }
 }
+ctkDicomAppServer::~ctkDicomAppServer()
+{
+  server.close ();
+}
 
 void ctkDicomAppServer::incomingWSDLMessage(
   const QString& message, QString* reply)

+ 1 - 1
Plugins/org.commontk.dah.app/ctkDicomAppServer_p.h

@@ -44,7 +44,7 @@ class ctkDicomAppServer : public QObject, ctkServiceTrackerCustomizer<ctkDicomAp
 
 public:
   ctkDicomAppServer(int port);
-
+  ~ctkDicomAppServer();
 public slots:
 
   void incomingSoapMessage(const QtSoapMessage& message,

+ 0 - 1
Plugins/org.commontk.dah.core/ctkExchangeSoapMessageProcessor.cpp

@@ -63,7 +63,6 @@ void ctkExchangeSoapMessageProcessor::processNotifyDataAvailable(
 {
   // extract arguments from input message
   const QtSoapType& inputType = message.method()[0];//"availableData"];
-  const QtSoapType& inputType = message.method()[0];
   if(inputType.isValid()==false)
   {
     qCritical() << "  NotifyDataAvailable: availableData not valid. " << inputType.errorString();

+ 5 - 5
Plugins/org.commontk.dah.core/ctkSoapLog.h

@@ -23,12 +23,12 @@
 #define CTKSOAPLOG_H
 
 //#define CTK_SOAP_LOG_LOWLEVEL(msg) qDebug() msg;
-#define CTK_SOAP_LOG_LOWLEVEL(msg) 
+#define CTK_SOAP_LOG_LOWLEVEL(msg)
 
-#define CTK_SOAP_LOG(msg) qDebug() msg;
-//#define CTK_SOAP_LOG(msg) 
+//#define CTK_SOAP_LOG(msg) qDebug() msg;
+#define CTK_SOAP_LOG(msg)
 
-#define CTK_SOAP_LOG_HIGHLEVEL(msg) qDebug() msg;
-//#define CTK_SOAP_LOG_HIGHLEVEL(msg) 
+//#define CTK_SOAP_LOG_HIGHLEVEL(msg) qDebug() msg;
+#define CTK_SOAP_LOG_HIGHLEVEL(msg)
 
 #endif // CTKSOAPLOG_H

+ 2 - 2
Plugins/org.commontk.dah.core/ctkSoapMessageProcessorList.cpp

@@ -41,8 +41,8 @@ bool ctkSoapMessageProcessorList::process(
     const QtSoapMessage& message,
     QtSoapMessage* reply ) const
 {
-  extern void DumpAll(const QtSoapType& type, int indent=0);
-  DumpAll(message.method());
+  //extern void DumpAll(const QtSoapType& type, int indent=0);
+  //DumpAll(message.method());
 
   foreach(ctkSoapMessageProcessor* processor, processors)
   {

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

@@ -40,6 +40,12 @@ ctkExampleDicomAppLogic::ctkExampleDicomAppLogic()
 
 ctkExampleDicomAppLogic::~ctkExampleDicomAppLogic()
 {
+  ctkPluginContext* context = ctkExampleDicomAppPlugin::getPluginContext();
+  QList <QSharedPointer<ctkPlugin> > plugins = context->getPlugins();
+  for (int i = 0; i < plugins.size(); ++i)
+  {
+    qDebug() << plugins.at(i)->getSymbolicName ();
+  }
 }
 
 ctkDicomAppHosting::State ctkExampleDicomAppLogic::getState()
@@ -118,7 +124,8 @@ void ctkExampleDicomAppLogic::changeState(int anewstate)
   if (newstate == ctkDicomAppHosting::EXIT)
   {
     qDebug() << "  Received changeState(EXIT) ... exiting.";
-    qApp->quit();
+    getHostInterface()->notifyStateChanged(ctkDicomAppHosting::EXIT);
+    qApp->exit(0);
   }
 }
 
@@ -152,8 +159,8 @@ bool ctkExampleDicomAppLogic::notifyDataAvailable(ctkDicomAppHosting::AvailableD
 }
 
 QList<ctkDicomAppHosting::ObjectLocator> ctkExampleDicomAppLogic::getData(
-  QList<QUuid> objectUUIDs, 
-  QList<QString> acceptableTransferSyntaxUIDs, 
+  QList<QUuid> objectUUIDs,
+  QList<QString> acceptableTransferSyntaxUIDs,
   bool includeBulkData)
 {
   Q_UNUSED(objectUUIDs)
@@ -193,4 +200,4 @@ void ctkExampleDicomAppLogic::buttonClicked()
     qDebug() << "URI: " << locators.begin()->URI;
   }
   button->setText(s);
-}
+}

+ 1 - 0
Plugins/org.commontk.dah.exampleapp/ctkExampleDicomAppPlugin.cpp

@@ -35,6 +35,7 @@ ctkExampleDicomAppPlugin::ctkExampleDicomAppPlugin()
 
 ctkExampleDicomAppPlugin::~ctkExampleDicomAppPlugin()
 {
+  qDebug()<< "delete applogic";
   delete appLogic;
 }
 

+ 2 - 1
Plugins/org.commontk.dah.examplehost/ctkExampleDicomHost.cpp

@@ -33,7 +33,7 @@ ctkExampleDicomHost::ctkExampleDicomHost(ctkHostedAppPlaceholderWidget* placehol
     placeholderWidget(placeholderWidget),
     applicationState(ctkDicomAppHosting::IDLE)
 {
-  connect(&this->appProcess,SIGNAL(readyReadStandardOutput()),SLOT(forwardConsoleOutput()));
+  //connect(&this->appProcess,SIGNAL(readyReadStandardOutput()),SLOT(forwardConsoleOutput()));
 }
 
 void ctkExampleDicomHost::StartApplication(QString AppPath)
@@ -70,6 +70,7 @@ void ctkExampleDicomHost::notifyStateChanged(ctkDicomAppHosting::State state)
 {
   qDebug()<< "new state received:"<< static_cast<int>(state);
   qDebug()<< "new state received:"<< ctkDicomSoapState::toStringValue(state);
+
   emit stateChangedReceived(state);
 }
 

+ 5 - 1
Plugins/org.commontk.dah.examplehost/ctkExampleDicomHost.h

@@ -53,6 +53,11 @@ public:
   virtual void releaseData(QList<QUuid> objectUUIDs);
 
   const QProcess& getAppProcess() const { return appProcess; }
+  const ctkDicomAppHosting::State getApplicationState()const {return applicationState;}
+  void setApplicationState(ctkDicomAppHosting::State state){applicationState = state;}
+
+  QByteArray processReadAll(){return appProcess.readAllStandardOutput ();}
+
   ~ctkExampleDicomHost();
 
 signals:
@@ -67,7 +72,6 @@ protected:
   ctkHostedAppPlaceholderWidget* placeholderWidget;
   ctkDicomAppHosting::State applicationState;
 
-
 protected slots:
 
   void forwardConsoleOutput();