mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merged with dev
This commit is contained in:
commit
26accc9e9a
@ -126,13 +126,9 @@ void RicToggleItemsFeatureImpl::setObjectToggleStateForSelection(SelectionToggle
|
||||
{
|
||||
caf::PdmField<bool>* field = dynamic_cast<caf::PdmField<bool>*>(uiObjectHandleChild->objectToggleField());
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
if (state == TOGGLE_ON) uiFieldHandle->setValueFromUi(true);
|
||||
if (state == TOGGLE_OFF) uiFieldHandle->setValueFromUi(false);
|
||||
if (state == TOGGLE_SUBITEMS) uiFieldHandle->setValueFromUi(!(field->v()));
|
||||
}
|
||||
if (state == TOGGLE_ON) field->setValueWithFieldChanged(true);
|
||||
if (state == TOGGLE_OFF) field->setValueWithFieldChanged(false);
|
||||
if (state == TOGGLE_SUBITEMS) field->setValueWithFieldChanged(!(field->v()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,15 +142,11 @@ void RicToggleItemsFeatureImpl::setObjectToggleStateForSelection(SelectionToggle
|
||||
{
|
||||
caf::PdmField<bool>* field = dynamic_cast<caf::PdmField<bool>* >(uiObjectHandle->objectToggleField());
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = field->uiCapability();
|
||||
if (uiFieldHandle)
|
||||
if (state == TOGGLE_ON) field->setValueWithFieldChanged(true);
|
||||
if (state == TOGGLE_OFF) field->setValueWithFieldChanged(false);
|
||||
if (state == TOGGLE_SUBITEMS || state == TOGGLE)
|
||||
{
|
||||
if (state == TOGGLE_ON) uiFieldHandle->setValueFromUi(true);
|
||||
if (state == TOGGLE_OFF) uiFieldHandle->setValueFromUi(false);
|
||||
if (state == TOGGLE_SUBITEMS || state == TOGGLE)
|
||||
{
|
||||
uiFieldHandle->setValueFromUi(!(field->v()));
|
||||
}
|
||||
field->setValueWithFieldChanged(!(field->v()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void RicShowAllLinkedViewsFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
for (size_t j = 0; j < views.size(); j++)
|
||||
{
|
||||
views[j]->showWindow.uiCapability()->setValueFromUi(true);
|
||||
views[j]->showWindow.setValueWithFieldChanged(true);
|
||||
views[j]->uiCapability()->updateUiIconFromToggleField();
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
#include "cafPdmValueField.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
@ -227,9 +228,16 @@ void RimCommandIssueFieldChanged::redo()
|
||||
|
||||
if (fieldHandle && fieldHandle->uiCapability())
|
||||
{
|
||||
caf::PdmValueField* valueField = dynamic_cast<caf::PdmValueField*>(fieldHandle);
|
||||
CVF_ASSERT(valueField);
|
||||
|
||||
QVariant oldValue = valueField->toQVariant();
|
||||
QVariant newValue(this->fieldValueToApply);
|
||||
|
||||
valueField->setFromQVariant(newValue);
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = fieldHandle->uiCapability();
|
||||
QVariant variantValue(this->fieldValueToApply);
|
||||
uiFieldHandle->setValueFromUi(variantValue);
|
||||
uiFieldHandle->notifyFieldChanged(oldValue, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -634,15 +634,20 @@ cvf::Vec3d RimIntersection::extrusionDirection() const
|
||||
{
|
||||
cvf::Vec3d dir = cvf::Vec3d::Z_AXIS;
|
||||
|
||||
if (direction() == RimIntersection::CS_HORIZONTAL &&
|
||||
m_userPolyline().size() > 1)
|
||||
if (direction() == RimIntersection::CS_HORIZONTAL)
|
||||
{
|
||||
// Use first and last point of polyline to approximate orientation of polyline
|
||||
// Then cross with Z axis to find extrusion direction
|
||||
std::vector< std::vector <cvf::Vec3d> > lines = this->polyLines();
|
||||
if (lines.size() > 0 && lines[0].size() > 1)
|
||||
{
|
||||
std::vector <cvf::Vec3d> firstLine = lines[0];
|
||||
|
||||
cvf::Vec3d polyLineDir = m_userPolyline()[m_userPolyline().size() - 1] - m_userPolyline()[0];
|
||||
cvf::Vec3d up = cvf::Vec3d::Z_AXIS;
|
||||
dir = polyLineDir ^ up;
|
||||
// Use first and last point of polyline to approximate orientation of polyline
|
||||
// Then cross with Z axis to find extrusion direction
|
||||
|
||||
cvf::Vec3d polyLineDir = firstLine[firstLine.size() - 1] - firstLine[0];
|
||||
cvf::Vec3d up = cvf::Vec3d::Z_AXIS;
|
||||
dir = polyLineDir ^ up;
|
||||
}
|
||||
}
|
||||
else if (direction() == RimIntersection::CS_TWO_POINTS && m_customExtrusionPoints().size() > 1)
|
||||
{
|
||||
|
@ -394,14 +394,14 @@ void RimView::setMeshOnlyDrawstyle()
|
||||
{
|
||||
if (isGridVisualizationMode())
|
||||
{
|
||||
meshMode.uiCapability()->setValueFromUi(FULL_MESH);
|
||||
meshMode.setValueWithFieldChanged(FULL_MESH);
|
||||
}
|
||||
else
|
||||
{
|
||||
meshMode.uiCapability()->setValueFromUi(FAULTS_MESH);
|
||||
meshMode.setValueWithFieldChanged(FAULTS_MESH);
|
||||
}
|
||||
|
||||
surfaceMode.uiCapability()->setValueFromUi(NO_SURFACE);
|
||||
surfaceMode.setValueWithFieldChanged(NO_SURFACE);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -411,13 +411,13 @@ void RimView::setMeshSurfDrawstyle()
|
||||
{
|
||||
if (isGridVisualizationMode())
|
||||
{
|
||||
surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
meshMode.uiCapability()->setValueFromUi(FULL_MESH);
|
||||
surfaceMode.setValueWithFieldChanged(SURFACE);
|
||||
meshMode.setValueWithFieldChanged(FULL_MESH);
|
||||
}
|
||||
else
|
||||
{
|
||||
surfaceMode.uiCapability()->setValueFromUi(FAULTS);
|
||||
meshMode.uiCapability()->setValueFromUi(FAULTS_MESH);
|
||||
surfaceMode.setValueWithFieldChanged(FAULTS);
|
||||
meshMode.setValueWithFieldChanged(FAULTS_MESH);
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,14 +433,14 @@ void RimView::setFaultMeshSurfDrawstyle()
|
||||
// Mesh SF SF SF
|
||||
if (this->isGridVisualizationMode())
|
||||
{
|
||||
surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
surfaceMode.setValueWithFieldChanged(SURFACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
surfaceMode.uiCapability()->setValueFromUi(FAULTS);
|
||||
surfaceMode.setValueWithFieldChanged(FAULTS);
|
||||
}
|
||||
|
||||
meshMode.uiCapability()->setValueFromUi(FAULTS_MESH);
|
||||
meshMode.setValueWithFieldChanged(FAULTS_MESH);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -450,14 +450,14 @@ void RimView::setSurfOnlyDrawstyle()
|
||||
{
|
||||
if (isGridVisualizationMode())
|
||||
{
|
||||
surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
surfaceMode.setValueWithFieldChanged(SURFACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
surfaceMode.uiCapability()->setValueFromUi(FAULTS);
|
||||
surfaceMode.setValueWithFieldChanged(FAULTS);
|
||||
}
|
||||
|
||||
meshMode.uiCapability()->setValueFromUi(NO_MESH);
|
||||
meshMode.setValueWithFieldChanged(NO_MESH);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -468,13 +468,13 @@ void RimView::showGridCells(bool enableGridCells)
|
||||
if (!enableGridCells)
|
||||
{
|
||||
m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH;
|
||||
if (surfaceMode() != NO_SURFACE) surfaceMode.uiCapability()->setValueFromUi(FAULTS);
|
||||
if (meshMode() != NO_MESH) meshMode.uiCapability()->setValueFromUi(FAULTS_MESH);
|
||||
if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS);
|
||||
if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (surfaceMode() != NO_SURFACE) surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
if (meshMode() != NO_MESH) meshMode.uiCapability()->setValueFromUi(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH);
|
||||
if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE);
|
||||
if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH);
|
||||
}
|
||||
|
||||
m_gridCollection->isActive = enableGridCells;
|
||||
@ -487,7 +487,7 @@ void RimView::showGridCells(bool enableGridCells)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimView::setSurfaceDrawstyle()
|
||||
{
|
||||
if (surfaceMode() != NO_SURFACE) surfaceMode.uiCapability()->setValueFromUi(SURFACE);
|
||||
if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -1129,8 +1129,7 @@ void RiuMainWindow::slotFramerateChanged(double frameRate)
|
||||
{
|
||||
if (RiaApplication::instance()->activeReservoirView() != NULL)
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = RiaApplication::instance()->activeReservoirView()->maximumFrameRate.uiCapability();
|
||||
uiFieldHandle->setValueFromUi(QVariant(frameRate));
|
||||
RiaApplication::instance()->activeReservoirView()->maximumFrameRate.setValueWithFieldChanged(frameRate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1385,8 +1384,7 @@ void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels)
|
||||
RimEclipseView* activeRiv = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
||||
if (!activeRiv) return;
|
||||
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = activeRiv->faultCollection->showFaultLabel.uiCapability();
|
||||
uiFieldHandle->setValueFromUi(showLabels);
|
||||
activeRiv->faultCollection->showFaultLabel.setValueWithFieldChanged(showLabels);
|
||||
|
||||
refreshDrawStyleActions();
|
||||
}
|
||||
@ -1488,8 +1486,7 @@ void RiuMainWindow::slotScaleChanged(int scaleValue)
|
||||
{
|
||||
if (RiaApplication::instance()->activeReservoirView())
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = RiaApplication::instance()->activeReservoirView()->scaleZ.uiCapability();
|
||||
uiFieldHandle->setValueFromUi(scaleValue);
|
||||
RiaApplication::instance()->activeReservoirView()->scaleZ.setValueWithFieldChanged(scaleValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1629,11 +1626,7 @@ void RiuMainWindow::slotAddWellCellsToRangeFilterAction(bool doAdd)
|
||||
caf::AppEnum<RimEclipseWellCollection::WellCellsRangeFilterType> rangeAddType;
|
||||
rangeAddType = doAdd ? RimEclipseWellCollection::RANGE_ADD_INDIVIDUAL : RimEclipseWellCollection::RANGE_ADD_NONE;
|
||||
|
||||
caf::PdmUiFieldHandle* pdmUiFieldHandle = riv->wellCollection()->wellCellsToRangeFilterMode.uiCapability();
|
||||
if (pdmUiFieldHandle)
|
||||
{
|
||||
pdmUiFieldHandle->setValueFromUi(static_cast<unsigned int>(rangeAddType.index()));
|
||||
}
|
||||
riv->wellCollection()->wellCellsToRangeFilterMode.setValueWithFieldChanged(rangeAddType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,11 +404,7 @@ void RiuViewerCommands::slotHideFault()
|
||||
RimFault* rimFault = eclipseView->faultCollection()->findFaultByName(faultName);
|
||||
if (rimFault)
|
||||
{
|
||||
caf::PdmUiFieldHandle* uiFieldHandle = rimFault->showFault.uiCapability();
|
||||
if (uiFieldHandle)
|
||||
{
|
||||
uiFieldHandle->setValueFromUi(!rimFault->showFault);
|
||||
}
|
||||
rimFault->showFault.setValueWithFieldChanged(!rimFault->showFault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,13 +97,17 @@ void CmdFieldChangeExec::redo()
|
||||
{
|
||||
if (m_commandData->m_redoFieldValueSerialized.isEmpty())
|
||||
{
|
||||
// We end up here only when the user actually has done something in the actual living Gui editor.
|
||||
{
|
||||
QXmlStreamWriter xmlStream(&m_commandData->m_undoFieldValueSerialized);
|
||||
writeFieldDataToValidXmlDocument(xmlStream, xmlFieldHandle);
|
||||
}
|
||||
|
||||
// This function will notify field change, no need to explicitly call notification
|
||||
uiFieldHandle->setValueFromUi(m_commandData->m_newUiValue);
|
||||
// The ui value might be an index into the option entry cache, so we need to set the value
|
||||
// and be aware of the option entries, and then serialize the actual field value we ended up with.
|
||||
|
||||
uiFieldHandle->setValueFromUiEditor(m_commandData->m_newUiValue);
|
||||
|
||||
{
|
||||
QXmlStreamWriter xmlStream(&m_commandData->m_redoFieldValueSerialized);
|
||||
|
@ -36,6 +36,7 @@ set( PROJECT_FILES
|
||||
cafPdmPtrField.inl
|
||||
cafPdmReferenceHelper.cpp
|
||||
cafPdmReferenceHelper.h
|
||||
cafPdmUiFieldHandleInterface.h
|
||||
cafPdmValueField.h
|
||||
|
||||
cafNotificationCenter.cpp
|
||||
|
@ -38,10 +38,13 @@
|
||||
#endif
|
||||
|
||||
#include "cafPdmValueField.h"
|
||||
|
||||
#include "cafInternalPdmValueFieldSpecializations.h"
|
||||
#include "cafPdmUiFieldHandleInterface.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include <vector>
|
||||
#include <QVariant>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
@ -74,6 +77,7 @@ public:
|
||||
|
||||
DataType value() const { return m_fieldValue; }
|
||||
void setValue(const DataType& fieldValue) { assert(isInitializedByInitFieldMacro()); m_fieldValue = fieldValue; }
|
||||
void setValueWithFieldChanged(const DataType& fieldValue);
|
||||
|
||||
// Implementation of PdmValueField interface
|
||||
|
||||
@ -106,4 +110,30 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename DataType >
|
||||
void caf::PdmDataValueField<DataType>::setValueWithFieldChanged(const DataType& fieldValue)
|
||||
{
|
||||
assert(isInitializedByInitFieldMacro());
|
||||
|
||||
PdmUiFieldHandleInterface* uiFieldHandleInterface = capability<PdmUiFieldHandleInterface>();
|
||||
if (uiFieldHandleInterface)
|
||||
{
|
||||
QVariant oldValue = uiFieldHandleInterface->toUiBasedQVariant();
|
||||
|
||||
m_fieldValue = fieldValue;
|
||||
|
||||
QVariant newUiBasedQVariant = uiFieldHandleInterface->toUiBasedQVariant();
|
||||
|
||||
uiFieldHandleInterface->notifyFieldChanged(oldValue, newUiBasedQVariant);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fieldValue = fieldValue;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace caf
|
||||
|
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class PdmUiFieldHandleInterface
|
||||
{
|
||||
public:
|
||||
PdmUiFieldHandleInterface() {}
|
||||
virtual ~PdmUiFieldHandleInterface() {}
|
||||
|
||||
virtual QVariant toUiBasedQVariant() const { return QVariant(); }
|
||||
virtual void notifyFieldChanged(const QVariant& oldUiBasedQVariant, const QVariant& newUiBasedQVariant) { };
|
||||
};
|
||||
|
||||
} // End of namespace caf
|
@ -16,7 +16,7 @@ public:
|
||||
// Gui generalized interface
|
||||
public:
|
||||
virtual QVariant uiValue() const;
|
||||
virtual void setValueFromUi(const QVariant& uiValue);
|
||||
virtual void setValueFromUiEditor(const QVariant& uiValue);
|
||||
virtual QList<PdmOptionItemInfo> valueOptions(bool* useOptionsOnly);
|
||||
|
||||
virtual QVariant toUiBasedQVariant() const;
|
||||
@ -43,7 +43,7 @@ public:
|
||||
// Gui generalized interface
|
||||
public:
|
||||
virtual QVariant uiValue() const { return QVariant();}
|
||||
virtual void setValueFromUi(const QVariant& uiValue) { }
|
||||
virtual void setValueFromUiEditor(const QVariant& uiValue) { }
|
||||
virtual QList<PdmOptionItemInfo> valueOptions(bool* useOptionsOnly) { return QList<PdmOptionItemInfo>(); }
|
||||
|
||||
virtual QVariant toUiBasedQVariant() const { return QVariant(); }
|
||||
@ -62,7 +62,7 @@ public:
|
||||
// Gui generalized interface
|
||||
public:
|
||||
virtual QVariant uiValue() const { return QVariant(); }
|
||||
virtual void setValueFromUi(const QVariant& uiValue) { }
|
||||
virtual void setValueFromUiEditor(const QVariant& uiValue) { }
|
||||
virtual QList<PdmOptionItemInfo> valueOptions(bool* useOptionsOnly) { return QList<PdmOptionItemInfo>(); }
|
||||
|
||||
virtual QVariant toUiBasedQVariant() const { return QVariant(); }
|
||||
|
@ -16,7 +16,7 @@ namespace caf
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
template<typename FieldType >
|
||||
void caf::PdmFieldUiCap<FieldType>::setValueFromUi(const QVariant& uiValue)
|
||||
void caf::PdmFieldUiCap<FieldType>::setValueFromUiEditor(const QVariant& uiValue)
|
||||
{
|
||||
QVariant oldUiBasedQVariant = toUiBasedQVariant();
|
||||
|
||||
|
@ -89,7 +89,7 @@ void PdmUiCommandSystemProxy::setUiValueToField(PdmUiFieldHandle* uiFieldHandle,
|
||||
}
|
||||
else
|
||||
{
|
||||
uiFieldHandle->setValueFromUi(newUiValue);
|
||||
uiFieldHandle->setValueFromUiEditor(newUiValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,9 +93,7 @@ void PdmUiFieldEditorHandle::createWidgets(QWidget * parent)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Well this is food for thought. How do we spawn commands, without making us
|
||||
/// dependent on the command system. It should be optional to use, and not depending on the command "library"
|
||||
/// JJS
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiFieldEditorHandle::setValueToField(const QVariant& newUiValue)
|
||||
{
|
||||
|
@ -2,13 +2,14 @@
|
||||
|
||||
#include "cafPdmUiItem.h"
|
||||
#include "cafPdmFieldCapability.h"
|
||||
#include "cafPdmUiFieldHandleInterface.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
class PdmFieldHandle;
|
||||
|
||||
class PdmUiFieldHandle : public PdmUiItem, public PdmFieldCapability
|
||||
class PdmUiFieldHandle : public PdmUiItem, public PdmFieldCapability, public PdmUiFieldHandleInterface
|
||||
{
|
||||
public:
|
||||
PdmUiFieldHandle(PdmFieldHandle* owner, bool giveOwnership);
|
||||
@ -20,15 +21,19 @@ public:
|
||||
// The QVariant encapsulates the real value, or an index into the valueOptions
|
||||
|
||||
virtual QVariant uiValue() const { return QVariant(); }
|
||||
virtual void setValueFromUi(const QVariant& uiValue) { }
|
||||
virtual QList<PdmOptionItemInfo>
|
||||
valueOptions(bool* useOptionsOnly) { return QList<PdmOptionItemInfo>(); }
|
||||
|
||||
virtual QVariant toUiBasedQVariant() const { return QVariant(); }
|
||||
void notifyFieldChanged(const QVariant& oldUiBasedQVariant, const QVariant& newUiBasedQVariant);
|
||||
virtual void notifyFieldChanged(const QVariant& oldUiBasedQVariant, const QVariant& newUiBasedQVariant);
|
||||
|
||||
bool isAutoAddingOptionFromValue() const { return m_isAutoAddingOptionFromValue; }
|
||||
void setAutoAddingOptionFromValue(bool isAddingValue) { m_isAutoAddingOptionFromValue = isAddingValue;}
|
||||
|
||||
private:
|
||||
friend class PdmUiCommandSystemProxy;
|
||||
friend class CmdFieldChangeExec;
|
||||
virtual void setValueFromUiEditor(const QVariant& uiValue) { }
|
||||
|
||||
private:
|
||||
PdmFieldHandle* m_owner;
|
||||
bool m_isAutoAddingOptionFromValue;
|
||||
|
Loading…
Reference in New Issue
Block a user