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 try:
00025 from ost import img
00026 _img_present=True
00027 except ImportError:
00028 _img_present=False
00029 pass
00030 from scene_selection_helper import SelHelper
00031
00032
00033 class WireframeWidget(QtGui.QWidget):
00034 def __init__(self, parent=None):
00035 QtGui.QWidget.__init__(self, parent)
00036
00037
00038 self.text_ = "Wireframe"
00039
00040
00041 min_line_width = 0.01
00042 max_line_width = 20
00043
00044
00045 self.mode_ = gfx.RenderMode.SIMPLE
00046
00047
00048 self.aa_rendering_cb_ = QtGui.QCheckBox()
00049
00050 self.radius_spinbox_ = QtGui.QDoubleSpinBox()
00051 self.radius_spinbox_.setRange(min_line_width, max_line_width)
00052 self.radius_spinbox_.setDecimals(2)
00053 self.radius_spinbox_.setSingleStep(0.1)
00054
00055 simple_label = QtGui.QLabel("Wireframe Settings")
00056 font = simple_label.font()
00057 font.setBold(True)
00058
00059 radius_label = QtGui.QLabel("Line Width")
00060 aa_label = QtGui.QLabel("AA-Lines")
00061
00062 grid = QtGui.QGridLayout()
00063 grid.addWidget(simple_label,0,0,1,3)
00064 grid.addWidget(aa_label, 1, 0, 1, 3)
00065 grid.addWidget(self.aa_rendering_cb_, 1, 2, 1, 1)
00066 grid.addWidget(radius_label,2,0,1,3)
00067 grid.addWidget(self.radius_spinbox_,2,2,1,1)
00068 grid.setRowStretch(5,1)
00069 self.setLayout(grid)
00070
00071 QtCore.QObject.connect(self.radius_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateLineWidth)
00072 QtCore.QObject.connect(self.aa_rendering_cb_, QtCore.SIGNAL("stateChanged(int)"), self.UpdateAA)
00073
00074 self.setMinimumSize(250,100)
00075
00076 def UpdateAA(self, value):
00077 scene_selection = gui.SceneSelection.Instance()
00078 for i in range(0,scene_selection.GetActiveNodeCount()):
00079 node = scene_selection.GetActiveNode(i)
00080 node.SetAALines(value)
00081
00082 def UpdateLineWidth(self, value):
00083 scene_selection = gui.SceneSelection.Instance()
00084 for i in range(0,scene_selection.GetActiveNodeCount()):
00085 node = scene_selection.GetActiveNode(i)
00086 node.SetLineWidth(value)
00087
00088 def UpdateGui(self):
00089 scene_selection = gui.SceneSelection.Instance()
00090 node = scene_selection.GetActiveNode(0)
00091 self.radius_spinbox_.setValue(node.GetLineWidth())
00092
00093 def Update(self):
00094 self.setEnabled(True)
00095 self.UpdateGui()
00096 if SelHelper().CheckNotFlags(SelHelper.HAS_IMG | SelHelper.IS_ONE_TYPE):
00097 self.setEnabled(False)
00098
00099 def GetText(self):
00100 return self.text_
00101
00102 def GetRenderMode(self):
00103 return self.mode_