Arch: Added specials snap
* Remove Arch option to snap to wall base (reimplemented below) * Added new Specials snap button * Special snap snaps to wall baselines, structure basepoints, and contents of SnapPoints property, if existing
This commit is contained in:
parent
52b98f9cf2
commit
6f38f91dd0
|
@ -240,6 +240,7 @@ class _Equipment(ArchComponent.Component):
|
|||
#obj.addProperty("Part::PropertyPartShape","SideView","Arch","an optional 2D shape representing a side view of this equipment")
|
||||
obj.addProperty("App::PropertyString","Model","Arch","The model description of this equipment")
|
||||
obj.addProperty("App::PropertyString","Url","Arch","The url of the product page of this equipment")
|
||||
obj.addProperty("App::PropertyVectorList","SnapPoints","Arch","Additional snap points for this equipment")
|
||||
self.Type = "Equipment"
|
||||
obj.Role = Roles
|
||||
obj.Proxy = self
|
||||
|
|
|
@ -66,7 +66,7 @@ class ArchWorkbench(Workbench):
|
|||
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',
|
||||
'Draft_Snap_Extension','Draft_Snap_Near','Draft_Snap_Ortho',
|
||||
'Draft_Snap_Extension','Draft_Snap_Near','Draft_Snap_Ortho','Draft_Snap_Special',
|
||||
'Draft_Snap_Dimensions','Draft_Snap_WorkingPlane']
|
||||
|
||||
def QT_TRANSLATE_NOOP(scope, text): return text
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>414</width>
|
||||
<height>696</height>
|
||||
<width>407</width>
|
||||
<height>646</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -20,35 +20,6 @@
|
|||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<property name="title">
|
||||
<string>Snapping</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_6">
|
||||
<property name="text">
|
||||
<string>Snap to baselines of Arch objects (override with CTRL)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ArchSnapToBase</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Arch</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
|
|
|
@ -97,7 +97,8 @@ class Snapper:
|
|||
'angle':'quad',
|
||||
'center':'quad',
|
||||
'ortho':'quad',
|
||||
'intersection':'quad'}
|
||||
'intersection':'quad',
|
||||
'special':'quad'}
|
||||
else:
|
||||
self.mk = {'passive':'circle',
|
||||
'extension':'circle',
|
||||
|
@ -109,7 +110,8 @@ class Snapper:
|
|||
'angle':'square',
|
||||
'center':'dot',
|
||||
'ortho':'dot',
|
||||
'intersection':'dot'}
|
||||
'intersection':'dot',
|
||||
'special':'dot'}
|
||||
self.cursors = {'passive':':/icons/Snap_Near.svg',
|
||||
'extension':':/icons/Snap_Extension.svg',
|
||||
'parallel':':/icons/Snap_Parallel.svg',
|
||||
|
@ -120,7 +122,8 @@ class Snapper:
|
|||
'angle':':/icons/Snap_Angle.svg',
|
||||
'center':':/icons/Snap_Center.svg',
|
||||
'ortho':':/icons/Snap_Ortho.svg',
|
||||
'intersection':':/icons/Snap_Intersection.svg'}
|
||||
'intersection':':/icons/Snap_Intersection.svg',
|
||||
'special':':/icons/Snap_Special.svg'}
|
||||
|
||||
def snap(self,screenpos,lastpoint=None,active=True,constrain=False,noTracker=False):
|
||||
"""snap(screenpos,lastpoint=None,active=True,constrain=False,noTracker=False): returns a snapped
|
||||
|
@ -263,36 +266,9 @@ class Snapper:
|
|||
# active snapping
|
||||
comp = self.snapInfo['Component']
|
||||
|
||||
archSnap = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("ArchSnapToBase",True)
|
||||
|
||||
if (Draft.getType(obj) == "Wall") and (not oldActive) and archSnap:
|
||||
# special snapping for wall: only to its base shape (except when CTRL is pressed)
|
||||
edges = []
|
||||
for o in [obj]+obj.Additions:
|
||||
if Draft.getType(o) == "Wall":
|
||||
if o.Base:
|
||||
edges.extend(o.Base.Shape.Edges)
|
||||
for edge in edges:
|
||||
snaps.extend(self.snapToEndpoints(edge))
|
||||
snaps.extend(self.snapToMidpoint(edge))
|
||||
snaps.extend(self.snapToPerpendicular(edge,lastpoint))
|
||||
snaps.extend(self.snapToIntersection(edge))
|
||||
snaps.extend(self.snapToElines(edge,eline))
|
||||
|
||||
elif (Draft.getType(obj) == "Structure") and (not oldActive) and archSnap:
|
||||
# special snapping for struct: only to its base point (except when CTRL is pressed)
|
||||
if obj.Base:
|
||||
for edge in obj.Base.Shape.Edges:
|
||||
snaps.extend(self.snapToEndpoints(edge))
|
||||
snaps.extend(self.snapToMidpoint(edge))
|
||||
snaps.extend(self.snapToPerpendicular(edge,lastpoint))
|
||||
snaps.extend(self.snapToIntersection(edge))
|
||||
snaps.extend(self.snapToElines(edge,eline))
|
||||
else:
|
||||
b = obj.Placement.Base
|
||||
snaps.append([b,'endpoint',self.toWP(b)])
|
||||
|
||||
elif obj.isDerivedFrom("Part::Feature"):
|
||||
if obj.isDerivedFrom("Part::Feature"):
|
||||
|
||||
snaps.extend(self.snapToSpecials(obj))
|
||||
|
||||
if Draft.getType(obj) == "Polygon":
|
||||
# special snapping for polygons: add the center
|
||||
|
@ -806,7 +782,36 @@ class Snapper:
|
|||
return [p,'passive',p]
|
||||
else:
|
||||
return []
|
||||
|
||||
|
||||
def snapToSpecials(self,obj):
|
||||
"returns special snap locations, if any"
|
||||
snaps = []
|
||||
if self.isEnabled("special"):
|
||||
|
||||
if (Draft.getType(obj) == "Wall"):
|
||||
# special snapping for wall: snap to its base shape if it is linear
|
||||
if obj.Base:
|
||||
if not obj.Base.Shape.Solids:
|
||||
for v in obj.Base.Shape.Vertexes:
|
||||
snaps.append([v.Point,'special',self.toWP(v.Point)])
|
||||
|
||||
elif (Draft.getType(obj) == "Structure"):
|
||||
# special snapping for struct: only to its base point
|
||||
if obj.Base:
|
||||
if not obj.Base.Shape.Solids:
|
||||
for v in obj.Base.Shape.Vertexes:
|
||||
snaps.append([v.Point,'special',self.toWP(v.Point)])
|
||||
else:
|
||||
b = obj.Placement.Base
|
||||
snaps.append([b,'special',self.toWP(b)])
|
||||
|
||||
elif hasattr(obj,"SnapPoints"):
|
||||
for p in obj.SnapPoints:
|
||||
p2 = obj.Placement.multVec(p)
|
||||
snaps.append([p2,'spacial',p2])
|
||||
|
||||
return snaps
|
||||
|
||||
def getScreenDist(self,dist,cursor):
|
||||
"returns a distance in 3D space from a screen pixels distance"
|
||||
view = Draft.get3DView()
|
||||
|
|
|
@ -4711,6 +4711,18 @@ class Draft_Snap_Ortho():
|
|||
if b.objectName() == "SnapButtonortho":
|
||||
b.toggle()
|
||||
|
||||
class Draft_Snap_Special():
|
||||
def GetResources(self):
|
||||
return {'Pixmap' : 'Snap_Special',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_Snap_Special", "Special"),
|
||||
'ToolTip' : QtCore.QT_TRANSLATE_NOOP("Draft_Snap_Special", "Snaps to special locations of objects")}
|
||||
def Activated(self):
|
||||
if hasattr(FreeCADGui,"Snapper"):
|
||||
if hasattr(FreeCADGui.Snapper,"toolbarButtons"):
|
||||
for b in FreeCADGui.Snapper.toolbarButtons:
|
||||
if b.objectName() == "SnapButtonspecial":
|
||||
b.toggle()
|
||||
|
||||
class Draft_Snap_Dimensions():
|
||||
def GetResources(self):
|
||||
return {'Pixmap' : 'Snap_Dimensions',
|
||||
|
@ -4805,6 +4817,7 @@ FreeCADGui.addCommand('Draft_Snap_Center',Draft_Snap_Center())
|
|||
FreeCADGui.addCommand('Draft_Snap_Extension',Draft_Snap_Extension())
|
||||
FreeCADGui.addCommand('Draft_Snap_Near',Draft_Snap_Near())
|
||||
FreeCADGui.addCommand('Draft_Snap_Ortho',Draft_Snap_Ortho())
|
||||
FreeCADGui.addCommand('Draft_Snap_Special',Draft_Snap_Special())
|
||||
FreeCADGui.addCommand('Draft_Snap_Dimensions',Draft_Snap_Dimensions())
|
||||
FreeCADGui.addCommand('Draft_Snap_WorkingPlane',Draft_Snap_WorkingPlane())
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class DraftWorkbench (Workbench):
|
|||
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',
|
||||
'Draft_Snap_Extension','Draft_Snap_Near','Draft_Snap_Ortho',
|
||||
'Draft_Snap_Extension','Draft_Snap_Near','Draft_Snap_Ortho','Draft_Snap_Special',
|
||||
'Draft_Snap_Dimensions','Draft_Snap_WorkingPlane']
|
||||
self.appendToolbar(QT_TRANSLATE_NOOP("Workbench","Draft creation tools"),self.cmdList)
|
||||
self.appendToolbar(QT_TRANSLATE_NOOP("Workbench","Draft modification tools"),self.modList)
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<file>icons/Snap_Near.svg</file>
|
||||
<file>icons/Snap_Dimensions.svg</file>
|
||||
<file>icons/Snap_WorkingPlane.svg</file>
|
||||
<file>icons/Snap_Special.svg</file>
|
||||
<file>icons/Draft_Clone.svg</file>
|
||||
<file>icons/Draft_Heal.svg</file>
|
||||
<file>icons/Draft_Ellipse.svg</file>
|
||||
|
|
138
src/Mod/Draft/Resources/icons/Snap_Special.svg
Normal file
138
src/Mod/Draft/Resources/icons/Snap_Special.svg
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?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="svg2726"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="Snap_Special.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
version="1.1">
|
||||
<defs
|
||||
id="defs2728">
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3144"
|
||||
id="radialGradient4274"
|
||||
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>
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3144"
|
||||
id="radialGradient4272"
|
||||
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" />
|
||||
<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="perspective2734" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3144"
|
||||
id="radialGradient3011"
|
||||
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" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.75"
|
||||
inkscape:cx="5.7443796"
|
||||
inkscape:cy="14.62037"
|
||||
inkscape:current-layer="g4289"
|
||||
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="metadata2731">
|
||||
<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">
|
||||
<g
|
||||
id="g4289"
|
||||
transform="matrix(0.1621282,0,0,0.1621282,6.3605986,-66.108806)">
|
||||
<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:#00b286;fill-opacity:1;fill-rule:nonzero;stroke:#002e2e;stroke-width:30.83979225;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 178.04538,442.10671 -91.441791,68.38893 -3.171931,201.41763 158.596552,3.17192 74.54037,-61.85265 1.77837,-209.34745 z"
|
||||
id="path4165"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccccc" />
|
||||
<circle
|
||||
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:#00b286;fill-opacity:1;fill-rule:nonzero;stroke:#002e2e;stroke-width:30.83979225;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"
|
||||
id="path4161"
|
||||
cx="70.086983"
|
||||
cy="697.43347"
|
||||
r="69.782486" />
|
||||
<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:none;fill-opacity:1;fill-rule:nonzero;stroke:#002e2e;stroke-width:30.83979225;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="M 240.44224,719.84309 243.61417,512.0816 91.361484,507.32371"
|
||||
id="path4223"
|
||||
inkscape:connector-curvature="0" />
|
||||
<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:#00b286;fill-opacity:1;fill-rule:nonzero;stroke:#002e2e;stroke-width:30.83979225;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 241.12983,515.41528 80.74419,-70.65116"
|
||||
id="path4230"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.3 KiB |
Loading…
Reference in New Issue
Block a user