annotate OrthancStone/Sources/Scene2D/PolylineSceneLayer.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 7053b8a0aaec
children c074c75cf416
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: 1596
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: 1596
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: 1596
diff changeset
16 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
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: 1596
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: 1596
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: 1596
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
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
26 #include "Color.h"
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "ScenePoint2D.h"
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
28 #include "ISceneLayer.h"
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
30 #include <Compatibility.h> // For ORTHANC_OVERRIDE
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
31
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include <vector>
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 namespace OrthancStone
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
36 class PolylineSceneLayer : public ISceneLayer
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 public:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 typedef std::vector<ScenePoint2D> Chain;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 private:
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
42 struct Item
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
43 {
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
44 Chain chain_;
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
45 bool closed_;
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
46 Color color_;
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
47 };
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
48
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
49 std::vector<Item> items_;
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
50 double thickness_;
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
51 uint64_t revision_;
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
52
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
53 const Item& GetItem(size_t i) const;
584
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 public:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 PolylineSceneLayer() :
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
57 thickness_(1.0),
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
58 revision_(0)
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
62 void Copy(const PolylineSceneLayer& other);
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
63
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
64 virtual uint64_t GetRevision() const ORTHANC_OVERRIDE
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
65 {
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
66 return revision_;
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
67 }
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
68
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
69 virtual ISceneLayer* Clone() const ORTHANC_OVERRIDE;
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 void SetThickness(double thickness);
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 double GetThickness() const
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 return thickness_;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
78 void Reserve(size_t countChains)
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
79 {
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
80 items_.reserve(countChains);
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
81 }
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 void AddChain(const Chain& chain,
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
84 bool isClosed,
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
85 uint8_t red,
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
86 uint8_t green,
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
87 uint8_t blue);
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
88
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
89 void AddChain(const Chain& chain,
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
90 bool isClosed,
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
91 const Color& color)
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
92 {
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
93 AddChain(chain, isClosed, color.GetRed(), color.GetGreen(), color.GetBlue());
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
94 }
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
632
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents: 584
diff changeset
96 void ClearAllChains();
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents: 584
diff changeset
97
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 size_t GetChainsCount() const
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
100 return items_.size();
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
101 }
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
102
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
103 const Chain& GetChain(size_t i) const
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
104 {
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
105 return GetItem(i).chain_;
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
108 bool IsClosedChain(size_t i) const
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
109 {
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
110 return GetItem(i).closed_;
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
111 }
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
113 const Color& GetColor(size_t i) const
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
114 {
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
115 return GetItem(i).color_;
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 632
diff changeset
116 }
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
118 virtual Type GetType() const ORTHANC_OVERRIDE
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 return Type_Polyline;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
1610
b7630b1a0253 ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
123 virtual void GetBoundingBox(Extent2D& target) const ORTHANC_OVERRIDE;
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 };
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }