Merge branch 'main' into patch-1

This commit is contained in:
clsergent
2025-03-05 07:46:56 +01:00
committed by GitHub
22 changed files with 576 additions and 361 deletions

View File

@@ -26,8 +26,14 @@
</item>
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="tabKeyNavigation">
<bool>false</bool>
@@ -39,10 +45,10 @@
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SelectionMode::NoSelection</enum>
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
<enum>QAbstractItemView::SelectItems</enum>
</property>
<property name="showGrid">
<bool>false</bool>
@@ -60,11 +66,8 @@
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel</set>
<set>QDialogButtonBox::Cancel</set>
</property>
</widget>
</item>

View File

@@ -26,6 +26,8 @@
import FreeCAD
import FreeCADGui
from packaging.version import Version
from addonmanager_utilities import create_pip_call
translate = FreeCAD.Qt.translate
QT_TRANSLATE_NOOP = FreeCAD.Qt.QT_TRANSLATE_NOOP
@@ -49,8 +51,7 @@ class IFC_UpdateIOS:
avail = self.get_avail_version()
if avail:
if version:
comp = self.compare_versions(avail, version)
if comp > 0:
if Version(version) < Version(avail):
self.show_dialog("update", avail)
else:
self.show_dialog("uptodate")
@@ -92,6 +93,7 @@ class IFC_UpdateIOS:
if mode in ["update", "install"]:
result = self.install()
if result:
FreeCAD.Console.PrintLog(f"{result.stdout}\n")
text = translate("BIM", "IfcOpenShell update successfully installed.")
buttons = QtGui.QMessageBox.Ok
reply = QtGui.QMessageBox.information(None, title, text, buttons)
@@ -104,7 +106,7 @@ class IFC_UpdateIOS:
from PySide import QtCore, QtGui
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
vendor_path = utils.get_pip_target_directory()
args = ["install", "--disable-pip-version-check", "--target", vendor_path, "ifcopenshell"]
args = ["install", "--upgrade", "--disable-pip-version-check", "--target", vendor_path, "ifcopenshell"]
result = self.run_pip(args)
QtGui.QApplication.restoreOverrideCursor()
return result
@@ -115,14 +117,17 @@ class IFC_UpdateIOS:
import addonmanager_utilities as utils
import freecad.utils
cmd = [freecad.utils.get_python_exe(), "-m", "pip"]
cmd.extend(args)
from subprocess import CalledProcessError
cmd = create_pip_call(args)
result = None
try:
result = utils.run_interruptable_subprocess(cmd)
except:
except CalledProcessError as pe:
FreeCAD.Console.PrintError(pe.stderr)
except Exception as e:
text = translate("BIM","Unable to run pip. Please ensure pip is installed on your system.")
FreeCAD.Console.PrintError(text + "\n")
FreeCAD.Console.PrintError(f"{text} {str(e)}\n")
return result
@@ -130,19 +135,19 @@ class IFC_UpdateIOS:
"""Retrieves the current ifcopenshell version"""
import addonmanager_utilities as utils
from packaging.version import InvalidVersion
try:
import ifcopenshell
version = ifcopenshell.version
version = ifcopenshell.version
try:
Version(version)
except InvalidVersion:
FreeCAD.Console.PrintWarning(f"Invalid IfcOpenShell version: {version}\n")
version = ""
except:
version = ""
if version.startswith("v"):
# this is a pip version
vendor_path = utils.get_pip_target_directory()
result = self.run_pip(["list", "--path", vendor_path])
if result:
result = result.stdout.split()
if "ifcopenshell" in result:
version = result[result.index("ifcopenshell")+1]
return version
@@ -159,31 +164,6 @@ class IFC_UpdateIOS:
return None
def compare_versions(self, v1, v2):
"""Compare two version strings in the form '0.7.0' or v0.7.0"""
# code from https://www.geeksforgeeks.org/compare-two-version-numbers
arr1 = v1.replace("v","").split(".")
arr2 = v2.replace("v","").split(".")
n = len(arr1)
m = len(arr2)
arr1 = [int(i) for i in arr1]
arr2 = [int(i) for i in arr2]
if n > m:
for i in range(m, n):
arr2.append(0)
elif m > n:
for i in range(n, m):
arr1.append(0)
for i in range(len(arr1)):
if arr1[i] > arr2[i]:
return 1
elif arr2[i] > arr1[i]:
return -1
return 0
FreeCADGui.addCommand("IFC_UpdateIOS", IFC_UpdateIOS())

View File

@@ -158,7 +158,6 @@ class Trimex(gui_base_original.Modifier):
self.finish()
_err(translate("draft", "Trimex is not supported yet on this type of object."))
return
# self.obj.ViewObject.Visibility = False
self.obj.ViewObject.LineColor = (0.5, 0.5, 0.5)
self.obj.ViewObject.LineWidth = 1
self.extrudeMode = False
@@ -393,7 +392,7 @@ class Trimex(gui_base_original.Modifier):
newedges.append(_sh)
ghost.on()
# resetting the visible edges
# resetting the edges
if not reverse:
li = list(range(npoint + 1, len(self.edges)))
else:
@@ -584,7 +583,6 @@ class Trimex(gui_base_original.Modifier):
for g in self.ghost:
g.finalize()
if self.obj:
self.obj.ViewObject.Visibility = True
if self.color:
self.obj.ViewObject.LineColor = self.color
if self.width:

View File

@@ -366,10 +366,23 @@ void SketchObject::buildShape() {
auto egf = ExternalGeometryFacade::getFacade(geo);
if(!egf->testFlag(ExternalGeometryExtension::Defining))
continue;
auto indexedName = Data::IndexedName::fromConst("ExternalEdge", i-1);
shapes.push_back(getEdge(geo, convertSubName(indexedName, false).c_str()));
if (checkSmallEdge(shapes.back())) {
FC_WARN("Edge too small: " << indexedName);
if (geo->isDerivedFrom<Part::GeomPoint>()) {
Part::TopoShape vertex(TopoDS::Vertex(geo->toShape()));
if (!vertex.hasElementMap()) {
vertex.resetElementMap(std::make_shared<Data::ElementMap>());
}
vertex.setElementName(Data::IndexedName::fromConst("Vertex", 1),
Data::MappedName::fromRawData(convertSubName(indexedName, false).c_str()),0L);
vertices.push_back(vertex);
vertices.back().copyElementMap(vertex, Part::OpCodes::Sketch);
} else {
shapes.push_back(getEdge(geo, convertSubName(indexedName, false).c_str()));
if (checkSmallEdge(shapes.back())) {
FC_WARN("Edge too small: " << indexedName);
}
}
}

View File

@@ -41,6 +41,8 @@ CustomFolderModel::CustomFolderModel(QObject* parent)
_customFolderDirectory =
QDir(QString::fromStdString(parameterGroup->GetASCII("CustomFolder", "")));
_showOnlyFCStd = parameterGroup->GetBool("ShowOnlyFCStd", false);
}
void CustomFolderModel::loadCustomFolder()
@@ -52,6 +54,11 @@ void CustomFolderModel::loadCustomFolder()
"BaseApp/Preferences/Mod/Start/CustomFolder: cannot read custom folder %s\n",
_customFolderDirectory.absolutePath().toStdString().c_str());
}
if (_showOnlyFCStd) {
_customFolderDirectory.setNameFilters(QStringList() << QStringLiteral("*.FCStd"));
}
auto entries = _customFolderDirectory.entryList(QDir::Filter::Files | QDir::Filter::Readable,
QDir::SortFlag::Name);
for (const auto& entry : entries) {

View File

@@ -46,6 +46,7 @@ public:
private:
QDir _customFolderDirectory;
bool _showOnlyFCStd; // Show only FreeCAD files
};
} // namespace Start

View File

@@ -20,6 +20,20 @@
<string>Contents</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QLabel" name="labelShowOnlyFCStd">
<property name="text">
<string>Show only FreeCAD files in additional folder</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Show examples folder contents</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCustomFolder">
<property name="text">
@@ -27,6 +41,22 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefFileChooser" name="fileChooserCustomFolder" native="true">
<property name="toolTip">
<string>An optional custom folder to be displayed on the Start page.</string>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefEntry" stdset="0">
<cstring>CustomFolder</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefCheckBox" name="checkBoxShowExamples">
<property name="toolTip">
@@ -49,29 +79,25 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefFileChooser" name="fileChooserCustomFolder" native="true">
<item row="2" column="1">
<widget class="Gui::PrefCheckBox" name="checkBoxShowOnlyFCStd">
<property name="toolTip">
<string>An optional custom folder to be displayed on the Start page.</string>
<string>If the additional folder contents should include only .FCStd files</string>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>CustomFolder</cstring>
<cstring>ShowOnlyFCStd</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Start</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Show examples folder contents</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -53,6 +53,7 @@ void DlgStartPreferencesImp::saveSettings()
ui->fileChooserCustomFolder->onSave();
ui->checkBoxShowExamples->onSave();
ui->checkBoxCloseAfterLoading->onSave();
ui->checkBoxShowOnlyFCStd->onSave();
}
void DlgStartPreferencesImp::loadSettings()
@@ -60,6 +61,7 @@ void DlgStartPreferencesImp::loadSettings()
ui->fileChooserCustomFolder->onRestore();
ui->checkBoxShowExamples->onRestore();
ui->checkBoxCloseAfterLoading->onRestore();
ui->checkBoxShowOnlyFCStd->onRestore();
}
/**

View File

@@ -39,7 +39,7 @@ FileCardView::FileCardView(QWidget* parent)
sizePolicy.setHeightForWidth(true);
setSizePolicy(sizePolicy);
setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
setViewMode(QListView::ViewMode::IconMode);
setFlow(QListView::Flow::LeftToRight);
setResizeMode(QListView::ResizeMode::Adjust);

View File

@@ -48,6 +48,10 @@
#include <boost/graph/boyer_myrvold_planar_test.hpp>
#include <boost/graph/is_kuratowski_subgraph.hpp>
#include <boost/random.hpp>
#include <boost/thread/lock_guard.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost_regex.hpp>
// Qt