annotate Framework/Layers/DicomStructureSetRendererFactory.cpp @ 123:ed0003f6102c wasm

dynamic loading of rt-struct renderers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 07 Oct 2017 13:11:12 +0200
parents e3433dabfb8d
children 44fc253d4876
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
40
7207a407bcd8 shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 16
diff changeset
5 * Copyright (C) 2017 Osimis, Belgium
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
10 * the License, or (at your option) any later version.
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
15 * Affero General Public License for more details.
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
16 *
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "DicomStructureSetRendererFactory.h"
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
123
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
24 #include "../Toolbox/MessagingToolbox.h"
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
25
113
2eca030792aa using the Orthanc Framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
26 #include <Core/OrthancException.h>
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 namespace OrthancStone
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 class DicomStructureSetRendererFactory::Renderer : public ILayerRenderer
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 private:
122
e3433dabfb8d refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 121
diff changeset
33 DicomStructureSet& structureSet_;
e3433dabfb8d refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 121
diff changeset
34 CoordinateSystem3D slice_;
e3433dabfb8d refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 121
diff changeset
35 bool visible_;
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 public:
122
e3433dabfb8d refactoring DicomStructureSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 121
diff changeset
38 Renderer(DicomStructureSet& structureSet,
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
39 const CoordinateSystem3D& slice) :
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 structureSet_(structureSet),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 slice_(slice),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 visible_(true)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 virtual bool RenderLayer(CairoContext& context,
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
47 const ViewportGeometry& view)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 if (visible_)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 cairo_set_line_width(context.GetObject(), 3.0f / view.GetZoom());
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 structureSet_.Render(context, slice_);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 return true;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
58 virtual const CoordinateSystem3D& GetLayerSlice()
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
59 {
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
60 return slice_;
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
61 }
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
62
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 virtual void SetLayerStyle(const RenderStyle& style)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 visible_ = style.visible_;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 virtual bool IsFullQuality()
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 return true;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 };
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
123
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
75 class DicomStructureSetRendererFactory::Operation : public Orthanc::IDynamicObject
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
76 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
77 public:
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
78 enum Type
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
79 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
80 Type_LoadStructureSet,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
81 Type_LookupSopInstanceUid,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
82 Type_LoadReferencedSlice
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
83 };
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
84
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
85 private:
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
86 Type type_;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
87 std::string value_;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
88
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
89 public:
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
90 Operation(Type type,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
91 const std::string& value) :
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
92 type_(type),
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
93 value_(value)
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
94 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
95 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
96
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
97 Type GetType() const
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
98 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
99 return type_;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
100 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
101
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
102 const std::string& GetIdentifier() const
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
103 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
104 return value_;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
105 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
106 };
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
107
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
108
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
109 void DicomStructureSetRendererFactory::NotifyError(const std::string& uri,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
110 Orthanc::IDynamicObject* payload)
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
111 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
112 // TODO
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
113 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
114
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
115
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
116 void DicomStructureSetRendererFactory::NotifySuccess(const std::string& uri,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
117 const void* answer,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
118 size_t answerSize,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
119 Orthanc::IDynamicObject* payload)
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
120 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
121 std::auto_ptr<Operation> op(dynamic_cast<Operation*>(payload));
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
122
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
123 switch (op->GetType())
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
124 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
125 case Operation::Type_LoadStructureSet:
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
126 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
127 OrthancPlugins::FullOrthancDataset dataset(answer, answerSize);
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
128 structureSet_.reset(new DicomStructureSet(dataset));
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
129
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
130 std::set<std::string> instances;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
131 structureSet_->GetReferencedInstances(instances);
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
132
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
133 for (std::set<std::string>::const_iterator it = instances.begin();
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
134 it != instances.end(); ++it)
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
135 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
136 orthanc_.SchedulePostRequest(*this, "/tools/lookup", *it,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
137 new Operation(Operation::Type_LookupSopInstanceUid, *it));
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
138 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
139
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
140 break;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
141 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
142
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
143 case Operation::Type_LookupSopInstanceUid:
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
144 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
145 Json::Value lookup;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
146
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
147 if (MessagingToolbox::ParseJson(lookup, answer, answerSize))
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
148 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
149 if (lookup.type() != Json::arrayValue ||
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
150 lookup.size() != 1 ||
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
151 !lookup[0].isMember("Type") ||
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
152 !lookup[0].isMember("Path") ||
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
153 lookup[0]["Type"].type() != Json::stringValue ||
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
154 lookup[0]["ID"].type() != Json::stringValue ||
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
155 lookup[0]["Type"].asString() != "Instance")
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
156 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
157 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
158 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
159
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
160 const std::string& instance = lookup[0]["ID"].asString();
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
161 orthanc_.ScheduleGetRequest(*this, "/instances/" + instance + "/tags",
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
162 new Operation(Operation::Type_LoadReferencedSlice, instance));
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
163 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
164 else
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
165 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
166 // TODO
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
167 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
168
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
169 break;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
170 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
171
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
172 case Operation::Type_LoadReferencedSlice:
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
173 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
174 OrthancPlugins::FullOrthancDataset dataset(answer, answerSize);
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
175
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
176 Orthanc::DicomMap slice;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
177 MessagingToolbox::ConvertDataset(slice, dataset);
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
178 structureSet_->AddReferencedSlice(slice);
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
179
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
180 LayerSourceBase::NotifyContentChange();
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
181
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
182 break;
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
183 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
184
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
185 default:
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
186 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
187 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
188 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
189
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
190
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
191 DicomStructureSetRendererFactory::DicomStructureSetRendererFactory(IWebService& orthanc,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
192 const std::string& instance) :
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
193 orthanc_(orthanc)
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
194 {
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
195 const std::string uri = "/instances/" + instance + "/tags?ignore-length=3006-0050";
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
196 orthanc_.ScheduleGetRequest(*this, uri, new Operation(Operation::Type_LoadStructureSet, instance));
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
197 }
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
198
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
199
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 113
diff changeset
200 void DicomStructureSetRendererFactory::ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 bool isOpposite;
123
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
203 if (structureSet_.get() != NULL &&
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
204 GeometryToolbox::IsParallelOrOpposite(isOpposite,
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
205 viewportSlice.GetNormal(),
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
206 structureSet_->GetNormal()))
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
123
ed0003f6102c dynamic loading of rt-struct renderers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
208 NotifyLayerReady(new Renderer(*structureSet_, viewportSlice), viewportSlice, false);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 }