TBTK
Path.h
Go to the documentation of this file.
1 /* Copyright 2017 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_PATH
24 #define COM_DAFER45_TBTK_PATH
25 
26 #include "TBTK/PlotCanvas.h"
27 #include "TBTK/Coordinate.h"
28 #include "TBTK/Decoration.h"
29 #include "TBTK/Drawable.h"
30 
31 #include <vector>
32 
33 #include <opencv2/core/core.hpp>
34 
35 namespace TBTK{
36 namespace Plot{
37 
38 class Path : public Drawable{
39 public:
41  Path();
42 
44  Path(const std::vector<Coordinate> &coordinates, Decoration &decoration);
45 
47  virtual ~Path();
48 
50  void add(const Coordinate &coordinate);
51 
53  void setDecoration(const Decoration &decoration);
54 
56  virtual void draw(PlotCanvas &canvas);
57 
59  virtual double getMinX() const;
60 
62  virtual double getMaxX() const;
63 
65  virtual double getMinY() const;
66 
68  virtual double getMaxY() const;
69 private:
71  std::vector<Coordinate> coordinates;
72 
74  Decoration decoration;
75 };
76 
77 inline Path::Path(){
78 }
79 
80 inline Path::Path(
81  const std::vector<Coordinate> &coordinates,
82  Decoration &decoration
83 ){
84  this->coordinates = coordinates;
85  this->decoration = decoration;
86 }
87 
88 inline Path::~Path(){
89 }
90 
91 inline void Path::add(const Coordinate &coordinate){
92  coordinates.push_back(coordinate);
93 }
94 
95 inline void Path::setDecoration(const Decoration &decoration){
96  this->decoration = decoration;
97 }
98 
99 inline double Path::getMinX() const{
100  if(coordinates.size() == 0)
101  return 0.;
102 
103  double min = coordinates[0].x;
104  for(unsigned int n = 0; n < coordinates.size(); n++)
105  if(coordinates[n].x < min)
106  min = coordinates[n].x;
107 
108  return min;
109 }
110 
111 inline double Path::getMaxX() const{
112  if(coordinates.size() == 0)
113  return 0.;
114 
115  double max = coordinates[0].x;
116  for(unsigned int n = 0; n < coordinates.size(); n++)
117  if(coordinates[n].x > max)
118  max = coordinates[n].x;
119 
120  return max;
121 }
122 
123 inline double Path::getMinY() const{
124  if(coordinates.size() == 0)
125  return 0.;
126 
127  double min = coordinates[0].y;
128  for(unsigned int n = 0; n < coordinates.size(); n++)
129  if(coordinates[n].y < min)
130  min = coordinates[n].y;
131 
132  return min;
133 }
134 
135 inline double Path::getMaxY() const{
136  if(coordinates.size() == 0)
137  return 0.;
138 
139  double max = coordinates[0].y;
140  for(unsigned int n = 0; n < coordinates.size(); n++)
141  if(coordinates[n].y > max)
142  max = coordinates[n].y;
143 
144  return max;
145 }
146 
147 }; //End namespace Plot
148 }; //End namespace TBTK
149 
150 #endif
virtual double getMaxX() const
Definition: Path.h:111
void setDecoration(const Decoration &decoration)
Definition: Path.h:95
void add(const Coordinate &coordinate)
Definition: Path.h:91
virtual double getMinX() const
Definition: Path.h:99
Definition: Drawable.h:35
Decoration.
Definition: PlotCanvas.h:36
Drawable.
Definition: Coordinate.h:33
Definition: Path.h:38
Path()
Definition: Path.h:77
Definition: Decoration.h:31
virtual double getMaxY() const
Definition: Path.h:135
virtual ~Path()
Definition: Path.h:88
Definition: ModelFactory.h:35
Coordinate.
virtual double getMinY() const
Definition: Path.h:123
virtual void draw(PlotCanvas &canvas)