Gui::MacroManager Class Reference

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...
 
PythonDebuggerdebugger () 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< ParameterGrpparams
 
std::vector< std::pair< LineType, std::string > > pendingLine
 
PythonConsolepyConsole
 
PythonDebuggerpyDebugger
 
bool recordGui
 
bool scriptToPyConsole
 
long totalLines
 

Friends

struct ApplicationP
 

Detailed Description

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).

Author
J├╝rgen Riegel

Member Enumeration Documentation

◆ LineType

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.

◆ MacroType

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.

Constructor & Destructor Documentation

◆ MacroManager()

◆ ~MacroManager()

MacroManager::~MacroManager ( )
protected

References pyDebugger.

Member Function Documentation

◆ addLine()

◆ cancel()

◆ commit()

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().

◆ debugger()

PythonDebugger * MacroManager::debugger ( ) const

Get the Python debugger.

References pyDebugger.

Referenced by Gui::PythonEditorP::PythonEditorP().

◆ getLines()

long Gui::MacroManager::getLines ( ) const

Return the added lines regardless of recording or not.

◆ isOpen()

◆ OnChange()

void MacroManager::OnChange ( Base::Subject< const char * > &  rCaller,
const char *  sReason 
)
virtual

Observes its parameter group.

Implements Base::Observer< const char * >.

References guiAsComment, localEnv, recordGui, and scriptToPyConsole.

◆ open()

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:

Parameters
eTypeType of the macro
sNameName or path of the macro
See also
commit()
cancel()

References Base::Console(), File, Base::ConsoleSingleton::Log(), macroInProgress, macroName, and openMacro.

Referenced by Gui::Dialog::DlgMacroRecordImp::on_buttonStart_clicked().

◆ run()

◆ setModule()

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.

Friends And Related Function Documentation

◆ ApplicationP

friend struct ApplicationP
friend

Member Data Documentation

◆ guiAsComment

bool Gui::MacroManager::guiAsComment
protected

Referenced by addLine(), and OnChange().

◆ localEnv

bool Gui::MacroManager::localEnv
protected

Referenced by OnChange(), and run().

◆ macroInProgress

QStringList Gui::MacroManager::macroInProgress
protected

Container for the macro.

Referenced by addLine(), cancel(), commit(), open(), and setModule().

◆ macroName

QString Gui::MacroManager::macroName
protected

name of the macro

Referenced by cancel(), commit(), and open().

◆ openMacro

bool Gui::MacroManager::openMacro
protected

Referenced by addLine(), cancel(), commit(), open(), and setModule().

◆ params

Base::Reference<ParameterGrp> Gui::MacroManager::params
protected

◆ pendingLine

std::vector<std::pair<LineType,std::string> > Gui::MacroManager::pendingLine
protected

Referenced by addLine().

◆ pyConsole

PythonConsole* Gui::MacroManager::pyConsole
protected

Referenced by addLine().

◆ pyDebugger

PythonDebugger* Gui::MacroManager::pyDebugger
protected

Referenced by debugger(), and ~MacroManager().

◆ recordGui

bool Gui::MacroManager::recordGui
protected

Referenced by addLine(), and OnChange().

◆ scriptToPyConsole

bool Gui::MacroManager::scriptToPyConsole
protected

Referenced by addLine(), and OnChange().

◆ totalLines

long Gui::MacroManager::totalLines
protected

Referenced by addLine().


The documentation for this class was generated from the following files: