mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
RFT file improvements
* Guard null pointer access * Delay open of RFT files until data is requested When opening ensemble summary cases, the opening of RFT files can take some time. Avoid this by delaying the file open operation. * Fix infinite update loop for RFT plots * Avoid moving the tracker line when clicking in the plot
This commit is contained in:
@@ -1210,7 +1210,7 @@ void RiaGuiApplication::onProjectBeingOpened()
|
||||
// When importing a project, do not maximize the first MDI window to be created
|
||||
m_maximizeWindowGuard = std::make_unique<RiuMdiMaximizeWindowGuard>();
|
||||
|
||||
m_mainWindow->setBlockSubWindowActivatedSignal( true );
|
||||
if ( m_mainWindow ) m_mainWindow->setBlockSubWindowActivatedSignal( true );
|
||||
if ( mainPlotWindow() ) mainPlotWindow()->setBlockSubWindowActivatedSignal( true );
|
||||
}
|
||||
|
||||
@@ -1272,7 +1272,7 @@ void RiaGuiApplication::onProjectOpened()
|
||||
|
||||
processEvents();
|
||||
|
||||
m_mainWindow->setBlockSubWindowActivatedSignal( false );
|
||||
if ( m_mainWindow ) m_mainWindow->setBlockSubWindowActivatedSignal( false );
|
||||
if ( mainPlotWindow() ) mainPlotWindow()->setBlockSubWindowActivatedSignal( false );
|
||||
|
||||
// Make sure to process events before this function to avoid strange Qt crash
|
||||
|
@@ -41,8 +41,9 @@
|
||||
RifReaderOpmRft::RifReaderOpmRft( const QString& fileName, const QString& dataDeckFileName )
|
||||
: m_segmentResultItemCount( 0 )
|
||||
, m_connectionResultItemCount( 0 )
|
||||
, m_fileName( fileName )
|
||||
, m_dataDeckFileName( dataDeckFileName )
|
||||
{
|
||||
openFiles( fileName, dataDeckFileName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -51,8 +52,8 @@ RifReaderOpmRft::RifReaderOpmRft( const QString& fileName, const QString& dataDe
|
||||
RifReaderOpmRft::RifReaderOpmRft( const QString& fileName )
|
||||
: m_segmentResultItemCount( 0 )
|
||||
, m_connectionResultItemCount( 0 )
|
||||
, m_fileName( fileName )
|
||||
{
|
||||
openFiles( fileName, "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -60,6 +61,8 @@ RifReaderOpmRft::RifReaderOpmRft( const QString& fileName )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseRftAddress> RifReaderOpmRft::eclipseRftAddresses()
|
||||
{
|
||||
openFiles();
|
||||
|
||||
return m_addresses;
|
||||
}
|
||||
|
||||
@@ -68,6 +71,8 @@ std::set<RifEclipseRftAddress> RifReaderOpmRft::eclipseRftAddresses()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vector<double>* values )
|
||||
{
|
||||
openFiles();
|
||||
|
||||
auto wellName = rftAddress.wellName().toStdString();
|
||||
auto resultName = rftAddress.segmentResultName().toStdString();
|
||||
|
||||
@@ -182,6 +187,8 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<QDateTime> RifReaderOpmRft::availableTimeSteps( const QString& wellName )
|
||||
{
|
||||
openFiles();
|
||||
|
||||
std::set<QDateTime> timeSteps;
|
||||
|
||||
for ( const auto& address : m_addresses )
|
||||
@@ -201,6 +208,8 @@ std::set<QDateTime>
|
||||
RifReaderOpmRft::availableTimeSteps( const QString& wellName,
|
||||
const RifEclipseRftAddress::RftWellLogChannelType& wellLogChannelName )
|
||||
{
|
||||
openFiles();
|
||||
|
||||
if ( wellLogChannelName == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES )
|
||||
return m_rftSegmentTimeSteps;
|
||||
|
||||
@@ -223,6 +232,8 @@ std::set<QDateTime>
|
||||
RifReaderOpmRft::availableTimeSteps( const QString& wellName,
|
||||
const std::set<RifEclipseRftAddress::RftWellLogChannelType>& relevantChannels )
|
||||
{
|
||||
openFiles();
|
||||
|
||||
std::set<QDateTime> timeSteps;
|
||||
|
||||
for ( const auto& address : m_addresses )
|
||||
@@ -240,6 +251,8 @@ std::set<QDateTime>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseRftAddress::RftWellLogChannelType> RifReaderOpmRft::availableWellLogChannels( const QString& wellName )
|
||||
{
|
||||
openFiles();
|
||||
|
||||
std::set<RifEclipseRftAddress::RftWellLogChannelType> types;
|
||||
|
||||
for ( const auto& a : m_addresses )
|
||||
@@ -258,6 +271,8 @@ std::set<RifEclipseRftAddress::RftWellLogChannelType> RifReaderOpmRft::available
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<QString> RifReaderOpmRft::wellNames()
|
||||
{
|
||||
openFiles();
|
||||
|
||||
return m_wellNames;
|
||||
}
|
||||
|
||||
@@ -266,6 +281,8 @@ std::set<QString> RifReaderOpmRft::wellNames()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderOpmRft::cellIndices( const RifEclipseRftAddress& rftAddress, std::vector<caf::VecIjk>* indices )
|
||||
{
|
||||
openFiles();
|
||||
|
||||
auto wellName = rftAddress.wellName().toStdString();
|
||||
|
||||
auto date = rftAddress.timeStep().date();
|
||||
@@ -324,6 +341,8 @@ std::map<int, int> RifReaderOpmRft::branchIdsAndOneBasedIndices( const QString&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifRftSegment RifReaderOpmRft::segmentForWell( const QString& wellName, const QDateTime& timeStep )
|
||||
{
|
||||
openFiles();
|
||||
|
||||
int y = timeStep.date().year();
|
||||
int m = timeStep.date().month();
|
||||
int d = timeStep.date().day();
|
||||
@@ -975,3 +994,16 @@ std::vector<float>
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderOpmRft::openFiles()
|
||||
{
|
||||
// The file open operations can be costly, so do lazy loading of the files
|
||||
// NB! Make sure that this function is called from all public functions that needs to access the files
|
||||
|
||||
if ( isOpen() ) return;
|
||||
|
||||
openFiles( m_fileName, m_dataDeckFileName );
|
||||
}
|
||||
|
@@ -92,6 +92,8 @@ private:
|
||||
std::vector<float>
|
||||
resultAsFloat( const std::string& resultName, const std::string& wellName, int year, int month, int day ) const;
|
||||
|
||||
void openFiles();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Opm::EclIO::ERft> m_opm_rft;
|
||||
|
||||
@@ -106,4 +108,7 @@ private:
|
||||
size_t m_connectionResultItemCount;
|
||||
|
||||
std::map<std::string, std::vector<std::pair<int, int>>> m_wseglink;
|
||||
|
||||
QString m_fileName;
|
||||
QString m_dataDeckFileName;
|
||||
};
|
||||
|
@@ -1035,37 +1035,40 @@ void RiuQwtPlotWidget::highlightPlotItems( const std::set<const QwtPlotItem*>& c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::resetPlotItemHighlighting( bool doUpdateCurveOrder )
|
||||
{
|
||||
auto plotItemList = m_plot->itemList();
|
||||
for ( QwtPlotItem* plotItem : plotItemList )
|
||||
if ( !m_originalZValues.empty() )
|
||||
{
|
||||
if ( auto* plotCurve = dynamic_cast<QwtPlotCurve*>( plotItem ) )
|
||||
auto plotItemList = m_plot->itemList();
|
||||
for ( QwtPlotItem* plotItem : plotItemList )
|
||||
{
|
||||
auto* riuPlotCurve = dynamic_cast<RiuPlotCurve*>( plotItem );
|
||||
|
||||
if ( auto rimPlotCurve =
|
||||
dynamic_cast<RimPlotCurve*>( m_plotDefinition->findPdmObjectFromPlotCurve( riuPlotCurve ) ) )
|
||||
if ( auto* plotCurve = dynamic_cast<QwtPlotCurve*>( plotItem ) )
|
||||
{
|
||||
rimPlotCurve->updateCurveAppearance();
|
||||
double zValue = m_originalZValues[plotCurve];
|
||||
riuPlotCurve->setZ( zValue );
|
||||
continue;
|
||||
auto* riuPlotCurve = dynamic_cast<RiuPlotCurve*>( plotItem );
|
||||
|
||||
if ( auto rimPlotCurve =
|
||||
dynamic_cast<RimPlotCurve*>( m_plotDefinition->findPdmObjectFromPlotCurve( riuPlotCurve ) ) )
|
||||
{
|
||||
rimPlotCurve->updateCurveAppearance();
|
||||
double zValue = m_originalZValues[plotCurve];
|
||||
riuPlotCurve->setZ( zValue );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
auto* plotShapeItem = dynamic_cast<QwtPlotShapeItem*>( plotItem );
|
||||
if ( plotShapeItem )
|
||||
{
|
||||
QPen pen = plotShapeItem->pen();
|
||||
|
||||
auto color = RiuGuiTheme::getColorByVariableName( "markerColor" );
|
||||
|
||||
pen.setColor( color );
|
||||
pen.setWidth( 1 );
|
||||
plotShapeItem->setPen( pen );
|
||||
plotShapeItem->setZ( plotShapeItem->z() - 100.0 );
|
||||
}
|
||||
}
|
||||
|
||||
auto* plotShapeItem = dynamic_cast<QwtPlotShapeItem*>( plotItem );
|
||||
if ( plotShapeItem )
|
||||
{
|
||||
QPen pen = plotShapeItem->pen();
|
||||
|
||||
auto color = RiuGuiTheme::getColorByVariableName( "markerColor" );
|
||||
|
||||
pen.setColor( color );
|
||||
pen.setWidth( 1 );
|
||||
plotShapeItem->setPen( pen );
|
||||
plotShapeItem->setZ( plotShapeItem->z() - 100.0 );
|
||||
}
|
||||
m_originalZValues.clear();
|
||||
}
|
||||
m_originalZValues.clear();
|
||||
|
||||
resetPlotAxisHighlighting();
|
||||
|
||||
|
@@ -253,6 +253,8 @@ void RiuWellLogTrack::onMouseMoveEvent( QMouseEvent* mouseEvent )
|
||||
{
|
||||
if ( !m_plotDefinition ) return;
|
||||
|
||||
if ( mouseEvent->type() != QMouseEvent::MouseMove ) return;
|
||||
|
||||
RimDepthTrackPlot* depthTrackPlot = nullptr;
|
||||
m_plotDefinition->firstAncestorOfType( depthTrackPlot );
|
||||
if ( !depthTrackPlot || !depthTrackPlot->isDepthMarkerLineEnabled() ) return;
|
||||
|
Reference in New Issue
Block a user