annotate Framework/Scene2DViewport/LayerHolder.cpp @ 1236:358461330978 broker

global function GetWebGLViewportsRegistry()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Dec 2019 20:45:47 +0100
parents 86a8266b8888
children 0ca50d275b9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 #include "LayerHolder.h"
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22 #include "../Scene2D/TextSceneLayer.h"
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 #include "../Scene2D/PolylineSceneLayer.h"
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #include "../Scene2D/Scene2D.h"
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25 #include "../Scene2DViewport/ViewportController.h"
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 #include "../StoneException.h"
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 namespace OrthancStone
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29 {
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 LayerHolder::LayerHolder(
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
31 boost::weak_ptr<ViewportController> controllerW,
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 int polylineLayerCount,
906
52b1c6ff10c5 Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
33 int textLayerCount,
52b1c6ff10c5 Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
34 int infoTextCount)
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 : textLayerCount_(textLayerCount)
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 , polylineLayerCount_(polylineLayerCount)
906
52b1c6ff10c5 Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
37 , infoTextCount_(infoTextCount)
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 , controllerW_(controllerW)
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 , baseLayerIndex_(-1)
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 {
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 }
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 void LayerHolder::CreateLayers()
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 {
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
46 boost::shared_ptr<ViewportController> controller = controllerW_.lock();
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
48 if (controller)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
49 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
50 assert(baseLayerIndex_ == -1);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
51
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
52 baseLayerIndex_ = controller->GetScene().GetMaxDepth() + 100;
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
54 for (int i = 0; i < polylineLayerCount_; ++i)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
55 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
56 std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer());
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
57 controller->GetScene().SetLayer(baseLayerIndex_ + i, layer.release());
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
58 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
59
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
60 for (int i = 0; i < textLayerCount_; ++i)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
61 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
62 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer());
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
63 controller->GetScene().SetLayer(
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
64 baseLayerIndex_ + polylineLayerCount_ + i,
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
65 layer.release());
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
66 }
751
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
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 void LayerHolder::CreateLayersIfNeeded()
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 if (baseLayerIndex_ == -1)
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 CreateLayers();
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
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 bool LayerHolder::AreLayersCreated() const
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 return (baseLayerIndex_ != -1);
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 }
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80
949
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
81 void LayerHolder::DeleteLayersIfNeeded()
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
82 {
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
83 if (baseLayerIndex_ != -1)
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
84 DeleteLayers();
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
85 }
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
86
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 void LayerHolder::DeleteLayers()
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 {
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
89 boost::shared_ptr<ViewportController> controller = controllerW_.lock();
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
90
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
91 if (controller)
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 {
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
93 for (int i = 0; i < textLayerCount_ + polylineLayerCount_; ++i)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
94 {
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
95 ORTHANC_ASSERT(controller->GetScene().HasLayer(baseLayerIndex_ + i), "No layer");
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
96 controller->GetScene().DeleteLayer(baseLayerIndex_ + i);
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
97 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
98 baseLayerIndex_ = -1;
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99 }
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 }
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
101
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 PolylineSceneLayer* LayerHolder::GetPolylineLayer(int index /*= 0*/)
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 {
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
104 boost::shared_ptr<ViewportController> controller = controllerW_.lock();
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
105
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
106 if (controller)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
107 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
108 using namespace Orthanc;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
109 ORTHANC_ASSERT(baseLayerIndex_ != -1);
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
110 ORTHANC_ASSERT(controller->GetScene().HasLayer(GetPolylineLayerIndex(index)));
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
111 ISceneLayer* layer =
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
112 &(controller->GetScene().GetLayer(GetPolylineLayerIndex(index)));
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
113
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
114 PolylineSceneLayer* concreteLayer =
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
115 dynamic_cast<PolylineSceneLayer*>(layer);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
116
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
117 ORTHANC_ASSERT(concreteLayer != NULL);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
118 return concreteLayer;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
119 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
120 else
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
121 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
122 return NULL; // TODO
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
123 }
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124 }
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 TextSceneLayer* LayerHolder::GetTextLayer(int index /*= 0*/)
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 {
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
128 boost::shared_ptr<ViewportController> controller = controllerW_.lock();
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
129
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
130 if (controller)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
131 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
132 using namespace Orthanc;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
133 ORTHANC_ASSERT(baseLayerIndex_ != -1);
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
134 ORTHANC_ASSERT(controller->GetScene().HasLayer(GetTextLayerIndex(index)));
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
135 ISceneLayer* layer =
1213
86a8266b8888 moving the scene from IViewport to ViewportController
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1203
diff changeset
136 &(controller->GetScene().GetLayer(GetTextLayerIndex(index)));
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
137
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
138 TextSceneLayer* concreteLayer =
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
139 dynamic_cast<TextSceneLayer*>(layer);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
140
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
141 ORTHANC_ASSERT(concreteLayer != NULL);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
142 return concreteLayer;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
143 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
144 else
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
145 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
146 return NULL; // TODO
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 949
diff changeset
147 }
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 }
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150 int LayerHolder::GetPolylineLayerIndex(int index /*= 0*/)
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 {
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
152 using namespace Orthanc;
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
153 ORTHANC_ASSERT(index < polylineLayerCount_);
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 return baseLayerIndex_ + index;
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
155 }
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158 int LayerHolder::GetTextLayerIndex(int index /*= 0*/)
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159 {
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
160 using namespace Orthanc;
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 ORTHANC_ASSERT(index < textLayerCount_);
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163 // the text layers are placed right after the polyline layers
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164 // this means they are drawn ON TOP
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165 return baseLayerIndex_ + polylineLayerCount_ + index;
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
166 }
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
167 }