Don't offer point-based pad editing in PCBNew.

This commit is contained in:
Jeff Young 2020-12-19 15:16:14 +00:00
parent e840e9d997
commit d9bbdffd99
3 changed files with 262 additions and 270 deletions

View File

@ -607,11 +607,8 @@ bool PCB_SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag,
guide.SetIgnoreZoneFills( displayOpts.m_ZoneDisplayMode != ZONE_DISPLAY_MODE::SHOW_FILLED );
if( m_enteredGroup &&
!m_enteredGroup->GetBoundingBox().Contains( wxPoint( aWhere.x, aWhere.y ) ) )
{
if( m_enteredGroup && !m_enteredGroup->GetBoundingBox().Contains( (wxPoint) aWhere ) )
ExitGroup();
}
collector.Collect( board(), m_isFootprintEditor ? GENERAL_COLLECTOR::FootprintItems
: GENERAL_COLLECTOR::AllBoardItems,

View File

@ -83,14 +83,51 @@ enum DIMENSION_POINTS
DIM_CROSSBAREND,
};
class EDIT_POINTS_FACTORY
POINT_EDITOR::POINT_EDITOR() :
PCB_TOOL_BASE( "pcbnew.PointEditor" ),
m_selectionTool( nullptr ),
m_editedPoint( nullptr ),
m_hoveredPoint( nullptr ),
m_original( VECTOR2I( 0, 0 ) ),
m_refill( false ),
m_altEditMethod( false ),
m_altConstrainer( VECTOR2I( 0, 0 ) )
{
private:
}
static void buildForPolyOutline( std::shared_ptr<EDIT_POINTS> points,
const SHAPE_POLY_SET* aOutline, KIGFX::GAL* aGal )
{
void POINT_EDITOR::Reset( RESET_REASON aReason )
{
m_refill = false;
m_editPoints.reset();
m_altConstraint.reset();
getViewControls()->SetAutoPan( false );
m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
m_statusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
m_statusPopup->SetText( _( "Self-intersecting polygons are not allowed." ) );
}
bool POINT_EDITOR::Init()
{
// Find the selection tool, so they can cooperate
m_selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
auto& menu = m_selectionTool->GetToolMenu().GetMenu();
menu.AddItem( PCB_ACTIONS::pointEditorAddCorner, POINT_EDITOR::addCornerCondition );
menu.AddItem( PCB_ACTIONS::pointEditorRemoveCorner,
std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
return true;
}
void POINT_EDITOR::buildForPolyOutline( std::shared_ptr<EDIT_POINTS> points,
const SHAPE_POLY_SET* aOutline )
{
int cornersCount = aOutline->TotalVertices();
for( auto iterator = aOutline->CIterateWithHoles(); iterator; iterator++ )
@ -106,14 +143,9 @@ private:
for( int i = 0; i < cornersCount - 1; ++i )
{
if( points->IsContourEnd( i ) )
{
points->AddLine( points->Point( i ),
points->Point( points->GetContourStartIdx( i ) ) );
}
points->AddLine( points->Point( i ), points->Point( points->GetContourStartIdx( i ) ) );
else
{
points->AddLine( points->Point( i ), points->Point( i + 1 ) );
}
points->Line( i ).SetConstraint( new EC_PERPLINE( points->Line( i ) ) );
}
@ -122,13 +154,13 @@ private:
points->AddLine( points->Point( cornersCount - 1 ),
points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
points->Line( points->LinesSize() - 1 ).SetConstraint(
new EC_PERPLINE( points->Line( points->LinesSize() - 1 ) ) );
}
points->Line( points->LinesSize() - 1 )
.SetConstraint( new EC_PERPLINE( points->Line( points->LinesSize() - 1 ) ) );
}
public:
static std::shared_ptr<EDIT_POINTS> Make( EDA_ITEM* aItem, KIGFX::GAL* aGal )
{
std::shared_ptr<EDIT_POINTS> POINT_EDITOR::makePoints( EDA_ITEM* aItem )
{
std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
if( !aItem )
@ -180,7 +212,7 @@ public:
break;
case S_POLYGON:
buildForPolyOutline( points, &shape->GetPolyShape(), aGal );
buildForPolyOutline( points, &shape->GetPolyShape() );
break;
case S_CURVE:
@ -200,11 +232,14 @@ public:
case PCB_PAD_T:
{
const PAD* pad = static_cast<const PAD*>( aItem );
FOOTPRINT* parent = pad->GetParent();
wxPoint shapePos = pad->ShapePos();
wxPoint halfSize( pad->GetSize().x / 2, pad->GetSize().y / 2 );
if( pad->GetParent() &&
( pad->GetParent()->IsLocked() || pad->GetParent()->PadsLocked() ) )
if( !m_isFootprintEditor )
break;
if( parent && ( parent->IsLocked() || parent->PadsLocked() ) )
break;
switch( pad->GetShape() )
@ -243,7 +278,7 @@ public:
case PCB_ZONE_T:
{
const ZONE* zone = static_cast<const ZONE*>( aItem );
buildForPolyOutline( points, zone->Outline(), aGal );
buildForPolyOutline( points, zone->Outline() );
}
break;
@ -302,52 +337,6 @@ public:
}
return points;
}
private:
EDIT_POINTS_FACTORY() {};
};
POINT_EDITOR::POINT_EDITOR() :
PCB_TOOL_BASE( "pcbnew.PointEditor" ),
m_selectionTool( nullptr ),
m_editedPoint( nullptr ),
m_hoveredPoint( nullptr ),
m_original( VECTOR2I( 0, 0 ) ),
m_altConstrainer( VECTOR2I( 0, 0 ) ),
m_refill( false ),
m_altEditMethod( false )
{
}
void POINT_EDITOR::Reset( RESET_REASON aReason )
{
m_refill = false;
m_editPoints.reset();
m_altConstraint.reset();
getViewControls()->SetAutoPan( false );
m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
m_statusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
m_statusPopup->SetText( _( "Self-intersecting polygons are not allowed." ) );
}
bool POINT_EDITOR::Init()
{
// Find the selection tool, so they can cooperate
m_selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" );
auto& menu = m_selectionTool->GetToolMenu().GetMenu();
menu.AddItem( PCB_ACTIONS::pointEditorAddCorner, POINT_EDITOR::addCornerCondition );
menu.AddItem( PCB_ACTIONS::pointEditorRemoveCorner,
std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
return true;
}
@ -416,7 +405,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
if( !item )
return 0;
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
m_editPoints = makePoints( item );
if( !m_editPoints )
return 0;
@ -1602,7 +1591,10 @@ void POINT_EDITOR::updatePoints()
{
getView()->Remove( m_editPoints.get() );
m_editedPoint = nullptr;
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
m_editPoints = makePoints( item );
if( m_editPoints )
getView()->Add( m_editPoints.get() );
}
else
@ -1645,7 +1637,10 @@ void POINT_EDITOR::updatePoints()
{
getView()->Remove( m_editPoints.get() );
m_editedPoint = nullptr;
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
m_editPoints = makePoints( item );
if( m_editPoints )
getView()->Add( m_editPoints.get() );
}
else if( target == 2 )
@ -1673,7 +1668,10 @@ void POINT_EDITOR::updatePoints()
{
getView()->Remove( m_editPoints.get() );
m_editedPoint = nullptr;
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
m_editPoints = makePoints( item );
if( m_editPoints )
getView()->Add( m_editPoints.get() );
}
else if( target == 4 )
@ -1707,7 +1705,10 @@ void POINT_EDITOR::updatePoints()
{
getView()->Remove( m_editPoints.get() );
m_editedPoint = nullptr;
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
m_editPoints = makePoints( item );
if( m_editPoints )
getView()->Add( m_editPoints.get() );
}
else
@ -1803,7 +1804,8 @@ void POINT_EDITOR::setAltConstraint( bool aEnabled )
if( line && isPoly )
{
m_altConstraint.reset( (EDIT_CONSTRAINT<EDIT_POINT>*)( new EC_CONVERGING( *line, *m_editPoints ) ) );
EC_CONVERGING* altConstraint = new EC_CONVERGING( *line, *m_editPoints );
m_altConstraint.reset( (EDIT_CONSTRAINT<EDIT_POINT>*) altConstraint );
}
else
{

View File

@ -64,37 +64,13 @@ public:
*/
bool HasPoint() { return m_editedPoint != nullptr; }
private:
///> Sets up handlers for various events.
void setTransitions() override;
private:
///> Selection tool used for obtaining selected items
PCB_SELECTION_TOOL* m_selectionTool;
void buildForPolyOutline( std::shared_ptr<EDIT_POINTS> points, const SHAPE_POLY_SET* aOutline );
///> Currently edited point, NULL if there is none.
EDIT_POINT* m_editedPoint;
EDIT_POINT* m_hoveredPoint;
///> Original position for the current drag point.
EDIT_POINT m_original;
///> Currently available edit points.
std::shared_ptr<EDIT_POINTS> m_editPoints;
// Alternative constraint, enabled while a modifier key is held
std::shared_ptr<EDIT_CONSTRAINT<EDIT_POINT> > m_altConstraint;
// EDIT_POINT for alternative constraint mode
EDIT_POINT m_altConstrainer;
// Flag indicating whether the selected zone needs to be refilled
bool m_refill;
// Flag indicating whether the alternative edit method is enabled.
bool m_altEditMethod;
std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
std::shared_ptr<EDIT_POINTS> makePoints( EDA_ITEM* aItem );
///> Updates item's points with edit points.
void updateItem() const;
@ -181,6 +157,23 @@ private:
///> Change the edit method to an alternative method ( currently, arcs only )
int changeEditMethod( const TOOL_EVENT& aEvent );
private:
PCB_SELECTION_TOOL* m_selectionTool;
std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
std::shared_ptr<EDIT_POINTS> m_editPoints;
EDIT_POINT* m_editedPoint;
EDIT_POINT* m_hoveredPoint;
EDIT_POINT m_original; ///> Original position for the current drag point.
bool m_refill;
bool m_altEditMethod;
// Alternative constraint, enabled while a modifier key is held
std::shared_ptr<EDIT_CONSTRAINT<EDIT_POINT>> m_altConstraint;
EDIT_POINT m_altConstrainer;
};
#endif