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 authored Sep 16, 2024
2 parents e92a687 + 79c6949 commit c16eb7f
Show file tree
Hide file tree
Showing 30 changed files with 272 additions and 194 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ endif()
project(FreeCAD)

set(PACKAGE_VERSION_MAJOR "1")
set(PACKAGE_VERSION_MINOR "0")
set(PACKAGE_VERSION_MINOR "1")
set(PACKAGE_VERSION_PATCH "0") # number of patch release (e.g. "4" for the 0.18.4 release)
set(PACKAGE_VERSION_SUFFIX "RC1") # either "dev" for development snapshot or "" (empty string)
set(PACKAGE_VERSION_SUFFIX "dev") # either "dev" for development snapshot or "" (empty string)
set(PACKAGE_BUILD_VERSION "0") # used when the same FreeCAD version will be re-released (for example using an updated LibPack)

set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
Expand Down
4 changes: 4 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
},
"cmakeExecutable": "${sourceDir}/conda/cmake.sh",
"cacheVariables": {
"CMAKE_IGNORE_PREFIX_PATH": {
"type": "STRING",
"value": "/opt/homebrew;/usr/local/homebrew"
},
"CMAKE_INCLUDE_PATH": {
"type": "FILEPATH",
"value": "${sourceDir}/.conda/freecad/include"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ macro(SetGlobalCompilerAndLinkerSettings)
if(FREECAD_RELEASE_PDB)
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG")
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG")
endif(FREECAD_RELEASE_PDB)
if(FREECAD_RELEASE_SEH)
# remove /EHsc or /EHs flags because they are incompatible with /EHa
Expand Down
9 changes: 7 additions & 2 deletions src/3rdParty/libE57Format/src/CheckedFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
* DEALINGS IN THE SOFTWARE.
*/

// convenience for all the BSDs
#if defined( __FreeBSD__) || defined( __NetBSD__) || defined( __OpenBSD__)
#define __BSD
#endif

#if defined( _WIN32 )
#if defined( _MSC_VER )
#include <codecvt>
Expand All @@ -44,7 +49,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#elif defined(__OpenBSD__)
#elif defined(__BSD)
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Expand Down Expand Up @@ -487,7 +492,7 @@ uint64_t CheckedFile::lseek64( int64_t offset, int whence )
#endif
#elif defined( __linux__ )
int64_t result = ::lseek64( fd_, offset, whence );
#elif defined( __APPLE__ ) || defined(__OpenBSD__)
#elif defined( __APPLE__ ) || defined(__BSD)
int64_t result = ::lseek( fd_, offset, whence );
#else
#error "no supported OS platform defined"
Expand Down
6 changes: 6 additions & 0 deletions src/App/DocumentObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ class AppExport DocumentObject: public App::TransactionalObject
/* Return true to cause PropertyView to show linked object's property */
virtual bool canLinkProperties() const {return true;}

/* Return whether this object is a link */
virtual bool isLink() const {return false;};

/* Return whether this object is a link group */
virtual bool isLinkGroup() const {return false;};

/* Return true to bypass duplicate label checking */
virtual bool allowDuplicateLabel() const {return false;}

Expand Down
62 changes: 62 additions & 0 deletions src/App/GeoFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include <App/GeoFeaturePy.h>

#include <Base/Tools.h>

#include "ComplexGeoData.h"
#include "Document.h"
#include "GeoFeature.h"
Expand Down Expand Up @@ -270,3 +272,63 @@ GeoFeature::getHigherElements(const char *element, bool silent) const
return {};
return prop->getComplexData()->getHigherElements(element, silent);
}

Base::Placement GeoFeature::getPlacementFromProp(App::DocumentObject* obj, const char* propName)
{
Base::Placement plc = Base::Placement();
auto* propPlacement = dynamic_cast<App::PropertyPlacement*>(obj->getPropertyByName(propName));
if (propPlacement) {
plc = propPlacement->getValue();
}
return plc;
}

Base::Placement GeoFeature::getGlobalPlacement(App::DocumentObject* targetObj,
App::DocumentObject* rootObj,
const std::string& sub)
{
if (!targetObj || !rootObj || sub.empty()) {
return Base::Placement();
}
std::vector<std::string> names = Base::Tools::splitSubName(sub);

App::Document* doc = rootObj->getDocument();
Base::Placement plc = getPlacementFromProp(rootObj, "Placement");

if (targetObj == rootObj) return plc;

for (auto& name : names) {
App::DocumentObject* obj = doc->getObject(name.c_str());
if (!obj) {
return Base::Placement();
}

plc = plc * getPlacementFromProp(obj, "Placement");

if (obj == targetObj) {
return plc;
}
if (obj->isLink()) {
// Update doc in case its an external link.
doc = obj->getLinkedObject()->getDocument();
}
}

// If targetObj has not been found there's a problem
return Base::Placement();
}

Base::Placement GeoFeature::getGlobalPlacement(App::DocumentObject* targetObj,
App::PropertyXLinkSub* prop)
{
if (!targetObj || !prop) {
return Base::Placement();
}

std::vector<std::string> subs = prop->getSubValues();
if (subs.empty()) {
return Base::Placement();
}

return getGlobalPlacement(targetObj, prop->getValue(), subs[0]);
}
4 changes: 4 additions & 0 deletions src/App/GeoFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ class AppExport GeoFeature : public App::DocumentObject
/// Return the higher level element names of the given element
virtual std::vector<Data::IndexedName> getHigherElements(const char *name, bool silent=false) const;

static Base::Placement getPlacementFromProp(DocumentObject* obj, const char* propName);
static Base::Placement getGlobalPlacement(DocumentObject* targetObj, DocumentObject* rootObj, const std::string& sub);
static Base::Placement getGlobalPlacement(DocumentObject* targetObj, PropertyXLinkSub* prop);

protected:
void onChanged(const Property* prop) override;
// void onDocumentRestored() override;
Expand Down
15 changes: 15 additions & 0 deletions src/App/Link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,16 @@ bool Link::canLinkProperties() const {
return true;
}

bool Link::isLink() const
{
return ElementCount.getValue() == 0;
}

bool Link::isLinkGroup() const
{
return ElementCount.getValue() > 0;
}

//////////////////////////////////////////////////////////////////////////////////////////

namespace App {
Expand Down Expand Up @@ -2309,6 +2319,11 @@ bool LinkElement::canDelete() const {
return !owner || !owner->getDocument()->getObjectByID(_LinkOwner.getValue());
}

bool LinkElement::isLink() const
{
return true;
}

App::Link* LinkElement::getLinkGroup() const
{
std::vector<App::DocumentObject*> inList = getInList();
Expand Down
6 changes: 6 additions & 0 deletions src/App/Link.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ class AppExport Link : public App::DocumentObject, public App::LinkExtension
}

bool canLinkProperties() const override;

bool isLink() const override;

bool isLinkGroup() const override;
};

using LinkPython = App::FeaturePythonT<Link>;
Expand Down Expand Up @@ -600,6 +604,8 @@ class AppExport LinkElement : public App::DocumentObject, public App::LinkBaseEx
_handleChangedPropertyName(reader,TypeName,PropName);
}

bool isLink() const override;

App::Link* getLinkGroup() const;
};

Expand Down
2 changes: 1 addition & 1 deletion src/Base/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#endif

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

#include "Parameter.h"
#include "Parameter.inl"
Expand Down
21 changes: 21 additions & 0 deletions src/Base/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,24 @@ std::string Base::Tools::currentDateTimeString()
.toString(Qt::ISODate)
.toStdString();
}

std::vector<std::string> Base::Tools::splitSubName(const std::string& subname)
{
// Turns 'Part.Part001.Body.Pad.Edge1'
// Into ['Part', 'Part001', 'Body', 'Pad', 'Edge1']
std::vector<std::string> subNames;
std::string subName;
std::istringstream subNameStream(subname);
while (std::getline(subNameStream, subName, '.')) {
subNames.push_back(subName);
}

// Check if the last character of the input string is the delimiter.
// If so, add an empty string to the subNames vector.
// Because the last subname is the element name and can be empty.
if (!subname.empty() && subname.back() == '.') {
subNames.push_back(""); // Append empty string for trailing dot.
}

return subNames;
}
2 changes: 2 additions & 0 deletions src/Base/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ struct BaseExport Tools
static std::string joinList(const std::vector<std::string>& vec, const std::string& sep = ", ");

static std::string currentDateTimeString();

static std::vector<std::string> splitSubName(const std::string& subname);
};


Expand Down
31 changes: 31 additions & 0 deletions src/Gui/BitmapFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class BitmapFactoryInstP
public:
QMap<std::string, const char**> xpmMap;
QMap<std::string, QPixmap> xpmCache;

bool useIconTheme;
};
}

Expand Down Expand Up @@ -93,7 +95,9 @@ void BitmapFactoryInst::destruct ()
BitmapFactoryInst::BitmapFactoryInst()
{
d = new BitmapFactoryInstP;

restoreCustomPaths();
configureUseIconTheme();
}

BitmapFactoryInst::~BitmapFactoryInst()
Expand All @@ -111,6 +115,14 @@ void BitmapFactoryInst::restoreCustomPaths()
}
}

void Gui::BitmapFactoryInst::configureUseIconTheme()
{
Base::Reference<ParameterGrp> group = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Bitmaps/Theme");

d->useIconTheme = group->GetBool("UseIconTheme", group->GetBool("ThemeSearchPaths", false));
}

void BitmapFactoryInst::addPath(const QString& path)
{
QDir::addSearchPath(QString::fromLatin1("icons"), path);
Expand Down Expand Up @@ -174,6 +186,10 @@ bool BitmapFactoryInst::findPixmapInCache(const char* name, QPixmap& px) const

QIcon BitmapFactoryInst::iconFromTheme(const char* name, const QIcon& fallback)
{
if (!d->useIconTheme) {
return iconFromDefaultTheme(name, fallback);
}

QString iconName = QString::fromUtf8(name);
QIcon icon = QIcon::fromTheme(iconName, fallback);
if (icon.isNull()) {
Expand Down Expand Up @@ -206,6 +222,21 @@ bool BitmapFactoryInst::loadPixmap(const QString& filename, QPixmap& icon) const
return !icon.isNull();
}

QIcon Gui::BitmapFactoryInst::iconFromDefaultTheme(const char* name, const QIcon& fallback)
{
QIcon icon;
QPixmap px = pixmap(name);

if (!px.isNull()) {
icon.addPixmap(px);
return icon;
} else {
return fallback;
}

return icon;
}

QPixmap BitmapFactoryInst::pixmap(const char* name) const
{
if (!name || *name == '\0')
Expand Down
5 changes: 5 additions & 0 deletions src/Gui/BitmapFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class GuiExport BitmapFactoryInst : public Base::Factory
* If no such icon is found in the current theme fallback is returned instead.
*/
QIcon iconFromTheme(const char* name, const QIcon& fallback = QIcon());
/** Returns the QIcon corresponding to name in the default (FreeCAD's) icon theme.
* If no such icon is found in the current theme fallback is returned instead.
*/
QIcon iconFromDefaultTheme(const char* name, const QIcon& fallback = QIcon());
/// Retrieves a pixmap by name
QPixmap pixmap(const char* name) const;
/** Retrieves a pixmap by name and size created by an
Expand Down Expand Up @@ -150,6 +154,7 @@ class GuiExport BitmapFactoryInst : public Base::Factory
private:
bool loadPixmap(const QString& path, QPixmap&) const;
void restoreCustomPaths();
void configureUseIconTheme();

static BitmapFactoryInst* _pcSingleton;
BitmapFactoryInst();
Expand Down
1 change: 1 addition & 0 deletions src/Gui/Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "PreCompiled.h"

#ifndef _PreComp_
# include <array>
# include <boost/algorithm/string/predicate.hpp>
# include <QApplication>
#endif
Expand Down
10 changes: 7 additions & 3 deletions src/Gui/SoFCCSysDragger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ TDragger::TDragger()
{
SO_KIT_CONSTRUCTOR(TDragger);

#if defined(Q_OS_MACOS)
#if defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
this->ref();
#endif

Expand Down Expand Up @@ -400,7 +400,7 @@ void TPlanarDragger::initClass()
TPlanarDragger::TPlanarDragger()
{
SO_KIT_CONSTRUCTOR(TPlanarDragger);
#if defined(Q_OS_MACOS)
#if defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
this->ref();
#endif

Expand Down Expand Up @@ -698,7 +698,7 @@ void RDragger::initClass()
RDragger::RDragger()
{
SO_KIT_CONSTRUCTOR(RDragger);
#if defined(Q_OS_MACOS)
#if defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
this->ref();
#endif

Expand Down Expand Up @@ -1008,6 +1008,10 @@ SoFCCSysDragger::SoFCCSysDragger()
{
SO_KIT_CONSTRUCTOR(SoFCCSysDragger);

#if defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
this->ref();
#endif

SO_KIT_ADD_CATALOG_ENTRY(annotation, So3DAnnotation, TRUE, geomSeparator, "", TRUE);
SO_KIT_ADD_CATALOG_ENTRY(scaleNode, SoScale, TRUE, annotation, "", TRUE);

Expand Down
7 changes: 1 addition & 6 deletions src/Gui/StartupProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,8 @@ void StartupProcess::setThemePaths()
QIcon::setThemeSearchPaths(searchPaths);
}

// KDE file dialog needs icons from the desktop theme
QIcon::setFallbackThemeName(QIcon::themeName());

std::string name = hTheme->GetASCII("Name");
if (name.empty()) {
QIcon::setThemeName(QLatin1String("FreeCAD-default"));
} else {
if (!name.empty()) {
QIcon::setThemeName(QString::fromLatin1(name.c_str()));
}
}
Expand Down
Loading

0 comments on commit c16eb7f

Please sign in to comment.