Arch structures can now be based on axes systems

This commit is contained in:
Yorik van Havre 2012-01-12 12:31:11 -02:00
parent 0de52ff73f
commit d26ba5f11b
3 changed files with 43 additions and 11 deletions

View File

@ -34,6 +34,7 @@ def addToComponent(compobject,addobject,mod=None):
"Components", the first one that exists in the component. Mod "Components", the first one that exists in the component. Mod
can be set to one of those attributes ("Objects", Base", etc...) can be set to one of those attributes ("Objects", Base", etc...)
to override the default.''' to override the default.'''
import Draft
if compobject == addobject: return if compobject == addobject: return
# first check is already there # first check is already there
found = False found = False
@ -51,11 +52,17 @@ def addToComponent(compobject,addobject,mod=None):
if hasattr(compobject,mod): if hasattr(compobject,mod):
if mod == "Base": if mod == "Base":
setattr(compobject,mod,addobject) setattr(compobject,mod,addobject)
addobject.ViewObject.hide()
elif mod == "Axes":
if Draft.getType(addobject) == "Axis":
l = getattr(compobject,mod)
l.append(addobject)
setattr(compobject,mod,l)
else: else:
l = getattr(compobject,mod) l = getattr(compobject,mod)
l.append(addobject) l.append(addobject)
setattr(compobject,mod,l) setattr(compobject,mod,l)
addobject.ViewObject.hide() addobject.ViewObject.hide()
else: else:
for a in attribs[:3]: for a in attribs[:3]:
if hasattr(compobject,a): if hasattr(compobject,a):
@ -103,7 +110,7 @@ class ComponentTaskPanel:
# the categories are shown only if they are not empty. # the categories are shown only if they are not empty.
self.obj = None self.obj = None
self.attribs = ["Base","Additions","Subtractions","Objects","Components"] self.attribs = ["Base","Additions","Subtractions","Objects","Components","Axes"]
self.form = QtGui.QWidget() self.form = QtGui.QWidget()
self.form.setObjectName("TaskPanel") self.form.setObjectName("TaskPanel")
self.grid = QtGui.QGridLayout(self.form) self.grid = QtGui.QGridLayout(self.form)
@ -233,6 +240,7 @@ class ComponentTaskPanel:
self.treeAdditions.setText(0,QtGui.QApplication.translate("Arch", "Additions", None, QtGui.QApplication.UnicodeUTF8)) self.treeAdditions.setText(0,QtGui.QApplication.translate("Arch", "Additions", None, QtGui.QApplication.UnicodeUTF8))
self.treeSubtractions.setText(0,QtGui.QApplication.translate("Arch", "Subtractions", None, QtGui.QApplication.UnicodeUTF8)) self.treeSubtractions.setText(0,QtGui.QApplication.translate("Arch", "Subtractions", None, QtGui.QApplication.UnicodeUTF8))
self.treeObjects.setText(0,QtGui.QApplication.translate("Arch", "Objects", None, QtGui.QApplication.UnicodeUTF8)) self.treeObjects.setText(0,QtGui.QApplication.translate("Arch", "Objects", None, QtGui.QApplication.UnicodeUTF8))
self.treeAxes.setText(0,QtGui.QApplication.translate("Arch", "Axes", None, QtGui.QApplication.UnicodeUTF8))
self.treeComponents.setText(0,QtGui.QApplication.translate("Arch", "Components", None, QtGui.QApplication.UnicodeUTF8)) self.treeComponents.setText(0,QtGui.QApplication.translate("Arch", "Components", None, QtGui.QApplication.UnicodeUTF8))
class Component: class Component:

View File

@ -84,15 +84,30 @@ class _Structure(ArchComponent.Component):
"The width of this element, if not based on a profile") "The width of this element, if not based on a profile")
obj.addProperty("App::PropertyLength","Height","Base", obj.addProperty("App::PropertyLength","Height","Base",
"The height or extrusion depth of this element. Keep 0 for automatic") "The height or extrusion depth of this element. Keep 0 for automatic")
obj.addProperty("App::PropertyLinkList","Axes","Base",
"Axes systems this structure is built on")
self.Type = "Structure" self.Type = "Structure"
def execute(self,obj): def execute(self,obj):
self.createGeometry(obj) self.createGeometry(obj)
def onChanged(self,obj,prop): def onChanged(self,obj,prop):
if prop in ["Base","Length","Width","Height","Normal","Additions","Subtractions"]: if prop in ["Base","Length","Width","Height","Normal","Additions","Subtractions","Axes"]:
self.createGeometry(obj) self.createGeometry(obj)
def getAxisPoints(self,obj):
"returns the gridpoints of linked axes"
from draftlibs import fcgeo
pts = []
if len(obj.Axes) >= 2:
set1 = obj.Axes[0].Shape.Edges
set2 = obj.Axes[1].Shape.Edges
for e1 in set1:
for e2 in set2:
pts.extend(fcgeo.findIntersection(e1,e2))
return pts
return None
def createGeometry(self,obj): def createGeometry(self,obj):
import Part import Part
from draftlibs import fcgeo from draftlibs import fcgeo
@ -158,8 +173,17 @@ class _Structure(ArchComponent.Component):
base = base.cut(hole.Shape) base = base.cut(hole.Shape)
hole.ViewObject.hide() # to be removed hole.ViewObject.hide() # to be removed
if base: if base:
obj.Shape = base pts = self.getAxisPoints(obj)
if not fcgeo.isNull(pl): obj.Placement = pl if pts:
fsh = []
for p in pts:
sh = base.copy()
sh.translate(p)
fsh.append(sh)
obj.Shape = Part.makeCompound(fsh)
else:
obj.Shape = base
if not fcgeo.isNull(pl): obj.Placement = pl
class _ViewProviderStructure(ArchComponent.ViewProviderComponent): class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
"A View Provider for the Structure object" "A View Provider for the Structure object"

View File

@ -536,13 +536,13 @@ def makeCopy(obj):
_Block(newobj) _Block(newobj)
_ViewProviderDraftPart(newobj.ViewObject) _ViewProviderDraftPart(newobj.ViewObject)
elif getType(obj) == "Structure": elif getType(obj) == "Structure":
import Structure import Arch
Structure._Structure(newobj) Arch._Structure(newobj)
Structure._ViewProviderStructure(newobj.ViewObject) Arch._ViewProviderStructure(newobj.ViewObject)
elif getType(obj) == "Wall": elif getType(obj) == "Wall":
import Wall import Arch
Wall._Wall(newobj) Arch._Wall(newobj)
Wall._ViewProviderWall(newobj.ViewObject) Arch._ViewProviderWall(newobj.ViewObject)
elif obj.isDerivedFrom("Part::Feature"): elif obj.isDerivedFrom("Part::Feature"):
newobj.Shape = obj.Shape newobj.Shape = obj.Shape
else: else: