OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
inspector_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 
20 import sys
21 from ost import gui
22 import sip
23 from ost import gfx
24 import ost
25 import os
26 from PyQt4 import QtCore, QtGui
27 from toolbar_options_widget import ToolBarOptionsWidget
28 from render_options_widget import RenderOptionsWidget
29 from color_options_widget import ColorOptionsWidget
30 from ost.gui.scene.scene_observer_impl import SceneObserverImpl
31 from map_level_widget import AdditionalSettingsWidget
32 from scene_selection_helper import SelHelper
33 
34 class InspectorWidget(ToolBarOptionsWidget):
35  ICONS_PATH = os.path.join(ost.GetSharedDataPath(), "scene", "icons/")
36  def __init__(self, parent=None):
37  ToolBarOptionsWidget.__init__(self, parent)
38  app=gui.GostyApp.Instance()
39  options = [
40  [InspectorWidget.ICONS_PATH+"render_icon.png",RenderOptionsWidget(self),None],
41  [InspectorWidget.ICONS_PATH+"color_icon.png",ColorOptionsWidget(self),None],
42  [InspectorWidget.ICONS_PATH+"preset_icon.png", AdditionalSettingsWidget(self),"Additional Node Settings"],
43  [InspectorWidget.ICONS_PATH+"tool_icon.png",app.tool_options_win.qobject,"Tool Options"]
44  ]
45  for o in options:
46  ToolBarOptionsWidget.AddWidget(self,o[0], o[1], o[2])
47 
49  self.obs.AttachObserver(self)
50  ost.scene.AttachObserver(self.obs)
51  QtCore.QObject.connect(app.scene_win.qobject,QtCore.SIGNAL("ActiveNodesChanged()"),
52  self.ActiveNodesChanged)
53 
54  self.setMinimumSize(250,215)
55  #ToolBarOptionsWidget Method
56  def OnComboChange(self, item):
57  self.DoResize()
58 
59  #Observer Methods
60  def NodeRemoved(self, node):
61  SelHelper().Update()
62  ToolBarOptionsWidget.Update(self)
63 
64  def RenderModeChanged(self, node):
65  SelHelper().Update()
66  ToolBarOptionsWidget.Update(self)
67 
68  def NodeChanged(self, node):
69  SelHelper().Update()
70  ToolBarOptionsWidget.Update(self)
71 
72  def ActiveNodesChanged(self):
73  SelHelper().Update()
74  ToolBarOptionsWidget.Update(self)
75 
76 class InspectorDialog(QtGui.QDialog):
77  def __init__(self, parent=None):
78  QtGui.QDialog.__init__(self, parent)
79  self.setWindowTitle("Inspector Gadget")
80  self.setAttribute(QtCore.Qt.WA_MacSmallSize)
81  self.layout=QtGui.QHBoxLayout()
82  self.layout.setMargin(0)
83  self.layout.setSpacing(0)
84  self.setLayout(self.layout)
86  self.layout.addWidget(self.mywidget_)
87  size_pol = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
88  QtGui.QSizePolicy.Expanding)
89  self.setSizePolicy(size_pol)
90  self.DoResize()
91 
92  def DoResize(self):
93  if(hasattr(self, "mywidget_")):
94  self.setMinimumSize(self.mywidget_.minimumWidth(),
95  self.mywidget_.minimumHeight())
96  self.resize(self.mywidget_.minimumWidth(),
97  self.mywidget_.minimumHeight())
98 
99  def ToggleHide(self,checked):
100  self.setHidden(not self.isHidden())
101 
102  def hideEvent(self, event):
103  self.emit(QtCore.SIGNAL("visible"),False)
104  QtGui.QDialog.hideEvent(self,event)
105 
106  def showEvent(self, event):
107  self.emit(QtCore.SIGNAL("visible"),True)
108  QtGui.QDialog.showEvent(self,event)
String DLLEXPORT_OST_BASE GetSharedDataPath()