Draft: Added Draft Slope command - allows to change the slope of a selected Line or Wire
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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>
|
||||
|
||||
415
src/Mod/Draft/Resources/icons/Draft_Slope.svg
Normal file
415
src/Mod/Draft/Resources/icons/Draft_Slope.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 13 KiB |
Reference in New Issue
Block a user