X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_SymbolPrs.cpp;h=2d42f57a568f39160cb31d29760ed9d5137c4458;hb=8476d5e088f7b1b5a414fa5e33ce99d6131929eb;hp=b66ecbd035211b72fca1adfb8ef989cb2e022c7f;hpb=c3ae28ba30027cc4a6a757ef623f40adaae96ead;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index b66ecbd03..2d42f57a5 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -249,7 +249,7 @@ std::map SketcherPrs_SymbolPrs::myIconsM SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint, const std::shared_ptr& thePlane) - : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane) + : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane), myIsConflicting(false) { SetAutoHilight(Standard_False); } @@ -271,11 +271,9 @@ Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon() return myIconsMap[iconName()]; } // Load icon for the presentation - char* aEnv = getenv("NEWGEOM_ROOT_DIR"); + char* aEnv = getenv("SHAPERResources"); if (aEnv != NULL) { TCollection_AsciiString aFile(aEnv); - aFile+=FSEP; - aFile+="resources"; aFile += FSEP; aFile += iconName(); Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap(); @@ -365,6 +363,7 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& // Update points with default shift value if (!updatePoints(20)) { + Events_Error::throwException("An empty AIS presentation: SketcherPrs_SymbolPrs"); return; } @@ -403,7 +402,7 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& void SketcherPrs_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer aMode) + const Standard_Integer aMode) { ClearSelected(); if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) { @@ -412,9 +411,31 @@ void SketcherPrs_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)& } } +void SketcherPrs_SymbolPrs::SetConflictingConstraint(const bool& theConflicting, + const std::vector& theColor) +{ + 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; + } +} void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace) const { + // this method is a combination of OCCT OpenGL functions. The main purpose is to have + // equal distance from the source object to symbol indpendently of zoom. + // It is base on OCCT 6.9.1 and might need changes when using later OCCT versions. + // The specific SHAPER modifications are marked by ShaperModification:start/end, other is OCCT code + // do not update presentation for invalid or already removed objects: the presentation // should be removed soon if (!myConstraint->data().get() || !myConstraint->data()->isValid()) @@ -424,10 +445,12 @@ void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace) const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext(); Handle(OpenGl_View) aView = theWorkspace->ActiveView(); + // ShaperModification:start double aScale = aView->Camera()->Scale(); // Update points coordinate taking the viewer scale into account if (!updatePoints(MyDist * aScale)) return; + // ShaperModification:end Handle(Graphic3d_Buffer) aAttribs = myPntArray->Attributes(); @@ -447,7 +470,10 @@ void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace) const Handle(OpenGl_PointSprite)& aSpriteNorm = anAspectMarker->SpriteRes(aCtx); if (!aSpriteNorm.IsNull() && !aSpriteNorm->IsDisplayList()) { - const bool toHilight = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) != 0; + // ShaperModification:start : filling the presentation with color if there is a conflict + const bool toHilight = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) != 0 || myIsConflicting; + // ShaperModification:end + const Handle(OpenGl_PointSprite)& aSprite = (toHilight && anAspectMarker->SpriteHighlightRes(aCtx)->IsValid()) ? anAspectMarker->SpriteHighlightRes(aCtx) : aSpriteNorm;