ctkExampleDicomAppLogic.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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. #include "ctkExampleDicomAppLogic_p.h"
  16. #include <QtPlugin>
  17. #include <QRect>
  18. #include <QDebug>
  19. #include <QPushButton>
  20. ctkExampleDicomAppLogic::ctkExampleDicomAppLogic(ServiceAccessor<ctkDicomHostInterface> host)
  21. : host(host)
  22. {
  23. connect(this, SIGNAL(stateChanged(int)), this, SLOT(changeState(int)), Qt::QueuedConnection);
  24. emit stateChanged(ctkDicomWG23::IDLE);
  25. }
  26. ctkExampleDicomAppLogic::~ctkExampleDicomAppLogic()
  27. {
  28. }
  29. ctkDicomWG23::State ctkExampleDicomAppLogic::getState()
  30. {
  31. return ctkDicomWG23::IDLE;
  32. }
  33. bool ctkExampleDicomAppLogic::setState(ctkDicomWG23::State newState)
  34. {
  35. qDebug() << "setState called";
  36. emit stateChanged(newState);
  37. return true;
  38. }
  39. bool ctkExampleDicomAppLogic::bringToFront(const QRect& /*requestedScreenArea*/)
  40. {
  41. return false;
  42. }
  43. void ctkExampleDicomAppLogic::do_something()
  44. {
  45. QPushButton *button = new QPushButton("Button from App");
  46. try
  47. {
  48. QRect preferred(50,50,100,100);
  49. qDebug() << " Asking:getAvailableScreen";
  50. QRect rect = host->getAvailableScreen(preferred);
  51. qDebug() << " got sth:" << rect.top();
  52. button->move(rect.topLeft());
  53. button->resize(rect.size());
  54. }
  55. catch (const std::runtime_error& e)
  56. {
  57. qCritical() << e.what();
  58. }
  59. button->show();
  60. }
  61. void ctkExampleDicomAppLogic::changeState(int anewstate)
  62. {
  63. ctkDicomWG23::State newstate = static_cast<ctkDicomWG23::State>(anewstate);
  64. try
  65. {
  66. host->notifyStateChanged(newstate);
  67. }
  68. catch (const std::runtime_error& e)
  69. {
  70. qCritical() << e.what();
  71. }
  72. if (newstate == ctkDicomWG23::INPROGRESS)
  73. {
  74. do_something();
  75. }
  76. }
  77. bool ctkExampleDicomAppLogic::notifyDataAvailable(ctkDicomWG23::AvailableData data, bool lastData)
  78. {
  79. return false;
  80. }
  81. QList<ctkDicomWG23::ObjectLocator>* ctkExampleDicomAppLogic::getData(
  82. QList<QUuid> objectUUIDs,
  83. QList<QString> acceptableTransferSyntaxUIDs,
  84. bool includeBulkData)
  85. {
  86. return NULL;
  87. }
  88. void ctkExampleDicomAppLogic::releaseData(QList<QUuid> objectUUIDs)
  89. {
  90. }