Skip to content

Commit

Permalink
Arch: minor fixes around Arch & Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Mar 7, 2014
1 parent be33ef6 commit b6c24cf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/Mod/Arch/ArchCommands.py
Expand Up @@ -325,6 +325,8 @@ def closeHole(shape):
def getCutVolume(cutplane,shapes):
"""getCutVolume(cutplane,shapes): returns a cut face and a cut volume
from the given shapes and the given cutting plane"""
if not shapes:
return None,None,None
import Part
if not isinstance(shapes,list):
shapes = [shapes]
Expand Down Expand Up @@ -652,8 +654,8 @@ def getBrepFacesData(obj,scale=1):
of solids inside the object. Scale can indicate a scaling factor"""
if hasattr(obj,"Shape"):
if obj.Shape:
if obj.Shape.isValid():
if not obj.Shape.isNull():
if not obj.Shape.isNull():
if obj.Shape.isValid():
sols = []
for sol in obj.Shape.Solids:
s = []
Expand Down
11 changes: 8 additions & 3 deletions src/Mod/Arch/ArchSectionPlane.py
Expand Up @@ -155,17 +155,19 @@ def attach(self,vobj):
self.lcoords = coin.SoCoordinate3()
ls = coin.SoType.fromName("SoBrepEdgeSet").createInstance()
ls.coordIndex.setValues(0,57,[0,1,-1,2,3,4,5,-1,6,7,8,9,-1,10,11,-1,12,13,14,15,-1,16,17,18,19,-1,20,21,-1,22,23,24,25,-1,26,27,28,29,-1,30,31,-1,32,33,34,35,-1,36,37,38,39,-1,40,41,42,43,44])
sep = coin.SoSeparator()
psep = coin.SoSeparator()
fsep = coin.SoSeparator()
fsep.addChild(self.mat2)
fsep.addChild(self.fcoords)
fsep.addChild(fs)
psep.addChild(fsep)
psep.addChild(self.mat1)
psep.addChild(self.drawstyle)
psep.addChild(self.lcoords)
psep.addChild(ls)
vobj.addDisplayMode(psep,"Default")
sep.addChild(fsep)
sep.addChild(psep)
vobj.addDisplayMode(sep,"Default")
self.onChanged(vobj,"DisplaySize")
self.onChanged(vobj,"LineColor")
self.onChanged(vobj,"Transparency")
Expand Down Expand Up @@ -318,7 +320,10 @@ def buildSVG(self, obj,join=False):
self.direction = p.Rotation.multVec(FreeCAD.Vector(0,0,1))
for o in objs:
if o.isDerivedFrom("Part::Feature"):
if o.Shape.isValid():
if o.Shape.isNull():
pass
#FreeCAD.Console.PrintWarning(translate("Arch","Skipping empty object: ")+o.Name)
elif o.Shape.isValid():
shapes.extend(o.Shape.Solids)
else:
FreeCAD.Console.PrintWarning(translate("Arch","Skipping invalid object: ")+o.Name)
Expand Down
26 changes: 17 additions & 9 deletions src/Mod/Draft/Draft.py
Expand Up @@ -2911,8 +2911,7 @@ class _ViewProviderDraftAlt(_ViewProviderDraft):
"a view provider that doesn't swallow its base object"

def __init__(self,vobj):
vobj.Proxy = self
self.Object = vobj.Object
_ViewProviderDraft.__init__(self,vobj)

def claimChildren(self):
return []
Expand All @@ -2921,8 +2920,7 @@ class _ViewProviderDraftPart(_ViewProviderDraftAlt):
"a view provider that displays a Part icon instead of a Draft icon"

def __init__(self,vobj):
vobj.Proxy = self
self.Object = vobj.Object
_ViewProviderDraftAlt.__init__(self,vobj)

def getIcon(self):
return ":/icons/Tree_Part.svg"
Expand Down Expand Up @@ -3190,9 +3188,7 @@ def updateData(self, obj, prop):
def onChanged(self, vobj, prop):
"called when a view property has changed"

if prop in ["ExtLines","TextSpacing","DisplayMode","Override","FlipArrows","Decimals"]:
self.updateData(vobj.Object,"Start")
elif prop == "FontSize":
if prop == "FontSize":
if hasattr(self,"font"):
self.font.size = vobj.FontSize.Value
if hasattr(self,"font3d"):
Expand Down Expand Up @@ -3248,6 +3244,8 @@ def onChanged(self, vobj, prop):
self.marks.addChild(s2)
self.node.insertChild(self.marks,2)
self.node3d.insertChild(self.marks,2)
else:
self.updateData(vobj.Object,"Start")

def getDisplayModes(self,vobj):
return ["2D","3D"]
Expand Down Expand Up @@ -4119,7 +4117,7 @@ def __init__(self,obj):
obj.addProperty("App::PropertyBool","HiddenLines","Draft","Show hidden lines")
obj.addProperty("App::PropertyBool","Tessellation","Draft","Tessellate BSplines into line segments using number of spline poles")
obj.Projection = Vector(0,0,1)
obj.ProjectionMode = ["Solid","Individual Faces","Cutlines"]
obj.ProjectionMode = ["Solid","Individual Faces","Cutlines","Cutfaces"]
obj.HiddenLines = False
obj.Tessellation = True
_DraftObject.__init__(self,obj,"Shape2DView")
Expand Down Expand Up @@ -4167,11 +4165,21 @@ def execute(self,obj):
opl = FreeCAD.Placement(obj.Base.Placement)
proj = opl.Rotation.multVec(FreeCAD.Vector(0,0,1))
obj.Shape = self.getProjected(obj,comp,proj)
elif obj.ProjectionMode == "Cutlines":
elif obj.ProjectionMode in ["Cutlines","Cutfaces"]:
for sh in shapes:
if sh.Volume < 0:
sh.reverse()
c = sh.section(cutp)
if (obj.ProjectionMode == "Cutfaces") and (sh.ShapeType == "Solid"):
try:
c = Part.Wire(DraftGeomUtils.sortEdges(c.Edges))
except:
pass
else:
try:
c = Part.Face(c)
except:
pass
cuts.append(c)
comp = Part.makeCompound(cuts)
opl = FreeCAD.Placement(obj.Base.Placement)
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/DraftSnap.py
Expand Up @@ -1081,7 +1081,7 @@ def makeSnapToolBar(self):
b.setIcon(QtGui.QIcon(":/icons/Snap_"+n+".svg"))
b.setIconSize(QtCore.QSize(16, 16))
b.setMaximumSize(QtCore.QSize(26,26))
b.setToolTip(c)
b.setToolTip(n)
b.setObjectName("SnapButton"+n)
b.setCheckable(True)
b.setChecked(True)
Expand Down

0 comments on commit b6c24cf

Please sign in to comment.