From d9043db5e003431bebb618339ebdf35817ccc6ba Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 15 Nov 2019 10:12:19 +0100 Subject: [PATCH] Refactor RimPlotWindow and RimPlotInterface --- .../RicExportToLasFileFeature.cpp | 6 +- .../Commands/RicNewMultiPlotFeature.cpp | 30 +-- .../Commands/RicNewMultiPlotFeature.h | 4 +- .../RicDeleteSubPlotFeature.cpp | 14 +- .../RicNewWellBoreStabilityPlotFeature.cpp | 12 +- .../ProjectDataModel/CMakeLists_files.cmake | 4 +- .../ProjectDataModel/Flow/RimWellPltPlot.cpp | 15 +- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 11 +- .../GridCrossPlots/RimGridCrossPlot.cpp | 139 ++--------- .../GridCrossPlots/RimGridCrossPlot.h | 42 ++-- .../ProjectDataModel/RimMultiPlot.cpp | 150 ++++------- .../ProjectDataModel/RimMultiPlot.h | 42 ++-- .../RimMultiPlotItemInterface.cpp | 40 +++ ApplicationCode/ProjectDataModel/RimPlot.cpp | 88 +++++++ .../{RimPlotInterface.h => RimPlot.h} | 63 +++-- .../RimPlotAxisAnnotation.cpp | 4 +- .../RimPlotAxisProperties.cpp | 4 +- .../ProjectDataModel/RimPlotInterface.cpp | 65 ----- .../ProjectDataModel/RimPlotWindow.cpp | 41 ++- .../ProjectDataModel/RimPlotWindow.h | 19 +- .../ProjectDataModel/RimViewWindow.cpp | 32 +++ .../ProjectDataModel/RimViewWindow.h | 15 +- .../RimWellBoreStabilityPlot.cpp | 4 +- .../ProjectDataModel/RimWellLogPlot.cpp | 35 +-- .../ProjectDataModel/RimWellLogPlot.h | 10 +- .../ProjectDataModel/RimWellLogTrack.cpp | 235 +++++++++--------- .../ProjectDataModel/RimWellLogTrack.h | 49 ++-- .../Summary/RimSummaryPlot.cpp | 148 ++++------- .../ProjectDataModel/Summary/RimSummaryPlot.h | 25 +- ApplicationCode/UserInterface/RiuDragDrop.cpp | 16 +- .../UserInterface/RiuGridCrossQwtPlot.cpp | 4 +- .../UserInterface/RiuGridCrossQwtPlot.h | 4 +- .../UserInterface/RiuMultiPlotWindow.cpp | 21 +- .../UserInterface/RiuMultiPlotWindow.h | 1 - .../UserInterface/RiuQwtPlotWidget.cpp | 38 ++- .../UserInterface/RiuQwtPlotWidget.h | 9 +- .../UserInterface/RiuSummaryQwtPlot.cpp | 11 +- .../UserInterface/RiuSummaryQwtPlot.h | 3 +- .../UserInterface/RiuWellLogPlot.cpp | 8 + .../UserInterface/RiuWellLogPlot.h | 1 + 40 files changed, 697 insertions(+), 765 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimMultiPlotItemInterface.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimPlot.cpp rename ApplicationCode/ProjectDataModel/{RimPlotInterface.h => RimPlot.h} (54%) delete mode 100644 ApplicationCode/ProjectDataModel/RimPlotInterface.cpp diff --git a/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp index 9fc623abe4..413175d3a6 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp @@ -50,10 +50,10 @@ std::vector RicExportToLasFileFeature::exportToLasFiles( const QString& bool capitalizeFileNames, double resampleInterval ) { - std::vector allCurves; - std::vector plots = plotWindow->visiblePlots(); + std::vector allCurves; + std::vector plots = plotWindow->visiblePlots(); - for ( RimPlotInterface* plot : plots ) + for ( RimPlot* plot : plots ) { RimWellLogTrack* track = dynamic_cast( plot ); if ( track ) diff --git a/ApplicationCode/Commands/RicNewMultiPlotFeature.cpp b/ApplicationCode/Commands/RicNewMultiPlotFeature.cpp index 8ae2e3f173..60862e3da6 100644 --- a/ApplicationCode/Commands/RicNewMultiPlotFeature.cpp +++ b/ApplicationCode/Commands/RicNewMultiPlotFeature.cpp @@ -24,7 +24,7 @@ #include "RimMainPlotCollection.h" #include "RimMultiPlot.h" #include "RimMultiPlotCollection.h" -#include "RimPlotInterface.h" +#include "RimPlot.h" #include "RimProject.h" #include "RiuPlotMainWindowTools.h" @@ -60,12 +60,12 @@ RicfCommandResponse RicNewMultiPlotFeature::execute() if ( !m_plots().empty() ) { - std::vector plotInterfaces; + std::vector plots; for ( auto ptr : m_plots() ) { - plotInterfaces.push_back( reinterpret_cast( ptr ) ); + plots.push_back( reinterpret_cast( ptr ) ); } - plotWindow->movePlotsToThis( plotInterfaces, nullptr ); + plotWindow->movePlotsToThis( plots, nullptr ); } plotCollection->updateAllRequiredEditors(); @@ -89,12 +89,12 @@ bool RicNewMultiPlotFeature::isCommandEnabled() return true; } - auto selectedPlots = selectedPlotInterfaces(); + auto plots = selectedPlots(); std::vector selectedUiItems; caf::SelectionManager::instance()->selectedItems( selectedUiItems ); - return !selectedPlots.empty() && selectedPlots.size() == selectedUiItems.size(); + return !plots.empty() && plots.size() == selectedUiItems.size(); } //-------------------------------------------------------------------------------------------------- @@ -103,10 +103,10 @@ bool RicNewMultiPlotFeature::isCommandEnabled() void RicNewMultiPlotFeature::onActionTriggered( bool isChecked ) { m_plots.v().clear(); - auto selectedPlots = selectedPlotInterfaces(); - for ( RimPlotInterface* plotInterface : selectedPlots ) + auto plots = selectedPlots(); + for ( RimPlot* plot : plots ) { - m_plots.v().push_back( reinterpret_cast( plotInterface ) ); + m_plots.v().push_back( reinterpret_cast( plot ) ); } execute(); } @@ -116,7 +116,7 @@ void RicNewMultiPlotFeature::onActionTriggered( bool isChecked ) //-------------------------------------------------------------------------------------------------- void RicNewMultiPlotFeature::setupActionLook( QAction* actionToSetup ) { - if ( selectedPlotInterfaces().empty() ) + if ( selectedPlots().empty() ) { actionToSetup->setText( "New Empty Multi Plot" ); actionToSetup->setIcon( QIcon( ":/WellLogPlot16x16.png" ) ); @@ -131,19 +131,19 @@ void RicNewMultiPlotFeature::setupActionLook( QAction* actionToSetup ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicNewMultiPlotFeature::selectedPlotInterfaces() +std::vector RicNewMultiPlotFeature::selectedPlots() { std::vector uiItems; caf::SelectionManager::instance()->selectedItems( uiItems ); - std::vector plotInterfaces; + std::vector plots; for ( caf::PdmUiItem* uiItem : uiItems ) { - RimPlotInterface* plotInterface = dynamic_cast( uiItem ); + RimPlot* plotInterface = dynamic_cast( uiItem ); if ( plotInterface ) { - plotInterfaces.push_back( plotInterface ); + plots.push_back( plotInterface ); } } - return plotInterfaces; + return plots; } diff --git a/ApplicationCode/Commands/RicNewMultiPlotFeature.h b/ApplicationCode/Commands/RicNewMultiPlotFeature.h index eefef77df5..4edd9f9be0 100644 --- a/ApplicationCode/Commands/RicNewMultiPlotFeature.h +++ b/ApplicationCode/Commands/RicNewMultiPlotFeature.h @@ -25,7 +25,7 @@ #include -class RimPlotInterface; +class RimPlot; //================================================================================================== /// @@ -45,7 +45,7 @@ protected: void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; - static std::vector selectedPlotInterfaces(); + static std::vector selectedPlots(); private: caf::PdmField> m_plots; diff --git a/ApplicationCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp index 2fbc2ec025..d634dc37d5 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp @@ -26,7 +26,7 @@ #include "RiuQwtPlotWidget.h" #include "RimMultiPlot.h" -#include "RimPlotInterface.h" +#include "RimPlotWindow.h" #include "RimWellLogTrack.h" #include "cafSelectionManager.h" @@ -52,7 +52,7 @@ bool RicDeleteSubPlotFeature::isCommandEnabled() { RimMultiPlot* multiPlot = nullptr; object->firstAncestorOrThisOfType( multiPlot ); - if ( dynamic_cast( object ) && multiPlot ) + if ( dynamic_cast( object ) && multiPlot ) { plotsSelected++; } @@ -70,21 +70,19 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked ) { if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return; - std::vector selection; + std::vector selection; caf::SelectionManager::instance()->objectsByType( &selection ); std::set alteredPlotWindows; - for ( size_t i = 0; i < selection.size(); i++ ) + for ( RimPlot* plot : selection ) { - RimPlotInterface* plot = dynamic_cast( selection[i] ); - RimMultiPlot* plotWindow = nullptr; - selection[i]->firstAncestorOrThisOfType( plotWindow ); + plot->firstAncestorOrThisOfType( plotWindow ); if ( plot && plotWindow ) { alteredPlotWindows.insert( plotWindow ); plotWindow->removePlot( plot ); - caf::SelectionManager::instance()->removeObjectFromAllSelections( selection[i] ); + caf::SelectionManager::instance()->removeObjectFromAllSelections( plot ); plotWindow->updateConnectedEditors(); delete plot; diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index 580937f572..8aedefa8f0 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -191,7 +191,7 @@ void RicNewWellBoreStabilityPlotFeature::createFormationTrack( RimWellBoreStabil formationTrack->setFormationCase( geoMechCase ); formationTrack->setAnnotationType( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS ); formationTrack->setVisibleXRange( 0.0, 0.0 ); - formationTrack->setColSpan( RimPlotInterface::ONE ); + formationTrack->setColSpan( RimPlot::ONE ); } //-------------------------------------------------------------------------------------------------- @@ -202,7 +202,7 @@ void RicNewWellBoreStabilityPlotFeature::createCasingShoeTrack( RimWellBoreStabi RimGeoMechCase* geoMechCase ) { RimWellLogTrack* casingShoeTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false, "Well Design", plot ); - casingShoeTrack->setColSpan( RimPlotInterface::ONE ); + casingShoeTrack->setColSpan( RimPlot::ONE ); casingShoeTrack->setFormationWellPath( wellPath ); casingShoeTrack->setFormationCase( geoMechCase ); casingShoeTrack->setAnnotationType( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS ); @@ -226,7 +226,7 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi RimWellLogTrack* paramCurvesTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false, "WBS Parameters", plot ); - paramCurvesTrack->setColSpan( RimPlotInterface::TWO ); + paramCurvesTrack->setColSpan( RimPlot::TWO ); paramCurvesTrack->setAutoScaleXEnabled( true ); paramCurvesTrack->setTickIntervals( 0.5, 0.05 ); paramCurvesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); @@ -234,7 +234,7 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi paramCurvesTrack->setFormationCase( geoMechCase ); paramCurvesTrack->setAnnotationType( RiuPlotAnnotationTool::CURVE_ANNOTATIONS ); paramCurvesTrack->setShowRegionLabels( true ); - paramCurvesTrack->setChecked( false ); + paramCurvesTrack->setShowWindow( false ); std::vector resultNames = RiaDefines::wellPathStabilityParameterNames(); std::vector colors = {cvf::Color3f::CRIMSON, cvf::Color3f::DARK_YELLOW}; @@ -272,7 +272,7 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore RimWellLogTrack* stabilityCurvesTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false, "Stability Curves", plot ); - stabilityCurvesTrack->setColSpan( RimPlotInterface::FIVE ); + stabilityCurvesTrack->setColSpan( RimPlot::FIVE ); stabilityCurvesTrack->setAutoScaleXEnabled( true ); stabilityCurvesTrack->setTickIntervals( 0.5, 0.05 ); stabilityCurvesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); @@ -361,7 +361,7 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability maxValue = cvf::Math::clamp( maxValue, angleIncrement, 360.0 ); minValue = cvf::Math::clamp( minValue, 0.0, maxValue - 90.0 ); } - wellPathAnglesTrack->setColSpan( RimPlotInterface::THREE ); + wellPathAnglesTrack->setColSpan( RimPlot::THREE ); wellPathAnglesTrack->setVisibleXRange( minValue, maxValue ); wellPathAnglesTrack->setTickIntervals( 90.0, 30.0 ); wellPathAnglesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index b74bfafa9f..30e0dc5864 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -72,7 +72,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.h -${CMAKE_CURRENT_LIST_DIR}/RimPlotInterface.h +${CMAKE_CURRENT_LIST_DIR}/RimPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.h ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.h @@ -214,7 +214,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.cpp -${CMAKE_CURRENT_LIST_DIR}/RimPlotInterface.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.cpp diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index e09b654939..ee520b0c34 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -136,8 +136,9 @@ RimWellPltPlot::RimWellPltPlot() m_nameConfig->setCustomName( "PLT Plot" ); this->setAsPlotMdiWindow(); - m_doInitAfterLoad = false; - m_isOnLoad = true; + m_doInitAfterLoad = false; + m_isOnLoad = true; + m_plotLegendsHorizontal = false; setAvailableDepthTypes( {RiaDefines::MEASURED_DEPTH} ); } @@ -199,6 +200,7 @@ void RimWellPltPlot::setPlotXAxisTitles( RimWellLogTrack* plotTrack ) axisTitle += RimWellPlotTools::flowPlotAxisTitle( RimWellLogFile::WELL_FLOW_COND_STANDARD, unitSet ); plotTrack->setXAxisTitle( axisTitle ); + #if 0 QString unitText; for ( auto unitSet: presentUnitSystems ) @@ -997,13 +999,14 @@ void RimWellPltPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& if ( track ) { track->uiOrderingForRftPltFormations( uiOrdering ); - caf::PdmUiGroup* axesGroup = uiOrdering.addNewGroup( "Axes" ); - track->uiOrderingForXAxisSettings( *axesGroup ); - uiOrderingForDepthAxis( *axesGroup ); + track->uiOrderingForXAxisSettings( uiOrdering ); + caf::PdmUiGroup* depthGroup = uiOrdering.addNewGroup( "Depth Axis Settings" ); + uiOrderingForDepthAxis( uiConfigName, *depthGroup ); caf::PdmUiGroup* plotLayoutGroup = uiOrdering.addNewGroup( "Plot Layout" ); plotLayoutGroup->setCollapsedByDefault( true ); - RimWellLogPlot::uiOrderingForPlotLayout( *plotLayoutGroup ); + RimWellLogPlot::uiOrderingForAutoName( uiConfigName, *plotLayoutGroup ); + RimWellLogPlot::uiOrderingForLegendSettings( uiConfigName, *plotLayoutGroup ); } } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 55ca942082..b4e624f7ec 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -118,7 +118,7 @@ RimWellRftPlot::RimWellRftPlot() m_wellPathCollection = RiaApplication::instance()->project()->activeOilField()->wellPathCollection(); m_nameConfig->setCustomName( "RFT Plot" ); - m_plotLegendsHorizontal = true; + m_plotLegendsHorizontal = false; this->setAsPlotMdiWindow(); m_isOnLoad = true; @@ -940,13 +940,14 @@ void RimWellRftPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& if ( track ) { track->uiOrderingForRftPltFormations( uiOrdering ); - caf::PdmUiGroup* axesGroup = uiOrdering.addNewGroup( "Axes" ); - track->uiOrderingForXAxisSettings( *axesGroup ); - uiOrderingForDepthAxis( *axesGroup ); + track->uiOrderingForXAxisSettings( uiOrdering ); + caf::PdmUiGroup* depthGroup = uiOrdering.addNewGroup( "Depth Axis Settings" ); + uiOrderingForDepthAxis( uiConfigName, *depthGroup ); caf::PdmUiGroup* plotLayoutGroup = uiOrdering.addNewGroup( "Plot Layout" ); plotLayoutGroup->setCollapsedByDefault( true ); - RimWellLogPlot::uiOrderingForPlotLayout( *plotLayoutGroup ); + RimWellLogPlot::uiOrderingForAutoName( uiConfigName, *plotLayoutGroup ); + RimWellLogPlot::uiOrderingForLegendSettings( uiConfigName, *plotLayoutGroup ); } } diff --git a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp index dc7a66063b..1d93f4d237 100644 --- a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp +++ b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp @@ -57,9 +57,6 @@ RimGridCrossPlot::RimGridCrossPlot() CAF_PDM_InitField( &m_showInfoBox, "ShowInfoBox", true, "Show Info Box", "", "", "" ); CAF_PDM_InitField( &m_showLegend_OBSOLETE, "ShowLegend", false, "Show Legend", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Col Span", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "Name Config", "", "", "" ); m_nameConfig.uiCapability()->setUiTreeHidden( true ); m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true ); @@ -90,22 +87,6 @@ RimGridCrossPlot::~RimGridCrossPlot() cleanupBeforeClose(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimGridCrossPlot::isChecked() const -{ - return isWindowVisible(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::setChecked( bool checked ) -{ - m_showWindow = checked; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -314,14 +295,6 @@ void RimGridCrossPlot::detachAllCurves() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::loadDataAndUpdate() -{ - onLoadDataAndUpdate(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -338,14 +311,6 @@ void RimGridCrossPlot::setAutoScaleYEnabled( bool enabled ) m_yAxisProperties->setAutoZoom( enabled ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::createPlotWidget() -{ - createViewWidget( nullptr ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -441,22 +406,6 @@ void RimGridCrossPlot::updateAfterInsertingIntoMultiPlot() updateLayout(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RimGridCrossPlot::rowSpan() const -{ - return static_cast( m_rowSpan() ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RimGridCrossPlot::colSpan() const -{ - return static_cast( m_colSpan() ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -508,7 +457,7 @@ void RimGridCrossPlot::initAfterRead() { if ( m_showLegend_OBSOLETE() ) { - m_showPlotLegends = true; + setLegendsVisible( true ); } } @@ -520,14 +469,9 @@ void RimGridCrossPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin caf::PdmUiGroup* generalGroup = uiOrdering.addNewGroup( "Plot Options" ); generalGroup->add( &m_showInfoBox ); - if ( isStandalonePlot() ) + if ( isMdiWindow() ) { - generalGroup->add( &m_showPlotLegends ); - - if ( m_showPlotLegends() ) - { - generalGroup->add( &m_legendFontSize ); - } + RimPlotWindow::uiOrderingForLegendSettings( uiConfigName, *generalGroup ); } else { @@ -563,14 +507,10 @@ void RimGridCrossPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField const QVariant& oldValue, const QVariant& newValue ) { - RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue ); - if ( changedField == &m_legendFontSize ) + RimPlot::fieldChangedByUi( changedField, oldValue, newValue ); + if ( changedField == &m_colSpan || changedField == &m_rowSpan ) { - updateLegend(); - } - else if ( changedField == &m_colSpan || changedField == &m_rowSpan ) - { - updatePlotWindowLayout(); + updateParentLayout(); } else { @@ -578,32 +518,6 @@ void RimGridCrossPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList RimGridCrossPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) -{ - QList options; - - if ( fieldNeedingOptions == &m_legendFontSize ) - { - std::vector fontSizes; - fontSizes.push_back( 8 ); - fontSizes.push_back( 10 ); - fontSizes.push_back( 12 ); - fontSizes.push_back( 14 ); - fontSizes.push_back( 16 ); - - for ( int value : fontSizes ) - { - QString text = QString( "%1" ).arg( value ); - options.push_back( caf::PdmOptionItemInfo( text, value ) ); - } - } - return options; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -660,7 +574,7 @@ void RimGridCrossPlot::updateCurveNamesAndPlotTitle() m_crossPlotDataSets[i]->updateCurveNames( i, m_crossPlotDataSets.size() ); } - if ( m_plotWidget && isStandalonePlot() ) + if ( m_plotWidget && isMdiWindow() ) { m_plotWidget->setTitle( this->createAutoName() ); } @@ -695,6 +609,20 @@ void RimGridCrossPlot::swapAxes() updateAxes(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGridCrossPlot::asciiDataForPlotExport() const +{ + QString fullData; + for ( int i = 0; i < (int)m_crossPlotDataSets.size(); ++i ) + { + fullData += asciiTitleForPlotExport( i ) + "\n"; + fullData += asciiDataForGridCrossPlotExport( i ) + "\n"; + } + return fullData; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -758,20 +686,6 @@ void RimGridCrossPlot::setYAxisInverted( bool inverted ) m_yAxisProperties->setAxisInverted( inverted ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RimGridCrossPlot::legendFontSize() const -{ - RimMultiPlot* plotWindow = nullptr; - this->firstAncestorOrThisOfType( plotWindow ); - if ( plotWindow ) - { - return plotWindow->legendFontSize(); - } - return m_legendFontSize; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -821,8 +735,8 @@ bool RimGridCrossPlot::applyFontSize( RiaDefines::FontSettingType fontSettingTyp if ( forceChange || legendFontSize() == oldFontSize ) { - m_legendFontSize = fontSize; - anyChange = true; + setLegendFontSize( fontSize ); + anyChange = true; } if ( anyChange ) loadDataAndUpdate(); @@ -833,8 +747,9 @@ bool RimGridCrossPlot::applyFontSize( RiaDefines::FontSettingType fontSettingTyp //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGridCrossPlot::updateLayout() +void RimGridCrossPlot::performLayoutUpdate() { + updateLegend(); updatePlot(); } @@ -843,8 +758,8 @@ void RimGridCrossPlot::updateLayout() //-------------------------------------------------------------------------------------------------- void RimGridCrossPlot::updateLegend() { - m_plotWidget->setInternalQwtLegendVisible( m_showPlotLegends() && isStandalonePlot() ); - m_plotWidget->setLegendFontSize( m_legendFontSize() ); + m_plotWidget->setInternalQwtLegendVisible( legendsVisible() && isMdiWindow() ); + m_plotWidget->setLegendFontSize( legendFontSize() ); for ( auto dataSet : m_crossPlotDataSets ) { dataSet->updateLegendIcons(); diff --git a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h index cf07ae9ceb..7a0b0f5f62 100644 --- a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h +++ b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h @@ -23,8 +23,7 @@ #include "RiaDefines.h" #include "RimNameConfig.h" -#include "RimPlotInterface.h" -#include "RimPlotWindow.h" +#include "RimPlot.h" #include @@ -49,7 +48,7 @@ protected: virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; }; -class RimGridCrossPlot : public RimPlotWindow, public RimPlotInterface, public RimNameConfigHolderInterface +class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface { CAF_PDM_HEADER_INIT; @@ -57,9 +56,6 @@ public: RimGridCrossPlot(); ~RimGridCrossPlot(); - bool isChecked() const override; - void setChecked( bool checked ) override; - QString description() const override; RimGridCrossPlotDataSet* createDataSet(); @@ -83,13 +79,14 @@ public: void performAutoNameUpdate() override; void updateCurveNamesAndPlotTitle(); void swapAxes(); - QString asciiTitleForPlotExport( int dataSetIndex ) const; - QString asciiDataForGridCrossPlotExport( int dataSetIndex ) const; + + QString asciiDataForPlotExport() const override; + QString asciiTitleForPlotExport( int dataSetIndex ) const; + QString asciiDataForGridCrossPlotExport( int dataSetIndex ) const; bool isXAxisLogarithmic() const; bool isYAxisLogarithmic() const; void setYAxisInverted( bool inverted ); - int legendFontSize() const; bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override; bool applyFontSize( RiaDefines::FontSettingType fontSettingType, @@ -97,17 +94,13 @@ public: int fontSize, bool forceChange = false ) override; - void updateLayout() override; void updateLegend(); void updateZoomInQwt() override; void updateZoomFromQwt() override; - void loadDataAndUpdate() override; - void setAutoScaleXEnabled( bool enabled ) override; void setAutoScaleYEnabled( bool enabled ) override; - void createPlotWidget() override; caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; void onAxisSelected( int axis, bool toggle ) override; @@ -117,24 +110,20 @@ public: void removeFromMdiAreaAndCollection() override; void updateAfterInsertingIntoMultiPlot() override; - int rowSpan() const override; - int colSpan() const override; - protected: - QWidget* createViewWidget( QWidget* mainWindowParent ) override; + QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) override; void deleteViewWidget() override; void onLoadDataAndUpdate() override; void initAfterRead() override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) override; - QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; - void updateAxes() override; - void updatePlot(); + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) override; + + void updateAxes() override; + void updatePlot(); virtual QString xAxisParameterString() const; QString yAxisParameterString() const; @@ -152,6 +141,8 @@ protected: std::set allPlotAxes() const; private: + void performLayoutUpdate() override; + void cleanupBeforeClose(); private: @@ -159,9 +150,6 @@ private: caf::PdmField m_showLegend_OBSOLETE; caf::PdmChildField m_nameConfig; - caf::PdmField m_rowSpan; - caf::PdmField m_colSpan; - caf::PdmChildField m_yAxisProperties; caf::PdmChildField m_xAxisProperties; diff --git a/ApplicationCode/ProjectDataModel/RimMultiPlot.cpp b/ApplicationCode/ProjectDataModel/RimMultiPlot.cpp index c21415c79d..8502bd6401 100644 --- a/ApplicationCode/ProjectDataModel/RimMultiPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimMultiPlot.cpp @@ -17,7 +17,8 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimMultiPlot.h" -#include "RimPlotInterface.h" +#include "RimPlot.h" + #include "RiuPlotMainWindow.h" #include "RiuPlotMainWindowTools.h" @@ -79,15 +80,11 @@ RimMultiPlot& RimMultiPlot::operator=( RimMultiPlot&& rhs ) { RimPlotWindow::operator=( std::move( rhs ) ); - m_showPlotWindowTitle = rhs.m_showPlotWindowTitle; - m_plotWindowTitle = rhs.m_plotWindowTitle; - // Move all tracks - std::vector plots = rhs.m_plots.childObjects(); + std::vector plots = rhs.m_plots.childObjects(); rhs.m_plots.clear(); - for ( caf::PdmObject* plot : plots ) + for ( RimPlot* plot : plots ) { - CAF_ASSERT( dynamic_cast( plot ) ); m_plots.push_back( plot ); } @@ -104,6 +101,14 @@ QWidget* RimMultiPlot::viewWidget() return m_viewer; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimMultiPlot::description() const +{ + return multiPlotTitle(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -139,7 +144,7 @@ void RimMultiPlot::setMultiPlotTitle( const QString& title ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimMultiPlot::addPlot( RimPlotInterface* plot ) +void RimMultiPlot::addPlot( RimPlot* plot ) { insertPlot( plot, m_plots.size() ); } @@ -147,12 +152,12 @@ void RimMultiPlot::addPlot( RimPlotInterface* plot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimMultiPlot::insertPlot( RimPlotInterface* plot, size_t index ) +void RimMultiPlot::insertPlot( RimPlot* plot, size_t index ) { if ( plot ) { - m_plots.insert( index, toPdmObjectAsserted( plot ) ); - plot->setChecked( true ); + m_plots.insert( index, plot ); + plot->setShowWindow( true ); if ( m_viewer ) { @@ -168,7 +173,7 @@ void RimMultiPlot::insertPlot( RimPlotInterface* plot, size_t index ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimMultiPlot::removePlot( RimPlotInterface* plot ) +void RimMultiPlot::removePlot( RimPlot* plot ) { if ( plot ) { @@ -176,7 +181,7 @@ void RimMultiPlot::removePlot( RimPlotInterface* plot ) { m_viewer->removePlot( plot->viewer() ); } - m_plots.removeChildObject( toPdmObjectAsserted( plot ) ); + m_plots.removeChildObject( plot ); onPlotAdditionOrRemoval(); } @@ -185,13 +190,12 @@ void RimMultiPlot::removePlot( RimPlotInterface* plot ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimMultiPlot::movePlotsToThis( const std::vector& plotsToMove, - RimPlotInterface* plotToInsertAfter ) +void RimMultiPlot::movePlotsToThis( const std::vector& plotsToMove, RimPlot* plotToInsertAfter ) { for ( size_t tIdx = 0; tIdx < plotsToMove.size(); tIdx++ ) { - RimPlotInterface* plot = plotsToMove[tIdx]; - caf::PdmObject* pdmObject = dynamic_cast( plot ); + RimPlot* plot = plotsToMove[tIdx]; + caf::PdmObject* pdmObject = dynamic_cast( plot ); RimMultiPlot* srcPlot = nullptr; pdmObject->firstAncestorOrThisOfType( srcPlot ); @@ -228,55 +232,47 @@ size_t RimMultiPlot::plotCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RimMultiPlot::plotIndex( const RimPlotInterface* plot ) const +size_t RimMultiPlot::plotIndex( const RimPlot* plot ) const { - return m_plots.index( toPdmObjectAsserted( plot ) ); + return m_plots.index( plot ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPlotInterface* RimMultiPlot::plotByIndex( size_t index ) const +RimPlot* RimMultiPlot::plotByIndex( size_t index ) const { - return toPlotInterfaceAsserted( m_plots[index] ); + return m_plots[index]; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimMultiPlot::plots() const +std::vector RimMultiPlot::plots() const { - std::vector allPlots; - allPlots.reserve( m_plots.size() ); + return m_plots.childObjects(); +} - for ( caf::PdmObject* pdmObject : m_plots ) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimMultiPlot::visiblePlots() const +{ + std::vector allVisiblePlots; + for ( RimPlot* plot : m_plots() ) { - allPlots.push_back( toPlotInterfaceAsserted( pdmObject ) ); - } - return allPlots; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimMultiPlot::visiblePlots() const -{ - std::vector allPlots; - for ( caf::PdmObject* pdmObject : m_plots() ) - { - RimPlotInterface* plot = toPlotInterfaceAsserted( pdmObject ); - if ( plot->isChecked() ) + if ( plot->showWindow() ) { - allPlots.push_back( plot ); + allVisiblePlots.push_back( plot ); } } - return allPlots; + return allVisiblePlots; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimMultiPlot::updateLayout() +void RimMultiPlot::performLayoutUpdate() { if ( m_showWindow ) { @@ -294,9 +290,9 @@ void RimMultiPlot::updatePlotNames() {} //-------------------------------------------------------------------------------------------------- void RimMultiPlot::updatePlotOrderFromGridWidget() { - std::sort( m_plots.begin(), m_plots.end(), [this]( caf::PdmObject* lhs, caf::PdmObject* rhs ) { - auto indexLhs = m_viewer->indexOfPlotWidget( toPlotInterfaceAsserted( lhs )->viewer() ); - auto indexRhs = m_viewer->indexOfPlotWidget( toPlotInterfaceAsserted( rhs )->viewer() ); + std::sort( m_plots.begin(), m_plots.end(), [this]( RimPlot* lhs, RimPlot* rhs ) { + auto indexLhs = m_viewer->indexOfPlotWidget( lhs->viewer() ); + auto indexRhs = m_viewer->indexOfPlotWidget( rhs->viewer() ); return indexLhs < indexRhs; } ); updatePlotNames(); @@ -308,7 +304,7 @@ void RimMultiPlot::updatePlotOrderFromGridWidget() //-------------------------------------------------------------------------------------------------- void RimMultiPlot::setAutoScaleXEnabled( bool enabled ) { - for ( RimPlotInterface* plot : plots() ) + for ( RimPlot* plot : plots() ) { plot->setAutoScaleXEnabled( enabled ); } @@ -319,7 +315,7 @@ void RimMultiPlot::setAutoScaleXEnabled( bool enabled ) //-------------------------------------------------------------------------------------------------- void RimMultiPlot::setAutoScaleYEnabled( bool enabled ) { - for ( RimPlotInterface* plot : plots() ) + for ( RimPlot* plot : plots() ) { plot->setAutoScaleYEnabled( enabled ); } @@ -370,9 +366,9 @@ QString RimMultiPlot::asciiDataForPlotExport() const { QString out = multiPlotTitle() + "\n"; - for ( RimPlotInterface* plot : plots() ) + for ( RimPlot* plot : plots() ) { - if ( plot->isChecked() ) + if ( plot->showWindow() ) { out += plot->asciiDataForPlotExport(); } @@ -467,18 +463,18 @@ void RimMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, void RimMultiPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { caf::PdmUiGroup* titleAndLegendsGroup = uiOrdering.addNewGroup( "Plot Layout" ); - uiOrderingForPlotLayout( *titleAndLegendsGroup ); + uiOrderingForPlotLayout( uiConfigName, *titleAndLegendsGroup ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimMultiPlot::uiOrderingForPlotLayout( caf::PdmUiOrdering& uiOrdering ) +void RimMultiPlot::uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_showPlotWindowTitle ); uiOrdering.add( &m_plotWindowTitle ); uiOrdering.add( &m_showIndividualPlotTitles ); - RimPlotWindow::uiOrderingForPlotLayout( uiOrdering ); + RimPlotWindow::uiOrderingForLegendSettings( uiConfigName, uiOrdering ); uiOrdering.add( &m_columnCountEnum ); } @@ -555,7 +551,7 @@ void RimMultiPlot::updatePlots() { if ( m_showWindow ) { - for ( RimPlotInterface* plot : plots() ) + for ( RimPlot* plot : plots() ) { plot->loadDataAndUpdate(); } @@ -568,7 +564,7 @@ void RimMultiPlot::updatePlots() //-------------------------------------------------------------------------------------------------- void RimMultiPlot::updateZoom() { - for ( RimPlotInterface* plot : plots() ) + for ( RimPlot* plot : plots() ) { plot->updateZoomInQwt(); } @@ -605,7 +601,7 @@ bool RimMultiPlot::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingTy { return true; } - for ( const RimPlotInterface* plot : plots() ) + for ( const RimPlot* plot : plots() ) { if ( plot->hasCustomFontSizes( fontSettingType, defaultFontSize ) ) { @@ -639,7 +635,7 @@ bool RimMultiPlot::applyFontSize( RiaDefines::FontSettingType fontSettingType, somethingChanged = true; } - for ( RimPlotInterface* plot : plots() ) + for ( RimPlot* plot : plots() ) { if ( plot->applyFontSize( fontSettingType, oldFontSize, fontSize, forceChange ) ) { @@ -671,43 +667,3 @@ void RimMultiPlot::cleanupBeforeClose() m_viewer = nullptr; } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPlotInterface* RimMultiPlot::toPlotInterfaceAsserted( caf::PdmObject* pdmObject ) -{ - RimPlotInterface* plotInterface = dynamic_cast( pdmObject ); - CAF_ASSERT( plotInterface ); - return plotInterface; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RimPlotInterface* RimMultiPlot::toPlotInterfaceAsserted( const caf::PdmObject* pdmObject ) -{ - const RimPlotInterface* plotInterface = dynamic_cast( pdmObject ); - CAF_ASSERT( plotInterface ); - return plotInterface; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmObject* RimMultiPlot::toPdmObjectAsserted( RimPlotInterface* plotInterface ) -{ - caf::PdmObject* pdmObject = dynamic_cast( plotInterface ); - CAF_ASSERT( pdmObject ); - return pdmObject; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const caf::PdmObject* RimMultiPlot::toPdmObjectAsserted( const RimPlotInterface* plotInterface ) -{ - const caf::PdmObject* pdmObject = dynamic_cast( plotInterface ); - CAF_ASSERT( pdmObject ); - return pdmObject; -} diff --git a/ApplicationCode/ProjectDataModel/RimMultiPlot.h b/ApplicationCode/ProjectDataModel/RimMultiPlot.h index fcf96abeef..4c27a26ab4 100644 --- a/ApplicationCode/ProjectDataModel/RimMultiPlot.h +++ b/ApplicationCode/ProjectDataModel/RimMultiPlot.h @@ -32,7 +32,7 @@ #include -class RimPlotInterface; +class RimPlot; class RimMultiPlot : public RimPlotWindow { @@ -47,7 +47,7 @@ public: COLUMNS_4 = 4, COLUMNS_UNLIMITED = 1000, }; - typedef caf::AppEnum ColumnCountEnum; + using ColumnCountEnum = caf::AppEnum; public: RimMultiPlot(); @@ -57,29 +57,30 @@ public: QWidget* viewWidget() override; + QString description() const override; + bool isMultiPlotTitleVisible() const; void setMultiPlotTitleVisible( bool visible ); QString multiPlotTitle() const; void setMultiPlotTitle( const QString& title ); - void addPlot( RimPlotInterface* plot ); - void insertPlot( RimPlotInterface* plot, size_t index ); - void removePlot( RimPlotInterface* plot ); - void movePlotsToThis( const std::vector& plots, RimPlotInterface* plotToInsertAfter ); + void addPlot( RimPlot* plot ); + void insertPlot( RimPlot* plot, size_t index ); + void removePlot( RimPlot* plot ); + void movePlotsToThis( const std::vector& plots, RimPlot* plotToInsertAfter ); - size_t plotCount() const; - size_t plotIndex( const RimPlotInterface* plot ) const; - RimPlotInterface* plotByIndex( size_t index ) const; + size_t plotCount() const; + size_t plotIndex( const RimPlot* plot ) const; + RimPlot* plotByIndex( size_t index ) const; - std::vector plots() const; - std::vector visiblePlots() const; + std::vector plots() const; + std::vector visiblePlots() const; - void updateLayout() override; virtual void updatePlotNames(); void updatePlotOrderFromGridWidget(); - virtual void setAutoScaleXEnabled( bool enabled ); - virtual void setAutoScaleYEnabled( bool enabled ); + void setAutoScaleXEnabled( bool enabled ); + void setAutoScaleYEnabled( bool enabled ); int columnCount() const; caf::PdmFieldHandle* columnCountField(); @@ -87,8 +88,7 @@ public: void zoomAll() override; - QString asciiDataForPlotExport() const; - + QString asciiDataForPlotExport() const; virtual void onPlotAdditionOrRemoval(); protected: @@ -104,7 +104,7 @@ protected: const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - void uiOrderingForPlotLayout( caf::PdmUiOrdering& uiOrdering ) override; + void uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) override; @@ -124,11 +124,7 @@ protected: private: void cleanupBeforeClose(); - - static RimPlotInterface* toPlotInterfaceAsserted( caf::PdmObject* pdmObject ); - static const RimPlotInterface* toPlotInterfaceAsserted( const caf::PdmObject* pdmObject ); - static caf::PdmObject* toPdmObjectAsserted( RimPlotInterface* plotInterface ); - static const caf::PdmObject* toPdmObjectAsserted( const RimPlotInterface* plotInterface ); + void performLayoutUpdate() override; protected: caf::PdmField m_showPlotWindowTitle; @@ -140,5 +136,5 @@ protected: QPointer m_viewer; private: - caf::PdmChildArrayField m_plots; + caf::PdmChildArrayField m_plots; }; diff --git a/ApplicationCode/ProjectDataModel/RimMultiPlotItemInterface.cpp b/ApplicationCode/ProjectDataModel/RimMultiPlotItemInterface.cpp new file mode 100644 index 0000000000..c2cc4b465b --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimMultiPlotItemInterface.cpp @@ -0,0 +1,40 @@ +#include "RimPlotWindow.h" + +#include "RimMultiPlot.h" +#include "RimPlotWindow.h" + +#include "RiuQwtPlotWidget.h" + +#include "cafPdmObject.h" + +namespace caf +{ +template <> +void RimPlotWindow::RowOrColSpanEnum::setUp() +{ + addItem( RimPlotWindow::UNLIMITED, "UNLIMITED", "Unlimited" ); + addItem( RimPlotWindow::ONE, "ONE", "1" ); + addItem( RimPlotWindow::TWO, "TWO", "2" ); + addItem( RimPlotWindow::THREE, "THREE", "3" ); + addItem( RimPlotWindow::FOUR, "FOUR", "4" ); + addItem( RimPlotWindow::FIVE, "FIVE", "5" ); + setDefault( RimPlotWindow::ONE ); +} + +} // namespace caf + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotWindow::updatePlotWindowLayout() +{ + const caf::PdmObject* thisPdm = dynamic_cast( this ); + CAF_ASSERT( thisPdm ); + + RimMultiPlot* plotWindow; + thisPdm->firstAncestorOrThisOfType( plotWindow ); + if ( plotWindow ) + { + plotWindow->updateLayout(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimPlot.cpp b/ApplicationCode/ProjectDataModel/RimPlot.cpp new file mode 100644 index 0000000000..86b65cbaa4 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimPlot.cpp @@ -0,0 +1,88 @@ +#include "RimPlot.h" + +#include "RimMultiPlot.h" +#include "RimPlotWindow.h" + +#include "RiuQwtPlotWidget.h" + +#include "cafPdmObject.h" + +namespace caf +{ +template <> +void RimPlot::RowOrColSpanEnum::setUp() +{ + addItem( RimPlot::UNLIMITED, "UNLIMITED", "Unlimited" ); + addItem( RimPlot::ONE, "ONE", "1" ); + addItem( RimPlot::TWO, "TWO", "2" ); + addItem( RimPlot::THREE, "THREE", "3" ); + addItem( RimPlot::FOUR, "FOUR", "4" ); + addItem( RimPlot::FIVE, "FIVE", "5" ); + setDefault( RimPlot::ONE ); +} +} // namespace caf + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "RimPlot" ); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlot::RimPlot() +{ + CAF_PDM_InitObject( "Plot", "", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Col Span", "", "", "" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::createPlotWidget() +{ + createViewWidget( nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlot::RowOrColSpan RimPlot::rowSpan() const +{ + return m_rowSpan(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlot::RowOrColSpan RimPlot::colSpan() const +{ + return m_colSpan(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::setRowSpan( RowOrColSpan rowSpan ) +{ + m_rowSpan = rowSpan; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::setColSpan( RowOrColSpan colSpan ) +{ + m_colSpan = colSpan; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_colSpan || changedField == &m_rowSpan ) + { + onRowOrColSpanChange(); + updateParentLayout(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimPlotInterface.h b/ApplicationCode/ProjectDataModel/RimPlot.h similarity index 54% rename from ApplicationCode/ProjectDataModel/RimPlotInterface.h rename to ApplicationCode/ProjectDataModel/RimPlot.h index c2ebc08683..40fb2189df 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotInterface.h +++ b/ApplicationCode/ProjectDataModel/RimPlot.h @@ -19,6 +19,8 @@ #include "RiaDefines.h" +#include "RimPlotWindow.h" + #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" @@ -30,8 +32,10 @@ class RiuQwtPlotWidget; class RimPlotCurve; class QwtPlotCurve; -class RimPlotInterface +class RimPlot : public RimPlotWindow { + CAF_PDM_HEADER_INIT; + public: enum RowOrColSpan { @@ -42,36 +46,21 @@ public: FOUR = 4, FIVE = 5 }; - typedef caf::AppEnum RowOrColSpanEnum; + using RowOrColSpanEnum = caf::AppEnum; public: - RimPlotInterface() = default; - virtual ~RimPlotInterface() = default; + RimPlot(); + virtual ~RimPlot() = default; - bool isStandalonePlot() const; + // Real implementations + void createPlotWidget(); + RowOrColSpan rowSpan() const; + RowOrColSpan colSpan() const; + void setRowSpan( RowOrColSpan rowSpan ); + void setColSpan( RowOrColSpan colSpan ); - virtual RiuQwtPlotWidget* viewer() = 0; - virtual bool isChecked() const = 0; - virtual void setChecked( bool checked ) = 0; - - virtual QString description() const = 0; - - virtual int rowSpan() const - { - return 1; - } - virtual int colSpan() const - { - return 1; - } - virtual void setRowSpan( RowOrColSpan rowSpan ) {} - virtual void setColSpan( RowOrColSpan colSpan ) {} - - virtual bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const = 0; - virtual bool applyFontSize( RiaDefines::FontSettingType fontSettingType, - int oldFontSize, - int fontSize, - bool forceChange = false ) = 0; + // Pure virtual interface methods + virtual RiuQwtPlotWidget* viewer() = 0; virtual void setAutoScaleXEnabled( bool enabled ) = 0; virtual void setAutoScaleYEnabled( bool enabled ) = 0; @@ -80,21 +69,27 @@ public: virtual void updateZoomInQwt() = 0; virtual void updateZoomFromQwt() = 0; - virtual QString asciiDataForPlotExport() const; + virtual QString asciiDataForPlotExport() const = 0; - virtual void createPlotWidget() = 0; - virtual void detachAllCurves() = 0; + virtual void detachAllCurves() = 0; virtual caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const = 0; - virtual void loadDataAndUpdate() = 0; - - virtual void onAxisSelected( int axis, bool toggle ) {} + virtual void onAxisSelected( int axis, bool toggle ) = 0; + // TODO: Refactor virtual void removeFromMdiAreaAndCollection() {} virtual void updateAfterInsertingIntoMultiPlot() {} protected: - void updatePlotWindowLayout(); + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) override; + +private: virtual void onRowOrColSpanChange() {} + +protected: + caf::PdmField m_rowSpan; + caf::PdmField m_colSpan; }; diff --git a/ApplicationCode/ProjectDataModel/RimPlotAxisAnnotation.cpp b/ApplicationCode/ProjectDataModel/RimPlotAxisAnnotation.cpp index 4966dfb011..edb66e0e10 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotAxisAnnotation.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotAxisAnnotation.cpp @@ -22,7 +22,7 @@ #include "RigEquil.h" #include "RimEclipseCase.h" -#include "RimPlotInterface.h" +#include "RimPlot.h" #include "RimTools.h" #include "RimViewWindow.h" @@ -158,7 +158,7 @@ void RimPlotAxisAnnotation::fieldChangedByUi( const caf::PdmFieldHandle* changed const QVariant& oldValue, const QVariant& newValue ) { - RimPlotInterface* parentPlot = nullptr; + RimPlot* parentPlot = nullptr; this->firstAncestorOrThisOfType( parentPlot ); if ( parentPlot ) { diff --git a/ApplicationCode/ProjectDataModel/RimPlotAxisProperties.cpp b/ApplicationCode/ProjectDataModel/RimPlotAxisProperties.cpp index c1328575b9..4f8c96b447 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotAxisProperties.cpp @@ -25,8 +25,8 @@ #include "RiaPreferences.h" #include "RigStatisticsCalculator.h" +#include "RimPlot.h" #include "RimPlotAxisAnnotation.h" -#include "RimPlotInterface.h" #include "cafPdmUiSliderEditor.h" @@ -416,7 +416,7 @@ void RimPlotAxisProperties::fieldChangedByUi( const caf::PdmFieldHandle* changed m_isAutoZoom = false; } - RimPlotInterface* parentPlot = nullptr; + RimPlot* parentPlot = nullptr; this->firstAncestorOrThisOfType( parentPlot ); if ( parentPlot ) { diff --git a/ApplicationCode/ProjectDataModel/RimPlotInterface.cpp b/ApplicationCode/ProjectDataModel/RimPlotInterface.cpp deleted file mode 100644 index 5a08ac85f8..0000000000 --- a/ApplicationCode/ProjectDataModel/RimPlotInterface.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "RimPlotInterface.h" - -#include "RimMultiPlot.h" -#include "RimPlotWindow.h" - -#include "RiuQwtPlotWidget.h" - -#include "cafPdmObject.h" - -namespace caf -{ -template <> -void RimPlotInterface::RowOrColSpanEnum::setUp() -{ - addItem( RimPlotInterface::UNLIMITED, "UNLIMITED", "Unlimited" ); - addItem( RimPlotInterface::ONE, "ONE", "1" ); - addItem( RimPlotInterface::TWO, "TWO", "2" ); - addItem( RimPlotInterface::THREE, "THREE", "3" ); - addItem( RimPlotInterface::FOUR, "FOUR", "4" ); - addItem( RimPlotInterface::FIVE, "FIVE", "5" ); - setDefault( RimPlotInterface::ONE ); -} - -} // namespace caf - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimPlotInterface::isStandalonePlot() const -{ - const caf::PdmObject* thisPdm = dynamic_cast( this ); - CAF_ASSERT( thisPdm ); - - if ( thisPdm ) - { - RimMultiPlot* multiPlot = nullptr; - thisPdm->firstAncestorOrThisOfType( multiPlot ); - return multiPlot == nullptr; - } - return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimPlotInterface::asciiDataForPlotExport() const -{ - return ""; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPlotInterface::updatePlotWindowLayout() -{ - const caf::PdmObject* thisPdm = dynamic_cast( this ); - CAF_ASSERT( thisPdm ); - - RimMultiPlot* plotWindow; - thisPdm->firstAncestorOrThisOfType( plotWindow ); - if ( plotWindow ) - { - plotWindow->updateLayout(); - } -} diff --git a/ApplicationCode/ProjectDataModel/RimPlotWindow.cpp b/ApplicationCode/ProjectDataModel/RimPlotWindow.cpp index 6ea0da4bda..c6e416e462 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotWindow.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotWindow.cpp @@ -29,14 +29,20 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlotWindow, "RimPlotWindow" ); // Do not us //-------------------------------------------------------------------------------------------------- RimPlotWindow::RimPlotWindow() { - CAF_PDM_InitObject( "Plot", "", "", "" ); + CAF_PDM_InitObject( "PlotWindow", "", "", "" ); CAF_PDM_InitField( &m_showPlotLegends, "ShowTrackLegends", true, "Show Legends", "", "", "" ); CAF_PDM_InitField( &m_plotLegendsHorizontal, "TrackLegendsHorizontal", true, "Legend Orientation", "", "", "" ); m_plotLegendsHorizontal.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); - int fontSize = RiaFontCache::pointSizeFromFontSizeEnum( + int defaultFontSize = RiaFontCache::pointSizeFromFontSizeEnum( RiaApplication::instance()->preferences()->defaultPlotFontSize() ); - CAF_PDM_InitField( &m_legendFontSize, "LegendFontSize", fontSize, "Legend Font Size", "", "", "" ); + CAF_PDM_InitField( &m_legendFontSize, + "LegendFontSize", + std::max( 8, defaultFontSize - 2 ), + "Legend Font Size", + "", + "", + "" ); } //-------------------------------------------------------------------------------------------------- @@ -51,6 +57,7 @@ RimPlotWindow& RimPlotWindow::operator=( RimPlotWindow&& rhs ) { m_showPlotLegends = rhs.m_showPlotLegends(); m_plotLegendsHorizontal = rhs.m_plotLegendsHorizontal(); + m_legendFontSize = rhs.m_legendFontSize(); return *this; } @@ -102,6 +109,32 @@ void RimPlotWindow::setLegendFontSize( int fontSize ) m_legendFontSize = fontSize; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotWindow::updateLayout() +{ + performLayoutUpdate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotWindow::updateParentLayout() +{ + caf::PdmFieldHandle* parentField = this->parentField(); + if ( parentField ) + { + caf::PdmObjectHandle* parentObject = parentField->ownerObject(); + RimPlotWindow* plotWindow = nullptr; + parentObject->firstAncestorOrThisOfType( plotWindow ); + if ( plotWindow ) + { + plotWindow->updateLayout(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -160,7 +193,7 @@ QList RimPlotWindow::calculateValueOptions( const caf::P //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotWindow::uiOrderingForPlotLayout( caf::PdmUiOrdering& uiOrdering ) +void RimPlotWindow::uiOrderingForLegendSettings( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_showPlotLegends ); uiOrdering.add( &m_plotLegendsHorizontal ); diff --git a/ApplicationCode/ProjectDataModel/RimPlotWindow.h b/ApplicationCode/ProjectDataModel/RimPlotWindow.h index 17047dc98e..fd360192b2 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotWindow.h +++ b/ApplicationCode/ProjectDataModel/RimPlotWindow.h @@ -24,6 +24,7 @@ #include "cafPdmFieldHandle.h" #include "cafPdmObject.h" +class QwtPlotCurve; class QKeyEvent; class RimPlotWindow : public RimViewWindow @@ -36,6 +37,8 @@ public: RimPlotWindow& operator=( RimPlotWindow&& rhs ); + virtual QString description() const = 0; + bool legendsVisible() const; void setLegendsVisible( bool doShow ); bool legendsHorizontal() const; @@ -43,17 +46,21 @@ public: int legendFontSize() const; void setLegendFontSize( int fontSize ); - virtual void handleKeyPressEvent( QKeyEvent* keyEvent ) {} - virtual void updateLayout() = 0; + void updateLayout(); + void updateParentLayout(); protected: - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) override; - virtual void uiOrderingForPlotLayout( caf::PdmUiOrdering& uiOrdering ); + void uiOrderingForLegendSettings( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + +private: + virtual void performLayoutUpdate() {} protected: caf::PdmField m_showPlotLegends; diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp index 894d9692f4..7980b66b93 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp @@ -90,6 +90,22 @@ void RimViewWindow::setId( int id ) m_viewId = id; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimViewWindow::showWindow() const +{ + return m_showWindow; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimViewWindow::setShowWindow( bool showWindow ) +{ + m_showWindow = showWindow; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -158,6 +174,22 @@ void RimViewWindow::updateMdiWindowVisibility() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimViewWindow::setAs3DViewMdiWindow() +{ + setAsMdiWindow( 0 ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimViewWindow::setAsPlotMdiWindow() +{ + setAsMdiWindow( 1 ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.h b/ApplicationCode/ProjectDataModel/RimViewWindow.h index bc85eb7ab3..904c7db503 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.h +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.h @@ -64,18 +64,15 @@ public: int id() const; void setId( int id ); + bool showWindow() const; + void setShowWindow( bool showWindow ); + void loadDataAndUpdate(); void handleMdiWindowClosed(); void updateMdiWindowVisibility(); - void setAs3DViewMdiWindow() - { - setAsMdiWindow( 0 ); - } - void setAsPlotMdiWindow() - { - setAsMdiWindow( 1 ); - } + void setAs3DViewMdiWindow(); + void setAsPlotMdiWindow(); void revokeMdiWindowStatus(); bool isMdiWindow() const; @@ -109,7 +106,7 @@ protected: friend class RimMdiWindowController; QString windowTitle(); - virtual QWidget* createViewWidget( QWidget* mainWindowParent ) = 0; + virtual QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) = 0; virtual void updateViewWidgetAfterCreation(){}; virtual void updateMdiWindowTitle(); // Has real default implementation virtual void deleteViewWidget() = 0; diff --git a/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp index a54212cd85..66745a76e7 100644 --- a/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp @@ -135,8 +135,8 @@ void RimWellBoreStabilityPlot::defineUiOrdering( QString uiConfigName, caf::PdmU parameterSources->add( &m_userDefinedUcs ); caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup( "Title, Legend and Axis" ); - RimWellLogPlot::uiOrderingForPlotLayout( *legendAndAxisGroup ); - uiOrderingForDepthAxis( *legendAndAxisGroup ); + RimWellLogPlot::uiOrderingForLegendSettings( uiConfigName, *legendAndAxisGroup ); + uiOrderingForDepthAxis( uiConfigName, *legendAndAxisGroup ); uiOrdering.skipRemainingFields( true ); } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 09d1f0e85b..ff67ad5620 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -26,6 +26,7 @@ #include "RimEclipseCase.h" #include "RimGeoMechCase.h" +#include "RimPlot.h" #include "RimWellAllocationPlot.h" #include "RimWellLogCurve.h" #include "RimWellLogCurveCommonDataSource.h" @@ -106,6 +107,7 @@ RimWellLogPlot::RimWellLogPlot() m_commonDataSourceEnabled = true; m_columnCountEnum = RimMultiPlot::COLUMNS_UNLIMITED; + m_plotLegendsHorizontal = false; setMultiPlotTitleVisible( false ); } @@ -168,7 +170,7 @@ void RimWellLogPlot::updateZoom() } } - for ( RimPlotInterface* plot : plots() ) + for ( RimPlot* plot : plots() ) { static_cast( plot )->setVisibleYRange( m_minVisibleDepth(), m_maxVisibleDepth() ); } @@ -234,7 +236,7 @@ void RimWellLogPlot::calculateAvailableDepthRange() double minTrackDepth = HUGE_VAL; double maxTrackDepth = -HUGE_VAL; - if ( plots[tIdx]->isChecked() ) + if ( plots[tIdx]->showWindow() ) { static_cast( plots[tIdx] )->availableDepthRange( &minTrackDepth, &maxTrackDepth ); @@ -286,7 +288,7 @@ void RimWellLogPlot::enableAllAutoNameTags( bool enable ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogPlot::uiOrderingForDepthAxis( caf::PdmUiOrdering& uiOrdering ) +void RimWellLogPlot::uiOrderingForDepthAxis( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { if ( m_availableDepthTypes.size() > 1u ) { @@ -306,13 +308,11 @@ void RimWellLogPlot::uiOrderingForDepthAxis( caf::PdmUiOrdering& uiOrdering ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogPlot::uiOrderingForPlotLayout( caf::PdmUiOrdering& uiOrdering ) +void RimWellLogPlot::uiOrderingForAutoName( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_showPlotWindowTitle ); - m_nameConfig->uiOrdering( "", uiOrdering ); + m_nameConfig->uiOrdering( uiConfigName, uiOrdering ); uiOrdering.add( &m_showIndividualPlotTitles ); - RimPlotWindow::uiOrderingForPlotLayout( uiOrdering ); - uiOrdering.add( &m_columnCountEnum ); } //-------------------------------------------------------------------------------------------------- @@ -409,7 +409,7 @@ QWidget* RimWellLogPlot::createViewWidget( QWidget* mainWindowParent ) void RimWellLogPlot::performAutoNameUpdate() { updateCommonDataSource(); - setMultiPlotTitle( m_nameConfig->name() ); + setMultiPlotTitle( createAutoName() ); updatePlotTitleInWidgets(); } @@ -585,10 +585,12 @@ void RimWellLogPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& } caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "Depth Axis" ); - uiOrderingForDepthAxis( *gridGroup ); + uiOrderingForDepthAxis( uiConfigName, *gridGroup ); caf::PdmUiGroup* titleAndLegendsGroup = uiOrdering.addNewGroup( "Plot Layout" ); - uiOrderingForPlotLayout( *titleAndLegendsGroup ); + uiOrderingForAutoName( uiConfigName, *titleAndLegendsGroup ); + RimPlotWindow::uiOrderingForLegendSettings( uiConfigName, uiOrdering ); + titleAndLegendsGroup->add( &m_columnCountEnum ); uiOrdering.skipRemainingFields( true ); } @@ -634,16 +636,17 @@ void RimWellLogPlot::initAfterRead() { RimMultiPlot::initAfterRead(); - updateCommonDataSource(); - if ( !m_plotWindowTitle().isEmpty() ) - { - m_nameConfig->setCustomName( m_plotWindowTitle() ); - } - if ( m_depthAxisGridVisibility() == AXIS_GRID_MINOR ) { m_depthAxisGridVisibility = AXIS_GRID_MAJOR_AND_MINOR; } + + if ( !m_plotWindowTitle().isEmpty() ) + { + m_nameConfig->setCustomName( m_plotWindowTitle ); + } + + performAutoNameUpdate(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h index 6a201a5f0c..8ebd5c904b 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h @@ -36,7 +36,7 @@ class RimWellLogCurveCommonDataSource; class RiuMultiPlotWindow; -class RimPlotInterface; +class RimPlotWindow; class QKeyEvent; //================================================================================================== @@ -85,11 +85,11 @@ public: void calculateAvailableDepthRange(); void availableDepthRange( double* minimumDepth, double* maximumDepth ) const; - void setAutoScaleYEnabled( bool enabled ) override; + void setAutoScaleYEnabled( bool enabled ); void enableAllAutoNameTags( bool enable ); - void uiOrderingForDepthAxis( caf::PdmUiOrdering& uiOrdering ); - void uiOrderingForPlotLayout( caf::PdmUiOrdering& uiOrdering ) override; + void uiOrderingForDepthAxis( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); + void uiOrderingForAutoName( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); QString createAutoName() const override; @@ -103,11 +103,11 @@ public: void onPlotAdditionOrRemoval() override; void updatePlotNames() override; + void handleKeyPressEvent( QKeyEvent* keyEvent ); protected: QWidget* createViewWidget( QWidget* mainWindowParent ) override; void performAutoNameUpdate() override; - void handleKeyPressEvent( QKeyEvent* keyEvent ) override; // Overridden PDM methods void fieldChangedByUi( const caf::PdmFieldHandle* changedField, diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index dc2b896385..08d3dd16d7 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -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* 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( m_colSpan() ) ) ); + double componentRangeMax = 1.5 * ( 4 / ( static_cast( 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, diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h index 288e3f5ca1..fb7682a650 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h @@ -24,7 +24,7 @@ #include "RigWellPathFormations.h" #include "RiuPlotAnnotationTool.h" -#include "RimPlotInterface.h" +#include "RimPlot.h" #include "RimRegularLegendConfig.h" #include "cafPdmChildArrayField.h" @@ -67,14 +67,11 @@ struct CurveSamplingPointData /// /// //================================================================================================== -class RimWellLogTrack : public caf::PdmObject, public RimPlotInterface +class RimWellLogTrack : public RimPlot { CAF_PDM_HEADER_INIT; public: - RimWellLogTrack(); - ~RimWellLogTrack() override; - enum TrajectoryType { WELL_PATH, @@ -86,17 +83,21 @@ public: WELL_PICK_FILTER }; - typedef caf::AppEnum RegionAnnotationTypeEnum; - typedef caf::AppEnum RegionAnnotationDisplayEnum; + using RegionAnnotationTypeEnum = caf::AppEnum; + using RegionAnnotationDisplayEnum = caf::AppEnum; + +public: + RimWellLogTrack(); + ~RimWellLogTrack() override; + + QWidget* viewWidget() override; + RiuQwtPlotWidget* viewer() override; + QImage snapshotWindowContent() override; + void zoomAll() override; - bool isChecked() const override; - void setChecked( bool checked ) override; QString description() const override; void setDescription( const QString& description ); - int colSpan() const override; - void setColSpan( RowOrColSpan colSpan ) override; - void addCurve( RimWellLogCurve* curve ); void insertCurve( RimWellLogCurve* curve, size_t index ); void takeOutCurve( RimWellLogCurve* curve ); @@ -124,12 +125,9 @@ public: void setFormationTrajectoryType( TrajectoryType trajectoryType ); TrajectoryType formationTrajectoryType() const; - void createPlotWidget() override; void detachAllCurves() override; void reattachAllCurves(); - void loadDataAndUpdate() override; - void setAndUpdateWellPathFormationNamesData( RimCase* rimCase, RimWellPath* wellPath ); void setAndUpdateSimWellFormationNamesAndBranchData( RimCase* rimCase, @@ -171,8 +169,7 @@ public: void setShowWellPathAttributes( bool on ); void setWellPathAttributesSource( RimWellPath* wellPath ); - RimWellPath* wellPathAttributeSource() const; - RiuQwtPlotWidget* viewer() override; + RimWellPath* wellPathAttributeSource() const; caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; @@ -191,7 +188,7 @@ public: void updateAllLegendItems(); - QString asciiDataForPlotExport() const; + QString asciiDataForPlotExport() const override; bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override; bool applyFontSize( RiaDefines::FontSettingType fontSettingType, @@ -203,7 +200,15 @@ public: void updateAxes() override; +protected: + // RimViewWindow overrides + QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) override; + void deleteViewWidget() override; + void onLoadDataAndUpdate() override; + private: + void cleanupBeforeClose(); + void detachAllPlotItems(); void calculateXZoomRange(); void calculateYZoomRange(); @@ -223,7 +228,6 @@ private: QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; - caf::PdmFieldHandle* objectToggleField() override; caf::PdmFieldHandle* userDescriptionField() override; void computeAndSetXRangeMinForLogarithmicScale(); @@ -262,16 +266,12 @@ private: void updateWellPathAttributesCollection(); - void onRowOrColSpanChange() override; - RimWellLogPlot* parentWellLogPlot() const; private: QString m_xAxisTitle; - caf::PdmField m_show; - caf::PdmField m_description; - caf::PdmField m_colSpan; + caf::PdmField m_description; caf::PdmChildArrayField m_curves; caf::PdmField m_visibleXRangeMin; @@ -311,6 +311,7 @@ private: caf::PdmPtrField m_wellPathAttributeCollection; caf::PdmField m_showFormations_OBSOLETE; + caf::PdmField m_show_OBSOLETE; std::vector> m_wellPathAttributePlotObjects; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index ff15c3a680..e5d0d79c3d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -141,7 +141,7 @@ CurvesData concatCurvesData( const std::vector& curvesData ); /// //-------------------------------------------------------------------------------------------------- RimSummaryPlot::RimSummaryPlot() - : RimPlotWindow() + : RimPlot() { CAF_PDM_InitObject( "Summary Plot", ":/SummaryPlotLight16x16.png", "", "" ); @@ -154,9 +154,6 @@ RimSummaryPlot::RimSummaryPlot() CAF_PDM_InitField( &m_normalizeCurveYValues, "normalizeCurveYValues", false, "Normalize all curves", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Column Span", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_summaryCurveCollection, "SummaryCurveCollection", "", "", "", "" ); m_summaryCurveCollection.uiCapability()->setUiTreeHidden( true ); m_summaryCurveCollection = new RimSummaryCurveCollection; @@ -327,6 +324,14 @@ RiuQwtPlotWidget* RimSummaryPlot::viewer() return m_plotWidget; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryPlot::asciiDataForPlotExport() const +{ + return asciiDataForSummaryPlotExport( DateTimePeriod::YEAR, false ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -377,14 +382,6 @@ QString RimSummaryPlot::asciiDataForSummaryPlotExport( DateTimePeriod resampling return out; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::createPlotWidget() -{ - createViewWidget( nullptr ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1315,14 +1312,6 @@ void RimSummaryPlot::addAsciiDataCruve( RimAsciiDataCurve* curve ) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::loadDataAndUpdate() -{ - onLoadDataAndUpdate(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1338,7 +1327,7 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { - RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue ); + RimPlot::fieldChangedByUi( changedField, oldValue, newValue ); if ( changedField == &m_showWindow ) { @@ -1361,11 +1350,6 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, } } - if ( changedField == &m_rowSpan || changedField == &m_colSpan ) - { - updatePlotWindowLayout(); - } - if ( changedField == &m_normalizeCurveYValues ) { this->loadDataAndUpdate(); @@ -1456,7 +1440,7 @@ void RimSummaryPlot::onLoadDataAndUpdate() if ( m_plotWidget ) { - m_plotWidget->setLegendVisible( m_showPlotLegends && isStandalonePlot() ); + m_plotWidget->setLegendVisible( m_showPlotLegends && isMdiWindow() ); m_plotWidget->setLegendFontSize( m_legendFontSize() ); m_plotWidget->updateLegend(); } @@ -1528,7 +1512,7 @@ std::set RimSummaryPlot::allPlotAxes() const //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::cleanupBeforeClose() { - detachAllCurves(); + detachAllPlotItems(); if ( m_plotWidget ) { @@ -1564,13 +1548,16 @@ void RimSummaryPlot::removeEnsembleCurveSetLegend( RimEnsembleCurveSet* curveSet //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::removeFromMdiAreaAndCollection() { - RimSummaryPlotCollection* summaryCollection = nullptr; - this->firstAncestorOrThisOfType( summaryCollection ); - if ( summaryCollection ) + if ( isMdiWindow() ) { - summaryCollection->removeSummaryPlot( this ); - this->revokeMdiWindowStatus(); - summaryCollection->updateAllRequiredEditors(); + RimSummaryPlotCollection* summaryCollection = nullptr; + this->firstAncestorOrThisOfType( summaryCollection ); + if ( summaryCollection ) + { + summaryCollection->removeSummaryPlot( this ); + this->revokeMdiWindowStatus(); + summaryCollection->updateAllRequiredEditors(); + } } } @@ -1592,22 +1579,6 @@ void RimSummaryPlot::updateAfterInsertingIntoMultiPlot() updateAxes(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RimSummaryPlot::rowSpan() const -{ - return static_cast( m_rowSpan() ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int RimSummaryPlot::colSpan() const -{ - return static_cast( m_colSpan() ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1632,22 +1603,6 @@ QString RimSummaryPlot::description() const return m_description(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimSummaryPlot::isChecked() const -{ - return isWindowVisible(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::setChecked( bool checked ) -{ - m_showWindow = checked; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1694,7 +1649,7 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* mainOptions = uiOrdering.addNewGroup( "General Plot Options" ); mainOptions->setCollapsedByDefault( true ); - if ( isStandalonePlot() ) + if ( isMdiWindow() ) { mainOptions->add( &m_showPlotTitle ); if ( m_showPlotTitle ) @@ -1712,7 +1667,7 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& } m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle ); - if ( isStandalonePlot() ) + if ( isMdiWindow() ) { mainOptions->add( &m_showPlotLegends ); if ( m_showPlotLegends() ) @@ -1821,7 +1776,7 @@ void RimSummaryPlot::initAfterRead() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateMdiWindowTitle() { - if ( m_plotWidget && isStandalonePlot() ) + if ( m_plotWidget && isMdiWindow() ) { QString plotTitle = description(); @@ -1887,26 +1842,48 @@ void RimSummaryPlot::updateNameHelperWithCurveData( RimSummaryPlotNameHelper* na //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateWindowVisibility() { - RimMultiPlot* plotWindow = nullptr; - this->firstAncestorOrThisOfType( plotWindow ); - if ( plotWindow ) - { - plotWindow->updateLayout(); - } - else + if ( isMdiWindow() ) { updateMdiWindowVisibility(); } + else + { + updateParentLayout(); + } + updateAxes(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateLayout() +void RimSummaryPlot::performLayoutUpdate() { this->loadDataAndUpdate(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::detachAllPlotItems() +{ + if ( m_summaryCurveCollection ) + { + m_summaryCurveCollection->detachQwtCurves(); + } + + m_ensembleCurveSetCollection->detachQwtCurves(); + + for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves ) + { + curve->detachQwtCurve(); + } + + for ( RimAsciiDataCurve* curve : m_asciiDataCurves ) + { + curve->detachQwtCurve(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1931,22 +1908,7 @@ void RimSummaryPlot::updateCurveNames() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::detachAllCurves() { - if ( m_summaryCurveCollection ) - { - m_summaryCurveCollection->detachQwtCurves(); - } - - m_ensembleCurveSetCollection->detachQwtCurves(); - - for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves ) - { - curve->detachQwtCurve(); - } - - for ( RimAsciiDataCurve* curve : m_asciiDataCurves ) - { - curve->detachQwtCurve(); - } + detachAllPlotItems(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index cbdad148c6..fc0f7ae6b8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -24,8 +24,7 @@ #include "RifEclipseSummaryAddress.h" -#include "RimPlotInterface.h" -#include "RimPlotWindow.h" +#include "RimPlot.h" #include "qwt_plot_textlabel.h" @@ -64,7 +63,7 @@ class QKeyEvent; /// /// //================================================================================================== -class RimSummaryPlot : public RimPlotWindow, public RimPlotInterface +class RimSummaryPlot : public RimPlot { CAF_PDM_HEADER_INIT; @@ -77,8 +76,6 @@ public: void setDescription( const QString& description ); QString description() const override; - bool isChecked() const override; - void setChecked( bool checked ) override; void setDraggable( bool draggable ); void enableAutoPlotTitle( bool enable ); @@ -118,6 +115,7 @@ public: QWidget* viewWidget() override; RiuQwtPlotWidget* viewer() override; + QString asciiDataForPlotExport() const override; QString asciiDataForSummaryPlotExport( DateTimePeriod resamplingPeriod, bool showTimeAsLongString ) const; std::vector summaryAndEnsembleCurves() const; @@ -136,8 +134,6 @@ public: void copyAxisPropertiesFromOther( const RimSummaryPlot& sourceSummaryPlot ); - void updateLayout() override; - void updateAll(); void updateAllLegendItems(); @@ -159,7 +155,7 @@ public: void setNormalizationEnabled( bool enable ); bool isNormalizationEnabled(); - void handleKeyPressEvent( QKeyEvent* keyEvent ) override; + void handleKeyPressEvent( QKeyEvent* keyEvent ); virtual RimSummaryPlotSourceStepping* sourceSteppingObjectForKeyEventHandling() const; virtual std::vector fieldsToShowInToolbar(); @@ -170,11 +166,9 @@ public: void updateZoomInQwt() override; void updateZoomFromQwt() override; - void createPlotWidget() override; caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; void onAxisSelected( int axis, bool toggle ) override; - void loadDataAndUpdate() override; void addOrUpdateEnsembleCurveSetLegend( RimEnsembleCurveSet* curveSet ); void removeEnsembleCurveSetLegend( RimEnsembleCurveSet* curveSet ); @@ -182,12 +176,9 @@ public: void removeFromMdiAreaAndCollection() override; void updateAfterInsertingIntoMultiPlot() override; - int rowSpan() const override; - int colSpan() const override; - public: // RimViewWindow overrides - QWidget* createViewWidget( QWidget* mainWindowParent ) override; + QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) override; void deleteViewWidget() override; void initAfterRead() override; @@ -196,6 +187,9 @@ private: void updateNameHelperWithCurveData( RimSummaryPlotNameHelper* nameHelper ) const; void updateWindowVisibility(); + void performLayoutUpdate() override; + + void detachAllPlotItems(); protected: // Overridden PDM methods @@ -236,9 +230,6 @@ private: caf::PdmField m_useAutoPlotTitle; caf::PdmField m_description; - caf::PdmField m_rowSpan; - caf::PdmField m_colSpan; - caf::PdmChildArrayField m_gridTimeHistoryCurves; caf::PdmChildField m_summaryCurveCollection; caf::PdmChildField m_ensembleCurveSetCollection; diff --git a/ApplicationCode/UserInterface/RiuDragDrop.cpp b/ApplicationCode/UserInterface/RiuDragDrop.cpp index 41f3e58af0..0772b6b39f 100644 --- a/ApplicationCode/UserInterface/RiuDragDrop.cpp +++ b/ApplicationCode/UserInterface/RiuDragDrop.cpp @@ -30,7 +30,7 @@ #include "RimIdenticalGridCaseGroup.h" #include "RimMimeData.h" #include "RimMultiPlot.h" -#include "RimPlotInterface.h" +#include "RimPlot.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" @@ -163,7 +163,7 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const } if ( dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || - dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || + dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) ) { // TODO: Remember to handle reservoir holding the main grid @@ -188,14 +188,14 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const } else if ( dynamic_cast( uiItem ) ) { - if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) + if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) { itemflags |= Qt::ItemIsDropEnabled; } } - else if ( dynamic_cast( uiItem ) ) + else if ( dynamic_cast( uiItem ) ) { - if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) + if ( RiuTypedPdmObjects::containsTypedObjects( m_dragItems ) ) { itemflags |= Qt::ItemIsDropEnabled; } @@ -459,19 +459,19 @@ bool RiuDragDrop::handleMultiPlotDrop( Qt::DropAction action, RimMultiPlot* multiPlot, int insertAtPosition ) { - std::vector plots = RiuTypedPdmObjects::typedObjectsFromGroup( draggedObjects ); + std::vector plots = RiuTypedPdmObjects::typedObjectsFromGroup( draggedObjects ); if ( plots.size() > 0 ) { if ( action == Qt::MoveAction ) { - RimPlotInterface* insertAfter = nullptr; + RimPlot* insertAfter = nullptr; if ( insertAtPosition > 0 ) { auto visibleTracks = multiPlot->visiblePlots(); if ( !visibleTracks.empty() ) { int insertAfterPosition = std::min( insertAtPosition - 1, (int)visibleTracks.size() - 1 ); - insertAfter = dynamic_cast( visibleTracks[insertAfterPosition] ); + insertAfter = dynamic_cast( visibleTracks[insertAfterPosition] ); } } multiPlot->movePlotsToThis( plots, insertAfter ); diff --git a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp index 28caca7e48..660793b93c 100644 --- a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp @@ -30,7 +30,7 @@ #include "RimGridCrossPlot.h" #include "RimGridCrossPlotCurve.h" #include "RimGridCrossPlotDataSet.h" -#include "RimPlotInterface.h" +#include "RimPlot.h" #include "RimRegularLegendConfig.h" #include "cafCmdFeatureMenuBuilder.h" @@ -58,7 +58,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimPlotInterface* plotDefinition, QWidget* parent /*= nullptr*/ ) +RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimPlot* plotDefinition, QWidget* parent /*= nullptr*/ ) : RiuQwtPlotWidget( plotDefinition, parent ) { // LeftButton for the zooming diff --git a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h index 2a63f47384..f8c7ce5c1f 100644 --- a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h @@ -29,7 +29,7 @@ class RimGridCrossPlotDataSet; class RimPlotAxisProperties; -class RimPlotInterface; +class RimPlot; class RiuCvfOverlayItemWidget; class RiuDraggableOverlayFrame; class RiuPlotAnnotationTool; @@ -50,7 +50,7 @@ class RiuGridCrossQwtPlot : public RiuQwtPlotWidget, public RiuInterfaceToViewWi Q_OBJECT; public: - RiuGridCrossQwtPlot( RimPlotInterface* plotDefinition, QWidget* parent = nullptr ); + RiuGridCrossQwtPlot( RimPlot* plotDefinition, QWidget* parent = nullptr ); ~RiuGridCrossQwtPlot(); RiuGridCrossQwtPlot( const RiuGridCrossQwtPlot& ) = delete; diff --git a/ApplicationCode/UserInterface/RiuMultiPlotWindow.cpp b/ApplicationCode/UserInterface/RiuMultiPlotWindow.cpp index aed8cb4d7f..d7b4943174 100644 --- a/ApplicationCode/UserInterface/RiuMultiPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMultiPlotWindow.cpp @@ -223,7 +223,7 @@ void RiuMultiPlotWindow::setSelectionsVisible( bool visible ) { for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets ) { - if ( visible && caf::SelectionManager::instance()->isSelected( plotWidget->plotOwner(), 0 ) ) + if ( visible && caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), 0 ) ) { plotWidget->setWidgetState( RiuWidgetStyleSheet::SELECTED ); } @@ -302,14 +302,6 @@ void RiuMultiPlotWindow::contextMenuEvent( QContextMenuEvent* event ) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMultiPlotWindow::keyPressEvent( QKeyEvent* keyEvent ) -{ - m_plotDefinition->handleKeyPressEvent( keyEvent ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -466,13 +458,13 @@ void RiuMultiPlotWindow::dropEvent( QDropEvent* event ) } } } - RimPlotInterface* insertAfter = nullptr; + RimPlot* insertAfter = nullptr; if ( beforeIndex > 0 ) { insertAfter = m_plotWidgets[beforeIndex - 1]->plotDefinition(); } - RimPlotInterface* plotToMove = source->plotDefinition(); + RimPlot* plotToMove = source->plotDefinition(); if ( insertAfter != plotToMove ) { @@ -518,7 +510,7 @@ void RiuMultiPlotWindow::onSelectionManagerSelectionChanged( const std::set for ( int changedLevel : changedSelectionLevels ) { isSelected = isSelected || - caf::SelectionManager::instance()->isSelected( plotWidget->plotOwner(), changedLevel ); + caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), changedLevel ); } if ( isSelected ) { @@ -590,8 +582,9 @@ void RiuMultiPlotWindow::reinsertPlotWidgets() int column = 0; for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex ) { - int colSpan = std::min( plotWidgets[visibleIndex]->plotDefinition()->colSpan(), rowAndColumnCount.second ); - int rowSpan = plotWidgets[visibleIndex]->plotDefinition()->rowSpan(); + int expextedColSpan = static_cast( plotWidgets[visibleIndex]->plotDefinition()->colSpan() ); + int colSpan = std::min( expextedColSpan, rowAndColumnCount.second ); + int rowSpan = plotWidgets[visibleIndex]->plotDefinition()->rowSpan(); std::tie( row, column ) = findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second ); diff --git a/ApplicationCode/UserInterface/RiuMultiPlotWindow.h b/ApplicationCode/UserInterface/RiuMultiPlotWindow.h index 2c4ae2e87d..5c67c619ad 100644 --- a/ApplicationCode/UserInterface/RiuMultiPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuMultiPlotWindow.h @@ -79,7 +79,6 @@ public: protected: void contextMenuEvent( QContextMenuEvent* ) override; - void keyPressEvent( QKeyEvent* keyEvent ) override; QLabel* createTitleLabel() const; void resizeEvent( QResizeEvent* event ) override; diff --git a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp index 4262393750..9986fbda1c 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp +++ b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp @@ -23,8 +23,8 @@ #include "RiaColorTools.h" #include "RiaPlotWindowRedrawScheduler.h" +#include "RimPlot.h" #include "RimPlotCurve.h" -#include "RimPlotInterface.h" #include "RiuPlotMainWindowTools.h" #include "RiuQwtCurvePointTracker.h" @@ -60,13 +60,11 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlotInterface* plotTrackDefinition, QWidget* parent ) +RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlot* plot, QWidget* parent ) : QwtPlot( parent ) + , m_plotDefinition( plot ) , m_draggable( true ) { - m_plotOwner = dynamic_cast( plotTrackDefinition ); - CAF_ASSERT( m_plotOwner ); - setDefaults(); this->installEventFilter( this ); @@ -78,9 +76,9 @@ RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlotInterface* plotTrackDefinition, QWidg //-------------------------------------------------------------------------------------------------- RiuQwtPlotWidget::~RiuQwtPlotWidget() { - if ( plotDefinition() ) + if ( m_plotDefinition ) { - plotDefinition()->detachAllCurves(); + m_plotDefinition->detachAllCurves(); } } @@ -89,9 +87,9 @@ RiuQwtPlotWidget::~RiuQwtPlotWidget() //-------------------------------------------------------------------------------------------------- bool RiuQwtPlotWidget::isChecked() const { - if ( plotDefinition() ) + if ( m_plotDefinition ) { - return plotDefinition()->isChecked(); + return m_plotDefinition->showWindow(); } return false; @@ -158,17 +156,9 @@ void RiuQwtPlotWidget::setAxisFontsAndAlignment( QwtPlot::Axis axis, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPlotInterface* RiuQwtPlotWidget::plotDefinition() const +RimPlot* RiuQwtPlotWidget::plotDefinition() const { - return dynamic_cast( m_plotOwner.p() ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -caf::PdmObject* RiuQwtPlotWidget::plotOwner() const -{ - return m_plotOwner.p(); + return m_plotDefinition; } //-------------------------------------------------------------------------------------------------- @@ -611,7 +601,7 @@ void RiuQwtPlotWidget::onAxisSelected( QwtScaleWidget* scale, bool toggleItemInS axisId = i; } } - plotDefinition()->onAxisSelected( axisId, toggleItemInSelection ); + m_plotDefinition->onAxisSelected( axisId, toggleItemInSelection ); } //-------------------------------------------------------------------------------------------------- @@ -671,11 +661,11 @@ void RiuQwtPlotWidget::selectPlotOwner( bool toggleItemInSelection ) { if ( toggleItemInSelection ) { - RiuPlotMainWindowTools::toggleItemInSelection( plotOwner() ); + RiuPlotMainWindowTools::toggleItemInSelection( m_plotDefinition ); } else { - RiuPlotMainWindowTools::selectAsCurrentItem( plotOwner() ); + RiuPlotMainWindowTools::selectAsCurrentItem( m_plotDefinition ); } scheduleReplot(); } @@ -710,10 +700,10 @@ void RiuQwtPlotWidget::selectClosestCurve( const QPoint& pos, bool toggleItemInS resetCurveHighlighting(); if ( closestCurve && distMin < 20 ) { - if ( plotDefinition() ) + if ( m_plotDefinition ) { RimPlotCurve* selectedCurve = dynamic_cast( - plotDefinition()->findPdmObjectFromQwtCurve( closestCurve ) ); + m_plotDefinition->findPdmObjectFromQwtCurve( closestCurve ) ); if ( selectedCurve ) { if ( toggleItemInSelection ) diff --git a/ApplicationCode/UserInterface/RiuQwtPlotWidget.h b/ApplicationCode/UserInterface/RiuQwtPlotWidget.h index a24f6b26ce..42af63acb3 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotWidget.h +++ b/ApplicationCode/UserInterface/RiuQwtPlotWidget.h @@ -31,7 +31,7 @@ #include class RiaPlotWindowRedrawScheduler; -class RimPlotInterface; +class RimPlot; class QwtLegend; class QwtPicker; @@ -53,11 +53,10 @@ class RiuQwtPlotWidget : public QwtPlot Q_OBJECT public: - RiuQwtPlotWidget( RimPlotInterface* plotTrackDefinition, QWidget* parent = nullptr ); + RiuQwtPlotWidget( RimPlot* plotTrackDefinition, QWidget* parent = nullptr ); ~RiuQwtPlotWidget() override; - RimPlotInterface* plotDefinition() const; - caf::PdmObject* plotOwner() const; + RimPlot* plotDefinition() const; bool isChecked() const; @@ -130,7 +129,7 @@ private: RiuWidgetStyleSheet createCanvasStyleSheet() const; private: - caf::PdmPointer m_plotOwner; + caf::PdmPointer m_plotDefinition; QPoint m_clickPosition; std::map m_axisTitles; std::map m_axisTitlesEnabled; diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 6bca64d47e..e0970cffc4 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -23,7 +23,7 @@ #include "RimEnsembleCurveSet.h" #include "RimEnsembleCurveSetCollection.h" #include "RimMainPlotCollection.h" -#include "RimPlotInterface.h" +#include "RimPlot.h" #include "RimRegularLegendConfig.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" @@ -92,7 +92,7 @@ static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlotInterface* plotDefinition, QWidget* parent /*= nullptr*/ ) +RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent /*= nullptr*/ ) : RiuQwtPlotWidget( plotDefinition, parent ) { // LeftButton for the zooming @@ -131,6 +131,11 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlotInterface* plotDefinition, QWidget* setLegendVisible( true ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuSummaryQwtPlot::~RiuSummaryQwtPlot() {} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -261,7 +266,7 @@ void RiuSummaryQwtPlot::contextMenuEvent( QContextMenuEvent* event ) QMenu menu; caf::CmdFeatureMenuBuilder menuBuilder; - caf::SelectionManager::instance()->setSelectedItem( plotOwner() ); + caf::SelectionManager::instance()->setSelectedItem( plotDefinition() ); menuBuilder << "RicShowPlotDataFeature"; menuBuilder << "RicSavePlotTemplateFeature"; diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h index 45a38687b2..8c8e313aaa 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h @@ -40,7 +40,8 @@ class RiuSummaryQwtPlot : public RiuQwtPlotWidget, public RiuInterfaceToViewWind Q_OBJECT; public: - RiuSummaryQwtPlot( RimPlotInterface* plotDefinition, QWidget* parent = nullptr ); + RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent = nullptr ); + ~RiuSummaryQwtPlot() override; void useDateBasedTimeAxis( const QString& dateFormat, diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp index 518eb710ca..e5ee52f021 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp @@ -72,6 +72,14 @@ void RiuWellLogPlot::updateVerticalScrollBar( double minVisible, double maxVisib m_trackScrollBar->blockSignals( false ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellLogPlot::keyPressEvent( QKeyEvent* event ) +{ + wellLogPlotDefinition()->handleKeyPressEvent( event ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.h b/ApplicationCode/UserInterface/RiuWellLogPlot.h index 45fd7d6ea1..2f08b09f9a 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.h +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.h @@ -33,6 +33,7 @@ public: void updateVerticalScrollBar( double minVisible, double maxVisible, double minAvailable, double maxAvailable ) override; protected: + void keyPressEvent( QKeyEvent* event ) override; bool willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const override; bool showYAxis( int row, int column ) const override;