69#include <dialogs/dialog_text_properties.h>
72#include <dialogs/dialog_table_properties.h>
77#include <wx/filedlg.h>
86 m_lastTextBold( false ),
87 m_lastTextItalic( false ),
100 m_mruPath( wxEmptyString ),
101 m_lastAutoLabelRotateOnPlacement( false ),
102 m_drawingRuleArea( false ),
103 m_inDrawingTool( false )
112 auto belowRootSheetCondition =
118 auto inDrawingRuleArea =
141 bool placeOneOnly = symbol !=
nullptr;
144 std::vector<PICKED_SYMBOL>* historyList =
nullptr;
145 bool ignorePrimePosition =
false;
149 bool keepSymbol =
false;
150 bool placeAllUnits =
false;
178 filter.FilterPowerSymbols(
true );
182 wxFAIL_MSG(
"PlaceSymbol(): unexpected request" );
217 existingRefs.
Clear();
245 for(
size_t i = 0; i < refs.
GetCount(); i++ )
246 existingRefs.
AddItem( refs[i] );
278 ignorePrimePosition =
true;
286 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
292 bool isSyntheticClick = symbol && evt->IsActivate() && evt->HasPosition() && evt->Matches( aEvent );
294 if( evt->IsCancelInteractive() || ( symbol && evt->IsAction( &
ACTIONS::undo ) ) )
308 else if( evt->IsActivate() && !isSyntheticClick )
310 if( symbol && evt->IsMoveTool() )
313 evt->SetPassEvent(
false );
320 evt->SetPassEvent(
false );
324 if( evt->IsMoveTool() )
335 else if( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) || isSyntheticClick )
344 std::set<UTF8> unique_libid;
345 std::vector<PICKED_SYMBOL> alreadyPlaced;
362 alreadyPlaced.push_back( pickedSymbol );
383 if( evt->IsPrime() && !ignorePrimePosition )
385 cursorPos =
grid.Align( evt->Position(), GRID_HELPER_GRIDS::GRID_CONNECTABLE );
392 GRID_HELPER_GRIDS::GRID_CONNECTABLE );
403 if( keywords.Contains( wxT(
"global power" ) ) )
405 keywords.Replace( wxT(
"global power" ), wxT(
"local power" ) );
411 if( desc.Contains( wxT(
"global label" ) ) )
413 desc.Replace( wxT(
"global label" ), wxT(
"local label" ) );
432 existingRefs.
AddItem( placedSymbolReference );
455 commit.
Added( symbol, screen );
461 commit.
Push(
_(
"Place Symbol" ) );
471 if( keepSymbol || placeAllUnits )
478 while( currentReference.
GetUnit() <= symbol->GetUnitCount()
479 && schematic.
Contains( currentReference ) )
484 if( currentReference.
GetUnit() > symbol->GetUnitCount() )
491 if( keepSymbol || currentReference.
GetUnit() > 1 )
497 addSymbol( nextSymbol );
500 if( currentReference.
GetUnit() == 1 )
505 existingRefs.
AddItem( placedSymbolReference );
539 if( symbol && symbol->GetBodyStyle() != bodyStyle )
564 symbol->SetPosition( cursorPos );
602 static const std::vector<KICAD_T> symbolTypes = {
SCH_SYMBOL_T };
605 if( selection.
Size() != 1 )
626 if( missingUnits.empty() )
633 const int nextMissing = *std::min_element( missingUnits.begin(), missingUnits.end() );
635 std::unique_ptr<SCH_SYMBOL> newSymbol = std::make_unique<SCH_SYMBOL>( *symbol );
638 newSymbol->SetUnitSelection( &sheetPath, nextMissing );
639 newSymbol->SetUnit( nextMissing );
640 newSymbol->SetRefProp( symbol->
GetRef( &sheetPath,
false ) );
661 if( !cfg || !common_settings )
669 std::unique_ptr<DESIGN_BLOCK> designBlock;
670 wxString sheetFileName = wxEmptyString;
672 if( placingDesignBlock )
684 sheetFileName = designBlock->GetSchematicFile();
689 wxString* importSourceFile = aEvent.
Parameter<wxString*>();
691 if( importSourceFile !=
nullptr )
692 sheetFileName = *importSourceFile;
699 : KICURSOR::COMPONENT );
702 auto placeSheetContents =
719 placingDesignBlock ) )
738 group->SetName( designBlock->GetLibId().GetLibItemName() );
739 group->SetDesignBlockLibId( designBlock->GetLibId() );
743 group->SetName( wxFileName( sheetFileName ).
GetName() );
753 static_cast<SCH_SYMBOL*
>( item )->ClearAnnotation( &sheetPath,
false );
759 group->AddItem( item );
761 commit.
Added( item, screen );
762 newItems.emplace_back( item );
793 if( !keepAnnotations )
824 commit.
Push( placingDesignBlock ?
_(
"Add Design Block" )
825 :
_(
"Import Schematic Sheet Content" ) );
839 if( sheetFileName.IsEmpty() )
844 if (!placingDesignBlock)
846 if( sheetFileName.IsEmpty() )
849 file = wxEmptyString;
853 path = wxPathOnly( sheetFileName );
854 file = wxFileName( sheetFileName ).GetFullName();
859 wxFileDialog dlg(
m_frame,
_(
"Choose Schematic" ),
path, file,
863 dlg.SetCustomizeHook( dlgHook );
865 if( dlg.ShowModal() == wxID_CANCEL )
868 sheetFileName = dlg.GetPath();
873 if( sheetFileName.IsEmpty() )
911 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
917 bool isSyntheticClick = designBlock && evt->IsActivate() && evt->HasPosition() && evt->Matches( aEvent );
919 if( evt->IsCancelInteractive() || ( designBlock && evt->IsAction( &
ACTIONS::undo ) ) )
924 else if( evt->IsActivate() && !isSyntheticClick )
929 else if( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) || isSyntheticClick )
931 if( placingDesignBlock )
973 bool immediateMode =
image !=
nullptr;
974 bool ignorePrimePosition =
false;
1037 ignorePrimePosition =
true;
1045 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1051 bool isSyntheticClick =
image && evt->IsActivate() && evt->HasPosition() && evt->Matches( aEvent );
1073 else if( evt->IsActivate() && !isSyntheticClick )
1075 if(
image && evt->IsMoveTool() )
1078 evt->SetPassEvent(
false );
1085 evt->SetPassEvent(
false );
1089 if( evt->IsMoveTool() )
1100 else if( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) || isSyntheticClick )
1107 _(
"Image Files" ) + wxS(
" " ) + wxImage::GetImageExtWildcard(),
1110 if( dlg.ShowModal() != wxID_OK )
1116 if( evt->IsPrime() && !ignorePrimePosition )
1118 cursorPos =
grid.Align( evt->Position() );
1127 wxString fullFilename = dlg.GetPath();
1130 if( wxFileExists( fullFilename ) )
1133 if( !
image || !
image->GetReferenceImage().ReadImageFile( fullFilename ) )
1135 wxMessageBox( wxString::Format(
_(
"Could not load image from '%s'." ), fullFilename ) );
1158 commit.
Push(
_(
"Place Image" ) );
1193 evt->SetPassEvent();
1198 image->SetPosition( cursorPos );
1214 evt->SetPassEvent();
1244 if( dlgResult != wxID_OK )
1250 wxMessageBox(
_(
"No graphic items found in file." ) );
1257 std::vector<SCH_ITEM*> newItems;
1258 std::vector<SCH_ITEM*> selectedItems;
1262 for( std::unique_ptr<EDA_ITEM>& ptr : list )
1265 wxCHECK2_MSG( item,
continue, wxString::Format(
"Bad item type: ", ptr->Type() ) );
1267 newItems.push_back( item );
1268 selectedItems.push_back( item );
1269 preview.
Add( item );
1280 commit.
Push(
_(
"Import Graphic" ) );
1289 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
1315 for(
SCH_ITEM* item : selectedItems )
1316 item->Move(
delta );
1318 currentOffset +=
delta;
1328 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1333 if( evt->IsCancelInteractive() || evt->IsActivate() )
1342 else if( evt->IsMotion() )
1344 delta = cursorPos - currentOffset;
1346 for(
SCH_ITEM* item : selectedItems )
1347 item->Move(
delta );
1349 currentOffset +=
delta;
1363 commit.
Push(
_(
"Import Graphic" ) );
1368 evt->SetPassEvent();
1391 bool loggedInfoBarError =
false;
1392 wxString description;
1394 bool allowRepeat =
false;
1420 description =
_(
"Add No Connect Flag" );
1427 description =
_(
"Add Junction" );
1433 description =
_(
"Add Wire to Bus Entry" );
1438 wxASSERT_MSG(
false,
"Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" );
1476 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1478 cursorPos = evt->IsPrime() ? evt->Position() : controls->
GetMousePosition();
1479 cursorPos =
grid.BestSnapAnchor( cursorPos,
grid.GetItemGrid( previewItem ),
nullptr );
1482 if( evt->IsCancelInteractive() )
1487 else if( evt->IsActivate() )
1489 if( evt->IsMoveTool() )
1502 if( !screen->
GetItem( cursorPos, 0, type ) )
1509 loggedInfoBarError =
true;
1512 else if( loggedInfoBarError )
1528 commit.
Added( newItem, screen );
1532 commit.
Push( description );
1587 std::deque<SCH_ITEM*> strokeItems;
1588 strokeItems.push_back( previewItem );
1597 std::deque<SCH_JUNCTION*> junctions;
1598 junctions.push_back(
static_cast<SCH_JUNCTION*
>( previewItem ) );
1615 evt->SetPassEvent();
1620 evt->SetPassEvent();
1653 wxASSERT( aWire->
IsWire() );
1659 SCH_ITEM* wireDriver = wireConnection->Driver();
1661 if( wireDriver && wireDriver->
IsType( { SCH_LABEL_T, SCH_GLOBAL_LABEL_T } ) )
1662 return wireConnection->LocalName();
1665 return wxEmptyString;
1670 std::list<std::unique_ptr<SCH_LABEL_BASE>>& aLabelList )
1672 SCHEMATIC* schematic = getModel<SCHEMATIC>();
1691 labelItem->
GetFields().emplace_back( labelItem, FIELD_T::USER, wxT(
"Netclass" ) );
1692 labelItem->
GetFields().emplace_back( labelItem, FIELD_T::USER, wxT(
"Component Class" ) );
1693 labelItem->
GetFields().back().SetItalic(
true );
1694 labelItem->
GetFields().back().SetVisible(
true );
1708 labelItem = globalLabel;
1716 wxFAIL_MSG(
"SCH_EDIT_FRAME::CreateNewText() unknown layer type" );
1734 if( !netName.IsEmpty() )
1737 labelItem->
SetText( netName );
1772 if( aLabelList.empty() )
1773 aLabelList.push_back( std::unique_ptr<SCH_LABEL_BASE>( labelItem ) );
1783 SCHEMATIC* schematic = getModel<SCHEMATIC>();
1787 textItem =
new SCH_TEXT( aPosition );
1822 pin->SetText( std::to_string( aSheet->
GetPins().size() + 1 ) );
1824 pin->SetPosition( aPosition );
1825 pin->ClearSelected();
1849 bool ignorePrimePosition =
false;
1852 wxString description;
1883 else if( isGlobalLabel )
1885 else if( isNetLabel )
1887 else if( isClassLabel )
1889 else if( isHierLabel )
1895 auto updatePreview =
1904 RECURSE_MODE::NO_RECURSE );
1917 auto prepItemForPlacement =
1949 && ( isText || isGlobalLabel || isHierLabel || isClassLabel || isNetLabel ) )
1952 ignorePrimePosition =
true;
1956 std::list<std::unique_ptr<SCH_LABEL_BASE>> itemsToPlace;
1963 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1966 cursorPos =
grid.BestSnapAnchor( cursorPos, snapGrid, item );
1970 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition() && evt->
Matches( aEvent );
1972 if( evt->IsCancelInteractive() || evt->IsAction( &
ACTIONS::undo ) )
1986 else if( evt->IsActivate() && !isSyntheticClick )
1988 if( item && evt->IsMoveTool() )
1991 evt->SetPassEvent(
false );
1998 evt->SetPassEvent(
false );
2002 if( evt->IsPointEditor() )
2006 else if( evt->IsMoveTool() )
2017 else if( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) || isSyntheticClick )
2028 description =
_(
"Add Text" );
2030 else if( isHierLabel )
2036 SCHEMATIC* schematic = getModel<SCHEMATIC>();
2047 itemsToPlace.push_back( std::unique_ptr<SCH_LABEL_BASE>( label ) );
2054 description =
_(
"Add Hierarchical Label" );
2056 else if( isNetLabel )
2059 description =
_(
"Add Label" );
2061 else if( isGlobalLabel )
2064 description =
_(
"Add Label" );
2066 else if( isClassLabel )
2069 description =
_(
"Add Label" );
2071 else if( isSheetPin )
2084 + wxPoint( 20, 20 ) );
2105 m_statusPopup->SetText(
_(
"No new hierarchical labels found." ) );
2107 + wxPoint( 20, 20 ) );
2119 description =
_(
"Add Sheet Pin" );
2125 if( evt->IsPrime() && !ignorePrimePosition )
2127 cursorPos =
grid.Align( evt->Position() );
2134 cursorPos =
grid.BestSnapAnchor( cursorPos, snapGrid, item );
2137 if( !itemsToPlace.empty() )
2139 item = itemsToPlace.front().release();
2140 itemsToPlace.pop_front();
2144 prepItemForPlacement( item, cursorPos );
2155 if( isSheetPin && sheet )
2170 commit.
Push( description );
2192 if( isSheetPin && sheet )
2199 m_statusPopup->SetText(
_(
"No new hierarchical labels found." ) );
2209 else if( !itemsToPlace.empty() )
2211 item = itemsToPlace.front().release();
2212 itemsToPlace.pop_front();
2213 prepItemForPlacement( item, cursorPos );
2225 else if( item && evt->IsSelectionEvent() )
2230 if( selection.
GetSize() == 1 )
2257 evt->SetPassEvent();
2279 evt->SetPassEvent();
2304 SCHEMATIC* schematic = getModel<SCHEMATIC>();
2309 wxString description;
2359 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2365 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition() && evt->
Matches( aEvent );
2367 if( evt->IsCancelInteractive() || ( item && evt->IsAction( &
ACTIONS::undo ) ) )
2379 else if( evt->IsActivate() && !isSyntheticClick )
2381 if( item && evt->IsMoveTool() )
2384 evt->SetPassEvent(
false );
2391 if( evt->IsPointEditor() )
2395 else if( evt->IsMoveTool() )
2406 else if( evt->IsClick(
BUT_LEFT ) && !item )
2429 description =
_(
"Add Text Box" );
2447 else if( item && ( evt->IsClick(
BUT_LEFT )
2493 commit.
Push( wxString::Format(
_(
"Draw %s" ), item->
GetClass() ) );
2515 evt->SetPassEvent();
2525 else if( evt->IsDblClick(
BUT_LEFT ) && !item )
2543 evt->SetPassEvent();
2572 bool started =
false;
2591 polyGeomMgr.
Reset();
2616 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2625 if( evt->IsCancelInteractive() )
2636 evt->SetPassEvent(
false );
2640 else if( evt->IsActivate() )
2645 if( evt->IsPointEditor() )
2649 else if( evt->IsMoveTool() )
2672 const bool endPolygon = evt->IsDblClick(
BUT_LEFT )
2679 polyGeomMgr.
Reset();
2686 else if( polyGeomMgr.
AddPoint( cursorPos ) )
2704 cursorPos = last.value();
2714 else if( started && ( evt->IsMotion() || evt->IsDrag(
BUT_LEFT ) ) )
2720 evt->SetPassEvent();
2734 SCHEMATIC* schematic = getModel<SCHEMATIC>();
2785 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2791 bool isSyntheticClick =
table && evt->IsActivate() && evt->HasPosition() && evt->Matches( aEvent );
2805 else if( evt->IsActivate() && !isSyntheticClick )
2807 if(
table && evt->IsMoveTool() )
2810 evt->SetPassEvent(
false );
2817 if( evt->IsPointEditor() )
2821 else if( evt->IsMoveTool() )
2837 table->SetColCount( 1 );
2843 table->AddCell( tableCell );
2845 table->SetParent( schematic );
2847 table->SetPosition( cursorPos );
2857 table->ClearEditFlags();
2868 commit.
Push(
_(
"Draw Table" ) );
2886 VECTOR2I requestedSize( cursorPos - origin );
2888 int colCount = std::max( 1, requestedSize.
x / ( fontSize * 15 ) );
2889 int rowCount = std::max( 1, requestedSize.
y / ( fontSize * 2 ) );
2891 VECTOR2I cellSize( std::max( gridSize.
x * 5, requestedSize.
x / colCount ),
2892 std::max( gridSize.
y * 2, requestedSize.
y / rowCount ) );
2894 cellSize.
x =
KiROUND( (
double) cellSize.
x / gridSize.
x ) * gridSize.
x;
2895 cellSize.
y =
KiROUND( (
double) cellSize.
y / gridSize.
y ) * gridSize.
y;
2897 table->ClearCells();
2898 table->SetColCount( colCount );
2900 for(
int col = 0; col < colCount; ++col )
2901 table->SetColWidth( col, cellSize.
x );
2903 for(
int row = 0; row < rowCount; ++row )
2905 table->SetRowHeight( row, cellSize.
y );
2907 for(
int col = 0; col < colCount; ++col )
2915 table->AddCell( cell );
2941 evt->SetPassEvent();
2961 std::unique_ptr<DESIGN_BLOCK> designBlock;
2966 if( isDrawSheetCopy )
2968 wxString* ptr = aEvent.
Parameter<wxString*>();
2975 else if( isDrawSheetFromDesignBlock )
2978 wxCHECK( designBlock, 0 );
2979 filename = designBlock->GetSchematicFile();
2982 if( ( isDrawSheetCopy || isDrawSheetFromDesignBlock ) && !wxFileExists( filename ) )
2984 wxMessageBox( wxString::Format(
_(
"File '%s' does not exist." ), filename ) );
3026 if( aEvent.
HasPosition() && !( isDrawSheetCopy || isDrawSheetFromDesignBlock ) )
3034 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3040 bool isSyntheticClick = sheet && evt->IsActivate() && evt->HasPosition()
3043 if( evt->IsCancelInteractive() || ( sheet && evt->IsAction( &
ACTIONS::undo ) ) )
3057 else if( evt->IsActivate() && !isSyntheticClick )
3059 if( sheet && evt->IsMoveTool() )
3062 evt->SetPassEvent(
false );
3069 evt->SetPassEvent(
false );
3073 if( evt->IsPointEditor() )
3077 else if( evt->IsMoveTool() )
3088 else if( !sheet && ( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) ) )
3092 if( selection.
Size() == 1
3101 else if( evt->IsDblClick(
BUT_LEFT ) )
3114 if( isDrawSheetCopy )
3116 wxFileName fn( filename );
3121 else if( isDrawSheetFromDesignBlock )
3123 wxFileName fn( filename );
3125 sheet->
GetField( FIELD_T::SHEET_NAME )->
SetText( designBlock->GetLibId().GetLibItemName() );
3128 std::vector<SCH_FIELD>& sheetFields = sheet->
GetFields();
3131 for(
const auto& [fieldName, fieldValue] : designBlock->GetFields() )
3133 sheetFields.emplace_back( sheet, FIELD_T::USER, fieldName );
3134 sheetFields.back().SetText( fieldValue );
3135 sheetFields.back().SetVisible(
false );
3140 sheet->
GetField( FIELD_T::SHEET_NAME )->
SetText( wxT(
"Untitled Sheet" ) );
3153 wxString pageNumber;
3157 pageNumber.Printf( wxT(
"%d" ),
static_cast<int>( hierarchy.size() ) + 1 );
3163 else if( sheet && ( evt->IsClick(
BUT_LEFT )
3173 nullptr, &filename ) )
3193 && !( ( isDrawSheetCopy || isDrawSheetFromDesignBlock )
3206 c.
Push( isDrawSheetCopy ?
"Import Sheet Copy" :
"Draw Sheet" );
3231 evt->SetPassEvent();
3255 evt->SetPassEvent();
3286 if( !sheetPaths.size() )
3290 m_frame, std::move( sheetPaths ),
3291 std::make_shared<SHEET_SYNCHRONIZATION_AGENT>(
3301 commit.
Push(
_(
"Modify sheet pin" ) );
3307 commit.
Push(
_(
"Modify schematic item" ) );
3318 selectionTool->AddItemToSel( aItem,
true );
3323 std::set<EDA_ITEM*> aTemplates )
3395 if( labels.empty() )
3399 m_statusPopup->SetText(
_(
"No new hierarchical labels found." ) );
3413 SCH_ITEM* lastPlacedLabel =
nullptr;
3415 auto calculatePositionForLabel =
3426 int currentWidth = currentLabel->GetBoundingBox().GetWidth();
3427 int currentHeight = currentLabel->GetBoundingBox().GetHeight();
3431 return { lastX + lastWidth, lastY };
3442 if( !lastPlacedLabel )
3444 std::vector<SCH_SHEET_PIN*> existingPins = sheet->
GetPins();
3446 if( !existingPins.empty() )
3448 std::sort( existingPins.begin(), existingPins.end(),
3451 return ( a->GetPosition().x < b->GetPosition().x )
3452 || ( a->GetPosition().x == b->GetPosition().x
3453 && a->GetPosition().y < b->GetPosition().y );
3456 lastPlacedLabel = existingPins.back();
3460 cursorPos = calculatePositionForLabel( lastPlacedLabel, label );
3477 commit.
Push(
_(
"Add Sheet Pin" ) );
3479 lastPlacedLabel = item;
3489 static const std::function<void( std::list<SCH_SHEET_PATH>&,
SCH_SCREEN*, std::set<SCH_SCREEN*>&,
3491 []( std::list<SCH_SHEET_PATH>& aPaths,
SCH_SCREEN* aScene, std::set<SCH_SCREEN*>& aVisited,
3494 if( ! aScene || aVisited.find(aScene) != aVisited.end() )
3497 std::vector<SCH_ITEM*> sheetChildren;
3498 aScene->GetSheets( &sheetChildren );
3499 aVisited.insert( aScene );
3501 for(
SCH_ITEM* child : sheetChildren )
3506 aPaths.push_back( cp );
3507 getSheetChildren( aPaths, sheet->
GetScreen(), aVisited, cp );
3511 std::list<SCH_SHEET_PATH> sheetPaths;
3512 std::set<SCH_SCREEN*> visited;
3517 if( sheetPaths.size() == 0 )
3532 std::vector<SCH_HIERLABEL*> labels;
3537 labels.push_back( label );
3540 std::sort( labels.begin(), labels.end(),
3543 return StrNumCmp( label1->GetText(), label2->GetText(), true ) < 0;
3548 if( !aSheet->
HasPin( label->GetText() ) )
3561 std::vector<SCH_HIERLABEL*> labels;
3568 labels.push_back( label );
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION duplicate
static TOOL_ACTION activatePointEditor
static TOOL_ACTION doDelete
static TOOL_ACTION increment
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)
PANEL_DESIGN_BLOCK_CHOOSER m_DesignBlockChooserPanel
constexpr const Vec & GetPosition() const
constexpr size_type GetWidth() const
constexpr size_type GetHeight() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const SizeVec & GetSize() const
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
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.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
DESIGN_BLOCK * GetDesignBlock(const LIB_ID &aLibId, bool aUseCacheLib, bool aShowErrorMsg)
Load design block from design block library table.
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
bool IsPlacementInteractive()
void SetLabelList(std::list< std::unique_ptr< SCH_LABEL_BASE > > *aLabelList)
FIELDS_GRID_TABLE * GetFieldsGridTable()
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 VECTOR2I GetPosition() const
virtual void ClearEditFlags()
virtual void SetPosition(const VECTOR2I &aPos)
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
EDA_ITEM_FLAGS GetEditFlags() const
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 wxString GetFriendlyName() const
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
void SetEnd(const VECTOR2I &aEnd)
const EDA_ANGLE & GetTextAngle() const
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
virtual void SetVisible(bool aVisible)
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
GR_TEXT_V_ALIGN_T GetVertJustify() const
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
PANEL_ANNOTATE m_AnnotatePanel
AUTOPLACE_FIELDS m_AutoplaceFields
EE_TYPE Overlapping(const BOX2I &aRect) const
EE_TYPE OfType(KICAD_T aType) const
A color representation with 4 components: red, green, blue, alpha.
void Update(const KIGFX::VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
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 Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
void RecacheAllItems()
Rebuild GAL display lists.
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
bool IsValid() const
Check if this LID_ID is valid.
Define a library symbol object.
wxString GetDescription() const override
const LIB_ID & GetLibId() const override
wxString GetKeyWords() const override
void SetDescription(const wxString &aDescription)
Gets the Description field text value */.
void SetKeyWords(const wxString &aKeyWords)
bool IsLocalPower() const override
bool IsGlobalPower() const override
A singleton reporter that reports to nowhere.
virtual COMMON_SETTINGS * GetCommonSettings() const
Class that handles the drawing of a polygon, including management of last corner deletion and drawing...
bool AddPoint(const VECTOR2I &aPt)
Lock in a polygon point.
@ DIRECT
Unconstrained point-to-point.
void SetCursorPosition(const VECTOR2I &aPos)
Set the current cursor position.
bool NewPointClosesOutline(const VECTOR2I &aPt) const
std::optional< VECTOR2I > DeleteLastCorner()
Remove the last-added point from the polygon.
void SetFinished()
Mark the polygon finished and update the client.
void SetLeaderMode(LEADER_MODE aMode)
Set the leader mode to use when calculating the leader/returner lines.
void Reset()
Clear the manager state and start again.
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
static SYMBOL_LIBS * SchLibs(PROJECT *aProject)
These are all prefaced with "Sch".
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
An adjunct helper to the DRAWING_TOOL interactive tool, which handles incoming geometry changes from ...
These are loaded from Eeschema settings but then overwritten by the project settings.
std::shared_ptr< REFDES_TRACKER > m_refDesTracker
A list of previously used schematic reference designators.
bool m_IntersheetRefsShow
Holds all the data relating to one schematic.
void CleanUp(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
SCHEMATIC_SETTINGS & Settings() const
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
bool Contains(const SCH_REFERENCE &aRef) const
Check if the schematic contains the specified reference.
static TOOL_ACTION rotateCCW
static TOOL_ACTION placeClassLabel
static TOOL_ACTION placeSheetPin
static TOOL_ACTION placeNextSymbolUnit
static TOOL_ACTION mirrorV
static TOOL_ACTION drawSheetFromFile
static TOOL_ACTION placeGlobalLabel
static TOOL_ACTION drawTextBox
static TOOL_ACTION syncAllSheetsPins
static TOOL_ACTION closeOutline
static TOOL_ACTION drawArc
static TOOL_ACTION drawSheet
static TOOL_ACTION properties
static TOOL_ACTION leaveSheet
static TOOL_ACTION autoplaceAllSheetPins
static TOOL_ACTION drawRectangle
static TOOL_ACTION placeHierLabel
static TOOL_ACTION placeLabel
static TOOL_ACTION drawCircle
static TOOL_ACTION importGraphics
static TOOL_ACTION placeBusWireEntry
static TOOL_ACTION drawBezier
static TOOL_ACTION rotateCW
static TOOL_ACTION importSheet
static TOOL_ACTION placeJunction
static TOOL_ACTION drawRuleArea
static TOOL_ACTION placeSymbol
static TOOL_ACTION placeImage
static TOOL_ACTION deleteLastPoint
static TOOL_ACTION drawSheetFromDesignBlock
static TOOL_ACTION mirrorH
static TOOL_ACTION placeDesignBlock
static TOOL_ACTION drawTable
static TOOL_ACTION placeSchematicText
static TOOL_ACTION changeSheet
static TOOL_ACTION enterSheet
static TOOL_ACTION repeatDrawItem
static TOOL_ACTION placeNoConnect
static TOOL_ACTION syncSheetPins
static TOOL_ACTION placePower
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PICKED_SYMBOL PickSymbolFromLibrary(const SYMBOL_LIBRARY_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, std::vector< PICKED_SYMBOL > &aAlreadyPlaced, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Call the library viewer to select symbol to import into schematic.
void SyncView()
Mark all items for refresh.
EESCHEMA_SETTINGS * eeconfig() const
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr) override
Add an item to the screen (and view) aScreen is the screen the item is located on,...
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, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Class for a wire to bus entry.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
Schematic editor (Eeschema) main window.
SCH_DESIGN_BLOCK_PANE * GetDesignBlockPane() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aCurrentSheet, const wxString &aFileName, bool aSkipRecursionCheck=false, bool aSkipLibCheck=false)
Load a the KiCad schematic file aFileName into the sheet aSheet.
void AnnotateSymbols(SCH_COMMIT *aCommit, ANNOTATE_SCOPE_T aAnnotateScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, bool aRecursive, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, REPORTER &aReporter)
Annotate the symbols in the schematic that are not currently annotated.
void HardRedraw() override
Rebuild the GAL and redraw the screen.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
bool EditSheetProperties(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aIsUndoable=nullptr, bool *aClearAnnotationNewItems=nullptr, bool *aUpdateHierarchyNavigator=nullptr, wxString *aSourceSheetFilename=nullptr)
Edit an existing sheet or add a new sheet to the schematic.
void UpdateHierarchyNavigator(bool aRefreshNetNavigator=true, bool aClear=false)
Update the hierarchy navigation tree and history.
void FlipBodyStyle(SCH_SYMBOL *aSymbol)
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SelectUnit(SCH_SYMBOL *aSymbol, int aUnit)
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it).
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void SetText(const wxString &aText) override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this label.
A set of SCH_ITEMs (i.e., without duplicates).
void SetSpinStyle(SPIN_STYLE aSpinStyle) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
virtual void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo)
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
virtual void SetUnit(int aUnit)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
SPIN_STYLE GetSpinStyle() const
void SetShape(LABEL_FLAG_SHAPE aShape)
LABEL_FLAG_SHAPE GetShape() const
void SetAutoRotateOnPlacement(bool autoRotate=true)
std::vector< SCH_FIELD > & GetFields()
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
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
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 SetRefDesTracker(std::shared_ptr< REFDES_TRACKER > aTracker)
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()
Get 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
Indicate that a junction dot may be placed at the given location.
void SetPosition(const VECTOR2I &aPos) override
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void EndEdit(bool aClosed=false) override
End an object editing action.
void SetStroke(const STROKE_PARAMS &aStroke) override
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
wxString GetClass() const override
Return the class name.
STROKE_PARAMS GetStroke() const override
VECTOR2I GetPosition() 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()
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetBorderColor(KIGFX::COLOR4D aColor)
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
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()
Return a reference to the vector holding the sheet's fields.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
void SetBackgroundColor(KIGFX::COLOR4D aColor)
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
bool HasPin(const wxString &aName) const
Check 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.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetBorderWidth(int aWidth)
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
void Resize(const VECTOR2I &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
std::vector< SCH_SHEET_PIN * > & GetPins()
const LIB_ID & GetLibId() const override
bool IsMulti() const override
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
RAII class that sets an value at construction and resets it to the original value at destruction.
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
virtual void Add(EDA_ITEM *aItem)
VECTOR2I GetReferencePoint() const
virtual unsigned int GetSize() const override
Return the number of stored items.
virtual void Clear() override
Remove all the stored items from the group.
int Size() const
Returns the number of selected parts.
SHEET_SYNCHRONIZATION_PLACEMENT
std::function< void()> MODIFICATION
Helper object to filter a list of libraries.
SYMBOL_LIB * GetCacheLibrary()
Object used to load, save, search, and otherwise manipulate symbol library files.
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
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
#define IGNORE_PARENT_GROUP
#define IS_NEW
New item, just created.
#define STRUCT_DELETED
flag indication structures to be erased
#define ENDPOINT
ends. (Used to support dragging.)
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define IS_MOVING
Item being moved.
#define STARTPOINT
When a line is selected, these flags indicate which.
@ ID_POPUP_SCH_SELECT_UNIT
@ ID_POPUP_SCH_SELECT_BASE
@ ID_POPUP_SCH_SELECT_ALT
@ ID_POPUP_SCH_SELECT_UNIT_END
static const std::string KiCadSchematicFileExtension
static wxString KiCadSchematicFileWildcard()
PGM_BASE & Pgm()
The global program "get" accessor.
LIB_SYMBOL * SchGetLibSymbol(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, SYMBOL_LIB *aCacheLib, wxWindow *aParent, bool aShowErrorMsg)
Load symbol from symbol library table.
Class to handle a set of SCH_ITEMs.
ANNOTATE_ORDER_T
Schematic annotation order options.
@ ANNOTATE_SELECTION
Annotate the selection.
ANNOTATE_ALGO_T
Schematic annotation type options.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
LINE_STYLE
Dashed line types.
constexpr int MilsToIU(int mils) const
COLOR4D default_sheet_border_color
COLOR4D default_sheet_background_color
int default_line_thickness
POWER_SYMBOLS new_power_symbols
SCH_SYMBOL * m_Symbol
< Provide a symbol to place
Definition for symbol library class.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I
Definition of file extensions used in Kicad.