File indexing completed on 2024-05-12 15:26:42

0001 /***************************************************************************
0002     File                 : SegmentPrivate.h
0003     Project              : LabPlot
0004     --------------------------------------------------------------------
0005     Copyright            : (C) 2015 by Ankit Wagadre (wagadre.ankit@gmail.com)
0006  ***************************************************************************/
0007 /***************************************************************************
0008  *                                                                         *
0009  *  This program is free software; you can redistribute it and/or modify   *
0010  *  it under the terms of the GNU General Public License as published by   *
0011  *  the Free Software Foundation; either version 2 of the License, or      *
0012  *  (at your option) any later version.                                    *
0013  *                                                                         *
0014  *  This program is distributed in the hope that it will be useful,        *
0015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0017  *  GNU General Public License for more details.                           *
0018  *                                                                         *
0019  *   You should have received a copy of the GNU General Public License     *
0020  *   along with this program; if not, write to the Free Software           *
0021  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0022  *   Boston, MA  02110-1301  USA                                           *
0023  *                                                                         *
0024  ***************************************************************************/
0025 
0026 
0027 #ifndef SEGMENTPRIVATE_H
0028 #define SEGMENTPRIVATE_H
0029 
0030 #include <QGraphicsItem>
0031 #include <QPen>
0032 
0033 class SegmentPrivate: public QGraphicsItem {
0034 public:
0035     explicit SegmentPrivate(Segment*);
0036 
0037     void retransform();
0038     virtual void recalcShapeAndBoundingRect();
0039 
0040     double scaleFactor;
0041     bool m_hovered{false};
0042     QPen pen;
0043     QPainterPath linePath;
0044     QRectF boundingRectangle;
0045     QPainterPath itemShape;
0046 
0047     QRectF boundingRect() const override;
0048     QPainterPath shape() const override;
0049     void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* widget = nullptr) override;
0050     Segment* const q;
0051 
0052 private:
0053     void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
0054     void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
0055     QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
0056 };
0057 
0058 #endif