OpenStructure
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 
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 
47  self.obsobs = SceneObserverImpl()
48  self.obsobs.AttachObserver(self)
49  ost.scene.AttachObserver(self.obsobs)
50  app.scene_win.qobject.ActiveNodesChanged.connect(self.ActiveNodesChangedActiveNodesChanged)
51 
52  self.setMinimumSize(250,215)
53  #ToolBarOptionsWidget Method
54  def OnComboChange(self, item):
55  self.DoResizeDoResize()
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.layoutlayout=QtWidgets.QHBoxLayout()
83  self.layoutlayout.setContentsMargins(0,0,0,0)
84  self.layoutlayout.setSpacing(0)
85  self.setLayout(self.layoutlayout)
86  self.mywidget_mywidget_ = InspectorWidget(self)
87  self.layoutlayout.addWidget(self.mywidget_mywidget_)
88  size_pol = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
89  QtWidgets.QSizePolicy.Expanding)
90  self.setSizePolicy(size_pol)
91  self.DoResizeDoResize()
92 
93  def DoResize(self):
94  if(hasattr(self, "mywidget_")):
95  self.setMinimumSize(self.mywidget_mywidget_.minimumWidth(),
96  self.mywidget_mywidget_.minimumHeight())
97  self.resize(self.mywidget_mywidget_.minimumWidth(),
98  self.mywidget_mywidget_.minimumHeight())
99 
100  def ToggleHide(self,checked):
101  self.setHidden(not self.isHidden())
102 
103  def hideEvent(self, event):
104  self.visiblevisible.emit(False)
105  QtWidgets.QDialog.hideEvent(self,event)
106 
107  def showEvent(self, event):
108  self.visiblevisible.emit(True)
109  QtWidgets.QDialog.showEvent(self,event)
String DLLEXPORT_OST_BASE GetSharedDataPath()