annotate OrthancStone/Sources/Scene2D/ScenePoint2D.h @ 1949:d3ae6858e77b

more consistent handling of numberOfFrames
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 Jul 2022 16:19:18 +0200
parents b896f20d24ca
children 07964689cb0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * the License, or (at your option) any later version.
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * 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
14 * 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
15 * 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
16 * 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
17 *
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
18 * 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
19 * 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
20 * <http://www.gnu.org/licenses/>.
584
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
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../Toolbox/AffineTransform2D.h"
699
5c551f078c18 Merge from default
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
27
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 namespace OrthancStone
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 class ScenePoint2D
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 private:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 double x_;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 double y_;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 public:
596
b716763571ad IPointerTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 584
diff changeset
37 ScenePoint2D() :
b716763571ad IPointerTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 584
diff changeset
38 x_(0),
b716763571ad IPointerTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 584
diff changeset
39 y_(0)
b716763571ad IPointerTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 584
diff changeset
40 {
b716763571ad IPointerTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 584
diff changeset
41 }
b716763571ad IPointerTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 584
diff changeset
42
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 ScenePoint2D(double x,
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
44 double y) :
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 x_(x),
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 y_(y)
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
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 double GetX() const
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 return x_;
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
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 double GetY() const
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 return y_;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
60 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
61
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
62 const ScenePoint2D operator-(const ScenePoint2D& a) const;
1160
59906485896f fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
63
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
64 const ScenePoint2D operator+(const ScenePoint2D& a) const;
1160
59906485896f fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
65
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
66 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
67
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
68 const ScenePoint2D operator/(double a) const;
1160
59906485896f fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
69
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
70 static void MidPoint(ScenePoint2D& result,
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
71 const ScenePoint2D& a,
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
72 const ScenePoint2D& b);
1160
59906485896f fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
73
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
74 static double Dot(const ScenePoint2D& a,
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
75 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
76
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
77 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
78
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
79 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
80
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
81 static double SquaredDistancePtPt(const ScenePoint2D& a,
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
82 const ScenePoint2D& b);
1160
59906485896f fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
83
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
84 static double DistancePtPt(const ScenePoint2D& a,
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
85 const ScenePoint2D& b);
1160
59906485896f fix EOL in ScenePoint2D.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 901
diff changeset
86
1804
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
87 // Distance from point p to [a,b] segment
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
88 static double SquaredDistancePtSegment(const ScenePoint2D& a,
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
89 const ScenePoint2D& b,
5a872e69c74f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
90 const ScenePoint2D& p);
1875
b896f20d24ca added UnionOfRectangles algorithm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
91
b896f20d24ca added UnionOfRectangles algorithm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
92 bool IsEqual(const ScenePoint2D& other) const
b896f20d24ca added UnionOfRectangles algorithm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
93 {
b896f20d24ca added UnionOfRectangles algorithm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
94 return LinearAlgebra::IsCloseToZero(DistancePtPt(*this, other));
b896f20d24ca added UnionOfRectangles algorithm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
95 }
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 };
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 }