Arch: Added pref option to not copy units to clipboard in survey mode
This commit is contained in:
parent
eca3ce2dde
commit
a07ad8dcf1
|
@ -730,6 +730,9 @@ def survey(callback=False):
|
|||
for o in newsels:
|
||||
if o.Object.isDerivedFrom("Part::Feature"):
|
||||
n = o.Object.Label
|
||||
showUnit = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("surveyUnits",True)
|
||||
t = ""
|
||||
u = FreeCAD.Units.Quantity()
|
||||
if not o.HasSubObjects:
|
||||
# entire object
|
||||
anno = FreeCAD.ActiveDocument.addObject("App::AnnotationLabel","surveyLabel")
|
||||
|
@ -738,27 +741,29 @@ def survey(callback=False):
|
|||
else:
|
||||
anno.BasePosition = o.Object.Shape.BoundBox.Center
|
||||
FreeCAD.SurveyObserver.labels.append(anno.Name)
|
||||
t = ""
|
||||
if o.Object.Shape.Solids:
|
||||
t = FreeCAD.Units.Quantity(o.Object.Shape.Volume,FreeCAD.Units.Volume)
|
||||
t = t.getUserPreferred()[0]
|
||||
u = FreeCAD.Units.Quantity(o.Object.Shape.Volume,FreeCAD.Units.Volume)
|
||||
t = u.getUserPreferred()[0]
|
||||
t = t.encode("utf8").replace("^3","³")
|
||||
anno.LabelText = "v " + t
|
||||
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: Whole, Volume: " + t.decode("utf8") + "\n")
|
||||
elif o.Object.Shape.Faces:
|
||||
t = FreeCAD.Units.Quantity(o.Object.Shape.Area,FreeCAD.Units.Area)
|
||||
t = t.getUserPreferred()[0]
|
||||
u = FreeCAD.Units.Quantity(o.Object.Shape.Area,FreeCAD.Units.Area)
|
||||
t = u.getUserPreferred()[0]
|
||||
t = t.encode("utf8").replace("^2","²")
|
||||
anno.LabelText = "a " + t
|
||||
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: Whole, Area: " + t.decode("utf8") + "\n")
|
||||
else:
|
||||
t = FreeCAD.Units.Quantity(o.Object.Shape.Length,FreeCAD.Units.Length)
|
||||
t = t.getUserPreferred()[0]
|
||||
u = FreeCAD.Units.Quantity(o.Object.Shape.Length,FreeCAD.Units.Length)
|
||||
t = u.getUserPreferred()[0]
|
||||
t = t.encode("utf8")
|
||||
anno.LabelText = "l " + t
|
||||
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: Whole, Length: " + t.decode("utf8") + "\n")
|
||||
if FreeCAD.GuiUp and t:
|
||||
QtGui.qApp.clipboard().setText(t)
|
||||
if showUnit:
|
||||
QtGui.qApp.clipboard().setText(t)
|
||||
else:
|
||||
QtGui.qApp.clipboard().setText(str(u.Value))
|
||||
else:
|
||||
# single element(s)
|
||||
for el in o.SubElementNames:
|
||||
|
@ -772,27 +777,29 @@ def survey(callback=False):
|
|||
else:
|
||||
anno.BasePosition = e.BoundBox.Center
|
||||
FreeCAD.SurveyObserver.labels.append(anno.Name)
|
||||
t = ""
|
||||
if "Face" in el:
|
||||
t = FreeCAD.Units.Quantity(e.Area,FreeCAD.Units.Area)
|
||||
t = t.getUserPreferred()[0]
|
||||
u = FreeCAD.Units.Quantity(e.Area,FreeCAD.Units.Area)
|
||||
t = u.getUserPreferred()[0]
|
||||
t = t.encode("utf8").replace("^2","²")
|
||||
anno.LabelText = "a " + t
|
||||
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Area: "+ t.decode("utf8") + "\n")
|
||||
elif "Edge" in el:
|
||||
t = FreeCAD.Units.Quantity(e.Length,FreeCAD.Units.Length)
|
||||
t = t.getUserPreferred()[0]
|
||||
u= FreeCAD.Units.Quantity(e.Length,FreeCAD.Units.Length)
|
||||
t = u.getUserPreferred()[0]
|
||||
t = t.encode("utf8")
|
||||
anno.LabelText = "l " + t
|
||||
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Length: " + t.decode("utf8") + "\n")
|
||||
elif "Vertex" in el:
|
||||
t = FreeCAD.Units.Quantity(e.Z,FreeCAD.Units.Length)
|
||||
t = t.getUserPreferred()[0]
|
||||
u = FreeCAD.Units.Quantity(e.Z,FreeCAD.Units.Length)
|
||||
t = u.getUserPreferred()[0]
|
||||
t = t.encode("utf8")
|
||||
anno.LabelText = "z " + t
|
||||
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Zcoord: " + t.decode("utf8") + "\n")
|
||||
if FreeCAD.GuiUp and t:
|
||||
QtGui.qApp.clipboard().setText(t)
|
||||
if showUnit:
|
||||
QtGui.qApp.clipboard().setText(t)
|
||||
else:
|
||||
QtGui.qApp.clipboard().setText(str(u.Value))
|
||||
|
||||
FreeCAD.SurveyObserver.selection.extend(newsels)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>460</width>
|
||||
<height>500</height>
|
||||
<height>537</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -402,6 +402,38 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Survey</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="checkBox_2">
|
||||
<property name="toolTip">
|
||||
<string>If this is checked, the text that gets placed in the clipboard will include the unit. Otherwise, it will be a simple number expressed in internal units (millimeters)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Include unit when sending measurements to clipboard</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>surveyUnits</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Arch</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
Loading…
Reference in New Issue
Block a user