File indexing completed on 2024-05-12 03:47:30

0001 /*
0002     File                 : SegmentPrivate.h
0003     Project              : LabPlot
0004     --------------------------------------------------------------------
0005     SPDX-FileCopyrightText: 2015 Ankit Wagadre <wagadre.ankit@gmail.com>
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef SEGMENTPRIVATE_H
0010 #define SEGMENTPRIVATE_H
0011 
0012 #include <QGraphicsItem>
0013 #include <QPen>
0014 
0015 class SegmentPrivate : public QGraphicsItem {
0016 public:
0017     explicit SegmentPrivate(Segment*);
0018 
0019     void retransform();
0020     virtual void recalcShapeAndBoundingRect();
0021 
0022     double scaleFactor;
0023     bool m_hovered{false};
0024     QPen pen;
0025     QPainterPath linePath;
0026     QRectF boundingRectangle;
0027     QPainterPath itemShape;
0028 
0029     QRectF boundingRect() const override;
0030     QPainterPath shape() const override;
0031     void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* widget = nullptr) override;
0032     Segment* const q;
0033 
0034 private:
0035     void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
0036     void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
0037     QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
0038 };
0039 
0040 #endif