comparison Applications/Samples/SingleFrameApplication.h @ 726:4f2416d519b4

moving layers, widgets and loaders to Deprecated namespace
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 May 2019 11:43:25 +0200
parents 6af3099ed8da
children c35e98d22764
comparison
equal deleted inserted replaced
714:d2c0e347ddc2 726:4f2416d519b4
39 class SingleFrameApplication : 39 class SingleFrameApplication :
40 public SampleSingleCanvasApplicationBase, 40 public SampleSingleCanvasApplicationBase,
41 public IObserver 41 public IObserver
42 { 42 {
43 private: 43 private:
44 class Interactor : public IWorldSceneInteractor 44 class Interactor : public Deprecated::IWorldSceneInteractor
45 { 45 {
46 private: 46 private:
47 SingleFrameApplication& application_; 47 SingleFrameApplication& application_;
48 48
49 public: 49 public:
50 Interactor(SingleFrameApplication& application) : 50 Interactor(SingleFrameApplication& application) :
51 application_(application) 51 application_(application)
52 { 52 {
53 } 53 }
54 54
55 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget, 55 virtual Deprecated::IWorldSceneMouseTracker* CreateMouseTracker(Deprecated::WorldSceneWidget& widget,
56 const ViewportGeometry& view, 56 const Deprecated::ViewportGeometry& view,
57 MouseButton button, 57 MouseButton button,
58 KeyboardModifiers modifiers, 58 KeyboardModifiers modifiers,
59 int viewportX, 59 int viewportX,
60 int viewportY, 60 int viewportY,
61 double x, 61 double x,
62 double y, 62 double y,
63 IStatusBar* statusBar, 63 Deprecated::IStatusBar* statusBar,
64 const std::vector<Touch>& displayTouches) 64 const std::vector<Deprecated::Touch>& displayTouches)
65 { 65 {
66 return NULL; 66 return NULL;
67 } 67 }
68 68
69 virtual void MouseOver(CairoContext& context, 69 virtual void MouseOver(CairoContext& context,
70 WorldSceneWidget& widget, 70 Deprecated::WorldSceneWidget& widget,
71 const ViewportGeometry& view, 71 const Deprecated::ViewportGeometry& view,
72 double x, 72 double x,
73 double y, 73 double y,
74 IStatusBar* statusBar) 74 Deprecated::IStatusBar* statusBar)
75 { 75 {
76 if (statusBar != NULL) 76 if (statusBar != NULL)
77 { 77 {
78 Vector p = dynamic_cast<SliceViewerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y); 78 Vector p = dynamic_cast<Deprecated::SliceViewerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y);
79 79
80 char buf[64]; 80 char buf[64];
81 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)", 81 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)",
82 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0); 82 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0);
83 statusBar->SetMessage(buf); 83 statusBar->SetMessage(buf);
84 } 84 }
85 } 85 }
86 86
87 virtual void MouseWheel(WorldSceneWidget& widget, 87 virtual void MouseWheel(Deprecated::WorldSceneWidget& widget,
88 MouseWheelDirection direction, 88 MouseWheelDirection direction,
89 KeyboardModifiers modifiers, 89 KeyboardModifiers modifiers,
90 IStatusBar* statusBar) 90 Deprecated::IStatusBar* statusBar)
91 { 91 {
92 int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1); 92 int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1);
93 93
94 switch (direction) 94 switch (direction)
95 { 95 {
104 default: 104 default:
105 break; 105 break;
106 } 106 }
107 } 107 }
108 108
109 virtual void KeyPressed(WorldSceneWidget& widget, 109 virtual void KeyPressed(Deprecated::WorldSceneWidget& widget,
110 KeyboardKeys key, 110 KeyboardKeys key,
111 char keyChar, 111 char keyChar,
112 KeyboardModifiers modifiers, 112 KeyboardModifiers modifiers,
113 IStatusBar* statusBar) 113 Deprecated::IStatusBar* statusBar)
114 { 114 {
115 switch (keyChar) 115 switch (keyChar)
116 { 116 {
117 case 's': 117 case 's':
118 widget.FitContent(); 118 widget.FitContent();
147 } 147 }
148 } 148 }
149 } 149 }
150 150
151 151
152 SliceViewerWidget& GetMainWidget() 152 Deprecated::SliceViewerWidget& GetMainWidget()
153 { 153 {
154 return *dynamic_cast<SliceViewerWidget*>(mainWidget_); 154 return *dynamic_cast<Deprecated::SliceViewerWidget*>(mainWidget_);
155 } 155 }
156 156
157 157
158 void SetSlice(size_t index) 158 void SetSlice(size_t index)
159 { 159 {
182 #endif 182 #endif
183 } 183 }
184 } 184 }
185 185
186 186
187 void OnMainWidgetGeometryReady(const IVolumeSlicer::GeometryReadyMessage& message) 187 void OnMainWidgetGeometryReady(const Deprecated::IVolumeSlicer::GeometryReadyMessage& message)
188 { 188 {
189 // Once the geometry of the series is downloaded from Orthanc, 189 // Once the geometry of the series is downloaded from Orthanc,
190 // display its middle slice, and adapt the viewport to fit this 190 // display its middle slice, and adapt the viewport to fit this
191 // slice 191 // slice
192 if (source_ == &message.GetOrigin()) 192 if (source_ == &message.GetOrigin())
196 196
197 GetMainWidget().FitContent(); 197 GetMainWidget().FitContent();
198 } 198 }
199 199
200 std::auto_ptr<Interactor> mainWidgetInteractor_; 200 std::auto_ptr<Interactor> mainWidgetInteractor_;
201 const DicomSeriesVolumeSlicer* source_; 201 const Deprecated::DicomSeriesVolumeSlicer* source_;
202 unsigned int slice_; 202 unsigned int slice_;
203 203
204 public: 204 public:
205 SingleFrameApplication(MessageBroker& broker) : 205 SingleFrameApplication(MessageBroker& broker) :
206 IObserver(broker), 206 IObserver(broker),
223 223
224 options.add(generic); 224 options.add(generic);
225 } 225 }
226 226
227 virtual void Initialize(StoneApplicationContext* context, 227 virtual void Initialize(StoneApplicationContext* context,
228 IStatusBar& statusBar, 228 Deprecated::IStatusBar& statusBar,
229 const boost::program_options::variables_map& parameters) 229 const boost::program_options::variables_map& parameters)
230 { 230 {
231 using namespace OrthancStone; 231 using namespace OrthancStone;
232 232
233 context_ = context; 233 context_ = context;
241 } 241 }
242 242
243 std::string instance = parameters["instance"].as<std::string>(); 243 std::string instance = parameters["instance"].as<std::string>();
244 int frame = parameters["frame"].as<unsigned int>(); 244 int frame = parameters["frame"].as<unsigned int>();
245 245
246 mainWidget_ = new SliceViewerWidget(GetBroker(), "main-widget"); 246 mainWidget_ = new Deprecated::SliceViewerWidget(GetBroker(), "main-widget");
247 247
248 std::auto_ptr<DicomSeriesVolumeSlicer> layer(new DicomSeriesVolumeSlicer(GetBroker(), context->GetOrthancApiClient())); 248 std::auto_ptr<Deprecated::DicomSeriesVolumeSlicer> layer(new Deprecated::DicomSeriesVolumeSlicer(GetBroker(), context->GetOrthancApiClient()));
249 source_ = layer.get(); 249 source_ = layer.get();
250 layer->LoadFrame(instance, frame); 250 layer->LoadFrame(instance, frame);
251 layer->RegisterObserverCallback(new Callable<SingleFrameApplication, IVolumeSlicer::GeometryReadyMessage>(*this, &SingleFrameApplication::OnMainWidgetGeometryReady)); 251 layer->RegisterObserverCallback(new Callable<SingleFrameApplication, Deprecated::IVolumeSlicer::GeometryReadyMessage>(*this, &SingleFrameApplication::OnMainWidgetGeometryReady));
252 GetMainWidget().AddLayer(layer.release()); 252 GetMainWidget().AddLayer(layer.release());
253 253
254 RenderStyle s; 254 Deprecated::RenderStyle s;
255 255
256 if (parameters["smooth"].as<bool>()) 256 if (parameters["smooth"].as<bool>())
257 { 257 {
258 s.interpolation_ = ImageInterpolation_Bilinear; 258 s.interpolation_ = ImageInterpolation_Bilinear;
259 } 259 }