Draft: Allow to switch the line of Draft Labels on/off

This commit is contained in:
Yorik van Havre
2018-09-03 16:03:10 -03:00
parent f2ec0eaca3
commit e79cadb6c0
2 changed files with 21 additions and 8 deletions

View File

@@ -7015,6 +7015,7 @@ class ViewProviderDraftLabel:
vobj.addProperty("App::PropertyEnumeration","TextAlignment","Base",QT_TRANSLATE_NOOP("App::Property","The vertical alignment of the text"))
vobj.addProperty("App::PropertyEnumeration","ArrowType","Base",QT_TRANSLATE_NOOP("App::Property","The type of arrow of this label"))
vobj.addProperty("App::PropertyEnumeration","Frame","Base",QT_TRANSLATE_NOOP("App::Property","The type of frame around the text of this object"))
vobj.addProperty("App::PropertyBool","Line","Base",QT_TRANSLATE_NOOP("App::Property","Display a leader line or not"))
vobj.addProperty("App::PropertyFloat","LineWidth","Base",QT_TRANSLATE_NOOP("App::Property","Line width"))
vobj.addProperty("App::PropertyColor","LineColor","Base",QT_TRANSLATE_NOOP("App::Property","Line color"))
vobj.addProperty("App::PropertyColor","TextColor","Base",QT_TRANSLATE_NOOP("App::Property","Text color"))
@@ -7030,6 +7031,7 @@ class ViewProviderDraftLabel:
vobj.ArrowType = arrowtypes
vobj.ArrowType = arrowtypes[getParam("dimsymbol")]
vobj.Frame = ["None","Rectangle"]
vobj.Line = True
def getIcon(self):
import Draft_rc
@@ -7060,13 +7062,18 @@ class ViewProviderDraftLabel:
self.text3d.justification = coin.SoAsciiText.RIGHT
self.fcoords = coin.SoCoordinate3()
self.frame = coin.SoType.fromName("SoBrepEdgeSet").createInstance()
self.lineswitch = coin.SoSwitch()
switchnode = coin.SoSeparator()
switchnode.addChild(self.line)
switchnode.addChild(self.arrow)
self.lineswitch.addChild(switchnode)
self.lineswitch.whichChild = 0
self.node2d = coin.SoGroup()
self.node2d.addChild(self.matline)
self.node2d.addChild(self.arrow)
self.node2d.addChild(self.drawstyle)
self.node2d.addChild(self.lcoords)
self.node2d.addChild(self.line)
self.node2d.addChild(self.arrow)
self.node2d.addChild(self.lineswitch)
self.node2d.addChild(self.mattext)
self.node2d.addChild(textdrawstyle)
self.node2d.addChild(self.textpos)
@@ -7079,8 +7086,7 @@ class ViewProviderDraftLabel:
self.node3d.addChild(self.arrow)
self.node3d.addChild(self.drawstyle)
self.node3d.addChild(self.lcoords)
self.node3d.addChild(self.line)
self.node3d.addChild(self.arrow)
self.node3d.addChild(self.lineswitch)
self.node3d.addChild(self.mattext)
self.node3d.addChild(textdrawstyle)
self.node3d.addChild(self.textpos)
@@ -7168,6 +7174,12 @@ class ViewProviderDraftLabel:
pos = vobj.Object.Placement.Base.add(v)
self.textpos.translation.setValue(pos)
self.textpos.rotation.setValue(vobj.Object.Placement.Rotation.Q)
elif prop == "Line":
if hasattr(vobj,"Line"):
if vobj.Line:
self.lineswitch.whichChild = 0
else:
self.lineswitch.whichChild = -1
elif prop == "ArrowType":
if hasattr(vobj,"ArrowType"):
if len(vobj.Object.Points) > 1:

View File

@@ -4087,10 +4087,11 @@ class Edit(Modifier):
# commented out the following line to disable updating
# the object during edit, otherwise it confuses the snapper
#self.update(self.trackers[self.editing].get())
if self.ui.addButton.isChecked():
self.obj.ViewObject.Selectable = True
else:
self.obj.ViewObject.Selectable = False
if hasattr(self.obj.ViewObject,"Selectable"):
if self.ui.addButton.isChecked():
self.obj.ViewObject.Selectable = True
else:
self.obj.ViewObject.Selectable = False
redraw3DView()
elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):