File indexing completed on 2024-05-26 04:23:53

0001 /*
0002  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #ifndef KCHARTLEVEYJENNINGSDIAGRAM_H
0010 #define KCHARTLEVEYJENNINGSDIAGRAM_H
0011 
0012 #include "KChartLineDiagram.h"
0013 #include "KChartLeveyJenningsCoordinatePlane.h"
0014 
0015 QT_BEGIN_NAMESPACE
0016 class QPainter;
0017 class QPolygonF;
0018 class QSvgRenderer;
0019 QT_END_NAMESPACE
0020 
0021 namespace KChart {
0022 
0023     class ThreeDLineAttributes;
0024 
0025 /**
0026  * @brief LeveyDiagram defines a Levey Jennings chart.
0027  *
0028  * It provides different subtypes which are set using \a setType.
0029  */
0030 class KCHART_EXPORT LeveyJenningsDiagram : public LineDiagram
0031 {
0032     Q_OBJECT
0033 
0034     Q_DISABLE_COPY( LeveyJenningsDiagram )
0035 //    KCHART_DECLARE_PRIVATE_DERIVED_PARENT( LineDiagram, CartesianCoordinatePlane * )
0036 
0037     KCHART_DECLARE_DERIVED_DIAGRAM( LeveyJenningsDiagram, LeveyJenningsCoordinatePlane )
0038 
0039 
0040 public:
0041     explicit LeveyJenningsDiagram( QWidget* parent = nullptr, LeveyJenningsCoordinatePlane* plane = nullptr );
0042     ~LeveyJenningsDiagram() override;
0043 
0044 
0045     /**
0046       * Creates an exact copy of this diagram.
0047       */
0048    LineDiagram * clone() const override;
0049 
0050     enum Symbol
0051     {
0052         OkDataPoint,
0053         NotOkDataPoint,
0054         LotChanged,
0055         SensorChanged,
0056         FluidicsPackChanged
0057     };
0058 
0059     /**
0060      * Returns true if both diagrams have the same settings.
0061      */
0062     bool compare( const LeveyJenningsDiagram* other ) const;
0063 
0064 
0065     /**
0066      * Sets the position of the lot change symbol to \a pos.
0067      * Valid values are: Qt::AlignTop (default), Qt::AlignBottom.
0068      */
0069     void setLotChangedSymbolPosition( Qt::Alignment pos );
0070 
0071     /**
0072      * Returns the position of the lot change symbol.
0073      */
0074     Qt::Alignment lotChangedSymbolPosition() const;
0075 
0076 
0077     /**
0078      * Sets the position of the fluidics pack changed symbol to \a pos.
0079      * Valid values are: Qt::AlignBottom (default), Qt::AlignTop.
0080      */
0081     void setFluidicsPackChangedSymbolPosition( Qt::Alignment pos );
0082 
0083     /**
0084      * Returns the position of the fluidics pack changed symbol.
0085      */
0086     Qt::Alignment fluidicsPackChangedSymbolPosition() const;
0087 
0088 
0089     /**
0090      * Sets the position of the sensor changed symbol to \a pos.
0091      * Valid values are: Qt::AlignBottom (default), Qt::AlignTop.
0092      */
0093     void setSensorChangedSymbolPosition( Qt::Alignment pos );
0094 
0095     /**
0096      * Returns the position of the sensor changed symbol.
0097      */
0098     Qt::Alignment sensorChangedSymbolPosition() const;
0099 
0100 
0101     /**
0102      * Sets the expected mean value over all QC values to \a meanValue.
0103      */
0104     void setExpectedMeanValue( float meanValue );
0105 
0106     /**
0107      * Returns the expected mean values over all QC values.
0108      */
0109     float expectedMeanValue() const;
0110 
0111 
0112     /**
0113      * Sets the expected standard deviaction over all QC values to \a sd.
0114      */
0115     void setExpectedStandardDeviation( float sd );
0116 
0117     /**
0118      * Returns the expected standard deviation over all QC values.
0119      */
0120     float expectedStandardDeviation() const;
0121 
0122 
0123     /**
0124      * Returns the calculated mean values over all QC values.
0125      */
0126     float calculatedMeanValue() const;
0127 
0128     /**
0129      * Returns the calculated standard deviation over all QC values.
0130      */
0131     float calculatedStandardDeviation() const;
0132 
0133 
0134     /**
0135      * Sets the date/time of all fluidics pack changes to \a changes.
0136      */
0137     void setFluidicsPackChanges( const QVector< QDateTime >& changes );
0138 
0139     /**
0140      * Returns the list of all fluidics pack changes.
0141      */
0142     QVector< QDateTime > fluidicsPackChanges() const;
0143 
0144 
0145     /**
0146      * Sets the date/time of all sensor changes to \a changes.
0147      */
0148     void setSensorChanges( const QVector< QDateTime >& changes );
0149 
0150     /**
0151      * Returns the list of all sensor changes.
0152      */
0153     QVector< QDateTime > sensorChanges() const;
0154 
0155 
0156     /**
0157      * Sets the pen used for drawing the scan line to \a pen
0158      */
0159     void setScanLinePen( const QPen& pen );
0160 
0161     /**
0162      * Returns the pen being used for drawing the scan line.
0163      */
0164     QPen scanLinePen() const;
0165 
0166 
0167     /**
0168      * Sets the symbol being used for \a symbol to a SVG file \a filename.
0169      */
0170     void setSymbol( Symbol symbol, const QString& filename );
0171 
0172     /**
0173      * Returns the SVG file name usef for \a symbol
0174      */
0175     QString symbol( Symbol symbol ) const;
0176 
0177     /* \reimpl */
0178     void setModel( QAbstractItemModel* model ) override;
0179 
0180 
0181     /**
0182      * Returns the timerange of the diagram's data.
0183      */
0184     QPair< QDateTime, QDateTime > timeRange() const;
0185 
0186     /**
0187      * Sets the \a timeRange visible on the x axis. Set it to QPair< QDateTime, QDateTime >()
0188      * to use the default auto calculation.
0189      */
0190     void setTimeRange( const QPair< QDateTime, QDateTime >& timeRange );
0191 
0192 protected:
0193 
0194     /** \reimpl */
0195     void paint( PaintContext* paintContext ) override;
0196 
0197     /**
0198      * Draws the fluidics pack and sensor changed symbols.
0199      */
0200     void drawChanges( PaintContext* paintContext );
0201 
0202 
0203     /**
0204      * Draws a data point symbol for the data point at \a pos.
0205      * @param ok True, when the data point is ok, false otherwise (different symbol)
0206      * @param ctx The PaintContext being used
0207      * @param pos Position
0208      * @param ok Draw as Ok or notOK data point
0209      */
0210     virtual void drawDataPointSymbol( PaintContext* paintContext, const QPointF& pos, bool ok );
0211 
0212     /**
0213      * Draws a lot changed symbol for the data point at \a pos.
0214      * @param ctx The PaintContext being used
0215      * @param pos Position
0216      * \sa lotChangedSymbolPosition
0217      */
0218     virtual void drawLotChangeSymbol( PaintContext* paintContext, const QPointF& pos );
0219 
0220     /**
0221      * Draws a sensor changed symbol for the data point at \a pos.
0222      * @param ctx The PaintContext being used
0223      * @param pos Position
0224      * \sa sensorChangedSymbolPosition
0225      */
0226     virtual void drawSensorChangedSymbol( PaintContext* paintContext, const QPointF& pos );
0227 
0228     /**
0229      * Draws a fluidics pack changed symbol for the data point at \a pos.
0230      * @param ctx The PaintContext being used
0231      * @param pos Position
0232      * \sa fluidicsPackChangedSymbolPosition
0233      */
0234     virtual void drawFluidicsPackChangedSymbol( PaintContext* paintContext, const QPointF& pos );
0235 
0236 
0237     /**
0238      * Returns the rectangle being used for drawing the icons
0239      */
0240     virtual QRectF iconRect() const;
0241 
0242 
0243     /**
0244      * Returns the SVG icon renderer for \a symbol
0245      */
0246     QSvgRenderer* iconRenderer( Symbol symbol );
0247 
0248     /* \reimpl */
0249 
0250     /** \reimpl */
0251     const QPair<QPointF, QPointF> calculateDataBoundaries() const override;
0252 
0253 protected Q_SLOTS:
0254     void calculateMeanAndStandardDeviation() const;
0255 }; // End of class KChartLineDiagram
0256 
0257 }
0258 
0259 #endif // KCHARTLINEDIAGRAM_H