Mercurial > hg > orthanc-stone
annotate Framework/Scene2D/PanSceneTracker.cpp @ 1370:28eb7106ef44 broker
Changes to GuiAdapter to allow it to work correctly with both new and old
Emscripten event selection rules that are defined by the DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR linker flag.
Doc has been added to GuiAdapter.cpp, should you require more info on
what has been done.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 20 Apr 2020 13:08:43 +0200 |
parents | ab81ee8fce1f |
children |
rev | line source |
---|---|
596 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
596 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "PanSceneTracker.h" | |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
23 #include "../Viewport/IViewport.h" |
736
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
700
diff
changeset
|
24 #include "../Scene2DViewport/ViewportController.h" |
596 | 25 |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
26 #include <memory> |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
27 |
596 | 28 namespace OrthancStone |
29 { | |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1305
diff
changeset
|
30 PanSceneTracker::PanSceneTracker(boost::shared_ptr<IViewport> viewport, |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
596
diff
changeset
|
31 const PointerEvent& event) |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
32 : OneGesturePointerTracker(viewport) |
596 | 33 { |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
34 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1305
diff
changeset
|
35 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
36 |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
37 originalSceneToCanvas_ = lock->GetController().GetSceneToCanvasTransform(); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
38 originalCanvasToScene_ = lock->GetController().GetCanvasToSceneTransform(); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
39 |
596 | 40 pivot_ = event.GetMainPosition().Apply(originalCanvasToScene_); |
41 } | |
42 | |
43 | |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
596
diff
changeset
|
44 void PanSceneTracker::PointerMove(const PointerEvent& event) |
596 | 45 { |
46 ScenePoint2D p = event.GetMainPosition().Apply(originalCanvasToScene_); | |
959
13e078adfb94
Better error log in fetch failure callback +
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
47 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1305
diff
changeset
|
48 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
49 |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
50 lock->GetController().SetSceneToCanvasTransform( |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
51 AffineTransform2D::Combine( |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
52 originalSceneToCanvas_, |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
53 AffineTransform2D::CreateOffset(p.GetX() - pivot_.GetX(), |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
54 p.GetY() - pivot_.GetY()))); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
55 lock->Invalidate(); |
596 | 56 } |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
596
diff
changeset
|
57 |
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
596
diff
changeset
|
58 void PanSceneTracker::Cancel() |
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
596
diff
changeset
|
59 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1305
diff
changeset
|
60 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1270
diff
changeset
|
61 lock->GetController().SetSceneToCanvasTransform(originalSceneToCanvas_); |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
596
diff
changeset
|
62 } |
596 | 63 } |