28 #include <wx/gdicmn.h> 29 #include <wx/string.h> 30 #include <wx/stringimpl.h> 31 #include <wx/translation.h> 123 if( !connection || !connection->
IsBus() || connection->
Members().empty() )
138 for(
const std::shared_ptr<SCH_CONNECTION>& member : connection->
Members() )
141 wxString
name = member->FullLocalName();
148 for(
const std::shared_ptr<SCH_CONNECTION>& sub_member : member->Members() )
151 name = sub_member->FullLocalName();
157 Append(
id,
name, wxEmptyString );
168 m_inDrawingTool( false )
197 auto belowRootSheetCondition =
212 ctxMenu.AddSeparator( 10 );
220 std::shared_ptr<BUS_UNFOLD_MENU> busUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
221 busUnfoldMenu->SetTool(
this );
225 ctxMenu.AddSeparator( 100 );
233 ctxMenu.AddSeparator( 200 );
241 std::shared_ptr<BUS_UNFOLD_MENU> selBusUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
314 wxString* netPtr = aEvent.
Parameter<wxString*>();
341 if(
id && ( *
id > 0 ) )
342 net = *evt->Parameter<wxString*>();
378 if( aPos == wxDefaultPosition )
409 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
413 if(
pin->GetPosition() == aPosition )
425 wxCHECK_RET( aSegments.first && aSegments.second,
426 wxT(
"Cannot compute break point of NULL line segment." ) );
428 SCH_LINE* segment = aSegments.first;
429 SCH_LINE* next_segment = aSegments.second;
443 aPosition.x +=
KiROUND(
getView()->GetGAL()->GetGridSize().x * direction );
446 midPoint.x = aPosition.x;
452 midPoint.y = aPosition.y;
456 midPoint.x = aPosition.x;
465 midPoint.y = aPosition.y;
469 midPoint.x = aPosition.x;
543 wxPoint contextMenuPos;
551 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
562 wxPoint cursorPos = static_cast<wxPoint>( evt->HasPosition() ?
575 if( !forceHV &&
m_wires.size() >= 2 && segment != nullptr )
585 else if( forceHV && segment )
590 segment = static_cast<SCH_LINE*>( segment->
Duplicate() );
603 if( evt->IsCancelInteractive() )
617 else if( evt->IsActivate() )
622 evt->SetPassEvent(
false );
626 if( evt->IsMoveTool() )
660 else if( evt->IsClick(
BUT_LEFT ) || ( segment && evt->IsDblClick(
BUT_LEFT ) ) )
697 segment = static_cast<SCH_LINE*>( segment->
Duplicate() );
706 if( evt->IsDblClick(
BUT_LEFT ) && segment )
708 if( forceHV &&
m_wires.size() >= 2 )
734 bool flipX = ( cursor_delta.x < 0 );
735 bool flipY = ( cursor_delta.y < 0 );
740 wxSize size = entry->
GetSize();
741 int ySign = flipY ? -1 : 1;
742 int xSign = flipX ? -1 : 1;
744 size.x = std::abs( size.x ) * xSign;
745 size.y = std::abs( size.y ) * ySign;
767 if( forceHV &&
m_wires.size() >= 2 )
775 if( !wire->IsNull() )
788 contextMenuPos = cursorPos;
796 wxASSERT_MSG( !segment, wxT(
"Bus unfold event received when already drawing!" ) );
799 wxString net = *evt->Parameter<wxString*>();
862 segment = static_cast<SCH_LINE*>( segment->
Duplicate() );
935 std::vector< wxPoint > new_ends;
943 std::vector<wxPoint> tmpends = wire->GetConnectionPoints();
945 new_ends.insert( new_ends.end(), tmpends.begin(), tmpends.end() );
947 for(
const wxPoint& pt : connections )
950 new_ends.push_back( pt );
987 std::vector<SCH_ITEM*> symbols;
990 symbols.push_back( symbol );
994 std::vector<wxPoint> pts = symbol->GetConnectionPoints();
999 for(
auto pt = pts.begin(); pt != pts.end(); pt++ )
1001 for(
auto secondPt = pt + 1; secondPt != pts.end(); secondPt++ )
1006 for(
const wxPoint& pt : new_ends )
1026 SCH_SCREEN* screen = sch->CurrentSheet().LastScreen();
1028 std::set<SCH_LINE*> lines;
1032 lines.insert( static_cast<SCH_LINE*>( item ) );
1034 for(
unsigned ii = 0; ii < aSelection->
GetSize(); ii++ )
1036 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSelection->
GetItem( ii ) );
1046 std::vector<wxPoint> conn_pts;
1048 for( wxPoint pt : pts )
1051 conn_pts.push_back( pt );
1053 if( conn_pts.size() > 2 )
1057 if( conn_pts.size() == 2 )
1070 std::vector<wxPoint> pts;
1073 std::set<SCH_LINE*> lines;
1077 lines.insert( static_cast<SCH_LINE*>( item ) );
1079 for(
unsigned ii = 0; ii < aSelection->
GetSize(); ii++ )
1081 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSelection->
GetItem( ii ) );
1087 pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
1095 for(
const wxPoint& pt : connections )
1098 pts.push_back( pt );
1104 std::sort( pts.begin(), pts.end(),
1105 [](
const wxPoint& a,
const wxPoint& b ) ->
bool 1107 return a.x < b.x || ( a.x == b.x && a.y < b.y );
1110 pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
1112 for(
const wxPoint& point : pts )
static wxString PrintBusForUI(const wxString &aString)
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
EE_TYPE OfType(KICAD_T aType) const
SCH_LINE * MergeOverlap(SCH_SCREEN *aScreen, SCH_LINE *aLine, bool aCheckJunctions)
Check line against aLine to see if it overlaps and merge if it does.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
virtual bool IsConnectable() const
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
bool flipY
True if the bus entry should be flipped in the y-axis.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
static TOOL_ACTION breakBus
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
wxPoint GetStartPoint() const
Holds all the data relating to one schematic.
void SetSize(const wxSize &aSize)
#define IS_NEW
New item, just created.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
static TOOL_ACTION doDelete
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
EDA_RECT GetBoundingBox() const override
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
bool IsTerminalPoint(const wxPoint &aPosition, int aLayer) const
Test if aPosition is a connection point on aLayer.
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static TOOL_ACTION placeHierLabel
static TOOL_ACTION placeJunction
static TOOL_ACTION selectConnection
If current selection is a wire or bus, expand to entire connection.
static TOOL_ACTION unfoldBus
static TOOL_ACTION finishLineWireOrBus
void SetFlags(EDA_ITEM_FLAGS aMask)
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
Schematic editor (Eeschema) main window.
void SetTextSize(const wxSize &aNewSize)
search types array terminator (End Of Types)
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)
static TOOL_ACTION breakWire
static TOOL_ACTION rotateCW
static TOOL_ACTION finishLine
void SetEndPoint(const wxPoint &aPosition)
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
void ShowPreview(bool aShow=true)
static TOOL_ACTION leaveSheet
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
EESCHEMA_SETTINGS * eeconfig() const
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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...
static TOOL_ACTION rotateCCW
static TOOL_ACTION trimOverlappingWires
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
#define IS_MOVING
Item being moved.
wxPoint origin
Origin (on the bus) of the unfold.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
VECTOR2< double > VECTOR2D
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
static TOOL_ACTION drawWire
SHEET_SIDE GetSide() const
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
void SetStartPoint(const wxPoint &aPosition)
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.
SCHEMATIC & Schematic() const
std::vector< wxPoint > GetSchematicConnections()
Collect a unique list of all possible connection points in the schematic.
An interface for classes handling user events controlling the view behavior such as zooming,...
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
static TOOL_ACTION clearSelection
Clears the current selection.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
A holder to handle information on schematic or board items.
static TOOL_ACTION addNeededJunctions
wxString net_name
Net label for the unfolding operation.
wxPoint GetPosition() const override
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
SCH_BUS_WIRE_ENTRY * entry
static TOOL_ACTION drawBus
EE_TYPE Overlapping(const EDA_RECT &aRect) const
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
virtual void Rotate90(bool aClockwise)
virtual unsigned int GetSize() const override
Return the number of stored items.
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
std::vector< SCH_SHEET_PIN * > & GetPins()
static bool m_allowRealTime
bool IsExplicitJunctionNeeded(const wxPoint &aPosition) const
Indicates that a junction dot is necessary at the given location, and does not yet exist.
static TOOL_ACTION placeLabel
#define SKIP_STRUCT
flag indicating that the structure should be ignored
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
Segment description base class to describe items which have 2 end points (track, wire,...
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
Handle the component boundary box.
static TOOL_ACTION selectNode
Select the junction, wire or bus segment under the cursor.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
A base class for most all the KiCad significant classes used in schematics and boards.
These settings were stored in SCH_BASE_FRAME previously.
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
Class for a wire to bus entry.
WX_INFOBAR * GetInfoBar()
SCH_SHEET_PATH & GetCurrentSheet() const
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
static TOOL_ACTION drawLines
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
bool label_placed
True if user has placed the net label.
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
static TOOL_ACTION placeGlobalLabel
static TOOL_ACTION finishBus
void SetPosition(const wxPoint &aPosition) override
bool flipX
True if the bus entry should be flipped in the x-axis.
Base class for any item which can be embedded within the SCHEMATIC container class,...
static TOOL_ACTION finishWire
static TOOL_ACTION refreshPreview
This item represents a bus vector.
bool in_progress
True if bus unfold operation is running.
KICAD_T Type() const
Returns the type of object.
wxPoint GetEndPoint() const