mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-11 16:06:04 -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_grid.h"
|
||||
#include "qwt_plot_layout.h"
|
||||
#include "qwt_plot_shapeitem.h"
|
||||
#include "qwt_scale_widget.h"
|
||||
|
||||
#include <QRegExp>
|
||||
@ -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>
|
||||
|
||||
class QwtPlot;
|
||||
class QwtPlotItem;
|
||||
|
||||
class RiuQwtPlotTools
|
||||
{
|
||||
@ -39,4 +40,12 @@ public:
|
||||
const QString& timeFormat,
|
||||
RiaQDateTimeTools::DateFormatComponents dateComponents,
|
||||
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 "RigWellPath.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_plot_marker.h"
|
||||
@ -410,65 +411,45 @@ void RiuWellPathComponentPlotItem::addColumnFeature( double startX,
|
||||
cvf::Color4f baseColor,
|
||||
Qt::BrushStyle brushStyle /*= Qt::SolidPattern*/ )
|
||||
{
|
||||
QColor baseQColor = RiaColorTools::toQColor( baseColor );
|
||||
if ( brushStyle != Qt::SolidPattern )
|
||||
{
|
||||
// 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 =
|
||||
createColumnShape( startX, endX, startDepth, endDepth, semiTransparentWhite, Qt::SolidPattern );
|
||||
RiuQwtPlotTools::createBoxShape( label(), startX, endX, startDepth, endDepth, semiTransparentWhite, Qt::SolidPattern );
|
||||
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 );
|
||||
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 );
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
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 );
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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,
|
||||
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;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user