2018-09-04 02:08:29 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Equinor ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2018-09-04 02:08:29 -05:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2018-09-04 02:08:29 -05:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-09-04 02:08:29 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "qwt_symbol.h"
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// This class overrides renderSymbols to draw symbols and labels.
|
|
|
|
/// The label is only visible in the legend, while it is clipped in the plot.
|
|
|
|
/// Therefore the method RiuQwtPlotCurve::drawSymbols also draw labels to have labels
|
|
|
|
/// in the plot as well.
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
class RiuQwtSymbol : public QwtSymbol
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum LabelPosition
|
|
|
|
{
|
|
|
|
LabelAboveSymbol,
|
2019-07-25 00:38:46 -05:00
|
|
|
LabelBelowSymbol,
|
2018-10-03 08:57:09 -05:00
|
|
|
LabelLeftOfSymbol,
|
2018-09-04 02:08:29 -05:00
|
|
|
LabelRightOfSymbol
|
|
|
|
};
|
|
|
|
enum PointSymbolEnum
|
|
|
|
{
|
|
|
|
SYMBOL_NONE,
|
|
|
|
SYMBOL_ELLIPSE,
|
|
|
|
SYMBOL_RECT,
|
|
|
|
SYMBOL_DIAMOND,
|
|
|
|
SYMBOL_TRIANGLE,
|
2019-02-21 05:52:23 -06:00
|
|
|
SYMBOL_DOWN_TRIANGLE,
|
2018-09-04 02:08:29 -05:00
|
|
|
SYMBOL_CROSS,
|
|
|
|
SYMBOL_XCROSS,
|
2019-07-25 00:38:46 -05:00
|
|
|
SYMBOL_LEFT_ALIGNED_TRIANGLE, // Aligned so pin point is at lower right corner
|
|
|
|
SYMBOL_RIGHT_ALIGNED_TRIANGLE, // Aligned so pin point is at lower left corner
|
2018-10-03 08:57:09 -05:00
|
|
|
SYMBOL_LEFT_ANGLED_TRIANGLE,
|
2019-02-21 05:52:23 -06:00
|
|
|
SYMBOL_RIGHT_ANGLED_TRIANGLE,
|
|
|
|
SYMBOL_UP_TRIANGLE,
|
|
|
|
SYMBOL_STAR1,
|
|
|
|
SYMBOL_STAR2,
|
2019-07-25 00:38:46 -05:00
|
|
|
SYMBOL_HEXAGON,
|
|
|
|
SYMBOL_LEFT_TRIANGLE,
|
|
|
|
SYMBOL_RIGHT_TRIANGLE
|
2018-09-04 02:08:29 -05:00
|
|
|
};
|
|
|
|
|
2020-01-07 07:25:19 -06:00
|
|
|
RiuQwtSymbol( PointSymbolEnum riuStyle,
|
|
|
|
const QString& label,
|
|
|
|
LabelPosition labelPosition = LabelAboveSymbol,
|
|
|
|
int labelFontSizePt = 8 );
|
2019-09-06 03:40:57 -05:00
|
|
|
void renderSymbols( QPainter* painter, const QPointF* points, int numPoints ) const override;
|
2019-09-25 10:48:19 -05:00
|
|
|
void renderSymbolLabel( QPainter* painter, const QPointF& position, const QString& label ) const;
|
|
|
|
QString globalLabel() const;
|
|
|
|
|
|
|
|
void setGlobalLabel( const QString& label );
|
2019-09-06 03:40:57 -05:00
|
|
|
|
|
|
|
void setLabelPosition( LabelPosition labelPosition );
|
|
|
|
|
|
|
|
static PointSymbolEnum cycledSymbolStyle( int indexLevel1, int indexLevel2 );
|
|
|
|
static PointSymbolEnum cycledSymbolStyle( int indexLevel );
|
2018-09-04 02:08:29 -05:00
|
|
|
|
2019-12-04 02:37:41 -06:00
|
|
|
static bool isFilledSymbol( PointSymbolEnum symbol );
|
|
|
|
|
2018-10-09 07:05:45 -05:00
|
|
|
private:
|
2019-09-25 10:48:19 -05:00
|
|
|
QRect labelBoundingRect( const QPainter* painter, const QRect& symbolRect, const QString& label ) const;
|
2018-10-09 07:05:45 -05:00
|
|
|
|
2018-09-04 02:08:29 -05:00
|
|
|
private:
|
2019-09-25 10:48:19 -05:00
|
|
|
QString m_globalLabel;
|
2020-01-07 07:25:19 -06:00
|
|
|
int m_labelFontSizePx;
|
2018-09-04 02:08:29 -05:00
|
|
|
LabelPosition m_labelPosition;
|
|
|
|
};
|