Draft: Added 3-point arc command from BIM WB

This commit is contained in:
Yorik van Havre
2019-04-07 17:23:42 -03:00
parent 2935cbb71a
commit 4f19a65559
4 changed files with 359 additions and 1 deletions

View File

@@ -5891,6 +5891,74 @@ class Draft_AddConstruction():
obrep.Transparency = 80
class Draft_Arc_3Points:
def GetResources(self):
return {'Pixmap' : "Draft_Arc_3Points.svg",
'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_Arc_3Points", "Arc 3 points"),
'ToolTip' : QtCore.QT_TRANSLATE_NOOP("Draft_Arc_3Points", "Creates an arc by giving 3 points through which the arc should pass"),
'Accel' : 'A,T'}
def IsActive(self):
if FreeCAD.ActiveDocument:
return True
else:
return False
def Activated(self):
import DraftTrackers
self.points = []
self.normal = None
self.tracker = DraftTrackers.arcTracker()
self.tracker.autoinvert = False
if hasattr(FreeCAD,"DraftWorkingPlane"):
FreeCAD.DraftWorkingPlane.setup()
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.drawArc)
def getPoint(self,point,info):
if not point: # cancelled
self.tracker.off()
return
if not(point in self.points): # avoid same point twice
self.points.append(point)
if len(self.points) < 3:
if len(self.points) == 2:
self.tracker.on()
FreeCADGui.Snapper.getPoint(last=self.points[-1],callback=self.getPoint,movecallback=self.drawArc)
else:
import Part
e = Part.Arc(self.points[0],self.points[1],self.points[2]).toShape()
if Draft.getParam("UsePartPrimitives",False) or True: # TODO Draft "native" object below is buggy, use common shape for now
o = FreeCAD.ActiveDocument.addObject("Part::Feature","Arc")
o.Shape = e
else:
radius = e.Curve.Radius
rot = FreeCAD.Rotation(e.Curve.XAxis,e.Curve.YAxis,e.Curve.Axis,"ZXY")
placement = FreeCAD.Placement(e.Curve.Center,rot)
start = e.FirstParameter
end = e.LastParameter
Draft.makeCircle(radius,placement,startangle=start,endangle=end)
self.tracker.off()
FreeCAD.ActiveDocument.recompute()
def drawArc(self,point,info):
if len(self.points) == 2:
import Part
if point.sub(self.points[1]).Length > 0.001:
e = Part.Arc(self.points[0],self.points[1],point).toShape()
self.tracker.normal = e.Curve.Axis.negative() # for some reason the axis always points "backwards"
self.tracker.basevector = self.tracker.getDeviation()
self.tracker.setCenter(e.Curve.Center)
self.tracker.setRadius(e.Curve.Radius)
self.tracker.setStartPoint(self.points[0])
self.tracker.setEndPoint(point)
#---------------------------------------------------------------------------
# Snap tools
#---------------------------------------------------------------------------
@@ -6084,6 +6152,7 @@ FreeCADGui.addCommand('Draft_Line',Line())
FreeCADGui.addCommand('Draft_Wire',Wire())
FreeCADGui.addCommand('Draft_Circle',Circle())
FreeCADGui.addCommand('Draft_Arc',Arc())
FreeCADGui.addCommand('Draft_Arc_3Points',Draft_Arc_3Points())
FreeCADGui.addCommand('Draft_Text',Text())
FreeCADGui.addCommand('Draft_Rectangle',Rectangle())
FreeCADGui.addCommand('Draft_Dimension',Dimension())

View File

@@ -68,7 +68,7 @@ class DraftWorkbench (Workbench):
FreeCAD.Console.PrintError("Error: Initializing one or more of the Draft modules failed, Draft will not work as expected.\n")
# setup menus
self.cmdList = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Ellipse",
self.cmdList = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Arc_3Points","Draft_Ellipse",
"Draft_Polygon","Draft_Rectangle", "Draft_Text",
"Draft_Dimension", "Draft_BSpline","Draft_Point",
"Draft_ShapeString","Draft_Facebinder","Draft_BezCurve","Draft_Label"]

View File

@@ -4,6 +4,7 @@
<file>icons/Draft_AddToGroup.svg</file>
<file>icons/Draft_Apply.svg</file>
<file>icons/Draft_Arc.svg</file>
<file>icons/Draft_Arc_3Points.svg</file>
<file>icons/Draft_BSpline.svg</file>
<file>icons/Draft_BezCurve.svg</file>
<file>icons/Draft_BezSharpNode.svg</file>

View File

@@ -0,0 +1,288 @@
<?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="svg2869"
sodipodi:version="0.32"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="BIM_Arc_3Points.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs2871">
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3144"
id="radialGradient2378"
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" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3144"
id="radialGradient2368"
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
inkscape:collect="always"
id="linearGradient3144">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop3146" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop3148" />
</linearGradient>
<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="perspective2877" />
<linearGradient
id="linearGradient3836">
<stop
style="stop-color:#c4a000;stop-opacity:1;"
offset="0"
id="stop3838" />
<stop
style="stop-color:#fce94f;stop-opacity:1;"
offset="1"
id="stop3840" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3836"
id="linearGradient3801"
gradientUnits="userSpaceOnUse"
x1="-18"
y1="18"
x2="-22"
y2="5" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3836-9"
id="linearGradient3801-7"
gradientUnits="userSpaceOnUse"
x1="-18"
y1="18"
x2="-22"
y2="5" />
<linearGradient
id="linearGradient3836-9">
<stop
style="stop-color:#c4a000;stop-opacity:1;"
offset="0"
id="stop3838-8" />
<stop
style="stop-color:#fce94f;stop-opacity:1;"
offset="1"
id="stop3840-1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3836-0"
id="linearGradient3801-1"
gradientUnits="userSpaceOnUse"
x1="-18"
y1="18"
x2="-22"
y2="5" />
<linearGradient
id="linearGradient3836-0">
<stop
style="stop-color:#c4a000;stop-opacity:1;"
offset="0"
id="stop3838-2" />
<stop
style="stop-color:#fce94f;stop-opacity:1;"
offset="1"
id="stop3840-5" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="6.8389122"
inkscape:cx="33.848293"
inkscape:cy="31.087466"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1360"
inkscape:window-height="739"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:snap-bbox="true"
inkscape:snap-nodes="true"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid3002"
units="px"
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
spacingx="1"
spacingy="1"
originx="0"
originy="0" />
</sodipodi:namedview>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
id="g3401"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/arc.png"
inkscape:export-xdpi="6.7480335"
inkscape:export-ydpi="6.7480335"
transform="matrix(0.146567,0,0,0.146567,96.1836,-71.115448)">
<g
id="g3389">
<path
style="fill:#d3d7cf;fill-opacity:1;fill-rule:evenodd;stroke:#2e3436;stroke-width:13.64563656;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m -567.54661,546.61314 0,40.93691 c 141.80801,1.02697 245.62146,96.97836 245.62146,231.97582 0,0.15497 8.93268,-0.46043 8.93242,-0.3125 l 32,0.3125 c 0.0101,-0.96882 0.004,0.96884 0.004,0 0,-152.19427 -127.26694,-272.91272 -286.55837,-272.91273 z"
id="path2380"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccsccsc" />
<path
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 10.999999,13 C 32,13 49,32 49,48"
id="path3892"
inkscape:connector-curvature="0"
transform="matrix(6.8228182,0,0,6.8228182,-628.95197,471.56214)"
sodipodi:nodetypes="cc" />
</g>
</g>
<g
id="g3827"
transform="translate(29.311457,-29.463877)">
<g
transform="translate(31.322131,40.570289)"
id="g3797">
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#2e2900;stroke-width:1.99999988;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4250"
d="M -26.156204,5.582626 A 8.993818,8.9934077 0.02042283 1 1 -12.493793,17.282241 8.993818,8.9934077 0.02042283 1 1 -26.156204,5.582626 Z" />
<path
inkscape:connector-curvature="0"
style="fill:url(#linearGradient3801);fill-opacity:1;stroke:#fce94f;stroke-width:1.99999952;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4250-7"
d="M -24.633588,6.893588 A 6.9999997,7.0000001 0 1 1 -14,16 6.9999997,7.0000001 0 0 1 -24.633588,6.893588 Z" />
</g>
</g>
<g
transform="translate(40,-2)"
id="g3827-0">
<g
transform="translate(31.322131,40.570289)"
id="g3797-7">
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#2e2900;stroke-width:1.99999988;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path4250-6"
d="M -26.156204,5.582626 A 8.993818,8.9934077 0.02042283 1 1 -12.493793,17.282241 8.993818,8.9934077 0.02042283 1 1 -26.156204,5.582626 z" />
<path
inkscape:connector-curvature="0"
style="fill:url(#linearGradient3801-7);fill-opacity:1;stroke:#fce94f;stroke-width:1.99999952;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path4250-7-0"
d="M -24.633588,6.893588 A 6.9999997,7.0000001 0 1 1 -14,16 6.9999997,7.0000001 0 0 1 -24.633588,6.893588 z" />
</g>
</g>
<g
transform="translate(2.005735,-40)"
id="g3827-1">
<g
transform="translate(31.322131,40.570289)"
id="g3797-9">
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#2e2900;stroke-width:1.99999988;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path4250-71"
d="M -26.156204,5.582626 A 8.993818,8.9934077 0.02042283 1 1 -12.493793,17.282241 8.993818,8.9934077 0.02042283 1 1 -26.156204,5.582626 z" />
<path
inkscape:connector-curvature="0"
style="fill:url(#linearGradient3801-1);fill-opacity:1;stroke:#fce94f;stroke-width:1.99999952;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="path4250-7-3"
d="M -24.633588,6.893588 A 6.9999997,7.0000001 0 1 1 -14,16 6.9999997,7.0000001 0 0 1 -24.633588,6.893588 z" />
</g>
</g>
</g>
<metadata
id="metadata3272">
<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:license
rdf:resource="" />
<dc:date>Mon Oct 10 13:44:52 2011 +0000</dc:date>
<dc:creator>
<cc:Agent>
<dc:title>[wmayer]</dc:title>
</cc:Agent>
</dc:creator>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/Draft/Resources/icons/Draft_Arc.svg</dc:identifier>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:contributor>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:contributor>
<dc:subject>
<rdf:Bag>
<rdf:li>point</rdf:li>
<rdf:li>dot</rdf:li>
<rdf:li>arc</rdf:li>
<rdf:li>curve</rdf:li>
<rdf:li>line</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:description>An arc of 90° with a point at each end with a third point in the lower left where the centerpoint of the arc would be</dc:description>
</cc:Work>
</rdf:RDF>
</metadata>
</svg>

After

Width:  |  Height:  |  Size: 10 KiB