Skip to content

Commit

Permalink
Add scaling to polygon in view
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Feb 19, 2024
1 parent 6e33f6e commit b38acd9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "RicPointTangentManipulator.h"

#include "Rim3dView.h"
#include "RimPolylinePickerInterface.h"
#include "RimPolylineTarget.h"

#include "RiuViewer.h"
Expand Down Expand Up @@ -96,8 +97,13 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam

cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();

const double handleScalingFactor = 0.7;
const double handleSize = handleScalingFactor * view->characteristicCellSize();
double scalingFactor = 0.7;
if ( auto pickerInterface = target->firstAncestorOrThisOfType<RimPolylinePickerInterface>() )
{
scalingFactor *= pickerInterface->handleScalingFactor();
}

const double handleSize = scalingFactor * view->characteristicCellSize();

m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() ) );
m_manipulator->setHandleSize( handleSize );
Expand Down
12 changes: 12 additions & 0 deletions ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonInView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ RimPolygonInView::RimPolygonInView()
caf::PdmUiPushButtonEditor::configureEditorForField( &m_enablePicking );
m_enablePicking.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosType::HIDDEN );

CAF_PDM_InitField( &m_handleScalingFactor, "HandleScalingFactor", 1.0, "Handle Scaling Factor" );

CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
m_targets.uiCapability()->setUiTreeChildrenHidden( true );
Expand Down Expand Up @@ -243,6 +245,8 @@ void RimPolygonInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
{
updateNameField();

uiOrdering.add( &m_handleScalingFactor );

if ( m_polygon() ) uiOrdering.add( m_polygon );
uiOrdering.add( &m_enablePicking );
}
Expand Down Expand Up @@ -288,6 +292,14 @@ void RimPolygonInView::defineObjectEditorAttribute( QString uiConfigName, caf::P
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPolygonInView::handleScalingFactor() const
{
return m_handleScalingFactor();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData
void appendPartsToModel( cvf::ModelBasicList* model, const caf::DisplayCoordTransform* scaleTransform, const cvf::BoundingBox& boundingBox );
void enablePicking( bool enable );

// RimPolylinesDataInterface
void insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert ) override;
void deleteTarget( RimPolylineTarget* targetToDelete ) override;
void updateEditorsAndVisualization() override;
void updateVisualization() override;
std::vector<RimPolylineTarget*> activeTargets() const override;
bool pickingEnabled() const override;
caf::PickEventHandler* pickEventHandler() const override;
double handleScalingFactor() const override;

cvf::ref<RigPolyLinesData> polyLinesData() const override;

Expand All @@ -87,6 +87,7 @@ class RimPolygonInView : public RimCheckableNamedObject, public RimPolylinesData
caf::PdmPtrField<RimPolygon*> m_polygon;

caf::PdmField<bool> m_enablePicking;
caf::PdmField<double> m_handleScalingFactor;
caf::PdmChildArrayField<RimPolylineTarget*> m_targets;

cvf::ref<RivPolylinePartMgr> m_polylinePartMgr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@

#include "RimPolylineTarget.h"

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimPolylinePickerInterface::handleScalingFactor() const
{
return 1.0;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class RimPolylinePickerInterface
virtual std::vector<RimPolylineTarget*> activeTargets() const = 0;
virtual bool pickingEnabled() const = 0;
virtual caf::PickEventHandler* pickEventHandler() const = 0;
virtual double handleScalingFactor() const;

std::pair<RimPolylineTarget*, RimPolylineTarget*> findActiveTargetsAroundInsertionPoint( const RimPolylineTarget* targetToInsertBefore );
};

0 comments on commit b38acd9

Please sign in to comment.