Package schrodinger :: Package tasks :: Module mappers :: Class AbstractParamMapper
[hide private]
[frames] | no frames]

Class AbstractParamMapper

object --+
         |
        AbstractParamMapper
Known Subclasses:

Instance Methods [hide private]
 
suspend_auto_update_target(*args, **kwds)
A param mapper manages synchronization between target objects that represent various params and a model object that contains those params.
 
__init__(self, auto_update_target=False)
x.__init__(...) initializes x; see help(type(x)) for signature
 
addMapping(self, target_obj, param)
Maps an abstract param to a target object.
 
setModelClass(self, model_class)
The first time this method is called, define self._model_class.
 
setModel(self, model)
Sets the model instance to map.
 
onModelValueChanged(self)
 
_getTargetValue(self, target_obj)
This virtual method should return a mapped object's value, however that is defined by the derived class.
 
_setTargetValue(self, target_obj, value)
This virtual method should set a mapped object's value, however that is defined by the derived class.
 
_getModelValue(self, param)
 
_setModelValue(self, param, value)
 
_updateModelParam(self, target_obj)
Updates the param value on the model object from the target object.
 
_updateTargetParam(self, target_obj)
Updates the mapped object from the param value on the model object.
 
updateModel(self)
Updates all mapped parameters on the model object from the target objects.
 
updateTarget(self)
Updates all target objects from the mapped parameters on the model object.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, auto_update_target=False)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • auto_update_target (bool) - whether target objects should be updated immediately whenever the correpsonding parameter is changed. This option only works if the model object emits valueChanged signal whenever any of the params changes. This facility is built in to the base class parameters.Param.
Overrides: object.__init__

addMapping(self, target_obj, param)

 

Maps an abstract param to a target object. An abstract param is a param
that is owned at the top level by the model's class rather than an
instance of the model. This allows the same mapping to be used on
multiple model instances.

The details of the target object are left to derived mapper classes.

Notes:
    If a param is already mapped to a target, the old mapping will be
    replaced by the new one.

    A param may be mapped to only one target. However, multple params
    may be mapped to the same target. This is useful when the same
    target (ex. a widget in a panel) is reused for multiple tasks.

@param target_obj: the target object mapped to a parameter.
@type target_obj: any hashable object for which can be operated on by
    L{AbstractParamMapper._getTargetValue} and
    L{AbstractParamMapper._setTargetValue}.

@param param: an abstract param (ex. Atom.coord.x)
@type param: L{parameters.Param}

setModelClass(self, model_class)

 

The first time this method is called, define self._model_class. For all subsequent calls, test the value of the model_class argument against the stored value. Meant to be called directly or through setModel.

Parameters:
  • model_class (parameters.Param class (not instance)) - the class of the model that this mapper will attempt to synchronize with external targets (views).
Raises:
  • TypeError - when the model class has already been set and this method is called with an argument that does not match the value of self._model_class.

setModel(self, model)

 

Sets the model instance to map. This should be an instance of the model class that is being used in addMapping().

Parameters:
  • model (object) - the model instance

onModelValueChanged(self)

 
Decorators:
  • @util.skip_if('auto_update_target', False)

_getTargetValue(self, target_obj)

 

This virtual method should return a mapped object's value, however that is defined by the derived class.

Parameters:
  • target_obj - the target object

_setTargetValue(self, target_obj, value)

 

This virtual method should set a mapped object's value, however that is defined by the derived class.

Parameters:
  • target_obj - the target object

_updateModelParam(self, target_obj)

 

Updates the param value on the model object from the target object. If the new value is the same as the current value, the param will not be set again.

Parameters:
  • param (parameters.Param) - the abstract param that defines the mapping

_updateTargetParam(self, target_obj)

 

Updates the mapped object from the param value on the model object. If the new value is the same as the target's current value, the value will not be set again on the target object.

Parameters:
  • param (parameters.Param) - the abstract param that defines the mapping

updateModel(self)

 

Updates all mapped parameters on the model object from the target objects. Any target values that are unchanged will be skipped.

updateTarget(self)

 

Updates all target objects from the mapped parameters on the model object. Any param values that are unchanged will be skipped.