Skip to content

Commit

Permalink
Merge branch 'FreeCAD:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sasobadovinac committed Apr 4, 2024
2 parents c46053b + 252707a commit ac451e1
Show file tree
Hide file tree
Showing 60 changed files with 1,475 additions and 117 deletions.
17 changes: 8 additions & 9 deletions src/Base/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#endif

#include <boost/algorithm/string.hpp>
#include "fmt/printf.h"

#include "Parameter.h"
#include "Parameter.inl"
Expand Down Expand Up @@ -805,9 +806,8 @@ long ParameterGrp::GetInt(const char* Name, long lPreset) const

void ParameterGrp::SetInt(const char* Name, long lValue)
{
char cBuf[256];
sprintf(cBuf, "%li", lValue);
_SetAttribute(ParamType::FCInt, Name, cBuf);
std::string buf = fmt::sprintf("%li", lValue);

Check warning on line 809 in src/Base/Parameter.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

Never use sprintf. Use snprintf instead. [runtime/printf] [5]
_SetAttribute(ParamType::FCInt, Name, buf.c_str());
}

std::vector<long> ParameterGrp::GetInts(const char* sFilter) const
Expand Down Expand Up @@ -875,9 +875,8 @@ unsigned long ParameterGrp::GetUnsigned(const char* Name, unsigned long lPreset)

void ParameterGrp::SetUnsigned(const char* Name, unsigned long lValue)
{
char cBuf[256];
sprintf(cBuf, "%lu", lValue);
_SetAttribute(ParamType::FCUInt, Name, cBuf);
std::string buf = fmt::sprintf("%lu", lValue);

Check warning on line 878 in src/Base/Parameter.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

Never use sprintf. Use snprintf instead. [runtime/printf] [5]
_SetAttribute(ParamType::FCUInt, Name, buf.c_str());
}

std::vector<unsigned long> ParameterGrp::GetUnsigneds(const char* sFilter) const
Expand Down Expand Up @@ -950,9 +949,9 @@ double ParameterGrp::GetFloat(const char* Name, double dPreset) const

void ParameterGrp::SetFloat(const char* Name, double dValue)
{
char cBuf[256];
sprintf(cBuf, "%.12f", dValue); // use %.12f instead of %f to handle values < 1.0e-6
_SetAttribute(ParamType::FCFloat, Name, cBuf);
// use %.12f instead of %f to handle values < 1.0e-6
std::string buf = fmt::sprintf("%.12f", dValue);
_SetAttribute(ParamType::FCFloat, Name, buf.c_str());
}

std::vector<double> ParameterGrp::GetFloats(const char* sFilter) const
Expand Down
23 changes: 14 additions & 9 deletions src/Ext/freecad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ else()
endif()

configure_file(__init__.py.template ${NAMESPACE_INIT})
configure_file(project_utility.py ${NAMESPACE_DIR}/project_utility.py)
configure_file(UiTools.py ${NAMESPACE_DIR}/UiTools.py)
configure_file(utils.py ${NAMESPACE_DIR}/utils.py)

set(EXT_FILES
part.py
partdesign.py
project_utility.py
sketcher.py
UiTools.py
utils.py
)

foreach (it ${EXT_FILES})
configure_file(${it} ${NAMESPACE_DIR}/${it})
endforeach()

if (INSTALL_TO_SITEPACKAGES)
SET(SITE_PACKAGE_DIR ${PYTHON_MAIN_DIR}/freecad)
Expand All @@ -38,12 +48,7 @@ endif()
INSTALL(
FILES
${NAMESPACE_INIT}
part.py
partdesign.py
sketcher.py
project_utility.py
UiTools.py
utils.py
${EXT_FILES}
DESTINATION
${SITE_PACKAGE_DIR}
)
3 changes: 1 addition & 2 deletions src/Gui/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,7 @@ void Application::createStandardOperations()
void Application::slotNewDocument(const App::Document& Doc, bool isMainDoc)
{
#ifdef FC_DEBUG
std::map<const App::Document*, Gui::Document*>::const_iterator it = d->documents.find(&Doc);
assert(it==d->documents.end());
assert(d->documents.find(&Doc) == d->documents.end());
#endif
auto pDoc = new Gui::Document(const_cast<App::Document*>(&Doc),this);
d->documents[&Doc] = pDoc;
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DocumentPy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ obj : Gui.ViewProvider</UserDocu>
</Documentation>
<Parameter Name="Transacting" Type="Boolean" />
</Attribute>
<Attribute Name="Modified" ReadOnly="true">
<Attribute Name="Modified">
<Documentation>
<UserDocu>Returns True if the document is marked as modified, and False otherwise.</UserDocu>
</Documentation>
Expand Down
5 changes: 5 additions & 0 deletions src/Gui/DocumentPyImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ Py::Boolean DocumentPy::getModified() const
return {getDocumentPtr()->isModified()};
}

void DocumentPy::setModified(Py::Boolean arg)
{
getDocumentPtr()->setModified(arg);
}

PyObject *DocumentPy::getCustomAttributes(const char* attr) const
{
// Note: Here we want to return only a document object if its
Expand Down
10 changes: 5 additions & 5 deletions src/Gui/WorkbenchSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void WorkbenchComboBox::refreshList(QList<QAction*> actionList)
}


WorkbenchTabWidget::WorkbenchTabWidget(WorkbenchGroup* aGroup, QWidget* parent)
WorkbenchTabWidget::WorkbenchTabWidget(WorkbenchGroup* aGroup, QWidget* parent)
: QTabBar(parent)
, wbActionGroup(aGroup)
{
Expand All @@ -124,7 +124,7 @@ WorkbenchTabWidget::WorkbenchTabWidget(WorkbenchGroup* aGroup, QWidget* parent)
});

if (parent->inherits("QToolBar")) {
// set the initial orientation. We cannot do updateLayoutAndTabOrientation(false);
// set the initial orientation. We cannot do updateLayoutAndTabOrientation(false);
// because on init the toolbar area is always TopToolBarArea.
ParameterGrp::handle hGrp;
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
Expand All @@ -145,7 +145,7 @@ WorkbenchTabWidget::WorkbenchTabWidget(WorkbenchGroup* aGroup, QWidget* parent)
refreshList(aGroup->getEnabledWbActions());
connect(aGroup, &WorkbenchGroup::workbenchListRefreshed, this, &WorkbenchTabWidget::refreshList);
connect(aGroup->groupAction(), &QActionGroup::triggered, this, [this, aGroup](QAction* action) {
int index = std::min(aGroup->actions().indexOf(action), this->count() - 1);
int index = std::min<int>(aGroup->actions().indexOf(action), this->count() - 1);
setCurrentIndex(index);
});
connect(this, qOverload<int>(&QTabBar::tabBarClicked), aGroup, [aGroup, moreAction](int index) {
Expand Down Expand Up @@ -202,7 +202,7 @@ void WorkbenchTabWidget::refreshList(QList<QAction*> actionList)
else {
addTab(icon, tr("More"));
}

buildPrefMenu();
}

Expand Down Expand Up @@ -238,7 +238,7 @@ void WorkbenchTabWidget::buildPrefMenu()
menu->addSeparator();

QAction* preferencesAction = menu->addAction(tr("Preferences"));
connect(preferencesAction, &QAction::triggered, this, [this]() {
connect(preferencesAction, &QAction::triggered, this, []() {
Gui::Dialog::DlgPreferencesImp cDlg(getMainWindow());
cDlg.activateGroupPage(QString::fromUtf8("Workbenches"), 0);
cDlg.exec();
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Arch/ArchCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def addComponents(objectsList,host):
if hostType in ["Floor","Building","Site","Project","BuildingPart"]:
for o in objectsList:
host.addObject(o)
elif hostType in ["Wall","Structure","Precast","Window","Roof","Stairs","StructuralSystem","Panel","Component"]:
elif hostType in ["Wall","Structure","Precast","Window","Roof","Stairs","StructuralSystem","Panel","Component","Pipe"]:

Check warning on line 101 in src/Mod/Arch/ArchCommands.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (123/100) (line-too-long)
import DraftGeomUtils
a = host.Additions
if hasattr(host,"Axes"):
Expand Down Expand Up @@ -142,7 +142,7 @@ def removeComponents(objectsList,host=None):
if not isinstance(objectsList,list):
objectsList = [objectsList]
if host:
if Draft.getType(host) in ["Wall","Structure","Precast","Window","Roof","Stairs","StructuralSystem","Panel","Component"]:
if Draft.getType(host) in ["Wall","Structure","Precast","Window","Roof","Stairs","StructuralSystem","Panel","Component","Pipe"]:

Check warning on line 145 in src/Mod/Arch/ArchCommands.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (136/100) (line-too-long)
if hasattr(host,"Tool"):
if objectsList[0] == host.Tool:
host.Tool = None
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def execute(self,obj):
sh = shapes[0]
else:
sh = Part.makeCompound(shapes)
obj.Shape = sh
obj.Shape = self.processSubShapes(obj,sh,pl)
if obj.Base:
obj.Length = w.Length
else:
Expand Down
32 changes: 29 additions & 3 deletions src/Mod/Arch/ArchRoof.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,39 @@ def getSubVolume(self, obj):
return None

if obj.Base.Shape.Solids:
return obj.Shape
# For roof created from Base object as solids:
# Not only the solid of the base object itself be subtracted from
# a Wall, but all portion of the wall above the roof solid would be
# subtracted as well.
#

Check warning on line 848 in src/Mod/Arch/ArchRoof.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

# <-- trailing whitespace
# FC forum discussion : Sketch based Arch_Roof and wall substraction
# - https://forum.freecad.org/viewtopic.php?t=84389
#

Check warning on line 851 in src/Mod/Arch/ArchRoof.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

# <-- trailing whitespace
faces = []
solids = []
for f in obj.Base.Shape.Faces: # obj.Base.Shape.Solids.Faces
p = f.findPlane() # Curve face (surface) seems return no Plane
if p:
if p.Axis[2] < 0: # z<0, i.e. normal pointing below horizon
faces.append(f)
else:
# Not sure if it is pointing towards and/or above horizon
# (upward or downward), or it is curve surface, just add.
faces.append(f)

# Attempt to find normal at non-planar face to verify if
# it is pointing downward, but cannot conclude even all test
# points happens to be pointing upward. So add in any rate.

for f in faces:
solid = f.extrude(Vector(0.0, 0.0, 1000000.0))
solids.append(solid)
compound = Part.Compound(solids)
return compound

# self.sub is auto-generated subvolume for wire-based roof
sub_field = getattr(self, 'sub', None)
if not sub_field:
self.execute(obj)

return self.sub


Expand Down
7 changes: 6 additions & 1 deletion src/Mod/Arch/ArchWall.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,10 @@ def getExtrusionData(self,obj):
if not height:
return None
if obj.Normal == Vector(0,0,0):
normal = Vector(0,0,1)
import DraftGeomUtils
normal = DraftGeomUtils.get_shape_normal(obj.Base.Shape)
if normal == None:
normal = Vector(0,0,1)
else:
normal = Vector(obj.Normal)
base = None
Expand Down Expand Up @@ -1275,8 +1278,10 @@ def getExtrusionData(self,obj):

# If the object is a single edge, use that as the
# basewires.

# TODO 2023.11.26: Need to check if it isn't Sketch after all first
# or use algorithm for Sketch altogether?

elif len(obj.Base.Shape.Edges) == 1:
self.basewires = [Part.Wire(obj.Base.Shape.Edges)]

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/importIFCHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def getColorFromStyledItem(styled_item):
# this is an error in the IFC file in my opinion
else:
# never seen an ifc with more than one Styles in IfcStyledItem
# the above seams to only apply for IFC2x3, IFC4 can have them
# the above seems to only apply for IFC2x3, IFC4 can have them
# see https://forum.freecad.org/viewtopic.php?f=39&t=33560&p=437056#p437056

# Get the `IfcPresentationStyleAssignment`, there should only be one,
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/CAM/Gui/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CmdPathArea::CmdPathArea()
:Command("CAM_Area")
{
sAppModule = "Path";
sGroup = QT_TR_NOOP("Path");
sGroup = QT_TR_NOOP("CAM");
sMenuText = QT_TR_NOOP("Area");
sToolTipText = QT_TR_NOOP("Creates a feature area from selected objects");
sWhatsThis = "CAM_Area";
Expand Down Expand Up @@ -125,7 +125,7 @@ CmdPathAreaWorkplane::CmdPathAreaWorkplane()
:Command("CAM_Area_Workplane")
{
sAppModule = "Path";
sGroup = QT_TR_NOOP("Path");
sGroup = QT_TR_NOOP("CAM");
sMenuText = QT_TR_NOOP("Area workplane");
sToolTipText = QT_TR_NOOP("Select a workplane for a FeatureArea");
sWhatsThis = "CAM_Area_Workplane";
Expand Down Expand Up @@ -215,7 +215,7 @@ CmdPathCompound::CmdPathCompound()
:Command("CAM_Compound")
{
sAppModule = "Path";
sGroup = QT_TR_NOOP("Path");
sGroup = QT_TR_NOOP("CAM");
sMenuText = QT_TR_NOOP("Compound");
sToolTipText = QT_TR_NOOP("Creates a compound from selected toolpaths");
sWhatsThis = "CAM_Compound";
Expand Down Expand Up @@ -267,7 +267,7 @@ CmdPathShape::CmdPathShape()
:Command("CAM_Shape")
{
sAppModule = "Path";
sGroup = QT_TR_NOOP("Path");
sGroup = QT_TR_NOOP("CAM");
sMenuText = QT_TR_NOOP("From Shape");
sToolTipText = QT_TR_NOOP("Creates a toolpath from a selected shape");
sWhatsThis = "CAM_Shape";
Expand Down
11 changes: 11 additions & 0 deletions src/Mod/CAM/Gui/Resources/panels/PageOpDrillingEdit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="feedRetractEnabled">
<property name="text">
<string>Feed retract</string>
</property>
<property name="toolTip">
<string>G85: Retract from the hole at the given feedrate instead of rapid move</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
Expand Down Expand Up @@ -197,6 +207,7 @@
<tabstops>
<tabstop>toolController</tabstop>
<tabstop>peckEnabled</tabstop>
<tabstop>feedRetractEnabled</tabstop>
<tabstop>dwellEnabled</tabstop>
</tabstops>
<resources/>
Expand Down
17 changes: 17 additions & 0 deletions src/Mod/CAM/Init.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@
# * *
# ***************************************************************************

# This code handles parameter groups following the CAM workbench renaming
# (PATH -> CAM). This code can be removed after the 1.0 release.


ParGrp = App.ParamGet("System parameter:Modules").GetGroup("Path")
if ParGrp.HasGroup("CAM"):
pass
elif ParGrp.HasGroup("Path"):
ParGrp.RenameGroup("Path", "CAM")

ParGrp = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
parent = ParGrp.Parent()
if parent.HasGroup("CAM"):
pass
elif parent.HasGroup("Path"):
result = parent.RenameGroup("Path", "CAM")

# Get the Parameter Group of this module
ParGrp = App.ParamGet("System parameter:Modules").GetGroup("Path")

Expand Down
17 changes: 15 additions & 2 deletions src/Mod/CAM/Path/Base/Generator/drill.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@


def generate(
edge, dwelltime=0.0, peckdepth=0.0, repeat=1, retractheight=None, chipBreak=False
edge, dwelltime=0.0, peckdepth=0.0, repeat=1, retractheight=None, chipBreak=False, feedRetract=False
):
"""
Generates Gcode for drilling a single hole.
Expand All @@ -59,6 +59,11 @@ def generate(
full retracts to clear chips from the hole.
http://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g73
If feedRetract is True, the generator will produce G85 cycles which retract
the tool at the specified feed rate instead of performing a rapid move.
This is useful for boring or reaming operations. Peck or dwell cannot be used with feed retract.
http://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g85
"""
startPoint = edge.Vertexes[0].Point
endPoint = edge.Vertexes[1].Point
Expand All @@ -73,6 +78,12 @@ def generate(
if dwelltime > 0.0 and peckdepth > 0.0:
raise ValueError("Peck and Dwell cannot be used together")

if dwelltime > 0.0 and feedRetract:
raise ValueError("Dwell and feed retract cannot be used together")

if peckdepth > 0.0 and feedRetract:
raise ValueError("Peck and feed retract cannot be used together")

if repeat < 1:
raise ValueError("repeat must be 1 or greater")

Expand Down Expand Up @@ -112,7 +123,9 @@ def generate(
if repeat > 1:
cmdParams["L"] = repeat

if peckdepth == 0.0:
if feedRetract:
cmd = "G85"
elif peckdepth == 0.0:
if dwelltime > 0.0:
cmd = "G82"
cmdParams["P"] = dwelltime
Expand Down
Loading

0 comments on commit ac451e1

Please sign in to comment.