ctkExampleDicomHost.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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() { return ""; }
  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*/) { return ""; }
  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. // exchange methods
  54. /**
  55. * The source of the data calls this method with descriptions of the available data that it can provide to the
  56. * recipient. If the source of the data expects that additional data will become available, it shall pass FALSE
  57. * in the lastData parameter. Otherwise, it shall pass TRUE.
  58. * \return TRUE if the recipient of the data successfully received the AvailableData list.
  59. */
  60. virtual bool notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData);
  61. /**
  62. * The recipient of data invokes this method to release access to binary data provided by the source of the
  63. * data through a getData() call. The ArrayOfUUID identifies the data streams that the recipient is releasing.
  64. */
  65. virtual void releaseData(const QList<QUuid>& objectUUIDs);
  66. const QProcess& getAppProcess() const { return this->AppProcess; }
  67. void exitApplication();
  68. QByteArray processReadAll(){return this->AppProcess.readAllStandardOutput ();}
  69. public slots:
  70. void onAppReady();
  71. void onReleaseAvailableResources();
  72. void onStartProgress();
  73. void onResumed();
  74. void onCompleted();
  75. void onSuspended();
  76. void onCanceled();
  77. void onExited();
  78. signals:
  79. void giveAvailableScreen(QRect rect);
  80. protected:
  81. QProcess AppProcess;
  82. ctkHostedAppPlaceholderWidget* PlaceholderWidget;
  83. private:
  84. bool exitingApplication;
  85. };
  86. #endif // CTKEXAMPLEDICOMHOST_H