Parcourir la source

ENH:dah starts new example based on AbstractHost

Benoît Bleuzé il y a 15 ans
Parent
commit
642d6f289f

+ 64 - 0
Applications/cktExampleHost2/CMakeLists.txt

@@ -0,0 +1,64 @@
+PROJECT(ctkExampleHost)
+
+#
+# See CTK/CMake/ctkMacroBuildApp.cmake for details
+#
+
+SET(KIT_SRCS
+  ctkExampleHostMain.cpp
+)
+
+SET(SRCS_2
+  ctkExampleHostMain2.cpp
+)
+# Headers that should run through moc
+SET(KIT_MOC_SRCS
+
+)
+
+# UI files
+SET(KIT_UI_FORMS
+  
+)
+
+# Resources
+SET(KIT_resources
+  
+)
+
+# Target libraries - See CMake/ctkMacroGetTargetLibraries.cmake
+# The following macro will read the target libraries from the file 'target_libraries.cmake'
+ctkMacroGetTargetLibraries(KIT_target_libraries)
+
+# Additional directories to include - Note that CTK_INCLUDE_LIBRARIES is already included
+SET(KIT_include_directories
+)
+
+# Fix this after having discussed include dependencies with Jc
+FOREACH(_dep ${${PROJECT_NAME}_DEPENDENCIES})
+  INCLUDE_DIRECTORIES(${${_dep}_SOURCE_DIR} ${${_dep}_BINARY_DIR})
+ENDFOREACH()
+
+ctkMacroBuildApp(
+  NAME ${PROJECT_NAME}
+  INCLUDE_DIRECTORIES ${KIT_include_directories}
+  SRCS ${KIT_SRCS}
+  MOC_SRCS ${KIT_MOC_SRCS}
+  UI_FORMS ${KIT_UI_FORMS}
+  TARGET_LIBRARIES ${KIT_target_libraries}
+  RESOURCES ${KIT_resources}
+  )
+ctkMacroBuildApp(
+  NAME ${PROJECT_NAME}2
+  INCLUDE_DIRECTORIES ${KIT_include_directories}
+  SRCS ${SRCS_2}
+  MOC_SRCS ${KIT_MOC_SRCS}
+  UI_FORMS ${KIT_UI_FORMS}
+  TARGET_LIBRARIES ${KIT_target_libraries}
+  RESOURCES ${KIT_resources}
+  )
+
+# Testing
+IF(BUILD_TESTING)
+#   ADD_SUBDIRECTORY(Testing)
+ENDIF(BUILD_TESTING)

+ 89 - 0
Applications/cktExampleHost2/ctkExampleHostMain.cpp

@@ -0,0 +1,89 @@
+/*=============================================================================
+
+  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 <ctkPluginFrameworkFactory.h>
+#include <ctkPluginFramework.h>
+#include <ctkPluginException.h>
+
+#include <QApplication>
+#include <QString>
+#include <QStringList>
+#include <QDirIterator>
+#include <QWidget>
+#include <QUrl>
+
+int main(int argv, char** argc)
+{
+  QApplication app(argv, argc);
+
+  qApp->setOrganizationName("CTK");
+  qApp->setOrganizationDomain("commontk.org");
+  qApp->setApplicationName("ctkExampleHost");
+
+  ctkPluginFrameworkFactory fwFactory;
+  ctkPluginFramework* framework = fwFactory.getFramework();
+
+  try {
+    framework->init();
+  }
+  catch (const ctkPluginException& exc)
+  {
+    qCritical() << "Failed to initialize the plug-in framework:" << exc;
+    exit(1);
+  }
+
+#ifdef CMAKE_INTDIR
+  QString pluginPath = qApp->applicationDirPath() + "/../plugins/" CMAKE_INTDIR "/";
+#else
+  QString pluginPath = qApp->applicationDirPath() + "/plugins/";
+#endif
+
+  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")
+          && !fileLocation.contains("app"))
+      {
+        ctkPlugin* plugin = framework->getPluginContext()->installPlugin(QUrl::fromLocalFile(fileLocation));
+        plugin->start(ctkPlugin::START_TRANSIENT);
+      }
+    }
+    catch (const ctkPluginException& e)
+    {
+      qCritical() << e.what();
+    }
+  }
+
+  framework->start();
+
+  QWidget placeholder;
+  placeholder.show();
+
+  return app.exec();
+
+}

+ 45 - 0
Applications/cktExampleHost2/ctkExampleHostMain2.cpp

@@ -0,0 +1,45 @@
+/*=============================================================================
+
+  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 <QApplication>
+#include <QString>
+#include <QStringList>
+#include <QDirIterator>
+#include <QWidget>
+#include <QUrl>
+
+int main(int argv, char** argc)
+{
+  QApplication app(argv, argc);
+
+  qApp->setOrganizationName("CTK");
+  qApp->setOrganizationDomain("commontk.org");
+  qApp->setApplicationName("ctkExampleHost");
+
+
+  
+  QWidget placeholder;
+  placeholder.show();
+
+  return app.exec();
+
+}

+ 10 - 0
Applications/cktExampleHost2/target_libraries.cmake

@@ -0,0 +1,10 @@
+#
+# See CMake/ctkMacroGetTargetLibraries.cmake
+# 
+# This file should list the libraries required to build the current CTK application.
+# 
+
+SET(target_libraries
+  CTKPluginFramework
+  org_commontk_dicom_wg23_host
+  )

+ 1 - 0
CMakeLists.txt

@@ -308,6 +308,7 @@ SET(CTK_APPLICATIONS
   ctkDICOMQuery:OFF
   ctkDICOMQuery:OFF
   ctkDICOMRetrieve:OFF
   ctkDICOMRetrieve:OFF
   ctkExampleHost:OFF
   ctkExampleHost:OFF
+  ctkExampleHost2:OFF
   ctkPluginBrowser:OFF
   ctkPluginBrowser:OFF
   ctkPluginGenerator:OFF
   ctkPluginGenerator:OFF
   ctkSimplePythonShell:OFF
   ctkSimplePythonShell:OFF

+ 13 - 0
Plugins/org.commontk.dicom.wg23.host/ctkDicomHostServer.cpp

@@ -30,4 +30,17 @@ ctkDicomHostServer::ctkDicomHostServer(ctkDicomHostInterface* hostInterface, int
 }
 }
 ctkDicomHostServer::~ctkDicomHostServer()
 ctkDicomHostServer::~ctkDicomHostServer()
 {
 {
+
+int ctkDicomHostServer::StartApplication(QString AppPath, QString App_URL, int port){
+    QStringList l;
+    l.append("--hostURL");
+    l.append("localhost:"+d_ptr->port);
+    l.append("--applicationURL");
+    l.append(App_URL+":"+QString(port));
+    if (!QProcess::startDetached (
+            AppPath,l))
+    {
+        qCritical()<<"application failed to start!";
+    }
+
 }
 }

+ 2 - 0
Plugins/org.commontk.dicom.wg23.host/ctkDicomHostServer.h

@@ -39,6 +39,8 @@ private:
   Q_DECLARE_PRIVATE(ctkDicomHostServer)
   Q_DECLARE_PRIVATE(ctkDicomHostServer)
 
 
   const QScopedPointer<ctkDicomHostServerPrivate> d_ptr;
   const QScopedPointer<ctkDicomHostServerPrivate> d_ptr;
+
+
 };
 };
 
 
 #endif // CTKDICOMHOSTSERVER_H
 #endif // CTKDICOMHOSTSERVER_H

+ 4 - 3
Plugins/org.commontk.dicom.wg23.host/ctkDicomHostServerPrivate.cpp

@@ -42,6 +42,8 @@ ctkDicomHostServerPrivate::ctkDicomHostServerPrivate(ctkDicomHostInterface* host
   }
   }
 }
 }
 
 
+
+
 void ctkDicomHostServerPrivate::incomingSoapMessage(const QtSoapMessage& message,
 void ctkDicomHostServerPrivate::incomingSoapMessage(const QtSoapMessage& message,
                                               QtSoapMessage* reply)
                                               QtSoapMessage* reply)
 {
 {
@@ -50,7 +52,7 @@ void ctkDicomHostServerPrivate::incomingSoapMessage(const QtSoapMessage& message
 
 
   qDebug() << "Received soap method request: " << methodName;
   qDebug() << "Received soap method request: " << methodName;
 
 
-  if (methodName == "GetAvailableScreen")
+  if (methodName == "getAvailableScreen")
   {
   {
     processGetAvailableScreen(message, reply);
     processGetAvailableScreen(message, reply);
   }
   }
@@ -72,7 +74,7 @@ void ctkDicomHostServerPrivate::processGetAvailableScreen(
 
 
   const QRect result = hostInterface->getAvailableScreen(preferredScreen);
   const QRect result = hostInterface->getAvailableScreen(preferredScreen);
 
 
-  reply->setMethod("GetAvailableScreenResponse");
+  reply->setMethod("getAvailableScreenResponse");
   QtSoapStruct* availableScreenType = new ctkDicomSoapRectangle("availableScreen",result);
   QtSoapStruct* availableScreenType = new ctkDicomSoapRectangle("availableScreen",result);
   reply->addMethodArgument(availableScreenType);
   reply->addMethodArgument(availableScreenType);
 }
 }
@@ -89,5 +91,4 @@ void ctkDicomHostServerPrivate::processNotifyStatus(
 {
 {
     const QtSoapType& status = message.method()["status"];
     const QtSoapType& status = message.method()["status"];
     hostInterface->notifyStatus(ctkDicomSoapStatus::getStatus(status));
     hostInterface->notifyStatus(ctkDicomSoapStatus::getStatus(status));
-
 }
 }