From: vsv Date: Tue, 23 Jun 2020 14:09:12 +0000 (+0300) Subject: Issue #3222: Show error shapes for fillet X-Git-Tag: V9_6_0a1~60^2~51 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=490fed9e39eced971522355b70a8fa90312d526f;p=modules%2Fshaper.git Issue #3222: Show error shapes for fillet --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet1D.cpp b/src/FeaturesPlugin/FeaturesPlugin_Fillet1D.cpp index d62fdee30..d2b9bac94 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet1D.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet1D.cpp @@ -164,9 +164,9 @@ bool FeaturesPlugin_Fillet1D::performFillet(const GeomShapePtr& theWire, if (isSendMessage) { // send message to highlight the failed vertices - std::shared_ptr aMessage( - new ModelAPI_Fillet1DFailedMessage(Events_Loop::eventByName(EVENT_1DFILLET_FAILED))); - aMessage->setVertices(myFailedVertices); + std::shared_ptr aMessage( + new ModelAPI_ShapesFailedMessage(Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED))); + aMessage->setShapes(myFailedVertices); Events_Loop::loop()->send(aMessage); } diff --git a/src/ModelAPI/ModelAPI_Events.cpp b/src/ModelAPI/ModelAPI_Events.cpp index 57ae12839..29658fd69 100644 --- a/src/ModelAPI/ModelAPI_Events.cpp +++ b/src/ModelAPI/ModelAPI_Events.cpp @@ -387,21 +387,21 @@ void ModelAPI_ObjectMovedMessage::setCurrentPosition( } -// ===== ModelAPI_Fillet1DFailedMessage ===== -ModelAPI_Fillet1DFailedMessage::ModelAPI_Fillet1DFailedMessage(const Events_ID theID, +// ===== ModelAPI_ShapesFailedMessage ===== +ModelAPI_ShapesFailedMessage::ModelAPI_ShapesFailedMessage(const Events_ID theID, const void* theSender) : Events_Message(theID, theSender) {} -ModelAPI_Fillet1DFailedMessage::~ModelAPI_Fillet1DFailedMessage() +ModelAPI_ShapesFailedMessage::~ModelAPI_ShapesFailedMessage() {} -void ModelAPI_Fillet1DFailedMessage::setVertices(const ListOfShape& theVertices) +void ModelAPI_ShapesFailedMessage::setShapes(const ListOfShape& theShapes) { - myVertices = theVertices; + myShapes = theShapes; } -const ListOfShape& ModelAPI_Fillet1DFailedMessage::vertices() const +const ListOfShape& ModelAPI_ShapesFailedMessage::shapes() const { - return myVertices; + return myShapes; } diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index fd2a7ff34..d951211eb 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -111,8 +111,8 @@ static const char * EVENT_DOF_OBJECTS = "DoFObjects"; /// Event ID that requests updates visual attributes for presentations static const char * EVENT_VISUAL_ATTRIBUTES = "UpdateVisualAttributes"; -/// Event ID that 1D-fillet failed (comes with ModelAPI_Fillet1DFailedMessage) -static const char * EVENT_1DFILLET_FAILED = "1DFilletFailed"; +/// Event ID that 1D-fillet failed (comes with ModelAPI_ShapesFailedMessage) +static const char * EVENT_OPERATION_SHAPES_FAILED = "OperationShapesFailed"; /// Message that feature was changed (used for Object Browser update): moved, updated and deleted class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup @@ -534,26 +534,26 @@ public: }; /// Message that sends the failed vertices of 1D-fillet to highlight them in 3D viewer -class ModelAPI_Fillet1DFailedMessage : public Events_Message +class ModelAPI_ShapesFailedMessage : public Events_Message { public: /// Creates an message - MODELAPI_EXPORT ModelAPI_Fillet1DFailedMessage(const Events_ID theID, const void* theSender = 0); + MODELAPI_EXPORT ModelAPI_ShapesFailedMessage(const Events_ID theID, const void* theSender = 0); /// Default destructor - MODELAPI_EXPORT virtual ~ModelAPI_Fillet1DFailedMessage(); + MODELAPI_EXPORT virtual ~ModelAPI_ShapesFailedMessage(); /// Static. Returns EventID of the message. MODELAPI_EXPORT static Events_ID eventId() { - return Events_Loop::eventByName(EVENT_1DFILLET_FAILED); + return Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED); } /// Sets list of failed vertices - MODELAPI_EXPORT void setVertices(const std::list< std::shared_ptr >& theVertices); + MODELAPI_EXPORT void setShapes(const std::list< std::shared_ptr >& theVertices); /// Returns list of failed vertices - MODELAPI_EXPORT const std::list< std::shared_ptr >& vertices() const; + MODELAPI_EXPORT const std::list< std::shared_ptr >& shapes() const; private: - std::list< std::shared_ptr > myVertices; + std::list< std::shared_ptr > myShapes; }; #endif diff --git a/src/PartSet/PartSet_CustomPrs.cpp b/src/PartSet/PartSet_CustomPrs.cpp index e18ca5bb0..06299acd0 100644 --- a/src/PartSet/PartSet_CustomPrs.cpp +++ b/src/PartSet/PartSet_CustomPrs.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,7 @@ PartSet_CustomPrs::PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop) { Events_Loop* aLoop = Events_Loop::loop(); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_OPERATION_PRESENTATION)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED)); initPresentation(ModuleBase_IModule::CustomizeArguments); initPresentation(ModuleBase_IModule::CustomizeResults); @@ -99,6 +101,8 @@ bool PartSet_CustomPrs::deactivate(const ModuleBase_IModule::ModuleBase_Customiz { myIsActive[theFlag] = false; erasePresentation(theFlag, theUpdateViewer); + if (theFlag == ModuleBase_IModule::CustomizeResults) + clearErrorShape(); return true; } @@ -244,12 +248,50 @@ void PartSet_CustomPrs::clearPrs() clearPresentation(ModuleBase_IModule::CustomizeArguments); clearPresentation(ModuleBase_IModule::CustomizeResults); clearPresentation(ModuleBase_IModule::CustomizeHighlightedObjects); + clearErrorShape(); +} + +void PartSet_CustomPrs::clearErrorShape() +{ + if (!myErrorShapes.IsNull()) { + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + if (aContext->IsDisplayed(myErrorShapes)) + aContext->Remove(myErrorShapes, true); + } } void PartSet_CustomPrs::processEvent(const std::shared_ptr& theMessage) { if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_OPERATION_PRESENTATION)) myPresentationIsEmpty = true; /// store state to analize it after display/erase is finished + else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OPERATION_SHAPES_FAILED)) { + std::shared_ptr aErrMsg = + std::dynamic_pointer_cast(theMessage); + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + ListOfShape aShapes = aErrMsg->shapes(); + if (aShapes.size() > 0) { + GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); + TopoDS_Shape aErrShape = aCompound->impl(); + if (myErrorShapes.IsNull()) { + myErrorShapes = new AIS_Shape(aErrShape); + myErrorShapes->SetColor(Quantity_NOC_RED); + Handle(Prs3d_Drawer) aDrawer = myErrorShapes->Attributes(); + aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_RING1, Quantity_NOC_RED, 2.)); + aDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 2.)); + aContext->Display(myErrorShapes, true); + aContext->Deactivate(myErrorShapes); + } + else { + myErrorShapes->Set(aErrShape); + aContext->Redisplay(myErrorShapes, true); + } + } + else { + if (!myErrorShapes.IsNull()) { + aContext->Remove(myErrorShapes, true); + } + } + } } void PartSet_CustomPrs::initPresentation( diff --git a/src/PartSet/PartSet_CustomPrs.h b/src/PartSet/PartSet_CustomPrs.h index 75638bc5b..2714ea717 100644 --- a/src/PartSet/PartSet_CustomPrs.h +++ b/src/PartSet/PartSet_CustomPrs.h @@ -151,6 +151,9 @@ private: /// \return theShapeColor a color Quantity_Color getShapeColor(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag); + /// Removes error shapes presentation + void clearErrorShape(); + private: bool myPresentationIsEmpty; /// Boolean state about empty presentation FeaturePtr myFeature; /// Reference to a feature object @@ -161,6 +164,8 @@ private: QMap myIsActive; int myDisabledMode; + + Handle(AIS_Shape) myErrorShapes; }; #endif diff --git a/src/PartSet/PartSet_OperationPrs.cpp b/src/PartSet/PartSet_OperationPrs.cpp index f782ca3c0..c98b82d28 100644 --- a/src/PartSet/PartSet_OperationPrs.cpp +++ b/src/PartSet/PartSet_OperationPrs.cpp @@ -123,7 +123,6 @@ void PartSet_OperationPrs::Compute( thePresentation->Clear(); bool aReadyToDisplay = !myShapeToPrsMap.IsEmpty(); - XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer(); Handle(Prs3d_Drawer) aDrawer = Attributes(); // create presentations on the base of the shapes BRep_Builder aBuilder; @@ -244,24 +243,20 @@ void PartSet_OperationPrs::appendShapeIfVisible(ModuleBase_IWorkshop* theWorksho GeomShapePtr theGeomShape, QMap >& theObjectShapes) { - XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer(); - // VSV: Do not use isVisible checking because it can be used when state "Show Only" is ON - //if (XGUI_Displayer::isVisible(aDisplayer, theObject)) { - if (theGeomShape.get()) { - if (theObjectShapes.contains(theObject)) - theObjectShapes[theObject].append(theGeomShape); - else { - QList aShapes; - aShapes.append(theGeomShape); - theObjectShapes[theObject] = aShapes; - } - } else { - #ifdef DEBUG_EMPTY_SHAPE - qDebug(QString("Empty shape in result, result: %1") - .arg(ModuleBase_Tools::objectInfo(theObject)).toStdString().c_str()); - #endif + if (theGeomShape.get()) { + if (theObjectShapes.contains(theObject)) + theObjectShapes[theObject].append(theGeomShape); + else { + QList aShapes; + aShapes.append(theGeomShape); + theObjectShapes[theObject] = aShapes; } - //} + } else { +#ifdef DEBUG_EMPTY_SHAPE + qDebug(QString("Empty shape in result, result: %1") + .arg(ModuleBase_Tools::objectInfo(theObject)).toStdString().c_str()); +#endif + } } void PartSet_OperationPrs::getFeatureShapes(const FeaturePtr& theFeature, @@ -364,8 +359,6 @@ void PartSet_OperationPrs::getResultShapes(const FeaturePtr& theFeature, if (!theFeature.get()) return; - XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer(); - std::list aResults; ModelAPI_Tools::allResults(theFeature, aResults); std::list::const_iterator aRIt = aResults.begin(),