00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 from ost import gui
00022 from ost import gfx
00023 from PyQt4 import QtCore, QtGui
00024
00025
00026
00027 class RenderModeWidget(QtGui.QWidget):
00028 def __init__(self, parent=None):
00029 QtGui.QWidget.__init__(self, parent)
00030 self.options_ = None
00031 self.entities_ = set()
00032
00033 def GetText(self):
00034 raise NotImplementedError, "Subclasses must define GetText()"
00035
00036 def GetRenderMode(self):
00037 raise NotImplementedError, "Subclasses must define GetRenderMode()"
00038
00039 def UpdateGui(self, options):
00040 pass
00041
00042 def Update(self):
00043 self.entities_.clear()
00044
00045 scene_selection = gui.SceneSelection.Instance()
00046 if scene_selection.GetActiveNodeCount() == 0 and scene_selection.GetActiveViewCount() == 0:
00047 self.setEnabled(False)
00048 return
00049
00050 if scene_selection.GetActiveNodeCount() > 0 :
00051 for i in range(0,scene_selection.GetActiveNodeCount()):
00052 entity = scene_selection.GetActiveNode(i)
00053 if isinstance(entity, gfx.Entity):
00054 self.entities_.add(entity)
00055 else:
00056 self.setEnabled(False)
00057 return
00058
00059 if scene_selection.GetActiveViewCount() > 0 :
00060 entity = scene_selection.GetViewEntity()
00061 self.entities_.add(entity)
00062
00063 if len(self.entities_)>0:
00064 entity = self.entities_.pop()
00065 self.options_=entity.GetOptions(self.GetRenderMode())
00066 self.UpdateGui(self.options_)
00067 QtGui.QWidget.setEnabled(self,True)
00068 else:
00069 QtGui.QWidget.setEnabled(self,False)
00070
00071 def ApplyOptions(self):
00072 for entity in self.entities_:
00073 entity.ApplyOptions(self.GetRenderMode(), self.GetOptions())
00074
00075 def GetOptions(self):
00076 return self.options_