mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
autopep8 aggressive
autopep8 --in-place --recursive --max-line-length=200 --aggressive --aggressive --aggressive ifcopenshell
This commit is contained in:
@@ -15,7 +15,7 @@ from collections import defaultdict, Iterable, OrderedDict
|
||||
os.environ['QT_API'] = 'pyqt4'
|
||||
try:
|
||||
from pyqode.qt import QtCore
|
||||
except:
|
||||
except BaseException:
|
||||
pass
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
@@ -24,22 +24,21 @@ from .code_editor_pane import code_edit
|
||||
|
||||
try:
|
||||
from OCC.Display.pyqt4Display import qtViewer3d
|
||||
except:
|
||||
except BaseException:
|
||||
import OCC.Display
|
||||
|
||||
try:
|
||||
import OCC.Display.backend
|
||||
except:
|
||||
except BaseException:
|
||||
pass
|
||||
|
||||
try:
|
||||
OCC.Display.backend.get_backend("qt-pyqt4")
|
||||
except:
|
||||
except BaseException:
|
||||
OCC.Display.backend.load_backend("qt-pyqt4")
|
||||
|
||||
from OCC.Display.qtDisplay import qtViewer3d
|
||||
|
||||
|
||||
from .main import settings, iterator
|
||||
from .occ_utils import display_shape
|
||||
|
||||
@@ -58,10 +57,11 @@ class configuration(object):
|
||||
try:
|
||||
import ConfigParser
|
||||
Cfg = ConfigParser.RawConfigParser
|
||||
except:
|
||||
except BaseException:
|
||||
import configparser
|
||||
|
||||
def Cfg(): return configparser.ConfigParser(interpolation=None)
|
||||
def Cfg():
|
||||
return configparser.ConfigParser(interpolation=None)
|
||||
|
||||
conf_file = os.path.expanduser(os.path.join("~", ".ifcopenshell", "app", "snippets.conf"))
|
||||
if conf_file.startswith("~"):
|
||||
@@ -114,7 +114,6 @@ if selection:
|
||||
|
||||
|
||||
class application(QtGui.QApplication):
|
||||
|
||||
"""A pythonOCC, PyQt based IfcOpenShell application
|
||||
with two tree views and a graphical 3d view"""
|
||||
|
||||
@@ -165,7 +164,8 @@ class application(QtGui.QApplication):
|
||||
itm = self.product_to_item.get(product)
|
||||
if itm is None:
|
||||
return
|
||||
self.selectionModel().setCurrentIndex(itm, QtGui.QItemSelectionModel.SelectCurrent | QtGui.QItemSelectionModel.Rows)
|
||||
self.selectionModel().setCurrentIndex(itm,
|
||||
QtGui.QItemSelectionModel.SelectCurrent | QtGui.QItemSelectionModel.Rows)
|
||||
|
||||
class decomposition_treeview(abstract_treeview):
|
||||
|
||||
@@ -233,6 +233,7 @@ class application(QtGui.QApplication):
|
||||
itm = items[t2] = QtGui.QTreeWidgetItem(items.get(s2, self), [t2])
|
||||
itm.setData(0, QtCore.Qt.UserRole, t2)
|
||||
self.children[s2].append(t2)
|
||||
|
||||
add(t)
|
||||
|
||||
for p in products:
|
||||
@@ -379,6 +380,7 @@ class application(QtGui.QApplication):
|
||||
shp = OCC.AIS.Handle_AIS_Shape.DownCast(li.Value(i + 1))
|
||||
if not shp.IsNull():
|
||||
yield shp
|
||||
|
||||
return tuple(shp.HashCode(1 << 24) for shp in yield_shapes())
|
||||
|
||||
def __init__(self, widget):
|
||||
@@ -528,6 +530,7 @@ class application(QtGui.QApplication):
|
||||
for c in self.components:
|
||||
if c != component:
|
||||
c.select(inst)
|
||||
|
||||
return handler
|
||||
|
||||
def __init__(self, settings=None):
|
||||
@@ -582,7 +585,8 @@ class application(QtGui.QApplication):
|
||||
sys.exit(self.exec_())
|
||||
|
||||
def browse(self):
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self.window, 'Open file', ".", "Industry Foundation Classes (*.ifc)")
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self.window, 'Open file', ".",
|
||||
"Industry Foundation Classes (*.ifc)")
|
||||
self.load(filename)
|
||||
|
||||
def clear(self):
|
||||
|
||||
@@ -11,7 +11,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
from PyQt4 import QtWidgets
|
||||
except:
|
||||
except BaseException:
|
||||
QtWidgets = QtGui
|
||||
|
||||
try:
|
||||
@@ -24,14 +24,14 @@ try:
|
||||
from pyqode.python.backend import server
|
||||
from pyqode.python import modes as pymodes, panels as pypanels, widgets
|
||||
from pyqode.python.widgets import PyInteractiveConsole
|
||||
|
||||
has_pyqode = True
|
||||
except:
|
||||
except BaseException:
|
||||
has_pyqode = False
|
||||
CodeEdit = QtWidgets.QPlainTextEdit
|
||||
|
||||
|
||||
class StdoutRedirector(object):
|
||||
|
||||
'''A class for redirecting stdout to this Text widget.'''
|
||||
|
||||
def __init__(self, widget):
|
||||
@@ -49,7 +49,6 @@ class StdoutRedirector(object):
|
||||
|
||||
|
||||
class code_edit(QtGui.QWidget):
|
||||
|
||||
class Console(InteractiveConsole):
|
||||
def __init__(*args):
|
||||
InteractiveConsole.__init__(*args)
|
||||
|
||||
@@ -32,7 +32,7 @@ from ..entity_instance import entity_instance
|
||||
def has_occ():
|
||||
try:
|
||||
import OCC.BRepTools
|
||||
except:
|
||||
except BaseException:
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -40,13 +40,17 @@ def has_occ():
|
||||
has_occ = has_occ()
|
||||
|
||||
|
||||
def wrap_shape_creation(settings, shape): return shape
|
||||
def wrap_shape_creation(settings, shape):
|
||||
return shape
|
||||
|
||||
|
||||
if has_occ:
|
||||
from . import occ_utils as utils
|
||||
|
||||
def wrap_shape_creation(settings, shape): return utils.create_shape_from_serialization(shape) if getattr(settings, 'use_python_opencascade', False) else shape
|
||||
def wrap_shape_creation(settings, shape): return utils.create_shape_from_serialization(shape) if getattr(settings,
|
||||
'use_python_opencascade',
|
||||
False) else shape
|
||||
|
||||
|
||||
# Subclass the settings module to provide an additional
|
||||
# setting to enable pythonOCC when available
|
||||
@@ -83,6 +87,7 @@ class iterator(_iterator):
|
||||
else:
|
||||
file_or_filename = os.path.abspath(file_or_filename)
|
||||
_iterator.__init__(self, settings, file_or_filename)
|
||||
|
||||
if has_occ:
|
||||
def get(self):
|
||||
return wrap_shape_creation(self.settings, _iterator.get(self))
|
||||
@@ -108,6 +113,7 @@ class tree(ifcopenshell_wrapper.tree):
|
||||
elif all(map(lambda v: hasattr(value, v), "XYZ")):
|
||||
return value.X(), value.Y(), value.Z()
|
||||
return value
|
||||
|
||||
args = [self, unwrap(value)]
|
||||
if isinstance(value, entity_instance):
|
||||
args.append(kwargs.get("completely_within", False))
|
||||
@@ -124,6 +130,7 @@ class tree(ifcopenshell_wrapper.tree):
|
||||
elif hasattr(value, "Get"):
|
||||
return value.Get()[:3], value.Get()[3:]
|
||||
return value
|
||||
|
||||
args = [self, unwrap(value)]
|
||||
if "extend" in kwargs or "completely_within" in kwargs:
|
||||
args.append(kwargs.get("completely_within", False))
|
||||
@@ -152,7 +159,9 @@ def iterate(settings, filename):
|
||||
|
||||
|
||||
def make_shape_function(fn):
|
||||
def entity_instance_or_none(e): return None if e is None else entity_instance(e)
|
||||
def entity_instance_or_none(e):
|
||||
return None if e is None else entity_instance(e)
|
||||
|
||||
if has_occ:
|
||||
import OCC.TopoDS
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ def initialize_display():
|
||||
while True:
|
||||
try:
|
||||
active_light = viewer.ActiveLight()
|
||||
except:
|
||||
except BaseException:
|
||||
break
|
||||
yield active_light
|
||||
viewer.NextActiveLights()
|
||||
@@ -115,7 +115,8 @@ def display_shape(shape, clr=None, viewer_handle=None):
|
||||
ais.SetMaterial(material)
|
||||
|
||||
if isinstance(clr, str):
|
||||
qclr = getattr(OCC.Quantity, "Quantity_NOC_%s" % clr.upper(), getattr(OCC.Quantity, "Quantity_NOC_%s1" % clr.upper(), None))
|
||||
qclr = getattr(OCC.Quantity, "Quantity_NOC_%s" % clr.upper(),
|
||||
getattr(OCC.Quantity, "Quantity_NOC_%s1" % clr.upper(), None))
|
||||
if qclr is None:
|
||||
raise Exception("No color named '%s'" % clr.upper())
|
||||
elif isinstance(clr, Iterable):
|
||||
@@ -146,7 +147,8 @@ def display_shape(shape, clr=None, viewer_handle=None):
|
||||
for shp, stl in zip(subshapes, representation.styles):
|
||||
subshape = OCC.AIS.AIS_Shape(shp)
|
||||
if min(stl) < 0. or max(stl) > 1.:
|
||||
default_style_applied = stl = DEFAULT_STYLES.get(representation.data.type, DEFAULT_STYLES["DEFAULT"])
|
||||
default_style_applied = stl = DEFAULT_STYLES.get(representation.data.type,
|
||||
DEFAULT_STYLES["DEFAULT"])
|
||||
subshape.SetColor(OCC.Quantity.Quantity_Color(stl[0], stl[1], stl[2], OCC.Quantity.Quantity_TOC_RGB))
|
||||
subshape.SetMaterial(material)
|
||||
if len(stl) == 4 and stl[3] < 1.:
|
||||
@@ -171,7 +173,9 @@ def display_shape(shape, clr=None, viewer_handle=None):
|
||||
ais = OCC.AIS.AIS_Shape(shape)
|
||||
ais.SetMaterial(material)
|
||||
|
||||
def r(): return random.random() * 0.3 + 0.7
|
||||
def r():
|
||||
return random.random() * 0.3 + 0.7
|
||||
|
||||
clr = OCC.Quantity.Quantity_Color(r(), r(), r(), OCC.Quantity.Quantity_TOC_RGB)
|
||||
ais.SetColor(clr)
|
||||
|
||||
@@ -211,12 +215,12 @@ def create_shape_from_serialization(brep_object):
|
||||
try:
|
||||
brep_data = brep_object.geometry.brep_data
|
||||
styles = brep_object.geometry.surface_styles
|
||||
except:
|
||||
except BaseException:
|
||||
try:
|
||||
brep_data = brep_object.brep_data
|
||||
styles = brep_object.surface_styles
|
||||
is_product_shape = False
|
||||
except:
|
||||
except BaseException:
|
||||
pass
|
||||
|
||||
styles = tuple(styles[i:i + 4] for i in range(0, len(styles), 4))
|
||||
@@ -228,7 +232,7 @@ def create_shape_from_serialization(brep_object):
|
||||
ss = OCC.BRepTools.BRepTools_ShapeSet()
|
||||
ss.ReadFromString(brep_data)
|
||||
occ_shape = ss.Shape(ss.NbShapes())
|
||||
except:
|
||||
except BaseException:
|
||||
pass
|
||||
|
||||
if is_product_shape:
|
||||
|
||||
Reference in New Issue
Block a user