From: nds Date: Tue, 7 Jun 2016 05:56:59 +0000 (+0300) Subject: Conflicting coincidence constraint is visualized in black color. X-Git-Tag: V_2.4.0~117 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=62f5b155e079d304e2017c7bc5e7ba825b5738da;p=modules%2Fshaper.git Conflicting coincidence constraint is visualized in black color. --- diff --git a/src/ModuleBase/ModuleBase_FilterValidated.cpp b/src/ModuleBase/ModuleBase_FilterValidated.cpp index bb56ba149..097eb60cb 100644 --- a/src/ModuleBase/ModuleBase_FilterValidated.cpp +++ b/src/ModuleBase/ModuleBase_FilterValidated.cpp @@ -6,6 +6,7 @@ #include "ModuleBase_FilterValidated.h" #include "ModuleBase_IWorkshop.h" +#include "ModuleBase_IViewer.h" #include #include @@ -19,32 +20,15 @@ IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterValidated, SelectMgr_Filter); IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterValidated, SelectMgr_Filter); -//#define DEBUG_CURRENT_SELECTION - Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const { bool aValid = true; ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation(); if (anOperation) { -#ifdef DEBUG_CURRENT_SELECTION - QString aPrefix = "ModuleBase_FilterValidated::IsOk: "; - QList aSelected = myWorkshop->selection()->getSelected(ModuleBase_ISelection::Viewer); - QList::const_iterator anIt = aSelected.begin(), aLast = aSelected.end(); - QStringList anInfo; - ModuleBase_ViewerPrsPtr aPrs; - for (; anIt != aLast; anIt++) { - aPrs = (*anIt); - if (!aPrs.get()) - continue; + ModuleBase_IViewer* aViewer = myWorkshop->viewer(); + Handle(AIS_InteractiveContext) aContext = aViewer->AISContext(); - //GeomShapePtr aShape = aPrs->shape(); - ObjectPtr anObject = aPrs->object(); - QString anObjectInfo = anObject.get() ? ModuleBase_Tools::objectInfo(anObject) : ""; - anInfo.append(anObjectInfo); - } - QString anInfoStr = anInfo.join(";\t"); - qDebug(QString("%1: %2, %3").arg(aPrefix).arg(anInfo.size()).arg(anInfoStr).toStdString().c_str()); -#endif + ModuleBase_Tools::selectionInfo(aContext, "ModuleBase_FilterValidated::IsOk"); ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel(); ModuleBase_ModelWidget* aCurrentWidget = aPanel->preselectionWidget(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index f53edf79b..37754a8b1 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -80,6 +80,7 @@ #include #include +#include #include #include @@ -968,6 +969,14 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the aPrs->SetConflictingConstraint(isConflicting, aColor); aCustomized = true; } + } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) { + Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO); + if (!aPrs.IsNull()) { + std::vector aColor; + myOverconstraintListener->getConflictingColor(aColor); + aPrs->SetConflictingConstraint(isConflicting, aColor); + aCustomized = true; + } } } } diff --git a/src/SketcherPrs/SketcherPrs_Coincident.cpp b/src/SketcherPrs/SketcherPrs_Coincident.cpp index e7ae5a144..c4539bf63 100644 --- a/src/SketcherPrs/SketcherPrs_Coincident.cpp +++ b/src/SketcherPrs/SketcherPrs_Coincident.cpp @@ -35,7 +35,7 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Coincident, AIS_InteractiveObject); SketcherPrs_Coincident::SketcherPrs_Coincident(ModelAPI_Feature* theConstraint, const std::shared_ptr& thePlane) : AIS_InteractiveObject(), myConstraint(theConstraint), mySketcherPlane(thePlane), - myPoint(gp_Pnt(0.0, 0.0, 0.0)) + myPoint(gp_Pnt(0.0, 0.0, 0.0)), myIsConflicting(false) { } @@ -82,10 +82,11 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)& } // Create the presentation as a combination of standard point markers + bool aValid = !myIsConflicting; // The external yellow contour aPtA->SetType(Aspect_TOM_RING3); aPtA->SetScale(2.); - aPtA->SetColor(Quantity_NOC_YELLOW); + aPtA->SetColor(aValid ? Quantity_NOC_YELLOW : Quantity_NOC_BLACK); Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation); aGroup->SetPrimitivesAspect(aPtA); @@ -128,3 +129,23 @@ void SketcherPrs_Coincident::SetColor(const Quantity_Color &aCol) hasOwnColor=Standard_True; myOwnColor=aCol; } + +void SketcherPrs_Coincident::SetConflictingConstraint(const bool& theConflicting, + const std::vector& theColor) +{ + myIsConflicting = theConflicting; + + /*if (theConflicting) + { + if (!myAspect.IsNull()) + myAspect->SetColor (Quantity_Color (theColor[0] / 255., theColor[1] / 255., theColor[2] / 255., + Quantity_TOC_RGB)); + myIsConflicting = true; + } + else + { + if (!myAspect.IsNull()) + myAspect->SetColor (Quantity_Color (1.0, 1.0, 0.0, Quantity_TOC_RGB)); + myIsConflicting = false; + }*/ +} diff --git a/src/SketcherPrs/SketcherPrs_Coincident.h b/src/SketcherPrs/SketcherPrs_Coincident.h index 082016c81..d041cac9d 100644 --- a/src/SketcherPrs/SketcherPrs_Coincident.h +++ b/src/SketcherPrs/SketcherPrs_Coincident.h @@ -38,6 +38,13 @@ public: /// \param aColor a color name Standard_EXPORT virtual void SetColor(const Quantity_NameOfColor aColor); + /// Set state of the presentation, in case of conflicting state, the icon of the presentation is + /// visualized in error color. The state is stored in an internal field, so should be changed when + /// constraint become not conflicting + /// \param theConflicting a state + /// \param theColor a color for conflicting object + Standard_EXPORT void SetConflictingConstraint(const bool& theConflicting, const std::vector& theColor); + /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation /// \param theConstraint a constraint feature /// \param thePlane a coordinate plane of current sketch @@ -64,6 +71,7 @@ private: ModelAPI_Feature* myConstraint; std::shared_ptr mySketcherPlane; gp_Pnt myPoint; + bool myIsConflicting; /// state if the presentation is visualized in error state };