mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3297 Make casing shoe a right-angled triangle and refactor symbols
* Put plot symbol enum inside the symbol class. * Put line style enums inside the line class. * Add custom capability.
This commit is contained in:
@@ -6,7 +6,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuDragDrop.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtSymbol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h
|
||||
@@ -82,7 +83,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuDragDrop.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtSymbol.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotCurve.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "RimFlowCharacteristicsPlot.h"
|
||||
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotWheelZoomer.h"
|
||||
#include "RiuQwtPlotZoomer.h"
|
||||
#include "RiuResultQwtPlot.h"
|
||||
@@ -151,7 +151,7 @@ void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(QwtPlot* plot, const QS
|
||||
|
||||
curve->setSymbol(symbol);
|
||||
|
||||
// Add date and value twice to avoid a cross as symbol generated by RiuLineSegmentQwtPlotCurve
|
||||
// Add date and value twice to avoid a cross as symbol generated by RiuQwtPlotCurve
|
||||
|
||||
std::vector<QDateTime> dateTimes;
|
||||
dateTimes.push_back(dateTime);
|
||||
@@ -167,9 +167,9 @@ void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(QwtPlot* plot, const QS
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuLineSegmentQwtPlotCurve* RiuFlowCharacteristicsPlot::createEmptyCurve(QwtPlot* plot, const QString& curveName, const QColor& curveColor )
|
||||
RiuQwtPlotCurve* RiuFlowCharacteristicsPlot::createEmptyCurve(QwtPlot* plot, const QString& curveName, const QColor& curveColor )
|
||||
{
|
||||
RiuLineSegmentQwtPlotCurve* plotCurve = new RiuLineSegmentQwtPlotCurve(curveName);
|
||||
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve(curveName);
|
||||
|
||||
plotCurve->setTitle(curveName);
|
||||
plotCurve->setPen(QPen(curveColor));
|
||||
@@ -184,7 +184,7 @@ void RiuFlowCharacteristicsPlot::addFlowCapStorageCapCurve(const QDateTime& date
|
||||
{
|
||||
CVF_ASSERT(!m_dateToColorMap.empty());
|
||||
|
||||
RiuLineSegmentQwtPlotCurve* plotCurve = createEmptyCurve(m_flowCapVsStorageCapPlot, dateTime.toString(), m_dateToColorMap[dateTime]);
|
||||
RiuQwtPlotCurve* plotCurve = createEmptyCurve(m_flowCapVsStorageCapPlot, dateTime.toString(), m_dateToColorMap[dateTime]);
|
||||
plotCurve->setSamplesFromXValuesAndYValues(xVals, yVals, false);
|
||||
m_flowCapVsStorageCapPlot->replot();
|
||||
}
|
||||
@@ -196,7 +196,7 @@ void RiuFlowCharacteristicsPlot::addSweepEfficiencyCurve(const QDateTime& dateTi
|
||||
{
|
||||
CVF_ASSERT(!m_dateToColorMap.empty());
|
||||
|
||||
RiuLineSegmentQwtPlotCurve* plotCurve = createEmptyCurve(m_sweepEffPlot, dateTime.toString(), m_dateToColorMap[dateTime]);
|
||||
RiuQwtPlotCurve* plotCurve = createEmptyCurve(m_sweepEffPlot, dateTime.toString(), m_dateToColorMap[dateTime]);
|
||||
plotCurve->setSamplesFromXValuesAndYValues(xVals, yVals, false);
|
||||
|
||||
m_sweepEffPlot->replot();
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
class RimFlowCharacteristicsPlot;
|
||||
class RiuNightchartsWidget;
|
||||
class RiuResultQwtPlot;
|
||||
class RiuLineSegmentQwtPlotCurve;
|
||||
class RiuQwtPlotCurve;
|
||||
|
||||
class QLabel;
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
virtual RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
static void addWindowZoom(QwtPlot* plot);
|
||||
static RiuLineSegmentQwtPlotCurve* createEmptyCurve(QwtPlot* plot, const QString& curveName, const QColor& curveColor);
|
||||
static RiuQwtPlotCurve* createEmptyCurve(QwtPlot* plot, const QString& curveName, const QColor& curveColor);
|
||||
|
||||
protected:
|
||||
virtual QSize sizeHint() const override;
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
|
||||
#include "RiaCurveDataTools.h"
|
||||
#include "RiuQwtSymbol.h"
|
||||
|
||||
#include "qwt_symbol.h"
|
||||
#include "RiaCurveDataTools.h"
|
||||
#include "qwt_date.h"
|
||||
#include "qwt_point_mapper.h"
|
||||
#include "qwt_painter.h"
|
||||
@@ -38,7 +40,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuLineSegmentQwtPlotCurve::RiuLineSegmentQwtPlotCurve(const QString &title)
|
||||
RiuQwtPlotCurve::RiuQwtPlotCurve(const QString &title)
|
||||
: QwtPlotCurve(title)
|
||||
{
|
||||
this->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
|
||||
@@ -61,14 +63,14 @@ RiuLineSegmentQwtPlotCurve::RiuLineSegmentQwtPlotCurve(const QString &title)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuLineSegmentQwtPlotCurve::~RiuLineSegmentQwtPlotCurve()
|
||||
RiuQwtPlotCurve::~RiuQwtPlotCurve()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromXValuesAndYValues(const std::vector<double>& xValues, const std::vector<double>& yValues, const std::vector<double>& yErrorValues, bool keepOnlyPositiveValues)
|
||||
void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues(const std::vector<double>& xValues, const std::vector<double>& yValues, const std::vector<double>& yErrorValues, bool keepOnlyPositiveValues)
|
||||
{
|
||||
CVF_ASSERT(xValues.size() == yValues.size());
|
||||
CVF_ASSERT(yErrorValues.empty() || yErrorValues.size() == xValues.size());
|
||||
@@ -115,7 +117,7 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromXValuesAndYValues(const std::vect
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromXValuesAndYValues(const std::vector<double>& xValues, const std::vector<double>& yValues, bool keepOnlyPositiveValues)
|
||||
void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues(const std::vector<double>& xValues, const std::vector<double>& yValues, bool keepOnlyPositiveValues)
|
||||
{
|
||||
setSamplesFromXValuesAndYValues(xValues, yValues, std::vector<double>(), keepOnlyPositiveValues);
|
||||
}
|
||||
@@ -123,31 +125,31 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromXValuesAndYValues(const std::vect
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromDatesAndYValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& yValues, bool keepOnlyPositiveValues)
|
||||
void RiuQwtPlotCurve::setSamplesFromDatesAndYValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& yValues, bool keepOnlyPositiveValues)
|
||||
{
|
||||
setSamplesFromXValuesAndYValues(RiuLineSegmentQwtPlotCurve::fromQDateTime(dateTimes), yValues, std::vector<double>(), keepOnlyPositiveValues);
|
||||
setSamplesFromXValuesAndYValues(RiuQwtPlotCurve::fromQDateTime(dateTimes), yValues, std::vector<double>(), keepOnlyPositiveValues);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromTimeTAndYValues(const std::vector<time_t>& dateTimes, const std::vector<double>& yValues, bool keepOnlyPositiveValues)
|
||||
void RiuQwtPlotCurve::setSamplesFromTimeTAndYValues(const std::vector<time_t>& dateTimes, const std::vector<double>& yValues, bool keepOnlyPositiveValues)
|
||||
{
|
||||
setSamplesFromXValuesAndYValues(RiuLineSegmentQwtPlotCurve::fromTime_t(dateTimes), yValues, std::vector<double>(), keepOnlyPositiveValues);
|
||||
setSamplesFromXValuesAndYValues(RiuQwtPlotCurve::fromTime_t(dateTimes), yValues, std::vector<double>(), keepOnlyPositiveValues);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromTimeTAndYValues(const std::vector<time_t>& dateTimes, const std::vector<double>& yValues, const std::vector<double>& yErrorValues, bool keepOnlyPositiveValues)
|
||||
void RiuQwtPlotCurve::setSamplesFromTimeTAndYValues(const std::vector<time_t>& dateTimes, const std::vector<double>& yValues, const std::vector<double>& yErrorValues, bool keepOnlyPositiveValues)
|
||||
{
|
||||
setSamplesFromXValuesAndYValues(RiuLineSegmentQwtPlotCurve::fromTime_t(dateTimes), yValues, yErrorValues, keepOnlyPositiveValues);
|
||||
setSamplesFromXValuesAndYValues(RiuQwtPlotCurve::fromTime_t(dateTimes), yValues, yErrorValues, keepOnlyPositiveValues);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::drawCurve(QPainter* p, int style,
|
||||
void RiuQwtPlotCurve::drawCurve(QPainter* p, int style,
|
||||
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
|
||||
const QRectF& canvasRect, int from, int to) const
|
||||
{
|
||||
@@ -181,7 +183,7 @@ void RiuLineSegmentQwtPlotCurve::drawCurve(QPainter* p, int style,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Drawing symbols but skipping if they are to close to the previous one
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::drawSymbols(QPainter *painter, const QwtSymbol &symbol,
|
||||
void RiuQwtPlotCurve::drawSymbols(QPainter *painter, const QwtSymbol &symbol,
|
||||
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
||||
const QRectF &canvasRect, int from, int to) const
|
||||
{
|
||||
@@ -237,7 +239,7 @@ void RiuLineSegmentQwtPlotCurve::drawSymbols(QPainter *painter, const QwtSymbol
|
||||
{
|
||||
symbol.drawSymbols(painter, pointsToDisplay);
|
||||
|
||||
const RiuCurveQwtSymbol* sym = dynamic_cast<const RiuCurveQwtSymbol*>(&symbol);
|
||||
const RiuQwtSymbol* sym = dynamic_cast<const RiuQwtSymbol*>(&symbol);
|
||||
|
||||
if (sym && !sym->label().isEmpty())
|
||||
{
|
||||
@@ -252,7 +254,7 @@ void RiuLineSegmentQwtPlotCurve::drawSymbols(QPainter *painter, const QwtSymbol
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setLineSegmentStartStopIndices(const std::vector< std::pair<size_t, size_t> >& lineSegmentStartStopIndices)
|
||||
void RiuQwtPlotCurve::setLineSegmentStartStopIndices(const std::vector< std::pair<size_t, size_t> >& lineSegmentStartStopIndices)
|
||||
{
|
||||
m_polyLineStartStopIndices = lineSegmentStartStopIndices;
|
||||
}
|
||||
@@ -260,7 +262,7 @@ void RiuLineSegmentQwtPlotCurve::setLineSegmentStartStopIndices(const std::vecto
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setSymbolSkipPixelDistance(float distance)
|
||||
void RiuQwtPlotCurve::setSymbolSkipPixelDistance(float distance)
|
||||
{
|
||||
m_symbolSkipPixelDistance = distance >= 0.0f ? distance: 0.0f;
|
||||
}
|
||||
@@ -268,7 +270,7 @@ void RiuLineSegmentQwtPlotCurve::setSymbolSkipPixelDistance(float distance)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::attach(QwtPlot *plot)
|
||||
void RiuQwtPlotCurve::attach(QwtPlot *plot)
|
||||
{
|
||||
QwtPlotItem::attach(plot);
|
||||
if(m_showErrorBars) m_errorBars->attach(plot);
|
||||
@@ -278,7 +280,7 @@ void RiuLineSegmentQwtPlotCurve::attach(QwtPlot *plot)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::detach()
|
||||
void RiuQwtPlotCurve::detach()
|
||||
{
|
||||
QwtPlotItem::detach();
|
||||
m_errorBars->detach();
|
||||
@@ -288,7 +290,7 @@ void RiuLineSegmentQwtPlotCurve::detach()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::clearErrorBars()
|
||||
void RiuQwtPlotCurve::clearErrorBars()
|
||||
{
|
||||
m_errorBars->setSamples(nullptr);
|
||||
}
|
||||
@@ -296,7 +298,7 @@ void RiuLineSegmentQwtPlotCurve::clearErrorBars()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::showErrorBars(bool show)
|
||||
void RiuQwtPlotCurve::showErrorBars(bool show)
|
||||
{
|
||||
m_showErrorBars = show;
|
||||
if (m_showErrorBars && m_attachedToPlot) m_errorBars->attach(m_attachedToPlot);
|
||||
@@ -306,17 +308,69 @@ void RiuLineSegmentQwtPlotCurve::showErrorBars(bool show)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setErrorBarsColor(QColor color)
|
||||
void RiuQwtPlotCurve::setErrorBarsColor(QColor color)
|
||||
{
|
||||
QwtIntervalSymbol* newSymbol = new QwtIntervalSymbol(QwtIntervalSymbol::Bar);
|
||||
newSymbol->setPen(QPen(color));
|
||||
m_errorBars->setSymbol(newSymbol);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotCurve::setAppearance(LineStyleEnum lineStyle,
|
||||
CurveInterpolationEnum interpolationType,
|
||||
int curveThickness,
|
||||
const QColor& curveColor)
|
||||
{
|
||||
QwtPlotCurve::CurveStyle curveStyle = QwtPlotCurve::NoCurve;
|
||||
Qt::PenStyle penStyle = Qt::SolidLine;
|
||||
|
||||
if (lineStyle != STYLE_NONE)
|
||||
{
|
||||
switch (interpolationType)
|
||||
{
|
||||
case INTERPOLATION_STEP_LEFT:
|
||||
curveStyle = QwtPlotCurve::Steps;
|
||||
setCurveAttribute(QwtPlotCurve::Inverted, false);
|
||||
break;
|
||||
case INTERPOLATION_POINT_TO_POINT: // Fall through
|
||||
default:
|
||||
curveStyle = QwtPlotCurve::Lines;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (lineStyle)
|
||||
{
|
||||
case STYLE_SOLID:
|
||||
penStyle = Qt::SolidLine;
|
||||
break;
|
||||
case STYLE_DASH:
|
||||
penStyle = Qt::DashLine;
|
||||
break;
|
||||
case STYLE_DOT:
|
||||
penStyle = Qt::DotLine;
|
||||
break;
|
||||
case STYLE_DASH_DOT:
|
||||
penStyle = Qt::DashDotLine;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
QPen curvePen(curveColor);
|
||||
curvePen.setWidth(curveThickness);
|
||||
curvePen.setStyle(penStyle);
|
||||
|
||||
setPen(curvePen);
|
||||
setStyle(curveStyle);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RiuLineSegmentQwtPlotCurve::fromQDateTime(const std::vector<QDateTime>& dateTimes)
|
||||
std::vector<double> RiuQwtPlotCurve::fromQDateTime(const std::vector<QDateTime>& dateTimes)
|
||||
{
|
||||
std::vector<double> doubleValues;
|
||||
|
||||
@@ -336,7 +390,7 @@ std::vector<double> RiuLineSegmentQwtPlotCurve::fromQDateTime(const std::vector<
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RiuLineSegmentQwtPlotCurve::fromTime_t(const std::vector<time_t>& timeSteps)
|
||||
std::vector<double> RiuQwtPlotCurve::fromTime_t(const std::vector<time_t>& timeSteps)
|
||||
{
|
||||
std::vector<double> doubleValues;
|
||||
|
||||
@@ -353,50 +407,3 @@ std::vector<double> RiuLineSegmentQwtPlotCurve::fromTime_t(const std::vector<tim
|
||||
|
||||
return doubleValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal class to support labels on symbols
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuCurveQwtSymbol::RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label, LabelPosition labelPosition)
|
||||
: QwtSymbol(style), m_label(label), m_labelPosition(labelPosition)
|
||||
{
|
||||
}
|
||||
|
||||
void RiuCurveQwtSymbol::renderSymbols(QPainter *painter, const QPointF *points, int numPoints) const
|
||||
{
|
||||
QwtSymbol::renderSymbols(painter, points, numPoints);
|
||||
|
||||
if (!m_label.isEmpty())
|
||||
{
|
||||
for (int i = 0; i < numPoints; i++)
|
||||
{
|
||||
auto position = points[i];
|
||||
renderSymbolLabel(painter, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuCurveQwtSymbol::renderSymbolLabel(QPainter *painter, const QPointF& position) const
|
||||
{
|
||||
int symbolWidth = this->size().width();
|
||||
int labelWidth = painter->fontMetrics().width(m_label);
|
||||
if (m_labelPosition == LabelAboveSymbol)
|
||||
{
|
||||
painter->drawText(position.x() - labelWidth / 2, position.y() - 5, m_label);
|
||||
}
|
||||
else if (m_labelPosition == LabelRightOfSymbol)
|
||||
{
|
||||
painter->drawText(position.x() + symbolWidth / 2 + 1, position.y(), m_label);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuCurveQwtSymbol::setLabelPosition(LabelPosition labelPosition)
|
||||
{
|
||||
m_labelPosition = labelPosition;
|
||||
}
|
||||
@@ -45,11 +45,27 @@ class RiuErrorBarsQwtPlotCurve;
|
||||
// Values 1.0|2.0|inf|inf|inf|1.0|2.0|1.0|inf|1.0|1.0|inf|1.0|inf
|
||||
// Vec index 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13
|
||||
//==================================================================================================
|
||||
class RiuLineSegmentQwtPlotCurve : public QwtPlotCurve
|
||||
class RiuQwtPlotCurve : public QwtPlotCurve
|
||||
{
|
||||
public:
|
||||
explicit RiuLineSegmentQwtPlotCurve(const QString &title = QString::null);
|
||||
virtual ~RiuLineSegmentQwtPlotCurve();
|
||||
enum CurveInterpolationEnum
|
||||
{
|
||||
INTERPOLATION_POINT_TO_POINT,
|
||||
INTERPOLATION_STEP_LEFT,
|
||||
};
|
||||
|
||||
enum LineStyleEnum
|
||||
{
|
||||
STYLE_NONE,
|
||||
STYLE_SOLID,
|
||||
STYLE_DASH,
|
||||
STYLE_DOT,
|
||||
STYLE_DASH_DOT
|
||||
};
|
||||
|
||||
public:
|
||||
explicit RiuQwtPlotCurve(const QString &title = QString::null);
|
||||
virtual ~RiuQwtPlotCurve();
|
||||
|
||||
void setSamplesFromXValuesAndYValues(const std::vector<double>& xValues,
|
||||
const std::vector<double>& yValues,
|
||||
@@ -83,6 +99,11 @@ public:
|
||||
void showErrorBars(bool show);
|
||||
void setErrorBarsColor(QColor color);
|
||||
|
||||
void setAppearance(LineStyleEnum lineStyle,
|
||||
CurveInterpolationEnum interpolationType,
|
||||
int curveThickness,
|
||||
const QColor& curveColor);
|
||||
|
||||
protected:
|
||||
virtual void drawCurve(QPainter* p, int style,
|
||||
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
|
||||
@@ -108,30 +129,3 @@ private:
|
||||
QwtPlotIntervalCurve* m_errorBars;
|
||||
QwtPlot* m_attachedToPlot;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// 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 RiuLineSegmentQwtPlotCurve::drawSymbols also draw labels to have labels
|
||||
/// in the plot as well.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiuCurveQwtSymbol : public QwtSymbol
|
||||
{
|
||||
public:
|
||||
enum LabelPosition
|
||||
{
|
||||
LabelAboveSymbol,
|
||||
LabelRightOfSymbol
|
||||
};
|
||||
RiuCurveQwtSymbol(QwtSymbol::Style style, const QString& label, LabelPosition labelPosition = LabelAboveSymbol);
|
||||
|
||||
virtual void renderSymbols(QPainter *painter, const QPointF *points, int numPoints) const override;
|
||||
void renderSymbolLabel(QPainter *painter, const QPointF& position) const;
|
||||
QString label() const { return m_label; }
|
||||
|
||||
void setLabelPosition(LabelPosition labelPosition);
|
||||
|
||||
private:
|
||||
QString m_label;
|
||||
LabelPosition m_labelPosition;
|
||||
};
|
||||
127
ApplicationCode/UserInterface/RiuQwtSymbol.cpp
Normal file
127
ApplicationCode/UserInterface/RiuQwtSymbol.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Equinor ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuQwtSymbol.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal class to support labels on symbols
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtSymbol::RiuQwtSymbol(PointSymbolEnum riuStyle, const QString& label, LabelPosition labelPosition)
|
||||
: QwtSymbol(QwtSymbol::NoSymbol), m_label(label), m_labelPosition(labelPosition)
|
||||
{
|
||||
QwtSymbol::Style style = QwtSymbol::NoSymbol;
|
||||
|
||||
switch (riuStyle)
|
||||
{
|
||||
case SYMBOL_ELLIPSE:
|
||||
style = QwtSymbol::Ellipse;
|
||||
break;
|
||||
case SYMBOL_RECT:
|
||||
style = QwtSymbol::Rect;
|
||||
break;
|
||||
case SYMBOL_DIAMOND:
|
||||
style = QwtSymbol::Diamond;
|
||||
break;
|
||||
case SYMBOL_TRIANGLE:
|
||||
style = QwtSymbol::Triangle;
|
||||
break;
|
||||
case SYMBOL_CROSS:
|
||||
style = QwtSymbol::Cross;
|
||||
break;
|
||||
case SYMBOL_XCROSS:
|
||||
style = QwtSymbol::XCross;
|
||||
break;
|
||||
case SYMBOL_DOWN_TRIANGLE:
|
||||
style = QwtSymbol::DTriangle;
|
||||
break;
|
||||
case SYMBOL_LEFT_TRIANGLE:
|
||||
style = QwtSymbol::Path;
|
||||
{
|
||||
QPainterPath path;
|
||||
path.moveTo(0, 0);
|
||||
path.lineTo(-10, 0);
|
||||
path.lineTo(0, -10);
|
||||
path.lineTo(0, 0);
|
||||
setPath(path);
|
||||
setPinPoint(QPointF(0, 0));
|
||||
}
|
||||
break;
|
||||
case SYMBOL_RIGHT_TRIANGLE:
|
||||
style = QwtSymbol::Path;
|
||||
{
|
||||
QPainterPath path;
|
||||
path.moveTo(0, 0);
|
||||
path.lineTo(10, 0);
|
||||
path.lineTo(0, -10);
|
||||
path.lineTo(0, 0);
|
||||
setPath(path);
|
||||
setPinPoint(QPointF(0, 0));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
setStyle(style);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtSymbol::renderSymbols(QPainter *painter, const QPointF *points, int numPoints) const
|
||||
{
|
||||
QwtSymbol::renderSymbols(painter, points, numPoints);
|
||||
|
||||
if (!m_label.isEmpty())
|
||||
{
|
||||
for (int i = 0; i < numPoints; i++)
|
||||
{
|
||||
auto position = points[i];
|
||||
renderSymbolLabel(painter, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtSymbol::renderSymbolLabel(QPainter *painter, const QPointF& position) const
|
||||
{
|
||||
int symbolWidth = this->size().width();
|
||||
int labelWidth = painter->fontMetrics().width(m_label);
|
||||
if (m_labelPosition == LabelAboveSymbol)
|
||||
{
|
||||
painter->drawText(position.x() - labelWidth / 2, position.y() - 5, m_label);
|
||||
}
|
||||
else if (m_labelPosition == LabelRightOfSymbol)
|
||||
{
|
||||
painter->drawText(position.x() + symbolWidth / 2 + 1, position.y(), m_label);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtSymbol::setLabelPosition(LabelPosition labelPosition)
|
||||
{
|
||||
m_labelPosition = labelPosition;
|
||||
}
|
||||
|
||||
|
||||
66
ApplicationCode/UserInterface/RiuQwtSymbol.h
Normal file
66
ApplicationCode/UserInterface/RiuQwtSymbol.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Equinor ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// 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,
|
||||
LabelRightOfSymbol
|
||||
};
|
||||
enum PointSymbolEnum
|
||||
{
|
||||
SYMBOL_NONE,
|
||||
SYMBOL_ELLIPSE,
|
||||
SYMBOL_RECT,
|
||||
SYMBOL_DIAMOND,
|
||||
SYMBOL_TRIANGLE,
|
||||
SYMBOL_CROSS,
|
||||
SYMBOL_XCROSS,
|
||||
SYMBOL_DOWN_TRIANGLE,
|
||||
SYMBOL_LEFT_TRIANGLE,
|
||||
SYMBOL_RIGHT_TRIANGLE
|
||||
};
|
||||
|
||||
RiuQwtSymbol(PointSymbolEnum riuStyle, const QString& label, LabelPosition labelPosition = LabelAboveSymbol);
|
||||
|
||||
virtual void renderSymbols(QPainter *painter, const QPointF *points, int numPoints) const override;
|
||||
void renderSymbolLabel(QPainter *painter, const QPointF& position) const;
|
||||
QString label() const { return m_label; }
|
||||
|
||||
void setLabelPosition(LabelPosition labelPosition);
|
||||
|
||||
private:
|
||||
QString m_label;
|
||||
LabelPosition m_labelPosition;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "RiuRelativePermeabilityPlotPanel.h"
|
||||
#include "RiuRelativePermeabilityPlotUpdater.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuTextDialog.h"
|
||||
|
||||
#include "RiaCurveDataTools.h"
|
||||
@@ -315,7 +315,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
|
||||
}
|
||||
|
||||
//QwtPlotCurve* qwtCurve = new QwtPlotCurve(curve.name.c_str());
|
||||
RiuLineSegmentQwtPlotCurve* qwtCurve = new RiuLineSegmentQwtPlotCurve(curve.name.c_str());
|
||||
RiuQwtPlotCurve* qwtCurve = new RiuQwtPlotCurve(curve.name.c_str());
|
||||
|
||||
CVF_ASSERT(curve.saturationVals.size() == curve.yVals.size());
|
||||
//qwtCurve->setSamples(curve.xVals.data(), curve.yVals.data(), static_cast<int>(curve.xVals.size()));
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "RimContextCommandBuilder.h"
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuTextDialog.h"
|
||||
|
||||
@@ -72,7 +72,7 @@ void RiuResultQwtPlot::addCurve(const RimCase* rimCase, const QString& curveName
|
||||
return;
|
||||
}
|
||||
|
||||
RiuLineSegmentQwtPlotCurve* plotCurve = new RiuLineSegmentQwtPlotCurve("Curve 1");
|
||||
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve("Curve 1");
|
||||
|
||||
plotCurve->setSamplesFromDatesAndYValues(dateTimes, timeHistoryValues, false);
|
||||
plotCurve->setTitle(curveName);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuRimQwtPlotCurve::RiuRimQwtPlotCurve(RimPlotCurve* ownerRimCurve, const QString &title /*= QString::null*/)
|
||||
: RiuLineSegmentQwtPlotCurve(title)
|
||||
: RiuQwtPlotCurve(title)
|
||||
, m_ownerRimCurve(ownerRimCurve)
|
||||
{
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
class RimPlotCurve;
|
||||
|
||||
class RiuRimQwtPlotCurve: public RiuLineSegmentQwtPlotCurve
|
||||
class RiuRimQwtPlotCurve: public RiuQwtPlotCurve
|
||||
{
|
||||
public:
|
||||
explicit RiuRimQwtPlotCurve(RimPlotCurve* ownerRimCurve, const QString &title = QString::null);
|
||||
|
||||
Reference in New Issue
Block a user