tilde~
Puredata Qt-based GUI
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
UIPatchcord.h
Go to the documentation of this file.
1 // (c) 2017 Alex Nadzharov
2 // License: GPL3
3 
4 #ifndef CM_PATCHCORD_H
5 #define CM_PATCHCORD_H
6 
7 #include "UIObject.h"
8 
9 #include <math.h>
10 
11 #include "Port.h"
12 
13 class ServerPatchcord;
14 
15 namespace tilde {
16 
20 typedef struct _patchcordAsNumbers {
21  int obj1;
22  int obj2;
23  int out1;
24  int in2;
26 
29 typedef enum { cm_pt_anything = 0,
31 
36 class UIPatchcord : public UIItem {
37 private:
38  UIItem* _obj1;
39  UIItem* _out1;
40  UIItem* _obj2;
41  UIItem* _in2;
42 
43  patchcordTypeEnum _patchcordType;
44 
45  QPainterPath _shape;
46 
47  ServerPatchcord* _serverPatchcord;
48 
49 public:
50  explicit UIPatchcord(UIItem* _obj1, UIItem* _out1, UIItem* _obj2, UIItem* _in2);
51  ~UIPatchcord();
52 
53  void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
54 
55  QPoint startPoint();
56  QPoint endPoint();
57 
59 
60  //workaround
61  void remove();
62 
63  UIObject* obj1();
64  UIObject* obj2();
65 
66  int outletIndex();
67  int inletIndex();
68 
69  bool isConnectedToObject(UIItem* obj);
70 
71  void hoverEnterEvent(QGraphicsSceneHoverEvent*);
72  void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
73 
74  void mousePressEvent(QGraphicsSceneMouseEvent*);
75 
76  void setServerPatchcord(ServerPatchcord* p) { _serverPatchcord = p; }
77  ServerPatchcord* serverPatchcord() { return _serverPatchcord; }
78 
79  //void deleteServerPatchcord(); ///> we don't delete server patchcord when we delete boxes - server does that automatically
80 
81 signals:
82  void selected();
83  void shiftClicked();
84  void altClicked();
85 };
86 }
87 
88 #endif // CM_PATCHCORD_H
patchcordTypeEnum
patchcord type - message / signal, can be extended later
Definition: UIPatchcord.h:29
QPoint endPoint()
Definition: UIPatchcord.cpp:108
void hoverLeaveEvent(QGraphicsSceneHoverEvent *)
Definition: UIPatchcord.cpp:167
Definition: UIPatchcord.h:29
void mousePressEvent(QGraphicsSceneMouseEvent *)
Definition: UIPatchcord.cpp:173
void hoverEnterEvent(QGraphicsSceneHoverEvent *)
Definition: UIPatchcord.cpp:160
UIItem QGraphicsObject class.
Definition: UIItem.h:15
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
Definition: UIPatchcord.cpp:37
Patchcord QGraphicsObject class.
Definition: UIPatchcord.h:36
int out1
Definition: UIPatchcord.h:23
int in2
Definition: UIPatchcord.h:24
UIPatchcord(UIItem *_obj1, UIItem *_out1, UIItem *_obj2, UIItem *_in2)
Definition: UIPatchcord.cpp:9
bool isConnectedToObject(UIItem *obj)
Definition: UIPatchcord.cpp:155
~UIPatchcord()
Definition: UIPatchcord.cpp:27
void altClicked()
deletes object and makes new line from obj2 out 'new line'
QPoint startPoint()
Definition: UIPatchcord.cpp:94
patchcord as numbers
Definition: UIPatchcord.h:20
UIObject * obj2()
Definition: UIPatchcord.cpp:141
Definition: UIPatchcord.h:30
int outletIndex()
Definition: UIPatchcord.cpp:146
int obj1
Definition: UIPatchcord.h:21
ServerPatchcord * serverPatchcord()
Definition: UIPatchcord.h:77
void setServerPatchcord(ServerPatchcord *p)
Definition: UIPatchcord.h:76
Definition: UIObject.h:44
void setPatchcordType(patchcordTypeEnum v)
Definition: UIPatchcord.cpp:125
struct tilde::_patchcordAsNumbers t_patchcordAsNumbers
patchcord as numbers
int inletIndex()
Definition: UIPatchcord.cpp:150
int obj2
Definition: UIPatchcord.h:22
UIObject * obj1()
Definition: UIPatchcord.cpp:137
void shiftClicked()
basic select signal - same as in UIObject class