OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-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 #Simple Render Options
27 class LineTraceWidget(RenderModeWidget):
28  def __init__(self, parent=None):
29  RenderModeWidget.__init__(self, parent)
30 
31  #Title
32  self.text_ = "Fast Trace"
33 
34  #Set Render Mode
35  self.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_ = QtGui.QDoubleSpinBox()
43  self.radius_spinbox_.setRange(min_line_width, max_line_width)
44  self.radius_spinbox_.setDecimals(2)
45  self.radius_spinbox_.setSingleStep(0.1)
46 
47  self.aa_rendering_cb_ = QtGui.QCheckBox()
48 
49  sline_label = QtGui.QLabel("Trace Settings")
50  font = sline_label.font()
51  font.setBold(True)
52 
53  radius_label = QtGui.QLabel("Line Width")
54  aa_label = QtGui.QLabel("AA-Lines")
55  grid = QtGui.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_, 1, 2, 1, 1)
59  grid.addWidget(aa_label, 2, 0, 1, 3)
60  grid.addWidget(self.aa_rendering_cb_, 2, 2, 1, 1)
61  grid.setRowStretch(3,1)
62  self.setLayout(grid)
63 
64  QtCore.QObject.connect(self.radius_spinbox_,
65  QtCore.SIGNAL("valueChanged(double)"),
66  self.UpdateLineWidth)
67  QtCore.QObject.connect(self.aa_rendering_cb_,
68  QtCore.SIGNAL("stateChanged(int)"),
69  self.UpdateAA)
70 
71  self.setMinimumSize(250,90)
72 
73  def UpdateAA(self, value):
74  self.GetOptions().SetAALines(value)
75  self.ApplyOptions()
76 
77  def UpdateLineWidth(self, value):
78  self.GetOptions().SetLineWidth(value)
79  self.ApplyOptions()
80 
81  def UpdateGui(self,options):
82  self.aa_rendering_cb_.setChecked(options.GetAALines())
83  self.radius_spinbox_.setValue(options.GetLineWidth())
84 
85  def GetText(self):
86  return self.text_
87 
88  def GetRenderMode(self):
89  return self.mode_