23 from PyQt4
import QtGui
29 NAME_ATTRIBUTE_NAME =
"Name"
31 CLASS_NAME_ATTRIBUTE_NAME =
"ClassName"
32 INDEX_ATTRIBUTE_NAME =
"Index"
34 MODULE_NAMES = [
"ost.gfx",
"ost.gui.scene.visibility_op",
"ost.gui.scene.render_op"]
47 self.ops_.insert(index, op)
56 return self.
ops_[index]
71 if (entity
is not None)
and isinstance(entity,
gfx.Entity):
73 if isinstance(op,ColorOp):
79 group.SetAttribute(Preset.NAME_ATTRIBUTE_NAME, self.
name_)
80 for i
in range(0,len(self.
ops_)):
81 op_group = group.CreateGroup(Preset.OP_GROUP_NAME)
82 op_group.SetAttribute(Preset.INDEX_ATTRIBUTE_NAME, str(i))
83 op_group.SetAttribute(Preset.CLASS_NAME_ATTRIBUTE_NAME,
"%s"%(self.
ops_[i].__class__.__name__))
89 if group.HasAttribute(Preset.NAME_ATTRIBUTE_NAME):
90 name = group.GetAttribute(Preset.NAME_ATTRIBUTE_NAME)
92 group_list = group.GetGroups(Preset.OP_GROUP_NAME)
94 class_order_dict = dict()
95 for op_group
in group_list:
96 if(op_group.HasAttribute(Preset.CLASS_NAME_ATTRIBUTE_NAME)
and op_group.HasAttribute(Preset.INDEX_ATTRIBUTE_NAME)):
97 class_name = op_group.GetAttribute(Preset.CLASS_NAME_ATTRIBUTE_NAME)
98 index = int(op_group.GetAttribute(Preset.INDEX_ATTRIBUTE_NAME))
100 for module
in Preset.MODULE_NAMES:
102 op_class = Preset.__get_op_class(
"%s.%s"%(module,class_name))
104 except AttributeError:
106 if op_class
is not None:
107 op = op_class.FromInfo(op_group)
108 class_order_dict[index]=op
109 for i
in range(0, len(class_order_dict)):
110 if(class_order_dict.has_key(i)):
111 preset.AddOp(class_order_dict[i])
115 def __get_op_class( cls ):
116 parts = cls.split(
'.')
117 module =
".".join(parts[:-1])
118 m = __import__( module )
119 for comp
in parts[1:]:
graphical rendering of mol::EntityHandle entites