File: action.py

package info (click to toggle)
camitk 6.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 389,508 kB
  • sloc: cpp: 103,476; sh: 2,448; python: 1,618; xml: 984; makefile: 128; perl: 84; sed: 20
file content (35 lines) | stat: -rw-r--r-- 1,332 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
# Script designed to be tested from inside the CamiTK Python interpreter using PythonManager::runScript
# See TestPythonScript.cpp
# 
# The requirements (if any) must defined in the the QRC file
#
import camitk

# get a known action
action = camitk.Application.getAction("Resample")
assert str(type(action)) == "<class 'camitk.Action'>"
assert action.getName() == "Resample"

# test parameter values
assert action.getParameterValue("New Image X Dimension") == 256
action.setParameterValue("New Image X Dimension", -1)
assert action.getParameterValue("New Image X Dimension") == -1

# test camitk property
prop = action.getProperty("New Image X Dimension")
assert prop.getName() == "New Image X Dimension"
assert prop.getDescription() == "The new image width (in voxels)."
assert prop.getUnit() == ""
assert prop.getReadOnly() == False
assert prop.getAttribute("minimum") == 1
assert prop.getAttribute("maximum") == 2**31 - 1 # set as std::numeric_limits<int>::max() in the Resample action constructor
assert prop.getAttribute("singleStep") == 1
prop.setAttribute("minimum", -42)
assert prop.getAttribute("minimum") == -42
prop.setAttribute("maximum", 0)
assert prop.getAttribute("maximum") == 0
prop.setAttribute("singleStep", 5)
assert prop.getAttribute("singleStep") == 5
prop.setReadOnly(True)
assert prop.getReadOnly() == True