42#include "../../scripting/python_scripting.h"
49 Py_XINCREF( aAction );
68 PyObject* pFunc = PyObject_GetAttrString(
m_PyAction, aMethod );
70 if( pFunc && PyCallable_Check( pFunc ) )
72 PyObject* result = PyObject_CallObject( pFunc, aArglist );
74 if( PyErr_Occurred() )
76 wxMessageBox( PyErrStringWithTraceback(),
77 _(
"Exception on python action plugin code" ),
78 wxICON_ERROR | wxOK );
89 wxString msg =
wxString::Format(
_(
"Method '%s' not found, or not callable" ), aMethod );
90 wxMessageBox( msg,
_(
"Unknown Method" ), wxICON_ERROR | wxOK );
107 PyObject* result =
CallMethod( aMethod, aArglist );
109 ret = PyStringToWx( result );
110 Py_XDECREF( result );
144 PyObject* result =
CallMethod(
"GetShowToolbarButton");
146 return PyObject_IsTrue(result);
154 PyObject* arglist = Py_BuildValue(
"(i)",
static_cast<int>( aDark ) );
158 Py_DECREF( arglist );
223 bool fromEmpty =
false;
264 aActionPlugin->
Run();
277 wxASSERT( oldBuffer );
284 std::set<BOARD_ITEM*> currItemList;
288 currItemList.insert( item );
292 currItemList.insert( item );
296 currItemList.insert( item );
300 currItemList.insert( zone );
303 for(
unsigned int i = 0; i < oldBuffer->
GetCount(); i++ )
310 if( currItemList.find( item ) == currItemList.end() )
312 deletedItemsList.
PushItem( picker );
319 for(
unsigned int i = 0; i < deletedItemsList.
GetCount(); i++ )
331 commit.
Added( item );
341 commit.
Added( item );
351 commit.
Added( item );
361 commit.
Added( zone );
421 Connect( item->GetId(), wxEVT_COMMAND_MENU_SELECTED,
431 bool need_separator =
true;
441 need_separator =
false;
447 if ( ap->iconBitmap.IsOk() )
452 wxAuiToolBarItem* button =
m_mainToolBar->AddTool( wxID_ANY, wxEmptyString,
453 bitmap, ap->GetName() );
455 Connect( button->GetId(), wxEVT_COMMAND_MENU_SELECTED,
469 std::vector<ACTION_PLUGIN*> plugins;
470 std::vector<ACTION_PLUGIN*> orderedPlugins;
478 auto loc = std::find_if( plugins.begin(), plugins.end(),
481 return plugin->GetPluginPath() == pair.first;
484 if( loc != plugins.end() )
486 orderedPlugins.push_back( *loc );
487 plugins.erase( loc );
492 for(
auto remaining_plugin : plugins )
493 orderedPlugins.push_back( remaining_plugin );
495 return orderedPlugins;
500 bool aPluginDefault )
506 if( entry.first == aPluginPath )
511 return aPluginDefault;
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
wxBitmap KiScaledBitmap(BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
static bool deregister_object(void *aObject)
Deregister an object which builds a action.
static ACTION_PLUGIN * GetActionByMenu(int aMenu)
Find action plugin associated to a menu ID.
static int GetActionsCount()
static ACTION_PLUGIN * GetAction(const wxString &aName)
static void SetActionButton(ACTION_PLUGIN *aAction, int idButton)
Associate a button id to an action plugin.
static void SetActionMenu(int aIndex, int idMenu)
Associate a menu id to an action plugin.
static void SetActionRunning(bool aRunning)
static ACTION_PLUGIN * GetActionByButton(int aButton)
Find action plugin associated to a button ID.
This is the parent class from where any action plugin class must derive.
void register_action()
It's the standard method of a "ACTION_PLUGIN" to register itself into the ACTION_PLUGINS singleton ma...
virtual wxString GetDescription()=0
virtual wxString GetName()=0
virtual void Run()=0
This method the the action.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
const VECTOR2I & GetGridOrigin()
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const PAGE_INFO & GetPageSettings() const
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
FOOTPRINTS & Footprints()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
COMMIT & Added(EDA_ITEM *aItem)
Remove a new item from the model.
COMMIT & Removed(EDA_ITEM *aItem)
Modify a given item in the model.
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
ACTION_TOOLBAR * m_mainToolBar
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
void Clear()
Remove all items from the view.
ACTION_PLUGIN_SETTINGS_LIST m_VisibleActionPlugins
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplayBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
void SyncLayersVisibility(const BOARD *aBoard)
Update "visibility" property of each layer of a given BOARD.
void OnModify() override
Must be called after a board change to set the modified flag.
static std::vector< ACTION_PLUGIN * > GetOrderedActionPlugins()
Return ordered list of plugins in sequence in which they should appear on toolbar or in settings.
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void OnActionPluginButton(wxCommandEvent &aEvent)
Launched by the button when an action is called.
void RunActionPlugin(ACTION_PLUGIN *aActionPlugin)
Execute action plugin's Run() method and updates undo buffer.
void buildActionPluginMenus(ACTION_MENU *aActionMenu)
Fill action menu with all registered action plugins.
void RebuildAndRefresh()
Rebuilds board connectivity, refreshes canvas.
static bool GetActionPluginButtonVisible(const wxString &aPluginPath, bool aPluginDefault)
Return true if button visibility action plugin setting was set to true or it is unset and plugin defa...
void OnActionPluginMenu(wxCommandEvent &aEvent)
Launched by the menu when an action is called.
void AddActionPluginTools()
Append action plugin buttons to main toolbar.
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
ITEM_PICKER GetItemWrapper(unsigned int aIdx) const
bool ContainsItem(const EDA_ITEM *aItem) const
unsigned GetCount() const
void ClearItemsList()
Delete only the list of pickers NOT the picked data itself.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
static void deregister_action(PyObject *aPyAction)
static void register_action(PyObject *aPyAction)
bool GetShowToolbarButton() override
wxString CallRetStrMethod(const char *aMethod, PyObject *aArglist=nullptr)
PyObject * CallMethod(const char *aMethod, PyObject *aArglist=nullptr)
wxString GetCategoryName() override
wxString GetName() override
wxString GetDescription() override
wxString GetPluginPath() override
PYTHON_ACTION_PLUGIN(PyObject *action)
void Run() override
This method the the action.
wxString GetIconFileName(bool aDark) override
void * GetObject() override
This method gets the pointer to the object from where this action constructs.
Handle a list of polygons defining a copper zone.
Class PCBNEW_ACTION_PLUGINS.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
VECTOR2< double > VECTOR2D