modify behavior of position relative tool
CHANGED: The reset buttons now set the X or Y offset to the current offset from the reference position. Selecting individual pads as the reference item is now also possible.
This commit is contained in:
parent
842d680b5e
commit
a8dea9274f
|
@ -156,12 +156,16 @@ void DIALOG_POSITION_RELATIVE::updateDialogControls( bool aPolar )
|
||||||
m_xOffset.SetLabel( _( "Distance:" ) ); // Polar radius
|
m_xOffset.SetLabel( _( "Distance:" ) ); // Polar radius
|
||||||
m_yOffset.SetLabel( _( "Angle:" ) ); // Polar theta or angle
|
m_yOffset.SetLabel( _( "Angle:" ) ); // Polar theta or angle
|
||||||
m_yOffset.SetUnits( EDA_UNITS::DEGREES );
|
m_yOffset.SetUnits( EDA_UNITS::DEGREES );
|
||||||
|
m_clearX->SetToolTip( _( "Reset to the current distance from the reference position." ) );
|
||||||
|
m_clearY->SetToolTip( _( "Reset to the current angle from the reference position." ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_xOffset.SetLabel( _( "Offset X:" ) );
|
m_xOffset.SetLabel( _( "Offset X:" ) );
|
||||||
m_yOffset.SetLabel( _( "Offset Y:" ) );
|
m_yOffset.SetLabel( _( "Offset Y:" ) );
|
||||||
m_yOffset.SetUnits( GetUserUnits() );
|
m_yOffset.SetUnits( GetUserUnits() );
|
||||||
|
m_clearX->SetToolTip( _( "Reset to the current X offset from the reference position." ) );
|
||||||
|
m_clearY->SetToolTip( _( "Reset to the current Y offset from the reference position." ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,14 +173,43 @@ void DIALOG_POSITION_RELATIVE::updateDialogControls( bool aPolar )
|
||||||
void DIALOG_POSITION_RELATIVE::OnClear( wxCommandEvent& event )
|
void DIALOG_POSITION_RELATIVE::OnClear( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxObject* obj = event.GetEventObject();
|
wxObject* obj = event.GetEventObject();
|
||||||
|
POSITION_RELATIVE_TOOL* posrelTool = m_toolMgr->GetTool<POSITION_RELATIVE_TOOL>();
|
||||||
|
wxASSERT( posrelTool );
|
||||||
|
|
||||||
|
wxPoint offset = posrelTool->GetSelectionAnchorPosition() - m_anchor_position;
|
||||||
|
double r, q;
|
||||||
|
ToPolarDeg( offset.x, offset.y, r, q );
|
||||||
|
|
||||||
|
|
||||||
if( obj == m_clearX )
|
if( obj == m_clearX )
|
||||||
{
|
{
|
||||||
m_xOffset.SetValue( 0 );
|
m_stateX = offset.x;
|
||||||
|
m_xOffset.SetDoubleValue( r );
|
||||||
|
m_stateRadius = m_xOffset.GetDoubleValue();
|
||||||
|
|
||||||
|
if( m_polarCoords->IsChecked() )
|
||||||
|
{
|
||||||
|
m_xOffset.SetDoubleValue( m_stateRadius );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_xOffset.SetValue( m_stateX );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( obj == m_clearY )
|
else if( obj == m_clearY )
|
||||||
{
|
{
|
||||||
m_yOffset.SetValue( 0 );
|
m_stateY = offset.y;
|
||||||
|
m_yOffset.SetDoubleValue( q * 10 );
|
||||||
|
m_stateTheta = m_yOffset.GetDoubleValue();
|
||||||
|
|
||||||
|
if( m_polarCoords->IsChecked() )
|
||||||
|
{
|
||||||
|
m_yOffset.SetDoubleValue( m_stateTheta );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_yOffset.SetValue( m_stateY );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags )
|
||||||
}
|
}
|
||||||
|
|
||||||
// case 2: selection contains both the module and its pads - remove the pads
|
// case 2: selection contains both the module and its pads - remove the pads
|
||||||
if( mod && aCollector.HasItem( mod ) )
|
if( !( aFlags & INCLUDE_PADS_AND_MODULES ) && mod && aCollector.HasItem( mod ) )
|
||||||
aCollector.Remove( item );
|
aCollector.Remove( item );
|
||||||
}
|
}
|
||||||
else if( ( aFlags & EXCLUDE_TRANSIENTS ) && item->Type() == PCB_MARKER_T )
|
else if( ( aFlags & EXCLUDE_TRANSIENTS ) && item->Type() == PCB_MARKER_T )
|
||||||
|
|
|
@ -50,9 +50,10 @@ namespace KIGFX {
|
||||||
* optionally excludes locked items and/or transient items (such as markers).
|
* optionally excludes locked items and/or transient items (such as markers).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define EXCLUDE_LOCKED 0x0001
|
#define EXCLUDE_LOCKED 0x0001
|
||||||
#define EXCLUDE_LOCKED_PADS 0x0002
|
#define EXCLUDE_LOCKED_PADS 0x0002
|
||||||
#define EXCLUDE_TRANSIENTS 0x0004
|
#define EXCLUDE_TRANSIENTS 0x0004
|
||||||
|
#define INCLUDE_PADS_AND_MODULES 0x0008
|
||||||
|
|
||||||
void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags );
|
void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags );
|
||||||
|
|
||||||
|
|
|
@ -92,21 +92,15 @@ int POSITION_RELATIVE_TOOL::PositionRelative( const TOOL_EVENT& aEvent )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPoint POSITION_RELATIVE_TOOL::GetSelectionAnchorPosition() const
|
||||||
|
{
|
||||||
|
return static_cast<BOARD_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int POSITION_RELATIVE_TOOL::RelativeItemSelectionMove( wxPoint aPosAnchor, wxPoint aTranslation )
|
int POSITION_RELATIVE_TOOL::RelativeItemSelectionMove( wxPoint aPosAnchor, wxPoint aTranslation )
|
||||||
{
|
{
|
||||||
wxPoint aSelAnchor( INT_MAX, INT_MAX );
|
wxPoint aggregateTranslation = aPosAnchor + aTranslation - GetSelectionAnchorPosition();
|
||||||
|
|
||||||
// Find top-left item anchor in selection
|
|
||||||
for( auto item : m_selection )
|
|
||||||
{
|
|
||||||
wxPoint itemAnchor = static_cast<BOARD_ITEM*>( item )->GetPosition();
|
|
||||||
|
|
||||||
if( EuclideanNorm( itemAnchor ) < EuclideanNorm( aSelAnchor ) )
|
|
||||||
aSelAnchor = itemAnchor;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPoint aggregateTranslation = aPosAnchor + aTranslation - aSelAnchor;
|
|
||||||
|
|
||||||
for( auto item : m_selection )
|
for( auto item : m_selection )
|
||||||
{
|
{
|
||||||
|
@ -146,10 +140,10 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
|
||||||
{
|
{
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
const PCBNEW_SELECTION& sel = m_selectionTool->RequestSelection(
|
const PCBNEW_SELECTION& sel = m_selectionTool->RequestSelection(
|
||||||
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) {
|
||||||
{
|
EditToolSelectionFilter(
|
||||||
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS );
|
aCollector, EXCLUDE_TRANSIENTS | INCLUDE_PADS_AND_MODULES );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if( sel.Empty() )
|
if( sel.Empty() )
|
||||||
return true; // still looking for an item
|
return true; // still looking for an item
|
||||||
|
|
|
@ -67,6 +67,14 @@ public:
|
||||||
*/
|
*/
|
||||||
int SelectPositionRelativeItem( const TOOL_EVENT& aEvent );
|
int SelectPositionRelativeItem( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetSelectionAnchorPosition()
|
||||||
|
*
|
||||||
|
* Returns the postion of the selected item(s)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
wxPoint GetSelectionAnchorPosition() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function RelativeItemSelectionMove()
|
* Function RelativeItemSelectionMove()
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue