annotate OrthancStone/Sources/Scene2D/GrayscaleWindowingSceneTracker.cpp @ 2008:37d6805b80ee deep-learning

integration mainline->deep-learning
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 18 Nov 2022 00:37:00 +0100
parents 5a434f5889f8
children 07964689cb0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
16 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1533
diff changeset
17 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
19 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
20 * <http://www.gnu.org/licenses/>.
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "GrayscaleWindowingSceneTracker.h"
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../Scene2DViewport/ViewportController.h"
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "FloatTextureSceneLayer.h"
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <OrthancException.h>
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 namespace
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 class GrayscaleLayerAccessor : public boost::noncopyable
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 private:
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 std::unique_ptr<IViewport::ILock> lock_;
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 FloatTextureSceneLayer* layer_;
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 public:
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
42 GrayscaleLayerAccessor(boost::weak_ptr<IViewport> viewportWeak,
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 int layerIndex) :
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 layer_(NULL)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
46 boost::shared_ptr<IViewport> viewport = viewportWeak.lock();
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 if (viewport != NULL)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 lock_.reset(viewport->Lock());
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 if (lock_->GetController().GetScene().HasLayer(layerIndex))
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 ISceneLayer& layer = lock_->GetController().GetScene().GetLayer(layerIndex);
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 if (layer.GetType() == ISceneLayer::Type_FloatTexture)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 layer_ = &dynamic_cast<FloatTextureSceneLayer&>(layer);
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 bool IsValid() const
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 return layer_ != NULL;
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 FloatTextureSceneLayer& GetLayer() const
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 if (layer_ == NULL)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 else
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 return *layer_;
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 void Invalidate()
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 if (lock_.get() != NULL)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 lock_->Invalidate();
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
1721
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
86
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
87 void BroadcastGrayscaleWindowingChanged(double center,
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
88 double width)
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
89 {
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
90 if (lock_.get() != NULL)
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
91 {
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
92 lock_->GetController().BroadcastGrayscaleWindowingChanged(center, width);
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
93 }
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
94 }
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 };
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 void GrayscaleWindowingSceneTracker::SetWindowing(float center,
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 float width)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 if (active_)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 {
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
103 boost::shared_ptr<IViewport> viewport = viewport_.lock();
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
104 GrayscaleLayerAccessor accessor(viewport, layerIndex_);
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 if (accessor.IsValid())
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 accessor.GetLayer().SetCustomWindowing(center, width);
1721
d4a8e2b19a65 new "GrayscaleWindowingChanged" message from GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1639
diff changeset
109 accessor.BroadcastGrayscaleWindowingChanged(center, width);
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 accessor.Invalidate();
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
116 GrayscaleWindowingSceneTracker::GrayscaleWindowingSceneTracker(boost::weak_ptr<IViewport> viewport,
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 int layerIndex,
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 const PointerEvent& event,
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 unsigned int canvasWidth,
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 unsigned int canvasHeight) :
1972
9c0adcc8feec refactoring to simplify OneGesturePointerTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
121 viewport_(viewport),
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 layerIndex_(layerIndex),
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 clickX_(event.GetMainPosition().GetX()),
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 clickY_(event.GetMainPosition().GetY())
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 active_ = false;
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 if (canvasWidth > 3 &&
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 canvasHeight > 3)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
1639
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
131 boost::shared_ptr<IViewport> locked = viewport_.lock();
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
132
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
133 if (locked)
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
134 {
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
135 GrayscaleLayerAccessor accessor(locked, layerIndex_);
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
1639
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
137 if (accessor.IsValid())
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
138 {
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
139 FloatTextureSceneLayer& layer = accessor.GetLayer();
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
1639
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
141 layer.GetWindowing(originalCenter_, originalWidth_);
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
142
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
143 float minValue, maxValue;
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
144 layer.GetRange(minValue, maxValue);
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145
1639
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
146 normalization_ = (maxValue - minValue) / static_cast<double>(std::min(canvasWidth, canvasHeight) - 1);
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
147 active_ = true;
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
148 }
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
149 else
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
150 {
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
151 LOG(INFO) << "Cannot create GrayscaleWindowingSceneTracker on a non-float texture";
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
152 }
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
1972
9c0adcc8feec refactoring to simplify OneGesturePointerTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
157 void GrayscaleWindowingSceneTracker::PointerMove(const PointerEvent& event,
9c0adcc8feec refactoring to simplify OneGesturePointerTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
158 const Scene2D& scene)
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 if (active_)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 const double x = event.GetMainPosition().GetX();
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 const double y = event.GetMainPosition().GetY();
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
165 float center = originalCenter_ + static_cast<float>((x - clickX_) * normalization_);
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
166 float width = originalWidth_ + static_cast<float>((y - clickY_) * normalization_);
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 if (width <= 1)
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 width = 1;
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 SetWindowing(center, width);
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
1975
5a434f5889f8 starting pixel probe
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1972
diff changeset
177 void GrayscaleWindowingSceneTracker::Cancel(const Scene2D& scene)
1533
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 {
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 SetWindowing(originalCenter_, originalWidth_);
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 }
82279abb92d0 GrayscaleWindowingSceneTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 }