70 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
88 commit = &localCommit;
90 std::vector<EDA_ITEM*> sorted =
selection.GetItemsSortedBySelectionOrder();
96 for(
size_t i = 0; i < sorted.size() - 1; i++ )
99 EDA_ITEM* edaItemB = sorted[( i + 1 ) % sorted.size()];
109 std::swap( aPos, bPos );
132 std::swap( aAngle, bAngle );
142 std::swap( aLayer, bLayer );
148 if( !localCommit.
Empty() )
149 localCommit.
Push(
_(
"Swap" ) );
174 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
179 aCollector.
Remove( item );
185 std::vector<FOOTPRINT*> footprintsToPack;
188 footprintsToPack.push_back(
static_cast<FOOTPRINT*
>( item ) );
190 if( footprintsToPack.empty() )
193 BOX2I footprintsBbox;
199 footprintsBbox.
Merge( fp->GetBoundingBox(
false ) );
205 commit.
Push(
_(
"Pack Footprints" ) );
242 localCommit.
Push(
_(
"Move" ) );
259 typedef std::numeric_limits<int> coord_limits;
261 static const double max = coord_limits::max() - (int)
COORDS_PADDING;
262 static const double min = -max;
265 testBox.
Offset( aBBoxOffset );
274 testBox.
Offset( aMovement );
282 if( testBox.
GetTop() < min )
303 std::unique_ptr<STATUS_TEXT_POPUP> statusPopup;
329 controls->ForceCursorPosition(
false );
331 auto displayConstraintsMessage =
332 [editFrame](
bool constrained )
335 : wxString( wxT(
"" ) ) );
338 auto updateStatusPopup =
339 [&](
EDA_ITEM* item,
size_t ii,
size_t count )
341 wxString popuptext =
_(
"Click to place %s (item %zu of %zu)\n"
342 "Press <esc> to cancel all; double-click to finish" );
354 msg = wxString::Format(
_(
"%s pad %s" ), fp->
GetReference(),
pad->GetNumber() );
362 statusPopup = std::make_unique<STATUS_TEXT_POPUP>(
frame() );
364 statusPopup->SetText( wxString::Format( popuptext, msg, ii, count ) );
367 std::vector<BOARD_ITEM*> sel_items;
368 std::vector<BOARD_ITEM*> orig_items;
377 orig_items.push_back( boardItem );
379 sel_items.push_back( boardItem );
387 sel_items.push_back(
pad );
397 if( moveWithReference && !
pickReferencePoint(
_(
"Select reference point for move..." ),
"",
"",
398 pickedReferencePoint ) )
403 editFrame->
PopTool( pushedEvent );
407 if( moveIndividually )
414 orig_items.push_back(
static_cast<BOARD_ITEM*
>( item ) );
417 updateStatusPopup( orig_items[ itemIdx ], itemIdx + 1, orig_items.size() );
418 statusPopup->Popup();
420 canvas()->SetStatusPopup( statusPopup->GetPanel() );
426 sel_items.push_back( orig_items[ itemIdx ] );
429 bool restore_state =
false;
433 bool updateBBox =
true;
439 bool enableLocalRatsnest =
true;
442 bool eatFirstMouseUp =
true;
447 std::unique_ptr<DRC_INTERACTIVE_COURTYARD_CLEARANCE> drc_on_move =
nullptr;
449 if( showCourtyardConflicts )
451 std::shared_ptr<DRC_ENGINE> drcEngine =
m_toolMgr->GetTool<
DRC_TOOL>()->GetDRCEngine();
453 drc_on_move->Init(
board );
456 displayConstraintsMessage( hv45Mode );
472 eatFirstMouseUp =
false;
485 bool redraw3D =
false;
491 if(
controls->GetSettings().m_lastKeyboardCursorPositionValid )
493 grid.SetSnap(
false );
494 grid.SetUseGrid(
false );
510 originalBBox =
BOX2I();
529 bboxMovement += movement;
536 item->Move( movement );
548 if( redraw3D && allowRedraw3D )
551 if( showCourtyardConflicts && drc_on_move->m_FpInMove.size() )
554 drc_on_move->UpdateConflicts(
m_toolMgr->GetView(),
true );
575 enableLocalRatsnest =
false;
588 static_cast<PCB_SHAPE*
>( item )->UpdateHatching();
596 static_cast<PCB_SHAPE*
>( child )->UpdateHatching();
607 grid.SetAuxAxes(
false );
634 if( showCourtyardConflicts )
636 std::vector<FOOTPRINT*>& FPs = drc_on_move->m_FpInMove;
641 FPs.push_back(
static_cast<FOOTPRINT*
>( item ) );
647 FPs.push_back(
static_cast<FOOTPRINT*
>( child ) );
660 if( moveWithReference )
662 selection.SetReferencePoint( pickedReferencePoint );
663 controls->ForceCursorPosition(
true, pickedReferencePoint );
683 grid.SetAuxAxes(
true, snapped );
691 originalPos =
selection.GetReferencePoint();
707 if( enableLocalRatsnest )
715 restore_state =
true;
724 restore_state =
true;
744 eatFirstMouseUp =
false;
752 eatFirstMouseUp =
false;
759 orig_items[itemIdx]->SetPosition( originalPos );
761 view()->Update( orig_items[itemIdx] );
764 if( ++itemIdx < orig_items.size() )
772 selection.SetReferencePoint( originalPos );
775 sel_items.push_back( nextItem );
776 updateStatusPopup( nextItem, itemIdx + 1, orig_items.size() );
791 if( moveIndividually )
792 orig_items[itemIdx]->SetPosition( originalPos );
799 displayConstraintsMessage( hv45Mode );
824 }
while( ( evt =
Wait() ) );
827 if( showCourtyardConflicts )
828 drc_on_move->ClearConflicts(
m_toolMgr->GetView() );
830 controls->ForceCursorPosition(
false );
845 if( sel_items.size() == 1 && sel_items.back()->Type() ==
PCB_GENERATOR_T )
853 if( sel_items.size() == 1 && sel_items.back()->Type() ==
PCB_GENERATOR_T )
859 EDA_ITEMS oItems( orig_items.begin(), orig_items.end() );
866 editFrame->
PopTool( pushedEvent );
869 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.
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
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.
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.
An interface for classes handling user events controlling the view behavior such as zooming,...
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 genFinishEdit
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 genCancelEdit
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
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.
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.
@ DIRECT
Unconstrained point-to-point.
PCB_LAYER_ID
A quick note on layer IDs:
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Class to handle a set of BOARD_ITEMs.
@ 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
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D