30#include <dialogs/dialog_text_properties.h>
67 auto isDrawingCondition =
71 return item && item->
IsNew();
95 bool ignorePrimePosition =
false;
137 ignorePrimePosition =
true;
147 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
153 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
156 if( evt->IsCancelInteractive() )
158 m_frame->GetInfoBar()->Dismiss();
170 else if( evt->IsActivate() && !isSyntheticClick )
172 if( item && evt->IsMoveTool() )
175 evt->SetPassEvent(
false );
181 m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel item creation." ) );
182 evt->SetPassEvent(
false );
186 if( evt->IsPointEditor() )
190 else if( evt->IsMoveTool() )
200 else if( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) || isSyntheticClick )
215 item = pinTool->
CreatePin( cursorPos, symbol );
226 text->SetParent( symbol );
237 schIUScale.MilsToIU( cfg->m_Defaults.text_size ) ) );
253 wxFAIL_MSG(
"TwoClickPlace(): unknown type" );
259 if( evt->IsPrime() && !ignorePrimePosition )
261 cursorPos =
grid.Align( evt->Position(),
grid.GetItemGrid( item ) );
276 m_view->AddToPreview( item,
false );
283 if(
m_frame->GetMoveWarpsCursor() )
293 switch( item->
Type() )
298 commit.
Push(
_(
"Place Pin" ) );
304 commit.
Push(
_(
"Draw Text" ) );
308 wxFAIL_MSG(
"TwoClickPlace(): unknown type" );
326 if( evt->HasParameter() )
335 m_view->AddToPreview( item,
false );
371 bool isTextBox = !aDrawingShape.has_value();
381 wxString description;
425 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
431 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
434 if( evt->IsCancelInteractive() )
446 else if( evt->IsActivate() && !isSyntheticClick )
451 if( evt->IsPointEditor() )
455 else if( evt->IsMoveTool() )
466 else if( evt->IsClick(
BUT_LEFT ) && !item )
469 symbol =
m_frame->GetCurSymbol();
498 description =
_(
"Add Text Box" );
521 else if( item && ( evt->IsClick(
BUT_LEFT )
526 if( symbol !=
m_frame->GetCurSymbol() )
528 symbol =
m_frame->GetCurSymbol();
577 commit.
Push( description );
588 else if( evt->IsDblClick(
BUT_LEFT ) && !item )
643 if( evt->IsCancelInteractive() )
648 else if( evt->IsActivate() )
662 symbol->
Move( -cursorPos );
666 m_view->RecacheAllItems();
698 if( dlgResult != wxID_OK )
704 wxMessageBox(
_(
"No graphic items found in file." ) );
711 std::vector<SCH_ITEM*> newItems;
712 std::vector<SCH_ITEM*> selectedItems;
716 for( std::unique_ptr<EDA_ITEM>& ptr : list )
719 wxCHECK2( item,
continue );
721 newItems.push_back( item );
722 selectedItems.push_back( item );
736 item->ClearEditFlags();
739 commit.
Push(
_(
"Import Graphic" ) );
750 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
755 auto setCursor = [&]()
775 for(
SCH_ITEM* item : selectedItems )
778 currentOffset +=
delta;
780 m_view->Update( &preview );
788 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
793 if( evt->IsCancelInteractive() || evt->IsActivate() )
802 else if( evt->IsMotion() )
804 delta = cursorPos - currentOffset;
806 for(
SCH_ITEM* item : selectedItems )
809 currentOffset +=
delta;
811 m_view->Update( &preview );
825 item->ClearEditFlags();
828 commit.
Push(
_(
"Import Graphic" ) );
838 m_view->Remove( &preview );
constexpr EDA_IU_SCALE schIUScale
static TOOL_ACTION cancelInteractive
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
static TOOL_ACTION activatePointEditor
static TOOL_ACTION increment
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION refreshPreview
static TOOL_ACTION finishInteractive
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
bool IsPlacementInteractive()
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void ClearEditFlags()
virtual void SetPosition(const VECTOR2I &aPos)
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
virtual wxString GetFriendlyName() const
virtual void SetParent(EDA_ITEM *aParent)
FILL_T GetFillMode() const
void SetFillColor(const COLOR4D &aColor)
COLOR4D GetFillColor() const
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
virtual EDA_ANGLE GetTextAngle() const
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
A color representation with 4 components: red, green, blue, alpha.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
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.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
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.
virtual void PinCursorInsideNonAutoscrollArea(bool aWarpMouseCursor)=0
Define a library symbol object.
void Move(const VECTOR2I &aOffset) override
Move the symbol aOffset.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
virtual COMMON_SETTINGS * GetCommonSettings() const
static TOOL_ACTION drawEllipseArc
static TOOL_ACTION drawArc
static TOOL_ACTION drawSymbolLines
static TOOL_ACTION placeSymbolPin
static TOOL_ACTION drawSymbolTextBox
static TOOL_ACTION properties
static TOOL_ACTION drawRectangle
static TOOL_ACTION drawEllipse
static TOOL_ACTION drawCircle
static TOOL_ACTION importGraphics
static TOOL_ACTION drawBezier
static TOOL_ACTION drawSymbolPolygon
static TOOL_ACTION placeSymbolAnchor
static TOOL_ACTION placeSymbolText
static TOOL_ACTION repeatDrawItem
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void SetBodyStyle(int aBodyStyle)
virtual void SetUnit(int aUnit)
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void EndEdit(bool aClosed=false) override
End an object editing action.
void SetStroke(const STROKE_PARAMS &aStroke) override
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
STROKE_PARAMS GetStroke() const override
VECTOR2I GetPosition() const override
virtual void Add(EDA_ITEM *aItem)
virtual void Clear() override
Remove all the stored items from the group.
The symbol library editor main window.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
PGM_BASE & Pgm()
The global program "get" accessor.
std::vector< EDA_ITEM * > EDA_ITEMS
T * GetAppSettings(const char *aFilename)
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
LINE_STYLE
Dashed line types.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I