FreeCAD C++
|
#include <Gui/Command.h>
The Command class.
This class is mostly used for commands implemented directly in C++ (see PythonCommand). It contains also a lot of helper methods to make implementing commands for FreeCAD as easy as possible.
Public Member Functions | |
Helper methods to generate help pages | |
const char * | beginCmdHelp (void) |
returns the begin of a online help page | |
const char * | endCmdHelp (void) |
returns the end of a online help page | |
virtual const char * | getHelpUrl (void) const |
Get the help URL. | |
Helper methods for the Active tests | |
bool | hasActiveDocument (void) const |
true when there is a document | |
bool | hasObject (const char *Name) |
true when there is a document and a Feature with Name | |
checking of internal state | |
const char * | getAppModuleName (void) const |
returns the name to which the command belongs | |
void | setAppModuleName (const char *) |
const char * | getName () const |
Get the command name. | |
const char * | getGroupName () const |
Get the name of the grouping of the command. | |
void | setGroupName (const char *) |
arbitrary helper methods | |
void | adjustCameraPosition () |
![]() | |
Action * | getAction () const |
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 *) |
virtual const char * | className () const =0 |
The C++ class name is needed as context for the translation framework. | |
Protected Types | |
enum | CmdType { AlterDoc = 1, Alter3DView = 2, AlterSelection = 4, ForEdit = 8 } |
Protected Member Functions | |
Methods to override when creating a new command | |
virtual void | activated (int iMsg)=0 |
Methods which gets called when activated, needs to be reimplemented! | |
virtual bool | isActive (void) |
Override this method if your Cmd is not always active. | |
virtual Action * | createAction (void) |
Creates the used Action. | |
void | applyCommandData (const char *context, Action *) |
Applies the menu text, tool and status tip to the passed action object. | |
const char * | keySequenceToAccel (int) const |
![]() |
Protected Attributes | |
Attributes | |
Set by the inherited constructor to set up the most important properties of the command. In the Command constructor are set default values! The real values should be set in the constructor of the inhereting class. | |
const char * | sAppModule |
const char * | sGroup |
const char * | sName |
const char * | sHelpUrl |
int | eType |
![]() | |
Action * | _pcAction |
const char * | sMenuText |
const char * | sToolTipText |
const char * | sWhatsThis |
const char * | sStatusTip |
const char * | sPixmap |
const char * | sAccel |
interface used by the CommandManager and the Action | |
void | testActive (void) |
Get somtile called to check the state of the command. | |
void | setEnabled (bool) |
Enables or disables the command. | |
void | invoke (int) |
get called by the QAction | |
void | addTo (QWidget *) |
adds this command to arbitrary widgets | |
void | addToGroup (ActionGroup *, bool checkable) |
Helper methods to get important classes | |
Gui::Document * | getActiveGuiDocument (void) const |
Get pointer to the active gui document. | |
App::Document * | getDocument (const char *Name=0) const |
bool | isViewOfType (Base::Type t) const |
checks if the active view is of a special type or derived | |
App::DocumentObject * | getObject (const char *Name) const |
returns the named feature or the active one from the active document or NULL | |
std::string | getUniqueObjectName (const char *BaseName) const |
Get unique Feature name from the active document. | |
static Application * | getGuiApplication (void) |
Get pointer to the Application Window. | |
static Gui::SelectionSingleton & | getSelection (void) |
Get a reference to the selection. | |
Helper methods for the Undo/Redo and Update handling | |
void | languageChange () |
Translate command. | |
void | updateAction (int mode) |
Updates the QAction with respect to the passed mode. | |
static void | openCommand (const char *sName=0) |
Open a new Undo transaction on the active document. | |
static void | commitCommand (void) |
Commit the Undo transaction on the active document. | |
static void | abortCommand (void) |
Abort the Undo transaction on the active document. | |
static bool | hasPendingCommand (void) |
Check if an Undo transaction is open on the active document. | |
static void | updateActive (void) |
Updates the (active) document (propagate changes) | |
static void | updateAll (std::list< Gui::Document * > cList) |
Updates the (all or listed) documents (propagate changes) | |
static bool | isActiveObjectValid (void) |
Checks if the active object of the active document is valid. | |
Helper methods for issuing commands to the Python interpreter | |
enum | DoCmd_Type { Doc, App, Gui } |
types of application level actions for DoCommand() More... | |
const std::string | strToPython (const char *Str) |
translate a string to a python string literal (needed e.g. in file names for windows...) | |
const std::string | strToPython (const std::string &Str) |
static void | blockCommand (bool) |
Blocks all command objects. | |
static void | doCommand (DoCmd_Type eType, const char *sCmd,...) |
Run a App level Action. | |
static void | runCommand (DoCmd_Type eType, const char *sCmd) |
static void | runCommand (DoCmd_Type eType, const QByteArray &sCmd) |
static void | addModule (DoCmd_Type eType, const char *sModuleName) |
import an external (or own) module only once | |
static std::string | assureWorkbench (const char *sName) |
assures the switch to a certain workbench, if already in the workbench, does nothing. | |
static void | copyVisual (const char *to, const char *attr, const char *from) |
static void | copyVisual (const char *to, const char *attr_to, const char *from, const char *attr_from) |
static std::string | getPythonTuple (const std::string &name, const std::vector< std::string > &subnames) |
Get Python tuple from object and sub-elements. | |
|
protected |
App::Document* Gui::Command::getDocument | ( | const char * | Name = 0 | ) | 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. NULL is returned when the name does not exist or no document is active!