Well Log Plot and Well Distribution Plots no longer inherit Multiplot

* Also cleaned up RiuQwtPlotWidget
This commit is contained in:
Gaute Lindkvist
2020-01-16 12:32:40 +01:00
parent 2044b99818
commit edc276db4d
70 changed files with 1568 additions and 1215 deletions

View File

@@ -61,6 +61,7 @@
#include "RimGridCrossPlotCollection.h" #include "RimGridCrossPlotCollection.h"
#include "RimIdenticalGridCaseGroup.h" #include "RimIdenticalGridCaseGroup.h"
#include "RimMainPlotCollection.h" #include "RimMainPlotCollection.h"
#include "RimMultiPlot.h"
#include "RimMultiPlotCollection.h" #include "RimMultiPlotCollection.h"
#include "RimObservedDataCollection.h" #include "RimObservedDataCollection.h"
#include "RimObservedSummaryData.h" #include "RimObservedSummaryData.h"

View File

@@ -17,8 +17,8 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RiaPlotWindowRedrawScheduler.h" #include "RiaPlotWindowRedrawScheduler.h"
#include "RiuMultiPlotBook.h"
#include "RiuMultiPlotPage.h" #include "RiuMultiPlotPage.h"
#include "RiuMultiPlotWindow.h"
#include "RiuQwtPlotWidget.h" #include "RiuQwtPlotWidget.h"
#include <QCoreApplication> #include <QCoreApplication>
@@ -41,7 +41,7 @@ RiaPlotWindowRedrawScheduler* RiaPlotWindowRedrawScheduler::instance()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaPlotWindowRedrawScheduler::scheduleMultiPlotWindowUpdate( RiuMultiPlotWindow* plotWindow ) void RiaPlotWindowRedrawScheduler::scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow )
{ {
m_plotWindowsToUpdate.push_back( plotWindow ); m_plotWindowsToUpdate.push_back( plotWindow );
@@ -90,26 +90,36 @@ void RiaPlotWindowRedrawScheduler::clearAllScheduledUpdates()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots() void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
{ {
std::set<RiuQwtPlotWidget*> updatedPlots; std::vector<QPointer<RiuMultiPlotBook>> plotWindowsToUpdate;
std::set<RiuMultiPlotWindow*> updatedPlotWindows; std::vector<QPointer<RiuMultiPlotPage>> plotPagesToUpdate;
std::set<RiuMultiPlotPage*> updatedPlotPages; std::vector<QPointer<RiuQwtPlotWidget>> plotWidgetsToReplot;
for ( RiuMultiPlotWindow* plotWindow : m_plotWindowsToUpdate ) plotWindowsToUpdate.swap( m_plotWindowsToUpdate );
plotPagesToUpdate.swap( m_plotPagesToUpdate );
plotWidgetsToReplot.swap( m_plotWidgetsToReplot );
std::set<QPointer<RiuQwtPlotWidget>> updatedPlots;
std::set<QPointer<RiuMultiPlotBook>> updatedPlotWindows;
std::set<QPointer<RiuMultiPlotPage>> updatedPlotPages;
for ( QPointer<RiuMultiPlotBook> plotWindow : plotWindowsToUpdate )
{ {
if ( plotWindow && !updatedPlotWindows.count( plotWindow ) ) if ( !plotWindow.isNull() && !updatedPlotWindows.count( plotWindow ) )
{ {
plotWindow->performUpdate();
updatedPlotWindows.insert( plotWindow );
for ( RiuMultiPlotPage* page : plotWindow->pages() ) for ( RiuMultiPlotPage* page : plotWindow->pages() )
{ {
updatedPlotPages.insert( page ); plotPagesToUpdate.erase( std::remove( plotPagesToUpdate.begin(), plotPagesToUpdate.end(), page ),
plotPagesToUpdate.end() );
} }
plotWindow->performUpdate();
updatedPlotWindows.insert( plotWindow );
} }
} }
for ( RiuMultiPlotPage* plotPage : m_plotPagesToUpdate ) for ( QPointer<RiuMultiPlotPage> plotPage : plotPagesToUpdate )
{ {
if ( plotPage && !updatedPlotPages.count( plotPage ) ) if ( !plotPage.isNull() && !updatedPlotPages.count( plotPage ) )
{ {
plotPage->performUpdate(); plotPage->performUpdate();
updatedPlotPages.insert( plotPage ); updatedPlotPages.insert( plotPage );
@@ -117,18 +127,14 @@ void RiaPlotWindowRedrawScheduler::performScheduledUpdatesAndReplots()
} }
// Perform update and replot. Make sure we handle legend update // Perform update and replot. Make sure we handle legend update
for ( RiuQwtPlotWidget* plot : m_plotWidgetsToReplot ) for ( QPointer<RiuQwtPlotWidget> plot : plotWidgetsToReplot )
{ {
if ( plot && !updatedPlots.count( plot ) ) if ( !plot.isNull() && !updatedPlots.count( plot ) )
{ {
plot->replot(); plot->replot();
updatedPlots.insert( plot ); updatedPlots.insert( plot );
} }
} }
m_plotWidgetsToReplot.clear();
m_plotPagesToUpdate.clear();
m_plotWindowsToUpdate.clear();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -27,7 +27,7 @@
#include <vector> #include <vector>
class RiuMultiPlotPage; class RiuMultiPlotPage;
class RiuMultiPlotWindow; class RiuMultiPlotBook;
class RiuQwtPlotWidget; class RiuQwtPlotWidget;
class RiaPlotWindowRedrawScheduler : public QObject class RiaPlotWindowRedrawScheduler : public QObject
@@ -36,7 +36,7 @@ class RiaPlotWindowRedrawScheduler : public QObject
public: public:
static RiaPlotWindowRedrawScheduler* instance(); static RiaPlotWindowRedrawScheduler* instance();
void scheduleMultiPlotWindowUpdate( RiuMultiPlotWindow* plotWindow ); void scheduleMultiPlotWindowUpdate( RiuMultiPlotBook* plotWindow );
void scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotWindow ); void scheduleMultiPlotPageUpdate( RiuMultiPlotPage* plotWindow );
void schedulePlotWidgetReplot( RiuQwtPlotWidget* plotWidget ); void schedulePlotWidgetReplot( RiuQwtPlotWidget* plotWidget );
void clearAllScheduledUpdates(); void clearAllScheduledUpdates();
@@ -53,7 +53,7 @@ private:
private: private:
std::vector<QPointer<RiuQwtPlotWidget>> m_plotWidgetsToReplot; std::vector<QPointer<RiuQwtPlotWidget>> m_plotWidgetsToReplot;
std::vector<QPointer<RiuMultiPlotWindow>> m_plotWindowsToUpdate; std::vector<QPointer<RiuMultiPlotBook>> m_plotWindowsToUpdate;
std::vector<QPointer<RiuMultiPlotPage>> m_plotPagesToUpdate; std::vector<QPointer<RiuMultiPlotPage>> m_plotPagesToUpdate;
QScopedPointer<QTimer> m_plotWindowUpdateTimer; QScopedPointer<QTimer> m_plotWindowUpdateTimer;
}; };

View File

@@ -245,7 +245,7 @@ void RicShowPlotDataFeature::onActionTriggered( bool isChecked )
for ( RimWellLogPlot* wellLogPlot : wellLogPlots ) for ( RimWellLogPlot* wellLogPlot : wellLogPlots )
{ {
QString title = wellLogPlot->multiPlotTitle(); QString title = wellLogPlot->description();
QString text = wellLogPlot->asciiDataForPlotExport(); QString text = wellLogPlot->asciiDataForPlotExport();
RicShowPlotDataFeature::showTextWindow( title, text ); RicShowPlotDataFeature::showTextWindow( title, text );
} }

View File

@@ -23,7 +23,7 @@
#include "RiaPlotWindowRedrawScheduler.h" #include "RiaPlotWindowRedrawScheduler.h"
#include "RimMainPlotCollection.h" #include "RimMainPlotCollection.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimPlotWindow.h" #include "RimPlotWindow.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimViewWindow.h" #include "RimViewWindow.h"
@@ -106,7 +106,7 @@ void RicSnapshotViewToFileFeature::savePlotPDFReportAs( const QString& fileName,
pdfPrinter.setResolution( resolution ); pdfPrinter.setResolution( resolution );
QRect widgetRect = plot->viewWidget()->contentsRect(); QRect widgetRect = plot->viewWidget()->contentsRect();
RimMultiPlotWindow* multiPlot = dynamic_cast<RimMultiPlotWindow*>( plot ); RimMultiPlot* multiPlot = dynamic_cast<RimMultiPlot*>( plot );
if ( multiPlot && multiPlot->previewModeEnabled() ) if ( multiPlot && multiPlot->previewModeEnabled() )
{ {
QRect pageRect = pdfPrinter.pageLayout().fullRectPixels( resolution ); QRect pageRect = pdfPrinter.pageLayout().fullRectPixels( resolution );

View File

@@ -44,7 +44,7 @@
#include "RimGridTimeHistoryCurve.h" #include "RimGridTimeHistoryCurve.h"
#include "RimIdenticalGridCaseGroup.h" #include "RimIdenticalGridCaseGroup.h"
#include "RimIntersectionResultDefinition.h" #include "RimIntersectionResultDefinition.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimPerforationInterval.h" #include "RimPerforationInterval.h"
#include "RimPolylinesAnnotation.h" #include "RimPolylinesAnnotation.h"
#include "RimReachCircleAnnotation.h" #include "RimReachCircleAnnotation.h"
@@ -112,7 +112,7 @@ bool isDeletable( caf::PdmUiItem* uiItem )
if ( dynamic_cast<RimWellLogCurve*>( uiItem ) ) return true; if ( dynamic_cast<RimWellLogCurve*>( uiItem ) ) return true;
if ( dynamic_cast<RimSummaryPlot*>( uiItem ) ) if ( dynamic_cast<RimSummaryPlot*>( uiItem ) )
{ {
RimMultiPlotWindow* plotWindow = nullptr; RimMultiPlot* plotWindow = nullptr;
static_cast<RimSummaryPlot*>( uiItem )->firstAncestorOrThisOfType( plotWindow ); static_cast<RimSummaryPlot*>( uiItem )->firstAncestorOrThisOfType( plotWindow );
return plotWindow == nullptr; return plotWindow == nullptr;
} }
@@ -144,7 +144,7 @@ bool isDeletable( caf::PdmUiItem* uiItem )
if ( dynamic_cast<RimGridCrossPlot*>( uiItem ) ) if ( dynamic_cast<RimGridCrossPlot*>( uiItem ) )
{ {
RimMultiPlotWindow* plotWindow = nullptr; RimMultiPlot* plotWindow = nullptr;
static_cast<RimGridCrossPlot*>( uiItem )->firstAncestorOrThisOfType( plotWindow ); static_cast<RimGridCrossPlot*>( uiItem )->firstAncestorOrThisOfType( plotWindow );
return plotWindow == nullptr; return plotWindow == nullptr;
} }

View File

@@ -22,8 +22,8 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RimMainPlotCollection.h" #include "RimMainPlotCollection.h"
#include "RimMultiPlot.h"
#include "RimMultiPlotCollection.h" #include "RimMultiPlotCollection.h"
#include "RimMultiPlotWindow.h"
#include "RimPlot.h" #include "RimPlot.h"
#include "RimProject.h" #include "RimProject.h"
@@ -53,7 +53,7 @@ RicfCommandResponse RicNewMultiPlotFeature::execute()
RimProject* project = RiaApplication::instance()->project(); RimProject* project = RiaApplication::instance()->project();
RimMultiPlotCollection* plotCollection = project->mainPlotCollection()->multiPlotCollection(); RimMultiPlotCollection* plotCollection = project->mainPlotCollection()->multiPlotCollection();
RimMultiPlotWindow* plotWindow = new RimMultiPlotWindow; RimMultiPlot* plotWindow = new RimMultiPlot;
plotWindow->setMultiPlotTitle( QString( "Multi Plot %1" ).arg( plotCollection->multiPlots().size() + 1 ) ); plotWindow->setMultiPlotTitle( QString( "Multi Plot %1" ).arg( plotCollection->multiPlots().size() + 1 ) );
plotWindow->setAsPlotMdiWindow(); plotWindow->setAsPlotMdiWindow();
plotCollection->addMultiPlot( plotWindow ); plotCollection->addMultiPlot( plotWindow );
@@ -68,7 +68,7 @@ RicfCommandResponse RicNewMultiPlotFeature::execute()
plotWindow->movePlotsToThis( plots, nullptr ); plotWindow->movePlotsToThis( plots, nullptr );
} }
plotCollection->updateAllRequiredEditors(); project->updateAllRequiredEditors();
plotWindow->loadDataAndUpdate(); plotWindow->loadDataAndUpdate();
RiuPlotMainWindowTools::setExpanded( plotCollection, true ); RiuPlotMainWindowTools::setExpanded( plotCollection, true );
@@ -82,13 +82,6 @@ RicfCommandResponse RicNewMultiPlotFeature::execute()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicNewMultiPlotFeature::isCommandEnabled() bool RicNewMultiPlotFeature::isCommandEnabled()
{ {
RimMultiPlotCollection* multiPlotCollection =
caf::SelectionManager::instance()->selectedItemOfType<RimMultiPlotCollection>();
if ( multiPlotCollection )
{
return true;
}
auto plots = selectedPlots(); auto plots = selectedPlots();
std::vector<caf::PdmUiItem*> selectedUiItems; std::vector<caf::PdmUiItem*> selectedUiItems;
@@ -116,16 +109,8 @@ void RicNewMultiPlotFeature::onActionTriggered( bool isChecked )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewMultiPlotFeature::setupActionLook( QAction* actionToSetup ) void RicNewMultiPlotFeature::setupActionLook( QAction* actionToSetup )
{ {
if ( selectedPlots().empty() )
{
actionToSetup->setText( "New Empty Multi Plot" );
actionToSetup->setIcon( QIcon( ":/WellLogPlot16x16.png" ) );
}
else
{
actionToSetup->setText( "Create Multi Plot from Selected Plots" ); actionToSetup->setText( "Create Multi Plot from Selected Plots" );
actionToSetup->setIcon( QIcon( ":/WellLogPlot16x16.png" ) ); actionToSetup->setIcon( QIcon( ":/WellLogPlot16x16.png" ) );
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -97,7 +97,6 @@ RicSummaryCurveCreator::RicSummaryCurveCreator()
CAF_PDM_InitFieldNoDefault( &m_regionAppearanceType, "RegionAppearanceType", "Region", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_regionAppearanceType, "RegionAppearanceType", "Region", "", "", "" );
m_previewPlot.reset( new RimSummaryPlot() ); m_previewPlot.reset( new RimSummaryPlot() );
m_previewPlot->setDraggable( false );
CAF_PDM_InitFieldNoDefault( &m_useAutoPlotTitleProxy, "UseAutoPlotTitle", "Auto Plot Title", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_useAutoPlotTitleProxy, "UseAutoPlotTitle", "Auto Plot Title", "", "", "" );
m_useAutoPlotTitleProxy.registerGetMethod( this, &RicSummaryCurveCreator::proxyPlotAutoTitle ); m_useAutoPlotTitleProxy.registerGetMethod( this, &RicSummaryCurveCreator::proxyPlotAutoTitle );

View File

@@ -240,7 +240,7 @@ QWidget* RicSummaryCurveCreatorSplitterUi::getOrCreatePlotWidget()
if ( m_summaryCurveCreator ) if ( m_summaryCurveCreator )
{ {
// TODO: Rename previewPlot()->createViewWidget to getOrCreateViewWidget // TODO: Rename previewPlot()->createViewWidget to getOrCreateViewWidget
return m_summaryCurveCreator->previewPlot()->createViewWidget( this->widget() ); return m_summaryCurveCreator->previewPlot()->createPlotWidget( this->widget() );
} }
return nullptr; return nullptr;

View File

@@ -65,7 +65,7 @@ void RicAsciiExportWellLogPlotFeature::onActionTriggered( bool isChecked )
{ {
RimWellLogPlot* wellLogPlot = selectedWellLogPlots.at( 0 ); RimWellLogPlot* wellLogPlot = selectedWellLogPlots.at( 0 );
QString defaultFileName = defaultDir + "/" + QString defaultFileName = defaultDir + "/" +
caf::Utils::makeValidFileBasename( ( wellLogPlot->multiPlotTitle() ) ) + ".ascii"; caf::Utils::makeValidFileBasename( ( wellLogPlot->description() ) ) + ".ascii";
QString fileName = QFileDialog::getSaveFileName( nullptr, QString fileName = QFileDialog::getSaveFileName( nullptr,
"Select File for Plot Data Export", "Select File for Plot Data Export",
defaultFileName, defaultFileName,
@@ -81,7 +81,7 @@ void RicAsciiExportWellLogPlotFeature::onActionTriggered( bool isChecked )
std::vector<QString> fileNames; std::vector<QString> fileNames;
for ( RimWellLogPlot* wellLogPlot : selectedWellLogPlots ) for ( RimWellLogPlot* wellLogPlot : selectedWellLogPlots )
{ {
QString fileName = caf::Utils::makeValidFileBasename( wellLogPlot->multiPlotTitle() ) + ".ascii"; QString fileName = caf::Utils::makeValidFileBasename( wellLogPlot->description() ) + ".ascii";
fileNames.push_back( fileName ); fileNames.push_back( fileName );
} }
@@ -92,8 +92,7 @@ void RicAsciiExportWellLogPlotFeature::onActionTriggered( bool isChecked )
RiaLogging::info( QString( "Writing to directory %!" ).arg( saveDir ) ); RiaLogging::info( QString( "Writing to directory %!" ).arg( saveDir ) );
for ( RimWellLogPlot* wellLogPlot : selectedWellLogPlots ) for ( RimWellLogPlot* wellLogPlot : selectedWellLogPlots )
{ {
QString fileName = saveDir + "/" + caf::Utils::makeValidFileBasename( wellLogPlot->multiPlotTitle() ) + QString fileName = saveDir + "/" + caf::Utils::makeValidFileBasename( wellLogPlot->description() ) + ".ascii";
".ascii";
RicAsciiExportWellLogPlotFeature::exportAsciiForWellLogPlot( fileName, wellLogPlot ); RicAsciiExportWellLogPlotFeature::exportAsciiForWellLogPlot( fileName, wellLogPlot );
progress++; progress++;
@@ -119,8 +118,7 @@ QString RicAsciiExportWellLogPlotFeature::makeValidExportFileName( const RimWell
const QString& prefix, const QString& prefix,
bool capitalizeFileName ) bool capitalizeFileName )
{ {
QString fileName = folder + "/" + prefix + caf::Utils::makeValidFileBasename( wellLogPlot->multiPlotTitle() ) + QString fileName = folder + "/" + prefix + caf::Utils::makeValidFileBasename( wellLogPlot->description() ) + ".ascii";
".ascii";
if ( capitalizeFileName ) fileName = fileName.toUpper(); if ( capitalizeFileName ) fileName = fileName.toUpper();
QDir dir( folder ); QDir dir( folder );
@@ -143,7 +141,7 @@ bool RicAsciiExportWellLogPlotFeature::exportAsciiForWellLogPlot( const QString&
QTextStream out( &file ); QTextStream out( &file );
out << wellLogPlot->multiPlotTitle(); out << wellLogPlot->description();
out << "\n"; out << "\n";
out << wellLogPlot->asciiDataForPlotExport(); out << wellLogPlot->asciiDataForPlotExport();
out << "\n\n"; out << "\n\n";

View File

@@ -25,7 +25,7 @@
#include "RiuPlotMainWindow.h" #include "RiuPlotMainWindow.h"
#include "RiuQwtPlotWidget.h" #include "RiuQwtPlotWidget.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimPlotWindow.h" #include "RimPlotWindow.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
@@ -50,7 +50,7 @@ bool RicDeleteSubPlotFeature::isCommandEnabled()
size_t plotsSelected = 0; size_t plotsSelected = 0;
for ( caf::PdmObject* object : selection ) for ( caf::PdmObject* object : selection )
{ {
RimMultiPlotWindow* multiPlot = nullptr; RimMultiPlot* multiPlot = nullptr;
object->firstAncestorOrThisOfType( multiPlot ); object->firstAncestorOrThisOfType( multiPlot );
if ( dynamic_cast<RimPlotWindow*>( object ) && multiPlot ) if ( dynamic_cast<RimPlotWindow*>( object ) && multiPlot )
{ {
@@ -72,11 +72,11 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
std::vector<RimPlot*> selection; std::vector<RimPlot*> selection;
caf::SelectionManager::instance()->objectsByType( &selection ); caf::SelectionManager::instance()->objectsByType( &selection );
std::set<RimMultiPlotWindow*> alteredPlotWindows; std::set<RimMultiPlot*> alteredPlotWindows;
for ( RimPlot* plot : selection ) for ( RimPlot* plot : selection )
{ {
RimMultiPlotWindow* plotWindow = nullptr; RimMultiPlot* plotWindow = nullptr;
plot->firstAncestorOrThisOfType( plotWindow ); plot->firstAncestorOrThisOfType( plotWindow );
if ( plot && plotWindow ) if ( plot && plotWindow )
{ {
@@ -89,7 +89,7 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
} }
} }
for ( RimMultiPlotWindow* plotWindow : alteredPlotWindows ) for ( RimMultiPlot* plotWindow : alteredPlotWindows )
{ {
plotWindow->uiCapability()->updateConnectedEditors(); plotWindow->uiCapability()->updateConnectedEditors();
} }

View File

@@ -116,7 +116,7 @@ void RicNewPltPlotFeature::onActionTriggered( bool isChecked )
plotTrack->setDescription( QString( "Track %1" ).arg( pltPlot->plotCount() ) ); plotTrack->setDescription( QString( "Track %1" ).arg( pltPlot->plotCount() ) );
pltPlotColl->addPlot( pltPlot ); pltPlotColl->addPlot( pltPlot );
pltPlot->setMultiPlotTitle( plotName ); pltPlot->nameConfig()->setCustomName( plotName );
// pltPlot->applyInitialSelections(); // pltPlot->applyInitialSelections();
pltPlot->loadDataAndUpdate(); pltPlot->loadDataAndUpdate();

View File

@@ -81,7 +81,7 @@ void RicNewRftPlotFeature::onActionTriggered( bool isChecked )
wellName = rftPlot->simWellOrWellPathName(); // We may have been given a default well name wellName = rftPlot->simWellOrWellPathName(); // We may have been given a default well name
QString plotName = QString( RimWellRftPlot::plotNameFormatString() ).arg( wellName ); QString plotName = QString( RimWellRftPlot::plotNameFormatString() ).arg( wellName );
rftPlot->setMultiPlotTitle( plotName ); rftPlot->nameConfig()->setCustomName( plotName );
rftPlot->loadDataAndUpdate(); rftPlot->loadDataAndUpdate();
rftPlotColl->updateConnectedEditors(); rftPlotColl->updateConnectedEditors();

View File

@@ -102,11 +102,11 @@ RimWellBoreStabilityPlot*
auto task = progInfo.task( "Updating all tracks", 5 ); auto task = progInfo.task( "Updating all tracks", 5 );
plot->nameConfig()->setAutoNameTags( true, true, true, false, true ); plot->nameConfig()->setAutoNameTags( true, true, true, false, true );
plot->setMultiPlotTitleVisible( true ); plot->setPlotTitleVisible( true );
plot->setLegendsVisible( true ); plot->setLegendsVisible( true );
plot->setLegendsHorizontal( true ); plot->setLegendsHorizontal( true );
plot->setDepthType( RiaDefines::TRUE_VERTICAL_DEPTH ); plot->setDepthType( RiaDefines::TRUE_VERTICAL_DEPTH );
plot->setAutoScaleYEnabled( true ); plot->setAutoScaleDepthEnabled( true );
RicNewWellLogPlotFeatureImpl::updateAfterCreation( plot ); RicNewWellLogPlotFeatureImpl::updateAfterCreation( plot );
} }

View File

@@ -58,11 +58,11 @@ RimWellBoreStabilityPlot*
if ( !plotDescription.isEmpty() ) if ( !plotDescription.isEmpty() )
{ {
plot->setMultiPlotTitle( plotDescription ); plot->nameConfig()->setCustomName( plotDescription );
} }
else else
{ {
plot->setMultiPlotTitle( plot->nameConfig()->setCustomName(
QString( "Well Bore Stability Plot %1" ).arg( wellLogPlotCollection()->wellLogPlots.size() ) ); QString( "Well Bore Stability Plot %1" ).arg( wellLogPlotCollection()->wellLogPlots.size() ) );
} }
@@ -92,11 +92,12 @@ RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createWellLogPlot( bool showAfterC
if ( !plotDescription.isEmpty() ) if ( !plotDescription.isEmpty() )
{ {
plot->setMultiPlotTitle( plotDescription ); plot->nameConfig()->setCustomName( plotDescription );
} }
else else
{ {
plot->setMultiPlotTitle( QString( "Well Log Plot %1" ).arg( wellLogPlotCollection()->wellLogPlots.size() ) ); plot->nameConfig()->setCustomName(
QString( "Well Log Plot %1" ).arg( wellLogPlotCollection()->wellLogPlots.size() ) );
} }
if ( showAfterCreation ) if ( showAfterCreation )

View File

@@ -85,8 +85,8 @@ void RicPasteWellLogPlotFeature::onActionTriggered( bool isChecked )
newObject->resolveReferencesRecursively(); newObject->resolveReferencesRecursively();
newObject->initAfterReadRecursively(); newObject->initAfterReadRecursively();
QString description = "Copy of " + newObject->multiPlotTitle(); QString customName = "Copy of " + newObject->nameConfig()->customName();
newObject->setMultiPlotTitle( description ); newObject->nameConfig()->setCustomName( customName );
newObject->loadDataAndUpdate(); newObject->loadDataAndUpdate();

View File

@@ -77,7 +77,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.h ${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.h
${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotWindow.h ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurve.h
@@ -229,7 +229,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RimMultiPlotWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellBoreStabilityPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellBoreStabilityPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.cpp
@@ -310,5 +310,8 @@ list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES} ${SOURCE_GROUP_SOURCE_FILES}
) )
list(APPEND QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RimPlot.h
)
source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@@ -103,7 +103,6 @@ RimWellAllocationPlot::RimWellAllocationPlot()
m_accumulatedWellFlowPlot->setDepthType( RiaDefines::CONNECTION_NUMBER ); m_accumulatedWellFlowPlot->setDepthType( RiaDefines::CONNECTION_NUMBER );
m_accumulatedWellFlowPlot->setLegendsVisible( false ); m_accumulatedWellFlowPlot->setLegendsVisible( false );
m_accumulatedWellFlowPlot->uiCapability()->setUiIconFromResourceString( ":/WellFlowPlot16x16.png" ); m_accumulatedWellFlowPlot->uiCapability()->setUiIconFromResourceString( ":/WellFlowPlot16x16.png" );
m_accumulatedWellFlowPlot->setAcceptDrops( false );
CAF_PDM_InitFieldNoDefault( &m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", "" );
m_totalWellAllocationPlot.uiCapability()->setUiHidden( true ); m_totalWellAllocationPlot.uiCapability()->setUiHidden( true );

View File

@@ -290,7 +290,7 @@ void RimWellDistributionPlot::doRemoveFromCollection()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QWidget* RimWellDistributionPlot::createViewWidget( QWidget* mainWindowParent ) RiuQwtPlotWidget* RimWellDistributionPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{ {
// cvf::Trace::show("RimWellDistributionPlot::createViewWidget()"); // cvf::Trace::show("RimWellDistributionPlot::createViewWidget()");
@@ -303,7 +303,6 @@ QWidget* RimWellDistributionPlot::createViewWidget( QWidget* mainWindowParent )
m_plotWidget = new RiuQwtPlotWidget( this, mainWindowParent ); m_plotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
m_plotWidget->setAutoReplot( false ); m_plotWidget->setAutoReplot( false );
m_plotWidget->setDraggable( false );
updateLegend(); updateLegend();
onLoadDataAndUpdate(); onLoadDataAndUpdate();

View File

@@ -75,11 +75,12 @@ private:
void doRemoveFromCollection() override; void doRemoveFromCollection() override;
// RimViewWindow implementations // RimViewWindow implementations
QWidget* createViewWidget( QWidget* mainWindowParent ) override;
void deleteViewWidget() override; void deleteViewWidget() override;
void onLoadDataAndUpdate() override; void onLoadDataAndUpdate() override;
private: private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override;
void fixupDependentFieldsAfterCaseChange(); void fixupDependentFieldsAfterCaseChange();
static void populatePlotWidgetWithCurveData( const RigTofWellDistributionCalculator& calculator, static void populatePlotWidgetWithCurveData( const RigTofWellDistributionCalculator& calculator,
const RimFlowDiagSolution& flowDiagSolution, const RimFlowDiagSolution& flowDiagSolution,

View File

@@ -19,6 +19,7 @@
#include "RimWellDistributionPlotCollection.h" #include "RimWellDistributionPlotCollection.h"
#include "RimEclipseResultCase.h" #include "RimEclipseResultCase.h"
#include "RimFlowDiagSolution.h" #include "RimFlowDiagSolution.h"
#include "RimPlot.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimWellDistributionPlot.h" #include "RimWellDistributionPlot.h"
@@ -27,6 +28,7 @@
#include "RiaColorTools.h" #include "RiaColorTools.h"
#include "RiuMultiPlotPage.h"
#include "RiuQwtPlotTools.h" #include "RiuQwtPlotTools.h"
#include "qwt_legend.h" #include "qwt_legend.h"
@@ -53,7 +55,6 @@ CAF_PDM_SOURCE_INIT( RimWellDistributionPlotCollection, "WellDistributionPlotCol
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellDistributionPlotCollection::RimWellDistributionPlotCollection() RimWellDistributionPlotCollection::RimWellDistributionPlotCollection()
: RimMultiPlotWindow( true )
{ {
// cvf::Trace::show("RimWellDistributionPlotCollection::RimWellDistributionPlotCollection()"); // cvf::Trace::show("RimWellDistributionPlotCollection::RimWellDistributionPlotCollection()");
@@ -73,17 +74,25 @@ RimWellDistributionPlotCollection::RimWellDistributionPlotCollection()
CAF_PDM_InitField( &m_maximumTof, "MaximumTOF", 20.0, "Maximum Time of Flight [0, 200]", "", "", "" ); CAF_PDM_InitField( &m_maximumTof, "MaximumTOF", 20.0, "Maximum Time of Flight [0, 200]", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_plots, "Plots", "", "", "", "" );
m_plots.uiCapability()->setUiHidden( true );
m_plots.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitField( &m_showOil, "ShowOil", true, "Show Oil", "", "", "" ); CAF_PDM_InitField( &m_showOil, "ShowOil", true, "Show Oil", "", "", "" );
CAF_PDM_InitField( &m_showGas, "ShowGas", true, "Show Gas", "", "", "" ); CAF_PDM_InitField( &m_showGas, "ShowGas", true, "Show Gas", "", "", "" );
CAF_PDM_InitField( &m_showWater, "ShowWater", true, "Show Water", "", "", "" ); CAF_PDM_InitField( &m_showWater, "ShowWater", true, "Show Water", "", "", "" );
m_plotWindowTitle = "Cumulative Phase Distribution Plots"; CAF_PDM_InitField( &m_plotWindowTitle,
m_columnCount = RimMultiPlotWindow::COLUMNS_UNLIMITED; "PlotDescription",
QString( "Cumulative Phase Distribution Plots" ),
"Name",
"",
"",
"" );
m_showPlotLegends = false; m_showPlotLegends = false;
m_showWindow = false; m_showWindow = false;
setAcceptDrops( false );
setAsPlotMdiWindow(); setAsPlotMdiWindow();
addPlot( new RimWellDistributionPlot( RiaDefines::OIL_PHASE ) ); addPlot( new RimWellDistributionPlot( RiaDefines::OIL_PHASE ) );
@@ -94,7 +103,13 @@ RimWellDistributionPlotCollection::RimWellDistributionPlotCollection()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellDistributionPlotCollection::~RimWellDistributionPlotCollection() {} RimWellDistributionPlotCollection::~RimWellDistributionPlotCollection()
{
removeMdiWindowFromMdiArea();
m_plots.deleteAllChildObjects();
cleanupBeforeClose();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@@ -108,14 +123,104 @@ void RimWellDistributionPlotCollection::setData( RimEclipseResultCase* eclipseCa
applyPlotParametersToContainedPlots(); applyPlotParametersToContainedPlots();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimWellDistributionPlotCollection::viewWidget()
{
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellDistributionPlotCollection::description() const
{
return m_plotWindowTitle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QImage RimWellDistributionPlotCollection::snapshotWindowContent()
{
QImage image;
if ( m_viewer )
{
QPixmap pix( m_viewer->size() );
m_viewer->renderTo( &pix );
image = pix.toImage();
}
return image;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlotCollection::zoomAll() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellDistributionPlotCollection::onLoadDataAndUpdate() void RimWellDistributionPlotCollection::onLoadDataAndUpdate()
{ {
// cvf::Trace::show("RimWellDistributionPlotCollection::onLoadDataAndUpdate()"); // cvf::Trace::show("RimWellDistributionPlotCollection::onLoadDataAndUpdate()");
updateMdiWindowVisibility();
updatePlots();
updateLayout();
}
RimMultiPlotWindow::onLoadDataAndUpdate(); //--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimWellDistributionPlotCollection::createViewWidget( QWidget* mainWindowParent )
{
m_viewer = new RiuMultiPlotPage( this, mainWindowParent );
m_viewer->setPlotTitle( m_plotWindowTitle );
recreatePlotWidgets();
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlotCollection::deleteViewWidget()
{
cleanupBeforeClose();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlotCollection::doRenderWindowContent( QPaintDevice* paintDevice )
{
if ( m_viewer )
{
m_viewer->renderTo( paintDevice );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlotCollection::addPlot( RimPlot* plot )
{
if ( plot )
{
size_t index = m_plots.size();
m_plots.insert( index, plot );
if ( m_viewer )
{
plot->createPlotWidget();
m_viewer->insertPlot( plot->viewer(), index );
}
plot->setShowWindow( true );
plot->setLegendsVisible( false );
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -147,8 +252,7 @@ QList<caf::PdmOptionItemInfo>
RimWellDistributionPlotCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, RimWellDistributionPlotCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) bool* useOptionsOnly )
{ {
QList<caf::PdmOptionItemInfo> options = RimMultiPlotWindow::calculateValueOptions( fieldNeedingOptions, QList<caf::PdmOptionItemInfo> options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
useOptionsOnly );
if ( fieldNeedingOptions == &m_case ) if ( fieldNeedingOptions == &m_case )
{ {
@@ -225,13 +329,12 @@ void RimWellDistributionPlotCollection::fieldChangedByUi( const caf::PdmFieldHan
shouldRecalculatePlotData = true; shouldRecalculatePlotData = true;
} }
RimMultiPlotWindow::fieldChangedByUi( changedField, oldValue, newValue ); RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue );
if ( shouldRecalculatePlotData ) if ( shouldRecalculatePlotData )
{ {
updateLayout();
loadDataAndUpdate(); loadDataAndUpdate();
updateLayout();
} }
} }
@@ -240,11 +343,11 @@ void RimWellDistributionPlotCollection::fieldChangedByUi( const caf::PdmFieldHan
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellDistributionPlotCollection::applyPlotParametersToContainedPlots() void RimWellDistributionPlotCollection::applyPlotParametersToContainedPlots()
{ {
const size_t numPlots = plotCount(); const size_t numPlots = m_plots.size();
for ( size_t i = 0; i < numPlots; i++ ) for ( size_t i = 0; i < numPlots; i++ )
{ {
// Dirty usage of dyn_cast, but type is lost when adding the plots to our base class // Dirty usage of dyn_cast, but type is lost when adding the plots to our base class
RimWellDistributionPlot* aPlot = dynamic_cast<RimWellDistributionPlot*>( plotByIndex( i ) ); RimWellDistributionPlot* aPlot = dynamic_cast<RimWellDistributionPlot*>( m_plots[i] );
if ( aPlot ) if ( aPlot )
{ {
if ( aPlot->phase() == RiaDefines::PhaseType::OIL_PHASE ) if ( aPlot->phase() == RiaDefines::PhaseType::OIL_PHASE )
@@ -266,6 +369,54 @@ void RimWellDistributionPlotCollection::applyPlotParametersToContainedPlots()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlotCollection::updatePlots()
{
if ( m_showWindow )
{
for ( RimPlot* plot : m_plots() )
{
plot->loadDataAndUpdate();
plot->updateZoomInQwt();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlotCollection::cleanupBeforeClose()
{
auto plotVector = m_plots.childObjects();
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
{
plotVector[tIdx]->detachAllCurves();
}
if ( m_viewer )
{
m_viewer->setParent( nullptr );
delete m_viewer;
m_viewer = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellDistributionPlotCollection::recreatePlotWidgets()
{
CVF_ASSERT( m_viewer );
for ( auto plot : m_plots() )
{
plot->createPlotWidget();
m_viewer->addPlot( plot->viewer() );
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -19,8 +19,10 @@
#pragma once #pragma once
#include "RiaDefines.h" #include "RiaDefines.h"
#include "RimMultiPlotWindow.h" #include "RimPlotWindow.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h" #include "cafPdmPtrField.h"
#include <QPointer> #include <QPointer>
@@ -29,7 +31,9 @@
class RimEclipseResultCase; class RimEclipseResultCase;
class RimFlowDiagSolution; class RimFlowDiagSolution;
class RimPlot;
class RigTofWellDistributionCalculator; class RigTofWellDistributionCalculator;
class RiuMultiPlotPage;
class QTextBrowser; class QTextBrowser;
class QwtPlot; class QwtPlot;
@@ -39,7 +43,7 @@ class QwtPlot;
// //
// //
//================================================================================================== //==================================================================================================
class RimWellDistributionPlotCollection : public RimMultiPlotWindow class RimWellDistributionPlotCollection : public RimPlotWindow
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
@@ -49,6 +53,11 @@ public:
void setData( RimEclipseResultCase* eclipseCase, QString wellName, int timeStepIndex ); void setData( RimEclipseResultCase* eclipseCase, QString wellName, int timeStepIndex );
QWidget* viewWidget() override;
QString description() const override;
QImage snapshotWindowContent() override;
void zoomAll() override;
private: private:
// RimPlotWindow overrides // RimPlotWindow overrides
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
@@ -58,11 +67,19 @@ private:
const QVariant& newValue ) override; const QVariant& newValue ) override;
void onLoadDataAndUpdate() override; void onLoadDataAndUpdate() override;
QWidget* createViewWidget( QWidget* mainWindowParent ) override;
void deleteViewWidget() override;
void doRenderWindowContent( QPaintDevice* paintDevice ) override;
private: private:
void addPlot( RimPlot* plot );
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fixupDependentFieldsAfterCaseChange(); void fixupDependentFieldsAfterCaseChange();
void applyPlotParametersToContainedPlots(); void applyPlotParametersToContainedPlots();
void updatePlots();
void cleanupBeforeClose();
void recreatePlotWidgets();
private: private:
caf::PdmPtrField<RimEclipseResultCase*> m_case; caf::PdmPtrField<RimEclipseResultCase*> m_case;
@@ -72,7 +89,12 @@ private:
caf::PdmField<double> m_smallContributionsRelativeThreshold; caf::PdmField<double> m_smallContributionsRelativeThreshold;
caf::PdmField<double> m_maximumTof; caf::PdmField<double> m_maximumTof;
caf::PdmField<QString> m_plotWindowTitle;
caf::PdmChildArrayField<RimPlot*> m_plots;
caf::PdmField<bool> m_showOil; caf::PdmField<bool> m_showOil;
caf::PdmField<bool> m_showGas; caf::PdmField<bool> m_showGas;
caf::PdmField<bool> m_showWater; caf::PdmField<bool> m_showWater;
QPointer<RiuMultiPlotPage> m_viewer;
}; };

View File

@@ -893,7 +893,7 @@ void RimWellPltPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
if ( changedField == &m_wellPathName ) if ( changedField == &m_wellPathName )
{ {
setMultiPlotTitle( QString( plotNameFormatString() ).arg( m_wellPathName ) ); m_nameConfig->setCustomName( QString( plotNameFormatString() ).arg( m_wellPathName ) );
} }
if ( changedField == &m_wellPathName ) if ( changedField == &m_wellPathName )

View File

@@ -878,7 +878,7 @@ void RimWellRftPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
if ( changedField == &m_wellPathNameOrSimWellName ) if ( changedField == &m_wellPathNameOrSimWellName )
{ {
setMultiPlotTitle( QString( plotNameFormatString() ).arg( m_wellPathNameOrSimWellName ) ); m_nameConfig->setCustomName( QString( plotNameFormatString() ).arg( m_wellPathNameOrSimWellName ) );
m_branchIndex = 0; m_branchIndex = 0;

View File

@@ -25,4 +25,8 @@ list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES} ${SOURCE_GROUP_SOURCE_FILES}
) )
list(APPEND QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RimGridCrossPlot.h
)
source_group( "ProjectDataModel\\GridCrossPlots" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) source_group( "ProjectDataModel\\GridCrossPlots" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@@ -30,7 +30,7 @@
#include "RimGridCrossPlotCollection.h" #include "RimGridCrossPlotCollection.h"
#include "RimGridCrossPlotCurve.h" #include "RimGridCrossPlotCurve.h"
#include "RimGridCrossPlotDataSet.h" #include "RimGridCrossPlotDataSet.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimPlotAxisProperties.h" #include "RimPlotAxisProperties.h"
#include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiCheckBoxEditor.h"
@@ -436,7 +436,17 @@ QString RimGridCrossPlot::generateInfoBoxText() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QWidget* RimGridCrossPlot::createViewWidget( QWidget* mainWindowParent ) void RimGridCrossPlot::onPlotZoomed()
{
setAutoScaleXEnabled( false );
setAutoScaleYEnabled( false );
updateZoomFromQwt();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget* RimGridCrossPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{ {
if ( !m_plotWidget ) if ( !m_plotWidget )
{ {
@@ -446,9 +456,11 @@ QWidget* RimGridCrossPlot::createViewWidget( QWidget* mainWindowParent )
{ {
dataSet->setParentQwtPlotNoReplot( m_plotWidget ); dataSet->setParentQwtPlotNoReplot( m_plotWidget );
} }
}
m_plotWidget->scheduleReplot(); updateCurveNamesAndPlotTitle();
this->connect( m_plotWidget, SIGNAL( plotZoomed() ), SLOT( onPlotZoomed() ) );
}
return m_plotWidget; return m_plotWidget;
} }
@@ -540,9 +552,9 @@ void RimGridCrossPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField
{ {
updateParentLayout(); updateParentLayout();
} }
else else if ( changedField == &m_showInfoBox )
{ {
onLoadDataAndUpdate(); updateLayout();
} }
} }
@@ -604,10 +616,9 @@ void RimGridCrossPlot::updateCurveNamesAndPlotTitle()
if ( m_plotWidget ) if ( m_plotWidget )
{ {
if ( isMdiWindow() ) QString plotTitle = this->createAutoName();
{ m_plotWidget->setPlotTitle( plotTitle );
m_plotWidget->setTitle( this->createAutoName() ); m_plotWidget->setPlotTitleEnabled( isMdiWindow() );
}
} }
updateMdiWindowTitle(); updateMdiWindowTitle();
} }
@@ -790,12 +801,15 @@ void RimGridCrossPlot::doUpdateLayout()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGridCrossPlot::updateLegend() void RimGridCrossPlot::updateLegend()
{ {
if ( m_plotWidget )
{
m_plotWidget->setInternalQwtLegendVisible( legendsVisible() && isMdiWindow() ); m_plotWidget->setInternalQwtLegendVisible( legendsVisible() && isMdiWindow() );
m_plotWidget->setLegendFontSize( legendFontSize() ); m_plotWidget->setLegendFontSize( legendFontSize() );
for ( auto dataSet : m_crossPlotDataSets ) for ( auto dataSet : m_crossPlotDataSets )
{ {
dataSet->updateLegendIcons(); dataSet->updateLegendIcons();
} }
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -54,6 +54,7 @@ private:
class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface
{ {
Q_OBJECT;
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public: public:
@@ -112,7 +113,6 @@ public:
void onAxisSelected( int axis, bool toggle ) override; void onAxisSelected( int axis, bool toggle ) override;
protected: protected:
QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) override;
void deleteViewWidget() override; void deleteViewWidget() override;
void onLoadDataAndUpdate() override; void onLoadDataAndUpdate() override;
void initAfterRead() override; void initAfterRead() override;
@@ -142,12 +142,17 @@ protected:
std::set<RimPlotAxisPropertiesInterface*> allPlotAxes() const; std::set<RimPlotAxisPropertiesInterface*> allPlotAxes() const;
private: private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
void doUpdateLayout() override; void doUpdateLayout() override;
void cleanupBeforeClose(); void cleanupBeforeClose();
void doRemoveFromCollection() override; void doRemoveFromCollection() override;
QString generateInfoBoxText() const; QString generateInfoBoxText() const;
private slots:
void onPlotZoomed();
private: private:
caf::PdmField<bool> m_showInfoBox; caf::PdmField<bool> m_showInfoBox;
caf::PdmField<bool> m_showLegend_OBSOLETE; caf::PdmField<bool> m_showLegend_OBSOLETE;

View File

@@ -72,7 +72,7 @@ void RimGridCrossPlotCurve::setSamples( const std::vector<double>& xValues, cons
{ {
CVF_ASSERT( xValues.size() == yValues.size() ); CVF_ASSERT( xValues.size() == yValues.size() );
if ( xValues.empty() || yValues.empty() ) return; if ( xValues.empty() || yValues.empty() || !m_qwtPlotCurve ) return;
m_qwtPlotCurve->setSamples( &xValues[0], &yValues[0], static_cast<int>( xValues.size() ) ); m_qwtPlotCurve->setSamples( &xValues[0], &yValues[0], static_cast<int>( xValues.size() ) );
} }
@@ -107,6 +107,8 @@ size_t RimGridCrossPlotCurve::sampleCount() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurve::determineLegendIcon() void RimGridCrossPlotCurve::determineLegendIcon()
{ {
if ( !m_qwtPlotCurve ) return;
RimGridCrossPlot* plot = nullptr; RimGridCrossPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot ); firstAncestorOrThisOfTypeAsserted( plot );
int fontSize = plot->legendFontSize(); int fontSize = plot->legendFontSize();
@@ -118,7 +120,10 @@ void RimGridCrossPlotCurve::determineLegendIcon()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurve::setBlackAndWhiteLegendIcons( bool blackAndWhite ) void RimGridCrossPlotCurve::setBlackAndWhiteLegendIcons( bool blackAndWhite )
{ {
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setBlackAndWhiteLegendIcon( blackAndWhite ); m_qwtPlotCurve->setBlackAndWhiteLegendIcon( blackAndWhite );
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -23,6 +23,7 @@
#include "RimFlowPlotCollection.h" #include "RimFlowPlotCollection.h"
#include "RimGridCrossPlot.h" #include "RimGridCrossPlot.h"
#include "RimGridCrossPlotCollection.h" #include "RimGridCrossPlotCollection.h"
#include "RimMultiPlot.h"
#include "RimMultiPlotCollection.h" #include "RimMultiPlotCollection.h"
#include "RimPltPlotCollection.h" #include "RimPltPlotCollection.h"
#include "RimProject.h" #include "RimProject.h"
@@ -262,7 +263,7 @@ void RimMainPlotCollection::updatePlotsWithFormations()
if ( m_multiPlotCollection ) if ( m_multiPlotCollection )
{ {
for ( RimMultiPlotWindow* plotWindow : m_multiPlotCollection->multiPlots() ) for ( RimMultiPlot* plotWindow : m_multiPlotCollection->multiPlots() )
{ {
plotWindow->loadDataAndUpdate(); plotWindow->loadDataAndUpdate();
} }
@@ -284,7 +285,7 @@ void RimMainPlotCollection::updatePlotsWithCompletions()
if ( m_multiPlotCollection ) if ( m_multiPlotCollection )
{ {
for ( RimMultiPlotWindow* plotWindow : m_multiPlotCollection->multiPlots() ) for ( RimMultiPlot* plotWindow : m_multiPlotCollection->multiPlots() )
{ {
plotWindow->loadDataAndUpdate(); plotWindow->loadDataAndUpdate();
} }

View File

@@ -15,11 +15,13 @@
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RiaApplication.h"
#include "RimPlot.h" #include "RimPlot.h"
#include "RimProject.h"
#include "RiuMultiPlotWindow.h" #include "RiuMultiPlotBook.h"
#include "RiuPlotMainWindow.h" #include "RiuPlotMainWindow.h"
#include "RiuPlotMainWindowTools.h" #include "RiuPlotMainWindowTools.h"
@@ -31,48 +33,46 @@
namespace caf namespace caf
{ {
template <> template <>
void RimMultiPlotWindow::ColumnCountEnum::setUp() void RimMultiPlot::ColumnCountEnum::setUp()
{ {
addItem( RimMultiPlotWindow::COLUMNS_1, "1", "1 Column" ); addItem( RimMultiPlot::ColumnCount::COLUMNS_1, "1", "1 Column" );
addItem( RimMultiPlotWindow::COLUMNS_2, "2", "2 Columns" ); addItem( RimMultiPlot::ColumnCount::COLUMNS_2, "2", "2 Columns" );
addItem( RimMultiPlotWindow::COLUMNS_3, "3", "3 Columns" ); addItem( RimMultiPlot::ColumnCount::COLUMNS_3, "3", "3 Columns" );
addItem( RimMultiPlotWindow::COLUMNS_4, "4", "4 Columns" ); addItem( RimMultiPlot::ColumnCount::COLUMNS_4, "4", "4 Columns" );
addItem( RimMultiPlotWindow::COLUMNS_UNLIMITED, "UNLIMITED", "Unlimited" ); addItem( RimMultiPlot::ColumnCount::COLUMNS_UNLIMITED, "UNLIMITED", "Unlimited" );
setDefault( RimMultiPlotWindow::COLUMNS_2 ); setDefault( RimMultiPlot::ColumnCount::COLUMNS_2 );
} }
template <> template <>
void RimMultiPlotWindow::RowCountEnum::setUp() void RimMultiPlot::RowCountEnum::setUp()
{ {
addItem( RimMultiPlotWindow::ROWS_1, "1", "1 Row" ); addItem( RimMultiPlot::ROWS_1, "1", "1 Row" );
addItem( RimMultiPlotWindow::ROWS_2, "2", "2 Rows" ); addItem( RimMultiPlot::ROWS_2, "2", "2 Rows" );
addItem( RimMultiPlotWindow::ROWS_3, "3", "3 Rows" ); addItem( RimMultiPlot::ROWS_3, "3", "3 Rows" );
addItem( RimMultiPlotWindow::ROWS_4, "4", "4 Rows" ); addItem( RimMultiPlot::ROWS_4, "4", "4 Rows" );
setDefault( RimMultiPlotWindow::ROWS_2 ); setDefault( RimMultiPlot::ROWS_2 );
} }
} // namespace caf } // namespace caf
CAF_PDM_SOURCE_INIT( RimMultiPlotWindow, "MultiPlot" ); CAF_PDM_SOURCE_INIT( RimMultiPlot, "MultiPlot" );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimMultiPlotWindow::RimMultiPlotWindow( bool hidePlotsInTreeView ) RimMultiPlot::RimMultiPlot()
: m_acceptDrops( true )
{ {
CAF_PDM_InitObject( "Multi Plot", ":/WellLogPlot16x16.png", "", "" ); CAF_PDM_InitObject( "Multi Plot", ":/WellLogPlot16x16.png", "", "" );
CAF_PDM_InitField( &m_showPlotWindowTitle, "ShowTitleInPlot", true, "Show Title", "", "", "" ); CAF_PDM_InitField( &m_showPlotWindowTitle, "ShowTitleInPlot", true, "Show Title", "", "", "" );
CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name", "", "", "" ); CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_plots, "Tracks", "", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_plots, "Plots", "", "", "", "" );
m_plots.uiCapability()->setUiHidden( true ); m_plots.uiCapability()->setUiHidden( true );
m_plots.uiCapability()->setUiTreeChildrenHidden( hidePlotsInTreeView );
CAF_PDM_InitFieldNoDefault( &m_columnCount, "NumberOfColumns", "Number of Columns", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_columnCount, "NumberOfColumns", "Number of Columns", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_rowsPerPage, "RowsPerPage", "Rows per Page", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_rowsPerPage, "RowsPerPage", "Rows per Page", "", "", "" );
CAF_PDM_InitField( &m_showIndividualPlotTitles, "ShowPlotTitles", false, "Show Sub Plot Titles", "", "", "" ); CAF_PDM_InitField( &m_showIndividualPlotTitles, "ShowPlotTitles", true, "Show Sub Plot Titles", "", "", "" );
m_viewer = nullptr; m_viewer = nullptr;
} }
@@ -80,7 +80,7 @@ RimMultiPlotWindow::RimMultiPlotWindow( bool hidePlotsInTreeView )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimMultiPlotWindow::~RimMultiPlotWindow() RimMultiPlot::~RimMultiPlot()
{ {
removeMdiWindowFromMdiArea(); removeMdiWindowFromMdiArea();
m_plots.deleteAllChildObjects(); m_plots.deleteAllChildObjects();
@@ -91,7 +91,7 @@ RimMultiPlotWindow::~RimMultiPlotWindow()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Move-assignment operator. Argument has to be passed with std::move() /// Move-assignment operator. Argument has to be passed with std::move()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimMultiPlotWindow& RimMultiPlotWindow::operator=( RimMultiPlotWindow&& rhs ) RimMultiPlot& RimMultiPlot::operator=( RimMultiPlot&& rhs )
{ {
RimPlotWindow::operator=( std::move( rhs ) ); RimPlotWindow::operator=( std::move( rhs ) );
@@ -112,15 +112,13 @@ RimMultiPlotWindow& RimMultiPlotWindow::operator=( RimMultiPlotWindow&& rhs )
m_rowsPerPage = rhs.m_rowsPerPage; m_rowsPerPage = rhs.m_rowsPerPage;
m_showIndividualPlotTitles = rhs.m_showIndividualPlotTitles; m_showIndividualPlotTitles = rhs.m_showIndividualPlotTitles;
m_acceptDrops = rhs.m_acceptDrops;
return *this; return *this;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QWidget* RimMultiPlotWindow::viewWidget() QWidget* RimMultiPlot::viewWidget()
{ {
return m_viewer; return m_viewer;
} }
@@ -128,7 +126,7 @@ QWidget* RimMultiPlotWindow::viewWidget()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimMultiPlotWindow::description() const QString RimMultiPlot::description() const
{ {
return multiPlotTitle(); return multiPlotTitle();
} }
@@ -136,7 +134,7 @@ QString RimMultiPlotWindow::description() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimMultiPlotWindow::isMultiPlotTitleVisible() const bool RimMultiPlot::isMultiPlotTitleVisible() const
{ {
return m_showPlotWindowTitle; return m_showPlotWindowTitle;
} }
@@ -144,7 +142,7 @@ bool RimMultiPlotWindow::isMultiPlotTitleVisible() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::setMultiPlotTitleVisible( bool visible ) void RimMultiPlot::setMultiPlotTitleVisible( bool visible )
{ {
m_showPlotWindowTitle = visible; m_showPlotWindowTitle = visible;
} }
@@ -152,7 +150,7 @@ void RimMultiPlotWindow::setMultiPlotTitleVisible( bool visible )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimMultiPlotWindow::multiPlotTitle() const QString RimMultiPlot::multiPlotTitle() const
{ {
return m_plotWindowTitle; return m_plotWindowTitle;
} }
@@ -160,7 +158,7 @@ QString RimMultiPlotWindow::multiPlotTitle() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::setMultiPlotTitle( const QString& title ) void RimMultiPlot::setMultiPlotTitle( const QString& title )
{ {
m_plotWindowTitle = title; m_plotWindowTitle = title;
} }
@@ -168,7 +166,7 @@ void RimMultiPlotWindow::setMultiPlotTitle( const QString& title )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::addPlot( RimPlot* plot ) void RimMultiPlot::addPlot( RimPlot* plot )
{ {
insertPlot( plot, m_plots.size() ); insertPlot( plot, m_plots.size() );
} }
@@ -176,7 +174,7 @@ void RimMultiPlotWindow::addPlot( RimPlot* plot )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::insertPlot( RimPlot* plot, size_t index ) void RimMultiPlot::insertPlot( RimPlot* plot, size_t index )
{ {
if ( plot ) if ( plot )
{ {
@@ -188,7 +186,7 @@ void RimMultiPlotWindow::insertPlot( RimPlot* plot, size_t index )
m_viewer->insertPlot( plot->viewer(), index ); m_viewer->insertPlot( plot->viewer(), index );
} }
plot->setShowWindow( true ); plot->setShowWindow( true );
plot->setLegendsVisible( false ); plot->updateAfterInsertingIntoMultiPlot();
onPlotAdditionOrRemoval(); onPlotAdditionOrRemoval();
} }
@@ -197,7 +195,7 @@ void RimMultiPlotWindow::insertPlot( RimPlot* plot, size_t index )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::removePlot( RimPlot* plot ) void RimMultiPlot::removePlot( RimPlot* plot )
{ {
if ( plot ) if ( plot )
{ {
@@ -214,11 +212,11 @@ void RimMultiPlotWindow::removePlot( RimPlot* plot )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::movePlotsToThis( const std::vector<RimPlot*>& plotsToMove, RimPlot* plotToInsertAfter ) void RimMultiPlot::movePlotsToThis( const std::vector<RimPlot*>& plotsToMove, RimPlot* plotToInsertAfter )
{ {
for ( size_t tIdx = 0; tIdx < plotsToMove.size(); tIdx++ ) for ( size_t tIdx = 0; tIdx < plotsToMove.size(); tIdx++ )
{ {
RimMultiPlotWindow* previousMultiPlotWindow = nullptr; RimMultiPlot* previousMultiPlotWindow = nullptr;
plotsToMove[tIdx]->firstAncestorOrThisOfType( previousMultiPlotWindow ); plotsToMove[tIdx]->firstAncestorOrThisOfType( previousMultiPlotWindow );
if ( previousMultiPlotWindow ) if ( previousMultiPlotWindow )
{ {
@@ -245,7 +243,7 @@ void RimMultiPlotWindow::movePlotsToThis( const std::vector<RimPlot*>& plotsToMo
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
size_t RimMultiPlotWindow::plotCount() const size_t RimMultiPlot::plotCount() const
{ {
return m_plots.size(); return m_plots.size();
} }
@@ -253,7 +251,7 @@ size_t RimMultiPlotWindow::plotCount() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
size_t RimMultiPlotWindow::plotIndex( const RimPlot* plot ) const size_t RimMultiPlot::plotIndex( const RimPlot* plot ) const
{ {
return m_plots.index( plot ); return m_plots.index( plot );
} }
@@ -261,7 +259,7 @@ size_t RimMultiPlotWindow::plotIndex( const RimPlot* plot ) const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimPlot* RimMultiPlotWindow::plotByIndex( size_t index ) const RimPlot* RimMultiPlot::plotByIndex( size_t index ) const
{ {
return m_plots[index]; return m_plots[index];
} }
@@ -269,7 +267,7 @@ RimPlot* RimMultiPlotWindow::plotByIndex( size_t index ) const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RimPlot*> RimMultiPlotWindow::plots() const std::vector<RimPlot*> RimMultiPlot::plots() const
{ {
return m_plots.childObjects(); return m_plots.childObjects();
} }
@@ -277,7 +275,7 @@ std::vector<RimPlot*> RimMultiPlotWindow::plots() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RimPlot*> RimMultiPlotWindow::visiblePlots() const std::vector<RimPlot*> RimMultiPlot::visiblePlots() const
{ {
std::vector<RimPlot*> allVisiblePlots; std::vector<RimPlot*> allVisiblePlots;
for ( RimPlot* plot : m_plots() ) for ( RimPlot* plot : m_plots() )
@@ -293,10 +291,13 @@ std::vector<RimPlot*> RimMultiPlotWindow::visiblePlots() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::doUpdateLayout() void RimMultiPlot::doUpdateLayout()
{ {
if ( m_showWindow && m_viewer ) if ( m_showWindow && m_viewer )
{ {
m_viewer->setPlotTitle( description() );
m_viewer->setTitleVisible( m_showPlotWindowTitle );
m_viewer->setSubTitlesVisible( m_showIndividualPlotTitles );
m_viewer->scheduleUpdate(); m_viewer->scheduleUpdate();
m_viewer->adjustSize(); m_viewer->adjustSize();
} }
@@ -305,28 +306,17 @@ void RimMultiPlotWindow::doUpdateLayout()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Empty default implementation /// Empty default implementation
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::updateSubPlotNames() {} void RimMultiPlot::updateSubPlotNames() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Empty default implementation /// Empty default implementation
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::updatePlotWindowTitle() {} void RimMultiPlot::updatePlotWindowTitle() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::doSetAutoScaleYEnabled( bool enabled ) void RimMultiPlot::doRenderWindowContent( QPaintDevice* paintDevice )
{
for ( RimPlot* plot : plots() )
{
plot->setAutoScaleYEnabled( enabled );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::doRenderWindowContent( QPaintDevice* paintDevice )
{ {
if ( m_viewer ) if ( m_viewer )
{ {
@@ -337,7 +327,7 @@ void RimMultiPlotWindow::doRenderWindowContent( QPaintDevice* paintDevice )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::updatePlotOrderFromGridWidget() void RimMultiPlot::updatePlotOrderFromGridWidget()
{ {
std::sort( m_plots.begin(), m_plots.end(), [this]( RimPlot* lhs, RimPlot* rhs ) { std::sort( m_plots.begin(), m_plots.end(), [this]( RimPlot* lhs, RimPlot* rhs ) {
auto indexLhs = m_viewer->indexOfPlotWidget( lhs->viewer() ); auto indexLhs = m_viewer->indexOfPlotWidget( lhs->viewer() );
@@ -351,7 +341,7 @@ void RimMultiPlotWindow::updatePlotOrderFromGridWidget()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::setAutoScaleXEnabled( bool enabled ) void RimMultiPlot::setAutoScaleXEnabled( bool enabled )
{ {
for ( RimPlot* plot : plots() ) for ( RimPlot* plot : plots() )
{ {
@@ -362,27 +352,30 @@ void RimMultiPlotWindow::setAutoScaleXEnabled( bool enabled )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::setAutoScaleYEnabled( bool enabled ) void RimMultiPlot::setAutoScaleYEnabled( bool enabled )
{ {
doSetAutoScaleYEnabled( enabled ); for ( RimPlot* plot : plots() )
{
plot->setAutoScaleYEnabled( enabled );
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int RimMultiPlotWindow::columnCount() const int RimMultiPlot::columnCount() const
{ {
if ( m_columnCount() == COLUMNS_UNLIMITED ) if ( m_columnCount() == ColumnCount::COLUMNS_UNLIMITED )
{ {
return std::numeric_limits<int>::max(); return std::numeric_limits<int>::max();
} }
return static_cast<int>( m_columnCount() ); return static_cast<int>( m_columnCount().value() );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int RimMultiPlotWindow::rowsPerPage() const int RimMultiPlot::rowsPerPage() const
{ {
return static_cast<int>( m_rowsPerPage() ); return static_cast<int>( m_rowsPerPage() );
} }
@@ -390,7 +383,7 @@ int RimMultiPlotWindow::rowsPerPage() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimMultiPlotWindow::columnCountField() caf::PdmFieldHandle* RimMultiPlot::columnCountField()
{ {
return &m_columnCount; return &m_columnCount;
} }
@@ -398,7 +391,7 @@ caf::PdmFieldHandle* RimMultiPlotWindow::columnCountField()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimMultiPlotWindow::rowsPerPageField() caf::PdmFieldHandle* RimMultiPlot::rowsPerPageField()
{ {
return &m_rowsPerPage; return &m_rowsPerPage;
} }
@@ -406,7 +399,7 @@ caf::PdmFieldHandle* RimMultiPlotWindow::rowsPerPageField()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimMultiPlotWindow::showPlotTitles() const bool RimMultiPlot::showPlotTitles() const
{ {
return m_showIndividualPlotTitles; return m_showIndividualPlotTitles;
} }
@@ -414,7 +407,7 @@ bool RimMultiPlotWindow::showPlotTitles() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::zoomAll() void RimMultiPlot::zoomAll()
{ {
setAutoScaleXEnabled( true ); setAutoScaleXEnabled( true );
setAutoScaleYEnabled( true ); setAutoScaleYEnabled( true );
@@ -424,7 +417,7 @@ void RimMultiPlotWindow::zoomAll()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimMultiPlotWindow::asciiDataForPlotExport() const QString RimMultiPlot::asciiDataForPlotExport() const
{ {
QString out = multiPlotTitle() + "\n"; QString out = multiPlotTitle() + "\n";
@@ -442,7 +435,7 @@ QString RimMultiPlotWindow::asciiDataForPlotExport() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::onPlotAdditionOrRemoval() void RimMultiPlot::onPlotAdditionOrRemoval()
{ {
updateSubPlotNames(); updateSubPlotNames();
updatePlotWindowTitle(); updatePlotWindowTitle();
@@ -455,23 +448,7 @@ void RimMultiPlotWindow::onPlotAdditionOrRemoval()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::setAcceptDrops( bool acceptDrops ) bool RimMultiPlot::previewModeEnabled() const
{
m_acceptDrops = acceptDrops;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimMultiPlotWindow::acceptDrops() const
{
return m_acceptDrops;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimMultiPlotWindow::previewModeEnabled() const
{ {
if ( m_viewer ) if ( m_viewer )
{ {
@@ -483,7 +460,7 @@ bool RimMultiPlotWindow::previewModeEnabled() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QImage RimMultiPlotWindow::snapshotWindowContent() QImage RimMultiPlot::snapshotWindowContent()
{ {
QImage image; QImage image;
@@ -500,20 +477,21 @@ QImage RimMultiPlotWindow::snapshotWindowContent()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QWidget* RimMultiPlotWindow::createViewWidget( QWidget* mainWindowParent ) QWidget* RimMultiPlot::createViewWidget( QWidget* mainWindowParent )
{ {
if ( m_viewer.isNull() ) if ( m_viewer.isNull() )
{ {
m_viewer = new RiuMultiPlotWindow( this, mainWindowParent ); m_viewer = new RiuMultiPlotBook( this, mainWindowParent );
} }
recreatePlotWidgets(); recreatePlotWidgets();
return m_viewer; return m_viewer;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::deleteViewWidget() void RimMultiPlot::deleteViewWidget()
{ {
cleanupBeforeClose(); cleanupBeforeClose();
} }
@@ -521,7 +499,7 @@ void RimMultiPlotWindow::deleteViewWidget()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimMultiPlotWindow::userDescriptionField() caf::PdmFieldHandle* RimMultiPlot::userDescriptionField()
{ {
return &m_plotWindowTitle; return &m_plotWindowTitle;
} }
@@ -529,7 +507,7 @@ caf::PdmFieldHandle* RimMultiPlotWindow::userDescriptionField()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::fieldChangedByUi( const caf::PdmFieldHandle* changedField, void RimMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) const QVariant& newValue )
{ {
@@ -555,7 +533,7 @@ void RimMultiPlotWindow::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) void RimMultiPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{ {
caf::PdmUiGroup* titleAndLegendsGroup = uiOrdering.addNewGroup( "Plot Layout" ); caf::PdmUiGroup* titleAndLegendsGroup = uiOrdering.addNewGroup( "Plot Layout" );
uiOrderingForMultiPlotLayout( uiConfigName, *titleAndLegendsGroup ); uiOrderingForMultiPlotLayout( uiConfigName, *titleAndLegendsGroup );
@@ -564,7 +542,7 @@ void RimMultiPlotWindow::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::uiOrderingForMultiPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) void RimMultiPlot::uiOrderingForMultiPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{ {
uiOrdering.add( &m_showPlotWindowTitle ); uiOrdering.add( &m_showPlotWindowTitle );
uiOrdering.add( &m_plotWindowTitle ); uiOrdering.add( &m_plotWindowTitle );
@@ -577,7 +555,7 @@ void RimMultiPlotWindow::uiOrderingForMultiPlotLayout( QString uiConfigName, caf
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimMultiPlotWindow::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, QList<caf::PdmOptionItemInfo> RimMultiPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) bool* useOptionsOnly )
{ {
QList<caf::PdmOptionItemInfo> options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); QList<caf::PdmOptionItemInfo> options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
@@ -587,7 +565,7 @@ QList<caf::PdmOptionItemInfo> RimMultiPlotWindow::calculateValueOptions( const c
for ( size_t i = 0; i < ColumnCountEnum::size(); ++i ) for ( size_t i = 0; i < ColumnCountEnum::size(); ++i )
{ {
ColumnCount enumVal = ColumnCountEnum::fromIndex( i ); ColumnCount enumVal = ColumnCountEnum::fromIndex( i );
if ( enumVal == COLUMNS_UNLIMITED ) if ( enumVal == ColumnCount::COLUMNS_UNLIMITED )
{ {
QString iconPath( ":/ColumnsUnlimited.png" ); QString iconPath( ":/ColumnsUnlimited.png" );
options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ), options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ),
@@ -611,7 +589,7 @@ QList<caf::PdmOptionItemInfo> RimMultiPlotWindow::calculateValueOptions( const c
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::onLoadDataAndUpdate() void RimMultiPlot::onLoadDataAndUpdate()
{ {
updateMdiWindowVisibility(); updateMdiWindowVisibility();
updatePlotWindowTitle(); updatePlotWindowTitle();
@@ -623,7 +601,7 @@ void RimMultiPlotWindow::onLoadDataAndUpdate()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::initAfterRead() void RimMultiPlot::initAfterRead()
{ {
RimPlotWindow::initAfterRead(); RimPlotWindow::initAfterRead();
} }
@@ -631,7 +609,7 @@ void RimMultiPlotWindow::initAfterRead()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::applyPlotWindowTitleToWidgets() void RimMultiPlot::applyPlotWindowTitleToWidgets()
{ {
if ( m_viewer ) if ( m_viewer )
{ {
@@ -644,7 +622,7 @@ void RimMultiPlotWindow::applyPlotWindowTitleToWidgets()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::updatePlots() void RimMultiPlot::updatePlots()
{ {
if ( m_showWindow ) if ( m_showWindow )
{ {
@@ -659,7 +637,7 @@ void RimMultiPlotWindow::updatePlots()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::updateZoom() void RimMultiPlot::updateZoom()
{ {
for ( RimPlot* plot : plots() ) for ( RimPlot* plot : plots() )
{ {
@@ -670,7 +648,7 @@ void RimMultiPlotWindow::updateZoom()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::recreatePlotWidgets() void RimMultiPlot::recreatePlotWidgets()
{ {
CVF_ASSERT( m_viewer ); CVF_ASSERT( m_viewer );
@@ -686,7 +664,7 @@ void RimMultiPlotWindow::recreatePlotWidgets()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimMultiPlotWindow::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const bool RimMultiPlot::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
{ {
if ( fontSettingType == RiaDefines::PLOT_FONT && m_viewer ) if ( fontSettingType == RiaDefines::PLOT_FONT && m_viewer )
{ {
@@ -712,7 +690,7 @@ bool RimMultiPlotWindow::hasCustomFontSizes( RiaDefines::FontSettingType fontSet
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimMultiPlotWindow::applyFontSize( RiaDefines::FontSettingType fontSettingType, bool RimMultiPlot::applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize, int oldFontSize,
int fontSize, int fontSize,
bool forceChange /*= false */ ) bool forceChange /*= false */ )
@@ -750,7 +728,7 @@ bool RimMultiPlotWindow::applyFontSize( RiaDefines::FontSettingType fontSettingT
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotWindow::cleanupBeforeClose() void RimMultiPlot::cleanupBeforeClose()
{ {
auto plotVector = plots(); auto plotVector = plots();
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx ) for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )

View File

@@ -18,7 +18,7 @@
#pragma once #pragma once
#include "RimPlotWindow.h" #include "RimPlotWindow.h"
#include "RiuMultiPlotInterface.h" #include "RiuMultiPlotBook.h"
#include "cafAppEnum.h" #include "cafAppEnum.h"
#include "cafPdmChildArrayField.h" #include "cafPdmChildArrayField.h"
@@ -34,19 +34,12 @@
class RimPlot; class RimPlot;
class RimMultiPlotWindow : public RimPlotWindow class RimMultiPlot : public RimPlotWindow
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public: public:
enum ColumnCount using ColumnCount = RiuMultiPlotBook::ColumnCount;
{
COLUMNS_1 = 1,
COLUMNS_2 = 2,
COLUMNS_3 = 3,
COLUMNS_4 = 4,
COLUMNS_UNLIMITED = 1000,
};
using ColumnCountEnum = caf::AppEnum<ColumnCount>; using ColumnCountEnum = caf::AppEnum<ColumnCount>;
enum RowCount enum RowCount
@@ -59,10 +52,10 @@ public:
using RowCountEnum = caf::AppEnum<RowCount>; using RowCountEnum = caf::AppEnum<RowCount>;
public: public:
RimMultiPlotWindow( bool hidePlotsInTreeView = false ); RimMultiPlot();
~RimMultiPlotWindow() override; ~RimMultiPlot() override;
RimMultiPlotWindow& operator=( RimMultiPlotWindow&& rhs ); RimMultiPlot& operator=( RimMultiPlot&& rhs );
QWidget* viewWidget() override; QWidget* viewWidget() override;
@@ -90,7 +83,7 @@ public:
void setAutoScaleXEnabled( bool enabled ); void setAutoScaleXEnabled( bool enabled );
void setAutoScaleYEnabled( bool enabled ); void setAutoScaleYEnabled( bool enabled );
int columnCount() const; int columnCount() const override;
int rowsPerPage() const; int rowsPerPage() const;
caf::PdmFieldHandle* columnCountField(); caf::PdmFieldHandle* columnCountField();
caf::PdmFieldHandle* rowsPerPageField(); caf::PdmFieldHandle* rowsPerPageField();
@@ -99,9 +92,6 @@ public:
void zoomAll() override; void zoomAll() override;
QString asciiDataForPlotExport() const; QString asciiDataForPlotExport() const;
virtual void onPlotAdditionOrRemoval();
void setAcceptDrops( bool acceptDrops );
bool acceptDrops() const;
bool previewModeEnabled() const; bool previewModeEnabled() const;
@@ -127,7 +117,7 @@ protected:
void applyPlotWindowTitleToWidgets(); void applyPlotWindowTitleToWidgets();
void updatePlots(); void updatePlots();
virtual void updateZoom(); void updateZoom();
void recreatePlotWidgets(); void recreatePlotWidgets();
bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override; bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override;
@@ -139,10 +129,10 @@ protected:
private: private:
void cleanupBeforeClose(); void cleanupBeforeClose();
void doUpdateLayout() override; void doUpdateLayout() override;
virtual void updateSubPlotNames(); void updateSubPlotNames();
virtual void updatePlotWindowTitle(); void updatePlotWindowTitle();
virtual void doSetAutoScaleYEnabled( bool enabled );
void doRenderWindowContent( QPaintDevice* paintDevice ) override; void doRenderWindowContent( QPaintDevice* paintDevice ) override;
void onPlotAdditionOrRemoval();
protected: protected:
caf::PdmField<bool> m_showPlotWindowTitle; caf::PdmField<bool> m_showPlotWindowTitle;
@@ -151,11 +141,9 @@ protected:
caf::PdmField<RowCountEnum> m_rowsPerPage; caf::PdmField<RowCountEnum> m_rowsPerPage;
caf::PdmField<bool> m_showIndividualPlotTitles; caf::PdmField<bool> m_showIndividualPlotTitles;
friend class RiuMultiPlotInterface; friend class RiuMultiPlotBook;
QPointer<RiuMultiPlotInterface> m_viewer; QPointer<RiuMultiPlotBook> m_viewer;
private: private:
caf::PdmChildArrayField<RimPlot*> m_plots; caf::PdmChildArrayField<RimPlot*> m_plots;
bool m_acceptDrops;
}; };

View File

@@ -18,7 +18,7 @@
#include "RimMultiPlotCollection.h" #include "RimMultiPlotCollection.h"
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimProject.h" #include "RimProject.h"
CAF_PDM_SOURCE_INIT( RimMultiPlotCollection, "RimMultiPlotCollection" ); CAF_PDM_SOURCE_INIT( RimMultiPlotCollection, "RimMultiPlotCollection" );
@@ -50,7 +50,7 @@ void RimMultiPlotCollection::deleteAllChildObjects()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RimMultiPlotWindow*> RimMultiPlotCollection::multiPlots() const std::vector<RimMultiPlot*> RimMultiPlotCollection::multiPlots() const
{ {
return m_multiPlots.childObjects(); return m_multiPlots.childObjects();
} }
@@ -58,9 +58,9 @@ std::vector<RimMultiPlotWindow*> RimMultiPlotCollection::multiPlots() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimMultiPlotWindow* RimMultiPlotCollection::createMultiPlot() RimMultiPlot* RimMultiPlotCollection::createMultiPlot()
{ {
RimMultiPlotWindow* plot = new RimMultiPlotWindow(); RimMultiPlot* plot = new RimMultiPlot();
plot->setAsPlotMdiWindow(); plot->setAsPlotMdiWindow();
addMultiPlot( plot ); addMultiPlot( plot );
@@ -70,7 +70,7 @@ RimMultiPlotWindow* RimMultiPlotCollection::createMultiPlot()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimMultiPlotCollection::addMultiPlot( RimMultiPlotWindow* plot ) void RimMultiPlotCollection::addMultiPlot( RimMultiPlot* plot )
{ {
m_multiPlots().push_back( plot ); m_multiPlots().push_back( plot );
} }

View File

@@ -20,7 +20,7 @@
#include "cafPdmChildArrayField.h" #include "cafPdmChildArrayField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
class RimMultiPlotWindow; class RimMultiPlot;
//================================================================================================== //==================================================================================================
/// ///
@@ -36,10 +36,10 @@ public:
void deleteAllChildObjects(); void deleteAllChildObjects();
std::vector<RimMultiPlotWindow*> multiPlots() const; std::vector<RimMultiPlot*> multiPlots() const;
RimMultiPlotWindow* createMultiPlot(); RimMultiPlot* createMultiPlot();
void addMultiPlot( RimMultiPlotWindow* plot ); void addMultiPlot( RimMultiPlot* plot );
private: private:
caf::PdmChildArrayField<RimMultiPlotWindow*> m_multiPlots; caf::PdmChildArrayField<RimMultiPlot*> m_multiPlots;
}; };

View File

@@ -1,8 +1,10 @@
#include "RimPlot.h" #include "RimPlot.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimPlotCurve.h"
#include "RimPlotWindow.h" #include "RimPlotWindow.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtPlotWidget.h" #include "RiuQwtPlotWidget.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
@@ -43,9 +45,24 @@ RimPlot::~RimPlot() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPlot::createPlotWidget() QWidget* RimPlot::createViewWidget( QWidget* parent /*= nullptr */ )
{ {
createViewWidget( nullptr ); RiuQwtPlotWidget* plotWidget = doCreatePlotViewWidget( parent );
RimPlot::attachPlotWidgetSignals( this, plotWidget );
updateWindowVisibility();
plotWidget->scheduleReplot();
return plotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimPlot::createPlotWidget( QWidget* parent )
{
return createViewWidget( parent );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -70,6 +87,7 @@ RimPlot::RowOrColSpan RimPlot::colSpan() const
void RimPlot::setRowSpan( RowOrColSpan rowSpan ) void RimPlot::setRowSpan( RowOrColSpan rowSpan )
{ {
m_rowSpan = rowSpan; m_rowSpan = rowSpan;
updateParentLayout();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -78,6 +96,7 @@ void RimPlot::setRowSpan( RowOrColSpan rowSpan )
void RimPlot::setColSpan( RowOrColSpan colSpan ) void RimPlot::setColSpan( RowOrColSpan colSpan )
{ {
m_colSpan = colSpan; m_colSpan = colSpan;
updateParentLayout();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -99,6 +118,7 @@ void RimPlot::updateAfterInsertingIntoMultiPlot()
{ {
updateLegend(); updateLegend();
updateAxes(); updateAxes();
updateLayout();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -118,10 +138,32 @@ void RimPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrde
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) void RimPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{ {
if ( changedField == &m_colSpan || changedField == &m_rowSpan ) RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_showWindow )
{ {
updateParentLayout(); updateParentLayout();
} }
else if ( changedField == &m_colSpan || changedField == &m_rowSpan )
{
updateParentLayout();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::attachPlotWidgetSignals( RimPlot* plot, RiuQwtPlotWidget* plotWidget )
{
CAF_ASSERT( plot && plotWidget );
plot->connect( plotWidget, SIGNAL( plotSelected( bool ) ), SLOT( onPlotSelected( bool ) ) );
plot->connect( plotWidget, SIGNAL( axisSelected( int, bool ) ), SLOT( onAxisSelected( int, bool ) ) );
plot->connect( plotWidget,
SIGNAL( curveSelected( QwtPlotCurve*, bool ) ),
SLOT( onCurveSelected( QwtPlotCurve*, bool ) ) );
plot->connect( plotWidget, SIGNAL( onKeyPressEvent( QKeyEvent* ) ), SLOT( onKeyPressEvent( QKeyEvent* ) ) );
plot->connect( plotWidget, SIGNAL( onWheelEvent( QWheelEvent* ) ), SLOT( onWheelEvent( QWheelEvent* ) ) );
plot->connect( plotWidget, SIGNAL( destroyed() ), SLOT( onViewerDestroyed() ) );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -134,3 +176,63 @@ void RimPlot::doRenderWindowContent( QPaintDevice* paintDevice )
viewer()->renderTo( paintDevice, viewer()->frameGeometry() ); viewer()->renderTo( paintDevice, viewer()->frameGeometry() );
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::onPlotSelected( bool toggle )
{
if ( toggle )
{
RiuPlotMainWindowTools::toggleItemInSelection( this );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( this );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::onCurveSelected( QwtPlotCurve* curve, bool toggle )
{
RimPlotCurve* selectedCurve = dynamic_cast<RimPlotCurve*>( this->findPdmObjectFromQwtCurve( curve ) );
if ( selectedCurve )
{
if ( toggle )
{
RiuPlotMainWindowTools::toggleItemInSelection( selectedCurve );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( selectedCurve );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::onViewerDestroyed()
{
m_showWindow = false;
updateConnectedEditors();
updateUiIconFromToggleField();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::onKeyPressEvent( QKeyEvent* event )
{
handleKeyPressEvent( event );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlot::onWheelEvent( QWheelEvent* event )
{
handleWheelEvent( event );
}

View File

@@ -26,6 +26,7 @@
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include <QObject>
#include <QPointer> #include <QPointer>
class RiuQwtPlotWidget; class RiuQwtPlotWidget;
@@ -33,13 +34,15 @@ class RimPlotCurve;
class QwtPlotCurve; class QwtPlotCurve;
class QPaintDevice; class QPaintDevice;
class QWheelEvent;
//================================================================================================== //==================================================================================================
/// ///
/// ///
//================================================================================================== //==================================================================================================
class RimPlot : public RimPlotWindow class RimPlot : public QObject, public RimPlotWindow
{ {
Q_OBJECT;
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public: public:
@@ -58,8 +61,7 @@ public:
RimPlot(); RimPlot();
virtual ~RimPlot(); virtual ~RimPlot();
// Real implementations QWidget* createPlotWidget( QWidget* parent = nullptr );
void createPlotWidget();
RowOrColSpan rowSpan() const; RowOrColSpan rowSpan() const;
RowOrColSpan colSpan() const; RowOrColSpan colSpan() const;
void setRowSpan( RowOrColSpan rowSpan ); void setRowSpan( RowOrColSpan rowSpan );
@@ -82,20 +84,31 @@ public:
virtual void reattachAllCurves() = 0; virtual void reattachAllCurves() = 0;
virtual void detachAllCurves() = 0; virtual void detachAllCurves() = 0;
virtual caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const = 0; virtual caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const = 0;
virtual void onAxisSelected( int axis, bool toggle ) = 0;
protected: protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) override; const QVariant& newValue ) override;
static void attachPlotWidgetSignals( RimPlot* plot, RiuQwtPlotWidget* plotWidget );
QWidget* createViewWidget( QWidget* parent = nullptr ) final;
private: private:
virtual void doRemoveFromCollection() = 0; virtual void doRemoveFromCollection() = 0;
virtual void doRenderWindowContent( QPaintDevice* paintDevice ); virtual void doRenderWindowContent( QPaintDevice* paintDevice );
virtual void handleKeyPressEvent( QKeyEvent* event ) {}
virtual void handleWheelEvent( QWheelEvent* event ) {}
virtual RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* parent ) = 0;
private slots:
void onPlotSelected( bool toggle );
virtual void onAxisSelected( int axis, bool toggle ) = 0;
void onCurveSelected( QwtPlotCurve* curve, bool toggle );
void onViewerDestroyed();
void onKeyPressEvent( QKeyEvent* event );
void onWheelEvent( QWheelEvent* event );
protected: protected:
caf::PdmField<RowOrColSpanEnum> m_rowSpan; caf::PdmField<RowOrColSpanEnum> m_rowSpan;

View File

@@ -430,6 +430,8 @@ void RimPlotCurve::updateCurveName()
m_curveName = m_customCurveName; m_curveName = m_customCurveName;
} }
if ( m_qwtPlotCurve )
{
if ( !m_legendEntryText().isEmpty() ) if ( !m_legendEntryText().isEmpty() )
{ {
m_qwtPlotCurve->setTitle( m_legendEntryText ); m_qwtPlotCurve->setTitle( m_legendEntryText );
@@ -438,6 +440,7 @@ void RimPlotCurve::updateCurveName()
{ {
m_qwtPlotCurve->setTitle( m_curveName ); m_qwtPlotCurve->setTitle( m_curveName );
} }
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -559,6 +562,45 @@ void RimPlotCurve::setSamplesFromXYErrorValues(
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromXYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( xValues, yValues, keepOnlyPositiveValues );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setSamplesFromDatesAndYValues( dateTimes, yValues, keepOnlyPositiveValues );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( dateTimes, yValues, keepOnlyPositiveValues );
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -591,7 +633,7 @@ void RimPlotCurve::curveNameUiOrdering( caf::PdmUiOrdering& uiOrdering )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateUiIconFromPlotSymbol() void RimPlotCurve::updateUiIconFromPlotSymbol()
{ {
if ( m_pointSymbol() != RiuQwtSymbol::NoSymbol ) if ( m_pointSymbol() != RiuQwtSymbol::NoSymbol && m_qwtPlotCurve )
{ {
CVF_ASSERT( RiaGuiApplication::isRunning() ); CVF_ASSERT( RiaGuiApplication::isRunning() );
QColor curveColor( m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte() ); QColor curveColor( m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte() );
@@ -651,8 +693,6 @@ void RimPlotCurve::attachCurveAndErrorBars()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateCurveAppearance() void RimPlotCurve::updateCurveAppearance()
{ {
CVF_ASSERT( m_qwtPlotCurve );
QColor curveColor( m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte() ); QColor curveColor( m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte() );
QwtSymbol* symbol = nullptr; QwtSymbol* symbol = nullptr;
@@ -681,16 +721,20 @@ void RimPlotCurve::updateCurveAppearance()
symbol->setPen( curveColor ); symbol->setPen( curveColor );
} }
} }
m_qwtPlotCurve->setAppearance( m_lineStyle(), m_curveInterpolation(), m_curveThickness(), curveColor );
m_qwtPlotCurve->setSymbol( symbol );
m_qwtPlotCurve->setSymbolSkipPixelDistance( m_symbolSkipPixelDistance() );
if ( m_qwtCurveErrorBars )
{ {
QwtIntervalSymbol* newSymbol = new QwtIntervalSymbol( QwtIntervalSymbol::Bar ); QwtIntervalSymbol* newSymbol = new QwtIntervalSymbol( QwtIntervalSymbol::Bar );
newSymbol->setPen( QPen( curveColor ) ); newSymbol->setPen( QPen( curveColor ) );
m_qwtCurveErrorBars->setSymbol( newSymbol ); m_qwtCurveErrorBars->setSymbol( newSymbol );
} }
if ( m_qwtPlotCurve )
{
m_qwtPlotCurve->setAppearance( m_lineStyle(), m_curveInterpolation(), m_curveThickness(), curveColor );
m_qwtPlotCurve->setSymbol( symbol );
m_qwtPlotCurve->setSymbolSkipPixelDistance( m_symbolSkipPixelDistance() );
// Make sure the legend lines are long enough to distinguish between line types. // Make sure the legend lines are long enough to distinguish between line types.
// Standard width in Qwt is 8 which is too short. // Standard width in Qwt is 8 which is too short.
// Use 10 and scale this by curve thickness + add space for displaying symbol. // Use 10 and scale this by curve thickness + add space for displaying symbol.
@@ -709,6 +753,7 @@ void RimPlotCurve::updateCurveAppearance()
legendIconSize.setWidth( width ); legendIconSize.setWidth( width );
m_qwtPlotCurve->setLegendIconSize( legendIconSize ); m_qwtPlotCurve->setLegendIconSize( legendIconSize );
} }
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -923,6 +968,8 @@ void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate()
{ {
if ( !m_qwtPlotCurve ) return;
RimEnsembleCurveSet* ensembleCurveSet = nullptr; RimEnsembleCurveSet* ensembleCurveSet = nullptr;
this->firstAncestorOrThisOfType( ensembleCurveSet ); this->firstAncestorOrThisOfType( ensembleCurveSet );
if ( ensembleCurveSet ) if ( ensembleCurveSet )

View File

@@ -128,6 +128,16 @@ protected:
const std::vector<double>& errorValues, const std::vector<double>& errorValues,
bool keepOnlyPositiveValues, bool keepOnlyPositiveValues,
RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ERROR_ALONG_Y_AXIS ); RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ERROR_ALONG_Y_AXIS );
void setSamplesFromXYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
void setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
void setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
protected: protected:
// Overridden PDM methods // Overridden PDM methods

View File

@@ -24,6 +24,7 @@
#include "RicfCommandObject.h" #include "RicfCommandObject.h"
#include "RimProject.h" #include "RimProject.h"
#include "RiuMultiPlotPage.h"
#include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiComboBoxEditor.h"
@@ -155,6 +156,14 @@ void RimPlotWindow::updateParentLayout()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimPlotWindow::columnCount() const
{
return static_cast<int>( RiuMultiPlotPage::ColumnCount::COLUMNS_UNLIMITED );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -186,6 +195,11 @@ void RimPlotWindow::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
{ {
RimViewWindow::fieldChangedByUi( changedField, oldValue, newValue ); RimViewWindow::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_showWindow )
{
updateWindowVisibility();
}
if ( changedField == &m_showPlotLegends || changedField == &m_plotLegendsHorizontal ) if ( changedField == &m_showPlotLegends || changedField == &m_plotLegendsHorizontal )
{ {
updateLayout(); updateLayout();
@@ -250,6 +264,21 @@ bool RimPlotWindow::hasCustomPageLayout( QPageLayout* customPageLayout ) const
return false; return false;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotWindow::updateWindowVisibility()
{
if ( isMdiWindow() )
{
updateMdiWindowVisibility();
}
else
{
updateParentLayout();
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -26,7 +26,9 @@
#include <QPageLayout> #include <QPageLayout>
class RimPlot;
class RimProject; class RimProject;
class RiuQwtPlotWidget;
class QwtPlotCurve; class QwtPlotCurve;
class QKeyEvent; class QKeyEvent;
@@ -49,7 +51,6 @@ public:
RimPlotWindow& operator=( RimPlotWindow&& rhs ); RimPlotWindow& operator=( RimPlotWindow&& rhs );
virtual QString description() const = 0; virtual QString description() const = 0;
bool legendsVisible() const; bool legendsVisible() const;
void setLegendsVisible( bool doShow ); void setLegendsVisible( bool doShow );
bool legendsHorizontal() const; bool legendsHorizontal() const;
@@ -60,6 +61,8 @@ public:
void updateLayout(); void updateLayout();
void updateParentLayout(); void updateParentLayout();
virtual int columnCount() const;
void renderWindowContent( QPaintDevice* painter ); void renderWindowContent( QPaintDevice* painter );
QPageLayout pageLayout() const; QPageLayout pageLayout() const;
@@ -72,6 +75,7 @@ protected:
bool* useOptionsOnly ) override; bool* useOptionsOnly ) override;
void uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); void uiOrderingForPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
void updateWindowVisibility();
private: private:
virtual void doUpdateLayout() {} virtual void doUpdateLayout() {}

View File

@@ -1357,7 +1357,8 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
itemCollection->add( mainPlotCollection->saturationPressurePlotCollection() ); itemCollection->add( mainPlotCollection->saturationPressurePlotCollection() );
} }
if ( mainPlotCollection->multiPlotCollection() ) if ( mainPlotCollection->multiPlotCollection() &&
!mainPlotCollection->multiPlotCollection()->multiPlots().empty() )
{ {
itemCollection->add( mainPlotCollection->multiPlotCollection() ); itemCollection->add( mainPlotCollection->multiPlotCollection() );
} }

View File

@@ -35,6 +35,7 @@
#include "RimGridCrossPlot.h" #include "RimGridCrossPlot.h"
#include "RimGridCrossPlotCollection.h" #include "RimGridCrossPlotCollection.h"
#include "RimMainPlotCollection.h" #include "RimMainPlotCollection.h"
#include "RimMultiPlot.h"
#include "RimMultiPlotCollection.h" #include "RimMultiPlotCollection.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimSummaryCaseMainCollection.h" #include "RimSummaryCaseMainCollection.h"
@@ -182,7 +183,7 @@ void RimReloadCaseTools::updateAllPlots()
RimMultiPlotCollection* multiPlotCollection = project->mainPlotCollection()->multiPlotCollection(); RimMultiPlotCollection* multiPlotCollection = project->mainPlotCollection()->multiPlotCollection();
if ( multiPlotCollection ) if ( multiPlotCollection )
{ {
for ( RimMultiPlotWindow* plotWindow : multiPlotCollection->multiPlots() ) for ( RimMultiPlot* plotWindow : multiPlotCollection->multiPlots() )
{ {
plotWindow->loadDataAndUpdate(); plotWindow->loadDataAndUpdate();
} }

View File

@@ -176,7 +176,7 @@ void RimWellLogCurve::updateZoomInParentPlot()
&maxCurveDepth ); &maxCurveDepth );
if ( minCurveDepth < minPlotDepth - eps * plotRange || maxCurveDepth > maxPlotDepth + eps * plotRange ) if ( minCurveDepth < minPlotDepth - eps * plotRange || maxCurveDepth > maxPlotDepth + eps * plotRange )
{ {
wellLogPlot->setAutoScaleYEnabled( true ); wellLogPlot->setAutoScaleDepthEnabled( true );
wellLogPlot->updateZoom(); wellLogPlot->updateZoom();
} }
} }

View File

@@ -82,6 +82,11 @@ RimWellLogPlot::RimWellLogPlot()
m_commonDataSource.xmlCapability()->disableIO(); m_commonDataSource.xmlCapability()->disableIO();
m_commonDataSource = new RimWellLogCurveCommonDataSource; m_commonDataSource = new RimWellLogCurveCommonDataSource;
CAF_PDM_InitField( &m_showPlotWindowTitle, "ShowTitleInPlot", true, "Show Title", "", "", "" );
CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name", "", "", "" );
m_plotWindowTitle.xmlCapability()->setIOWritable( false );
caf::AppEnum<RimWellLogPlot::DepthTypeEnum> depthType = RiaDefines::MEASURED_DEPTH; caf::AppEnum<RimWellLogPlot::DepthTypeEnum> depthType = RiaDefines::MEASURED_DEPTH;
CAF_PDM_InitField( &m_depthType, "DepthType", depthType, "Type", "", "", "" ); CAF_PDM_InitField( &m_depthType, "DepthType", depthType, "Type", "", "", "" );
@@ -102,6 +107,9 @@ RimWellLogPlot::RimWellLogPlot()
m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true ); m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true );
m_nameConfig = new RimWellLogPlotNameConfig(); m_nameConfig = new RimWellLogPlotNameConfig();
CAF_PDM_InitFieldNoDefault( &m_plots, "Tracks", "", "", "", "" );
m_plots.uiCapability()->setUiHidden( true );
m_availableDepthUnits = {RiaDefines::UNIT_METER, RiaDefines::UNIT_FEET}; m_availableDepthUnits = {RiaDefines::UNIT_METER, RiaDefines::UNIT_FEET};
m_availableDepthTypes = {RiaDefines::MEASURED_DEPTH, m_availableDepthTypes = {RiaDefines::MEASURED_DEPTH,
RiaDefines::TRUE_VERTICAL_DEPTH, RiaDefines::TRUE_VERTICAL_DEPTH,
@@ -111,11 +119,9 @@ RimWellLogPlot::RimWellLogPlot()
m_maxAvailableDepth = -HUGE_VAL; m_maxAvailableDepth = -HUGE_VAL;
m_commonDataSourceEnabled = true; m_commonDataSourceEnabled = true;
m_columnCount = RimMultiPlotWindow::COLUMNS_UNLIMITED;
m_plotWindowTitle.xmlCapability()->setIOWritable( false );
m_plotLegendsHorizontal = false; m_plotLegendsHorizontal = false;
setMultiPlotTitleVisible( false ); setPlotTitleVisible( false );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -123,7 +129,21 @@ RimWellLogPlot::RimWellLogPlot()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellLogPlot& RimWellLogPlot::operator=( RimWellLogPlot&& rhs ) RimWellLogPlot& RimWellLogPlot::operator=( RimWellLogPlot&& rhs )
{ {
RimMultiPlotWindow::operator=( std::move( rhs ) ); RimPlotWindow::operator=( std::move( rhs ) );
// Move all tracks
std::vector<RimPlot*> plots = rhs.m_plots.childObjects();
rhs.m_plots.clear();
for ( RimPlot* plot : plots )
{
m_plots.push_back( plot );
}
// Deliberately don't set m_plotWindowTitle. This operator is used for copying parameters from children.
// This only happens for some plots that used to own a plot but now inherits the plot.
// These all had their own description at top level which we don't want to overwrite.
m_showPlotWindowTitle = rhs.m_showPlotWindowTitle;
auto dataSource = rhs.m_commonDataSource(); auto dataSource = rhs.m_commonDataSource();
rhs.m_commonDataSource.removeChildObject( dataSource ); rhs.m_commonDataSource.removeChildObject( dataSource );
@@ -152,6 +172,19 @@ RimWellLogPlot::~RimWellLogPlot()
{ {
delete m_commonDataSource; delete m_commonDataSource;
delete m_nameConfig; delete m_nameConfig;
removeMdiWindowFromMdiArea();
m_plots.deleteAllChildObjects();
cleanupBeforeClose();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimWellLogPlot::viewWidget()
{
return m_viewer;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -162,6 +195,124 @@ QWidget* RimWellLogPlot::createPlotWidget( QWidget* mainWindowParent /*= nullptr
return createViewWidget( mainWindowParent ); return createViewWidget( mainWindowParent );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogPlot::description() const
{
return m_plotWindowTitle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellLogPlot::isPlotTitleVisible() const
{
return m_showPlotWindowTitle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::setPlotTitleVisible( bool visible )
{
m_showPlotWindowTitle = visible;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::addPlot( RimPlot* plot )
{
insertPlot( plot, m_plots.size() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::insertPlot( RimPlot* plot, size_t index )
{
if ( plot )
{
m_plots.insert( index, plot );
if ( m_viewer )
{
plot->createPlotWidget();
m_viewer->insertPlot( plot->viewer(), index );
}
plot->setShowWindow( true );
plot->setLegendsVisible( false );
onPlotAdditionOrRemoval();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::removePlot( RimPlot* plot )
{
if ( plot )
{
if ( m_viewer )
{
m_viewer->removePlot( plot->viewer() );
}
m_plots.removeChildObject( plot );
onPlotAdditionOrRemoval();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimWellLogPlot::plotCount() const
{
return m_plots.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimWellLogPlot::plotIndex( const RimPlot* plot ) const
{
return m_plots.index( plot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlot* RimWellLogPlot::plotByIndex( size_t index ) const
{
return m_plots[index];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPlot*> RimWellLogPlot::plots() const
{
return m_plots.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimPlot*> RimWellLogPlot::visiblePlots() const
{
std::vector<RimPlot*> allVisiblePlots;
for ( RimPlot* plot : m_plots() )
{
if ( plot->showWindow() )
{
allVisiblePlots.push_back( plot );
}
}
return allVisiblePlots;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -180,6 +331,7 @@ void RimWellLogPlot::updateZoom()
for ( RimPlot* plot : plots() ) for ( RimPlot* plot : plots() )
{ {
static_cast<RimWellLogTrack*>( plot )->setVisibleYRange( m_minVisibleDepth(), m_maxVisibleDepth() ); static_cast<RimWellLogTrack*>( plot )->setVisibleYRange( m_minVisibleDepth(), m_maxVisibleDepth() );
plot->updateZoomInQwt();
} }
if ( m_viewer ) if ( m_viewer )
@@ -189,8 +341,6 @@ void RimWellLogPlot::updateZoom()
m_minAvailableDepth, m_minAvailableDepth,
m_maxAvailableDepth ); m_maxAvailableDepth );
} }
RimMultiPlotWindow::updateZoom();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -224,7 +374,7 @@ void RimWellLogPlot::setDepthAxisRange( double minimumDepth, double maximumDepth
m_minVisibleDepth.uiCapability()->updateConnectedEditors(); m_minVisibleDepth.uiCapability()->updateConnectedEditors();
m_maxVisibleDepth.uiCapability()->updateConnectedEditors(); m_maxVisibleDepth.uiCapability()->updateConnectedEditors();
setAutoScaleYEnabled( false ); setAutoScaleDepthEnabled( false );
updateZoom(); updateZoom();
} }
@@ -399,6 +549,23 @@ RimWellLogPlotNameConfig* RimWellLogPlot::nameConfig() const
return m_nameConfig; return m_nameConfig;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QImage RimWellLogPlot::snapshotWindowContent()
{
QImage image;
if ( m_viewer )
{
QPixmap pix( m_viewer->size() );
m_viewer->renderTo( &pix );
image = pix.toImage();
}
return image;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -409,14 +576,43 @@ QWidget* RimWellLogPlot::createViewWidget( QWidget* mainWindowParent )
return m_viewer; return m_viewer;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::deleteViewWidget()
{
cleanupBeforeClose();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogPlot::performAutoNameUpdate() void RimWellLogPlot::performAutoNameUpdate()
{ {
updateCommonDataSource(); updateCommonDataSource();
setMultiPlotTitle( createAutoName() ); m_plotWindowTitle = createAutoName();
applyPlotWindowTitleToWidgets(); if ( m_viewer )
{
m_viewer->setTitleVisible( m_showPlotWindowTitle() );
m_viewer->setPlotTitle( m_plotWindowTitle );
}
updateMdiWindowTitle();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::recreatePlotWidgets()
{
CVF_ASSERT( m_viewer );
auto plotVector = plots();
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
{
plotVector[tIdx]->createPlotWidget();
m_viewer->addPlot( plotVector[tIdx]->viewer() );
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -502,6 +698,24 @@ void RimWellLogPlot::setAvailableDepthTypes( const std::set<DepthTypeEnum>& dept
m_availableDepthTypes = depthTypes; m_availableDepthTypes = depthTypes;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogPlot::asciiDataForPlotExport() const
{
QString out = description() + "\n";
for ( RimPlot* plot : plots() )
{
if ( plot->showWindow() )
{
out += plot->asciiDataForPlotExport();
}
}
return out;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -509,7 +723,36 @@ void RimWellLogPlot::onPlotAdditionOrRemoval()
{ {
calculateAvailableDepthRange(); calculateAvailableDepthRange();
updateZoom(); updateZoom();
RimMultiPlotWindow::onPlotAdditionOrRemoval(); }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::doRenderWindowContent( QPaintDevice* paintDevice )
{
if ( m_viewer )
{
m_viewer->renderTo( paintDevice );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::cleanupBeforeClose()
{
auto plotVector = plots();
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
{
plotVector[tIdx]->detachAllCurves();
}
if ( m_viewer )
{
m_viewer->setParent( nullptr );
delete m_viewer;
m_viewer = nullptr;
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -532,23 +775,6 @@ void RimWellLogPlot::updateSubPlotNames()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::updatePlotWindowTitle()
{
performAutoNameUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::doSetAutoScaleYEnabled( bool on )
{
m_isAutoScaleDepthEnabled = on;
m_isAutoScaleDepthEnabled.uiCapability()->updateConnectedEditors();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -556,7 +782,7 @@ void RimWellLogPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) const QVariant& newValue )
{ {
RimMultiPlotWindow::fieldChangedByUi( changedField, oldValue, newValue ); RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_minVisibleDepth || changedField == &m_maxVisibleDepth ) if ( changedField == &m_minVisibleDepth || changedField == &m_maxVisibleDepth )
{ {
@@ -623,7 +849,6 @@ void RimWellLogPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* plotLayoutGroup = uiOrdering.addNewGroup( "Plot Layout" ); caf::PdmUiGroup* plotLayoutGroup = uiOrdering.addNewGroup( "Plot Layout" );
RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, *plotLayoutGroup ); RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, *plotLayoutGroup );
plotLayoutGroup->add( &m_columnCount );
uiOrdering.skipRemainingFields( true ); uiOrdering.skipRemainingFields( true );
} }
@@ -634,8 +859,7 @@ void RimWellLogPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
QList<caf::PdmOptionItemInfo> RimWellLogPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, QList<caf::PdmOptionItemInfo> RimWellLogPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) bool* useOptionsOnly )
{ {
QList<caf::PdmOptionItemInfo> options = RimMultiPlotWindow::calculateValueOptions( fieldNeedingOptions, QList<caf::PdmOptionItemInfo> options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
useOptionsOnly );
if ( fieldNeedingOptions == &m_depthType ) if ( fieldNeedingOptions == &m_depthType )
{ {
@@ -668,7 +892,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogPlot::calculateValueOptions( const caf::
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogPlot::initAfterRead() void RimWellLogPlot::initAfterRead()
{ {
RimMultiPlotWindow::initAfterRead(); RimPlotWindow::initAfterRead();
if ( m_depthAxisGridVisibility() == AXIS_GRID_MINOR ) if ( m_depthAxisGridVisibility() == AXIS_GRID_MINOR )
{ {
@@ -690,15 +914,7 @@ void RimWellLogPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName, QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) caf::PdmUiEditorAttribute* attribute )
{ {
if ( field == &m_columnCount ) if ( field == &m_minVisibleDepth || field == &m_maxVisibleDepth )
{
auto comboAttr = dynamic_cast<caf::PdmUiComboBoxEditorAttribute*>( attribute );
if ( comboAttr )
{
comboAttr->iconSize = QSize( 24, 14 );
}
}
else if ( field == &m_minVisibleDepth || field == &m_maxVisibleDepth )
{ {
auto doubleAttr = dynamic_cast<caf::PdmUiDoubleValueEditorAttribute*>( attribute ); auto doubleAttr = dynamic_cast<caf::PdmUiDoubleValueEditorAttribute*>( attribute );
if ( doubleAttr ) if ( doubleAttr )
@@ -709,6 +925,40 @@ void RimWellLogPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::onLoadDataAndUpdate()
{
updateMdiWindowVisibility();
performAutoNameUpdate();
updatePlots();
updateLayout();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::updatePlots()
{
if ( m_showWindow )
{
for ( RimPlot* plot : plots() )
{
plot->loadDataAndUpdate();
}
this->updateZoom();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellLogPlot::userDescriptionField()
{
return &m_plotWindowTitle;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -797,6 +1047,36 @@ RimWellLogPlot::AxisGridVisibility RimWellLogPlot::depthAxisGridLinesEnabled() c
return m_depthAxisGridVisibility(); return m_depthAxisGridVisibility();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::setAutoScaleXEnabled( bool enabled )
{
for ( RimPlot* plot : plots() )
{
plot->setAutoScaleXEnabled( enabled );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::setAutoScaleDepthEnabled( bool enabled )
{
m_isAutoScaleDepthEnabled = enabled;
m_isAutoScaleDepthEnabled.uiCapability()->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::zoomAll()
{
setAutoScaleXEnabled( true );
setAutoScaleDepthEnabled( true );
updateZoom();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -27,7 +27,7 @@
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include "RiaDefines.h" #include "RiaDefines.h"
#include "RimMultiPlotWindow.h" #include "RimPlotWindow.h"
#include "RimWellLogPlotNameConfig.h" #include "RimWellLogPlotNameConfig.h"
#include <QPointer> #include <QPointer>
@@ -35,15 +35,15 @@
#include <set> #include <set>
class RimWellLogCurveCommonDataSource; class RimWellLogCurveCommonDataSource;
class RiuMultiPlotPage; class RiuWellLogPlot;
class RimPlotWindow; class RimPlot;
class QKeyEvent; class QKeyEvent;
//================================================================================================== //==================================================================================================
/// ///
/// ///
//================================================================================================== //==================================================================================================
class RimWellLogPlot : public RimMultiPlotWindow, public RimNameConfigHolderInterface class RimWellLogPlot : public RimPlotWindow, public RimNameConfigHolderInterface
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
@@ -63,10 +63,26 @@ public:
RimWellLogPlot(); RimWellLogPlot();
~RimWellLogPlot() override; ~RimWellLogPlot() override;
QWidget* createPlotWidget( QWidget* mainWindowParent = nullptr );
RimWellLogPlot& operator=( RimWellLogPlot&& rhs ); RimWellLogPlot& operator=( RimWellLogPlot&& rhs );
QWidget* viewWidget() override;
QWidget* createPlotWidget( QWidget* mainWindowParent = nullptr );
QString description() const override;
bool isPlotTitleVisible() const;
void setPlotTitleVisible( bool visible );
void addPlot( RimPlot* plot );
void insertPlot( RimPlot* plot, size_t index );
void removePlot( RimPlot* plot );
size_t plotCount() const;
size_t plotIndex( const RimPlot* plot ) const;
RimPlot* plotByIndex( size_t index ) const;
std::vector<RimPlot*> plots() const;
std::vector<RimPlot*> visiblePlots() const;
DepthTypeEnum depthType() const; DepthTypeEnum depthType() const;
void setDepthType( DepthTypeEnum depthType ); void setDepthType( DepthTypeEnum depthType );
@@ -77,7 +93,11 @@ public:
void enableDepthAxisGridLines( AxisGridVisibility gridVisibility ); void enableDepthAxisGridLines( AxisGridVisibility gridVisibility );
AxisGridVisibility depthAxisGridLinesEnabled() const; AxisGridVisibility depthAxisGridLinesEnabled() const;
void updateZoom() override; void setAutoScaleXEnabled( bool enabled );
void setAutoScaleDepthEnabled( bool enabled );
void zoomAll() override;
void updateZoom();
void setDepthAxisRangeByFactorAndCenter( double zoomFactor, double zoomCenter ); void setDepthAxisRangeByFactorAndCenter( double zoomFactor, double zoomCenter );
void setDepthAxisRangeByPanDepth( double panFactor ); void setDepthAxisRangeByPanDepth( double panFactor );
void setDepthAxisRange( double minimumDepth, double maximumDepth ); void setDepthAxisRange( double minimumDepth, double maximumDepth );
@@ -99,13 +119,16 @@ public:
void setAvailableDepthUnits( const std::set<RiaDefines::DepthUnitType>& depthUnits ); void setAvailableDepthUnits( const std::set<RiaDefines::DepthUnitType>& depthUnits );
void setAvailableDepthTypes( const std::set<DepthTypeEnum>& depthTypes ); void setAvailableDepthTypes( const std::set<DepthTypeEnum>& depthTypes );
void onPlotAdditionOrRemoval() override; QString asciiDataForPlotExport() const;
void handleKeyPressEvent( QKeyEvent* keyEvent ); void handleKeyPressEvent( QKeyEvent* keyEvent );
protected: protected:
QImage snapshotWindowContent() override;
QWidget* createViewWidget( QWidget* mainWindowParent ) override; QWidget* createViewWidget( QWidget* mainWindowParent ) override;
void deleteViewWidget() override;
void performAutoNameUpdate() override; void performAutoNameUpdate() override;
void recreatePlotWidgets();
// Overridden PDM methods // Overridden PDM methods
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
@@ -119,16 +142,22 @@ protected:
void defineEditorAttribute( const caf::PdmFieldHandle* field, void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName, QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override; caf::PdmUiEditorAttribute* attribute ) override;
void onLoadDataAndUpdate() override;
void updatePlots();
caf::PdmFieldHandle* userDescriptionField() override;
private: private:
void updateSubPlotNames() override; void cleanupBeforeClose();
void updatePlotWindowTitle() override; void updateSubPlotNames();
void doSetAutoScaleYEnabled( bool enabled ) override; void onPlotAdditionOrRemoval();
void doRenderWindowContent( QPaintDevice* paintDevice ) override;
protected: protected:
caf::PdmChildField<RimWellLogCurveCommonDataSource*> m_commonDataSource; caf::PdmChildField<RimWellLogCurveCommonDataSource*> m_commonDataSource;
bool m_commonDataSourceEnabled; bool m_commonDataSourceEnabled;
caf::PdmField<bool> m_showPlotWindowTitle;
caf::PdmField<QString> m_plotWindowTitle;
caf::PdmField<caf::AppEnum<DepthTypeEnum>> m_depthType; caf::PdmField<caf::AppEnum<DepthTypeEnum>> m_depthType;
caf::PdmField<caf::AppEnum<RiaDefines::DepthUnitType>> m_depthUnit; caf::PdmField<caf::AppEnum<RiaDefines::DepthUnitType>> m_depthUnit;
caf::PdmField<double> m_minVisibleDepth; caf::PdmField<double> m_minVisibleDepth;
@@ -137,7 +166,9 @@ protected:
caf::PdmField<bool> m_isAutoScaleDepthEnabled; caf::PdmField<bool> m_isAutoScaleDepthEnabled;
caf::PdmChildField<RimWellLogPlotNameConfig*> m_nameConfig; caf::PdmChildField<RimWellLogPlotNameConfig*> m_nameConfig;
caf::PdmChildArrayField<RimPlot*> m_plots;
QPointer<RiuWellLogPlot> m_viewer;
std::set<RiaDefines::DepthUnitType> m_availableDepthUnits; std::set<RiaDefines::DepthUnitType> m_availableDepthUnits;
std::set<DepthTypeEnum> m_availableDepthTypes; std::set<DepthTypeEnum> m_availableDepthTypes;

View File

@@ -78,8 +78,13 @@
#include "cafPdmUiSliderEditor.h" #include "cafPdmUiSliderEditor.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
#include "cvfAssert.h" #include "cvfAssert.h"
#include <QWheelEvent>
#define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0 #define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0
#define RI_LOGPLOTTRACK_MAXX_DEFAULT 100.0 #define RI_LOGPLOTTRACK_MAXX_DEFAULT 100.0
#define RI_SCROLLWHEEL_ZOOMFACTOR 1.1
#define RI_SCROLLWHEEL_PANFACTOR 0.1
CAF_PDM_SOURCE_INIT( RimWellLogTrack, "WellLogPlotTrack" ); CAF_PDM_SOURCE_INIT( RimWellLogTrack, "WellLogPlotTrack" );
@@ -482,11 +487,11 @@ void RimWellLogTrack::updateYZoom()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogTrack::doRemoveFromCollection() void RimWellLogTrack::doRemoveFromCollection()
{ {
RimMultiPlotWindow* multiPlot = nullptr; RimWellLogPlot* wellLogPlot = nullptr;
this->firstAncestorOrThisOfType( multiPlot ); this->firstAncestorOrThisOfType( wellLogPlot );
if ( multiPlot ) if ( wellLogPlot )
{ {
multiPlot->removePlot( this ); wellLogPlot->removePlot( this );
} }
} }
@@ -1296,21 +1301,18 @@ RimWellLogTrack::TrajectoryType RimWellLogTrack::formationTrajectoryType() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QWidget* RimWellLogTrack::createViewWidget( QWidget* mainWindowParent ) RiuQwtPlotWidget* RimWellLogTrack::doCreatePlotViewWidget( QWidget* mainWindowParent )
{ {
if ( m_plotWidget == nullptr ) if ( m_plotWidget == nullptr )
{ {
m_plotWidget = new RiuWellLogTrack( this, mainWindowParent ); m_plotWidget = new RiuWellLogTrack( this, mainWindowParent );
m_plotWidget->setAxisInverted( QwtPlot::yLeft ); m_plotWidget->setAxisInverted( QwtPlot::yLeft );
updateAxisScaleEngine(); updateAxisScaleEngine();
for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx ) for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx )
{ {
m_curves[cIdx]->setParentQwtPlotNoReplot( this->m_plotWidget ); m_curves[cIdx]->setParentQwtPlotNoReplot( this->m_plotWidget );
} }
m_plotWidget->scheduleReplot();
} }
return m_plotWidget; return m_plotWidget;
} }
@@ -1760,6 +1762,38 @@ RimWellLogPlot* RimWellLogTrack::parentWellLogPlot() const
return wellLogPlot; return wellLogPlot;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::handleWheelEvent( QWheelEvent* event )
{
RimWellLogPlot* wellLogPlot = nullptr;
this->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
if ( event->modifiers() & Qt::ControlModifier )
{
QwtScaleMap scaleMap = m_plotWidget->canvasMap( QwtPlot::yLeft );
double zoomCenter = scaleMap.invTransform( event->pos().y() );
if ( event->delta() > 0 )
{
wellLogPlot->setDepthAxisRangeByFactorAndCenter( RI_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
}
else
{
wellLogPlot->setDepthAxisRangeByFactorAndCenter( 1.0 / RI_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
}
}
else
{
wellLogPlot->setDepthAxisRangeByPanDepth( event->delta() < 0 ? RI_SCROLLWHEEL_PANFACTOR
: -RI_SCROLLWHEEL_PANFACTOR );
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -204,11 +204,12 @@ public:
protected: protected:
// RimViewWindow overrides // RimViewWindow overrides
QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) override;
void deleteViewWidget() override; void deleteViewWidget() override;
void onLoadDataAndUpdate() override; void onLoadDataAndUpdate() override;
private: private:
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
void cleanupBeforeClose(); void cleanupBeforeClose();
void detachAllPlotItems(); void detachAllPlotItems();
void calculateXZoomRange(); void calculateXZoomRange();
@@ -272,6 +273,8 @@ private:
RimWellLogPlot* parentWellLogPlot() const; RimWellLogPlot* parentWellLogPlot() const;
void handleWheelEvent( QWheelEvent* event ) override;
private: private:
QString m_xAxisTitle; QString m_xAxisTitle;

View File

@@ -87,4 +87,8 @@ list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES} ${SOURCE_GROUP_SOURCE_FILES}
) )
list(APPEND QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.h
)
source_group( "ProjectDataModel\\Summary" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) source_group( "ProjectDataModel\\Summary" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@@ -496,7 +496,7 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( curveMerger.allXValues().size() > 0 ) if ( curveMerger.allXValues().size() > 0 )
{ {
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( curveMerger.interpolatedYValuesForAllXValues( 0 ), this->setSamplesFromXYValues( curveMerger.interpolatedYValuesForAllXValues( 0 ),
curveMerger.interpolatedYValuesForAllXValues( 1 ), curveMerger.interpolatedYValuesForAllXValues( 1 ),
isLogCurve ); isLogCurve );
} }
@@ -530,12 +530,12 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot )
} }
else else
{ {
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( timeSteps, curveValuesY, isLogCurve ); this->setSamplesFromXYValues( timeSteps, curveValuesY, isLogCurve );
} }
} }
else else
{ {
m_qwtPlotCurve->setSamplesFromTimeTAndYValues( curveTimeStepsY, curveValuesY, isLogCurve ); this->setSamplesFromTimeTAndYValues( curveTimeStepsY, curveValuesY, isLogCurve );
} }
} }
} }
@@ -553,7 +553,7 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot )
} }
} }
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( timeFromSimulationStart, curveValuesY, isLogCurve ); this->setSamplesFromXYValues( timeFromSimulationStart, curveValuesY, isLogCurve );
} }
} }
else else
@@ -564,7 +564,7 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( shouldPopulateViewWithEmptyData ) if ( shouldPopulateViewWithEmptyData )
{ {
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( std::vector<double>(), std::vector<double>(), isLogCurve ); this->setSamplesFromXYValues( std::vector<double>(), std::vector<double>(), isLogCurve );
} }
if ( updateParentPlot && m_parentQwtPlot ) if ( updateParentPlot && m_parentQwtPlot )

View File

@@ -34,7 +34,7 @@
#include "RimEnsembleCurveSet.h" #include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h" #include "RimEnsembleCurveSetCollection.h"
#include "RimGridTimeHistoryCurve.h" #include "RimGridTimeHistoryCurve.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimPlotAxisProperties.h" #include "RimPlotAxisProperties.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimSummaryCase.h" #include "RimSummaryCase.h"
@@ -209,7 +209,6 @@ RimSummaryPlot::RimSummaryPlot()
m_summaryCurves_OBSOLETE.uiCapability()->setUiTreeHidden( true ); m_summaryCurves_OBSOLETE.uiCapability()->setUiTreeHidden( true );
m_isCrossPlot = false; m_isCrossPlot = false;
m_isDraggable = true;
m_nameHelperAllCurves.reset( new RimSummaryPlotNameHelper ); m_nameHelperAllCurves.reset( new RimSummaryPlotNameHelper );
@@ -543,6 +542,14 @@ void RimSummaryPlot::updatePlotTitle()
updateCurveNames(); updateCurveNames();
updateMdiWindowTitle(); updateMdiWindowTitle();
if ( m_plotWidget )
{
QString plotTitle = description();
m_plotWidget->setPlotTitle( plotTitle );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && isMdiWindow() );
m_plotWidget->scheduleReplot();
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -1336,11 +1343,6 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
{ {
RimPlot::fieldChangedByUi( changedField, oldValue, newValue ); RimPlot::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_showWindow )
{
updateWindowVisibility();
}
if ( changedField == &m_showPlotTitle || changedField == &m_description || changedField == &m_useAutoPlotTitle ) if ( changedField == &m_showPlotTitle || changedField == &m_description || changedField == &m_useAutoPlotTitle )
{ {
updatePlotTitle(); updatePlotTitle();
@@ -1425,8 +1427,7 @@ void RimSummaryPlot::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
void RimSummaryPlot::onLoadDataAndUpdate() void RimSummaryPlot::onLoadDataAndUpdate()
{ {
updatePlotTitle(); updatePlotTitle();
updateMdiWindowVisibility();
updateWindowVisibility();
if ( m_summaryCurveCollection ) if ( m_summaryCurveCollection )
{ {
@@ -1567,14 +1568,6 @@ QString RimSummaryPlot::description() const
return m_description(); return m_description();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::setDraggable( bool draggable )
{
m_isDraggable = draggable;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -1599,6 +1592,16 @@ void RimSummaryPlot::setAsCrossPlot()
m_isCrossPlot = true; m_isCrossPlot = true;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::onPlotZoomed()
{
setAutoScaleXEnabled( false );
setAutoScaleYEnabled( false );
updateZoomFromQwt();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -1648,12 +1651,11 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QWidget* RimSummaryPlot::createViewWidget( QWidget* mainWindowParent ) RiuQwtPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent )
{ {
if ( !m_plotWidget ) if ( !m_plotWidget )
{ {
m_plotWidget = new RiuSummaryQwtPlot( this, mainWindowParent ); m_plotWidget = new RiuSummaryQwtPlot( this, mainWindowParent );
m_plotWidget->setDraggable( m_isDraggable );
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves ) for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{ {
@@ -1674,6 +1676,10 @@ QWidget* RimSummaryPlot::createViewWidget( QWidget* mainWindowParent )
{ {
m_ensembleCurveSetCollection->setParentQwtPlotAndReplot( m_plotWidget ); m_ensembleCurveSetCollection->setParentQwtPlotAndReplot( m_plotWidget );
} }
this->connect( m_plotWidget, SIGNAL( plotZoomed() ), SLOT( onPlotZoomed() ) );
updatePlotTitle();
} }
return m_plotWidget; return m_plotWidget;
@@ -1735,36 +1741,6 @@ void RimSummaryPlot::initAfterRead()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateMdiWindowTitle()
{
if ( m_plotWidget )
{
if ( isMdiWindow() )
{
QString plotTitle = description();
m_plotWidget->setWindowTitle( plotTitle );
if ( m_showPlotTitle )
{
m_plotWidget->setTitle( plotTitle );
}
else
{
m_plotWidget->setTitle( "" );
}
}
else
{
m_plotWidget->setTitle( "" );
}
m_plotWidget->scheduleReplot();
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -1817,22 +1793,6 @@ void RimSummaryPlot::updateNameHelperWithCurveData( RimSummaryPlotNameHelper* na
nameHelper->setEnsembleCases( ensembleCases ); nameHelper->setEnsembleCases( ensembleCases );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateWindowVisibility()
{
if ( isMdiWindow() )
{
updateMdiWindowVisibility();
}
else
{
updateParentLayout();
}
updateAxes();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -65,6 +65,7 @@ class QKeyEvent;
//================================================================================================== //==================================================================================================
class RimSummaryPlot : public RimPlot class RimSummaryPlot : public RimPlot
{ {
Q_OBJECT;
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public: public:
@@ -76,8 +77,6 @@ public:
void setDescription( const QString& description ); void setDescription( const QString& description );
QString description() const override; QString description() const override;
void setDraggable( bool draggable );
void enableAutoPlotTitle( bool enable ); void enableAutoPlotTitle( bool enable );
bool autoPlotTitle() const; bool autoPlotTitle() const;
@@ -155,7 +154,6 @@ public:
void setNormalizationEnabled( bool enable ); void setNormalizationEnabled( bool enable );
bool isNormalizationEnabled(); bool isNormalizationEnabled();
void handleKeyPressEvent( QKeyEvent* keyEvent );
virtual RimSummaryPlotSourceStepping* sourceSteppingObjectForKeyEventHandling() const; virtual RimSummaryPlotSourceStepping* sourceSteppingObjectForKeyEventHandling() const;
virtual std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar(); virtual std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar();
@@ -172,20 +170,20 @@ public:
public: public:
// RimViewWindow overrides // RimViewWindow overrides
QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) override;
void deleteViewWidget() override; void deleteViewWidget() override;
void initAfterRead() override; void initAfterRead() override;
private: private:
void updateMdiWindowTitle() override; RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
void updateNameHelperWithCurveData( RimSummaryPlotNameHelper* nameHelper ) const; void updateNameHelperWithCurveData( RimSummaryPlotNameHelper* nameHelper ) const;
void updateWindowVisibility();
void doUpdateLayout() override; void doUpdateLayout() override;
void detachAllPlotItems(); void detachAllPlotItems();
void doRemoveFromCollection() override; void doRemoveFromCollection() override;
void handleKeyPressEvent( QKeyEvent* keyEvent ) override;
protected: protected:
// Overridden PDM methods // Overridden PDM methods
@@ -201,6 +199,9 @@ protected:
void setAsCrossPlot(); void setAsCrossPlot();
private slots:
void onPlotZoomed();
private: private:
std::vector<RimSummaryCurve*> visibleSummaryCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const; std::vector<RimSummaryCurve*> visibleSummaryCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const;
std::vector<RimGridTimeHistoryCurve*> visibleTimeHistoryCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const; std::vector<RimGridTimeHistoryCurve*> visibleTimeHistoryCurvesForAxis( RiaDefines::PlotAxis plotAxis ) const;
@@ -244,7 +245,6 @@ private:
std::unique_ptr<QwtPlotTextLabel> m_plotInfoLabel; std::unique_ptr<QwtPlotTextLabel> m_plotInfoLabel;
bool m_isCrossPlot; bool m_isCrossPlot;
bool m_isDraggable;
std::unique_ptr<RimSummaryPlotNameHelper> m_nameHelperAllCurves; std::unique_ptr<RimSummaryPlotNameHelper> m_nameHelperAllCurves;

View File

@@ -52,10 +52,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuCellAndNncPickEventHandler.h
${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.h ${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotInterface.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.h ${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.h
@@ -148,7 +146,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.cpp
@@ -213,9 +211,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h
${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h ${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotInterface.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h ${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h
${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h ${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h

View File

@@ -29,7 +29,7 @@
#include "RimEclipseResultCase.h" #include "RimEclipseResultCase.h"
#include "RimIdenticalGridCaseGroup.h" #include "RimIdenticalGridCaseGroup.h"
#include "RimMimeData.h" #include "RimMimeData.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimPlot.h" #include "RimPlot.h"
#include "RimSummaryCase.h" #include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseCollection.h"
@@ -186,7 +186,7 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
itemflags |= Qt::ItemIsDropEnabled; itemflags |= Qt::ItemIsDropEnabled;
} }
} }
else if ( dynamic_cast<RimMultiPlotWindow*>( uiItem ) ) else if ( dynamic_cast<RimMultiPlot*>( uiItem ) )
{ {
if ( RiuTypedPdmObjects<RimPlot>::containsTypedObjects( m_dragItems ) ) if ( RiuTypedPdmObjects<RimPlot>::containsTypedObjects( m_dragItems ) )
{ {
@@ -297,14 +297,7 @@ bool RiuDragDrop::dropMimeData( const QMimeData* data, Qt::DropAction action, in
return handleWellLogPlotCurveDrop( action, draggedObjects, wellLogPlotCurve ); return handleWellLogPlotCurveDrop( action, draggedObjects, wellLogPlotCurve );
} }
RimWellLogTrack* wellLogPlotTrack; RimMultiPlot* multiPlot;
dropTarget->firstAncestorOrThisOfType( wellLogPlotTrack );
if ( wellLogPlotTrack )
{
return handleWellLogPlotTrackDrop( action, draggedObjects, wellLogPlotTrack, row );
}
RimMultiPlotWindow* multiPlot;
dropTarget->firstAncestorOrThisOfType( multiPlot ); dropTarget->firstAncestorOrThisOfType( multiPlot );
if ( multiPlot ) if ( multiPlot )
{ {
@@ -396,67 +389,12 @@ bool RiuDragDrop::handleGridCaseGroupDrop( Qt::DropAction action,
return true; return true;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleWellLogPlotTrackDrop( Qt::DropAction action,
caf::PdmObjectGroup& draggedObjects,
RimWellLogTrack* trackTarget,
int insertAtPosition )
{
std::vector<RimWellLogFileChannel*> wellLogFileChannels =
RiuTypedPdmObjects<RimWellLogFileChannel>::typedObjectsFromGroup( draggedObjects );
if ( wellLogFileChannels.size() > 0 )
{
if ( action == Qt::CopyAction )
{
RicWellLogTools::addWellLogChannelsToPlotTrack( trackTarget, wellLogFileChannels );
return true;
}
}
std::vector<RimWellLogCurve*> wellLogPlotCurves = RiuTypedPdmObjects<RimWellLogCurve>::typedObjectsFromGroup(
draggedObjects );
if ( wellLogPlotCurves.size() > 0 )
{
if ( action == Qt::MoveAction )
{
RimWellLogCurve* insertAfter = nullptr;
if ( insertAtPosition > 0 )
{
auto visibleCurves = trackTarget->visibleCurves();
if ( !visibleCurves.empty() )
{
int insertAfterPosition = std::min( insertAtPosition - 1, (int)visibleCurves.size() - 1 );
insertAfter = visibleCurves[insertAfterPosition];
}
}
RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack( trackTarget, wellLogPlotCurves, insertAfter );
return true;
}
}
std::vector<RimWellLogTrack*> wellLogPlotTracks = RiuTypedPdmObjects<RimWellLogTrack>::typedObjectsFromGroup(
draggedObjects );
if ( wellLogPlotTracks.size() > 0 )
{
if ( action == Qt::MoveAction )
{
RimWellLogPlot* wellLogPlot;
trackTarget->firstAncestorOrThisOfType( wellLogPlot );
return handleMultiPlotDrop( action, draggedObjects, wellLogPlot, insertAtPosition );
}
}
return false;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleMultiPlotDrop( Qt::DropAction action, bool RiuDragDrop::handleMultiPlotDrop( Qt::DropAction action,
caf::PdmObjectGroup& draggedObjects, caf::PdmObjectGroup& draggedObjects,
RimMultiPlotWindow* multiPlot, RimMultiPlot* multiPlot,
int insertAtPosition ) int insertAtPosition )
{ {
std::vector<RimPlot*> plots = RiuTypedPdmObjects<RimPlot>::typedObjectsFromGroup( draggedObjects ); std::vector<RimPlot*> plots = RiuTypedPdmObjects<RimPlot>::typedObjectsFromGroup( draggedObjects );

View File

@@ -29,7 +29,7 @@ namespace caf
class PdmObjectHandle; class PdmObjectHandle;
} }
class RimMultiPlotWindow; class RimMultiPlot;
class RimIdenticalGridCaseGroup; class RimIdenticalGridCaseGroup;
class RimSummaryCaseCollection; class RimSummaryCaseCollection;
class RimSummaryCaseMainCollection; class RimSummaryCaseMainCollection;
@@ -67,7 +67,7 @@ private:
int insertAtPosition ); int insertAtPosition );
bool handleMultiPlotDrop( Qt::DropAction action, bool handleMultiPlotDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup, caf::PdmObjectGroup& objectGroup,
RimMultiPlotWindow* multiPlot, RimMultiPlot* multiPlot,
int insertAtPosition ); int insertAtPosition );
bool handleWellLogPlotCurveDrop( Qt::DropAction action, bool handleWellLogPlotCurveDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup, caf::PdmObjectGroup& objectGroup,

View File

@@ -58,8 +58,8 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimPlot* plotDefinition, QWidget* parent /*= nullptr*/ ) RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* parent /*= nullptr*/ )
: RiuQwtPlotWidget( plotDefinition, parent ) : RiuQwtPlotWidget( plot, parent )
{ {
// LeftButton for the zooming // LeftButton for the zooming
m_zoomerLeft = new RiuQwtPlotZoomer( canvas() ); m_zoomerLeft = new RiuQwtPlotZoomer( canvas() );
@@ -132,14 +132,6 @@ void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisProperties* axisPr
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuGridCrossQwtPlot::ownerViewWindow() const
{
return dynamic_cast<RimViewWindow*>( plotDefinition() );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -182,7 +174,7 @@ void RiuGridCrossQwtPlot::contextMenuEvent( QContextMenuEvent* event )
QMenu menu; QMenu menu;
caf::CmdFeatureMenuBuilder menuBuilder; caf::CmdFeatureMenuBuilder menuBuilder;
caf::SelectionManager::instance()->setSelectedItem( ownerViewWindow() ); emit plotSelected( false );
menuBuilder << "RicSwapGridCrossPlotDataSetAxesFeature"; menuBuilder << "RicSwapGridCrossPlotDataSetAxesFeature";
menuBuilder << "Separator"; menuBuilder << "Separator";
@@ -281,5 +273,5 @@ void RiuGridCrossQwtPlot::endZoomOperations()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::onZoomedSlot() void RiuGridCrossQwtPlot::onZoomedSlot()
{ {
plotDefinition()->updateZoomFromQwt(); emit plotZoomed();
} }

View File

@@ -27,6 +27,7 @@
#include <memory> #include <memory>
class RimGridCrossPlot;
class RimGridCrossPlotDataSet; class RimGridCrossPlotDataSet;
class RimPlotAxisProperties; class RimPlotAxisProperties;
class RimPlot; class RimPlot;
@@ -45,23 +46,24 @@ class TitledOverlayFrame;
// //
// //
//================================================================================================== //==================================================================================================
class RiuGridCrossQwtPlot : public RiuQwtPlotWidget, public RiuInterfaceToViewWindow class RiuGridCrossQwtPlot : public RiuQwtPlotWidget
{ {
Q_OBJECT; Q_OBJECT;
public: public:
RiuGridCrossQwtPlot( RimPlot* plotDefinition, QWidget* parent = nullptr ); RiuGridCrossQwtPlot( RimGridCrossPlot* crossPlot, QWidget* parent = nullptr );
~RiuGridCrossQwtPlot(); ~RiuGridCrossQwtPlot();
RiuGridCrossQwtPlot( const RiuGridCrossQwtPlot& ) = delete; RiuGridCrossQwtPlot( const RiuGridCrossQwtPlot& ) = delete;
void updateAnnotationObjects( RimPlotAxisProperties* axisProperties ); void updateAnnotationObjects( RimPlotAxisProperties* axisProperties );
RimViewWindow* ownerViewWindow() const override;
void setLegendFontSize( int fontSize ); void setLegendFontSize( int fontSize );
void setInternalQwtLegendVisible( bool visible ); void setInternalQwtLegendVisible( bool visible );
signals:
void plotZoomed();
protected: protected:
void contextMenuEvent( QContextMenuEvent* ) override; void contextMenuEvent( QContextMenuEvent* ) override;

View File

@@ -15,14 +15,14 @@
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RiuMultiPlotWindow.h" #include "RiuMultiPlotBook.h"
#include "RiaGuiApplication.h" #include "RiaGuiApplication.h"
#include "RiaPlotWindowRedrawScheduler.h" #include "RiaPlotWindowRedrawScheduler.h"
#include "RiaPreferences.h" #include "RiaPreferences.h"
#include "RimContextCommandBuilder.h" #include "RimContextCommandBuilder.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
@@ -98,16 +98,14 @@ private:
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuMultiPlotWindow::RiuMultiPlotWindow( RimMultiPlotWindow* plotDefinition, QWidget* parent ) RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* parent )
: RiuMultiPlotInterface( parent ) : QWidget( parent )
, m_plotDefinition( plotDefinition ) , m_plotDefinition( plotDefinition )
, m_plotTitle( "Multi Plot" ) , m_plotTitle( "Multi Plot" )
, m_titleVisible( true ) , m_titleVisible( true )
, m_subTitlesVisible( true )
, m_previewMode( true ) , m_previewMode( true )
{ {
Q_ASSERT( plotDefinition );
m_plotDefinition = plotDefinition;
const int spacing = 8; const int spacing = 8;
this->setBackgroundRole( QPalette::Dark ); this->setBackgroundRole( QPalette::Dark );
@@ -147,12 +145,12 @@ RiuMultiPlotWindow::RiuMultiPlotWindow( RimMultiPlotWindow* plotDefinition, QWid
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuMultiPlotWindow::~RiuMultiPlotWindow() {} RiuMultiPlotBook::~RiuMultiPlotBook() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimMultiPlotWindow* RiuMultiPlotWindow::ownerPlotDefinition() RimViewWindow* RiuMultiPlotBook::ownerViewWindow() const
{ {
return m_plotDefinition; return m_plotDefinition;
} }
@@ -160,15 +158,7 @@ RimMultiPlotWindow* RiuMultiPlotWindow::ownerPlotDefinition()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimViewWindow* RiuMultiPlotWindow::ownerViewWindow() const void RiuMultiPlotBook::addPlot( RiuQwtPlotWidget* plotWidget )
{
return m_plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::addPlot( RiuQwtPlotWidget* plotWidget )
{ {
// Push the plot to the back of the list // Push the plot to the back of the list
insertPlot( plotWidget, m_plotWidgets.size() ); insertPlot( plotWidget, m_plotWidgets.size() );
@@ -177,9 +167,8 @@ void RiuMultiPlotWindow::addPlot( RiuQwtPlotWidget* plotWidget )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) void RiuMultiPlotBook::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
{ {
plotWidget->setDraggable( true ); // Becomes draggable when added to a grid plot window
m_plotWidgets.insert( static_cast<int>( index ), plotWidget ); m_plotWidgets.insert( static_cast<int>( index ), plotWidget );
scheduleUpdate(); scheduleUpdate();
} }
@@ -187,7 +176,7 @@ void RiuMultiPlotWindow::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::removePlot( RiuQwtPlotWidget* plotWidget ) void RiuMultiPlotBook::removePlot( RiuQwtPlotWidget* plotWidget )
{ {
if ( !plotWidget ) return; if ( !plotWidget ) return;
@@ -202,7 +191,7 @@ void RiuMultiPlotWindow::removePlot( RiuQwtPlotWidget* plotWidget )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setPlotTitle( const QString& plotTitle ) void RiuMultiPlotBook::setPlotTitle( const QString& plotTitle )
{ {
m_plotTitle = plotTitle; m_plotTitle = plotTitle;
for ( int i = 0; i < m_pages.size(); ++i ) for ( int i = 0; i < m_pages.size(); ++i )
@@ -214,7 +203,7 @@ void RiuMultiPlotWindow::setPlotTitle( const QString& plotTitle )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setTitleVisible( bool visible ) void RiuMultiPlotBook::setTitleVisible( bool visible )
{ {
m_titleVisible = visible; m_titleVisible = visible;
for ( auto page : m_pages ) for ( auto page : m_pages )
@@ -226,25 +215,19 @@ void RiuMultiPlotWindow::setTitleVisible( bool visible )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setSelectionsVisible( bool visible ) void RiuMultiPlotBook::setSubTitlesVisible( bool visible )
{ {
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets ) m_subTitlesVisible = visible;
for ( auto page : m_pages )
{ {
if ( visible && caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), 0 ) ) page->setSubTitlesVisible( visible );
{
plotWidget->setWidgetState( "selected" );
}
else
{
caf::UiStyleSheet::clearWidgetStates( plotWidget );
}
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setFontSize( int fontSize ) void RiuMultiPlotBook::setFontSize( int fontSize )
{ {
QFont font = this->font(); QFont font = this->font();
int pixelSize = RiaFontCache::pointSizeToPixelSize( fontSize ); int pixelSize = RiaFontCache::pointSizeToPixelSize( fontSize );
@@ -256,14 +239,12 @@ void RiuMultiPlotWindow::setFontSize( int fontSize )
{ {
page->setFontSize( fontSize ); page->setFontSize( fontSize );
} }
scheduleUpdate();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int RiuMultiPlotWindow::fontSize() const int RiuMultiPlotBook::fontSize() const
{ {
return RiaFontCache::pixelSizeToPointSize( this->font().pixelSize() ); return RiaFontCache::pixelSizeToPointSize( this->font().pixelSize() );
} }
@@ -271,7 +252,7 @@ int RiuMultiPlotWindow::fontSize() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int RiuMultiPlotWindow::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ) int RiuMultiPlotBook::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
{ {
return m_plotWidgets.indexOf( plotWidget ); return m_plotWidgets.indexOf( plotWidget );
} }
@@ -279,7 +260,7 @@ int RiuMultiPlotWindow::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RiuMultiPlotWindow::previewModeEnabled() const bool RiuMultiPlotBook::previewModeEnabled() const
{ {
return m_previewMode; return m_previewMode;
} }
@@ -287,7 +268,7 @@ bool RiuMultiPlotWindow::previewModeEnabled() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setPreviewModeEnabled( bool previewMode ) void RiuMultiPlotBook::setPreviewModeEnabled( bool previewMode )
{ {
m_previewMode = previewMode; m_previewMode = previewMode;
@@ -295,14 +276,12 @@ void RiuMultiPlotWindow::setPreviewModeEnabled( bool previewMode )
{ {
page->setPreviewModeEnabled( previewModeEnabled() ); page->setPreviewModeEnabled( previewModeEnabled() );
} }
scheduleUpdate();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::scheduleUpdate() void RiuMultiPlotBook::scheduleUpdate()
{ {
RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotWindowUpdate( this ); RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotWindowUpdate( this );
} }
@@ -310,7 +289,7 @@ void RiuMultiPlotWindow::scheduleUpdate()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::scheduleReplotOfAllPlots() void RiuMultiPlotBook::scheduleReplotOfAllPlots()
{ {
for ( RiuQwtPlotWidget* plotWidget : visiblePlotWidgets() ) for ( RiuQwtPlotWidget* plotWidget : visiblePlotWidgets() )
{ {
@@ -321,9 +300,12 @@ void RiuMultiPlotWindow::scheduleReplotOfAllPlots()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::renderTo( QPaintDevice* paintDevice ) void RiuMultiPlotBook::renderTo( QPaintDevice* paintDevice )
{ {
setSelectionsVisible( false ); for ( auto page : m_pages )
{
page->stashWidgetStates();
}
int resolution = paintDevice->logicalDpiX(); int resolution = paintDevice->logicalDpiX();
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() ); double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
@@ -344,18 +326,21 @@ void RiuMultiPlotWindow::renderTo( QPaintDevice* paintDevice )
firstPage = false; firstPage = false;
} }
setSelectionsVisible( true ); for ( auto page : m_pages )
{
page->restoreWidgetStates();
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::contextMenuEvent( QContextMenuEvent* event ) void RiuMultiPlotBook::contextMenuEvent( QContextMenuEvent* event )
{ {
QMenu menu; QMenu menu;
caf::CmdFeatureMenuBuilder menuBuilder; caf::CmdFeatureMenuBuilder menuBuilder;
caf::SelectionManager::instance()->setSelectedItem( ownerPlotDefinition() ); caf::SelectionManager::instance()->setSelectedItem( ownerViewWindow() );
menuBuilder << "RicShowPlotDataFeature"; menuBuilder << "RicShowPlotDataFeature";
menuBuilder << "RicShowContributingWellsFromPlotFeature"; menuBuilder << "RicShowContributingWellsFromPlotFeature";
@@ -371,7 +356,7 @@ void RiuMultiPlotWindow::contextMenuEvent( QContextMenuEvent* event )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::showEvent( QShowEvent* event ) void RiuMultiPlotBook::showEvent( QShowEvent* event )
{ {
QWidget::showEvent( event ); QWidget::showEvent( event );
performUpdate(); performUpdate();
@@ -381,7 +366,7 @@ void RiuMultiPlotWindow::showEvent( QShowEvent* event )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::resizeEvent( QResizeEvent* event ) void RiuMultiPlotBook::resizeEvent( QResizeEvent* event )
{ {
setBookSize( event->size().width() ); setBookSize( event->size().width() );
QWidget::resizeEvent( event ); QWidget::resizeEvent( event );
@@ -390,7 +375,7 @@ void RiuMultiPlotWindow::resizeEvent( QResizeEvent* event )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setBookSize( int frameWidth ) void RiuMultiPlotBook::setBookSize( int frameWidth )
{ {
for ( auto page : m_pages ) for ( auto page : m_pages )
{ {
@@ -404,7 +389,7 @@ void RiuMultiPlotWindow::setBookSize( int frameWidth )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::pair<int, int> RiuMultiPlotWindow::rowAndColumnCount( int plotWidgetCount ) const std::pair<int, int> RiuMultiPlotBook::rowAndColumnCount( int plotWidgetCount ) const
{ {
if ( plotWidgetCount == 0 ) if ( plotWidgetCount == 0 )
{ {
@@ -419,7 +404,7 @@ std::pair<int, int> RiuMultiPlotWindow::rowAndColumnCount( int plotWidgetCount )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RiuMultiPlotWindow::showYAxis( int row, int column ) const bool RiuMultiPlotBook::showYAxis( int row, int column ) const
{ {
return true; return true;
} }
@@ -427,7 +412,7 @@ bool RiuMultiPlotWindow::showYAxis( int row, int column ) const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::performUpdate() void RiuMultiPlotBook::performUpdate()
{ {
deleteAllPages(); deleteAllPages();
createPages(); createPages();
@@ -437,7 +422,7 @@ void RiuMultiPlotWindow::performUpdate()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotWindow::visiblePlotWidgets() const QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotBook::visiblePlotWidgets() const
{ {
QList<QPointer<RiuQwtPlotWidget>> plotWidgets; QList<QPointer<RiuQwtPlotWidget>> plotWidgets;
for ( QPointer<RiuQwtPlotWidget> plotWidget : m_plotWidgets ) for ( QPointer<RiuQwtPlotWidget> plotWidget : m_plotWidgets )
@@ -453,7 +438,7 @@ QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotWindow::visiblePlotWidgets() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::deleteAllPages() void RiuMultiPlotBook::deleteAllPages()
{ {
for ( RiuMultiPlotPage* page : m_pages ) for ( RiuMultiPlotPage* page : m_pages )
{ {
@@ -467,8 +452,10 @@ void RiuMultiPlotWindow::deleteAllPages()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::createPages() void RiuMultiPlotBook::createPages()
{ {
CAF_ASSERT( m_plotDefinition );
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets(); QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() ); auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
@@ -476,41 +463,53 @@ void RiuMultiPlotWindow::createPages()
int row = 0; int row = 0;
int column = 0; int column = 0;
RiuMultiPlotPage* page = new RiuMultiPlotPage( m_plotDefinition, this ); // Make sure we always add a page. For empty multi-plots we'll have an empty page with a drop target.
m_pages.push_back( page ); RiuMultiPlotPage* page = createPage();
m_bookLayout->addWidget( page );
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex ) for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
{ {
int expextedColSpan = static_cast<int>( plotWidgets[visibleIndex]->plotDefinition()->colSpan() ); int expextedColSpan = static_cast<int>( plotWidgets[visibleIndex]->colSpan() );
int colSpan = std::min( expextedColSpan, rowAndColumnCount.second ); int colSpan = std::min( expextedColSpan, rowAndColumnCount.second );
std::tie( row, column ) = page->findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second ); std::tie( row, column ) = page->findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second );
if ( row >= rowsPerPage ) if ( row >= rowsPerPage )
{ {
page = new RiuMultiPlotPage( m_plotDefinition, this ); page = createPage();
m_pages.push_back( page );
m_bookLayout->addWidget( page );
row = 0; row = 0;
column = 0; column = 0;
} }
page->addPlot( plotWidgets[visibleIndex] ); page->addPlot( plotWidgets[visibleIndex] );
page->setVisible( true );
page->performUpdate(); page->performUpdate();
} }
// Reapply plot settings
setPlotTitle( m_plotTitle );
setFontSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() );
setTitleVisible( m_titleVisible );
setPreviewModeEnabled( m_previewMode );
m_book->adjustSize(); m_book->adjustSize();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const QList<QPointer<RiuMultiPlotPage>>& RiuMultiPlotWindow::pages() const const QList<QPointer<RiuMultiPlotPage>>& RiuMultiPlotBook::pages() const
{ {
return m_pages; return m_pages;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMultiPlotPage* RiuMultiPlotBook::createPage()
{
RiuMultiPlotPage* page = new RiuMultiPlotPage( m_plotDefinition, this );
// Reapply plot settings
size_t pageNumber = m_pages.size() + 1;
page->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( pageNumber ) );
page->setFontSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() );
page->setTitleVisible( m_titleVisible );
page->setSubTitlesVisible( m_subTitlesVisible );
page->setPreviewModeEnabled( m_previewMode );
m_pages.push_back( page );
m_bookLayout->addWidget( page );
page->setVisible( true );
return page;
}

View File

@@ -18,8 +18,7 @@
#pragma once #pragma once
#include "RiuInterfaceToViewWindow.h" #include "RiuInterfaceToViewWindow.h"
#include "RiuMultiPlotInterface.h" #include "RiuMultiPlotPage.h"
#include "cafUiStyleSheet.h" #include "cafUiStyleSheet.h"
#include "cafPdmPointer.h" #include "cafPdmPointer.h"
@@ -35,7 +34,7 @@
#include <map> #include <map>
class RiaPlotWindowRedrawScheduler; class RiaPlotWindowRedrawScheduler;
class RimMultiPlotWindow; class RimMultiPlot;
class RiuMultiPlotPage; class RiuMultiPlotPage;
class RiuQwtPlotWidget; class RiuQwtPlotWidget;
@@ -49,42 +48,43 @@ class QwtPlot;
//================================================================================================== //==================================================================================================
// //
// RiuMultiPlotWidget // RiuMultiPlotWindow
// //
//================================================================================================== //==================================================================================================
class RiuMultiPlotWindow : public RiuMultiPlotInterface, public RiuInterfaceToViewWindow class RiuMultiPlotBook : public QWidget, public RiuInterfaceToViewWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
RiuMultiPlotWindow( RimMultiPlotWindow* plotDefinition, QWidget* parent = nullptr ); using ColumnCount = RiuMultiPlotPage::ColumnCount;
~RiuMultiPlotWindow() override;
public:
RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* parent = nullptr );
~RiuMultiPlotBook() override;
RimMultiPlotWindow* ownerPlotDefinition();
RimViewWindow* ownerViewWindow() const override; RimViewWindow* ownerViewWindow() const override;
void addPlot( RiuQwtPlotWidget* plotWidget ) override; void addPlot( RiuQwtPlotWidget* plotWidget );
void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) override; void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index );
void removePlot( RiuQwtPlotWidget* plotWidget ) override; void removePlot( RiuQwtPlotWidget* plotWidget );
void setPlotTitle( const QString& plotTitle ) override; void setPlotTitle( const QString& plotTitle );
void setTitleVisible( bool visible ) override; void setTitleVisible( bool visible );
void setSelectionsVisible( bool visible ); void setSubTitlesVisible( bool visible );
void setFontSize( int fontSize ); void setFontSize( int fontSize );
int fontSize() const; int fontSize() const;
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ); int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
bool previewModeEnabled() const override; bool previewModeEnabled() const;
void setPreviewModeEnabled( bool previewMode ) override; void setPreviewModeEnabled( bool previewMode );
void scheduleUpdate(); void scheduleUpdate();
void scheduleReplotOfAllPlots(); void scheduleReplotOfAllPlots();
void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) override {}
void renderTo( QPaintDevice* painter ) override; void renderTo( QPaintDevice* painter );
protected: protected:
void contextMenuEvent( QContextMenuEvent* ) override; void contextMenuEvent( QContextMenuEvent* ) override;
@@ -104,6 +104,7 @@ private:
void deleteAllPages(); void deleteAllPages();
void createPages(); void createPages();
const QList<QPointer<RiuMultiPlotPage>>& pages() const; const QList<QPointer<RiuMultiPlotPage>>& pages() const;
RiuMultiPlotPage* createPage();
private slots: private slots:
virtual void performUpdate(); virtual void performUpdate();
@@ -118,8 +119,9 @@ protected:
QList<QPointer<RiuMultiPlotPage>> m_pages; QList<QPointer<RiuMultiPlotPage>> m_pages;
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets; QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimMultiPlotWindow> m_plotDefinition; caf::PdmPointer<RimMultiPlot> m_plotDefinition;
QString m_plotTitle; QString m_plotTitle;
bool m_titleVisible; bool m_titleVisible;
bool m_subTitlesVisible;
bool m_previewMode; bool m_previewMode;
}; };

View File

@@ -1,61 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QWidget>
class RiuQwtPlotWidget;
class QPaintDevice;
class QScrollBar;
//==================================================================================================
//
// RiuMultiPlotInterface
//
//==================================================================================================
class RiuMultiPlotInterface : public QWidget
{
Q_OBJECT
public:
RiuMultiPlotInterface( QWidget* parent = nullptr )
: QWidget( parent )
{
}
virtual ~RiuMultiPlotInterface() {}
virtual void addPlot( RiuQwtPlotWidget* plotWidget ) = 0;
virtual void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) = 0;
virtual void removePlot( RiuQwtPlotWidget* plotWidget ) = 0;
virtual int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ) = 0;
virtual void setPlotTitle( const QString& plotTitle ) = 0;
virtual void setTitleVisible( bool visible ) = 0;
virtual void setFontSize( int fontSize ) = 0;
virtual int fontSize() const = 0;
virtual bool previewModeEnabled() const = 0;
virtual void setPreviewModeEnabled( bool previewMode ) = 0;
virtual void scheduleUpdate() = 0;
virtual void scheduleReplotOfAllPlots() = 0;
virtual void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) = 0;
virtual void renderTo( QPaintDevice* paintDevice ) = 0;
};

View File

@@ -28,7 +28,7 @@
#include "RiaGuiApplication.h" #include "RiaGuiApplication.h"
#include "RimContextCommandBuilder.h" #include "RimContextCommandBuilder.h"
#include "RimMultiPlotWindow.h" #include "RimMultiPlot.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
@@ -63,13 +63,13 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuMultiPlotPage::RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget* parent ) RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* parent )
: RiuMultiPlotInterface( parent ) : QWidget( parent )
, m_plotDefinition( plotDefinition ) , m_plotDefinition( plotDefinition )
, m_previewMode( false ) , m_previewMode( false )
, m_showSubTitles( false )
{ {
Q_ASSERT( plotDefinition ); CAF_ASSERT( m_plotDefinition );
m_plotDefinition = plotDefinition;
m_layout = new QVBoxLayout( this ); m_layout = new QVBoxLayout( this );
m_layout->setMargin( 0 ); m_layout->setMargin( 0 );
@@ -77,7 +77,7 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget*
m_plotTitle = createTitleLabel(); m_plotTitle = createTitleLabel();
m_layout->addWidget( m_plotTitle ); m_layout->addWidget( m_plotTitle );
m_plotTitle->setVisible( m_plotDefinition->isMultiPlotTitleVisible() ); m_plotTitle->setVisible( true );
m_plotLayout = new QHBoxLayout; m_plotLayout = new QHBoxLayout;
m_layout->addLayout( m_plotLayout ); m_layout->addLayout( m_plotLayout );
@@ -98,19 +98,10 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget*
new RiuPlotObjectPicker( m_plotTitle, m_plotDefinition ); new RiuPlotObjectPicker( m_plotTitle, m_plotDefinition );
m_dropTargetPlaceHolder = new QLabel( "Drag plots here" );
m_dropTargetPlaceHolder->setAlignment( Qt::AlignCenter );
m_dropTargetPlaceHolder->setObjectName(
QString( "%1" ).arg( reinterpret_cast<uint64_t>( m_dropTargetPlaceHolder.data() ) ) );
m_dropTargetStyleSheet = createDropTargetStyleSheet();
m_dropTargetStyleSheet.applyToWidget( m_dropTargetPlaceHolder );
this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding ); this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
setFocusPolicy( Qt::StrongFocus ); setFocusPolicy( Qt::StrongFocus );
setAcceptDrops( m_plotDefinition->acceptDrops() );
RiaApplication* app = RiaApplication::instance(); RiaApplication* app = RiaApplication::instance();
int defaultFontSize = app->preferences()->defaultPlotFontSize(); int defaultFontSize = app->preferences()->defaultPlotFontSize();
setFontSize( defaultFontSize ); setFontSize( defaultFontSize );
@@ -136,7 +127,15 @@ RiuMultiPlotPage::~RiuMultiPlotPage() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimMultiPlotWindow* RiuMultiPlotPage::ownerPlotDefinition() RimViewWindow* RiuMultiPlotPage::ownerViewWindow() const
{
return m_plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotWindow* RiuMultiPlotPage::ownerPlotDefinition()
{ {
return m_plotDefinition; return m_plotDefinition;
} }
@@ -155,11 +154,11 @@ void RiuMultiPlotPage::addPlot( RiuQwtPlotWidget* plotWidget )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
{ {
plotWidget->setDraggable( true ); // Becomes draggable when added to a grid plot window
m_plotWidgets.insert( static_cast<int>( index ), plotWidget ); m_plotWidgets.insert( static_cast<int>( index ), plotWidget );
plotWidget->setVisible( false ); plotWidget->setVisible( false );
QLabel* subTitle = new QLabel( plotWidget->plotDefinition()->description() ); QString subTitleText = plotWidget->plotTitle();
QLabel* subTitle = new QLabel( subTitleText );
subTitle->setAlignment( Qt::AlignHCenter ); subTitle->setAlignment( Qt::AlignHCenter );
subTitle->setVisible( false ); subTitle->setVisible( false );
m_subTitles.insert( static_cast<int>( index ), subTitle ); m_subTitles.insert( static_cast<int>( index ), subTitle );
@@ -240,24 +239,6 @@ void RiuMultiPlotPage::setTitleVisible( bool visible )
m_plotTitle->setVisible( visible ); m_plotTitle->setVisible( visible );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::setSelectionsVisible( bool visible )
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
if ( visible && caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), 0 ) )
{
plotWidget->setWidgetState( "selected" );
}
else
{
caf::UiStyleSheet::clearWidgetStates( plotWidget );
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -289,6 +270,14 @@ int RiuMultiPlotPage::fontSize() const
return m_plotTitle->font().pointSize() - 2; return m_plotTitle->font().pointSize() - 2;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::setSubTitlesVisible( bool visible )
{
m_showSubTitles = visible;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -318,6 +307,7 @@ int RiuMultiPlotPage::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::scheduleUpdate() void RiuMultiPlotPage::scheduleUpdate()
{ {
CAF_ASSERT( m_plotDefinition );
RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotPageUpdate( this ); RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotPageUpdate( this );
} }
@@ -349,7 +339,7 @@ void RiuMultiPlotPage::renderTo( QPaintDevice* paintDevice )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor ) void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor )
{ {
setSelectionsVisible( false ); stashWidgetStates();
painter->fillRect( painter->viewport(), Qt::white ); painter->fillRect( painter->viewport(), Qt::white );
m_plotTitle->render( painter ); m_plotTitle->render( painter );
@@ -381,7 +371,7 @@ void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor )
plotWidget->renderTo( painter, plotWidgetGeometry, scalingFactor ); plotWidget->renderTo( painter, plotWidgetGeometry, scalingFactor );
} }
setSelectionsVisible( true ); restoreWidgetStates();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -410,7 +400,7 @@ void RiuMultiPlotPage::contextMenuEvent( QContextMenuEvent* event )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QLabel* RiuMultiPlotPage::createTitleLabel() const QLabel* RiuMultiPlotPage::createTitleLabel() const
{ {
QLabel* plotTitle = new QLabel( "PLOT TITLE HERE", nullptr ); QLabel* plotTitle = new QLabel( "", nullptr );
plotTitle->setAlignment( Qt::AlignHCenter ); plotTitle->setAlignment( Qt::AlignHCenter );
plotTitle->setWordWrap( true ); plotTitle->setWordWrap( true );
plotTitle->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); plotTitle->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
@@ -423,128 +413,7 @@ QLabel* RiuMultiPlotPage::createTitleLabel() const
void RiuMultiPlotPage::showEvent( QShowEvent* event ) void RiuMultiPlotPage::showEvent( QShowEvent* event )
{ {
QWidget::showEvent( event ); QWidget::showEvent( event );
scheduleUpdate(); performUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::dragEnterEvent( QDragEnterEvent* event )
{
RiuQwtPlotWidget* source = dynamic_cast<RiuQwtPlotWidget*>( event->source() );
if ( source )
{
setWidgetState( "dragTargetInto" );
event->acceptProposedAction();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::dragMoveEvent( QDragMoveEvent* event )
{
if ( event->answerRect().intersects( this->geometry() ) )
{
RiuQwtPlotWidget* source = dynamic_cast<RiuQwtPlotWidget*>( event->source() );
if ( source && willAcceptDroppedPlot( source ) )
{
setWidgetState( "dragTargetInto" );
QRect originalGeometry = source->geometry();
QPoint offset = source->dragStartPosition();
QRect newRect( event->pos() - offset, originalGeometry.size() );
QList<QPointer<RiuQwtPlotWidget>> visiblePlotWidgets = this->visiblePlotWidgets();
int insertBeforeIndex = visiblePlotWidgets.size();
for ( int visibleIndex = 0; visibleIndex < visiblePlotWidgets.size(); ++visibleIndex )
{
caf::UiStyleSheet::clearWidgetStates( visiblePlotWidgets[visibleIndex] );
if ( visiblePlotWidgets[visibleIndex]->frameIsInFrontOfThis( newRect ) )
{
insertBeforeIndex = std::min( insertBeforeIndex, visibleIndex );
}
}
if ( insertBeforeIndex >= 0 && insertBeforeIndex < visiblePlotWidgets.size() )
{
visiblePlotWidgets[insertBeforeIndex]->setWidgetState( "dragTargetBefore" );
}
if ( insertBeforeIndex > 0 )
{
int insertAfterIndex = insertBeforeIndex - 1;
visiblePlotWidgets[insertAfterIndex]->setWidgetState( "dragTargetAfter" );
}
event->acceptProposedAction();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::dragLeaveEvent( QDragLeaveEvent* event )
{
caf::UiStyleSheet::clearWidgetStates( this );
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
caf::UiStyleSheet::clearWidgetStates( m_plotWidgets[tIdx] );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::dropEvent( QDropEvent* event )
{
caf::UiStyleSheet::clearWidgetStates( this );
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
caf::UiStyleSheet::clearWidgetStates( m_plotWidgets[tIdx] );
}
if ( this->geometry().contains( event->pos() ) )
{
RiuQwtPlotWidget* source = dynamic_cast<RiuQwtPlotWidget*>( event->source() );
if ( source && willAcceptDroppedPlot( source ) )
{
event->acceptProposedAction();
QRect originalGeometry = source->geometry();
QPoint offset = source->dragStartPosition();
QRect newRect( event->pos() - offset, originalGeometry.size() );
int beforeIndex = m_plotWidgets.size();
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
if ( m_plotWidgets[tIdx]->isVisible() )
{
if ( m_plotWidgets[tIdx]->frameIsInFrontOfThis( newRect ) )
{
beforeIndex = tIdx;
break;
}
}
}
RimPlot* insertAfter = nullptr;
if ( beforeIndex > 0 )
{
insertAfter = m_plotWidgets[beforeIndex - 1]->plotDefinition();
}
RimPlot* plotToMove = source->plotDefinition();
if ( insertAfter != plotToMove )
{
m_plotDefinition->movePlotsToThis( {plotToMove}, insertAfter );
}
}
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -590,13 +459,16 @@ void RiuMultiPlotPage::updateMarginsFromPageLayout()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QSize RiuMultiPlotPage::sizeHint() const QSize RiuMultiPlotPage::sizeHint() const
{ {
QPageLayout pageLayout = m_plotDefinition->pageLayout(); QPageLayout pageLayout = RiaApplication::instance()->preferences()->defaultPageLayout();
if ( m_plotDefinition )
{
pageLayout = m_plotDefinition->pageLayout();
}
const int resolution = RiaGuiApplication::applicationResolution(); const int resolution = RiaGuiApplication::applicationResolution();
QRect rect = pageLayout.fullRectPixels( resolution ); QRect rect = pageLayout.fullRectPixels( resolution );
return rect.size(); return rect.size();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -606,14 +478,6 @@ QSize RiuMultiPlotPage::minimumSizeHint() const
return QSize( fullSizeHint.width() / 2, fullSizeHint.height() / 2 ); return QSize( fullSizeHint.width() / 2, fullSizeHint.height() / 2 );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMultiPlotPage::willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const
{
return true;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -634,15 +498,18 @@ std::pair<int, int> RiuMultiPlotPage::rowAndColumnCount( int plotWidgetCount ) c
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels )
{ {
if ( !m_plotDefinition ) return;
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets ) for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{ {
CAF_ASSERT( plotWidget ); CAF_ASSERT( plotWidget );
RimPlot* plot = plotWidget->plotDefinition();
if ( !plot ) continue;
bool isSelected = false; bool isSelected = false;
for ( int changedLevel : changedSelectionLevels ) for ( int changedLevel : changedSelectionLevels )
{ {
isSelected = isSelected || isSelected = isSelected || caf::SelectionManager::instance()->isSelected( plot, changedLevel );
caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), changedLevel );
} }
if ( isSelected ) if ( isSelected )
{ {
@@ -655,14 +522,6 @@ void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>&
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::setWidgetState( const QString& widgetState )
{
m_dropTargetStyleSheet.setWidgetState( m_dropTargetPlaceHolder, widgetState );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -716,25 +575,17 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
QList<QPointer<RiuQwtPlotLegend>> legends = this->legendsForVisiblePlots(); QList<QPointer<RiuQwtPlotLegend>> legends = this->legendsForVisiblePlots();
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets(); QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
if ( plotWidgets.empty() && acceptDrops() ) if ( !plotWidgets.empty() )
{ {
m_gridLayout->addWidget( m_dropTargetPlaceHolder, 0, 0 );
m_gridLayout->setRowStretch( 0, 1 );
m_dropTargetPlaceHolder->setVisible( true );
}
else
{
m_dropTargetPlaceHolder->setVisible( false );
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() ); auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
int row = 0; int row = 0;
int column = 0; int column = 0;
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex ) for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
{ {
int expextedColSpan = static_cast<int>( plotWidgets[visibleIndex]->plotDefinition()->colSpan() ); int expectedColSpan = static_cast<int>( plotWidgets[visibleIndex]->colSpan() );
int colSpan = std::min( expextedColSpan, rowAndColumnCount.second ); int colSpan = std::min( expectedColSpan, rowAndColumnCount.second );
int rowSpan = plotWidgets[visibleIndex]->plotDefinition()->rowSpan(); int rowSpan = plotWidgets[visibleIndex]->rowSpan();
std::tie( row, column ) = findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second ); std::tie( row, column ) = findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second );
@@ -743,7 +594,7 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
->addWidget( legends[visibleIndex], 3 * row + 1, column, 1, colSpan, Qt::AlignHCenter | Qt::AlignBottom ); ->addWidget( legends[visibleIndex], 3 * row + 1, column, 1, colSpan, Qt::AlignHCenter | Qt::AlignBottom );
m_gridLayout->addWidget( plotWidgets[visibleIndex], 3 * row + 2, column, 1 + ( rowSpan - 1 ) * 3, colSpan ); m_gridLayout->addWidget( plotWidgets[visibleIndex], 3 * row + 2, column, 1 + ( rowSpan - 1 ) * 3, colSpan );
subTitles[visibleIndex]->setVisible( m_plotDefinition->showPlotTitles() ); subTitles[visibleIndex]->setVisible( m_showSubTitles );
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, showYAxis( row, column ) ); plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, showYAxis( row, column ) ); plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
@@ -775,7 +626,7 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
} }
for ( int c = column; c < column + colSpan; ++c ) for ( int c = column; c < column + colSpan; ++c )
{ {
int colStretch = 1; int colStretch = 6;
if ( showYAxis( row, column ) ) colStretch += 1; if ( showYAxis( row, column ) ) colStretch += 1;
m_gridLayout->setColumnStretch( c, std::max( colStretch, m_gridLayout->columnStretch( c ) ) ); m_gridLayout->setColumnStretch( c, std::max( colStretch, m_gridLayout->columnStretch( c ) ) );
} }
@@ -840,22 +691,6 @@ void RiuMultiPlotPage::clearGridLayout()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::UiStyleSheet RiuMultiPlotPage::createDropTargetStyleSheet()
{
caf::UiStyleSheet styleSheet;
styleSheet.set( "background-color", "white" );
styleSheet.set( "border", "1px dashed black" );
styleSheet.set( "font-size", "14pt" );
styleSheet.property( "dragTargetInto" ).set( "border", "1px dashed lime" );
styleSheet.property( "dragTargetInto" ).set( "background-color", "#DDFFDD" );
return styleSheet;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -939,3 +774,25 @@ std::pair<int, int>
} }
return std::make_pair( availableRow, availableColumn ); return std::make_pair( availableRow, availableColumn );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::stashWidgetStates()
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
plotWidget->stashWidgetStates();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::restoreWidgetStates()
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
plotWidget->restoreWidgetStates();
}
}

View File

@@ -17,12 +17,11 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#pragma once #pragma once
#include "RiuMultiPlotInterface.h" #include "RiuInterfaceToViewWindow.h"
#include "cafUiStyleSheet.h"
#include "cafPdmPointer.h" #include "cafPdmPointer.h"
#include "cafSelectionChangedReceiver.h" #include "cafSelectionChangedReceiver.h"
#include "cafUiStyleSheet.h"
#include <QFrame> #include <QFrame>
#include <QGridLayout> #include <QGridLayout>
@@ -34,7 +33,7 @@
#include <map> #include <map>
class RiaPlotWindowRedrawScheduler; class RiaPlotWindowRedrawScheduler;
class RimMultiPlotWindow; class RimPlotWindow;
class RiuQwtPlotLegend; class RiuQwtPlotLegend;
class RiuQwtPlotWidget; class RiuQwtPlotWidget;
@@ -51,37 +50,47 @@ class QwtPlot;
// RiuMultiPlotPage // RiuMultiPlotPage
// //
//================================================================================================== //==================================================================================================
class RiuMultiPlotPage : public RiuMultiPlotInterface, public caf::SelectionChangedReceiver class RiuMultiPlotPage : public QWidget, public caf::SelectionChangedReceiver, public RiuInterfaceToViewWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget* parent = nullptr ); enum class ColumnCount
{
COLUMNS_1 = 1,
COLUMNS_2 = 2,
COLUMNS_3 = 3,
COLUMNS_4 = 4,
COLUMNS_UNLIMITED = 1000,
};
public:
RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* parent = nullptr );
~RiuMultiPlotPage() override; ~RiuMultiPlotPage() override;
RimMultiPlotWindow* ownerPlotDefinition(); RimViewWindow* ownerViewWindow() const override;
RimPlotWindow* ownerPlotDefinition();
void addPlot( RiuQwtPlotWidget* plotWidget ) override; void addPlot( RiuQwtPlotWidget* plotWidget );
void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) override; void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index );
void removePlot( RiuQwtPlotWidget* plotWidget ) override; void removePlot( RiuQwtPlotWidget* plotWidget );
void removeAllPlots(); void removeAllPlots();
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ) override; int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
void setSelectionsVisible( bool visible ); void setPlotTitle( const QString& plotTitle );
void setTitleVisible( bool visible );
void setFontSize( int fontSize );
int fontSize() const;
void setSubTitlesVisible( bool visible );
void setPlotTitle( const QString& plotTitle ) override; bool previewModeEnabled() const;
void setTitleVisible( bool visible ) override; void setPreviewModeEnabled( bool previewMode );
void setFontSize( int fontSize ) override;
int fontSize() const override;
bool previewModeEnabled() const override; void scheduleUpdate();
void setPreviewModeEnabled( bool previewMode ) override; void scheduleReplotOfAllPlots();
virtual void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) {}
void scheduleUpdate() override; virtual void renderTo( QPaintDevice* paintDevice );
void scheduleReplotOfAllPlots() override;
void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) override {}
void renderTo( QPaintDevice* paintDevice ) override;
void renderTo( QPainter* painter, double scalingFactor ); void renderTo( QPainter* painter, double scalingFactor );
QSize sizeHint() const override; QSize sizeHint() const override;
@@ -93,28 +102,19 @@ protected:
QLabel* createTitleLabel() const; QLabel* createTitleLabel() const;
void showEvent( QShowEvent* event ) override; void showEvent( QShowEvent* event ) override;
void dragEnterEvent( QDragEnterEvent* event ) override;
void dragMoveEvent( QDragMoveEvent* event ) override;
void dragLeaveEvent( QDragLeaveEvent* event ) override;
void dropEvent( QDropEvent* event ) override;
bool hasHeightForWidth() const override; bool hasHeightForWidth() const override;
void updateMarginsFromPageLayout(); void updateMarginsFromPageLayout();
virtual bool willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const;
std::pair<int, int> rowAndColumnCount( int plotWidgetCount ) const; std::pair<int, int> rowAndColumnCount( int plotWidgetCount ) const;
virtual void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override; virtual void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
void setWidgetState( const QString& widgetState );
virtual bool showYAxis( int row, int column ) const; virtual bool showYAxis( int row, int column ) const;
void reinsertPlotWidgets(); void reinsertPlotWidgets();
int alignCanvasTops(); int alignCanvasTops();
void clearGridLayout(); void clearGridLayout();
caf::UiStyleSheet createDropTargetStyleSheet();
QList<QPointer<RiuQwtPlotWidget>> visiblePlotWidgets() const; QList<QPointer<RiuQwtPlotWidget>> visiblePlotWidgets() const;
QList<QPointer<RiuQwtPlotLegend>> legendsForVisiblePlots() const; QList<QPointer<RiuQwtPlotLegend>> legendsForVisiblePlots() const;
@@ -122,12 +122,15 @@ protected:
std::pair<int, int> findAvailableRowAndColumn( int startRow, int startColumn, int columnSpan, int columnCount ) const; std::pair<int, int> findAvailableRowAndColumn( int startRow, int startColumn, int columnSpan, int columnCount ) const;
void stashWidgetStates();
void restoreWidgetStates();
private slots: private slots:
virtual void performUpdate(); virtual void performUpdate();
void onLegendUpdated(); void onLegendUpdated();
protected: protected:
friend class RiuMultiPlotWindow; friend class RiuMultiPlotBook;
QPointer<QVBoxLayout> m_layout; QPointer<QVBoxLayout> m_layout;
QPointer<QHBoxLayout> m_plotLayout; QPointer<QHBoxLayout> m_plotLayout;
@@ -137,11 +140,10 @@ protected:
QList<QPointer<QLabel>> m_subTitles; QList<QPointer<QLabel>> m_subTitles;
QList<QPointer<RiuQwtPlotLegend>> m_legends; QList<QPointer<RiuQwtPlotLegend>> m_legends;
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets; QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimMultiPlotWindow> m_plotDefinition; caf::PdmPointer<RimPlotWindow> m_plotDefinition;
QPointer<QLabel> m_dropTargetPlaceHolder;
bool m_previewMode;
caf::UiStyleSheet m_dropTargetStyleSheet; bool m_previewMode;
bool m_showSubTitles;
private: private:
friend class RiaPlotWindowRedrawScheduler; friend class RiaPlotWindowRedrawScheduler;

View File

@@ -25,6 +25,7 @@
#include "RiaSummaryTools.h" #include "RiaSummaryTools.h"
#include "RimEnsembleCurveSetCollection.h" #include "RimEnsembleCurveSetCollection.h"
#include "RimMultiPlot.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimSummaryCaseMainCollection.h" #include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurveCollection.h" #include "RimSummaryCurveCollection.h"
@@ -576,7 +577,7 @@ void RiuPlotMainWindow::updateWellLogPlotToolBar()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::updateMultiPlotToolBar() void RiuPlotMainWindow::updateMultiPlotToolBar()
{ {
RimMultiPlotWindow* plotWindow = dynamic_cast<RimMultiPlotWindow*>( m_activePlotViewWindow.p() ); RimMultiPlot* plotWindow = dynamic_cast<RimMultiPlot*>( m_activePlotViewWindow.p() );
if ( plotWindow ) if ( plotWindow )
{ {
std::vector<caf::PdmFieldHandle*> toolBarFields = {plotWindow->columnCountField()}; std::vector<caf::PdmFieldHandle*> toolBarFields = {plotWindow->columnCountField()};
@@ -598,7 +599,7 @@ void RiuPlotMainWindow::updateMultiPlotToolBar()
void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi ) void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi )
{ {
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( m_activePlotViewWindow.p() ); RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( m_activePlotViewWindow.p() );
RimMultiPlotWindow* multiPlot = dynamic_cast<RimMultiPlotWindow*>( m_activePlotViewWindow.p() ); RimMultiPlot* multiPlot = dynamic_cast<RimMultiPlot*>( m_activePlotViewWindow.p() );
if ( multiPlot ) if ( multiPlot )
{ {
summaryPlot = caf::SelectionManager::instance()->selectedItemOfType<RimSummaryPlot>(); summaryPlot = caf::SelectionManager::instance()->selectedItemOfType<RimSummaryPlot>();

View File

@@ -23,9 +23,7 @@
#include "RiaFontCache.h" #include "RiaFontCache.h"
#include "RiaGuiApplication.h" #include "RiaGuiApplication.h"
#include "RiaPlotWindowRedrawScheduler.h" #include "RiaPlotWindowRedrawScheduler.h"
#include "RimPlot.h" #include "RimPlot.h"
#include "RimPlotCurve.h"
#include "RiuDraggableOverlayFrame.h" #include "RiuDraggableOverlayFrame.h"
#include "RiuPlotMainWindowTools.h" #include "RiuPlotMainWindowTools.h"
@@ -66,12 +64,12 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlot* plot, QWidget* parent ) RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlot* plotDefinition, QWidget* parent )
: QwtPlot( parent ) : QwtPlot( parent )
, m_plotDefinition( plot ) , m_plotDefinition( plotDefinition )
, m_draggable( true )
, m_overlayMargins( 5 ) , m_overlayMargins( 5 )
{ {
CAF_ASSERT( m_plotDefinition );
RiuQwtPlotTools::setCommonPlotBehaviour( this ); RiuQwtPlotTools::setCommonPlotBehaviour( this );
this->installEventFilter( this ); this->installEventFilter( this );
@@ -89,6 +87,14 @@ RiuQwtPlotWidget::~RiuQwtPlotWidget()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlot* RiuQwtPlotWidget::plotDefinition()
{
return m_plotDefinition;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -98,16 +104,31 @@ bool RiuQwtPlotWidget::isChecked() const
{ {
return m_plotDefinition->showWindow(); return m_plotDefinition->showWindow();
} }
return false; return false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setDraggable( bool draggable ) int RiuQwtPlotWidget::colSpan() const
{ {
m_draggable = draggable; if ( m_plotDefinition )
{
return m_plotDefinition->colSpan();
}
return 1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuQwtPlotWidget::rowSpan() const
{
if ( m_plotDefinition )
{
return m_plotDefinition->rowSpan();
}
return 1;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -160,14 +181,6 @@ void RiuQwtPlotWidget::setAxisFontsAndAlignment( QwtPlot::Axis axis,
setAxisTitle( axis, axisTitle ); setAxisTitle( axis, axisTitle );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlot* RiuQwtPlotWidget::plotDefinition() const
{
return m_plotDefinition;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -186,6 +199,40 @@ void RiuQwtPlotWidget::setAxisTitleEnabled( QwtPlot::Axis axis, bool enable )
applyAxisTitleToQwt( axis ); applyAxisTitleToQwt( axis );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setPlotTitle( const QString& plotTitle )
{
m_plotTitle = plotTitle;
applyPlotTitleToQwt();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QString& RiuQwtPlotWidget::plotTitle() const
{
return m_plotTitle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setPlotTitleEnabled( bool enabled )
{
m_plotTitleEnabled = enabled;
applyPlotTitleToQwt();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuQwtPlotWidget::plotTitleEnabled() const
{
return m_plotTitleEnabled;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -399,6 +446,22 @@ void RiuQwtPlotWidget::scheduleReplot()
RiaPlotWindowRedrawScheduler::instance()->schedulePlotWidgetReplot( this ); RiaPlotWindowRedrawScheduler::instance()->schedulePlotWidgetReplot( this );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::stashWidgetStates()
{
m_plotStyleSheet.stashWidgetStates();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::restoreWidgetStates()
{
m_plotStyleSheet.restoreWidgetStates();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -442,27 +505,20 @@ void RiuQwtPlotWidget::updateLayout()
updateOverlayFrameLayout(); updateOverlayFrameLayout();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiuQwtPlotWidget::sizeHint() const
{
return QSize( 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiuQwtPlotWidget::minimumSizeHint() const
{
return QSize( 0, 0 );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event ) bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
{ {
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event );
if ( wheelEvent && watched == canvas() )
{
event->accept();
emit onWheelEvent( wheelEvent );
return true;
}
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>( event ); QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>( event );
if ( mouseEvent ) if ( mouseEvent )
{ {
@@ -470,48 +526,32 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
bool toggleItemInSelection = ( mouseEvent->modifiers() & Qt::ControlModifier ) != 0; bool toggleItemInSelection = ( mouseEvent->modifiers() & Qt::ControlModifier ) != 0;
if ( m_draggable && mouseEvent->type() == QMouseEvent::MouseButtonPress && mouseEvent->button() == Qt::LeftButton ) if ( mouseEvent->type() == QMouseEvent::MouseButtonPress && mouseEvent->button() == Qt::LeftButton )
{ {
m_clickPosition = mouseEvent->pos(); m_clickPosition = mouseEvent->pos();
} }
if ( watched == this && !this->canvas()->geometry().contains( mouseEvent->pos() ) ) if ( watched == this && !this->canvas()->geometry().contains( mouseEvent->pos() ) )
{ {
if ( m_draggable && mouseEvent->type() == QMouseEvent::MouseMove && if ( mouseEvent->type() == QMouseEvent::MouseButtonRelease && ( mouseEvent->button() == Qt::LeftButton ) &&
( mouseEvent->buttons() & Qt::LeftButton ) && !m_clickPosition.isNull() ) !m_clickPosition.isNull() )
{
int dragLength = ( mouseEvent->pos() - m_clickPosition ).manhattanLength();
if ( dragLength >= QApplication::startDragDistance() )
{
QPixmap pixmap = this->grab();
QDrag* drag = new QDrag( this );
QMimeData* mimeData = new QMimeData;
mimeData->setImageData( pixmap );
drag->setMimeData( mimeData );
drag->setPixmap( pixmap );
drag->setHotSpot( mouseEvent->pos() );
drag->exec( Qt::MoveAction );
return true;
}
}
else if ( mouseEvent->type() == QMouseEvent::MouseButtonRelease &&
( mouseEvent->button() == Qt::LeftButton ) && !m_clickPosition.isNull() )
{ {
QWidget* childClicked = this->childAt( m_clickPosition ); QWidget* childClicked = this->childAt( m_clickPosition );
if ( childClicked ) if ( childClicked )
{ {
QwtScaleWidget* scaleWidget = qobject_cast<QwtScaleWidget*>( childClicked ); QwtScaleWidget* scaleWidget = qobject_cast<QwtScaleWidget*>( childClicked );
if ( scaleWidget ) if ( scaleWidget )
{ {
onAxisSelected( scaleWidget, toggleItemInSelection ); onAxisSelected( scaleWidget, toggleItemInSelection );
m_clickPosition = QPoint();
return true; return true;
} }
} }
else else
{ {
selectPlotOwner( toggleItemInSelection );
endZoomOperations(); endZoomOperations();
emit plotSelected( toggleItemInSelection );
m_clickPosition = QPoint();
return true; return true;
} }
} }
@@ -521,8 +561,9 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
if ( mouseEvent->type() == QMouseEvent::MouseButtonRelease && mouseEvent->button() == Qt::LeftButton && if ( mouseEvent->type() == QMouseEvent::MouseButtonRelease && mouseEvent->button() == Qt::LeftButton &&
!m_clickPosition.isNull() ) !m_clickPosition.isNull() )
{ {
selectClosestCurve( mouseEvent->pos(), toggleItemInSelection );
endZoomOperations(); endZoomOperations();
selectClosestCurve( mouseEvent->pos(), toggleItemInSelection );
m_clickPosition = QPoint();
return true; return true;
} }
} }
@@ -563,6 +604,28 @@ void RiuQwtPlotWidget::resizeEvent( QResizeEvent* event )
event->accept(); event->accept();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::keyPressEvent( QKeyEvent* event )
{
emit onKeyPressEvent( event );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::applyPlotTitleToQwt()
{
QString plotTitleToApply = m_plotTitleEnabled ? m_plotTitle : QString( "" );
QwtText plotTitle = this->title();
if ( plotTitleToApply != plotTitle.text() )
{
plotTitle.setText( plotTitleToApply );
setTitle( plotTitle );
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -687,7 +750,7 @@ void RiuQwtPlotWidget::onAxisSelected( QwtScaleWidget* scale, bool toggleItemInS
axisId = i; axisId = i;
} }
} }
m_plotDefinition->onAxisSelected( axisId, toggleItemInSelection ); emit axisSelected( axisId, toggleItemInSelection );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -706,19 +769,6 @@ caf::UiStyleSheet RiuQwtPlotWidget::createPlotStyleSheet() const
styleSheet.property( "selected" ).set( "border", QString( "1px solid %1" ).arg( highlightColor.name() ) ); styleSheet.property( "selected" ).set( "border", QString( "1px solid %1" ).arg( highlightColor.name() ) );
if ( m_draggable )
{
QString backgroundGradient = QString( QString( "qlineargradient( x1 : 1, y1 : 0, x2 : 1, y2 : 1,"
"stop: 0 %1, stop: 0.02 %2, stop:1 %3 )" )
.arg( blendedHighlightColor.name() )
.arg( nearlyBackgroundColor.name() )
.arg( backgroundColor.name() ) );
styleSheet.pseudoState( "hover" ).set( "background", backgroundGradient );
styleSheet.pseudoState( "hover" ).set( "border", QString( "1px dashed %1" ).arg( blendedHighlightColor.name() ) );
}
styleSheet.property( "dropTargetBefore" ).set( "border-left", "1px solid lime" );
styleSheet.property( "dropTargetAfter" ).set( "border-right", "1px solid lime" );
return styleSheet; return styleSheet;
} }
@@ -784,22 +834,6 @@ void RiuQwtPlotWidget::updateOverlayFrameLayout()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::selectPlotOwner( bool toggleItemInSelection )
{
if ( toggleItemInSelection )
{
RiuPlotMainWindowTools::toggleItemInSelection( m_plotDefinition );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( m_plotDefinition );
}
scheduleReplot();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -830,24 +864,10 @@ void RiuQwtPlotWidget::selectClosestCurve( const QPoint& pos, bool toggleItemInS
resetCurveHighlighting(); resetCurveHighlighting();
if ( closestCurve && distMin < 20 ) if ( closestCurve && distMin < 20 )
{ {
if ( m_plotDefinition )
{
RimPlotCurve* selectedCurve = dynamic_cast<RimPlotCurve*>(
m_plotDefinition->findPdmObjectFromQwtCurve( closestCurve ) );
if ( selectedCurve )
{
if ( toggleItemInSelection )
{
RiuPlotMainWindowTools::toggleItemInSelection( selectedCurve );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( selectedCurve );
}
// TODO: highlight all selected curves // TODO: highlight all selected curves
highlightCurve( closestCurve ); highlightCurve( closestCurve );
} emit curveSelected( closestCurve, toggleItemInSelection );
}
if ( distMin < 10 ) if ( distMin < 10 )
{ {
selectPoint( closestCurve, closestCurvePoint ); selectPoint( closestCurve, closestCurvePoint );
@@ -860,7 +880,7 @@ void RiuQwtPlotWidget::selectClosestCurve( const QPoint& pos, bool toggleItemInS
} }
else else
{ {
selectPlotOwner( toggleItemInSelection ); emit plotSelected( toggleItemInSelection );
} }
} }

View File

@@ -45,6 +45,7 @@ class QEvent;
class QLabel; class QLabel;
class QPainter; class QPainter;
class QPaintDevice; class QPaintDevice;
class QWheelEvent;
//================================================================================================== //==================================================================================================
// //
@@ -56,14 +57,15 @@ class RiuQwtPlotWidget : public QwtPlot
Q_OBJECT Q_OBJECT
public: public:
RiuQwtPlotWidget( RimPlot* plotTrackDefinition, QWidget* parent = nullptr ); RiuQwtPlotWidget( RimPlot* plotDefinition, QWidget* parent = nullptr );
~RiuQwtPlotWidget() override; ~RiuQwtPlotWidget() override;
RimPlot* plotDefinition() const; RimPlot* plotDefinition();
bool isChecked() const; bool isChecked() const;
void setDraggable( bool draggable ); int colSpan() const;
int rowSpan() const;
int axisTitleFontSize( QwtPlot::Axis axis ) const; int axisTitleFontSize( QwtPlot::Axis axis ) const;
int axisValueFontSize( QwtPlot::Axis axis ) const; int axisValueFontSize( QwtPlot::Axis axis ) const;
@@ -76,6 +78,11 @@ public:
void setAxisTitleText( QwtPlot::Axis axis, const QString& title ); void setAxisTitleText( QwtPlot::Axis axis, const QString& title );
void setAxisTitleEnabled( QwtPlot::Axis axis, bool enable ); void setAxisTitleEnabled( QwtPlot::Axis axis, bool enable );
void setPlotTitle( const QString& plotTitle );
const QString& plotTitle() const;
void setPlotTitleEnabled( bool enabled );
bool plotTitleEnabled() const;
QwtInterval axisRange( QwtPlot::Axis axis ); QwtInterval axisRange( QwtPlot::Axis axis );
void setAxisRange( QwtPlot::Axis axis, double min, double max ); void setAxisRange( QwtPlot::Axis axis, double min, double max );
@@ -99,6 +106,8 @@ public:
QPoint dragStartPosition() const; QPoint dragStartPosition() const;
void scheduleReplot(); void scheduleReplot();
void stashWidgetStates();
void restoreWidgetStates();
void setWidgetState( const QString& widgetState ); void setWidgetState( const QString& widgetState );
void addOverlayFrame( RiuDraggableOverlayFrame* overlayWidget ); void addOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
@@ -109,14 +118,21 @@ public:
void renderTo( QPaintDevice* painter, const QRect& targetRect ); void renderTo( QPaintDevice* painter, const QRect& targetRect );
int overlayMargins() const; int overlayMargins() const;
signals:
void plotSelected( bool toggleSelection );
void axisSelected( int axisId, bool toggleSelection );
void curveSelected( QwtPlotCurve* curve, bool toggleSelection );
void onKeyPressEvent( QKeyEvent* event );
void onWheelEvent( QWheelEvent* event );
protected: protected:
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
bool eventFilter( QObject* watched, QEvent* event ) override; bool eventFilter( QObject* watched, QEvent* event ) override;
void hideEvent( QHideEvent* event ) override; void hideEvent( QHideEvent* event ) override;
void showEvent( QShowEvent* event ) override; void showEvent( QShowEvent* event ) override;
void resizeEvent( QResizeEvent* event ) override; void resizeEvent( QResizeEvent* event ) override;
void keyPressEvent( QKeyEvent* event ) override;
void applyPlotTitleToQwt();
void applyAxisTitleToQwt( QwtPlot::Axis axis ); void applyAxisTitleToQwt( QwtPlot::Axis axis );
virtual void selectPoint( QwtPlotCurve* curve, int pointNumber ); virtual void selectPoint( QwtPlotCurve* curve, int pointNumber );
@@ -125,7 +141,6 @@ protected:
virtual void endZoomOperations(); virtual void endZoomOperations();
private: private:
void selectPlotOwner( bool toggleItemInSelection = false );
void selectClosestCurve( const QPoint& pos, bool toggleItemInSelection = false ); void selectClosestCurve( const QPoint& pos, bool toggleItemInSelection = false );
static int defaultMinimumWidth(); static int defaultMinimumWidth();
void replot() override; void replot() override;
@@ -145,8 +160,9 @@ private:
std::map<QwtPlot::Axis, QString> m_axisTitles; std::map<QwtPlot::Axis, QString> m_axisTitles;
std::map<QwtPlot::Axis, bool> m_axisTitlesEnabled; std::map<QwtPlot::Axis, bool> m_axisTitlesEnabled;
QPointer<QwtPlotPicker> m_plotPicker; QPointer<QwtPlotPicker> m_plotPicker;
bool m_draggable;
const int m_overlayMargins; const int m_overlayMargins;
QString m_plotTitle;
bool m_plotTitleEnabled;
QList<QPointer<RiuDraggableOverlayFrame>> m_overlayFrames; QList<QPointer<RiuDraggableOverlayFrame>> m_overlayFrames;

View File

@@ -92,8 +92,8 @@ static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider;
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent /*= nullptr*/ ) RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= nullptr*/ )
: RiuQwtPlotWidget( plotDefinition, parent ) : RiuQwtPlotWidget( plot, parent )
{ {
// LeftButton for the zooming // LeftButton for the zooming
m_zoomerLeft = new RiuQwtPlotZoomer( canvas() ); m_zoomerLeft = new RiuQwtPlotZoomer( canvas() );
@@ -125,9 +125,6 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent /
RiuQwtPlotTools::setCommonPlotBehaviour( this ); RiuQwtPlotTools::setCommonPlotBehaviour( this );
RiuQwtPlotTools::setDefaultAxes( this ); RiuQwtPlotTools::setDefaultAxes( this );
this->installEventFilter( this );
this->canvas()->installEventFilter( this );
setLegendVisible( true ); setLegendVisible( true );
} }
@@ -156,14 +153,6 @@ void RiuSummaryQwtPlot::useTimeBasedTimeAxis()
setAxisScaleDraw( QwtPlot::xBottom, new QwtScaleDraw() ); setAxisScaleDraw( QwtPlot::xBottom, new QwtScaleDraw() );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuSummaryQwtPlot::ownerViewWindow() const
{
return dynamic_cast<RimViewWindow*>( plotDefinition() );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -207,19 +196,6 @@ void RiuSummaryQwtPlot::setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithm
if ( m_wheelZoomer ) m_wheelZoomer->setAxisIsLogarithmic( axis, logarithmic ); if ( m_wheelZoomer ) m_wheelZoomer->setAxisIsLogarithmic( axis, logarithmic );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::keyPressEvent( QKeyEvent* keyEvent )
{
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( plotDefinition() );
if ( summaryPlot )
{
summaryPlot->handleKeyPressEvent( keyEvent );
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -228,7 +204,7 @@ void RiuSummaryQwtPlot::contextMenuEvent( QContextMenuEvent* event )
QMenu menu; QMenu menu;
caf::CmdFeatureMenuBuilder menuBuilder; caf::CmdFeatureMenuBuilder menuBuilder;
caf::SelectionManager::instance()->setSelectedItem( plotDefinition() ); emit plotSelected( false );
menuBuilder << "RicShowPlotDataFeature"; menuBuilder << "RicShowPlotDataFeature";
menuBuilder << "RicSavePlotTemplateFeature"; menuBuilder << "RicSavePlotTemplateFeature";
@@ -274,7 +250,5 @@ void RiuSummaryQwtPlot::endZoomOperations()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::onZoomedSlot() void RiuSummaryQwtPlot::onZoomedSlot()
{ {
plotDefinition()->setAutoScaleXEnabled( false ); emit plotZoomed();
plotDefinition()->setAutoScaleYEnabled( false );
plotDefinition()->updateZoomFromQwt();
} }

View File

@@ -27,6 +27,7 @@
#include <QPointer> #include <QPointer>
class RimEnsembleParameterColorHandlerInterface; class RimEnsembleParameterColorHandlerInterface;
class RimSummaryPlot;
class RiuCvfOverlayItemWidget; class RiuCvfOverlayItemWidget;
class RiuQwtPlotZoomer; class RiuQwtPlotZoomer;
class RiuQwtPlotWheelZoomer; class RiuQwtPlotWheelZoomer;
@@ -36,12 +37,12 @@ class RiuQwtPlotWheelZoomer;
// //
// //
//================================================================================================== //==================================================================================================
class RiuSummaryQwtPlot : public RiuQwtPlotWidget, public RiuInterfaceToViewWindow class RiuSummaryQwtPlot : public RiuQwtPlotWidget
{ {
Q_OBJECT; Q_OBJECT;
public: public:
RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent = nullptr ); RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent = nullptr );
~RiuSummaryQwtPlot() override; ~RiuSummaryQwtPlot() override;
void useDateBasedTimeAxis( void useDateBasedTimeAxis(
@@ -52,15 +53,15 @@ public:
void useTimeBasedTimeAxis(); void useTimeBasedTimeAxis();
RimViewWindow* ownerViewWindow() const override;
void setLegendFontSize( int fontSize ); void setLegendFontSize( int fontSize );
void setLegendVisible( bool visible ); void setLegendVisible( bool visible );
void setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithmic ); void setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithmic );
signals:
void plotZoomed();
protected: protected:
void keyPressEvent( QKeyEvent* ) override;
void contextMenuEvent( QContextMenuEvent* ) override; void contextMenuEvent( QContextMenuEvent* ) override;
void setDefaults(); void setDefaults();
bool isZoomerActive() const override; bool isZoomerActive() const override;

View File

@@ -73,22 +73,6 @@ void RiuWellLogPlot::renderTo( QPaintDevice* paintDevice )
m_trackScrollBar->setVisible( true ); m_trackScrollBar->setVisible( true );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::keyPressEvent( QKeyEvent* event )
{
wellLogPlotDefinition()->handleKeyPressEvent( event );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogPlot::willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const
{
return dynamic_cast<const RiuWellLogTrack*>( plotWidget ) != nullptr;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -131,7 +115,7 @@ void RiuWellLogPlot::slotSetMinDepth( int value )
double delta = value - minimumDepth; double delta = value - minimumDepth;
wellLogPlotDefinition()->setDepthAxisRange( minimumDepth + delta, maximumDepth + delta ); wellLogPlotDefinition()->setDepthAxisRange( minimumDepth + delta, maximumDepth + delta );
wellLogPlotDefinition()->setAutoScaleYEnabled( false ); wellLogPlotDefinition()->setAutoScaleDepthEnabled( false );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -23,7 +23,7 @@
class RiuQwtPlotWidget; class RiuQwtPlotWidget;
class RimWellLogPlot; class RimWellLogPlot;
class RiuWellLogPlot : public RiuMultiPlotPage, public RiuInterfaceToViewWindow class RiuWellLogPlot : public RiuMultiPlotPage
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -35,8 +35,6 @@ public:
void renderTo( QPaintDevice* paintDevice ) override; void renderTo( QPaintDevice* paintDevice ) override;
protected: protected:
void keyPressEvent( QKeyEvent* event ) override;
bool willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const override;
bool showYAxis( int row, int column ) const override; bool showYAxis( int row, int column ) const override;
void reinsertScrollbar(); void reinsertScrollbar();

View File

@@ -27,14 +27,11 @@
#include <QWheelEvent> #include <QWheelEvent>
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent /*= nullptr */ ) RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* track, QWidget* parent /*= nullptr */ )
: RiuQwtPlotWidget( plotTrackDefinition, parent ) : RiuQwtPlotWidget( track, parent )
{ {
setAxisEnabled( QwtPlot::yLeft, true ); setAxisEnabled( QwtPlot::yLeft, true );
setAxisEnabled( QwtPlot::yRight, false ); setAxisEnabled( QwtPlot::yRight, false );
@@ -47,49 +44,6 @@ RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget*
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuWellLogTrack::~RiuWellLogTrack() {} RiuWellLogTrack::~RiuWellLogTrack() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogTrack::eventFilter( QObject* watched, QEvent* event )
{
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event );
if ( wheelEvent && watched == canvas() )
{
RimWellLogTrack* track = dynamic_cast<RimWellLogTrack*>( plotDefinition() );
CAF_ASSERT( track );
RimWellLogPlot* wellLogPlot = nullptr;
track->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
if ( wheelEvent->modifiers() & Qt::ControlModifier )
{
QwtScaleMap scaleMap = canvasMap( QwtPlot::yLeft );
double zoomCenter = scaleMap.invTransform( wheelEvent->pos().y() );
if ( wheelEvent->delta() > 0 )
{
wellLogPlot->setDepthAxisRangeByFactorAndCenter( RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
}
else
{
wellLogPlot->setDepthAxisRangeByFactorAndCenter( 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
}
}
else
{
wellLogPlot->setDepthAxisRangeByPanDepth( wheelEvent->delta() < 0 ? RIU_SCROLLWHEEL_PANFACTOR
: -RIU_SCROLLWHEEL_PANFACTOR );
}
event->accept();
return true;
}
}
return RiuQwtPlotWidget::eventFilter( watched, event );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -21,6 +21,7 @@
#include "RiuQwtPlotWidget.h" #include "RiuQwtPlotWidget.h"
class RimWellLogTrack; class RimWellLogTrack;
class QWheelEvent;
//================================================================================================== //==================================================================================================
// //
@@ -32,12 +33,9 @@ class RiuWellLogTrack : public RiuQwtPlotWidget
Q_OBJECT Q_OBJECT
public: public:
RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent = nullptr ); RiuWellLogTrack( RimWellLogTrack* track, QWidget* parent = nullptr );
~RiuWellLogTrack() override; ~RiuWellLogTrack() override;
protected:
bool eventFilter( QObject* watched, QEvent* event ) override;
private: private:
void setAxisEnabled( QwtPlot::Axis axis, bool enabled ); void setAxisEnabled( QwtPlot::Axis axis, bool enabled );
}; };