annotate Samples/Sdl/TrackerSampleApp.cpp @ 819:a68cd7ae8838

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 29 May 2019 13:39:31 +0200
parents 61ba4b504e9a
children e42b491f1fb2
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
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
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
737
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
23 #include "../../Applications/Sdl/SdlOpenGLWindow.h"
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24
737
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
25 #include "../../Framework/Scene2D/CairoCompositor.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
26 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
27 #include "../../Framework/Scene2D/OpenGLCompositor.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
28 #include "../../Framework/Scene2D/PanSceneTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
29 #include "../../Framework/Scene2D/RotateSceneTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
30 #include "../../Framework/Scene2D/Scene2D.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
31 #include "../../Framework/Scene2D/ZoomSceneTracker.h"
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 using namespace Orthanc;
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 namespace OrthancStone
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 const char* MeasureToolToString(size_t i)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 static const char* descs[] = {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 "GuiTool_Rotate",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 "GuiTool_Pan",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 "GuiTool_Zoom",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 "GuiTool_LineMeasure",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 "GuiTool_CircleMeasure",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 "GuiTool_AngleMeasure",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 "GuiTool_EllipseMeasure",
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 "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 if (i >= GuiTool_LAST)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Wrong tool index");
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 return descs[i];
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
72 Scene2DPtr TrackerSampleApp::GetScene()
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 {
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
74 return controller_->GetScene();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
77 Scene2DConstPtr TrackerSampleApp::GetScene() const
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
78 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
79 return controller_->GetScene();
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
80 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
81
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 void TrackerSampleApp::SelectNextTool()
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 currentTool_ = static_cast<GuiTool>(currentTool_ + 1);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 if (currentTool_ == GuiTool_LAST)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 currentTool_ = static_cast<GuiTool>(0);;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 printf("Current tool is now: %s\n", MeasureToolToString(currentTool_));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
90 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
91 {
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
92 // 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
93 if (compositor_.get() == NULL)
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
94 return;
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
95
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
96 std::stringstream msg;
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
97
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
98 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
99 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
100 {
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
101 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
102 }
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
103 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
104
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
105 TextSceneLayer* layerP = NULL;
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
106 if (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
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 TextSceneLayer& layer = dynamic_cast<TextSceneLayer&>(
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
109 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
110 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
111 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
112 else
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
113 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
114 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
115 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
116 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
117 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
118 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
119 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
120 //layer->SetPosition(0,0);
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
121 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
122 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
123 // 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
124 layerP->SetText(msgS.c_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
125 double cX = compositor_->GetCanvasWidth() * (-0.5);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
126 double cY = compositor_->GetCanvasHeight() * (-0.5);
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
127 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
128 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
129 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
130
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
131 void TrackerSampleApp::DisplayFloatingCtrlInfoText(const PointerEvent& e)
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 {
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
133 ScenePoint2D p = e.GetMainPosition().Apply(GetScene()->GetCanvasToSceneTransform());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
135 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
136 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
137 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
138 e.GetMainPosition().GetX(), e.GetMainPosition().GetY());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
140 if (GetScene()->HasLayer(FLOATING_INFOTEXT_LAYER_ZINDEX))
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 TextSceneLayer& layer =
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
143 dynamic_cast<TextSceneLayer&>(GetScene()->GetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 layer.SetText(buf);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 layer.SetPosition(p.GetX(), p.GetY());
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 else
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150 layer->SetColor(0, 255, 0);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 layer->SetText(buf);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152 layer->SetBorder(20);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
153 layer->SetAnchor(BitmapAnchor_BottomCenter);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 layer->SetPosition(p.GetX(), p.GetY());
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
155 GetScene()->SetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX, layer.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159 void TrackerSampleApp::HideInfoText()
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 {
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
161 GetScene()->DeleteLayer(FLOATING_INFOTEXT_LAYER_ZINDEX);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
164 ScenePoint2D TrackerSampleApp::GetRandomPointInScene() const
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
165 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
166 unsigned int w = compositor_->GetCanvasWidth();
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
167 LOG(TRACE) << "compositor_->GetCanvasWidth() = " <<
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
168 compositor_->GetCanvasWidth();
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
169 unsigned int h = compositor_->GetCanvasHeight();
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
170 LOG(TRACE) << "compositor_->GetCanvasHeight() = " <<
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
171 compositor_->GetCanvasHeight();
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 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
174 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
175
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
176 int x = rand() % w;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
177 int y = rand() % h;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
178 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
179
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
180 ScenePoint2D p = compositor_->GetPixelCenterCoordinates(x, y);
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
181 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
182
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
183 ScenePoint2D r = p.Apply(GetScene()->GetCanvasToSceneTransform());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
184 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
185 return r;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
186 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
187
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
188 void TrackerSampleApp::CreateRandomMeasureTool()
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
189 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
190 static bool srandCalled = false;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
191 if (!srandCalled)
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
192 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
193 srand(42);
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
194 srandCalled = true;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
195 }
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 int i = rand() % 2;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
198 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
199 switch (i)
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
200 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
201 case 0:
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
202 // line measure
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
203 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
204 CreateLineMeasureCommandPtr cmd =
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
205 boost::make_shared<CreateLineMeasureCommand>(
787
1a28fce57ff3 Fixed Visual Studio 2008 build
Benjamin Golinvaux <bgo@osimis.io>
parents: 761
diff changeset
206 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
207 controller_,
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
208 GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
209 cmd->SetEnd(GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
210 controller_->PushCommand(cmd);
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 break;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
213 case 1:
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
214 // angle measure
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
215 {
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
216 CreateAngleMeasureCommandPtr cmd =
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
217 boost::make_shared<CreateAngleMeasureCommand>(
787
1a28fce57ff3 Fixed Visual Studio 2008 build
Benjamin Golinvaux <bgo@osimis.io>
parents: 761
diff changeset
218 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
219 controller_,
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
220 GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
221 cmd->SetCenter(GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
222 cmd->SetSide2End(GetRandomPointInScene());
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
223 controller_->PushCommand(cmd);
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
224 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
225 break;
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
226 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
227 }
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
228
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
229 void TrackerSampleApp::HandleApplicationEvent(
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
230 const SDL_Event & event)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
231 {
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 DisplayInfoText();
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
233
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
234 if (event.type == SDL_MOUSEMOTION)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
235 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
236 int scancodeCount = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
237 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
238
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
239 if (activeTracker_.get() == NULL &&
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
240 SDL_SCANCODE_LALT < scancodeCount &&
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
241 keyboardState[SDL_SCANCODE_LALT])
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
242 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
243 // The "left-ctrl" key is down, while no tracker is present
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
244 // Let's display the info text
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
245 PointerEvent e;
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
246 e.AddPosition(compositor_->GetPixelCenterCoordinates(
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
247 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
248
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
249 DisplayFloatingCtrlInfoText(e);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
250 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
251 else
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
253 HideInfoText();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
254 //LOG(TRACE) << "(event.type == SDL_MOUSEMOTION)";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
255 if (activeTracker_.get() != NULL)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
256 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
257 //LOG(TRACE) << "(activeTracker_.get() != NULL)";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
258 PointerEvent e;
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
259 e.AddPosition(compositor_->GetPixelCenterCoordinates(
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
260 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
261
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
262 //LOG(TRACE) << "event.button.x = " << event.button.x << " " <<
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
263 // "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
264 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
265 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
266
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
267 activeTracker_->PointerMove(e);
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
268 if (!activeTracker_->IsAlive())
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
269 activeTracker_.reset();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
270 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
271 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
272 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
273 else if (event.type == SDL_MOUSEBUTTONUP)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
274 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
275 if (activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
276 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
277 PointerEvent e;
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
278 e.AddPosition(compositor_->GetPixelCenterCoordinates(event.button.x, event.button.y));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
279 activeTracker_->PointerUp(e);
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
280 if (!activeTracker_->IsAlive())
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
281 activeTracker_.reset();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
282 }
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_MOUSEBUTTONDOWN)
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 PointerEvent e;
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
287 e.AddPosition(compositor_->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
288 event.button.x, event.button.y));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
289 if (activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
290 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
291 activeTracker_->PointerDown(e);
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
292 if (!activeTracker_->IsAlive())
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
293 activeTracker_.reset();
644
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
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 // 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
298 activeTracker_ = CreateSuitableTracker(event, e);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
299 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
300 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
301 else if (event.type == SDL_KEYDOWN &&
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
302 event.key.repeat == 0 /* Ignore key bounce */)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
303 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
304 switch (event.key.keysym.sym)
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 case SDLK_ESCAPE:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
307 if (activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
308 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
309 activeTracker_->Cancel();
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
310 if (!activeTracker_->IsAlive())
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
311 activeTracker_.reset();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
312 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
313 break;
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 case SDLK_t:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
316 if (!activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
317 SelectNextTool();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
318 else
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 LOG(WARNING) << "You cannot change the active tool when an interaction"
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
321 " is taking place";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
322 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
323 break;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
324
753
Benjamin Golinvaux <bgo@osimis.io>
parents: 750
diff changeset
325 case SDLK_m:
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
326 CreateRandomMeasureTool();
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
327 break;
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
328 case SDLK_s:
721
af0aa0c149fa FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents: 706
diff changeset
329 controller_->FitContent(compositor_->GetCanvasWidth(),
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
330 compositor_->GetCanvasHeight());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
331 break;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
332
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
333 case SDLK_z:
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
334 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
335 if (event.key.keysym.mod & KMOD_CTRL)
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
336 {
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
337 if (controller_->CanUndo())
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
338 {
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
339 LOG(TRACE) << "Undoing...";
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
340 controller_->Undo();
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
341 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
342 else
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
343 {
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
344 LOG(WARNING) << "Nothing to undo!!!";
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
345 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
346 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
347 break;
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
348
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
349 case SDLK_y:
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
350 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
351 if (event.key.keysym.mod & KMOD_CTRL)
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 if (controller_->CanRedo())
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
354 {
761
07adcffba38c truncation warning fixes + CRLF -> LF + random measuring tool creation (keyb
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
355 LOG(TRACE) << "Redoing...";
750
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
356 controller_->Redo();
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 else
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 LOG(WARNING) << "Nothing to redo!!!";
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
361 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
362 }
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
363 break;
284f37dc1c66 Wired undo redo to keys
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
364
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
365 case SDLK_c:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
366 TakeScreenshot(
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
367 "screenshot.png",
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
368 compositor_->GetCanvasWidth(),
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
369 compositor_->GetCanvasHeight());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
370 break;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
371
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
372 default:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
373 break;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
374 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
375 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
376 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
377
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
378
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
379 void TrackerSampleApp::OnSceneTransformChanged(
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
380 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
381 {
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
382 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
383 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
384
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
385 FlexiblePointerTrackerPtr TrackerSampleApp::CreateSuitableTracker(
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
386 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
387 const PointerEvent & e)
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
388 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
389 switch (event.button.button)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
390 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
391 case SDL_BUTTON_MIDDLE:
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
392 return FlexiblePointerTrackerPtr(new PanSceneTracker
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
393 (controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
394
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
395 case SDL_BUTTON_RIGHT:
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
396 return FlexiblePointerTrackerPtr(new ZoomSceneTracker
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
397 (controller_, e, compositor_->GetCanvasHeight()));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
398
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
399 case SDL_BUTTON_LEFT:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
400 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
401 //LOG(TRACE) << "CreateSuitableTracker: case SDL_BUTTON_LEFT:";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
402 // 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
403 // 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
404 // Otherwise, depending upon the active tool, we might want to create
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
405 // a "measuring tool creation" tracker
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
406
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
407 // TODO: if there are conflicts, we should prefer a tracker that
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
408 // pertains to the type of measuring tool currently selected (TBD?)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
409 FlexiblePointerTrackerPtr hitTestTracker = TrackerHitTest(e);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
410
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
411 if (hitTestTracker != NULL)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
412 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
413 //LOG(TRACE) << "hitTestTracker != NULL";
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
414 return hitTestTracker;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
415 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
416 else
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
417 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
418 switch (currentTool_)
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 case GuiTool_Rotate:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
421 //LOG(TRACE) << "Creating RotateSceneTracker";
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
422 return FlexiblePointerTrackerPtr(new RotateSceneTracker(
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
423 controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
424 case GuiTool_Pan:
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
425 return FlexiblePointerTrackerPtr(new PanSceneTracker(
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
426 controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
427 case GuiTool_Zoom:
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
428 return FlexiblePointerTrackerPtr(new ZoomSceneTracker(
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
429 controller_, e, compositor_->GetCanvasHeight()));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
430 //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
431 // return new AngleMeasureTracker(GetScene(), e);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
432 //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
433 // return new CircleMeasureTracker(GetScene(), e);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
434 //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
435 // 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
436 case GuiTool_LineMeasure:
62f6ff016085 Iteration in angle measuring tool. Text label is not ok and handles and arcs
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
437 return FlexiblePointerTrackerPtr(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
438 IObserver::GetBroker(), controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
439 case GuiTool_AngleMeasure:
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
440 return FlexiblePointerTrackerPtr(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
441 IObserver::GetBroker(), controller_, e));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
442 case GuiTool_CircleMeasure:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
443 LOG(ERROR) << "Not implemented yet!";
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
444 return FlexiblePointerTrackerPtr();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
445 case GuiTool_EllipseMeasure:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
446 LOG(ERROR) << "Not implemented yet!";
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
447 return FlexiblePointerTrackerPtr();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
448 default:
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
449 throw OrthancException(ErrorCode_InternalError, "Wrong tool!");
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
450 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
451 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
452 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
453 default:
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
454 return FlexiblePointerTrackerPtr();
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
455 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
456 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
457
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
458
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
459 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
460 , currentTool_(GuiTool_Rotate)
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
461 {
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
462 controller_ = ViewportControllerPtr(new ViewportController(broker));
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
463
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
464 controller_->RegisterObserverCallback(
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
465 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
466 (*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
467
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
468 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
469 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
470 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
471 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
472 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
473 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
474 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
475 }
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
476
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
477 void TrackerSampleApp::PrepareScene()
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
478 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
479 // Texture of 2x2 size
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
480 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
481 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 2, 2, false);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
482
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
483 uint8_t* p = reinterpret_cast<uint8_t*>(i.GetRow(0));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
484 p[0] = 255;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
485 p[1] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
486 p[2] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
487
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
488 p[3] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
489 p[4] = 255;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
490 p[5] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
491
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
492 p = reinterpret_cast<uint8_t*>(i.GetRow(1));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
493 p[0] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
494 p[1] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
495 p[2] = 255;
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 p[3] = 255;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
498 p[4] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
499 p[5] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
500
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
501 GetScene()->SetLayer(TEXTURE_2x2_1_ZINDEX, new ColorTextureSceneLayer(i));
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
502
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
503 std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
504 l->SetOrigin(-3, 2);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
505 l->SetPixelSpacing(1.5, 1);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
506 l->SetAngle(20.0 / 180.0 * M_PI);
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
507 GetScene()->SetLayer(TEXTURE_2x2_2_ZINDEX, l.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
508 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
509
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
510 // Texture of 1x1 size
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
511 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
512 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 1, 1, false);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
513
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
514 uint8_t* p = reinterpret_cast<uint8_t*>(i.GetRow(0));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
515 p[0] = 255;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
516 p[1] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
517 p[2] = 0;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
518
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
519 std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
520 l->SetOrigin(-2, 1);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
521 l->SetAngle(20.0 / 180.0 * M_PI);
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
522 GetScene()->SetLayer(TEXTURE_1x1_ZINDEX, l.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
523 }
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 // Some lines
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
526 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
527 std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
528
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
529 layer->SetThickness(1);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
530
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
531 PolylineSceneLayer::Chain chain;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
532 chain.push_back(ScenePoint2D(0 - 0.5, 0 - 0.5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
533 chain.push_back(ScenePoint2D(0 - 0.5, 2 - 0.5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
534 chain.push_back(ScenePoint2D(2 - 0.5, 2 - 0.5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
535 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
536 layer->AddChain(chain, true, 255, 0, 0);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
537
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
538 chain.clear();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
539 chain.push_back(ScenePoint2D(-5, -5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
540 chain.push_back(ScenePoint2D(5, -5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
541 chain.push_back(ScenePoint2D(5, 5));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
542 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
543 layer->AddChain(chain, true, 0, 255, 0);
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 double dy = 1.01;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
546 chain.clear();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
547 chain.push_back(ScenePoint2D(-4, -4));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
548 chain.push_back(ScenePoint2D(4, -4 + dy));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
549 chain.push_back(ScenePoint2D(-4, -4 + 2.0 * dy));
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
550 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
551 layer->AddChain(chain, false, 0, 0, 255);
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
552
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
553 GetScene()->SetLayer(LINESET_1_ZINDEX, layer.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
554 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
555
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
556 // Some text
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
557 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
558 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
559 layer->SetText("Hello");
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents: 660
diff changeset
560 GetScene()->SetLayer(LINESET_2_ZINDEX, layer.release());
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
561 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
562 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
563
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
564
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
565 void TrackerSampleApp::DisableTracker()
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
566 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
567 if (activeTracker_)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
568 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
569 activeTracker_->Cancel();
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
570 activeTracker_.reset();
644
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 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
573
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
574 void TrackerSampleApp::TakeScreenshot(const std::string& target,
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
575 unsigned int canvasWidth,
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
576 unsigned int canvasHeight)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
577 {
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
578 CairoCompositor compositor(*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
579 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
580 compositor.Refresh();
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
581
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
582 Orthanc::ImageAccessor canvas;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
583 compositor.GetCanvas().GetReadOnlyAccessor(canvas);
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 Orthanc::Image png(Orthanc::PixelFormat_RGB24, canvas.GetWidth(), canvas.GetHeight(), false);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
586 Orthanc::ImageProcessing::Convert(png, canvas);
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 Orthanc::PngWriter writer;
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
589 writer.WriteToFile(target, png);
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
590 }
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
591
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
592
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
593 FlexiblePointerTrackerPtr TrackerSampleApp::TrackerHitTest(const PointerEvent & e)
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
594 {
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
595 // std::vector<MeasureToolPtr> measureTools_;
706
ef07304d4423 Fixed C++ code to be C++03 compatible
Benjamin Golinvaux <bgo@osimis.io>
parents: 700
diff changeset
596 return FlexiblePointerTrackerPtr();
644
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
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
599 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
600 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
601 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
602 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
603 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
604 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
605 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
606 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
607 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
608 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
609 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
610 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
611 (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
612 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
613 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
614 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
615
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
616 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
617
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
618 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
619 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
620 // False means we do NOT let Windows treat this as a legacy application
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
621 // that needs to be scaled
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
622 SdlOpenGLWindow window("Hello", 1024, 1024, false);
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
623
721
af0aa0c149fa FitContent is now wrapped by the controller (for observability)
Benjamin Golinvaux <bgo@osimis.io>
parents: 706
diff changeset
624 controller_->FitContent(window.GetCanvasWidth(), window.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
625
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
626 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
627 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
628
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
629 compositor_.reset(new OpenGLCompositor(window, *GetScene()));
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
630
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
631 compositor_->SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT,
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
632 FONT_SIZE_0, 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
633 compositor_->SetFont(1, Orthanc::EmbeddedResources::UBUNTU_FONT,
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
634 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
635
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
636 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
637 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
638 compositor_->Refresh();
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 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
641 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
642 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
643 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
644 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
645 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
646 break;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
647 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
648 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
649 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
650 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
651 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
652 compositor_->UpdateSize();
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
653 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
654 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
655 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
656 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
657 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
658 {
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
659 case SDLK_f:
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
660 window.GetWindow().ToggleMaximize();
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
661 break;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
662
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
663 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
664 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
665 break;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
666 default:
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
667 break;
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
668 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
669 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
670 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
671 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
672 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
673 }
700
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
674
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
675 // the following is paramount because the compositor holds a reference
059e1fd05fd6 Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents: 699
diff changeset
676 // to the scene and we do not want this reference to become dangling
656
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
677 compositor_.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
678 }
002d9562c8f5 Added support to DISABLE legacy scaling in SDL Windows (only in WIN32... this
Benjamin Golinvaux <bgo@osimis.io>
parents: 654
diff changeset
679
660
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
680 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
681 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
682 {
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
683 if (value == "")
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
684 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
685 else
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
686 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
687 DisplayInfoText();
cb3b76d16234 Added info display map to the app + global logging function + fixed bisecting
Benjamin Golinvaux <bgo@osimis.io>
parents: 656
diff changeset
688 }
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
689
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
690 }