SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
- : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
+ : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane), myIsConflicting(false)
{
SetAutoHilight(Standard_False);
+ myPntArray = new Graphic3d_ArrayOfPoints(1);
+ myPntArray->AddVertex(0., 0., 0.);
}
SketcherPrs_SymbolPrs::~SketcherPrs_SymbolPrs()
return myIconsMap[iconName()];
}
// Load icon for the presentation
- char* aEnv = getenv("NEWGEOM_ROOT_DIR");
- if (aEnv != NULL) {
- TCollection_AsciiString aFile(aEnv);
- aFile+=FSEP;
- aFile+="resources";
- aFile += FSEP;
- aFile += iconName();
- Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
- if (aPixMap->Load(aFile)) {
- myIconsMap[iconName()] = aPixMap;
- return aPixMap;
- }
+ 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;
+ aFile += iconName();
+ Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
+ if (aPixMap->Load(aFile.c_str())) {
+ myIconsMap[iconName()] = aPixMap;
+ return aPixMap;
}
// The icon for constraint is not found
static const char aMsg[] = "Error! constraint images are not found";
}
// Update points with default shift value
- if (!updatePoints(20)) {
- return;
- }
+ // it updates array of points if the presentation is ready to display, or the array of points
+ // contains the previous values
+
+ bool aReadyToDisplay = updateIfReadyToDisplay(20);
int aNbVertex = myPntArray->VertexNumber();
if (myOwner.IsNull()) {
// Disable frustum culling for this object by marking it as mutable
aGroup->Structure()->SetMutable(true);
//aGroup->AddPrimitiveArray(myPntArray);
+
+ if (!aReadyToDisplay)
+ SketcherPrs_Tools::sendEmptyPresentationError(myConstraint,
+ "An empty AIS presentation: SketcherPrs_LengthDimension");
}
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)) {
}
}
+void SketcherPrs_SymbolPrs::SetConflictingConstraint(const bool& theConflicting,
+ const std::vector<int>& 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())
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;
+ updateIfReadyToDisplay(MyDist * aScale);
+
+ // ShaperModification:end
Handle(Graphic3d_Buffer) aAttribs = myPntArray->Attributes();
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;