Support setting well log plot fields from Python

This commit is contained in:
Gaute Lindkvist 2020-01-21 11:08:09 +01:00
parent 56d141d4c3
commit 896767c991
4 changed files with 60 additions and 6 deletions

View File

@ -43,7 +43,8 @@ for case in cases:
replace_params.user_poisson_ratio = 0.654321
replace_params.user_fg_shale = 1.0321
wbsplot.set_parameters(replace_params)
wbsplot.set_depth_type("TRUE_VERTICAL_DEPTH_RKB")
wbsplot.export_snapshot(export_folder=dirname)
except grpc.RpcError as e:
print("Error: ", e.details())

View File

@ -68,14 +68,52 @@ class WellLogPlot(Plot):
"""
return self.get_value("MinimumDepth"), self.get_value("MaximumDepth")
def set_depth_range(self, min_depth, max_depth):
def set_depth_range(self, min_depth, max_depth, update=True):
""" Set the visible depth range minimum
Arguments:
min_depth(double): The new minimum depth
max_depth(double): The new maximum depth
update(bool, optional): Update the plot after setting the value?
"""
self.set_value("MinimumDepth", min_depth)
self.set_value("MaximumDepth", max_depth)
self.update()
self.set_value("AutoScaleDepthEnabled", False)
if update:
self.update()
def depth_type(self):
"""Get the plot depth type
Returns: an enum string. Can be "MEASURED_DEPTH", "TRUE_VERTICAL_DEPTH" or "TRUE_VERTICAL_DEPTH_RKB".
"""
return self.get_value("DepthType")
def set_depth_type(self, depth_type, update=True):
"""Set the depth type
Arguments:
depth_type(enum string): can be "MEASURED_DEPTH", "TRUE_VERTICAL_DEPTH" or "TRUE_VERTICAL_DEPTH_RKB".
update(bool, optional): Update the plot after setting the value?
"""
self.set_value("DepthType", depth_type)
if update:
self.update()
def depth_unit(self):
"""Get the plot depth units
Returns: an enum string. Can be "UNIT_METER", "UNIT_FEET" or "UNIT_NONE".
"""
def set_depth_unit(self, depth_unit, update=True):
"""Set the depth unit
Arguments:
depth_unit(enum string): can be "UNIT_METER", "UNIT_FEET" or "UNIT_NONE".
update(bool, optional): Update the plot after setting the value?
"""
self.set_value("DepthUnit", depth_unit)
if update:
self.update()

View File

@ -115,7 +115,11 @@ void RiaGrpcServiceInterface::copyPdmObjectFromRipsToCaf( const rips::PdmObject*
QString keyword = pdmValueField->keyword();
QString value = QString::fromStdString( parametersMap[keyword.toStdString()] );
assignFieldValue( value, pdmValueField );
QVariant oldValue, newValue;
if ( assignFieldValue( value, pdmValueField, &oldValue, &newValue ) )
{
destination->uiCapability()->fieldChangedByUi( field, oldValue, newValue );
}
}
}
}
@ -123,15 +127,24 @@ void RiaGrpcServiceInterface::copyPdmObjectFromRipsToCaf( const rips::PdmObject*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaGrpcServiceInterface::assignFieldValue( const QString& stringValue, caf::PdmValueField* field )
bool RiaGrpcServiceInterface::assignFieldValue( const QString& stringValue,
caf::PdmValueField* field,
QVariant* oldValue,
QVariant* newValue )
{
CAF_ASSERT( oldValue && newValue );
auto ricfHandle = field->template capability<RicfFieldHandle>();
if ( field && ricfHandle != nullptr )
{
QTextStream stream( stringValue.toLatin1() );
RicfMessages messages;
*oldValue = field->toQVariant();
ricfHandle->readFieldData( stream, nullptr, &messages, false );
*newValue = field->toQVariant();
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------

View File

@ -39,6 +39,7 @@ class PdmObject;
}
class QString;
class QVariant;
//==================================================================================================
//
@ -56,7 +57,8 @@ public:
static void copyPdmObjectFromCafToRips( const caf::PdmObjectHandle* source, rips::PdmObject* destination );
static void copyPdmObjectFromRipsToCaf( const rips::PdmObject* source, caf::PdmObjectHandle* destination );
static void assignFieldValue( const QString& stringValue, caf::PdmValueField* field );
static bool
assignFieldValue( const QString& stringValue, caf::PdmValueField* field, QVariant* oldValue, QVariant* newValue );
static caf::PdmObjectHandle* emplaceChildField( caf::PdmObject* parent, const QString& fieldLabel );