#include <ModelAPI_Session.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Validator.h>
+
+#include <ModelGeomAlgo_Point2D.h>
#include <Events_Loop.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
#include <V3d_View.hxx>
#include <gp_Pln.hxx>
// may be feature is not updated yet, execute is not performed and references features
// are not created. Case: rectangle macro feature
- ModuleBase_ModelWidget::updateObject(theFeature);
+ ModuleBase_Tools::flushUpdated(theFeature);
std::list<AttributePtr> anAttributes = theFeature->data()->attributes(
ModelAPI_AttributeRefList::typeId());
theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
aLast = anAttiributes.end();
+ ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+
for (; anIt != aLast && !aFPoint; anIt++) {
std::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
- if (aCurPoint && (aCurPoint->pnt()->distance(thePoint) < Precision::Confusion())) {
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+ if (aCurPoint && aCurPoint->isInitialized() &&
+ aValidators->isCase(theFeature, aCurPoint->id()) &&
+ (aCurPoint->pnt()->distance(thePoint) < Precision::Confusion())) {
aFPoint = aCurPoint;
break;
}
std::list<std::shared_ptr<ModelAPI_Attribute> > anAttiributes;
for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
- if (!aFeature.get() || theFeature == aFeature)
+ if (!aFeature.get() || (theFeature == aFeature) || (aFeaturePoint->owner() == aFeature))
continue;
std::shared_ptr<GeomDataAPI_Point2D> aFPoint = PartSet_Tools::findFirstEqualPoint(aFeature,
aClickedPoint);
{
std::shared_ptr<GeomAPI_Pln> aPlane;
- std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
- if (aData) {
- std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
- aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- aData->attribute(SketchPlugin_Sketch::NORM_ID()));
- if (aNormal.get() && aNormal->isInitialized() &&
- anOrigin.get() && anOrigin->isInitialized()) {
- double adX = aNormal->x();
- double adY = aNormal->y();
- double adZ = aNormal->z();
-
- if ( (adX != 0) || (adY != 0) || (adZ != 0) ) { // Plane is valid
- double aX = anOrigin->x();
- double aY = anOrigin->y();
- double aZ = anOrigin->z();
- gp_Pln aPln(gp_Pnt(aX, aY, aZ), gp_Dir(adX, adY, adZ));
- double aA, aB, aC, aD;
- aPln.Coefficients(aA, aB, aC, aD);
- aPlane = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
- }
- }
- }
+ std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+ theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ theSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+
+ if (aNormal.get() && aNormal->isInitialized() &&
+ anOrigin.get() && anOrigin->isInitialized())
+ aPlane = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(anOrigin->pnt(), aNormal->dir()));
+
return aPlane;
}
FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
setObject(aMyFeature->lastResult());
+ // we need to flush created signal in order to fixed constraint is processed by solver
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
//}
return aMyFeature->lastResult();
}
FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
setObject(aMyFeature->lastResult());
+ // we need to flush created signal in order to fixed constraint is processed by solver
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
//}
return aMyFeature->lastResult();
}
std::shared_ptr<GeomAPI_Pnt2d> PartSet_Tools::getPoint(std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::string& theAttribute)
{
- std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
-
- if (!theFeature->data())
- return std::shared_ptr<GeomAPI_Pnt2d>();
-
- FeaturePtr aFeature;
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(theFeature->data()->attribute(theAttribute));
- if (!anAttr)
- return std::shared_ptr<GeomAPI_Pnt2d>();
-
- aFeature = ModelAPI_Feature::feature(anAttr->object());
-
- if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
- aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
-
- else if (anAttr->attr()) {
- aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
- }
+ std::shared_ptr<GeomDataAPI_Point2D> aPointAttr = ModelGeomAlgo_Point2D::getPointOfRefAttr(
+ theFeature.get(), theAttribute, SketchPlugin_Point::ID(),
+ SketchPlugin_Point::COORD_ID());
if (aPointAttr.get() != NULL)
return aPointAttr->pnt();
return std::shared_ptr<GeomAPI_Pnt2d>();
for (; anIt != aLast && !anAttribute; anIt++) {
std::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+ if (!aCurPoint->isInitialized())
+ continue;
std::shared_ptr<GeomAPI_Pnt> aPnt = convertTo3D(aCurPoint->x(), aCurPoint->y(), theSketch);
if (aPnt && (aPnt->distance(aValue) < Precision::Confusion())) {