const Standard_Integer theMode)
{
std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
- if (aShapePtr.get()) {
+ bool aReadyToDisplay = aShapePtr.get();
+ if (aReadyToDisplay) {
myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
if (!myOriginalShape.IsNull())
Set(myOriginalShape);
}
- else {
+ // change deviation coefficient to provide more precise circle
+ ModuleBase_Tools::setDefaultDeviationCoefficient(Shape(), Attributes());
+ AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
+
+ if (!aReadyToDisplay) {
Events_Error::throwException("An empty AIS presentation: ModuleBase_ResultPrs");
static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
}
- // change deviation coefficient to provide more precise circle
- ModuleBase_Tools::setDefaultDeviationCoefficient(Shape(), Attributes());
- AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
}
void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> aShapeToPrsMap;
fillShapeList(myFeatureShapes, aShapeToPrsMap);
- if (!aShapeToPrsMap.IsEmpty()) {
+ bool aReadyToDisplay = !myShapeToPrsMap.IsEmpty();
+ if (aReadyToDisplay) {
myShapeToPrsMap.Clear();
myShapeToPrsMap.Assign(aShapeToPrsMap);
}
+
XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
Handle(Prs3d_Drawer) aDrawer = Attributes();
// create presentations on the base of the shapes
StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
}
- if (myShapeToPrsMap.IsEmpty()) {
+ if (!aReadyToDisplay) {
Events_Error::throwException("An empty AIS presentation: PartSet_OperationPrs");
-
//std::shared_ptr<Events_Message> aMsg = std::shared_ptr<Events_Message>(
// new Events_Message(Events_Loop::eventByName(EVENT_EMPTY_OPERATION_PRESENTATION)));
//Events_Loop::loop()->send(aMsg);
NCollection_List<TopoDS_Shape> aFaceList;
fillShapes(aResultShape, anAuxiliaryCompound, mySketchFaceList);
- bool isEmptyPresentation = aResultShape.IsNull() && anAuxiliaryCompound.IsNull();
+ bool aReadyToDisplay = !aResultShape.IsNull() || !anAuxiliaryCompound.IsNull();
- if (!aResultShape.IsNull()) {
- myOriginalShape = aResultShape;
- if (!myOriginalShape.IsNull())
- Set(myOriginalShape);
- }
-
- if (!anAuxiliaryCompound.IsNull())
+ if (aReadyToDisplay) {
+ if (!aResultShape.IsNull()) {
+ myOriginalShape = aResultShape;
+ if (!myOriginalShape.IsNull())
+ Set(myOriginalShape);
+ }
myAuxiliaryCompound = anAuxiliaryCompound;
+ }
setAuxiliaryPresentationStyle(false);
- // change deviation coefficient to provide more precise circle
+ // change deviation coefficient to provide more precise circle
ModuleBase_Tools::setDefaultDeviationCoefficient(Shape(), Attributes());
AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
StdPrs_WFDeflectionShape::Add(thePresentation, myAuxiliaryCompound, aDrawer);
}
- if (isEmptyPresentation) {
+ if (!aReadyToDisplay) {
Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs");
static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
}
bool SketcherPrs_Coincident::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
- const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
{
- bool aReadyToDisplay = false;
+ gp_Pnt aPoint;
+ return readyToDisplay(theConstraint, thePlane, aPoint);
+}
+bool SketcherPrs_Coincident::readyToDisplay(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ gp_Pnt& thePoint)
+{
+ bool aReadyToDisplay = false;
// Get point of the presentation
std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(theConstraint,
SketchPlugin_Constraint::ENTITY_A());
- if (aPnt.get() == NULL)
+ if (aPnt.get() == NULL) {
aPnt = SketcherPrs_Tools::getPoint(theConstraint, SketchPlugin_Constraint::ENTITY_B());
-
- aReadyToDisplay = aPnt.get() != NULL;
+ aReadyToDisplay = aPnt.get() != NULL;
+ if (aReadyToDisplay)
+ thePoint = aPnt->impl<gp_Pnt>();
+ }
return aReadyToDisplay;
}
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
- bool aReadyToDisplay = IsReadyToDisplay(myConstraint, mySketcherPlane);
- if (aReadyToDisplay) {
- std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(myConstraint,
- SketchPlugin_Constraint::ENTITY_A());
- if (aPnt.get() == NULL)
- aPnt = SketcherPrs_Tools::getPoint(myConstraint, SketchPlugin_Constraint::ENTITY_B());
- std::shared_ptr<GeomAPI_Pnt> aPoint = mySketcherPlane->to3D(aPnt->x(), aPnt->y());
- myPoint = aPoint->impl<gp_Pnt>();
- }
+ gp_Pnt aPoint;
+ bool aReadyToDisplay = readyToDisplay(myConstraint, mySketcherPlane, aPoint);
+ if (aReadyToDisplay)
+ myPoint = aPoint;
// Get point of the presentation
static Handle(Graphic3d_AspectMarker3d) aPtA;
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode) ;
+private:
+ static bool readyToDisplay(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ gp_Pnt& thePoint);
+
private:
ModelAPI_Feature* myConstraint;
std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
bool SketcherPrs_LengthDimension::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
{
- bool aReadyToDisplay = false;
-
gp_Pnt aPnt1, aPnt2;
- aReadyToDisplay = getPoints(theConstraint, thePlane, aPnt1, aPnt2);
-
- return aReadyToDisplay;
+ return readyToDisplay(theConstraint, thePlane, aPnt1, aPnt2);
}
void SketcherPrs_LengthDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
- bool aReadyToDisplay = IsReadyToDisplay(myConstraint, mySketcherPlane);
+ gp_Pnt aPnt1, aPnt2;
+ bool aReadyToDisplay = readyToDisplay(myConstraint, mySketcherPlane, aPnt1, aPnt2);
if (aReadyToDisplay) {
+ myFirstPoint = aPnt1;
+ mySecondPoint = aPnt2;
+
myDistance = SketcherPrs_Tools::getFlyoutDistance(myConstraint);
- getPoints(myConstraint, mySketcherPlane, myFirstPoint, mySecondPoint);
myPlane = gp_Pln(mySketcherPlane->impl<gp_Ax3>());
AttributeDoublePtr anAttributeValue = myConstraint->data()->real(SketchPlugin_Constraint::VALUE());
if (!aReadyToDisplay)
SketcherPrs_Tools::sendEmptyPresentationError(myConstraint,
"An empty AIS presentation: SketcherPrs_LengthDimension");
-
}
-bool SketcherPrs_LengthDimension::getPoints(ModelAPI_Feature* theConstraint,
- const std::shared_ptr<GeomAPI_Ax3>& thePlane,
- gp_Pnt& thePnt1, gp_Pnt& thePnt2)
+bool SketcherPrs_LengthDimension::readyToDisplay(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ gp_Pnt& thePnt1, gp_Pnt& thePnt2)
{
DataPtr aData = theConstraint->data();
if (theConstraint->getKind() == SketchPlugin_ConstraintLength::ID()) {
const Standard_Integer aMode);
private:
- static bool getPoints(ModelAPI_Feature* theConstraint,
- const std::shared_ptr<GeomAPI_Ax3>& thePlane,
- gp_Pnt& thePnt1, gp_Pnt& thePnt2);
+ static bool readyToDisplay(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ gp_Pnt& thePnt1, gp_Pnt& thePnt2);
/// Constraint feature
ModelAPI_Feature* myConstraint;
bool SketcherPrs_Radius::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+ gp_Circ aCircle;
+ gp_Pnt anAnchorPoint;
+ double aRadius;
+ return readyToDisplay(theConstraint, thePlane, aCircle, anAnchorPoint, aRadius);
+}
+
+bool SketcherPrs_Radius::readyToDisplay(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ gp_Circ& theCircle, gp_Pnt& theAnchorPoint,
+ double& theRadius)
{
bool aReadyToDisplay = false;
return aReadyToDisplay;
std::shared_ptr<ModelAPI_Feature> aCyrcFeature = ModelAPI_Feature::feature(anAttr->object());
- double aRadius = 1;
+ theRadius = 1;
std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr;
// it is possible that circle result becomes zero, in this case the presentation should disappear
// for example, it happens when circle radius is set to zero
AttributeDoublePtr aCircRadius =
std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
aCyrcFeature->data()->attribute(SketchPlugin_Circle::RADIUS_ID()));
- aRadius = aCircRadius->value();
+ theRadius = aCircRadius->value();
} else { // arc
aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aCyrcFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID()));
std::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>
(aCyrcFeature->data()->attribute(SketchPlugin_Arc::START_ID()));
- aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
+ theRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
}
std::shared_ptr<GeomAPI_Pnt> aCenter = thePlane->to3D(aCenterAttr->x(), aCenterAttr->y());
std::shared_ptr<GeomAPI_Dir> aNormal = thePlane->normal();
- GeomAPI_Circ aCircle(aCenter, aNormal, aRadius);
-
+ GeomAPI_Circ aCircle(aCenter, aNormal, theRadius);
std::shared_ptr<GeomAPI_Pnt> anAnchor = SketcherPrs_Tools::getAnchorPoint(theConstraint, thePlane);
- gp_Circ aCirc = aCircle.impl<gp_Circ>();
- gp_Pnt anAncorPnt = anAnchor->impl<gp_Pnt>();
- // anchor point should not coincide to the location point of the circle
- // OCCT does not process this case.
+ theCircle = aCircle.impl<gp_Circ>();
+ theAnchorPoint = anAnchor->impl<gp_Pnt>();
+
+ aReadyToDisplay = theAnchorPoint.Distance(theCircle.Location()) > 1e-7;
- aReadyToDisplay = anAncorPnt.Distance(aCirc.Location()) > 1e-7;
return aReadyToDisplay;
}
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
- bool aReadyToDisplay = IsReadyToDisplay(myConstraint, mySketcherPlane);
+ gp_Circ aCircle;
+ gp_Pnt anAnchorPoint;
+ double aRadius;
+ bool aReadyToDisplay = readyToDisplay(myConstraint, mySketcherPlane, aCircle, anAnchorPoint, aRadius);
if (aReadyToDisplay) {
- //myDistance = SketcherPrs_Tools::getFlyoutDistance(myConstraint);
-
- DataPtr aData = myConstraint->data();
-
- // Flyout point
- std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-
- // Get circle
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>
- (aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
-
- std::shared_ptr<ModelAPI_Feature> aCyrcFeature = ModelAPI_Feature::feature(anAttr->object());
- myRadius = 1;
- std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr;
- if (aCyrcFeature->getKind() == SketchPlugin_Circle::ID()) { // circle
- aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aCyrcFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
- AttributeDoublePtr aCircRadius =
- std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
- aCyrcFeature->data()->attribute(SketchPlugin_Circle::RADIUS_ID()));
- myRadius = aCircRadius->value();
- } else { // arc
- aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aCyrcFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID()));
- std::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aCyrcFeature->data()->attribute(SketchPlugin_Arc::START_ID()));
- myRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
- }
- std::shared_ptr<GeomAPI_Pnt> aCenter = mySketcherPlane->to3D(aCenterAttr->x(), aCenterAttr->y());
- std::shared_ptr<GeomAPI_Dir> aNormal = mySketcherPlane->normal();
-
- GeomAPI_Circ aCircle(aCenter, aNormal, myRadius);
- std::shared_ptr<GeomAPI_Pnt> anAnchor = SketcherPrs_Tools::getAnchorPoint(myConstraint, mySketcherPlane);
-
- myCircle = aCircle.impl<gp_Circ>();
- myAncorPnt = anAnchor->impl<gp_Pnt>();
+ myCircle = aCircle;
+ myAnchorPoint = anAnchorPoint;
+ myRadius = aRadius;
AttributeDoublePtr anAttributeValue = myConstraint->data()->real(SketchPlugin_Constraint::VALUE());
myHasParameters = anAttributeValue->usedParameters().size() > 0;
myValue = anAttributeValue->text();
}
- SetMeasuredGeometry(myCircle, myAncorPnt);
+ SetMeasuredGeometry(myCircle, myAnchorPoint);
SetCustomValue(myRadius);
// Update variable aspect parameters (depending on viewer scale)
/// \return boolean result value
static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+private:
+ /// Fills the constraint parameters by constraint and plane
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ /// \param theCircle a circle build on the constraint values
+ /// \param thePoint an anchor point to show text value
+ /// \param theRadius a circle custom radius value to be visualized
+ /// \return boolean result value
+ static bool readyToDisplay(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ gp_Circ& theCircle, gp_Pnt& theAnchorPoint,
+ double& theRadius);
protected:
/// Redefinition of virtual function
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
/// container of values obtained from the constraint, which are necessary to fill the presentation
double myRadius; ///< the radius custom value
gp_Circ myCircle; ///< the radius circle
- gp_Pnt myAncorPnt; ///< an ancor for the radius value visualization
+ gp_Pnt myAnchorPoint; ///< an ancor for the radius value visualization
bool myHasParameters; ///< true if the atrribute value has used parameters
std::string myValue; ///< dimension value