Seamly2D
Code documentation
scene_rect.h
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * @file scene_rect.cpp *
4  * @author DSCaskey *
5  * @date 3.30.2021 *
6  * Copyright (C) 2017 Seamly, LLC *
7  * *
8  * https://github.com/fashionfreedom/seamly2d *
9  * *
10  ***************************************************************************
11  **
12  ** Seamly2D is free software: you can redistribute it and/or modify
13  ** it under the terms of the GNU General Public License as published by
14  ** the Free Software Foundation, either version 3 of the License, or
15  ** (at your option) any later version.
16  **
17  ** Seamly2D is distributed in the hope that it will be useful,
18  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  ** GNU General Public License for more details.
21  **
22  ** You should have received a copy of the GNU General Public License
23  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
24  **
25  **************************************************************************/
26 
27 #ifndef SCENE_RECT_H
28 #define SCENE_RECT_H
29 
30 #include <QtGlobal>
31 #include <QGraphicsRectItem>
32 
33 #include "../vmisc/def.h"
34 
35 class VPointF;
36 class VScaledLine;
37 
38 class SceneRect: public QGraphicsRectItem
39 {
40 public:
41  explicit SceneRect(const QColor &lineColor, QGraphicsItem *parent = nullptr);
42  virtual ~SceneRect() = default;
43  virtual int type() const Q_DECL_OVERRIDE {return Type;}
44  enum { Type = UserType + static_cast<int>(Vis::ScenePoint)};
45 
46  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
47  QWidget *widget = nullptr) Q_DECL_OVERRIDE;
48  virtual void refreshPointGeometry(const VPointF &point);
49 
50 protected:
51  QColor m_rectColor; /** @brief m_rectColor color of point. */
55 
56  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
57  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
58 
59  void setOnlyPoint(bool value);
60  bool isOnlyPoint() const;
61 
62  void setPointColor(const QString &value);
63 
64 private:
65  Q_DISABLE_COPY(SceneRect)
66 
67  void setRectPen(qreal scale);
68 };
69 
70 #endif // SCENE_RECT_H
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) Q_DECL_OVERRIDE
Definition: scene_rect.cpp:54
void setOnlyPoint(bool value)
Definition: scene_rect.cpp:73
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
Definition: scene_rect.cpp:90
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
Definition: scene_rect.cpp:97
virtual ~SceneRect()=default
virtual int type() const Q_DECL_OVERRIDE
Definition: scene_rect.h:43
QColor m_rectColor
Definition: scene_rect.h:51
void setPointColor(const QString &value)
Definition: scene_rect.cpp:84
bool m_isHovered
Definition: scene_rect.h:53
bool m_onlyPoint
m_rectColor color of point.
Definition: scene_rect.h:52
void setRectPen(qreal scale)
Definition: scene_rect.cpp:104
virtual void refreshPointGeometry(const VPointF &point)
Definition: scene_rect.cpp:65
bool m_showPointName
Definition: scene_rect.h:54
SceneRect(const QColor &lineColor, QGraphicsItem *parent=nullptr)
Definition: scene_rect.cpp:41
bool isOnlyPoint() const
Definition: scene_rect.cpp:79
The VPointF class keep data of point.
Definition: vpointf.h:75
@ ScenePoint