1. Introduce the Last kind of selection in order to realize second feature selection for the distance constraint
SM_FirstPoint,
SM_SecondPoint,
SM_ThirdPoint,
+ SM_LastPoint,
SM_DonePoint
};
return SKETCH_CONSTRAINT_DISTANCE_KIND;
}
-bool PartSet_ConstraintDistancePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+PartSet_SelectionMode PartSet_ConstraintDistancePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
{
- bool aResult = false;
+ PartSet_SelectionMode aMode = theMode;
if (feature() && theFeature && theFeature->getKind() == SKETCH_LINE_KIND && theMode == SM_FirstPoint)
{
// set length feature
double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
- aResult = true;
+ aMode = SM_SecondPoint;
}
- return aResult;
+ return aMode;
}
PartSet_SelectionMode PartSet_ConstraintDistancePrs::setPoint(double theX, double theY,
PartSet_SelectionMode aMode = theMode;
switch (theMode)
{
- case SM_SecondPoint: {
+ case SM_LastPoint: {
boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
/// \param theFeature a feature instance
/// \param theMode the selection mode
/// \return whether the feature is set
- virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
+ virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
/// Sets the point to the feature in an attribute depending on the selection mode
/// \param theX the 2D point horizontal coordinate
return SKETCH_CONSTRAINT_LENGTH_KIND;
}
-bool PartSet_ConstraintLengthPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+PartSet_SelectionMode PartSet_ConstraintLengthPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
{
- bool aResult = false;
+ PartSet_SelectionMode aMode = theMode;
if (feature() && theFeature && theFeature->getKind() == SKETCH_LINE_KIND && theMode == SM_FirstPoint)
{
// set length feature
double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
- aResult = true;
+ aMode = SM_LastPoint;
}
- return aResult;
+ return aMode;
}
PartSet_SelectionMode PartSet_ConstraintLengthPrs::setPoint(double theX, double theY,
PartSet_SelectionMode aMode = theMode;
switch (theMode)
{
- case SM_SecondPoint: {
+ case SM_LastPoint: {
boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
/// \param theFeature a feature instance
/// \param theMode the selection mode
/// \return whether the feature is set
- virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
+ virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
/// Sets the point to the feature in an attribute depending on the selection mode
/// \param theX the 2D point horizontal coordinate
return SKETCH_CONSTRAINT_RADIUS_KIND;
}
-bool PartSet_ConstraintRadiusPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+PartSet_SelectionMode PartSet_ConstraintRadiusPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
{
- bool aResult = false;
+ PartSet_SelectionMode aMode = theMode;
if (!feature() || theMode != SM_FirstPoint || !theFeature) {
- return aResult;
+ return aMode;
}
std::string aKind = theFeature->getKind();
if (aKind == SKETCH_CIRCLE_KIND || aKind == SKETCH_ARC_KIND) {
}
PartSet_Tools::setFeatureValue(feature(), aLength, CONSTRAINT_ATTR_VALUE);
- aResult = true;
+ aMode = SM_LastPoint;
}
- return aResult;
+ return aMode;
}
PartSet_SelectionMode PartSet_ConstraintRadiusPrs::setPoint(double theX, double theY,
PartSet_SelectionMode aMode = theMode;
switch (theMode)
{
- case SM_SecondPoint: {
+ case SM_LastPoint: {
boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
// boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
//aFlyoutAttr->setValue(aDistance);
- aMode = SM_DonePoint;
+ aMode = SM_LastPoint;
}
break;
default:
/// \param theFeature a feature instance
/// \param theMode the selection mode
/// \return whether the feature is set
- virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
+ virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
/// Sets the point to the feature in an attribute depending on the selection mode
/// \param theX the 2D point horizontal coordinate
return aMode;
}
-bool PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+PartSet_SelectionMode PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
{
- bool aResult = false;
+ PartSet_SelectionMode aMode = theMode;
if (feature() && theFeature && theMode == SM_FirstPoint)
{
// use the last point of the previous feature as the first of the new one
boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
(aData->attribute(LINE_ATTR_START));
PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint);
- aResult = true;
+ aMode = SM_SecondPoint;
}
- return aResult;
+ return aMode;
}
std::string PartSet_FeatureLinePrs::getAttribute(const PartSet_SelectionMode& theMode) const
/// \param theFeature a feature instance
/// \param theMode the selection mode
/// \return whether the feature is set
- virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
+ virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
/// Returns the feature attribute name for the selection mode
/// \param theMode the current operation selection mode. The feature attribute depends on the mode
return myFeature;
}
+PartSet_SelectionMode PartSet_FeaturePrs::setFeature(FeaturePtr theFeature,
+ const PartSet_SelectionMode& theMode)
+{
+ return SM_FirstPoint;
+}
+
void PartSet_FeaturePrs::setConstraints(double theX, double theY,
const PartSet_SelectionMode& theMode)
{
/// \param theFeature a feature instance
/// \param theMode the selection mode
/// \return whether the feature is set
- virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode) { return false; };
+ /// \return the new selection mode
+ virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
/// Returns the feature attribute name for the selection mode
/// \param theMode the current operation selection mode. The feature attribute depends on the mode
{
switch (myPointSelectionMode)
{
- case SM_FirstPoint: {
+ case SM_FirstPoint:
+ case SM_SecondPoint: {
if (!theSelected.empty()) {
XGUI_ViewerPrs aPrs = theSelected.front();
FeaturePtr aFeature = aPrs.feature();
- if (myFeaturePrs->setFeature(aFeature, myPointSelectionMode)) {
+ PartSet_SelectionMode aMode = myFeaturePrs->setFeature(aFeature, myPointSelectionMode);
+ if (aMode != myPointSelectionMode) {
flushUpdated();
- setPointSelectionMode(SM_SecondPoint);
+ setPointSelectionMode(aMode);
}
}
}
break;
- case SM_SecondPoint: {
+ case SM_LastPoint: {
double aX, anY;
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
double aValue = PartSet_Tools::featureValue(feature(), CONSTRAINT_ATTR_VALUE, isValid);
if (isValid) {
showEditor(theEvent, aValue);
- setPointSelectionMode(SM_ThirdPoint/*aMode*/);
}
}
break;
switch (myPointSelectionMode)
{
//case SM_FirstPoint:
- case SM_SecondPoint:
- //case SM_ThirdPoint:
+ //case SM_SecondPoint:
+ case SM_LastPoint:
{
double aX, anY;
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
}
// changed
// the modification is really need until the focus of editor do not accept the focus
- if (myPointSelectionMode == SM_ThirdPoint) {
- if (myEditor->isStarted())
- myEditor->stop();
+ if (myPointSelectionMode == SM_LastPoint && myEditor->isStarted()) {
+ myEditor->stop();
commit();
// it start a new line creation at a free point
restartOperation(feature()->getKind(), FeaturePtr()/*feature()*/);
void PartSet_OperationCreateConstraint::startOperation()
{
PartSet_OperationSketchBase::startOperation();
- setPointSelectionMode(!myInitFeature ? SM_FirstPoint : SM_SecondPoint);
+ //setPointSelectionMode(!myInitFeature ? SM_FirstPoint : SM_SecondPoint);
emit multiSelectionEnabled(false);
}
aFeature->addSub(aNewFeature);
}
myFeaturePrs->init(aNewFeature);
- if (myInitFeature)
- myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
+ if (myInitFeature) {
+ PartSet_SelectionMode aMode = myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
+ //setPointSelectionMode(aMode);
+ }
emit featureConstructed(aNewFeature, FM_Activation);
if (theFlushMessage)
anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
}
}
- myFeaturePrs->setPoint(aX, anY, SM_SecondPoint);
+ myFeaturePrs->setPoint(aX, anY, SM_LastPoint);
/*std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();