This commit is contained in:
Jeff Young 2022-02-27 11:54:03 +00:00
parent 8de4f762e1
commit d299ddbc7e
4 changed files with 72 additions and 63 deletions

View File

@ -115,6 +115,15 @@ wxString MessageTextFromValue( EDA_UNITS aUnits, long long int aValue, bool aAdd
} }
wxString MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel )
{
if( aAddUnitLabel )
return wxString::Format( wxT( "%.1f°" ), aValue.AsDegrees() );
else
return wxString::Format( wxT( "%.1f" ), aValue.AsDegrees() );
}
// A lower-precision (for readability) version of StringFromValue() // A lower-precision (for readability) version of StringFromValue()
wxString MessageTextFromValue( EDA_UNITS aUnits, double aValue, bool aAddUnitLabel, wxString MessageTextFromValue( EDA_UNITS aUnits, double aValue, bool aAddUnitLabel,
EDA_DATA_TYPE aType ) EDA_DATA_TYPE aType )

View File

@ -557,7 +557,7 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
case SHAPE_T::ARC: case SHAPE_T::ARC:
aList.emplace_back( shape, _( "Arc" ) ); aList.emplace_back( shape, _( "Arc" ) );
msg.Printf( wxT( "%.1f" ), GetArcAngle().AsDegrees() ); msg = MessageTextFromValue( GetArcAngle() );
aList.emplace_back( _( "Angle" ), msg ); aList.emplace_back( _( "Angle" ), msg );
msg = MessageTextFromValue( units, GetRadius() ); msg = MessageTextFromValue( units, GetRadius() );
@ -596,9 +596,9 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
aList.emplace_back( _( "Length" ), msg ); aList.emplace_back( _( "Length" ), msg );
// angle counter-clockwise from 3'o-clock // angle counter-clockwise from 3'o-clock
const double deg = RAD2DEG( atan2( (double)( GetStart().y - GetEnd().y ), EDA_ANGLE angle( atan2( (double)( GetStart().y - GetEnd().y ),
(double)( GetEnd().x - GetStart().x ) ) ); (double)( GetEnd().x - GetStart().x ) ), RADIANS_T );
aList.emplace_back( _( "Angle" ), wxString::Format( "%.1f", deg ) ); aList.emplace_back( _( "Angle" ), MessageTextFromValue( angle ) );
break; break;
} }

View File

@ -105,6 +105,8 @@ wxString MessageTextFromValue( EDA_UNITS aUnits, int aValue, bool aAddUnitLabel
wxString MessageTextFromValue( EDA_UNITS aUnits, long long int aValue, bool aAddUnitLabel = true, wxString MessageTextFromValue( EDA_UNITS aUnits, long long int aValue, bool aAddUnitLabel = true,
EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE );
wxString MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel = true );
/** /**
* Function StringFromValue * Function StringFromValue
* returns the string from \a aValue according to units (inch, mm ...) for display, * returns the string from \a aValue according to units (inch, mm ...) for display,

View File

@ -334,14 +334,15 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
if( selection.Size() != 1 || selection.Front()->Type() != PCB_ARC_T ) if( selection.Size() != 1 || selection.Front()->Type() != PCB_ARC_T )
return 0; return 0;
PCB_ARC* theArc = static_cast<PCB_ARC*>( selection.Front() ); PCB_ARC* theArc = static_cast<PCB_ARC*>( selection.Front() );
double arcAngleDegrees = std::abs( theArc->GetAngle().AsDegrees() ); EDA_ANGLE maxTangentDeviation( ADVANCED_CFG::GetCfg().m_MaxTangentAngleDeviation, DEGREES_T );
if( arcAngleDegrees + ADVANCED_CFG::GetCfg().m_MaxTangentAngleDeviation >= 180.0 ) if( theArc->GetAngle() + maxTangentDeviation >= ANGLE_180 )
{ {
frame()->ShowInfoBarError( wxString msg = wxString::Format( _( "Unable to resize arc tracks of %s or greater." ),
wxString::Format( _( "Unable to resize arc tracks %.1f degrees or greater." ), MessageTextFromValue( ANGLE_180 - maxTangentDeviation ) );
180.0 - ADVANCED_CFG::GetCfg().m_MaxTangentAngleDeviation ) ); frame()->ShowInfoBarError( msg );
return 0; // don't bother with > 180 degree arcs return 0; // don't bother with > 180 degree arcs
} }
@ -367,55 +368,52 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
KICAD_T track_types[] = { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT }; KICAD_T track_types[] = { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT };
auto getUniqueTrackAtAnchorCollinear = auto getUniqueTrackAtAnchorCollinear =
[&]( const VECTOR2I& aAnchor, const SEG& aCollinearSeg ) -> PCB_TRACK* [&]( const VECTOR2I& aAnchor, const SEG& aCollinearSeg ) -> PCB_TRACK*
{
auto conn = board()->GetConnectivity();
// Allow items at a distance within the width of the arc track
int allowedDeviation = theArc->GetWidth();
std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
for( int i = 0; i < 3; i++ )
{ {
itemsOnAnchor = conn->GetConnectedItemsAtAnchor( theArc, aAnchor, track_types, auto conn = board()->GetConnectivity();
allowedDeviation );
allowedDeviation /= 2;
if( itemsOnAnchor.size() == 1 ) // Allow items at a distance within the width of the arc track
break; int allowedDeviation = theArc->GetWidth();
}
PCB_TRACK* retval = nullptr; std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
if( itemsOnAnchor.size() == 1 && itemsOnAnchor.front()->Type() == PCB_TRACE_T ) for( int i = 0; i < 3; i++ )
{
retval = static_cast<PCB_TRACK*>( itemsOnAnchor.front() );
SEG trackSeg( retval->GetStart(), retval->GetEnd() );
// Allow deviations in colinearity as defined in ADVANCED_CFG
if( trackSeg.Angle( aCollinearSeg )
> EDA_ANGLE( ADVANCED_CFG::GetCfg().m_MaxTangentAngleDeviation, DEGREES_T ) )
{ {
retval = nullptr; itemsOnAnchor = conn->GetConnectedItemsAtAnchor( theArc, aAnchor, track_types,
allowedDeviation );
allowedDeviation /= 2;
if( itemsOnAnchor.size() == 1 )
break;
} }
}
if( !retval ) PCB_TRACK* retval = nullptr;
{
retval = new PCB_TRACK( theArc->GetParent() );
retval->SetStart( aAnchor );
retval->SetEnd( aAnchor );
retval->SetNet( theArc->GetNet() );
retval->SetLayer( theArc->GetLayer() );
retval->SetWidth( theArc->GetWidth() );
retval->SetLocked( theArc->IsLocked() );
retval->SetFlags( IS_NEW );
getView()->Add( retval );
}
return retval; if( itemsOnAnchor.size() == 1 && itemsOnAnchor.front()->Type() == PCB_TRACE_T )
}; {
retval = static_cast<PCB_TRACK*>( itemsOnAnchor.front() );
SEG trackSeg( retval->GetStart(), retval->GetEnd() );
// Allow deviations in colinearity as defined in ADVANCED_CFG
if( trackSeg.Angle( aCollinearSeg ) > maxTangentDeviation )
retval = nullptr;
}
if( !retval )
{
retval = new PCB_TRACK( theArc->GetParent() );
retval->SetStart( aAnchor );
retval->SetEnd( aAnchor );
retval->SetNet( theArc->GetNet() );
retval->SetLayer( theArc->GetLayer() );
retval->SetWidth( theArc->GetWidth() );
retval->SetLocked( theArc->IsLocked() );
retval->SetFlags( IS_NEW );
getView()->Add( retval );
}
return retval;
};
PCB_TRACK* trackOnStart = getUniqueTrackAtAnchorCollinear( theArc->GetStart(), tanStart); PCB_TRACK* trackOnStart = getUniqueTrackAtAnchorCollinear( theArc->GetStart(), tanStart);
PCB_TRACK* trackOnEnd = getUniqueTrackAtAnchorCollinear( theArc->GetEnd(), tanEnd ); PCB_TRACK* trackOnEnd = getUniqueTrackAtAnchorCollinear( theArc->GetEnd(), tanEnd );
@ -441,13 +439,13 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent )
tanIntersect = tanStart.IntersectLines( tanEnd ).get(); tanIntersect = tanStart.IntersectLines( tanEnd ).get();
auto isTrackStartClosestToArcStart = auto isTrackStartClosestToArcStart =
[&]( PCB_TRACK* aTrack ) -> bool [&]( PCB_TRACK* aTrack ) -> bool
{ {
double trackStartToArcStart = GetLineLength( aTrack->GetStart(), theArc->GetStart() ); double trackStartToArcStart = GetLineLength( aTrack->GetStart(), theArc->GetStart() );
double trackEndToArcStart = GetLineLength( aTrack->GetEnd(), theArc->GetStart() ); double trackEndToArcStart = GetLineLength( aTrack->GetEnd(), theArc->GetStart() );
return trackStartToArcStart < trackEndToArcStart; return trackStartToArcStart < trackEndToArcStart;
}; };
bool isStartTrackOnStartPt = isTrackStartClosestToArcStart( trackOnStart ); bool isStartTrackOnStartPt = isTrackStartClosestToArcStart( trackOnStart );
bool isEndTrackOnStartPt = isTrackStartClosestToArcStart( trackOnEnd ); bool isEndTrackOnStartPt = isTrackStartClosestToArcStart( trackOnEnd );
@ -790,12 +788,12 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
} }
} }
bool restore_state = false; bool restore_state = false;
VECTOR2I originalPos; VECTOR2I originalPos;
VECTOR2I totalMovement; VECTOR2I totalMovement;
PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() ); PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() );
TOOL_EVENT* evt = &aEvent; TOOL_EVENT* evt = &aEvent;
VECTOR2I prevPos; VECTOR2I prevPos;
bool lock45 = false; bool lock45 = false;
bool eatFirstMouseUp = true; bool eatFirstMouseUp = true;
@ -1151,7 +1149,7 @@ int EDIT_TOOL::ChangeTrackWidth( const TOOL_EVENT& aEvent )
} }
} }
m_commit->Push( _("Edit track width/via size") ); m_commit->Push( _( "Edit track width/via size" ) );
if( selection.IsHover() ) if( selection.IsHover() )
{ {