/home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_gui/include/items/geometry_item.h Source File

MathVizAnimator: /home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_gui/include/items/geometry_item.h Source File
MathVizAnimator  0.0.1
geometry_item.h
1 /* mathvizanimator
2  * Copyright (C) 2023-2024 codingwithmagga
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef LIBS_MVA_GUI_INCLUDE_ITEMS_GEOMETRY_ITEM_H_
19 #define LIBS_MVA_GUI_INCLUDE_ITEMS_GEOMETRY_ITEM_H_
20 
21 #include <QObject>
22 
23 #include "abstractitem.h"
24 
25 class GeometryItem : public AbstractItem {
26  Q_OBJECT
27 
28  // There is already a filledColor property in QQuickPaintedItem so I call this "filledColor"
29  Q_PROPERTY(QColor filledColor READ filledColor WRITE setFilledColor NOTIFY filledColorChanged)
30  Q_PROPERTY(qreal filledOpacity READ filledOpacity WRITE setFilledOpacity NOTIFY filledOpacityChanged)
31 
32  Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
33  Q_PROPERTY(qreal borderOpacity READ borderOpacity WRITE setBorderOpacity NOTIFY borderOpacityChanged)
34  Q_PROPERTY(qreal borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged)
35 
36  public:
37  explicit GeometryItem(const QString& qml_file, BasicItem* parent = nullptr);
38 
39  QColor filledColor() const;
40  void setFilledColor(const QColor& new_filled_color);
41 
42  qreal filledOpacity() const;
43  void setFilledOpacity(const qreal& new_filled_opacity);
44 
45  QColor borderColor() const;
46  void setBorderColor(const QColor& new_border_color);
47 
48  qreal borderOpacity() const;
49  void setBorderOpacity(const qreal& new_border_opacity);
50 
51  qreal borderWidth() const;
52  void setBorderWidth(const qreal& new_border_width);
53 
54  QStringList editableProperties() const override;
55 
56  signals:
57  void filledColorChanged();
58  void filledOpacityChanged();
59  void borderColorChanged();
60  void borderOpacityChanged();
61  void borderWidthChanged();
62 
63  protected:
64  void preparePainterForBorder(QPainter* painter);
65  void preparePainterForFill(QPainter* painter);
66 
67  private:
68  QColor m_filled_color = Qt::transparent;
69  qreal m_filled_opacity = 1.0;
70 
71  QColor m_border_color;
72  qreal m_border_opacity = 1.0;
73  qreal m_border_width = 4.0;
74 };
75 
76 #endif // LIBS_MVA_GUI_INCLUDE_ITEMS_GEOMETRY_ITEM_H_
An abstract class representing a visible item like a circle or a rectangle.
Definition: abstractitem.h:56
Definition: basic_item.h:28
Definition: geometry_item.h:25
QStringList editableProperties() const override
Returns the properties which can be edited by the user in a QStringList.
Definition: geometry_item.cpp:84