File indexing completed on 2024-05-12 03:48:19
0001 /* 0002 File : InfoElementPrivate.h 0003 Project : LabPlot 0004 Description : Private members of InfoElement 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2020 Martin Marmsoler <martin.marmsoler@gmail.com> 0007 SPDX-FileCopyrightText: 2020-2022 Alexander Semke <alexander.semke@web.de> 0008 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 */ 0011 0012 #ifndef INFOELEMENTPRIVATE_H 0013 #define INFOELEMENTPRIVATE_H 0014 0015 #include "backend/worksheet/WorksheetElementPrivate.h" 0016 0017 class InfoElement; 0018 class XYCurve; 0019 class QGraphicsSceneMouseEvent; 0020 0021 class InfoElementPrivate : public WorksheetElementPrivate { 0022 public: 0023 InfoElementPrivate(InfoElement* owner); 0024 InfoElementPrivate(InfoElement* owner, const XYCurve*); 0025 0026 // reimplemented from QGraphicsItem 0027 void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* widget = nullptr) override; 0028 void keyPressEvent(QKeyEvent*) override; 0029 void mousePressEvent(QGraphicsSceneMouseEvent*) override; 0030 void mouseMoveEvent(QGraphicsSceneMouseEvent*) override; 0031 0032 void init(); 0033 void updatePosition(); 0034 void retransform() override; 0035 void updateVerticalLine(); 0036 void updateConnectionLine(); 0037 bool changeVisibility(bool on); 0038 0039 virtual bool activate(QPointF mouseScenePos, double maxDist = -1); 0040 0041 // TextLabel Gluepoint 0042 int gluePointIndex{-1}; // negative value means automatic mode 0043 int m_index{-1}; // index of the actual position 0044 QString connectionLineCurveName; 0045 double positionLogical; 0046 0047 Line* verticalLine{nullptr}; 0048 Line* connectionLine{nullptr}; 0049 0050 // TODO 0051 // CartesianPlot* plot{nullptr}; 0052 0053 InfoElement* const q; 0054 0055 private: 0056 void recalcShape(); 0057 void recalcShapeAndBoundingRect(const QRectF&); 0058 virtual void recalcShapeAndBoundingRect() override; 0059 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*) override; 0060 0061 private: 0062 QPointF sceneDeltaPoint; // delta position from worksheetinfoElementPrivate to the first marker point in scene coords 0063 QPointF sceneDeltaTextLabel; 0064 0065 QLineF m_connectionLine; // line between CustomPoint and TextLabel 0066 QLineF xposLine; // Line which connects all markerpoints, when there are more than 1 0067 QPointF oldMousePos; 0068 bool m_suppressKeyPressEvents{false}; 0069 }; 0070 0071 #endif // WORKSHEETINFOELEMENTPRIVATE_H