Macro recording and play back management The purpos of this class is to handle record function calls from a command and save it in a macro file (so far). More...
#include <Macro.h>
Public Types | |
enum | LineType { Base, Gui } |
Line type enumeration. More... | |
enum | MacroType { File, App, Doc } |
Macro type enumeration. More... | |
Public Member Functions | |
void | addLine (LineType Type, const char *sLine) |
insert a new line in the macro | |
void | cancel (void) |
cancels the recording session | |
void | commit (void) |
close (and save) the recording session | |
PythonDebugger * | debugger () const |
Get the Python debugger. | |
bool | isOpen (void) const |
indicates if a macro recording in in progress | |
void | OnChange (Base::Subject< const char * > &rCaller, const char *sReason) |
Observes its parameter group. | |
void | open (MacroType eType, const char *sName) |
Opens a new Macro recording session Starts a session with the type and the name of the macro. | |
void | run (MacroType eType, const char *sName) |
void | setModule (const char *sModule) |
Set the active module This is normaly done by the workbench switch. | |
Protected Member Functions | |
MacroManager () | |
~MacroManager () | |
Protected Attributes | |
bool | guiAsComment |
QString | macroInProgress |
Container for the macro. | |
QString | macroName |
name of the macro | |
bool | openMacro |
Base::Reference< ParameterGrp > | params |
PythonConsole * | pyConsole |
PythonDebugger * | pyDebugger |
bool | recordGui |
bool | scriptToPyConsole |
Friends | |
struct | ApplicationP |
Macro recording and play back management The purpos of this class is to handle record function calls from a command and save it in a macro file (so far).
Definition at line 43 of file Macro.h.
Line type enumeration.
Base |
The line effects only the document and Application (FreeCAD). |
Gui |
The line effects the Gui (FreeCADGui). |
Macro type enumeration.
File |
The macro will be saved in a file. |
App |
The macro belongs to the Application and will be saved in the UserParameter. |
Doc |
Teh macro belongs to the Document and will be saved and restored with the Document. |
MacroManager::MacroManager | ( | ) | [protected] |
Definition at line 49 of file Macro.cpp.
References App::GetApplication(), App::Application::GetParameterGroupByPath(), and params.
MacroManager::~MacroManager | ( | ) | [protected] |
Definition at line 63 of file Macro.cpp.
References params, and pyDebugger.
void MacroManager::addLine | ( | LineType | Type, | |
const char * | sLine | |||
) |
insert a new line in the macro
Definition at line 158 of file Macro.cpp.
References Gui::getMainWindow(), Gui, guiAsComment, macroInProgress, openMacro, Gui::PythonConsole::printStatement(), pyConsole, recordGui, and scriptToPyConsole.
Referenced by StdCmdViewIvIssueCamPos::activated(), Gui::Command::doCommand(), Gui::Application::runCommand(), Gui::Application::runPythonCode(), and Gui::Application::setActiveDocument().
void MacroManager::cancel | ( | void | ) |
cancels the recording session
Definition at line 149 of file Macro.cpp.
References Base::Console(), macroInProgress, macroName, and openMacro.
Referenced by commit(), and Gui::Dialog::DlgMacroRecordImp::on_buttonCancel_clicked().
void MacroManager::commit | ( | void | ) |
close (and save) the recording session
Definition at line 93 of file Macro.cpp.
References cancel(), Base::Console(), DrawingExample::file, macroInProgress, macroName, and openMacro.
Referenced by StdCmdMacroStopRecord::activated(), and Gui::Dialog::DlgMacroRecordImp::on_buttonStop_clicked().
PythonDebugger * MacroManager::debugger | ( | ) | const |
Get the Python debugger.
Definition at line 232 of file Macro.cpp.
References pyDebugger.
Referenced by Gui::PythonEditorView::PythonEditorView().
bool Gui::MacroManager::isOpen | ( | void | ) | const [inline] |
indicates if a macro recording in in progress
Definition at line 79 of file Macro.h.
Referenced by Gui::Dialog::DlgMacroRecordImp::DlgMacroRecordImp(), StdCmdDlgMacroExecute::isActive(), StdCmdMacroStopRecord::isActive(), StdCmdDlgMacroRecord::isActive(), Gui::Dialog::DlgMacroRecordImp::on_buttonCancel_clicked(), and Gui::Dialog::DlgMacroRecordImp::on_buttonStop_clicked().
void MacroManager::OnChange | ( | Base::Subject< const char * > & | rCaller, | |
const char * | sReason | |||
) | [virtual] |
Observes its parameter group.
Implements Base::Observer< const char * >.
Definition at line 69 of file Macro.cpp.
References guiAsComment, params, recordGui, and scriptToPyConsole.
void MacroManager::open | ( | MacroType | eType, | |
const char * | sName | |||
) |
Opens a new Macro recording session Starts a session with the type and the name of the macro.
All user interactions will be recorded as long as the commit() or cancel() isn't called. There is only one recording session possible. Trying to open a second one causes an exception:
eType | Type of the macro | |
sName | Name or path of the macro |
Definition at line 76 of file Macro.cpp.
References Base::Console(), File, macroInProgress, macroName, and openMacro.
Referenced by Gui::Dialog::DlgMacroRecordImp::on_buttonStart_clicked().
void MacroManager::run | ( | MacroType | eType, | |
const char * | sName | |||
) |
Definition at line 217 of file Macro.cpp.
References Base::Interpreter(), and Base::Exception::what().
Referenced by Gui::Dialog::DlgMacroExecuteImp::accept(), Gui::MacroCommand::activated(), and Gui::PythonEditorView::executeScript().
void MacroManager::setModule | ( | const char * | sModule | ) |
Set the active module This is normaly done by the workbench switch.
It sets the actually active application module so when the macro gets started the right import can be issued.
Definition at line 184 of file Macro.cpp.
References macroInProgress, and openMacro.
Referenced by Gui::Command::invoke().
friend struct ApplicationP [friend] |
bool Gui::MacroManager::guiAsComment [protected] |
Definition at line 99 of file Macro.h.
Referenced by addLine(), and OnChange().
QString Gui::MacroManager::macroInProgress [protected] |
QString Gui::MacroManager::macroName [protected] |
bool Gui::MacroManager::openMacro [protected] |
Base::Reference<ParameterGrp> Gui::MacroManager::params [protected] |
Definition at line 103 of file Macro.h.
Referenced by MacroManager(), OnChange(), and ~MacroManager().
PythonConsole* Gui::MacroManager::pyConsole [protected] |
PythonDebugger* Gui::MacroManager::pyDebugger [protected] |
Definition at line 102 of file Macro.h.
Referenced by debugger(), and ~MacroManager().
bool Gui::MacroManager::recordGui [protected] |
Definition at line 98 of file Macro.h.
Referenced by addLine(), and OnChange().
bool Gui::MacroManager::scriptToPyConsole [protected] |
Definition at line 100 of file Macro.h.
Referenced by addLine(), and OnChange().