X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_IconFactory.cpp;h=d6f054093c3e973790d95e41501a563c3d410a86;hb=02f05f9a36e033a4d52bab90d0917d9679683c0f;hp=5543d690201d7e1a49a1dc6224db81312b6ded3b;hpb=7074394f8f08413d885f63be01df6bd5007b868c;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_IconFactory.cpp b/src/PartSet/PartSet_IconFactory.cpp index 5543d6902..d6f054093 100644 --- a/src/PartSet/PartSet_IconFactory.cpp +++ b/src/PartSet/PartSet_IconFactory.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,16 +12,23 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "PartSet_IconFactory.h" +#include "PartSet_Tools.h" +#include "PartSet_Module.h" +#include "XGUI_DataModel.h" + +#include +#include + #include #include +#include #include #include #include @@ -31,7 +38,8 @@ QMap PartSet_IconFactory::myIcons; -PartSet_IconFactory::PartSet_IconFactory():ModuleBase_IconFactory() +PartSet_IconFactory::PartSet_IconFactory(PartSet_Module* theModule) + : ModuleBase_IconFactory(), myModule(theModule) { Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(Config_FeatureMessage::GUI_EVENT())); @@ -40,60 +48,99 @@ PartSet_IconFactory::PartSet_IconFactory():ModuleBase_IconFactory() QIcon PartSet_IconFactory::getIcon(ObjectPtr theObj) { - QIcon anIcon; - if (!theObj.get()) - return anIcon; + return QIcon(); + std::string aGroup = theObj->groupName(); FeaturePtr aFeature = std::dynamic_pointer_cast(theObj); if (aFeature.get()) { std::string aKind = aFeature->getKind(); QString aId(aKind.c_str()); if (!myIcons.contains(aId)) - return anIcon; + return QIcon(); QString anIconString = myIcons[aId]; ModelAPI_ExecState aState = aFeature->data()->execState(); - switch(aState) { - case ModelAPI_StateDone: - case ModelAPI_StateNothing: { - anIcon = loadIcon(anIconString); - } + switch (aState) { + case ModelAPI_StateMustBeUpdated: + return ModuleBase_Tools::composite(":icons/toWork.png", anIconString); + //anIcon = ModuleBase_Tools::lighter(anIconString); break; - case ModelAPI_StateMustBeUpdated: { - anIcon = ModuleBase_Tools::lighter(anIconString); - } + case ModelAPI_StateExecFailed: + return ModuleBase_Tools::composite(":icons/isFailed.png", anIconString); break; - case ModelAPI_StateExecFailed: { - anIcon = ModuleBase_Tools::composite(":icons/exec_state_failed.png", anIconString); - } + case ModelAPI_StateInvalidArgument: + return ModuleBase_Tools::composite(":icons/exec_state_invalid_parameters.png", + anIconString); break; - case ModelAPI_StateInvalidArgument: { - anIcon = ModuleBase_Tools::composite(":icons/exec_state_invalid_parameters.png", - anIconString); - } + default: + return loadIcon(anIconString); break; - default: break; } } - if (theObj->data() && theObj->data()->execState() == ModelAPI_StateMustBeUpdated) - return QIcon(":pictures/constr_object_modified.png"); + //if (theObj->data() && theObj->data()->execState() == ModelAPI_StateMustBeUpdated) + // return QIcon(":pictures/constr_object_modified.png"); - std::string aGroup = theObj->groupName(); if (aGroup == ModelAPI_ResultPart::group()) return QIcon(":pictures/part_ico.png"); if (aGroup == ModelAPI_ResultConstruction::group()) return QIcon(":pictures/constr_object.png"); + if (aGroup == ModelAPI_Folder::group()) { + static QString anIconString(":pictures/features_folder.png"); + int aFirst = -1, aLast = -1; + PartSet_Tools::getFirstAndLastIndexInFolder(theObj, aFirst, aLast); + if ((aFirst != -1) && (aLast != -1)) { + int aNbItems = aLast - aFirst + 1; + if (aNbItems) { + XGUI_ObjectsBrowser* aObBrowser = myModule->getWorkshop()->objectBrowser(); + XGUI_DataTree* aTree = aObBrowser->treeView(); + QModelIndex aIndex = aTree->dataModel()->objectIndex(theObj, 0); + if (!aTree->isExpanded(aIndex)) { + DocumentPtr aDoc = theObj->document(); + ObjectPtr aSubObj; + ModelAPI_ExecState aState; + bool aHasWarning = false; + for (int i = aFirst; i < aLast + 1; i++) { + aSubObj = aDoc->object(ModelAPI_Feature::group(), i); + aState = aSubObj->data()->execState(); + if ((aState == ModelAPI_StateExecFailed) || (aState == ModelAPI_StateMustBeUpdated)) { + aHasWarning = true; + break; + } + } + if (aHasWarning) { + return QIcon(ModuleBase_Tools::composite(":icons/hasWarning.png", anIconString)); + } + } + } + } + return loadIcon(anIconString); + } + ResultPtr aResult = std::dynamic_pointer_cast(theObj); if (aResult.get()) { GeomShapePtr aShape = aResult->shape(); if(aShape.get()) { switch(aShape->shapeType()) { case GeomAPI_Shape::COMPOUND: { + if (aResult->groupName() == ModelAPI_ResultGroup::group()) { + switch (aShape->typeOfCompoundShapes()) { + case GeomAPI_Shape::VERTEX: + return QIcon(":icons/group_vertex.png"); + case GeomAPI_Shape::EDGE: + return QIcon(":icons/group_edge.png"); + case GeomAPI_Shape::FACE: + return QIcon(":icons/group_face.png"); + case GeomAPI_Shape::SOLID: + return QIcon(":icons/group_solid.png"); + default: // [to avoid compilation warning] + break; + } + } ResultBodyPtr aBody = std::dynamic_pointer_cast(aResult); if (aBody.get() && aBody->isConnectedTopology()) return QIcon(":pictures/compoundofsolids.png"); @@ -106,10 +153,12 @@ QIcon PartSet_IconFactory::getIcon(ObjectPtr theObj) case GeomAPI_Shape::WIRE: return QIcon(":pictures/wire.png"); case GeomAPI_Shape::EDGE: return QIcon(":pictures/edge.png"); case GeomAPI_Shape::VERTEX: return QIcon(":pictures/vertex.png"); + default: // [to avoid compilation warning] + break; } } } - return anIcon; + return QIcon(); } void PartSet_IconFactory::processEvent(const std::shared_ptr& theMessage) @@ -118,11 +167,9 @@ void PartSet_IconFactory::processEvent(const std::shared_ptr& th Events_Loop::loop()->eventByName(Config_FeatureMessage::GUI_EVENT())) { std::shared_ptr aFeatureMsg = std::dynamic_pointer_cast(theMessage); - if (!aFeatureMsg->isInternal()) { - ActionInfo aFeatureInfo; - aFeatureInfo.initFrom(aFeatureMsg); - // Remember features icons - myIcons[QString::fromStdString(aFeatureMsg->id())] = aFeatureInfo.iconFile; - } + ActionInfo aFeatureInfo; + aFeatureInfo.initFrom(aFeatureMsg); + // Remember features icons + myIcons[QString::fromStdString(aFeatureMsg->id())] = aFeatureInfo.iconFile; } } \ No newline at end of file