OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sline_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 #Simple Render Options
27 class SlineWidget(RenderModeWidget):
28  def __init__(self, parent=None):
29  RenderModeWidget.__init__(self, parent)
30 
31  #Title
32  self.text_ = "Fast Spline"
33 
34  #Set Render Mode
35  self.mode_ = gfx.RenderMode.SLINE
36 
37  #Defaults
38  min_detail = 1
39  max_detail = 20
40 
41  min_line_width = 0.01
42  max_line_width = 20
43 
44  #Create Ui elements
45  self.detail_spinbox_ = QtWidgets.QSpinBox()
46  self.detail_spinbox_.setRange(min_detail, max_detail)
47  self.detail_spinbox_.setSingleStep(1)
48 
49  self.aa_rendering_cb_ = QtWidgets.QCheckBox()
50 
51  self.radius_spinbox_ = QtWidgets.QDoubleSpinBox()
52  self.radius_spinbox_.setRange(min_line_width, max_line_width)
53  self.radius_spinbox_.setDecimals(2)
54  self.radius_spinbox_.setSingleStep(0.1)
55 
56  sline_label = QtWidgets.QLabel("Spline Settings")
57  font = sline_label.font()
58  font.setBold(True)
59 
60  detail_label = QtWidgets.QLabel("Spline Detail")
61  aa_label = QtWidgets.QLabel("AA-Lines")
62  radius_label = QtWidgets.QLabel("Line Width")
63  grid = QtWidgets.QGridLayout()
64  grid.addWidget(sline_label, 0, 0, 1, 1)
65  grid.addWidget(detail_label, 1, 0, 1, 3)
66  grid.addWidget(self.detail_spinbox_, 1, 2, 1, 1)
67  grid.addWidget(aa_label, 2, 0, 1, 3)
68  grid.addWidget(self.aa_rendering_cb_, 2, 2, 1, 1)
69  grid.addWidget(radius_label, 3, 0, 1, 3)
70  grid.addWidget(self.radius_spinbox_, 3, 2, 1, 1)
71  grid.setRowStretch(4,1)
72  self.setLayout(grid)
73 
74  self.detail_spinbox_.valueChanged.connect(self.UpdateDetail)
75  self.aa_rendering_cb_.stateChanged.connect(self.UpdateAA)
76  self.radius_spinbox_.valueChanged.connect(self.UpdateLineWidth)
77 
78  self.setMinimumSize(250,120)
79 
80  def UpdateDetail(self, value):
81  self.GetOptions().SetSplineDetail(value)
82  self.ApplyOptions()
83 
84  def UpdateAA(self, value):
85  self.GetOptions().SetAALines(value)
86  self.ApplyOptions()
87 
88  def UpdateLineWidth(self, value):
89  self.GetOptions().SetLineWidth(value)
90  self.ApplyOptions()
91 
92  def UpdateGui(self,options):
93  self.detail_spinbox_.setValue(options.GetSplineDetail())
94  self.aa_rendering_cb_.setChecked(options.GetAALines())
95  self.radius_spinbox_.setValue(options.GetLineWidth())
96 
97  def GetText(self):
98  return self.text_
99 
100  def GetRenderMode(self):
101  return self.mode_