annotate Samples/Shared/RadiographyEditorApp.cpp @ 889:6e79e8c9021c am-dev

integration mainline->am-dev
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jul 2019 12:05:02 +0200
parents 56e4e9281076
children
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"
885
56e4e9281076 sharing code between Qt/SDL BasiceScene sample
Alain Mazy <alain@mazy.be>
parents: 848
diff changeset
34 #include "../../Framework/Scene2DViewport/UndoStack.h"
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
35 #include "../../Framework/StoneInitialization.h"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
36
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
37 // From Orthanc framework
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
38 #include <Core/Logging.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
39 #include <Core/OrthancException.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
40 #include <Core/Images/Image.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
41 #include <Core/Images/ImageProcessing.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
42 #include <Core/Images/PngWriter.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
43
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
44 #include <boost/ref.hpp>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
45 #include <boost/make_shared.hpp>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
46 #include <SDL.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
47
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
48 #include <stdio.h>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
49
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
50 namespace OrthancStone
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
51 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
52 const char* MeasureToolToString(size_t i)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
53 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
54 static const char* descs[] = {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
55 "GuiTool_Rotate",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
56 "GuiTool_Pan",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
57 "GuiTool_Zoom",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
58 "GuiTool_LineMeasure",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
59 "GuiTool_CircleMeasure",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
60 "GuiTool_AngleMeasure",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
61 "GuiTool_EllipseMeasure",
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
62 "GuiTool_LAST"
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
63 };
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
64 if (i >= GuiTool_LAST)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
65 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
66 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
67 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
68 return descs[i];
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
71 boost::shared_ptr<Scene2D> RadiographyEditorApp::GetScene()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
72 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
73 return controller_->GetScene();
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
76 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
77 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
78 return controller_->GetScene();
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
81 void RadiographyEditorApp::SelectNextTool()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
82 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
83 currentTool_ = static_cast<GuiTool>(currentTool_ + 1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
84 if (currentTool_ == GuiTool_LAST)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
85 currentTool_ = static_cast<GuiTool>(0);;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
86 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
87 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
88
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
89 void RadiographyEditorApp::DisplayInfoText()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
90 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
91 // 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
92 if (compositor_.get() == NULL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
93 return;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
94
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
95 std::stringstream msg;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
96
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
97 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
98 kv != infoTextMap_.end(); ++kv)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
99 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
100 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
101 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
102 std::string msgS = msg.str();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
103
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
104 TextSceneLayer* layerP = NULL;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
105 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
106 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
107 TextSceneLayer& layer = dynamic_cast<TextSceneLayer&>(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
108 GetScene()->GetLayer(FIXED_INFOTEXT_LAYER_ZINDEX));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
109 layerP = &layer;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
110 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
111 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
112 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
113 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
114 layerP = layer.get();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
115 layer->SetColor(0, 255, 0);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
116 layer->SetFontIndex(1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
117 layer->SetBorder(20);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
118 layer->SetAnchor(BitmapAnchor_TopLeft);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
119 //layer->SetPosition(0,0);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
120 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
121 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
122 // 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
123 layerP->SetText(msgS.c_str());
889
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
124 double cX = compositor_->GetCanvasWidth() * (-0.5);
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
125 double cY = compositor_->GetCanvasHeight() * (-0.5);
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
126 GetScene()->GetCanvasToSceneTransform().Apply(cX,cY);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
127 layerP->SetPosition(cX, cY);
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
130 void RadiographyEditorApp::DisplayFloatingCtrlInfoText(const PointerEvent& e)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
131 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
132 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
133
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
134 char buf[128];
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
135 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
136 p.GetX(), p.GetY(),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
137 e.GetMainPosition().GetX(), e.GetMainPosition().GetY());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
138
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
139 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
140 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
141 TextSceneLayer& layer =
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
142 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
143 layer.SetText(buf);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
144 layer.SetPosition(p.GetX(), p.GetY());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
145 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
146 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
147 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
148 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
149 layer->SetColor(0, 255, 0);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
150 layer->SetText(buf);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
151 layer->SetBorder(20);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
152 layer->SetAnchor(BitmapAnchor_BottomCenter);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
153 layer->SetPosition(p.GetX(), p.GetY());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
154 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
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
158 void RadiographyEditorApp::HideInfoText()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
159 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
160 GetScene()->DeleteLayer(FLOATING_INFOTEXT_LAYER_ZINDEX);
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
163 ScenePoint2D RadiographyEditorApp::GetRandomPointInScene() const
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
164 {
889
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
165 unsigned int w = compositor_->GetCanvasWidth();
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
166 LOG(TRACE) << "compositor_->GetCanvasWidth() = " <<
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
167 compositor_->GetCanvasWidth();
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
168 unsigned int h = compositor_->GetCanvasHeight();
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
169 LOG(TRACE) << "compositor_->GetCanvasHeight() = " <<
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
170 compositor_->GetCanvasHeight();
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
171
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
172 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
173 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
174
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
175 int x = rand() % w;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
176 int y = rand() % h;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
177 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
178
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
179 ScenePoint2D p = compositor_->GetPixelCenterCoordinates(x, y);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
180 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
181
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
182 ScenePoint2D r = p.Apply(GetScene()->GetCanvasToSceneTransform());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
183 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
184 return r;
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
187 void RadiographyEditorApp::CreateRandomMeasureTool()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
188 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
189 static bool srandCalled = false;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
190 if (!srandCalled)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
191 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
192 srand(42);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
193 srandCalled = true;
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
196 int i = rand() % 2;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
197 LOG(TRACE) << "random i = " << i;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
198 switch (i)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
199 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
200 case 0:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
201 // line measure
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
202 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
203 boost::shared_ptr<CreateLineMeasureCommand> cmd =
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
204 boost::make_shared<CreateLineMeasureCommand>(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
205 boost::ref(IObserver::GetBroker()),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
206 controller_,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
207 GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
208 cmd->SetEnd(GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
209 controller_->PushCommand(cmd);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
210 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
211 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
212 case 1:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
213 // angle measure
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
214 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
215 boost::shared_ptr<CreateAngleMeasureCommand> cmd =
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
216 boost::make_shared<CreateAngleMeasureCommand>(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
217 boost::ref(IObserver::GetBroker()),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
218 controller_,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
219 GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
220 cmd->SetCenter(GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
221 cmd->SetSide2End(GetRandomPointInScene());
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
222 controller_->PushCommand(cmd);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
223 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
224 break;
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
228 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
229 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
230 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
231 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
232 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
233 // 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
234 // Let's display the info text
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
235 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
236 e.AddPosition(compositor_->GetPixelCenterCoordinates(x, y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
237
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
238 DisplayFloatingCtrlInfoText(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
239 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
240 else {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
241 HideInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
242 //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
243 if (activeTracker_.get() != NULL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
244 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
245 //LOG(TRACE) << "(activeTracker_.get() != NULL)";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
246 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
247 e.AddPosition(compositor_->GetPixelCenterCoordinates(x, y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
248
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
249 //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
250 // "event.button.y = " << event.button.y;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
251 LOG(TRACE) << "activeTracker_->PointerMove(e); " <<
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
252 e.GetMainPosition().GetX() << " " << e.GetMainPosition().GetY();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
253
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
254 activeTracker_->PointerMove(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
255 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
256 activeTracker_.reset();
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
261 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
262 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
263 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
264
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
265 switch (keyChar)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
266 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
267 case '\033': // escape
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
268 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
269 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
270 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
271 activeTracker_->Cancel();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
272 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
273 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
274 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
275 };break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
276 case 't':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
277 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
278 if (!activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
279 SelectNextTool();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
280 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
281 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
282 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
283 " is taking place";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
284 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
285 };break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
286 case 'm':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
287 CreateRandomMeasureTool();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
288 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
289 case 's':
889
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
290 controller_->FitContent(compositor_->GetCanvasWidth(),
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
291 compositor_->GetCanvasHeight());
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
292 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
293 case 'z':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
294 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
295 if (modifiers & OrthancStone::KeyboardModifiers_Control)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
296 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
297 if (controller_->CanUndo())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
298 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
299 LOG(TRACE) << "Undoing...";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
300 controller_->Undo();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
301 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
302 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
303 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
304 LOG(WARNING) << "Nothing to undo!!!";
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 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
307 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
308
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
309 case 'y':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
310 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
311 if (modifiers & OrthancStone::KeyboardModifiers_Control)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
312 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
313 if (controller_->CanRedo())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
314 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
315 LOG(TRACE) << "Redoing...";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
316 controller_->Redo();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
317 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
318 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
319 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
320 LOG(WARNING) << "Nothing to redo!!!";
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 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
323 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
324
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
325 case 'c':
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
326 TakeScreenshot(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
327 "screenshot.png",
889
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
328 compositor_->GetCanvasWidth(),
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
329 compositor_->GetCanvasHeight());
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
330 break;
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
335 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
336 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
337 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
338 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
339 e.AddPosition(compositor_->GetPixelCenterCoordinates(x, y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
340 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
341
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
342 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
343 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
344 activeTracker_->PointerDown(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
345 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
346 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
347 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
348 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
349 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
350 // 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
351 activeTracker_ = CreateSuitableTracker(button, e);
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
355 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
356 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
357 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
358 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
359 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
360 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
361 e.AddPosition(compositor_->GetPixelCenterCoordinates(x, y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
362 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
363
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
364 activeTracker_->PointerUp(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
365 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
366 activeTracker_.reset();
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
370 void RadiographyEditorApp::HandleApplicationEvent(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
371 const SDL_Event & event)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
372 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
373 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
374
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
375 if (event.type == SDL_MOUSEMOTION)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
376 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
377 int scancodeCount = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
378 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
379
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
380 if (activeTracker_.get() == NULL &&
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
381 SDL_SCANCODE_LALT < scancodeCount &&
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
382 keyboardState[SDL_SCANCODE_LALT])
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
383 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
384 // 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
385 // Let's display the info text
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
386 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
387 e.AddPosition(compositor_->GetPixelCenterCoordinates(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
388 event.button.x, event.button.y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
389 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
390
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
391 DisplayFloatingCtrlInfoText(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
392 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
393 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
394 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
395 HideInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
396 //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
397 if (activeTracker_.get() != NULL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
398 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
399 //LOG(TRACE) << "(activeTracker_.get() != NULL)";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
400 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
401 e.AddPosition(compositor_->GetPixelCenterCoordinates(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
402 event.button.x, event.button.y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
403 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
404
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
405 //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
406 // "event.button.y = " << event.button.y;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
407 LOG(TRACE) << "activeTracker_->PointerMove(e); " <<
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
408 e.GetMainPosition().GetX() << " " << e.GetMainPosition().GetY();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
409
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
410 activeTracker_->PointerMove(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
411 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
412 activeTracker_.reset();
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 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
416 else if (event.type == SDL_MOUSEBUTTONUP)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
417 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
418 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
419 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
420 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
421 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
422 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
423 activeTracker_->PointerUp(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
424 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
425 activeTracker_.reset();
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 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
428 else if (event.type == SDL_MOUSEBUTTONDOWN)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
429 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
430 PointerEvent e;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
431 e.AddPosition(compositor_->GetPixelCenterCoordinates(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
432 event.button.x, event.button.y));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
433 // TODO: set modifiers in e
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
434 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
435 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
436 activeTracker_->PointerDown(e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
437 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
438 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
439 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
440 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
441 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
442 // 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
443 // activeTracker_ = CreateSuitableTracker(event, e);
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 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
446 else if (event.type == SDL_KEYDOWN &&
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
447 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
448 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
449 switch (event.key.keysym.sym)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
450 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
451 case SDLK_ESCAPE:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
452 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
453 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
454 activeTracker_->Cancel();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
455 if (!activeTracker_->IsAlive())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
456 activeTracker_.reset();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
457 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
458 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
459
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
460 case SDLK_t:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
461 if (!activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
462 SelectNextTool();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
463 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
464 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
465 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
466 " is taking place";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
467 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
468 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
469
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
470 case SDLK_m:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
471 CreateRandomMeasureTool();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
472 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
473 case SDLK_s:
889
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
474 controller_->FitContent(compositor_->GetCanvasWidth(),
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
475 compositor_->GetCanvasHeight());
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
476 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
477
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
478 case SDLK_z:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
479 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
480 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
481 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
482 if (controller_->CanUndo())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
483 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
484 LOG(TRACE) << "Undoing...";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
485 controller_->Undo();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
486 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
487 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
488 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
489 LOG(WARNING) << "Nothing to undo!!!";
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 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
492 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
493
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
494 case SDLK_y:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
495 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
496 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
497 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
498 if (controller_->CanRedo())
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
499 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
500 LOG(TRACE) << "Redoing...";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
501 controller_->Redo();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
502 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
503 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
504 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
505 LOG(WARNING) << "Nothing to redo!!!";
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 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
508 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
509
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
510 case SDLK_c:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
511 TakeScreenshot(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
512 "screenshot.png",
889
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
513 compositor_->GetCanvasWidth(),
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
514 compositor_->GetCanvasHeight());
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
515 break;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
516
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
517 default:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
518 break;
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
524 void RadiographyEditorApp::OnSceneTransformChanged(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
525 const ViewportController::SceneTransformChanged& message)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
526 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
527 DisplayInfoText();
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
530 boost::shared_ptr<IFlexiblePointerTracker> RadiographyEditorApp::CreateSuitableTracker(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
531 OrthancStone::MouseButton button,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
532 const PointerEvent & e)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
533 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
534 using namespace Orthanc;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
535
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
536 switch (button)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
537 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
538 case OrthancStone::MouseButton_Middle:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
539 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
540 (controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
541
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
542 case OrthancStone::MouseButton_Right:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
543 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker
889
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
544 (controller_, e, compositor_->GetCanvasHeight()));
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
545
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
546 case OrthancStone::MouseButton_Left:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
547 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
548 //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
549 // 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
550 // 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
551 // 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
552 // a "measuring tool creation" tracker
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
553
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
554 // 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
555 // 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
556 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
557
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
558 if (hitTestTracker != NULL)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
559 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
560 //LOG(TRACE) << "hitTestTracker != NULL";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
561 return hitTestTracker;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
562 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
563 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
564 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
565 switch (currentTool_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
566 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
567 case GuiTool_Rotate:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
568 //LOG(TRACE) << "Creating RotateSceneTracker";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
569 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
570 controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
571 case GuiTool_Pan:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
572 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
573 controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
574 case GuiTool_Zoom:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
575 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker(
889
6e79e8c9021c integration mainline->am-dev
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 885
diff changeset
576 controller_, e, compositor_->GetCanvasHeight()));
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
577 //case GuiTool_AngleMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
578 // return new AngleMeasureTracker(GetScene(), e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
579 //case GuiTool_CircleMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
580 // return new CircleMeasureTracker(GetScene(), e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
581 //case GuiTool_EllipseMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
582 // return new EllipseMeasureTracker(GetScene(), e);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
583 case GuiTool_LineMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
584 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
585 IObserver::GetBroker(), controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
586 case GuiTool_AngleMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
587 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
588 IObserver::GetBroker(), controller_, e));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
589 case GuiTool_CircleMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
590 LOG(ERROR) << "Not implemented yet!";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
591 return boost::shared_ptr<IFlexiblePointerTracker>();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
592 case GuiTool_EllipseMeasure:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
593 LOG(ERROR) << "Not implemented yet!";
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
594 return boost::shared_ptr<IFlexiblePointerTracker>();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
595 default:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
596 throw OrthancException(ErrorCode_InternalError, "Wrong tool!");
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 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
600 default:
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
601 return boost::shared_ptr<IFlexiblePointerTracker>();
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
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
606 RadiographyEditorApp::RadiographyEditorApp(OrthancStone::IOracle& oracle,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
607 IObservable& oracleObservable,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
608 ICompositorFactory* compositorFactory) :
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
609 IObserver(oracleObservable.GetBroker()),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
610 oracle_(oracle),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
611 compositorFactory_(compositorFactory),
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
612 currentTool_(GuiTool_Rotate)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
613 {
885
56e4e9281076 sharing code between Qt/SDL BasiceScene sample
Alain Mazy <alain@mazy.be>
parents: 848
diff changeset
614 boost::shared_ptr<UndoStack> undoStack(new UndoStack);
56e4e9281076 sharing code between Qt/SDL BasiceScene sample
Alain Mazy <alain@mazy.be>
parents: 848
diff changeset
615 controller_ = boost::shared_ptr<ViewportController>(new ViewportController(undoStack, IObserver::GetBroker()));
848
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
616
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
617 controller_->RegisterObserverCallback(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
618 new Callable<RadiographyEditorApp, ViewportController::SceneTransformChanged>
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
619 (*this, &RadiographyEditorApp::OnSceneTransformChanged));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
620
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
621 TEXTURE_2x2_1_ZINDEX = 1;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
622 TEXTURE_1x1_ZINDEX = 2;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
623 TEXTURE_2x2_2_ZINDEX = 3;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
624 LINESET_1_ZINDEX = 4;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
625 LINESET_2_ZINDEX = 5;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
626 FLOATING_INFOTEXT_LAYER_ZINDEX = 6;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
627 FIXED_INFOTEXT_LAYER_ZINDEX = 7;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
628 }
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 void RadiographyEditorApp::PrepareScene()
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 // Texture of 2x2 size
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 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
635
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
636 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
637 p[0] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
638 p[1] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
639 p[2] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
640
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
641 p[3] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
642 p[4] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
643 p[5] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
644
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
645 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
646 p[0] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
647 p[1] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
648 p[2] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
649
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
650 p[3] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
651 p[4] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
652 p[5] = 0;
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 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
655
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
656 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
657 l->SetOrigin(-3, 2);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
658 l->SetPixelSpacing(1.5, 1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
659 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
660 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
661 }
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 // Texture of 1x1 size
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 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
666
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
667 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
668 p[0] = 255;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
669 p[1] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
670 p[2] = 0;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
671
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
672 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
673 l->SetOrigin(-2, 1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
674 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
675 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
676 }
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 // Some lines
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 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
681
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
682 layer->SetThickness(1);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
683
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
684 PolylineSceneLayer::Chain chain;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
685 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
686 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
687 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
688 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
689 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
690
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
691 chain.clear();
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 chain.push_back(ScenePoint2D(5, 5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
695 chain.push_back(ScenePoint2D(-5, 5));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
696 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
697
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
698 double dy = 1.01;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
699 chain.clear();
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));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
701 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
702 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
703 chain.push_back(ScenePoint2D(4, 2));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
704 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
705
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
706 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
707 }
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 // Some text
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
710 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
711 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
712 layer->SetText("Hello");
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
713 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
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
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 void RadiographyEditorApp::DisableTracker()
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 if (activeTracker_)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
721 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
722 activeTracker_->Cancel();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
723 activeTracker_.reset();
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 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
726
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
727 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
728 unsigned int canvasWidth,
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
729 unsigned int canvasHeight)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
730 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
731 CairoCompositor compositor(*GetScene(), canvasWidth, canvasHeight);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
732 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
733 compositor.Refresh();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
734
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
735 Orthanc::ImageAccessor canvas;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
736 compositor.GetCanvas().GetReadOnlyAccessor(canvas);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
737
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
738 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
739 Orthanc::ImageProcessing::Convert(png, canvas);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
740
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
741 Orthanc::PngWriter writer;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
742 writer.WriteToFile(target, png);
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
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 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
747 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
748 // 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
749 return boost::shared_ptr<IFlexiblePointerTracker>();
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
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 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
754 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
755 controller_->FitContent(width, height);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
756 }
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 void RadiographyEditorApp::UpdateSize()
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 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
761 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
762 dynamic_cast<OpenGLCompositor*>(compositor_.get())->UpdateSize();
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 }
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 void RadiographyEditorApp::Refresh()
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
767 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
768 compositor_.reset(compositorFactory_->GetCompositor(*GetScene()));
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
769 compositor_->Refresh();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
770
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
771 // 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
772 // 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
773 // TODO ???? compositor_.reset(NULL);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
774 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
775
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
776 void RadiographyEditorApp::SetInfoDisplayMessage(
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
777 std::string key, std::string value)
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
778 {
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
779 if (value == "")
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
780 infoTextMap_.erase(key);
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
781 else
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
782 infoTextMap_[key] = value;
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
783 DisplayInfoText();
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
784 }
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
785
80829436ce0c starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
diff changeset
786 }