Separate symbol editor polyline and polygon tools.

Fixes https://gitlab.com/kicad/code/kicad/issues/14695
This commit is contained in:
Jeff Young 2023-05-07 14:51:17 +01:00
parent 7a7a23c83a
commit 4a62cc6edd
10 changed files with 67 additions and 44 deletions

View File

@ -140,7 +140,7 @@ public:
*
* This is used to end or abort an edit action in progress initiated by BeginEdit().
*/
virtual void EndEdit() {}
virtual void EndEdit( bool aClosed = false ) {}
/**
* Calculate the attributes of an item at \a aPosition when it is being edited.

View File

@ -78,7 +78,7 @@ public:
bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
void EndEdit() override { endEdit( false ); }
void EndEdit( bool aClosed = false ) override { endEdit( aClosed ); }
void SetEditState( int aState ) { setEditState( aState ); }
void AddPoint( const VECTOR2I& aPosition );

View File

@ -145,6 +145,7 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar()
placeMenu->Add( EE_ACTIONS::drawCircle );
placeMenu->Add( EE_ACTIONS::drawArc );
placeMenu->Add( EE_ACTIONS::drawSymbolLines );
placeMenu->Add( EE_ACTIONS::drawSymbolPolygon );
//-- Inspect menu -----------------------------------------------

View File

@ -524,6 +524,7 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( EE_ACTIONS::drawCircle, EDIT_TOOL( EE_ACTIONS::drawCircle ) );
mgr->SetConditions( EE_ACTIONS::drawArc, EDIT_TOOL( EE_ACTIONS::drawArc ) );
mgr->SetConditions( EE_ACTIONS::drawSymbolLines, EDIT_TOOL( EE_ACTIONS::drawSymbolLines ) );
mgr->SetConditions( EE_ACTIONS::drawSymbolPolygon, EDIT_TOOL( EE_ACTIONS::drawSymbolPolygon ) );
mgr->SetConditions( EE_ACTIONS::placeSymbolAnchor, EDIT_TOOL( EE_ACTIONS::placeSymbolAnchor ) );
#undef CHECK

View File

@ -64,6 +64,7 @@ void SYMBOL_EDIT_FRAME::ReCreateVToolbar()
m_drawToolBar->Add( EE_ACTIONS::drawCircle, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::drawArc, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::drawSymbolLines, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::drawSymbolPolygon, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::placeSymbolAnchor, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE );

View File

@ -246,23 +246,28 @@ TOOL_ACTION EE_ACTIONS::toggleSyncedPinsMode( "eeschema.SymbolLibraryControl.tog
TOOL_ACTION EE_ACTIONS::placeSymbolPin( "eeschema.SymbolDrawing.placeSymbolPin",
AS_GLOBAL,
'P', LEGACY_HK_NAME( "Create Pin" ),
_( "Add Pin" ), _( "Add a pin" ),
_( "Add Pin" ), _( "Draw pins" ),
BITMAPS::pin, AF_ACTIVATE, (void*) LIB_PIN_T );
TOOL_ACTION EE_ACTIONS::placeSymbolText( "eeschema.SymbolDrawing.placeSymbolText",
AS_GLOBAL, 0, "",
_( "Add Text" ), _( "Add a text item" ),
_( "Add Text" ), _( "Draw text items" ),
BITMAPS::text, AF_ACTIVATE, (void*) LIB_TEXT_T );
TOOL_ACTION EE_ACTIONS::drawSymbolTextBox( "eeschema.SymbolDrawing.drawSymbolTextBox",
AS_GLOBAL, 0, "",
_( "Add Text Box" ), _( "Add a text box item" ),
_( "Add Text Box" ), _( "Draw text box items" ),
BITMAPS::add_textbox, AF_ACTIVATE, (void*) LIB_TEXTBOX_T );
TOOL_ACTION EE_ACTIONS::drawSymbolLines( "eeschema.SymbolDrawing.drawSymbolLines",
AS_GLOBAL, 0, "",
_( "Add Lines" ), _( "Add connected graphic lines" ),
BITMAPS::add_graphical_segments, AF_ACTIVATE, (void*) SHAPE_T::POLY );
_( "Add Lines" ), _( "Draw lines" ),
BITMAPS::add_graphical_segments, AF_ACTIVATE, (void*) SHAPE_T::SEGMENT );
TOOL_ACTION EE_ACTIONS::drawSymbolPolygon( "eeschema.SymbolDrawing.drawSymbolPolygon",
AS_GLOBAL, 0, "",
_( "Add Polygon" ), _( "Draw polygons" ),
BITMAPS::add_graphical_polygon, AF_ACTIVATE, (void*) SHAPE_T::POLY );
TOOL_ACTION EE_ACTIONS::placeSymbolAnchor( "eeschema.SymbolDrawing.placeSymbolAnchor",
AS_GLOBAL, 0, "",
@ -297,25 +302,25 @@ TOOL_ACTION EE_ACTIONS::pushPinNumSize( "eeschema.PinEditing.pushPinNumSize",
TOOL_ACTION EE_ACTIONS::placeSymbol( "eeschema.InteractiveDrawing.placeSymbol",
AS_GLOBAL,
'A', LEGACY_HK_NAME( "Add Symbol" ),
_( "Add Symbol" ), _( "Add a symbol" ),
_( "Add Symbol" ), _( "Add symbols" ),
BITMAPS::add_component, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::placePower( "eeschema.InteractiveDrawing.placePowerSymbol",
AS_GLOBAL,
'P', LEGACY_HK_NAME( "Add Power" ),
_( "Add Power" ), _( "Add a power symbol" ),
_( "Add Power" ), _( "Add power symbols" ),
BITMAPS::add_power, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::placeNoConnect( "eeschema.InteractiveDrawing.placeNoConnect",
AS_GLOBAL,
'Q', LEGACY_HK_NAME( "Add No Connect Flag" ),
_( "Add No Connect Flag" ), _( "Add a no-connection flag" ),
_( "Add No Connect Flag" ), _( "Draw no-connection flags" ),
BITMAPS::noconn, AF_ACTIVATE, (void*) SCH_NO_CONNECT_T );
TOOL_ACTION EE_ACTIONS::placeJunction( "eeschema.InteractiveDrawing.placeJunction",
AS_GLOBAL,
'J', LEGACY_HK_NAME( "Add Junction" ),
_( "Add Junction" ), _( "Add a junction" ),
_( "Add Junction" ), _( "Draw junctions" ),
BITMAPS::add_junction, AF_ACTIVATE, (void*) SCH_JUNCTION_T );
TOOL_ACTION EE_ACTIONS::placeBusWireEntry( "eeschema.InteractiveDrawing.placeBusWireEntry",
@ -327,66 +332,66 @@ TOOL_ACTION EE_ACTIONS::placeBusWireEntry( "eeschema.InteractiveDrawing.placeBus
TOOL_ACTION EE_ACTIONS::placeLabel( "eeschema.InteractiveDrawing.placeLabel",
AS_GLOBAL,
'L', LEGACY_HK_NAME( "Add Label" ),
_( "Add Label" ), _( "Add a net label" ),
_( "Add Label" ), _( "Draw net labels" ),
BITMAPS::add_label, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::placeClassLabel( "eeschema.InteractiveDrawing.placeClassLabel",
AS_GLOBAL, 0, "",
_( "Add Net Class Directive" ), _( "Add a net class directive label" ),
_( "Add Net Class Directive" ), _( "Add net class directive labels" ),
BITMAPS::add_class_flag, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::placeHierLabel( "eeschema.InteractiveDrawing.placeHierarchicalLabel",
AS_GLOBAL,
'H', LEGACY_HK_NAME( "Add Hierarchical Label" ),
_( "Add Hierarchical Label" ), _( "Add a hierarchical label" ),
_( "Add Hierarchical Label" ), _( "Add hierarchical labels" ),
BITMAPS::add_hierarchical_label, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::drawSheet( "eeschema.InteractiveDrawing.drawSheet",
AS_GLOBAL,
'S', LEGACY_HK_NAME( "Add Sheet" ),
_( "Add Sheet" ), _( "Add a hierarchical sheet" ),
_( "Add Sheet" ), _( "Draw hierarchical sheets" ),
BITMAPS::add_hierarchical_subsheet, AF_ACTIVATE, (void*) SCH_SHEET_T );
TOOL_ACTION EE_ACTIONS::importSheetPin( "eeschema.InteractiveDrawing.importSheetPin",
AS_GLOBAL, 0, "",
_( "Import Sheet Pin" ), _( "Import a hierarchical sheet pin" ),
_( "Import Sheet Pin" ), _( "Import hierarchical sheet pins" ),
BITMAPS::import_hierarchical_label, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::placeGlobalLabel( "eeschema.InteractiveDrawing.placeGlobalLabel",
AS_GLOBAL,
MD_CTRL + 'L', LEGACY_HK_NAME( "Add Global Label" ),
_( "Add Global Label" ), _( "Add a global label" ),
_( "Add Global Label" ), _( "Add global labels" ),
BITMAPS::add_glabel, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::placeSchematicText( "eeschema.InteractiveDrawing.placeSchematicText",
AS_GLOBAL,
'T', LEGACY_HK_NAME( "Add Graphic Text" ),
_( "Add Text" ), _( "Add text" ),
_( "Add Text" ), _( "Draw text items" ),
BITMAPS::text, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::drawTextBox( "eeschema.InteractiveDrawing.drawTextBox",
AS_GLOBAL, 0, "",
_( "Add Text Box" ), _( "Add a text box" ),
_( "Add Text Box" ), _( "Draw text box items" ),
BITMAPS::add_textbox, AF_ACTIVATE, (void*) SHAPE_T::RECT );
TOOL_ACTION EE_ACTIONS::drawRectangle( "eeschema.InteractiveDrawing.drawRectangle",
AS_GLOBAL, 0, "",
_( "Add Rectangle" ), _( "Add a rectangle" ),
_( "Add Rectangle" ), _( "Draw rectangles" ),
BITMAPS::add_rectangle, AF_ACTIVATE, (void*) SHAPE_T::RECT );
TOOL_ACTION EE_ACTIONS::drawCircle( "eeschema.InteractiveDrawing.drawCircle",
AS_GLOBAL, 0, "",
_( "Add Circle" ), _( "Add a circle" ),
_( "Add Circle" ), _( "Draw circles" ),
BITMAPS::add_circle, AF_ACTIVATE, (void*) SHAPE_T::CIRCLE );
TOOL_ACTION EE_ACTIONS::drawArc( "eeschema.InteractiveDrawing.drawArc",
AS_GLOBAL, 0, "",
_( "Add Arc" ), _( "Add an arc" ),
_( "Add Arc" ), _( "Draw arcs" ),
BITMAPS::add_arc, AF_ACTIVATE, (void*) SHAPE_T::ARC );
TOOL_ACTION EE_ACTIONS::placeImage( "eeschema.InteractiveDrawing.placeImage",
AS_GLOBAL, 0, "",
_( "Add Image" ), _( "Add bitmap image" ),
_( "Add Image" ), _( "Add bitmap images" ),
BITMAPS::image, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::finishSheet( "eeschema.InteractiveDrawing.finishSheet",
@ -908,8 +913,8 @@ const DRAW_SEGMENT_EVENT_PARAMS drawLinesActionParam = { LAYER_NOTES, false, nul
TOOL_ACTION EE_ACTIONS::drawLines( "eeschema.InteractiveDrawingLineWireBus.drawLines",
AS_GLOBAL,
'I', LEGACY_HK_NAME( "Add Graphic PolyLine" ),
_( "Add Lines" ), _( "Add connected graphic lines" ),
BITMAPS::add_dashed_line, AF_ACTIVATE, (void*) &drawLinesActionParam );
_( "Add Lines" ), _( "Draw graphic lines" ),
BITMAPS::add_graphical_segments, AF_ACTIVATE, (void*) &drawLinesActionParam );
TOOL_ACTION EE_ACTIONS::undoLastSegment( "eeschema.InteractiveDrawingLineWireBus.undoLastSegment",
AS_GLOBAL,

View File

@ -110,6 +110,7 @@ public:
static TOOL_ACTION placeSymbolText;
static TOOL_ACTION drawSymbolTextBox;
static TOOL_ACTION drawSymbolLines;
static TOOL_ACTION drawSymbolPolygon;
static TOOL_ACTION placeSymbolAnchor;
static TOOL_ACTION finishDrawing;

View File

@ -329,7 +329,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
{
SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
SYMBOL_EDITOR_SETTINGS* settings = settingsMgr.GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
SHAPE_T type = aEvent.Parameter<SHAPE_T>();
SHAPE_T toolType = aEvent.Parameter<SHAPE_T>();
SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
LIB_SHAPE* item = nullptr;
bool isTextBox = aEvent.IsAction( &EE_ACTIONS::drawSymbolTextBox );
@ -441,7 +442,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
}
else
{
item = new LIB_SHAPE( symbol, type, lineWidth, m_lastFillStyle );
item = new LIB_SHAPE( symbol, shapeType, lineWidth, m_lastFillStyle );
}
item->SetStroke( m_lastStroke );
@ -472,7 +473,16 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing )
|| !item->ContinueEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ) )
{
item->EndEdit();
if( toolType == SHAPE_T::POLY )
{
item->CalcEdit( item->GetPosition() ); // Close shape
item->EndEdit( true );
}
else
{
item->EndEdit();
}
item->ClearEditFlags();
if( isTextBox )
@ -652,6 +662,7 @@ void SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions()
Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawCircle.MakeEvent() );
Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawArc.MakeEvent() );
Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolLines.MakeEvent() );
Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolPolygon.MakeEvent() );
Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolTextBox.MakeEvent() );
Go( &SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor, EE_ACTIONS::placeSymbolAnchor.MakeEvent() );
Go( &SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem, EE_ACTIONS::repeatDrawItem.MakeEvent() );

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 B

After

Width:  |  Height:  |  Size: 213 B

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="Слой_1"
data-name="Слой 1"
viewBox="0 0 24 24"
version="1.1"
sodipodi:docname="add_line.svg"
inkscape:version="1.0.1 (1.0.1+r74)">
inkscape:version="1.2.1 (9c6d41e, 2022-07-14)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
@ -22,18 +22,21 @@
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2560"
inkscape:window-height="1371"
inkscape:window-width="1503"
inkscape:window-height="741"
id="namedview30"
showgrid="true"
inkscape:zoom="19.771793"
inkscape:cx="3.3259971"
inkscape:cy="13"
inkscape:cx="-1.3402932"
inkscape:cy="10.798211"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:window-y="38"
inkscape:window-maximized="0"
inkscape:document-rotation="0"
inkscape:current-layer="Слой_1">
inkscape:current-layer="Слой_1"
inkscape:showpageshadow="2"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1">
<inkscape:grid
type="xygrid"
id="grid_kicad"
@ -81,7 +84,7 @@
id="title344">add_line</title>
<path
id="line346"
style="fill:none;stroke:#545454;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="fill:none;stroke:#1a81c4;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1"
d="M 21,3 3,21"
class="cls-1"
sodipodi:nodetypes="cc" />

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB