comparison Framework/Scene2DViewport/MeasureCommands.h @ 698:8b6adfb62a2f refactor-viewport-controller

Code is broken -- stashing ongoing work in a branch
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 15 May 2019 16:56:17 +0200
parents
children 059e1fd05fd6
comparison
equal deleted inserted replaced
660:cb3b76d16234 698:8b6adfb62a2f
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-2019 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 #pragma once
21
22 #include <Framework/Scene2D/Scene2D.h>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/noncopyable.hpp>
25
26 // to be moved into Stone
27 #include "PointerTypes.h"
28 #include "MeasureTools.h"
29 #include "LineMeasureTool.h"
30 #include "AngleMeasureTool.h"
31
32 namespace OrthancStone
33 {
34 class TrackerCommand : public boost::noncopyable
35 {
36 public:
37 TrackerCommand(Scene2DWPtr sceneW) : scene_(sceneW)
38 {
39
40 }
41 virtual void Undo() = 0;
42 virtual void Redo() = 0;
43 Scene2DPtr GetScene()
44 {
45 return scene_.lock();
46 }
47
48 protected:
49 Scene2DWPtr scene_;
50 };
51
52 class CreateMeasureCommand : public TrackerCommand
53 {
54 public:
55 CreateMeasureCommand(Scene2DWPtr sceneW, MeasureToolList& measureTools);
56 ~CreateMeasureCommand();
57 virtual void Undo() ORTHANC_OVERRIDE;
58 virtual void Redo() ORTHANC_OVERRIDE;
59 protected:
60 MeasureToolList& measureTools_;
61 private:
62 /** Must be implemented by the subclasses that create the actual tool */
63 virtual MeasureToolPtr GetMeasureTool() = 0;
64 };
65
66
67 class CreateLineMeasureCommand : public CreateMeasureCommand
68 {
69 public:
70 CreateLineMeasureCommand(
71 MessageBroker& broker,
72 Scene2DWPtr scene,
73 MeasureToolList& measureTools,
74 ScenePoint2D point);
75
76 // the starting position is set in the ctor
77 void SetEnd(ScenePoint2D scenePos);
78
79 private:
80 virtual MeasureToolPtr GetMeasureTool() ORTHANC_OVERRIDE
81 {
82 return measureTool_;
83 }
84 LineMeasureToolPtr measureTool_;
85 };
86
87
88 class CreateAngleMeasureCommand : public CreateMeasureCommand
89 {
90 public:
91 /** Ctor sets end of side 1*/
92 CreateAngleMeasureCommand(
93 MessageBroker& broker,
94 Scene2DWPtr scene,
95 MeasureToolList& measureTools,
96 ScenePoint2D point);
97
98 /** This method sets center*/
99 void SetCenter(ScenePoint2D scenePos);
100
101 /** This method sets end of side 2*/
102 void SetSide2End(ScenePoint2D scenePos);
103
104 private:
105 virtual MeasureToolPtr GetMeasureTool() ORTHANC_OVERRIDE
106 {
107 return measureTool_;
108 }
109 AngleMeasureToolPtr measureTool_;
110 };
111
112 }
113