mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5365 Implement toggling of PdmObjects
This commit is contained in:
parent
6b461218af
commit
4494c21c8f
@ -42,6 +42,7 @@ message PdmObject
|
||||
string class_keyword = 1;
|
||||
uint64 address = 2;
|
||||
map<string, string> parameters = 3;
|
||||
bool visible = 4;
|
||||
}
|
||||
|
||||
message PdmObjectArray
|
||||
|
@ -25,3 +25,5 @@ if resinsight is not None:
|
||||
view.set_show_grid_box(False)
|
||||
new_view.set_background_color("#FFAA33")
|
||||
new_view.update()
|
||||
view.set_visible(False)
|
||||
view.update()
|
||||
|
@ -69,6 +69,14 @@ class PdmObject:
|
||||
"""Get the class keyword in the ResInsight Data Model for the given PdmObject"""
|
||||
return self._pb2_object.class_keyword
|
||||
|
||||
def set_visible(self, visible):
|
||||
"""Set the visibility of the object in the ResInsight project tree"""
|
||||
self._pb2_object.visible = visible
|
||||
|
||||
def visible(self):
|
||||
"""Get the visibility of the object in the ResInsight project tree"""
|
||||
return self._pb2_object.visible
|
||||
|
||||
def keywords(self):
|
||||
"""Get a list of all parameter keywords available in the object"""
|
||||
list_of_keywords = []
|
||||
|
@ -73,6 +73,19 @@ void RiaGrpcServiceInterface::copyPdmObjectFromCafToRips( const caf::PdmObjectHa
|
||||
|
||||
destination->set_class_keyword( source->xmlCapability()->classKeyword().toStdString() );
|
||||
destination->set_address( reinterpret_cast<uint64_t>( source ) );
|
||||
|
||||
bool visible = true;
|
||||
if ( source->uiCapability() && source->uiCapability()->objectToggleField() )
|
||||
{
|
||||
const caf::PdmField<bool>* boolField = dynamic_cast<const caf::PdmField<bool>*>(
|
||||
source->uiCapability()->objectToggleField() );
|
||||
if ( boolField )
|
||||
{
|
||||
visible = boolField->value();
|
||||
}
|
||||
}
|
||||
destination->set_visible( visible );
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
source->fields( fields );
|
||||
|
||||
@ -103,6 +116,20 @@ void RiaGrpcServiceInterface::copyPdmObjectFromRipsToCaf( const rips::PdmObject*
|
||||
{
|
||||
CAF_ASSERT( source && destination && destination->xmlCapability() );
|
||||
CAF_ASSERT( source->class_keyword() == destination->xmlCapability()->classKeyword().toStdString() );
|
||||
|
||||
if ( destination->uiCapability() && destination->uiCapability()->objectToggleField() )
|
||||
{
|
||||
caf::PdmField<bool>* boolField = dynamic_cast<caf::PdmField<bool>*>(
|
||||
destination->uiCapability()->objectToggleField() );
|
||||
if ( boolField )
|
||||
{
|
||||
QVariant oldValue = boolField->toQVariant();
|
||||
boolField->setValue( source->visible() );
|
||||
QVariant newValue = boolField->toQVariant();
|
||||
destination->uiCapability()->fieldChangedByUi( boolField, oldValue, newValue );
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
destination->fields( fields );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user