From 7bf6f72259b4d5b585f35766434a74a2d1d78af7 Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Sun, 27 Sep 2020 22:56:48 -0500 Subject: [PATCH] Surface: new SVG icon for the workbench, rename others Replace the hard-coded XPM icon in `InitGui.py` for the workbench with an SVG file, which at this time is identical to the `Surface` icon. Change `CMakeLists.txt` to properly install this new icon. Rename all icons, so that all have the `Surface_` prefix. Use the new icon names in the viewproviders and task panels. --- src/Mod/Surface/Gui/CMakeLists.txt | 12 +- src/Mod/Surface/Gui/Command.cpp | 2 +- src/Mod/Surface/Gui/Resources/Surface.qrc | 15 +- ...ineSurf.svg => Surface_BSplineSurface.svg} | 0 ...{BezSurf.svg => Surface_BezierSurface.svg} | 0 .../icons/{Sewing.svg => Surface_Sewing.svg} | 0 .../{Surface.svg => Surface_Surface.svg} | 0 .../Gui/Resources/icons/Surface_Workbench.svg | 281 ++++++++++++++++++ src/Mod/Surface/Gui/TaskFilling.cpp | 6 +- src/Mod/Surface/Gui/TaskGeomFillSurface.cpp | 4 +- src/Mod/Surface/Gui/TaskSections.cpp | 2 +- src/Mod/Surface/InitGui.py | 118 +++----- 12 files changed, 346 insertions(+), 94 deletions(-) rename src/Mod/Surface/Gui/Resources/icons/{BSplineSurf.svg => Surface_BSplineSurface.svg} (100%) rename src/Mod/Surface/Gui/Resources/icons/{BezSurf.svg => Surface_BezierSurface.svg} (100%) rename src/Mod/Surface/Gui/Resources/icons/{Sewing.svg => Surface_Sewing.svg} (100%) rename src/Mod/Surface/Gui/Resources/icons/{Surface.svg => Surface_Surface.svg} (100%) create mode 100644 src/Mod/Surface/Gui/Resources/icons/Surface_Workbench.svg diff --git a/src/Mod/Surface/Gui/CMakeLists.txt b/src/Mod/Surface/Gui/CMakeLists.txt index c09ff9601a18..cfef5bbede2d 100644 --- a/src/Mod/Surface/Gui/CMakeLists.txt +++ b/src/Mod/Surface/Gui/CMakeLists.txt @@ -76,11 +76,19 @@ SET(SurfaceGui_SRCS # ViewProviderCut.h ) +SET(SurfaceGuiIcon_SVG + Resources/icons/Surface_Workbench.svg +) + link_directories(${OCC_LIBRARY_DIR}) -add_library(SurfaceGui SHARED ${SurfaceGui_SRCS}) +add_library(SurfaceGui SHARED ${SurfaceGui_SRCS} ${SurfaceGuiIcon_SVG}) target_link_libraries(SurfaceGui ${SurfaceGui_LIBS}) SET_BIN_DIR(SurfaceGui SurfaceGui /Mod/Surface) SET_PYTHON_PREFIX_SUFFIX(SurfaceGui) - + +fc_copy_sources(SurfaceGui "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Surface" ${SurfaceGuiIcon_SVG}) + install(TARGETS SurfaceGui DESTINATION ${CMAKE_INSTALL_LIBDIR}) +INSTALL(FILES ${SurfaceGuiIcon_SVG} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/Surface/Resources/icons") + diff --git a/src/Mod/Surface/Gui/Command.cpp b/src/Mod/Surface/Gui/Command.cpp index 5227c781dc6d..8b35ba020c14 100644 --- a/src/Mod/Surface/Gui/Command.cpp +++ b/src/Mod/Surface/Gui/Command.cpp @@ -169,7 +169,7 @@ CmdSurfaceGeomFillSurface::CmdSurfaceGeomFillSurface() sToolTipText = QT_TR_NOOP("Creates a surface from two, three or four boundary edges"); sWhatsThis = "Surface_GeomFillSurface"; sStatusTip = sToolTipText; - sPixmap = "BSplineSurf"; + sPixmap = "Surface_BSplineSurface"; } bool CmdSurfaceGeomFillSurface::isActive(void) diff --git a/src/Mod/Surface/Gui/Resources/Surface.qrc b/src/Mod/Surface/Gui/Resources/Surface.qrc index c48ba70c2da8..d4f2fcc90c4e 100644 --- a/src/Mod/Surface/Gui/Resources/Surface.qrc +++ b/src/Mod/Surface/Gui/Resources/Surface.qrc @@ -1,10 +1,13 @@ - - - icons/BezSurf.svg - icons/BSplineSurf.svg + + + icons/Surface_BezierSurface.svg + icons/Surface_BSplineSurface.svg icons/Surface_Cut.svg icons/Surface_Filling.svg icons/Surface_Sections.svg - icons/Sewing.svg + icons/Surface_Sewing.svg + icons/Surface_Surface.svg + icons/Surface_Workbench.svg - + + diff --git a/src/Mod/Surface/Gui/Resources/icons/BSplineSurf.svg b/src/Mod/Surface/Gui/Resources/icons/Surface_BSplineSurface.svg similarity index 100% rename from src/Mod/Surface/Gui/Resources/icons/BSplineSurf.svg rename to src/Mod/Surface/Gui/Resources/icons/Surface_BSplineSurface.svg diff --git a/src/Mod/Surface/Gui/Resources/icons/BezSurf.svg b/src/Mod/Surface/Gui/Resources/icons/Surface_BezierSurface.svg similarity index 100% rename from src/Mod/Surface/Gui/Resources/icons/BezSurf.svg rename to src/Mod/Surface/Gui/Resources/icons/Surface_BezierSurface.svg diff --git a/src/Mod/Surface/Gui/Resources/icons/Sewing.svg b/src/Mod/Surface/Gui/Resources/icons/Surface_Sewing.svg similarity index 100% rename from src/Mod/Surface/Gui/Resources/icons/Sewing.svg rename to src/Mod/Surface/Gui/Resources/icons/Surface_Sewing.svg diff --git a/src/Mod/Surface/Gui/Resources/icons/Surface.svg b/src/Mod/Surface/Gui/Resources/icons/Surface_Surface.svg similarity index 100% rename from src/Mod/Surface/Gui/Resources/icons/Surface.svg rename to src/Mod/Surface/Gui/Resources/icons/Surface_Surface.svg diff --git a/src/Mod/Surface/Gui/Resources/icons/Surface_Workbench.svg b/src/Mod/Surface/Gui/Resources/icons/Surface_Workbench.svg new file mode 100644 index 000000000000..159fa8740eb8 --- /dev/null +++ b/src/Mod/Surface/Gui/Resources/icons/Surface_Workbench.svg @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 1441b87b4cf3..ae7725148bea 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -102,7 +102,7 @@ void ViewProviderFilling::unsetEdit(int ModNum) QIcon ViewProviderFilling::getIcon(void) const { - return Gui::BitmapFactory().pixmap("BSplineSurf"); + return Gui::BitmapFactory().pixmap("Surface_Filling"); } void ViewProviderFilling::highlightReferences(ShapeType type, const References& refs, bool on) @@ -529,7 +529,7 @@ void FillingPanel::on_listBoundary_itemDoubleClicked(QListWidgetItem* item) const TopTools_ListOfShape& adj_faces = edge2Face.FindFromKey(edge); if (adj_faces.Extent() > 0) { int n = adj_faces.Extent(); - ui->statusLabel->setText(tr("Edge has %n adjacent face(s)", 0, n)); + ui->statusLabel->setText(tr("Edge has %n adjacent faces", 0, n)); // fill up the combo boxes modifyBoundary(true); @@ -818,7 +818,7 @@ TaskFilling::TaskFilling(ViewProviderFilling* vp, Surface::Filling* obj) // first task box widget1 = new FillingPanel(vp, obj); Gui::TaskView::TaskBox* taskbox1 = new Gui::TaskView::TaskBox( - Gui::BitmapFactory().pixmap("BezSurf"), + Gui::BitmapFactory().pixmap("Surface_Filling"), widget1->windowTitle(), true, 0); taskbox1->groupLayout()->addWidget(widget1); Content.push_back(taskbox1); diff --git a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp index 970cd72967c7..38b592adba42 100644 --- a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp +++ b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp @@ -98,7 +98,7 @@ void ViewProviderGeomFillSurface::unsetEdit(int ModNum) QIcon ViewProviderGeomFillSurface::getIcon(void) const { - return Gui::BitmapFactory().pixmap("BSplineSurf"); + return Gui::BitmapFactory().pixmap("Surface_BSplineSurface"); } void ViewProviderGeomFillSurface::highlightReferences(bool on) @@ -585,7 +585,7 @@ TaskGeomFillSurface::TaskGeomFillSurface(ViewProviderGeomFillSurface* vp, Surfac widget = new GeomFillSurface(vp, obj); widget->setWindowTitle(QObject::tr("Surface")); taskbox = new Gui::TaskView::TaskBox( - Gui::BitmapFactory().pixmap("BezSurf"), + Gui::BitmapFactory().pixmap("Surface_BSplineSurface"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/Surface/Gui/TaskSections.cpp b/src/Mod/Surface/Gui/TaskSections.cpp index 17564244f8e4..eda3824d3222 100644 --- a/src/Mod/Surface/Gui/TaskSections.cpp +++ b/src/Mod/Surface/Gui/TaskSections.cpp @@ -100,7 +100,7 @@ void ViewProviderSections::unsetEdit(int ModNum) QIcon ViewProviderSections::getIcon(void) const { - return Gui::BitmapFactory().pixmap("BSplineSurf"); + return Gui::BitmapFactory().pixmap("Surface_Sections"); } void ViewProviderSections::highlightReferences(ShapeType type, const References& refs, bool on) diff --git a/src/Mod/Surface/InitGui.py b/src/Mod/Surface/InitGui.py index bed343f7ed99..492fad9dad72 100644 --- a/src/Mod/Surface/InitGui.py +++ b/src/Mod/Surface/InitGui.py @@ -1,90 +1,50 @@ -# Surface gui init module -# (c) 2001 Juergen Riegel LGPL +# -*- coding: utf8 -*- +# *************************************************************************** +# * Copyright (c) 2014 Nathan Miller * +# * Copyright (c) 2014 Balázs Bámer * +# * * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * This library is free software; you can redistribute it and/or * +# * modify it under the terms of the GNU Library General Public * +# * License as published by the Free Software Foundation; either * +# * version 2 of the License, or (at your option) any later version. * +# * * +# * This library 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 Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this library; see the file COPYING.LIB. If not, * +# * write to the Free Software Foundation, Inc., 59 Temple Place, * +# * Suite 330, Boston, MA 02111-1307, USA * +# * * +# *************************************************************************** +"""The Surface Workbench GUI initialization.""" -class SurfaceWorkbench ( Workbench ): - "Surface workbench object" - Icon = """ - /* XPM */ - static char * Surface_Tools_Workbench_Main_xpm[] = { - "16 16 48 1", - " c None", - ". c #171D96", - "+ c #1A229B", - "@ c #222CA1", - "# c #181D95", - "$ c #232DA2", - "% c #3344B3", - "& c #2A36A9", - "* c #181C96", - "= c #181B94", - "- c #161C96", - "; c #4961C8", - "> c #5776D5", - ", c #192098", - "' c #171C96", - ") c #394DB9", - "! c #5C7DDB", - "~ c #5B7BDA", - "{ c #465FC5", - "] c #384AB5", - "^ c #4D67CB", - "/ c #4D67CC", - "( c #171D97", - "_ c #3D51BC", - ": c #181E96", - "< c #181E97", - "[ c #4961C7", - "} c #1B2099", - "| c #1F269E", - "1 c #506DCF", - "2 c #516ED0", - "3 c #171F96", - "4 c #4861C8", - "5 c #5A7BDA", - "6 c #2631A5", - "7 c #191E97", - "8 c #181F99", - "9 c #1B229A", - "0 c #445AC3", - "a c #597AD9", - "b c #1F279E", - "c c #2E3BAD", - "d c #181D97", - "e c #192097", - "f c #181D98", - "g c #181F97", - "h c #3C51BC", - "i c #10128F", - " ", - " ", - " .. ", - " +@ ", - " #$%&*= -;>, ", - " ')!!!~{]^!!/( ", - " '!!!!!!!!!!!_: ", - " <[!!!!!!!!!!!} ", - " |!!!!11!!!!23 ", - " :4!567890!ab ", - " |!c def ", - " gh( ", - " i ", - " ", - " ", - " "}; - """ +import os + +import FreeCAD as App +import FreeCADGui as Gui + + +class SurfaceWorkbench(Gui.Workbench): + """Surface workbench object.""" + + Icon = os.path.join(App.getResourceDir(), + "Mod", "Surface", + "Resources", "icons", "Surface_Workbench.svg") MenuText = "Surface" ToolTip = "Surface workbench: Create and edit complex surfaces" def Initialize(self): - # load the module - import SurfaceGui - import FreeCADGui + """Initialize the module.""" import Surface - - # Set path to icon labels - FreeCADGui.addIconPath('./Gui/Resources/Icons/') + import SurfaceGui def GetClassName(self): return "SurfaceGui::Workbench" + Gui.addWorkbench(SurfaceWorkbench())