53#include <dialogs/dialog_text_properties.h>
59#include <wx/filedlg.h>
67 m_lastTextBold( false ),
68 m_lastTextItalic( false ),
77 m_mruPath( wxEmptyString ),
78 m_lastAutoLabelRotateOnPlacement( false ),
79 m_inPlaceSymbol( false ),
80 m_inDrawShape( false ),
81 m_inPlaceImage( false ),
82 m_inSingleClickPlace( false ),
83 m_inTwoClickPlace( false ),
84 m_inDrawSheet( false )
93 auto belowRootSheetCondition =
110 std::vector<PICKED_SYMBOL>* historyList =
nullptr;
111 bool ignorePrimePosition =
false;
140 filter.FilterPowerSymbols(
true );
144 wxFAIL_MSG(
"PlaceSymbol(): unexpected request" );
178 existingRefs.
Clear();
207 for(
size_t i = 0; i < refs.
GetCount(); i++ )
208 existingRefs.
AddItem( refs[i] );
237 ignorePrimePosition =
true;
245 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
250 bool isSyntheticClick = symbol && evt->IsActivate() && evt->HasPosition()
253 if( evt->IsCancelInteractive() )
267 else if( evt->IsActivate() && !isSyntheticClick )
269 if( symbol && evt->IsMoveTool() )
272 evt->SetPassEvent(
false );
279 evt->SetPassEvent(
false );
283 if( evt->IsMoveTool() )
294 else if( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) || isSyntheticClick )
303 1, 1, footprintPreviews );
314 if( evt->IsPrime() && !ignorePrimePosition )
316 cursorPos =
grid.Align( evt->Position() );
333 existingRefs.
AddItem( placedSymbolReference );
362 int new_unit = symbol->
GetUnit();
378 nextSymbol->
SetUnit( new_unit );
385 addSymbol( nextSymbol );
393 existingRefs.
AddItem( placedSymbolReference );
468 bool immediateMode =
image !=
nullptr;
470 bool ignorePrimePosition =
false;
529 ignorePrimePosition =
true;
539 bool isSyntheticClick =
image && evt->IsActivate() && evt->HasPosition()
540 && evt->Matches( aEvent );
542 if( evt->IsCancelInteractive() )
562 else if( evt->IsActivate() && !isSyntheticClick )
564 if(
image && evt->IsMoveTool() )
567 evt->SetPassEvent(
false );
574 evt->SetPassEvent(
false );
578 if( evt->IsMoveTool() )
589 else if( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) || isSyntheticClick )
596 _(
"Image Files" ) + wxS(
" " ) + wxImage::GetImageExtWildcard(),
599 if( dlg.ShowModal() != wxID_OK )
605 if( evt->IsPrime() && !ignorePrimePosition )
607 cursorPos =
grid.Align( evt->Position() );
616 wxString fullFilename = dlg.GetPath();
619 if( wxFileExists( fullFilename ) )
622 if( !
image || !
image->ReadImageFile( fullFilename ) )
624 wxMessageBox(
_(
"Could not load image from '%s'." ), fullFilename );
668 image->SetPosition( cursorPos );
703 bool loggedInfoBarError =
false;
742 wxASSERT_MSG(
false,
"Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" );
780 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
782 cursorPos = evt->IsPrime() ? evt->Position() : controls->
GetMousePosition();
786 if( evt->IsCancelInteractive() )
791 else if( evt->IsActivate() )
793 if( evt->IsMoveTool() )
813 "wires and/or pins." ) );
814 loggedInfoBarError =
true;
817 else if( loggedInfoBarError )
888 std::deque<SCH_ITEM*> strokeItems;
889 strokeItems.push_back( previewItem );
893 if( dlg.ShowModal() == wxID_OK )
903 std::deque<SCH_JUNCTION*> junctions;
904 junctions.push_back(
static_cast<SCH_JUNCTION*
>( previewItem ) );
908 if( dlg.ShowModal() == wxID_OK )
946 SCHEMATIC* schematic = getModel<SCHEMATIC>();
954 textItem =
new SCH_TEXT( aPosition );
959 textItem = labelItem;
965 labelItem->
GetFields().emplace_back(
SCH_FIELD( {0,0}, 0, labelItem, wxT(
"Netclass" ) ) );
966 labelItem->
GetFields().back().SetItalic(
true );
967 labelItem->
GetFields().back().SetVisible(
true );
968 textItem = labelItem;
975 textItem = labelItem;
983 textItem = labelItem;
987 wxFAIL_MSG(
"SCH_EDIT_FRAME::CreateNewText() unknown layer type" );
1116 bool ignorePrimePosition =
false;
1148 else if( isGlobalLabel )
1150 else if( isNetLabel )
1152 else if( isClassLabel )
1154 else if( isHierLabel )
1160 auto updatePreview =
1194 && ( isText || isGlobalLabel || isHierLabel || isClassLabel || isNetLabel ) )
1197 ignorePrimePosition =
true;
1205 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1208 cursorPos =
grid.BestSnapAnchor( cursorPos, snapLayer, item );
1212 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
1215 auto createNextSheetPin =
1226 m_statusPopup->SetText(
_(
"No new hierarchical labels found." ) );
1227 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1242 if( evt->IsCancelInteractive() )
1256 else if( evt->IsActivate() && !isSyntheticClick )
1258 if( item && evt->IsMoveTool() )
1261 evt->SetPassEvent(
false );
1268 evt->SetPassEvent(
false );
1272 if( evt->IsPointEditor() )
1276 else if( evt->IsMoveTool() )
1287 else if( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) || isSyntheticClick )
1298 else if( isHierLabel )
1302 else if( isNetLabel || isGlobalLabel )
1323 if( netName.IsEmpty() )
1334 SCHEMATIC* schematic = getModel<SCHEMATIC>();
1350 labelItem->
SetParent( getModel<SCHEMATIC>() );
1357 labelItem->
SetText( netName );
1361 else if( isClassLabel )
1365 else if( isSheetPin )
1377 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1383 createNextSheetPin();
1396 if( evt->IsPrime() && !ignorePrimePosition )
1398 cursorPos =
grid.Align( evt->Position() );
1437 createNextSheetPin();
1455 else if( item && evt->IsSelectionEvent() )
1460 if( selection.
GetSize() == 1 )
1482 evt->SetPassEvent();
1500 SCHEMATIC* schematic = getModel<SCHEMATIC>();
1553 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
1556 if( evt->IsCancelInteractive() )
1568 else if( evt->IsActivate() && !isSyntheticClick )
1570 if( item && evt->IsMoveTool() )
1573 evt->SetPassEvent(
false );
1580 if( evt->IsPointEditor() )
1584 else if( evt->IsMoveTool() )
1595 else if( evt->IsClick(
BUT_LEFT ) && !item )
1628 else if( item && ( evt->IsClick(
BUT_LEFT )
1648 if( dlg.ShowModal() != wxID_OK )
1684 else if( evt->IsDblClick(
BUT_LEFT ) && !item )
1698 evt->SetPassEvent();
1760 bool isSyntheticClick = sheet && evt->IsActivate() && evt->HasPosition()
1763 if( evt->IsCancelInteractive() )
1777 else if( evt->IsActivate() && !isSyntheticClick )
1779 if( sheet && evt->IsMoveTool() )
1782 evt->SetPassEvent(
false );
1789 evt->SetPassEvent(
false );
1793 if( evt->IsPointEditor() )
1797 else if( evt->IsMoveTool() )
1808 else if( !sheet && ( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) ) )
1813 if( selection.
Size() == 1
1822 else if( evt->IsDblClick(
BUT_LEFT ) )
1844 else if( sheet && ( evt->IsClick(
BUT_LEFT )
1886 evt->SetPassEvent();
constexpr EDA_IU_SCALE schIUScale
static TOOL_ACTION duplicate
static TOOL_ACTION activatePointEditor
static TOOL_ACTION doDelete
static TOOL_ACTION refreshPreview
bool Contains(const Vec &aPoint) const
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
WX_INFOBAR * GetInfoBar()
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
VECTOR2I GetNearestGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize location to aPosition.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void SetPosition(const VECTOR2I &aPos)
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
virtual void SetParent(EDA_ITEM *aParent)
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
FILL_T GetFillMode() const
void SetFillColor(const COLOR4D &aColor)
COLOR4D GetFillColor() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
GR_TEXT_H_ALIGN_T GetHorizJustify() const
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
PANEL_ANNOTATE m_AnnotatePanel
PANEL_SYM_CHOOSER m_SymChooserPanel
AUTOPLACE_FIELDS m_AutoplaceFields
static TOOL_ACTION mirrorV
static TOOL_ACTION properties
static TOOL_ACTION placeSymbol
static TOOL_ACTION clearSelection
Clears the current selection.
static TOOL_ACTION placeClassLabel
static TOOL_ACTION drawCircle
static TOOL_ACTION rotateCCW
static TOOL_ACTION placePower
static TOOL_ACTION mirrorH
static TOOL_ACTION rotateCW
static TOOL_ACTION importSheetPin
static TOOL_ACTION leaveSheet
static TOOL_ACTION placeGlobalLabel
static TOOL_ACTION placeHierLabel
static TOOL_ACTION drawTextBox
static TOOL_ACTION drawRectangle
static TOOL_ACTION placeImage
static TOOL_ACTION enterSheet
static TOOL_ACTION finishSheet
static TOOL_ACTION placeSchematicText
static TOOL_ACTION finishDrawing
static TOOL_ACTION drawArc
static TOOL_ACTION drawSheet
static TOOL_ACTION placeLabel
static TOOL_ACTION placeBusWireEntry
static TOOL_ACTION placeJunction
static TOOL_ACTION placeNoConnect
EE_TYPE Overlapping(const BOX2I &aRect) const
EE_TYPE OfType(KICAD_T aType) const
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
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.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
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 SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
virtual void PinCursorInsideNonAutoscrollArea(bool aWarpMouseCursor)=0
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
void RecacheAllItems()
Rebuild GAL display lists.
bool IsValid() const
Check if this LID_ID is valid.
Define a library symbol object.
These settings were stored in SCH_BASE_FRAME previously.
bool m_IntersheetRefsShow
Holds all the data relating to one schematic.
SCHEMATIC_SETTINGS & Settings() const
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PICKED_SYMBOL PickSymbolFromLibTree(const SYMBOL_LIBRARY_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Call the library viewer to select symbol to import into schematic.
EESCHEMA_SETTINGS * eeconfig() const
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
Object to handle a bitmap image that can be inserted in a schematic.
Base class for a bus or wire entry.
VECTOR2I GetPosition() const override
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Class for a wire to bus entry.
Schematic editor (Eeschema) main window.
void RollbackSchematicFromUndo()
Perform an undo of the last edit WITHOUT logging a corresponding redo.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void SelectUnit(SCH_SYMBOL *aSymbol, int aUnit)
bool EditSheetProperties(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
void SetAutoRotateOnPlacement(bool autoRotate=true)
setAutoRotateOnPlacement
void SetShape(LABEL_FLAG_SHAPE aShape) override
LABEL_FLAG_SHAPE GetShape() const override
std::vector< SCH_FIELD > & GetFields()
Segment description base class to describe items which have 2 end points (track, wire,...
bool IsWire() const
Return true if the line is a wire.
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
wxString GetNetname(const SCH_SHEET_PATH &aSheet)
This function travel though all the connected wire segments to look for connected labels.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void SortByReferenceOnly()
Sort the list of references by reference.
void ReannotateByOptions(ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, int aStartNumber, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent, SCH_SHEET_LIST *aHierarchy)
Forces reannotation of the provided references.
void AddItem(const SCH_REFERENCE &aItem)
void UpdateAnnotation()
Update the symbol references for the schematic project (or the current sheet).
A helper to define a symbol's reference designator in a schematic.
bool AlwaysAnnotate() const
Verify the reference should always be automatically annotated.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
SCH_ITEM * GetItem(const VECTOR2I &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
bool IsExplicitJunctionAllowed(const VECTOR2I &aPosition) const
Indicates that a juction dot may be placed at the given location.
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
void CalcEdit(const VECTOR2I &aPosition)
bool ContinueEdit(const VECTOR2I &aPosition)
void BeginEdit(const VECTOR2I &aStartPoint)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetStroke(const STROKE_PARAMS &aStroke) override
STROKE_PARAMS GetStroke() const override
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
SCH_SHEET_LIST FindAllSheetsForScreen(const SCH_SCREEN *aScreen) const
Return a SCH_SHEET_LIST with a copy of all the SCH_SHEET_PATH using a particular screen.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
void SetPosition(const VECTOR2I &aPosition) override
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetBorderColor(KIGFX::COLOR4D aColor)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
std::vector< SCH_FIELD > & GetFields()
void SetBackgroundColor(KIGFX::COLOR4D aColor)
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
void SetBorderWidth(int aWidth)
void Resize(const VECTOR2I &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
int GetUnitCount() const
Return the number of units per package of the symbol.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the symbol.
void SetPosition(const VECTOR2I &aPosition) override
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
void SetUnit(int aUnit)
Change the unit number to aUnit.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
TEXT_SPIN_STYLE GetTextSpinStyle() const
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
virtual unsigned int GetSize() const override
Return the number of stored items.
int Size() const
Returns the number of selected parts.
Helper object to filter a list of libraries.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
This file is part of the common library.
static constexpr EDA_ANGLE & ANGLE_0
#define IS_NEW
New item, just created.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_MOVING
Item being moved.
@ ID_POPUP_SCH_SELECT_UNIT_CMP
@ ID_POPUP_SCH_SELECT_UNIT_SYM_MAX
const std::string KiCadSchematicFileExtension
ANNOTATE_ORDER_T
Schematic annotation order options.
ANNOTATE_ALGO_T
Schematic annotation type options.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
PLOT_DASH_TYPE
Dashed line types.
constexpr int MilsToIU(int mils) const
COLOR4D default_sheet_border_color
COLOR4D default_sheet_background_color
int default_line_thickness
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition of file extensions used in Kicad.