39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
#ifndef ELECTRICCONNECTLINEITEM_H
|
|
#define ELECTRICCONNECTLINEITEM_H
|
|
|
|
#include <QPainterPath>
|
|
#include <QUuid>
|
|
#include "graphicsBaseItem.h"
|
|
|
|
class ElectricConnectLineItem : public GraphicsProjectModelItem
|
|
{
|
|
public:
|
|
ElectricConnectLineItem(QGraphicsItem *parent = 0);
|
|
virtual ~ElectricConnectLineItem();
|
|
|
|
void setStartPoint(const QPointF& p);
|
|
void setEndPoint(const QPointF& p);
|
|
QPainterPath getPoints(void) const { return m_points; }
|
|
|
|
void moveLine(QPointF); //鼠标点击拖动
|
|
void calculatePath();
|
|
void resetCurLine(){_curLine = QPoint();}
|
|
|
|
void setConnection(Connection con){m_connectState = con;} //保留,用以获取当前图中的连接
|
|
Connection getConnection() const {return m_connectState;}
|
|
|
|
protected:
|
|
virtual QPainterPath shape() const override;
|
|
virtual QRectF boundingRect() const override;
|
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
|
private:
|
|
Connection m_connectState;
|
|
QPainterPath m_points;
|
|
QPainterPath m_pointsBoundingRect; //包裹点的矩形集合
|
|
QList<QPointF> m_lstPoints;
|
|
QPoint _curLine; //参数1用点序号表示的当前线段起始点,参数2表示线段方向
|
|
|
|
};
|
|
|
|
#endif
|