Move setConstraint method to the feature.
{
return myAttributeID;
}
-
-void ModuleBase_ModelWidget::setHasDefaultValue(const bool& theHasDefaultValue)
-{
- myHasDefaultValue = theHasDefaultValue;
-}
/// \return a boolean value
bool hasDefaultValue() const { return myHasDefaultValue; }
+ /// Returns the attribute name
+ /// \returns the string value
+ std::string attributeID() const;
+
signals:
/// The signal about widget values changed
void valuesChanged();
void keyReleased(const std::string& theAttributeName, QKeyEvent* theEvent);
protected:
- /// Returns the attribute name
- /// \returns the string value
- std::string attributeID() const;
-
- /// Sets the has default value state to the widget
- /// \param theHasDefaultValue the boolean value
- void setHasDefaultValue(const bool& theHasDefaultValue);
+ bool myHasDefaultValue; /// the boolean state whether the control has a default value
private:
- bool myHasDefaultValue; /// the boolean state whether the control has a default value
std::string myAttributeID; /// the attribute name of the model feature
};
aProp = theData->getProperty(DOUBLE_WDG_DFLT);
double aDefVal = QString::fromStdString(aProp).toDouble(&isOk);
- setHasDefaultValue(isOk);
+ myHasDefaultValue = isOk;
if (isOk) {
mySpinBox->setValue(aDefVal);
}
{
return SM_FirstPoint;
}
-
-void PartSet_FeaturePrs::setConstraints(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- // find a feature point by the selection mode
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = featurePoint(theMode);
-
- // get all sketch features. If the point with the given coordinates belong to any sketch feature,
- // the constraint is created between the feature point and the found sketch point
- boost::shared_ptr<ModelAPI_Data> aData = sketch()->data();
- boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
-
- std::list<FeaturePtr > aFeatures = aRefList->list();
- std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
- for (; anIt != aLast; anIt++)
- {
- FeaturePtr aFeature = *anIt;
- boost::shared_ptr<GeomDataAPI_Point2D> aFPoint = PartSet_Tools::findPoint(aFeature, theX, theY);
- if (aFPoint)
- PartSet_Tools::createConstraint(sketch(), aFPoint, aPoint);
- }
-}
virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
double theY) = 0;
- /// Creates constrains of the current
- /// \param theX the horizontal coordnate of the point
- /// \param theY the vertical coordnate of the point
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- void setConstraints(double theX, double theY, const PartSet_SelectionMode& theMode);
-
protected:
/// Returns the operation feature
/// \return the feature
aPoint = BRep_Tool::Pnt(aVertex);
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
- myFeaturePrs->setConstraints(aX, anY, myPointSelectionMode);
+ //myFeaturePrs->setConstraints(aX, anY, myPointSelectionMode);
}
}
else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected
aPoint = BRep_Tool::Pnt(aVertex);
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
- //myFeaturePrs->setConstraints(aX, anY, myPointSelectionMode);
+ PartSet_Tools::setConstraints(sketch(), feature(), myActiveWidget->attributeID(),
+ aX, anY);
}
}
else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected
// TODO: to be realized in the custom point selector. The last point values of the init feature
// should be to to the start point of a new feature
//myActiveWidget->init(myInitFeature);
+ //PartSet_FeatureLinePrs::setFeature(myInitFeature, SM_FirstPoint);
myInitFeature = FeaturePtr();
emit activateNextWidget(myActiveWidget);
}
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Document.h>
#include <GeomDataAPI_Point.h>
aFeature->execute();
}
+void PartSet_Tools::setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
+ const std::string& theAttribute, double theX, double theY)
+{
+ // find a feature point by the selection mode
+ //boost::shared_ptr<GeomDataAPI_Point2D> aPoint = featurePoint(theMode);
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
+ if (!aPoint)
+ return;
+
+ // get all sketch features. If the point with the given coordinates belong to any sketch feature,
+ // the constraint is created between the feature point and the found sketch point
+ boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
+ boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
+
+ std::list<FeaturePtr > aFeatures = aRefList->list();
+ std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+ for (; anIt != aLast; anIt++)
+ {
+ FeaturePtr aFeature = *anIt;
+ boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;// = aFeature->findPoint(theX, theY);
+ if (aFPoint)
+ PartSet_Tools::createConstraint(theSketch, aFPoint, aPoint);
+ }
+}
+
boost::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::findPoint(FeaturePtr theFeature,
double theX, double theY)
{
return theKind == PartSet_ConstraintLengthPrs::getKind() ||
theKind == PartSet_ConstraintDistancePrs::getKind() ||
theKind == PartSet_ConstraintRadiusPrs::getKind();
-}
\ No newline at end of file
+}
boost::shared_ptr<GeomDataAPI_Point2D> thePoint1,
boost::shared_ptr<GeomDataAPI_Point2D> thePoint2);
+ /// Creates constrains of the current
+ /// \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
+ 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