ctkExampleDicomHost.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKEXAMPLEDICOMHOST_H
  16. #define CTKEXAMPLEDICOMHOST_H
  17. // Qt includes
  18. #include <QUrl>
  19. #include <QProcess>
  20. // CTK includes
  21. #include <ctkDicomAbstractHost.h>
  22. #include <ctkHostedAppPlaceholderWidget.h>
  23. #include <org_commontk_dah_examplehost_Export.h>
  24. class org_commontk_dah_examplehost_EXPORT ctkExampleDicomHost : public ctkDicomAbstractHost
  25. {
  26. Q_OBJECT
  27. public:
  28. ctkExampleDicomHost(ctkHostedAppPlaceholderWidget* placeholderWidget, int hostPort = 8080, int appPort = 8081);
  29. virtual ~ctkExampleDicomHost();
  30. virtual void StartApplication(QString AppPath);
  31. /**
  32. * Returns a newly created DICOM UID that the Hosted Application might use, e.g., to create new data
  33. * objects and structures.
  34. */
  35. virtual QString generateUID();
  36. /**
  37. * The Hosted Application supplies its preferred screen size in the appPreferredScreen parameter. The
  38. * Hosting System may utilize this information as a hint, but may return a window location and size that best
  39. * suits the Hosting System's GUI.
  40. */
  41. virtual QRect getAvailableScreen(const QRect& preferredScreen);
  42. /**
  43. * This method returns a URI that a Hosted Application may use to store output that it may provide back to
  44. * the Hosting System (e.g. in response to a getData() call).
  45. * \return a URI that a Hosted Application may use to store output.
  46. */
  47. virtual QString getOutputLocation(const QStringList& preferredProtocols);
  48. /**
  49. * Method used by the Hosted Application to inform the Hosting System of notable events that occur during execution.
  50. * The Hosted Application invoks this method, passing the information in the status parameter.
  51. */
  52. virtual void notifyStatus(const ctkDicomAppHosting::Status& status);
  53. ctkDicomAppHosting::State getApplicationState() const;
  54. const QProcess& getAppProcess() const { return this->AppProcess; }
  55. void exitApplication();
  56. QByteArray processReadAll(){return this->AppProcess.readAllStandardOutput ();}
  57. void exitApplicationBlocking(int timeout = 2000);
  58. public Q_SLOTS:
  59. void onAppReady();
  60. void onReleaseAvailableResources();
  61. void onStartProgress();
  62. void onResumed();
  63. void onCompleted();
  64. void onSuspended();
  65. void onCanceled();
  66. void onExited();
  67. Q_SIGNALS:
  68. void giveAvailableScreen(QRect rect);
  69. protected:
  70. QEventLoop BlockingLoopForExiting;
  71. protected slots:
  72. void onBlockingExiting(QProcess::ProcessState);
  73. void onBlockingExiting();
  74. protected:
  75. QProcess AppProcess;
  76. ctkHostedAppPlaceholderWidget* PlaceholderWidget;
  77. private:
  78. bool exitingApplication;
  79. };
  80. #endif // CTKEXAMPLEDICOMHOST_H