Skip to content

Commit

Permalink
Create virtual-functions.md
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj authored Mar 12, 2024
1 parent 2ca7431 commit db53984
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions _docs/virtual-functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Virtual functions
permalink: /object/virtual-functions
layout: default
---

## Overview of virtual functions

A PDM object inherits PdmObject which inherits PdmUiObjectHandle. This documents gives an overview of virtual functions that can be overridden with short examples of usage.
[cafPdmUiObjectHandle()](https://github.com/OPM/ResInsight/blob/dev/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h)

## appendMenuItems
Used to append menu items to the right click menu of an object. Previous pattern created these menus centralized in RimContextCommandBuilder which will be obsoleted.

void RimPolygon::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicDuplicatePolygonFeature";
menuBuilder << "Separator";
menuBuilder << "RicExportPolygonCsvFeature";
}

## userDescriptionField
If defined, the string defined by this field will be used when displaying object text in the Property Tree.

caf::PdmFieldHandle* RimNamedObject::userDescriptionField()
{
return nameField();
}

## objectToggleField
If defined, displays a checkbox next to the object in the Project Tree. The field must be of the boolean type.

caf::PdmField<bool> m_isActive;
caf::PdmFieldHandle* RimCellFilter::objectToggleField()
{
return &m_isActive;
}

## fieldChangedByUi
Use this method to react on user interaction in the user interface. A pointer to the field being changed, old and new value is available.

## objectToggleField
If defined, displays a checkbox next to the object in the Project Tree. The field must be of the boolean type.

void RimPolygon::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_pointsInDomainCoords )
{
coordinatesChanged.send();
objectChanged.send();
}
}



0 comments on commit db53984

Please sign in to comment.