Documentation/CLI Support in CTK: Difference between revisions

From Commontk
Jump to navigationJump to search
(Created page with "This page is a working draft and does not contain final information. Command Line Interface (CLI) support in CTK will primarly focus on providing an API for working with existin...")
 
mNo edit summary
 
(19 intermediate revisions by 5 users not shown)
Line 1: Line 1:
This page is a working draft and does not contain final information.
Command Line Interface (CLI) support in CTK will primarly focus on providing an API for working with existing CLI modules. Providing utilities and tools for creating CLI modules from scratch is a desired addition but there are no concrete plans for this yet. See [[Documentation/Command_Line_Interface]] for more general information about CLI modules.


Command Line Interface (CLI) support in CTK will primarly focus on providing an API for working with existing CLI modules. Providing utiltities and tools for creating CLI modules from scratch is a desired addition but there are no concrete plans for this yet.
=== Getting the Code ===


The code is available in the CTK master:


=== Experimental Code ===
https://github.com/commontk/CTK
 
Some experimental code can be found here:
 
https://github.com/saschazelzer/CTK/tree/wip-cli-support


Enable the following CMake options to be able to play with the code:
Enable the following CMake options to be able to play with the code:


* '''BUILD_TESTING''' (for creating CLI test modules)
* '''BUILD_TESTING''' (for creating CLI test modules)
* '''CTK_APP_ctkCLIPluginExplorer''' (small program allowing you to test-drive CLI modules using the CTK CLI module API)
* '''CTK_APP_ctkCommandLineModuleExplorer''' (small program allowing you to test-drive CLI modules using the CTK CLI module API, enables all the options below)
* '''CTK_BUILD_QTDESIGNER_PLUGINS''' (needed by the ctkCLIPluginExplorer to create a Qt GUI from the generated .ui files at runtime)
* '''CTK_LIB_CommandLineModules/Core''' (the CTK library providing the core CLI module API)
* '''CTK_LIB_ModuleDescription''' (the CTK library providing the CLI module API)
* '''CTK_LIB_CommandLineModules/Frontend/QtGui''' (the CTK library providing GUI generation using the Qt widgets)
* '''CTK_LIB_Widgets''' (used by the ctkCLIPluginExplorer to create a Qt GUI for the CLI module from the .ui file)
* '''CTK_LIB_CommandLineModules/Backend/LocalProcess''' (the CTK library for executing local executable files as command line modules)


=== API Design ===
=== API Design ===


...
This is a partially overview of the API design, showing the GUI generation process for the Qt front-end.
 
<graphviz>
digraph G {
graph [
rankdir = "TB"
];
node [
fontsize = "16"
shape = "ellipse"
];
edge [
];
subgraph cluster_0 {
  label = "CTK";
  color = lightGray;
  "xmlFile" [
  label = "{<f0> Command Line Module XML (.xml)| <f1>}"
  shape = "record"
  ];
  "gui" [
  label = "{<f0> Qt GUI | <f1>}"
  shape = "record"
  ];
  "uiFile" [
  label = "{<f0> CLI UI (.ui) | <f1>}"
  shape = "record"
  ];
  "ctkCLIModuleDescription" [
  label = "{<f0> ctkCmdLineModuleDescription| <f1>}"
  shape = "record"
  ];
}
 
subgraph cluster_1 {
  label = "3D Slicer";
  color = gray;
  "vtkMRMLParametersNode" [
  label = "{<f0> vtkMRMLParametersNode| <f1>}"
  shape = "record"
  ];
}
"xmlFile":f0:e -> "xmlFile":f0:ne [label = "XSD file check" ];
"xmlFile":f1 -> "uiFile":f0 [label = "QtGui XSL file" ];
"xmlFile":f1 -> "uiFile":f0 [label = "" style=invis];
"xmlFile":f1 -> "ctkCLIModuleDescription":f0 [label=ctkCmdLineModuleXmlParser];
"ctkCLIModuleDescription":f1 -> "vtkMRMLParametersNode":f0 [label=create];
"uiFile":f1 -> "gui":f0 [label = QUiLoader];
"gui":f1:e -> "vtkMRMLParametersNode":f1:w [dir = both label=synchronize constraint=false];
}
</graphviz>
 
Overview of some central classes and their scope.
 
Please see the full [file:///opt/ctk-builds/CTK-debug-gcc/CTK-build/Documentation/html/group__CommandLineModulesCore__API.html Core API] for a list of available classes and their documentation.
 
==== ctkCmdLineModuleDescription ====
 
C++ API for accessing the command line arguments meta-data defined in the XML description.
 
This class is ''read-only''.
 
==== ctkCmdLineModuleReference ====
 
A handle to a command line module.
 
* Get ctkCmdLineModuleDescription class
* Convenient meta-data access (module location etc.)
* Used to crate actual ctkCmdLineModuleFrontend instances from specific ctkCmdLineModuleFrontendFactory implementations
 
==== ctkCmdLineModuleFrontend ====
 
Represents an invokable command line module and its current parameter values.
 
Multiple instances for the same ModuleReference may exist.
 
* Set/Get individual parameter values or all at once
* Reset to default parameters
* Get GUI representation (QObject*)
* Get parameter value change notifications
 
==== ctkCmdLineModuleFuture ====
 
Returned by the ctkCmdLineModuleManager run method and used to communicate with a running module.
 
* Run/Abort
* Status
* Progress reporting
==== ctkCmdLineModuleManager ====
 
Responsible for managing and running other ctkCmdLineModule* classes.
* Register specific back-ends for handling different types of modules
* Register/Unregister modules
* Get ctkCmdLineModuleReference objects
* Run ctkCmdLineModuleFrontend objects


=== Customizability ===
=== Customizability ===


...
==== Qt Widget related ====
 
See also the [http://www.commontk.org/docs/html/classctkCmdLineModuleFrontendQtGui.html ctkCmdLineModuleFrontendQtGui] class for customization information.
 
* Use parameters for the default XSLT file to customize widget class names for argument types
* Use your own XSLT file for custom transformations of XML to UI
* Use your own QUiLoader to control instantiation of certain widget types


=== Boston Hackfest Work Items ===
==== General ====


...
* Use a custom ''factory'' to create your own GUI based on a ctkCmdLineModuleDescription instance.

Latest revision as of 06:57, 5 November 2014

Home < Documentation < CLI Support in CTK

Command Line Interface (CLI) support in CTK will primarly focus on providing an API for working with existing CLI modules. Providing utilities and tools for creating CLI modules from scratch is a desired addition but there are no concrete plans for this yet. See Documentation/Command_Line_Interface for more general information about CLI modules.

Getting the Code

The code is available in the CTK master:

https://github.com/commontk/CTK

Enable the following CMake options to be able to play with the code:

  • BUILD_TESTING (for creating CLI test modules)
  • CTK_APP_ctkCommandLineModuleExplorer (small program allowing you to test-drive CLI modules using the CTK CLI module API, enables all the options below)
  • CTK_LIB_CommandLineModules/Core (the CTK library providing the core CLI module API)
  • CTK_LIB_CommandLineModules/Frontend/QtGui (the CTK library providing GUI generation using the Qt widgets)
  • CTK_LIB_CommandLineModules/Backend/LocalProcess (the CTK library for executing local executable files as command line modules)

API Design

This is a partially overview of the API design, showing the GUI generation process for the Qt front-end.

This is a graph with borders and nodes. Maybe there is an Imagemap used so the nodes may be linking to some Pages.

Overview of some central classes and their scope.

Please see the full [file:///opt/ctk-builds/CTK-debug-gcc/CTK-build/Documentation/html/group__CommandLineModulesCore__API.html Core API] for a list of available classes and their documentation.

ctkCmdLineModuleDescription

C++ API for accessing the command line arguments meta-data defined in the XML description.

This class is read-only.

ctkCmdLineModuleReference

A handle to a command line module.

  • Get ctkCmdLineModuleDescription class
  • Convenient meta-data access (module location etc.)
  • Used to crate actual ctkCmdLineModuleFrontend instances from specific ctkCmdLineModuleFrontendFactory implementations

ctkCmdLineModuleFrontend

Represents an invokable command line module and its current parameter values.

Multiple instances for the same ModuleReference may exist.

  • Set/Get individual parameter values or all at once
  • Reset to default parameters
  • Get GUI representation (QObject*)
  • Get parameter value change notifications

ctkCmdLineModuleFuture

Returned by the ctkCmdLineModuleManager run method and used to communicate with a running module.

  • Run/Abort
  • Status
  • Progress reporting

ctkCmdLineModuleManager

Responsible for managing and running other ctkCmdLineModule* classes.

  • Register specific back-ends for handling different types of modules
  • Register/Unregister modules
  • Get ctkCmdLineModuleReference objects
  • Run ctkCmdLineModuleFrontend objects

Customizability

Qt Widget related

See also the ctkCmdLineModuleFrontendQtGui class for customization information.

  • Use parameters for the default XSLT file to customize widget class names for argument types
  • Use your own XSLT file for custom transformations of XML to UI
  • Use your own QUiLoader to control instantiation of certain widget types

General

  • Use a custom factory to create your own GUI based on a ctkCmdLineModuleDescription instance.