Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/ViewportGeometry.h @ 79:4e21f6b3aa0d wasm
cleaning up
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 24 May 2017 21:23:29 +0200 |
parents | c2dc924f1a63 |
children | 53bd9277b025 |
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 | |
40
7207a407bcd8
shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
5 * Copyright (C) 2017 Osimis, 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" | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 class ViewportGeometry | |
29 { | |
30 private: | |
31 // Extent of the scene (in world units) | |
32 double x1_; | |
33 double y1_; | |
34 double x2_; | |
35 double y2_; | |
36 | |
37 // Size of the display (in pixels) | |
38 unsigned int width_; | |
39 unsigned int height_; | |
40 | |
41 // Zoom/pan | |
42 double zoom_; | |
43 double panX_; // In pixels (display units) | |
44 double panY_; | |
45 | |
46 cairo_matrix_t transform_; // Scene-to-display transformation | |
47 | |
48 void ComputeTransform(); | |
49 | |
50 public: | |
51 ViewportGeometry(); | |
52 | |
53 void SetDisplaySize(unsigned int width, | |
54 unsigned int height); | |
55 | |
56 void SetSceneExtent(double x1, | |
57 double y1, | |
58 double x2, | |
59 double y2); | |
60 | |
61 void GetSceneExtent(double& x1, | |
62 double& y1, | |
63 double& x2, | |
64 double& y2) const; | |
65 | |
66 void MapDisplayToScene(double& sceneX /* out */, | |
67 double& sceneY /* out */, | |
68 double x, | |
69 double y) const; | |
70 | |
71 void MapSceneToDisplay(int& displayX /* out */, | |
72 int& displayY /* out */, | |
73 double x, | |
74 double y) const; | |
75 | |
76 unsigned int GetDisplayWidth() const | |
77 { | |
78 return width_; | |
79 } | |
80 | |
81 unsigned int GetDisplayHeight() const | |
82 { | |
83 return height_; | |
84 } | |
85 | |
86 double GetZoom() const | |
87 { | |
88 return zoom_; | |
89 } | |
90 | |
91 void SetDefaultView(); | |
92 | |
93 void ApplyTransform(CairoContext& context) const; | |
94 | |
95 void GetPan(double& x, | |
96 double& y) const; | |
97 | |
98 void SetPan(double x, | |
99 double y); | |
100 | |
101 void SetZoom(double zoom); | |
102 }; | |
103 } |