mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
@@ -1,10 +1,11 @@
|
||||
import grpc
|
||||
import os
|
||||
import sys
|
||||
from .Grid import Grid
|
||||
from .Properties import Properties
|
||||
from .PdmObject import PdmObject
|
||||
from .View import View
|
||||
from rips.Commands import Commands
|
||||
from rips.Grid import Grid
|
||||
from rips.Properties import Properties
|
||||
from rips.PdmObject import PdmObject
|
||||
from rips.View import View
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'generated'))
|
||||
|
||||
@@ -156,3 +157,8 @@ class Case (PdmObject):
|
||||
return viewObject
|
||||
return None
|
||||
|
||||
def createView(self):
|
||||
"""Create a new view in the current case"""
|
||||
viewId = Commands(self.channel).createView(self.id)
|
||||
return self.view(viewId)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'generated'))
|
||||
from Definitions_pb2 import Empty
|
||||
import Commands_pb2 as Cmd
|
||||
import Commands_pb2_grpc as CmdRpc
|
||||
from .Case import Case
|
||||
import rips.Case
|
||||
|
||||
class Commands:
|
||||
"""Command executor which can run ResInsight Command File commands nearly verbatim
|
||||
@@ -65,7 +65,7 @@ class Commands:
|
||||
|
||||
"""
|
||||
commandReply = self.__execute(loadCase=Cmd.FilePathRequest(path=path))
|
||||
return Case(self.channel, commandReply.loadCaseResult.id)
|
||||
return rips.Case(self.channel, commandReply.loadCaseResult.id)
|
||||
|
||||
def replaceCase(self, newGridFile, caseId=0):
|
||||
"""Replace the given case with a new case loaded from file
|
||||
@@ -276,3 +276,9 @@ class Commands:
|
||||
fileName=fileName,
|
||||
minimumCommunication = minimumCommunication,
|
||||
aquiferCellThreshold = aquiferCellThreshold))
|
||||
|
||||
def createView(self, caseId):
|
||||
return self.__execute(createView=Cmd.CreateViewRequest(caseId=caseId)).createViewResult.viewId
|
||||
|
||||
def cloneView(self, viewId):
|
||||
return self.__execute(cloneView=Cmd.CloneViewRequest(viewId=viewId)).createViewResult.viewId
|
||||
@@ -1,8 +1,8 @@
|
||||
import grpc
|
||||
import os
|
||||
import sys
|
||||
from .PdmObject import PdmObject
|
||||
from .View import View
|
||||
from rips.PdmObject import PdmObject
|
||||
from rips.View import View
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'generated'))
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ from Definitions_pb2 import Empty
|
||||
|
||||
import RiaVersionInfo
|
||||
|
||||
from .Commands import Commands
|
||||
from .Project import Project
|
||||
from rips.Commands import Commands
|
||||
from rips.Project import Project
|
||||
|
||||
class Instance:
|
||||
"""The ResInsight Instance class. Use to launch or find existing ResInsight instances
|
||||
|
||||
@@ -2,11 +2,11 @@ import grpc
|
||||
import os
|
||||
import sys
|
||||
|
||||
from .Case import Case
|
||||
from .Commands import Commands
|
||||
from .GridCaseGroup import GridCaseGroup
|
||||
from .PdmObject import PdmObject
|
||||
from .View import View
|
||||
from rips.Case import Case
|
||||
from rips.Commands import Commands
|
||||
from rips.GridCaseGroup import GridCaseGroup
|
||||
from rips.PdmObject import PdmObject
|
||||
from rips.View import View
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'generated'))
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
###################################################################################
|
||||
# This example will connect to ResInsight, retrieve a list of cases and print info
|
||||
# Also creates a new view for all cases
|
||||
###################################################################################
|
||||
|
||||
# Import the ResInsight Processing Server Module
|
||||
@@ -15,4 +16,7 @@ if resInsight is not None:
|
||||
for case in cases:
|
||||
print("Case name: " + case.name)
|
||||
print("Case grid path: " + case.gridPath())
|
||||
# Create a new view
|
||||
view = case.createView()
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#############################################################
|
||||
# This example will alter the views of all cases
|
||||
# By setting the background color and toggle the grid box
|
||||
# Also clones the first view
|
||||
#############################################################
|
||||
import rips
|
||||
# Connect to ResInsight instance
|
||||
@@ -18,4 +19,9 @@ if resInsight is not None:
|
||||
view.setShowGridBox(not view.showGridBox())
|
||||
view.setBackgroundColor("#3388AA")
|
||||
# Update the view in ResInsight
|
||||
view.update()
|
||||
view.update()
|
||||
# Clone the first view
|
||||
newView = views[0].clone()
|
||||
view.setShowGridBox(False)
|
||||
newView.setBackgroundColor("#FFAA33")
|
||||
newView.update()
|
||||
@@ -1,4 +1,6 @@
|
||||
from .PdmObject import PdmObject
|
||||
import rips.Case # Circular import of Case, which already imports View. Use full name.
|
||||
from rips.Commands import Commands
|
||||
from rips.PdmObject import PdmObject
|
||||
|
||||
class View (PdmObject):
|
||||
"""ResInsight view class
|
||||
@@ -81,4 +83,18 @@ class View (PdmObject):
|
||||
if selectionMode == 'FLOW_TR_BY_SELECTION':
|
||||
cellResult.setValue("SelectedInjectorTracers", injectors)
|
||||
cellResult.setValue("SelectedProducerTracers", producers)
|
||||
cellResult.update()
|
||||
cellResult.update()
|
||||
|
||||
def case(self):
|
||||
"""Get the case the view belongs to"""
|
||||
pdmCase = self.ancestor("EclipseCase")
|
||||
if pdmCase is None:
|
||||
pdmCase = self.ancestor("ResInsightGeoMechCase")
|
||||
if pdmCase is None:
|
||||
return None
|
||||
return rips.Case(self.channel, pdmCase.getValue("CaseId"))
|
||||
|
||||
def clone(self):
|
||||
"""Clone the current view"""
|
||||
viewId = Commands(self.channel).cloneView(self.id)
|
||||
return self.case().view(viewId)
|
||||
Reference in New Issue
Block a user