51#include <wx/hyperlink.h>
83 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
85 BOARD_ITEM* item = aCollector[i];
87 switch( item->Type() )
89 case PCB_TRACE_T: aCollector.Remove( item ); break;
97 if( selection.Size() < 2 )
103 if( IsFootprintEditor() )
105 m_commit->Modify( selection.Front() );
115 if( item->GetParent() && item->GetParent()->IsSelected() )
118 m_commit->Modify( item );
126 m_commit->Modify( bItem );
132 for(
size_t i = 0; i < sorted.size() - 1; i++ )
139 std::swap( aPos, bPos );
145 static_cast<PAD*
>( a )->SetLocalCoord();
160 aFP->
Flip( aPos,
false );
161 bFP->
Flip( bPos,
false );
166 std::swap( aAngle, bAngle );
176 std::swap( aLayer, bLayer );
183 m_commit->Push(
_(
"Swap" ) );
201 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
203 BOARD_ITEM* item = aCollector[i];
205 if( !dynamic_cast<FOOTPRINT*>( item ) )
206 aCollector.Remove( item );
211 std::vector<FOOTPRINT*> footprintsToPack;
214 footprintsToPack.push_back(
static_cast<FOOTPRINT*
>( item ) );
216 if( footprintsToPack.empty() )
219 BOX2I footprintsBbox;
221 for(
FOOTPRINT* item : footprintsToPack )
224 footprintsBbox.
Merge( item->GetBoundingBox(
false,
false ) );
248 typedef std::numeric_limits<int> coord_limits;
250 int max = coord_limits::max();
257 double bottom = top + aSourceBBox.
GetSize().
y;
260 if(
left < min || top < min || right > max || bottom > max )
268 tryMovement = clampedBBoxOrigin - bBoxOrigin;
273 tryMovement = clampedBBoxEnd - bBoxEnd;
275 return GetClampedCoords<double, int>( tryMovement );
344 auto displayConstraintsMessage =
345 [editFrame](
bool constrained )
351 auto updateStatusPopup =
352 [&](
EDA_ITEM* item,
size_t ii,
size_t count )
354 wxString popuptext =
_(
"Click to place %s (item %ld of %ld)\n"
355 "Press <esc> to cancel all; double-click to finish" );
377 std::vector<BOARD_ITEM*> sel_items;
378 std::vector<BOARD_ITEM*> orig_items;
388 orig_items.push_back( boardItem );
390 sel_items.push_back( boardItem );
396 sel_items.push_back(
pad );
404 if( moveWithReference && !
pickReferencePoint(
_(
"Select reference point for move..." ),
"",
"",
405 pickedReferencePoint ) )
414 if( moveIndividually )
419 orig_items.push_back(
static_cast<BOARD_ITEM*
>( item ) );
421 updateStatusPopup( orig_items[ itemIdx ], itemIdx + 1, orig_items.size() );
423 statusPopup.
Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
430 sel_items.push_back( orig_items[ itemIdx ] );
433 bool restore_state =
false;
438 bool updateBBox =
true;
444 bool hv45Mode =
false;
445 bool eatFirstMouseUp =
true;
446 bool hasRedrawn3D =
false;
451 std::unique_ptr<DRC_INTERACTIVE_COURTYARD_CLEARANCE> drc_on_move =
nullptr;
453 if( showCourtyardConflicts )
457 drc_on_move->Init(
board );
460 displayConstraintsMessage( hv45Mode );
476 eatFirstMouseUp =
false;
485 bool redraw3D =
false;
489 m_cursor =
grid.BestSnapAnchor( mousePos, item_layers, sel_items );
514 originalBBox =
BOX2I();
522 originalBBox = viewBBOX;
524 originalBBox.
Merge( viewBBOX );
540 totalMovement += movement;
541 bboxMovement += movement;
557 if( redraw3D && allowRedraw3D )
563 if( showCourtyardConflicts && drc_on_move->m_FpInMove.size() )
614 grid.SetAuxAxes(
false );
641 drc_on_move->m_FpInMove.push_back(
static_cast<FOOTPRINT*
>( item ) );
644 m_cursor =
grid.BestDragOrigin( originalCursorPos, sel_items,
649 if( moveWithReference )
678 statusPopup.
Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
687 restore_state =
true;
692 restore_state =
true;
713 eatFirstMouseUp =
false;
722 i->
Move( -totalMovement );
732 eatFirstMouseUp =
false;
739 orig_items[itemIdx]->SetPosition( originalPos );
743 if( ++itemIdx < orig_items.size() )
754 sel_items.push_back( nextItem );
755 updateStatusPopup( nextItem, itemIdx + 1, orig_items.size() );
770 if( moveIndividually )
771 orig_items[itemIdx]->SetPosition( originalPos );
777 hv45Mode = !hv45Mode;
778 displayConstraintsMessage( hv45Mode );
790 }
while( ( evt =
Wait() ) );
793 if( showCourtyardConflicts )
840 return restore_state ? -1 : 0;
static TOOL_ACTION duplicate
static TOOL_ACTION doDelete
static TOOL_ACTION refreshPreview
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.
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
const Vec & GetPosition() const
const Vec & GetOrigin() const
coord_type GetHeight() const
coord_type GetWidth() const
const Vec & GetSize() const
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
int GetCount() const
Return the number of objects in the list.
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.
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 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,...
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
Apply VIEW_CONTROLS settings from an object.
LSET is a set of PCB_LAYER_IDs.
void SetLocalCoord()
< Set relative coordinates.
DISPLAY_OPTIONS m_Display
bool m_ShowCourtyardCollisions
static TOOL_ACTION toggleHV45Mode
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION hideLocalRatsnest
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION moveWithReference
move with a reference point
static TOOL_ACTION moveExact
Activation of the exact move tool.
static TOOL_ACTION updateLocalRatsnest
static TOOL_ACTION moveIndividually
move items one-by-one
static TOOL_ACTION move
move or drag an item
static TOOL_ACTION mirrorV
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
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.
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
PCBNEW_SETTINGS * GetPcbNewSettings() 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.
A set of BOARD_ITEMs (i.e., without duplicates).
const LSET GetSelectionLayers()
const std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
VECTOR2I GetReferencePoint() const
void ClearReferencePoint()
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=1u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
PCB_LAYER_ID
A quick note on layer IDs:
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
bool m_lastKeyboardCursorPositionValid
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
long m_lastKeyboardCursorCommand
Position of the above event.
@ 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