mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
* Refactor interface to PdmObjectHandle and PdmFieldHandle Return objects instead of passing in structures as parameters * Add nodiscard to several functions * Remove redundant this-> * Rename to ptrReferencedObjectsByType
128 lines
4.5 KiB
C++
128 lines
4.5 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2022 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.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RimSeismicDataCollection.h"
|
|
|
|
#include "RiaLogging.h"
|
|
|
|
#include "Rim3dView.h"
|
|
#include "RimGridView.h"
|
|
#include "RimProject.h"
|
|
#include "RimSeismicData.h"
|
|
#include "RimSeismicSectionCollection.h"
|
|
|
|
#include <QFile>
|
|
#include <QFileInfo>
|
|
|
|
CAF_PDM_SOURCE_INIT( RimSeismicDataCollection, "SeismicDataCollection", "SeismicCollection" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimSeismicDataCollection::RimSeismicDataCollection()
|
|
{
|
|
CAF_PDM_InitObject( "Seismic", ":/Seismic16x16.png" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_seismicData, "SeismicData", "Seismic Data" );
|
|
m_seismicData.uiCapability()->setUiTreeHidden( true );
|
|
|
|
setDeletable( false );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimSeismicDataCollection::~RimSeismicDataCollection()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimSeismicData* RimSeismicDataCollection::importSeismicFromFile( const QString fileName )
|
|
{
|
|
RimSeismicData* seisData = new RimSeismicData();
|
|
seisData->setFileName( fileName );
|
|
|
|
QFileInfo fi( fileName );
|
|
seisData->setUserDescription( fi.baseName() );
|
|
m_seismicData.push_back( seisData );
|
|
updateAllRequiredEditors();
|
|
|
|
if ( m_seismicData.size() == 1 ) updateTreeForAllViews();
|
|
|
|
return seisData;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimSeismicData*> RimSeismicDataCollection::seismicData() const
|
|
{
|
|
return m_seismicData.childrenByType();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimSeismicDataCollection::isEmpty()
|
|
{
|
|
return !m_seismicData.hasChildren();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimSeismicDataCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects )
|
|
{
|
|
updateViews();
|
|
if ( m_seismicData.size() == 0 ) updateTreeForAllViews();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimSeismicDataCollection::updateViews()
|
|
{
|
|
RimProject* proj = RimProject::current();
|
|
std::vector<RimGridView*> views;
|
|
proj->allVisibleGridViews( views );
|
|
|
|
for ( auto view : views )
|
|
{
|
|
view->scheduleCreateDisplayModelAndRedraw();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimSeismicDataCollection::updateTreeForAllViews()
|
|
{
|
|
RimProject* proj = RimProject::current();
|
|
if ( proj != nullptr )
|
|
{
|
|
std::vector<RimGridView*> views;
|
|
proj->allVisibleGridViews( views );
|
|
for ( auto view : views )
|
|
{
|
|
view->updateAllRequiredEditors();
|
|
}
|
|
}
|
|
}
|