From: nds Date: Wed, 7 Sep 2016 09:27:01 +0000 (+0300) Subject: 1. Tangent Arc - restart operation. Scenario: create Line, point, Start tangent arc... X-Git-Tag: V_2.5.0~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6da8c412d0102f5997e2af9734edf23627daf937;p=modules%2Fshaper.git 1. Tangent Arc - restart operation. Scenario: create Line, point, Start tangent arc creation, Select point of Line, point, Mouse move to have new tangent arc, result: coincidence to CENTER_ID 2. #1717 split and length constraint --- diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 3f84648c8..4cfcf167d 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -157,6 +158,11 @@ bool PartSet_SketcherReetntrantMgr::processMouseMoved(ModuleBase_IViewWindow* th } bool aCanBeActivatedByMove = isLineFeature || isArcFeature; if (aCanBeActivatedByMove) { + /// before restarting of operation we need to clear selection, as it may take part in + /// new feature creation, e.g. tangent arc. But it is not necessary as it was processed + /// by mouse release when the operation was restarted. + workshop()->selector()->clearSelection(); + myPreviousFeature = aFOperation->feature(); restartOperation(); myPreviousFeature = FeaturePtr(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index ba18dae3e..9a87f7f26 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -103,6 +103,18 @@ bool SketchPlugin_ConstraintLength::compute(const std::string& theAttributeId) return true; } +bool SketchPlugin_ConstraintLength::computeLenghtValue(double& theValue) +{ + bool aResult = false; + std::shared_ptr aPoint1, aPoint2; + std::shared_ptr aStartPoint, anEndPoint; + if (getPoints(aPoint1, aPoint2, aStartPoint, anEndPoint)) { + theValue = aPoint1->distance(aPoint2); + aResult = true; + } + return aResult; +} + bool SketchPlugin_ConstraintLength::getPoints( std::shared_ptr& thePoint1, std::shared_ptr& thePoint2, std::shared_ptr& theStartPoint, @@ -175,12 +187,9 @@ void SketchPlugin_ConstraintLength::attributeChanged(const std::string& theID) { std::shared_ptr aValueAttr = std::dynamic_pointer_cast< ModelAPI_AttributeDouble>(attribute(SketchPlugin_Constraint::VALUE())); if (!aValueAttr->isInitialized()) { // only if it is not initialized, try to compute the current value - std::shared_ptr aPoint1, aPoint2; - std::shared_ptr aStartPoint, anEndPoint; - if (getPoints(aPoint1, aPoint2, aStartPoint, anEndPoint)) { - double aLength = aPoint1->distance(aPoint2); + double aLength; + if (computeLenghtValue(aLength)) aValueAttr->setValue(aLength); - } } } else if (theID == SketchPlugin_Constraint::FLYOUT_VALUE_PNT() && !myFlyoutUpdate) { myFlyoutUpdate = true; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.h b/src/SketchPlugin/SketchPlugin_ConstraintLength.h index 662e276ee..af63c7f9d 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.h @@ -71,8 +71,13 @@ class SketchPlugin_ConstraintLength : public SketchPlugin_ConstraintBase /// \brief Use plugin manager for features creation SketchPlugin_ConstraintLength(); + /// Computes distance between lenght point attributes + /// \param theValue [out] distance or 0 if one of point attributes is not initialized + /// \return boolean value if distance is computed + bool computeLenghtValue(double& theValue); + private: - // retrns the points-base of length, returns false if it is not possible + /// retrns the points-base of length, returns false if it is not possible bool getPoints( std::shared_ptr& thePoint1, std::shared_ptr& thePoint2, std::shared_ptr& theStartPoint, diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp index 7ef3dd553..54edf285c 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -86,12 +88,10 @@ void SketchPlugin_ConstraintSplit::execute() // Find feature constraints FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value()); ResultPtr aBaseFeatureResult = getFeatureResult(aBaseFeature); - - std::set aFeaturesToDelete; + std::set aFeaturesToDelete, aFeaturesToUpdate; std::map aTangentFeatures; std::map aCoincidenceToFeature; - //std::map aCoincidenceToPoint; - getConstraints(aFeaturesToDelete, aTangentFeatures, aCoincidenceToFeature);//, aCoincidenceToPoint); + getConstraints(aFeaturesToDelete, aFeaturesToUpdate, aTangentFeatures, aCoincidenceToFeature); std::map > aBaseRefAttributes; getRefAttributes(aBaseFeature, aBaseRefAttributes); @@ -145,21 +145,6 @@ void SketchPlugin_ConstraintSplit::execute() } } - /*if (!aCoincidenceToPoint.empty()) { - std::cout << std::endl; - std::cout << "Coincidences to points on base feature[" << aCoincidenceToPoint.size() << "]: " << std::endl; - std::map::const_iterator anIt = aCoincidenceToPoint.begin(), - aLast = aCoincidenceToPoint.end(); - for (int i = 1; anIt != aLast; anIt++, i++) { - FeaturePtr aFeature = (*anIt).first; - std::string anAttributeId = (*anIt).second.first; - std::shared_ptr aPointAttr = (*anIt).second.second; - - std::cout << i << "-" << getFeatureInfo(aFeature) << std::endl; - std::cout << " -Attribute to correct:" << anAttributeId << std::endl; - std::cout << " -Point attribute:" << ModelGeomAlgo_Point2D::getPointAttributeInfo(aPointAttr) << std::endl; - } - }*/ std::map >::const_iterator aRefIt = aBaseRefAttributes.begin(), aRefLast = aBaseRefAttributes.end(); std::cout << std::endl << "References to attributes of base feature [" << aBaseRefAttributes.size() << "]" << std::endl; @@ -262,9 +247,6 @@ void SketchPlugin_ConstraintSplit::execute() // coincidence to feature updateCoincidenceConstraintsToFeature(aCoincidenceToFeature, aFurtherCoincidences, aFeatureResults); - // coincidence to points - //updateCoincidenceConstraintsToFeature(aCoincidenceToPoint, aFurtherCoincidences, - // std::set()); // tangency updateTangentConstraintsToFeature(aTangentFeatures, aFurtherCoincidences); @@ -282,6 +264,17 @@ void SketchPlugin_ConstraintSplit::execute() #endif ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToDelete); +#ifdef DEBUG_SPLIT + std::cout << "update features after split:" << std::endl; + std::set::const_iterator anUIt = aFeaturesToUpdate.begin(), + anULast = aFeaturesToUpdate.end(); + for (; anUIt != anULast; anUIt++) { + std::cout << getFeatureInfo(*anUIt, false) << std::endl; + std::cout << std::endl; + } +#endif + updateFeaturesAfterSplit(aFeaturesToUpdate); + // Send events to update the sub-features by the solver. if(isUpdateFlushed) { Events_Loop::loop()->setFlushed(anUpdateEvent, true); @@ -344,9 +337,9 @@ void SketchPlugin_ConstraintSplit::getFeaturePoints(AttributePoint2DPtr& theStar } void SketchPlugin_ConstraintSplit::getConstraints(std::set& theFeaturesToDelete, + std::set& theFeaturesToUpdate, std::map& theTangentFeatures, - std::map& theCoincidenceToFeature/*, - std::map& theCoincidenceToPoint*/) + std::map& theCoincidenceToFeature) { std::shared_ptr aData = data(); @@ -369,6 +362,8 @@ void SketchPlugin_ConstraintSplit::getConstraints(std::set& theFeatu aRefFeatureKind == SketchPlugin_MultiRotation::ID() || aRefFeatureKind == SketchPlugin_MultiTranslation::ID()) theFeaturesToDelete.insert(aRefFeature); + else if (aRefFeatureKind == SketchPlugin_ConstraintLength::ID()) + theFeaturesToUpdate.insert(aRefFeature); else if (aRefFeatureKind == SketchPlugin_ConstraintTangent::ID()) { if (aBaseFeature->getKind() == SketchPlugin_Circle::ID()) /// TEMPORARY limitaion theFeaturesToDelete.insert(aRefFeature); /// until tangency between arc and line is implemented @@ -456,9 +451,6 @@ void SketchPlugin_ConstraintSplit::getConstraints(std::set& theFeatu if (isToFeature) theCoincidenceToFeature[aRefFeature] = std::make_pair(anAttributeToBeModified, aCoincidentPoint); - //else - //theCoincidenceToPoint[aRefFeature] = std::make_pair(anAttributeToBeModified, - // aCoincidentPoint); } else theFeaturesToDelete.insert(aRefFeature); /// this case should not happen @@ -1103,6 +1095,28 @@ FeaturePtr SketchPlugin_ConstraintSplit::createConstraintForObjects(const std::s return aConstraint; } +void SketchPlugin_ConstraintSplit::updateFeaturesAfterSplit( + const std::set& theFeaturesToUpdate) +{ + std::set::const_iterator anIt = theFeaturesToUpdate.begin(), + aLast = theFeaturesToUpdate.end(); + for (; anIt != aLast; anIt++) { + FeaturePtr aRefFeature = std::dynamic_pointer_cast(*anIt); + std::string aRefFeatureKind = aRefFeature->getKind(); + if (aRefFeatureKind == SketchPlugin_ConstraintLength::ID()) { + std::shared_ptr aLenghtFeature = + std::dynamic_pointer_cast(*anIt); + if (aLenghtFeature.get()) { + std::shared_ptr aValueAttr = std::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(aLenghtFeature->attribute(SketchPlugin_Constraint::VALUE())); + double aValue; + if (aLenghtFeature->computeLenghtValue(aValue) && aValueAttr.get()) + aValueAttr->setValue(aValue); + } + } + } +} + std::shared_ptr SketchPlugin_ConstraintSplit::getFeatureResult( const std::shared_ptr& theFeature) { diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.h b/src/SketchPlugin/SketchPlugin_ConstraintSplit.h index f8f90dcb7..1acbadd2b 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.h @@ -101,10 +101,12 @@ private: /// Obtains those constraints of the feature that should be modified. output maps contain /// point of coincidence and attribute id to be modified after split /// \param theFeaturesToDelete [out] constrains that will be deleted after split + /// \param theFeaturesToUpdate [out] constrains that will be updated after split /// \param theTangentFeatures [out] tangent feature to be connected to new feature /// \param theCoincidenceToFeature [out] coincidence to feature to be connected to new feature /// \param theCoincidenceToPoint [out] coincidence to point be connected to new feature void getConstraints(std::set>& theFeaturesToDelete, + std::set>& theFeaturesToUpdate, std::map, IdToPointPair>& theTangentFeatures, std::map, IdToPointPair>& theCoincidenceToFeature/*, std::map, IdToPointPair>& theCoincidenceToPoint*/); @@ -240,6 +242,10 @@ private: const std::shared_ptr& theFirstObject, const std::shared_ptr& theSecondObject); + /// Add feature coincidence constraint between given attributes + /// \param theFeaturesToUpdate a constraint index + void updateFeaturesAfterSplit(const std::set& theFeaturesToUpdate); + /// Result result of the feature to build constraint with. For arc, circle it is an edge result. /// \param theFeature a feature /// \return result object diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index e37d69f91..82c99cf8c 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -241,7 +241,7 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget, if (isFoundWidget || !theWidget) { if (!aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID())) - continue; // this attribute is not participated in the current case + continue; // this attribute does not participate in the current case if (isCheckVisibility && !aCurrentWidget->isInternal()) { if (!aCurrentWidget->isVisible()) continue;