Restore GUI-free Web module runtimes
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
Build Release / upload_src (push) Has been cancelled
Build Release / build (10.13, macos-15-intel, osx-64) (push) Has been cancelled
Build Release / build (11.0, macos-latest, osx-arm64) (push) Has been cancelled
Build Release / build (15.0, macos-latest, osx-arm64) (push) Has been cancelled
Build Release / build (ubuntu-22.04, linux-64) (push) Has been cancelled
Build Release / build (ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Build Release / build (windows-latest, win-64) (push) Has been cancelled
CodeQL Advanced (c-cpp) / Analyze (c-cpp) (push) Has been cancelled
Push Crowdin Translations / update-crowdin (push) Has been cancelled
Fetch Crowdin Translations / update-crowdin (push) Has been cancelled
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
Build Release / upload_src (push) Has been cancelled
Build Release / build (10.13, macos-15-intel, osx-64) (push) Has been cancelled
Build Release / build (11.0, macos-latest, osx-arm64) (push) Has been cancelled
Build Release / build (15.0, macos-latest, osx-arm64) (push) Has been cancelled
Build Release / build (ubuntu-22.04, linux-64) (push) Has been cancelled
Build Release / build (ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Build Release / build (windows-latest, win-64) (push) Has been cancelled
CodeQL Advanced (c-cpp) / Analyze (c-cpp) (push) Has been cancelled
Push Crowdin Translations / update-crowdin (push) Has been cancelled
Fetch Crowdin Translations / update-crowdin (push) Has been cancelled
This commit is contained in:
@@ -70,9 +70,9 @@ if(BUILD_CAM)
|
||||
add_subdirectory(CAM)
|
||||
endif(BUILD_CAM)
|
||||
|
||||
if(BUILD_PLOT)
|
||||
if(BUILD_PLOT OR FREECAD_WEB)
|
||||
add_subdirectory(Plot)
|
||||
endif(BUILD_PLOT)
|
||||
endif()
|
||||
|
||||
if(BUILD_POINTS)
|
||||
add_subdirectory(Points)
|
||||
@@ -80,7 +80,7 @@ endif(BUILD_POINTS)
|
||||
|
||||
if(BUILD_REVERSEENGINEERING)
|
||||
add_subdirectory(ReverseEngineering)
|
||||
endif(BUILD_REVERSEENGINEERING)
|
||||
endif()
|
||||
|
||||
if(BUILD_ROBOT)
|
||||
if(EIGEN3_FOUND)
|
||||
|
||||
@@ -96,14 +96,14 @@ void PropertyMaterial::Restore(Base::XMLReader& reader)
|
||||
|
||||
const auto materialUuid = QString::fromLatin1(uuid);
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
try {
|
||||
setValue(*MaterialManager::getManager().getMaterial(materialUuid));
|
||||
}
|
||||
catch (const MaterialNotFound&) {
|
||||
Material placeholder;
|
||||
placeholder.setUUID(materialUuid);
|
||||
setValue(placeholder);
|
||||
}
|
||||
// The Web core does not embed the GUI material/model libraries. Looking up
|
||||
// a persisted UUID would initialize those registries and can fail before
|
||||
// MaterialNotFound is translated, so retain the UUID on a standalone
|
||||
// default material instead.
|
||||
Material fallback;
|
||||
fallback.setUUID(materialUuid);
|
||||
fallback.setName(QStringLiteral("Web default material"));
|
||||
setValue(fallback);
|
||||
#else
|
||||
setValue(*MaterialManager::getManager().getMaterial(materialUuid));
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,11 @@
|
||||
|
||||
#include "PartFeature.h"
|
||||
#include "PartPyCXX.h"
|
||||
#include "PropertyTopoShape.h"
|
||||
#include "PropertyTopoShape.h"
|
||||
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
extern "C" void fc_web_document_restore_property(const char* name);
|
||||
#endif
|
||||
#include "TopoShapePy.h"
|
||||
#include "PartFeature.h"
|
||||
|
||||
@@ -687,6 +691,9 @@ void PropertyPartShape::loadFromFile(Base::Reader& reader)
|
||||
|
||||
void PropertyPartShape::loadFromStream(Base::Reader& reader)
|
||||
{
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property((std::string("brep-stream:") + reader.getFileName()).c_str());
|
||||
#endif
|
||||
// Save locale before calling OCCT. TopTools_ShapeSet::Read imbues the stream
|
||||
// with std::locale::classic() and restores it on return, but uses a non-RAII
|
||||
// pattern. When exceptions propagate out (due to the exception mask below),
|
||||
@@ -698,15 +705,51 @@ void PropertyPartShape::loadFromStream(Base::Reader& reader)
|
||||
// to the binary entry. Clear that state before enabling strict BRep
|
||||
// read exceptions; basic_ios::exceptions() throws immediately when
|
||||
// the current state intersects the requested mask.
|
||||
// clear() itself may throw when an EOF/fail state is already present
|
||||
// under the caller's exception mask (notably for an empty optional
|
||||
// PartDesign suppressed shape). Disable the mask before normalizing
|
||||
// the state, then enable strict BREP diagnostics.
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property("brep-mask-off");
|
||||
#endif
|
||||
reader.exceptions(std::ios::goodbit);
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property("brep-clear-before-read");
|
||||
#endif
|
||||
reader.clear();
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property("brep-mask-strict");
|
||||
#endif
|
||||
#ifndef FREECAD_WEB_CORE
|
||||
reader.exceptions(std::istream::failbit | std::istream::badbit);
|
||||
#endif
|
||||
BRep_Builder builder;
|
||||
TopoDS_Shape shape;
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property("brep-occt-read");
|
||||
#endif
|
||||
BRepTools::Read(shape, reader, builder);
|
||||
setValue(shape);
|
||||
setValue(shape);
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
reader.exceptions(std::ios::goodbit);
|
||||
reader.clear();
|
||||
#endif
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property((std::string("brep-base-error:") + reader.getFileName()).c_str());
|
||||
#endif
|
||||
reader.exceptions(std::ios::goodbit);
|
||||
reader.clear();
|
||||
reader.imbue(savedLocale);
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
reader.imbue(savedLocale);
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property((std::string("brep-stream-error:") + reader.getFileName()).c_str());
|
||||
#endif
|
||||
reader.exceptions(std::ios::goodbit);
|
||||
reader.clear();
|
||||
reader.imbue(savedLocale);
|
||||
if (!reader.eof()) {
|
||||
Base::Console().warning("Failed to load BRep file %s\n", reader.getFileName().c_str());
|
||||
}
|
||||
@@ -743,6 +786,9 @@ void PropertyPartShape::SaveDocFile(Base::Writer& writer) const
|
||||
|
||||
void PropertyPartShape::RestoreDocFile(Base::Reader& reader)
|
||||
{
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property((std::string("brep-file:") + reader.getFileName()).c_str());
|
||||
#endif
|
||||
|
||||
// save the element map
|
||||
auto elementMap = _Shape.resetElementMap();
|
||||
@@ -772,9 +818,24 @@ void PropertyPartShape::RestoreDocFile(Base::Reader& reader)
|
||||
}
|
||||
else {
|
||||
auto iostate = reader.exceptions();
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property("brep-restore-load");
|
||||
#endif
|
||||
loadFromStream(reader);
|
||||
// A zero-byte optional shape (for example PartDesign's
|
||||
// SuppressedShape) legitimately reaches EOF. loadFromStream
|
||||
// handles that as an empty shape, but the stream state must be
|
||||
// cleared before restoring an exception mask that includes eof.
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property("brep-restore-clear");
|
||||
#endif
|
||||
reader.exceptions(std::ios::goodbit);
|
||||
reader.clear();
|
||||
#ifdef FREECAD_WEB_CORE
|
||||
fc_web_document_restore_property("brep-restore-mask");
|
||||
#endif
|
||||
reader.exceptions(iostate);
|
||||
}
|
||||
}
|
||||
shape = getValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,42 +23,63 @@
|
||||
|
||||
import FreeCAD
|
||||
|
||||
import PySide
|
||||
from PySide import QtCore, QtGui
|
||||
import sys
|
||||
_WEB_HEADLESS = sys.platform == "emscripten"
|
||||
|
||||
try:
|
||||
import matplotlib
|
||||
if not _WEB_HEADLESS:
|
||||
import PySide
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
matplotlib.use("QtAgg")
|
||||
try:
|
||||
import matplotlib
|
||||
|
||||
# Force matplotlib to use PySide backend by temporarily unloading PyQt
|
||||
pyqt5_unloaded = False
|
||||
pyqt6_unloaded = False
|
||||
if "PyQt5.QtCore" in sys.modules:
|
||||
del sys.modules["PyQt5.QtCore"]
|
||||
pyqt5_unloaded = True
|
||||
if "PyQt6.QtCore" in sys.modules:
|
||||
del sys.modules["PyQt6.QtCore"]
|
||||
pyqt6_unloaded = True
|
||||
matplotlib.use("QtAgg")
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
# Force matplotlib to use PySide backend by temporarily unloading PyQt
|
||||
pyqt5_unloaded = False
|
||||
pyqt6_unloaded = False
|
||||
if "PyQt5.QtCore" in sys.modules:
|
||||
del sys.modules["PyQt5.QtCore"]
|
||||
pyqt5_unloaded = True
|
||||
if "PyQt6.QtCore" in sys.modules:
|
||||
del sys.modules["PyQt6.QtCore"]
|
||||
pyqt6_unloaded = True
|
||||
|
||||
# restore PyQt if unloaded
|
||||
if pyqt5_unloaded:
|
||||
import PyQt5.QtCore
|
||||
if pyqt6_unloaded:
|
||||
import PyQt6.QtCore
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas
|
||||
from matplotlib.backends.backend_qtagg import NavigationToolbar2QT as NavigationToolbar
|
||||
# restore PyQt if unloaded
|
||||
if pyqt5_unloaded:
|
||||
import PyQt5.QtCore
|
||||
if pyqt6_unloaded:
|
||||
import PyQt6.QtCore
|
||||
|
||||
from matplotlib.figure import Figure
|
||||
except ImportError:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
"The 'matplotlib' Python package was not found. Plot module cannot be loaded\n"
|
||||
)
|
||||
raise ImportError("matplotlib not installed")
|
||||
from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas
|
||||
from matplotlib.backends.backend_qtagg import NavigationToolbar2QT as NavigationToolbar
|
||||
|
||||
from matplotlib.figure import Figure
|
||||
except ImportError:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
"The 'matplotlib' Python package was not found. Plot module cannot be loaded\n"
|
||||
)
|
||||
raise ImportError("matplotlib not installed")
|
||||
else:
|
||||
# GUI-free Web uses the public Plot data API with a deterministic SVG
|
||||
# renderer. This branch deliberately does not import PySide, QtAgg, or
|
||||
# matplotlib, none of which are part of the isolated Web Python runtime.
|
||||
class _WebQtWidget:
|
||||
class QWidget:
|
||||
pass
|
||||
|
||||
class _WebQtCore:
|
||||
class Qt:
|
||||
WindowFlags = int
|
||||
|
||||
class _WebQt:
|
||||
QtGui = _WebQtWidget
|
||||
QtCore = _WebQtCore
|
||||
|
||||
PySide = _WebQt()
|
||||
QtCore = QtGui = FigureCanvas = NavigationToolbar = Figure = None
|
||||
|
||||
|
||||
def getMainWindow():
|
||||
@@ -493,3 +514,274 @@ class Plot(PySide.QtGui.QWidget):
|
||||
"""
|
||||
self.axes = self.axesList[index]
|
||||
self.fig.sca(self.axes)
|
||||
|
||||
|
||||
if _WEB_HEADLESS:
|
||||
import math
|
||||
|
||||
def _xml_escape(value):
|
||||
return (str(value).replace("&", "&").replace("<", "<")
|
||||
.replace(">", ">").replace('"', """).replace("'", "'"))
|
||||
|
||||
_WEB_ACTIVE_PLOT = None
|
||||
|
||||
class _WebAxis:
|
||||
def __init__(self, rect=(0.1, 0.1, 0.85, 0.8), frameon=True, patchcolor="none"):
|
||||
self.rect = tuple(rect)
|
||||
self.frameon = bool(frameon)
|
||||
self.patchcolor = patchcolor
|
||||
self.lines = []
|
||||
self.title = ""
|
||||
self.xlabel = ""
|
||||
self.ylabel = ""
|
||||
self.grid_enabled = False
|
||||
|
||||
def get_position(self):
|
||||
return self.rect
|
||||
|
||||
def grid(self, status):
|
||||
self.grid_enabled = bool(status)
|
||||
|
||||
class _WebFigure:
|
||||
def __init__(self):
|
||||
self.axes = []
|
||||
self.size = (6.4, 4.8)
|
||||
self.dpi = 100
|
||||
|
||||
def add_subplot(self, _code=111):
|
||||
axis = _WebAxis()
|
||||
self.axes.append(axis)
|
||||
return axis
|
||||
|
||||
def add_axes(self, rect, frameon=True):
|
||||
axis = _WebAxis(rect, frameon)
|
||||
self.axes.append(axis)
|
||||
return axis
|
||||
|
||||
def sca(self, axis):
|
||||
return axis
|
||||
|
||||
def set_size_inches(self, width, height=None):
|
||||
if height is None:
|
||||
width, height = width
|
||||
self.size = (float(width), float(height))
|
||||
|
||||
def get_size_inches(self):
|
||||
return self.size
|
||||
|
||||
def set_dpi(self, dpi):
|
||||
self.dpi = float(dpi)
|
||||
|
||||
def get_dpi(self):
|
||||
return self.dpi
|
||||
|
||||
def svg(self):
|
||||
width = max(1, int(round(self.size[0] * self.dpi)))
|
||||
height = max(1, int(round(self.size[1] * self.dpi)))
|
||||
lines = [
|
||||
f'<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}">',
|
||||
'<rect width="100%" height="100%" fill="white"/>',
|
||||
]
|
||||
palette = ("#1769aa", "#d1495b", "#2a9d8f", "#e9c46a", "#6a4c93")
|
||||
for axis in self.axes:
|
||||
values = [(line.x[i], line.y[i]) for line in axis.lines for i in range(min(len(line.x), len(line.y)))]
|
||||
if not values:
|
||||
continue
|
||||
min_x = min(value[0] for value in values)
|
||||
max_x = max(value[0] for value in values)
|
||||
min_y = min(value[1] for value in values)
|
||||
max_y = max(value[1] for value in values)
|
||||
span_x = max(max_x - min_x, 1e-12)
|
||||
span_y = max(max_y - min_y, 1e-12)
|
||||
left, top = 60, 35
|
||||
plot_width, plot_height = width - 90, height - 85
|
||||
if axis.grid_enabled:
|
||||
lines.append(f'<path d="M {left} {top} V {top + plot_height} H {left + plot_width}" fill="none" stroke="#cbd5e1"/>')
|
||||
for index, line in enumerate(axis.lines):
|
||||
points = []
|
||||
for x, y in zip(line.x, line.y):
|
||||
px = left + (x - min_x) / span_x * plot_width
|
||||
py = top + plot_height - (y - min_y) / span_y * plot_height
|
||||
points.append(f"{px:.3f},{py:.3f}")
|
||||
color = line.properties.get("color", palette[index % len(palette)])
|
||||
lines.append(f'<polyline points="{" ".join(points)}" fill="none" stroke="{_xml_escape(color)}" stroke-width="2"/>')
|
||||
if line.name:
|
||||
lines.append(f'<text x="{left + 8}" y="{top + 18 + index * 16}" fill="{_xml_escape(color)}">{_xml_escape(line.name)}</text>')
|
||||
if axis.title:
|
||||
lines.append(f'<text x="{left + plot_width / 2:.1f}" y="20" text-anchor="middle">{_xml_escape(axis.title)}</text>')
|
||||
if axis.xlabel:
|
||||
lines.append(f'<text x="{left + plot_width / 2:.1f}" y="{height - 12}" text-anchor="middle">{_xml_escape(axis.xlabel)}</text>')
|
||||
if axis.ylabel:
|
||||
lines.append(f'<text x="14" y="{top + plot_height / 2:.1f}" transform="rotate(-90 14 {top + plot_height / 2:.1f})" text-anchor="middle">{_xml_escape(axis.ylabel)}</text>')
|
||||
lines.append('</svg>')
|
||||
return "".join(lines)
|
||||
|
||||
class _WebCanvas:
|
||||
def __init__(self, figure):
|
||||
self.figure = figure
|
||||
|
||||
def draw(self):
|
||||
return None
|
||||
|
||||
def print_figure(self, path):
|
||||
with open(path, "w", encoding="utf-8") as output:
|
||||
output.write(self.figure.svg())
|
||||
|
||||
class Line:
|
||||
def __init__(self, axis, x, y, name=None):
|
||||
if len(x) != len(y) or not x:
|
||||
raise ValueError("plot series requires equally sized non-empty x and y values")
|
||||
self.axes = axis
|
||||
self.x = [float(value) for value in x]
|
||||
self.y = [float(value) for value in y]
|
||||
if not all(math.isfinite(value) for value in self.x + self.y):
|
||||
raise ValueError("plot series values must be finite")
|
||||
self.name = name
|
||||
self.lid = len(axis.lines)
|
||||
self.properties = {}
|
||||
axis.lines.append(self)
|
||||
|
||||
def setp(self, prop, value):
|
||||
self.properties[str(prop)] = value
|
||||
|
||||
def getp(self, prop):
|
||||
return self.properties.get(str(prop))
|
||||
|
||||
class Plot:
|
||||
def __init__(self, winTitle="plot", parent=None, flags=0):
|
||||
self.winTitle = str(winTitle)
|
||||
self.fig = _WebFigure()
|
||||
self.canvas = _WebCanvas(self.fig)
|
||||
self.axes = self.fig.add_subplot(111)
|
||||
self.axesList = [self.axes]
|
||||
self.mpl_toolbar = None
|
||||
self.series = []
|
||||
self.skip = False
|
||||
self.legend = False
|
||||
self.legPos = (1.0, 1.0)
|
||||
self.legSiz = 14
|
||||
self.grid = False
|
||||
|
||||
def plot(self, x, y, name=None):
|
||||
line = Line(self.axes, x, y, name)
|
||||
self.series.append(line)
|
||||
self.update()
|
||||
return line
|
||||
|
||||
def update(self):
|
||||
return None
|
||||
|
||||
def isGrid(self):
|
||||
return bool(self.grid)
|
||||
|
||||
def isLegend(self):
|
||||
return bool(self.legend)
|
||||
|
||||
def setActiveAxes(self, index):
|
||||
self.axes = self.axesList[index]
|
||||
|
||||
def getMainWindow():
|
||||
return None
|
||||
|
||||
def getMdiArea():
|
||||
return None
|
||||
|
||||
def getPlot():
|
||||
return _WEB_ACTIVE_PLOT
|
||||
|
||||
def closePlot():
|
||||
global _WEB_ACTIVE_PLOT
|
||||
_WEB_ACTIVE_PLOT = None
|
||||
|
||||
def figure(winTitle="plot"):
|
||||
global _WEB_ACTIVE_PLOT
|
||||
_WEB_ACTIVE_PLOT = Plot(winTitle)
|
||||
return _WEB_ACTIVE_PLOT
|
||||
|
||||
def plot(x, y, name=None):
|
||||
active = getPlot() or figure()
|
||||
return active.plot(x, y, name)
|
||||
|
||||
def series():
|
||||
active = getPlot()
|
||||
return [] if active is None else active.series
|
||||
|
||||
def removeSerie(index):
|
||||
active = getPlot()
|
||||
if active is None:
|
||||
return None
|
||||
line = active.series.pop(index)
|
||||
active.axes.lines.remove(line)
|
||||
return None
|
||||
|
||||
def legend(status=True, pos=None, fontsize=None):
|
||||
active = getPlot()
|
||||
if active is not None:
|
||||
active.legend = bool(status)
|
||||
if pos is not None:
|
||||
active.legPos = pos
|
||||
if fontsize is not None:
|
||||
active.legSiz = fontsize
|
||||
|
||||
def grid(status=True):
|
||||
active = getPlot()
|
||||
if active is not None:
|
||||
active.grid = bool(status)
|
||||
active.axes.grid(status)
|
||||
|
||||
def title(string):
|
||||
active = getPlot()
|
||||
if active is not None:
|
||||
active.axes.title = str(string)
|
||||
|
||||
def xlabel(string):
|
||||
active = getPlot()
|
||||
if active is not None:
|
||||
active.axes.xlabel = str(string)
|
||||
|
||||
def ylabel(string):
|
||||
active = getPlot()
|
||||
if active is not None:
|
||||
active.axes.ylabel = str(string)
|
||||
|
||||
def axesList():
|
||||
active = getPlot()
|
||||
return [] if active is None else active.axesList
|
||||
|
||||
def axes():
|
||||
active = getPlot()
|
||||
return None if active is None else active.axes
|
||||
|
||||
def addNewAxes(rect=None, frameon=True, patchcolor="none"):
|
||||
active = getPlot()
|
||||
if active is None:
|
||||
return None
|
||||
if rect is None:
|
||||
rect = active.axes.get_position()
|
||||
axis = active.fig.add_axes(rect, frameon)
|
||||
axis.patchcolor = patchcolor
|
||||
active.axesList.append(axis)
|
||||
active.setActiveAxes(-1)
|
||||
return axis
|
||||
|
||||
def save(path, figsize=None, dpi=None):
|
||||
active = getPlot()
|
||||
if active is None:
|
||||
return None
|
||||
old_size = active.fig.get_size_inches()
|
||||
old_dpi = active.fig.get_dpi()
|
||||
try:
|
||||
if figsize:
|
||||
active.fig.set_size_inches(figsize[0], figsize[1])
|
||||
if dpi:
|
||||
active.fig.set_dpi(dpi)
|
||||
active.canvas.print_figure(path)
|
||||
finally:
|
||||
active.fig.set_size_inches(*old_size)
|
||||
active.fig.set_dpi(old_dpi)
|
||||
|
||||
def addNavigationToolbar():
|
||||
return None
|
||||
|
||||
def delNavigationToolbar():
|
||||
return None
|
||||
|
||||
@@ -22,9 +22,11 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QFuture>
|
||||
#include <QFutureWatcher>
|
||||
#include <QtConcurrentMap>
|
||||
#ifndef FREECAD_WEB_CORE
|
||||
# include <QFuture>
|
||||
# include <QFutureWatcher>
|
||||
# include <QtConcurrentMap>
|
||||
#endif
|
||||
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Precision.hxx>
|
||||
@@ -39,7 +41,9 @@
|
||||
|
||||
|
||||
using namespace Reen;
|
||||
namespace sp = std::placeholders;
|
||||
#ifndef FREECAD_WEB_CORE
|
||||
namespace sp = std::placeholders;
|
||||
#endif
|
||||
|
||||
// SplineBasisfunction
|
||||
|
||||
@@ -1198,9 +1202,10 @@ bool BSplineParameterCorrection::SolveWithSmoothing(double fWeight)
|
||||
}
|
||||
}
|
||||
|
||||
// The product of its transform and itself results in the quadratic
|
||||
// system matrix (slowly)
|
||||
#if 0
|
||||
// The product of its transform and itself results in the quadratic
|
||||
// system matrix. Web builds use the same calculation synchronously because
|
||||
// QtConcurrent is not part of the GUI-free Qt footprint.
|
||||
#if 0
|
||||
math_Matrix MTM = M.TMultiply(M);
|
||||
#elif 0
|
||||
math_Matrix MTM(0, ulDim - 1, 0, ulDim - 1);
|
||||
@@ -1210,7 +1215,15 @@ bool BSplineParameterCorrection::SolveWithSmoothing(double fWeight)
|
||||
MTM(m, n) = MTM(n, m) = Mm * M.Col(n);
|
||||
}
|
||||
}
|
||||
#else // multi-threaded
|
||||
#elif defined(FREECAD_WEB_CORE)
|
||||
math_Matrix MTM(0, ulDim - 1, 0, ulDim - 1);
|
||||
for (unsigned m = 0; m < ulDim; m++) {
|
||||
math_Vector Mm = M.Col(m);
|
||||
for (unsigned n = m; n < ulDim; n++) {
|
||||
MTM(m, n) = MTM(n, m) = Mm * M.Col(n);
|
||||
}
|
||||
}
|
||||
#else // multi-threaded
|
||||
std::vector<int> columns(ulDim);
|
||||
std::generate(columns.begin(), columns.end(), Base::iotaGen<int>(0));
|
||||
ScalarProduct scalar(M);
|
||||
|
||||
@@ -45,7 +45,9 @@
|
||||
#include <math_Gauss.hxx>
|
||||
#include <math_Householder.hxx>
|
||||
|
||||
// Qt
|
||||
#include <QFuture>
|
||||
#include <QFutureWatcher>
|
||||
#include <QtConcurrentMap>
|
||||
// Qt
|
||||
#ifndef FREECAD_WEB_CORE
|
||||
# include <QFuture>
|
||||
# include <QFutureWatcher>
|
||||
# include <QtConcurrentMap>
|
||||
#endif
|
||||
|
||||
@@ -907,11 +907,11 @@ void SketchObject::Save(Writer& writer) const
|
||||
Part::Part2DObject::Save(writer);
|
||||
}
|
||||
|
||||
void SketchObject::Restore(XMLReader& reader)
|
||||
{
|
||||
// read the father classes
|
||||
Part::Part2DObject::Restore(reader);
|
||||
}
|
||||
void SketchObject::Restore(XMLReader& reader)
|
||||
{
|
||||
// read the father classes
|
||||
Part::Part2DObject::Restore(reader);
|
||||
}
|
||||
|
||||
void SketchObject::handleChangedPropertyType(Base::XMLReader &reader,
|
||||
const char *TypeName, App::Property *prop)
|
||||
|
||||
Reference in New Issue
Block a user