mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactor connection between cases and views.
Eclipse grid views and contour maps are not longer a child of the case. The views are not separate collections (one for grid and one for contour maps) on root level.
This commit is contained in:
@@ -325,13 +325,31 @@ def view(self, view_id):
|
||||
Returns:
|
||||
:class:`rips.generated.generated_classes.View`
|
||||
"""
|
||||
views = self.views()
|
||||
project = self.ancestor(rips.project.Project)
|
||||
views = project.views()
|
||||
for view_object in views:
|
||||
if view_object.id == view_id:
|
||||
return view_object
|
||||
return None
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def views(self):
|
||||
"""Get all views of a case
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.generated_classes.View`
|
||||
"""
|
||||
project = self.ancestor(rips.project.Project)
|
||||
views = project.views()
|
||||
views_for_case = []
|
||||
for view_object in views:
|
||||
view_object.print_object_info()
|
||||
if view_object.id == self.id:
|
||||
views_for_case.append(view_object)
|
||||
return views_for_case
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def create_view(self):
|
||||
"""Create a new view in the current case
|
||||
@@ -990,8 +1008,10 @@ def simulation_wells(self):
|
||||
:class:`rips.generated.generated_classes.SimulationWell`
|
||||
|
||||
"""
|
||||
wells = self.descendants(SimulationWell)
|
||||
return wells
|
||||
if self.views():
|
||||
# Use the first view to get simulation wells.
|
||||
return self.views()[0].descendants(SimulationWell)
|
||||
return []
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
|
||||
@@ -14,6 +14,7 @@ import PdmObject_pb2
|
||||
from .resinsight_classes import SimulationWell
|
||||
|
||||
from .case import Case
|
||||
from .view import View
|
||||
from .pdmobject import PdmObjectBase, add_method
|
||||
|
||||
from typing import List, Optional
|
||||
@@ -80,4 +81,8 @@ def cells(
|
||||
|
||||
@add_method(SimulationWell)
|
||||
def case(self: SimulationWell) -> Optional[Case]:
|
||||
return self.ancestor(Case)
|
||||
view = self.ancestor(View)
|
||||
if view:
|
||||
return view.case()
|
||||
else:
|
||||
return None
|
||||
|
||||
@@ -187,12 +187,24 @@ def export_property(self, undefined_value=0.0):
|
||||
)
|
||||
|
||||
|
||||
@add_method(ViewWindow)
|
||||
def extract_address(address) -> int:
|
||||
# Address form: "RimReservoir:123345345345435"
|
||||
parts = address.split(":")
|
||||
return int(parts[1])
|
||||
|
||||
|
||||
@add_method(View)
|
||||
def case(self):
|
||||
"""Get the case the view belongs to"""
|
||||
mycase = self.ancestor(rips.case.Case)
|
||||
assert mycase is not None
|
||||
return mycase
|
||||
project = self.ancestor(rips.project.Project)
|
||||
|
||||
eclipse_case_addr = extract_address(self.eclipse_case)
|
||||
|
||||
cases = project.cases()
|
||||
for c in cases:
|
||||
if c.address() == eclipse_case_addr:
|
||||
return c
|
||||
return None
|
||||
|
||||
|
||||
@add_method(ViewWindow)
|
||||
|
||||
@@ -462,18 +462,15 @@ void RiaNNCInputValuesStateHandler::finish()
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED_NOT_SAVED;
|
||||
}
|
||||
|
||||
for ( size_t i = 0; i < m_eclipseCase->reservoirViews.size(); ++i )
|
||||
for ( RimEclipseView* view : m_eclipseCase->reservoirViews() )
|
||||
{
|
||||
if ( m_eclipseCase->reservoirViews[i] )
|
||||
{
|
||||
// As new result might have been introduced, update all editors connected
|
||||
m_eclipseCase->reservoirViews[i]->cellResult()->updateConnectedEditors();
|
||||
// As new result might have been introduced, update all editors connected
|
||||
view->cellResult()->updateConnectedEditors();
|
||||
|
||||
// It is usually not needed to create new display model, but if any derived geometry based on
|
||||
// generated data (from Octave) a full display model rebuild is required
|
||||
m_eclipseCase->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw();
|
||||
m_eclipseCase->reservoirViews[i]->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
|
||||
}
|
||||
// It is usually not needed to create new display model, but if any derived geometry based on
|
||||
// generated data (from Octave) a full display model rebuild is required
|
||||
view->scheduleCreateDisplayModelAndRedraw();
|
||||
view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user