]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Remove sketch_constraint_shape_selector and use_external flag is created
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 10 Apr 2015 14:33:05 +0000 (17:33 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 10 Apr 2015 14:33:05 +0000 (17:33 +0300)
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp [deleted file]
src/PartSet/PartSet_WidgetConstraintShapeSelector.h [deleted file]
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/PartSet/PartSet_WidgetShapeSelector.h
src/SketchPlugin/plugin-Sketch.xml

index 8b85b15c621600b877eeba50480d98dcdd6dc25c..76fc4c119760c0d1dd9c5995a916045024df3689 100644 (file)
@@ -12,7 +12,6 @@ SET(PROJECT_HEADERS
        PartSet_WidgetSketchLabel.h
        PartSet_Validators.h
        PartSet_WidgetPoint2d.h
-       PartSet_WidgetConstraintShapeSelector.h
     PartSet_WidgetEditor.h
        PartSet_WidgetPoint2dDistance.h
        PartSet_WidgetShapeSelector.h
@@ -27,7 +26,6 @@ SET(PROJECT_SOURCES
        PartSet_Tools.cpp
        PartSet_WidgetSketchLabel.cpp
        PartSet_Validators.cpp
-       PartSet_WidgetConstraintShapeSelector.cpp
     PartSet_WidgetEditor.cpp
        PartSet_WidgetPoint2d.cpp
        PartSet_WidgetPoint2dDistance.cpp
index b81a64bb3291fb07b2280883008df0594e201f99..60ab634a785d3722796b414c8cbc176039bd2249 100644 (file)
@@ -7,7 +7,6 @@
 #include <PartSet_WidgetPoint2d.h>
 #include <PartSet_WidgetPoint2dDistance.h>
 #include <PartSet_WidgetShapeSelector.h>
-#include <PartSet_WidgetConstraintShapeSelector.h>
 #include <PartSet_WidgetEditor.h>
 #include "PartSet_SketcherMgr.h"
 #include "PartSet_MenuMgr.h"
@@ -472,11 +471,6 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
       new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
     aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
     aWgt = aShapeSelectorWgt;
-  } if (theType == "sketch_constraint_shape_selector") {
-    PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt =
-      new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
-    aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
-    aWgt = aConstraintShapeSelectorWgt;
   } if (theType == WDG_DOUBLEVALUE_EDITOR) {
     aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId);
   } 
diff --git a/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp b/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp
deleted file mode 100644 (file)
index f379935..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        PartSet_WidgetShapeSelector.cpp
-// Created:     27 Nov 2014
-// Author:      Vitaly Smetannikov
-
-#include "PartSet_WidgetConstraintShapeSelector.h"
-
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Validator.h>
-
-#include <PartSet_Tools.h>
-#include <SketchPlugin_Feature.h>
-
-bool PartSet_WidgetConstraintShapeSelector::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape)
-{
-  // initially the method is wrote to create an external object. Since the parent widget creates it,
-  // the redefinition is not necessary anymore.
-  // TODO: remove the widget and use the parent one insted of it
-  return PartSet_WidgetShapeSelector::setObject(theSelectedObject, theShape);
-  /*ObjectPtr aSelectedObject = theSelectedObject;
-
-  FeaturePtr aFeature = ModelAPI_Feature::feature(aSelectedObject);
-  if (aFeature) {
-    std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
-            std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-    if ((!aSPFeature) && (!theShape->isNull())) {
-      createExternal(theSelectedObject, theShape);
-
-      if (myExternalObject) {
-        aSelectedObject = myExternalObject;
-      } else 
-        return false;
-    }
-  }
-  return ModuleBase_WidgetShapeSelector::setObject(aSelectedObject, theShape);*/
-}
diff --git a/src/PartSet/PartSet_WidgetConstraintShapeSelector.h b/src/PartSet/PartSet_WidgetConstraintShapeSelector.h
deleted file mode 100644 (file)
index 9a69e43..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        PartSet_WidgetShapeSelector.h
-// Created:     27 Nov 2014
-// Author:      Vitaly Smetannikov
-
-
-#ifndef PartSet_WidgetConstraintShapeSelector_H
-#define PartSet_WidgetConstraintShapeSelector_H
-
-#include "PartSet.h"
-
-#include <PartSet_WidgetShapeSelector.h>
-
-#include <ModelAPI_CompositeFeature.h>
-
-
-/**
-* \ingroup Modules
-* Customosation of PartSet_WidgetShapeSelector in order to provide 
-* working with constraints.
-*/
-class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public PartSet_WidgetShapeSelector
-{
-Q_OBJECT
- public:
-  /// Constructor
-  /// \param theParent the parent object
-  /// \param theWorkshop instance of workshop interface
-  /// \param theData the widget configuation. The attribute of the model widget is obtained from
-  /// \param theParentId is Id of a parent of the current attribute
-  PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
-    const Config_WidgetAPI* theData, const std::string& theParentId)
-    : PartSet_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
-
-  virtual ~PartSet_WidgetConstraintShapeSelector() {}
-
-  /// Set sketcher
-  /// \param theSketch a sketcher object
-  //void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
-
-  /// Retrurns installed sketcher
-  //CompositeFeaturePtr sketch() const { return mySketch; }
-
-protected:
-  /// Store the values to the model attribute of the widget. It casts this attribute to
-  /// the specific type and set the given values
-  /// \param theSelectedObject an object
-  /// \param theShape a selected shape, which is used in the selection attribute
-  virtual bool setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape);
-
-//private:
-  /// Pointer to a sketch 
-  //CompositeFeaturePtr mySketch;
-};
-
-#endif
\ No newline at end of file
index cd659c04dc1aaac826683c67df61c3e6a167fe51..089bd98a6ccf1cc1794b3d8cd0da43b06a6d416b 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModelAPI_Validator.h>
 
 #include <ModuleBase_Definitions.h>
+#include <Config_WidgetAPI.h>
 
 #include <PartSet_Tools.h>
 #include <SketchPlugin_Feature.h>
@@ -23,8 +24,13 @@ PartSet_WidgetShapeSelector::PartSet_WidgetShapeSelector(QWidget* theParent,
                                                          ModuleBase_IWorkshop* theWorkshop,
                                                          const Config_WidgetAPI* theData,
                                                          const std::string& theParentId)
-: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId)
+: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId), myUseExternal(true)
 {
+  QString aIsExternal(theData->getProperty("use_external").c_str());
+  if (!aIsExternal.isEmpty()) {
+    QString aStr = aIsExternal.toUpper();
+    myUseExternal = (aStr == "TRUE") || (aStr == "YES"); 
+  }
 }
 
 bool PartSet_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape)
@@ -35,9 +41,15 @@ bool PartSet_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject, GeomSha
   FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aSelectedObject);
   if (aSelectedFeature == myFeature)  // In order to avoid selection of the same object
     return false;
+  // Do check using of external feature
   std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
-  if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull()) {
+
+  // Do check that we can use external feature
+  if ((aSPFeature.get() != NULL) && aSPFeature->isExternal() && (!myUseExternal))
+    return false;
+
+  if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull() && myUseExternal) {
     aSelectedObject = PartSet_Tools::findFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
                                                   theSelectedObject, mySketch);
     if (!aSelectedObject.get()) {
index fb32bff9cc7242135412d6e1fc82a7b421395003..b10c8a06fff2bf1e060e266e4e01d57faf4eceea 100644 (file)
@@ -63,6 +63,8 @@ protected:
 
   /// An external object
   ObjectPtr myExternalObject;
+
+  bool myUseExternal;
 };
 
 #endif
\ No newline at end of file
index 382bd3d612f7e8d9610be38cd0a515e4f26e2aaa..b42b4af66a0a9fa6d94983293f98cf3ec24c2c58 100644 (file)
       
     <!--  SketchConstraintParallel  -->
       <feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines" icon=":icons/parallel.png">
-        <sketch_constraint_shape_selector id="ConstraintEntityA" 
+        <sketch_shape_selector id="ConstraintEntityA" 
             label="First line" tooltip="Select a line" shape_types="edge">
             <validator id="GeomValidators_Edge" parameters="line"/>
             <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         
-        <sketch_constraint_shape_selector id="ConstraintEntityB" label="Second line" tooltip="Select a line" 
+        <sketch_shape_selector id="ConstraintEntityB" label="Second line" tooltip="Select a line" 
             shape_types="edge">
             <validator id="GeomValidators_Edge" parameters="line"/>
             <validator id="PartSet_DifferentObjects"/>
             <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         <validator id="PartSet_ParallelSelection"/>
       </feature>
       
       <feature id="SketchConstraintPerpendicular" title="Perpendicular" 
         tooltip="Create constraint defining two perpendicular lines" 
         icon=":icons/perpendicular.png">
-        <sketch_constraint_shape_selector id="ConstraintEntityA" 
+        <sketch_shape_selector id="ConstraintEntityA" 
             label="First line" tooltip="Select an line" 
             shape_types="edge">
           <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
             <validator id="GeomValidators_Edge" parameters="line"/>
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         
-        <sketch_constraint_shape_selector id="ConstraintEntityB" 
+        <sketch_shape_selector id="ConstraintEntityB" 
             label="Second line" tooltip="Select an line" 
             shape_types="edge">
             <validator id="PartSet_DifferentObjects"/>
           <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
             <validator id="GeomValidators_Edge" parameters="line"/>
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         <validator id="PartSet_PerpendicularSelection"/>
       </feature>
 
       
     <!--  SketchConstraintHorizontal  -->
       <feature id="SketchConstraintHorizontal" title="Horizontal" tooltip="Create constraint defining horizontal line" icon=":icons/horisontal.png">
-        <sketch_constraint_shape_selector id="ConstraintEntityA" 
-            label="Line" tooltip="Select a line" shape_types="edge">
+        <sketch_shape_selector id="ConstraintEntityA" 
+            label="Line" tooltip="Select a line" shape_types="edge" use_external="false">
             <validator id="GeomValidators_Edge" parameters="line"/>
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         <validator id="PartSet_HVDirSelection"/>
       </feature>
       
     <!--  SketchConstraintVertical  -->
       <feature id="SketchConstraintVertical" title="Vertical" tooltip="Create constraint defining vertical line" icon=":icons/vertical.png">
-        <sketch_constraint_shape_selector id="ConstraintEntityA" 
-            label="Line" tooltip="Select a line" shape_types="edge">
+        <sketch_shape_selector id="ConstraintEntityA" 
+            label="Line" tooltip="Select a line" shape_types="edge" use_external="false">
             <validator id="GeomValidators_Edge" parameters="line"/>
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         <validator id="PartSet_HVDirSelection"/>
       </feature>
       
       <feature id="SketchConstraintEqual" title="Equal"
         tooltip="Create constraint defining equal lengths of two lines or line and arc or equal radii of two arcs or two circles or arc and circle"
         icon=":icons/equal.png">
-        <sketch_constraint_shape_selector id="ConstraintEntityA" 
+        <sketch_shape_selector id="ConstraintEntityA" 
             label="First object" tooltip="Select line, circle or arc" shape_types="edge">
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         
-        <sketch_constraint_shape_selector id="ConstraintEntityB"
+        <sketch_shape_selector id="ConstraintEntityB"
             label="Second object" tooltip="Select line, circle or arc" shape_types="edge">
           <validator id="SketchPlugin_EqualAttr" parameters="ConstraintEntityA"/>
           <validator id="PartSet_DifferentObjects"/>
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
       </feature>
       
     <!--  SketchConstraintTangent  -->
       <feature id="SketchConstraintTangent" title="Tangent" tooltip="Create constraint defining tangency of two objects" icon=":icons/tangent.png">
-        <sketch_constraint_shape_selector id="ConstraintEntityA" 
+        <sketch_shape_selector id="ConstraintEntityA" 
             label="First object" tooltip="Select line or arc" shape_types="edge">
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         
-        <sketch_constraint_shape_selector id="ConstraintEntityB"
+        <sketch_shape_selector id="ConstraintEntityB"
             label="Second object" tooltip="Select line or arc" shape_types="edge">
         <validator id="SketchPlugin_TangentAttr" parameters="ConstraintEntityA"/>
         <validator id="PartSet_DifferentObjects"/>
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         <validator id="PartSet_TangentSelection"/>
       </feature>
       
     <group id="Edit">
       <!--  SketchConstraintFillet  -->
       <feature id="SketchConstraintFillet" title="Fillet" tooltip="Create constraint defining fillet between two objects" icon=":icons/fillet.png">
-        <sketch_constraint_shape_selector id="ConstraintEntityA" 
+        <sketch_shape_selector id="ConstraintEntityA" 
             label="First object" tooltip="Select line or arc" shape_types="edge">
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
 
-        <sketch_constraint_shape_selector id="ConstraintEntityB"
+        <sketch_shape_selector id="ConstraintEntityB"
             label="Second object" tooltip="Select line or arc" shape_types="edge">
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
 
         <doublevalue_editor label="Value" tooltip="Fillet radius" id="ConstraintValue" min="0">
           <validator id="GeomValidators_Positive"/>
         id="SketchConstraintMirror"
         title="Mirror" icon=":icons/mirror.png"
         tooltip="Create constraint, mirroring group of objects">
-        <sketch_constraint_shape_selector id="ConstraintEntityA"
+        <sketch_shape_selector id="ConstraintEntityA"
             label="Mirror line" tooltip="Select mirror line" shape_types="edge">
             <validator id="GeomValidators_Edge" parameters="line"/>
-        </sketch_constraint_shape_selector>
+        </sketch_shape_selector>
         <multi_selector id="ConstraintMirrorList"
             label="List of objects"
             tooltip="Select list of mirroring objects"