Merge branch 'master' into feature/expose-enumerations-to-python
This commit is contained in:
@@ -461,7 +461,11 @@ void GraphvizView::print()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setFullPage(true);
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation(QPageLayout::Landscape);
|
||||
#else
|
||||
printer.setOrientation(QPrinter::Landscape);
|
||||
#endif
|
||||
QPrintDialog dlg(&printer, this);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
print(&printer);
|
||||
@@ -491,7 +495,11 @@ void GraphvizView::printPreview()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setFullPage(true);
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation(QPageLayout::Landscape);
|
||||
#else
|
||||
printer.setOrientation(QPrinter::Landscape);
|
||||
#endif
|
||||
|
||||
QPrintPreviewDialog dlg(&printer, this);
|
||||
connect(&dlg, SIGNAL(paintRequested (QPrinter *)),
|
||||
|
||||
@@ -516,7 +516,11 @@ void View3DInventor::printPreview()
|
||||
#if (QT_VERSION > QT_VERSION_CHECK(5, 9, 0))
|
||||
printer.setPageSize(QPrinter::A4);
|
||||
#endif
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation(QPageLayout::Landscape);
|
||||
#else
|
||||
printer.setOrientation(QPrinter::Landscape);
|
||||
#endif
|
||||
|
||||
QPrintPreviewDialog dlg(&printer, this);
|
||||
connect(&dlg, SIGNAL(paintRequested (QPrinter *)),
|
||||
|
||||
@@ -258,8 +258,11 @@ DrawingView::DrawingView(Gui::Document* doc, QWidget* parent)
|
||||
|
||||
setCentralWidget(m_view);
|
||||
//setWindowTitle(tr("SVG Viewer"));
|
||||
|
||||
#if QT_VERSION >= 0x050300
|
||||
m_orientation = QPageLayout::Landscape;
|
||||
#else
|
||||
m_orientation = QPrinter::Landscape;
|
||||
#endif
|
||||
m_pageSize = QPrinter::A4;
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
@@ -302,10 +305,18 @@ void DrawingView::load (const QString & fileName)
|
||||
void DrawingView::findPrinterSettings(const QString& fileName)
|
||||
{
|
||||
if (fileName.indexOf(QLatin1String("Portrait"), Qt::CaseInsensitive) >= 0) {
|
||||
#if QT_VERSION >= 0x050300
|
||||
m_orientation = QPageLayout::Portrait;
|
||||
#else
|
||||
m_orientation = QPrinter::Portrait;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#if QT_VERSION >= 0x050300
|
||||
m_orientation = QPageLayout::Landscape;
|
||||
#else
|
||||
m_orientation = QPrinter::Landscape;
|
||||
#endif
|
||||
}
|
||||
|
||||
QMap<QPrinter::PageSize, QString> pageSizes;
|
||||
@@ -517,7 +528,11 @@ void DrawingView::printPdf()
|
||||
printer.setFullPage(true);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setOutputFileName(filename);
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation(m_orientation);
|
||||
#else
|
||||
printer.setOrientation(m_orientation);
|
||||
#endif
|
||||
QList<QListWidgetItem*> items = listWidget->selectedItems();
|
||||
if (items.size() == 1) {
|
||||
int AX = items.front()->data(Qt::UserRole).toInt();
|
||||
@@ -533,7 +548,11 @@ void DrawingView::print()
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setFullPage(true);
|
||||
printer.setPageSize(m_pageSize);
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation(m_orientation);
|
||||
#else
|
||||
printer.setOrientation(m_orientation);
|
||||
#endif
|
||||
|
||||
QPrintDialog dlg(&printer, this);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
@@ -546,7 +565,11 @@ void DrawingView::printPreview()
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setFullPage(true);
|
||||
printer.setPageSize(m_pageSize);
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation(m_orientation);
|
||||
#else
|
||||
printer.setOrientation(m_orientation);
|
||||
#endif
|
||||
|
||||
QPrintPreviewDialog dlg(&printer, this);
|
||||
connect(&dlg, SIGNAL(paintRequested (QPrinter *)),
|
||||
@@ -578,7 +601,11 @@ void DrawingView::print(QPrinter* printer)
|
||||
// care if it uses wrong printer settings
|
||||
bool doPrint = paintType != QPaintEngine::Picture;
|
||||
|
||||
#if QT_VERSION >= 0x050300
|
||||
if (doPrint && printer->pageLayout().orientation() != this->m_orientation) {
|
||||
#else
|
||||
if (doPrint && printer->orientation() != this->m_orientation) {
|
||||
#endif
|
||||
int ret = QMessageBox::warning(this, tr("Different orientation"),
|
||||
tr("The printer uses a different orientation than the drawing.\n"
|
||||
"Do you want to continue?"),
|
||||
|
||||
@@ -121,7 +121,11 @@ private:
|
||||
std::string m_objectName;
|
||||
|
||||
QString m_currentPath;
|
||||
#if QT_VERSION >= 0x050300
|
||||
QPageLayout::Orientation m_orientation;
|
||||
#else
|
||||
QPrinter::Orientation m_orientation;
|
||||
#endif
|
||||
QPrinter::PageSize m_pageSize;
|
||||
};
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ units_information = """*********************************************************
|
||||
** 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:
|
||||
**
|
||||
@@ -68,10 +68,10 @@ units_information = """*********************************************************
|
||||
** 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)
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -745,7 +745,7 @@ def guessDepths(objshape, subs=None):
|
||||
|
||||
def drillTipLength(tool):
|
||||
"""returns the length of the drillbit tip."""
|
||||
if tool.CuttingEdgeAngle == 180 or tool.CuttingEdgeAngle == 0.0 or float(tool.Diameter) == 0.0:
|
||||
if not hasattr(tool, 'CuttingEdgeAngle') or tool.CuttingEdgeAngle == 180 or tool.CuttingEdgeAngle == 0.0 or float(tool.Diameter) == 0.0:
|
||||
return 0.0
|
||||
else:
|
||||
if tool.CuttingEdgeAngle <= 0 or tool.CuttingEdgeAngle >= 180:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2015 Dan Falck <ddfalck@gmail.com> *
|
||||
# * Copyright (c) 2020 Schildkroet *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -48,6 +49,7 @@ Arguments for centroid:
|
||||
--show-editor, --no-show-editor ... pop up editor before writing output(--show-editor)
|
||||
--feed-precision=1 ... number of digits of precision for feed rate. Default=1
|
||||
--axis-precision=4 ... number of digits of precision for axis moves. Default=4
|
||||
--inches ... Convert output for US imperial mode (G20)
|
||||
'''
|
||||
now = datetime.datetime.now()
|
||||
|
||||
@@ -65,8 +67,9 @@ COMMAND_SPACE = " "
|
||||
LINENR = 100 # line number starting value
|
||||
|
||||
# These globals will be reflected in the Machine configuration of the project
|
||||
UNITS = "G20" # G21 for metric, G20 for us standard
|
||||
UNIT_FORMAT = 'mm/min'
|
||||
UNITS = "G21" # G21 for metric, G20 for us standard
|
||||
UNIT_FORMAT = 'mm'
|
||||
UNIT_SPEED_FORMAT = 'mm/min'
|
||||
MACHINE_NAME = "Centroid"
|
||||
CORNER_MIN = {'x': -609.6, 'y': -152.4, 'z': 0} # use metric for internal units
|
||||
CORNER_MAX = {'x': 609.6, 'y': 152.4, 'z': 304.8} # use metric for internal units
|
||||
@@ -91,7 +94,8 @@ PREAMBLE = '''G53 G00 G17
|
||||
POSTAMBLE = '''M99
|
||||
'''
|
||||
|
||||
TOOLRETURN = '''M5 M25
|
||||
TOOLRETURN = '''M5
|
||||
M25
|
||||
G49 H0
|
||||
''' # spindle off,height offset canceled,spindle retracted (M25 is a centroid command to retract spindle)
|
||||
|
||||
@@ -125,6 +129,9 @@ def processArguments(argstring):
|
||||
global SHOW_EDITOR
|
||||
global AXIS_PRECISION
|
||||
global FEED_PRECISION
|
||||
global UNIT_SPEED_FORMAT
|
||||
global UNIT_FORMAT
|
||||
global UNITS
|
||||
|
||||
for arg in argstring.split():
|
||||
if arg == '--header':
|
||||
@@ -147,6 +154,10 @@ def processArguments(argstring):
|
||||
AXIS_PRECISION = arg.split('=')[1]
|
||||
elif arg.split('=')[0] == '--feed-precision':
|
||||
FEED_PRECISION = arg.split('=')[1]
|
||||
elif arg == '--inches':
|
||||
UNITS = 'G20'
|
||||
UNIT_SPEED_FORMAT = 'in/min'
|
||||
UNIT_FORMAT = 'in'
|
||||
|
||||
|
||||
def export(objectslist, filename, argstring):
|
||||
@@ -156,6 +167,7 @@ def export(objectslist, filename, argstring):
|
||||
print(i.Name)
|
||||
global UNITS
|
||||
global UNIT_FORMAT
|
||||
global UNIT_SPEED_FORMAT
|
||||
|
||||
print("postprocessing...")
|
||||
gcode = ""
|
||||
@@ -169,11 +181,7 @@ def export(objectslist, filename, argstring):
|
||||
# Write the preamble
|
||||
if OUTPUT_COMMENTS:
|
||||
for item in objectslist:
|
||||
if hasattr(item, "Proxy"):
|
||||
itm_trgt = item.Proxy
|
||||
else:
|
||||
itm_trgt = item
|
||||
if isinstance(itm_trgt, PathScripts.PathToolController.ToolController):
|
||||
if hasattr(item, "Proxy") and isinstance(item.Proxy, PathScripts.PathToolController.ToolController):
|
||||
gcode += ";T{}={}\n".format(item.ToolNumber, item.Name)
|
||||
gcode += linenumber() + ";begin preamble\n"
|
||||
for line in PREAMBLE.splitlines(True):
|
||||
@@ -283,7 +291,7 @@ def parse(pathobj):
|
||||
if c.Name not in ["G0", "G00"]: # centroid doesn't use rapid speeds
|
||||
speed = Units.Quantity(c.Parameters['F'], FreeCAD.Units.Velocity)
|
||||
commandlist.append(
|
||||
param + format(float(speed.getValueAs(UNIT_FORMAT)), feed_precision_string))
|
||||
param + format(float(speed.getValueAs(UNIT_SPEED_FORMAT)), feed_precision_string))
|
||||
elif param == 'H':
|
||||
commandlist.append(param + str(int(c.Parameters['H'])))
|
||||
elif param == 'S':
|
||||
@@ -291,8 +299,9 @@ def parse(pathobj):
|
||||
elif param == 'T':
|
||||
commandlist.append(param + str(int(c.Parameters['T'])))
|
||||
else:
|
||||
pos = Units.Quantity(c.Parameters[param], FreeCAD.Units.Length)
|
||||
commandlist.append(
|
||||
param + format(c.Parameters[param], axis_precision_string))
|
||||
param + format(float(pos.getValueAs(UNIT_FORMAT)), axis_precision_string))
|
||||
outstr = str(commandlist)
|
||||
outstr = outstr.replace('[', '')
|
||||
outstr = outstr.replace(']', '')
|
||||
@@ -328,4 +337,4 @@ def parse(pathobj):
|
||||
return out
|
||||
|
||||
|
||||
# print(__name__ + " gcode postprocessor loaded.")
|
||||
print(__name__ + " gcode postprocessor loaded.")
|
||||
|
||||
@@ -391,6 +391,7 @@ void init_pyarea(py::module &m){
|
||||
.def_readwrite("stockToLeave", &Adaptive2d::stockToLeave)
|
||||
.def_readwrite("helixRampDiameter", &Adaptive2d::helixRampDiameter)
|
||||
.def_readwrite("forceInsideOut", &Adaptive2d::forceInsideOut)
|
||||
.def_readwrite("finishingProfile", &Adaptive2d::finishingProfile)
|
||||
//.def_readwrite("polyTreeNestingLimit", &Adaptive2d::polyTreeNestingLimit)
|
||||
.def_readwrite("tolerance", &Adaptive2d::tolerance)
|
||||
.def_readwrite("keepToolDownDistRatio", &Adaptive2d::keepToolDownDistRatio)
|
||||
|
||||
@@ -117,7 +117,11 @@ TYPESYSTEM_SOURCE_ABSTRACT(TechDrawGui::MDIViewPage, Gui::MDIView)
|
||||
|
||||
MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget* parent)
|
||||
: Gui::MDIView(doc, parent),
|
||||
#if QT_VERSION >= 0x050300
|
||||
m_orientation(QPageLayout::Landscape),
|
||||
#else
|
||||
m_orientation(QPrinter::Landscape),
|
||||
#endif
|
||||
m_paperSize(QPrinter::A4),
|
||||
m_vpPage(pageVp)
|
||||
{
|
||||
@@ -311,9 +315,17 @@ void MDIViewPage::attachTemplate(TechDraw::DrawTemplate *obj)
|
||||
double height = obj->Height.getValue();
|
||||
m_paperSize = getPaperSize(int(round(width)),int(round(height)));
|
||||
if (width > height) {
|
||||
#if QT_VERSION >= 0x050300
|
||||
m_orientation = QPageLayout::Landscape;
|
||||
#else
|
||||
m_orientation = QPrinter::Landscape;
|
||||
#endif
|
||||
} else {
|
||||
#if QT_VERSION >= 0x050300
|
||||
m_orientation = QPageLayout::Portrait;
|
||||
#else
|
||||
m_orientation = QPrinter::Portrait;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,9 +676,17 @@ void MDIViewPage::printPdf(std::string file)
|
||||
printer.setFullPage(true);
|
||||
printer.setOutputFileName(filename);
|
||||
if (m_paperSize == QPrinter::Ledger) {
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation((QPageLayout::Orientation) (1 - m_orientation)); //reverse 0/1
|
||||
#else
|
||||
printer.setOrientation((QPrinter::Orientation) (1 - m_orientation)); //reverse 0/1
|
||||
#endif
|
||||
} else {
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation(m_orientation);
|
||||
#else
|
||||
printer.setOrientation(m_orientation);
|
||||
#endif
|
||||
}
|
||||
printer.setPaperSize(m_paperSize);
|
||||
print(&printer);
|
||||
@@ -677,7 +697,11 @@ void MDIViewPage::print()
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setFullPage(true);
|
||||
printer.setPaperSize(m_paperSize);
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation(m_orientation);
|
||||
#else
|
||||
printer.setOrientation(m_orientation);
|
||||
#endif
|
||||
QPrintDialog dlg(&printer, this);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
print(&printer);
|
||||
@@ -689,7 +713,11 @@ void MDIViewPage::printPreview()
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setFullPage(true);
|
||||
printer.setPaperSize(m_paperSize);
|
||||
#if QT_VERSION >= 0x050300
|
||||
printer.setPageOrientation(m_orientation);
|
||||
#else
|
||||
printer.setOrientation(m_orientation);
|
||||
#endif
|
||||
|
||||
QPrintPreviewDialog dlg(&printer, this);
|
||||
connect(&dlg, SIGNAL(paintRequested (QPrinter *)),
|
||||
@@ -722,7 +750,11 @@ void MDIViewPage::print(QPrinter* printer)
|
||||
// care if it uses wrong printer settings
|
||||
bool doPrint = paintType != QPaintEngine::Picture;
|
||||
|
||||
#if QT_VERSION >= 0x050300
|
||||
if (doPrint && printer->pageLayout().orientation() != m_orientation) {
|
||||
#else
|
||||
if (doPrint && printer->orientation() != m_orientation) {
|
||||
#endif
|
||||
int ret = QMessageBox::warning(this, tr("Different orientation"),
|
||||
tr("The printer uses a different orientation than the drawing.\n"
|
||||
"Do you want to continue?"),
|
||||
|
||||
@@ -159,7 +159,11 @@ private:
|
||||
QTimer *m_timer;
|
||||
|
||||
QString m_currentPath;
|
||||
#if QT_VERSION >= 0x050300
|
||||
QPageLayout::Orientation m_orientation;
|
||||
#else
|
||||
QPrinter::Orientation m_orientation;
|
||||
#endif
|
||||
QPrinter::PaperSize m_paperSize;
|
||||
ViewProviderPage *m_vpPage;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user