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

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