4 #include "canvascv/colors.h" 5 #include "canvascv/consts.h" 7 #include <opencv2/core/mat.hpp> 105 virtual const char *
getType()
const = 0;
120 virtual bool isAtPos(
const cv::Point &pos) = 0;
122 virtual void translate(
const cv::Point &offset) = 0;
124 bool isReady()
const;
130 virtual void writeInternals(cv::FileStorage& fs)
const = 0;
131 virtual void readInternals(
const cv::FileNode& node) = 0;
140 virtual bool mousePressed(
const cv::Point &pos,
bool onCreate =
false) = 0;
151 virtual bool mouseMoved(
const cv::Point &pos) = 0;
160 virtual std::shared_ptr<Shape>
getShape(
int id);
191 virtual void draw(cv::Mat &canvas) = 0;
196 const std::string &getStatusMsg()
const;
197 virtual const std::string &getCreateStatusMsg()
const = 0;
198 virtual const std::string &getEditStatusMsg()
const = 0;
200 void setCanvas(
Canvas &value);
206 virtual void setReady();
209 cv::Scalar outlineColor;
210 cv::Scalar fillColor;
219 friend void read(
const cv::FileNode& node,
Canvas& x,
const Canvas&);
224 void broadcastEvent(
Event event);
228 friend void write(cv::FileStorage& fs,
const std::string&,
const Shape& x);
229 friend void read(
const cv::FileNode& node,
Shape*& x,
const Shape* default_value);
231 void write(cv::FileStorage& fs)
const;
232 void read(
const cv::FileNode& node);
234 std::list<CBPerShape> cbs;
240 void write(cv::FileStorage& fs,
const std::string&,
const Shape& x);
241 void read(
const cv::FileNode& node,
Shape*& x,
const Shape* default_value);
244 std::ostream & operator<<(std::ostream& o,
const Shape &shape);
shape unselected
Definition: shape.h:52
virtual void setLineType(int value)
set the line type (LINE_4, LINE_8, LINE_AA)
virtual void draw(cv::Mat &canvas)=0
draw shape on the canvas
shape selected
Definition: shape.h:51
shape removed
Definition: shape.h:53
virtual bool mouseMoved(const cv::Point &pos)=0
mouseMoved
int getThickness() const
get line thickness to use when drawing
virtual std::list< Handle * > getConnectionTargets()=0
getConnectionTargets
virtual void setOutlineColor(const cv::Scalar &value)
set the outline color
virtual bool mousePressed(const cv::Point &pos, bool onCreate=false)=0
mousePressed
virtual std::shared_ptr< Shape > getShape(int id)
getShape
The Shape class hierarchy is for geomertric user interaction.
Definition: shape.h:32
void notifyOnEvent(CBPerShape cb)
used to register for notifications on shape
int getId()
return a unique id for this shape
int getLineType() const
get the line type (LINE_4, LINE_8, LINE_AA)
The CompoundShape class.
Definition: compoundshape.h:20
virtual void lostFocus()
lostFocus is called by Canvas if we're in it and just became non-active
virtual bool mouseReleased(const cv::Point &pos)=0
mouseReleased
bool getLocked() const
is the shape locked (can't be moved/edited)
cv::Scalar getOutlineColor() const
get the outline color
virtual void setLocked(bool value)
set the shape lock state (can/can't be moved/edited)
cv::Scalar getFillColor() const
get the fill color (fill color is not very useful for shapes right now)
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
std::function< void(Shape *, Event)> CBPerShape
signature of a callback which gets the Event
Definition: shape.h:57
virtual ~Shape()
virtual destructor
virtual const char * getType() const =0
getType is always implemented by derived to return the same static pointer per shape.
virtual bool isAtPos(const cv::Point &pos)=0
returns true if shape is at pos, false otherwise
virtual bool keyPressed(int &key)
keyPressed will be called by Canvas for active shapes
bool getVisible() const
is the shape visible
Event
The Event enum will let you know what just happended to the shape.
Definition: shape.h:49
virtual void setVisible(bool value)
set the shape visible state
void drawHelper(cv::Mat &canvas, Shape *other)
helper method for non compund shapes to draw their members
virtual void setFillColor(const cv::Scalar &value)
set the fill color (fill color is not very useful for shapes right now)
The Canvas class is the entry point into CanvasCV.
Definition: canvas.h:33
virtual void setThickness(int value)
set line thickness to use when drawing