Gui: Command API changes

* invoke(), distinguish between command triggering source. Also add
  support of auto transaction using App::AutoTransaction. Now all
  command will support undo/redo by default.

* setupCheckable(), a helper function to Improve support of
  PythonGroupCommand

* getObjectCmd(), helper function to output Python command to refer to
  an object without ambiguity. Because with introduction of external
  linking, an object can no longer be safely referred through the
  current active document.

* Support auto MacroManager command logger. For commands that does not
  log any output to MacroManager, a log entry of 'Gui.runCommand()' will
  be auto generated.

* Support linked object in copyVisual()

* Modified do/runCommand() to print calling file and line number.

* Add various helper macros for run command involving a document or
  object.
This commit is contained in:
Zheng, Lei
2019-07-07 12:00:13 +08:00
committed by wmayer
parent cd7725227f
commit 4bd31c4b91
8 changed files with 678 additions and 93 deletions

View File

@@ -54,7 +54,8 @@ MacroManager::MacroManager()
scriptToPyConsole(true),
localEnv(true),
pyConsole(0),
pyDebugger(new PythonDebugger())
pyDebugger(new PythonDebugger()),
totalLines(0)
{
// Attach to the Parametergroup regarding macros
this->params = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro");
@@ -166,8 +167,25 @@ void MacroManager::cancel(void)
this->openMacro = false;
}
void MacroManager::addLine(LineType Type, const char* sLine)
void MacroManager::addLine(LineType Type, const char* sLine, bool pending)
{
if(pending) {
if(!sLine)
pendingLine.clear();
else {
pendingType = Type;
pendingLine = sLine;
}
return;
}
if(!sLine)
return;
if(pendingLine.size() && pendingLine.c_str()!=sLine) {
addLine(pendingType,pendingLine.c_str());
pendingLine.clear();
}
++totalLines;
if (this->openMacro) {
bool comment = false;
if (Type == Gui) {