]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1343 Improvement of Extrusion and Revolution operations: sketcher start or...
authornds <nds@opencascade.com>
Tue, 22 Mar 2016 11:28:44 +0000 (14:28 +0300)
committerdbv <dbv@opencascade.com>
Fri, 25 Mar 2016 15:50:17 +0000 (18:50 +0300)
19 files changed:
src/ExchangePlugin/plugin-Exchange.xml
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp [new file with mode: 0755]
src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.h [new file with mode: 0755]
src/FeaturesPlugin/extrusion_widget.xml
src/FeaturesPlugin/group_widget.xml
src/FeaturesPlugin/revolution_widget.xml
src/GeomValidators/CMakeLists.txt
src/GeomValidators/GeomValidators_FeatureKind.cpp [new file with mode: 0755]
src/GeomValidators/GeomValidators_FeatureKind.h [new file with mode: 0755]
src/GeomValidators/GeomValidators_Plugin.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/PartSet/PartSet_WidgetSketchCreator.cpp
src/PartSet/PartSet_WidgetSketchCreator.h
src/XGUI/XGUI_OperationMgr.cpp

index d8bb8a0c7f8cb97e8af8a8f3dcde3ed6005436bf..1dfef175e3573b167965fed582920ba3653142e1 100644 (file)
@@ -12,7 +12,8 @@
         <export_file_selector id="file_path" type="save" title="Export file" path="">
           <validator id="ExchangePlugin_ExportFormat" parameters="BREP|BRP:BREP,STEP|STP:STEP,IGES|IGS:IGES-5.1,IGES|IGS:IGES-5.3" />
         </export_file_selector>
-        <multi_selector id="selection_list" tooltip="Select a set of objects" type_choice="Vertices Edges Faces Solids Objects">
+        <multi_selector id="selection_list" tooltip="Select a set of objects"
+                        type_choice="Vertices Edges Faces Solids Objects" use_choice="true">
           <validator id="GeomValidators_Finite"/>
         </multi_selector>
       </feature>
index 8a1001b85a5c495e3fcb0d81cf353471b0b35bd4..86530f1647f1f58a8cdcf1a41d0d43138b65af25 100644 (file)
@@ -26,6 +26,7 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_RevolutionBoolean.h
     FeaturesPlugin_RevolutionCut.h
     FeaturesPlugin_RevolutionFuse.h
+    FeaturesPlugin_ValidatorExtrusionBase.h
     FeaturesPlugin_ValidatorTransform.h
     FeaturesPlugin_Validators.h
 )
@@ -52,6 +53,7 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_RevolutionBoolean.cpp
     FeaturesPlugin_RevolutionCut.cpp
     FeaturesPlugin_RevolutionFuse.cpp
+    FeaturesPlugin_ValidatorExtrusionBase.cpp
     FeaturesPlugin_ValidatorTransform.cpp
     FeaturesPlugin_Validators.cpp
 )
@@ -80,6 +82,7 @@ INCLUDE_DIRECTORIES(
   ../ModelAPI
   ../GeomAPI
   ../GeomAlgoAPI
+  ../GeomValidators
   ../Events
 )
 
@@ -88,6 +91,7 @@ SET(PROJECT_LIBRARIES
     ModelAPI
     GeomAPI
     GeomAlgoAPI
+    GeomValidators
 )
 
 ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS)
index 432e388507c47507a92f8fb499bd1c50e5bd6ab2..0fd2ba3b4efb4fa6ba21c99ea9f0d52f27eb36b7 100644 (file)
@@ -19,6 +19,7 @@
 #include <FeaturesPlugin_RevolutionFuse.h>
 #include <FeaturesPlugin_Rotation.h>
 #include <FeaturesPlugin_ValidatorTransform.h>
+#include <FeaturesPlugin_ValidatorExtrusionBase.h>
 #include <FeaturesPlugin_Validators.h>
 
 #include <ModelAPI_Session.h>
@@ -38,6 +39,8 @@ FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   aFactory->registerValidator("FeaturesPlugin_ValidatorTransform",
                               new FeaturesPlugin_ValidatorTransform);
+  aFactory->registerValidator("FeaturesPlugin_ValidatorExtrusionBase",
+                              new FeaturesPlugin_ValidatorExtrusionBase);
   aFactory->registerValidator("FeaturesPlugin_PipeLocationsValidator",
                               new FeaturesPlugin_PipeLocationsValidator);
 
diff --git a/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp b/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp
new file mode 100755 (executable)
index 0000000..7f16df4
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include "FeaturesPlugin_ValidatorExtrusionBase.h"
+
+#include "GeomValidators_FeatureKind.h"
+#include "GeomValidators_ShapeType.h"
+
+#include "ModelAPI_AttributeSelectionList.h"
+#include "ModelAPI_ResultPart.h"
+#include "ModelAPI_ResultBody.h"
+#include "ModelAPI_ResultCompSolid.h"
+#include "ModelAPI_Session.h"
+
+bool FeaturesPlugin_ValidatorExtrusionBase::isValid(const AttributePtr& theAttribute,
+                                                const std::list<std::string>& theArguments,
+                                                std::string& theError) const
+{
+  bool aValid = true;
+
+  GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind();
+  // check whether the selection is on the sketch
+  bool aFeatureKindValid = aValidator->isValid(theAttribute, theArguments, theError);
+  if (!aFeatureKindValid) {
+    // check if selection has Face selected
+    GeomValidators_ShapeType* aShapeType = new GeomValidators_ShapeType();
+    std::list<std::string> anArguments;
+    anArguments.push_back("face");
+    aValid = aShapeType->isValid(theAttribute, anArguments, theError);
+  }
+  return aValid;
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.h b/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.h
new file mode 100755 (executable)
index 0000000..240718b
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        FeaturesPlugin_ValidatorExtrusionBase.h
+// Created:     16 Sep 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef FeaturesPlugin_ValidatorExtrusionBase_H
+#define FeaturesPlugin_ValidatorExtrusionBase_H
+
+#include "ModelAPI_AttributeValidator.h"
+
+/** \class FeaturesPlugin_ValidatorExtrusionBase
+ *  \ingroup Validators
+ *  \brief A validator of selection
+ */
+class FeaturesPlugin_ValidatorExtrusionBase : public ModelAPI_AttributeValidator
+{
+ public:
+  /** \return true if attribute is valid
+   *  \param theAttribute the checked attribute
+   *  \param theArguments arguments of the attribute
+   *  \param theError error message
+   */
+  virtual bool isValid(const AttributePtr& theAttribute,
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
+};
+
+#endif
index 09462cf8e0f2c8dc4ae15345de5c74f08a14ce1b..6f0faf6104e04b91309f3cdb869f543a6fb7218a 100644 (file)
@@ -9,17 +9,17 @@ Extrusion will be filled with them"
     icon=":icons/sketch.png"
     use_body="false"
     tooltip="Create or edit a sketch"
-    shape_types="vertex edge face wire objects">
+    shape_types="face objects">
   </sketch_launcher>
+  <composite_multi_selector id="base"
+    label="Select a sketch face"
+    icon=":icons/sketch.png"
+    tooltip="Select a sketch face"
+    type_choice="Faces Objects">
+    <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+  </composite_multi_selector>
   <toolbox id="CreationMethod">
     <box id="BySizes" title="By sizes" icon=":icons/dimension_up_down_32x32.png">
-      <composite_multi_selector id="base"
-        label="Select a sketch face"
-        icon=":icons/sketch.png"
-        tooltip="Select a sketch face"
-        type_choice="Faces">
-        <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
-      </composite_multi_selector>
       <groupbox>
         <doublevalue
           id="to_size"
@@ -42,13 +42,6 @@ Extrusion will be filled with them"
       </groupbox>
     </box>
     <box id="ByPlanesAndOffsets" title="By bounding planes and offsets" icon=":icons/plane_inverted_32x32.png">
-      <composite_multi_selector id="base"
-        label="Select a sketch face"
-        icon=":icons/sketch.png"
-        tooltip="Select a sketch face"
-        type_choice="Faces">
-        <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
-      </composite_multi_selector>
       <groupbox title="From">
         <shape_selector id="from_object"
                         icon=":icons/plane.png"
index a39b7ac96287da1f5fc60e96072b9f92d45e81e2..731522c559459caa12ebae1d2365803ba4357324 100644 (file)
@@ -3,7 +3,8 @@
 <source>
   <multi_selector id="group_list"
     tooltip="Select a set of objects"
-    type_choice="Vertices Edges Faces Solids">
+    type_choice="Vertices Edges Faces Solids"
+    use_choice="true">
     <validator id="GeomValidators_BodyShapes" parameters="Sketch"/>
   </multi_selector>
 </source>
\ No newline at end of file
index 80ad354cd995d1c865a3656e431fb1e9f77609bc..187317bc087ab9c109f2672c6c7f6836b18895a8 100644 (file)
@@ -8,7 +8,7 @@
         icon=":icons/sketch.png"
         tooltip="Select a sketch face"
         type_choice="Faces">
-        <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
+        <validator id="GeomValidators_FeatureKind" parameters="Sketch"/>
       </multi_selector>
       <shape_selector id="axis_object"
                       icon=":icons/axis.png"
@@ -45,7 +45,7 @@
         icon=":icons/sketch.png"
         tooltip="Select a sketch face"
         type_choice="Faces">
-        <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
+        <validator id="GeomValidators_FeatureKind" parameters="Sketch"/>
       </multi_selector>
       <shape_selector id="axis_object"
                       icon=":icons/axis.png"
index af20eedc4c250afe68b591f44450f8404d260664..c64d2a557c272cba75a5286c8b05c5a77d50686f 100644 (file)
@@ -9,6 +9,7 @@ SET(PROJECT_HEADERS
     GeomValidators_ConstructionComposite.h
     GeomValidators_DifferentShapes.h
     GeomValidators_Face.h
+    GeomValidators_FeatureKind.h
     GeomValidators_Finite.h
     GeomValidators_PartitionArguments.h
     GeomValidators_Plugin.h
@@ -27,6 +28,7 @@ SET(PROJECT_SOURCES
     GeomValidators_ConstructionComposite.cpp
     GeomValidators_DifferentShapes.cpp
     GeomValidators_Face.cpp
+    GeomValidators_FeatureKind.cpp
     GeomValidators_Finite.cpp
     GeomValidators_PartitionArguments.cpp
     GeomValidators_Plugin.cpp
diff --git a/src/GeomValidators/GeomValidators_FeatureKind.cpp b/src/GeomValidators/GeomValidators_FeatureKind.cpp
new file mode 100755 (executable)
index 0000000..cdf2ebd
--- /dev/null
@@ -0,0 +1,100 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomValidators_FeatureKind.cpp
+// Created:     22 March 2015
+// Author:      Natalia Ermolaeva
+
+#include "GeomValidators_FeatureKind.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_Object.h>
+
+bool GeomValidators_FeatureKind::isValid(const AttributePtr& theAttribute,
+                                      const std::list<std::string>& theArguments,
+                                      std::string& theError) const
+{
+  bool isSketchEntities = true;
+  std::set<std::string> anEntityKinds;
+  std::string anEntityKindsStr;
+  std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
+  for (; anIt != aLast; anIt++) {
+    anEntityKinds.insert(*anIt);
+    if (!anEntityKindsStr.empty())
+      anEntityKindsStr += ", ";
+    anEntityKindsStr += *anIt;
+  }
+
+  std::string anAttributeType = theAttribute->attributeType();
+  if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectionListAttr = 
+                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+    // all context objects should be sketch entities
+    for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize && isSketchEntities; i++) {
+      AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
+      ObjectPtr anObject = aSelectAttr->context();
+      // a context of the selection attribute is a feature result. It can be a case when the result
+      // of the feature is null, e.g. the feature is modified and has not been executed yet.
+      // The validator returns an invalid result here. The case is an extrusion built on a sketch
+      // feature. A new sketch element creation leads to an empty result.
+      if (!anObject.get())
+        isSketchEntities = false;
+      else {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+        isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+      }
+    }
+  }
+  if (anAttributeType == ModelAPI_AttributeSelection::typeId()) {
+    AttributeSelectionPtr aSelectAttr = 
+                      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+    ObjectPtr anObject = aSelectAttr->context();
+    // a context of the selection attribute is a feature result. It can be a case when the result
+    // of the feature is null, e.g. the feature is modified and has not been executed yet.
+    // The validator returns an invalid result here. The case is an extrusion built on a sketch
+    // feature. A new sketch element creation leads to an empty result.
+    if (!anObject.get())
+      isSketchEntities = false;
+    else {
+      FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+      isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+    }
+  }
+  if (anAttributeType == ModelAPI_AttributeRefList::typeId()) {
+    AttributeRefListPtr aRefListAttr =
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+    // all context objects should be sketch entities
+    for (int i = 0, aSize = aRefListAttr->size(); i < aSize && isSketchEntities; i++) {
+      ObjectPtr anObject = aRefListAttr->object(i);
+      // a context of the selection attribute is a feature result. It can be a case when the result
+      // of the feature is null, e.g. the feature is modified and has not been executed yet.
+      // The validator returns an invalid result here. The case is an extrusion built on a sketch
+      // feature. A new sketch element creation leads to an empty result.
+      if (!anObject.get())
+        isSketchEntities = false;
+      else {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+        isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+      }
+    }
+  }
+  if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
+    std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+                     std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+    isSketchEntities = false;
+    if (aRef->isObject()) {
+      ObjectPtr anObject = aRef->object();
+      if (anObject.get() != NULL) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+        if (aFeature.get() != NULL)
+          isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
+      }
+    }
+  }
+  if (!isSketchEntities) {
+    theError = "It refers to feature, which kind is not in the list: " + anEntityKindsStr;
+  }
+
+  return isSketchEntities;
+}
diff --git a/src/GeomValidators/GeomValidators_FeatureKind.h b/src/GeomValidators/GeomValidators_FeatureKind.h
new file mode 100755 (executable)
index 0000000..8949927
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomValidators_FeatureKind.h
+// Created:     22 March 2015
+// Author:      Natalia Ermolaeva
+
+#ifndef GeomValidators_FeatureKind_H
+#define GeomValidators_FeatureKind_H
+
+#include <GeomValidators.h>
+
+#include <ModelAPI_AttributeValidator.h>
+#include <ModelAPI_Attribute.h>
+
+/**
+ * Generic validator for any attribute of a feature.
+ */
+class GeomValidators_FeatureKind : public ModelAPI_AttributeValidator
+{
+public:
+  /// \return True if the attribute is valid. It checks whether the shape is a
+  /// body subshape. Does not allow select construction shapes.
+  /// \param[in] theAttribute an attribute to check
+  /// \param[in] theArguments a filter parameters
+  /// \param[out] theError error message.
+  GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
+                                             const std::list<std::string>& theArguments,
+                                             std::string& theError) const;
+};
+
+#endif
index 824206f632a4de4dfe64c5e12599805b8313c4f3..831ad0dc922d540fc4f5e8aec02f19bb139df4c7 100644 (file)
@@ -14,6 +14,7 @@
 #include <GeomValidators_ShapeType.h>
 #include <GeomValidators_ZeroOffset.h>
 #include <GeomValidators_IntersectionSelection.h>
+#include <GeomValidators_FeatureKind.h>
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
@@ -39,6 +40,7 @@ GeomValidators_Plugin::GeomValidators_Plugin()
   aFactory->registerValidator("GeomValidators_ZeroOffset", new GeomValidators_ZeroOffset);
   aFactory->registerValidator("GeomValidators_BooleanSelection", new GeomValidators_BooleanSelection);
   aFactory->registerValidator("GeomValidators_IntersectionSelection", new GeomValidators_IntersectionSelection);
+  aFactory->registerValidator("GeomValidators_FeatureKind", new GeomValidators_FeatureKind);
 
   // register this plugin
   ModelAPI_Session::get()->registerPlugin(this);
index f5c1ef25189538e99e380c7265321c6785bd7132..59c24dc85b9ae9e8f0d6a0668385fed30cee5704 100755 (executable)
@@ -101,7 +101,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen
   QString aTypesStr = aPropertyTypes.c_str();
   QStringList aShapeTypes = aTypesStr.split(' ', QString::SkipEmptyParts);
 
-  myIsUseChoice = theData->getBooleanAttribute("use_choice", true);
+  myIsUseChoice = theData->getBooleanAttribute("use_choice", false);
 
   if (!aShapeTypes.empty())
     myTypeCombo->addItems(aShapeTypes);
index 08a3de2c5d722d3472322d91669244ba9f17da70..fe337ef0b16199c452291757c053f3ec5dbedbee 100755 (executable)
@@ -221,7 +221,6 @@ void PartSet_Module::registerValidators()
   aFactory->registerValidator("PartSet_MiddlePointSelection", new PartSet_MiddlePointSelection);
   aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
   aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr);
-  aFactory->registerValidator("PartSet_SketchEntityValidator", new PartSet_SketchEntityValidator);
 }
 
 void PartSet_Module::registerFilters()
index 163063bd0b514ba46ac4bb844ae5dc0701230762..32c028565dce545a42ee4141e8e188d146360804 100755 (executable)
@@ -533,94 +533,6 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
   return true;
 }
 
-bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
-                                            const std::list<std::string>& theArguments,
-                                            std::string& theError) const
-{
-  bool isSketchEntities = true;
-  std::set<std::string> anEntityKinds;
-  std::string anEntityKindsStr;
-  std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
-  for (; anIt != aLast; anIt++) {
-    anEntityKinds.insert(*anIt);
-    if (!anEntityKindsStr.empty())
-      anEntityKindsStr += ", ";
-    anEntityKindsStr += *anIt;
-  }
-
-  std::string anAttributeType = theAttribute->attributeType();
-  if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
-    AttributeSelectionListPtr aSelectionListAttr = 
-                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
-    // all context objects should be sketch entities
-    for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize && isSketchEntities; i++) {
-      AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
-      ObjectPtr anObject = aSelectAttr->context();
-      // a context of the selection attribute is a feature result. It can be a case when the result
-      // of the feature is null, e.g. the feature is modified and has not been executed yet.
-      // The validator returns an invalid result here. The case is an extrusion built on a sketch
-      // feature. A new sketch element creation leads to an empty result.
-      if (!anObject.get())
-        isSketchEntities = false;
-      else {
-        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
-        isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
-      }
-    }
-  }
-  if (anAttributeType == ModelAPI_AttributeSelection::typeId()) {
-    AttributeSelectionPtr aSelectAttr = 
-                      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
-    ObjectPtr anObject = aSelectAttr->context();
-    // a context of the selection attribute is a feature result. It can be a case when the result
-    // of the feature is null, e.g. the feature is modified and has not been executed yet.
-    // The validator returns an invalid result here. The case is an extrusion built on a sketch
-    // feature. A new sketch element creation leads to an empty result.
-    if (!anObject.get())
-      isSketchEntities = false;
-    else {
-      FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
-      isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
-    }
-  }
-  if (anAttributeType == ModelAPI_AttributeRefList::typeId()) {
-    AttributeRefListPtr aRefListAttr =
-      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
-    // all context objects should be sketch entities
-    for (int i = 0, aSize = aRefListAttr->size(); i < aSize && isSketchEntities; i++) {
-      ObjectPtr anObject = aRefListAttr->object(i);
-      // a context of the selection attribute is a feature result. It can be a case when the result
-      // of the feature is null, e.g. the feature is modified and has not been executed yet.
-      // The validator returns an invalid result here. The case is an extrusion built on a sketch
-      // feature. A new sketch element creation leads to an empty result.
-      if (!anObject.get())
-        isSketchEntities = false;
-      else {
-        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
-        isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
-      }
-    }
-  }
-  if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
-    std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
-                     std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
-    isSketchEntities = false;
-    if (aRef->isObject()) {
-      ObjectPtr anObject = aRef->object();
-      if (anObject.get() != NULL) {
-        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
-        if (aFeature.get() != NULL)
-          isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();
-      }
-    }
-  }
-  if (!isSketchEntities) {
-    theError = "It refers to feature, which kind is not in the list: " + anEntityKindsStr;
-  }
-
-  return isSketchEntities;
-}
-
 bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute, 
                                      const std::list<std::string>& theArguments,
                                      std::string& theError) const
index aaf3c88c942c634c3cf33fa768b0f0b29aa79478..2111ef63d94e310fd8357066635b318a17e68952 100644 (file)
@@ -165,22 +165,6 @@ private:
 
 };
 
-/**
-* \ingroup Validators
-* A validator which checks that objects selected for feature attributes are different (not the same)
-*/
-class PartSet_SketchEntityValidator : public ModelAPI_AttributeValidator
-{
- public:
-  //! Returns true if the attribute is good for the feature attribute
-  //! \param theAttribute an attribute
-  //! \param theArguments a list of arguments (names of attributes to check)
-  //! \param theError an output error string
-  virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments,
-                       std::string& theError) const;
-};
-
 /**\class PartSet_CoincidentAttr
  * \ingroup Validators
  * \brief Validator to check whether there is a coincident constraint between
index 4e9ccb983cae8896a397e0d8772ba6a4c76663e4..cecf69f4dd94c001d488fea56d239644dd23fa65 100644 (file)
@@ -114,20 +114,6 @@ bool PartSet_WidgetSketchCreator::storeValueCustom() const
   return true;
 }
 
-void PartSet_WidgetSketchCreator::activateCustom()
-{
-  //if (isSelectionMode()) {
-  //  ModuleBase_WidgetSelector::activateCustom();
-    //connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
-
-    //setVisibleSelectionControl(true);
-  //}
-  //else {
-  //  setVisibleSelectionControl(false);
-  //  emit focusOutWidget(this);
-  //}
-}
-
 void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelectionControl)
 {
   // hide current widget, activate the next widget
@@ -157,12 +143,6 @@ QIntList PartSet_WidgetSketchCreator::getShapeTypes() const
   return aShapeTypes;
 }
 
-void PartSet_WidgetSketchCreator::deactivate()
-{
-  if (isSelectionMode())
-    ModuleBase_WidgetSelector::deactivate();
-}
-
 void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing)
 {
   ModuleBase_ModelWidget::setEditingMode(isEditing);
@@ -172,24 +152,17 @@ void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing)
 
 bool PartSet_WidgetSketchCreator::isSelectionMode() const
 {
-  //CompositeFeaturePtr aCompFeature =
-  //  std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
-  //bool aHasSub = aCompFeature->numberOfSubs() > 0;
-
   AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
   bool aHasValueInList = anAttrList.get() && anAttrList->size() > 0;
 
-  return !aHasValueInList;//aHasSub || aHasValueInList;
+  return !aHasValueInList;
 }
 
 void PartSet_WidgetSketchCreator::onSelectionChanged()
 {
   QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
 
-  if (startSketchOperation(aSelected)) {
-
-  }
-  else {// if (aSelected.size() > 1) {
+  if (!startSketchOperation(aSelected)) {
     QList<ModuleBase_ViewerPrs>::const_iterator anIt = aSelected.begin(), aLast = aSelected.end();
     bool aProcessed = false;
     for (; anIt != aLast; anIt++) {
@@ -201,6 +174,8 @@ void PartSet_WidgetSketchCreator::onSelectionChanged()
       emit valuesChanged();
       updateObject(myFeature);
       setVisibleSelectionControl(false);
+      // manually deactivation because the widget was not activated as has no focus acceptin controls
+      deactivate();
       emit focusOutWidget(this);
     }
   }
@@ -223,10 +198,6 @@ void PartSet_WidgetSketchCreator::setObject(ObjectPtr theSelectedObject,
     }
   }
 }
-//void PartSet_WidgetSketchCreator::onStarted()
-//{
-//  disconnect(myModule, SIGNAL(operationLaunched()), this, SLOT(onStarted()));
-//}
 
 bool PartSet_WidgetSketchCreator::startSketchOperation(const QList<ModuleBase_ViewerPrs>& theValues)
 {
@@ -240,57 +211,33 @@ bool PartSet_WidgetSketchCreator::startSketchOperation(const QList<ModuleBase_Vi
     return aSketchStarted;
 
   aSketchStarted = true;
-  // Check that model already has bodies
-  /*XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
-  XGUI_Workshop* aWorkshop = aConnector->workshop();
-  XGUI_Displayer* aDisp = aWorkshop->displayer();
-  QObjectPtrList aObjList = aDisp->displayedObjects();
-  bool aHasBody = !myUseBody;
-  ResultBodyPtr aBody;
-  if(!aHasBody) {
-    foreach(ObjectPtr aObj, aObjList) {
-      aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
-      if (aBody.get() != NULL) {
-        aHasBody = true;
-        break;
-      }
-    }
-  }*/
 
-  //if (aHasBody) {
-    // Launch Sketch operation
-    CompositeFeaturePtr aCompFeature = 
-      std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+  // manually deactivation because the widget was not activated as has no focus acceptin controls
+  deactivate();
+
+  // Launch Sketch operation
+  CompositeFeaturePtr aCompFeature = 
+    std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+
+  /// add sketch feature without current feature change.
+  /// it is important to do not change the current feature in order to
+  /// after sketch edition, the extrusion cut feature becomes current
+  SessionPtr aMgr = ModelAPI_Session::get();
+  DocumentPtr aDoc = aMgr->activeDocument();
+  FeaturePtr aPreviousCurrentFeature = aDoc->currentFeature(false);
+  FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
+
+  PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(aSketch, aValue);
+
+  aDoc->setCurrentFeature(aPreviousCurrentFeature, false);
+
+  // start edit operation for the sketch
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                            (myModule->createOperation("Sketch"));
+  if (aFOperation)
+    aFOperation->setFeature(aSketch);
+  myModule->sendOperation(aFOperation);
 
-    /// add sketch feature without current feature change.
-    /// it is important to do not change the current feature in order to
-    /// after sketch edition, the extrusion cut feature becomes current
-    SessionPtr aMgr = ModelAPI_Session::get();
-    DocumentPtr aDoc = aMgr->activeDocument();
-    FeaturePtr aPreviousCurrentFeature = aDoc->currentFeature(false);
-    FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
-
-    PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(aSketch, aValue);
-
-    aDoc->setCurrentFeature(aPreviousCurrentFeature, false);
-
-    // start edit operation for the sketch
-    ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
-                                                             (myModule->createOperation("Sketch"));
-    if (aFOperation)
-      aFOperation->setFeature(aSketch);
-    myModule->sendOperation(aFOperation);
-    //connect(anOperation, SIGNAL(aborted()), aWorkshop->operationMgr(), SLOT(abortAllOperations()));
-  //}
-  /* else {
-    // Break current operation
-    std::string anOperationName = feature()->getKind();
-    QString aTitle = tr( anOperationName.c_str() );
-    QMessageBox::warning(this, aTitle,
-        tr("There are no bodies found. Operation aborted."), QMessageBox::Ok);
-    ModuleBase_Operation* aOp = myModule->workshop()->currentOperation();
-    aOp->abort();
-  }*/
   return aSketchStarted;
 }
 
@@ -299,14 +246,9 @@ bool PartSet_WidgetSketchCreator::focusTo()
   if (isSelectionMode()) {
     setVisibleSelectionControl(true);
 
-    //CompositeFeaturePtr aCompFeature = 
-    //   std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
-    // if (aCompFeature->numberOfSubs() == 0)
-    //   return ModuleBase_ModelWidget::focusTo(); 
-    //connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
     // we need to call activate here as the widget has no focus accepted controls
     // if these controls are added here, activate will happens automatically after focusIn()
-    ModuleBase_WidgetSelector::activateCustom();
+    activateCustom();
     return true;
   }
   else {
index f6f56f8a2b52484cf5a8154d87e03f84afd7fc55..aa25800bd9242e8f56993332040f1bb3ea9b9ec5 100644 (file)
@@ -47,9 +47,6 @@ public:
   /// \return the state whether the widget can accept the focus
   virtual bool focusTo();
 
-  /// The methiod called when widget is deactivated
-  virtual void deactivate();
-
   /// Editing mode depends on mode of current operation. This value is defined by it.
   virtual void setEditingMode(bool isEditing);
 
@@ -60,9 +57,6 @@ protected:
 
   virtual bool restoreValueCustom();
 
-  /// The methiod called when widget is activated
-  virtual void activateCustom();
-
   /// Visualization of the current control or others in PP
   /// \param theSelectionControl state whether the control should be shown/hidden
   void setVisibleSelectionControl(const bool theSelectionControl);
@@ -90,8 +84,6 @@ protected slots:
   virtual void onSelectionChanged();
 
 private slots:
-  //void onStarted();
-
   void onResumed(ModuleBase_Operation* theOp);
 
 private:
index e2b43b619f271b868d0790bb2b7e21ba049f9977..79657c302066b6109deb83407bc486d189983e67 100644 (file)
@@ -595,6 +595,9 @@ bool XGUI_OperationMgr::onProcessEnter(QObject* theObject)
 {
   bool isAccepted = false;
   ModuleBase_Operation* aOperation = currentOperation();
+  // to avoid enter processing when operation has not been started yet
+  if (!aOperation)
+    return isAccepted;
   ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
   // only property panel enter is processed in order to do not process enter in application dialogs
   bool isPPChild = isChildObject(theObject, aPanel);