comparison Framework/Scene2D/PolylineSceneLayer.h @ 804:61ba4b504e9a

PolylineSceneLayer now has one color per chain
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 May 2019 15:58:21 +0200
parents 500c3f70b6c2
children 2d8ab34c8c91
comparison
equal deleted inserted replaced
802:f38c1fc08655 804:61ba4b504e9a
19 **/ 19 **/
20 20
21 21
22 #pragma once 22 #pragma once
23 23
24 #include "ColorSceneLayer.h" 24 #include "Color.h"
25 #include "ScenePoint2D.h" 25 #include "ScenePoint2D.h"
26 #include "ISceneLayer.h"
26 27
27 #include <vector> 28 #include <vector>
28 29
29 namespace OrthancStone 30 namespace OrthancStone
30 { 31 {
31 class PolylineSceneLayer : public ColorSceneLayer 32 class PolylineSceneLayer : public ISceneLayer
32 { 33 {
33 public: 34 public:
34 typedef std::vector<ScenePoint2D> Chain; 35 typedef std::vector<ScenePoint2D> Chain;
35 36
36 private: 37 private:
37 std::vector<Chain> chains_; 38 struct Item
38 std::vector<bool> closed_; 39 {
39 double thickness_; 40 Chain chain_;
41 bool closed_;
42 Color color_;
43 };
44
45 std::vector<Item> items_;
46 double thickness_;
47 uint64_t revision_;
48
49 const Item& GetItem(size_t i) const;
40 50
41 public: 51 public:
42 PolylineSceneLayer() : 52 PolylineSceneLayer() :
43 thickness_(1.0) 53 thickness_(1.0),
54 revision_(0)
44 { 55 {
56 }
57
58 void Copy(const PolylineSceneLayer& other);
59
60 virtual uint64_t GetRevision() const
61 {
62 return revision_;
45 } 63 }
46 64
47 virtual ISceneLayer* Clone() const; 65 virtual ISceneLayer* Clone() const;
48 66
49 void SetThickness(double thickness); 67 void SetThickness(double thickness);
51 double GetThickness() const 69 double GetThickness() const
52 { 70 {
53 return thickness_; 71 return thickness_;
54 } 72 }
55 73
56 void Copy(const PolylineSceneLayer& from); 74 void Reserve(size_t countChains)
57 75 {
58 void Reserve(size_t countChains); 76 items_.reserve(countChains);
77 }
59 78
60 void AddChain(const Chain& chain, 79 void AddChain(const Chain& chain,
61 bool isClosed); 80 bool isClosed,
81 uint8_t red,
82 uint8_t green,
83 uint8_t blue);
84
85 void AddChain(const Chain& chain,
86 bool isClosed,
87 const Color& color)
88 {
89 AddChain(chain, isClosed, color.GetRed(), color.GetGreen(), color.GetBlue());
90 }
62 91
63 void ClearAllChains(); 92 void ClearAllChains();
64 93
65 size_t GetChainsCount() const 94 size_t GetChainsCount() const
66 { 95 {
67 return chains_.size(); 96 return items_.size();
68 } 97 }
69 98
70 const Chain& GetChain(size_t i) const; 99 const Chain& GetChain(size_t i) const
100 {
101 return GetItem(i).chain_;
102 }
71 103
72 bool IsClosedChain(size_t i) const; 104 bool IsClosedChain(size_t i) const
105 {
106 return GetItem(i).closed_;
107 }
108
109 const Color& GetColor(size_t i) const
110 {
111 return GetItem(i).color_;
112 }
73 113
74 virtual Type GetType() const 114 virtual Type GetType() const
75 { 115 {
76 return Type_Polyline; 116 return Type_Polyline;
77 } 117 }