mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5536 Move orientation argument.
Testplot code moved to separate method.
This commit is contained in:
parent
e9f8cf8105
commit
1f109d0ee2
@ -320,8 +320,33 @@ void RimAnalysisPlot::onLoadDataAndUpdate()
|
|||||||
|
|
||||||
if ( m_plotWidget )
|
if ( m_plotWidget )
|
||||||
{
|
{
|
||||||
RiuGroupedBarChartBuilder chartBuilder( Qt::Horizontal );
|
RiuGroupedBarChartBuilder chartBuilder;
|
||||||
|
|
||||||
|
buildTestPlot( chartBuilder );
|
||||||
|
|
||||||
|
chartBuilder.addBarChartToPlot( m_plotWidget, Qt::Horizontal );
|
||||||
|
|
||||||
|
if ( m_showPlotLegends && m_plotWidget->legend() == nullptr )
|
||||||
|
{
|
||||||
|
QwtLegend* legend = new QwtLegend( m_plotWidget );
|
||||||
|
m_plotWidget->insertLegend( legend, QwtPlot::RightLegend );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_plotWidget->insertLegend( nullptr );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_plotWidget->updateLegend();
|
||||||
|
}
|
||||||
|
|
||||||
|
this->updateAxes();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimAnalysisPlot::buildTestPlot( RiuGroupedBarChartBuilder& chartBuilder )
|
||||||
|
{
|
||||||
chartBuilder.addBarEntry( "T1_The_red_Fox", "", "", std::numeric_limits<double>::infinity(), "R1", "", 0.4 );
|
chartBuilder.addBarEntry( "T1_The_red_Fox", "", "", std::numeric_limits<double>::infinity(), "R1", "", 0.4 );
|
||||||
chartBuilder.addBarEntry( "T1_The_red_Fox", "", "", std::numeric_limits<double>::infinity(), "R2", "", 0.45 );
|
chartBuilder.addBarEntry( "T1_The_red_Fox", "", "", std::numeric_limits<double>::infinity(), "R2", "", 0.45 );
|
||||||
chartBuilder.addBarEntry( "T1_The_red_Fox", "W1", "", std::numeric_limits<double>::infinity(), "R1", "", 0.5 );
|
chartBuilder.addBarEntry( "T1_The_red_Fox", "W1", "", std::numeric_limits<double>::infinity(), "R1", "", 0.5 );
|
||||||
@ -366,22 +391,4 @@ void RimAnalysisPlot::onLoadDataAndUpdate()
|
|||||||
chartBuilder.addBarEntry( "", "", "", 2.0, "", "D", 2.0 );
|
chartBuilder.addBarEntry( "", "", "", 2.0, "", "D", 2.0 );
|
||||||
chartBuilder.addBarEntry( "", "", "", 1.6, "", "E", 1.6 );
|
chartBuilder.addBarEntry( "", "", "", 1.6, "", "E", 1.6 );
|
||||||
chartBuilder.addBarEntry( "", "", "", 2.4, "", "F", -2.4 );
|
chartBuilder.addBarEntry( "", "", "", 2.4, "", "F", -2.4 );
|
||||||
|
|
||||||
chartBuilder.addBarChartToPlot( m_plotWidget );
|
|
||||||
|
|
||||||
if ( m_showPlotLegends && m_plotWidget->legend() == nullptr )
|
|
||||||
{
|
|
||||||
QwtLegend* legend = new QwtLegend( m_plotWidget );
|
|
||||||
m_plotWidget->insertLegend( legend, QwtPlot::RightLegend );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_plotWidget->insertLegend( nullptr );
|
|
||||||
}
|
|
||||||
|
|
||||||
// m_plotWidget->setLegendFontSize( m_legendFontSize() );
|
|
||||||
m_plotWidget->updateLegend();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->updateAxes();
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
class RiuSummaryQwtPlot;
|
class RiuSummaryQwtPlot;
|
||||||
class RimAnalysisPlotDataEntry;
|
class RimAnalysisPlotDataEntry;
|
||||||
|
class RiuGroupedBarChartBuilder;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -106,6 +107,8 @@ private:
|
|||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
void onLoadDataAndUpdate() override;
|
void onLoadDataAndUpdate() override;
|
||||||
|
|
||||||
|
void buildTestPlot( RiuGroupedBarChartBuilder& chartBuilder );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<RiuQwtPlotWidget> m_plotWidget;
|
QPointer<RiuQwtPlotWidget> m_plotWidget;
|
||||||
|
|
||||||
|
@ -185,10 +185,7 @@ protected:
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuGroupedBarChartBuilder::RiuGroupedBarChartBuilder( Qt::Orientation orientation )
|
RiuGroupedBarChartBuilder::RiuGroupedBarChartBuilder() {}
|
||||||
: m_orientation( orientation )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -208,7 +205,7 @@ void RiuGroupedBarChartBuilder::addBarEntry( const QString& majorTickText,
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuGroupedBarChartBuilder::addBarChartToPlot( QwtPlot* plot )
|
void RiuGroupedBarChartBuilder::addBarChartToPlot( QwtPlot* plot, Qt::Orientation orientation )
|
||||||
{
|
{
|
||||||
const double majGroupSpacing = 1.6;
|
const double majGroupSpacing = 1.6;
|
||||||
const double midGroupSpacing = 0.5;
|
const double midGroupSpacing = 0.5;
|
||||||
@ -384,14 +381,15 @@ void RiuGroupedBarChartBuilder::addBarChartToPlot( QwtPlot* plot )
|
|||||||
addQwtBarChart( plot,
|
addQwtBarChart( plot,
|
||||||
legendToBarPointsPair.second,
|
legendToBarPointsPair.second,
|
||||||
legendToBarPointsPair.first,
|
legendToBarPointsPair.first,
|
||||||
RiaColorTables::summaryCurveDefaultPaletteColors().cycledQColor( idx ) );
|
RiaColorTables::summaryCurveDefaultPaletteColors().cycledQColor( idx ),
|
||||||
|
orientation );
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the axis to contain group texts and tick marks
|
// Set up the axis to contain group texts and tick marks
|
||||||
{
|
{
|
||||||
QwtPlot::Axis axis = QwtPlot::xBottom;
|
QwtPlot::Axis axis = QwtPlot::xBottom;
|
||||||
if ( m_orientation == Qt::Horizontal )
|
if ( orientation == Qt::Horizontal )
|
||||||
{
|
{
|
||||||
axis = QwtPlot::yLeft;
|
axis = QwtPlot::yLeft;
|
||||||
}
|
}
|
||||||
@ -402,7 +400,7 @@ void RiuGroupedBarChartBuilder::addBarChartToPlot( QwtPlot* plot )
|
|||||||
if ( midTickPositions.size() ) groupAxisScaleDiv.setTicks( QwtScaleDiv::MediumTick, midTickPositions );
|
if ( midTickPositions.size() ) groupAxisScaleDiv.setTicks( QwtScaleDiv::MediumTick, midTickPositions );
|
||||||
if ( minTickPositions.size() ) groupAxisScaleDiv.setTicks( QwtScaleDiv::MinorTick, minTickPositions );
|
if ( minTickPositions.size() ) groupAxisScaleDiv.setTicks( QwtScaleDiv::MinorTick, minTickPositions );
|
||||||
|
|
||||||
if ( m_orientation == Qt::Horizontal )
|
if ( orientation == Qt::Horizontal )
|
||||||
{
|
{
|
||||||
groupAxisScaleDiv.invert();
|
groupAxisScaleDiv.invert();
|
||||||
}
|
}
|
||||||
@ -417,7 +415,7 @@ void RiuGroupedBarChartBuilder::addBarChartToPlot( QwtPlot* plot )
|
|||||||
// Add texts on the bars inside the plot
|
// Add texts on the bars inside the plot
|
||||||
{
|
{
|
||||||
QwtScaleDraw::Alignment alignment = QwtScaleDraw::TopScale;
|
QwtScaleDraw::Alignment alignment = QwtScaleDraw::TopScale;
|
||||||
if ( m_orientation == Qt::Horizontal )
|
if ( orientation == Qt::Horizontal )
|
||||||
{
|
{
|
||||||
alignment = QwtScaleDraw::RightScale;
|
alignment = QwtScaleDraw::RightScale;
|
||||||
}
|
}
|
||||||
@ -432,7 +430,7 @@ void RiuGroupedBarChartBuilder::addBarChartToPlot( QwtPlot* plot )
|
|||||||
}
|
}
|
||||||
|
|
||||||
barTextScaleDiv.setTicks( QwtScaleDiv::MinorTick, onBarTickPositions );
|
barTextScaleDiv.setTicks( QwtScaleDiv::MinorTick, onBarTickPositions );
|
||||||
if ( m_orientation == Qt::Horizontal )
|
if ( orientation == Qt::Horizontal )
|
||||||
{
|
{
|
||||||
barTextScaleDiv.invert();
|
barTextScaleDiv.invert();
|
||||||
}
|
}
|
||||||
@ -455,7 +453,8 @@ void RiuGroupedBarChartBuilder::addBarChartToPlot( QwtPlot* plot )
|
|||||||
void RiuGroupedBarChartBuilder::addQwtBarChart( QwtPlot* plot,
|
void RiuGroupedBarChartBuilder::addQwtBarChart( QwtPlot* plot,
|
||||||
const QVector<QPointF>& posAndValue,
|
const QVector<QPointF>& posAndValue,
|
||||||
const QString& legendText,
|
const QString& legendText,
|
||||||
const QColor& barColor )
|
const QColor& barColor,
|
||||||
|
Qt::Orientation orientation )
|
||||||
{
|
{
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
palette.setColor( QPalette::Window, barColor );
|
palette.setColor( QPalette::Window, barColor );
|
||||||
@ -472,7 +471,7 @@ void RiuGroupedBarChartBuilder::addQwtBarChart( QwtPlot* plot,
|
|||||||
barChart->setLayoutPolicy( QwtPlotAbstractBarChart::ScaleSamplesToAxes );
|
barChart->setLayoutPolicy( QwtPlotAbstractBarChart::ScaleSamplesToAxes );
|
||||||
barChart->setLayoutHint( 1.0 );
|
barChart->setLayoutHint( 1.0 );
|
||||||
barChart->setSymbol( barStyle );
|
barChart->setSymbol( barStyle );
|
||||||
barChart->setOrientation( m_orientation );
|
barChart->setOrientation( orientation );
|
||||||
barChart->attach( plot );
|
barChart->attach( plot );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class QColor;
|
|||||||
class RiuGroupedBarChartBuilder
|
class RiuGroupedBarChartBuilder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RiuGroupedBarChartBuilder( Qt::Orientation orientation );
|
RiuGroupedBarChartBuilder();
|
||||||
|
|
||||||
void addBarEntry( const QString& majorTickText,
|
void addBarEntry( const QString& majorTickText,
|
||||||
const QString& midTickText,
|
const QString& midTickText,
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
const QString& barText,
|
const QString& barText,
|
||||||
const double value );
|
const double value );
|
||||||
|
|
||||||
void addBarChartToPlot( QwtPlot* plot );
|
void addBarChartToPlot( QwtPlot* plot, Qt::Orientation orientation );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double midPoint( double v1, double v2 )
|
double midPoint( double v1, double v2 )
|
||||||
@ -53,7 +53,8 @@ private:
|
|||||||
void addQwtBarChart( QwtPlot* plot,
|
void addQwtBarChart( QwtPlot* plot,
|
||||||
const QVector<QPointF>& posAndValue,
|
const QVector<QPointF>& posAndValue,
|
||||||
const QString& legendText,
|
const QString& legendText,
|
||||||
const QColor& barColor );
|
const QColor& barColor,
|
||||||
|
Qt::Orientation orientation );
|
||||||
|
|
||||||
struct BarEntry
|
struct BarEntry
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user