Skip to content

Commit

Permalink
ENH: Add Python-accessible CLI progress query method
Browse files Browse the repository at this point in the history
The method allows Jupyter notebook widgets to report progress during CLI execution.
  • Loading branch information
lassoan committed May 7, 2020
1 parent 07c5324 commit 865dd83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Libs/MRML/CLI/vtkMRMLCommandLineModuleNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ bool vtkMRMLCommandLineModuleNode::IsBusy() const
return this->Internal->Status & vtkMRMLCommandLineModuleNode::BusyMask;
}

//----------------------------------------------------------------------------
int vtkMRMLCommandLineModuleNode::GetProgress() const
{
return vtkMath::Round(this->GetModuleDescription().GetProcessInformation()->Progress * 100.0);
}

//----------------------------------------------------------------------------
void vtkMRMLCommandLineModuleNode::SetAutoRun(bool autoRun)
{
Expand Down
2 changes: 2 additions & 0 deletions Libs/MRML/CLI/vtkMRMLCommandLineModuleNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ class VTK_MRML_CLI_EXPORT vtkMRMLCommandLineModuleNode : public vtkMRMLNode
/// \sa SetStatus(), GetStatus(), BusyMask, Cancel()
bool IsBusy()const;

int GetProgress()const;

/// Set a request to stop the processing of the CLI.
/// Do nothing if the module is not "busy".
/// \sa IsBusy(), Cancelling, Cancelled
Expand Down

0 comments on commit 865dd83

Please sign in to comment.