]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#2027 Sketcher Trim feature - deselect base feature
authornds <nds@opencascade.com>
Tue, 14 Mar 2017 13:12:51 +0000 (16:12 +0300)
committernds <nds@opencascade.com>
Tue, 14 Mar 2017 13:13:08 +0000 (16:13 +0300)
src/PartSet/PartSet_CustomPrs.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_WidgetFeaturePointSelector.cpp
src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp
src/SketchPlugin/SketchPlugin_ConstraintSplit.h
src/SketchPlugin/SketchPlugin_Trim.cpp

index f64ed35cd6c953458fe4f92c7a2491acf5bb9218..1902c0139afd169f0147e65f7394249140dd2737 100755 (executable)
@@ -39,6 +39,8 @@ public:
   /// Returns color between white and color of highlight
   static const std::string OPERATION_HIGHLIGHT_COLOR() { return "128, 0, 0"; }
 
+  /// Returns color lighter than sketch feature entity : pink
+  static const std::string OPERATION_REMOVE_FEATURE_COLOR() { return "255, 174, 201"; }
 public:
   /// Constructor
   /// \param theWorkshop a reference to workshop
index f4480e827d1cfd2f95a90fb58031fb16a599857e..760234e1fd1cb4db515516d168ef4e979c5a8ed4 100755 (executable)
@@ -166,6 +166,9 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   Config_PropManager::registerProp("Visualization", "operation_highlight_color",
                           "Multi selector item color in operation", Config_Prop::Color,
                           PartSet_CustomPrs::OPERATION_HIGHLIGHT_COLOR());
+  Config_PropManager::registerProp("Visualization", "operation_remove_feature_color",
+                          "Color of removed feature in operation", Config_Prop::Color,
+                          PartSet_CustomPrs::OPERATION_REMOVE_FEATURE_COLOR());
 }
 
 PartSet_Module::~PartSet_Module()
index 77f1344a1cf5a07735a375c554396b8294b05ef3..e7e2458f560fe68c7a118d50c7ec2e6990d1c3b1 100755 (executable)
@@ -354,9 +354,9 @@ std::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::findFirstEqualPoint(
 }
 
 std::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::findFirstEqualPointInSketch(
-                                              const CompositeFeaturePtr& theSketch,
-                                              const std::shared_ptr<GeomDataAPI_Point2D>& theFeaturePoint,
-                                              const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+                                    const CompositeFeaturePtr& theSketch,
+                                    const std::shared_ptr<GeomDataAPI_Point2D>& theFeaturePoint,
+                                    const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
 {
   // 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
index eaa7f58e2123c5d385a150842cce833b8dbaed46..ed14ea8d6896a72b53a02f881e6c7b635386445b 100644 (file)
@@ -135,6 +135,8 @@ void PartSet_WidgetFeaturePointSelector::mouseReleased(ModuleBase_IViewWindow* t
     return;
 
   emit focusOutWidget(this);
+  // we need to deselect base feature for better visibility of selected feature
+  XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(false);
 }
 
 //********************************************************************
index db8606551df058801d15508e915f4b7120079e31..afc2536ba8f0249b0345a1ea4d7c423e49a86a12 100755 (executable)
@@ -142,23 +142,6 @@ void SketchPlugin_ConstraintSplit::execute()
     }
   }
 
-  /*if (!aTangentFeatures.empty()) {
-    std::cout << std::endl;
-    std::cout << "Tangencies to base feature[" << aTangentFeatures.size() << "]: " << std::endl;
-    std::map<FeaturePtr, IdToPointPair>::const_iterator anIt = aTangentFeatures.begin(),
-                                                        aLast = aTangentFeatures.end();
-    for (int i = 1; anIt != aLast; anIt++, i++) {
-      FeaturePtr aFeature = (*anIt).first;
-      std::string anAttributeId = (*anIt).second.first;
-      std::shared_ptr<GeomDataAPI_Point2D> 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<AttributePtr, std::list<AttributePtr> >::const_iterator
     aRefIt = aBaseRefAttributes.begin(), aRefLast = aBaseRefAttributes.end();
   std::cout << std::endl << "References to attributes of base feature [" <<
@@ -286,8 +269,6 @@ void SketchPlugin_ConstraintSplit::execute()
   // coincidence to feature
   updateCoincidenceConstraintsToFeature(aCoincidenceToFeature, aFurtherCoincidences,
                                         aFeatureResults, aSplitFeature);
-  // tangency
-  //updateTangentConstraintsToFeature(aTangentFeatures, aFurtherCoincidences);
 
   updateRefAttConstraints(aBaseRefAttributes, aModifiedAttributes);
 
@@ -440,7 +421,6 @@ void SketchPlugin_ConstraintSplit::getFeaturePoints(const FeaturePtr& theFeature
 
 void SketchPlugin_ConstraintSplit::getConstraints(std::set<FeaturePtr>& theFeaturesToDelete,
                                       std::set<FeaturePtr>& theFeaturesToUpdate,
-                                      //std::map<FeaturePtr, IdToPointPair>& theTangentFeatures,
                                       std::map<FeaturePtr, IdToPointPair>& theCoincidenceToFeature)
 {
   std::shared_ptr<ModelAPI_Data> aData = data();
@@ -467,46 +447,7 @@ void SketchPlugin_ConstraintSplit::getConstraints(std::set<FeaturePtr>& theFeatu
       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
-        /// until tangency between arc and line is implemented
-        theFeaturesToDelete.insert(aRefFeature);
-      else {
-        std::string anAttributeToBeModified;
-        AttributePoint2DPtr aTangentPoint;
-        ObjectPtr aResult1 = aRefFeature->refattr(SketchPlugin_Constraint::ENTITY_A())->object();
-        ObjectPtr aResult2 = aRefFeature->refattr(SketchPlugin_Constraint::ENTITY_B())->object();
-        if (aResult1.get() && aResult2.get()) {
-          FeaturePtr aCoincidenceFeature =
-            SketchPlugin_ConstraintCoincidence::findCoincidenceFeature
-                                                       (ModelAPI_Feature::feature(aResult1),
-                                                        ModelAPI_Feature::feature(aResult2));
-          // get the point not lying on the splitting feature
-          for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
-            AttributeRefAttrPtr aRefAttr = aCoincidenceFeature->refattr(ATTRIBUTE(i));
-            if (!aRefAttr || aRefAttr->isObject())
-              continue;
-            AttributePoint2DPtr aPoint =
-                std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aRefAttr->attr());
-            if (!aPoint)
-              continue;
-            if (aPoint->owner() != aBaseFeature) {
-              aTangentPoint = aPoint;
-              break;
-            }
-          }
-        }
-        if (aTangentPoint.get()) {
-          FeaturePtr aFeature1 = ModelAPI_Feature::feature(aResult1);
-          std::string anAttributeToBeModified = aFeature1 == aBaseFeature
-                       ? SketchPlugin_Constraint::ENTITY_A() : SketchPlugin_Constraint::ENTITY_B();
-          theTangentFeatures[aRefFeature] = std::make_pair(anAttributeToBeModified, aTangentPoint);
-        }
-        else /// there is not coincident point between tangent constraint
-          theFeaturesToDelete.insert(aRefFeature);
-      }
-    }
-    */else if (aRefFeatureKind == SketchPlugin_ConstraintCoincidence::ID()) {
+    else if (aRefFeatureKind == SketchPlugin_ConstraintCoincidence::ID()) {
       std::string anAttributeToBeModified;
       AttributePoint2DPtr aCoincidentPoint;
       AttributeRefAttrPtr anAttrA = aRefFeature->refattr(SketchPlugin_Constraint::ENTITY_A());
@@ -682,44 +623,6 @@ void SketchPlugin_ConstraintSplit::updateCoincidenceConstraintsToFeature(
   }
 }
 
-//void SketchPlugin_ConstraintSplit::updateTangentConstraintsToFeature(
-//      const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theTangentFeatures,
-//      const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences)
-//{
-//  if (theTangentFeatures.empty())
-//    return;
-//
-//  std::map<FeaturePtr, IdToPointPair>::const_iterator aTIt = theTangentFeatures.begin(),
-//                                                      aTLast = theTangentFeatures.end();
-//#ifdef DEBUG_SPLIT
-//  std::cout << std::endl;
-//  std::cout << "Tangencies to feature(modified):"<< std::endl;
-//#endif
-//  for (; aTIt != aTLast; aTIt++) {
-//    FeaturePtr aTangentFeature = aTIt->first;
-//    std::string anAttributeId = aTIt->second.first;
-//    AttributePoint2DPtr aTangentPoint = aTIt->second.second;
-//    std::set<AttributePoint2DPtr>::const_iterator aFCIt = theFurtherCoincidences.begin(),
-//                                                  aFCLast = theFurtherCoincidences.end();
-//    std::shared_ptr<GeomAPI_Pnt2d> aCoincPnt = aTangentPoint->pnt();
-//    AttributePoint2DPtr aFeaturePointAttribute;
-//    /// here we rely on created coincidence between further coincidence point and tangent result
-//    for (; aFCIt != aFCLast && !aFeaturePointAttribute.get(); aFCIt++) {
-//      AttributePoint2DPtr aFCAttribute = *aFCIt;
-//      if (aCoincPnt->isEqual(aFCAttribute->pnt()))
-//        aFeaturePointAttribute = aFCAttribute;
-//    }
-//    if (aFeaturePointAttribute.get()) {
-//      FeaturePtr aFeature =
-//        std::dynamic_pointer_cast<ModelAPI_Feature>(aFeaturePointAttribute->owner());
-//      aTangentFeature->refattr(anAttributeId)->setObject(getFeatureResult(aFeature));
-//    }
-//#ifdef DEBUG_SPLIT
-//  std::cout << " -" << getFeatureInfo(aTangentFeature) << std::endl;
-//#endif
-//  }
-//}
-
 void SketchPlugin_ConstraintSplit::updateRefFeatureConstraints(
                                                   const ResultPtr& theFeatureBaseResult,
                                                   const std::list<AttributePtr>& theRefsToFeature)
index 39bf2c03edc94f5abc51add71c8eefa3eb718edb..e4e1bc7705eb816b4abd8994ea553c445326d6b5 100755 (executable)
@@ -80,11 +80,6 @@ class SketchPlugin_ConstraintSplit : public SketchPlugin_ConstraintBase
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintSplit();
 
-  /// \return map of base points and features;
-  //SKETCHPLUGIN_EXPORT const std::map<AttributePtr, FilletFeatures> pointsFeaturesMap() const {
-  //  return myPointFeaturesMap;
-  //};
-
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
@@ -112,9 +107,7 @@ private:
   /// \param theCoincidenceToPoint [out] coincidence to point be connected to new feature
   void getConstraints(std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToDelete,
               std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToUpdate,
-              //std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theTangentFeatures,
-              std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature/*,
-              std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToPoint*/);
+              std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature);
 
   /// Obtains references to feature point attributes and to feature,
   /// e.g. for feature line: 1st container is
@@ -139,14 +132,6 @@ private:
       const std::set<ResultPtr>& theFeatureResults,
       const FeaturePtr& theSplitFeature);
 
-  /// Move tangency constraint to the nearest split feature that has a coincidence to the tangent
-  /// \param theTangentFeatures tangencies to feature to be connected to nearest feature
-  /// \param theFurtherCoincidences a list of points where coincidences is built
-  //void updateTangentConstraintsToFeature(
-  //            const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theTangentFeatures,
-  //            const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences);
-
-
   /// Move constraints from base feature to given feature
   /// \param theFeature a base feature
   /// \param theRefsToFeature list of attributes referenced to base feature
index daab0d6077371b38aa797ee4699bba77d926f563..d57e409c5ce2fd60cf93d37976278d2421694236 100644 (file)
@@ -56,6 +56,7 @@
 static const double PI = 3.141592653589793238463;
 
 static const std::string OPERATION_HIGHLIGHT_COLOR() { return "128, 0, 0"; }
+static const std::string OPERATION_REMOVE_FEATURE_COLOR() { return "255, 174, 201"; }
 
 SketchPlugin_Trim::SketchPlugin_Trim()
 {
@@ -365,8 +366,8 @@ AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious)
           bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value();
 
           std::vector<int> aColor;
-          aColor = Config_PropManager::color("Visualization", "operation_highlight_color",
-                                             OPERATION_HIGHLIGHT_COLOR());
+          aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color",
+                                             OPERATION_REMOVE_FEATURE_COLOR());
           double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH();
           int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE();
           if (isConstruction) {
@@ -374,8 +375,7 @@ AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious)
             aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY();
           }
           anAIS->setColor(aColor[0], aColor[1], aColor[2]);
-           // modification of width should be replaced to value 1 after highlight problem is fixed
-          anAIS->setWidth(aWidth + 2);//1);
+          anAIS->setWidth(aWidth);
           anAIS->setLineStyle(aLineStyle);
           break;
         }