OpenStructure
line_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 #Simple Render Options
28  def __init__(self, parent=None):
29  RenderModeWidget.__init__(self, parent)
30 
31  #Title
32  self.text_text_ = "Fast Trace"
33 
34  #Set Render Mode
35  self.mode_mode_ = gfx.RenderMode.LINE_TRACE
36 
37  #Defaults
38  min_line_width = 0.01
39  max_line_width = 20
40 
41  #Create Ui elements
42  self.radius_spinbox_radius_spinbox_ = QtWidgets.QDoubleSpinBox()
43  self.radius_spinbox_radius_spinbox_.setRange(min_line_width, max_line_width)
44  self.radius_spinbox_radius_spinbox_.setDecimals(2)
45  self.radius_spinbox_radius_spinbox_.setSingleStep(0.1)
46 
47  self.aa_rendering_cb_aa_rendering_cb_ = QtWidgets.QCheckBox()
48 
49  sline_label = QtWidgets.QLabel("Trace Settings")
50  font = sline_label.font()
51  font.setBold(True)
52 
53  radius_label = QtWidgets.QLabel("Line Width")
54  aa_label = QtWidgets.QLabel("AA-Lines")
55  grid = QtWidgets.QGridLayout()
56  grid.addWidget(sline_label, 0, 0, 1, 1)
57  grid.addWidget(radius_label, 1, 0, 1, 3)
58  grid.addWidget(self.radius_spinbox_radius_spinbox_, 1, 2, 1, 1)
59  grid.addWidget(aa_label, 2, 0, 1, 3)
60  grid.addWidget(self.aa_rendering_cb_aa_rendering_cb_, 2, 2, 1, 1)
61  grid.setRowStretch(3,1)
62  self.setLayout(grid)
63 
64  self.radius_spinbox_radius_spinbox_.valueChanged.connect(self.UpdateLineWidthUpdateLineWidth)
65  self.aa_rendering_cb_aa_rendering_cb_.stateChanged.connect(self.UpdateAAUpdateAA)
66 
67  self.setMinimumSize(250,90)
68 
69  def UpdateAA(self, value):
70  self.GetOptionsGetOptions().SetAALines(value)
71  self.ApplyOptionsApplyOptions()
72 
73  def UpdateLineWidth(self, value):
74  self.GetOptionsGetOptions().SetLineWidth(value)
75  self.ApplyOptionsApplyOptions()
76 
77  def UpdateGui(self,options):
78  self.aa_rendering_cb_aa_rendering_cb_.setChecked(options.GetAALines())
79  self.radius_spinbox_radius_spinbox_.setValue(options.GetLineWidth())
80 
81  def GetText(self):
82  return self.text_text_
83 
84  def GetRenderMode(self):
85  return self.mode_mode_