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