ctkDicomExampleHost.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "ctkDicomExampleHost.h"
  2. #include "ctkDicomWG23TypesHelper.h"
  3. #include <QProcess>
  4. #include <QtDebug>
  5. ctkDicomExampleHost::ctkDicomExampleHost(QWidget* placeholderWidget, int hostPort, int appPort) :
  6. ctkDicomAbstractHost(hostPort, appPort),
  7. placeholderWidget(placeholderWidget),
  8. applicationState(ctkDicomWG23::IDLE)
  9. {
  10. }
  11. void ctkDicomExampleHost::StartApplication(QString AppPath){
  12. QStringList l;
  13. l.append("--hostURL");
  14. l.append(QString("http://localhost:") + QString::number(this->getHostPort()) );
  15. l.append("--applicationURL");
  16. l.append(QString("http://localhost:") + QString::number(this->getAppPort()));
  17. l.append("dicomapp"); // the app plugin to use - has to be changed later
  18. if (!QProcess::startDetached (
  19. AppPath,l))
  20. {
  21. qCritical() << "application failed to start!";
  22. }
  23. qDebug() << "starting application: " << AppPath << " " << l;
  24. this->appProcess.start(AppPath,l);
  25. }
  26. QRect ctkDicomExampleHost::getAvailableScreen(const QRect& preferredScreen){
  27. qDebug()<< "set screen from preferredScreen:"<< preferredScreen;
  28. QRect rect (preferredScreen);
  29. emit giveAvailableScreen(rect);
  30. return rect;
  31. }
  32. void ctkDicomExampleHost::notifyStateChanged(ctkDicomWG23::State state){
  33. qDebug()<< "new state received:"<< ctkDicomSoapState::toStringValue(state);
  34. emit stateChangedReceived(state);
  35. }
  36. void ctkDicomExampleHost::notifyStatus(const ctkDicomWG23::Status& status){
  37. qDebug()<< "new status received:"<<status.codeMeaning;
  38. emit statusReceived(status);;
  39. }
  40. ctkDicomExampleHost::~ctkDicomExampleHost()
  41. {
  42. qDebug() << "Exiting host: trying to terminate app";
  43. this->appProcess.terminate();
  44. qDebug() << "Exiting host: trying to kill app";
  45. this->appProcess.kill();
  46. }