5 #include "shapefactory.h" 7 #include <opencv2/opencv.hpp> 22 typedef std::function<void(const cv::Point &)> PosChangedCB;
23 typedef std::list<PosChangedCB>::iterator CBID;
37 void setPos(
const cv::Point &pos,
bool notify =
true);
39 virtual void translate(
const cv::Point &offset);
56 virtual bool isAtPos(
const cv::Point &pos)
63 virtual const char *
getType()
const;
65 static const char * type;
73 Handle(
const cv::Point &pos);
75 virtual void writeInternals(cv::FileStorage &fs)
const;
76 virtual void readInternals(
const cv::FileNode &node);
78 virtual void draw(cv::Mat &canvas);
79 virtual bool mousePressed(
const cv::Point &pos,
bool =
false);
84 virtual const string &getCreateStatusMsg()
const;
85 virtual const string &getEditStatusMsg()
const;
89 void connectedFrom(
Handle &other);
90 void disconnectFrom(
Handle &other);
92 bool isPoint(
const cv::Point &pos,
int threshold=3)
94 threshold += thickness/2;
95 return abs(pos.x - pt.x) <= threshold &&
96 abs(pos.y - pt.y) <= threshold;
99 void broadcastPosChanged(
const cv::Point& pos);
101 std::list<PosChangedCB> posChangedCBs;
102 std::map<Handle*, CBID> connectedHandles;
The ShapeFactory class.
Definition: shapefactory.h:24
CBID addPosChangedCB(PosChangedCB cb)
register to be notified when this handle changes
virtual bool mouseReleased(const cv::Point &pos)
mouseReleased
virtual void draw(cv::Mat &canvas)
draw shape on the canvas
void disconnect(Handle &other)
disconnect from a handle that needed to change with us
virtual bool mousePressed(const cv::Point &pos, bool=false)
mousePressed
virtual bool isAtPos(const cv::Point &pos)
returns true if shape is at pos, false otherwise
Definition: handle.h:56
void connect(Handle &other)
connect to a handle to change when we change
The Shape class hierarchy is for geomertric user interaction.
Definition: shape.h:32
virtual const char * getType() const
getType is always implemented by derived to return the same static pointer per shape.
const cv::Point & operator()() const
return the Point location of this Handle
Definition: handle.h:26
The ShapeFactoryT class.
Definition: shapefactory.h:45
int getRadius() const
return the radius of this circled handle
virtual bool mouseMoved(const cv::Point &pos)
mouseMoved
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
void delPosChangedCB(const CBID &id)
unregister to be notified when this handle changes
void setPos(const cv::Point &pos, bool notify=true)
setPos
virtual void lostFocus()
lostFocus is called by Canvas if we're in it and just became non-active
virtual std::list< Handle * > getConnectionTargets()
getConnectionTargets
The Handle class.
Definition: handle.h:19