Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/ViewportGeometry.h @ 281:300d8b8c48b3 am-2
mouse tracker tuning
author | am@osimis.io |
---|---|
date | Tue, 28 Aug 2018 10:01:31 +0200 |
parents | fccffbf99ba1 |
children | 7a364e44fbb4 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
134
4cff7b1ed31d
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 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. | |
0 | 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 | |
47 | 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 | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "../Viewport/CairoContext.h" | |
111
7665ccbf33db
rename Extent as Extent2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
109
diff
changeset
|
25 #include "../Toolbox/Extent2D.h" |
0 | 26 |
27 namespace OrthancStone | |
28 { | |
29 class ViewportGeometry | |
30 { | |
31 private: | |
32 // Extent of the scene (in world units) | |
111
7665ccbf33db
rename Extent as Extent2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
109
diff
changeset
|
33 Extent2D sceneExtent_; |
0 | 34 |
35 // Size of the display (in pixels) | |
36 unsigned int width_; | |
37 unsigned int height_; | |
38 | |
39 // Zoom/pan | |
40 double zoom_; | |
41 double panX_; // In pixels (display units) | |
42 double panY_; | |
43 | |
44 cairo_matrix_t transform_; // Scene-to-display transformation | |
45 | |
46 void ComputeTransform(); | |
47 | |
48 public: | |
49 ViewportGeometry(); | |
50 | |
51 void SetDisplaySize(unsigned int width, | |
52 unsigned int height); | |
53 | |
111
7665ccbf33db
rename Extent as Extent2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
109
diff
changeset
|
54 void SetSceneExtent(const Extent2D& extent); |
0 | 55 |
111
7665ccbf33db
rename Extent as Extent2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
109
diff
changeset
|
56 const Extent2D& GetSceneExtent() const |
109
53bd9277b025
using the Extent class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
57 { |
53bd9277b025
using the Extent class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
58 return sceneExtent_; |
53bd9277b025
using the Extent class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
59 } |
0 | 60 |
61 void MapDisplayToScene(double& sceneX /* out */, | |
62 double& sceneY /* out */, | |
63 double x, | |
64 double y) const; | |
65 | |
66 void MapSceneToDisplay(int& displayX /* out */, | |
67 int& displayY /* out */, | |
68 double x, | |
69 double y) const; | |
70 | |
71 unsigned int GetDisplayWidth() const | |
72 { | |
73 return width_; | |
74 } | |
75 | |
76 unsigned int GetDisplayHeight() const | |
77 { | |
78 return height_; | |
79 } | |
80 | |
81 double GetZoom() const | |
82 { | |
83 return zoom_; | |
84 } | |
85 | |
86 void SetDefaultView(); | |
87 | |
88 void ApplyTransform(CairoContext& context) const; | |
89 | |
90 void GetPan(double& x, | |
91 double& y) const; | |
92 | |
93 void SetPan(double x, | |
94 double y); | |
95 | |
96 void SetZoom(double zoom); | |
97 }; | |
98 } |