mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Moved Box shape creator to QwtPlotTools for use in correlation matrix
This commit is contained in:
parent
48c4d81505
commit
85851d0794
@ -25,6 +25,7 @@
|
|||||||
#include "qwt_plot.h"
|
#include "qwt_plot.h"
|
||||||
#include "qwt_plot_grid.h"
|
#include "qwt_plot_grid.h"
|
||||||
#include "qwt_plot_layout.h"
|
#include "qwt_plot_layout.h"
|
||||||
|
#include "qwt_plot_shapeitem.h"
|
||||||
#include "qwt_scale_widget.h"
|
#include "qwt_scale_widget.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
@ -66,7 +67,7 @@ void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot )
|
|||||||
plot->setAxisFont( QwtPlot::yRight, axisFont );
|
plot->setAxisFont( QwtPlot::yRight, axisFont );
|
||||||
|
|
||||||
// Axis title font
|
// Axis title font
|
||||||
std::vector<QwtPlot::Axis> axes = {QwtPlot::xBottom, QwtPlot::xTop, QwtPlot::yLeft, QwtPlot::yRight};
|
std::vector<QwtPlot::Axis> axes = { QwtPlot::xBottom, QwtPlot::xTop, QwtPlot::yLeft, QwtPlot::yRight };
|
||||||
|
|
||||||
for ( QwtPlot::Axis axis : axes )
|
for ( QwtPlot::Axis axis : axes )
|
||||||
{
|
{
|
||||||
@ -130,14 +131,14 @@ void RiuQwtPlotTools::enableDateBasedBottomXAxis( QwtPlot*
|
|||||||
{
|
{
|
||||||
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw( Qt::UTC );
|
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw( Qt::UTC );
|
||||||
|
|
||||||
std::set<QwtDate::IntervalType> intervals = {QwtDate::Year,
|
std::set<QwtDate::IntervalType> intervals = { QwtDate::Year,
|
||||||
QwtDate::Month,
|
QwtDate::Month,
|
||||||
QwtDate::Week,
|
QwtDate::Week,
|
||||||
QwtDate::Day,
|
QwtDate::Day,
|
||||||
QwtDate::Hour,
|
QwtDate::Hour,
|
||||||
QwtDate::Minute,
|
QwtDate::Minute,
|
||||||
QwtDate::Second,
|
QwtDate::Second,
|
||||||
QwtDate::Millisecond};
|
QwtDate::Millisecond };
|
||||||
|
|
||||||
for ( QwtDate::IntervalType interval : intervals )
|
for ( QwtDate::IntervalType interval : intervals )
|
||||||
{
|
{
|
||||||
@ -208,3 +209,30 @@ QString RiuQwtPlotTools::dateTimeFormatForInterval( QwtDate::IntervalType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QwtPlotItem* RiuQwtPlotTools::createBoxShape( const QString& label,
|
||||||
|
double startX,
|
||||||
|
double endX,
|
||||||
|
double startY,
|
||||||
|
double endY,
|
||||||
|
QColor color,
|
||||||
|
Qt::BrushStyle brushStyle )
|
||||||
|
{
|
||||||
|
QwtPlotShapeItem* columnShape = new QwtPlotShapeItem( label );
|
||||||
|
QPolygonF polygon;
|
||||||
|
|
||||||
|
polygon.push_back( QPointF( startX, startY ) );
|
||||||
|
polygon.push_back( QPointF( endX, startY ) );
|
||||||
|
polygon.push_back( QPointF( endX, endY ) );
|
||||||
|
polygon.push_back( QPointF( startX, endY ) );
|
||||||
|
polygon.push_back( QPointF( startX, startY ) );
|
||||||
|
columnShape->setPolygon( polygon );
|
||||||
|
columnShape->setXAxis( QwtPlot::xBottom );
|
||||||
|
columnShape->setBrush( QBrush( color, brushStyle ) );
|
||||||
|
columnShape->setLegendMode( QwtPlotShapeItem::LegendShape );
|
||||||
|
columnShape->setLegendIconSize( QSize( 16, 16 ) );
|
||||||
|
return columnShape;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <qwt_date.h>
|
#include <qwt_date.h>
|
||||||
|
|
||||||
class QwtPlot;
|
class QwtPlot;
|
||||||
|
class QwtPlotItem;
|
||||||
|
|
||||||
class RiuQwtPlotTools
|
class RiuQwtPlotTools
|
||||||
{
|
{
|
||||||
@ -39,4 +40,12 @@ public:
|
|||||||
const QString& timeFormat,
|
const QString& timeFormat,
|
||||||
RiaQDateTimeTools::DateFormatComponents dateComponents,
|
RiaQDateTimeTools::DateFormatComponents dateComponents,
|
||||||
RiaQDateTimeTools::TimeFormatComponents timeComponents );
|
RiaQDateTimeTools::TimeFormatComponents timeComponents );
|
||||||
|
|
||||||
|
static QwtPlotItem* createBoxShape( const QString& label,
|
||||||
|
double startX,
|
||||||
|
double endX,
|
||||||
|
double startY,
|
||||||
|
double endY,
|
||||||
|
QColor color,
|
||||||
|
Qt::BrushStyle brushStyle = Qt::SolidPattern );
|
||||||
};
|
};
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "RimWellPathValve.h"
|
#include "RimWellPathValve.h"
|
||||||
|
|
||||||
#include "RigWellPath.h"
|
#include "RigWellPath.h"
|
||||||
|
#include "RiuQwtPlotTools.h"
|
||||||
|
|
||||||
#include "qwt_plot.h"
|
#include "qwt_plot.h"
|
||||||
#include "qwt_plot_marker.h"
|
#include "qwt_plot_marker.h"
|
||||||
@ -410,65 +411,45 @@ void RiuWellPathComponentPlotItem::addColumnFeature( double startX,
|
|||||||
cvf::Color4f baseColor,
|
cvf::Color4f baseColor,
|
||||||
Qt::BrushStyle brushStyle /*= Qt::SolidPattern*/ )
|
Qt::BrushStyle brushStyle /*= Qt::SolidPattern*/ )
|
||||||
{
|
{
|
||||||
|
QColor baseQColor = RiaColorTools::toQColor( baseColor );
|
||||||
if ( brushStyle != Qt::SolidPattern )
|
if ( brushStyle != Qt::SolidPattern )
|
||||||
{
|
{
|
||||||
// If we're doing a special pattern, draw the background in white first over the existing pattern
|
// If we're doing a special pattern, draw the background in white first over the existing pattern
|
||||||
cvf::Color4f semiTransparentWhite( cvf::Color3f( cvf::Color3::WHITE ), 0.9f );
|
QColor semiTransparentWhite( Qt::white );
|
||||||
|
semiTransparentWhite.setAlphaF( 0.9f );
|
||||||
QwtPlotItem* backgroundShape =
|
QwtPlotItem* backgroundShape =
|
||||||
createColumnShape( startX, endX, startDepth, endDepth, semiTransparentWhite, Qt::SolidPattern );
|
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startDepth, endDepth, semiTransparentWhite, Qt::SolidPattern );
|
||||||
m_combinedComponentGroup.addPlotItem( backgroundShape );
|
m_combinedComponentGroup.addPlotItem( backgroundShape );
|
||||||
|
|
||||||
QwtPlotItem* patternShape = createColumnShape( startX, endX, startDepth, endDepth, baseColor, brushStyle );
|
QwtPlotItem* patternShape =
|
||||||
|
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startDepth, endDepth, baseQColor, brushStyle );
|
||||||
m_combinedComponentGroup.addPlotItem( patternShape );
|
m_combinedComponentGroup.addPlotItem( patternShape );
|
||||||
if ( endX >= 0.0 )
|
if ( endX >= 0.0 )
|
||||||
{
|
{
|
||||||
QwtPlotItem* legendBGShape = createColumnShape( 0.0, 16.0, 0.0, 16.0, semiTransparentWhite, Qt::SolidPattern );
|
QwtPlotItem* legendBGShape =
|
||||||
|
RiuQwtPlotTools::createBoxShape( label(), 0.0, 16.0, 0.0, 16.0, semiTransparentWhite, Qt::SolidPattern );
|
||||||
m_combinedComponentGroup.addLegendItem( legendBGShape );
|
m_combinedComponentGroup.addLegendItem( legendBGShape );
|
||||||
|
|
||||||
QwtPlotItem* legendShape = createColumnShape( 0.0, 16.0, 0.0, 16.0, baseColor, brushStyle );
|
QwtPlotItem* legendShape =
|
||||||
|
RiuQwtPlotTools::createBoxShape( label(), 0.0, 16.0, 0.0, 16.0, baseQColor, brushStyle );
|
||||||
m_combinedComponentGroup.addLegendItem( legendShape );
|
m_combinedComponentGroup.addLegendItem( legendShape );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QwtPlotItem* backgroundShape = createColumnShape( startX, endX, startDepth, endDepth, baseColor, Qt::SolidPattern );
|
QwtPlotItem* backgroundShape =
|
||||||
|
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startDepth, endDepth, baseQColor, Qt::SolidPattern );
|
||||||
m_combinedComponentGroup.addPlotItem( backgroundShape );
|
m_combinedComponentGroup.addPlotItem( backgroundShape );
|
||||||
|
|
||||||
if ( endX >= 0.0 )
|
if ( endX >= 0.0 )
|
||||||
{
|
{
|
||||||
QwtPlotItem* legendShape = createColumnShape( 0.0, 16.0, 0.0, 16.0, baseColor, Qt::SolidPattern );
|
QwtPlotItem* legendShape =
|
||||||
|
RiuQwtPlotTools::createBoxShape( label(), 0.0, 16.0, 0.0, 16.0, baseQColor, Qt::SolidPattern );
|
||||||
m_combinedComponentGroup.addLegendItem( legendShape );
|
m_combinedComponentGroup.addLegendItem( legendShape );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
QwtPlotItem* RiuWellPathComponentPlotItem::createColumnShape( double startX,
|
|
||||||
double endX,
|
|
||||||
double startDepth,
|
|
||||||
double endDepth,
|
|
||||||
cvf::Color4f baseColor,
|
|
||||||
Qt::BrushStyle brushStyle )
|
|
||||||
{
|
|
||||||
QwtPlotShapeItem* columnShape = new QwtPlotShapeItem( label() );
|
|
||||||
QPolygonF polygon;
|
|
||||||
QColor color = RiaColorTools::toQColor( baseColor );
|
|
||||||
|
|
||||||
polygon.push_back( QPointF( startX, startDepth ) );
|
|
||||||
polygon.push_back( QPointF( endX, startDepth ) );
|
|
||||||
polygon.push_back( QPointF( endX, endDepth ) );
|
|
||||||
polygon.push_back( QPointF( startX, endDepth ) );
|
|
||||||
polygon.push_back( QPointF( startX, startDepth ) );
|
|
||||||
columnShape->setPolygon( polygon );
|
|
||||||
columnShape->setXAxis( QwtPlot::xBottom );
|
|
||||||
columnShape->setBrush( QBrush( color, brushStyle ) );
|
|
||||||
columnShape->setLegendMode( QwtPlotShapeItem::LegendShape );
|
|
||||||
columnShape->setLegendIconSize( QSize( 16, 16 ) );
|
|
||||||
return columnShape;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -107,13 +107,6 @@ private:
|
|||||||
cvf::Color4f baseColor,
|
cvf::Color4f baseColor,
|
||||||
Qt::BrushStyle brushStyle = Qt::SolidPattern );
|
Qt::BrushStyle brushStyle = Qt::SolidPattern );
|
||||||
|
|
||||||
QwtPlotItem* createColumnShape( double startX,
|
|
||||||
double endX,
|
|
||||||
double startDepth,
|
|
||||||
double endDepth,
|
|
||||||
cvf::Color4f baseColor,
|
|
||||||
Qt::BrushStyle brushStyle = Qt::SolidPattern );
|
|
||||||
|
|
||||||
cvf::Color4f componentColor( float alpha = 1.0 ) const;
|
cvf::Color4f componentColor( float alpha = 1.0 ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user