mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05:00
cafTestApplication: Move PDM object classes into PdmObjects subfolder
This commit is contained in:
1 parent
26a2861d56
commit
4dceac69dc
30 files changed
+1405
-1139
No files matched your search
@@ -32,24 +32,38 @@ set(PROJECT_FILES
|
||||
MainWindow.h
|
||||
WidgetLayoutTest.cpp
|
||||
WidgetLayoutTest.h
|
||||
ManyGroups.cpp
|
||||
ManyGroups.h
|
||||
CustomObjectEditor.cpp
|
||||
CustomObjectEditor.h
|
||||
MenuItemProducer.cpp
|
||||
MenuItemProducer.h
|
||||
TamComboBox.h
|
||||
TamComboBox.cpp
|
||||
LineEditAndPushButtons.h
|
||||
LineEditAndPushButtons.cpp
|
||||
LabelsAndHyperlinks.h
|
||||
LabelsAndHyperlinks.cpp
|
||||
ApplicationEnum.h
|
||||
ApplicationEnum.cpp
|
||||
OptionalFields.h
|
||||
OptionalFields.cpp
|
||||
ValidationTest.h
|
||||
ValidationTest.cpp
|
||||
PdmObjects/ColorTriplet.h
|
||||
PdmObjects/ColorTriplet.cpp
|
||||
PdmObjects/DemoPdmObject.h
|
||||
PdmObjects/DemoPdmObject.cpp
|
||||
PdmObjects/DemoPdmObjectGroup.h
|
||||
PdmObjects/DemoPdmObjectGroup.cpp
|
||||
PdmObjects/ManyGroups.cpp
|
||||
PdmObjects/ManyGroups.h
|
||||
PdmObjects/SingleEditorPdmObject.h
|
||||
PdmObjects/SingleEditorPdmObject.cpp
|
||||
PdmObjects/SmallDemoPdmObject.h
|
||||
PdmObjects/SmallDemoPdmObject.cpp
|
||||
PdmObjects/SmallDemoPdmObjectA.h
|
||||
PdmObjects/SmallDemoPdmObjectA.cpp
|
||||
PdmObjects/SmallGridDemoPdmObject.h
|
||||
PdmObjects/SmallGridDemoPdmObject.cpp
|
||||
PdmObjects/TamComboBox.h
|
||||
PdmObjects/TamComboBox.cpp
|
||||
PdmObjects/LineEditAndPushButtons.h
|
||||
PdmObjects/LineEditAndPushButtons.cpp
|
||||
PdmObjects/LabelsAndHyperlinks.h
|
||||
PdmObjects/LabelsAndHyperlinks.cpp
|
||||
PdmObjects/ApplicationEnum.h
|
||||
PdmObjects/ApplicationEnum.cpp
|
||||
PdmObjects/OptionalFields.h
|
||||
PdmObjects/OptionalFields.cpp
|
||||
PdmObjects/ValidationTest.h
|
||||
PdmObjects/ValidationTest.cpp
|
||||
)
|
||||
|
||||
qt_add_executable(
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,16 @@
|
||||
#include "ColorTriplet.h"
|
||||
|
||||
#include "cafPdmUiColorEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( ColorTriplet, "ColorTriplet" );
|
||||
|
||||
ColorTriplet::ColorTriplet()
|
||||
{
|
||||
CAF_PDM_InitObject( "ColorTriplet", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_colorField, "Color", "color", "", "", "" );
|
||||
m_colorField.uiCapability()->setUiEditorTypeName( caf::PdmUiColorEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_categoryValue, "category", "category value", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_categoryText, "text", "category text", "", "", "" );
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class ColorTriplet : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
ColorTriplet();
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_colorField;
|
||||
caf::PdmField<int> m_categoryValue;
|
||||
caf::PdmField<QString> m_categoryText;
|
||||
};
|
||||
@@ -0,0 +1,259 @@
|
||||
#include "DemoPdmObject.h"
|
||||
|
||||
#include "../MenuItemProducer.h"
|
||||
|
||||
#include "SmallDemoPdmObject.h"
|
||||
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTableView.h"
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
#include "cafPdmUiValueRangeEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( DemoPdmObject, "DemoPdmObject" );
|
||||
|
||||
DemoPdmObject::DemoPdmObject()
|
||||
{
|
||||
CAF_PDM_InitObject( "Demo Object",
|
||||
"",
|
||||
"This object is a demo of the CAF framework",
|
||||
"This object is a demo of the CAF framework" );
|
||||
|
||||
CAF_PDM_InitField( &m_toggleField, "Toggle", false, "Toggle Field", "", "Toggle Field tooltip", " Toggle Field whatsthis" );
|
||||
|
||||
CAF_PDM_InitField( &m_applyAutoOnChildObjectFields, "ApplyAutoValue", false, "Apply Auto Values" );
|
||||
m_applyAutoOnChildObjectFields.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
||||
m_applyAutoOnChildObjectFields.uiCapability()->setAttribute( caf::PdmUiPushButtonEditor::Keys::BUTTON_TEXT,
|
||||
"Apply Auto Values" );
|
||||
|
||||
CAF_PDM_InitField( &m_updateAutoValues, "UpdateAutoValue", false, "Update Auto Values" );
|
||||
m_updateAutoValues.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
||||
m_updateAutoValues.uiCapability()->setAttribute( caf::PdmUiPushButtonEditor::Keys::BUTTON_TEXT, "Update Auto Values" );
|
||||
|
||||
CAF_PDM_InitField( &m_doubleField,
|
||||
"BigNumber",
|
||||
0.0,
|
||||
"Big Number",
|
||||
"",
|
||||
"Enter a big number here",
|
||||
"This is a place you can enter a big real value if you want" );
|
||||
CAF_PDM_InitField( &m_intField,
|
||||
"IntNumber",
|
||||
0,
|
||||
"Small Number",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_sizeField, "SizeField", size_t( 0 ), "Size Field", "", "", "" );
|
||||
CAF_PDM_InitField( &m_boolField,
|
||||
"BooleanValue",
|
||||
false,
|
||||
"Boolean:",
|
||||
"",
|
||||
"Boolean:Enter some small number here",
|
||||
"Boolean:This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_textField, "TextField", QString( "Demo Object Description Field" ), "Description Field", "", "", "" );
|
||||
CAF_PDM_InitField( &m_filePath, "FilePath", QString( "" ), "Filename", "", "", "" );
|
||||
CAF_PDM_InitField( &m_longText, "LongText", QString( "Test text" ), "Long Text", "", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_minMaxSlider, "MinMaxSlider", std::make_pair( 2.5, 10.1 ), "Min max slider", "", "", "" );
|
||||
m_minMaxSlider.uiCapability()->setUiEditorTypeName( caf::PdmUiValueRangeEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_multiSelectList, "MultiSelect", "Selection List", "", "List", "This is a multi selection list" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_objectList, "ObjectList", "Objects list Field", "", "List", "This is a list of PdmObjects" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_objectListOfSameType,
|
||||
"m_objectListOfSameType",
|
||||
"Same type Objects list Field",
|
||||
"",
|
||||
"Same type List",
|
||||
"Same type list of PdmObjects" );
|
||||
m_objectListOfSameType.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
|
||||
m_objectListOfSameType.uiCapability()->setCustomContextMenuEnabled( true );
|
||||
CAF_PDM_InitFieldNoDefault( &m_ptrField, "m_ptrField", "PtrField", "", "Same type List", "Same type list of PdmObjects" );
|
||||
|
||||
m_filePath.capability<caf::PdmUiFieldHandle>()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
||||
m_filePath.capability<caf::PdmUiFieldHandle>()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::TOP );
|
||||
m_longText.capability<caf::PdmUiFieldHandle>()->setUiEditorTypeName( caf::PdmUiTextEditor::uiEditorTypeName() );
|
||||
m_longText.capability<caf::PdmUiFieldHandle>()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::HIDDEN );
|
||||
|
||||
m_menuItemProducer = new MenuItemProducer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void DemoPdmObject::buildTestData()
|
||||
{
|
||||
m_textField = "Mitt Demo Obj";
|
||||
|
||||
DemoPdmObject* demoObj2 = new DemoPdmObject;
|
||||
m_objectList.push_back( demoObj2 );
|
||||
m_objectList.push_back( new SmallDemoPdmObjectA() );
|
||||
SmallDemoPdmObject* smallObj3 = new SmallDemoPdmObject();
|
||||
m_objectList.push_back( smallObj3 );
|
||||
m_objectList.push_back( new SmallDemoPdmObject() );
|
||||
|
||||
m_objectListOfSameType.push_back( new SmallDemoPdmObjectA() );
|
||||
m_objectListOfSameType.push_back( new SmallDemoPdmObjectA() );
|
||||
m_objectListOfSameType.push_back( new SmallDemoPdmObjectA() );
|
||||
m_objectListOfSameType.push_back( new SmallDemoPdmObjectA() );
|
||||
|
||||
demoObj2->m_objectList.push_back( new SmallDemoPdmObjectA() );
|
||||
demoObj2->m_objectList.push_back( new SmallDemoPdmObjectA() );
|
||||
demoObj2->m_objectList.push_back( new SmallDemoPdmObject() );
|
||||
|
||||
delete smallObj3;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* DemoPdmObject::userDescriptionField()
|
||||
{
|
||||
return &m_textField;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* DemoPdmObject::objectToggleField()
|
||||
{
|
||||
return &m_toggleField;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void DemoPdmObject::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_sizeField );
|
||||
|
||||
uiOrdering.add( &m_applyAutoOnChildObjectFields );
|
||||
uiOrdering.add( &m_updateAutoValues );
|
||||
|
||||
uiOrdering.add( &m_minMaxSlider );
|
||||
|
||||
uiOrdering.add( &m_objectListOfSameType );
|
||||
uiOrdering.add( &m_ptrField );
|
||||
uiOrdering.add( &m_boolField );
|
||||
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Name1" );
|
||||
group1->add( &m_doubleField );
|
||||
caf::PdmUiGroup* group2 = uiOrdering.addNewGroup( "Name2" );
|
||||
group2->add( &m_intField );
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> DemoPdmObject::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
if ( &m_multiSelectList == fieldNeedingOptions )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( "Choice 1", "Choice1" ) );
|
||||
options.push_back( caf::PdmOptionItemInfo( "Choice 2", "Choice2" ) );
|
||||
options.push_back( caf::PdmOptionItemInfo( "Choice 3", "Choice3" ) );
|
||||
options.push_back( caf::PdmOptionItemInfo( "Choice 4", "Choice4" ) );
|
||||
options.push_back( caf::PdmOptionItemInfo( "Choice 5", "Choice5" ) );
|
||||
options.push_back( caf::PdmOptionItemInfo( "Choice 6", "Choice6" ) );
|
||||
}
|
||||
|
||||
if ( &m_ptrField == fieldNeedingOptions )
|
||||
{
|
||||
for ( size_t i = 0; i < m_objectListOfSameType.size(); ++i )
|
||||
{
|
||||
caf::PdmUiObjectHandle* uiObject = caf::uiObj( m_objectListOfSameType[i] );
|
||||
if ( uiObject )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( uiObject->uiName(),
|
||||
QVariant::fromValue( caf::PdmPointer<caf::PdmObjectHandle>(
|
||||
m_objectListOfSameType[i] ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
void DemoPdmObject::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_toggleField )
|
||||
{
|
||||
std::cout << "Toggle Field changed" << std::endl;
|
||||
}
|
||||
|
||||
static int counter = 0;
|
||||
counter++;
|
||||
double doubleValue = 1.23456 + counter;
|
||||
int intValue = -1213141516 + counter;
|
||||
auto enumValue = SmallDemoPdmObjectA::TestEnumType::T2;
|
||||
|
||||
if ( changedField == &m_applyAutoOnChildObjectFields )
|
||||
{
|
||||
auto objs = descendantsIncludingThisOfType<SmallDemoPdmObjectA>();
|
||||
for ( auto obj : objs )
|
||||
{
|
||||
obj->enableAutoValueForDouble( doubleValue );
|
||||
obj->enableAutoValueForInt( intValue );
|
||||
obj->enableAutoValueForTestEnum( enumValue );
|
||||
}
|
||||
|
||||
m_applyAutoOnChildObjectFields = false;
|
||||
}
|
||||
|
||||
if ( changedField == &m_updateAutoValues )
|
||||
{
|
||||
auto objs = descendantsIncludingThisOfType<SmallDemoPdmObjectA>();
|
||||
for ( auto obj : objs )
|
||||
{
|
||||
obj->setAutoValueForDouble( doubleValue );
|
||||
obj->setAutoValueForInt( intValue );
|
||||
obj->setAutoValueForTestEnum( enumValue );
|
||||
}
|
||||
|
||||
m_updateAutoValues = false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void DemoPdmObject::onEditorWidgetsCreated()
|
||||
{
|
||||
for ( auto e : m_longText.uiCapability()->connectedEditors() )
|
||||
{
|
||||
caf::PdmUiTextEditor* textEditor = dynamic_cast<caf::PdmUiTextEditor*>( e );
|
||||
if ( !textEditor ) continue;
|
||||
|
||||
QWidget* containerWidget = textEditor->editorWidget();
|
||||
if ( !containerWidget ) continue;
|
||||
|
||||
for ( auto qObj : containerWidget->children() )
|
||||
{
|
||||
QTextEdit* textEdit = dynamic_cast<QTextEdit*>( qObj );
|
||||
if ( textEdit )
|
||||
{
|
||||
m_menuItemProducer->attachTextEdit( textEdit );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void DemoPdmObject::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu,
|
||||
QMenu* menu,
|
||||
QWidget* fieldEditorWidget )
|
||||
{
|
||||
if ( fieldNeedingMenu == &m_objectListOfSameType )
|
||||
{
|
||||
caf::PdmUiTableView::addActionsToMenu( menu, &m_objectListOfSameType );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include "SmallDemoPdmObjectA.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class MenuItemProducer;
|
||||
|
||||
class DemoPdmObject : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
DemoPdmObject();
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
|
||||
void buildTestData();
|
||||
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void onEditorWidgetsCreated() override;
|
||||
|
||||
protected:
|
||||
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_boolField;
|
||||
caf::PdmField<double> m_doubleField;
|
||||
caf::PdmField<int> m_intField;
|
||||
caf::PdmField<size_t> m_sizeField;
|
||||
caf::PdmField<QString> m_textField;
|
||||
|
||||
caf::PdmField<QString> m_filePath;
|
||||
|
||||
caf::PdmField<std::pair<double, double>> m_minMaxSlider;
|
||||
|
||||
caf::PdmField<QString> m_longText;
|
||||
caf::PdmField<std::vector<QString>> m_multiSelectList;
|
||||
|
||||
caf::PdmChildArrayField<caf::PdmObjectHandle*> m_objectList;
|
||||
caf::PdmChildArrayField<SmallDemoPdmObjectA*> m_objectListOfSameType;
|
||||
caf::PdmPtrField<SmallDemoPdmObjectA*> m_ptrField;
|
||||
|
||||
caf::PdmField<bool> m_toggleField;
|
||||
caf::PdmField<bool> m_applyAutoOnChildObjectFields;
|
||||
caf::PdmField<bool> m_updateAutoValues;
|
||||
|
||||
MenuItemProducer* m_menuItemProducer;
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "DemoPdmObjectGroup.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( DemoPdmObjectGroup, "DemoPdmObjectGroup" );
|
||||
|
||||
DemoPdmObjectGroup::DemoPdmObjectGroup()
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "MyRootObject", "", "", "" );
|
||||
|
||||
objects.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmDocument.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class DemoPdmObjectGroup : public caf::PdmDocument
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
DemoPdmObjectGroup();
|
||||
|
||||
public:
|
||||
caf::PdmChildArrayField<caf::PdmObjectHandle*> objects;
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "LabelsAndHyperlinks.h"
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "../MainWindow.h"
|
||||
#include "OptionalFields.h"
|
||||
|
||||
#include "cafPdmUiButton.h"
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,29 @@
|
||||
#include "SingleEditorPdmObject.h"
|
||||
|
||||
#include "cafPdmUiOrdering.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( SingleEditorPdmObject, "SingleEditorObject" );
|
||||
|
||||
SingleEditorPdmObject::SingleEditorPdmObject()
|
||||
{
|
||||
CAF_PDM_InitObject( "Single Editor Object",
|
||||
"",
|
||||
"This object is a demo of the CAF framework",
|
||||
"This object is a demo of the CAF framework" );
|
||||
|
||||
CAF_PDM_InitField( &m_intFieldStandard,
|
||||
"Standard",
|
||||
0,
|
||||
"Fairly Wide Label",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SingleEditorPdmObject::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_intFieldStandard );
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class SingleEditorPdmObject : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
SingleEditorPdmObject();
|
||||
|
||||
// Outside group
|
||||
caf::PdmField<int> m_intFieldStandard;
|
||||
|
||||
protected:
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
};
|
||||
@@ -0,0 +1,219 @@
|
||||
#include "SmallDemoPdmObject.h"
|
||||
|
||||
#include "cafIconProvider.h"
|
||||
#include "cafPdmUiCheckBoxAndTextEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QVariant>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( SmallDemoPdmObject, "SmallDemoPdmObject" );
|
||||
|
||||
SmallDemoPdmObject::SmallDemoPdmObject()
|
||||
{
|
||||
CAF_PDM_InitObject( "Small Demo Object",
|
||||
":/images/win/filenew.png",
|
||||
"This object is a demo of the CAF framework",
|
||||
"This object is a demo of the CAF framework" );
|
||||
|
||||
CAF_PDM_InitField( &m_toggleField,
|
||||
"Toggle",
|
||||
false,
|
||||
"Add Items To Multi Select",
|
||||
"",
|
||||
"Toggle Field tooltip",
|
||||
" Toggle Field whatsthis" );
|
||||
CAF_PDM_InitField( &m_doubleField,
|
||||
"BigNumber",
|
||||
0.0,
|
||||
"Big Number",
|
||||
"",
|
||||
"Enter a big number here",
|
||||
"This is a place you can enter a big real value if you want" );
|
||||
m_doubleField.uiCapability()->setCustomContextMenuEnabled( true );
|
||||
|
||||
CAF_PDM_InitField( &m_intField,
|
||||
"IntNumber",
|
||||
0,
|
||||
"Small Number",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_textField,
|
||||
"TextField",
|
||||
QString( "" ),
|
||||
"Text",
|
||||
"",
|
||||
"Text tooltip",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_booleanAndDoubleField, "BooleanAndDoubleField", "Checkable double" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_booleanAndTextField, "BooleanAndTextField", "Checkable text" );
|
||||
m_booleanAndTextField.uiCapability()->setUiEditorTypeName( caf::PdmUiCheckBoxAndTextEditor::uiEditorTypeName() );
|
||||
|
||||
m_proxyDoubleField.registerSetMethod( this, &SmallDemoPdmObject::setDoubleMember );
|
||||
m_proxyDoubleField.registerGetMethod( this, &SmallDemoPdmObject::doubleMember );
|
||||
CAF_PDM_InitFieldNoDefault( &m_proxyDoubleField, "ProxyDouble", "Proxy Double" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_colorTriplets, "colorTriplets", "color Triplets", "", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_fileName, "FileName", caf::FilePath( "filename" ), "File Name", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_fileNameList, "FileNameList", "File Name List", "", "", "" );
|
||||
m_fileNameList.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() );
|
||||
|
||||
m_proxyDoubleField = 0;
|
||||
if ( !( m_proxyDoubleField == 3 ) )
|
||||
{
|
||||
std::cout << "Double is not 3 " << std::endl;
|
||||
}
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_multiSelectList, "SelectedItems", "Multi Select Field", "", "", "" );
|
||||
m_multiSelectList.xmlCapability()->setIOReadable( false );
|
||||
m_multiSelectList.xmlCapability()->setIOWritable( false );
|
||||
m_multiSelectList.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
||||
|
||||
m_multiSelectList.v().push_back( "First" );
|
||||
m_multiSelectList.v().push_back( "Second" );
|
||||
m_multiSelectList.v().push_back( "Third" );
|
||||
|
||||
m_colorTriplets.push_back( new ColorTriplet );
|
||||
m_colorTriplets.push_back( new ColorTriplet );
|
||||
m_colorTriplets.push_back( new ColorTriplet );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> SmallDemoPdmObject::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_multiSelectList )
|
||||
{
|
||||
QString text;
|
||||
|
||||
text = "First";
|
||||
options.push_back( caf::PdmOptionItemInfo( text, text ) );
|
||||
|
||||
text = "Second";
|
||||
options.push_back(
|
||||
caf::PdmOptionItemInfo::createHeader( text, false, caf::IconProvider( ":/images/win/textbold.png" ) ) );
|
||||
|
||||
{
|
||||
text = "Second_a";
|
||||
caf::PdmOptionItemInfo itemInfo = caf::PdmOptionItemInfo( text, text, true );
|
||||
itemInfo.setLevel( 1 );
|
||||
options.push_back( itemInfo );
|
||||
}
|
||||
|
||||
{
|
||||
text = "Second_b";
|
||||
caf::PdmOptionItemInfo itemInfo =
|
||||
caf::PdmOptionItemInfo( text, text, false, caf::IconProvider( ":/images/win/filenew.png" ) );
|
||||
itemInfo.setLevel( 1 );
|
||||
options.push_back( itemInfo );
|
||||
}
|
||||
|
||||
int additionalSubItems = 2;
|
||||
for ( auto i = 0; i < additionalSubItems; i++ )
|
||||
{
|
||||
text = "Second_b_" + QString::number( i );
|
||||
caf::PdmOptionItemInfo itemInfo = caf::PdmOptionItemInfo( text, text );
|
||||
itemInfo.setLevel( 1 );
|
||||
options.push_back( itemInfo );
|
||||
}
|
||||
|
||||
static int s_additionalSubItems = 0;
|
||||
if ( m_toggleField() )
|
||||
{
|
||||
s_additionalSubItems++;
|
||||
}
|
||||
for ( auto i = 0; i < s_additionalSubItems; i++ )
|
||||
{
|
||||
text = "Second_b_" + QString::number( i );
|
||||
caf::PdmOptionItemInfo itemInfo = caf::PdmOptionItemInfo( text, text );
|
||||
itemInfo.setLevel( 1 );
|
||||
options.push_back( itemInfo );
|
||||
}
|
||||
|
||||
text = "Third";
|
||||
options.push_back( caf::PdmOptionItemInfo( text, text ) );
|
||||
|
||||
text = "Fourth";
|
||||
options.push_back( caf::PdmOptionItemInfo( text, text ) );
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* SmallDemoPdmObject::objectToggleField()
|
||||
{
|
||||
return &m_toggleField;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObject::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_toggleField )
|
||||
{
|
||||
std::cout << "Toggle Field changed" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObject::setDoubleMember( const double& d )
|
||||
{
|
||||
m_doubleMember = d;
|
||||
std::cout << "setDoubleMember" << std::endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double SmallDemoPdmObject::doubleMember() const
|
||||
{
|
||||
std::cout << "doubleMember" << std::endl;
|
||||
return m_doubleMember;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObject::defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu,
|
||||
QMenu* menu,
|
||||
QWidget* fieldEditorWidget )
|
||||
{
|
||||
menu->addAction( "test" );
|
||||
menu->addAction( "other test <<>>" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObject::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_booleanAndDoubleField );
|
||||
uiOrdering.add( &m_booleanAndTextField );
|
||||
|
||||
uiOrdering.add( &m_doubleField );
|
||||
uiOrdering.add( &m_intField );
|
||||
QString dynamicGroupName = QString( "Dynamic Group Text (%1)" ).arg( m_intField() );
|
||||
|
||||
caf::PdmUiGroup* group = uiOrdering.addNewGroupWithKeyword( dynamicGroupName, "MyTest" );
|
||||
group->add( &m_textField );
|
||||
group->add( &m_proxyDoubleField );
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "ColorTriplet.h"
|
||||
|
||||
#include "cafFilePath.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class SmallDemoPdmObject : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
SmallDemoPdmObject();
|
||||
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
void defineCustomContextMenu( const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
void setDoubleMember( const double& d );
|
||||
double doubleMember() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<double> m_doubleField;
|
||||
caf::PdmField<int> m_intField;
|
||||
caf::PdmField<QString> m_textField;
|
||||
|
||||
caf::PdmField<std::pair<bool, double>> m_booleanAndDoubleField;
|
||||
caf::PdmField<std::pair<bool, QString>> m_booleanAndTextField;
|
||||
|
||||
caf::PdmChildArrayField<ColorTriplet*> m_colorTriplets;
|
||||
|
||||
caf::PdmProxyValueField<double> m_proxyDoubleField;
|
||||
caf::PdmField<caf::FilePath> m_fileName;
|
||||
caf::PdmField<std::vector<caf::FilePath>> m_fileNameList;
|
||||
|
||||
caf::PdmField<std::vector<QString>> m_multiSelectList;
|
||||
|
||||
caf::PdmField<bool> m_toggleField;
|
||||
|
||||
double m_doubleMember;
|
||||
};
|
||||
@@ -0,0 +1,265 @@
|
||||
#include "SmallDemoPdmObjectA.h"
|
||||
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( SmallDemoPdmObjectA, "SmallDemoPdmObjectA" );
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template <>
|
||||
void AppEnum<SmallDemoPdmObjectA::TestEnumType>::setUp()
|
||||
{
|
||||
addItem( SmallDemoPdmObjectA::TestEnumType::T1, "T1", "An A letter" );
|
||||
addItem( SmallDemoPdmObjectA::TestEnumType::T2, "T2", "A B letter" );
|
||||
addItem( SmallDemoPdmObjectA::TestEnumType::T3, "T3", "A B C letter" );
|
||||
setDefault( SmallDemoPdmObjectA::TestEnumType::T1 );
|
||||
}
|
||||
|
||||
} // namespace caf
|
||||
|
||||
Q_DECLARE_METATYPE( caf::AppEnum<SmallDemoPdmObjectA::TestEnumType> );
|
||||
|
||||
SmallDemoPdmObjectA::SmallDemoPdmObjectA()
|
||||
{
|
||||
CAF_PDM_InitObject( "Small Demo Object A",
|
||||
"",
|
||||
"This object is a demo of the CAF framework",
|
||||
"This object is a demo of the CAF framework" );
|
||||
|
||||
CAF_PDM_InitField( &m_toggleField,
|
||||
"Toggle",
|
||||
false,
|
||||
"Toggle Field much text much text much much text much text muchmuch text much text "
|
||||
"muchmuch "
|
||||
"text much "
|
||||
"text muchmuch text much text muchmuch text much text much",
|
||||
"",
|
||||
"Toggle Field tooltip",
|
||||
" Toggle Field whatsthis" );
|
||||
|
||||
CAF_PDM_InitField( &m_pushButtonField, "Push", false, "Button Field", "", "", " " );
|
||||
CAF_PDM_InitField( &m_doubleField,
|
||||
"BigNumber",
|
||||
0.0,
|
||||
"Big Number",
|
||||
"",
|
||||
"Enter a big number here",
|
||||
"This is a place you can enter a big real value if you want" );
|
||||
CAF_PDM_InitField( &m_intField,
|
||||
"IntNumber",
|
||||
0,
|
||||
"Small Number",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_textField, "TextField", QString( "Small Demo Object A" ), "Name Text Field", "", "", "" );
|
||||
CAF_PDM_InitField( &m_testEnumField, "TestEnumValue", caf::AppEnum<TestEnumType>( TestEnumType::T1 ), "EnumField", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_ptrField, "m_ptrField", "PtrField", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_proxyEnumField, "ProxyEnumValue", "ProxyEnum", "", "", "" );
|
||||
m_proxyEnumField.registerSetMethod( this, &SmallDemoPdmObjectA::setEnumMember );
|
||||
m_proxyEnumField.registerGetMethod( this, &SmallDemoPdmObjectA::enumMember );
|
||||
m_proxyEnumMember = TestEnumType::T2;
|
||||
m_proxyEnumField.uiCapability()->setAttribute<bool>( "showPreviousAndNextButtons", true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_multipleAppEnum, "MultipleAppEnumValue", "MultipleAppEnumValue", "", "", "" );
|
||||
m_multipleAppEnum.capability<caf::PdmUiFieldHandle>()->setUiEditorTypeName(
|
||||
caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
||||
CAF_PDM_InitFieldNoDefault( &m_highlightedEnum, "HighlightedEnum", "HighlightedEnum", "", "", "" );
|
||||
m_highlightedEnum.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* SmallDemoPdmObjectA::objectToggleField()
|
||||
{
|
||||
return &m_toggleField;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* SmallDemoPdmObjectA::userDescriptionField()
|
||||
{
|
||||
return &m_textField;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::migrateFieldContent( QString& fieldContent, caf::PdmFieldHandle* fieldHandle )
|
||||
{
|
||||
if ( fieldHandle == &m_textField )
|
||||
{
|
||||
fieldContent = "Migrated Text Field Content";
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_toggleField )
|
||||
{
|
||||
std::cout << "Toggle Field changed" << std::endl;
|
||||
}
|
||||
else if ( changedField == &m_highlightedEnum )
|
||||
{
|
||||
std::cout << "Highlight value " << m_highlightedEnum().uiText().toStdString() << std::endl;
|
||||
}
|
||||
else if ( changedField == &m_pushButtonField )
|
||||
{
|
||||
std::cout << "Push Button pressed " << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::setEnumMember( const caf::AppEnum<TestEnumType>& val )
|
||||
{
|
||||
m_proxyEnumMember = val;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::AppEnum<SmallDemoPdmObjectA::TestEnumType> SmallDemoPdmObjectA::enumMember() const
|
||||
{
|
||||
return m_proxyEnumMember;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::enableAutoValueForTestEnum( TestEnumType value )
|
||||
{
|
||||
auto enumValue = static_cast<std::underlying_type_t<TestEnumType>>( value );
|
||||
m_testEnumField.uiCapability()->enableAndSetAutoValue( enumValue );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::enableAutoValueForDouble( double value )
|
||||
{
|
||||
m_doubleField.uiCapability()->enableAndSetAutoValue( value );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::enableAutoValueForInt( double value )
|
||||
{
|
||||
m_intField.uiCapability()->enableAndSetAutoValue( value );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::setAutoValueForTestEnum( TestEnumType value )
|
||||
{
|
||||
auto enumValue = static_cast<std::underlying_type_t<TestEnumType>>( value );
|
||||
m_testEnumField.uiCapability()->setAutoValue( enumValue );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::setAutoValueForDouble( double value )
|
||||
{
|
||||
m_doubleField.uiCapability()->setAutoValue( value );
|
||||
m_doubleField.uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::setAutoValueForInt( double value )
|
||||
{
|
||||
m_intField.uiCapability()->setAutoValue( value );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> SmallDemoPdmObjectA::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( &m_ptrField == fieldNeedingOptions )
|
||||
{
|
||||
caf::PdmFieldHandle* field = this->parentField();
|
||||
std::vector<caf::PdmObjectHandle*> objects = field->children();
|
||||
for ( size_t i = 0; i < objects.size(); ++i )
|
||||
{
|
||||
QString userDesc;
|
||||
|
||||
caf::PdmUiObjectHandle* uiObject = caf::uiObj( objects[i] );
|
||||
if ( uiObject )
|
||||
{
|
||||
if ( uiObject->userDescriptionField() )
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = uiObject->userDescriptionField()->uiCapability();
|
||||
if ( uiFieldHandle )
|
||||
{
|
||||
userDesc = uiFieldHandle->uiValue().toString();
|
||||
}
|
||||
}
|
||||
|
||||
options.push_back(
|
||||
caf::PdmOptionItemInfo( uiObject->uiName() + "(" + userDesc + ")",
|
||||
QVariant::fromValue( caf::PdmPointer<caf::PdmObjectHandle>( objects[i] ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( &m_multipleAppEnum == fieldNeedingOptions )
|
||||
{
|
||||
for ( size_t i = 0; i < caf::AppEnum<TestEnumType>::size(); ++i )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( caf::AppEnum<TestEnumType>::uiTextFromIndex( i ),
|
||||
caf::AppEnum<TestEnumType>::fromIndex( i ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( field == &m_multipleAppEnum )
|
||||
{
|
||||
caf::PdmUiTreeSelectionEditorAttribute* attr = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*>( attribute );
|
||||
if ( attr )
|
||||
{
|
||||
attr->currentIndexFieldHandle = &m_highlightedEnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallDemoPdmObjectA::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
caf::PdmUiTableViewPushButtonEditorAttribute* attr =
|
||||
dynamic_cast<caf::PdmUiTableViewPushButtonEditorAttribute*>( attribute );
|
||||
if ( attr )
|
||||
{
|
||||
attr->registerPushButtonTextForFieldKeyword( m_pushButtonField.keyword(), "Edit" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class SmallDemoPdmObjectA : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum class TestEnumType
|
||||
{
|
||||
T1 = 10,
|
||||
T2,
|
||||
T3
|
||||
};
|
||||
|
||||
SmallDemoPdmObjectA();
|
||||
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
void migrateFieldContent( QString& fieldContent, caf::PdmFieldHandle* fieldHandle ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
void setEnumMember( const caf::AppEnum<TestEnumType>& val );
|
||||
caf::AppEnum<TestEnumType> enumMember() const;
|
||||
|
||||
void enableAutoValueForTestEnum( TestEnumType value );
|
||||
void enableAutoValueForDouble( double value );
|
||||
void enableAutoValueForInt( double value );
|
||||
|
||||
void setAutoValueForTestEnum( TestEnumType value );
|
||||
void setAutoValueForDouble( double value );
|
||||
void setAutoValueForInt( double value );
|
||||
|
||||
protected:
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<double> m_doubleField;
|
||||
caf::PdmField<int> m_intField;
|
||||
caf::PdmField<QString> m_textField;
|
||||
caf::PdmField<caf::AppEnum<TestEnumType>> m_testEnumField;
|
||||
caf::PdmPtrField<SmallDemoPdmObjectA*> m_ptrField;
|
||||
|
||||
caf::PdmProxyValueField<caf::AppEnum<TestEnumType>> m_proxyEnumField;
|
||||
TestEnumType m_proxyEnumMember;
|
||||
|
||||
caf::PdmField<std::vector<caf::AppEnum<TestEnumType>>> m_multipleAppEnum;
|
||||
caf::PdmField<caf::AppEnum<TestEnumType>> m_highlightedEnum;
|
||||
|
||||
caf::PdmField<bool> m_toggleField;
|
||||
caf::PdmField<bool> m_pushButtonField;
|
||||
};
|
||||
@@ -0,0 +1,277 @@
|
||||
#include "SmallGridDemoPdmObject.h"
|
||||
|
||||
#include "cafPdmUiOrdering.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( SmallGridDemoPdmObject, "SmallGridDemoPdmObject" );
|
||||
|
||||
SmallGridDemoPdmObject::SmallGridDemoPdmObject()
|
||||
{
|
||||
CAF_PDM_InitObject( "Small Grid Demo Object",
|
||||
"",
|
||||
"This object is a demo of the CAF framework",
|
||||
"This object is a demo of the CAF framework" );
|
||||
|
||||
CAF_PDM_InitField( &m_intFieldStandard,
|
||||
"Standard",
|
||||
0,
|
||||
"Standard",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldUseFullSpace,
|
||||
"FullSpace",
|
||||
0,
|
||||
"Use Full Space For Both",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldUseFullSpaceLabel,
|
||||
"FullSpaceLabel",
|
||||
0,
|
||||
"Total 3, Label MAX",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldUseFullSpaceField,
|
||||
"FullSpaceField",
|
||||
0,
|
||||
"Total MAX, Label 1",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldWideLabel,
|
||||
"WideLabel",
|
||||
0,
|
||||
"Wide Label",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldWideField,
|
||||
"WideField",
|
||||
0,
|
||||
"Wide Field",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldLeft,
|
||||
"LeftField",
|
||||
0,
|
||||
"Left Field",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldRight,
|
||||
"RightField",
|
||||
0,
|
||||
"Right Field With More Text",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldWideBoth,
|
||||
"WideBoth",
|
||||
0,
|
||||
"Wide Both",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
|
||||
CAF_PDM_InitField( &m_intFieldWideBoth2,
|
||||
"WideBoth2",
|
||||
0,
|
||||
"Wide Both",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldLeft2,
|
||||
"LeftFieldInGrp",
|
||||
0,
|
||||
"Left Field",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldCenter,
|
||||
"CenterFieldInGrp",
|
||||
0,
|
||||
"Center Field",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldRight2,
|
||||
"RightFieldInGrp",
|
||||
0,
|
||||
"Right Field",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldLabelTop,
|
||||
"FieldLabelTop",
|
||||
0,
|
||||
"Field Label Top",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
m_intFieldLabelTop.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::TOP );
|
||||
CAF_PDM_InitField( &m_stringFieldLabelHidden,
|
||||
"FieldLabelHidden",
|
||||
QString( "Hidden Label Field" ),
|
||||
"Field Label Hidden",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
m_stringFieldLabelHidden.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::HIDDEN );
|
||||
|
||||
CAF_PDM_InitField( &m_intFieldWideBothAuto,
|
||||
"WideBothAuto",
|
||||
0,
|
||||
"Wide ",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldLeftAuto,
|
||||
"LeftFieldInGrpAuto",
|
||||
0,
|
||||
"Left Field",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldCenterAuto,
|
||||
"CenterFieldInGrpAuto",
|
||||
0,
|
||||
"Center Field",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldRightAuto,
|
||||
"RightFieldInGrpAuto",
|
||||
0,
|
||||
"Right Field",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldLabelTopAuto,
|
||||
"FieldLabelTopAuto",
|
||||
0,
|
||||
"Field Label Top",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
m_intFieldLabelTopAuto.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::TOP );
|
||||
CAF_PDM_InitField( &m_stringFieldLabelHiddenAuto,
|
||||
"FieldLabelHiddenAuto",
|
||||
QString( "Hidden Label Field" ),
|
||||
"Field Label Hidden",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
m_stringFieldLabelHiddenAuto.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::HIDDEN );
|
||||
|
||||
CAF_PDM_InitField( &m_intFieldLeftOfGroup,
|
||||
"FieldLeftOfGrp",
|
||||
0,
|
||||
"Left of group",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldRightOfGroup,
|
||||
"FieldRightOfGrp",
|
||||
0,
|
||||
"Right of group wide label",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
|
||||
CAF_PDM_InitField( &m_intFieldInsideGroup1,
|
||||
"FieldInGrp1",
|
||||
0,
|
||||
"Inside Group",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldInsideGroup2,
|
||||
"FieldInGrp2",
|
||||
0,
|
||||
"Inside Group",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldInsideGroup3,
|
||||
"FieldInGrp3",
|
||||
0,
|
||||
"Inside Group",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldInsideGroup4,
|
||||
"FieldInGrp4",
|
||||
0,
|
||||
"Inside Group",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldInsideGroup5,
|
||||
"FieldInGrp5",
|
||||
0,
|
||||
"Inside Group",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
CAF_PDM_InitField( &m_intFieldInsideGroup6,
|
||||
"FieldInGrp6",
|
||||
0,
|
||||
"Inside Group",
|
||||
"",
|
||||
"Enter some small number here",
|
||||
"This is a place you can enter a small integer value if you want" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SmallGridDemoPdmObject::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_intFieldStandard );
|
||||
uiOrdering.add( &m_intFieldUseFullSpace );
|
||||
uiOrdering.add( &m_intFieldUseFullSpaceLabel, { .totalColumnSpan = 3 } );
|
||||
uiOrdering.add( &m_intFieldUseFullSpaceField, { .leftLabelColumnSpan = 1 } );
|
||||
uiOrdering.add( &m_intFieldWideLabel, { .totalColumnSpan = 4, .leftLabelColumnSpan = 3 } );
|
||||
uiOrdering.add( &m_intFieldWideField, { .totalColumnSpan = 4, .leftLabelColumnSpan = 1 } );
|
||||
uiOrdering.add( &m_intFieldLeft );
|
||||
uiOrdering.appendToRow( &m_intFieldRight );
|
||||
uiOrdering.add( &m_intFieldWideBoth, { .totalColumnSpan = 4, .leftLabelColumnSpan = 2 } );
|
||||
|
||||
QString dynamicGroupName = QString( "Dynamic Group Text (%1)" ).arg( m_intFieldStandard() );
|
||||
|
||||
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Wide Group", { .totalColumnSpan = 4 } );
|
||||
group->add( &m_intFieldWideBoth2, { .totalColumnSpan = 6, .leftLabelColumnSpan = 3 } );
|
||||
group->add( &m_intFieldLeft2 );
|
||||
group->appendToRow( &m_intFieldCenter );
|
||||
group->appendToRow( &m_intFieldRight2 );
|
||||
group->add( &m_intFieldLabelTop, { .totalColumnSpan = 6 } );
|
||||
group->add( &m_stringFieldLabelHidden, { .totalColumnSpan = 6 } );
|
||||
|
||||
caf::PdmUiGroup* autoGroup = uiOrdering.addNewGroup( "Automatic Full Width Group" );
|
||||
autoGroup->add( &m_intFieldWideBothAuto );
|
||||
autoGroup->add( &m_intFieldLeftAuto );
|
||||
autoGroup->appendToRow( &m_intFieldCenterAuto );
|
||||
autoGroup->appendToRow( &m_intFieldRightAuto );
|
||||
autoGroup->add( &m_intFieldLabelTopAuto );
|
||||
autoGroup->add( &m_stringFieldLabelHiddenAuto );
|
||||
|
||||
uiOrdering.add( &m_intFieldLeftOfGroup );
|
||||
caf::PdmUiGroup* group2 =
|
||||
uiOrdering.addNewGroup( "Right Group", { .newRow = false, .totalColumnSpan = 2, .leftLabelColumnSpan = 0 } );
|
||||
group2->setEnableFrame( false );
|
||||
group2->add( &m_intFieldInsideGroup1 );
|
||||
|
||||
caf::PdmUiGroup* group3 = uiOrdering.addNewGroup( "Narrow L", { .totalColumnSpan = 1 } );
|
||||
group3->add( &m_intFieldInsideGroup2 );
|
||||
uiOrdering.add( &m_intFieldRightOfGroup, { .newRow = false, .totalColumnSpan = 3, .leftLabelColumnSpan = 2 } );
|
||||
|
||||
caf::PdmUiGroup* groupL = uiOrdering.addNewGroup( "Left Group", { .totalColumnSpan = 1 } );
|
||||
groupL->add( &m_intFieldInsideGroup3 );
|
||||
groupL->add( &m_intFieldInsideGroup5 );
|
||||
caf::PdmUiGroup* groupR = uiOrdering.addNewGroup( "Right Wide Group", { .newRow = false, .totalColumnSpan = 3 } );
|
||||
groupR->setEnableFrame( false );
|
||||
groupR->add( &m_intFieldInsideGroup4 );
|
||||
groupR->add( &m_intFieldInsideGroup6 );
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class SmallGridDemoPdmObject : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
SmallGridDemoPdmObject();
|
||||
|
||||
// Outside group
|
||||
caf::PdmField<int> m_intFieldStandard;
|
||||
caf::PdmField<int> m_intFieldUseFullSpace;
|
||||
caf::PdmField<int> m_intFieldUseFullSpaceLabel;
|
||||
caf::PdmField<int> m_intFieldUseFullSpaceField;
|
||||
caf::PdmField<int> m_intFieldWideLabel;
|
||||
caf::PdmField<int> m_intFieldWideField;
|
||||
caf::PdmField<int> m_intFieldWideBoth;
|
||||
caf::PdmField<int> m_intFieldLeft;
|
||||
caf::PdmField<int> m_intFieldRight;
|
||||
|
||||
// First group
|
||||
caf::PdmField<int> m_intFieldWideBoth2;
|
||||
caf::PdmField<int> m_intFieldLeft2;
|
||||
caf::PdmField<int> m_intFieldCenter;
|
||||
caf::PdmField<int> m_intFieldRight2;
|
||||
caf::PdmField<int> m_intFieldLabelTop;
|
||||
caf::PdmField<QString> m_stringFieldLabelHidden;
|
||||
|
||||
// Auto group
|
||||
caf::PdmField<int> m_intFieldWideBothAuto;
|
||||
caf::PdmField<int> m_intFieldLeftAuto;
|
||||
caf::PdmField<int> m_intFieldCenterAuto;
|
||||
caf::PdmField<int> m_intFieldRightAuto;
|
||||
caf::PdmField<int> m_intFieldLabelTopAuto;
|
||||
caf::PdmField<QString> m_stringFieldLabelHiddenAuto;
|
||||
|
||||
// Combination with groups
|
||||
caf::PdmField<int> m_intFieldLeftOfGroup;
|
||||
caf::PdmField<int> m_intFieldRightOfGroup;
|
||||
caf::PdmField<int> m_intFieldInsideGroup1;
|
||||
caf::PdmField<int> m_intFieldInsideGroup2;
|
||||
|
||||
// Side-by-side groups
|
||||
caf::PdmField<int> m_intFieldInsideGroup3;
|
||||
caf::PdmField<int> m_intFieldInsideGroup4;
|
||||
caf::PdmField<int> m_intFieldInsideGroup5;
|
||||
caf::PdmField<int> m_intFieldInsideGroup6;
|
||||
|
||||
protected:
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
};
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user