74 const auto inDrawingArc =
80 const auto canUndoPoint = [
this](
const SELECTION& aSel )
132 aItem->ClearEditFlags();
141 aCommit.
Push( aDescription );
146 aCommit.
Add( aItem.release(),
frame()->GetScreen() );
147 aCommit.
Push( aDescription );
173 std::unique_ptr<SCH_SHAPE> item;
181 frame()->PushTool( aEvent );
215 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
221 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition() && evt->Matches( aEvent );
223 if( evt->IsCancelInteractive() || ( item && evt->IsAction( &
ACTIONS::undo ) ) )
231 frame()->PopTool( aEvent );
235 else if( evt->IsActivate() && !isSyntheticClick )
237 if( item && evt->IsMoveTool() )
240 evt->SetPassEvent(
false );
247 if( evt->IsPointEditor() )
251 else if( evt->IsMoveTool() )
258 frame()->PopTool( aEvent );
262 else if( !item && ( evt->IsClick(
BUT_LEFT )
271 textbox->SetTextSize(
VECTOR2I( defaultTextSize, defaultTextSize ) );
282 textbox->SetParent( parent );
284 item = std::move( textbox );
288 item = std::make_unique<SCH_SHAPE>( type, shapeLayer, 0,
m_lastFillStyle );
292 item->SetParent( parent );
299 item->BeginEdit( cursorPos );
302 m_view->AddToPreview( item->Clone() );
309 bool finished =
false;
319 finished = !item->ContinueEdit( cursorPos );
361 commitItem( commit, std::move( item ), wxString::Format(
_(
"Draw %s" ), item->GetClass() ) );
380 frame()->PopTool( aEvent );
386 item->CalcEdit( cursorPos );
388 m_view->AddToPreview( item->Clone() );
390 frame()->SetMsgPanel( item.get() );
392 else if( evt->IsDblClick(
BUT_LEFT ) && !item )
439 std::vector<VECTOR2D> initialPts;
441 const auto makeNewArc =
447 arc->SetParent( parent );
455 std::unique_ptr<SCH_SHAPE> arc = makeNewArc();
463 initialPts.push_back( aEvent.
Position() );
478 commitItem( commit, std::move( arc ),
_(
"Draw Arc" ) );
505 std::vector<VECTOR2D> initialPts;
507 const auto makeNewEllipseArc =
510 std::unique_ptr<SCH_SHAPE> arc = std::make_unique<SCH_SHAPE>(
514 arc->SetParent( parent );
522 std::unique_ptr<SCH_SHAPE> arc = makeNewEllipseArc();
528 initialPts.push_back( aEvent.
Position() );
543 commitItem( commit, std::move( arc ),
_(
"Draw Elliptical Arc" ) );
548 arc = makeNewEllipseArc();
570 std::vector<VECTOR2D> initialPts;
572 const auto makeNewBezier =
575 std::unique_ptr<SCH_SHAPE> bezier = std::make_unique<SCH_SHAPE>(
579 bezier->SetParent( parent );
580 bezier->SetFlags(
IS_NEW );
587 std::unique_ptr<SCH_SHAPE> bezier = makeNewBezier();
593 initialPts.push_back( aEvent.
Position() );
607 initialPts.push_back( bezier->GetEnd() );
610 if( bezier->GetEnd() != bezier->GetBezierC2() )
612 VECTOR2D mirroredC1 = bezier->GetEnd() - ( bezier->GetBezierC2() - bezier->GetEnd() );
613 initialPts.push_back( mirroredC1 );
619 commitItem( commit, std::move( bezier ),
_(
"Draw Bezier" ) );
628 bezier = makeNewBezier();
637 const std::vector<VECTOR2D>& aInitialPts )
670 bool started =
false;
671 bool cancelled =
false;
678 for(
const VECTOR2D& pt : aInitialPts )
681 if( !aInitialPts.empty() )
688 preview.
Add( aShape.get() );
689 frame()->SetMsgPanel( aShape.get() );
691 m_toolMgr->PrimeTool( aInitialPts.back() );
700 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
705 if( evt->IsCancelInteractive() )
711 evt->SetPassEvent(
false );
723 else if( evt->IsActivate() )
725 if( evt->IsPointEditor() )
729 else if( evt->IsMoveTool() )
752 preview.
Add( aShape.get() );
753 frame()->SetMsgPanel( aShape.get() );
768 else if( evt->IsMotion() )
801 m_view->Update( &preview );
806 frame()->SetMsgPanel( aShape.get() );
808 frame()->SetMsgPanel( parent );
812 preview.
Remove( aShape.get() );
814 m_view->Remove( &preview );
817 frame()->SetMsgPanel( parent );
855 if( dlgResult != wxID_OK )
861 wxMessageBox(
_(
"No graphic items found in file." ) );
868 std::vector<SCH_ITEM*> newItems;
869 std::vector<SCH_ITEM*> selectedItems;
874 [&](
const std::vector<SCH_ITEM*>& aItems )
884 item->ClearEditFlags();
890 commit.
Add( item,
frame()->GetScreen() );
893 commit.
Push(
_(
"Import Graphic" ) );
899 for( std::unique_ptr<EDA_ITEM>& ptr : list )
902 wxCHECK2_MSG( item,
continue, wxString::Format(
"Bad item type: ", ptr->Type() ) );
904 newItems.push_back( item );
905 selectedItems.push_back( item );
913 commitImport( newItems );
921 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
924 frame()->PushTool( aEvent );
943 for(
SCH_ITEM* item : selectedItems )
946 currentOffset +=
delta;
947 m_view->Update( &preview );
955 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
960 if( evt->IsCancelInteractive() || evt->IsActivate() )
969 else if( evt->IsMotion() )
971 delta = cursorPos - currentOffset;
973 for(
SCH_ITEM* item : selectedItems )
976 currentOffset +=
delta;
977 m_view->Update( &preview );
986 commitImport( newItems );
996 m_view->Remove( &preview );
1000 frame()->PopTool( aEvent );
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.
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 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)
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.
#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
LINE_STYLE
Dashed line types.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D