Bug fixes and enhancements for dimensions.

1) Make them easier to select.
2) Mirror text when flipping to other side of board.
3) Flip around a more "known" point (the text position isn't really
here nor there).

Fixes https://gitlab.com/kicad/code/kicad/issues/6219
This commit is contained in:
Jeff Young 2020-11-03 22:45:26 +00:00
parent 5507575d64
commit 5ede4061e3
4 changed files with 30 additions and 20 deletions

View File

@ -65,18 +65,6 @@ void DIMENSION::SetParent( EDA_ITEM* aParent )
}
void DIMENSION::SetPosition( const wxPoint& aPos )
{
m_text.SetTextPos( aPos );
}
wxPoint DIMENSION::GetPosition() const
{
return m_text.GetTextPos();
}
void DIMENSION::updateText()
{
wxString text = m_overrideTextEnabled ? m_valueString : GetValueText();
@ -271,7 +259,6 @@ void DIMENSION::Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight )
wxPoint newPos = m_text.GetTextPos();
#define INVERT( pos ) ( ( pos ) = axis - ( ( pos ) - axis ) )
if( aMirrorLeftRight )
INVERT( newPos.x );
else
@ -293,6 +280,8 @@ void DIMENSION::Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight )
INVERT( m_end.y );
}
m_text.SetMirrored( !m_text.IsMirrored() );
Update();
}

View File

@ -129,9 +129,8 @@ public:
virtual const wxPoint& GetEnd() const { return m_end; }
virtual void SetEnd( const wxPoint& aPoint );
// These deal with the text position
wxPoint GetPosition() const override;
void SetPosition( const wxPoint& aPos ) override;
wxPoint GetPosition() const override { return m_start; }
void SetPosition( const wxPoint& aPos ) override { m_start = aPos; }
bool GetOverrideTextEnabled() const { return m_overrideTextEnabled; }
void SetOverrideTextEnabled( bool aOverride ) { m_overrideTextEnabled = aOverride; }

View File

@ -30,13 +30,13 @@
#include <class_pad.h>
#include <class_track.h>
#include <class_marker_pcb.h>
#include <class_dimension.h>
#include <class_zone.h>
#include <pcb_shape.h>
#include <class_pcb_group.h>
#include <macros.h>
#include <math/util.h> // for KiROUND
/* This module contains out of line member functions for classes given in
* collectors.h. Those classes augment the functionality of class PCB_EDIT_FRAME.
*/
@ -196,6 +196,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
MARKER_PCB* marker = nullptr;
ZONE_CONTAINER* zone = nullptr;
PCB_SHAPE* shape = nullptr;
DIMENSION* dimension = nullptr;
#if 0 // debugging
static int breakhere = 0;
@ -324,6 +325,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
case PCB_DIM_CENTER_T:
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T:
dimension = static_cast<DIMENSION*>( item );
break;
case PCB_TARGET_T:
@ -493,7 +495,17 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
{
if( shape->HitTest( m_refPos, accuracy ) )
{
Append( item );
Append( shape );
goto exit;
}
}
else if( dimension )
{
// Dimensions feels particularly hard to select, probably due to their
// noisy shape making it feel like they should have a larger bounary.
if( dimension->HitTest( m_refPos, KiROUND( accuracy * 1.5 ) ) )
{
Append( dimension );
goto exit;
}
}
@ -557,7 +569,17 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
{
if( shape->HitTest( m_refPos, accuracy ) )
{
Append( item );
Append( shape );
goto exit;
}
}
else if( dimension )
{
// Dimensions feels particularly hard to select, probably due to their
// noisy shape making it feel like they should have a larger bounary.
if( dimension->HitTest( m_refPos, KiROUND( accuracy * 1.5 ) ) )
{
Append( dimension );
goto exit;
}
}

View File

@ -1162,7 +1162,7 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
// of the bounding box center) to avoid moving the item anchor
if( selection.GetSize() == 1 )
{
if( selection.HasReferencePoint() )
if( m_dragging && selection.HasReferencePoint() )
modPoint = selection.GetReferencePoint();
else
modPoint = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) )->GetPosition();