CanvasCV: CanvasCV-doxygen/src/canvascv/shapes/linecrossing.h Source File
CanvasCV  1.0.0
linecrossing.h
1 #ifndef LINECROSSING_H
2 #define LINECROSSING_H
3 
4 #include "arrow.h"
5 #include "line.h"
6 #include "textbox.h"
7 #include "shapefactory.h"
8 #include <memory>
9 
10 namespace canvascv
11 {
12 
20 {
21 public:
22 
24  int getDirection() const;
25 
27  const std::string &getName() const;
28 
30  void setName(const std::string &value) const;
31 
32  int getArrowMagnitude() const;
33 
34  void setArrowMagnitude(int mag);
35 
36  const cv::Point &getTail() const;
37 
38  const cv::Point &getHead() const;
39 
42 
44  Line *getLine();
45 
47  Arrow *getArrow();
48 
57  bool wasCrossed(const Point &pt) const;
58 
72  int isCrossedBySegment(const Point &lineStart, const Point &lineEnd) const;
73 
74  virtual bool isAtPos(const cv::Point &pos)
75  {
76  return line->isAtPos(pos);
77  }
78 
79  virtual std::list<Handle *> getConnectionTargets();
80  virtual const char *getType() const;
81  static const char * type;
82 
83 protected:
84  friend class ShapeFactory;
85  template <class T> friend class ShapeFactoryT;
86 
87  LineCrossing(const cv::Point& pos);
88 
89  virtual void draw(cv::Mat &canvas);
90  virtual bool mousePressed(const cv::Point &pos, bool onCreate = false);
91 
92  void registerCBs();
93 
94  void recalcArrow();
95 
96  void recalcTextBox();
97 
98  cv::Point middlePoint();
99 
100  bool isMiddlePoint(const cv::Point &pos, int threshold=3);
101 
102  void arrowTailHead(cv::Point &tail, cv::Point &head);
103 
104  virtual void writeInternals(cv::FileStorage &fs) const;
105  virtual void readInternals(const cv::FileNode &node);
106 
107  virtual void reloadPointers(const std::list<Shape*> &lst, std::list<Shape*>::const_iterator &i);
108 
109  virtual const std::string &getEditStatusMsg() const;
110 
111  int cross_z(const Point &pt) const;
112  int cross_z(const Point &lineStart, const Point &lineEnd, int direction, const Point &pt) const;
113 
114 private:
115  Line* line;
116  Arrow* arrow;
117  TextBox* textBox;
118  int direction;
119  int arrowMagnitude;
120 };
121 
122 }
123 
128 #endif // LINECROSSING_H
The ShapeFactory class.
Definition: shapefactory.h:24
bool wasCrossed(const Point &pt) const
wasCrossed
virtual bool mousePressed(const cv::Point &pos, bool onCreate=false)
mousePressed
The Line class.
Definition: line.h:18
The LineCrossing class.
Definition: linecrossing.h:19
virtual bool isAtPos(const cv::Point &pos)
returns true if shape is at pos, false otherwise
Definition: line.h:88
TextBox * getTextBox()
getter to internal TextBox
virtual std::list< Handle * > getConnectionTargets()
getConnectionTargets
The CompoundShape class.
Definition: compoundshape.h:20
Line * getLine()
getter to internal Line
void setName(const std::string &value) const
sets the text in the attached TextBox
int isCrossedBySegment(const Point &lineStart, const Point &lineEnd) const
isCrossedBy
The ShapeFactoryT class.
Definition: shapefactory.h:45
virtual const char * getType() const
getType is always implemented by derived to return the same static pointer per shape.
virtual void draw(cv::Mat &canvas)
draw shape on the canvas
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
const std::string & getName() const
gets the text from the attached TextBox
The TextBox class.
Definition: textbox.h:19
int getDirection() const
-1 or 1
The Arrow class.
Definition: arrow.h:14
Arrow * getArrow()
getter to internal Arrow
virtual bool isAtPos(const cv::Point &pos)
returns true if shape is at pos, false otherwise
Definition: linecrossing.h:74