annotate Samples/Shared/RadiographyEditorApp.cpp @ 848:80829436ce0c am-mainline

starting to re-implement radiography editor with latest framework
author Alain Mazy <alain@mazy.be>
date Thu, 13 Jun 2019 16:47:02 +0200
parents
children 56e4e9281076
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
1 /**
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
2 * Stone of Orthanc
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
6 *
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
10 * the License, or (at your option) any later version.
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
11 *
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
15 * Affero General Public License for more details.
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
16 *
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
19 **/
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
20
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
21 #include "RadiographyEditorApp.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
22
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
23 #include "../../Applications/Sdl/SdlOpenGLWindow.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
24
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
25 #include "../../Framework/Scene2D/CairoCompositor.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
26 #include "../../Framework/Scene2D/OpenGLCompositor.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
27 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
28 #include "../../Framework/Scene2D/PanSceneTracker.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
29 #include "../../Framework/Scene2D/RotateSceneTracker.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
30 #include "../../Framework/Scene2D/Scene2D.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
31 #include "../../Framework/Scene2D/ZoomSceneTracker.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
32 #include "../../Framework/Scene2DViewport/CreateAngleMeasureTracker.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
33 #include "../../Framework/Scene2DViewport/CreateLineMeasureTracker.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
34 #include "../../Framework/StoneInitialization.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
35
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
36 // From Orthanc framework
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
37 #include <Core/Logging.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
38 #include <Core/OrthancException.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
39 #include <Core/Images/Image.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
40 #include <Core/Images/ImageProcessing.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
41 #include <Core/Images/PngWriter.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
42
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
43 #include <boost/ref.hpp>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
44 #include <boost/make_shared.hpp>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
45 #include <SDL.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
46
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
47 #include <stdio.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
48
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
49 namespace OrthancStone
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
50 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
51 const char* MeasureToolToString(size_t i)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
52 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
53 static const char* descs[] = {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
54 "GuiTool_Rotate",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
55 "GuiTool_Pan",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
56 "GuiTool_Zoom",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
57 "GuiTool_LineMeasure",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
58 "GuiTool_CircleMeasure",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
59 "GuiTool_AngleMeasure",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
60 "GuiTool_EllipseMeasure",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
61 "GuiTool_LAST"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
62 };
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
63 if (i >= GuiTool_LAST)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
64 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
65 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Wrong tool index");
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
66 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
67 return descs[i];
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
68 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
69
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
70 boost::shared_ptr<Scene2D> RadiographyEditorApp::GetScene()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
71 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
72 return controller_->GetScene();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
73 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
74
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
75 boost::shared_ptr<const Scene2D> RadiographyEditorApp::GetScene() const
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
76 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
77 return controller_->GetScene();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
78 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
79
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
80 void RadiographyEditorApp::SelectNextTool()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
81 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
82 currentTool_ = static_cast<GuiTool>(currentTool_ + 1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
83 if (currentTool_ == GuiTool_LAST)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
84 currentTool_ = static_cast<GuiTool>(0);;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
85 printf("Current tool is now: %s\n", MeasureToolToString(currentTool_));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
86 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
87
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
88 void RadiographyEditorApp::DisplayInfoText()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
89 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
90 // do not try to use stuff too early!
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
91 if (compositor_.get() == NULL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
92 return;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
93
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
94 std::stringstream msg;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
95
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
96 for (std::map<std::string, std::string>::const_iterator kv = infoTextMap_.begin();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
97 kv != infoTextMap_.end(); ++kv)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
98 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
99 msg << kv->first << " : " << kv->second << std::endl;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
100 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
101 std::string msgS = msg.str();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
102
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
103 TextSceneLayer* layerP = NULL;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
104 if (GetScene()->HasLayer(FIXED_INFOTEXT_LAYER_ZINDEX))
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
105 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
106 TextSceneLayer& layer = dynamic_cast<TextSceneLayer&>(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
107 GetScene()->GetLayer(FIXED_INFOTEXT_LAYER_ZINDEX));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
108 layerP = &layer;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
109 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
110 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
111 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
112 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
113 layerP = layer.get();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
114 layer->SetColor(0, 255, 0);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
115 layer->SetFontIndex(1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
116 layer->SetBorder(20);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
117 layer->SetAnchor(BitmapAnchor_TopLeft);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
118 //layer->SetPosition(0,0);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
119 GetScene()->SetLayer(FIXED_INFOTEXT_LAYER_ZINDEX, layer.release());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
120 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
121 // position the fixed info text in the upper right corner
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
122 layerP->SetText(msgS.c_str());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
123 double cX = compositor_->GetWidth() * (-0.5);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
124 double cY = compositor_->GetHeight() * (-0.5);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
125 GetScene()->GetCanvasToSceneTransform().Apply(cX,cY);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
126 layerP->SetPosition(cX, cY);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
127 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
128
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
129 void RadiographyEditorApp::DisplayFloatingCtrlInfoText(const PointerEvent& e)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
130 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
131 ScenePoint2D p = e.GetMainPosition().Apply(GetScene()->GetCanvasToSceneTransform());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
132
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
133 char buf[128];
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
134 sprintf(buf, "S:(%0.02f,%0.02f) C:(%0.02f,%0.02f)",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
135 p.GetX(), p.GetY(),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
136 e.GetMainPosition().GetX(), e.GetMainPosition().GetY());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
137
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
138 if (GetScene()->HasLayer(FLOATING_INFOTEXT_LAYER_ZINDEX))
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
139 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
140 TextSceneLayer& layer =
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
141 dynamic_cast<TextSceneLayer&>(GetScene()->GetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
142 layer.SetText(buf);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
143 layer.SetPosition(p.GetX(), p.GetY());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
144 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
145 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
146 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
147 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
148 layer->SetColor(0, 255, 0);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
149 layer->SetText(buf);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
150 layer->SetBorder(20);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
151 layer->SetAnchor(BitmapAnchor_BottomCenter);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
152 layer->SetPosition(p.GetX(), p.GetY());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
153 GetScene()->SetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX, layer.release());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
154 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
155 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
156
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
157 void RadiographyEditorApp::HideInfoText()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
158 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
159 GetScene()->DeleteLayer(FLOATING_INFOTEXT_LAYER_ZINDEX);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
160 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
161
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
162 ScenePoint2D RadiographyEditorApp::GetRandomPointInScene() const
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
163 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
164 unsigned int w = compositor_->GetWidth();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
165 LOG(TRACE) << "compositor_->GetWidth() = " <<
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
166 compositor_->GetWidth();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
167 unsigned int h = compositor_->GetHeight();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
168 LOG(TRACE) << "compositor_->GetHeight() = " <<
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
169 compositor_->GetHeight();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
170
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
171 if ((w >= RAND_MAX) || (h >= RAND_MAX))
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
172 LOG(WARNING) << "Canvas is too big : tools will not be randomly placed";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
173
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
174 int x = rand() % w;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
175 int y = rand() % h;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
176 LOG(TRACE) << "random x = " << x << "random y = " << y;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
177
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
178 ScenePoint2D p = compositor_->GetPixelCenterCoordinates(x, y);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
179 LOG(TRACE) << "--> p.GetX() = " << p.GetX() << " p.GetY() = " << p.GetY();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
180
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
181 ScenePoint2D r = p.Apply(GetScene()->GetCanvasToSceneTransform());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
182 LOG(TRACE) << "--> r.GetX() = " << r.GetX() << " r.GetY() = " << r.GetY();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
183 return r;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
184 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
185
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
186 void RadiographyEditorApp::CreateRandomMeasureTool()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
187 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
188 static bool srandCalled = false;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
189 if (!srandCalled)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
190 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
191 srand(42);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
192 srandCalled = true;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
193 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
194
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
195 int i = rand() % 2;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
196 LOG(TRACE) << "random i = " << i;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
197 switch (i)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
198 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
199 case 0:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
200 // line measure
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
201 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
202 boost::shared_ptr<CreateLineMeasureCommand> cmd =
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
203 boost::make_shared<CreateLineMeasureCommand>(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
204 boost::ref(IObserver::GetBroker()),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
205 controller_,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
206 GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
207 cmd->SetEnd(GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
208 controller_->PushCommand(cmd);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
209 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
210 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
211 case 1:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
212 // angle measure
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
213 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
214 boost::shared_ptr<CreateAngleMeasureCommand> cmd =
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
215 boost::make_shared<CreateAngleMeasureCommand>(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
216 boost::ref(IObserver::GetBroker()),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
217 controller_,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
218 GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
219 cmd->SetCenter(GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
220 cmd->SetSide2End(GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
221 controller_->PushCommand(cmd);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
222 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
223 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
224 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
225 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
226
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
227 void RadiographyEditorApp::OnMouseMove(int x, int y, OrthancStone::KeyboardModifiers modifiers)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
228 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
229 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
230 if (activeTracker_.get() == NULL && (modifiers & OrthancStone::KeyboardModifiers_Alt))
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
231 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
232 // The "left-ctrl" key is down, while no tracker is present
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
233 // Let's display the info text
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
234 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
235 e.AddPosition(compositor_->GetPixelCenterCoordinates(x, y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
236
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
237 DisplayFloatingCtrlInfoText(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
238 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
239 else {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
240 HideInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
241 //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
242 if (activeTracker_.get() != NULL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
243 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
244 //LOG(TRACE) << "(activeTracker_.get() != NULL)";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
245 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
246 e.AddPosition(compositor_->GetPixelCenterCoordinates(x, y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
247
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
248 //LOG(TRACE) << "event.button.x = " << event.button.x << " " <<
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
249 // "event.button.y = " << event.button.y;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
250 LOG(TRACE) << "activeTracker_->PointerMove(e); " <<
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
251 e.GetMainPosition().GetX() << " " << e.GetMainPosition().GetY();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
252
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
253 activeTracker_->PointerMove(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
254 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
255 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
256 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
257 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
258 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
259
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
260 void RadiographyEditorApp::OnKeyPressed(char keyChar, OrthancStone::KeyboardModifiers modifiers)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
261 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
262 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
263
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
264 switch (keyChar)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
265 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
266 case '\033': // escape
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
267 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
268 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
269 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
270 activeTracker_->Cancel();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
271 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
272 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
273 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
274 };break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
275 case 't':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
276 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
277 if (!activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
278 SelectNextTool();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
279 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
280 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
281 LOG(WARNING) << "You cannot change the active tool when an interaction"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
282 " is taking place";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
283 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
284 };break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
285 case 'm':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
286 CreateRandomMeasureTool();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
287 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
288 case 's':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
289 controller_->FitContent(compositor_->GetWidth(),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
290 compositor_->GetHeight());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
291 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
292 case 'z':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
293 LOG(TRACE) << "z has been pressed. modifier = " << modifiers;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
294 if (modifiers & OrthancStone::KeyboardModifiers_Control)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
295 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
296 if (controller_->CanUndo())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
297 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
298 LOG(TRACE) << "Undoing...";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
299 controller_->Undo();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
300 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
301 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
302 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
303 LOG(WARNING) << "Nothing to undo!!!";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
304 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
305 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
306 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
307
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
308 case 'y':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
309 LOG(TRACE) << "y has been pressed. modifier = " << modifiers;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
310 if (modifiers & OrthancStone::KeyboardModifiers_Control)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
311 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
312 if (controller_->CanRedo())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
313 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
314 LOG(TRACE) << "Redoing...";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
315 controller_->Redo();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
316 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
317 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
318 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
319 LOG(WARNING) << "Nothing to redo!!!";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
320 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
321 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
322 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
323
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
324 case 'c':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
325 TakeScreenshot(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
326 "screenshot.png",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
327 compositor_->GetWidth(),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
328 compositor_->GetHeight());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
329 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
330
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
331 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
332 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
333
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
334 void RadiographyEditorApp::OnMouseDown(int x, int y, OrthancStone::KeyboardModifiers modifiers, OrthancStone::MouseButton button)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
335 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
336 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
337 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
338 e.AddPosition(compositor_->GetPixelCenterCoordinates(x, y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
339 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
340
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
341 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
342 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
343 activeTracker_->PointerDown(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
344 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
345 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
346 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
347 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
348 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
349 // we ATTEMPT to create a tracker if need be
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
350 activeTracker_ = CreateSuitableTracker(button, e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
351 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
352 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
353
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
354 void RadiographyEditorApp::OnMouseUp(int x, int y, OrthancStone::KeyboardModifiers modifiers, OrthancStone::MouseButton button)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
355 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
356 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
357 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
358 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
359 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
360 e.AddPosition(compositor_->GetPixelCenterCoordinates(x, y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
361 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
362
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
363 activeTracker_->PointerUp(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
364 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
365 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
366 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
367 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
368
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
369 void RadiographyEditorApp::HandleApplicationEvent(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
370 const SDL_Event & event)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
371 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
372 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
373
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
374 if (event.type == SDL_MOUSEMOTION)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
375 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
376 int scancodeCount = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
377 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
378
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
379 if (activeTracker_.get() == NULL &&
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
380 SDL_SCANCODE_LALT < scancodeCount &&
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
381 keyboardState[SDL_SCANCODE_LALT])
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
382 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
383 // The "left-ctrl" key is down, while no tracker is present
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
384 // Let's display the info text
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
385 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
386 e.AddPosition(compositor_->GetPixelCenterCoordinates(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
387 event.button.x, event.button.y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
388 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
389
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
390 DisplayFloatingCtrlInfoText(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
391 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
392 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
393 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
394 HideInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
395 //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
396 if (activeTracker_.get() != NULL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
397 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
398 //LOG(TRACE) << "(activeTracker_.get() != NULL)";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
399 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
400 e.AddPosition(compositor_->GetPixelCenterCoordinates(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
401 event.button.x, event.button.y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
402 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
403
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
404 //LOG(TRACE) << "event.button.x = " << event.button.x << " " <<
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
405 // "event.button.y = " << event.button.y;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
406 LOG(TRACE) << "activeTracker_->PointerMove(e); " <<
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
407 e.GetMainPosition().GetX() << " " << e.GetMainPosition().GetY();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
408
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
409 activeTracker_->PointerMove(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
410 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
411 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
412 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
413 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
414 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
415 else if (event.type == SDL_MOUSEBUTTONUP)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
416 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
417 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
418 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
419 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
420 e.AddPosition(compositor_->GetPixelCenterCoordinates(event.button.x, event.button.y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
421 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
422 activeTracker_->PointerUp(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
423 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
424 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
425 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
426 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
427 else if (event.type == SDL_MOUSEBUTTONDOWN)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
428 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
429 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
430 e.AddPosition(compositor_->GetPixelCenterCoordinates(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
431 event.button.x, event.button.y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
432 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
433 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
434 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
435 activeTracker_->PointerDown(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
436 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
437 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
438 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
439 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
440 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
441 // we ATTEMPT to create a tracker if need be
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
442 // activeTracker_ = CreateSuitableTracker(event, e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
443 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
444 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
445 else if (event.type == SDL_KEYDOWN &&
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
446 event.key.repeat == 0 /* Ignore key bounce */)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
447 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
448 switch (event.key.keysym.sym)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
449 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
450 case SDLK_ESCAPE:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
451 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
452 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
453 activeTracker_->Cancel();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
454 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
455 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
456 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
457 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
458
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
459 case SDLK_t:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
460 if (!activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
461 SelectNextTool();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
462 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
463 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
464 LOG(WARNING) << "You cannot change the active tool when an interaction"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
465 " is taking place";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
466 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
467 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
468
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
469 case SDLK_m:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
470 CreateRandomMeasureTool();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
471 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
472 case SDLK_s:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
473 controller_->FitContent(compositor_->GetWidth(),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
474 compositor_->GetHeight());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
475 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
476
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
477 case SDLK_z:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
478 LOG(TRACE) << "SDLK_z has been pressed. event.key.keysym.mod == " << event.key.keysym.mod;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
479 if (event.key.keysym.mod & KMOD_CTRL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
480 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
481 if (controller_->CanUndo())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
482 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
483 LOG(TRACE) << "Undoing...";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
484 controller_->Undo();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
485 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
486 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
487 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
488 LOG(WARNING) << "Nothing to undo!!!";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
489 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
490 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
491 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
492
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
493 case SDLK_y:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
494 LOG(TRACE) << "SDLK_y has been pressed. event.key.keysym.mod == " << event.key.keysym.mod;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
495 if (event.key.keysym.mod & KMOD_CTRL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
496 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
497 if (controller_->CanRedo())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
498 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
499 LOG(TRACE) << "Redoing...";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
500 controller_->Redo();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
501 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
502 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
503 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
504 LOG(WARNING) << "Nothing to redo!!!";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
505 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
506 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
507 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
508
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
509 case SDLK_c:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
510 TakeScreenshot(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
511 "screenshot.png",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
512 compositor_->GetWidth(),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
513 compositor_->GetHeight());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
514 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
515
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
516 default:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
517 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
518 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
519 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
520 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
521
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
522
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
523 void RadiographyEditorApp::OnSceneTransformChanged(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
524 const ViewportController::SceneTransformChanged& message)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
525 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
526 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
527 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
528
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
529 boost::shared_ptr<IFlexiblePointerTracker> RadiographyEditorApp::CreateSuitableTracker(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
530 OrthancStone::MouseButton button,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
531 const PointerEvent & e)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
532 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
533 using namespace Orthanc;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
534
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
535 switch (button)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
536 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
537 case OrthancStone::MouseButton_Middle:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
538 return boost::shared_ptr<IFlexiblePointerTracker>(new PanSceneTracker
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
539 (controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
540
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
541 case OrthancStone::MouseButton_Right:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
542 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
543 (controller_, e, compositor_->GetHeight()));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
544
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
545 case OrthancStone::MouseButton_Left:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
546 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
547 //LOG(TRACE) << "CreateSuitableTracker: case SDL_BUTTON_LEFT:";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
548 // TODO: we need to iterate on the set of measuring tool and perform
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
549 // a hit test to check if a tracker needs to be created for edition.
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
550 // Otherwise, depending upon the active tool, we might want to create
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
551 // a "measuring tool creation" tracker
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
552
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
553 // TODO: if there are conflicts, we should prefer a tracker that
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
554 // pertains to the type of measuring tool currently selected (TBD?)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
555 boost::shared_ptr<IFlexiblePointerTracker> hitTestTracker = TrackerHitTest(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
556
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
557 if (hitTestTracker != NULL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
558 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
559 //LOG(TRACE) << "hitTestTracker != NULL";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
560 return hitTestTracker;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
561 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
562 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
563 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
564 switch (currentTool_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
565 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
566 case GuiTool_Rotate:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
567 //LOG(TRACE) << "Creating RotateSceneTracker";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
568 return boost::shared_ptr<IFlexiblePointerTracker>(new RotateSceneTracker(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
569 controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
570 case GuiTool_Pan:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
571 return boost::shared_ptr<IFlexiblePointerTracker>(new PanSceneTracker(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
572 controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
573 case GuiTool_Zoom:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
574 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
575 controller_, e, compositor_->GetHeight()));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
576 //case GuiTool_AngleMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
577 // return new AngleMeasureTracker(GetScene(), e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
578 //case GuiTool_CircleMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
579 // return new CircleMeasureTracker(GetScene(), e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
580 //case GuiTool_EllipseMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
581 // return new EllipseMeasureTracker(GetScene(), e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
582 case GuiTool_LineMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
583 return boost::shared_ptr<IFlexiblePointerTracker>(new CreateLineMeasureTracker(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
584 IObserver::GetBroker(), controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
585 case GuiTool_AngleMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
586 return boost::shared_ptr<IFlexiblePointerTracker>(new CreateAngleMeasureTracker(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
587 IObserver::GetBroker(), controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
588 case GuiTool_CircleMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
589 LOG(ERROR) << "Not implemented yet!";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
590 return boost::shared_ptr<IFlexiblePointerTracker>();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
591 case GuiTool_EllipseMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
592 LOG(ERROR) << "Not implemented yet!";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
593 return boost::shared_ptr<IFlexiblePointerTracker>();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
594 default:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
595 throw OrthancException(ErrorCode_InternalError, "Wrong tool!");
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
596 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
597 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
598 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
599 default:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
600 return boost::shared_ptr<IFlexiblePointerTracker>();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
601 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
602 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
603
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
604
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
605 RadiographyEditorApp::RadiographyEditorApp(OrthancStone::IOracle& oracle,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
606 IObservable& oracleObservable,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
607 ICompositorFactory* compositorFactory) :
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
608 IObserver(oracleObservable.GetBroker()),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
609 oracle_(oracle),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
610 compositorFactory_(compositorFactory),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
611 currentTool_(GuiTool_Rotate)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
612 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
613 controller_ = boost::shared_ptr<ViewportController>(new ViewportController(IObserver::GetBroker()));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
614
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
615 controller_->RegisterObserverCallback(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
616 new Callable<RadiographyEditorApp, ViewportController::SceneTransformChanged>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
617 (*this, &RadiographyEditorApp::OnSceneTransformChanged));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
618
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
619 TEXTURE_2x2_1_ZINDEX = 1;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
620 TEXTURE_1x1_ZINDEX = 2;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
621 TEXTURE_2x2_2_ZINDEX = 3;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
622 LINESET_1_ZINDEX = 4;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
623 LINESET_2_ZINDEX = 5;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
624 FLOATING_INFOTEXT_LAYER_ZINDEX = 6;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
625 FIXED_INFOTEXT_LAYER_ZINDEX = 7;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
626 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
627
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
628 void RadiographyEditorApp::PrepareScene()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
629 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
630 // Texture of 2x2 size
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
631 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
632 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 2, 2, false);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
633
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
634 uint8_t* p = reinterpret_cast<uint8_t*>(i.GetRow(0));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
635 p[0] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
636 p[1] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
637 p[2] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
638
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
639 p[3] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
640 p[4] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
641 p[5] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
642
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
643 p = reinterpret_cast<uint8_t*>(i.GetRow(1));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
644 p[0] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
645 p[1] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
646 p[2] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
647
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
648 p[3] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
649 p[4] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
650 p[5] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
651
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
652 GetScene()->SetLayer(TEXTURE_2x2_1_ZINDEX, new ColorTextureSceneLayer(i));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
653
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
654 std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
655 l->SetOrigin(-3, 2);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
656 l->SetPixelSpacing(1.5, 1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
657 l->SetAngle(20.0 / 180.0 * M_PI);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
658 GetScene()->SetLayer(TEXTURE_2x2_2_ZINDEX, l.release());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
659 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
660
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
661 // Texture of 1x1 size
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
662 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
663 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 1, 1, false);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
664
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
665 uint8_t* p = reinterpret_cast<uint8_t*>(i.GetRow(0));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
666 p[0] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
667 p[1] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
668 p[2] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
669
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
670 std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
671 l->SetOrigin(-2, 1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
672 l->SetAngle(20.0 / 180.0 * M_PI);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
673 GetScene()->SetLayer(TEXTURE_1x1_ZINDEX, l.release());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
674 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
675
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
676 // Some lines
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
677 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
678 std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
679
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
680 layer->SetThickness(1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
681
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
682 PolylineSceneLayer::Chain chain;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
683 chain.push_back(ScenePoint2D(0 - 0.5, 0 - 0.5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
684 chain.push_back(ScenePoint2D(0 - 0.5, 2 - 0.5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
685 chain.push_back(ScenePoint2D(2 - 0.5, 2 - 0.5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
686 chain.push_back(ScenePoint2D(2 - 0.5, 0 - 0.5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
687 layer->AddChain(chain, true, 255, 0, 0);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
688
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
689 chain.clear();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
690 chain.push_back(ScenePoint2D(-5, -5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
691 chain.push_back(ScenePoint2D(5, -5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
692 chain.push_back(ScenePoint2D(5, 5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
693 chain.push_back(ScenePoint2D(-5, 5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
694 layer->AddChain(chain, true, 0, 255, 0);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
695
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
696 double dy = 1.01;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
697 chain.clear();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
698 chain.push_back(ScenePoint2D(-4, -4));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
699 chain.push_back(ScenePoint2D(4, -4 + dy));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
700 chain.push_back(ScenePoint2D(-4, -4 + 2.0 * dy));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
701 chain.push_back(ScenePoint2D(4, 2));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
702 layer->AddChain(chain, false, 0, 0, 255);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
703
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
704 GetScene()->SetLayer(LINESET_1_ZINDEX, layer.release());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
705 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
706
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
707 // Some text
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
708 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
709 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
710 layer->SetText("Hello");
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
711 GetScene()->SetLayer(LINESET_2_ZINDEX, layer.release());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
712 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
713 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
714
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
715
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
716 void RadiographyEditorApp::DisableTracker()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
717 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
718 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
719 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
720 activeTracker_->Cancel();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
721 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
722 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
723 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
724
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
725 void RadiographyEditorApp::TakeScreenshot(const std::string& target,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
726 unsigned int canvasWidth,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
727 unsigned int canvasHeight)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
728 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
729 CairoCompositor compositor(*GetScene(), canvasWidth, canvasHeight);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
730 compositor.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, FONT_SIZE_0, Orthanc::Encoding_Latin1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
731 compositor.Refresh();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
732
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
733 Orthanc::ImageAccessor canvas;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
734 compositor.GetCanvas().GetReadOnlyAccessor(canvas);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
735
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
736 Orthanc::Image png(Orthanc::PixelFormat_RGB24, canvas.GetWidth(), canvas.GetHeight(), false);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
737 Orthanc::ImageProcessing::Convert(png, canvas);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
738
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
739 Orthanc::PngWriter writer;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
740 writer.WriteToFile(target, png);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
741 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
742
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
743
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
744 boost::shared_ptr<IFlexiblePointerTracker> RadiographyEditorApp::TrackerHitTest(const PointerEvent & e)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
745 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
746 // std::vector<boost::shared_ptr<MeasureTool>> measureTools_;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
747 return boost::shared_ptr<IFlexiblePointerTracker>();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
748 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
749
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
750
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
751 void RadiographyEditorApp::FitContent(unsigned int width, unsigned int height)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
752 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
753 controller_->FitContent(width, height);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
754 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
755
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
756 void RadiographyEditorApp::UpdateSize()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
757 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
758 if (dynamic_cast<OpenGLCompositor*>(compositor_.get()) != NULL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
759 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
760 dynamic_cast<OpenGLCompositor*>(compositor_.get())->UpdateSize();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
761 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
762 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
763
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
764 void RadiographyEditorApp::Refresh()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
765 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
766 compositor_.reset(compositorFactory_->GetCompositor(*GetScene()));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
767 compositor_->Refresh();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
768
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
769 // the following is paramount because the compositor holds a reference
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
770 // to the scene and we do not want this reference to become dangling
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
771 // TODO ???? compositor_.reset(NULL);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
772 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
773
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
774 void RadiographyEditorApp::SetInfoDisplayMessage(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
775 std::string key, std::string value)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
776 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
777 if (value == "")
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
778 infoTextMap_.erase(key);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
779 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
780 infoTextMap_[key] = value;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
781 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
782 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
783
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
784 }