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 { App , Gui , Cmt } |
Line type enumeration More... | |
enum | MacroType { File , User , Doc } |
Macro type enumeration More... | |
Public Member Functions | |
void | addLine (LineType Type, const char *sLine, bool pending=false) |
insert a new line in the macro More... | |
void | cancel (void) |
cancels the recording session More... | |
void | commit (void) |
close (and save) the recording session More... | |
PythonDebugger * | debugger () const |
Get the Python debugger. More... | |
long | getLines () const |
Return the added lines regardless of recording or not. More... | |
bool | isOpen (void) const |
indicates if a macro recording is in progress More... | |
void | OnChange (Base::Subject< const char * > &rCaller, const char *sReason) |
Observes its parameter group. More... | |
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. More... | |
void | run (MacroType eType, const char *sName) |
void | setModule (const char *sModule) |
Set the active module This is normally done by the workbench switch. More... | |
Public Member Functions inherited from Base::Observer< const char * > | |
virtual const char * | Name () |
This method can be reimplemented from the concrete Observer and returns the name of the observer. More... | |
Observer () | |
A constructor. More... | |
virtual void | OnChange (Subject< const char * > &rCaller, const char * rcReason)=0 |
This method need to be reimplemented from the concrete Observer and get called by the observed class. More... | |
virtual void | OnDestroy (Subject< const char * > &rCaller) |
This method need to be reimplemented from the concrete Observer and get called by the observed class. More... | |
virtual | ~Observer () |
A destructor. More... | |
Protected Member Functions | |
MacroManager () | |
~MacroManager () | |
Protected Attributes | |
bool | guiAsComment |
bool | localEnv |
QStringList | macroInProgress |
Container for the macro. More... | |
QString | macroName |
name of the macro More... | |
bool | openMacro |
Base::Reference< ParameterGrp > | params |
std::vector< std::pair< LineType, std::string > > | pendingLine |
PythonConsole * | pyConsole |
PythonDebugger * | pyDebugger |
bool | recordGui |
bool | scriptToPyConsole |
long | totalLines |
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).
Line type enumeration
Enumerator | |
---|---|
App | The line effects only the document and Application (FreeCAD) |
Gui | The line effects the Gui (FreeCADGui) |
Cmt | The line is handled as a comment. |
Macro type enumeration
Enumerator | |
---|---|
File | The macro will be saved in a file. |
User | The macro belongs to the Application and will be saved in the UserParameter. |
Doc | The macro belongs to the Document and will be saved and restored with the Document. |
|
protected |
|
protected |
References pyDebugger.
insert a new line in the macro
References addLine(), Cmt, Gui::getMainWindow(), guiAsComment, macroInProgress, openMacro, pendingLine, Gui::PythonConsole::printStatement(), pyConsole, recordGui, scriptToPyConsole, and totalLines.
Referenced by StdCmdViewIvIssueCamPos::activated(), addLine(), Gui::Command::addModule(), PendingLine::cancel(), Gui::SelectionSingleton::clearCompleteSelection(), Gui::SelectionSingleton::clearSelection(), PendingLine::PendingLine(), Gui::Command::printCaller(), Gui::Application::sDoCommand(), Gui::Application::sDoCommandGui(), and Gui::Application::setActiveDocument().
void MacroManager::cancel | ( | void | ) |
cancels the recording session
References Base::Console(), Base::ConsoleSingleton::Log(), macroInProgress, macroName, and openMacro.
Referenced by commit(), DraftGui.DraftToolBar::finish(), DraftGui.DraftToolBar::offUi(), Gui::Dialog::DlgMacroRecordImp::on_buttonCancel_clicked(), and DraftGui.DraftToolBar::pointUi().
void MacroManager::commit | ( | void | ) |
close (and save) the recording session
References cancel(), Base::Console(), Base::ConsoleSingleton::Error(), Base::ConsoleSingleton::Log(), macroInProgress, macroName, and openMacro.
Referenced by draftguitools.gui_offset.Offset::action(), StdCmdMacroStopRecord::activated(), draftguitools.gui_labels.Label::create(), draftguitools.gui_dimensions.Dimension::create_angle_dimension(), draftguitools.gui_dimensions.Dimension::create_linear_dimension(), draftguitools.gui_dimensions.Dimension::create_linear_dimension_obj(), draftguitools.gui_dimensions.Dimension::create_radial_dimension_obj(), draftguitools.gui_dimensions.Dimension::create_with_app_measure(), draftguitools.gui_ellipses.Ellipse::createObject(), draftguitools.gui_rectangles.Rectangle::createObject(), draftguitools.gui_shapestrings.ShapeString::createObject(), draftguitools.gui_texts.Text::createObject(), draftguitools.gui_stretch.Stretch::doStretch(), draftguitools.gui_fillets.Fillet::draw_arc(), draftguitools.gui_arcs.Arc::drawArc(), draftguitools.gui_polygons.Polygon::drawPolygon(), draftguitools.gui_beziers.BezCurve::finish(), draftguitools.gui_beziers.CubicBezCurve::finish(), draftguitools.gui_lines.Line::finish(), draftguitools.gui_splines.BSpline::finish(), draftguitools.gui_mirror.Mirror::mirror(), draftguitools.gui_move.Move::move_object(), draftguitools.gui_move.Move::move_subelements(), draftguitools.gui_offset.Offset::numericRadius(), Gui::Dialog::DlgMacroRecordImp::on_buttonStop_clicked(), draftguitools.gui_array_simple.Array::proceed(), draftguitools.gui_downgrade.Downgrade::proceed(), draftguitools.gui_draft2sketch.Draft2Sketch::proceed(), draftguitools.gui_join.Join::proceed(), draftguitools.gui_patharray.PathArray::proceed(), draftguitools.gui_pathtwistedarray.PathTwistedArray::proceed(), draftguitools.gui_pointarray.PointArray::proceed(), draftguitools.gui_shape2dview.Shape2DView::proceed(), draftguitools.gui_upgrade.Upgrade::proceed(), draftguitools.gui_split.Split::proceed(), draftguitools.gui_rotate.Rotate::rotate_object(), draftguitools.gui_rotate.Rotate::rotate_subelements(), draftguitools.gui_scale.Scale::scale_object(), draftguitools.gui_scale.Scale::scale_subelements(), and draftguitools.gui_scale.Scale::scale_with_clone().
PythonDebugger * MacroManager::debugger | ( | ) | const |
long Gui::MacroManager::getLines | ( | ) | const |
Return the added lines regardless of recording or not.
bool Gui::MacroManager::isOpen | ( | void | ) | const |
indicates if a macro recording is in progress
Referenced by Gui::Dialog::DlgMacroRecordImp::DlgMacroRecordImp(), StdCmdDlgMacroRecord::isActive(), StdCmdMacroStopRecord::isActive(), StdCmdDlgMacroExecute::isActive(), Gui::Dialog::DlgMacroRecordImp::on_buttonCancel_clicked(), and Gui::Dialog::DlgMacroRecordImp::on_buttonStop_clicked().
|
virtual |
Observes its parameter group.
Implements Base::Observer< const char * >.
References guiAsComment, localEnv, 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 |
References Base::Console(), File, Base::ConsoleSingleton::Log(), macroInProgress, macroName, and openMacro.
Referenced by Gui::Dialog::DlgMacroRecordImp::on_buttonStart_clicked().
void MacroManager::run | ( | MacroType | eType, |
const char * | sName | ||
) |
References App::GetApplication(), ParameterGrp::GetBool(), ParameterGrp::GetGroup(), App::Application::GetUserParameter(), Base::Interpreter(), localEnv, and Base::InterpreterSingleton::runFile().
Referenced by Gui::Dialog::DlgMacroExecuteImp::accept(), Gui::MacroCommand::activated(), Gui::RecentMacrosAction::activateFile(), femexamples.examplesgui.FemExamples::clicked(), Gui::PythonEditorView::executeScript(), and femsolver.task.Task::protector().
void MacroManager::setModule | ( | const char * | sModule | ) |
Set the active module This is normally done by the workbench switch.
It sets the actually active application module so when the macro gets started the right import can be issued.
References macroInProgress, and openMacro.
|
friend |
|
protected |
Referenced by addLine(), and OnChange().
|
protected |
Referenced by OnChange(), and run().
|
protected |
Container for the macro.
Referenced by addLine(), cancel(), commit(), open(), and setModule().
|
protected |
|
protected |
Referenced by addLine(), cancel(), commit(), open(), and setModule().
|
protected |
Referenced by PathScripts.post.comparams_post.saveVals::retVals().
|
protected |
Referenced by addLine().
|
protected |
Referenced by addLine().
|
protected |
Referenced by debugger(), and ~MacroManager().
|
protected |
Referenced by addLine(), and OnChange().
|
protected |
Referenced by addLine(), and OnChange().
|
protected |
Referenced by addLine().