From b0434962195bc456f5bbea9698761d774a14ba87 Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 22 Jun 2016 17:48:48 +0300 Subject: [PATCH] Changed highlight presentation of vertices --- src/ModuleBase/ModuleBase_Tools.cpp | 49 ++++++++++++++++++++++++++-- src/XGUI/CMakeLists.txt | 1 + src/XGUI/icons/marker_dot.png | Bin 0 -> 263 bytes 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/XGUI/icons/marker_dot.png diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 9e77f0650..fa47856fa 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -44,6 +44,8 @@ #include #include +#include + #include #include #include @@ -82,6 +84,12 @@ const double DEFAULT_DEVIATION_COEFFICIENT = 1.e-4; #include #endif +#ifdef WIN32 +# define FSEP "\\" +#else +# define FSEP "/" +#endif + namespace ModuleBase_Tools { //****************************************************************** @@ -1159,10 +1167,47 @@ void translate(const std::string& theContext, std::string& theMessage) void setPointBallHighlighting(AIS_Shape* theAIS) { + static Handle(Image_AlienPixMap) aPixMap; + if(aPixMap.IsNull()) { + // Load icon for the presentation + std::string aFile; + char* anEnv = getenv("SHAPER_ROOT_DIR"); + if(anEnv) { + aFile = std::string(anEnv) + + FSEP + "share" + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper"; + } else { + anEnv = getenv("OPENPARTS_ROOT_DIR"); + if (anEnv) + aFile = std::string(anEnv) + FSEP + "resources"; + } + + aFile += FSEP; + static const std::string aMarkerName = "marker_dot.png"; + aFile += aMarkerName; + aPixMap = new Image_AlienPixMap(); + if(!aPixMap->Load(aFile.c_str())) { + // The icon for constraint is not found + static const std::string aMsg = "Error: Point market not found by path: \"" + aFile + "\". Falling back."; + //Events_InfoMessage("ModuleBase_Tools::setPointBallHighlighting", aMsg).send(); + } + } + + Handle(Graphic3d_AspectMarker3d) anAspect; Handle(Prs3d_Drawer) aDrawer = theAIS->HilightAttributes(); - if (aDrawer->HasOwnPointAspect()) { + if(aDrawer->HasOwnPointAspect()) { Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect(); - aPntAspect->Aspect()->SetType(Aspect_TOM_BALL); + if(aPixMap->IsEmpty()) { + anAspect = aPntAspect->Aspect(); + anAspect->SetType(Aspect_TOM_BALL); + } else { + if(aPixMap->Format() == Image_PixMap::ImgGray) { + aPixMap->SetFormat (Image_PixMap::ImgAlpha); + } else if(aPixMap->Format() == Image_PixMap::ImgGrayF) { + aPixMap->SetFormat (Image_PixMap::ImgAlphaF); + } + anAspect = new Graphic3d_AspectMarker3d(aPixMap); + aPntAspect->SetAspect(anAspect); + } aDrawer->SetPointAspect(aPntAspect); theAIS->SetHilightAttributes(aDrawer); } diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index 1d7d56c41..2a8561f4a 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -152,3 +152,4 @@ TARGET_LINK_LIBRARIES(XGUI ${PROJECT_LIBRARIES}) INSTALL(TARGETS XGUI DESTINATION ${SHAPER_INSTALL_BIN}) INSTALL(FILES ${QM_RESOURCES} DESTINATION ${SHAPER_INSTALL_QM_RESOURCES}) INSTALL(FILES ${PREFERENCES_XML} DESTINATION ${SHAPER_INSTALL_RESOURCES}) +INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_RESOURCES}) diff --git a/src/XGUI/icons/marker_dot.png b/src/XGUI/icons/marker_dot.png new file mode 100644 index 0000000000000000000000000000000000000000..23394f25f72c5d9cac81e6dacb6e0da9941c095f GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^+#t-s1|(OmDOUqhjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=ff|HBnDNrxx<5cc_7YEDSN6MXY`l8%ZXGk01BE0?Tq84D>8>jO+Y>YEnI2978mM=k_^r9Z=w5vHfn)YP=~(IJ6NH(e&r)V*xhzQaYZ!>j*(t6`p@P+jZ?1M##Zxy1Tk-e;8eEZTco zGF|DJpxserw?pZ2iSZAb>N~ySn=iE0Z}`F_r?rx0U81fu&_V`JS3j3^P6