27#include <fmt/format.h>
54 m_selectionTool( nullptr ),
55 m_moveInProgress( false ),
58 m_pickerItem( nullptr )
65 m_frame = getEditFrame<PL_EDITOR_FRAME>();
68 wxASSERT_MSG(
m_selectionTool,
"plEditor.InteractiveSelection tool is not available" );
101 m_frame = getEditFrame<PL_EDITOR_FRAME>();
114 bool unselect = selection.
IsHover();
119 std::set<DS_DATA_ITEM*> unique_peers;
124 unique_peers.insert( drawItem->
GetPeer() );
134 bool restore_state =
false;
135 bool chain_commands =
false;
146 catch(
const fmt::format_error& exc )
148 wxLogWarning( wxS(
"Exception \"%s\" serializing string ocurred." ),
186 else if( selection.
Size() == 1 )
242 restore_state =
true;
271 restore_state =
true;
273 chain_commands =
true;
297 }
while( ( evt =
Wait() ) );
303 if( !chain_commands )
309 item->ClearEditFlags();
345 if( aSelection.
Size() == 1 )
375 if( selection.
Size() == 0 )
388 while( selection.
Front() )
398 if( item->IsSelected() )
413#define HITTEST_THRESHOLD_PIXELS 5
427 [
this] (
const VECTOR2D& aPosition ) ->
bool
451 if( drawItem->HitTest( aPos, threshold ) )
474 [
this] (
const int& aFinalState )
505 int retVal =
Copy( aEvent );
517 std::vector<DS_DATA_ITEM*> items;
533 wxMessageBox( ioe.
What(),
_(
"Error writing objects to clipboard" ) );
547 bool createdAnything =
false;
551 auto image = std::make_unique<BITMAP_BASE>();
552 image->SetImage( *clipImg );
553 auto dataItem = std::make_unique<DS_DATA_ITEM_BITMAP>(
image.release() );
554 model.
Append( dataItem.release() );
556 createdAnything =
true;
563 model.
SetPageLayout( clipText.c_str(),
true, wxT(
"clipboard" ) );
564 createdAnything =
true;
568 if( !createdAnything )
574 if( dataItem->GetDrawItems().empty() )
576 dataItem->SyncDrawItems(
nullptr,
getView() );
577 dataItem->GetDrawItems().front()->SetSelected();
583 if( !selection.
Empty() )
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION pickerTool
static TOOL_ACTION duplicate
static TOOL_ACTION doDelete
static TOOL_ACTION deleteTool
static TOOL_ACTION refreshPreview
Drawing sheet structure type definitions.
void MoveToIU(const VECTOR2I &aPosition)
Move item to a new position.
const VECTOR2I GetStartPosIU(int ii=0) const
const std::vector< DS_DRAW_ITEM_BASE * > & GetDrawItems() const
Handle the graphic items list to draw/plot the frame and title block.
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void Append(DS_DATA_ITEM *aItem)
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
void Remove(DS_DATA_ITEM *aItem)
std::vector< DS_DATA_ITEM * > & GetItems()
void SetPageLayout(const char *aPageLayout, bool aAppend=false, const wxString &aSource=wxT("Sexpr_string"))
Populate the list from a S expr description stored in a string.
Base class to handle basic graphic items.
DS_DATA_ITEM * GetPeer() const
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...
WX_INFOBAR * GetInfoBar()
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
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
EDA_ITEM_FLAGS GetFlags() const
static const TOOL_EVENT SelectedEvent
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
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 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.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
static TOOL_ACTION clearSelection
Clear the current selection.
static TOOL_ACTION selectionActivate
Activation of the selection tool.
static TOOL_ACTION appendImportedDrawingSheet
void OnModify() override
Must be called after a change in order to set the "modify" flag.
void Files_io(wxCommandEvent &event)
void GetLayoutFromRedoList()
Redo the last edit:
void GetLayoutFromUndoList()
Undo the last edit:
void RollbackFromUndo()
Apply the last command in Undo List without stacking a Redo.
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
const std::deque< EDA_ITEM * > GetItems() const
VECTOR2I GetReferencePoint() const
virtual unsigned int GetSize() const override
Return the number of stored items.
int Size() const
Returns the number of selected parts.
void ClearReferencePoint()
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
std::unique_ptr< wxImage > GetImageFromClipboard()
Get image data from the clipboard, if there is any.
This file is part of the common library.
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.