74 const auto inDrawingArc =
80 const auto inManagedShape = [
this](
const SELECTION& aSel )
133 aItem->ClearEditFlags();
142 aCommit.
Push( aDescription );
147 aCommit.
Add( aItem.release(),
frame()->GetScreen() );
148 aCommit.
Push( aDescription );
174 std::unique_ptr<SCH_SHAPE> item;
217 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
223 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition() && evt->Matches( aEvent );
225 if( evt->IsCancelInteractive() || ( item && evt->IsAction( &
ACTIONS::undo ) ) )
232 else if( evt->IsActivate() && !isSyntheticClick )
234 if( item && evt->IsMoveTool() )
237 evt->SetPassEvent(
false );
244 if( evt->IsPointEditor() )
250 if( evt->IsMoveTool() )
253 frame()->PushTool( originalEvent );
258 else if( !item && ( evt->IsClick(
BUT_LEFT )
267 textbox->SetTextSize(
VECTOR2I( defaultTextSize, defaultTextSize ) );
278 textbox->SetParent( parent );
280 item = std::move( textbox );
284 item = std::make_unique<SCH_SHAPE>( type, shapeLayer, 0,
m_lastFillStyle );
288 item->SetParent( parent );
295 item->BeginEdit( cursorPos );
298 m_view->AddToPreview( item->Clone() );
305 bool finished =
false;
315 finished = !item->ContinueEdit( cursorPos );
357 wxString msg = wxString::Format(
_(
"Draw %s" ), item->GetClass() );
382 item->CalcEdit( cursorPos );
384 m_view->AddToPreview( item->Clone() );
386 frame()->SetMsgPanel( item.get() );
388 else if( evt->IsDblClick(
BUT_LEFT ) && !item )
435 std::vector<VECTOR2D> initialPts;
437 const auto makeNewArc =
443 arc->SetParent( parent );
451 std::unique_ptr<SCH_SHAPE> arc = makeNewArc();
460 initialPts.push_back( aEvent.
Position() );
479 commitItem( commit, std::move( arc ),
_(
"Draw Arc" ) );
506 std::vector<VECTOR2D> initialPts;
508 const auto makeNewEllipseArc =
515 arc->SetParent( parent );
523 std::unique_ptr<SCH_SHAPE> arc = makeNewEllipseArc();
530 initialPts.push_back( aEvent.
Position() );
549 commitItem( commit, std::move( arc ),
_(
"Draw Elliptical Arc" ) );
554 arc = makeNewEllipseArc();
576 std::vector<VECTOR2D> initialPts;
578 const auto makeNewBezier =
581 std::unique_ptr<SCH_SHAPE> bezier = std::make_unique<SCH_SHAPE>(
585 bezier->SetParent( parent );
586 bezier->SetFlags(
IS_NEW );
593 std::unique_ptr<SCH_SHAPE> bezier = makeNewBezier();
600 initialPts.push_back( aEvent.
Position() );
618 initialPts.push_back( bezier->GetEnd() );
621 if( bezier->GetEnd() != bezier->GetBezierC2() )
623 VECTOR2D mirroredC1 = bezier->GetEnd() - ( bezier->GetBezierC2() - bezier->GetEnd() );
624 initialPts.push_back( mirroredC1 );
630 commitItem( commit, std::move( bezier ),
_(
"Draw Bezier" ) );
639 bezier = makeNewBezier();
647 std::unique_ptr<SCH_SHAPE>& aShape,
649 const std::vector<VECTOR2D>& aInitialPts )
682 bool started =
false;
683 bool cancelled =
false;
684 bool finished =
false;
691 for(
const VECTOR2D& pt : aInitialPts )
694 if( !aInitialPts.empty() )
701 preview.
Add( aShape.get() );
702 frame()->SetMsgPanel( aShape.get() );
711 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
716 if( evt->IsCancelInteractive() )
722 evt->SetPassEvent(
false );
733 else if( evt->IsActivate() )
735 if( evt->IsPointEditor() )
741 if( evt->IsMoveTool() )
760 preview.
Add( aShape.get() );
761 frame()->SetMsgPanel( aShape.get() );
767 else if( evt->IsDblClick(
BUT_LEFT )
787 else if( evt->IsMotion() )
820 m_view->Update( &preview );
825 frame()->SetMsgPanel( aShape.get() );
827 frame()->SetMsgPanel( parent );
831 preview.
Remove( aShape.get() );
833 m_view->Remove( &preview );
836 frame()->SetMsgPanel( parent );
883 if( dlgResult != wxID_OK )
889 wxMessageBox(
_(
"No graphic items found in file." ) );
896 std::vector<SCH_ITEM*> newItems;
897 std::vector<SCH_ITEM*> selectedItems;
902 [&](
const std::vector<SCH_ITEM*>& aItems )
912 item->ClearEditFlags();
918 commit.
Add( item,
frame()->GetScreen() );
921 commit.
Push(
_(
"Import Graphic" ) );
927 for( std::unique_ptr<EDA_ITEM>& ptr : list )
932 wxCHECK2_MSG( item,
continue, wxString::Format(
"Bad item type: ", eda_item->
Type() ) );
934 newItems.push_back( item );
935 selectedItems.push_back( item );
941 commitImport( newItems );
949 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
971 for(
SCH_ITEM* item : selectedItems )
974 currentOffset +=
delta;
975 m_view->Update( &preview );
983 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
988 if( evt->IsCancelInteractive() || evt->IsActivate() )
997 else if( evt->IsMotion() )
999 delta = cursorPos - currentOffset;
1001 for(
SCH_ITEM* item : selectedItems )
1002 item->Move(
delta );
1004 currentOffset +=
delta;
1005 m_view->Update( &preview );
1014 commitImport( newItems );
1019 evt->SetPassEvent();
1024 m_view->Remove( &preview );
constexpr EDA_IU_SCALE schIUScale
static TOOL_ACTION cancelInteractive
static TOOL_ACTION arcPosture
static TOOL_ACTION updateUnits
static TOOL_ACTION deleteLastPoint
static TOOL_ACTION cursorDblClick
static TOOL_ACTION duplicate
static TOOL_ACTION activatePointEditor
static TOOL_ACTION cursorClick
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION refreshPreview
static TOOL_ACTION finishInteractive
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Interactive arc drawing behaviour: center -> start -> end angle.
Interactive bezier drawing behaviour: start -> control1 -> end -> control2.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
void SetFilenameOverride(const wxString &aFilenameOverride)
Set the filename override to be applied in TransferDataToWindow.
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
bool IsPlacementInteractive()
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
FILL_T GetFillMode() const
COLOR4D GetFillColor() const
GR_TEXT_H_ALIGN_T GetHorizJustify() const
virtual EDA_ANGLE GetTextAngle() const
GR_TEXT_V_ALIGN_T GetVertJustify() const
Interactive elliptical-arc drawing behaviour: bbox corner 1 -> bbox corner 2 -> start angle -> end an...
A color representation with 4 components: red, green, blue, alpha.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
Define a library symbol object.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
static TOOL_ACTION drawEllipseArc
static TOOL_ACTION drawTextBox
static TOOL_ACTION drawArc
static TOOL_ACTION drawSymbolLines
static TOOL_ACTION drawSymbolTextBox
static TOOL_ACTION properties
static TOOL_ACTION ddImportGraphics
static TOOL_ACTION drawRectangle
static TOOL_ACTION drawEllipse
static TOOL_ACTION drawCircle
static TOOL_ACTION importGraphics
static TOOL_ACTION drawBezier
static TOOL_ACTION drawSymbolPolygon
static TOOL_ACTION drawPolygon
static TOOL_ACTION repeatDrawItem
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void SetBodyStyle(int aBodyStyle)
virtual void SetUnit(int aUnit)
STROKE_PARAMS GetStroke() const override
RAII class that sets an value at construction and resets it to the original value at destruction.
virtual void Add(EDA_ITEM *aItem)
A null aItem is ignored; the selection never holds null members.
virtual void Remove(EDA_ITEM *aItem)
virtual void Clear() override
Remove all the stored items from the group.
Abstract interface for interactive shape-drawing behaviours.
virtual void AddPoint(const VECTOR2I &aPosition)=0
Lock in a point and advance the construction state.
virtual void Reset()=0
Reset the behaviour to its initial state for chained object creation loops.
virtual bool IsComplete() const =0
True when all points have been locked in.
virtual void SetCursorPosition(const VECTOR2I &aPosition)=0
Preview the cursor position without advancing state.
virtual void SetUnits(EDA_UNITS aUnits)=0
Forward a units change to the assistant overlay.
virtual bool HasGeometryChanged() const =0
True if the geometry changed since the last call to ClearGeometryChanged().
virtual void RemoveLastPoint()=0
Undo the last locked-in point.
virtual EDA_ITEM & GetAssistant()=0
Return the visual assistant overlay item.
virtual void ClearGeometryChanged()=0
Reset the geometry-changed flag (call after updating the preview).
virtual void ApplyToShape(EDA_SHAPE &aShape) const =0
Transfer the current geometry to an EDA_SHAPE.
virtual void ToggleClockwise()
Flip arc direction (applies only when the shape has such a concept of directionality,...
The symbol library editor main window.
bool GetDrawSpecificUnit() const
bool GetDrawSpecificBodyStyle() const
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
bool IsSymbolGraphicallyEditable() const
Test if a symbol is loaded and can be edited graphically.
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
static constexpr EDA_ANGLE ANGLE_0
#define IS_NEW
New item, just created.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
SCH_LAYER_ID
Eeschema drawing layers.
std::vector< EDA_ITEM * > EDA_ITEMS
SHAPE_DRAW_RESULT
Outcome of an interactive shape drawing loop, telling the caller how to continue.
@ NEXT_SHAPE
Commit the shape, if any, and start drawing another.
@ FINISHED
The user finished; commit the shape, if any, and stop drawing.
@ CANCELLED
The user cancelled; nothing to commit, stop drawing.
LINE_STYLE
Dashed line types.
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D