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 from render_mode_widget import RenderModeWidget
00025
00026
00027 class CPKWidget(RenderModeWidget):
00028 def __init__(self, parent=None):
00029 RenderModeWidget.__init__(self, parent)
00030
00031
00032 self.text_ = "Spheres"
00033
00034
00035 min_sphere_detail = 1
00036 max_sphere_detail = 20
00037
00038
00039 self.mode_ = gfx.RenderMode.CPK
00040
00041
00042
00043 self.sphere_spinbox_ = QtGui.QSpinBox()
00044 self.sphere_spinbox_.setRange(min_sphere_detail, max_sphere_detail)
00045 cpk_mode_label = QtGui.QLabel("Rendering Mode")
00046 self.cpk_mode_ = QtGui.QComboBox()
00047 self.cpk_mode_.addItem("Triangles")
00048 self.cpk_mode_.addItem("3D Sprites")
00049 cpk_label = QtGui.QLabel(self.text_)
00050 font = cpk_label.font()
00051 font.setBold(True)
00052
00053 sphere_label = QtGui.QLabel("Sphere Detail")
00054 grid = QtGui.QGridLayout()
00055 grid.addWidget(cpk_label,0,0,1,1)
00056 grid.addWidget(sphere_label, 1, 0, 1, 3)
00057 grid.addWidget(self.sphere_spinbox_, 1, 2, 1, 1)
00058 grid.setRowStretch(2,1)
00059 self.setLayout(grid)
00060
00061 QtCore.QObject.connect(self.sphere_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSphereDetail)
00062 QtCore.QObject.connect(self.cpk_mode_, QtCore.SIGNAL("currentIndexChanged(int)"), self.UpdateSphereMode)
00063
00064 self.setMinimumSize(250,60)
00065
00066 def UpdateSphereDetail(self, value):
00067 self.GetOptions().SetSphereDetail(value)
00068 self.ApplyOptions()
00069
00070 def UpdateSphereMode(self, value):
00071 self.GetOptions().SetSphereMode(value)
00072 self.ApplyOptions()
00073
00074 def UpdateGui(self,options):
00075 self.sphere_spinbox_.setValue(options.GetSphereDetail())
00076 self.cpk_mode_.setCurrentIndex(options.GetSphereMode())
00077
00078 def GetText(self):
00079 return self.text_
00080
00081 def GetRenderMode(self):
00082 return self.mode_