Draft: Added Draft Slope command - allows to change the slope of a selected Line or Wire

This commit is contained in:
Yorik van Havre 2016-08-22 17:34:38 -03:00
parent 94f07c85ee
commit 51ec213f45
5 changed files with 474 additions and 3 deletions

View File

@ -62,7 +62,8 @@ class ArchWorkbench(Workbench):
"Draft_ShowSnapBar","Draft_ToggleGrid","Draft_UndoLine",
"Draft_FinishLine","Draft_CloseLine"]
self.draftutils = ["Draft_VisGroup","Draft_Heal","Draft_FlipDimension",
"Draft_ToggleConstructionMode","Draft_ToggleContinueMode","Draft_Edit"]
"Draft_ToggleConstructionMode","Draft_ToggleContinueMode","Draft_Edit",
"Draft_Slope"]
self.snapList = ['Draft_Snap_Lock','Draft_Snap_Midpoint','Draft_Snap_Perpendicular',
'Draft_Snap_Grid','Draft_Snap_Intersection','Draft_Snap_Parallel',
'Draft_Snap_Endpoint','Draft_Snap_Angle','Draft_Snap_Center',

View File

@ -604,7 +604,7 @@ class Wire(Line):
['Draft.makeWire(['+pts+'])']+rems)])
return
Line.Activated(self,name=translate("draft","DWire"))
Line.Activated(self,name=translate("draft","DWire"))
class BSpline(Line):
@ -4564,6 +4564,58 @@ class Mirror(Modifier):
self.finish()
class Draft_Slope():
def GetResources(self):
return {'Pixmap' : 'Draft_Slope',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_Slope", "Set slope"),
'ToolTip' : QtCore.QT_TRANSLATE_NOOP("Draft_Slope", "Sets the slope of a selected line or wire")}
def Activated(self):
if not FreeCADGui.Selection.getSelection():
return
for obj in FreeCADGui.Selection.getSelection():
if Draft.getType(obj) != "Wire":
msg(translate("draft", "This tool only works with Wires and Lines\n"))
return
w = QtGui.QWidget()
w.setWindowTitle(translate("Draft","Slope"))
layout = QtGui.QHBoxLayout(w)
label = QtGui.QLabel(w)
label.setText(translate("Draft", "Slope")+":")
layout.addWidget(label)
self.spinbox = QtGui.QDoubleSpinBox(w)
self.spinbox.setMinimum(-9999.99)
self.spinbox.setMaximum(9999.99)
self.spinbox.setSingleStep(0.01)
self.spinbox.setToolTip(translate("Draft", "Slope to give toselected Wires/Lines: 0 = horizontal, 1 = 45deg up, -1 = 45deg down"))
layout.addWidget(self.spinbox)
taskwidget = QtGui.QWidget()
taskwidget.form = w
taskwidget.accept = self.accept
FreeCADGui.Control.showDialog(taskwidget)
def accept(self):
if hasattr(self,"spinbox"):
pc = self.spinbox.value()
FreeCAD.ActiveDocument.openTransaction("Change slope")
for obj in FreeCADGui.Selection.getSelection():
if Draft.getType(obj) == "Wire":
if len(obj.Points) > 1:
lp = None
np = []
for p in obj.Points:
if not lp:
lp = p
else:
z = pc*FreeCAD.Vector(p.x,p.y,lp.z).Length
lp = FreeCAD.Vector(p.x,p.y,z)
np.append(lp)
obj.Points = np
FreeCAD.ActiveDocument.commitTransaction()
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()
#---------------------------------------------------------------------------
# Snap tools
#---------------------------------------------------------------------------
@ -4788,6 +4840,7 @@ FreeCADGui.addCommand('Draft_PathArray',PathArray())
FreeCADGui.addCommand('Draft_Heal',Heal())
FreeCADGui.addCommand('Draft_VisGroup',VisGroup())
FreeCADGui.addCommand('Draft_Mirror',Mirror())
FreeCADGui.addCommand('Draft_Slope',Draft_Slope())
# context commands
FreeCADGui.addCommand('Draft_FinishLine',FinishLine())

View File

@ -82,7 +82,8 @@ class DraftWorkbench (Workbench):
"Draft_ShowSnapBar","Draft_ToggleGrid"]
self.lineList = ["Draft_UndoLine","Draft_FinishLine","Draft_CloseLine"]
self.utils = ["Draft_VisGroup","Draft_Heal","Draft_FlipDimension",
"Draft_ToggleConstructionMode","Draft_ToggleContinueMode","Draft_Edit"]
"Draft_ToggleConstructionMode","Draft_ToggleContinueMode","Draft_Edit",
"Draft_Slope"]
self.snapList = ['Draft_Snap_Lock','Draft_Snap_Midpoint','Draft_Snap_Perpendicular',
'Draft_Snap_Grid','Draft_Snap_Intersection','Draft_Snap_Parallel',
'Draft_Snap_Endpoint','Draft_Snap_Angle','Draft_Snap_Center',

View File

@ -69,6 +69,7 @@
<file>icons/Draft_FlipDimension.svg</file>
<file>icons/Draft_Mirror.svg</file>
<file>icons/Draft_Grid.svg</file>
<file>icons/Draft_Slope.svg</file>
<file>icons/DraftWorkbench.svg</file>
<file>patterns/concrete.svg</file>
<file>patterns/cross.svg</file>

View File

@ -0,0 +1,415 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg3612"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="Draft_Slope.svg">
<defs
id="defs3614">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective3620" />
<inkscape:perspective
id="perspective3588"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3692"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
id="linearGradient3144-6">
<stop
id="stop3146-9"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop3148-2"
style="stop-color:#ffffff;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
id="linearGradient3701">
<stop
id="stop3703"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop3705"
style="stop-color:#ffffff;stop-opacity:0"
offset="1" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3144-6"
id="radialGradient3688"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.6985294,0,202.82863)"
cx="225.26402"
cy="672.79736"
fx="225.26402"
fy="672.79736"
r="34.345188" />
<linearGradient
id="linearGradient3708">
<stop
id="stop3710"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop3712"
style="stop-color:#ffffff;stop-opacity:0"
offset="1" />
</linearGradient>
<inkscape:perspective
id="perspective3805"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
id="linearGradient3864-0-0">
<stop
id="stop3866-5-7"
offset="0"
style="stop-color:#0619c0;stop-opacity:1;" />
<stop
id="stop3868-7-6"
offset="1"
style="stop-color:#379cfb;stop-opacity:1;" />
</linearGradient>
<linearGradient
id="linearGradient3377">
<stop
id="stop3379"
offset="0"
style="stop-color:#ffaa00;stop-opacity:1;" />
<stop
id="stop3381"
offset="1"
style="stop-color:#faff2b;stop-opacity:1;" />
</linearGradient>
<linearGradient
id="linearGradient3864-0">
<stop
id="stop3866-5"
offset="0"
style="stop-color:#0619c0;stop-opacity:1;" />
<stop
id="stop3868-7"
offset="1"
style="stop-color:#379cfb;stop-opacity:1;" />
</linearGradient>
<inkscape:perspective
id="perspective3902"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
id="linearGradient5048">
<stop
style="stop-color:black;stop-opacity:0;"
offset="0"
id="stop5050" />
<stop
id="stop5056"
offset="0.5"
style="stop-color:black;stop-opacity:1;" />
<stop
style="stop-color:black;stop-opacity:0;"
offset="1"
id="stop5052" />
</linearGradient>
<linearGradient
id="linearGradient3841-0-3">
<stop
id="stop3843-1-3"
offset="0"
style="stop-color:#0619c0;stop-opacity:1;" />
<stop
id="stop3845-0-8"
offset="1"
style="stop-color:#379cfb;stop-opacity:1;" />
</linearGradient>
<radialGradient
gradientUnits="userSpaceOnUse"
fy="114.5684"
fx="20.892099"
r="5.256"
cy="114.5684"
cx="20.892099"
id="aigrd2">
<stop
id="stop15566"
style="stop-color:#F0F0F0"
offset="0" />
<stop
id="stop15568"
style="stop-color:#9a9a9a;stop-opacity:1.0000000;"
offset="1.0000000" />
</radialGradient>
<radialGradient
gradientUnits="userSpaceOnUse"
fy="64.567902"
fx="20.892099"
r="5.257"
cy="64.567902"
cx="20.892099"
id="aigrd3">
<stop
id="stop15573"
style="stop-color:#F0F0F0"
offset="0" />
<stop
id="stop15575"
style="stop-color:#9a9a9a;stop-opacity:1.0000000;"
offset="1.0000000" />
</radialGradient>
<linearGradient
id="linearGradient15662">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop15664" />
<stop
style="stop-color:#f8f8f8;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop15666" />
</linearGradient>
<radialGradient
r="86.70845"
fy="35.736916"
fx="33.966679"
cy="35.736916"
cx="33.966679"
gradientTransform="matrix(0.96049297,0,0,1.041132,-52.144249,-702.33158)"
gradientUnits="userSpaceOnUse"
id="radialGradient4452"
xlink:href="#linearGradient259"
inkscape:collect="always" />
<linearGradient
id="linearGradient259">
<stop
style="stop-color:#fafafa;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop260" />
<stop
style="stop-color:#bbbbbb;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop261" />
</linearGradient>
<radialGradient
r="37.751713"
fy="3.7561285"
fx="8.824419"
cy="3.7561285"
cx="8.824419"
gradientTransform="matrix(0.96827297,0,0,1.032767,-48.790699,-701.68513)"
gradientUnits="userSpaceOnUse"
id="radialGradient4454"
xlink:href="#linearGradient269"
inkscape:collect="always" />
<linearGradient
id="linearGradient269">
<stop
style="stop-color:#a3a3a3;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop270" />
<stop
style="stop-color:#4c4c4c;stop-opacity:1.0000000;"
offset="1.0000000"
id="stop271" />
</linearGradient>
<inkscape:perspective
id="perspective4947"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
id="linearGradient4095">
<stop
style="stop-color:#0048c8;stop-opacity:1"
offset="0"
id="stop4097" />
<stop
style="stop-color:#30a1e4;stop-opacity:1"
offset="1"
id="stop4099" />
</linearGradient>
<inkscape:perspective
id="perspective5027"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective5076"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4247"
id="linearGradient4253"
x1="394.15784"
y1="185.1304"
x2="434.73947"
y2="140.22731"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.94231826,0,0,0.94231826,23.727549,8.8262536)" />
<linearGradient
id="linearGradient4247">
<stop
style="stop-color:#2e8207;stop-opacity:1;"
offset="0"
id="stop4249" />
<stop
style="stop-color:#52ff00;stop-opacity:1;"
offset="1"
id="stop4251" />
</linearGradient>
<inkscape:perspective
id="perspective5141"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective5225"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3144-8"
id="radialGradient4317"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.6985294,0,202.82863)"
cx="225.26402"
cy="672.79736"
fx="225.26402"
fy="672.79736"
r="34.345188" />
<linearGradient
id="linearGradient3144-8">
<stop
id="stop3146-96"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop3148-4"
style="stop-color:#ffffff;stop-opacity:0"
offset="1" />
</linearGradient>
<inkscape:perspective
id="perspective5301"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
id="linearGradient3144-8-4">
<stop
id="stop3146-96-8"
style="stop-color:#ffffff;stop-opacity:1"
offset="0" />
<stop
id="stop3148-4-0"
style="stop-color:#ffffff;stop-opacity:0"
offset="1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4095"
id="linearGradient4248"
x1="11.263056"
y1="21.430153"
x2="55.130848"
y2="21.430153"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.8890873"
inkscape:cx="34.950925"
inkscape:cy="34.512542"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1053"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata3617">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<rect
width="4.4988194"
height="54.438503"
x="29.892143"
y="-69.320946"
transform="matrix(-0.29039954,0.95690548,-0.95705178,-0.28991704,0,0)"
id="rect4329"
style="display:inline;overflow:visible;visibility:visible;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.50000012;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
<path
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:url(#linearGradient4248);fill-opacity:1.0;fill-rule:nonzero;stroke:#10121e;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 42.104588,12.717092 -2.401331,7.041558 -25.191717,-9.13173 -2.248512,6.281225 25.191717,9.131728 -2.424608,6.193521 19.100787,-4.115576 z"
id="rect4236"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 13 KiB