annotate Framework/Scene2DViewport/MeasureCommands.h @ 722:28b9e3a54200

Undo mechanism implemented (not connected to UI yet). Undo stack and measuring tools are now handled by the ViewportController. Multi-touch does not crash trackers anymore.
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 21 May 2019 10:27:54 +0200
parents 059e1fd05fd6
children c0fcb2757b0a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 *
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 *
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 *
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19 **/
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20 #pragma once
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22 #include <Framework/Scene2D/Scene2D.h>
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 #include <boost/shared_ptr.hpp>
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #include <boost/noncopyable.hpp>
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 // to be moved into Stone
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 #include "PointerTypes.h"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 #include "MeasureTools.h"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29 #include "LineMeasureTool.h"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 #include "AngleMeasureTool.h"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 namespace OrthancStone
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 class TrackerCommand : public boost::noncopyable
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 public:
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
37 TrackerCommand(ViewportControllerWPtr controllerW)
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
38 : controllerW_(controllerW)
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 virtual void Undo() = 0;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 virtual void Redo() = 0;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 protected:
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
46 ViewportControllerPtr GetController();
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
47 ViewportControllerWPtr controllerW_;
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 };
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 class CreateMeasureCommand : public TrackerCommand
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 public:
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
53 CreateMeasureCommand(ViewportControllerWPtr controllerW);
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 ~CreateMeasureCommand();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 virtual void Undo() ORTHANC_OVERRIDE;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 virtual void Redo() ORTHANC_OVERRIDE;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 private:
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 /** Must be implemented by the subclasses that create the actual tool */
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 virtual MeasureToolPtr GetMeasureTool() = 0;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 };
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
61
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 class CreateLineMeasureCommand : public CreateMeasureCommand
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 public:
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 CreateLineMeasureCommand(
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
66 MessageBroker& broker,
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
67 ViewportControllerWPtr controllerW,
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
68 ScenePoint2D point);
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 // the starting position is set in the ctor
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 void SetEnd(ScenePoint2D scenePos);
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 private:
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 virtual MeasureToolPtr GetMeasureTool() ORTHANC_OVERRIDE
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 return measureTool_;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 LineMeasureToolPtr measureTool_;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 };
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 class CreateAngleMeasureCommand : public CreateMeasureCommand
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 public:
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 /** Ctor sets end of side 1*/
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 CreateAngleMeasureCommand(
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
87 MessageBroker& broker,
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
88 ViewportControllerWPtr controllerW,
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
89 ScenePoint2D point);
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 /** This method sets center*/
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 void SetCenter(ScenePoint2D scenePos);
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 /** This method sets end of side 2*/
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 void SetSide2End(ScenePoint2D scenePos);
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 private:
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 virtual MeasureToolPtr GetMeasureTool() ORTHANC_OVERRIDE
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 return measureTool_;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 AngleMeasureToolPtr measureTool_;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 };
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106