mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5178 Fix axis rounding on plots other than Well Log Plots
This commit is contained in:
parent
11d69281d7
commit
a8454450eb
@ -67,7 +67,7 @@ RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlotInterface* plotTrackDefinition, QWidg
|
|||||||
m_plotOwner = dynamic_cast<caf::PdmObject*>( plotTrackDefinition );
|
m_plotOwner = dynamic_cast<caf::PdmObject*>( plotTrackDefinition );
|
||||||
CAF_ASSERT( m_plotOwner );
|
CAF_ASSERT( m_plotOwner );
|
||||||
|
|
||||||
setDefaults();
|
RiuQwtPlotTools::setCommonPlotBehaviour( this );
|
||||||
|
|
||||||
this->installEventFilter( this );
|
this->installEventFilter( this );
|
||||||
this->canvas()->installEventFilter( this );
|
this->canvas()->installEventFilter( this );
|
||||||
@ -171,34 +171,6 @@ caf::PdmObject* RiuQwtPlotWidget::plotOwner() const
|
|||||||
return m_plotOwner.p();
|
return m_plotOwner.p();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RiuQwtPlotWidget::setEnabledAxes( const std::set<QwtPlot::Axis> enabledAxes )
|
|
||||||
{
|
|
||||||
for ( int axisId = 0; axisId < QwtPlot::axisCnt; ++axisId )
|
|
||||||
{
|
|
||||||
QwtPlot::Axis axis = static_cast<QwtPlot::Axis>( axisId );
|
|
||||||
if ( enabledAxes.count( axis ) )
|
|
||||||
{
|
|
||||||
enableAxis( axis, true );
|
|
||||||
// Align the canvas with the actual min and max values of the curves
|
|
||||||
axisScaleEngine( axis )->setAttribute( QwtScaleEngine::Floating, true );
|
|
||||||
setAxisScale( axis, 0.0, 100.0 );
|
|
||||||
axisScaleDraw( axis )->setMinimumExtent( axisExtent( axis ) );
|
|
||||||
setMinimumWidth( defaultMinimumWidth() );
|
|
||||||
|
|
||||||
axisWidget( axis )->setMargin( 0 );
|
|
||||||
m_axisTitlesEnabled[axis] = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
enableAxis( axis, false );
|
|
||||||
m_axisTitlesEnabled[axis] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -664,15 +636,6 @@ RiuWidgetStyleSheet RiuQwtPlotWidget::createCanvasStyleSheet() const
|
|||||||
return styleSheet;
|
return styleSheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RiuQwtPlotWidget::setDefaults()
|
|
||||||
{
|
|
||||||
setEnabledAxes( {QwtPlot::xTop, QwtPlot::yLeft} );
|
|
||||||
RiuQwtPlotTools::setCommonPlotBehaviour( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
void RiuQwtPlotWidget::selectPlotOwner( bool toggleItemInSelection )
|
void RiuQwtPlotWidget::selectPlotOwner( bool toggleItemInSelection )
|
||||||
{
|
{
|
||||||
if ( toggleItemInSelection )
|
if ( toggleItemInSelection )
|
||||||
|
@ -71,8 +71,6 @@ public:
|
|||||||
bool titleBold = false,
|
bool titleBold = false,
|
||||||
Qt::AlignmentFlag alignment = Qt::AlignRight );
|
Qt::AlignmentFlag alignment = Qt::AlignRight );
|
||||||
|
|
||||||
void setEnabledAxes( const std::set<QwtPlot::Axis> enabledAxes );
|
|
||||||
|
|
||||||
void setAxisTitleText( QwtPlot::Axis axis, const QString& title );
|
void setAxisTitleText( QwtPlot::Axis axis, const QString& title );
|
||||||
void setAxisTitleEnabled( QwtPlot::Axis axis, bool enable );
|
void setAxisTitleEnabled( QwtPlot::Axis axis, bool enable );
|
||||||
|
|
||||||
@ -118,7 +116,6 @@ protected:
|
|||||||
virtual void endZoomOperations();
|
virtual void endZoomOperations();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setDefaults();
|
|
||||||
void selectPlotOwner( bool toggleItemInSelection = false );
|
void selectPlotOwner( bool toggleItemInSelection = false );
|
||||||
void selectClosestCurve( const QPoint& pos, bool toggleItemInSelection = false );
|
void selectClosestCurve( const QPoint& pos, bool toggleItemInSelection = false );
|
||||||
static int defaultMinimumWidth();
|
static int defaultMinimumWidth();
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
#include "RimWellLogTrack.h"
|
#include "RimWellLogTrack.h"
|
||||||
|
|
||||||
|
#include "qwt_scale_draw.h"
|
||||||
|
#include "qwt_scale_engine.h"
|
||||||
|
#include "qwt_scale_widget.h"
|
||||||
|
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
|
||||||
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
|
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
|
||||||
@ -32,6 +36,10 @@
|
|||||||
RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent /*= nullptr */ )
|
RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent /*= nullptr */ )
|
||||||
: RiuQwtPlotWidget( plotTrackDefinition, parent )
|
: RiuQwtPlotWidget( plotTrackDefinition, parent )
|
||||||
{
|
{
|
||||||
|
setAxisEnabled( QwtPlot::yLeft, true );
|
||||||
|
setAxisEnabled( QwtPlot::yRight, false );
|
||||||
|
setAxisEnabled( QwtPlot::xTop, true );
|
||||||
|
setAxisEnabled( QwtPlot::xBottom, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -81,3 +89,26 @@ bool RiuWellLogTrack::eventFilter( QObject* watched, QEvent* event )
|
|||||||
}
|
}
|
||||||
return RiuQwtPlotWidget::eventFilter( watched, event );
|
return RiuQwtPlotWidget::eventFilter( watched, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuWellLogTrack::setAxisEnabled( QwtPlot::Axis axis, bool enabled )
|
||||||
|
{
|
||||||
|
if ( enabled )
|
||||||
|
{
|
||||||
|
enableAxis( axis, true );
|
||||||
|
|
||||||
|
// Align the canvas with the actual min and max values of the curves
|
||||||
|
axisScaleEngine( axis )->setAttribute( QwtScaleEngine::Floating, true );
|
||||||
|
setAxisScale( axis, 0.0, 100.0 );
|
||||||
|
axisScaleDraw( axis )->setMinimumExtent( axisExtent( axis ) );
|
||||||
|
|
||||||
|
axisWidget( axis )->setMargin( 0 );
|
||||||
|
setAxisTitleEnabled( axis, true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enableAxis( axis, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -37,4 +37,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter( QObject* watched, QEvent* event ) override;
|
bool eventFilter( QObject* watched, QEvent* event ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setAxisEnabled( QwtPlot::Axis axis, bool enabled );
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user