72 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
74 BOARD_ITEM* item = aCollector[i];
76 if( item->Type() == PCB_TRACE_T )
77 aCollector.Remove( item );
82 if( selection.
Size() < 2 )
89 commit = &localCommit;
96 if( !item->IsNew() && !item->IsMoving() )
97 commit->
Modify( item,
nullptr, RECURSE_MODE::RECURSE );
100 for(
size_t i = 0; i < sorted.size() - 1; i++ )
103 EDA_ITEM* edaItemB = sorted[( i + 1 ) % sorted.size()];
113 std::swap( aPos, bPos );
131 aFP->
Flip( aPos, FLIP_DIRECTION::TOP_BOTTOM );
132 bFP->
Flip( bPos, FLIP_DIRECTION::TOP_BOTTOM );
136 std::swap( aAngle, bAngle );
146 std::swap( aLayer, bLayer );
152 if( !localCommit.
Empty() )
153 localCommit.
Push(
_(
"Swap" ) );
178 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
180 BOARD_ITEM* item = aCollector[i];
182 if( !dynamic_cast<FOOTPRINT*>( item ) )
183 aCollector.Remove( item );
188 std::vector<FOOTPRINT*> footprintsToPack;
191 footprintsToPack.push_back(
static_cast<FOOTPRINT*
>( item ) );
193 if( footprintsToPack.empty() )
196 BOX2I footprintsBbox;
202 footprintsBbox.
Merge( fp->GetBoundingBox(
false ) );
208 commit.
Push(
_(
"Pack Footprints" ) );
245 localCommit.
Push(
_(
"Move" ) );
262 typedef std::numeric_limits<int> coord_limits;
264 static const double max = coord_limits::max() - (int)
COORDS_PADDING;
265 static const double min = -max;
268 testBox.
Offset( aBBoxOffset );
277 testBox.
Offset( aMovement );
285 if( testBox.
GetTop() < min )
306 std::unique_ptr<STATUS_TEXT_POPUP> statusPopup;
334 auto displayConstraintsMessage =
335 [editFrame](
bool constrained )
338 : wxString( wxT(
"" ) ) );
341 auto updateStatusPopup =
342 [&](
EDA_ITEM* item,
size_t ii,
size_t count )
344 wxString popuptext =
_(
"Click to place %s (item %zu of %zu)\n"
345 "Press <esc> to cancel all; double-click to finish" );
357 msg = wxString::Format(
_(
"%s pad %s" ), fp->
GetReference(),
pad->GetNumber() );
365 statusPopup = std::make_unique<STATUS_TEXT_POPUP>(
frame() );
367 statusPopup->SetText( wxString::Format( popuptext, msg, ii, count ) );
370 std::vector<BOARD_ITEM*> sel_items;
371 std::vector<BOARD_ITEM*> orig_items;
380 orig_items.push_back( boardItem );
382 sel_items.push_back( boardItem );
390 sel_items.push_back(
pad );
400 if( moveWithReference && !
pickReferencePoint(
_(
"Select reference point for move..." ),
"",
"",
401 pickedReferencePoint ) )
406 editFrame->
PopTool( pushedEvent );
410 if( moveIndividually )
417 orig_items.push_back(
static_cast<BOARD_ITEM*
>( item ) );
420 updateStatusPopup( orig_items[ itemIdx ], itemIdx + 1, orig_items.size() );
421 statusPopup->Popup();
429 sel_items.push_back( orig_items[ itemIdx ] );
432 bool restore_state =
false;
436 bool updateBBox =
true;
442 bool enableLocalRatsnest =
true;
444 bool hv45Mode =
false;
445 bool eatFirstMouseUp =
true;
450 std::unique_ptr<DRC_INTERACTIVE_COURTYARD_CLEARANCE> drc_on_move =
nullptr;
452 if( showCourtyardConflicts )
456 drc_on_move->Init( board );
459 displayConstraintsMessage( hv45Mode );
475 eatFirstMouseUp =
false;
488 bool redraw3D =
false;
493 grid.GetSelectionGrid( selection ), sel_items );
497 grid.SetSnap(
false );
498 grid.SetUseGrid(
false );
502 grid.GetSelectionGrid( selection ), sel_items );
515 originalBBox =
BOX2I();
534 bboxMovement += movement;
541 item->Move( movement );
553 if( redraw3D && allowRedraw3D )
556 if( showCourtyardConflicts && drc_on_move->m_FpInMove.size() )
580 enableLocalRatsnest =
false;
587 aCommit->
Modify( item,
nullptr, RECURSE_MODE::RECURSE );
593 static_cast<PCB_SHAPE*
>( item )->UpdateHatching();
601 static_cast<PCB_SHAPE*
>( child )->UpdateHatching();
603 RECURSE_MODE::RECURSE );
612 grid.SetAuxAxes(
false );
635 selection.SetReferencePoint(
m_cursor );
639 if( showCourtyardConflicts )
641 std::vector<FOOTPRINT*>& FPs = drc_on_move->m_FpInMove;
646 FPs.push_back(
static_cast<FOOTPRINT*
>( item ) );
652 FPs.push_back(
static_cast<FOOTPRINT*
>( child ) );
654 RECURSE_MODE::RECURSE );
660 m_cursor =
grid.BestDragOrigin( originalMousePos, sel_items,
661 grid.GetSelectionGrid( selection ),
666 if( moveWithReference )
698 if( enableLocalRatsnest )
706 restore_state =
true;
715 restore_state =
true;
729 eatFirstMouseUp =
false;
737 eatFirstMouseUp =
false;
744 orig_items[itemIdx]->SetPosition( originalPos );
749 if( ++itemIdx < orig_items.size() )
760 sel_items.push_back( nextItem );
761 updateStatusPopup( nextItem, itemIdx + 1, orig_items.size() );
764 aCommit->
Modify( nextItem,
nullptr, RECURSE_MODE::RECURSE );
776 if( moveIndividually )
777 orig_items[itemIdx]->SetPosition( originalPos );
783 hv45Mode = !hv45Mode;
784 displayConstraintsMessage( hv45Mode );
807 }
while( ( evt =
Wait() ) );
810 if( showCourtyardConflicts )
828 if( sel_items.size() == 1 && sel_items.back()->Type() ==
PCB_GENERATOR_T )
836 if( sel_items.size() == 1 && sel_items.back()->Type() ==
PCB_GENERATOR_T )
842 EDA_ITEMS oItems( orig_items.begin(), orig_items.end() );
849 editFrame->
PopTool( pushedEvent );
852 return !restore_state;
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION duplicate
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION increment
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION refreshPreview
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
constexpr const Vec & GetPosition() const
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr coord_type GetLeft() const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr const SizeVec & GetSize() const
constexpr coord_type GetTop() const
constexpr void Offset(coord_type dx, coord_type dy)
constexpr coord_type GetBottom() const
int GetCount() const
Return the number of objects in the list.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
void DisplayConstraintsMsg(const wxString &msg)
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
void SetStatusPopup(wxWindow *aPopup)
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
virtual void SetPosition(const VECTOR2I &aPos)
wxString GetTypeDesc() const
Return a translated description of the type for this EDA_ITEM for display in user facing messages.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
static const TOOL_EVENT SelectedEvent
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
Used when the right click button is pressed, or when the select tool is in effect.
virtual void Update(const 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 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.
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.
const VC_SETTINGS & GetSettings() const
Return the current VIEW_CONTROLS settings.
bool IsBOARD_ITEM() const
LSET is a set of PCB_LAYER_IDs.
DISPLAY_OPTIONS m_Display
bool m_ShowCourtyardCollisions
static TOOL_ACTION toggleHV45Mode
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION genPushEdit
static TOOL_ACTION hideLocalRatsnest
static TOOL_ACTION genStartEdit
static TOOL_ACTION moveWithReference
move with a reference point
static TOOL_ACTION moveExact
Activation of the exact move tool.
static TOOL_ACTION copyWithReference
copy command with manual reference point selection
static TOOL_ACTION positionRelativeInteractively
static TOOL_ACTION genUpdateEdit
static TOOL_ACTION updateLocalRatsnest
static TOOL_ACTION moveIndividually
move items one-by-one
static TOOL_ACTION positionRelative
static TOOL_ACTION move
move or drag an item
static TOOL_ACTION mirrorV
static TOOL_ACTION flip
Flipping of selected objects.
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
static TOOL_ACTION genRevertEdit
Common, abstract interface for edit frames.
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual PCB_LAYER_ID GetActiveLayer() const
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
VECTOR2I GetReferencePoint() const
int Size() const
Returns the number of selected parts.
std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
void ClearReferencePoint()
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
#define IS_MOVING
Item being moved.
a few functions useful in geometry calculations.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
PCB_LAYER_ID
A quick note on layer IDs:
Class to handle a set of BOARD_ITEMs.
bool m_lastKeyboardCursorPositionValid
Is last cursor motion event coming from keyboard arrow cursor motion action.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
VECTOR2< double > VECTOR2D