Mercurial > hg > orthanc-stone
annotate Samples/Sdl/FusionMprSdl.cpp @ 901:240359ab1651
Added Dot + magnitude + couple helpers in ScenePoint2D + Added ability to target several sets of 5-layer text packs stored in LayerHolder
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 17 Jul 2019 09:39:51 +0200 |
parents | 0c5201499af8 |
children | f9ae731fdc25 |
rev | line source |
---|---|
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include "FusionMprSdl.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
23 #include "../../Applications/Sdl/SdlOpenGLContext.h" |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 #include "../../Framework/StoneInitialization.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 #include "../../Framework/Scene2D/CairoCompositor.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 #include "../../Framework/Scene2D/OpenGLCompositor.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 #include "../../Framework/Scene2D/PanSceneTracker.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 #include "../../Framework/Scene2D/ZoomSceneTracker.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 #include "../../Framework/Scene2D/RotateSceneTracker.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
841
diff
changeset
|
34 #include "../../Framework/Scene2DViewport/UndoStack.h" |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 #include "../../Framework/Scene2DViewport/CreateLineMeasureTracker.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 #include "../../Framework/Scene2DViewport/CreateAngleMeasureTracker.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 #include "../../Framework/Scene2DViewport/IFlexiblePointerTracker.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 #include "../../Framework/Scene2DViewport/MeasureTool.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 #include "../../Framework/Scene2DViewport/PredeclaredTypes.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 #include "../../Framework/Volumes/VolumeSceneLayerSource.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 #include <Core/Images/Image.h> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 #include <Core/Images/ImageProcessing.h> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 #include <Core/Images/PngWriter.h> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 #include <Core/Logging.h> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 #include <Core/OrthancException.h> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 #include <boost/shared_ptr.hpp> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 #include <boost/weak_ptr.hpp> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 #include <boost/make_shared.hpp> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 #include <stdio.h> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 #include "../../Framework/Oracle/GetOrthancWebViewerJpegCommand.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 #include "../../Framework/Oracle/ThreadedOracle.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 #include "../../Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 #include "../../Framework/Loaders/OrthancMultiframeVolumeLoader.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 #include "../../Framework/Loaders/DicomStructureSetLoader.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 #include "../../Framework/Scene2D/GrayscaleStyleConfigurator.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 #include "../../Framework/Scene2D/LookupTableStyleConfigurator.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 #include "../../Framework/Volumes/DicomVolumeImageMPRSlicer.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 #include "Core/SystemToolbox.h" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 namespace OrthancStone |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 const char* FusionMprMeasureToolToString(size_t i) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 static const char* descs[] = { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 "FusionMprGuiTool_Rotate", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 "FusionMprGuiTool_Pan", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 "FusionMprGuiTool_Zoom", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 "FusionMprGuiTool_LineMeasure", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 "FusionMprGuiTool_CircleMeasure", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 "FusionMprGuiTool_AngleMeasure", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 "FusionMprGuiTool_EllipseMeasure", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 "FusionMprGuiTool_LAST" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 }; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 if (i >= FusionMprGuiTool_LAST) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Wrong tool index"); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 return descs[i]; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 |
893
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
85 Scene2D& FusionMprSdlApp::GetScene() |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 return controller_->GetScene(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 |
893
0c5201499af8
Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
90 const Scene2D& FusionMprSdlApp::GetScene() const |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 return controller_->GetScene(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 void FusionMprSdlApp::SelectNextTool() |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 currentTool_ = static_cast<FusionMprGuiTool>(currentTool_ + 1); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 if (currentTool_ == FusionMprGuiTool_LAST) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 currentTool_ = static_cast<FusionMprGuiTool>(0);; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 printf("Current tool is now: %s\n", FusionMprMeasureToolToString(currentTool_)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 void FusionMprSdlApp::DisplayInfoText() |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 // do not try to use stuff too early! |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 if (compositor_.get() == NULL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 return; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 std::stringstream msg; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 for (std::map<std::string, std::string>::const_iterator kv = infoTextMap_.begin(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
112 kv != infoTextMap_.end(); ++kv) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 msg << kv->first << " : " << kv->second << std::endl; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 std::string msgS = msg.str(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 TextSceneLayer* layerP = NULL; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 if (GetScene()->HasLayer(FIXED_INFOTEXT_LAYER_ZINDEX)) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 TextSceneLayer& layer = dynamic_cast<TextSceneLayer&>( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 GetScene()->GetLayer(FIXED_INFOTEXT_LAYER_ZINDEX)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 layerP = &layer; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 layerP = layer.get(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 layer->SetColor(0, 255, 0); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 layer->SetFontIndex(1); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 layer->SetBorder(20); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 layer->SetAnchor(BitmapAnchor_TopLeft); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 //layer->SetPosition(0,0); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 GetScene()->SetLayer(FIXED_INFOTEXT_LAYER_ZINDEX, layer.release()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
136 // position the fixed info text in the upper right corner |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 layerP->SetText(msgS.c_str()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 double cX = compositor_->GetCanvasWidth() * (-0.5); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 double cY = compositor_->GetCanvasHeight() * (-0.5); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 GetScene()->GetCanvasToSceneTransform().Apply(cX,cY); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 layerP->SetPosition(cX, cY); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 void FusionMprSdlApp::DisplayFloatingCtrlInfoText(const PointerEvent& e) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 ScenePoint2D p = e.GetMainPosition().Apply(GetScene()->GetCanvasToSceneTransform()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 char buf[128]; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 sprintf(buf, "S:(%0.02f,%0.02f) C:(%0.02f,%0.02f)", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 p.GetX(), p.GetY(), |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 e.GetMainPosition().GetX(), e.GetMainPosition().GetY()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
153 if (GetScene()->HasLayer(FLOATING_INFOTEXT_LAYER_ZINDEX)) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 TextSceneLayer& layer = |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 dynamic_cast<TextSceneLayer&>(GetScene()->GetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
157 layer.SetText(buf); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 layer.SetPosition(p.GetX(), p.GetY()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
159 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 layer->SetColor(0, 255, 0); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
164 layer->SetText(buf); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
165 layer->SetBorder(20); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
166 layer->SetAnchor(BitmapAnchor_BottomCenter); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 layer->SetPosition(p.GetX(), p.GetY()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 GetScene()->SetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX, layer.release()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 void FusionMprSdlApp::HideInfoText() |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 GetScene()->DeleteLayer(FLOATING_INFOTEXT_LAYER_ZINDEX); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 void FusionMprSdlApp::HandleApplicationEvent( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 const SDL_Event & event) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 DisplayInfoText(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 if (event.type == SDL_MOUSEMOTION) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 int scancodeCount = 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 if (activeTracker_.get() == NULL && |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 SDL_SCANCODE_LALT < scancodeCount && |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
189 keyboardState[SDL_SCANCODE_LALT]) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
190 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 // The "left-ctrl" key is down, while no tracker is present |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 // Let's display the info text |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 PointerEvent e; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 e.AddPosition(compositor_->GetPixelCenterCoordinates( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
195 event.button.x, event.button.y)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
196 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
197 DisplayFloatingCtrlInfoText(e); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
198 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
199 else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
200 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
201 HideInfoText(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
202 //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
203 if (activeTracker_.get() != NULL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
204 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 //LOG(TRACE) << "(activeTracker_.get() != NULL)"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
206 PointerEvent e; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
207 e.AddPosition(compositor_->GetPixelCenterCoordinates( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
208 event.button.x, event.button.y)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 //LOG(TRACE) << "event.button.x = " << event.button.x << " " << |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
211 // "event.button.y = " << event.button.y; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
212 LOG(TRACE) << "activeTracker_->PointerMove(e); " << |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
213 e.GetMainPosition().GetX() << " " << e.GetMainPosition().GetY(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
214 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
215 activeTracker_->PointerMove(e); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
216 if (!activeTracker_->IsAlive()) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
217 activeTracker_.reset(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
218 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
219 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
220 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
221 else if (event.type == SDL_MOUSEBUTTONUP) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
222 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
223 if (activeTracker_) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
224 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 PointerEvent e; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 e.AddPosition(compositor_->GetPixelCenterCoordinates(event.button.x, event.button.y)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 activeTracker_->PointerUp(e); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 if (!activeTracker_->IsAlive()) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
229 activeTracker_.reset(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
230 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
231 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
232 else if (event.type == SDL_MOUSEBUTTONDOWN) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
233 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
234 PointerEvent e; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
235 e.AddPosition(compositor_->GetPixelCenterCoordinates( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
236 event.button.x, event.button.y)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
237 if (activeTracker_) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
238 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
239 activeTracker_->PointerDown(e); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
240 if (!activeTracker_->IsAlive()) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
241 activeTracker_.reset(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
242 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
243 else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
244 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
245 // we ATTEMPT to create a tracker if need be |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
246 activeTracker_ = CreateSuitableTracker(event, e); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
247 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
248 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
249 else if (event.type == SDL_KEYDOWN && |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 event.key.repeat == 0 /* Ignore key bounce */) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
251 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
252 switch (event.key.keysym.sym) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
253 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
254 case SDLK_ESCAPE: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
255 if (activeTracker_) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
256 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
257 activeTracker_->Cancel(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
258 if (!activeTracker_->IsAlive()) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
259 activeTracker_.reset(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
260 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
261 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
262 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
263 case SDLK_t: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
264 if (!activeTracker_) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
265 SelectNextTool(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
266 else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
267 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
268 LOG(WARNING) << "You cannot change the active tool when an interaction" |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
269 " is taking place"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
270 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
271 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
272 case SDLK_s: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
273 controller_->FitContent(compositor_->GetCanvasWidth(), |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
274 compositor_->GetCanvasHeight()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
275 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
276 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
277 case SDLK_z: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
278 LOG(TRACE) << "SDLK_z has been pressed. event.key.keysym.mod == " << event.key.keysym.mod; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
279 if (event.key.keysym.mod & KMOD_CTRL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
280 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
281 if (controller_->CanUndo()) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
283 LOG(TRACE) << "Undoing..."; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
284 controller_->Undo(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
285 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
286 else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
287 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
288 LOG(WARNING) << "Nothing to undo!!!"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
289 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
290 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
291 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
292 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
293 case SDLK_y: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
294 LOG(TRACE) << "SDLK_y has been pressed. event.key.keysym.mod == " << event.key.keysym.mod; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
295 if (event.key.keysym.mod & KMOD_CTRL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
296 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
297 if (controller_->CanRedo()) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
298 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
299 LOG(TRACE) << "Redoing..."; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
300 controller_->Redo(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
301 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
302 else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
303 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
304 LOG(WARNING) << "Nothing to redo!!!"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
305 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
306 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
307 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
308 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
309 case SDLK_c: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
310 TakeScreenshot( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
311 "screenshot.png", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
312 compositor_->GetCanvasWidth(), |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
313 compositor_->GetCanvasHeight()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
314 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
315 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
316 default: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
317 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
318 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
319 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
320 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
321 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
322 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
323 void FusionMprSdlApp::OnSceneTransformChanged( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
324 const ViewportController::SceneTransformChanged& message) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
325 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
326 DisplayInfoText(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
327 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
328 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
329 boost::shared_ptr<IFlexiblePointerTracker> FusionMprSdlApp::CreateSuitableTracker( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
330 const SDL_Event & event, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
331 const PointerEvent & e) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
332 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
333 using namespace Orthanc; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
334 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
335 switch (event.button.button) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
336 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
337 case SDL_BUTTON_MIDDLE: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
338 return boost::shared_ptr<IFlexiblePointerTracker>(new PanSceneTracker |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
339 (controller_, e)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
340 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
341 case SDL_BUTTON_RIGHT: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
342 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
343 (controller_, e, compositor_->GetCanvasHeight())); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
344 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
345 case SDL_BUTTON_LEFT: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
346 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
347 //LOG(TRACE) << "CreateSuitableTracker: case SDL_BUTTON_LEFT:"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
348 // TODO: we need to iterate on the set of measuring tool and perform |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
349 // a hit test to check if a tracker needs to be created for edition. |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
350 // Otherwise, depending upon the active tool, we might want to create |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
351 // a "measuring tool creation" tracker |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
352 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
353 // TODO: if there are conflicts, we should prefer a tracker that |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
354 // pertains to the type of measuring tool currently selected (TBD?) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
355 boost::shared_ptr<IFlexiblePointerTracker> hitTestTracker = TrackerHitTest(e); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
356 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
357 if (hitTestTracker != NULL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
358 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
359 //LOG(TRACE) << "hitTestTracker != NULL"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
360 return hitTestTracker; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
361 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
362 else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
363 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
364 switch (currentTool_) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
365 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
366 case FusionMprGuiTool_Rotate: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
367 //LOG(TRACE) << "Creating RotateSceneTracker"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
368 return boost::shared_ptr<IFlexiblePointerTracker>(new RotateSceneTracker( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
369 controller_, e)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
370 case FusionMprGuiTool_Pan: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
371 return boost::shared_ptr<IFlexiblePointerTracker>(new PanSceneTracker( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
372 controller_, e)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
373 case FusionMprGuiTool_Zoom: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
374 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
375 controller_, e, compositor_->GetCanvasHeight())); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
376 //case GuiTool_AngleMeasure: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
377 // return new AngleMeasureTracker(GetScene(), e); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
378 //case GuiTool_CircleMeasure: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
379 // return new CircleMeasureTracker(GetScene(), e); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
380 //case GuiTool_EllipseMeasure: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
381 // return new EllipseMeasureTracker(GetScene(), e); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
382 case FusionMprGuiTool_LineMeasure: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
383 return boost::shared_ptr<IFlexiblePointerTracker>(new CreateLineMeasureTracker( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
384 IObserver::GetBroker(), controller_, e)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
385 case FusionMprGuiTool_AngleMeasure: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
386 return boost::shared_ptr<IFlexiblePointerTracker>(new CreateAngleMeasureTracker( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
387 IObserver::GetBroker(), controller_, e)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
388 case FusionMprGuiTool_CircleMeasure: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
389 LOG(ERROR) << "Not implemented yet!"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
390 return boost::shared_ptr<IFlexiblePointerTracker>(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
391 case FusionMprGuiTool_EllipseMeasure: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
392 LOG(ERROR) << "Not implemented yet!"; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
393 return boost::shared_ptr<IFlexiblePointerTracker>(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
394 default: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
395 throw OrthancException(ErrorCode_InternalError, "Wrong tool!"); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
396 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
397 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
398 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
399 default: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
400 return boost::shared_ptr<IFlexiblePointerTracker>(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
401 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
402 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
403 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
404 |
828 | 405 FusionMprSdlApp::FusionMprSdlApp(MessageBroker& broker) |
406 : IObserver(broker) | |
407 , broker_(broker) | |
408 , oracleObservable_(broker) | |
409 , oracle_(*this) | |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
410 , currentTool_(FusionMprGuiTool_Rotate) |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
841
diff
changeset
|
411 , undoStack_(new UndoStack) |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
412 { |
828 | 413 //oracleObservable.RegisterObserverCallback |
414 //(new Callable | |
415 // <FusionMprSdlApp, SleepOracleCommand::TimeoutMessage>(*this, &FusionMprSdlApp::Handle)); | |
416 | |
417 //oracleObservable.RegisterObserverCallback | |
418 //(new Callable | |
419 // <Toto, GetOrthancImageCommand::SuccessMessage>(*this, &FusionMprSdlApp::Handle)); | |
420 | |
421 //oracleObservable.RegisterObserverCallback | |
422 //(new Callable | |
423 // <FusionMprSdlApp, GetOrthancWebViewerJpegCommand::SuccessMessage>(*this, &ToFusionMprSdlAppto::Handle)); | |
424 | |
425 oracleObservable_.RegisterObserverCallback | |
426 (new Callable | |
427 <FusionMprSdlApp, OracleCommandExceptionMessage>(*this, &FusionMprSdlApp::Handle)); | |
428 | |
429 controller_ = boost::shared_ptr<ViewportController>( | |
858
e3c56d4f863f
GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents:
841
diff
changeset
|
430 new ViewportController(undoStack_, broker_)); |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
431 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
432 controller_->RegisterObserverCallback( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
433 new Callable<FusionMprSdlApp, ViewportController::SceneTransformChanged> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
434 (*this, &FusionMprSdlApp::OnSceneTransformChanged)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
435 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
436 TEXTURE_2x2_1_ZINDEX = 1; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
437 TEXTURE_1x1_ZINDEX = 2; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
438 TEXTURE_2x2_2_ZINDEX = 3; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
439 LINESET_1_ZINDEX = 4; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
440 LINESET_2_ZINDEX = 5; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
441 FLOATING_INFOTEXT_LAYER_ZINDEX = 6; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
442 FIXED_INFOTEXT_LAYER_ZINDEX = 7; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
443 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
444 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
445 void FusionMprSdlApp::PrepareScene() |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
446 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
447 // Texture of 2x2 size |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
448 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
449 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 2, 2, false); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
450 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
451 uint8_t* p = reinterpret_cast<uint8_t*>(i.GetRow(0)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
452 p[0] = 255; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
453 p[1] = 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
454 p[2] = 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
455 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
456 p[3] = 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
457 p[4] = 255; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
458 p[5] = 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
459 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
460 p = reinterpret_cast<uint8_t*>(i.GetRow(1)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
461 p[0] = 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
462 p[1] = 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
463 p[2] = 255; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
464 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
465 p[3] = 255; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
466 p[4] = 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
467 p[5] = 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
468 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
469 GetScene()->SetLayer(TEXTURE_2x2_1_ZINDEX, new ColorTextureSceneLayer(i)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
470 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
471 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
472 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
473 void FusionMprSdlApp::DisableTracker() |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
474 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
475 if (activeTracker_) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
476 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
477 activeTracker_->Cancel(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
478 activeTracker_.reset(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
479 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
480 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
481 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
482 void FusionMprSdlApp::TakeScreenshot(const std::string& target, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
483 unsigned int canvasWidth, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
484 unsigned int canvasHeight) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
485 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
486 CairoCompositor compositor(*GetScene(), canvasWidth, canvasHeight); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
487 compositor.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, FONT_SIZE_0, Orthanc::Encoding_Latin1); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
488 compositor.Refresh(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
489 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
490 Orthanc::ImageAccessor canvas; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
491 compositor.GetCanvas().GetReadOnlyAccessor(canvas); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
492 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
493 Orthanc::Image png(Orthanc::PixelFormat_RGB24, canvas.GetWidth(), canvas.GetHeight(), false); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
494 Orthanc::ImageProcessing::Convert(png, canvas); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
495 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
496 Orthanc::PngWriter writer; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
497 writer.WriteToFile(target, png); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
498 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
499 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
500 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
501 boost::shared_ptr<IFlexiblePointerTracker> FusionMprSdlApp::TrackerHitTest(const PointerEvent & e) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
502 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
503 // std::vector<boost::shared_ptr<MeasureTool>> measureTools_; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
504 return boost::shared_ptr<IFlexiblePointerTracker>(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
505 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
506 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
507 static void GLAPIENTRY |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
508 OpenGLMessageCallback(GLenum source, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
509 GLenum type, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
510 GLuint id, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
511 GLenum severity, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
512 GLsizei length, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
513 const GLchar* message, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
514 const void* userParam) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
515 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
516 if (severity != GL_DEBUG_SEVERITY_NOTIFICATION) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
517 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
518 fprintf(stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n", |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
519 (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""), |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
520 type, severity, message); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
521 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
522 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
523 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
524 static bool g_stopApplication = false; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
525 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
526 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
527 void FusionMprSdlApp::Handle(const DicomVolumeImage::GeometryReadyMessage& message) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
528 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
529 printf("Geometry ready\n"); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
530 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
531 //plane_ = message.GetOrigin().GetGeometry().GetSagittalGeometry(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
532 //plane_ = message.GetOrigin().GetGeometry().GetAxialGeometry(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
533 plane_ = message.GetOrigin().GetGeometry().GetCoronalGeometry(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
534 plane_.SetOrigin(message.GetOrigin().GetGeometry().GetCoordinates(0.5f, 0.5f, 0.5f)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
535 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
536 //Refresh(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
537 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
538 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
539 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
540 void FusionMprSdlApp::Handle(const OracleCommandExceptionMessage& message) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
541 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
542 printf("EXCEPTION: [%s] on command type %d\n", message.GetException().What(), message.GetCommand().GetType()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
543 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
544 switch (message.GetCommand().GetType()) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
545 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
546 case IOracleCommand::Type_GetOrthancWebViewerJpeg: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
547 printf("URI: [%s]\n", dynamic_cast<const GetOrthancWebViewerJpegCommand&> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
548 (message.GetCommand()).GetUri().c_str()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
549 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
550 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
551 default: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
552 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
553 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
554 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
555 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
556 void FusionMprSdlApp::SetVolume1(int depth, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
557 const boost::shared_ptr<OrthancStone::IVolumeSlicer>& volume, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
558 OrthancStone::ILayerStyleConfigurator* style) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
559 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
560 source1_.reset(new OrthancStone::VolumeSceneLayerSource(*controller_->GetScene(), depth, volume)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
561 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
562 if (style != NULL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
563 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
564 source1_->SetConfigurator(style); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
565 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
566 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
567 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
568 void FusionMprSdlApp::SetVolume2(int depth, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
569 const boost::shared_ptr<OrthancStone::IVolumeSlicer>& volume, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
570 OrthancStone::ILayerStyleConfigurator* style) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
571 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
572 source2_.reset(new OrthancStone::VolumeSceneLayerSource(*controller_->GetScene(), depth, volume)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
573 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
574 if (style != NULL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
575 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
576 source2_->SetConfigurator(style); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
577 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
578 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
579 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
580 void FusionMprSdlApp::SetStructureSet(int depth, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
581 const boost::shared_ptr<OrthancStone::DicomStructureSetLoader>& volume) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
582 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
583 source3_.reset(new OrthancStone::VolumeSceneLayerSource(*controller_->GetScene(), depth, volume)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
584 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
585 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
586 void FusionMprSdlApp::Run() |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
587 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
588 // False means we do NOT let Windows treat this as a legacy application |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
589 // that needs to be scaled |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
590 SdlOpenGLContext window("Hello", 1024, 1024, false); |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
591 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
592 controller_->FitContent(window.GetCanvasWidth(), window.GetCanvasHeight()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
593 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
594 glEnable(GL_DEBUG_OUTPUT); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
595 glDebugMessageCallback(OpenGLMessageCallback, 0); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
596 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
597 compositor_.reset(new OpenGLCompositor(window, *GetScene())); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
598 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
599 compositor_->SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
600 FONT_SIZE_0, Orthanc::Encoding_Latin1); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
601 compositor_->SetFont(1, Orthanc::EmbeddedResources::UBUNTU_FONT, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
602 FONT_SIZE_1, Orthanc::Encoding_Latin1); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
603 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
604 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
605 //////// from loader |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
606 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
607 Orthanc::WebServiceParameters p; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
608 //p.SetUrl("http://localhost:8043/"); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
609 p.SetCredentials("orthanc", "orthanc"); |
828 | 610 oracle_.SetOrthancParameters(p); |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
611 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
612 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
613 //////// from Run |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
614 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
615 boost::shared_ptr<DicomVolumeImage> ct(new DicomVolumeImage); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
616 boost::shared_ptr<DicomVolumeImage> dose(new DicomVolumeImage); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
617 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
618 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
619 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> ctLoader; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
620 boost::shared_ptr<OrthancMultiframeVolumeLoader> doseLoader; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
621 boost::shared_ptr<DicomStructureSetLoader> rtstructLoader; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
622 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
623 { |
828 | 624 ctLoader.reset(new OrthancSeriesVolumeProgressiveLoader(ct, oracle_, oracleObservable_)); |
625 doseLoader.reset(new OrthancMultiframeVolumeLoader(dose, oracle_, oracleObservable_)); | |
626 rtstructLoader.reset(new DicomStructureSetLoader(oracle_, oracleObservable_)); | |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
627 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
628 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
629 //toto->SetReferenceLoader(*ctLoader); |
828 | 630 //doseLoader->RegisterObserverCallback |
631 //(new Callable | |
632 // <FusionMprSdlApp, DicomVolumeImage::GeometryReadyMessage>(*this, &FusionMprSdlApp::Handle)); | |
633 ctLoader->RegisterObserverCallback | |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
634 (new Callable |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
635 <FusionMprSdlApp, DicomVolumeImage::GeometryReadyMessage>(*this, &FusionMprSdlApp::Handle)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
636 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
637 this->SetVolume1(0, ctLoader, new GrayscaleStyleConfigurator); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
638 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
639 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
640 std::auto_ptr<LookupTableStyleConfigurator> config(new LookupTableStyleConfigurator); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
641 config->SetLookupTable(Orthanc::EmbeddedResources::COLORMAP_HOT); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
642 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
643 boost::shared_ptr<DicomVolumeImageMPRSlicer> tmp(new DicomVolumeImageMPRSlicer(dose)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
644 this->SetVolume2(1, tmp, config.release()); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
645 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
646 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
647 this->SetStructureSet(2, rtstructLoader); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
648 |
828 | 649 #if 1 |
839
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
650 /* |
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
651 BGO data |
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
652 http://localhost:8042/twiga-orthanc-viewer-demo/twiga-orthanc-viewer-demo.html?ct-series=a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa |
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
653 & |
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
654 dose-instance=830a69ff-8e4b5ee3-b7f966c8-bccc20fb-d322dceb |
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
655 & |
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
656 struct-instance=54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9 |
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
657 */ |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
658 ctLoader->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"); // CT |
839
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
659 doseLoader->LoadInstance("830a69ff-8e4b5ee3-b7f966c8-bccc20fb-d322dceb"); // RT-DOSE |
c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
660 rtstructLoader->LoadInstance("54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9"); // RT-STRUCT |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
661 #else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
662 //ctLoader->LoadSeries("cb3ea4d1-d08f3856-ad7b6314-74d88d77-60b05618"); // CT |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
663 //doseLoader->LoadInstance("41029085-71718346-811efac4-420e2c15-d39f99b6"); // RT-DOSE |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
664 //rtstructLoader->LoadInstance("83d9c0c3-913a7fee-610097d7-cbf0522d-fd75bee6"); // RT-STRUCT |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
665 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
666 // 2017-05-16 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
667 ctLoader->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"); // CT |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
668 doseLoader->LoadInstance("eac822ef-a395f94e-e8121fe0-8411fef8-1f7bffad"); // RT-DOSE |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
669 rtstructLoader->LoadInstance("54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9"); // RT-STRUCT |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
670 #endif |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
671 |
828 | 672 oracle_.Start(); |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
673 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
674 //// END from loader |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
675 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
676 while (!g_stopApplication) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
677 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
678 compositor_->Refresh(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
679 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
680 //////// from loader |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
681 if (source1_.get() != NULL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
682 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
683 source1_->Update(plane_); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
684 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
685 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
686 if (source2_.get() != NULL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
687 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
688 source2_->Update(plane_); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
689 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
690 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
691 if (source3_.get() != NULL) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
692 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
693 source3_->Update(plane_); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
694 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
695 //// END from loader |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
696 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
697 SDL_Event event; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
698 while (!g_stopApplication && SDL_PollEvent(&event)) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
699 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
700 if (event.type == SDL_QUIT) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
701 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
702 g_stopApplication = true; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
703 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
704 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
705 else if (event.type == SDL_WINDOWEVENT && |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
706 event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
707 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
708 DisableTracker(); // was: tracker.reset(NULL); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
709 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
710 else if (event.type == SDL_KEYDOWN && |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
711 event.key.repeat == 0 /* Ignore key bounce */) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
712 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
713 switch (event.key.keysym.sym) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
714 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
715 case SDLK_f: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
716 window.GetWindow().ToggleMaximize(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
717 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
718 |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
839
diff
changeset
|
719 case SDLK_s: |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
839
diff
changeset
|
720 controller_->FitContent( |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
839
diff
changeset
|
721 window.GetCanvasWidth(), window.GetCanvasHeight()); |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
839
diff
changeset
|
722 break; |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
839
diff
changeset
|
723 |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
724 case SDLK_q: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
725 g_stopApplication = true; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
726 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
727 default: |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
728 break; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
729 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
730 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
731 HandleApplicationEvent(event); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
732 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
733 SDL_Delay(1); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
734 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
735 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
736 // the following is paramount because the compositor holds a reference |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
737 // to the scene and we do not want this reference to become dangling |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
738 compositor_.reset(NULL); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
739 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
740 //// from loader |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
741 |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
839
diff
changeset
|
742 //Orthanc::SystemToolbox::ServerBarrier(); |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
743 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
744 /** |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
745 * WARNING => The oracle must be stopped BEFORE the objects using |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
746 * it are destroyed!!! This forces to wait for the completion of |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
747 * the running callback methods. Otherwise, the callbacks methods |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
748 * might still be running while their parent object is destroyed, |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
749 * resulting in crashes. This is very visible if adding a sleep(), |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
750 * as in (*). |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
751 **/ |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
752 |
828 | 753 oracle_.Stop(); |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
754 //// END from loader |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
755 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
756 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
757 void FusionMprSdlApp::SetInfoDisplayMessage( |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
758 std::string key, std::string value) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
759 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
760 if (value == "") |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
761 infoTextMap_.erase(key); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
762 else |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
763 infoTextMap_[key] = value; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
764 DisplayInfoText(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
765 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
766 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
767 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
768 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
769 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
770 boost::weak_ptr<OrthancStone::FusionMprSdlApp> g_app; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
771 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
772 void FusionMprSdl_SetInfoDisplayMessage(std::string key, std::string value) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
773 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
774 boost::shared_ptr<OrthancStone::FusionMprSdlApp> app = g_app.lock(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
775 if (app) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
776 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
777 app->SetInfoDisplayMessage(key, value); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
778 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
779 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
780 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
781 /** |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
782 * IMPORTANT: The full arguments to "main()" are needed for SDL on |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
783 * Windows. Otherwise, one gets the linking error "undefined reference |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
784 * to `SDL_main'". https://wiki.libsdl.org/FAQWindows |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
785 **/ |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
786 int main(int argc, char* argv[]) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
787 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
788 using namespace OrthancStone; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
789 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
790 StoneInitialize(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
791 Orthanc::Logging::EnableInfoLevel(true); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
792 // Orthanc::Logging::EnableTraceLevel(true); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
793 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
794 try |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
795 { |
828 | 796 OrthancStone::MessageBroker broker; |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
797 boost::shared_ptr<FusionMprSdlApp> app(new FusionMprSdlApp(broker)); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
798 g_app = app; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
799 app->PrepareScene(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
800 app->Run(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
801 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
802 catch (Orthanc::OrthancException& e) |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
803 { |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
804 LOG(ERROR) << "EXCEPTION: " << e.What(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
805 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
806 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
807 StoneFinalize(); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
808 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
809 return 0; |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
810 } |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
811 |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
812 |