File indexing completed on 2024-04-28 05:38:11
0001 /*************************************************************************** 0002 * Copyright (C) 2010 by Renaud Guezennec * 0003 * * 0004 * * 0005 * rolisteam is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #ifndef HIGHLIGHTERITEM_H 0021 #define HIGHLIGHTERITEM_H 0022 0023 #include "rwidgets_global.h" 0024 #include <QGraphicsObject> 0025 class QPropertyAnimation; 0026 namespace vmap 0027 { 0028 class VisualItemController; 0029 } 0030 /** 0031 * @brief displays an ellipse on maps. 0032 */ 0033 class RWIDGET_EXPORT HighlighterItem : public QGraphicsObject 0034 { 0035 Q_OBJECT 0036 Q_PROPERTY(qreal radius READ getRadius WRITE setRadius NOTIFY radiusChanged) 0037 public: 0038 /** 0039 * @brief constructor with parameters 0040 * @param center first point clicked by the user 0041 * @param either the shape is filled or not 0042 * @param color used for drawing it. 0043 */ 0044 HighlighterItem(const QPointF& center, int penSize, const QColor& penColor, QGraphicsItem* parent= nullptr, 0045 bool autoDestruction= true); 0046 /** 0047 * @brief paint the ellipse at the correct position 0048 */ 0049 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget= nullptr); 0050 0051 virtual QPainterPath shape() const; 0052 0053 /** 0054 * @brief gives the bounding rect of the ellipse 0055 */ 0056 virtual QRectF boundingRect() const; 0057 0058 void setRadius(qreal radius); 0059 qreal getRadius() const; 0060 0061 signals: 0062 void radiusChanged(); 0063 0064 protected: 0065 void initAnimation(bool autoDestruction); 0066 0067 private: 0068 qreal m_radius; 0069 QPointF m_center; 0070 QColor m_color; 0071 quint16 m_penSize; 0072 QPropertyAnimation* m_animation; 0073 }; 0074 0075 #endif // HIGHLIGHTERITEM_H