gui: add command to lock mover for fixed parts

This commit is contained in:
Zheng, Lei 2018-06-03 13:14:24 +08:00
parent 939f571aa8
commit 35385866aa
4 changed files with 522 additions and 1 deletions

View File

@ -0,0 +1,493 @@
<?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="svg2963"
sodipodi:version="0.32"
inkscape:version="0.91 r13725"
sodipodi:docname="Assembly_LockMove.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs2965">
<linearGradient
id="linearGradient3354">
<stop
style="stop-color:#2157c7;stop-opacity:1;"
offset="0"
id="stop3356" />
<stop
style="stop-color:#6daaff;stop-opacity:1;"
offset="1"
id="stop3358" />
</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="perspective2971" />
<linearGradient
gradientTransform="matrix(0,-1.4500001,1.4705882,0,-15.05882,91.45)"
y2="36.079998"
x2="21.689653"
y1="29.279999"
x1="56.172409"
gradientUnits="userSpaceOnUse"
id="linearGradient3036"
xlink:href="#linearGradient3895"
inkscape:collect="always" />
<linearGradient
id="linearGradient3895">
<stop
style="stop-color:#729fcf;stop-opacity:1;"
offset="0"
id="stop3897" />
<stop
style="stop-color:#204a87;stop-opacity:1;"
offset="1"
id="stop3899" />
</linearGradient>
<linearGradient
y2="36.079998"
x2="21.689653"
y1="29.279999"
x1="56.172409"
gradientTransform="matrix(0,-0.58000003,0.58823527,0,13.176471,38.379999)"
gradientUnits="userSpaceOnUse"
id="linearGradient3918-3"
xlink:href="#linearGradient3895-6"
inkscape:collect="always" />
<linearGradient
id="linearGradient3895-6">
<stop
style="stop-color:#729fcf;stop-opacity:1;"
offset="0"
id="stop3897-7" />
<stop
style="stop-color:#204a87;stop-opacity:1;"
offset="1"
id="stop3899-5" />
</linearGradient>
<linearGradient
y2="36.079998"
x2="21.689653"
y1="29.279999"
x1="56.172409"
gradientTransform="matrix(0.58000003,0,0,0.58823527,25.620001,13.176471)"
gradientUnits="userSpaceOnUse"
id="linearGradient3029-6"
xlink:href="#linearGradient3895-6-2"
inkscape:collect="always" />
<linearGradient
id="linearGradient3895-6-2">
<stop
style="stop-color:#729fcf;stop-opacity:1;"
offset="0"
id="stop3897-7-9" />
<stop
style="stop-color:#204a87;stop-opacity:1;"
offset="1"
id="stop3899-5-1" />
</linearGradient>
<linearGradient
y2="36.079998"
x2="21.689653"
y1="29.279999"
x1="56.172409"
gradientTransform="matrix(0,-0.58000003,0.58823527,0,13.176471,38.379999)"
gradientUnits="userSpaceOnUse"
id="linearGradient3918-0"
xlink:href="#linearGradient3895-9"
inkscape:collect="always" />
<linearGradient
id="linearGradient3895-9">
<stop
style="stop-color:#729fcf;stop-opacity:1;"
offset="0"
id="stop3897-3" />
<stop
style="stop-color:#204a87;stop-opacity:1;"
offset="1"
id="stop3899-6" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3895"
id="linearGradient3154"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,-0.58000003,0.58823527,0,13.176471,38.379999)"
x1="45.482754"
y1="11.599999"
x2="-23.482759"
y2="52.400002" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3895-6-2"
id="linearGradient3156"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.58000003,0,0,0.58823527,38.379999,13.176471)"
x1="31.689651"
y1="-2.0000007"
x2="-9.6896563"
y2="66" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3895-6"
id="linearGradient3158"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.58000003,0,0,0.58823527,25.620001,13.176471)"
x1="-9.6896563"
y1="-2.0000007"
x2="31.689651"
y2="66" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3895-9"
id="linearGradient3160"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0,0.58000003,0.58823527,0,13.176471,25.620001)"
x1="-23.482759"
y1="11.599999"
x2="45.482754"
y2="52.400002" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3895-9"
id="linearGradient3936"
x1="20"
y1="12"
x2="44"
y2="52"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3895-9"
id="linearGradient3944"
x1="20"
y1="12"
x2="44"
y2="52"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3836-0-6-92-4-2">
<stop
style="stop-color:#a40000;stop-opacity:1"
offset="0"
id="stop3838-2-7-06-8-0" />
<stop
style="stop-color:#ef2929;stop-opacity:1"
offset="1"
id="stop3840-5-5-8-7-23" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3838"
id="linearGradient3199"
gradientUnits="userSpaceOnUse"
x1="2802.9631"
y1="538.36249"
x2="2859.7263"
y2="786.05646" />
<linearGradient
inkscape:collect="always"
id="linearGradient3838">
<stop
style="stop-color:#34e0e2;stop-opacity:1"
offset="0"
id="stop3840" />
<stop
style="stop-color:#06989a;stop-opacity:1"
offset="1"
id="stop3842" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3166"
id="linearGradient3197"
gradientUnits="userSpaceOnUse"
x1="2802.9631"
y1="626.0874"
x2="2849.4058"
y2="822.17853"
gradientTransform="translate(61.257658,0)" />
<linearGradient
id="linearGradient3166"
inkscape:collect="always">
<stop
id="stop3168"
offset="0"
style="stop-color:#ef2929;stop-opacity:1" />
<stop
id="stop3170"
offset="1"
style="stop-color:#a40000;stop-opacity:1" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.8020019"
inkscape:cx="-51.869083"
inkscape:cy="54.207986"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1375"
inkscape:window-height="876"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:snap-global="true"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid3009"
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
<inkscape:grid
type="xygrid"
id="grid3011"
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
spacingx="16px"
spacingy="16px"
empcolor="#ff0000"
empopacity="0.25098039"
color="#ff0000"
opacity="0.1254902" />
</sodipodi:namedview>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
id="g4351"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/move.png"
inkscape:export-xdpi="6.5591564"
inkscape:export-ydpi="6.5591564"
transform="matrix(0.1378133,0,0,0.1378133,-221.39699,-138.35275)" />
<g
id="g4199"
transform="matrix(0.80000094,0,0,0.80000094,6.39997,6.3999698)">
<rect
y="29"
x="26"
height="6"
width="12"
id="rect3126"
style="fill:url(#linearGradient3936);fill-opacity:1;stroke:none" />
<rect
y="26"
x="29"
height="11.999999"
width="6"
id="rect3126-2"
style="fill:url(#linearGradient3944);fill-opacity:1;stroke:none" />
<path
inkscape:export-ydpi="4.1683898"
inkscape:export-xdpi="4.1683898"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/changeprop.png"
sodipodi:nodetypes="ccccccc"
id="path3343"
d="m 37,28 0,-15 6,0 -11,-10 -11,10 6,0 0,15"
style="fill:url(#linearGradient3154);fill-opacity:1;fill-rule:evenodd;stroke:#0b1521;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
inkscape:export-ydpi="4.1683898"
inkscape:export-xdpi="4.1683898"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/changeprop.png"
sodipodi:nodetypes="ccccccc"
id="path3343-2"
d="M 35,29 35,11 37.831259,11 32,5.7026937 26.168741,11 29,11 29,29"
style="fill:none;stroke:#729fcf;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
inkscape:export-ydpi="4.1683898"
inkscape:export-xdpi="4.1683898"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/changeprop.png"
sodipodi:nodetypes="ccccccc"
id="path3343-3"
d="m 37,37 14,0 0,6 10,-11 -10,-11 0,6 -14,0"
style="fill:url(#linearGradient3158);fill-opacity:1;fill-rule:evenodd;stroke:#0b1521;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
inkscape:export-ydpi="4.1683898"
inkscape:export-xdpi="4.1683898"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/changeprop.png"
sodipodi:nodetypes="ccccccc"
id="path3343-2-5"
d="m 35,35 18,0 0,2.831259 L 58.297306,32 53,26.168741 53,29 34,29"
style="fill:none;stroke:#729fcf;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
inkscape:export-ydpi="4.1683898"
inkscape:export-xdpi="4.1683898"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/changeprop.png"
sodipodi:nodetypes="ccccccc"
id="path3343-3-2"
d="m 27,37 -14,0 0,6 -10,-11 10,-11 0,6 14,0"
style="fill:url(#linearGradient3156);fill-opacity:1;fill-rule:evenodd;stroke:#0b1521;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
inkscape:export-ydpi="4.1683898"
inkscape:export-xdpi="4.1683898"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/changeprop.png"
sodipodi:nodetypes="ccccccc"
id="path3343-2-5-7"
d="M 29,35 11,35 11,37.831259 5.702694,32 11,26.168741 11,29 30,29"
style="fill:none;stroke:#729fcf;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
inkscape:export-ydpi="4.1683898"
inkscape:export-xdpi="4.1683898"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/changeprop.png"
sodipodi:nodetypes="ccccccc"
id="path3343-0"
d="m 37,36 0,15 6,0 -11,10 -11,-10 6,0 0,-15"
style="fill:url(#linearGradient3160);fill-opacity:1;fill-rule:evenodd;stroke:#0b1521;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
inkscape:export-ydpi="4.1683898"
inkscape:export-xdpi="4.1683898"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/changeprop.png"
sodipodi:nodetypes="ccccccc"
id="path3343-2-6"
d="m 35,34 0,19 2.831259,0 L 32,58.297306 26.168741,53 29,53 29,34"
style="fill:none;stroke:#729fcf;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
</g>
<g
id="g4261"
transform="translate(-1.9309158,-71.866669)">
<circle
id="path3006"
style="fill:none;stroke:#204a87;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4.5;stroke-dasharray:none;stroke-dashoffset:20.39999962;stroke-opacity:1"
cx="33.930916"
cy="103.86667"
r="27" />
<circle
id="path3006-6"
style="fill:none;stroke:#729fcf;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4.5;stroke-dasharray:none;stroke-dashoffset:20.39999962;stroke-opacity:1"
cx="33.930916"
cy="103.86667"
r="27" />
</g>
<g
id="g3188"
transform="matrix(1.1305964,0,0,1.1305964,68.274395,-3.9735395)">
<g
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:54.21519089px;font-family:Arial;-inkscape-font-specification:Arial;display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient3199);fill-opacity:1;fill-rule:nonzero;stroke:#042a2a;stroke-width:15.05897331;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="g2385"
transform="matrix(0.13059592,0,0,0.13506401,-395.42513,-48.743698)"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/close.png"
inkscape:export-xdpi="6.5019679"
inkscape:export-ydpi="6.5019679">
<path
sodipodi:nodetypes="cccccccscccccccc"
inkscape:connector-curvature="0"
id="path2387"
d="m 2805.793,620.0297 0,0 0,0 0,59.23117 30.6289,0 0,-59.23117 0,0 c 0.2977,-25.0696 27.7989,-44.42339 53.6004,-44.42339 25.8014,0 53.601,18.62193 53.6005,44.42339 l 0,0 0,59.23117 30.6288,0 0,-59.23117 0,0 c 5e-4,-41.28234 -32.6264,-74.03897 -84.2293,-74.03897 -51.6029,0 -84.2293,32.75663 -84.2293,74.03897 z"
style="display:inline;overflow:visible;visibility:visible;fill:#ef2929;fill-opacity:1;fill-rule:evenodd;stroke:#280000;stroke-width:15.05897331;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
<rect
y="649.64526"
x="2790.4788"
height="148.07797"
width="199.08757"
id="rect2389"
style="display:inline;overflow:visible;visibility:visible;fill:url(#linearGradient3197);fill-opacity:1;fill-rule:evenodd;stroke:#280000;stroke-width:15.05897331;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
<rect
y="664.45306"
x="2805.7932"
height="118.46237"
width="168.45859"
id="rect2389-0"
style="display:inline;overflow:visible;visibility:visible;fill:none;stroke:#ef2929;stroke-width:15.05897331;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
</g>
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path3777-7"
d="M -25.000001,45 -11,45"
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:54.21519089px;font-family:Arial;-inkscape-font-specification:Arial;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#a40000;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path3777-3-5"
d="m -25,49 14,0"
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:54.21519089px;font-family:Arial;-inkscape-font-specification:Arial;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#a40000;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path3777-6-3"
d="m -25,53 14,0"
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:54.21519089px;font-family:Arial;-inkscape-font-specification:Arial;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#a40000;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
</g>
</g>
<metadata
id="metadata5006">
<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_Move.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>arrow</rdf:li>
<rdf:li>move</rdf:li>
<rdf:li>arrows</rdf:li>
<rdf:li>compass</rdf:li>
<rdf:li>cross</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:description>Four equally sized arrow heads at 90° to eachother, all joined at the tail</dc:description>
</cc:Work>
</rdf:RDF>
</metadata>
</svg>

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -495,7 +495,7 @@ class Constraint(ProxyType):
firstInfo = elements[0].Proxy.getInfo()
if not found:
if not firstInfo:
if not firstInfo or not solver:
return ret
if utils.isDraftObject(firstInfo.Part):
Locked.lockElement(firstInfo,solver)

14
gui.py
View File

@ -315,6 +315,20 @@ class AsmCmdCheckable(AsmCmdBase):
def Activated(cls,checked):
cls.setChecked(True if checked else False)
class AsmCmdLockMover(AsmCmdCheckable):
_id = 15
_menuText = 'Lock mover'
_tooltip = 'Lock mover for fixed part'
_iconName = 'Assembly_LockMover.svg'
_saveParam = True
@classmethod
def Activated(cls,checked):
super(AsmCmdLockMover,cls).Activated(checked)
AsmCmdMove._active = None
AsmCmdAxialMove._active = None
AsmCmdQuickMove._active = None
class AsmCmdTrace(AsmCmdCheckable):
_id = 4
_menuText = 'Trace part move'

View File

@ -210,6 +210,18 @@ class AsmMovingPart(object):
# AsmMovingPart.update()
return self.draggerPlacement
def _checkFixedPart(info):
if not gui.AsmCmdManager.LockMover:
return
if isTypeOf(info.Parent,Assembly,True):
assembly = info.Parent.getLinkedObject(True).Proxy
else:
assembly = info.Parent.getAssembly()
cstrs = assembly.getConstraints()
parts = assembly.getPartGroup().Group
if info.Part in Constraint.getFixedParts(None,cstrs,parts):
raise RuntimeError('cannot move fixed part')
def getMovingElementInfo():
'''Extract information from current selection for part moving
@ -246,6 +258,7 @@ def getMovingElementInfo():
if len(sels[0].SubElementNames)==1:
info = getElementInfo(ret[0].Assembly,
ret[0].Subname, checkPlacement=True)
_checkFixedPart(info)
return MovingPartInfo(SelObj=selObj,
SelSubname=selSub,
Hierarchy=ret,
@ -270,6 +283,7 @@ def getMovingElementInfo():
for r in ret2:
if assembly == r.Assembly:
info = getElementInfo(r.Assembly,r.Subname,checkPlacement=True)
_checkFixedPart(info)
return MovingPartInfo(SelObj=selObj,
SelSubname=selSub,
Hierarchy=ret2,