OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
trace_widget.py
Go to the documentation of this file.
1 #------------------------------------------------------------------------------
2 # This file is part of the OpenStructure project <www.openstructure.org>
3 #
4 # Copyright (C) 2008-2011 by the OpenStructure authors
5 #
6 # This library is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation; either version 3.0 of the License, or (at your option)
9 # any later version.
10 # This library is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this library; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #------------------------------------------------------------------------------
19 # -*- coding: utf-8 -*-
20 
21 from ost import gui
22 from ost import gfx
23 from PyQt4 import QtCore, QtGui
24 from render_mode_widget import RenderModeWidget
25 
26 #Trace Render Options
27 class TraceWidget(RenderModeWidget):
28  def __init__(self, parent=None):
29  RenderModeWidget.__init__(self, parent)
30 
31  #Title
32  self.text_ = "Trace"
33 
34  #Set Render Mode
35  self.mode_ = gfx.RenderMode.TRACE
36 
37  min_arc_detail = 1
38  max_arc_detail = 20
39 
40  min_width = 0.1
41  max_width = 2.5
42  max_tube_width= 2.0
43 
44  #########UI##########
45 
46  #Arc Label
47  arc_label = QtGui.QLabel("Arc Detail")
48 
49  self.arc_spinbox_ = QtGui.QSpinBox()
50  self.arc_spinbox_.setRange(min_arc_detail, max_arc_detail)
51 
52  #Tube Radius
53  radius_tube_label = QtGui.QLabel("Radius")
54 
55  self.width_tube_spinbox_ = QtGui.QDoubleSpinBox()
56  self.width_tube_spinbox_.setRange(min_width, max_tube_width)
57  self.width_tube_spinbox_.setDecimals(1)
58  self.width_tube_spinbox_.setSingleStep(0.1)
59 
60  self.width_tube_slider_ = QtGui.QSlider(QtCore.Qt.Horizontal, self)
61  self.width_tube_slider_.setRange(min_width*10.0, max_tube_width*10.0)
62  self.width_tube_slider_.setTickPosition(QtGui.QSlider.NoTicks)
63  self.width_tube_slider_.setTickInterval(1)
64 
65  grid = QtGui.QGridLayout()
66  grid.addWidget(arc_label,3,0,1,3)
67  grid.addWidget(self.arc_spinbox_,3,4,1,1)
68 
69  grid.addWidget(radius_tube_label, 5, 0, 1, 1)
70  grid.addWidget(self.width_tube_slider_, 5, 1, 1, 3)
71  grid.addWidget(self.width_tube_spinbox_, 5, 4, 1, 1)
72 
73  grid.setRowStretch(15,1)
74  self.setLayout(grid)
75 
76  QtCore.QObject.connect(self.arc_spinbox_, QtCore.SIGNAL("valueChanged(int)"),
77  self.UpdateArcDetail)
78 
79  QtCore.QObject.connect(self.width_tube_spinbox_,
80  QtCore.SIGNAL("valueChanged(double)"),
81  self.UpdateTubeRadius)
82  QtCore.QObject.connect(self.width_tube_slider_,
83  QtCore.SIGNAL("valueChanged(int)"),
85 
86  self.setMinimumSize(250,60) #2*30
87  ########/UI########
88  def UpdateGui(self,options):
89  self.arc_spinbox_.setValue(options.GetArcDetail())
90 
91  self.UpdateTubeRadiusGui(options.GetTubeRadius())
92 
93  def UpdatePolyMode(self, value):
94  self.GetOptions().SetPolyMode(value)
95  self.ApplyOptions()
96 
97  def UpdateArcDetail(self, value):
98  self.GetOptions().SetArcDetail(value)
99  self.ApplyOptions()
100 
101  def UpdateTubeRadius(self, value):
102  self.GetOptions().SetTubeRadius(value)
103 
104  def UpdateSliderTubeRadius(self, value):
105  self.GetOptions().SetTubeRadius(value/10.0)
106 
107  def UpdateTubeRadiusGui(self,value):
108  value = round(value, 2)
109  if(abs(value*10.0 - self.width_tube_slider_.value())>=self.width_tube_slider_.singleStep()):
110  self.width_tube_slider_.setValue(value*10.0)
111  if(abs(value - self.width_tube_spinbox_.value())>=self.width_tube_spinbox_.singleStep()):
112  self.width_tube_spinbox_.setValue(value)
113 
114  def GetText(self):
115  return self.text_
116 
117  def GetRenderMode(self):
118  return self.mode_