2016-09-19 00:55:03 +02:00
|
|
|
#ifndef PATHITEM_H
|
|
|
|
#define PATHITEM_H
|
|
|
|
|
2016-09-19 00:56:10 +02:00
|
|
|
#include <QGraphicsObject>
|
2016-09-26 21:01:58 +02:00
|
|
|
#include <QPen>
|
|
|
|
#include "markeritem.h"
|
2016-09-19 00:56:10 +02:00
|
|
|
#include "units.h"
|
|
|
|
|
2016-09-26 21:01:58 +02:00
|
|
|
|
2016-09-19 00:56:10 +02:00
|
|
|
class PathItem : public QGraphicsObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-09-26 21:01:58 +02:00
|
|
|
PathItem(QGraphicsItem *parent = 0);
|
|
|
|
|
|
|
|
QPainterPath shape() const {return _shape;}
|
|
|
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget);
|
|
|
|
|
|
|
|
const QPainterPath &path() const {return _path;}
|
|
|
|
void showMarker(bool show) {_marker->setVisible(show);}
|
|
|
|
void setScale(qreal scale);
|
|
|
|
void setUnits(enum Units units);
|
|
|
|
void setColor(const QColor &color);
|
2016-12-06 01:48:26 +01:00
|
|
|
void setWidth(int width);
|
|
|
|
void setStyle(Qt::PenStyle style);
|
2016-09-19 00:56:10 +02:00
|
|
|
|
|
|
|
public slots:
|
2016-09-26 21:01:58 +02:00
|
|
|
void moveMarker(qreal distance);
|
2016-09-22 20:59:13 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void selected(bool);
|
2016-09-26 21:01:58 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void updateShape();
|
|
|
|
|
2016-11-14 22:12:43 +01:00
|
|
|
QVector<qreal> _distance;
|
2016-09-26 21:01:58 +02:00
|
|
|
QPainterPath _path;
|
|
|
|
MarkerItem *_marker;
|
|
|
|
Units _units;
|
|
|
|
|
|
|
|
private:
|
2016-11-14 22:12:43 +01:00
|
|
|
QPointF position(qreal distance) const;
|
|
|
|
|
2016-09-26 21:01:58 +02:00
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
2016-12-06 01:48:26 +01:00
|
|
|
|
|
|
|
int _width;
|
|
|
|
QPen _pen;
|
|
|
|
QPainterPath _shape;
|
2016-09-19 00:56:10 +02:00
|
|
|
};
|
|
|
|
|
2016-09-19 00:55:03 +02:00
|
|
|
#endif // PATHITEM_H
|