Skip to content

Commit

Permalink
Draft: More streamlined console output
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed May 14, 2018
1 parent a711474 commit 4cb93bf
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/Mod/Draft/DraftTools.py
Expand Up @@ -533,6 +533,7 @@ def GetResources(self):

def Activated(self,name=translate("draft","Line")):
Creator.Activated(self,name)
self.pointPrinted = 0
if self.doc:
self.obj = None # stores the temp shape
self.oldWP = None # stores the WP if we modify it
Expand All @@ -547,10 +548,15 @@ def Activated(self,name=translate("draft","Line")):
# self.obj.ViewObject.Selectable = False
Draft.formatObject(self.obj)
self.call = self.view.addEventCallback("SoEvent",self.action)
msg(translate("draft", "Pick first point:")+"\n")
msg(translate("draft", "First point:")+" ")

def finish(self,closed=False,cont=False):
"terminates the operation and closes the poly if asked"
if len(self.node) > self.pointPrinted:
msg(str(tuple(self.node[-1])))
if closed:
msg(translate("draft","Closing")+"\n")
msg("\n")
if self.obj:
# remove temporary object, if any
try:
Expand Down Expand Up @@ -624,7 +630,7 @@ def action(self,arg):
if ((self.point-self.node[0]).Length < Draft.tolerance()):
self.undolast()
self.finish(True,cont=True)
msg(translate("draft", "DWire has been closed")+"\n")
#msg(translate("draft", "DWire has been closed")+"\n")

def undolast(self):
"undoes last line segment"
Expand All @@ -639,29 +645,36 @@ def undolast(self):
else:
self.obj.ViewObject.hide()
# DNC: report on removal
msg(translate("draft", "Last point has been removed")+"\n")
msg(translate("draft", "Removing last point")+"\n")
msg(translate("draft", "Next point:")+" ")

def drawSegment(self,point):
"draws a new segment"
if self.planetrack and self.node:
self.planetrack.set(self.node[-1])
if (len(self.node) == 1):
msg(translate("draft", "Pick next point:")+"\n")
msg(str(tuple(self.node[-1]))+"\n")
msg(translate("draft", "Next point:")+" ")
self.pointPrinted += 1
elif (len(self.node) == 2):
last = self.node[len(self.node)-2]
newseg = Part.LineSegment(last,point).toShape()
self.obj.Shape = newseg
self.obj.ViewObject.Visibility = True
if self.isWire:
msg(translate("draft", "Pick next point, or Finish (shift-F) or close (o):")+"\n")
msg(str(tuple(self.node[-1]))+"\n")
msg(translate("draft", "Next point:")+" ")
self.pointPrinted += 1
else:
currentshape = self.obj.Shape.copy()
last = self.node[len(self.node)-2]
if not DraftVecUtils.equals(last,point):
newseg = Part.LineSegment(last,point).toShape()
newshape=currentshape.fuse(newseg)
self.obj.Shape = newshape
msg(translate("draft", "Pick next point, or Finish (shift-F) or close (o):")+"\n")
msg(str(tuple(self.node[-1]))+"\n")
msg(translate("draft", "Next point:")+" ")
self.pointPrinted += 1

def wipe(self):
"removes all previous segments and starts from last point"
Expand All @@ -671,7 +684,8 @@ def wipe(self):
self.node = [self.node[-1]]
if self.planetrack:
self.planetrack.set(self.node[0])
msg(translate("draft", "Pick next point:")+"\n")
msg("\n"+translate("draft","Restarting from")+" "+str(tuple(self.node[-1]))+"\n")
msg(translate("draft", "Next point:"))

def orientWP(self):
if hasattr(FreeCAD,"DraftWorkingPlane"):
Expand Down Expand Up @@ -1024,7 +1038,7 @@ def Activated(self):
self.ui.extUi()
self.call = self.view.addEventCallback("SoEvent",self.action)
self.rect = rectangleTracker()
msg(translate("draft", "Pick first point:\n"))
msg(translate("draft", "Pick first point:")+"\n")

def finish(self,closed=False,cont=False):
"terminates the operation and closes the poly if asked"
Expand Down

0 comments on commit 4cb93bf

Please sign in to comment.