Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
750:284f37dc1c66 | 751:712ff6ff3c19 |
---|---|
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 | |
21 #pragma once | |
22 | |
23 #include "PointerTypes.h" | |
24 #include "boost/noncopyable.hpp" | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 class PolylineSceneLayer; | |
29 class TextSceneLayer; | |
30 | |
31 /** | |
32 This class holds the indices of a set a layer and supplies | |
33 getters to the concrete layer objects. Sounds very ad hoc, and it is. | |
34 */ | |
35 class LayerHolder : public boost::noncopyable | |
36 { | |
37 public: | |
38 /** | |
39 This ctor merely stores the scene and layer counts. No layer creation | |
40 performed at this time | |
41 */ | |
42 LayerHolder( | |
43 ViewportControllerWPtr controllerW, | |
44 int polylineLayerCount, int textLayerCount); | |
45 | |
46 /** | |
47 This actually creates the layers | |
48 */ | |
49 void CreateLayers(); | |
50 | |
51 /** | |
52 This creates the layers if they are not created yet. Can be useful in | |
53 some scenarios | |
54 */ | |
55 void CreateLayersIfNeeded(); | |
56 | |
57 /** | |
58 Whether the various text and polylines layers have all been created or | |
59 none at all | |
60 */ | |
61 bool AreLayersCreated() const; | |
62 | |
63 /** | |
64 This removes the layers from the scene | |
65 */ | |
66 void DeleteLayers(); | |
67 | |
68 /** | |
69 Please note that the returned pointer belongs to the scene.Don't you dare | |
70 storing or deleting it, you fool! | |
71 | |
72 This throws if the index is not valid or if the layers are not created or | |
73 have been deleted | |
74 */ | |
75 PolylineSceneLayer* GetPolylineLayer(int index = 0); | |
76 | |
77 /** | |
78 Please note that the returned pointer belongs to the scene. Don't you dare | |
79 storing or deleting it, you fool! | |
80 | |
81 This throws if the index is not valid or if the layers are not created or | |
82 have been deleted | |
83 */ | |
84 TextSceneLayer* GetTextLayer(int index = 0); | |
85 | |
86 private: | |
87 int GetPolylineLayerIndex(int index = 0); | |
88 int GetTextLayerIndex(int index = 0); | |
89 Scene2DPtr GetScene(); | |
90 | |
91 int textLayerCount_; | |
92 int polylineLayerCount_; | |
93 ViewportControllerWPtr controllerW_; | |
94 int baseLayerIndex_; | |
95 }; | |
96 | |
97 typedef boost::shared_ptr<LayerHolder> LayerHolderPtr; | |
98 } | |
99 |