From 458e2727d23acd0abf71abbd8faf6c5332a7d6f4 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 23 May 2024 09:20:33 +0200 Subject: [PATCH] BIM: Fixed more wrong resource loading - #14210 --- src/Mod/BIM/BimStatusBar.py | 4 +-- src/Mod/BIM/CMakeLists.txt | 1 - src/Mod/BIM/bimcommands/BimLibrary.py | 18 ++--------- src/Mod/BIM/bimcommands/BimMaterial.py | 4 +-- src/Mod/BIM/bimcommands/BimPreflight.py | 4 +-- src/Mod/BIM/bimcommands/BimProjectManager.py | 12 ++++--- src/Mod/BIM/bimcommands/BimTrash.py | 2 +- src/Mod/BIM/nativeifc/ifc_preferences.py | 34 -------------------- 8 files changed, 13 insertions(+), 66 deletions(-) delete mode 100644 src/Mod/BIM/nativeifc/ifc_preferences.py diff --git a/src/Mod/BIM/BimStatusBar.py b/src/Mod/BIM/BimStatusBar.py index f0f3d33554..e9f329cc48 100644 --- a/src/Mod/BIM/BimStatusBar.py +++ b/src/Mod/BIM/BimStatusBar.py @@ -74,9 +74,7 @@ def setStatusIcons(show=True): utext = action.text().replace("&", "") if utext == nudgeLabelsM[0]: # load dialog - form = FreeCADGui.PySideUic.loadUi( - os.path.join(os.path.dirname(__file__), "dialogNudgeValue.ui") - ) + form = FreeCADGui.PySideUic.loadUi(":/ui/dialogNudgeValue.ui") # center the dialog over FreeCAD window mw = FreeCADGui.getMainWindow() form.move( diff --git a/src/Mod/BIM/CMakeLists.txt b/src/Mod/BIM/CMakeLists.txt index d9e3cf3665..68ee02c0c7 100644 --- a/src/Mod/BIM/CMakeLists.txt +++ b/src/Mod/BIM/CMakeLists.txt @@ -178,7 +178,6 @@ SET(nativeifc_SRCS nativeifc/ifc_objects.py nativeifc/ifc_observer.py nativeifc/ifc_performance_test.py - nativeifc/ifc_preferences.py nativeifc/ifc_psets.py nativeifc/ifc_selftest.py nativeifc/ifc_status.py diff --git a/src/Mod/BIM/bimcommands/BimLibrary.py b/src/Mod/BIM/bimcommands/BimLibrary.py index 548017d5f2..e0f6846854 100644 --- a/src/Mod/BIM/bimcommands/BimLibrary.py +++ b/src/Mod/BIM/bimcommands/BimLibrary.py @@ -399,23 +399,9 @@ class BIM_Library_TaskPanel: if f.endswith(".fcstd"): it.setIcon(QtGui.QIcon(":icons/freecad-doc.png")) elif f.endswith(".ifc"): - it.setIcon( - QtGui.QIcon( - os.path.join( - os.path.dirname(__file__), "icons", "IFC.svg" - ) - ) - ) + it.setIcon(QtGui.QIcon(":/icons/IFC.svg")) else: - it.setIcon( - QtGui.QIcon( - os.path.join( - os.path.dirname(__file__), - "icons", - "Part_document.svg", - ) - ) - ) + it.setIcon(QtGui.QIcon(":/icons/Part_document.svg")) self.modelmode = 0 def getFilters(self): diff --git a/src/Mod/BIM/bimcommands/BimMaterial.py b/src/Mod/BIM/bimcommands/BimMaterial.py index cabf38bfa9..9b4504842d 100644 --- a/src/Mod/BIM/bimcommands/BimMaterial.py +++ b/src/Mod/BIM/bimcommands/BimMaterial.py @@ -341,9 +341,7 @@ class BIM_Material: if item: oldmat = FreeCAD.ActiveDocument.getObject(item.toolTip()) # load dialog - form = FreeCADGui.PySideUic.loadUi( - os.path.join(os.path.dirname(__file__), "dialogListWidget.ui") - ) + form = FreeCADGui.PySideUic.loadUi(":/ui/dialogListWidget.ui") # center the dialog over FreeCAD window mw = FreeCADGui.getMainWindow() form.move( diff --git a/src/Mod/BIM/bimcommands/BimPreflight.py b/src/Mod/BIM/bimcommands/BimPreflight.py index 9e3434217c..ce87ea2a2d 100644 --- a/src/Mod/BIM/bimcommands/BimPreflight.py +++ b/src/Mod/BIM/bimcommands/BimPreflight.py @@ -205,9 +205,7 @@ class BIM_Preflight_TaskPanel: for c in self.culprits[test]: FreeCADGui.Selection.addSelection(c) if not self.rform: - self.rform = FreeCADGui.PySideUic.loadUi( - os.path.join(os.path.dirname(__file__), "dialogPreflightResults.ui") - ) + self.rform = FreeCADGui.PySideUic.loadUi(":/ui/dialogPreflightResults.ui") # center the dialog over FreeCAD window mw = FreeCADGui.getMainWindow() self.rform.move( diff --git a/src/Mod/BIM/bimcommands/BimProjectManager.py b/src/Mod/BIM/bimcommands/BimProjectManager.py index 472f9263aa..6e17092c4f 100644 --- a/src/Mod/BIM/bimcommands/BimProjectManager.py +++ b/src/Mod/BIM/bimcommands/BimProjectManager.py @@ -130,14 +130,16 @@ class BIM_ProjectManager: ).Value human = None if self.form.addHumanFigure.isChecked(): - humanshape = Part.Shape() + # TODO ; fix loading of human shape humanpath = os.path.join( os.path.dirname(__file__), "geometry", "human figure.brep" ) - humanshape.importBrep(humanpath) - human = FreeCAD.ActiveDocument.addObject("Part::Feature", "Human") - human.Shape = humanshape - human.Placement.move(FreeCAD.Vector(500, 500, 0)) + if os.path.exists(humanpath): + humanshape = Part.Shape() + humanshape.importBrep(humanpath) + human = FreeCAD.ActiveDocument.addObject("Part::Feature", "Human") + human.Shape = humanshape + human.Placement.move(FreeCAD.Vector(500, 500, 0)) if self.form.groupBuilding.isChecked(): building = Arch.makeBuilding() if site: diff --git a/src/Mod/BIM/bimcommands/BimTrash.py b/src/Mod/BIM/bimcommands/BimTrash.py index dcc41318c7..88759b55ce 100644 --- a/src/Mod/BIM/bimcommands/BimTrash.py +++ b/src/Mod/BIM/bimcommands/BimTrash.py @@ -75,7 +75,7 @@ FreeCADGui.addCommand("BIM_Trash", BIM_Trash()) class BIM_EmptyTrash: def GetResources(self): return { - "Pixmap": os.path.join(os.path.dirname(__file__), "icons", "BIM_Trash.svg"), + "Pixmap": "BIM_Trash", "MenuText": QT_TRANSLATE_NOOP("BIM_EmptyTrash", "Clean Trash"), "ToolTip": QT_TRANSLATE_NOOP( "BIM_EmptyTrash", diff --git a/src/Mod/BIM/nativeifc/ifc_preferences.py b/src/Mod/BIM/nativeifc/ifc_preferences.py deleted file mode 100644 index 29c2e4e8d0..0000000000 --- a/src/Mod/BIM/nativeifc/ifc_preferences.py +++ /dev/null @@ -1,34 +0,0 @@ -# *************************************************************************** -# * * -# * Copyright (c) 2022 Yorik van Havre * -# * * -# * This program is free software; you can redistribute it and/or modify * -# * it under the terms of the GNU General Public License (GPL) * -# * as published by the Free Software Foundation; either version 3 of * -# * the License, or (at your option) any later version. * -# * for detail see the LICENCE text file. * -# * * -# * This program is distributed in the hope that it will be useful, * -# * but WITHOUT ANY WARRANTY; without even the implied warranty of * -# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -# * GNU General Public License for more details. * -# * * -# * You should have received a copy of the GNU Library General Public * -# * License along with this program; if not, write to the Free Software * -# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -# * USA * -# * * -# *************************************************************************** - -import os -import FreeCADGui -from PySide.QtCore import QT_TRANSLATE_NOOP - -"""Helper for InitGui""" - - -def add_preferences_page(): - """Adds the NativeIFC preferences page""" - page = os.path.join(os.path.dirname(__file__), "ui", "preferencesNativeIFC.ui") - category = QT_TRANSLATE_NOOP("NativeIFC", "Import-Export") - FreeCADGui.addPreferencePage(page, category)