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"]
46 self.ops_.insert(index, op)
55 return self.
ops_[index]
70 if (entity
is not None)
and isinstance(entity,
gfx.Entity):
72 if isinstance(op,ColorOp):
78 group.SetAttribute(Preset.NAME_ATTRIBUTE_NAME, self.
name_)
79 for i
in range(0,len(self.
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_[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(class_order_dict.has_key(i)):
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