File indexing completed on 2025-01-26 03:34:14

0001 /*
0002     File                 : ReferenceRange.h
0003     Project              : LabPlot
0004     Description          : Reference range on the plot
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2022 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef REFERENCERANGE_H
0011 #define REFERENCERANGE_H
0012 
0013 #include <QPen>
0014 
0015 #include "backend/lib/macros.h"
0016 #include "backend/worksheet/WorksheetElement.h"
0017 
0018 class ReferenceRangePrivate;
0019 class CartesianPlot;
0020 class Background;
0021 class Line;
0022 class QActionGroup;
0023 
0024 class ReferenceRange : public WorksheetElement {
0025     Q_OBJECT
0026 
0027 public:
0028     explicit ReferenceRange(CartesianPlot*, const QString&);
0029     ~ReferenceRange() override;
0030 
0031     QIcon icon() const override;
0032     QMenu* createContextMenu() override;
0033 
0034     void save(QXmlStreamWriter*) const override;
0035     bool load(XmlStreamReader*, bool preview) override;
0036     void loadThemeConfig(const KConfig&) override;
0037 
0038     // position and orientation
0039     BASIC_D_ACCESSOR_DECL(QPointF, positionLogicalStart, PositionLogicalStart)
0040     BASIC_D_ACCESSOR_DECL(QPointF, positionLogicalEnd, PositionLogicalEnd)
0041     BASIC_D_ACCESSOR_DECL(Orientation, orientation, Orientation)
0042 
0043     // background and border
0044     Background* background() const;
0045     Line* line() const;
0046 
0047     void retransform() override;
0048     void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
0049 
0050     typedef ReferenceRangePrivate Private;
0051 
0052 protected:
0053     ReferenceRange(const QString& name, ReferenceRangePrivate* dd);
0054 
0055 private:
0056     Q_DECLARE_PRIVATE(ReferenceRange)
0057     void init();
0058     void initActions();
0059     void initMenus();
0060 
0061     QAction* orientationHorizontalAction{nullptr};
0062     QAction* orientationVerticalAction{nullptr};
0063 
0064     QActionGroup* lineStyleActionGroup{nullptr};
0065     QActionGroup* lineColorActionGroup{nullptr};
0066 
0067     QMenu* orientationMenu{nullptr};
0068     QMenu* lineMenu{nullptr};
0069     QMenu* lineStyleMenu{nullptr};
0070     QMenu* lineColorMenu{nullptr};
0071 
0072 private Q_SLOTS:
0073     // SLOTs for changes triggered via QActions in the context menu
0074     void orientationChangedSlot(QAction*);
0075     void lineStyleChanged(QAction*);
0076     void lineColorChanged(QAction*);
0077 
0078     void updateStartEndPositions();
0079 
0080 Q_SIGNALS:
0081     friend class ReferenceRangeSetPositionCmd;
0082     void positionLogicalStartChanged(QPointF);
0083     void positionLogicalEndChanged(QPointF);
0084     void orientationChanged(Orientation);
0085 
0086     friend class WorksheetElementTest;
0087 };
0088 
0089 #endif