Don't offer point-based pad editing in PCBNew.
This commit is contained in:
parent
e840e9d997
commit
d9bbdffd99
|
@ -607,11 +607,8 @@ bool PCB_SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag,
|
||||||
|
|
||||||
guide.SetIgnoreZoneFills( displayOpts.m_ZoneDisplayMode != ZONE_DISPLAY_MODE::SHOW_FILLED );
|
guide.SetIgnoreZoneFills( displayOpts.m_ZoneDisplayMode != ZONE_DISPLAY_MODE::SHOW_FILLED );
|
||||||
|
|
||||||
if( m_enteredGroup &&
|
if( m_enteredGroup && !m_enteredGroup->GetBoundingBox().Contains( (wxPoint) aWhere ) )
|
||||||
!m_enteredGroup->GetBoundingBox().Contains( wxPoint( aWhere.x, aWhere.y ) ) )
|
|
||||||
{
|
|
||||||
ExitGroup();
|
ExitGroup();
|
||||||
}
|
|
||||||
|
|
||||||
collector.Collect( board(), m_isFootprintEditor ? GENERAL_COLLECTOR::FootprintItems
|
collector.Collect( board(), m_isFootprintEditor ? GENERAL_COLLECTOR::FootprintItems
|
||||||
: GENERAL_COLLECTOR::AllBoardItems,
|
: GENERAL_COLLECTOR::AllBoardItems,
|
||||||
|
|
|
@ -83,14 +83,51 @@ enum DIMENSION_POINTS
|
||||||
DIM_CROSSBAREND,
|
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();
|
int cornersCount = aOutline->TotalVertices();
|
||||||
|
|
||||||
for( auto iterator = aOutline->CIterateWithHoles(); iterator; iterator++ )
|
for( auto iterator = aOutline->CIterateWithHoles(); iterator; iterator++ )
|
||||||
|
@ -106,14 +143,9 @@ private:
|
||||||
for( int i = 0; i < cornersCount - 1; ++i )
|
for( int i = 0; i < cornersCount - 1; ++i )
|
||||||
{
|
{
|
||||||
if( points->IsContourEnd( 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
|
else
|
||||||
{
|
|
||||||
points->AddLine( points->Point( i ), points->Point( i + 1 ) );
|
points->AddLine( points->Point( i ), points->Point( i + 1 ) );
|
||||||
}
|
|
||||||
|
|
||||||
points->Line( i ).SetConstraint( new EC_PERPLINE( points->Line( i ) ) );
|
points->Line( i ).SetConstraint( new EC_PERPLINE( points->Line( i ) ) );
|
||||||
}
|
}
|
||||||
|
@ -122,12 +154,12 @@ private:
|
||||||
points->AddLine( points->Point( cornersCount - 1 ),
|
points->AddLine( points->Point( cornersCount - 1 ),
|
||||||
points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
|
points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
|
||||||
|
|
||||||
points->Line( points->LinesSize() - 1 ).SetConstraint(
|
points->Line( points->LinesSize() - 1 )
|
||||||
new EC_PERPLINE( 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 );
|
std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
|
||||||
|
|
||||||
|
@ -180,7 +212,7 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_POLYGON:
|
case S_POLYGON:
|
||||||
buildForPolyOutline( points, &shape->GetPolyShape(), aGal );
|
buildForPolyOutline( points, &shape->GetPolyShape() );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_CURVE:
|
case S_CURVE:
|
||||||
|
@ -200,11 +232,14 @@ public:
|
||||||
case PCB_PAD_T:
|
case PCB_PAD_T:
|
||||||
{
|
{
|
||||||
const PAD* pad = static_cast<const PAD*>( aItem );
|
const PAD* pad = static_cast<const PAD*>( aItem );
|
||||||
|
FOOTPRINT* parent = pad->GetParent();
|
||||||
wxPoint shapePos = pad->ShapePos();
|
wxPoint shapePos = pad->ShapePos();
|
||||||
wxPoint halfSize( pad->GetSize().x / 2, pad->GetSize().y / 2 );
|
wxPoint halfSize( pad->GetSize().x / 2, pad->GetSize().y / 2 );
|
||||||
|
|
||||||
if( pad->GetParent() &&
|
if( !m_isFootprintEditor )
|
||||||
( pad->GetParent()->IsLocked() || pad->GetParent()->PadsLocked() ) )
|
break;
|
||||||
|
|
||||||
|
if( parent && ( parent->IsLocked() || parent->PadsLocked() ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch( pad->GetShape() )
|
switch( pad->GetShape() )
|
||||||
|
@ -243,7 +278,7 @@ public:
|
||||||
case PCB_ZONE_T:
|
case PCB_ZONE_T:
|
||||||
{
|
{
|
||||||
const ZONE* zone = static_cast<const ZONE*>( aItem );
|
const ZONE* zone = static_cast<const ZONE*>( aItem );
|
||||||
buildForPolyOutline( points, zone->Outline(), aGal );
|
buildForPolyOutline( points, zone->Outline() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -304,52 +339,6 @@ public:
|
||||||
return points;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
void POINT_EDITOR::updateEditedPoint( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
@ -416,7 +405,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||||
if( !item )
|
if( !item )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
|
m_editPoints = makePoints( item );
|
||||||
|
|
||||||
if( !m_editPoints )
|
if( !m_editPoints )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1602,7 +1591,10 @@ void POINT_EDITOR::updatePoints()
|
||||||
{
|
{
|
||||||
getView()->Remove( m_editPoints.get() );
|
getView()->Remove( m_editPoints.get() );
|
||||||
m_editedPoint = nullptr;
|
m_editedPoint = nullptr;
|
||||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
|
|
||||||
|
m_editPoints = makePoints( item );
|
||||||
|
|
||||||
|
if( m_editPoints )
|
||||||
getView()->Add( m_editPoints.get() );
|
getView()->Add( m_editPoints.get() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1645,7 +1637,10 @@ void POINT_EDITOR::updatePoints()
|
||||||
{
|
{
|
||||||
getView()->Remove( m_editPoints.get() );
|
getView()->Remove( m_editPoints.get() );
|
||||||
m_editedPoint = nullptr;
|
m_editedPoint = nullptr;
|
||||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
|
|
||||||
|
m_editPoints = makePoints( item );
|
||||||
|
|
||||||
|
if( m_editPoints )
|
||||||
getView()->Add( m_editPoints.get() );
|
getView()->Add( m_editPoints.get() );
|
||||||
}
|
}
|
||||||
else if( target == 2 )
|
else if( target == 2 )
|
||||||
|
@ -1673,7 +1668,10 @@ void POINT_EDITOR::updatePoints()
|
||||||
{
|
{
|
||||||
getView()->Remove( m_editPoints.get() );
|
getView()->Remove( m_editPoints.get() );
|
||||||
m_editedPoint = nullptr;
|
m_editedPoint = nullptr;
|
||||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
|
|
||||||
|
m_editPoints = makePoints( item );
|
||||||
|
|
||||||
|
if( m_editPoints )
|
||||||
getView()->Add( m_editPoints.get() );
|
getView()->Add( m_editPoints.get() );
|
||||||
}
|
}
|
||||||
else if( target == 4 )
|
else if( target == 4 )
|
||||||
|
@ -1707,7 +1705,10 @@ void POINT_EDITOR::updatePoints()
|
||||||
{
|
{
|
||||||
getView()->Remove( m_editPoints.get() );
|
getView()->Remove( m_editPoints.get() );
|
||||||
m_editedPoint = nullptr;
|
m_editedPoint = nullptr;
|
||||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
|
|
||||||
|
m_editPoints = makePoints( item );
|
||||||
|
|
||||||
|
if( m_editPoints )
|
||||||
getView()->Add( m_editPoints.get() );
|
getView()->Add( m_editPoints.get() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1803,7 +1804,8 @@ void POINT_EDITOR::setAltConstraint( bool aEnabled )
|
||||||
|
|
||||||
if( line && isPoly )
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,37 +64,13 @@ public:
|
||||||
*/
|
*/
|
||||||
bool HasPoint() { return m_editedPoint != nullptr; }
|
bool HasPoint() { return m_editedPoint != nullptr; }
|
||||||
|
|
||||||
|
private:
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
private:
|
void buildForPolyOutline( std::shared_ptr<EDIT_POINTS> points, const SHAPE_POLY_SET* aOutline );
|
||||||
///> Selection tool used for obtaining selected items
|
|
||||||
PCB_SELECTION_TOOL* m_selectionTool;
|
|
||||||
|
|
||||||
///> Currently edited point, NULL if there is none.
|
std::shared_ptr<EDIT_POINTS> makePoints( EDA_ITEM* aItem );
|
||||||
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;
|
|
||||||
|
|
||||||
///> Updates item's points with edit points.
|
///> Updates item's points with edit points.
|
||||||
void updateItem() const;
|
void updateItem() const;
|
||||||
|
@ -181,6 +157,23 @@ private:
|
||||||
|
|
||||||
///> Change the edit method to an alternative method ( currently, arcs only )
|
///> Change the edit method to an alternative method ( currently, arcs only )
|
||||||
int changeEditMethod( const TOOL_EVENT& aEvent );
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue