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-2020 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 PyQt5 import QtCore, QtWidgets
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 = QtWidgets.QLabel("Arc Detail")
48 
49  self.arc_spinbox_ = QtWidgets.QSpinBox()
50  self.arc_spinbox_.setRange(min_arc_detail, max_arc_detail)
51 
52  #Tube Radius
53  radius_tube_label = QtWidgets.QLabel("Radius")
54 
55  self.width_tube_spinbox_ = QtWidgets.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_ = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
61  self.width_tube_slider_.setRange(int(min_width*10.0), int(max_tube_width*10.0))
62  self.width_tube_slider_.setTickPosition(QtWidgets.QSlider.NoTicks)
63  self.width_tube_slider_.setTickInterval(1)
64 
65  grid = QtWidgets.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  self.arc_spinbox_.valueChanged.connect(self.UpdateArcDetail)
77  self.width_tube_spinbox_.valueChanged.connect(self.UpdateTubeRadius)
78  self.width_tube_slider_.valueChanged.connect(self.UpdateSliderTubeRadius)
79 
80  self.setMinimumSize(250,60) #2*30
81  ########/UI########
82  def UpdateGui(self,options):
83  self.arc_spinbox_.setValue(options.GetArcDetail())
84 
85  self.UpdateTubeRadiusGui(options.GetTubeRadius())
86 
87  def UpdatePolyMode(self, value):
88  self.GetOptions().SetPolyMode(value)
89  self.ApplyOptions()
90 
91  def UpdateArcDetail(self, value):
92  self.GetOptions().SetArcDetail(value)
93  self.ApplyOptions()
94 
95  def UpdateTubeRadius(self, value):
96  self.GetOptions().SetTubeRadius(value)
97 
98  def UpdateSliderTubeRadius(self, value):
99  self.GetOptions().SetTubeRadius(value/10.0)
100 
101  def UpdateTubeRadiusGui(self,value):
102  value = round(value, 2)
103  if(abs(value*10.0 - self.width_tube_slider_.value())>=self.width_tube_slider_.singleStep()):
104  self.width_tube_slider_.setValue(int(value*10.0))
105  if(abs(value - self.width_tube_spinbox_.value())>=self.width_tube_spinbox_.singleStep()):
106  self.width_tube_spinbox_.setValue(value)
107 
108  def GetText(self):
109  return self.text_
110 
111  def GetRenderMode(self):
112  return self.mode_