comparison Applications/Samples/Deprecated/SimpleViewer/Qt/SimpleViewerMainWindow.cpp @ 1347:bfd77672d825 broker

Moved Application/Samples/* to Application/Samples/Deprecated/*
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 07 Apr 2020 14:29:01 +0200
parents Applications/Samples/SimpleViewer/Qt/SimpleViewerMainWindow.cpp@2d8ab34c8c91
children c53a4667f895
comparison
equal deleted inserted replaced
1346:df8bf351c23f 1347:bfd77672d825
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21 #include "SimpleViewerMainWindow.h"
22
23 /**
24 * Don't use "ui_MainWindow.h" instead of <ui_MainWindow.h> below, as
25 * this makes CMake unable to detect when the UI file changes.
26 **/
27 #include <ui_SimpleViewerMainWindow.h>
28 #include "../SimpleViewerApplication.h"
29
30
31 namespace SimpleViewer
32 {
33 template<typename T, typename U>
34 bool ExecuteCommand(U* handler, const T& command)
35 {
36 std::string serializedCommand = StoneSerialize(command);
37 StoneDispatchToHandler(serializedCommand, handler);
38 }
39
40 SimpleViewerMainWindow::SimpleViewerMainWindow(
41 OrthancStone::NativeStoneApplicationContext& context,
42 SimpleViewerApplication& stoneApplication,
43 QWidget *parent) :
44 QStoneMainWindow(context, parent),
45 ui_(new Ui::SimpleViewerMainWindow),
46 stoneApplication_(stoneApplication)
47 {
48 ui_->setupUi(this);
49 SetCentralStoneWidget(*ui_->cairoCentralWidget);
50
51 #if QT_VERSION >= 0x050000
52 connect(ui_->toolButtonCrop, &QToolButton::clicked, this, &SimpleViewerMainWindow::cropClicked);
53 connect(ui_->pushButtonUndoCrop, &QToolButton::clicked, this, &SimpleViewerMainWindow::undoCropClicked);
54 connect(ui_->toolButtonLine, &QToolButton::clicked, this, &SimpleViewerMainWindow::lineClicked);
55 connect(ui_->toolButtonCircle, &QToolButton::clicked, this, &SimpleViewerMainWindow::circleClicked);
56 connect(ui_->toolButtonWindowing, &QToolButton::clicked, this, &SimpleViewerMainWindow::windowingClicked);
57 connect(ui_->pushButtonRotate, &QPushButton::clicked, this, &SimpleViewerMainWindow::rotateClicked);
58 connect(ui_->pushButtonInvert, &QPushButton::clicked, this, &SimpleViewerMainWindow::invertClicked);
59 #else
60 connect(ui_->toolButtonCrop, SIGNAL(clicked()), this, SLOT(cropClicked()));
61 connect(ui_->toolButtonLine, SIGNAL(clicked()), this, SLOT(lineClicked()));
62 connect(ui_->toolButtonCircle, SIGNAL(clicked()), this, SLOT(circleClicked()));
63 connect(ui_->toolButtonWindowing, SIGNAL(clicked()), this, SLOT(windowingClicked()));
64 connect(ui_->pushButtonUndoCrop, SIGNAL(clicked()), this, SLOT(undoCropClicked()));
65 connect(ui_->pushButtonRotate, SIGNAL(clicked()), this, SLOT(rotateClicked()));
66 connect(ui_->pushButtonInvert, SIGNAL(clicked()), this, SLOT(invertClicked()));
67 #endif
68 }
69
70 SimpleViewerMainWindow::~SimpleViewerMainWindow()
71 {
72 delete ui_;
73 }
74
75 void SimpleViewerMainWindow::cropClicked()
76 {
77 stoneApplication_.ExecuteCommand(SelectTool(Tool_Crop));
78 }
79
80 void SimpleViewerMainWindow::undoCropClicked()
81 {
82 stoneApplication_.ExecuteCommand(Action(ActionType_UndoCrop));
83 }
84
85 void SimpleViewerMainWindow::lineClicked()
86 {
87 stoneApplication_.ExecuteCommand(SelectTool(Tool_LineMeasure));
88 }
89
90 void SimpleViewerMainWindow::circleClicked()
91 {
92 stoneApplication_.ExecuteCommand(SelectTool(Tool_CircleMeasure));
93 }
94
95 void SimpleViewerMainWindow::windowingClicked()
96 {
97 stoneApplication_.ExecuteCommand(SelectTool(Tool_Windowing));
98 }
99
100 void SimpleViewerMainWindow::rotateClicked()
101 {
102 stoneApplication_.ExecuteCommand(Action(ActionType_Rotate));
103 }
104
105 void SimpleViewerMainWindow::invertClicked()
106 {
107 stoneApplication_.ExecuteCommand(Action(ActionType_Invert));
108 }
109 }