]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide local selection for operations outside of sketcher
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 9 Oct 2014 09:05:23 +0000 (13:05 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 9 Oct 2014 09:05:23 +0000 (13:05 +0400)
13 files changed:
src/FeaturesPlugin/extrusion_widget.xml
src/GeomAPI/GeomAPI_Wire.cpp
src/ModuleBase/ModuleBase_Definitions.h
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_ViewerFilters.cpp

index 0bcf41643e799e782f2f921cafcf460e4f5748cc..426bb3fd592e17d2af551090f2da9f80a9f7655e 100644 (file)
@@ -4,7 +4,8 @@
     icon=":icons/sketch.png" 
     tooltip="Select a face for extrusion"
     activate="true"
-    shape_types="face"
+    shape_types="face wire"
+    use_subshapes="true"
   />
   <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="0" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
     <validator id="GeomValidators_Positive"/>
index c70d5c5e8998374913a70eb7f69f913ad83d4e45..6932444bf75af2be55d57c4d5afe616e47caa31b 100644 (file)
@@ -18,9 +18,9 @@
 
 GeomAPI_Wire::GeomAPI_Wire() : GeomAPI_Shape()
 {
-  TopoDS_Wire aBigWireImpl;
+  TopoDS_Compound aBigWireImpl;
   BRep_Builder aBuilder;
-  aBuilder.MakeWire(aBigWireImpl);
+  aBuilder.MakeCompound(aBigWireImpl);
   this->setImpl(new TopoDS_Shape(aBigWireImpl));
 }
 
index 56049acec437d3ace6a27f5c9922e9c4edcf9629..926de63ca9fb4a83dc85f9403c747bdecc31abe0 100644 (file)
@@ -10,5 +10,4 @@ typedef QList<short> QShortList;     //!< list of short int values
 typedef QList<double> QDoubleList;    //!< list of double values
 typedef QList<FeaturePtr> QFeatureList;  //!< List of features
 typedef QList<ResultPtr> QResultList;  //!< List of results
-
 #endif
index d4b9265ca1868233629abd8744451fc8eced7f5d..700f2baecbaf66e5006740ec6f939b3f8684896f 100644 (file)
@@ -6,6 +6,7 @@
 #define ModuleBase_IWorkshop_H
 
 #include "ModuleBase.h"
+#include "ModuleBase_Definitions.h"
 
 #include <ModelAPI_Object.h>
 
@@ -32,6 +33,13 @@ Q_OBJECT
 
   virtual ModuleBase_ISelection* selection() const = 0;
 
+  /// Activate sub-shapes selection (opens local context)
+  /// Types has to be dined according to TopAbs_ShapeEnum
+  virtual void activateSubShapesSelection(const QIntList& theTypes) = 0;
+
+  /// Deactivate sub-shapes selection (closes local context)
+  virtual void deactivateSubShapesSelection() = 0;
+
   //! Returns instance of loaded module
   virtual ModuleBase_IModule* module() const = 0;
 
index d8f50a4cd51e1a94f8d264df51c001741676dae5..d55bdc3f0e54ef8dcc5ccacb6158db8f1aa0fb43 100644 (file)
@@ -210,8 +210,8 @@ bool ModuleBase_Operation::commit()
     disconnect(myPropertyPanel, 0, this, 0);
 
     stopOperation();
-
     ModelAPI_Session::get()->finishOperation();
+
     emit stopped();
 
     afterCommitOperation();
index 3fb534b36482d1effb4df9ee153ffc0c085e1218..29443bf5d3f12fd85cad14cab528e58a1f082cb8 100644 (file)
@@ -59,7 +59,7 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen
                                                      const Config_WidgetAPI* theData,
                                                      const std::string& theParentId)
     : ModuleBase_ModelWidget(theParent, theData, theParentId),
-      myWorkshop(theWorkshop), myIsActive(false)
+      myWorkshop(theWorkshop), myIsActive(false), myUseSubShapes(false)
 {
   myContainer = new QWidget(theParent);
   QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
@@ -88,6 +88,12 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen
 
   std::string aTypes = theData->getProperty("shape_types");
   myShapeTypes = QString(aTypes.c_str()).split(' ');
+
+  std::string aUseSubShapes = theData->getProperty("use_subshapes");
+  if (aUseSubShapes.length() > 0) {
+    QString aVal(aUseSubShapes.c_str());
+    myUseSubShapes = (aVal.toUpper() == "TRUE");
+  }
 }
 
 //********************************************************************
@@ -250,10 +256,19 @@ void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate)
     myTextLine->setPalette(myInactivePalet);
   updateSelectionName();
 
-  if (myIsActive)
+  if (myIsActive) {
     connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-  else
+    if (myUseSubShapes) {
+      QIntList aList;
+      foreach (QString aType, myShapeTypes)
+        aList.append(shapeType(aType));
+      myWorkshop->activateSubShapesSelection(aList);
+    }
+  } else {
     disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+    if (myUseSubShapes) 
+      myWorkshop->deactivateSubShapesSelection();
+  }
 }
 
 //********************************************************************
index c1decfa56450fdf6eb19c3aa2d1b6362a131ecbe..75863884304d906e8bcb6174f875575ef005bac0 100644 (file)
@@ -91,6 +91,9 @@ private:
   ObjectPtr mySelectedObject;
   QStringList myShapeTypes;
 
+  /// If true then local selector has to be activated in context
+  bool myUseSubShapes;
+
   QPalette myBasePalet;
   QPalette myInactivePalet;
 
index 0232196f9d608f3d439ff197151e2185fecdcf54..3ada0450be9e24064d97904d6dde6157ea05cdca 100644 (file)
@@ -155,6 +155,7 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
     aDisplayer->deactivateObjectsOutOfContext();
   } else {
     Handle(AIS_InteractiveContext) aAIS = xWorkshop()->viewer()->AISContext();
+    //TODO (VSV): We have to open Local context because at neutral point filters don't work (bug 25340)
     aAIS->AddFilter(myDocumentShapeFilter);
   }
 }
index fdb56312b0aa0462f86fa5f147e7ca7bb8f349b4..2c8426c0485e87dc9773f95bcc251b417ecf18ea 100644 (file)
@@ -155,7 +155,10 @@ void PartSet_OperationSketch::stopOperation()
   PartSet_OperationSketchBase::stopOperation();
   emit featureConstructed(feature(), FM_Hide);
   emit closeLocalContext();
+}
 
+void PartSet_OperationSketch::afterCommitOperation()
+{
   FeaturePtr aFeature = feature();
   std::list<ResultPtr> aResults = aFeature->results();
   std::list<ResultPtr>::const_iterator aIt;
index 94ddf02d91e173e034c2eedb3edc0354be737454..f885503e308e0c81013b4a1541381540ffefdf8c 100644 (file)
@@ -112,6 +112,9 @@ signals:
   /// Default impl calls corresponding slot and commits immediately.
   virtual void startOperation();
 
+  /// Virtual method called after operation committed (see commit() method for more description)
+  virtual void afterCommitOperation();
+
  private:
   std::list<ModuleBase_ViewerPrs> myFeatures;  ///< the features to apply the edit operation
 };
index 4c36e61d17bc916dd5ea553bbdce976d4f074841..aecada78b636372148cee115f97b7caae6ce0f53 100644 (file)
@@ -47,3 +47,19 @@ ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
 {
   return myWorkshop->operationMgr()->currentOperation();
 }
+
+
+void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
+{
+  Handle(AIS_InteractiveContext) aAIS = myWorkshop->viewer()->AISContext();
+  if (!aAIS->HasOpenedContext())
+    aAIS->OpenLocalContext();
+  foreach(int aType, theTypes)
+    aAIS->ActivateStandardMode((TopAbs_ShapeEnum)aType);
+}
+
+void XGUI_ModuleConnector::deactivateSubShapesSelection()
+{
+  Handle(AIS_InteractiveContext) aAIS = myWorkshop->viewer()->AISContext();
+  aAIS->CloseAllContexts();
+}
index c78c1d82a20ea8353cb79a3321b35e62261de3b7..054ad0872e5db2944c72c4c2cf2f89dd3873922b 100644 (file)
@@ -27,6 +27,13 @@ Q_OBJECT
   //! Returns list of currently selected data objects
   virtual ModuleBase_ISelection* selection() const;
 
+  /// Activate sub-shapes selection (opens local context if it was not opened)
+  /// Types has to be dined according to TopAbs_ShapeEnum
+  virtual void activateSubShapesSelection(const QIntList& theTypes);
+
+  /// Deactivate sub-shapes selection (closes local context)
+  virtual void deactivateSubShapesSelection();
+
   //! Returns instance of loaded module
   virtual ModuleBase_IModule* module() const;
 
index c99c5bbfc2d51507c42fc6c7f0f9298325f2dd73..6efd9143e2d7da816ddb789c4b7859e4a617671a 100644 (file)
@@ -15,7 +15,7 @@ IMPLEMENT_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
 IMPLEMENT_STANDARD_RTTIEXT(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
 
 
-//TODO (VSV): Check bug in OCCT: Filter result is ignored
+//TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340)
 Standard_Boolean XGUI_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
   if (theOwner->HasSelectable()) {