Refactor RimPlotWindow and RimPlotInterface

This commit is contained in:
Gaute Lindkvist
2019-11-15 10:12:19 +01:00
parent 4dd0651dae
commit d9043db5e0
40 changed files with 697 additions and 765 deletions

View File

@@ -150,13 +150,9 @@ RimWellLogTrack::RimWellLogTrack()
{
CAF_PDM_InitObject( "Track", ":/WellLogTrack16x16.png", "", "" );
CAF_PDM_InitField( &m_show, "Show", true, "Show Plot", "", "", "" );
m_show.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_description, "TrackDescription", "Name", "", "", "" );
m_description.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Column Span", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_curves, "Curves", "", "", "", "" );
m_curves.uiCapability()->setUiHidden( true );
@@ -249,6 +245,10 @@ RimWellLogTrack::RimWellLogTrack()
CAF_PDM_InitFieldNoDefault( &m_wellPathComponentSource, "AttributesWellPathSource", "Well Path", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_wellPathAttributeCollection, "AttributesCollection", "Well Attributes", "", "", "" );
CAF_PDM_InitField( &m_show_OBSOLETE, "Show", false, "Show Plot", "", "", "" );
m_show_OBSOLETE.uiCapability()->setUiHidden( true );
m_show_OBSOLETE.xmlCapability()->setIOWritable( false );
m_formationsForCaseWithSimWellOnly = false;
}
@@ -260,22 +260,6 @@ RimWellLogTrack::~RimWellLogTrack()
m_curves.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogTrack::isChecked() const
{
return m_show();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setChecked( bool checked )
{
m_show = checked;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -292,22 +276,6 @@ void RimWellLogTrack::setDescription( const QString& description )
m_description = description;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellLogTrack::colSpan() const
{
return m_colSpan();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setColSpan( RowOrColSpan colSpan )
{
m_colSpan = colSpan;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -332,6 +300,34 @@ void RimWellLogTrack::simWellOptionItems( QList<caf::PdmOptionItemInfo>* options
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::cleanupBeforeClose()
{
detachAllPlotItems();
if ( m_plotWidget )
{
m_plotWidget->deleteLater();
m_plotWidget = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::detachAllPlotItems()
{
for ( RimPlotCurve* curve : m_curves )
{
curve->detachQwtCurve();
}
for ( auto& plotObjects : m_wellPathAttributePlotObjects )
{
plotObjects->detachFromQwt();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -471,7 +467,7 @@ void RimWellLogTrack::updateXZoom()
// Attribute range. Fixed range where well components are positioned [-1, 1].
// Set an extended range here to allow for some label space.
double componentRangeMax = 1.5 * ( 4 / ( static_cast<int>( m_colSpan() ) ) );
double componentRangeMax = 1.5 * ( 4 / ( static_cast<int>( colSpan() ) ) );
double componentRangeMin = -0.25;
if ( m_showWellPathComponentsBothSides )
{
@@ -498,23 +494,18 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_show )
if ( changedField == &m_showWindow )
{
if ( m_plotWidget )
{
m_plotWidget->setVisible( m_show() );
m_plotWidget->setVisible( m_showWindow );
}
updatePlotWindowLayout();
updateParentLayout();
}
else if ( changedField == &m_description )
{
updatePlotWindowLayout();
}
else if ( changedField == &m_colSpan )
{
onRowOrColSpanChange();
updatePlotWindowLayout();
updateParentLayout();
}
else if ( changedField == &m_explicitTickIntervals )
{
@@ -590,7 +581,7 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
loadDataAndUpdate();
updatePlotWindowLayout();
updateParentLayout();
updateConnectedEditors();
RiuPlotMainWindowTools::refreshToolbars();
}
@@ -609,19 +600,19 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
loadDataAndUpdate();
updatePlotWindowLayout();
updateParentLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
else if ( changedField == &m_formationWellPathForSourceCase )
{
loadDataAndUpdate();
updatePlotWindowLayout();
updateParentLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
else if ( changedField == &m_formationSimWellName )
{
loadDataAndUpdate();
updatePlotWindowLayout();
updateParentLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
else if ( changedField == &m_formationTrajectoryType )
@@ -640,7 +631,7 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
loadDataAndUpdate();
updatePlotWindowLayout();
updateParentLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
else if ( changedField == &m_formationBranchIndex || changedField == &m_formationBranchDetection )
@@ -650,13 +641,13 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
m_formationBranchDetection );
loadDataAndUpdate();
updatePlotWindowLayout();
updateParentLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
else if ( changedField == &m_formationWellPathForSourceWellPath )
{
loadDataAndUpdate();
updatePlotWindowLayout();
updateParentLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
else if ( changedField == &m_formationLevel )
@@ -672,14 +663,14 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
changedField == &m_wellPathAttributesInLegend || changedField == &m_wellPathCompletionsInLegend )
{
updateWellPathAttributesOnPlot();
updatePlotWindowLayout();
updateParentLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
else if ( changedField == &m_wellPathComponentSource )
{
updateWellPathAttributesCollection();
updateWellPathAttributesOnPlot();
updatePlotWindowLayout();
updateParentLayout();
RiuPlotMainWindowTools::refreshToolbars();
}
}
@@ -701,31 +692,8 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals()
}
else
{
int majorTickIntervals = 3;
int minorTickIntervals = 0;
switch ( m_colSpan() )
{
case ONE:
majorTickIntervals = 3;
minorTickIntervals = 2;
break;
case TWO:
majorTickIntervals = 3;
minorTickIntervals = 5;
break;
case THREE:
majorTickIntervals = 5;
minorTickIntervals = 5;
break;
case FOUR:
majorTickIntervals = 5;
minorTickIntervals = 10;
break;
case FIVE:
majorTickIntervals = 10;
minorTickIntervals = 10;
break;
}
int majorTickIntervals = 5;
int minorTickIntervals = 10;
m_plotWidget->setAutoTickIntervalCounts( QwtPlot::xTop, majorTickIntervals, minorTickIntervals );
m_plotWidget->setAxisRange( QwtPlot::xTop, m_visibleXRangeMin, m_visibleXRangeMax );
}
@@ -1048,14 +1016,6 @@ void RimWellLogTrack::deleteAllCurves()
m_curves.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimWellLogTrack::viewer()
{
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1079,7 +1039,7 @@ void RimWellLogTrack::availableDepthRange( double* minimumDepth, double* maximum
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::loadDataAndUpdate()
void RimWellLogTrack::onLoadDataAndUpdate()
{
RimWellLogPlot* wellLogPlot = nullptr;
firstAncestorOrThisOfType( wellLogPlot );
@@ -1315,11 +1275,11 @@ RimWellLogTrack::TrajectoryType RimWellLogTrack::formationTrajectoryType() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::createPlotWidget()
QWidget* RimWellLogTrack::createViewWidget( QWidget* mainWindowParent )
{
if ( m_plotWidget == nullptr )
{
m_plotWidget = new RiuWellLogTrack( this );
m_plotWidget = new RiuWellLogTrack( this, mainWindowParent );
m_plotWidget->setAxisInverted( QwtPlot::yLeft );
updateAxisScaleEngine();
@@ -1331,6 +1291,15 @@ void RimWellLogTrack::createPlotWidget()
m_plotWidget->scheduleReplot();
}
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::deleteViewWidget()
{
cleanupBeforeClose();
}
//--------------------------------------------------------------------------------------------------
@@ -1338,14 +1307,7 @@ void RimWellLogTrack::createPlotWidget()
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::detachAllCurves()
{
for ( RimPlotCurve* curve : m_curves )
{
curve->detachQwtCurve();
}
for ( auto& plotObjects : m_wellPathAttributePlotObjects )
{
plotObjects->detachFromQwt();
}
detachAllPlotItems();
}
//--------------------------------------------------------------------------------------------------
@@ -1519,6 +1481,50 @@ RimWellPath* RimWellLogTrack::wellPathAttributeSource() const
return m_wellPathComponentSource;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimWellLogTrack::viewWidget()
{
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimWellLogTrack::viewer()
{
return m_plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QImage RimWellLogTrack::snapshotWindowContent()
{
QImage image;
if ( m_plotWidget )
{
QPixmap pix = m_plotWidget->grab();
image = pix.toImage();
}
return image;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::zoomAll()
{
setAutoScaleXEnabled( true );
setAutoScaleYEnabled( true );
calculateXZoomRange();
calculateYZoomRange();
updateZoomInQwt();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1632,6 +1638,11 @@ void RimWellLogTrack::initAfterRead()
{
m_xAxisGridVisibility = RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR;
}
if ( m_show_OBSOLETE )
{
m_showWindow = true;
}
}
//--------------------------------------------------------------------------------------------------
@@ -1652,14 +1663,6 @@ void RimWellLogTrack::defineEditorAttribute( const caf::PdmFieldHandle* field,
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellLogTrack::objectToggleField()
{
return &m_show;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1726,14 +1729,6 @@ void RimWellLogTrack::updateWellPathAttributesCollection()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::onRowOrColSpanChange()
{
updateXZoom();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -2151,7 +2146,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
caf::ColorTable colorTable( RimRegularLegendConfig::colorArrayFromColorType( m_colorShadingPalette() ) );
m_annotationTool->attachNamedRegions( this->viewer(),
m_annotationTool->attachNamedRegions( m_plotWidget,
formationNamesToPlot,
xRange,
yValues,
@@ -2180,7 +2175,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
m_showformationFluids(),
plot->depthType() );
m_annotationTool->attachWellPicks( this->viewer(), formationNamesToPlot, yValues );
m_annotationTool->attachWellPicks( m_plotWidget, formationNamesToPlot, yValues );
}
}
@@ -2242,7 +2237,7 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
wellBoreStabilityPlot->depthType(),
&sourceNamesToPlot,
&yValues );
m_annotationTool->attachNamedRegions( this->viewer(),
m_annotationTool->attachNamedRegions( m_plotWidget,
sourceNamesToPlot,
xRange,
yValues,
@@ -2271,7 +2266,7 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
wellBoreStabilityPlot->depthType(),
&sourceNamesToPlot,
&yValues );
m_annotationTool->attachNamedRegions( this->viewer(),
m_annotationTool->attachNamedRegions( m_plotWidget,
sourceNamesToPlot,
xRange,
yValues,
@@ -2300,7 +2295,7 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
wellBoreStabilityPlot->depthType(),
&sourceNamesToPlot,
&yValues );
m_annotationTool->attachNamedRegions( this->viewer(),
m_annotationTool->attachNamedRegions( m_plotWidget,
sourceNamesToPlot,
xRange,
yValues,