Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/ScenePoint2D.h @ 1841:6f82cd776cf6
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 24 Jun 2021 13:53:33 +0200 |
parents | 5a872e69c74f |
children | 3889ae96d2e9 |
rev | line source |
---|---|
584
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
584
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * 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:
1512
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
584
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * 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:
1512
diff
changeset
|
14 * 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:
1512
diff
changeset
|
15 * Lesser General Public License for more details. |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
699
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
17 * 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:
1512
diff
changeset
|
18 * 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:
1512
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
584
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #pragma once |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../Toolbox/AffineTransform2D.h" |
699 | 26 |
584
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 namespace OrthancStone |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 { |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 class ScenePoint2D |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 private: |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 double x_; |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 double y_; |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 public: |
596 | 36 ScenePoint2D() : |
37 x_(0), | |
38 y_(0) | |
39 { | |
40 } | |
41 | |
584
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 ScenePoint2D(double x, |
1804 | 43 double y) : |
584
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 x_(x), |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 y_(y) |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 } |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 double GetX() const |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 return x_; |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 } |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 double GetY() const |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 { |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 return y_; |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 } |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 |
1804 | 59 ScenePoint2D Apply(const AffineTransform2D& t) const; |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
699
diff
changeset
|
60 |
1804 | 61 const ScenePoint2D operator-(const ScenePoint2D& a) const; |
1160
59906485896f
fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
901
diff
changeset
|
62 |
1804 | 63 const ScenePoint2D operator+(const ScenePoint2D& a) const; |
1160
59906485896f
fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
901
diff
changeset
|
64 |
1804 | 65 const ScenePoint2D operator*(double a) const; |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
699
diff
changeset
|
66 |
1804 | 67 const ScenePoint2D operator/(double a) const; |
1160
59906485896f
fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
901
diff
changeset
|
68 |
1804 | 69 static void MidPoint(ScenePoint2D& result, |
70 const ScenePoint2D& a, | |
71 const ScenePoint2D& b); | |
1160
59906485896f
fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
901
diff
changeset
|
72 |
1804 | 73 static double Dot(const ScenePoint2D& a, |
74 const ScenePoint2D& b); | |
901
240359ab1651
Added Dot + magnitude + couple helpers in ScenePoint2D + Added ability to target several sets of 5-layer text packs stored in LayerHolder
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
75 |
1804 | 76 static double SquaredMagnitude(const ScenePoint2D& v); |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
699
diff
changeset
|
77 |
1804 | 78 static double Magnitude(const ScenePoint2D& v); |
901
240359ab1651
Added Dot + magnitude + couple helpers in ScenePoint2D + Added ability to target several sets of 5-layer text packs stored in LayerHolder
Benjamin Golinvaux <bgo@osimis.io>
parents:
866
diff
changeset
|
79 |
1804 | 80 static double SquaredDistancePtPt(const ScenePoint2D& a, |
81 const ScenePoint2D& b); | |
1160
59906485896f
fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
901
diff
changeset
|
82 |
1804 | 83 static double DistancePtPt(const ScenePoint2D& a, |
84 const ScenePoint2D& b); | |
1160
59906485896f
fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
901
diff
changeset
|
85 |
1804 | 86 // Distance from point p to [a,b] segment |
87 static double SquaredDistancePtSegment(const ScenePoint2D& a, | |
88 const ScenePoint2D& b, | |
89 const ScenePoint2D& p); | |
584
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 }; |
434ceeb0bcab
layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 } |