return aReadyToDisplay;
}
-bool SketcherPrs_Collinear::updatePoints(double theStep) const
+bool SketcherPrs_Collinear::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
};
#endif
\ No newline at end of file
return aReadyToDisplay;
}
-bool SketcherPrs_Equal::updatePoints(double theStep) const
+bool SketcherPrs_Equal::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
};
#endif
\ No newline at end of file
return aReadyToDisplay;
}
-bool SketcherPrs_HVDirection::updatePoints(double theStep) const
+bool SketcherPrs_HVDirection::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
private:
bool myIsHorisontal;
return aReadyToDisplay;
}
-bool SketcherPrs_Middle::updatePoints(double theStep) const
+bool SketcherPrs_Middle::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
/// Draw shape of the object. Find shape result if the object is feature
void drawLine(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor,
return aReadyToDisplay;
}
-bool SketcherPrs_Mirror::updatePoints(double theStep) const
+bool SketcherPrs_Mirror::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
};
#endif
\ No newline at end of file
return aReadyToDisplay;
}
-bool SketcherPrs_Parallel::updatePoints(double theStep) const
+bool SketcherPrs_Parallel::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
};
#endif
\ No newline at end of file
return aReadyToDisplay;
}
-bool SketcherPrs_Perpendicular::updatePoints(double theStep) const
+bool SketcherPrs_Perpendicular::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
};
#endif
\ No newline at end of file
return aReadyToDisplay;
}
-bool SketcherPrs_Rigid::updatePoints(double theStep) const
+bool SketcherPrs_Rigid::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
};
}
// Update points with default shift value
- if (!updatePoints(20)) {
- Events_Error::throwException("An empty AIS presentation: SketcherPrs_SymbolPrs");
- 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");
}
// 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();
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const { return true; }
+ virtual bool updateIfReadyToDisplay(double theStep) const { return true; }
/// Draw a shape into the given presentation scene
/// \param theShape the shape to draw
return aReadyToDisplay;
}
-bool SketcherPrs_Tangent::updatePoints(double theStep) const
+bool SketcherPrs_Tangent::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
};
#endif
\ No newline at end of file
AttributePtr getAttribute(ModelAPI_Feature* theFeature, const std::string& theAttrName)
{
- std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
- return !anAttr->isObject() ? anAttr->attr() : AttributePtr();
+ AttributePtr anAttribute;
+ if (theFeature) {
+ std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ if (aData.get() && aData->isValid()) { /// essential check as it is called in openGl thread
+ std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
+ if (!anAttr->isObject())
+ anAttribute = anAttr->attr();
+ }
+ }
+ return anAttribute;
}
ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName)
{
- std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
- return anAttr->object();
+ ObjectPtr anObject;
+ if (theFeature) {
+ std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ if (aData.get() && aData->isValid()) { /// essential check as it is called in openGl thread
+ std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
+ if (anAttr.get())
+ anObject = anAttr->object();
+ }
+ }
+ return anObject;
}
std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject)
{
ResultConstructionPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theObject);
- if (aRes.get() != NULL) {
+ if (aRes.get() != NULL && aRes->data()->isValid()) {/// essential check as it is called in openGl thread
return aRes->shape();
}
return std::shared_ptr<GeomAPI_Shape>();
{
std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
- if (!theFeature->data())
+ /// essential check as it is called in openGl thread
+ if (!theFeature || !theFeature->data().get() || !theFeature->data()->isValid())
return std::shared_ptr<GeomAPI_Pnt2d>();
FeaturePtr aFeature;
{
std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
- if (!theData)
+ if (!theData.get() || !theData->isValid()) /// essential check as it is called in openGl thread
return aPointAttr;
FeaturePtr aFeature;
const std::string& theAttribute)
{
FeaturePtr aLine;
- if (!theData)
+ if (!theData.get() || !theData->isValid()) /// essential check as it is called in openGl thread)
return aLine;
std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
DataPtr aData = theLine->data();
+ if (!aData.get() || !aData->isValid())
+ return std::shared_ptr<GeomAPI_Pnt2d>();
+
std::shared_ptr<GeomDataAPI_Point2D> aPoint1 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(SketchPlugin_Line::START_ID()));
std::shared_ptr<GeomDataAPI_Point2D> aPoint2 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
return aReadyToDisplay;
}
-bool SketcherPrs_Transformation::updatePoints(double theStep) const
+bool SketcherPrs_Transformation::updateIfReadyToDisplay(double theStep) const
{
if (!IsReadyToDisplay(myConstraint, myPlane))
return false;
/// Update myPntArray according to presentation positions
/// \return true in case of success
- virtual bool updatePoints(double theStep) const;
+ virtual bool updateIfReadyToDisplay(double theStep) const;
private:
bool myIsTranslation;