Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2DViewport/MeasureCommands.h @ 1979:b31e494e34c5
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 29 Oct 2022 17:10:21 +0200 |
parents | 7053b8a0aaec |
children | 07964689cb0b |
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 |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * 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
|
11 * 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
|
12 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * 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
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
16 * Lesser General Public License for more details. |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
19 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
698
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 #pragma once |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
24 #include "../Viewport/IViewport.h" |
698
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 |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
774
diff
changeset
|
27 #include "PredeclaredTypes.h" |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
736
diff
changeset
|
28 #include "MeasureTool.h" |
698
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 |
736
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
32 #include <boost/shared_ptr.hpp> |
1606
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
33 #include <boost/weak_ptr.hpp> |
736
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
34 #include <boost/noncopyable.hpp> |
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
35 |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 namespace OrthancStone |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 { |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
38 class MeasureCommand : public boost::noncopyable |
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 protected: |
1606
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
41 boost::weak_ptr<IViewport> viewport_; |
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
42 |
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
43 /** |
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
44 This will return a scoped lock to the viewport. |
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
45 If the viewport does not exist anymore, then nullptr is returned. |
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
46 */ |
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
47 IViewport::ILock* GetViewportLock(); |
1571 | 48 |
49 public: | |
1606
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
50 explicit MeasureCommand(boost::weak_ptr<IViewport> viewport) : |
1571 | 51 viewport_(viewport) |
52 { | |
53 } | |
54 | |
55 virtual ~MeasureCommand() | |
56 { | |
57 } | |
58 | |
59 virtual void Undo() = 0; | |
60 | |
61 virtual void Redo() = 0; | |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 }; |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 |
1571 | 64 |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
65 class CreateMeasureCommand : public MeasureCommand |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 private: |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 /** Must be implemented by the subclasses that create the actual tool */ |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
774
diff
changeset
|
69 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() = 0; |
1571 | 70 |
71 public: | |
1606
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
72 explicit CreateMeasureCommand(boost::weak_ptr<IViewport> viewport); |
1571 | 73 |
74 virtual ~CreateMeasureCommand(); | |
75 | |
76 virtual void Undo() ORTHANC_OVERRIDE; | |
77 | |
78 virtual void Redo() ORTHANC_OVERRIDE; | |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 }; |
1571 | 80 |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
81 |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
82 class EditMeasureCommand : public MeasureCommand |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
83 { |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
84 private: |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
85 /** Must be implemented by the subclasses that edit the actual tool */ |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
86 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() = 0; |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
87 |
1791
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
88 /** This memento is updated by the subclasses upon modifications */ |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
89 std::unique_ptr<MeasureToolMemento> mementoModified_; |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
90 |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
91 /** This memento is the original object state */ |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
92 std::unique_ptr<MeasureToolMemento> mementoOriginal_; |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
93 |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
94 protected: |
1791
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
95 void SetMementoModified(MeasureToolMemento* memento); // takes ownership |
1571 | 96 |
97 public: | |
98 EditMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, | |
1606
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
99 boost::weak_ptr<IViewport> viewport); |
1571 | 100 |
101 virtual ~EditMeasureCommand(); | |
102 | |
103 virtual void Undo() ORTHANC_OVERRIDE; | |
104 | |
105 virtual void Redo() ORTHANC_OVERRIDE; | |
1791
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
106 |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
107 const MeasureToolMemento& GetMementoOriginal() const; |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
108 }; |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
109 |
1571 | 110 |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
111 class DeleteMeasureCommand : public MeasureCommand |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
112 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 private: |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
114 /** Must be implemented by the subclasses that edit the actual tool */ |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
115 virtual boost::shared_ptr<MeasureTool> GetMeasureTool() |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
116 { |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
117 return measureTool_; |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
118 } |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
119 |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
120 boost::shared_ptr<MeasureTool> measureTool_; |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 |
1791
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
122 /** This memento is updated by the subclasses upon modifications */ |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
123 std::unique_ptr<MeasureToolMemento> mementoModified_; |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
124 |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
125 /** This memento is the original object state */ |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
126 std::unique_ptr<MeasureToolMemento> mementoOriginal_; |
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
127 |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
128 protected: |
1791
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
129 void SetMementoModified(MeasureToolMemento* memento); // takes ownership |
1571 | 130 |
131 public: | |
132 DeleteMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, | |
1606
874e178f34e9
- ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1598
diff
changeset
|
133 boost::weak_ptr<IViewport> viewport); |
1571 | 134 |
135 virtual ~DeleteMeasureCommand(); | |
136 | |
137 virtual void Undo() ORTHANC_OVERRIDE; | |
138 | |
139 virtual void Redo() ORTHANC_OVERRIDE; | |
140 | |
1791
9b650ab68d4c
replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
141 const MeasureToolMemento& GetMementoOriginal() const; |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
142 }; |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 |