Back to index

salome-paravis  6.5.0
Public Member Functions | Public Attributes | Properties
paravisSM.EnumerationProperty Class Reference
Inheritance diagram for paravisSM.EnumerationProperty:
Inheritance graph
[legend]
Collaboration diagram for paravisSM.EnumerationProperty:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def GetElement
def ConvertValue
def GetAvailable
def __len__
def __iter__
def __setitem__
def __getitem__
def GetData
def SetData
def Clear
def __repr__
def __call__
def __getattr__

Public Attributes

 SMProperty
 Proxy

Properties

 Available
 Name

Detailed Description

Subclass of VectorProperty that is applicable for enumeration type
properties.

Definition at line 757 of file paravisSM.py.


Member Function Documentation

def paravisSM.Property.__call__ (   self) [inherited]
Forces a property update using InvokeCommand.

Definition at line 563 of file paravisSM.py.

00563 
00564     def __call__(self):
00565         """Forces a property update using InvokeCommand."""
00566         if type(self) is Property:
00567             self.Proxy.SMProxy.InvokeCommand(self._FindPropertyName())
00568         else:
00569             raise RuntimeError, "Cannot invoke this property"

Here is the call graph for this function:

def paravisSM.Property.__getattr__ (   self,
  name 
) [inherited]

Reimplemented in paravisSM.ProxyProperty.

Definition at line 585 of file paravisSM.py.

00585 
00586     def __getattr__(self, name):
00587         "Unknown attribute requests get forwarded to SMProperty."
00588         return getattr(self.SMProperty, name)

def paravisSM.VectorProperty.__getitem__ (   self,
  idx 
) [inherited]
Returns the range [min, max) of elements. Raises an IndexError
exception if an argument is out of bounds.

Reimplemented in paravisSM.ArrayListProperty, and paravisSM.ArraySelectionProperty.

Definition at line 648 of file paravisSM.py.

00648 
00649     def __getitem__(self, idx):
00650         """Returns the range [min, max) of elements. Raises an IndexError
00651         exception if an argument is out of bounds."""
00652         ls = len(self)
00653         if isinstance(idx, slice):
00654             indices = idx.indices(ls)
00655             retVal = []
00656             for i in range(*indices):
00657                retVal.append(self.GetElement(i))
00658             return retVal
00659         elif idx >= ls:
00660             raise IndexError
00661         elif idx < 0:
00662             idx = ls + idx
00663             if idx < 0:
00664                 raise IndexError
00665 
00666         return self.GetElement(idx)

Here is the call graph for this function:

def paravisSM.VectorProperty.__iter__ (   self) [inherited]
Implementation of the sequence API

Reimplemented in paravisSM.ArrayListProperty.

Definition at line 628 of file paravisSM.py.

00628 
00629     def __iter__(self):
00630         """Implementation of the sequence API"""
00631         return GenericIterator(self)

Here is the caller graph for this function:

def paravisSM.VectorProperty.__len__ (   self) [inherited]
Returns the number of elements.

Reimplemented in paravisSM.ArrayListProperty, and paravisSM.ArraySelectionProperty.

Definition at line 624 of file paravisSM.py.

00624 
00625     def __len__(self):
00626         """Returns the number of elements."""
00627         return self.SMProperty.GetNumberOfElements()

def paravisSM.Property.__repr__ (   self) [inherited]
Returns a string representation containing property name
and value

Definition at line 545 of file paravisSM.py.

00545 
00546     def __repr__(self):
00547         """Returns a string representation containing property name
00548         and value"""
00549         if not type(self) is Property:
00550             if self.GetData() is not None:
00551                 repr = self.GetData().__repr__()
00552             else:
00553                 repr = "None"
00554         else:
00555             repr = "Property name= "
00556             name = self.Proxy.GetPropertyName(self.SMProperty)
00557             if name:
00558                 repr += name
00559             else:
00560                 repr += "Unknown"
00561 
00562         return repr

Here is the call graph for this function:

def paravisSM.VectorProperty.__setitem__ (   self,
  idx,
  value 
) [inherited]
Given a list or tuple of values, sets a slice of values [min, max)

Reimplemented in paravisSM.ArrayListProperty, and paravisSM.ArraySelectionProperty.

Definition at line 632 of file paravisSM.py.

00632 
00633     def __setitem__(self, idx, value):
00634         """Given a list or tuple of values, sets a slice of values [min, max)"""
00635         if isinstance(idx, slice):
00636             indices = idx.indices(len(self))
00637             for i, j in zip(range(*indices), value):
00638                 self.SMProperty.SetElement(i, self.ConvertValue(j))
00639             self._UpdateProperty()
00640         elif idx >= len(self) or idx < 0:
00641             raise IndexError
00642         else:
00643             self.SMProperty.SetElement(idx, self.ConvertValue(value))
00644             self._UpdateProperty()

Here is the call graph for this function:

def paravisSM.VectorProperty.Clear (   self) [inherited]

Definition at line 692 of file paravisSM.py.

00692 
00693     def Clear(self):
00694         "Removes all elements."
00695         self.SMProperty().SetNumberOfElements(0)
00696         self._UpdateProperty()

Here is the call graph for this function:

def paravisSM.EnumerationProperty.ConvertValue (   self,
  value 
)
Converts value to type suitable for vtSMProperty::SetElement()

Reimplemented from paravisSM.VectorProperty.

Definition at line 771 of file paravisSM.py.

00771 
00772     def ConvertValue(self, value):
00773         """Converts value to type suitable for vtSMProperty::SetElement()"""
00774         if type(value) == str:
00775             domain = self.SMProperty.GetDomain("enum")
00776             if domain.HasEntryText(value):
00777                 return domain.GetEntryValueForText(value)
00778             else:
00779                 raise ValueError("%s is not a valid value." % value)
00780         return VectorProperty.ConvertValue(self, value)

Definition at line 781 of file paravisSM.py.

00781 
00782     def GetAvailable(self):
00783         "Returns the list of available values for the property."
00784         retVal = []
00785         domain = self.SMProperty.GetDomain("enum")
00786         for i in range(domain.GetNumberOfEntries()):
00787             retVal.append(domain.GetEntryText(i))
00788         return retVal

def paravisSM.VectorProperty.GetData (   self) [inherited]

Reimplemented in paravisSM.ArrayListProperty.

Definition at line 667 of file paravisSM.py.

00667 
00668     def GetData(self):
00669         "Returns all elements as either a list or a single value."
00670         property = self.SMProperty
00671         if property.GetRepeatable() or \
00672            property.GetNumberOfElements() > 1:
00673             return self[0:len(self)]
00674         elif property.GetNumberOfElements() == 1:
00675             return self.GetElement(0)

Here is the call graph for this function:

Here is the caller graph for this function:

def paravisSM.EnumerationProperty.GetElement (   self,
  index 
)
Returns the text for the given element if available. Returns
the numerical values otherwise.

Reimplemented from paravisSM.VectorProperty.

Definition at line 761 of file paravisSM.py.

00761 
00762     def GetElement(self, index):
00763         """Returns the text for the given element if available. Returns
00764         the numerical values otherwise."""
00765         val = self.SMProperty.GetElement(index)
00766         domain = self.SMProperty.GetDomain("enum")
00767         for i in range(domain.GetNumberOfEntries()):
00768             if domain.GetEntryValue(i) == val:
00769                 return domain.GetEntryText(i)
00770         return val

def paravisSM.VectorProperty.SetData (   self,
  values 
) [inherited]
Allows setting of all values at once. Requires a single value or
a iterable object.

Reimplemented in paravisSM.ArrayListProperty, paravisSM.ArraySelectionProperty, and paravisSM.ColorArrayProperty.

Definition at line 676 of file paravisSM.py.

00676 
00677     def SetData(self, values):
00678         """Allows setting of all values at once. Requires a single value or
00679         a iterable object."""
00680         if not hasattr(values, "__iter__"):
00681             values = (values,)
00682         if not self.GetRepeatable() and len(values) != self.GetNumberOfElements():
00683             raise RuntimeError("This property requires %d values." % self.GetNumberOfElements())
00684         if self.GetRepeatable():
00685             # Clean up first
00686             self.SMProperty.SetNumberOfElements(0)
00687         idx = 0
00688         for val in values:
00689             self.SMProperty.SetElement(idx, self.ConvertValue(val))
00690             idx += 1
00691         self._UpdateProperty()

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 543 of file paravisSM.py.

Definition at line 542 of file paravisSM.py.


Property Documentation

Initial value:
property(GetAvailable, None, None, \
        "This read-only property contains the list of values that can be applied to this property.")

Definition at line 789 of file paravisSM.py.

paravisSM.Property.Name [static, inherited]
Initial value:
property(_FindPropertyName, None, None,
           "Returns the name for the property")

Definition at line 589 of file paravisSM.py.


The documentation for this class was generated from the following file: