"Fossies" - the Fresh Open Source Software Archive

Member "labplot-2.8.2/src/backend/worksheet/plots/cartesian/AxisPrivate.h" (24 Feb 2021, 6910 Bytes) of package /linux/privat/labplot-2.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AxisPrivate.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.8.1_vs_2.8.2.

    1 /***************************************************************************
    2     File                 : AxisPrivate.h
    3     Project              : LabPlot
    4     Description          : Private members of Axis.
    5     --------------------------------------------------------------------
    6     Copyright            : (C) 2011-2018 Alexander Semke (alexander.semke@web.de)
    7 
    8  ***************************************************************************/
    9 
   10 /***************************************************************************
   11  *                                                                         *
   12  *  This program is free software; you can redistribute it and/or modify   *
   13  *  it under the terms of the GNU General Public License as published by   *
   14  *  the Free Software Foundation; either version 2 of the License, or      *
   15  *  (at your option) any later version.                                    *
   16  *                                                                         *
   17  *  This program is distributed in the hope that it will be useful,        *
   18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
   19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
   20  *  GNU General Public License for more details.                           *
   21  *                                                                         *
   22  *   You should have received a copy of the GNU General Public License     *
   23  *   along with this program; if not, write to the Free Software           *
   24  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
   25  *   Boston, MA  02110-1301  USA                                           *
   26  *                                                                         *
   27  ***************************************************************************/
   28 
   29 #ifndef AXISPRIVATE_H
   30 #define AXISPRIVATE_H
   31 
   32 #include <QGraphicsItem>
   33 #include <QPen>
   34 #include <QFont>
   35 #include "Axis.h"
   36 
   37 class QGraphicsSceneHoverEvent;
   38 
   39 class AxisGrid;
   40 class CartesianPlot;
   41 class CartesianCoordinateSystem;
   42 class TextLabel;
   43 
   44 class AxisPrivate: public QGraphicsItem {
   45 public:
   46     explicit AxisPrivate(Axis*);
   47 
   48     QRectF boundingRect() const override;
   49     QPainterPath shape() const override;
   50 
   51     QString name() const;
   52     void retransform();
   53     void retransformLine();
   54     void retransformArrow();
   55     void retransformTicks();
   56     void retransformTickLabelPositions();
   57     void retransformTickLabelStrings();
   58     void retransformMinorGrid();
   59     void retransformMajorGrid();
   60     void updateGrid();
   61     bool swapVisible(bool);
   62     void recalcShapeAndBoundingRect();
   63     void setPrinting(bool);
   64     bool isHovered() const;
   65 
   66     bool isDefault{false};
   67 
   68     //general
   69     bool autoScale;
   70     Axis::Orientation orientation; //!< horizontal or vertical
   71     Axis::Position position; //!< left, right, bottom, top or custom (usually not changed after creation)
   72     Axis::Scale scale;
   73     double offset; //!< offset from zero in the direction perpendicular to the axis
   74     double start; //!< start coordinate of the axis line
   75     double end; //!< end coordinate of the axis line
   76     qreal scalingFactor;
   77     qreal zeroOffset;
   78 
   79     //line
   80     QVector<QLineF> lines;
   81     QPen linePen;
   82     qreal lineOpacity;
   83     Axis::ArrowType arrowType;
   84     Axis::ArrowPosition arrowPosition;
   85     qreal arrowSize;
   86 
   87     // Title
   88     TextLabel* title{nullptr};
   89     qreal titleOffsetX; //distance to the axis line
   90     qreal titleOffsetY; //distance to the axis line
   91 
   92     // Ticks
   93     Axis::TicksDirection majorTicksDirection; //!< major ticks direction: inwards, outwards, both, or none
   94     Axis::TicksType majorTicksType; //!< the way how the number of major ticks is specified  - either as a total number or an increment
   95     int majorTicksNumber; //!< number of major ticks
   96     qreal majorTicksSpacing; //!< spacing (step) for the major ticks
   97     const AbstractColumn* majorTicksColumn{nullptr}; //!< column containing values for major ticks' positions
   98     QString majorTicksColumnPath;
   99     qreal majorTicksLength; //!< major tick length (in page units!)
  100     QPen majorTicksPen;
  101     qreal majorTicksOpacity;
  102 
  103     Axis::TicksDirection minorTicksDirection; //!< minor ticks direction: inwards, outwards, both, or none
  104     Axis::TicksType minorTicksType;  //!< the way how the number of minor ticks is specified  - either as a total number or an increment
  105     int minorTicksNumber; //!< number of minor ticks (between each two major ticks)
  106     qreal minorTicksIncrement; //!< spacing (step) for the minor ticks
  107     const AbstractColumn* minorTicksColumn{nullptr}; //!< column containing values for minor ticks' positions
  108     QString minorTicksColumnPath;
  109     qreal minorTicksLength; //!< minor tick length (in page units!)
  110     QPen minorTicksPen;
  111     qreal minorTicksOpacity;
  112 
  113     // Tick Label
  114     Axis::LabelsFormat labelsFormat;
  115     int labelsPrecision;
  116     bool labelsAutoPrecision;
  117     QString labelsDateTimeFormat;
  118     Axis::LabelsPosition labelsPosition;
  119     qreal labelsRotationAngle;
  120     QColor labelsColor;
  121     QFont labelsFont;
  122     Axis::LabelsBackgroundType labelsBackgroundType;
  123     QColor labelsBackgroundColor;
  124     qreal labelsOffset; //!< offset, distance to the end of the tick line (in page units)
  125     qreal labelsOpacity;
  126     QString labelsPrefix;
  127     QString labelsSuffix;
  128 
  129     //Grid
  130     AxisGrid* gridItem{nullptr};
  131     QPen majorGridPen;
  132     qreal majorGridOpacity;
  133     QPen minorGridPen;
  134     qreal minorGridOpacity;
  135 
  136     Axis* const q{nullptr};
  137 
  138     QPainterPath linePath;
  139     QPainterPath majorGridPath;
  140     QPainterPath minorGridPath;
  141     bool suppressRetransform{false};
  142     bool labelsFormatDecimalOverruled{false};
  143     bool labelsFormatAutoChanged{false};
  144 
  145     CartesianPlot* plot{nullptr};
  146     const CartesianCoordinateSystem* cSystem{nullptr};
  147 
  148 private:
  149     void contextMenuEvent(QGraphicsSceneContextMenuEvent*) override;
  150     void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
  151     void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
  152     void mousePressEvent(QGraphicsSceneMouseEvent*) override;
  153     void mouseMoveEvent(QGraphicsSceneMouseEvent*) override;
  154     void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
  155     void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* widget = nullptr) override;
  156 
  157     void addArrow(QPointF point, int direction);
  158     int upperLabelsPrecision(int precision, Axis::LabelsFormat);
  159     int lowerLabelsPrecision(int precision, Axis::LabelsFormat);
  160     bool transformAnchor(QPointF*);
  161 
  162     QPainterPath arrowPath;
  163     QPainterPath majorTicksPath;
  164     QPainterPath minorTicksPath;
  165     QRectF boundingRectangle;
  166     QPainterPath axisShape;
  167 
  168     QVector<QPointF> majorTickPoints;//!< position of the major ticks  on the axis.
  169     QVector<QPointF> minorTickPoints;//!< position of the major ticks  on the axis.
  170     QVector<QPointF> tickLabelPoints; //!< position of the major tick labels (left lower edge of label's bounding rect)
  171     QVector<double> tickLabelValues; //!< major tick labels values
  172     QVector<QString> tickLabelStrings; //!< the actual text of the major tick labels
  173 
  174     bool m_hovered{false};
  175     bool m_suppressRecalc{false};
  176     bool m_printing{false};
  177     bool m_panningStarted{false};
  178     QPointF m_panningStart;
  179 };
  180 
  181 #endif