mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Integrated fix for undo framework. Added virtual destructors.
This commit is contained in:
parent
fdcee2dd42
commit
2b47793d68
@ -38,6 +38,7 @@
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
|
||||
#include "cafCmdExecuteCommand.h"
|
||||
#include "cafCmdFieldChangeExec.h"
|
||||
#include "cafCmdUiCommandSystemImpl.h"
|
||||
#include "cafPdmUiCommandSystemProxy.h"
|
||||
|
||||
@ -140,7 +141,18 @@ QUndoStack* CmdExecCommandManager::undoStack()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdExecCommandManager::processExecuteCommand(CmdExecuteCommand* executeCommand)
|
||||
{
|
||||
if (m_commandFeatureInterface && m_commandFeatureInterface->isUndoEnabled())
|
||||
bool useUndo = false;
|
||||
|
||||
if (dynamic_cast<CmdFieldChangeExec*>(executeCommand) && m_commandFeatureInterface->disableUndoForFieldChange())
|
||||
{
|
||||
useUndo = false;
|
||||
}
|
||||
else if (m_commandFeatureInterface && m_commandFeatureInterface->isUndoEnabled())
|
||||
{
|
||||
useUndo = true;
|
||||
}
|
||||
|
||||
if (useUndo)
|
||||
{
|
||||
// Transfer ownership of execute command to wrapper object
|
||||
UndoRedoWrapper* undoRedoWrapper = new UndoRedoWrapper(executeCommand);
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
m_notificationCenter = notificationCenter;
|
||||
}
|
||||
|
||||
virtual ~CmdExecuteCommand() {};
|
||||
virtual ~CmdExecuteCommand() { };
|
||||
|
||||
virtual QString name() = 0;
|
||||
virtual void redo() = 0;
|
||||
|
@ -167,6 +167,15 @@ CmdFieldChangeExec::CmdFieldChangeExec(NotificationCenter* notificationCenter)
|
||||
m_commandData = new CmdFieldChangeExecData;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdFieldChangeExec::~CmdFieldChangeExec()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -77,6 +77,8 @@ class CmdFieldChangeExec : public CmdExecuteCommand
|
||||
{
|
||||
public:
|
||||
CmdFieldChangeExec(NotificationCenter* notificationCenter);
|
||||
virtual ~CmdFieldChangeExec();
|
||||
|
||||
|
||||
CmdFieldChangeExecData* commandData();
|
||||
|
||||
|
@ -89,6 +89,15 @@ CmdSelectionChangeExec::CmdSelectionChangeExec(NotificationCenter* notificationC
|
||||
m_commandData = new CmdSelectionChangeExecData;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdSelectionChangeExec::~CmdSelectionChangeExec()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -79,6 +79,7 @@ class CmdSelectionChangeExec : public CmdExecuteCommand
|
||||
{
|
||||
public:
|
||||
CmdSelectionChangeExec(NotificationCenter* notificationCenter);
|
||||
virtual ~CmdSelectionChangeExec();;
|
||||
|
||||
CmdSelectionChangeExecData* commandData();
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace caf
|
||||
CmdUiCommandSystemImpl::CmdUiCommandSystemImpl()
|
||||
{
|
||||
m_undoFeatureEnabled = false;
|
||||
m_disableUndoFeatureOverride = false;
|
||||
m_disableUndoForFieldChange = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -137,10 +137,10 @@ void CmdUiCommandSystemImpl::fieldChangedCommand(PdmFieldHandle* editorField, co
|
||||
}
|
||||
|
||||
caf::PdmUiObjectHandle* uiOwnerObjectHandle = uiObj(editorField->ownerObject());
|
||||
if (uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoFramework())
|
||||
if (uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoForFieldChanged())
|
||||
{
|
||||
// Temporarily disable undo framework as requested by the PdmUiObjectHandle
|
||||
m_disableUndoFeatureOverride = true;
|
||||
m_disableUndoForFieldChange = true;
|
||||
}
|
||||
|
||||
if (commands.size() == 1)
|
||||
@ -152,10 +152,10 @@ void CmdUiCommandSystemImpl::fieldChangedCommand(PdmFieldHandle* editorField, co
|
||||
CmdExecCommandManager::instance()->processExecuteCommandsAsMacro("Multiple Field Change", commands);
|
||||
}
|
||||
|
||||
if (uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoFramework())
|
||||
if (uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoForFieldChanged())
|
||||
{
|
||||
// Restore undo feature to normal operation
|
||||
m_disableUndoFeatureOverride = false;
|
||||
m_disableUndoForFieldChange = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,8 +183,6 @@ void CmdUiCommandSystemImpl::populateMenuWithDefaultCommands(const QString& uiCo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CmdUiCommandSystemImpl::isUndoEnabled()
|
||||
{
|
||||
if (m_disableUndoFeatureOverride) return false;
|
||||
|
||||
return m_undoFeatureEnabled;
|
||||
}
|
||||
|
||||
@ -196,4 +194,12 @@ void CmdUiCommandSystemImpl::enableUndoFeature(bool enable)
|
||||
m_undoFeatureEnabled = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CmdUiCommandSystemImpl::disableUndoForFieldChange()
|
||||
{
|
||||
return m_disableUndoForFieldChange;
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -56,9 +56,11 @@ public:
|
||||
bool isUndoEnabled();
|
||||
void enableUndoFeature(bool enable);
|
||||
|
||||
bool disableUndoForFieldChange();
|
||||
|
||||
private:
|
||||
bool m_undoFeatureEnabled;
|
||||
bool m_disableUndoFeatureOverride;
|
||||
bool m_disableUndoForFieldChange;
|
||||
};
|
||||
|
||||
|
||||
|
@ -158,6 +158,15 @@ CmdAddItemExec::CmdAddItemExec(NotificationCenter* notificationCenter)
|
||||
m_commandData = new CmdAddItemExecData;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CmdAddItemExec::~CmdAddItemExec()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -52,6 +52,7 @@ class CmdAddItemExec : public CmdExecuteCommand
|
||||
{
|
||||
public:
|
||||
CmdAddItemExec(NotificationCenter* notificationCenter);
|
||||
virtual ~CmdAddItemExec();;
|
||||
|
||||
CmdAddItemExecData* commandData();
|
||||
|
||||
|
@ -52,6 +52,8 @@ class CmdDeleteItemExec : public CmdExecuteCommand
|
||||
{
|
||||
public:
|
||||
CmdDeleteItemExec(NotificationCenter* notificationCenter);
|
||||
virtual ~CmdDeleteItemExec() {};
|
||||
|
||||
|
||||
CmdDeleteItemExecData* commandData();
|
||||
|
||||
|
135
Fwk/AppFwk/cafProjectDataModel/PdmModularization.plantuml
Normal file
135
Fwk/AppFwk/cafProjectDataModel/PdmModularization.plantuml
Normal file
@ -0,0 +1,135 @@
|
||||
@startuml
|
||||
|
||||
class PdmObjectHandle {
|
||||
name()
|
||||
fields();
|
||||
referencingFields();
|
||||
parentField();
|
||||
template<T> capability()
|
||||
void addCapability()
|
||||
|
||||
---
|
||||
std::vector<PdmFieldHandle> m_fields;
|
||||
std::vector<PdmObjectCapability*> m_capabilities;
|
||||
}
|
||||
|
||||
|
||||
PdmObjectHandle --* "n" PdmObjectCapability
|
||||
|
||||
class PdmUiItem{
|
||||
|
||||
}
|
||||
|
||||
PdmObjectCapability <|- PdmUiObjectHandle
|
||||
PdmUiItem <|- PdmUiObjectHandle
|
||||
|
||||
class PdmUiObjectHandle {
|
||||
uiOrdering() = ?;
|
||||
uiTreeOrdering() = ? ;
|
||||
editorAttribute() = ?;
|
||||
|
||||
objectEditorAttribute() = ? ;
|
||||
|
||||
userDescriptionField();
|
||||
objectToggleField()
|
||||
|
||||
calculateValueOptions() = ?;
|
||||
|
||||
fieldChangedByUi() = 0;
|
||||
---
|
||||
m_descriptionField;
|
||||
m_objectToggleField;
|
||||
}
|
||||
|
||||
PdmUiObjectHandle <|-- PdmObject
|
||||
PdmObjectHandle <|-- PdmObject
|
||||
PdmXmlObjectHandle <|-- PdmObject
|
||||
|
||||
|
||||
class PdmXmlObjectHandle {
|
||||
classKeyword() = 0;
|
||||
readFields ();
|
||||
writeFields();
|
||||
}
|
||||
|
||||
PdmObjectCapability <|- PdmXmlObjectHandle
|
||||
|
||||
|
||||
|
||||
package FieldHandle{
|
||||
|
||||
PdmObjectHandle --> "n" PdmFieldHandle
|
||||
|
||||
class PdmFieldHandle{
|
||||
name()
|
||||
|
||||
setOwnerObject();
|
||||
ownerObject();
|
||||
|
||||
hasChildObjects() = 0;
|
||||
childObjects( ) = 0;
|
||||
---
|
||||
std::vector<PdmFieldCapability*> m_attributes;
|
||||
}
|
||||
|
||||
|
||||
PdmFieldHandle --* "n" PdmFieldCapability
|
||||
|
||||
class PdmUiFieldHandle{
|
||||
|
||||
uiValue()
|
||||
setValueFromUi()
|
||||
|
||||
valueOptions( ) = 0;
|
||||
|
||||
}
|
||||
|
||||
PdmFieldCapability <|- PdmUiFieldHandle
|
||||
PdmUiItem <|- PdmUiFieldHandle
|
||||
|
||||
|
||||
class PdmXmlFieldHandle {
|
||||
setKeyword();
|
||||
keyword();
|
||||
|
||||
readFieldData() = 0;
|
||||
writeFieldData() = 0;
|
||||
|
||||
isIOReadable()
|
||||
isIOWritable()
|
||||
setIOWritable()
|
||||
setIOReadable()
|
||||
---
|
||||
bool m_isReadable;
|
||||
bool m_isWritable;
|
||||
}
|
||||
|
||||
PdmFieldCapability <|- PdmXmlFieldHandle
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
PdmFieldHandle <|- "PdmPtrField<T*>"
|
||||
PdmFieldHandle <|- "PdmChildField<T*>"
|
||||
|
||||
PdmFieldHandle <|- PdmValueField
|
||||
PdmValueField <|-- "PdmDataValueField<T>"
|
||||
PdmValueField <|-- "PdmProxyValueField<T>"
|
||||
|
||||
PdmFieldHandle <|- PdmChildArrayFieldHandle
|
||||
PdmChildArrayFieldHandle <|-- "PdmChildArrayField<T*>"
|
||||
|
||||
PdmField ..u.. PdmValueField
|
||||
|
||||
class PdmField {
|
||||
Macro used to replace
|
||||
PdmField with PdmValueField (used in ResInsight)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@enduml
|
||||
|
76
Fwk/AppFwk/cafProjectDataModel/PdmOverview.plantuml
Normal file
76
Fwk/AppFwk/cafProjectDataModel/PdmOverview.plantuml
Normal file
@ -0,0 +1,76 @@
|
||||
@startuml
|
||||
left to right direction
|
||||
|
||||
component cafProjectDataModel
|
||||
note right of [cafProjectDataModel]
|
||||
Templated factory class
|
||||
Multithreaded mutex
|
||||
Aggreagated class PdmObject, inherits Core, Ui, Xml
|
||||
Helper macro to be able to use PdmField(macro for replacing with PdmValueField)
|
||||
PdmObjectGroup - collection of PdmObjects
|
||||
end note
|
||||
|
||||
|
||||
component cafPdmCore
|
||||
note right of [cafPdmCore]
|
||||
cafAppEnum
|
||||
Classes derived from cafPdmFieldHandle
|
||||
cafPdmPointer
|
||||
end note
|
||||
|
||||
component cafPdmUiCore
|
||||
note right of [cafPdmUiCore]
|
||||
Object editor handle
|
||||
Field editor handle
|
||||
Ui ordering for properties
|
||||
Ui ordering for tree view
|
||||
Selection manager
|
||||
end note
|
||||
|
||||
component cafPdmXml
|
||||
note right of [cafPdmXml]
|
||||
Default object factory
|
||||
Serialization of objects to Xml
|
||||
end note
|
||||
|
||||
component cafUserInterface
|
||||
note right of [cafUserInterface]
|
||||
Default object property editor
|
||||
Property view contained in a dialog (used to display preferences)
|
||||
|
||||
Table editor
|
||||
Progress info
|
||||
|
||||
PdmField editors (line, checkbox, list view, ...)
|
||||
end note
|
||||
|
||||
component cafCommand
|
||||
note right of [cafCommand]
|
||||
Feature manager
|
||||
Base class for features
|
||||
Base class for feature commands
|
||||
Management of undo/redo
|
||||
end note
|
||||
|
||||
component cafAnimControl
|
||||
component cafTensor
|
||||
|
||||
component cafViewer
|
||||
note right of [cafViewer]
|
||||
Viewer widget used to display 3D models
|
||||
Mouse navigation policies
|
||||
end note
|
||||
|
||||
component cafPdmCvf
|
||||
note right of [cafPdmCvf]
|
||||
Definition of default Ui editors for CVF classes
|
||||
Color3f
|
||||
Vec3d
|
||||
Mat4d
|
||||
end note
|
||||
|
||||
|
||||
|
||||
|
||||
@enduml
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
void objectEditorAttribute(QString uiConfigName, PdmUiEditorAttribute* attribute);
|
||||
|
||||
/// Field used to control if field change of and object should be covered by undo/redo framework
|
||||
virtual bool useUndoRedoFramework() { return true; }
|
||||
virtual bool useUndoRedoForFieldChanged() { return true; }
|
||||
|
||||
void updateUiIconFromToggleField();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user