55 #include <wx/filedlg.h> 63 m_lastTextBold( false ),
64 m_lastTextItalic( false ),
65 m_mruPath( wxEmptyString ),
66 m_inPlaceSymbol( false ),
67 m_inPlaceImage( false ),
68 m_inSingleClickPlace( false ),
69 m_inTwoClickPlace( false ),
70 m_inDrawSheet( false )
79 auto belowRootSheetCondition =
97 EDA_RECT canvas_area( wxPoint( 0, 0 ), canvas_size );
114 std::vector<PICKED_SYMBOL>* historyList =
nullptr;
128 filter.FilterPowerSymbols(
true );
132 wxFAIL_MSG( wxT(
"PlaceSymbol(): unexpected request" ) );
193 if( evt->IsCancelInteractive() )
207 else if( evt->IsActivate() )
209 if( symbol && evt->IsMoveTool() )
212 evt->SetPassEvent(
false );
219 evt->SetPassEvent(
false );
223 if( evt->IsMoveTool() )
253 1, 1, footprintPreviews );
258 if( canvas_area.
Contains( wxPoint( initialMousePos ) ) )
260 else if( !canvas_area.
Contains( wxPoint( newMousePos ) ) )
271 wxPoint pos( cursorPos );
299 int new_unit = symbol->
GetUnit();
314 nextSymbol = static_cast<SCH_SYMBOL*>( symbol->
Duplicate() );
315 nextSymbol->
SetUnit( new_unit );
318 addSymbol( nextSymbol );
377 bool immediateMode =
image;
390 image->SetPosition( (wxPoint)cursorPos );
433 if( evt->IsCancelInteractive() )
453 else if( evt->IsActivate() )
455 if(
image && evt->IsMoveTool() )
458 evt->SetPassEvent(
false );
465 evt->SetPassEvent(
false );
469 if( evt->IsMoveTool() )
498 _(
"Image Files" ) + wxS(
" " ) + wxImage::GetImageExtWildcard(),
501 if( dlg.ShowModal() != wxID_OK )
508 if( canvas_area.
Contains( wxPoint( initialMousePos ) ) )
510 else if( !canvas_area.
Contains( wxPoint( newMousePos ) ) )
517 wxString fullFilename = dlg.GetPath();
520 if( wxFileExists( fullFilename ) )
523 if( !
image || !
image->ReadImageFile( fullFilename ) )
525 wxMessageBox(
_(
"Could not load image from '%s'." ), fullFilename );
569 image->SetPosition( (wxPoint)cursorPos );
603 bool loggedInfoBarError =
false;
613 SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.
Front() );
654 m_statusPopup->SetText(
_(
"No new hierarchical labels found." ) );
655 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
665 wxASSERT_MSG(
false, wxT(
"Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" ) );
671 cursorPos = static_cast<wxPoint>( aEvent.
HasPosition() ?
704 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
706 cursorPos = evt->IsPrime() ? (wxPoint) evt->Position()
712 if( evt->IsCancelInteractive() )
717 else if( evt->IsActivate() )
719 if( evt->IsMoveTool() )
739 "wires and/or pins." ) );
740 loggedInfoBarError =
true;
743 else if( loggedInfoBarError )
749 SCH_ITEM* newItem = static_cast<SCH_ITEM*>( previewItem->
Clone() );
813 std::deque<SCH_ITEM*> strokeItems;
814 strokeItems.push_back( previewItem );
818 if( dlg.ShowModal() == wxID_OK )
828 std::deque<SCH_JUNCTION*> junctions;
829 junctions.push_back( static_cast<SCH_JUNCTION*>( previewItem ) );
833 if( dlg.ShowModal() == wxID_OK )
871 SCHEMATIC* schematic = getModel<SCHEMATIC>();
878 textItem =
new SCH_TEXT( (wxPoint) aPosition );
882 textItem =
new SCH_LABEL( (wxPoint) aPosition );
895 static_cast<SCH_GLOBALLABEL*>( textItem )->GetIntersheetRefs()->SetVisible(
true );
900 wxFAIL_MSG( wxT(
"SCH_EDIT_FRAME::CreateNewText() unknown layer type" ) );
990 bool ignorePrimePosition =
false;
1015 else if( isGlobalLabel )
1017 else if( isNetLabel )
1019 else if( isHierLabel )
1025 auto updatePreview =
1062 ignorePrimePosition =
true;
1070 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1073 cursorPos =
grid.BestSnapAnchor( cursorPos, snapLayer, item );
1076 if( evt->IsCancelInteractive() )
1090 else if( evt->IsActivate() )
1092 if( item && evt->IsMoveTool() )
1095 evt->SetPassEvent(
false );
1102 evt->SetPassEvent(
false );
1106 if( evt->IsPointEditor() )
1110 else if( evt->IsMoveTool() )
1131 else if( isGlobalLabel )
1135 else if( isHierLabel )
1139 else if( isNetLabel )
1143 else if( isSheetPin )
1150 sheet = dynamic_cast<SCH_SHEET*>( i );
1158 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1169 m_statusPopup->SetText(
_(
"No new hierarchical labels found." ) );
1170 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1183 if( evt->IsPrime() && ignorePrimePosition )
1222 else if( item && evt->IsSelectionEvent() )
1227 if( selection.
GetSize() == 1 )
1249 evt->SetPassEvent();
1311 if( evt->IsCancelInteractive() )
1325 else if( evt->IsActivate() )
1327 if( sheet && evt->IsMoveTool() )
1330 evt->SetPassEvent(
false );
1337 evt->SetPassEvent(
false );
1341 if( evt->IsPointEditor() )
1345 else if( evt->IsMoveTool() )
1356 else if( !sheet && ( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) ) )
1363 static_cast<wxPoint>( cursorPos ) );
1376 else if( sheet && ( evt->IsClick(
BUT_LEFT )
1391 int pageNum = static_cast<int>( hierarchy.size() ) + 1;
1434 evt->SetPassEvent();
1453 wxPoint size = (wxPoint) aPos - pos;
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
EE_TYPE OfType(KICAD_T aType) const
static TOOL_ACTION properties
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void SetShape(PINSHEETLABEL_SHAPE aShape)
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
static TOOL_ACTION finishSheet
COLOR4D default_sheet_background_color
void SetPosition(const wxPoint &aPosition) override
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
static TOOL_ACTION activatePointEditor
wxPoint GetStartPoint() const
void SetUnit(int aUnit)
Change the unit number to aUnit.
Holds all the data relating to one schematic.
#define IS_NEW
New item, just created.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
#define IS_RESIZING
Item being resized.
This file is part of the common library.
static TOOL_ACTION doDelete
virtual void SetPosition(const wxPoint &aPos)
int GetUnitCount() const
Return the number of units per package of the symbol.
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
SCHEMATIC_SETTINGS & Settings() const
static TOOL_ACTION placeHierLabel
void SetItalic(bool isItalic)
static TOOL_ACTION placeJunction
void RecacheAllItems()
Rebuild GAL display lists.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
void SetFlags(EDA_ITEM_FLAGS aMask)
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.
Schematic editor (Eeschema) main window.
static TOOL_ACTION placeBusWireEntry
void SetTextSize(const wxSize &aNewSize)
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void SelectUnit(SCH_SYMBOL *aSymbol, int aUnit)
static const KICAD_T SheetsOnly[]
static TOOL_ACTION mirrorH
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
static TOOL_ACTION importSingleSheetPin
bool IsValid() const
Check if this LID_ID is valid.
SCH_SCREEN * GetScreen() const
Define a library symbol object.
PANEL_SYM_CHOOSER m_SymChooserPanel
bool Contains(const wxPoint &aPoint) const
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
virtual void SetParent(EDA_ITEM *aParent)
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
static TOOL_ACTION mirrorV
static TOOL_ACTION rotateCW
const VC_SETTINGS & GetSettings() const
Apply VIEW_CONTROLS settings from an object.
static TOOL_ACTION leaveSheet
void SetBorderWidth(int aWidth)
Base class for a bus or wire entry.
EESCHEMA_SETTINGS * eeconfig() const
std::vector< SCH_FIELD > & GetFields()
int default_line_thickness
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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...
static TOOL_ACTION drawSheet
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...
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
static TOOL_ACTION rotateCCW
static TOOL_ACTION trimOverlappingWires
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
bool m_IntersheetRefsShow
AUTOPLACE_FIELDS m_AutoplaceFields
void SetBackgroundColor(KIGFX::COLOR4D aColor)
static TOOL_ACTION placePower
#define IS_MOVING
Item being moved.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
PICKED_SYMBOL PickSymbolFromLibTree(const SCHLIB_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.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the symbol.
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
static TOOL_ACTION placeSchematicText
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
static TOOL_ACTION placeImage
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition of file extensions used in Kicad.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
Definition for symbol library class.
An interface for classes handling user events controlling the view behavior such as zooming,...
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Define a sheet pin (label) used in sheets to create hierarchical schematics.
static TOOL_ACTION importSheetPin
static TOOL_ACTION clearSelection
Clears the current selection.
static TOOL_ACTION placeSymbol
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
float m_autoPanMargin
How fast is panning when in auto mode.
static TOOL_ACTION addNeededJunctions
wxPoint GetPosition() const override
bool m_autoPanEnabled
Flag for turning on autopanning.
Object to handle a bitmap image that can be inserted in a schematic.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
virtual unsigned int GetSize() const override
Return the number of stored items.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
static TOOL_ACTION placeLabel
void SetPosition(const wxPoint &aPosition) override
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
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.
bool IsExplicitJunctionAllowed(const wxPoint &aPosition) const
Indicates that a juction dot may be placed at the given location.
SCH_SCREEN * LastScreen()
Segment description base class to describe items which have 2 end points (track, wire,...
void RollbackSchematicFromUndo()
Perform an undo of the last edit WITHOUT logging a corresponding redo.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
static TOOL_ACTION placeNoConnect
Handle the component boundary box.
const std::string KiCadSchematicFileExtension
A base class for most all the KiCad significant classes used in schematics and boards.
These settings were stored in SCH_BASE_FRAME previously.
Class for a wire to bus entry.
bool EditSheetProperties(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
WX_INFOBAR * GetInfoBar()
SCH_SHEET_PATH & GetCurrentSheet() const
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
static TOOL_ACTION placeGlobalLabel
Base class for any item which can be embedded within the SCHEMATIC container class,...
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.
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
virtual const wxString & GetText() const
Return the string associated with the text object.
static TOOL_ACTION refreshPreview
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
static TOOL_ACTION cursorClick
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...
COLOR4D default_sheet_border_color
PINSHEETLABEL_SHAPE GetShape() const
KICAD_T Type() const
Returns the type of object.
bool AddInstance(const SCH_SHEET_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
wxPoint GetPosition() const override
wxPoint GetEndPoint() const