4 #include "compoundshape.h" 5 #include "shapefactory.h" 8 #include <opencv2/highgui.hpp> 41 const cv::Point &p1 = (*pt1)();
42 const cv::Point &p2 = (*pt2)();
43 return sqrt(pow(p2.y-p1.y,2)+pow(p2.x-p1.x,2));
49 threshold += thickness/2;
50 const cv::Point &p1 = (*pt1)();
51 const cv::Point &p2 = (*pt2)();
55 if (threshold <= abs((p2.y-p1.y)*p3.x-(p2.x-p1.x)*p3.y+p2.x*p1.y-p2.y*p1.x) / len)
63 if(sqrt(pow(p3.y-p1.y,2)+pow(p3.x-p1.x,2)) > len)
68 if(sqrt(pow(p3.y-p2.y,2)+pow(p3.x-p2.x,2)) > len)
83 const cv::Point &
getTail()
const;
86 const cv::Point &
getHead()
const;
88 virtual bool isAtPos(
const cv::Point &pos)
97 virtual const char *
getType()
const;
99 static const char * type;
105 Line(
const cv::Point &pos);
107 virtual void draw(cv::Mat &canvas);
108 virtual bool mousePressed(
const cv::Point &pos,
bool onCreate =
false);
109 virtual bool mouseMoved(
const cv::Point &pos);
115 virtual void reloadPointers(
const std::list<Shape*> &lst, std::list<Shape*>::const_iterator &i);
virtual void draw(cv::Mat &canvas)
draw shape on the canvas
The ShapeFactory class.
Definition: shapefactory.h:24
virtual bool mouseMoved(const cv::Point &pos)
mouseMoved
virtual bool mouseReleased(const cv::Point &pos)
mouseReleased
virtual std::list< Handle * > getConnectionTargets()
getConnectionTargets
virtual bool keyPressed(int &key)
keyPressed will be called by Canvas for active shapes
The Line class.
Definition: line.h:18
virtual bool isAtPos(const cv::Point &pos)
returns true if shape is at pos, false otherwise
Definition: line.h:88
virtual bool mousePressed(const cv::Point &pos, bool onCreate=false)
mousePressed
void setHeadPos(const cv::Point &pos)
will move the head (Handle) of the line to pos
void lockHead(bool isLocked)
set if to lock the head (Handle) of the line
void lockTail(bool isLocked)
set if to lock the tail (Handle) of the line
Handle & getPT2()
get the Handle to the head of the
The CompoundShape class.
Definition: compoundshape.h:20
void showHead(bool isVisible)
set if to show the head (Handle) of the line
virtual const char * getType() const
getType is always implemented by derived to return the same static pointer per shape.
The ShapeFactoryT class.
Definition: shapefactory.h:45
const cv::Point & getHead() const
get the Point position og the head Handle
bool isPointOnLine(const cv::Point &p3, int threshold=3) const
returns true if the point 'p3' is on the line, give or take 'threshold' pixels
Definition: line.h:47
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
double length() const
returns the length of the line in pixels
Definition: line.h:40
const cv::Point & getTail() const
get the Point position og the tail Handle
Handle & getPT1()
get the Handle to the tail of the
void showTail(bool isVisible)
set if to show the tail (Handle) of the line
void setTailPos(const cv::Point &pos)
will move the tail (Handle) of the line to pos
The Handle class.
Definition: handle.h:19