33#include <dialogs/dialog_text_properties.h>
50 m_lastTextBold( false ),
51 m_lastTextItalic( false ),
57 m_drawSpecificBodyStyle( true ),
58 m_drawSpecificUnit( false ),
59 m_inDrawShape( false ),
60 m_inTwoClickPlace( false )
69 auto isDrawingCondition =
73 return item && item->
IsNew();
99 bool ignorePrimePosition =
false;
141 ignorePrimePosition =
true;
149 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
155 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
158 if( evt->IsCancelInteractive() )
172 else if( evt->IsActivate() && !isSyntheticClick )
174 if( item && evt->IsMoveTool() )
177 evt->SetPassEvent(
false );
184 evt->SetPassEvent(
false );
188 if( evt->IsPointEditor() )
192 else if( evt->IsMoveTool() )
202 else if( evt->IsClick(
BUT_LEFT ) || evt->IsDblClick(
BUT_LEFT ) || isSyntheticClick )
218 item = pinTool->CreatePin( cursorPos, symbol );
229 text->SetParent( symbol );
251 wxFAIL_MSG(
"TwoClickPlace(): unknown type" );
257 if( evt->IsPrime() && !ignorePrimePosition )
259 cursorPos =
grid.Align( evt->Position(),
grid.GetItemGrid( item ) );
289 switch( item->
Type() )
292 pinTool->PlacePin(
static_cast<SCH_PIN*
>( item ) );
294 commit.
Push(
_(
"Place Pin" ) );
300 commit.
Push(
_(
"Draw Text" ) );
304 wxFAIL_MSG(
"TwoClickPlace(): unknown type" );
360 bool isTextBox = !aDrawingShape.has_value();
361 SHAPE_T toolType = aDrawingShape.value_or( SHAPE_T::SEGMENT );
368 SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
371 wxString description;
415 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
421 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
424 if( evt->IsCancelInteractive() )
436 else if( evt->IsActivate() && !isSyntheticClick )
441 if( evt->IsPointEditor() )
445 else if( evt->IsMoveTool() )
456 else if( evt->IsClick(
BUT_LEFT ) && !item )
484 description =
_(
"Add Text Box" );
507 else if( item && ( evt->IsClick(
BUT_LEFT )
521 if( toolType == SHAPE_T::POLY )
563 commit.
Push( description );
574 else if( evt->IsDblClick(
BUT_LEFT ) && !item )
624 if( evt->IsCancelInteractive() )
629 else if( evt->IsActivate() )
643 symbol->
Move( -cursorPos );
679 if( dlgResult != wxID_OK )
685 wxMessageBox(
_(
"No graphic items found in file." ) );
692 std::vector<SCH_ITEM*> newItems;
693 std::vector<SCH_ITEM*> selectedItems;
697 for( std::unique_ptr<EDA_ITEM>& ptr : list )
700 wxCHECK2( item,
continue );
702 newItems.push_back( item );
703 selectedItems.push_back( item );
717 item->ClearEditFlags();
720 commit.
Push(
_(
"Import Graphic" ) );
731 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
736 auto setCursor = [&]()
756 for(
SCH_ITEM* item : selectedItems )
759 currentOffset +=
delta;
769 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
774 if( evt->IsCancelInteractive() || evt->IsActivate() )
783 else if( evt->IsMotion() )
785 delta = cursorPos - currentOffset;
787 for(
SCH_ITEM* item : selectedItems )
790 currentOffset +=
delta;
806 item->ClearEditFlags();
809 commit.
Push(
_(
"Import Graphic" ) );
constexpr EDA_IU_SCALE schIUScale
static TOOL_ACTION cancelInteractive
static TOOL_ACTION activatePointEditor
static TOOL_ACTION refreshPreview
static TOOL_ACTION finishInteractive
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
bool IsPlacementInteractive()
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 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 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 void SetParent(EDA_ITEM *aParent)
virtual wxString GetFriendlyName() const
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
FILL_T GetFillMode() const
void SetFillColor(const COLOR4D &aColor)
COLOR4D GetFillColor() const
const EDA_ANGLE & GetTextAngle() const
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
GR_TEXT_H_ALIGN_T GetHorizJustify() 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)
static TOOL_ACTION properties
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
static TOOL_ACTION clearSelection
Clears the current selection.
static TOOL_ACTION placeSymbolAnchor
static TOOL_ACTION drawSymbolPolygon
static TOOL_ACTION drawCircle
static TOOL_ACTION placeSymbolText
static TOOL_ACTION importGraphics
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
static TOOL_ACTION drawRectangle
static TOOL_ACTION drawSymbolTextBox
static TOOL_ACTION drawSymbolLines
static TOOL_ACTION drawArc
static TOOL_ACTION drawBezier
static TOOL_ACTION repeatDrawItem
static TOOL_ACTION placeSymbolPin
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
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
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...
void RecacheAllItems()
Rebuild GAL display lists.
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
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
virtual SETTINGS_MANAGER & GetSettingsManager() const
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
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.
T * GetAppSettings(const wxString &aFilename)
Returns a handle to the a given settings by type If the settings have already been loaded,...
The symbol library editor main window.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
PGM_BASE & Pgm()
The global Program "get" accessor.
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
LINE_STYLE
Dashed line types.
constexpr int MilsToIU(int mils) const
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I