-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWire.hpp
36 lines (34 loc) · 1.16 KB
/
Wire.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include <QGraphicsLineItem>
#include <QGraphicsSceneMouseEvent>
#include <QMouseEvent>
#include <QDebug>
#include <QPainter>
#include <QObject>
#include "GridBackground.hpp"
#include "AnchorPoint.hpp"
class Wire : public QObject, public QGraphicsLineItem {
Q_OBJECT
public:
Wire(QPointF, QGraphicsItem *parent = nullptr);
void setStartAnchor(AnchorPoint*);
void setEndAnchor(AnchorPoint*);
void PressEvent(QPointF);
void MoveEvent(QPointF);
void ReleaseEvent(QPointF);
void setSelected(bool);
bool isSelected() const { return m_selected; }
inline QPointF& getStartPoint() {return pointList.front();}
inline QPointF& getEndPoint() {return pointList.back();}
protected:
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
QRectF boundingRect() const override;
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
void updateGeometry();
private:
AnchorPoint *anchor_start, *anchor_end;
QList<QPointF> pointList;
bool m_selected;
};