CanvasCV: CanvasCV-doxygen/src/canvascv/shapes/shapesconnector.h Source File
CanvasCV  1.0.0
shapesconnector.h
1 #ifndef SHAPESCONNECTOR_H
2 #define SHAPESCONNECTOR_H
3 
4 #include "line.h"
5 
6 namespace canvascv
7 {
8 
14 class ShapesConnector : public Line
15 {
16 public:
17 
19  int getSpacing() const;
20 
22  void setSpacing(int value);
23 
25  void connectTail(Shape &shape, Handle &handle);
26 
28  void connectHead(Shape &shape, Handle &handle);
29 
31  void disconnectTail();
32 
34  void disconnectHead();
35 
37  void reconnect();
38 
41  {
42  return tailShape;
43  }
44 
47  {
48  return headShape;
49  }
50 
53 
56 
58  void disconnectShape(int id);
59 
60  virtual void translate(const cv::Point &offset);
61 
62  virtual std::list<Handle *> getConnectionTargets();
63 
64  virtual const char *getType() const;
65 
66  static const char * type;
67 
68 protected:
69  friend class ShapeFactory;
70  template <class T> friend class ShapeFactoryT;
71 
72  ShapesConnector(const cv::Point &pos);
73 
74  virtual void draw(Mat &canvas);
75  virtual bool mousePressed(const cv::Point &pos, bool onCreate = false);
76  virtual bool mouseReleased(const cv::Point &pos);
77 
78  virtual const string &getCreateStatusMsg() const;
79  virtual const string &getEditStatusMsg() const;
80 
81  Handle *center;
82 
83  virtual void writeInternals(cv::FileStorage &fs) const;
84  virtual void readInternals(const cv::FileNode &node);
85 
86 
87  virtual void reloadPointers(const std::list<Shape*> &lst, std::list<Shape*>::const_iterator &i)
88  {
89  Line::reloadPointers(lst, i);
90  center = dynamic_cast<Handle*>(*i++);
91  registerCBs();
92  }
93 
94 private:
95 
96  Shape *getShapeFromCanvas(int id);
97  bool connectToEndPoint(Shape &shape, Handle &handle, Handle &endPoint);
98  void DisconnectEndPoint(int handleId, Handle &endPoint);
99  void registerCBs();
100  Handle::CBID registerCenterUpdateCB(Handle *handle);
101  Handle::CBID registerConnectCB(const int &shapeId, Handle *handle);
102 
103  int tailShape;
104  int tailHandle;
105  int headShape;
106  int headHandle;
107  int space;
108  std::list<std::shared_ptr<Shape>> dragTargetShapes;
109  std::list<Handle*> dragTargetHandles;
110  Handle::CBID tailCBID;
111  Handle::CBID headCBID;
112  Handle *tmpDragTarget;
113  cv::Scalar tmpDragTargetColor;
114  int tmpDragTargetThickness;
115 };
116 
117 }
118 
123 #endif // SHAPESCONNECTOR_H
void connectHead(Shape &shape, Handle &handle)
Connect &#39;shape&#39; with it&#39;s Handle &#39;handle&#39; to our own head Handle.
The ShapeFactory class.
Definition: shapefactory.h:24
The Line class.
Definition: line.h:18
void reconnect()
called after read of Canvas from file, assuming internals are filled, but not connected ...
virtual const char * getType() const
getType is always implemented by derived to return the same static pointer per shape.
void setSpacing(int value)
set the spacing of the dotted connecting line
void disconnectHead()
disconnect our own head Handle from any previously connected shape
The Shape class hierarchy is for geomertric user interaction.
Definition: shape.h:32
virtual bool mousePressed(const cv::Point &pos, bool onCreate=false)
mousePressed
virtual bool mouseReleased(const cv::Point &pos)
mouseReleased
int getSpacing() const
get the spacing of the dotted connecting line
virtual std::list< Handle * > getConnectionTargets()
getConnectionTargets
void disconnectTail()
disconnect our own tail Handle from any previously connected shape
The ShapeFactoryT class.
Definition: shapefactory.h:45
void disconnectShape(int id)
disconnect a previouslt connected shape with an &#39;id&#39;
This namespace holds all the classes of the CanvasCV library.
Definition: canvas.h:20
Shape * getHeadShape()
get the shape connected to our head Handle
int getTailShapeId()
get the id of the shape connected to our tail Handle
Definition: shapesconnector.h:40
Shape * getTailShape()
get the shape connected to our tail Handle
void connectTail(Shape &shape, Handle &handle)
Connect &#39;shape&#39; with it&#39;s Handle &#39;handle&#39; to our own tail Handle.
int getHeadShapeId()
get the id of the shape connected to our head Handle
Definition: shapesconnector.h:46
The ShapesConnector class.
Definition: shapesconnector.h:14
The Handle class.
Definition: handle.h:19