mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3836 Annotations. Polyline edit fixes. Default pos
This commit is contained in:
parent
17e12a92a0
commit
65390ac6e9
@ -62,7 +62,7 @@ RicPolylineTarget3dEditor::~RicPolylineTarget3dEditor()
|
||||
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>(this->pdmObject());
|
||||
if (oldTarget)
|
||||
{
|
||||
oldTarget->m_targetPoint.uiCapability()->removeFieldEditor(this);
|
||||
oldTarget->targetPointUiCapability()->removeFieldEditor(this);
|
||||
}
|
||||
|
||||
delete m_manipulator;
|
||||
@ -85,7 +85,7 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi(const QString& uiConfigName
|
||||
RimUserDefinedPolylinesAnnotation* polylineDef;
|
||||
target->firstAncestorOrThisOfTypeAsserted(polylineDef);
|
||||
|
||||
target->m_targetPoint.uiCapability()->addFieldEditor(this);
|
||||
target->targetPointUiCapability()->addFieldEditor(this);
|
||||
|
||||
if (m_manipulator.isNull())
|
||||
{
|
||||
@ -131,7 +131,7 @@ void RicPolylineTarget3dEditor::cleanupBeforeSettingPdmObject()
|
||||
RimPolylineTarget* oldTarget = dynamic_cast<RimPolylineTarget*>(this->pdmObject());
|
||||
if (oldTarget)
|
||||
{
|
||||
oldTarget->m_targetPoint.uiCapability()->removeFieldEditor(this);
|
||||
oldTarget->targetPointUiCapability()->removeFieldEditor(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ void RicPolylineTarget3dEditor::slotUpdated(const cvf::Vec3d& origin, const cvf:
|
||||
QVariant originVariant = caf::PdmValueFieldSpecialization < cvf::Vec3d >::convert(domainOrigin);
|
||||
|
||||
target->enableFullUpdate(false);
|
||||
caf::PdmUiCommandSystemProxy::instance()->setUiValueToField(target->m_targetPoint.uiCapability(), originVariant);
|
||||
caf::PdmUiCommandSystemProxy::instance()->setUiValueToField(target->targetPointUiCapability(), originVariant);
|
||||
target->enableFullUpdate(true);
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,18 @@
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewPolylineTargetFeature, "RicNewPolylineTargetFeature");
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimUserDefinedPolylinesAnnotation.h"
|
||||
#include "RimPolylineTarget.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include <QAction>
|
||||
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -71,7 +78,10 @@ void RicNewPolylineTargetFeature::onActionTriggered(bool isChecked)
|
||||
if (!afterBeforePair.first && afterBeforePair.second)
|
||||
{
|
||||
newPos = afterBeforePair.second->targetPointXYZ();
|
||||
newPos.z() = -newPos.z();
|
||||
|
||||
// Small displacement to separate the targets
|
||||
newPos.x() -= 50;
|
||||
newPos.y() -= 50;
|
||||
}
|
||||
else if (afterBeforePair.first && afterBeforePair.second)
|
||||
{
|
||||
@ -114,7 +124,18 @@ void RicNewPolylineTargetFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
if ( targetCount == 0 )
|
||||
{
|
||||
polylineDef->appendTarget();
|
||||
auto defaultPos = cvf::Vec3d::ZERO;
|
||||
|
||||
// Set decent position
|
||||
std::vector<RimGridView*> gridViews;
|
||||
RiaApplication::instance()->project()->allVisibleGridViews(gridViews);
|
||||
if (!gridViews.empty())
|
||||
{
|
||||
auto minPos = gridViews.front()->ownerCase()->allCellsBoundingBox().min();
|
||||
defaultPos = minPos;
|
||||
}
|
||||
|
||||
polylineDef->appendTarget(defaultPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -15,8 +15,7 @@ RimPolylineTarget::RimPolylineTarget()
|
||||
{
|
||||
|
||||
CAF_PDM_InitField(&m_isEnabled, "IsEnabled", true, "", "", "", "");
|
||||
//m_targetType.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&m_targetPoint, "TargetPoint", "Point", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_targetPointXyd, "TargetPointXyd", "Point", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -40,17 +39,15 @@ bool RimPolylineTarget::isEnabled() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolylineTarget::setAsPointTargetXYD(const cvf::Vec3d& point)
|
||||
{
|
||||
m_targetPoint = point;
|
||||
m_targetPointXyd = point;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolylineTarget::setAsPointXYZAndTangentTarget(const cvf::Vec3d& point,
|
||||
double azimuth,
|
||||
double inclination)
|
||||
void RimPolylineTarget::setAsPointXYZ(const cvf::Vec3d& point)
|
||||
{
|
||||
m_targetPoint = cvf::Vec3d(point.x(), point.y(), -point.z());
|
||||
m_targetPointXyd = cvf::Vec3d(point.x(), point.y(), -point.z());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -58,11 +55,19 @@ void RimPolylineTarget::setAsPointXYZAndTangentTarget(const cvf::Vec3d& point,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RimPolylineTarget::targetPointXYZ() const
|
||||
{
|
||||
cvf::Vec3d xyzPoint(m_targetPoint());
|
||||
cvf::Vec3d xyzPoint(m_targetPointXyd());
|
||||
xyzPoint.z() = -xyzPoint.z();
|
||||
return xyzPoint;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmUiFieldHandle* RimPolylineTarget::targetPointUiCapability()
|
||||
{
|
||||
return m_targetPointXyd.uiCapability();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -95,5 +100,5 @@ void RimPolylineTarget::fieldChangedByUi(const caf::PdmFieldHandle* changedField
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolylineTarget::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
m_targetPoint.uiCapability()->setUiReadOnly(m_isEnabled());
|
||||
m_targetPointXyd.uiCapability()->setUiReadOnly(m_isEnabled());
|
||||
}
|
||||
|
@ -36,9 +36,11 @@ public:
|
||||
bool isEnabled() const;
|
||||
|
||||
void setAsPointTargetXYD(const cvf::Vec3d& point);
|
||||
void setAsPointXYZAndTangentTarget(const cvf::Vec3d& point, double azimuth, double inclination);
|
||||
void setAsPointXYZ(const cvf::Vec3d& point);
|
||||
|
||||
cvf::Vec3d targetPointXYZ() const;
|
||||
caf::PdmUiFieldHandle* targetPointUiCapability();
|
||||
void enableFullUpdate(bool enable);
|
||||
|
||||
private:
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||
@ -46,11 +48,9 @@ private:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
private:
|
||||
friend class RicPolylineTarget3dEditor;
|
||||
void enableFullUpdate(bool enable);
|
||||
bool m_isFullUpdateEnabled;
|
||||
caf::PdmField<bool> m_isEnabled;
|
||||
caf::PdmField<cvf::Vec3d> m_targetPoint;
|
||||
caf::PdmField<cvf::Vec3d> m_targetPointXyd;
|
||||
|
||||
};
|
||||
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
#include "RiuViewerCommands.h"
|
||||
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
@ -58,7 +60,7 @@ CAF_PDM_SOURCE_INIT(RimUserDefinedPolylinesAnnotation, "UserDefinedPolylinesAnno
|
||||
RimUserDefinedPolylinesAnnotation::RimUserDefinedPolylinesAnnotation()
|
||||
: m_pickTargetsEventHandler(new RicPolylineTargetsPickEventHandler(this))
|
||||
{
|
||||
CAF_PDM_InitObject("PolyLines Annotation", ":/WellCollection.png", "", "");
|
||||
CAF_PDM_InitObject("PolyLines Annotation", ":/PolylinesFromFile16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_enablePicking, "EnablePicking", false, "", "", "", "");
|
||||
caf::PdmUiPushButtonEditor::configureEditorForField(&m_enablePicking);
|
||||
@ -119,24 +121,25 @@ bool RimUserDefinedPolylinesAnnotation::isEmpty()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUserDefinedPolylinesAnnotation::appendTarget()
|
||||
void RimUserDefinedPolylinesAnnotation::appendTarget(const cvf::Vec3d& defaultPos)
|
||||
{
|
||||
RimPolylineTarget* wellPathTarget = nullptr;
|
||||
RimPolylineTarget* target = nullptr;
|
||||
|
||||
auto targets = m_targets.childObjects();
|
||||
if (targets.empty())
|
||||
{
|
||||
wellPathTarget = new RimPolylineTarget();
|
||||
target = new RimPolylineTarget();
|
||||
target->setAsPointXYZ(defaultPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
wellPathTarget = dynamic_cast<RimPolylineTarget*>(
|
||||
target = dynamic_cast<RimPolylineTarget*>(
|
||||
targets.back()->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
}
|
||||
|
||||
if (wellPathTarget)
|
||||
if (target)
|
||||
{
|
||||
m_targets.push_back(wellPathTarget);
|
||||
m_targets.push_back(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
std::vector<RimPolylineTarget*> activeTargets() const;
|
||||
virtual bool isEmpty() override;
|
||||
|
||||
void appendTarget();
|
||||
void appendTarget(const cvf::Vec3d& defaultPos = cvf::Vec3d::ZERO);
|
||||
void insertTarget(const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert);
|
||||
void deleteTarget(RimPolylineTarget* targetTodelete);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user