File indexing completed on 2024-05-12 15:26:42
0001 /*************************************************************************** 0002 File : DatapickerPoint.h 0003 Project : LabPlot 0004 Description : Graphic Item for coordinate points of Datapicker 0005 -------------------------------------------------------------------- 0006 Copyright : (C) 2015 by Ankit Wagadre (wagadre.ankit@gmail.com) 0007 Copyright : (C) 2015-2019 Alexander Semke (alexander.semke@web.de) 0008 ***************************************************************************/ 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 * This program is distributed in the hope that it will be useful, * 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0019 * GNU General Public License for more details. * 0020 * * 0021 * You should have received a copy of the GNU General Public License * 0022 * along with this program; if not, write to the Free Software * 0023 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0024 * Boston, MA 02110-1301 USA * 0025 * * 0026 ***************************************************************************/ 0027 0028 #ifndef DATAPICKERPOINT_H 0029 #define DATAPICKERPOINT_H 0030 0031 #include "backend/datapicker/DatapickerCurve.h" 0032 #include "backend/lib/macros.h" 0033 0034 #include <QGraphicsItem> 0035 0036 //TODO: own file 0037 class ErrorBarItem : public QObject, public QGraphicsRectItem { 0038 Q_OBJECT 0039 0040 public: 0041 enum class ErrorBarType {PlusDeltaX, MinusDeltaX, PlusDeltaY, MinusDeltaY}; 0042 0043 explicit ErrorBarItem(DatapickerPoint* parent = nullptr, ErrorBarType type = ErrorBarType::PlusDeltaX); 0044 void setRectSize(const qreal); 0045 0046 public slots: 0047 void setPosition(QPointF); 0048 0049 private: 0050 void initRect(); 0051 void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override; 0052 void hoverEnterEvent(QGraphicsSceneHoverEvent*) override; 0053 QVariant itemChange(GraphicsItemChange, const QVariant &value) override; 0054 0055 QGraphicsLineItem* barLineItem; 0056 QRectF m_rect; 0057 ErrorBarType m_type; 0058 DatapickerPoint* m_parentItem; 0059 }; 0060 0061 class DatapickerPointPrivate; 0062 class DatapickerPoint : public AbstractAspect { 0063 Q_OBJECT 0064 0065 public: 0066 explicit DatapickerPoint(const QString& name); 0067 ~DatapickerPoint() override; 0068 0069 QIcon icon() const override; 0070 QMenu* createContextMenu() override; 0071 QGraphicsItem* graphicsItem() const; 0072 void setParentGraphicsItem(QGraphicsItem*); 0073 void setPrinting(bool); 0074 void initErrorBar(DatapickerCurve::Errors); 0075 0076 void save(QXmlStreamWriter*) const override; 0077 bool load(XmlStreamReader*, bool preview) override; 0078 0079 BASIC_D_ACCESSOR_DECL(QPointF, position, Position) 0080 BASIC_D_ACCESSOR_DECL(QPointF, plusDeltaXPos, PlusDeltaXPos) 0081 BASIC_D_ACCESSOR_DECL(QPointF, minusDeltaXPos, MinusDeltaXPos) 0082 BASIC_D_ACCESSOR_DECL(QPointF, plusDeltaYPos, PlusDeltaYPos) 0083 BASIC_D_ACCESSOR_DECL(QPointF, minusDeltaYPos, MinusDeltaYPos) 0084 0085 typedef DatapickerPointPrivate Private; 0086 0087 public slots: 0088 void retransform(); 0089 0090 protected: 0091 DatapickerPointPrivate* const d_ptr; 0092 DatapickerPoint(const QString &name, DatapickerPointPrivate *dd); 0093 static QPen selectedPen; 0094 static float selectedOpacity; 0095 0096 private: 0097 Q_DECLARE_PRIVATE(DatapickerPoint) 0098 void init(); 0099 0100 QList<ErrorBarItem*> m_errorBarItemList; 0101 0102 signals: 0103 void positionChanged(QPointF); 0104 void plusDeltaXPosChanged(QPointF); 0105 void minusDeltaXPosChanged(QPointF); 0106 void plusDeltaYPosChanged(QPointF); 0107 void minusDeltaYPosChanged(QPointF); 0108 }; 0109 0110 #endif