Merge branch 'master' into feature/expose-enumerations-to-python

This commit is contained in:
mlampert
2021-01-05 15:48:56 -08:00
committed by GitHub
79 changed files with 4575 additions and 219 deletions

View File

@@ -320,7 +320,7 @@ def getSVG(source,
lineColor=(0.0, 0.0, 0.0),
fontsize=1,
showFill=False,
fillColor=(0.8, 0.8, 0.8),
fillColor=(1.0, 1.0, 1.0),
techdraw=False,
fillSpaces=False,
cutlinewidth=0,
@@ -400,10 +400,10 @@ def getSVG(source,
svgSymbolLineWidth = str(linewidth * yt)
hiddenPattern = archUserParameters.GetString("archHiddenPattern","30,10")
svgHiddenPattern = hiddenPattern.replace(" ","")
fillpattern = '<pattern id="sectionfill" patternUnits="userSpaceOnUse" patternTransform="matrix(5,0,0,5,0,0)"'
fillpattern += ' x="0" y="0" width="10" height="10">'
fillpattern += '<g>'
fillpattern += '<rect width="10" height="10" style="stroke:none; fill:#ffffff" /><path style="stroke:#000000; stroke-width:1" d="M0,0 l10,10" /></g></pattern>'
#fillpattern = '<pattern id="sectionfill" patternUnits="userSpaceOnUse" patternTransform="matrix(5,0,0,5,0,0)"'
#fillpattern += ' x="0" y="0" width="10" height="10">'
#fillpattern += '<g>'
#fillpattern += '<rect width="10" height="10" style="stroke:none; fill:#ffffff" /><path style="stroke:#000000; stroke-width:1" d="M0,0 l10,10" /></g></pattern>'
svgLineColor = Draft.getrgb(lineColor)
svg = ''
# reading cached version
@@ -444,11 +444,16 @@ def getSVG(source,
render.cut(cutplane,showHidden)
else:
render.cut(cutplane)
svgcache += '<g transform="scale(1,-1)">\n'
g = '<g transform="scale(1,-1)">\n'
if hasattr(source.ViewObject,"RotateSolidRender"):
if (source.ViewObject.RotateSolidRender.Value != 0):
g = '<g transform="scale(1,-1) rotate('
g += str(source.ViewObject.RotateSolidRender.Value)
g += ')">\n'
svgcache += g
svgcache += render.getViewSVG(linewidth="SVGLINEWIDTH")
svgcache += fillpattern
svgcache += render.getSectionSVG(linewidth="SVGCUTLINEWIDTH",
fillpattern="sectionfill")
#svgcache += fillpattern
svgcache += render.getSectionSVG(linewidth="SVGCUTLINEWIDTH",fillpattern="#ffffff")
if showHidden:
svgcache += render.getHiddenSVG(linewidth="SVGLINEWIDTH")
svgcache += '</g>\n'

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>453</width>
<height>424</height>
<width>416</width>
<height>542</height>
</rect>
</property>
<property name="windowTitle">
@@ -22,6 +22,18 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="comboBoxStyles">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>The name of your style. Existing style names can be edited.</string>
</property>
@@ -46,11 +58,17 @@
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
@@ -71,11 +89,17 @@
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
@@ -90,6 +114,26 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonImport">
<property name="toolTip">
<string>Import styles from json file</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonExport">
<property name="toolTip">
<string>Export styles to json file</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -108,8 +152,8 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-290</y>
<width>420</width>
<y>0</y>
<width>383</width>
<height>589</height>
</rect>
</property>
@@ -152,6 +196,18 @@
</item>
<item row="0" column="1">
<widget class="QFontComboBox" name="FontName">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>The font to use for texts and dimensions</string>
</property>
@@ -400,6 +456,18 @@
</item>
<item row="4" column="1">
<widget class="QComboBox" name="ArrowType">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>The type of arrows or markers to use at the end of dimension lines</string>
</property>

View File

@@ -27,12 +27,21 @@
## \addtogroup draftfuctions
# @{
import lazy_loader.lazy_loader as lz
import FreeCAD as App
import draftutils.gui_utils as gui_utils
import draftmake.make_block as make_block
import draftmake.make_wire as make_wire
import draftmake.make_circle as make_circle
import draftmake.make_bspline as make_bspline
import draftmake.make_bezcurve as make_bezcurve
import draftmake.make_arc_3points as make_arc_3points
# Delay import of module until first use because it is heavy
Part = lz.LazyLoader("Part", globals(), "Part")
DraftGeomUtils = lz.LazyLoader("DraftGeomUtils", globals(), "DraftGeomUtils")
def draftify(objectslist, makeblock=False, delete=True):
"""draftify(objectslist,[makeblock],[delete])
@@ -52,24 +61,18 @@ def draftify(objectslist, makeblock=False, delete=True):
delete : bool
If delete = False, old objects are not deleted
"""
import Part
import DraftGeomUtils
if not isinstance(objectslist,list):
objectslist = [objectslist]
newobjlist = []
for obj in objectslist:
if hasattr(obj,'Shape'):
for cluster in Part.getSortedClusters(obj.Shape.Edges):
for cluster in Part.sortEdges(obj.Shape.Edges):
w = Part.Wire(cluster)
if DraftGeomUtils.hasCurves(w):
if (len(w.Edges) == 1) and (DraftGeomUtils.geomType(w.Edges[0]) == "Circle"):
nobj = make_circle.make_circle(w.Edges[0])
else:
nobj = App.ActiveDocument.addObject("Part::Feature", obj.Name)
nobj.Shape = w
else:
nobj = make_wire.make_wire(w)
nobj = draftify_shape(w)
if nobj == None:
nobj = App.ActiveDocument.addObject("Part::Feature", obj.Name)
nobj.Shape = w
newobjlist.append(nobj)
gui_utils.format_object(nobj, obj)
# sketches are always in wireframe mode. In Draft we don't like that!
@@ -85,4 +88,34 @@ def draftify(objectslist, makeblock=False, delete=True):
return newobjlist[0]
return newobjlist
def draftify_shape(shape):
nobj = None
if DraftGeomUtils.hasCurves(shape):
if (len(shape.Edges) == 1):
edge = shape.Edges[0]
edge_type = DraftGeomUtils.geomType(edge)
if edge_type == "Circle":
if edge.isClosed():
nobj = make_circle.make_circle(edge)
else:
first_parameter = edge.FirstParameter
last_parameter = edge.LastParameter
points = [edge.Curve.value(first_parameter),
edge.Curve.value((first_parameter + last_parameter)/2),
edge.Curve.value(last_parameter)]
nobj = make_arc_3points.make_arc_3points(points)
# TODO: take into consideration trimmed curves and capture the specific
# type of BSpline and Bezier that can be converted to a draft object.
# elif edge_type == "BSplineCurve":
# knots = [edge.Curve.value(p) for p in edge.Curve.getKnots()]
# nobj = make_bspline.make_bspline(knots, closed=edge.isClosed())
# elif edge_type == "BezierCurve":
# nobj = make_bezcurve.make_bezcurve(edge.Curve.getPoles(),
# closed=edge.isClosed())
else:
nobj = make_wire.make_wire(shape)
return nobj
## @}

View File

@@ -504,18 +504,10 @@ def upgrade(objects, delete=False, force=None):
if result:
_msg(_tr("Found closed wires: creating faces"))
# wires or edges: we try to join them
elif len(wires) > 1 or len(loneedges) > 1:
elif len(objects) > 1 and len(edges) > 1:
result = makeWires(objects)
if result:
_msg(_tr("Found several wires or edges: wiring them"))
# TODO: improve draftify function
# only one object: if not parametric, we "draftify" it
# elif (len(objects) == 1
# and not objects[0].isDerivedFrom("Part::Part2DObjectPython")):
# result = ext_draftify.draftify(objects[0])
# if result:
# _msg(_tr("Found 1 non-parametric objects: "
# "draftifying it"))
# special case, we have only one open wire. We close it,
# unless it has only 1 edge!
elif len(objects) == 1 and len(openwires) == 1:
@@ -524,14 +516,23 @@ def upgrade(objects, delete=False, force=None):
if result:
_msg(_tr("Found 1 open wire: closing it"))
# we have only one object that contains one edge
# TODO: this case should be considered in draftify
elif len(objects) == 1 and len(edges) == 1:
# turn to Draft Line
# TODO: improve draftify function
# only one object: if not parametric, we "draftify" it
# elif (len(objects) == 1
# and not objects[0].isDerivedFrom("Part::Part2DObjectPython")):
# result = ext_draftify.draftify(objects[0])
# if result:
# _msg(_tr("Found 1 non-parametric objects: "
# "draftifying it"))
elif (len(objects) == 1 and len(edges) == 1
and not objects[0].isDerivedFrom("Part::Part2DObjectPython")):
e = objects[0].Shape.Edges[0]
if isinstance(e.Curve, (Part.LineSegment, Part.Line)):
result = turnToLine(objects[0])
edge_type = DraftGeomUtils.geomType(e)
# currently only support Line and Circle
if edge_type in ("Line", "Circle"):
result = ext_draftify.draftify(objects[0])
if result:
_msg(_tr("Found 1 linear object: converting to line"))
_msg(_tr("Found 1 object: draftifying it"))
# only points, no edges
elif not edges and len(objects) > 1:
result = makeCompound(objects)

View File

@@ -111,6 +111,8 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
self.form.pushButtonRename.setIcon(QtGui.QIcon(":/icons/accessories-text-editor.svg"))
self.form.pushButtonDelete.resize(self.form.pushButtonDelete.sizeHint())
self.form.pushButtonRename.resize(self.form.pushButtonRename.sizeHint())
self.form.pushButtonImport.setIcon(QtGui.QIcon(":/icons/Std_Import.svg"))
self.form.pushButtonExport.setIcon(QtGui.QIcon(":/icons/Std_Export.svg"))
# fill the styles combo
self.styles = self.read_meta()
@@ -121,6 +123,8 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
self.form.comboBoxStyles.currentIndexChanged.connect(self.on_style_changed)
self.form.pushButtonDelete.clicked.connect(self.on_delete)
self.form.pushButtonRename.clicked.connect(self.on_rename)
self.form.pushButtonImport.clicked.connect(self.on_import)
self.form.pushButtonExport.clicked.connect(self.on_export)
for attr in DEFAULT.keys():
control = getattr(self.form, attr)
for signal in ("clicked", "textChanged",
@@ -280,6 +284,42 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
self.styles[newname] = value
self.renamed[style] = newname
def on_import(self):
"""imports styles from a json file"""
filename = QtGui.QFileDialog.getOpenFileName(
QtGui.QApplication.activeWindow(),
_tr("Open styles file"),
None,
_tr("JSON file (*.json)"))
if filename and filename[0]:
with open(filename[0]) as f:
nstyles = json.load(f)
if nstyles:
self.styles.update(nstyles)
l1 = self.form.comboBoxStyles.itemText(0)
l2 = self.form.comboBoxStyles.itemText(1)
self.form.comboBoxStyles.clear()
self.form.comboBoxStyles.addItem(l1)
self.form.comboBoxStyles.addItem(l2)
for style in self.styles.keys():
self.form.comboBoxStyles.addItem(style)
print("Styles updated from "+filename[0])
def on_export(self):
"""exports styles to a json file"""
filename = QtGui.QFileDialog.getSaveFileName(
QtGui.QApplication.activeWindow(),
_tr("Save styles file"),
None,
_tr("JSON file (*.json)"))
if filename and filename[0]:
with open(filename[0],"w") as f:
json.dump(self.styles,f,indent=4)
print("Styles saved to "+filename[0])
def fill_editor(self, style):
"""Fill the editor fields with the contents of a style."""
if style is None:

View File

@@ -79,16 +79,14 @@ class Array(gui_base_original.Modifier):
if self.ui:
self.ui.selectUi()
_msg(translate("draft", "Select an object to array"))
self.call = \
self.view.addEventCallback("SoEvent",
gui_tool_utils.selectObject)
self.call = self.view.addEventCallback(
"SoEvent",
gui_tool_utils.selectObject)
else:
self.proceed()
def proceed(self):
"""Proceed with the command if one object was selected."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
if Gui.Selection.getSelection():
obj = Gui.Selection.getSelection()[0]
Gui.addModule("Draft")

View File

@@ -80,17 +80,14 @@ class Clone(gui_base_original.Modifier):
if self.ui:
self.ui.selectUi()
_msg(translate("draft", "Select an object to clone"))
self.call = \
self.view.addEventCallback("SoEvent",
gui_tool_utils.selectObject)
self.call = self.view.addEventCallback(
"SoEvent",
gui_tool_utils.selectObject)
else:
self.proceed()
def proceed(self):
"""Proceed with the command if one object was selected."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
if Gui.Selection.getSelection():
sels = len(Gui.Selection.getSelection())
Gui.addModule("Draft")

View File

@@ -71,17 +71,14 @@ class Downgrade(gui_base_original.Modifier):
if not Gui.Selection.getSelection():
self.ui.selectUi()
_msg(translate("draft", "Select an object to upgrade"))
self.call = \
self.view.addEventCallback("SoEvent",
gui_tool_utils.selectObject)
self.call = self.view.addEventCallback(
"SoEvent",
gui_tool_utils.selectObject)
else:
self.proceed()
def proceed(self):
"""Proceed with execution of the command after selection."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
if Gui.Selection.getSelection():
Gui.addModule("Draft")
_cmd = 'Draft.downgrade'

View File

@@ -71,17 +71,14 @@ class Draft2Sketch(gui_base_original.Modifier):
if self.ui:
self.ui.selectUi()
_msg(translate("draft", "Select an object to convert."))
self.call = \
self.view.addEventCallback("SoEvent",
gui_tool_utils.selectObject)
self.call = self.view.addEventCallback(
"SoEvent",
gui_tool_utils.selectObject)
else:
self.proceed()
def proceed(self):
"""Proceed with the command if one object was selected."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
sel = Gui.Selection.getSelection()
allSketches = True
allDraft = True

View File

@@ -70,16 +70,14 @@ class Facebinder(gui_base_original.Creator):
if self.ui:
self.ui.selectUi()
_msg(translate("draft", "Select faces from existing objects"))
self.call = \
self.view.addEventCallback("SoEvent",
gui_tool_utils.selectObject)
self.call = self.view.addEventCallback(
"SoEvent",
gui_tool_utils.selectObject)
else:
self.proceed()
def proceed(self):
"""Proceed when a valid selection has been made."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
if Gui.Selection.getSelection():
App.ActiveDocument.openTransaction("Create Facebinder")
Gui.addModule("Draft")

View File

@@ -78,8 +78,9 @@ class Join(gui_base_original.Modifier):
if not Gui.Selection.getSelection():
self.ui.selectUi()
_msg(translate("draft", "Select an object to join"))
self.call = self.view.addEventCallback("SoEvent",
gui_tool_utils.selectObject)
self.call = self.view.addEventCallback(
"SoEvent",
gui_tool_utils.selectObject)
else:
self.proceed()
@@ -90,8 +91,6 @@ class Join(gui_base_original.Modifier):
visually share a point. This is due to the underlying `joinWires`
method not handling the points correctly.
"""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
if Gui.Selection.getSelection():
self.print_selection()
Gui.addModule("Draft")

View File

@@ -78,9 +78,9 @@ class Offset(gui_base_original.Modifier):
if not Gui.Selection.getSelection():
self.ui.selectUi()
_msg(translate("draft", "Select an object to offset"))
self.call = \
self.view.addEventCallback("SoEvent",
gui_tool_utils.selectObject)
self.call = self.view.addEventCallback(
"SoEvent",
gui_tool_utils.selectObject)
elif len(Gui.Selection.getSelection()) > 1:
_wrn(translate("draft", "Offset only works "
"on one object at a time."))

View File

@@ -103,9 +103,6 @@ class PathArray(gui_base_original.Modifier):
def proceed(self):
"""Proceed with the command if one object was selected."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
sel = Gui.Selection.getSelectionEx()
if len(sel) != 2:
_err(_tr("Please select exactly two objects, "

View File

@@ -80,9 +80,6 @@ class PathTwistedArray(gui_base_original.Modifier):
def proceed(self):
"""Proceed with the command if one object was selected."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
sel = Gui.Selection.getSelectionEx()
if len(sel) != 2:
_err(_tr("Please select exactly two objects, "

View File

@@ -113,9 +113,6 @@ class PointArray(gui_base_original.Modifier):
def proceed(self):
"""Proceed with the command if one object was selected."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
sel = Gui.Selection.getSelectionEx()
if len(sel) != 2:
_err(_tr("Please select exactly two objects, "

View File

@@ -75,17 +75,14 @@ class Shape2DView(gui_base_original.Modifier):
if self.ui:
self.ui.selectUi()
_msg(translate("draft", "Select an object to project"))
self.call = \
self.view.addEventCallback("SoEvent",
gui_tool_utils.selectObject)
self.call = self.view.addEventCallback(
"SoEvent",
gui_tool_utils.selectObject)
else:
self.proceed()
def proceed(self):
"""Proceed with the command if one object was selected."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
faces = []
objs = []
vec = Gui.ActiveDocument.ActiveView.getViewDirection().negative()

View File

@@ -112,8 +112,6 @@ class Split(gui_base_original.Modifier):
self.commit(translate("draft", "Split line"),
_cmd_list)
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
self.finish()

View File

@@ -73,17 +73,14 @@ class Upgrade(gui_base_original.Modifier):
if not Gui.Selection.getSelection():
self.ui.selectUi()
_msg(translate("draft", "Select an object to upgrade"))
self.call = \
self.view.addEventCallback("SoEvent",
gui_tool_utils.selectObject)
self.call = self.view.addEventCallback(
"SoEvent",
gui_tool_utils.selectObject)
else:
self.proceed()
def proceed(self):
"""Proceed with execution of the command after selection."""
if self.call:
self.view.removeEventCallback("SoEvent", self.call)
if Gui.Selection.getSelection():
Gui.addModule("Draft")
_cmd = 'Draft.upgrade'

View File

@@ -59,12 +59,18 @@ def make_copy(obj, force=None, reparent=False, simple_copy=False):
newobj = None
if simple_copy and hasattr(obj, 'Shape'):
# this was the old implementation that is actyally not used by default
_name = utils.get_real_name(obj.Name)
newobj = App.ActiveDocument.addObject("Part::Feature", _name)
newobj.Shape = obj.Shape
gui_utils.format_object(newobj, obj)
elif not simple_copy:
newobj = App.ActiveDocument.copyObject(obj)
# this is the new implementation using doc.copyObject API
if obj.hasExtension("App::OriginGroupExtension"):
# always copy with dependencies when copying App::Part and PartDesign::Body
newobj = App.ActiveDocument.copyObject(obj, True)
else:
newobj = App.ActiveDocument.copyObject(obj)
if not newobj:
return None

View File

@@ -260,10 +260,11 @@ DrawingView::DrawingView(Gui::Document* doc, QWidget* parent)
//setWindowTitle(tr("SVG Viewer"));
#if QT_VERSION >= 0x050300
m_orientation = QPageLayout::Landscape;
m_pageSize = QPageSize::A4;
#else
m_orientation = QPrinter::Landscape;
#endif
m_pageSize = QPrinter::A4;
#endif
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View");
@@ -319,6 +320,29 @@ void DrawingView::findPrinterSettings(const QString& fileName)
#endif
}
#if QT_VERSION >= 0x050300
QMap<QPageSize::PageSizeId, QString> pageSizes;
pageSizes[QPageSize::A0] = QString::fromLatin1("A0");
pageSizes[QPageSize::A1] = QString::fromLatin1("A1");
pageSizes[QPageSize::A2] = QString::fromLatin1("A2");
pageSizes[QPageSize::A3] = QString::fromLatin1("A3");
pageSizes[QPageSize::A4] = QString::fromLatin1("A4");
pageSizes[QPageSize::A5] = QString::fromLatin1("A5");
pageSizes[QPageSize::A6] = QString::fromLatin1("A6");
pageSizes[QPageSize::A7] = QString::fromLatin1("A7");
pageSizes[QPageSize::A8] = QString::fromLatin1("A8");
pageSizes[QPageSize::A9] = QString::fromLatin1("A9");
pageSizes[QPageSize::B0] = QString::fromLatin1("B0");
pageSizes[QPageSize::B1] = QString::fromLatin1("B1");
pageSizes[QPageSize::B2] = QString::fromLatin1("B2");
pageSizes[QPageSize::B3] = QString::fromLatin1("B3");
pageSizes[QPageSize::B4] = QString::fromLatin1("B4");
pageSizes[QPageSize::B5] = QString::fromLatin1("B5");
pageSizes[QPageSize::B6] = QString::fromLatin1("B6");
pageSizes[QPageSize::B7] = QString::fromLatin1("B7");
pageSizes[QPageSize::B8] = QString::fromLatin1("B8");
pageSizes[QPageSize::B9] = QString::fromLatin1("B9");
#else
QMap<QPrinter::PageSize, QString> pageSizes;
pageSizes[QPrinter::A0] = QString::fromLatin1("A0");
pageSizes[QPrinter::A1] = QString::fromLatin1("A1");
@@ -340,7 +364,12 @@ void DrawingView::findPrinterSettings(const QString& fileName)
pageSizes[QPrinter::B7] = QString::fromLatin1("B7");
pageSizes[QPrinter::B8] = QString::fromLatin1("B8");
pageSizes[QPrinter::B9] = QString::fromLatin1("B9");
#endif
#if QT_VERSION >= 0x050300
for (QMap<QPageSize::PageSizeId, QString>::iterator it = pageSizes.begin(); it != pageSizes.end(); ++it) {
#else
for (QMap<QPrinter::PageSize, QString>::iterator it = pageSizes.begin(); it != pageSizes.end(); ++it) {
#endif
if (fileName.startsWith(it.value(), Qt::CaseInsensitive)) {
m_pageSize = it.key();
break;
@@ -499,6 +528,20 @@ void DrawingView::printPdf()
formLayout->addWidget(groupBox, 0, 0, 1, 1);
groupBox->setTitle(tr("Page sizes"));
#if QT_VERSION >= 0x050300
item = new QListWidgetItem(tr("A0"), listWidget);
item->setData(Qt::UserRole, QVariant(QPageSize::A0));
item = new QListWidgetItem(tr("A1"), listWidget);
item->setData(Qt::UserRole, QVariant(QPageSize::A1));
item = new QListWidgetItem(tr("A2"), listWidget);
item->setData(Qt::UserRole, QVariant(QPageSize::A2));
item = new QListWidgetItem(tr("A3"), listWidget);
item->setData(Qt::UserRole, QVariant(QPageSize::A3));
item = new QListWidgetItem(tr("A4"), listWidget);
item->setData(Qt::UserRole, QVariant(QPageSize::A4));
item = new QListWidgetItem(tr("A5"), listWidget);
item->setData(Qt::UserRole, QVariant(QPageSize::A5));
#else
item = new QListWidgetItem(tr("A0"), listWidget);
item->setData(Qt::UserRole, QVariant(QPrinter::A0));
item = new QListWidgetItem(tr("A1"), listWidget);
@@ -511,6 +554,7 @@ void DrawingView::printPdf()
item->setData(Qt::UserRole, QVariant(QPrinter::A4));
item = new QListWidgetItem(tr("A5"), listWidget);
item->setData(Qt::UserRole, QVariant(QPrinter::A5));
#endif
int index = 4; // by default A4
for (int i=0; i<listWidget->count(); i++) {
if (listWidget->item(i)->data(Qt::UserRole).toInt() == m_pageSize) {
@@ -536,7 +580,11 @@ void DrawingView::printPdf()
QList<QListWidgetItem*> items = listWidget->selectedItems();
if (items.size() == 1) {
int AX = items.front()->data(Qt::UserRole).toInt();
#if QT_VERSION >= 0x050300
printer.setPageSize(QPageSize(QPageSize::PageSizeId(AX)));
#else
printer.setPaperSize(QPrinter::PageSize(AX));
#endif
}
print(&printer);
@@ -547,10 +595,12 @@ void DrawingView::print()
{
QPrinter printer(QPrinter::HighResolution);
printer.setFullPage(true);
printer.setPageSize(m_pageSize);
#if QT_VERSION >= 0x050300
printer.setPageSize(QPageSize(m_pageSize));
printer.setPageOrientation(m_orientation);
#else
printer.setPageSize(m_pageSize);
printer.setOrientation(m_orientation);
#endif
@@ -564,10 +614,12 @@ void DrawingView::printPreview()
{
QPrinter printer(QPrinter::HighResolution);
printer.setFullPage(true);
printer.setPageSize(m_pageSize);
#if QT_VERSION >= 0x050300
printer.setPageSize(QPageSize(m_pageSize));
printer.setPageOrientation(m_orientation);
#else
printer.setPageSize(m_pageSize);
printer.setOrientation(m_orientation);
#endif
@@ -594,8 +646,13 @@ void DrawingView::print(QPrinter* printer)
if (printer->outputFormat() == QPrinter::NativeFormat) {
int w = printer->widthMM();
int h = printer->heightMM();
#if QT_VERSION >= 0x050300
QPageSize::PageSizeId realPaperSize = getPageSize(w, h);
QPageSize::PageSizeId curPaperSize = printer->pageLayout().pageSize().id();
#else
QPrinter::PaperSize realPaperSize = getPageSize(w, h);
QPrinter::PaperSize curPaperSize = printer->paperSize();
#endif
// for the preview a 'Picture' paint engine is used which we don't
// care if it uses wrong printer settings
@@ -658,7 +715,11 @@ void DrawingView::print(QPrinter* printer)
p.end();
}
#if QT_VERSION >= 0x050300
QPageSize::PageSizeId DrawingView::getPageSize(int w, int h) const
#else
QPrinter::PageSize DrawingView::getPageSize(int w, int h) const
#endif
{
static const float paperSizes[][2] = {
{210, 297}, // A4
@@ -693,17 +754,29 @@ QPrinter::PageSize DrawingView::getPageSize(int w, int h) const
{279.4f, 431.8f} // Tabloid
};
#if QT_VERSION >= 0x050300
QPageSize::PageSizeId ps = QPageSize::Custom;
#else
QPrinter::PageSize ps = QPrinter::Custom;
#endif
for (int i=0; i<30; i++) {
if (std::abs(paperSizes[i][0]-w) <= 1 &&
std::abs(paperSizes[i][1]-h) <= 1) {
#if QT_VERSION >= 0x050300
ps = static_cast<QPageSize::PageSizeId>(i);
#else
ps = static_cast<QPrinter::PageSize>(i);
#endif
break;
}
else
if (std::abs(paperSizes[i][0]-h) <= 1 &&
std::abs(paperSizes[i][1]-w) <= 1) {
#if QT_VERSION >= 0x050300
ps = static_cast<QPageSize::PageSizeId>(i);
#else
ps = static_cast<QPrinter::PageSize>(i);
#endif
break;
}
}

View File

@@ -107,7 +107,11 @@ protected:
void contextMenuEvent(QContextMenuEvent *event);
void closeEvent(QCloseEvent*);
void findPrinterSettings(const QString&);
#if QT_VERSION >= 0x050300
QPageSize::PageSizeId getPageSize(int w, int h) const;
#else
QPrinter::PageSize getPageSize(int w, int h) const;
#endif
private:
QAction *m_nativeAction;
@@ -123,10 +127,11 @@ private:
QString m_currentPath;
#if QT_VERSION >= 0x050300
QPageLayout::Orientation m_orientation;
QPageSize::PageSizeId m_pageSize;
#else
QPrinter::Orientation m_orientation;
#endif
QPrinter::PageSize m_pageSize;
#endif
};
} // namespace DrawingViewGui

View File

@@ -482,7 +482,7 @@ S, E
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -494,8 +494,8 @@ S, E
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -613,7 +613,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -625,8 +625,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -432,7 +432,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -444,8 +444,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -466,7 +466,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -478,8 +478,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -429,7 +429,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -441,8 +441,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -437,7 +437,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -449,8 +449,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -38439,7 +38439,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -38451,8 +38451,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -5371,7 +5371,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -5383,8 +5383,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -3485,7 +3485,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -3497,8 +3497,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -2213,7 +2213,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -2225,8 +2225,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -18677,7 +18677,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -18689,8 +18689,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -29213,7 +29213,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -29225,8 +29225,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -2724,7 +2724,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -2736,8 +2736,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -1305,7 +1305,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -1317,8 +1317,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -20142,7 +20142,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -20154,8 +20154,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -2687,7 +2687,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -2699,8 +2699,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -2799,7 +2799,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -2811,8 +2811,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -8274,7 +8274,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -8286,8 +8286,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -183,7 +183,7 @@ MF, PS
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -195,8 +195,8 @@ MF, PS
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -222,7 +222,7 @@ RF
** Golden rule: The user must make sure that the numbers he provides have consistent units.
** The user is the FreeCAD calculix writer module ;-)
**
** The unit system which is used at Guido Dhodts company: mm, N, s, K
** The unit system which is used at Guido Dhondt's company: mm, N, s, K
** Since Length and Mass are connected by Force, if Length is mm the Mass is in t to get N
** The following units are used to write to inp file:
**
@@ -234,8 +234,8 @@ RF
** This leads to:
** Force: N
** Pressure: N/mm^2
** Density: t/mm^2
** Density: t/mm^3
** Gravity: mm/s^2
** Thermal conductivity: t*mm/K*s^3
** Specific Heat: kJ/t/K = mm^2/s^2/K
** Thermal conductivity: t*mm/K/s^3 (same as W/m/K)
** Specific Heat: mm^2/s^2/K (same as J/kg/K)
**

View File

@@ -141,6 +141,12 @@ SOURCE_GROUP("Module" FILES ${Mod_SRCS})
add_library(Path SHARED ${Path_SRCS})
target_link_libraries(Path ${Path_LIBS})
# Boost >= 1.75.0
if(NOT ${Boost_VERSION} LESS 107500)
set_target_properties(Path PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(Path PROPERTIES CXX_STANDARD 14)
endif()
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" Path_CPP_SRCS ${Path_SRCS})

View File

@@ -174,6 +174,7 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
if obj.UseHelixArcs == False:
# rapid move to start point
op.commandlist.append(Path.Command("G0", {"Z": obj.ClearanceHeight.Value}))
op.commandlist.append(Path.Command("G0", {"X": helixStart[0], "Y": helixStart[1], "Z": obj.ClearanceHeight.Value}))
# rapid move to safe height
@@ -205,6 +206,7 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
helixStart = [region["HelixCenterPoint"][0] + r, region["HelixCenterPoint"][1]]
# rapid move to start point
op.commandlist.append(Path.Command("G0", {"Z": obj.ClearanceHeight.Value}))
op.commandlist.append(Path.Command("G0", {"X": helixStart[0], "Y": helixStart[1], "Z": obj.ClearanceHeight.Value}))
# rapid move to safe height
@@ -238,6 +240,7 @@ def GenerateGCode(op,obj,adaptiveResults, helixDiameter):
else: # no helix entry
# rapid move to clearance height
op.commandlist.append(Path.Command("G0", {"Z": obj.ClearanceHeight.Value}))
op.commandlist.append(Path.Command("G0", {"X": region["StartPoint"][0], "Y": region["StartPoint"][1], "Z": obj.ClearanceHeight.Value}))
# straight plunge to target depth
op.commandlist.append(Path.Command("G1", {"X":region["StartPoint"][0], "Y": region["StartPoint"][1], "Z": passEndDepth,"F": op.vertFeed}))

View File

@@ -58,6 +58,7 @@ class JobTemplate:
PostProcessorOutputFile = 'Output'
SetupSheet = 'SetupSheet'
Stock = 'Stock'
# TCs are grouped under Tools in a job, the template refers to them directly though
ToolController = 'ToolController'
Version = 'Version'
@@ -120,7 +121,7 @@ class ObjectJob:
obj.addProperty("App::PropertyLink", "Stock", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Solid object to be used as stock."))
obj.addProperty("App::PropertyLink", "Operations", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Compound path of all operations in the order they are processed."))
obj.addProperty("App::PropertyLinkList", "ToolController", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Collection of tool controllers available for this job."))
#obj.addProperty("App::PropertyLinkList", "ToolController", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Collection of tool controllers available for this job."))
obj.addProperty("App::PropertyBool", "SplitOutput", "Output", QtCore.QT_TRANSLATE_NOOP("PathJob", "Split output into multiple gcode files"))
obj.addProperty("App::PropertyEnumeration", "OrderOutputBy", "WCS", QtCore.QT_TRANSLATE_NOOP("PathJob", "If multiple WCS, order the output this way"))
@@ -150,6 +151,7 @@ class ObjectJob:
self.setupSetupSheet(obj)
self.setupBaseModel(obj, models)
self.setupToolTable(obj)
self.tooltip = None
self.tooltipArgs = None
@@ -191,6 +193,18 @@ class ObjectJob:
obj.Base = None
obj.removeProperty('Base')
def setupToolTable(self, obj):
if not hasattr(obj, 'Tools'):
obj.addProperty("App::PropertyLink", "Tools", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Collection of all tool controllers for the job"))
toolTable = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup", "Tools")
toolTable.Label = 'Tools'
if toolTable.ViewObject:
toolTable.ViewObject.Visibility = False
if hasattr(obj, 'ToolController'):
toolTable.addObjects(obj.ToolController)
obj.removeProperty('ToolController')
obj.Tools = toolTable
def removeBase(self, obj, base, removeFromModel):
if isResourceClone(obj, base, None):
PathUtil.clearExpressionEngine(base)
@@ -234,14 +248,16 @@ class ObjectJob:
# Tool controllers might refer to either legacy tool or toolbit
PathLog.debug('taking down tool controller')
for tc in obj.ToolController:
for tc in obj.Tools.Group:
if hasattr(tc.Tool, "Proxy"):
PathUtil.clearExpressionEngine(tc.Tool)
doc.removeObject(tc.Tool.Name)
PathUtil.clearExpressionEngine(tc)
tc.Proxy.onDelete(tc)
doc.removeObject(tc.Name)
obj.ToolController = []
obj.Tools.Group = []
doc.removeObject(obj.Tools.Name)
obj.Tools = None
# SetupSheet
PathUtil.clearExpressionEngine(obj.SetupSheet)
@@ -268,6 +284,7 @@ class ObjectJob:
self.setupBaseModel(obj)
self.fixupOperations(obj)
self.setupSetupSheet(obj)
self.setupToolTable(obj)
obj.setEditorMode('Operations', 2) # hide
obj.setEditorMode('Placement', 2)
@@ -334,7 +351,7 @@ class ObjectJob:
obj.Stock = PathStock.CreateFromTemplate(obj, attrs.get(JobTemplate.Stock))
PathLog.debug("setting tool controllers (%d)" % len(tcs))
obj.ToolController = tcs
obj.Tools.Group = tcs
else:
PathLog.error(translate('PathJob', "Unsupported PathJob template version %s") % attrs.get(JobTemplate.Version))
if not tcs:
@@ -414,13 +431,12 @@ class ObjectJob:
op.Path.Center = self.obj.Operations.Path.Center
def addToolController(self, tc):
group = self.obj.ToolController
group = self.obj.Tools.Group
PathLog.debug("addToolController(%s): %s" % (tc.Label, [t.Label for t in group]))
if tc.Name not in [str(t.Name) for t in group]:
tc.setExpression('VertRapid', "%s.%s" % (self.setupSheet.expressionReference(), PathSetupSheet.Template.VertRapid))
tc.setExpression('HorizRapid', "%s.%s" % (self.setupSheet.expressionReference(), PathSetupSheet.Template.HorizRapid))
group.append(tc)
self.obj.ToolController = group
self.obj.Tools.addObject(tc)
Notification.updateTC.emit(self.obj, tc)
def allOperations(self):

View File

@@ -146,7 +146,7 @@ class CommandJobTemplateExport:
attrs.pop(PathJob.JobTemplate.PostProcessorOutputFile, None)
# tool controller settings
toolControllers = dialog.includeToolControllers() if dialog else job.ToolController
toolControllers = dialog.includeToolControllers() if dialog else job.Tools.Group
if toolControllers:
tcAttrs = [tc.Proxy.templateAttrs(tc) for tc in toolControllers]
attrs[PathJob.JobTemplate.ToolController] = tcAttrs

View File

@@ -338,7 +338,7 @@ class JobTemplateExport:
self.dialog.settingsOpsList.addItem(item)
self.dialog.toolsList.clear()
for tc in sorted(job.ToolController, key=lambda o: o.Label):
for tc in sorted(job.Tools.Group, key=lambda o: o.Label):
item = QtGui.QListWidgetItem(tc.Label)
item.setData(self.DataObject, tc)
item.setCheckState(QtCore.Qt.CheckState.Checked)

View File

@@ -210,7 +210,7 @@ class ViewProvider:
return ":/icons/Path_Job.svg"
def claimChildren(self):
children = self.obj.ToolController
children = []
children.append(self.obj.Operations)
if hasattr(self.obj, 'Model'):
# unfortunately this function is called before the object has been fully loaded
@@ -222,6 +222,8 @@ class ViewProvider:
if hasattr(self.obj, 'SetupSheet'):
# when loading a job that didn't have a setup sheet they might not've been created yet
children.append(self.obj.SetupSheet)
if hasattr(self.obj, 'Tools'):
children.append(self.obj.Tools)
return children
def onDelete(self, vobj, arg2=None):
@@ -707,7 +709,7 @@ class TaskPanel:
vUnit = FreeCAD.Units.Quantity(1, FreeCAD.Units.Velocity).getUserPreferred()[2]
for row, tc in enumerate(sorted(self.obj.ToolController, key=lambda tc: tc.Label)):
for row, tc in enumerate(sorted(self.obj.Tools.Group, key=lambda tc: tc.Label)):
self.form.activeToolController.addItem(tc.Label, tc)
if tc == select:
index = row
@@ -847,7 +849,7 @@ class TaskPanel:
# can only delete what is selected
delete = edit
# ... but we want to make sure there's at least one TC left
if len(self.obj.ToolController) == len(self.form.toolControllerList.selectedItems()):
if len(self.obj.Tools.Group) == len(self.form.toolControllerList.selectedItems()):
delete = False
# ... also don't want to delete any TCs that are already used
if delete:

View File

@@ -517,7 +517,7 @@ class CommandPathSanity:
data = {}
try:
for TC in obj.ToolController:
for TC in obj.Tools.Group:
if not hasattr(TC.Tool, 'BitBody'):
self.squawk("PathSanity",
"Tool number {} is a legacy tool. Legacy tools not \

View File

@@ -165,12 +165,12 @@ class CommandPathToolController(object):
tool = PathToolBitGui.ToolBitSelector().getTool()
if tool:
toolNr = None
for tc in job.ToolController:
for tc in job.Tools.Group:
if tc.Tool == tool:
toolNr = tc.ToolNumber
break
if not toolNr:
toolNr = max([tc.ToolNumber for tc in job.ToolController]) + 1
toolNr = max([tc.ToolNumber for tc in job.Tools.Group]) + 1
tc = Create("TC: {}".format(tool.Label), tool, toolNr)
job.Proxy.addToolController(tc)
FreeCAD.ActiveDocument.recompute()

View File

@@ -403,7 +403,7 @@ def getToolControllers(obj, proxy=None):
PathLog.debug("op={} ({})".format(obj.Label, type(obj)))
if job:
return [c for c in job.ToolController if proxy.isToolSupported(obj, c.Tool)]
return [tc for tc in job.Tools.Group if proxy.isToolSupported(obj, tc.Tool)]
return []

View File

@@ -62,7 +62,7 @@ class TestPathHelix(PathTestUtils.PathTestBase):
def test02(self):
'''Verify Helix generates proper holes for rotated model'''
self.job.ToolController[0].Tool.Diameter = 0.5
self.job.Tools.Group[0].Tool.Diameter = 0.5
op = PathHelix.Create('Helix')
proxy = op.Proxy
@@ -87,7 +87,7 @@ class TestPathHelix(PathTestUtils.PathTestBase):
self.doc.Body.Placement.Rotation = FreeCAD.Rotation(deg, 0, 0)
self.job = PathJob.Create('Job', [self.doc.Body])
self.job.ToolController[0].Tool.Diameter = 0.5
self.job.Tools.Group[0].Tool.Diameter = 0.5
op = PathHelix.Create('Helix')
proxy = op.Proxy
@@ -109,7 +109,7 @@ class TestPathHelix(PathTestUtils.PathTestBase):
self.clone.Placement.Rotation = FreeCAD.Rotation(deg, 0, 0)
self.job = PathJob.Create('Job', [self.clone])
self.job.ToolController[0].Tool.Diameter = 0.5
self.job.Tools.Group[0].Tool.Diameter = 0.5
op = PathHelix.Create('Helix')
proxy = op.Proxy

View File

@@ -11,7 +11,7 @@
<div class="title">
<div class="version">
VERSIONSTRING
<a href="OpenSettings.py">
<a title="T_VTOOLTIP" href="OpenSettings.py">
<img class="settingsicon" src="IMAGE_SRC_SETTINGS">
</a>
</div>

View File

@@ -79,3 +79,4 @@ T_EXTERNALLINKS = translate("StartPage", "To open any of the links above in your
T_CREATIONDATE = translate("StartPage", "Creation date")
T_LASTMODIFIED = translate("StartPage", "Last modification")
T_NOTES = translate("StartPage", "Notes")
T_VTOOLTIP = translate("StartPage", "Open start page preferences")

View File

@@ -119,10 +119,11 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
: Gui::MDIView(doc, parent),
#if QT_VERSION >= 0x050300
m_orientation(QPageLayout::Landscape),
m_paperSize(QPageSize::A4),
#else
m_orientation(QPrinter::Landscape),
#endif
m_paperSize(QPrinter::A4),
#endif
m_vpPage(pageVp)
{
@@ -675,10 +676,12 @@ void MDIViewPage::printPdf(std::string file)
QPrinter printer(QPrinter::HighResolution);
printer.setFullPage(true);
printer.setOutputFileName(filename);
if (m_paperSize == QPrinter::Ledger) {
#if QT_VERSION >= 0x050300
if (m_paperSize == QPageSize::Ledger) {
printer.setPageOrientation((QPageLayout::Orientation) (1 - m_orientation)); //reverse 0/1
#else
if (m_paperSize == QPrinter::Ledger) {
printer.setOrientation((QPrinter::Orientation) (1 - m_orientation)); //reverse 0/1
#endif
} else {
@@ -688,7 +691,11 @@ void MDIViewPage::printPdf(std::string file)
printer.setOrientation(m_orientation);
#endif
}
#if QT_VERSION >= 0x050300
printer.setPageSize(QPageSize(m_paperSize));
#else
printer.setPaperSize(m_paperSize);
#endif
print(&printer);
}
@@ -696,10 +703,11 @@ void MDIViewPage::print()
{
QPrinter printer(QPrinter::HighResolution);
printer.setFullPage(true);
printer.setPaperSize(m_paperSize);
#if QT_VERSION >= 0x050300
printer.setPageSize(QPageSize(m_paperSize));
printer.setPageOrientation(m_orientation);
#else
printer.setPaperSize(m_paperSize);
printer.setOrientation(m_orientation);
#endif
QPrintDialog dlg(&printer, this);
@@ -712,10 +720,11 @@ void MDIViewPage::printPreview()
{
QPrinter printer(QPrinter::HighResolution);
printer.setFullPage(true);
printer.setPaperSize(m_paperSize);
#if QT_VERSION >= 0x050300
printer.setPageSize(QPageSize(m_paperSize));
printer.setPageOrientation(m_orientation);
#else
printer.setPaperSize(m_paperSize);
printer.setOrientation(m_orientation);
#endif
@@ -743,8 +752,13 @@ void MDIViewPage::print(QPrinter* printer)
if (printer->outputFormat() == QPrinter::NativeFormat) {
int w = printer->widthMM();
int h = printer->heightMM();
#if QT_VERSION >= 0x050300
QPageSize::PageSizeId psPrtCalcd = getPaperSize(w, h);
QPageSize::PageSizeId psPrtSetting = printer->pageLayout().pageSize().id();
#else
QPrinter::PaperSize psPrtCalcd = getPaperSize(w, h);
QPrinter::PaperSize psPrtSetting = printer->paperSize();
#endif
// for the preview a 'Picture' paint engine is used which we don't
// care if it uses wrong printer settings
@@ -836,8 +850,11 @@ void MDIViewPage::print(QPrinter* printer)
static_cast<void> (blockConnection(false));
}
#if QT_VERSION >= 0x050300
QPageSize::PageSizeId MDIViewPage::getPaperSize(int w, int h) const
#else
QPrinter::PaperSize MDIViewPage::getPaperSize(int w, int h) const
#endif
{
static const float paperSizes[][2] = {
{210, 297}, // A4
@@ -872,25 +889,46 @@ QPrinter::PaperSize MDIViewPage::getPaperSize(int w, int h) const
{279.4f, 431.8f} // Tabloid (29) causes trouble with orientation on PDF export
};
#if QT_VERSION >= 0x050300
QPageSize::PageSizeId ps = QPageSize::Custom;
#else
QPrinter::PaperSize ps = QPrinter::Custom;
#endif
for (int i=0; i<30; i++) {
if (std::abs(paperSizes[i][0]-w) <= 1 &&
std::abs(paperSizes[i][1]-h) <= 1) {
#if QT_VERSION >= 0x050300
ps = static_cast<QPageSize::PageSizeId>(i);
#else
ps = static_cast<QPrinter::PaperSize>(i);
#endif
break;
}
else //handle landscape & portrait w/h
if (std::abs(paperSizes[i][0]-h) <= 1 &&
std::abs(paperSizes[i][1]-w) <= 1) {
#if QT_VERSION >= 0x050300
ps = static_cast<QPageSize::PageSizeId>(i);
#else
ps = static_cast<QPrinter::PaperSize>(i);
#endif
break;
}
}
#if QT_VERSION >= 0x050300
if (ps == QPageSize::Ledger) { //check if really Tabloid
if (w < 431) {
ps = QPageSize::Tabloid;
}
}
#else
if (ps == QPrinter::Ledger) { //check if really Tabloid
if (w < 431) {
ps = QPrinter::Tabloid;
}
}
#endif
return ps;
}

View File

@@ -128,7 +128,12 @@ protected:
void contextMenuEvent(QContextMenuEvent *event);
void closeEvent(QCloseEvent*);
#if QT_VERSION >= 0x050300
QPageSize::PageSizeId getPaperSize(int w, int h) const;
#else
QPrinter::PaperSize getPaperSize(int w, int h) const;
#endif
void setDimensionGroups(void);
void setBalloonGroups(void);
void setLeaderGroups(void);
@@ -161,10 +166,11 @@ private:
QString m_currentPath;
#if QT_VERSION >= 0x050300
QPageLayout::Orientation m_orientation;
QPageSize::PageSizeId m_paperSize;
#else
QPrinter::Orientation m_orientation;
#endif
QPrinter::PaperSize m_paperSize;
#endif
ViewProviderPage *m_vpPage;
QList<QGraphicsItem*> m_qgSceneSelected; //items in selection order