It replaces findPoint() method by using attributes(type) data model method.
map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter = myAttrs.begin();
for(; anAttrsIter != myAttrs.end(); anAttrsIter++) {
if (theType.empty() || anAttrsIter->second->attributeType() == theType) {
+ aResult.push_back(anAttrsIter->second);
}
}
return aResult;
return SM_FirstPoint;
}
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::findPoint(FeaturePtr theFeature,
- double theX, double theY)
-{
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
- return aPoint2D;
-}
-
boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::featurePoint
(const PartSet_SelectionMode& theMode)
{
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// Find a point in the line with given coordinates
- /// \param theFeature the line feature
- /// \param theX the horizontal point coordinate
- /// \param theY the vertical point coordinate
- virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
- double theY);
protected:
/// Returns the feature point in the selection mode position.
/// \param theMode the current operation selection mode. The feature attribute depends on the mode
return SM_FirstPoint;
}
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintLengthPrs::findPoint(FeaturePtr theFeature,
- double theX, double theY)
-{
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
- return aPoint2D;
-}
-
boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintLengthPrs::featurePoint
(const PartSet_SelectionMode& theMode)
{
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// Find a point in the line with given coordinates
- /// \param theFeature the line feature
- /// \param theX the horizontal point coordinate
- /// \param theY the vertical point coordinate
- virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
- double theY);
protected:
/// Returns the feature point in the selection mode position.
/// \param theMode the current operation selection mode. The feature attribute depends on the mode
return SM_FirstPoint;
}
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintRadiusPrs::findPoint(FeaturePtr theFeature,
- double theX, double theY)
-{
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
- return aPoint2D;
-}
-
boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintRadiusPrs::featurePoint
(const PartSet_SelectionMode& theMode)
{
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// Find a point in the line with given coordinates
- /// \param theFeature the line feature
- /// \param theX the horizontal point coordinate
- /// \param theY the vertical point coordinate
- virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
- double theY);
/// Project the view point on the feature. The output coordinates belong to the feature
/// \param theFeature a feature
/// \param theSketch the sketch feature
return aMode;
}
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureArcPrs::findPoint(FeaturePtr theFeature,
- double theX, double theY)
-{
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
- if (!theFeature || theFeature->getKind() != getKind())
- return aPoint2D;
-
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
- if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
- fabs(aPoint->y() - theY) < Precision::Confusion()) {
- aPoint2D = aPoint;
- }
- if (!aPoint2D) {
- aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
- if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
- fabs(aPoint->y() - theY) < Precision::Confusion())
- aPoint2D = aPoint;
- }
- if (!aPoint2D) {
- aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_END));
- if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
- fabs(aPoint->y() - theY) < Precision::Confusion())
- aPoint2D = aPoint;
- }
- return aPoint2D;
-}
-
void PartSet_FeatureArcPrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
gp_Pnt& thePoint, Handle(V3d_View) theView,
double& theX, double& theY)
static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
Handle_V3d_View theView, double& theX, double& theY);
- /// Find a point in the line with given coordinates
- /// \param theFeature the line feature
- /// \param theX the horizontal point coordinate
- /// \param theY the vertical point coordinate
- virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
- double theY);
-
/// Computes the feature's radius
/// \param theFeature an arc feature
/// \return the double value
return aMode;
}
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureCirclePrs::findPoint(FeaturePtr theFeature,
- double theX, double theY)
-{
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
- if (!theFeature || theFeature->getKind() != getKind())
- return aPoint2D;
-
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CIRCLE_ATTR_CENTER));
- if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
- aPoint2D = aPoint;
-
- return aPoint2D;
-}
-
void PartSet_FeatureCirclePrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
gp_Pnt& thePoint, Handle(V3d_View) theView,
double& theX, double& theY)
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// Find a point in the line with given coordinates
- /// \param theFeature the line feature
- /// \param theX the horizontal point coordinate
- /// \param theY the vertical point coordinate
- virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
- double theY);
/// Project the view point on the feature. The output coordinates belong to the feature
/// \param theFeature a feature
/// \param theSketch the sketch feature
}
}
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureLinePrs::findPoint(FeaturePtr theFeature,
- double theX, double theY)
-{
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
- if (!theFeature || theFeature->getKind() != getKind())
- return aPoint2D;
-
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
- if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
- fabs(aPoint->y() - theY) < Precision::Confusion())
- aPoint2D = aPoint;
- else {
- aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
- if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
- fabs(aPoint->y() - theY) < Precision::Confusion())
- aPoint2D = aPoint;
- }
- return aPoint2D;
-}
-
boost::shared_ptr<GeomAPI_Lin2d> PartSet_FeatureLinePrs::createLin2d(FeaturePtr theFeature)
{
boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin;
const gp_Pnt& thePoint, Handle_V3d_View theView,
double& theX, double& theY);
- /// Find a point in the line with given coordinates
- /// \param theFeature the line feature
- /// \param theX the horizontal point coordinate
- /// \param theY the vertical point coordinate
- virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
- double theY);
-
/// Creates a lin 2d object on a base of the line feature
/// \param theFeature the line feature
static boost::shared_ptr<GeomAPI_Lin2d> createLin2d(FeaturePtr theFeature);
return aMode;
}
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePointPrs::findPoint(FeaturePtr theFeature,
- double theX, double theY)
-{
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
- if (!theFeature || theFeature->getKind() != getKind())
- return aPoint2D;
-
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(POINT_ATTR_COORD));
- if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
- aPoint2D = aPoint;
-
- return aPoint2D;
-}
-
boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePointPrs::featurePoint
(const PartSet_SelectionMode& theMode)
{
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// Find a point in the line with given coordinates
- /// \param theFeature the line feature
- /// \param theX the horizontal point coordinate
- /// \param theY the vertical point coordinate
- virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
- double theY);
-
protected:
/// Returns the feature point in the selection mode position.
/// \param theMode the current operation selection mode. The feature attribute depends on the mode
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const = 0;
- /// Find a point in the line with given coordinates
- /// \param theFeature the line feature
- /// \param theX the horizontal point coordinate
- /// \param theY the vertical point coordinate
- virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
- double theY) = 0;
-
protected:
/// Returns the operation feature
/// \return the feature
}
void PartSet_Tools::setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
- const std::string& theAttribute, double theX, double theY)
+ const std::string& theAttribute,
+ double theClickedX, double theClickedY)
{
// find a feature point by the selection mode
//boost::shared_ptr<GeomDataAPI_Point2D> aPoint = featurePoint(theMode);
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+ boost::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
- if (!aPoint)
+ if (!aFeaturePoint)
return;
// get all sketch features. If the point with the given coordinates belong to any sketch feature,
std::list<FeaturePtr > aFeatures = aRefList->list();
std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+ std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes;
+ boost::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = boost::shared_ptr<GeomAPI_Pnt2d>
+ (new GeomAPI_Pnt2d(theClickedX, theClickedY));
for (; anIt != aLast; anIt++)
{
FeaturePtr aFeature = *anIt;
- boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;// = aFeature->findPoint(theX, theY);
+ // find the given point in the feature attributes
+ anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+ std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
+ aLast = anAttiributes.end();
+ boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;
+ for (;anIt!=aLast && !aFPoint; anIt++) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+ if (aCurPoint && aCurPoint->pnt()->distance(aClickedPoint) < Precision::Confusion())
+ aFPoint = aCurPoint;
+ }
if (aFPoint)
- PartSet_Tools::createConstraint(theSketch, aFPoint, aPoint);
+ PartSet_Tools::createConstraint(theSketch, aFPoint, aFeaturePoint);
}
}
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::findPoint(FeaturePtr theFeature,
- double theX, double theY)
-{
- boost::shared_ptr<PartSet_FeaturePrs> aFeaturePrs = PartSet_Tools::createFeaturePrs(
- theFeature->getKind(), FeaturePtr(), theFeature);
-
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
- if (aFeaturePrs)
- aPoint2D = aFeaturePrs->findPoint(theFeature, theX, theY);
-
- return aPoint2D;
-}
-
boost::shared_ptr<GeomAPI_Pln> PartSet_Tools::sketchPlane(FeaturePtr theSketch)
{
boost::shared_ptr<GeomAPI_Pln> aPlane;
/// \param theSketch a sketch feature
/// \param theFeature a source feature
/// \param theAttribute a name of the requried attribute attribute
- /// \param theX the horizontal coordnate of the point
- /// \param theY the vertical coordnate of the point
+ /// \param theClickedX the horizontal coordnate of the point
+ /// \param theClickedY the vertical coordnate of the point
static void setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
- const std::string& theAttribute, double theX, double theY);
-
- /// Find a point in the line with given coordinates
- /// \param theFeature the line feature
- /// \param theX the horizontal point coordinate
- /// \param theY the vertical point coordinate
- static boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
- double theY);
+ const std::string& theAttribute, double theClickedX, double theClickedY);
/// Create a sketch plane instance
/// \param theSketch a sketch feature