Move time-step control and grid-only hooks from Rim3dView to RimGridView

* #14760 Move time-step control and grid-only hooks from Rim3dView to RimGridView
* #14760 Store named 3D visualization models in a shared collection instead of per-model fields
This commit is contained in:
Magne Sjaastad authored and GitHub committed 2026-09-16 08:44:00 +02:00
1 parent f73afc5b76
commit 0579dbb468
16 files changed
+362 -237

No files matched your search

@@ -55,6 +55,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RivRefinementRegionPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivNamedVisualizationModels.cpp
)
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
@@ -0,0 +1,77 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2026- 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 "RivNamedVisualizationModels.h"
// ModelBasicList's implicit destructor needs cvf::Part to be a complete type (it holds a
// cvf::Collection<Part>), which is only forward-declared in cvfModelBasicList.h.
#include "cvfPart.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ModelBasicList* RivNamedVisualizationModels::findOrCreate( const cvf::String& modelName )
{
auto it = m_models.find( modelName );
if ( it != m_models.end() ) return it->second.p();
cvf::ref<cvf::ModelBasicList> model = new cvf::ModelBasicList;
model->setName( modelName );
return m_models.emplace( modelName, model ).first->second.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ModelBasicList* RivNamedVisualizationModels::findOrCreateAndClear( const cvf::String& modelName )
{
auto* model = findOrCreate( modelName );
model->removeAllParts();
return model;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ModelBasicList* RivNamedVisualizationModels::find( const cvf::String& modelName ) const
{
auto it = m_models.find( modelName );
return it != m_models.end() ? const_cast<cvf::ModelBasicList*>( it->second.p() ) : nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::ModelBasicList*> RivNamedVisualizationModels::allModels() const
{
std::vector<cvf::ModelBasicList*> models;
for ( const auto& [name, model] : m_models )
{
models.push_back( const_cast<cvf::ModelBasicList*>( model.p() ) );
}
return models;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivNamedVisualizationModels::clear()
{
m_models.clear();
}
@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2026- 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 "cvfModelBasicList.h"
#include "cvfObject.h"
#include "cvfString.h"
#include <map>
#include <vector>
//==================================================================================================
///
/// Named collection of cvf::ModelBasicList visualization models, created lazily by name.
///
/// The names of the well-known models shared across several 3D view types are centralized here as
/// static accessors, so the string literals identifying a given model are defined in a single place
///
//==================================================================================================
class RivNamedVisualizationModels
{
public:
static const char* wellPathPipeModelName() { return "WellPathPipeModel"; }
static const char* seismicSectionModelName() { return "SeismicSectionModel"; }
static const char* surfaceModelName() { return "SurfaceModel"; }
static const char* polygonModelName() { return "PolygonModel"; }
static const char* crossSectionModelName() { return "CrossSectionModel"; }
static const char* intersectionModelName() { return "IntersectionModel"; }
static const char* faultReactivationModelName() { return "FaultReactModel"; }
static const char* refinementRegionsModelName() { return "RefinementRegionsModel"; }
static const char* highlightModelName() { return "HighlightModel"; }
static const char* screenSpaceModelName() { return "ScreenSpaceModel"; }
cvf::ModelBasicList* findOrCreate( const cvf::String& modelName );
cvf::ModelBasicList* findOrCreateAndClear( const cvf::String& modelName );
cvf::ModelBasicList* find( const cvf::String& modelName ) const;
std::vector<cvf::ModelBasicList*> allModels() const;
void clear();
private:
std::map<cvf::String, cvf::ref<cvf::ModelBasicList>> m_models;
};