Mercurial > hg > orthanc-stone
annotate Framework/Scene2DViewport/LayerHolder.h @ 751:712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
- added LayerHolder to streamline layer index management
- added overloads for ORTHANC_ASSERT with no string message (some heavy
preprocessor wizardry in there)
- fixing wasm BasicScene is *not* finished.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 22 May 2019 11:55:52 +0200 |
parents | |
children | 07adcffba38c |
rev | line source |
---|---|
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #pragma once |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 #include "PointerTypes.h" |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 #include "boost/noncopyable.hpp" |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 namespace OrthancStone |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 { |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 class PolylineSceneLayer; |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 class TextSceneLayer; |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 /** |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 This class holds the indices of a set a layer and supplies |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 getters to the concrete layer objects. Sounds very ad hoc, and it is. |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 */ |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 class LayerHolder : public boost::noncopyable |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 { |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 public: |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 /** |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 This ctor merely stores the scene and layer counts. No layer creation |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 performed at this time |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 */ |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 LayerHolder( |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 ViewportControllerWPtr controllerW, |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 int polylineLayerCount, int textLayerCount); |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 /** |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 This actually creates the layers |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 */ |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 void CreateLayers(); |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 /** |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 This creates the layers if they are not created yet. Can be useful in |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 some scenarios |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 */ |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 void CreateLayersIfNeeded(); |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 /** |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 Whether the various text and polylines layers have all been created or |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 none at all |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 */ |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 bool AreLayersCreated() const; |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 /** |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 This removes the layers from the scene |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 */ |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 void DeleteLayers(); |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 /** |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 Please note that the returned pointer belongs to the scene.Don't you dare |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 storing or deleting it, you fool! |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 This throws if the index is not valid or if the layers are not created or |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 have been deleted |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 */ |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 PolylineSceneLayer* GetPolylineLayer(int index = 0); |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 /** |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 Please note that the returned pointer belongs to the scene. Don't you dare |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 storing or deleting it, you fool! |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 This throws if the index is not valid or if the layers are not created or |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 have been deleted |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 */ |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 TextSceneLayer* GetTextLayer(int index = 0); |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 private: |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 int GetPolylineLayerIndex(int index = 0); |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 int GetTextLayerIndex(int index = 0); |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 Scene2DPtr GetScene(); |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 int textLayerCount_; |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 int polylineLayerCount_; |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 ViewportControllerWPtr controllerW_; |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 int baseLayerIndex_; |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 }; |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 typedef boost::shared_ptr<LayerHolder> LayerHolderPtr; |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 } |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 |