mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 14:59:50 +00:00
Eeschema: point editor: as a behavior class for SCH_LINEs
This adds the concept of editing _other_ items to the one that informs the POINT_EDIT_BEHAVIOR - in this case connected lines. This is one of the motivations behind this system, as it will allow to bring similar logic to Pcbnew.
This commit is contained in:
parent
cd8ae3afd1
commit
fe57c531e2
eeschema/tools
include/tool
pcbnew/tools
@ -104,10 +104,101 @@ enum BEZIER_POINTS
|
||||
};
|
||||
|
||||
|
||||
class LINE_POINT_EDIT_BEHAVIOR : public POINT_EDIT_BEHAVIOR
|
||||
{
|
||||
public:
|
||||
LINE_POINT_EDIT_BEHAVIOR( SCH_LINE& aLine, SCH_SCREEN& aScreen ) :
|
||||
m_line( aLine ), m_screen( aScreen )
|
||||
{
|
||||
}
|
||||
|
||||
void MakePoints( EDIT_POINTS& aPoints ) override
|
||||
{
|
||||
std::pair<EDA_ITEM*, int> connectedStart = { nullptr, STARTPOINT };
|
||||
std::pair<EDA_ITEM*, int> connectedEnd = { nullptr, STARTPOINT };
|
||||
|
||||
for( SCH_ITEM* test : m_screen.Items().OfType( SCH_LINE_T ) )
|
||||
{
|
||||
if( test->GetLayer() != LAYER_NOTES )
|
||||
continue;
|
||||
|
||||
if( test == &m_line )
|
||||
continue;
|
||||
|
||||
SCH_LINE* testLine = static_cast<SCH_LINE*>( test );
|
||||
|
||||
if( testLine->GetStartPoint() == m_line.GetStartPoint() )
|
||||
{
|
||||
connectedStart = { testLine, STARTPOINT };
|
||||
}
|
||||
else if( testLine->GetEndPoint() == m_line.GetStartPoint() )
|
||||
{
|
||||
connectedStart = { testLine, ENDPOINT };
|
||||
}
|
||||
else if( testLine->GetStartPoint() == m_line.GetEndPoint() )
|
||||
{
|
||||
connectedEnd = { testLine, STARTPOINT };
|
||||
}
|
||||
else if( testLine->GetEndPoint() == m_line.GetEndPoint() )
|
||||
{
|
||||
connectedEnd = { testLine, ENDPOINT };
|
||||
}
|
||||
}
|
||||
|
||||
aPoints.AddPoint( m_line.GetStartPoint(), connectedStart );
|
||||
aPoints.AddPoint( m_line.GetEndPoint(), connectedEnd );
|
||||
}
|
||||
|
||||
void UpdatePoints( EDIT_POINTS& aPoints ) override
|
||||
{
|
||||
aPoints.Point( LINE_START ).SetPosition( m_line.GetStartPoint() );
|
||||
aPoints.Point( LINE_END ).SetPosition( m_line.GetEndPoint() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoints, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
m_line.SetStartPoint( aPoints.Point( LINE_START ).GetPosition() );
|
||||
m_line.SetEndPoint( aPoints.Point( LINE_END ).GetPosition() );
|
||||
|
||||
std::pair<EDA_ITEM*, int> connected = aPoints.Point( LINE_START ).GetConnected();
|
||||
|
||||
if( connected.first )
|
||||
{
|
||||
aCommit.Modify( connected.first, &m_screen );
|
||||
aUpdatedItems.push_back( connected.first );
|
||||
|
||||
if( connected.second == STARTPOINT )
|
||||
static_cast<SCH_LINE*>( connected.first )->SetStartPoint( m_line.GetStartPoint() );
|
||||
else if( connected.second == ENDPOINT )
|
||||
static_cast<SCH_LINE*>( connected.first )->SetEndPoint( m_line.GetStartPoint() );
|
||||
}
|
||||
|
||||
connected = aPoints.Point( LINE_END ).GetConnected();
|
||||
|
||||
if( connected.first )
|
||||
{
|
||||
aCommit.Modify( connected.first, &m_screen );
|
||||
aUpdatedItems.push_back( connected.first );
|
||||
|
||||
if( connected.second == STARTPOINT )
|
||||
static_cast<SCH_LINE*>( connected.first )->SetStartPoint( m_line.GetEndPoint() );
|
||||
else if( connected.second == ENDPOINT )
|
||||
static_cast<SCH_LINE*>( connected.first )->SetEndPoint( m_line.GetEndPoint() );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SCH_LINE& m_line;
|
||||
SCH_SCREEN& m_screen;
|
||||
};
|
||||
|
||||
|
||||
class EDIT_POINTS_FACTORY
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<EDIT_POINTS> Make( EDA_ITEM* aItem, SCH_BASE_FRAME* frame )
|
||||
static std::shared_ptr<EDIT_POINTS> Make( EDA_ITEM* aItem, SCH_BASE_FRAME* frame,
|
||||
std::unique_ptr<POINT_EDIT_BEHAVIOR>& editBehavior )
|
||||
{
|
||||
std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
|
||||
|
||||
@ -272,46 +363,16 @@ public:
|
||||
|
||||
case SCH_LINE_T:
|
||||
{
|
||||
SCH_LINE* line = (SCH_LINE*) aItem;
|
||||
std::pair<EDA_ITEM*, int> connectedStart = { nullptr, STARTPOINT };
|
||||
std::pair<EDA_ITEM*, int> connectedEnd = { nullptr, STARTPOINT };
|
||||
|
||||
for( SCH_ITEM* test : frame->GetScreen()->Items().OfType( SCH_LINE_T ) )
|
||||
{
|
||||
if( test->GetLayer() != LAYER_NOTES )
|
||||
continue;
|
||||
|
||||
if( test == aItem )
|
||||
continue;
|
||||
|
||||
SCH_LINE* testLine = static_cast<SCH_LINE*>( test );
|
||||
|
||||
if( testLine->GetStartPoint() == line->GetStartPoint() )
|
||||
{
|
||||
connectedStart = { testLine, STARTPOINT };
|
||||
}
|
||||
else if( testLine->GetEndPoint() == line->GetStartPoint() )
|
||||
{
|
||||
connectedStart = { testLine, ENDPOINT };
|
||||
}
|
||||
else if( testLine->GetStartPoint() == line->GetEndPoint() )
|
||||
{
|
||||
connectedEnd = { testLine, STARTPOINT };
|
||||
}
|
||||
else if( testLine->GetEndPoint() == line->GetEndPoint() )
|
||||
{
|
||||
connectedEnd = { testLine, ENDPOINT };
|
||||
}
|
||||
}
|
||||
|
||||
points->AddPoint( line->GetStartPoint(), connectedStart );
|
||||
points->AddPoint( line->GetEndPoint(), connectedEnd );
|
||||
SCH_LINE& line = static_cast<SCH_LINE&>( *aItem );
|
||||
editBehavior = std::make_unique<LINE_POINT_EDIT_BEHAVIOR>( line, *frame->GetScreen() );
|
||||
break;
|
||||
}
|
||||
default: points.reset(); break;
|
||||
}
|
||||
|
||||
default:
|
||||
points.reset();
|
||||
break;
|
||||
if( editBehavior )
|
||||
{
|
||||
editBehavior->MakePoints( *points );
|
||||
}
|
||||
|
||||
return points;
|
||||
@ -427,7 +488,7 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
||||
|
||||
controls->ShowCursor( true );
|
||||
|
||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, m_frame );
|
||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, m_frame, m_editBehavior );
|
||||
view->Add( m_editPoints.get() );
|
||||
setEditedPoint( nullptr );
|
||||
updateEditedPoint( aEvent );
|
||||
@ -461,19 +522,7 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
commit.Modify( m_editPoints->GetParent(), m_frame->GetScreen() );
|
||||
|
||||
if( m_editPoints->GetParent()->Type() == SCH_LINE_T )
|
||||
{
|
||||
std::pair<EDA_ITEM*, int> connected = m_editPoints->Point( LINE_START ).GetConnected();
|
||||
|
||||
if( connected.first )
|
||||
commit.Modify( connected.first, m_frame->GetScreen() );
|
||||
|
||||
connected = m_editPoints->Point( LINE_END ).GetConnected();
|
||||
|
||||
if( connected.first )
|
||||
commit.Modify( connected.first, m_frame->GetScreen() );
|
||||
}
|
||||
else if( m_editPoints->GetParent()->Type() == SCH_TABLECELL_T )
|
||||
if( m_editPoints->GetParent()->Type() == SCH_TABLECELL_T )
|
||||
{
|
||||
SCH_TABLECELL* cell = static_cast<SCH_TABLECELL*>( m_editPoints->GetParent() );
|
||||
SCH_TABLE* table = static_cast<SCH_TABLE*>( cell->GetParent() );
|
||||
@ -729,6 +778,19 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid, SCH_COMMIT& aCommit )
|
||||
if( !item )
|
||||
return;
|
||||
|
||||
std::vector<EDA_ITEM*> updateditems = { item };
|
||||
if( m_editBehavior )
|
||||
{
|
||||
m_editBehavior->UpdateItem( *m_editedPoint, *m_editPoints, aCommit, updateditems );
|
||||
|
||||
for( EDA_ITEM* updatedItem : updateditems )
|
||||
{
|
||||
updateItem( updatedItem, true );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_RULE_AREA_T:
|
||||
@ -1095,46 +1157,14 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid, SCH_COMMIT& aCommit )
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SCH_LINE_T:
|
||||
{
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
|
||||
line->SetStartPoint( m_editPoints->Point( LINE_START ).GetPosition() );
|
||||
line->SetEndPoint( m_editPoints->Point( LINE_END ).GetPosition() );
|
||||
|
||||
std::pair<EDA_ITEM*, int> connected = m_editPoints->Point( LINE_START ).GetConnected();
|
||||
|
||||
if( connected.first )
|
||||
{
|
||||
if( connected.second == STARTPOINT )
|
||||
static_cast<SCH_LINE*>( connected.first )->SetStartPoint( line->GetStartPoint() );
|
||||
else if( connected.second == ENDPOINT )
|
||||
static_cast<SCH_LINE*>( connected.first )->SetEndPoint( line->GetStartPoint() );
|
||||
|
||||
updateItem( connected.first, true );
|
||||
}
|
||||
|
||||
connected = m_editPoints->Point( LINE_END ).GetConnected();
|
||||
|
||||
if( connected.first )
|
||||
{
|
||||
if( connected.second == STARTPOINT )
|
||||
static_cast<SCH_LINE*>( connected.first )->SetStartPoint( line->GetEndPoint() );
|
||||
else if( connected.second == ENDPOINT )
|
||||
static_cast<SCH_LINE*>( connected.first )->SetEndPoint( line->GetEndPoint() );
|
||||
|
||||
updateItem( connected.first, true );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
updateItem( item, true );
|
||||
for( EDA_ITEM* updatedItem : updateditems )
|
||||
{
|
||||
updateItem( updatedItem, true );
|
||||
}
|
||||
m_frame->SetMsgPanel( item );
|
||||
}
|
||||
|
||||
@ -1149,6 +1179,12 @@ void EE_POINT_EDITOR::updatePoints()
|
||||
if( !item )
|
||||
return;
|
||||
|
||||
if( m_editBehavior )
|
||||
{
|
||||
m_editBehavior->UpdatePoints( *m_editPoints );
|
||||
return;
|
||||
}
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_RULE_AREA_T:
|
||||
@ -1175,7 +1211,7 @@ void EE_POINT_EDITOR::updatePoints()
|
||||
{
|
||||
getView()->Remove( m_editPoints.get() );
|
||||
m_editedPoint = nullptr;
|
||||
m_editPoints = EDIT_POINTS_FACTORY::Make( item, m_frame );
|
||||
// m_editPoints = EDIT_POINTS_FACTORY::Make( item, m_frame );
|
||||
getView()->Add( m_editPoints.get() );
|
||||
}
|
||||
else
|
||||
@ -1285,15 +1321,6 @@ void EE_POINT_EDITOR::updatePoints()
|
||||
break;
|
||||
}
|
||||
|
||||
case SCH_LINE_T:
|
||||
{
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
|
||||
m_editPoints->Point( LINE_START ).SetPosition( line->GetStartPoint() );
|
||||
m_editPoints->Point( LINE_END ).SetPosition( line->GetEndPoint() );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -115,6 +115,9 @@ private:
|
||||
|
||||
///< Currently available edit points.
|
||||
std::shared_ptr<EDIT_POINTS> m_editPoints;
|
||||
|
||||
///< Current item-specific edit behavior.
|
||||
std::unique_ptr<POINT_EDIT_BEHAVIOR> m_editBehavior;
|
||||
};
|
||||
|
||||
#endif // EE_POINT_EDITOR_H
|
||||
|
@ -614,6 +614,10 @@ public:
|
||||
/**
|
||||
* Update the list of the edit points for the item.
|
||||
*
|
||||
* Be very careful not to overrun the list of points -
|
||||
* this class knows how bug there are because it made them
|
||||
* in the first place.
|
||||
*
|
||||
* If item has changed such that that number of points needs to
|
||||
* change, this method has to handle that (probably by clearing
|
||||
* the list and refilling it).
|
||||
@ -625,11 +629,21 @@ public:
|
||||
/**
|
||||
* Update the item with the new positions of the edit points.
|
||||
*
|
||||
* This method should all commit and add to the update list anything that
|
||||
* is NOT the parent item of the EDIT_POINTs. For example, connected lines,
|
||||
* parent tables, etc. The item itself is already handled (most behaviors
|
||||
* don't need more than that).
|
||||
*
|
||||
* @param aEditedPoint The point that was dragged.
|
||||
* You can use this to check by address which point to update.
|
||||
* @param aPoints The new positions of the edit points.
|
||||
* @param aCommit The commit object to use to modify the item.
|
||||
* @param aUpdatedItems The list of items that were updated by the edit (not only the
|
||||
* item that was being edited, but also any other items that were
|
||||
* affected, e.g. by being conneted to the edited item).
|
||||
*/
|
||||
virtual void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) = 0;
|
||||
virtual void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) = 0;
|
||||
|
||||
/**
|
||||
* Get the 45-degree constrainer for the item, when the given point is moved.
|
||||
|
@ -131,7 +131,8 @@ public:
|
||||
aPoints.Point( SEG_END ) = m_segment.GetEnd();
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, 2 );
|
||||
|
||||
@ -309,7 +310,8 @@ public:
|
||||
UpdatePoints( m_rectangle, aPoints );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
UpdateItem( m_rectangle, aEditedPoint, aPoints );
|
||||
}
|
||||
@ -473,7 +475,8 @@ public:
|
||||
aPoints.Point( ARC_CENTER ).SetPosition( m_arc.GetCenter() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, 4 );
|
||||
|
||||
@ -866,7 +869,8 @@ public:
|
||||
aPoints.Point( CIRC_END ).SetPosition( m_circle.GetEnd() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, 2 );
|
||||
|
||||
@ -990,7 +994,8 @@ public:
|
||||
UpdatePointsFromOutline( m_polygon.GetPolyShape(), aPoints );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
UpdateOutlineFromPoints( m_polygon.GetPolyShape(), aEditedPoint, aPoints );
|
||||
}
|
||||
@ -1016,7 +1021,8 @@ public:
|
||||
POLYGON_POINT_EDIT_BEHAVIOR::UpdatePointsFromOutline( *m_zone.Outline(), aPoints );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
SHAPE_POLY_SET& outline = *m_zone.Outline();
|
||||
CHECK_POINT_COUNT( aPoints, (unsigned) outline.TotalVertices() );
|
||||
@ -1072,7 +1078,8 @@ public:
|
||||
aPoints.Point( BEZIER_END ).SetPosition( m_bezier.GetEnd() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, BEZIER_MAX_POINTS );
|
||||
|
||||
@ -1148,7 +1155,8 @@ public:
|
||||
.SetPosition( refImage.GetPosition() + refImage.GetTransformOriginOffset() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, REFIMG_MAX_POINTS );
|
||||
|
||||
@ -1262,12 +1270,16 @@ public:
|
||||
.SetPosition( m_cell.GetEndX() - m_cell.GetRectangleWidth() / 2, m_cell.GetEndY() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, TABLECELL_MAX_POINTS );
|
||||
|
||||
PCB_TABLE& table = static_cast<PCB_TABLE&>( *m_cell.GetParent() );
|
||||
|
||||
aCommit.Modify( &table );
|
||||
aUpdatedItems.push_back( &table );
|
||||
|
||||
if( isModified( aEditedPoint, aPoints.Point( COL_WIDTH ) ) )
|
||||
{
|
||||
m_cell.SetEnd( VECTOR2I( aPoints.Point( 0 ).GetX(), m_cell.GetEndY() ) );
|
||||
@ -1410,7 +1422,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
// TODO(JE) padstacks
|
||||
switch( m_pad.GetShape( PADSTACK::ALL_LAYERS ) )
|
||||
@ -1539,7 +1552,8 @@ public:
|
||||
m_generator.UpdateEditPoints( aPoints );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
m_generator.UpdateFromEditPoints( aPoints );
|
||||
}
|
||||
@ -1709,7 +1723,8 @@ public:
|
||||
aPoints.Point( DIM_CROSSBAREND ).SetPosition( m_dimension.GetCrossbarEnd() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, DIM_ALIGNED_MAX );
|
||||
|
||||
@ -1900,7 +1915,8 @@ public:
|
||||
aPoints.Point( DIM_END ).SetPosition( m_dimension.GetEnd() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, DIM_CENTER_MAX );
|
||||
|
||||
@ -1962,7 +1978,8 @@ public:
|
||||
aPoints.Point( DIM_KNEE ).SetPosition( m_dimension.GetKnee() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, DIM_RADIAL_MAX );
|
||||
|
||||
@ -2053,7 +2070,8 @@ public:
|
||||
aPoints.Point( DIM_TEXT ).SetPosition( m_dimension.GetTextPos() );
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
CHECK_POINT_COUNT( aPoints, DIM_LEADER_MAX );
|
||||
|
||||
@ -2129,7 +2147,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints ) override
|
||||
void UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit,
|
||||
std::vector<EDA_ITEM*>& aUpdatedItems ) override
|
||||
{
|
||||
if( m_textbox.GetShape() == SHAPE_T::RECTANGLE )
|
||||
{
|
||||
@ -2439,17 +2458,6 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genStartEdit, &commit,
|
||||
static_cast<PCB_GENERATOR*>( item ) );
|
||||
}
|
||||
else if( item->Type() == PCB_TABLECELL_T )
|
||||
{
|
||||
PCB_TABLECELL* cell = static_cast<PCB_TABLECELL*>( item );
|
||||
PCB_TABLE* table = static_cast<PCB_TABLE*>( cell->GetParent() );
|
||||
|
||||
commit.Modify( table );
|
||||
}
|
||||
else
|
||||
{
|
||||
commit.Modify( item );
|
||||
}
|
||||
|
||||
getViewControls()->ForceCursorPosition( false );
|
||||
m_original = *m_editedPoint; // Save the original position
|
||||
@ -2533,7 +2541,7 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||
{ item } ) );
|
||||
}
|
||||
|
||||
updateItem( &commit );
|
||||
updateItem( commit );
|
||||
getViewControls()->ForceCursorPosition( true, m_editedPoint->GetPosition() );
|
||||
updatePoints();
|
||||
}
|
||||
@ -2660,7 +2668,7 @@ int PCB_POINT_EDITOR::movePoint( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
pt = editFrame->GetOriginTransforms().FromDisplayAbs( dlg.GetValue() );
|
||||
m_editedPoint->SetPosition( pt );
|
||||
updateItem( &commit );
|
||||
updateItem( commit );
|
||||
commit.Push( msg );
|
||||
}
|
||||
|
||||
@ -2668,18 +2676,22 @@ int PCB_POINT_EDITOR::movePoint( const TOOL_EVENT& aEvent )
|
||||
}
|
||||
|
||||
|
||||
void PCB_POINT_EDITOR::updateItem( BOARD_COMMIT* aCommit )
|
||||
void PCB_POINT_EDITOR::updateItem( BOARD_COMMIT& aCommit )
|
||||
{
|
||||
wxCHECK( m_editPoints, /* void */ );
|
||||
EDA_ITEM* item = m_editPoints->GetParent();
|
||||
|
||||
if( !item || !m_editorBehavior )
|
||||
if( !item )
|
||||
return;
|
||||
|
||||
// item is always updated
|
||||
std::vector<EDA_ITEM*> updatedItems = { item };
|
||||
aCommit.Modify( item );
|
||||
|
||||
if( m_editorBehavior )
|
||||
{
|
||||
wxCHECK( m_editedPoint, /* void */ );
|
||||
m_editorBehavior->UpdateItem( *m_editedPoint, *m_editPoints );
|
||||
m_editorBehavior->UpdateItem( *m_editedPoint, *m_editPoints, aCommit, updatedItems );
|
||||
}
|
||||
|
||||
// Perform any post-edit actions that the item may require
|
||||
@ -2706,20 +2718,12 @@ void PCB_POINT_EDITOR::updateItem( BOARD_COMMIT* aCommit )
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_TABLECELL_T:
|
||||
{
|
||||
PCB_TABLECELL& cell = static_cast<PCB_TABLECELL&>( *item );
|
||||
PCB_TABLE& table = static_cast<PCB_TABLE&>( *cell.GetParent() );
|
||||
getView()->Update( &table );
|
||||
break;
|
||||
}
|
||||
case PCB_GENERATOR_T:
|
||||
{
|
||||
GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool<GENERATOR_TOOL>();
|
||||
PCB_GENERATOR* generatorItem = static_cast<PCB_GENERATOR*>( item );
|
||||
|
||||
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genUpdateEdit, aCommit, generatorItem );
|
||||
m_toolMgr->RunSynchronousAction( PCB_ACTIONS::genUpdateEdit, &aCommit, generatorItem );
|
||||
|
||||
// Note: POINT_EDITOR::m_preview holds only the canvas-draw status "popup"; the meanders
|
||||
// themselves (ROUTER_PREVIEW_ITEMs) are owned by the router.
|
||||
@ -2739,7 +2743,11 @@ void PCB_POINT_EDITOR::updateItem( BOARD_COMMIT* aCommit )
|
||||
break;
|
||||
}
|
||||
|
||||
getView()->Update( item );
|
||||
// Update the item and any affected items
|
||||
for( EDA_ITEM* updatedItem : updatedItems )
|
||||
{
|
||||
getView()->Update( updatedItem );
|
||||
}
|
||||
|
||||
frame()->SetMsgPanel( item );
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ private:
|
||||
std::shared_ptr<EDIT_POINTS> makePoints( EDA_ITEM* aItem );
|
||||
|
||||
///< Update item's points with edit points.
|
||||
void updateItem( BOARD_COMMIT* aCommit );
|
||||
void updateItem( BOARD_COMMIT& aCommit );
|
||||
|
||||
///< Update edit points with item's points.
|
||||
void updatePoints();
|
||||
|
Loading…
Reference in New Issue
Block a user