annotate Samples/Sdl/TrackerSampleApp.cpp @ 1323:c0af7657d398 broker

Fixed warnings
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 24 Mar 2020 16:17:03 +0100
parents 8a0a62189f46
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1047
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 *
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 *
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 *
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19 **/
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 #include "TrackerSampleApp.h"
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22
1047
efc5b62b9539 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 938
diff changeset
23 #include "../../Framework/OpenGL/SdlOpenGLContext.h"
737
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
24 #include "../../Framework/Scene2D/CairoCompositor.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
25 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
26 #include "../../Framework/Scene2D/OpenGLCompositor.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
27 #include "../../Framework/Scene2D/PanSceneTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
28 #include "../../Framework/Scene2D/RotateSceneTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
29 #include "../../Framework/Scene2D/Scene2D.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
30 #include "../../Framework/Scene2D/ZoomSceneTracker.h"
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 818
diff changeset
31 #include "../../Framework/Scene2DViewport/UndoStack.h"
737
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
32 #include "../../Framework/Scene2DViewport/CreateAngleMeasureTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
33 #include "../../Framework/Scene2DViewport/CreateLineMeasureTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
34 #include "../../Framework/StoneInitialization.h"
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
35
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
36 // From Orthanc framework
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 #include <Core/Logging.h>
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 #include <Core/OrthancException.h>
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 #include <Core/Images/Image.h>
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 #include <Core/Images/ImageProcessing.h>
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 #include <Core/Images/PngWriter.h>
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42
787
1a28fce57ff3 Fixed Visual Studio 2008 build
Benjamin Golinvaux <bgo@osimis.io>
parents: 761
diff changeset
43 #include <boost/ref.hpp>
1a28fce57ff3 Fixed Visual Studio 2008 build
Benjamin Golinvaux <bgo@osimis.io>
parents: 761
diff changeset
44 #include <boost/make_shared.hpp>
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 #include <SDL.h>
787
1a28fce57ff3 Fixed Visual Studio 2008 build
Benjamin Golinvaux <bgo@osimis.io>
parents: 761
diff changeset
46
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 #include <stdio.h>
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 namespace OrthancStone
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 const char* MeasureToolToString(size_t i)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 static const char* descs[] = {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 "GuiTool_Rotate",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 "GuiTool_Pan",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 "GuiTool_Zoom",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 "GuiTool_LineMeasure",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 "GuiTool_CircleMeasure",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 "GuiTool_AngleMeasure",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 "GuiTool_EllipseMeasure",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 "GuiTool_LAST"
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 };
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 if (i >= GuiTool_LAST)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Wrong tool index");
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 return descs[i];
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 void TrackerSampleApp::SelectNextTool()
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 currentTool_ = static_cast<GuiTool>(currentTool_ + 1);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 if (currentTool_ == GuiTool_LAST)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 currentTool_ = static_cast<GuiTool>(0);;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 printf("Current tool is now: %s\n", MeasureToolToString(currentTool_));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
78 void TrackerSampleApp::DisplayInfoText()
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
79 {
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
80 // do not try to use stuff too early!
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
81 std::stringstream msg;
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
82
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
83 for (std::map<std::string, std::string>::const_iterator kv = infoTextMap_.begin();
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
84 kv != infoTextMap_.end(); ++kv)
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
85 {
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
86 msg << kv->first << " : " << kv->second << std::endl;
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
87 }
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
88 std::string msgS = msg.str();
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
89
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
90 TextSceneLayer* layerP = NULL;
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
91 if (controller_->GetScene().HasLayer(FIXED_INFOTEXT_LAYER_ZINDEX))
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
92 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
93 TextSceneLayer& layer = dynamic_cast<TextSceneLayer&>(
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
94 controller_->GetScene().GetLayer(FIXED_INFOTEXT_LAYER_ZINDEX));
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
95 layerP = &layer;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
96 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
97 else
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
98 {
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
99 std::unique_ptr<TextSceneLayer> layer(new TextSceneLayer);
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
100 layerP = layer.get();
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
101 layer->SetColor(0, 255, 0);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
102 layer->SetFontIndex(1);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
103 layer->SetBorder(20);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
104 layer->SetAnchor(BitmapAnchor_TopLeft);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
105 //layer->SetPosition(0,0);
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
106 controller_->GetScene().SetLayer(FIXED_INFOTEXT_LAYER_ZINDEX, layer.release());
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
107 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
108 // position the fixed info text in the upper right corner
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
109 layerP->SetText(msgS.c_str());
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
110 double cX = GetCompositor().GetCanvasWidth() * (-0.5);
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
111 double cY = GetCompositor().GetCanvasHeight() * (-0.5);
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
112 controller_->GetScene().GetCanvasToSceneTransform().Apply(cX,cY);
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
113 layerP->SetPosition(cX, cY);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
114 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
115
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
116 void TrackerSampleApp::DisplayFloatingCtrlInfoText(const PointerEvent& e)
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 {
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
118 ScenePoint2D p = e.GetMainPosition().Apply(controller_->GetScene().GetCanvasToSceneTransform());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
120 char buf[128];
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
121 sprintf(buf, "S:(%0.02f,%0.02f) C:(%0.02f,%0.02f)",
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
122 p.GetX(), p.GetY(),
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
123 e.GetMainPosition().GetX(), e.GetMainPosition().GetY());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
125 if (controller_->GetScene().HasLayer(FLOATING_INFOTEXT_LAYER_ZINDEX))
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 TextSceneLayer& layer =
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
128 dynamic_cast<TextSceneLayer&>(controller_->GetScene().GetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 layer.SetText(buf);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 layer.SetPosition(p.GetX(), p.GetY());
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 else
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133 {
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
134 std::unique_ptr<TextSceneLayer> layer(new TextSceneLayer);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 layer->SetColor(0, 255, 0);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 layer->SetText(buf);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 layer->SetBorder(20);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 layer->SetAnchor(BitmapAnchor_BottomCenter);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 layer->SetPosition(p.GetX(), p.GetY());
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
140 controller_->GetScene().SetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX, layer.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 void TrackerSampleApp::HideInfoText()
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 {
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
146 controller_->GetScene().DeleteLayer(FLOATING_INFOTEXT_LAYER_ZINDEX);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
149 ScenePoint2D TrackerSampleApp::GetRandomPointInScene() const
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
150 {
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
151 unsigned int w = GetCompositor().GetCanvasWidth();
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
152 LOG(TRACE) << "GetCompositor().GetCanvasWidth() = " <<
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
153 GetCompositor().GetCanvasWidth();
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
154 unsigned int h = GetCompositor().GetCanvasHeight();
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
155 LOG(TRACE) << "GetCompositor().GetCanvasHeight() = " <<
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
156 GetCompositor().GetCanvasHeight();
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
157
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
158 if ((w >= RAND_MAX) || (h >= RAND_MAX))
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
159 LOG(WARNING) << "Canvas is too big : tools will not be randomly placed";
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
160
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
161 int x = rand() % w;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
162 int y = rand() % h;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
163 LOG(TRACE) << "random x = " << x << "random y = " << y;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
164
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
165 ScenePoint2D p = controller_->GetViewport().GetPixelCenterCoordinates(x, y);
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
166 LOG(TRACE) << "--> p.GetX() = " << p.GetX() << " p.GetY() = " << p.GetY();
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
167
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
168 ScenePoint2D r = p.Apply(controller_->GetScene().GetCanvasToSceneTransform());
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
169 LOG(TRACE) << "--> r.GetX() = " << r.GetX() << " r.GetY() = " << r.GetY();
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
170 return r;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
171 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
172
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
173 void TrackerSampleApp::CreateRandomMeasureTool()
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
174 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
175 static bool srandCalled = false;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
176 if (!srandCalled)
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
177 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
178 srand(42);
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
179 srandCalled = true;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
180 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
181
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
182 int i = rand() % 2;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
183 LOG(TRACE) << "random i = " << i;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
184 switch (i)
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
185 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
186 case 0:
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
187 // line measure
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
188 {
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
189 boost::shared_ptr<CreateLineMeasureCommand> cmd =
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
190 boost::make_shared<CreateLineMeasureCommand>(
787
1a28fce57ff3 Fixed Visual Studio 2008 build
Benjamin Golinvaux <bgo@osimis.io>
parents: 761
diff changeset
191 boost::ref(IObserver::GetBroker()),
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
192 controller_,
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
193 GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
194 cmd->SetEnd(GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
195 controller_->PushCommand(cmd);
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
196 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
197 break;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
198 case 1:
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
199 // angle measure
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
200 {
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
201 boost::shared_ptr<CreateAngleMeasureCommand> cmd =
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
202 boost::make_shared<CreateAngleMeasureCommand>(
787
1a28fce57ff3 Fixed Visual Studio 2008 build
Benjamin Golinvaux <bgo@osimis.io>
parents: 761
diff changeset
203 boost::ref(IObserver::GetBroker()),
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
204 controller_,
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
205 GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
206 cmd->SetCenter(GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
207 cmd->SetSide2End(GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
208 controller_->PushCommand(cmd);
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
209 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
210 break;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
211 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
212 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
213
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
214 void TrackerSampleApp::HandleApplicationEvent(
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
215 const SDL_Event & event)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
216 {
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
217 DisplayInfoText();
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
218
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
219 if (event.type == SDL_MOUSEMOTION)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
220 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
221 int scancodeCount = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
223
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
224 if (activeTracker_.get() == NULL &&
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
225 SDL_SCANCODE_LALT < scancodeCount &&
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
226 keyboardState[SDL_SCANCODE_LALT])
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
227 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
228 // The "left-ctrl" key is down, while no tracker is present
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
229 // Let's display the info text
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
230 PointerEvent e;
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
231 e.AddPosition(controller_->GetViewport().GetPixelCenterCoordinates(
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
232 event.button.x, event.button.y));
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
233
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
234 DisplayFloatingCtrlInfoText(e);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
235 }
871
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
236 else if (activeTracker_.get() != NULL)
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
237 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
238 HideInfoText();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
239 //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
240 if (activeTracker_.get() != NULL)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
241 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
242 //LOG(TRACE) << "(activeTracker_.get() != NULL)";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
243 PointerEvent e;
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
244 e.AddPosition(controller_->GetViewport().GetPixelCenterCoordinates(
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
245 event.button.x, event.button.y));
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
246
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
247 //LOG(TRACE) << "event.button.x = " << event.button.x << " " <<
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
248 // "event.button.y = " << event.button.y;
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
249 LOG(TRACE) << "activeTracker_->PointerMove(e); " <<
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
250 e.GetMainPosition().GetX() << " " << e.GetMainPosition().GetY();
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
251
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 activeTracker_->PointerMove(e);
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
253 if (!activeTracker_->IsAlive())
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
254 activeTracker_.reset();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
255 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
256 }
871
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
257 else
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
258 {
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
259 HideInfoText();
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
260
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
261 PointerEvent e;
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
262 e.AddPosition(controller_->GetViewport().GetPixelCenterCoordinates(event.button.x, event.button.y));
871
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
263
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
264 ScenePoint2D scenePos = e.GetMainPosition().Apply(
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
265 controller_->GetScene().GetCanvasToSceneTransform());
871
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
266 //auto measureTools = GetController()->HitTestMeasureTools(scenePos);
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
267 //LOG(TRACE) << "# of hit tests: " << measureTools.size();
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
268
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
269 // this returns the collection of measuring tools where hit test is true
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
270 std::vector<boost::shared_ptr<MeasureTool> > measureTools = controller_->HitTestMeasureTools(scenePos);
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
271
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
272 // let's refresh the measuring tools highlighted state
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
273 // first let's tag them as "unhighlighted"
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
274 controller_->ResetMeasuringToolsHighlight();
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
275
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
276 // then immediately take the first one and ask it to highlight the
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
277 // measuring tool UI part that is hot
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
278 if (measureTools.size() > 0)
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
279 {
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
280 measureTools[0]->Highlight(scenePos);
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
281 }
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
282 }
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
283 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
284 else if (event.type == SDL_MOUSEBUTTONUP)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
285 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
286 if (activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
287 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
288 PointerEvent e;
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
289 e.AddPosition(controller_->GetViewport().GetPixelCenterCoordinates(event.button.x, event.button.y));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
290 activeTracker_->PointerUp(e);
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
291 if (!activeTracker_->IsAlive())
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
292 activeTracker_.reset();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
293 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
294 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
295 else if (event.type == SDL_MOUSEBUTTONDOWN)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
296 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
297 PointerEvent e;
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
298 e.AddPosition(controller_->GetViewport().GetPixelCenterCoordinates(
651
62f6ff016085 Iteration in angle measuring tool. Text label is not ok and handles and arcs
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
299 event.button.x, event.button.y));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
300 if (activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
301 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
302 activeTracker_->PointerDown(e);
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
303 if (!activeTracker_->IsAlive())
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
304 activeTracker_.reset();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
305 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
306 else
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
307 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
308 // we ATTEMPT to create a tracker if need be
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
309 activeTracker_ = CreateSuitableTracker(event, e);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
310 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
311 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
312 else if (event.type == SDL_KEYDOWN &&
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
313 event.key.repeat == 0 /* Ignore key bounce */)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
314 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
315 switch (event.key.keysym.sym)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
316 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
317 case SDLK_ESCAPE:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
318 if (activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
319 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
320 activeTracker_->Cancel();
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
321 if (!activeTracker_->IsAlive())
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
322 activeTracker_.reset();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
323 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
324 break;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
325
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
326 case SDLK_t:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
327 if (!activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
328 SelectNextTool();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
329 else
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
330 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
331 LOG(WARNING) << "You cannot change the active tool when an interaction"
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
332 " is taking place";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
333 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
334 break;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
335
753
Benjamin Golinvaux <bgo@osimis.io>
parents: 750
diff changeset
336 case SDLK_m:
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
337 CreateRandomMeasureTool();
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
338 break;
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
339 case SDLK_s:
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
340 controller_->FitContent(GetCompositor().GetCanvasWidth(),
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
341 GetCompositor().GetCanvasHeight());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
342 break;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
343
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
344 case SDLK_z:
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
345 LOG(TRACE) << "SDLK_z has been pressed. event.key.keysym.mod == " << event.key.keysym.mod;
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
346 if (event.key.keysym.mod & KMOD_CTRL)
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
347 {
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
348 if (controller_->CanUndo())
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
349 {
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
350 LOG(TRACE) << "Undoing...";
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
351 controller_->Undo();
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
352 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
353 else
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
354 {
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
355 LOG(WARNING) << "Nothing to undo!!!";
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
356 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
357 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
358 break;
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
359
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
360 case SDLK_y:
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
361 LOG(TRACE) << "SDLK_y has been pressed. event.key.keysym.mod == " << event.key.keysym.mod;
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
362 if (event.key.keysym.mod & KMOD_CTRL)
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
363 {
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
364 if (controller_->CanRedo())
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
365 {
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
366 LOG(TRACE) << "Redoing...";
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
367 controller_->Redo();
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
368 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
369 else
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
370 {
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
371 LOG(WARNING) << "Nothing to redo!!!";
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
372 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
373 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
374 break;
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
375
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
376 case SDLK_c:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
377 TakeScreenshot(
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
378 "screenshot.png",
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
379 GetCompositor().GetCanvasWidth(),
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
380 GetCompositor().GetCanvasHeight());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
381 break;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
382
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
383 default:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
384 break;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
385 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
386 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
387 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
388
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
389
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
390 void TrackerSampleApp::OnSceneTransformChanged(
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
391 const ViewportController::SceneTransformChanged& message)
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
392 {
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
393 DisplayInfoText();
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
394 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
395
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
396 boost::shared_ptr<IFlexiblePointerTracker> TrackerSampleApp::CreateSuitableTracker(
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
397 const SDL_Event & event,
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
398 const PointerEvent & e)
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
399 {
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
400 using namespace Orthanc;
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
401
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
402 switch (event.button.button)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
403 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
404 case SDL_BUTTON_MIDDLE:
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
405 return boost::shared_ptr<IFlexiblePointerTracker>(new PanSceneTracker
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
406 (controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
407
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
408 case SDL_BUTTON_RIGHT:
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
409 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
410 (controller_, e, GetCompositor().GetCanvasHeight()));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
411
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
412 case SDL_BUTTON_LEFT:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
413 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
414 //LOG(TRACE) << "CreateSuitableTracker: case SDL_BUTTON_LEFT:";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
415 // TODO: we need to iterate on the set of measuring tool and perform
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
416 // a hit test to check if a tracker needs to be created for edition.
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
417 // Otherwise, depending upon the active tool, we might want to create
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
418 // a "measuring tool creation" tracker
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
419
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
420 // TODO: if there are conflicts, we should prefer a tracker that
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
421 // pertains to the type of measuring tool currently selected (TBD?)
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
422 boost::shared_ptr<IFlexiblePointerTracker> hitTestTracker = TrackerHitTest(e);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
423
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
424 if (hitTestTracker != NULL)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
425 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
426 //LOG(TRACE) << "hitTestTracker != NULL";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
427 return hitTestTracker;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
428 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
429 else
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
430 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
431 switch (currentTool_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
432 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
433 case GuiTool_Rotate:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
434 //LOG(TRACE) << "Creating RotateSceneTracker";
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
435 return boost::shared_ptr<IFlexiblePointerTracker>(new RotateSceneTracker(
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
436 controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
437 case GuiTool_Pan:
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
438 return boost::shared_ptr<IFlexiblePointerTracker>(new PanSceneTracker(
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
439 controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
440 case GuiTool_Zoom:
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
441 return boost::shared_ptr<IFlexiblePointerTracker>(new ZoomSceneTracker(
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
442 controller_, e, GetCompositor().GetCanvasHeight()));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
443 //case GuiTool_AngleMeasure:
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 721
diff changeset
444 // return new AngleMeasureTracker(GetScene(), e);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
445 //case GuiTool_CircleMeasure:
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 721
diff changeset
446 // return new CircleMeasureTracker(GetScene(), e);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
447 //case GuiTool_EllipseMeasure:
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 721
diff changeset
448 // return new EllipseMeasureTracker(GetScene(), e);
651
62f6ff016085 Iteration in angle measuring tool. Text label is not ok and handles and arcs
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
449 case GuiTool_LineMeasure:
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
450 return boost::shared_ptr<IFlexiblePointerTracker>(new CreateLineMeasureTracker(
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 721
diff changeset
451 IObserver::GetBroker(), controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
452 case GuiTool_AngleMeasure:
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
453 return boost::shared_ptr<IFlexiblePointerTracker>(new CreateAngleMeasureTracker(
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 721
diff changeset
454 IObserver::GetBroker(), controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
455 case GuiTool_CircleMeasure:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
456 LOG(ERROR) << "Not implemented yet!";
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
457 return boost::shared_ptr<IFlexiblePointerTracker>();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
458 case GuiTool_EllipseMeasure:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
459 LOG(ERROR) << "Not implemented yet!";
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
460 return boost::shared_ptr<IFlexiblePointerTracker>();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
461 default:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
462 throw OrthancException(ErrorCode_InternalError, "Wrong tool!");
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
463 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
464 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
465 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
466 default:
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
467 return boost::shared_ptr<IFlexiblePointerTracker>();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
468 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
469 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
470
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
471
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
472 TrackerSampleApp::TrackerSampleApp(MessageBroker& broker) : IObserver(broker)
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
473 , currentTool_(GuiTool_Rotate)
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 818
diff changeset
474 , undoStack_(new UndoStack)
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
475 , viewport_("Hello", 1024, 1024, false) // False means we do NOT let Windows treat this as a legacy application that needs to be scaled
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
476 {
858
e3c56d4f863f GuiAdapter : mouse event routing in SDL + split the undo stack from the
Benjamin Golinvaux <bgo@osimis.io>
parents: 818
diff changeset
477 controller_ = boost::shared_ptr<ViewportController>(
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
478 new ViewportController(undoStack_, broker, viewport_));
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
479
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
480 controller_->RegisterObserverCallback(
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
481 new Callable<TrackerSampleApp, ViewportController::SceneTransformChanged>
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
482 (*this, &TrackerSampleApp::OnSceneTransformChanged));
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
483
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
484 TEXTURE_2x2_1_ZINDEX = 1;
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
485 TEXTURE_1x1_ZINDEX = 2;
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
486 TEXTURE_2x2_2_ZINDEX = 3;
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
487 LINESET_1_ZINDEX = 4;
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
488 LINESET_2_ZINDEX = 5;
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
489 FLOATING_INFOTEXT_LAYER_ZINDEX = 6;
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
490 FIXED_INFOTEXT_LAYER_ZINDEX = 7;
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
491 }
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
492
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
493 void TrackerSampleApp::PrepareScene()
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
494 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
495 // Texture of 2x2 size
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
496 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
497 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 2, 2, false);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
498
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
499 uint8_t* p = reinterpret_cast<uint8_t*>(i.GetRow(0));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
500 p[0] = 255;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
501 p[1] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
502 p[2] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
503
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
504 p[3] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
505 p[4] = 255;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
506 p[5] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
507
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
508 p = reinterpret_cast<uint8_t*>(i.GetRow(1));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
509 p[0] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
510 p[1] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
511 p[2] = 255;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
512
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
513 p[3] = 255;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
514 p[4] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
515 p[5] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
516
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
517 controller_->GetScene().SetLayer(TEXTURE_2x2_1_ZINDEX, new ColorTextureSceneLayer(i));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
518
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
519 std::unique_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
520 l->SetOrigin(-3, 2);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
521 l->SetPixelSpacing(1.5, 1);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
522 l->SetAngle(20.0 / 180.0 * M_PI);
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
523 controller_->GetScene().SetLayer(TEXTURE_2x2_2_ZINDEX, l.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
524 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
525
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
526 // Texture of 1x1 size
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
527 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
528 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 1, 1, false);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
529
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
530 uint8_t* p = reinterpret_cast<uint8_t*>(i.GetRow(0));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
531 p[0] = 255;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
532 p[1] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
533 p[2] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
534
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
535 std::unique_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
536 l->SetOrigin(-2, 1);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
537 l->SetAngle(20.0 / 180.0 * M_PI);
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
538 controller_->GetScene().SetLayer(TEXTURE_1x1_ZINDEX, l.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
539 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
540
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
541 // Some lines
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
542 {
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
543 std::unique_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
544
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
545 layer->SetThickness(1);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
546
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
547 PolylineSceneLayer::Chain chain;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
548 chain.push_back(ScenePoint2D(0 - 0.5, 0 - 0.5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
549 chain.push_back(ScenePoint2D(0 - 0.5, 2 - 0.5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
550 chain.push_back(ScenePoint2D(2 - 0.5, 2 - 0.5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
551 chain.push_back(ScenePoint2D(2 - 0.5, 0 - 0.5));
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
552 layer->AddChain(chain, true, 255, 0, 0);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
553
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
554 chain.clear();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
555 chain.push_back(ScenePoint2D(-5, -5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
556 chain.push_back(ScenePoint2D(5, -5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
557 chain.push_back(ScenePoint2D(5, 5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
558 chain.push_back(ScenePoint2D(-5, 5));
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
559 layer->AddChain(chain, true, 0, 255, 0);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
560
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
561 double dy = 1.01;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
562 chain.clear();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
563 chain.push_back(ScenePoint2D(-4, -4));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
564 chain.push_back(ScenePoint2D(4, -4 + dy));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
565 chain.push_back(ScenePoint2D(-4, -4 + 2.0 * dy));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
566 chain.push_back(ScenePoint2D(4, 2));
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
567 layer->AddChain(chain, false, 0, 0, 255);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
568
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
569 controller_->GetScene().SetLayer(LINESET_1_ZINDEX, layer.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
570 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
571
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
572 // Some text
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
573 {
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
574 std::unique_ptr<TextSceneLayer> layer(new TextSceneLayer);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
575 layer->SetText("Hello");
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
576 controller_->GetScene().SetLayer(LINESET_2_ZINDEX, layer.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
577 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
578 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
579
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
580
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
581 void TrackerSampleApp::DisableTracker()
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
582 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
583 if (activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
584 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
585 activeTracker_->Cancel();
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
586 activeTracker_.reset();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
587 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
588 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
589
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
590 void TrackerSampleApp::TakeScreenshot(const std::string& target,
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
591 unsigned int canvasWidth,
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
592 unsigned int canvasHeight)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
593 {
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
594 CairoCompositor compositor(controller_->GetScene(), canvasWidth, canvasHeight);
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
595 compositor.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, FONT_SIZE_0, Orthanc::Encoding_Latin1);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
596 compositor.Refresh();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
597
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
598 Orthanc::ImageAccessor canvas;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
599 compositor.GetCanvas().GetReadOnlyAccessor(canvas);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
600
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
601 Orthanc::Image png(Orthanc::PixelFormat_RGB24, canvas.GetWidth(), canvas.GetHeight(), false);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
602 Orthanc::ImageProcessing::Convert(png, canvas);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
603
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
604 Orthanc::PngWriter writer;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
605 writer.WriteToFile(target, png);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
606 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
607
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
608
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
609 boost::shared_ptr<IFlexiblePointerTracker> TrackerSampleApp::TrackerHitTest(const PointerEvent & e)
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
610 {
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
611 // std::vector<boost::shared_ptr<MeasureTool>> measureTools_;
871
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
612 ScenePoint2D scenePos = e.GetMainPosition().Apply(
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 890
diff changeset
613 controller_->GetScene().GetCanvasToSceneTransform());
871
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
614
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
615 std::vector<boost::shared_ptr<MeasureTool> > measureTools = controller_->HitTestMeasureTools(scenePos);
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
616
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
617 if (measureTools.size() > 0)
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
618 {
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
619 return measureTools[0]->CreateEditionTracker(e);
4bc8d9609447 Added support for measuring tool edition in TrackerSampleApp
Benjamin Golinvaux <bgo@osimis.io>
parents: 858
diff changeset
620 }
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
621 return boost::shared_ptr<IFlexiblePointerTracker>();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
622 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
623
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
624 static void GLAPIENTRY
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
625 OpenGLMessageCallback(GLenum source,
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
626 GLenum type,
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
627 GLuint id,
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
628 GLenum severity,
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
629 GLsizei length,
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
630 const GLchar* message,
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
631 const void* userParam)
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
632 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
633 if (severity != GL_DEBUG_SEVERITY_NOTIFICATION)
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
634 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
635 fprintf(stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n",
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
636 (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""),
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
637 type, severity, message);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
638 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
639 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
640
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
641 static bool g_stopApplication = false;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
642
938
eaaa9b574e05 Fixed the Stone samples wrt the recent API changes (SdlOpenGLViewport, ICompositor...)
Benjamin Golinvaux <bgo@osimis.io>
parents: 900
diff changeset
643 ICompositor& TrackerSampleApp::GetCompositor()
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
644 {
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
645 using namespace Orthanc;
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
646 try
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
647 {
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
648 SdlViewport& viewport = dynamic_cast<SdlViewport&>(viewport_);
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
649 return viewport.GetCompositor();
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
650 }
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
651 catch (std::bad_cast e)
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
652 {
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
653 throw OrthancException(ErrorCode_InternalError, "Wrong viewport type!");
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
654 }
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
655 }
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
656
938
eaaa9b574e05 Fixed the Stone samples wrt the recent API changes (SdlOpenGLViewport, ICompositor...)
Benjamin Golinvaux <bgo@osimis.io>
parents: 900
diff changeset
657 const ICompositor& TrackerSampleApp::GetCompositor() const
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
658 {
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
659 using namespace Orthanc;
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
660 try
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
661 {
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
662 SdlViewport& viewport = const_cast<SdlViewport&>(dynamic_cast<const SdlViewport&>(viewport_));
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
663 return viewport.GetCompositor();
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
664 }
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
665 catch (std::bad_cast e)
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
666 {
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
667 throw OrthancException(ErrorCode_InternalError, "Wrong viewport type!");
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
668 }
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
669 }
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
670
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
671
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
672 void TrackerSampleApp::Run()
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
673 {
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
674 controller_->FitContent(viewport_.GetCanvasWidth(), viewport_.GetCanvasHeight());
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
675
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
676 glEnable(GL_DEBUG_OUTPUT);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
677 glDebugMessageCallback(OpenGLMessageCallback, 0);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
678
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
679 GetCompositor().SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT,
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
680 FONT_SIZE_0, Orthanc::Encoding_Latin1);
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
681 GetCompositor().SetFont(1, Orthanc::EmbeddedResources::UBUNTU_FONT,
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
682 FONT_SIZE_1, Orthanc::Encoding_Latin1);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
683
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
684 while (!g_stopApplication)
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
685 {
893
0c5201499af8 Fixes to TrackerSampleApp following IViewport refactoring (FusionMprSdl not working yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 891
diff changeset
686 GetCompositor().Refresh();
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
687
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
688 SDL_Event event;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
689 while (!g_stopApplication && SDL_PollEvent(&event))
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
690 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
691 if (event.type == SDL_QUIT)
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
692 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
693 g_stopApplication = true;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
694 break;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
695 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
696 else if (event.type == SDL_WINDOWEVENT &&
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
697 event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
698 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
699 DisableTracker(); // was: tracker.reset(NULL);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
700 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
701 else if (event.type == SDL_KEYDOWN &&
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
702 event.key.repeat == 0 /* Ignore key bounce */)
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
703 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
704 switch (event.key.keysym.sym)
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
705 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
706 case SDLK_f:
938
eaaa9b574e05 Fixed the Stone samples wrt the recent API changes (SdlOpenGLViewport, ICompositor...)
Benjamin Golinvaux <bgo@osimis.io>
parents: 900
diff changeset
707 viewport_.GetWindow().ToggleMaximize();
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
708 break;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
709
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
710 case SDLK_q:
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
711 g_stopApplication = true;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
712 break;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
713 default:
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
714 break;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
715 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
716 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
717 HandleApplicationEvent(event);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
718 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
719 SDL_Delay(1);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
720 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
721 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
722
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
723 void TrackerSampleApp::SetInfoDisplayMessage(
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
724 std::string key, std::string value)
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
725 {
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
726 if (value == "")
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
727 infoTextMap_.erase(key);
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
728 else
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
729 infoTextMap_[key] = value;
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
730 DisplayInfoText();
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
731 }
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
732
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
733 }