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 PyQt5 import QtCore, QtWidgets
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  app.scene_win.qobject.ActiveNodesChanged.connect(self.ActiveNodesChanged)
52 
53  self.setMinimumSize(250,215)
54  #ToolBarOptionsWidget Method
55  def OnComboChange(self, item):
56  self.DoResize()
57 
58  #Observer Methods
59  def NodeRemoved(self, node):
60  SelHelper().Update()
61  ToolBarOptionsWidget.Update(self)
62 
63  def RenderModeChanged(self, node):
64  SelHelper().Update()
65  ToolBarOptionsWidget.Update(self)
66 
67  def NodeChanged(self, node):
68  SelHelper().Update()
69  ToolBarOptionsWidget.Update(self)
70 
71  def ActiveNodesChanged(self):
72  SelHelper().Update()
73  ToolBarOptionsWidget.Update(self)
74 
75 class InspectorDialog(QtWidgets.QDialog):
76 
77  visible = QtCore.pyqtSignal(bool, name="visible")
78 
79  def __init__(self, parent=None):
80  QtWidgets.QDialog.__init__(self, parent)
81  self.setWindowTitle("Inspector Gadget")
82  self.setAttribute(QtCore.Qt.WA_MacSmallSize)
83  self.layout=QtWidgets.QHBoxLayout()
84  self.layout.setContentsMargins(0,0,0,0)
85  self.layout.setSpacing(0)
86  self.setLayout(self.layout)
88  self.layout.addWidget(self.mywidget_)
89  size_pol = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
90  QtWidgets.QSizePolicy.Expanding)
91  self.setSizePolicy(size_pol)
92  self.DoResize()
93 
94  def DoResize(self):
95  if(hasattr(self, "mywidget_")):
96  self.setMinimumSize(self.mywidget_.minimumWidth(),
97  self.mywidget_.minimumHeight())
98  self.resize(self.mywidget_.minimumWidth(),
99  self.mywidget_.minimumHeight())
100 
101  def ToggleHide(self,checked):
102  self.setHidden(not self.isHidden())
103 
104  def hideEvent(self, event):
105  self.visible.emit(False)
106  QtWidgets.QDialog.hideEvent(self,event)
107 
108  def showEvent(self, event):
109  self.visible.emit(True)
110  QtWidgets.QDialog.showEvent(self,event)
String DLLEXPORT_OST_BASE GetSharedDataPath()