OpenStructure
simple_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 Bonds"
33 
34  #Defaults
35  min_line_width = 0.01
36  max_line_width = 20
37  min_bo_dist = 0.01
38  max_bo_dist = 0.20
39 
40  #Set Render Mode
41  self.mode_mode_ = gfx.RenderMode.SIMPLE
42 
43  #Create Ui elements
44  self.aa_rendering_cb_aa_rendering_cb_ = QtWidgets.QCheckBox()
45 
46  self.radius_spinbox_radius_spinbox_ = QtWidgets.QDoubleSpinBox()
47  self.radius_spinbox_radius_spinbox_.setRange(min_line_width, max_line_width)
48  self.radius_spinbox_radius_spinbox_.setDecimals(2)
49  self.radius_spinbox_radius_spinbox_.setSingleStep(0.1)
50 
51  self.bo_rendering_cb_bo_rendering_cb_ = QtWidgets.QCheckBox()
52 
53  self.bo_distance_spinbox_bo_distance_spinbox_ = QtWidgets.QDoubleSpinBox()
54  self.bo_distance_spinbox_bo_distance_spinbox_.setRange(min_bo_dist, max_bo_dist)
55  self.bo_distance_spinbox_bo_distance_spinbox_.setDecimals(2)
56  self.bo_distance_spinbox_bo_distance_spinbox_.setSingleStep(0.01)
57 
58  simple_label = QtWidgets.QLabel("Fast Bonds Simple Settings")
59  font = simple_label.font()
60  font.setBold(True)
61 
62  radius_label = QtWidgets.QLabel("Line Width")
63  aa_label = QtWidgets.QLabel("AA-Lines")
64  bo_label = QtWidgets.QLabel("Show Bond Order")
65  bo_distance = QtWidgets.QLabel("Bond Order Distance")
66 
67  grid = QtWidgets.QGridLayout()
68  grid.addWidget(simple_label,0,0,1,3)
69  grid.addWidget(aa_label, 1, 0, 1, 3)
70  grid.addWidget(self.aa_rendering_cb_aa_rendering_cb_, 1, 2, 1, 1)
71  grid.addWidget(radius_label,2,0,1,3)
72  grid.addWidget(self.radius_spinbox_radius_spinbox_,2,2,1,1)
73  grid.addWidget(bo_label, 3, 0, 1, 3)
74  grid.addWidget(self.bo_rendering_cb_bo_rendering_cb_, 3,2,1,1)
75  grid.addWidget(bo_distance, 4, 0, 1, 3)
76  grid.addWidget(self.bo_distance_spinbox_bo_distance_spinbox_, 4,2,1,1)
77  grid.setRowStretch(5,1)
78  self.setLayout(grid)
79 
80  self.radius_spinbox_radius_spinbox_.valueChanged.connect(self.UpdateLineWidthUpdateLineWidth)
81  self.aa_rendering_cb_aa_rendering_cb_.stateChanged.connect(self.UpdateAAUpdateAA)
82  self.bo_distance_spinbox_bo_distance_spinbox_.valueChanged.connect(self.UpdateBODistanceUpdateBODistance)
83  self.bo_rendering_cb_bo_rendering_cb_.stateChanged.connect(self.UpdateBOUpdateBO)
84  self.setMinimumSize(250,140)
85 
86  self.setMinimumSize(250,140)
87 
88  def UpdateAA(self, value):
89  self.GetOptionsGetOptions().SetAALines(value)
90  self.ApplyOptionsApplyOptions()
91 
92  def UpdateLineWidth(self, value):
93  self.GetOptionsGetOptions().SetLineWidth(value)
94  self.ApplyOptionsApplyOptions()
95 
96  def UpdateBO(self, value):
97  self.GetOptionsGetOptions().SetBondOrderFlag(value)
98  self.ApplyOptionsApplyOptions()
99 
100  def UpdateBODistance(self, value):
101  self.GetOptionsGetOptions().SetBondOrderDistance(value)
102  self.ApplyOptionsApplyOptions()
103 
104  def UpdateGui(self,options):
105  self.aa_rendering_cb_aa_rendering_cb_.setChecked(options.GetAALines())
106  self.radius_spinbox_radius_spinbox_.setValue(options.GetLineWidth())
107  self.bo_rendering_cb_bo_rendering_cb_.setChecked(options.GetBondOrderFlag())
108  self.bo_distance_spinbox_bo_distance_spinbox_.setValue(options.GetBondOrderDistance())
109 
110  def GetText(self):
111  return self.text_text_
112 
113  def GetRenderMode(self):
114  return self.mode_mode_