annotate Framework/Widgets/PanMouseTracker.cpp @ 332:50e5ec1bdd46 am-2

separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 Oct 2018 19:38:39 +0200
parents
children 99e31898910e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
332
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "PanMouseTracker.h"
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include <Core/Logging.h>
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 namespace OrthancStone
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 {
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 PanMouseTracker::PanMouseTracker(WorldSceneWidget& that,
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 int x,
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 int y) :
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 that_(that)
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 that.GetView().GetPan(originalPanX_, originalPanY_);
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 that.GetView().MapPixelCenterToScene(downX_, downY_, x, y);
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 }
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 void PanMouseTracker::Render(CairoContext& context,
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 double zoom)
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 }
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 void PanMouseTracker::MouseMove(int displayX,
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 int displayY,
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 double x,
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 double y)
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 ViewportGeometry view = that_.GetView();
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 view.SetPan(originalPanX_ + (x - downX_) * view.GetZoom(),
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 originalPanY_ + (y - downY_) * view.GetZoom());
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 that_.SetView(view);
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
50e5ec1bdd46 separating ZoomMouseTracker and PanMouseTracker from WorldSceneWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 }