28 NAME_ATTRIBUTE_NAME =
"Name"
30 CLASS_NAME_ATTRIBUTE_NAME =
"ClassName"
31 INDEX_ATTRIBUTE_NAME =
"Index"
33 MODULE_NAMES = [
"ost.gfx",
"ost.gui.scene.visibility_op",
"ost.gui.scene.render_op"]
40 self.
name_name_ = name
43 return self.
name_name_
46 self.
ops_ops_.insert(index, op)
49 self.
ops_ops_.remove(op)
52 del(self.
ops_ops_[index])
55 return self.
ops_ops_[index]
58 return len(self.
ops_ops_)
61 self.
ops_ops_[index] = op
64 self.
ops_ops_.append(op)
70 if (entity
is not None)
and isinstance(entity,
gfx.Entity):
71 for op
in self.
ops_ops_:
72 if isinstance(op,ColorOp):
78 group.SetAttribute(Preset.NAME_ATTRIBUTE_NAME, self.
name_name_)
79 for i
in range(0,len(self.
ops_ops_)):
80 op_group = group.CreateGroup(Preset.OP_GROUP_NAME)
81 op_group.SetAttribute(Preset.INDEX_ATTRIBUTE_NAME, str(i))
82 op_group.SetAttribute(Preset.CLASS_NAME_ATTRIBUTE_NAME,
"%s"%(self.
ops_ops_[i].__class__.__name__))
88 if group.HasAttribute(Preset.NAME_ATTRIBUTE_NAME):
89 name = group.GetAttribute(Preset.NAME_ATTRIBUTE_NAME)
91 group_list = group.GetGroups(Preset.OP_GROUP_NAME)
93 class_order_dict = dict()
94 for op_group
in group_list:
95 if(op_group.HasAttribute(Preset.CLASS_NAME_ATTRIBUTE_NAME)
and op_group.HasAttribute(Preset.INDEX_ATTRIBUTE_NAME)):
96 class_name = op_group.GetAttribute(Preset.CLASS_NAME_ATTRIBUTE_NAME)
97 index = int(op_group.GetAttribute(Preset.INDEX_ATTRIBUTE_NAME))
99 for module
in Preset.MODULE_NAMES:
101 op_class = Preset.__get_op_class(
"%s.%s"%(module,class_name))
103 except AttributeError:
105 if op_class
is not None:
106 op = op_class.FromInfo(op_group)
107 class_order_dict[index]=op
108 for i
in range(0, len(class_order_dict)):
109 if(i
in class_order_dict):
110 preset.AddOp(class_order_dict[i])
114 def __get_op_class( cls ):
115 parts = cls.split(
'.')
116 module =
".".join(parts[:-1])
117 m = __import__( module )
118 for comp
in parts[1:]:
graphical rendering of mol::EntityHandle entites
def SetOp(self, index, op)
def ApplyOn(self, entity)
def __init__(self, name, parent=None)
def RemoveOpAt(self, index)
def InsertOp(self, index, op)