CMLibs Argon
The CMLibs Argon is the core data structures for GUI applications using Zinc cmlibs.org.
Manages and serializes argon file.
Install
Requirements
python >= 3.6
cmlibs.zinc >= 3.6
pip install
CMLibs Argon can be installed from PyPi.org with the following command:
pip install cmlibs.argon
Usage
This package provides ten modules
argondocument
argonerror
argonlogger
argonmaterials
argonmodelsources
argonregion
argonsceneviewer
argonspectrums
argontessellations
argonviews
These modules are surfaced under the namespace package cmlibs within the argon package. To use these modules the following import statement can be used:
import cmlibs.argon.argondocument
import cmlibs.argon.argonerror
import cmlibs.argon.argonlogger
import cmlibs.argon.argonmaterials
import cmlibs.argon.argonmodelsources
import cmlibs.argon.argonregion
import cmlibs.argon.argonsceneviewer
import cmlibs.argon.argonspectrums
import cmlibs.argon.argontessellations
import cmlibs.argon.argonviews
Classes
ArgonDocument Class
- class cmlibs.argon.argondocument.ArgonDocument(name='Argon')
- checkVersion(minimum_required)
Check the version number of this Argon library. Raise an error if current Argon is less than the minimun required version.
- deserialize(state)
Read the JSON description to the argon document object. This will change the settings of ArgonDocument Object.
- Parameters:
state – string serialisation of Argon JSON document.
- findRegion(name)
Find region by name.
- Parameters:
name – The name of the region as a string.
- Returns:
ArgonRegion or None if region is not found.
- freeVisualisationContents()
Deletes subobjects of document to help free memory held by Zinc objects earlier.
- getMaterials()
Returns the materials in the context.
- Returns:
ArgonMaterials
- getName()
Returns the name of the zinc Context.
- Returns:
string
- getRootRegion()
Returns the root region in the context. A convenience for applications that need only one region tree.
- Returns:
ArgonRegion
- getSpectrums()
Returns the spectrums in the context.
- Returns:
ArgonSpectrums
- getTessellations()
Returns the tessellations in the context.
- Returns:
ArgonTessellations
- getViewManager()
Returns the view manager in the context.
- Returns:
ArgonViewManager
- getZincContext()
Returns the underlying Zinc context for the document.
- Returns:
cmlibs.zinc.context.Context
- initialiseVisualisationContents()
Initialise the default Visualisation Contents.
- serialize(base_path=None)
Write the JSON file describing the Argon document in the argon document object, which can be used to store the current argon document settings.
- Parameters:
base_path – The base path of JSON file, default is None.
- Returns:
Python JSON object containing the JSON description of argon document object.
ArgonError Class
ArgonLogger Class
- class cmlibs.argon.argonlogger.ArgonLogger
- static closeLogger()
Deletes subobjects of Argon logger to help free memory held by Argon objects earlier.
- static getLogger()
Return the Argon Logger.
- Returns:
ArgonLogger
- static loggerCallback(event)
Argon Logger Callback, wirte different type of message based on the input event flags.
- Parameters:
event – event
- static setCallback(callback)
Set Argon Logger callback.
- Parameters:
callback – Callback function.
- static setZincContext(zincContext)
Set the underlying Zinc context for the Argon Logger.
- Parameters:
zincContext – cmlibs.zinc.context.Context
- static writeErrorMessage(string)
Write Argon Logger Error message.
- Parameters:
string – string
- static writeInformationMessage(string)
Write Argon Logger Information message.
- Parameters:
string – string
- static writeWarningMessage(string)
Write Argon Logger Warning message.
- Parameters:
string – string
ArgonMaterials Class
- class cmlibs.argon.argonmaterials.ArgonMaterials(zincContext)
Manages and serializes Zinc Materials.
- deserialize(dictInput)
Read the JSON description to the argon Material object. This will change the materials in the material module.
- Parameters:
dictInput – The string containing JSON description.
- getZincContext()
Returns the underlying Zinc context for the Argon Material.
- Returns:
cmlibs.zinc.context.Context
- serialize()
Write the JSON file describing the materials in the Argon Materials object, which can be used to store the current material settings.
- Returns:
Python JSON object containing the JSON description of Argon Materials object, otherwise 0.
ArgonModelSourceFile Class
- class cmlibs.argon.argonmodelsources.ArgonModelSourceFile(file_name=None, dict_input=None)
- addToZincStreaminformationRegion(stream_info)
Add to Zinc Stream information Region.
- Parameters:
stream_info – streamInfo
- getDisplayName()
Returns the display name of current Argon model sources.
- Returns:
string
- getFileName()
Returns the file name of current Argon model sources.
- Returns:
string
- getTime()
Returns the time of current Argon model sources.
- Returns:
string
- getType()
Returns Argon Model Source File type “FILE”.
- Returns:
string
- isEdit()
Returns the edit state of current Argon model sources.
- Returns:
boolean
- isLoaded()
Returns the load state of current Argon model sources.
- Returns:
boolean
- serialize(base_path=None)
Write the JSON file describing the Argon model sources, which can be used to store the current Argon model sources settings. :param base_path: The base path of JSON file, default is None. :return: Python JSON object containing the JSON description of Argon model sources object.
- setEdit(edit)
Change edit state for Argon model sources.
- Parameters:
edit – boolean
- setFileName(file_name)
Set file name.
- Parameters:
file_name – string
- setTime(time)
Change time.
- Parameters:
time – string
- unload()
Set Argon model sources loaded state to False.
ArgonRegion Class
- class cmlibs.argon.argonregion.ArgonRegion(name, zincRegion, parent=None)
- addFieldTypeToDict(field, fieldType)
Add new field type and field to the field type dictionary in current region.
- Parameters:
field – The field need to be added to current region.
fieldType – The field type of the field.
- addModelSource(modelSource)
Add model source, applying it if not currently editing
- Parameters:
modelSource – The model source to add
- applyModelSource(modelSource)
Apply model source, loading it or reloading it with all other sources as required
- Parameters:
modelSource – The model source to apply
- clear()
Clear all contents of region. Can be called for root region
- connectRegionChange(callableObject)
Request callbacks on region tree changes.
- Parameters:
callableObject – Callable object taking a NeonRegion argument and a boolean flag which is True if tree structure below region needs to be rebuilt.
- createChild()
Create a child region with a default name
- Returns:
ArgonRegion
- deserialize(dictInput)
Read the JSON description to the argon region object. This will change the settings of ArgonRegion Object.
- Parameters:
state – string serialisation of Argon JSON Region.
- freeContents()
Deletes subobjects of region to help free memory held by Zinc objects earlier.
- getChild(index)
Returns the child region of current region by given index.
- Parameters:
index – The index of target region.
- Returns:
ArgonRegion
- getChildCount()
Returns the number of child regions the current region has.
- Returns:
int
- getDisplayName()
Returns the display name of current region.
- Returns:
string
- getFieldTypeDict()
Returns the dictionary of field type in current region.
- Returns:
dict
- getModelSources()
Get model sources.
- Returns:
The model source
- getName()
Returns the name of current region.
- Returns:
string
- getParent()
Returns the parent Argon region of current region.
- Returns:
ArgonRegion
- getPath()
Returns the path of current region.
- Returns:
string
- getZincRegion()
Returns the underlying Zinc context for the Argon region.
- Returns:
cmlibs.zinc.context.Context
- remove()
Remove self from region tree and destroy; replace with blank region if root
- removeChild(childRegion)
Remove child region and destroy.
- Parameters:
childRegion – ArgonRegion
- removeModelSource(modelSource)
Remove model source, reloading model if it removed source had been loaded
- Parameters:
modelSource – The model source to remove
- replaceFieldTypeKey(oldName, newName)
Replace field type name in the field type dictionary in current region.
- Parameters:
oldName – Current field need to be replaced.
newName – New name that will be change to.
- serialize(basePath=None)
Write the JSON file describing the Argon region, which can be used to store the current argon region settings.
- Parameters:
basePath – The base path of JSON file, default is None.
- Returns:
Python JSON object containing the JSON description of argon region object.
- setName(name)
Change region name, the name of Root Region can not be changed.
- Parameters:
name – string
ArgonSceneviewer Class
- class cmlibs.argon.argonsceneviewer.ArgonSceneviewer(zinc_context, parent=None)
- applyParameters(sceneviewer)
Apply Argon sceneviewer parameters to Zinc sceneviewer.
- Parameters:
sceneviewer – Zinc scenviewer object.
- deserialize(d)
Read the JSON description to the Argon sceneviewer object. This will change the settings of ArgonSceneviewer Object.
- Parameters:
d – Python JSON object containing the JSON description of Argon sceneviewer object.
- get_view_parameters()
Return the view parameters of Argon sceneviewer.
- Returns:
dictionary
- serialize()
Write the JSON file describing the Argon sceneviewer, which can be used to store the current Argon sceneviewer settings.
- Returns:
Python JSON object containing the JSON description of Argon sceneviewer object.
- updateParameters(sceneviewer)
Read parameters from Zinc scenviewer to the Argon sceneviewer object. This will change the settings of ArgonSceneviewer Object.
- Parameters:
sceneviewer – Zinc scenviewer object.
ArgonSpectrums Class
- class cmlibs.argon.argonspectrums.ArgonSpectrums(zincContext)
Manages and serializes Zinc Spectrums within Neon. Generates colour bar glyphs for spectrums, which is automatically done if if not found on loading.
- deserialize(dictInput)
Read the JSON description to the Argon spectrum object. This will change the spectrums in the Zinc spectrum module. Raising an ArgonError if Zinc spectrum module read JSON description failed.
- Parameters:
dictInput – The string containing JSON description
- findOrCreateSpectrumGlyphColourBar(spectrum)
Find or create a GlyphColourBar for spectrum in the glyph module. Newly created colour bar is set up for display in the normalised window coordinates at left.
- Parameters:
spectrum – The spectrum that the colour bar belongs to.
- getZincContext()
Return the zinc Context of current argon spectrum.
- Returns:
cmlibs.zinc.context.Context
- removeSpectrumByName(name)
Unmanages spectrum and its colour bar. Note spectrum is only removed if neither are in use.
- Returns:
True if spectrum and colour bar removed, false if failed i.e. either are in use.
- renameSpectrum(spectrum, name)
Renames spectrum and its glyph
- Parameters:
spectrum – The spectrum that need to be renamed.
name – New name to the spectrum.
- Returns:
True on success, otherwise False (means name not set)
- serialize()
Write the JSON file describing the spectrums in the argon spectrum object, which can be used to store the current spectrum settings.
- Returns:
Python JSON object containing the JSON description of argon spectrum object, otherwise 0.
ArgonTessellations Class
- class cmlibs.argon.argontessellations.ArgonTessellations(zincContext)
Manages and serializes Zinc Tessellations within Neon.
- deserialize(dictInput)
Read the JSON description to the Argon Tessellations object. This will change the tessellation in the Zinc tessellation module. Raising an ArgonError if Zinc tessellation module read JSON description failed.
- Parameters:
dictInput – The string containing JSON description
- getZincContext()
Return the zinc Context of current Argon Tessellations.
- Returns:
cmlibs.zinc.context.Context
- serialize()
Write the JSON file describing the tessellations in the argon tessellation object, which can be used to store the current tessellation settings.
- Returns:
Python JSON object containing the JSON description of argon tessellation object, otherwise 0.
ArgonView Class
- class cmlibs.argon.argonviews.ArgonView(zincContext)
Defines and serializes a single view.
- deserialize(d)
Read the JSON description to the Argon View object. This will change settings of ArgonView Object.
- Parameters:
d – Python JSON object containing the JSON description of Argon view object.
- getGridSpecification()
Returns the grid specification of current region.
- Returns:
string
- getName()
Returns the name of current view.
- Returns:
string
- getScenes()
Returns a list of scene in current view.
- Returns:
list
- getZincContext()
Return the zinc Context of current argon view.
- Returns:
cmlibs.zinc.context.Context
- serialize()
Write the JSON file describing the Argon view, which can be used to store the current Argon view settings.
- Returns:
Python JSON object containing the JSON description of Argon view object.
- setName(name)
Set name of current view.
- Parameters:
name – string
- updateSceneviewer(row, col, sceneviewer)
Update sceneviewer at given grid location.
- Parameters:
row – int
col – int
sceneviewer – ArgonSceneviewer
ArgonViewManager Class
- class cmlibs.argon.argonviews.ArgonViewManager(zinc_context)
Manages and serializes ArgonViews.
- addViewByType(view_type, name=None)
Create a new view with given view layout type, there are two available types: LAYOUT1 for view with single sceneviewer, LAYOUT2x2GRID for view with four sceneviewers.
- Parameters:
view_type – View layout type.
name – Name of the new view, default is None. If it is None, will use view type as name.
- deserialize(d)
Read the JSON description to the ArgonViewManager object. This will change settings of ArgonViewManager Object.
- Parameters:
d – Python JSON object containing the JSON description of ArgonViewManager object.
- getActiveView()
Returns current active view.
- Returns:
ArgonView
- getView(index)
Get view by index.
- Parameters:
index – int
- getViews()
Get a list of views.
- Returns:
list
- getZincContext()
Returns the underlying Zinc context for the view manager.
- Returns:
cmlibs.zinc.context.Context
- removeView(identifier)
Remove view by given identifier.
- Parameters:
identifier – The identifier of view.
- serialize()
Write the JSON file describing the ArgonViewManager, which can be used to store the current ArgonViewManager settings.
- Returns:
Python JSON object containing the JSON description of ArgonViewManager object.
- setActiveView(view)
Sets current active view.
- Parameters:
view – ArgonView
- setViews(views)
Set views.
- Parameters:
views – list
- updateSceneviewers(view_index, sceneviewers_info)
Update sceneviewer info in the view.
- Parameters:
view_index – The index of view that need to be updated.
sceneviewers_info – New sceneviewers info.
- viewCount()
Get the total number of views in this ArgonViewManager object.
- Returns:
int