Add BIM workbench to .pre-commit-config.yaml (#21591)
* Add BIM workbench to .pre-commit-config.yaml * pre-commit: ignore translations * pre-commit: add additional ignore pattern * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -22,9 +22,9 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
__title__ = "FreeCAD Axis System"
|
||||
__title__ = "FreeCAD Axis System"
|
||||
__author__ = "Yorik van Havre"
|
||||
__url__ = "https://www.freecad.org"
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
## @package ArchAxisSystem
|
||||
# \ingroup ARCH
|
||||
@@ -45,48 +45,61 @@ if FreeCAD.GuiUp:
|
||||
from draftutils.translate import translate
|
||||
else:
|
||||
# \cond
|
||||
def translate(ctxt,txt):
|
||||
def translate(ctxt, txt):
|
||||
return txt
|
||||
def QT_TRANSLATE_NOOP(ctxt,txt):
|
||||
|
||||
def QT_TRANSLATE_NOOP(ctxt, txt):
|
||||
return txt
|
||||
|
||||
# \endcond
|
||||
|
||||
|
||||
class _AxisSystem:
|
||||
|
||||
"The Axis System object"
|
||||
|
||||
def __init__(self,obj):
|
||||
def __init__(self, obj):
|
||||
|
||||
obj.Proxy = self
|
||||
self.Type = "AxisSystem"
|
||||
self.setProperties(obj)
|
||||
|
||||
def setProperties(self,obj):
|
||||
def setProperties(self, obj):
|
||||
|
||||
pl = obj.PropertiesList
|
||||
if not "Axes" in pl:
|
||||
obj.addProperty("App::PropertyLinkList","Axes","AxisSystem", QT_TRANSLATE_NOOP("App::Property","The axes this system is made of"), locked=True)
|
||||
obj.addProperty(
|
||||
"App::PropertyLinkList",
|
||||
"Axes",
|
||||
"AxisSystem",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The axes this system is made of"),
|
||||
locked=True,
|
||||
)
|
||||
if not "Placement" in pl:
|
||||
obj.addProperty("App::PropertyPlacement","Placement","AxisSystem",QT_TRANSLATE_NOOP("App::Property","The placement of this axis system"), locked=True)
|
||||
obj.addProperty(
|
||||
"App::PropertyPlacement",
|
||||
"Placement",
|
||||
"AxisSystem",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The placement of this axis system"),
|
||||
locked=True,
|
||||
)
|
||||
|
||||
def onDocumentRestored(self,obj):
|
||||
def onDocumentRestored(self, obj):
|
||||
|
||||
self.setProperties(obj)
|
||||
|
||||
def execute(self,obj):
|
||||
def execute(self, obj):
|
||||
|
||||
pass
|
||||
|
||||
def onBeforeChange(self,obj,prop):
|
||||
def onBeforeChange(self, obj, prop):
|
||||
|
||||
if prop == "Placement":
|
||||
self.Placement = obj.Placement
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
def onChanged(self, obj, prop):
|
||||
|
||||
if prop == "Placement":
|
||||
if hasattr(self,"Placement"):
|
||||
if hasattr(self, "Placement"):
|
||||
delta = obj.Placement.multiply(self.Placement.inverse())
|
||||
for o in obj.Axes:
|
||||
o.Placement = delta.multiply(o.Placement)
|
||||
@@ -95,12 +108,11 @@ class _AxisSystem:
|
||||
|
||||
return None
|
||||
|
||||
def loads(self,state):
|
||||
def loads(self, state):
|
||||
|
||||
self.Type = "AxisSystem"
|
||||
|
||||
def getPoints(self,obj):
|
||||
|
||||
def getPoints(self, obj):
|
||||
"returns the gridpoints of linked axes"
|
||||
|
||||
pts = []
|
||||
@@ -108,20 +120,20 @@ class _AxisSystem:
|
||||
for e in obj.Axes[0].Shape.Edges:
|
||||
pts.append(e.Vertexes[0].Point)
|
||||
elif len(obj.Axes) == 2:
|
||||
set1 = obj.Axes[0].Shape.Edges # X
|
||||
set2 = obj.Axes[1].Shape.Edges # Y
|
||||
set1 = obj.Axes[0].Shape.Edges # X
|
||||
set2 = obj.Axes[1].Shape.Edges # Y
|
||||
for e1 in set1:
|
||||
for e2 in set2:
|
||||
pts.extend(DraftGeomUtils.findIntersection(e1,e2))
|
||||
pts.extend(DraftGeomUtils.findIntersection(e1, e2))
|
||||
elif len(obj.Axes) == 3:
|
||||
set1 = obj.Axes[0].Shape.Edges # X
|
||||
set2 = obj.Axes[1].Shape.Edges # Y
|
||||
set3 = obj.Axes[2].Shape.Edges # Z
|
||||
set1 = obj.Axes[0].Shape.Edges # X
|
||||
set2 = obj.Axes[1].Shape.Edges # Y
|
||||
set3 = obj.Axes[2].Shape.Edges # Z
|
||||
bset = []
|
||||
cv = None
|
||||
for e1 in set1:
|
||||
for e2 in set2:
|
||||
bset.extend(DraftGeomUtils.findIntersection(e1,e2))
|
||||
bset.extend(DraftGeomUtils.findIntersection(e1, e2))
|
||||
for e3 in set3:
|
||||
if not cv:
|
||||
cv = e3.Vertexes[0].Point
|
||||
@@ -131,39 +143,39 @@ class _AxisSystem:
|
||||
pts.extend([p.add(v) for p in bset])
|
||||
return pts
|
||||
|
||||
def getAxisData(self,obj):
|
||||
def getAxisData(self, obj):
|
||||
data = []
|
||||
for axis in obj.Axes:
|
||||
if hasattr(axis,"Proxy") and hasattr(axis.Proxy,"getAxisData"):
|
||||
if hasattr(axis, "Proxy") and hasattr(axis.Proxy, "getAxisData"):
|
||||
data.append(axis.Proxy.getAxisData(axis))
|
||||
return data
|
||||
|
||||
|
||||
class _ViewProviderAxisSystem:
|
||||
|
||||
"A View Provider for the Axis object"
|
||||
|
||||
def __init__(self,vobj):
|
||||
def __init__(self, vobj):
|
||||
|
||||
vobj.Proxy = self
|
||||
|
||||
def getIcon(self):
|
||||
|
||||
import Arch_rc
|
||||
|
||||
return ":/icons/Arch_Axis_System_Tree.svg"
|
||||
|
||||
def claimChildren(self):
|
||||
|
||||
if hasattr(self,"axes"):
|
||||
if hasattr(self, "axes"):
|
||||
return self.axes
|
||||
return []
|
||||
|
||||
def attach(self, vobj):
|
||||
self.Object = vobj.Object
|
||||
self.axes = vobj.Object.Axes
|
||||
vobj.addDisplayMode(coin.SoSeparator(),"Default")
|
||||
vobj.addDisplayMode(coin.SoSeparator(), "Default")
|
||||
|
||||
def getDisplayModes(self,vobj):
|
||||
def getDisplayModes(self, vobj):
|
||||
|
||||
return ["Default"]
|
||||
|
||||
@@ -171,11 +183,11 @@ class _ViewProviderAxisSystem:
|
||||
|
||||
return "Default"
|
||||
|
||||
def setDisplayMode(self,mode):
|
||||
def setDisplayMode(self, mode):
|
||||
|
||||
return mode
|
||||
|
||||
def updateData(self,obj,prop):
|
||||
def updateData(self, obj, prop):
|
||||
|
||||
self.axes = obj.Axes
|
||||
|
||||
@@ -205,13 +217,10 @@ class _ViewProviderAxisSystem:
|
||||
return True
|
||||
|
||||
def setupContextMenu(self, vobj, menu):
|
||||
if FreeCADGui.activeWorkbench().name() != 'BIMWorkbench':
|
||||
if FreeCADGui.activeWorkbench().name() != "BIMWorkbench":
|
||||
return
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"),
|
||||
menu)
|
||||
QtCore.QObject.connect(actionEdit,
|
||||
QtCore.SIGNAL("triggered()"),
|
||||
self.edit)
|
||||
actionEdit = QtGui.QAction(translate("Arch", "Edit"), menu)
|
||||
QtCore.QObject.connect(actionEdit, QtCore.SIGNAL("triggered()"), self.edit)
|
||||
menu.addAction(actionEdit)
|
||||
|
||||
def edit(self):
|
||||
@@ -221,16 +230,15 @@ class _ViewProviderAxisSystem:
|
||||
|
||||
return None
|
||||
|
||||
def loads(self,state):
|
||||
def loads(self, state):
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class AxisSystemTaskPanel:
|
||||
"""A TaskPanel for all the section plane object"""
|
||||
|
||||
'''A TaskPanel for all the section plane object'''
|
||||
|
||||
def __init__(self,obj):
|
||||
def __init__(self, obj):
|
||||
|
||||
self.obj = obj
|
||||
self.form = QtGui.QWidget()
|
||||
@@ -273,9 +281,9 @@ class AxisSystemTaskPanel:
|
||||
|
||||
return QtGui.QDialogButtonBox.Ok
|
||||
|
||||
def getIcon(self,obj):
|
||||
def getIcon(self, obj):
|
||||
|
||||
if hasattr(obj.ViewObject,"Proxy"):
|
||||
if hasattr(obj.ViewObject, "Proxy"):
|
||||
return QtGui.QIcon(obj.ViewObject.Proxy.getIcon())
|
||||
elif obj.isDerivedFrom("Sketcher::SketchObject"):
|
||||
return QtGui.QIcon(":/icons/Sketcher_Sketch.svg")
|
||||
@@ -291,16 +299,16 @@ class AxisSystemTaskPanel:
|
||||
if self.obj:
|
||||
for o in self.obj.Axes:
|
||||
item = QtGui.QTreeWidgetItem(self.tree)
|
||||
item.setText(0,o.Label)
|
||||
item.setToolTip(0,o.Name)
|
||||
item.setIcon(0,self.getIcon(o))
|
||||
item.setText(0, o.Label)
|
||||
item.setToolTip(0, o.Name)
|
||||
item.setIcon(0, self.getIcon(o))
|
||||
self.retranslateUi(self.form)
|
||||
|
||||
def addElement(self):
|
||||
|
||||
if self.obj:
|
||||
for o in FreeCADGui.Selection.getSelection():
|
||||
if not(o in self.obj.Axes) and (o != self.obj):
|
||||
if not (o in self.obj.Axes) and (o != self.obj):
|
||||
g = self.obj.Axes
|
||||
g.append(o)
|
||||
self.obj.Axes = g
|
||||
|
||||
Reference in New Issue
Block a user