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 TraceWidget(RenderModeWidget):
00028 def __init__(self, parent=None):
00029 RenderModeWidget.__init__(self, parent)
00030
00031
00032 self.text_ = "Trace"
00033
00034
00035 self.mode_ = gfx.RenderMode.TRACE
00036
00037 min_arc_detail = 1
00038 max_arc_detail = 20
00039
00040 min_width = 0.1
00041 max_width = 2.5
00042 max_tube_width= 2.0
00043
00044
00045
00046
00047 arc_label = QtGui.QLabel("Arc Detail")
00048
00049 self.arc_spinbox_ = QtGui.QSpinBox()
00050 self.arc_spinbox_.setRange(min_arc_detail, max_arc_detail)
00051
00052
00053 radius_tube_label = QtGui.QLabel("Radius")
00054
00055 self.width_tube_spinbox_ = QtGui.QDoubleSpinBox()
00056 self.width_tube_spinbox_.setRange(min_width, max_tube_width)
00057 self.width_tube_spinbox_.setDecimals(1)
00058 self.width_tube_spinbox_.setSingleStep(0.1)
00059
00060 self.width_tube_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self)
00061 self.width_tube_slider_.setRange(min_width*10.0, max_tube_width*10.0)
00062 self.width_tube_slider_.setTickPosition(QtGui.QSlider.NoTicks)
00063 self.width_tube_slider_.setTickInterval(1)
00064
00065 grid = QtGui.QGridLayout()
00066 grid.addWidget(arc_label,3,0,1,3)
00067 grid.addWidget(self.arc_spinbox_,3,4,1,1)
00068
00069 grid.addWidget(radius_tube_label, 5, 0, 1, 1)
00070 grid.addWidget(self.width_tube_slider_, 5, 1, 1, 3)
00071 grid.addWidget(self.width_tube_spinbox_, 5, 4, 1, 1)
00072
00073 grid.setRowStretch(15,1)
00074 self.setLayout(grid)
00075
00076 QtCore.QObject.connect(self.arc_spinbox_, QtCore.SIGNAL("valueChanged(int)"),
00077 self.UpdateArcDetail)
00078
00079 QtCore.QObject.connect(self.width_tube_spinbox_,
00080 QtCore.SIGNAL("valueChanged(double)"),
00081 self.UpdateTubeRadius)
00082 QtCore.QObject.connect(self.width_tube_slider_,
00083 QtCore.SIGNAL("valueChanged(int)"),
00084 self.UpdateSliderTubeRadius)
00085
00086 self.setMinimumSize(250,60)
00087
00088 def UpdateGui(self,options):
00089 self.arc_spinbox_.setValue(options.GetArcDetail())
00090
00091 self.UpdateTubeRadiusGui(options.GetTubeRadius())
00092
00093 def UpdatePolyMode(self, value):
00094 self.GetOptions().SetPolyMode(value)
00095 self.ApplyOptions()
00096
00097 def UpdateArcDetail(self, value):
00098 self.GetOptions().SetArcDetail(value)
00099 self.ApplyOptions()
00100
00101 def UpdateTubeRadius(self, value):
00102 self.GetOptions().SetTubeRadius(value)
00103
00104 def UpdateSliderTubeRadius(self, value):
00105 self.GetOptions().SetTubeRadius(value/10.0)
00106
00107 def UpdateTubeRadiusGui(self,value):
00108 value = round(value, 2)
00109 if(abs(value*10.0 - self.width_tube_slider_.value())>=self.width_tube_slider_.singleStep()):
00110 self.width_tube_slider_.setValue(value*10.0)
00111 if(abs(value - self.width_tube_spinbox_.value())>=self.width_tube_spinbox_.singleStep()):
00112 self.width_tube_spinbox_.setValue(value)
00113
00114 def GetText(self):
00115 return self.text_
00116
00117 def GetRenderMode(self):
00118 return self.mode_