28 #include <wx/gdicmn.h> 29 #include <wx/string.h> 30 #include <wx/stringimpl.h> 31 #include <wx/translation.h> 122 if( !connection || !connection->
IsBus() || connection->
Members().empty() )
137 for(
const auto& member : connection->
Members() )
140 wxString
name = member->FullLocalName();
148 for(
const auto& sub_member : member->Members() )
151 name = sub_member->FullLocalName();
157 Append(
id,
name, wxEmptyString );
196 auto belowRootSheetCondition =
211 ctxMenu.AddSeparator( 10 );
219 std::shared_ptr<BUS_UNFOLD_MENU> busUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
220 busUnfoldMenu->SetTool(
this );
224 ctxMenu.AddSeparator( 100 );
232 ctxMenu.AddSeparator( 200 );
240 std::shared_ptr<BUS_UNFOLD_MENU> selBusUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
303 wxString* netPtr = aEvent.
Parameter<wxString*>();
330 if(
id && ( *
id > 0 ) )
331 net = *evt->Parameter<wxString*>();
365 if( aPos == wxDefaultPosition )
396 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
400 if( pin->GetPosition() == aPosition )
412 wxCHECK_RET( aSegments.first && aSegments.second,
413 wxT(
"Cannot compute break point of NULL line segment." ) );
415 SCH_LINE* segment = aSegments.first;
416 SCH_LINE* next_segment = aSegments.second;
430 aPosition.x +=
KiROUND(
getView()->GetGAL()->GetGridSize().x * direction );
433 midPoint.x = aPosition.x;
439 midPoint.y = aPosition.y;
443 midPoint.x = aPosition.x;
452 midPoint.y = aPosition.y;
456 midPoint.x = aPosition.x;
503 wxPoint contextMenuPos;
522 wxPoint cursorPos = static_cast<wxPoint>( evt->HasPosition() ?
562 if( evt->IsCancelInteractive() )
572 else if( evt->IsActivate() )
577 if( evt->IsMoveTool() )
611 else if( evt->IsClick(
BUT_LEFT ) || ( segment && evt->IsDblClick(
BUT_LEFT ) ) )
657 if( evt->IsDblClick(
BUT_LEFT ) && segment )
659 if( forceHV &&
m_wires.size() >= 2 )
685 bool flipX = ( cursor_delta.x < 0 );
686 bool flipY = ( cursor_delta.y < 0 );
691 wxSize size = entry->
GetSize();
692 int ySign = flipY ? -1 : 1;
693 int xSign = flipX ? -1 : 1;
695 size.x = std::abs( size.x ) * xSign;
696 size.y = std::abs( size.y ) * ySign;
718 if( forceHV &&
m_wires.size() >= 2 )
726 if( !wire->IsNull() )
739 contextMenuPos = cursorPos;
747 wxASSERT_MSG( !segment,
"Bus unfold event received when already drawing!" );
750 wxString net = *evt->Parameter<wxString*>();
865 std::vector< wxPoint > new_ends;
873 std::vector<wxPoint> tmpends = wire->GetConnectionPoints();
875 new_ends.insert( new_ends.end(), tmpends.begin(), tmpends.end() );
877 for(
const wxPoint& pt : connections )
880 new_ends.push_back( pt );
917 std::vector<SCH_ITEM*> components;
920 components.push_back( item );
924 std::vector<wxPoint> pts = item->GetConnectionPoints();
929 for(
auto pt = pts.begin(); pt != pts.end(); pt++ )
931 for(
auto secondPt = pt + 1; secondPt != pts.end(); secondPt++ )
936 for(
const wxPoint& pt : new_ends )
956 std::vector<wxPoint> pts;
959 for(
unsigned ii = 0; ii < aSelection->
GetSize(); ii++ )
967 pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
975 for(
const wxPoint& pt : connections )
984 for(
auto pt = new_pts.begin(); pt != new_pts.end(); pt++ )
986 for(
auto secondPt = pt + 1; secondPt != new_pts.end(); secondPt++ )
993 std::sort( pts.begin(), pts.end(),
994 [](
const wxPoint& a,
const wxPoint& b ) ->
bool 996 return a.x < b.x || ( a.x == b.x && a.y < b.y );
999 pts.erase( unique( pts.begin(), pts.end() ), pts.end() );
1001 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)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
SHEET_SIDE
Defines the edge of the sheet that the sheet pin is positioned SHEET_LEFT_SIDE = 0: pin on left side ...
virtual bool IsConnectable() const
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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)
Generates the connection data for the entire schematic hierarchy.
wxPoint GetStartPoint() const
void SetSize(const wxSize &aSize)
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
const BITMAP_OPAQUE add_line2bus_xpm[1]
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...
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
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.
EE_TYPE Overlapping(const EDA_RECT &aRect)
static TOOL_ACTION unfoldBus
static TOOL_ACTION finishLineWireOrBus
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,...
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, int aLayer, SCH_ITEM *aDraggedItem)
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
SHEET_SIDE GetEdge() const
Schematic editor (Eeschema) main window.
void SetTextSize(const wxSize &aNewSize)
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
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
void ClearMaskFlag(int aFlag)
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.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
wxPoint origin
Origin (on the bus) of the unfold.
void SetFlags(STATUS_FLAGS aMask)
VECTOR2< double > VECTOR2D
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
static TOOL_ACTION drawWire
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.
SCHEMATIC & Schematic() const
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
std::vector< wxPoint > GetSchematicConnections()
Collects 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,...
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.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
wxPoint GetPosition() const override
#define IS_MOVED
Item being moved.
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
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.
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
std::vector< SCH_SHEET_PIN * > & GetPins()
static bool m_allowRealTime
static TOOL_ACTION placeLabel
bool IsTerminalPoint(const wxPoint &aPosition, int aLayer)
Test if aPosition is a connection point on aLayer.
void SetUseGrid(bool aSnapToGrid)
Board layer functions and definitions.
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,...
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.
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
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".
These settings were stored in SCH_BASE_FRAME previously.
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
Class for a wire to bus entry.
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.
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.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
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,...
#define IS_NEW
New item, just created.
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