Interface Method Argument Descriptors

Argument Descriptor

Descriptor for method arguments (inputs and outputs) of interface methods.

This descriptor contains the specifications of:

  • argument kind (depending on the specified type);
  • argument count;
  • associated documentation.
class ORSServiceClass.OrsPlugin.InterfaceMethodArgumentDescriptors.argumentdescriptor.ArgumentDescriptor(valueType, count=1, const=False, documentation='')
COUNT_GREATER_OR_EQUAL_THAN_VALUE = 2
COUNT_LESS_OR_EQUAL_THAN_VALUE = 1
COUNT_RANGE = 3
COUNT_SINGLE = 0
canExtractValueFromASTNode(nodeValue)
canIdentifyVariableByValue(singleValue)
canSelectionBeUsedToDefineVariable()
classmethod createFromDocstringDict(dictArgumentFromDocstring, isInput)
classmethod determineCountValue(count)

Method used to determine if the argument is a list of elements of the specified type, or if no list should be used.

It determines also how many elements can be contained in the list.

Parameters:count – a single integer or a list of 2 integers. If given as a single integer, the argument is a list that should contain that number of elements. That number must be greater or equal to 0. Exception: if the value “1”, no list is used. If given as a list of 2 positive integers, the first value gives the minimal acceptable count of elements in the list and the second value gives the maximal acceptable count of elements in the list. The second value must be greater or equal than the first value. The first value can be set as “None”, meaning 0. The second value can be set as “None”, meaning no maximum count.
Returns:output – 1 if the argument should be used directly (no list used), or a list with 2 elements (the minimal and maximal accepted number of elements in the list)
extractValueFromASTNode(nodeValue)
getAsCallable(value)

Gets a callable version of a value of a given type.

This method is to be used when we want to preserve the identity of an immutable variable (ex: int, float, str, …) in the logging process.

Use this method on the argument descriptor.

See also: ArgumentDescriptor.getVariableAsCallable

Parameters:value – the value to get a callable version of
Return:the callable version of the value (if the argument type supports this functionality)
getAvailableTypes()
getConstAsString()
getCountAsString()

Gets the count as a string. This is a summary string for display information. :return: string of the count :rtype: str

getCountForDocstring()

Gets the count description string. Example: “[2, None]”. This is to be used when writing the file canvas, in the docstring of the interface method.

Return:string to print.
Rtype:str
getCountMax()
getCountMin()
getCountMode()
getDefaultValueAsString()
getDocumentation()
getIsConstValue()
getIsValidValue(valueToValidate)
getPythonObjectFromInputArgument(name, valueToValidate)
getRepresentsAConstantValue()
getRepresentsFileValue()
getRepresentsFolderValue()
getRepresentsORSModelClassValue()
getRepresentsORSObjectValue()
getRepresentsPythonNativeValue()
getSingleElementFromAvailableSelection()
getSingleValueRepresentationAsOutput(singleValue)
getSingleValueRepresentationForDefinition(singleValue)
getSingleValueShouldBeDefined(singleValue)
getTypeAsString()

Gets the type of a single argument :return: string of the type :rtype: str

getUniqueIdentifierForSingleValue(singleValue)
getValueFromWidget(descriptorWidget)
classmethod getVariableAsCallable(value, valueType)

Gets a callable version of a value of a given type.

This method is to be used when we want to preserve the identity of an immutable variable (ex: int, float, str, …) in the logging process.

Use this method when the argument descriptor is not known in advance, for example when we want to use the same integer in input of multiple method calls to be logged.

See also: ArgumentDescriptor.getAsCallable

Parameters:
  • value – the value to get a callable version of
  • valueType – the type of the value (ex: bool, int, float, str)
Returns:

output – the callable version of the value (if the argument type supports this functionality)

getWidget(parent)
isAvailableSelectionContainsSingleElement()
isAvailableSelectionShouldConsiderAllVariableUsages()
isCollection()
isValueValidForAllDescriptors(valueToValidate)
setDescriptorsToSatisfyForValidAvailableSelection(listArgumentDescriptors)
setValueInWidget(descriptorWidget, value)

Types of arguments

These are the accepted types to be used in common interface methods.

Python native

Descriptor for arguments of Python native types.

Supported types:

Type to write Accepted argument type Example of argument
bool bool True
int int 5
float float or int 6.48, 5
str str 'Hello world!'
tuple tuple (2, -3.5, 6, True, None)
dict dict {'a': 3, 'b': -10}

Files

Descriptor for arguments specifying files.

Supported types:

Type to write Accepted argument type Example of argument
file a string of a path to an existing file on the disk 'C:/tmp/anExistingFile.png'
file saving a string of a path to a file that may exist or not (used essentially for saving results) 'C:/tmp/aFileToCreate.png'

Folders

Descriptor for arguments specifying folders.

Supported types:

Type to write Accepted argument type Example of argument
folder a string of a path to an existing folder on the disk 'C:/tmp/anExistingFolder'
folder saving a string of a path to a folder that may exist or not (used essentially for saving results) 'C:/tmp/aFolderToCreate'

Instances of Managed

Descriptor for arguments of ORS Managed types.

Supported types:

Type to write Accepted argument type Example of argument

any subclass of ORSModel.ors.Managed, separated by commas.

Example (for an instance of the Channel class): ORSModel.ors.Channel

Example (for an instance of the ROI or MultiROI class): ORSModel.ors.ROI, ORSModel.ors.MultiROI

an instance of this class (recommended) Channel()
a string of the GUID of the instance of this class (in that case, the instance corresponding to this GUID will be given to the method) '8709183874076527723CxvChannel'

Instances of Unmanaged

Descriptor for arguments of ORS Unmanaged types.

Supported types:

Type to write Accepted argument type Example of argument

any subclass of ORSModel.ors.Unmanaged

Example (for an instance of the Vector3 class): ORSModel.ors.Vector3

an instance of this class orsVect(1.0, 0.0, 0.0)

Classes of Managed or Unmanaged

Descriptor for arguments of ORS Managed and ORS Unmanaged classes types.

Supported types:

Type to write Accepted argument type Example of argument

any subclass of ORSModel.ors.Managed or ORSModel.ors.Unmanaged, followed by class.

Example (for the StructuredGrid class): ORSModel.ors.StructuredGrid class

the specified class or any of his subclasses Channel

IntEnum

Descriptor for arguments of IntEnum types.

Supported types:

Type to write Accepted argument type Example of argument

any subclass of IntEnum contained in COMWrapper.ORS_def, preceded by IntEnum.

Example (for the CxvChannel_Data_Type class): IntEnum CxvChannel_Data_Type

an element of the specified IntEnum class (recommended) COMWrapper.ORS_def.CxvChannel_Data_Type.CXVCHANNEL_DATA_TYPE_UNSIGNED_INT
an integer corresponding to an element of the specified IntEnum class. 4

Transient

Descriptor for arguments of transient type.

These arguments are to be used to transfer intermediate results between multiple logging methods. It can occur in situation such as: a first step of computation is done, then the user interaction is required to determine a value based on the first step of computation (using a UI manipulator), then performing a second step to complete the workflow. This transient object to be transferred between interface methods may contain the GUIDs of Managed instances to be used at the second step and any other kind of information. It is suggested to define a class where the information can be entered.

Supported types:

Type to write Accepted argument type Example of argument

transient followed by the class name

Example (for an instance of the myTransientClass class): transient myTransientClass

any mutable variable myTransientClass()

Source code example:

  1. Download the compressed file;
  2. Extract these files into a plugin extension folder;
  3. Start the application;
  4. Open the top level menu Demos to see the menu item named Demo: transient argument. Click on that menu item to create an instance of the plugin and open his mainform;
  5. Start a new recording of the Macro Player;
  6. Click on the button Generate new Class1 instance to generate a new instance of Class1;
  7. Using the spin box, set a new value for the integer;
  8. Using the line edit, set a new value for the string;
  9. Click on the button Show values in popup to see these values in a popup window;
  10. Stop the macro recording;
  11. Replay the macro.

Undefined

Descriptor for arguments of undefined type.

Supported types:

Type to write Accepted argument type Example of argument
undefined anything np.amin