mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 14:50:11 +00:00
Position interactive: use the forward vector value
On reflection, the forward vector makes more sense, because the value in the edit box is then the same as the vector the user just drew with the ruler.
This commit is contained in:
parent
87cd0a74f2
commit
11ac6ea976
common/preview_items
include/preview_items
pcbnew/tools
@ -348,20 +348,20 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
||||
drawBacksideTicks( aView, origin, rulerVec, majorTickLen, 2, drawingDropShadows );
|
||||
}
|
||||
|
||||
if( m_showOriginArrowHead )
|
||||
if( m_showEndArrowHead )
|
||||
{
|
||||
const EDA_ANGLE arrowAngle{ 30.0 };
|
||||
VECTOR2D arrowHead = rulerVec;
|
||||
RotatePoint( arrowHead, arrowAngle );
|
||||
arrowHead = arrowHead.Resize( -majorTickLen );
|
||||
arrowHead = arrowHead.Resize( majorTickLen );
|
||||
|
||||
gal->DrawLine( origin, origin - arrowHead );
|
||||
gal->DrawLine( end, end - arrowHead );
|
||||
|
||||
arrowHead = rulerVec;
|
||||
RotatePoint( arrowHead, -arrowAngle );
|
||||
arrowHead = arrowHead.Resize( -majorTickLen );
|
||||
arrowHead = arrowHead.Resize( majorTickLen );
|
||||
|
||||
gal->DrawLine( origin, origin - arrowHead );
|
||||
gal->DrawLine( end, end - arrowHead );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
|
||||
void SetShowTicks( bool aShow ) { m_showTicks = aShow; }
|
||||
|
||||
void SetShowOriginArrowHead( bool aShow ) { m_showOriginArrowHead = aShow; }
|
||||
void SetShowEndArrowHead( bool aShow ) { m_showEndArrowHead = aShow; }
|
||||
|
||||
/**
|
||||
* Get the strings for the dimensions of the ruler
|
||||
@ -103,7 +103,7 @@ private:
|
||||
bool m_flipY;
|
||||
std::optional<COLOR4D> m_color;
|
||||
bool m_showTicks = true;
|
||||
bool m_showOriginArrowHead = false;
|
||||
bool m_showEndArrowHead = false;
|
||||
};
|
||||
|
||||
} // PREVIEW
|
||||
|
@ -170,7 +170,7 @@ int POSITION_RELATIVE_TOOL::PositionRelativeInteractively( const TOOL_EVENT& aEv
|
||||
// Some colour to make it obviously not just a ruler
|
||||
ruler.SetColor( view.GetPainter()->GetSettings()->GetLayerColor( LAYER_ANCHOR ) );
|
||||
ruler.SetShowTicks( false );
|
||||
ruler.SetShowOriginArrowHead( true );
|
||||
ruler.SetShowEndArrowHead( true );
|
||||
|
||||
view.Add( &ruler );
|
||||
view.SetVisible( &ruler, false );
|
||||
@ -292,18 +292,17 @@ int POSITION_RELATIVE_TOOL::PositionRelativeInteractively( const TOOL_EVENT& aEv
|
||||
// second click or mouse up after drag ends
|
||||
else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
|
||||
{
|
||||
// The reverse vector, as (I think) it's clearer if the arrow points to
|
||||
// the thing that's going to move, and it's more natural to start drawing
|
||||
// at the item you just selected (which is the one that will move)
|
||||
const VECTOR2I origVector = twoPtMgr.GetOrigin() - twoPtMgr.GetEnd();
|
||||
// This is the forward vector from the ruler item
|
||||
const VECTOR2I origVector = twoPtMgr.GetEnd() - twoPtMgr.GetOrigin();
|
||||
VECTOR2I offsetVector = origVector;
|
||||
// Start with the value of that vector in the dialog (will match the rule HUD)
|
||||
DIALOG_SET_OFFSET dlg( *frame(), offsetVector, false );
|
||||
|
||||
int ret = dlg.ShowModal();
|
||||
|
||||
if( ret == wxID_OK )
|
||||
{
|
||||
const VECTOR2I move = offsetVector - origVector;
|
||||
const VECTOR2I move = origVector - offsetVector;
|
||||
|
||||
applyVector( move );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user