mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5285 Visualization and update of Surfaces
This commit is contained in:
@@ -539,6 +539,15 @@ void RimEclipseView::onCreateDisplayModel()
|
||||
m_reservoirGridPartManager->scaleTransform() );
|
||||
nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() );
|
||||
|
||||
// Surfaces
|
||||
|
||||
m_surfaceVizModel->removeAllParts();
|
||||
if ( m_surfaceCollection )
|
||||
{
|
||||
m_surfaceCollection->appendPartsToModel( m_surfaceVizModel.p(), m_reservoirGridPartManager->scaleTransform() );
|
||||
nativeOrOverrideViewer()->addStaticModelOnce( m_surfaceVizModel.p(), isUsingOverrideViewer() );
|
||||
}
|
||||
|
||||
// Well path model
|
||||
|
||||
m_wellPathPipeVizModel->removeAllParts();
|
||||
|
||||
@@ -298,6 +298,15 @@ void RimGeoMechView::onCreateDisplayModel()
|
||||
m_intersectionCollection->appendPartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() );
|
||||
nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() );
|
||||
|
||||
// Surfaces
|
||||
|
||||
m_surfaceVizModel->removeAllParts();
|
||||
if ( m_surfaceCollection )
|
||||
{
|
||||
m_surfaceCollection->appendPartsToModel( m_surfaceVizModel.p(), scaleTransform() );
|
||||
nativeOrOverrideViewer()->addStaticModelOnce( m_surfaceVizModel.p(), isUsingOverrideViewer() );
|
||||
}
|
||||
|
||||
// If the animation was active before recreating everything, make viewer view current frame
|
||||
|
||||
if ( isTimeStepDependentDataVisibleInThisOrComparisonView() )
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "RivSingleCellPartGenerator.h"
|
||||
|
||||
#include "cvfModel.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfScene.h"
|
||||
|
||||
@@ -103,6 +104,9 @@ RimGridView::RimGridView()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_surfaceCollection, "SurfaceInViewCollection", "Surface Collection Field", "", "", "" );
|
||||
m_surfaceCollection.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
m_surfaceVizModel = new cvf::ModelBasicList;
|
||||
m_surfaceVizModel->setName( "SurfaceModel" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -90,6 +90,8 @@ protected:
|
||||
void initAfterRead() override;
|
||||
|
||||
protected:
|
||||
cvf::ref<cvf::ModelBasicList> m_surfaceVizModel;
|
||||
|
||||
// Fields
|
||||
caf::PdmChildField<RimIntersectionCollection*> m_intersectionCollection;
|
||||
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RimSurface.h"
|
||||
|
||||
#include "RimSurfaceCollection.h"
|
||||
|
||||
#include "RigSurface.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <fstream>
|
||||
#include <iosfwd>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSurface, "Surface" );
|
||||
|
||||
@@ -56,6 +57,30 @@ void RimSurface::setSurfaceFilePath( const QString& filePath )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSurface::surfaceFilePath()
|
||||
{
|
||||
return m_surfaceDefinitionFilePath().path();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurface::setColor( const cvf::Color3f& color )
|
||||
{
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3f RimSurface::color() const
|
||||
{
|
||||
return m_color();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -64,6 +89,14 @@ QString RimSurface::userDescription()
|
||||
return m_userDescription();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigSurface* RimSurface::surfaceData()
|
||||
{
|
||||
return m_surfaceData.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -81,13 +114,17 @@ void RimSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
{
|
||||
if ( changedField == &m_surfaceDefinitionFilePath )
|
||||
{
|
||||
updateDataFromFile();
|
||||
updateSurfaceDataFromFile();
|
||||
|
||||
// Todo: Update visualization
|
||||
RimSurfaceCollection* surfColl;
|
||||
this->firstAncestorOrThisOfTypeAsserted( surfColl );
|
||||
surfColl->updateViews( {this} );
|
||||
}
|
||||
else if ( changedField == &m_color )
|
||||
{
|
||||
// Todo: Update visualization
|
||||
RimSurfaceCollection* surfColl;
|
||||
this->firstAncestorOrThisOfTypeAsserted( surfColl );
|
||||
surfColl->updateViews( {this} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +139,7 @@ struct SurfacePointData
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns false for fatal failure
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSurface::updateDataFromFile()
|
||||
bool RimSurface::updateSurfaceDataFromFile()
|
||||
{
|
||||
std::ifstream stream( this->surfaceFilePath().toLatin1().data() );
|
||||
|
||||
|
||||
@@ -35,16 +35,13 @@ public:
|
||||
~RimSurface() override;
|
||||
|
||||
void setSurfaceFilePath( const QString& filePath );
|
||||
QString surfaceFilePath()
|
||||
{
|
||||
return m_surfaceDefinitionFilePath().path();
|
||||
}
|
||||
void setColor( const cvf::Color3f& color )
|
||||
{
|
||||
m_color = color;
|
||||
}
|
||||
QString surfaceFilePath();
|
||||
|
||||
bool updateDataFromFile();
|
||||
void setColor( const cvf::Color3f& color );
|
||||
cvf::Color3f color() const;
|
||||
|
||||
bool updateSurfaceDataFromFile();
|
||||
RigSurface* surfaceData();
|
||||
|
||||
QString userDescription();
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ RimSurface* RimSurfaceCollection::importSurfacesFromFiles( const QStringList& fi
|
||||
newSurface->setSurfaceFilePath( newFileName );
|
||||
newSurface->setColor( newColor );
|
||||
|
||||
if ( !newSurface->updateDataFromFile() )
|
||||
if ( !newSurface->updateSurfaceDataFromFile() )
|
||||
{
|
||||
delete newSurface;
|
||||
errorMessages += newFileName + "\n";
|
||||
@@ -132,20 +132,36 @@ std::vector<RimSurface*> RimSurfaceCollection::surfaces() const
|
||||
return m_surfaces.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceCollection::loadData()
|
||||
{
|
||||
for ( auto surf : m_surfaces )
|
||||
{
|
||||
if ( !surf->updateSurfaceDataFromFile() )
|
||||
{
|
||||
// Error: could not open the surface file surf->surfaceFilePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceCollection::updateViews( const std::vector<RimSurface*>& surfsToReload )
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimGridView*> views;
|
||||
proj->allVisibleGridViews( views );
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
|
||||
std::vector<Rim3dView*> views;
|
||||
proj->allViews( views );
|
||||
|
||||
// Make sure the tree items are syncronized
|
||||
|
||||
for ( auto view : views )
|
||||
{
|
||||
view->updateSurfacesInViewTreeItems();
|
||||
auto gridView = dynamic_cast<RimGridView*>( view );
|
||||
if ( gridView ) gridView->updateSurfacesInViewTreeItems();
|
||||
}
|
||||
|
||||
std::set<RimGridView*> viewsNeedingUpdate;
|
||||
|
||||
@@ -36,10 +36,10 @@ public:
|
||||
|
||||
std::vector<RimSurface*> surfaces() const;
|
||||
|
||||
void loadData();
|
||||
void updateViews();
|
||||
|
||||
private:
|
||||
void updateViews( const std::vector<RimSurface*>& surfsToReload );
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimSurface*> m_surfaces;
|
||||
};
|
||||
|
||||
@@ -18,8 +18,11 @@
|
||||
|
||||
#include "RimSurfaceInView.h"
|
||||
|
||||
#include "RimGridView.h"
|
||||
#include "RimSurface.h"
|
||||
|
||||
#include "RivSurfacePartMgr.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSurfaceInView, "SurfaceInView" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -75,6 +78,47 @@ void RimSurfaceInView::setSurface( RimSurface* surf )
|
||||
m_surface = surf;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSurfaceInView::isActive()
|
||||
{
|
||||
return m_isActive();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInView::clearGeometry()
|
||||
{
|
||||
m_surfacePartMgr = nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivSurfacePartMgr* RimSurfaceInView::surfacePartMgr()
|
||||
{
|
||||
if ( m_surfacePartMgr.isNull() ) m_surfacePartMgr = new RivSurfacePartMgr( this );
|
||||
|
||||
return m_surfacePartMgr.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_isActive )
|
||||
{
|
||||
RimGridView* ownerView;
|
||||
this->firstAncestorOrThisOfTypeAsserted( ownerView );
|
||||
ownerView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -22,7 +22,10 @@
|
||||
#include "cafPdmProxyValueField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include "cvfObject.h"
|
||||
|
||||
class RimSurface;
|
||||
class RivSurfacePartMgr;
|
||||
|
||||
class RimSurfaceInView : public caf::PdmObject
|
||||
{
|
||||
@@ -37,12 +40,21 @@ public:
|
||||
QString name() const;
|
||||
RimSurface* surface() const;
|
||||
void setSurface( RimSurface* surf );
|
||||
bool isActive();
|
||||
|
||||
void clearGeometry();
|
||||
RivSurfacePartMgr* surfacePartMgr();
|
||||
|
||||
private:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue ) override;
|
||||
|
||||
caf::PdmProxyValueField<QString> m_name;
|
||||
caf::PdmField<bool> m_isActive;
|
||||
caf::PdmPtrField<RimSurface*> m_surface;
|
||||
|
||||
cvf::ref<RivSurfacePartMgr> m_surfacePartMgr;
|
||||
};
|
||||
|
||||
@@ -19,11 +19,16 @@
|
||||
#include "RimSurfaceInViewCollection.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSurfaceCollection.h"
|
||||
#include "RimSurfaceInView.h"
|
||||
|
||||
#include "RivSurfacePartMgr.h"
|
||||
|
||||
#include "cvfModelBasicList.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSurfaceInViewCollection, "SurfaceInViewCollection" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -86,6 +91,39 @@ void RimSurfaceInViewCollection::updateFromSurfaceCollection()
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform )
|
||||
{
|
||||
if ( !m_isActive() ) return;
|
||||
|
||||
for ( RimSurfaceInView* surf : m_surfacesInView )
|
||||
{
|
||||
if ( surf->isActive() )
|
||||
{
|
||||
surf->surfacePartMgr()->appendNativeGeometryPartsToModel( model, scaleTransform );
|
||||
}
|
||||
}
|
||||
|
||||
model->updateBoundingBoxesRecursive();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_isActive )
|
||||
{
|
||||
RimGridView* ownerView;
|
||||
this->firstAncestorOrThisOfTypeAsserted( ownerView );
|
||||
ownerView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -21,6 +21,13 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
class ScalarMapper;
|
||||
} // namespace cvf
|
||||
|
||||
class RimSurfaceInView;
|
||||
class RimSurface;
|
||||
|
||||
@@ -34,10 +41,15 @@ public:
|
||||
|
||||
void updateFromSurfaceCollection();
|
||||
|
||||
void appendPartsToModel( cvf::ModelBasicList* surfaceVizModel, cvf::Transform* scaleTransform );
|
||||
|
||||
private:
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue ) override;
|
||||
|
||||
bool hasSurfaceInViewForSurface(const RimSurface * surf) const;
|
||||
bool hasSurfaceInViewForSurface( const RimSurface* surf ) const;
|
||||
|
||||
caf::PdmField<bool> m_isActive;
|
||||
caf::PdmChildArrayField<RimSurfaceInView*> m_surfacesInView;
|
||||
|
||||
Reference in New Issue
Block a user