The script command class This is a special type of command class. More...
#include <Command.h>
Public Member Functions | |
| MacroCommand (const char *name, bool system=false) | |
| virtual | ~MacroCommand () |
Methods to set the properties of the Script Command | |
| void | setScriptName (const char *) |
| Sets the script name. More... | |
Public Member Functions inherited from Gui::Command | |
| const char * | beginCmdHelp (void) |
| returns the begin of a online help page More... | |
| const char * | endCmdHelp (void) |
| returns the end of a online help page More... | |
| virtual const char * | getHelpUrl (void) const |
| Get the help URL. More... | |
| bool | hasActiveDocument (void) const |
| true when there is a document More... | |
| bool | hasObject (const char *Name) |
| true when there is a document and a Feature with Name More... | |
| const char * | getAppModuleName (void) const |
| returns the name to which the command belongs More... | |
| void | setAppModuleName (const char *) |
| const char * | getName () const |
| Get the command name. More... | |
| const char * | getGroupName () const |
| Get the name of the grouping of the command. More... | |
| void | setGroupName (const char *) |
| QString | translatedGroupName () const |
| virtual bool | isActive (void) |
| Override this method if your Cmd is not always active. More... | |
| void | testActive (void) |
| Get somtile called to check the state of the command. More... | |
| void | setEnabled (bool) |
| Enables or disables the command. More... | |
| void | recreateTooltip (const char *context, Action *) |
| (Re)Create the text for the tooltip (for example, when the shortcut is changed) More... | |
| TriggerSource | triggerSource () const |
| Return the current command trigger source. More... | |
| void | invoke (int index, TriggerSource trigger=TriggerNone) |
| Called to invoke the command. More... | |
| void | addTo (QWidget *) |
| adds this command to arbitrary widgets More... | |
| void | addToGroup (ActionGroup *, bool checkable) |
| void | addToGroup (ActionGroup *) |
| void | adjustCameraPosition () |
| Gui::Document * | getActiveGuiDocument (void) const |
| Get pointer to the active gui document. More... | |
| App::Document * | getDocument (const char *Name=nullptr) const |
| Get pointer to the named or active App document Returns a pointer to the named document or the active document when no name is given. More... | |
| bool | isViewOfType (Base::Type t) const |
| checks if the active view is of a special type or derived More... | |
| App::DocumentObject * | getObject (const char *Name) const |
| returns the named feature or the active one from the active document or NULL More... | |
| std::string | getUniqueObjectName (const char *BaseName, const App::DocumentObject *obj=nullptr) const |
| Get unique Feature name from the active document. More... | |
| void | updateAction (int mode) |
| Updates the QAction with respect to the passed mode. More... | |
| void | setupCheckable (int iMsg) |
| Setup checkable actions based on current TriggerSource. More... | |
| const std::string | strToPython (const char *Str) |
| translate a string to a python string literal (needed e.g. in file names for windows...) More... | |
| const std::string | strToPython (const std::string &Str) |
Public Member Functions inherited from Gui::CommandBase | |
| Action * | getAction () const |
| Returns the Action object of this command, or 0 if it doesn't exist. More... | |
| virtual const char * | getMenuText () const |
| virtual const char * | getToolTipText () const |
| virtual const char * | getStatusTip () const |
| virtual const char * | getWhatsThis () const |
| virtual const char * | getPixmap () const |
| virtual const char * | getAccel () const |
| void | setWhatsThis (const char *) |
| void | setMenuText (const char *) |
| void | setToolTipText (const char *) |
| void | setStatusTip (const char *) |
| void | setPixmap (const char *) |
| void | setAccel (const char *) |
Methods to load and save macro commands. | |
| const char * | sScriptName |
| bool | systemMacro |
| static void | load () |
| Loads all macros command from the preferences. More... | |
| static void | save () |
| Saves all macros command to the preferences. More... | |
methods reimplemented for Command Framework | |
| const char * | getScriptName () const |
| Returns the script name. More... | |
| void | languageChange () |
| Ignore when language has changed. More... | |
| const char * | className () const |
| The C++ class name is needed as context for the translation framework. More... | |
| void | activated (int iMsg) |
| Method which get called when activated. More... | |
| Action * | createAction (void) |
| Creates the used Action. More... | |
Additional Inherited Members | |
Public Types inherited from Gui::Command | |
| enum | TriggerSource { TriggerNone , TriggerAction , TriggerChildAction } |
| Command trigger source. More... | |
| enum | DoCmd_Type { Doc , App , Gui } |
| types of application level actions for DoCommand() More... | |
Static Public Member Functions inherited from Gui::Command | |
| static void | blockCommand (bool) |
| Blocks all command objects. More... | |
| static void | printPyCaller () |
| Print to Python console the current Python calling source file and line number. More... | |
| static void | printCaller (const char *file, int line) |
| Print to Python console the current calling source file and line number. More... | |
| static void | addModule (DoCmd_Type eType, const char *sModuleName) |
| import an external (or own) module only once More... | |
| static Application * | getGuiApplication (void) |
| Get pointer to the Application Window. More... | |
| static Gui::SelectionSingleton & | getSelection (void) |
| Get a reference to the selection. More... | |
| static std::string | getObjectCmd (const char *Name, const App::Document *doc=nullptr, const char *prefix=nullptr, const char *postfix=nullptr, bool gui=false) |
| returns a python command string to retrieve an object from a document More... | |
| static std::string | getObjectCmd (const App::DocumentObject *obj, const char *prefix=nullptr, const char *postfix=nullptr, bool gui=false) |
| returns a python command string to retrieve the given object More... | |
| static void | openCommand (const char *sName=nullptr) |
| Open a new Undo transaction on the active document. More... | |
| static void | commitCommand (void) |
| Commit the Undo transaction on the active document. More... | |
| static void | abortCommand (void) |
| Abort the Undo transaction on the active document. More... | |
| static bool | hasPendingCommand (void) |
| Check if an Undo transaction is open on the active document. More... | |
| static void | updateActive (void) |
| Updates the (active) document (propagate changes) More... | |
| static void | updateAll (std::list< Gui::Document * > cList) |
| Updates the (all or listed) documents (propagate changes) More... | |
| static bool | isActiveObjectValid (void) |
| Checks if the active object of the active document is valid. More... | |
| static std::string | getPythonTuple (const std::string &name, const std::vector< std::string > &subnames) |
| Get Python tuple from object and sub-elements. More... | |
Protected Types inherited from Gui::Command | |
| enum | CmdType { AlterDoc = 1 , Alter3DView = 2 , AlterSelection = 4 , ForEdit = 8 , NoTransaction = 16 } |
Protected Member Functions inherited from Gui::Command | |
| Command (const char *name) | |
| virtual | ~Command () |
| void | applyCommandData (const char *context, Action *) |
| Applies the menu text, tool and status tip to the passed action object. More... | |
| const char * | keySequenceToAccel (int) const |
| void | printConflictingAccelerators () const |
Protected Member Functions inherited from Gui::CommandBase | |
| CommandBase (const char *sMenu, const char *sToolTip=nullptr, const char *sWhat=nullptr, const char *sStatus=nullptr, const char *sPixmap=nullptr, const char *sAccel=nullptr) | |
| virtual | ~CommandBase () |
Protected Attributes inherited from Gui::Command | |
| const char * | sAppModule |
| const char * | sGroup |
| const char * | sName |
| const char * | sHelpUrl |
| int | eType |
| bool | bCanLog |
| Indicate if the command shall log to MacroManager. More... | |
Protected Attributes inherited from Gui::CommandBase | |
| const char * | sMenuText |
| const char * | sToolTipText |
| const char * | sWhatsThis |
| const char * | sStatusTip |
| const char * | sPixmap |
| const char * | sAccel |
| std::string | displayText |
The script command class This is a special type of command class.
Its used to bind a macro or Python script to the FreeCAD command framework. An object of this class gets a string to the place where the script is in the file system. Unlike the other commands the resources can be set by several methods.
| MacroCommand::MacroCommand | ( | const char * | name, |
| bool | system = false |
||
| ) |
References Gui::Command::eType, Gui::Command::sGroup, and sScriptName.
Referenced by load().
|
virtual |
|
protectedvirtual |
Method which get called when activated.
Implements Gui::Command.
References Gui::Application::activeDocument(), Gui::MacroManager::File, App::GetApplication(), ParameterGrp::GetASCII(), Gui::Document::getDocument(), App::Application::getHomePath(), Gui::getMainWindow(), App::Application::GetParameterGroupByPath(), App::Application::getUserMacroDir(), Gui::Application::Instance, Gui::Application::macroManager(), App::Document::recompute(), Gui::MacroManager::run(), sScriptName, and systemMacro.
|
virtual |
The C++ class name is needed as context for the translation framework.
Implements Gui::CommandBase.
|
protectedvirtual |
Creates the used Action.
Reimplemented from Gui::Command.
References Gui::BitmapFactory(), Gui::getMainWindow(), Gui::Command::printConflictingAccelerators(), Gui::CommandBase::sAccel, Gui::Action::setIcon(), Gui::Action::setShortcut(), Gui::Action::setStatusTip(), Gui::Action::setText(), Gui::Action::setToolTip(), Gui::Action::setWhatsThis(), Gui::Action::shortcut(), Gui::CommandBase::sMenuText, Gui::CommandBase::sPixmap, Gui::CommandBase::sStatusTip, Gui::Action::statusTip(), Gui::CommandBase::sToolTipText, Gui::CommandBase::sWhatsThis, and Gui::Action::toolTip().
| const char * Gui::MacroCommand::getScriptName | ( | ) | const |
Returns the script name.
References sScriptName.
Referenced by Gui::Dialog::DlgCustomActionsImp::on_actionListWidget_itemActivated(), Gui::Dialog::DlgMacroExecuteImp::on_toolbarButton_clicked(), and save().
|
virtual |
Ignore when language has changed.
Reimplemented from Gui::Command.
|
static |
Loads all macros command from the preferences.
References Gui::CommandManager::addCommand(), Gui::Application::commandManager(), App::GetApplication(), ParameterGrp::GetGroup(), ParameterGrp::GetGroups(), App::Application::GetParameterGroupByPath(), ParameterGrp::HasGroup(), Gui::Application::Instance, MacroCommand(), Gui::CommandBase::setAccel(), Gui::CommandBase::setMenuText(), Gui::CommandBase::setPixmap(), setScriptName(), Gui::CommandBase::setStatusTip(), Gui::CommandBase::setToolTipText(), Gui::CommandBase::setWhatsThis(), and systemMacro.
Referenced by Gui::Application::Application(), draftguitools.gui_setstyle.Draft_SetStyle_TaskPanel::loadDefaults(), draftguitools.gui_setstyle.Draft_SetStyle_TaskPanel::onLoadStyle(), and draftguitools.gui_setstyle.Draft_SetStyle_TaskPanel::onSaveStyle().
|
static |
Saves all macros command to the preferences.
References ParameterGrp::Clear(), Gui::Application::commandManager(), Gui::CommandBase::getAccel(), App::GetApplication(), ParameterGrp::GetGroup(), Gui::CommandManager::getGroupCommands(), Gui::CommandBase::getMenuText(), Gui::Command::getName(), App::Application::GetParameterGroupByPath(), Gui::CommandBase::getPixmap(), getScriptName(), Gui::CommandBase::getStatusTip(), Gui::CommandBase::getToolTipText(), Gui::CommandBase::getWhatsThis(), Gui::Application::Instance, ParameterGrp::SetASCII(), ParameterGrp::SetBool(), and systemMacro.
Referenced by Mod.Show.mTempoVis.TempoVis::modify(), Mod.Show.mTempoVis.TempoVis::modifyVPProperty(), draftguitools.gui_setstyle.Draft_SetStyle_TaskPanel::onSaveStyle(), Mod.Show.mTempoVis.TempoVis::saveCamera(), and Gui::Application::~Application().
| void MacroCommand::setScriptName | ( | const char * | s | ) |
Sets the script name.
References StringCache::New(), and sScriptName.
Referenced by load(), Gui::Dialog::DlgCustomActionsImp::on_buttonAddAction_clicked(), and Gui::Dialog::DlgCustomActionsImp::on_buttonReplaceAction_clicked().
|
protected |
Referenced by activated(), getScriptName(), MacroCommand(), and setScriptName().
|
protected |
Referenced by activated(), load(), and save().