23#include <fmt/format.h>
66 wxASSERT_MSG(
m_selectionTool,
"plEditor.InteractiveSelection tool is not available" );
112 bool unselect = selection.
IsHover();
117 std::set<DS_DATA_ITEM*> unique_peers;
122 unique_peers.insert( drawItem->
GetPeer() );
132 bool restore_state =
false;
133 bool chain_commands =
false;
144 catch(
const fmt::format_error& exc )
146 wxLogWarning( wxS(
"Exception \"%s\" serializing string ocurred." ), exc.what() );
185 else if( selection.
Size() == 1 )
225 m_frame->GetInfoBar()->Dismiss();
234 m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel move." ) );
241 restore_state =
true;
270 restore_state =
true;
272 chain_commands =
true;
296 }
while( ( evt =
Wait() ) );
302 if( !chain_commands )
308 item->ClearEditFlags();
343 if( aSelection.
Size() == 1 )
373 if( selection.
Size() == 0 )
386 while( selection.
Front() )
396 if( item->IsSelected() )
411#define HITTEST_THRESHOLD_PIXELS 5
425 [
this] (
const VECTOR2D& aPosition ) ->
bool
449 if( drawItem->HitTest( aPos, threshold ) )
472 [
this] (
const int& aFinalState )
489 m_frame->GetLayoutFromUndoList();
496 m_frame->GetLayoutFromRedoList();
503 int retVal =
Copy( aEvent );
515 std::vector<DS_DATA_ITEM*> items;
528 items.push_back( peer );
533 model.SaveInString( items, &sexpr );
537 wxMessageBox( ioe.
What(),
_(
"Error writing objects to clipboard" ) );
554 auto image = std::make_unique<BITMAP_BASE>();
555 image->SetImage( clipImg->ConvertToImage() );
556 auto dataItem = std::make_unique<DS_DATA_ITEM_BITMAP>(
image.release() );
557 model.Append( dataItem.release() );
564 model.SetPageLayout( clipText.c_str(),
true, wxT(
"clipboard" ) );
570 if( dataItem->GetDrawItems().empty() )
572 m_frame->SyncDataItem( dataItem );
573 dataItem->GetDrawItems().front()->SetSelected();
579 if( !selection.
Empty() )
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION pickerTool
static TOOL_ACTION selectionActivate
Activation of the selection tool.
static TOOL_ACTION duplicate
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION deleteTool
static TOOL_ACTION selectionClear
Clear the current selection.
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()
Return the instance of DS_DATA_MODEL used in the application.
void Remove(DS_DATA_ITEM *aItem)
Base class to handle basic graphic items.
DS_DATA_ITEM * GetPeer() const
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
Selected items were moved, this can be very high frequency on the canvas, use with care.
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 appendImportedDrawingSheet
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
std::unique_ptr< wxBitmap > GetImageFromClipboard()
Get image data from the clipboard, if there is any.
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
This file is part of the common library.
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
This file contains miscellaneous commonly used macros and functions.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
#define HITTEST_THRESHOLD_PIXELS
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D