]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge remote-tracking branch 'origin/BR_WIRE_RESULTS'
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 8 Oct 2014 07:35:29 +0000 (11:35 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 8 Oct 2014 07:35:29 +0000 (11:35 +0400)
12 files changed:
src/FeaturesPlugin/extrusion_widget.xml
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ViewerFilters.cpp [new file with mode: 0644]
src/XGUI/XGUI_ViewerFilters.h [new file with mode: 0644]

index 698905a7fd4a7f9f588c6f043518fbe679eceed5..0bcf41643e799e782f2f921cafcf460e4f5748cc 100644 (file)
@@ -6,7 +6,7 @@
     activate="true"
     shape_types="face"
   />
-  <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
+  <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"/>
   </doublevalue>
   <boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
index 718ded61a83a8b56f2667c16d895507ac81540d0..d8f50a4cd51e1a94f8d264df51c001741676dae5 100644 (file)
@@ -238,13 +238,7 @@ void ModuleBase_Operation::activateByPreselection()
     aValue.setObject(aPrs.object());
     if (aActiveWgt->setValue(&aValue)) {
       myPreSelection.remove(aPrs);
-      if(isValid()) {
-        //myActiveWidget = NULL;
-        commit();
-      } else {
-        myPropertyPanel->activateNextWidget();
-        //emit activateNextWidget(myActiveWidget);
-      }
+      myPropertyPanel->activateNextWidget();
     }
     // If preselection is enough to make a valid feature - apply it immediately
   }
index 910bd6eaed26dfdee57c11bfbbeb69bfd20c40af..dbf2b3406c1851ab1c91e25e4ea96e3603220528 100644 (file)
@@ -202,7 +202,7 @@ signals:
   /// Returns pointer to the root document.
   boost::shared_ptr<ModelAPI_Document> document() const;
 
-  ///
+  /// Activates widgets by preselection if it is accepted
   virtual void activateByPreselection();
 
   /// Set value to the active widget
index 47471dab3ef16e2046636f43debc39712a180931..3fb534b36482d1effb4df9ee153ffc0c085e1218 100644 (file)
@@ -14,6 +14,7 @@
 #include <ModelAPI_Tools.h>
 
 #include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Result.h>
 #include <ModelAPI_AttributeReference.h>
@@ -152,6 +153,7 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged()
       return;
 
     setObject(aObject);
+    emit focusOutWidget(this);
   }
 }
 
@@ -170,7 +172,6 @@ void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj)
   updateSelectionName();
   activateSelection(false);
   emit valuesChanged();
-  emit focusOutWidget(this);
 }
 
 //********************************************************************
@@ -186,6 +187,13 @@ bool ModuleBase_WidgetShapeSelector::isAccepted(const ObjectPtr theResult) const
         return false;
     }
   }
+  // Check that object belongs to active document or PartSet
+  DocumentPtr aDoc = aResult->document();
+  SessionPtr aMgr = ModelAPI_Session::get();
+  if (!(aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument()))
+    return false;
+
+  // Check that the shape of necessary type
   boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
   if (!aShapePtr)
     return false;
index 8b45d5e47a7d7a98075fffcd5a556876f817d5ea..0232196f9d608f3d439ff197151e2185fecdcf54 100644 (file)
@@ -79,7 +79,8 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   connect(myWorkshop, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
           SLOT(onOperationStopped(ModuleBase_Operation*)));
 
-  XGUI_ContextMenuMgr* aContextMenuMgr = xWorkshop()->contextMenuMgr();
+  XGUI_Workshop* aXWshop = xWorkshop();
+  XGUI_ContextMenuMgr* aContextMenuMgr = aXWshop->contextMenuMgr();
   connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
           SLOT(onContextMenuCommand(const QString&, bool)));
 
@@ -93,6 +94,8 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
           SLOT(onKeyRelease(QKeyEvent*)));
   connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
           SLOT(onMouseDoubleClick(QMouseEvent*)));
+
+  myDocumentShapeFilter = new XGUI_ShapeDocumentFilter(aXWshop->displayer());
 }
 
 PartSet_Module::~PartSet_Module()
@@ -130,11 +133,6 @@ std::string PartSet_Module::featureFile(const std::string& theFeatureId)
  */
 void PartSet_Module::onFeatureTriggered()
 {
-  //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(),
-  //                                   myWorkshop->viewer()->activeView());
-
-  //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(),
-  //                                       myWorkshop->viewer()->activeView());
   QAction* aCmd = dynamic_cast<QAction*>(sender());
   //Do nothing on uncheck
   if (aCmd->isCheckable() && !aCmd->isChecked())
@@ -142,19 +140,6 @@ void PartSet_Module::onFeatureTriggered()
   launchOperation(aCmd->data().toString());
 }
 
-//void PartSet_Module::launchOperation(const QString& theCmdId)
-//{
-//  ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
-//  //PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-//  //if (aPreviewOp) {
-//    XGUI_Selection* aSelection = myWorkshop->selector()->selection();
-//    // Initialise operation with preliminary selection
-//    std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
-//    std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
-//    anOperation->initSelection(aSelected, aHighlighted);
-//  //}
-//  sendOperation(anOperation);
-//}
 
 void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
 {
@@ -168,6 +153,9 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
     XGUI_Displayer* aDisplayer = aXWshp->displayer();
     aDisplayer->openLocalContext();
     aDisplayer->deactivateObjectsOutOfContext();
+  } else {
+    Handle(AIS_InteractiveContext) aAIS = xWorkshop()->viewer()->AISContext();
+    aAIS->AddFilter(myDocumentShapeFilter);
   }
 }
 
@@ -179,8 +167,6 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
   if (aPreviewOp) {
     XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
-    //disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
-    //           this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
   } else {
     // Activate results of current feature for selection
     FeaturePtr aFeature = theOperation->feature();
@@ -190,6 +176,9 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
     for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
       aDisplayer->activate(*aIt);
     }
+
+    Handle(AIS_InteractiveContext) aAIS = xWorkshop()->viewer()->AISContext();
+    aAIS->RemoveFilter(myDocumentShapeFilter);
   }
 }
 
index d0698530717639ee7386beb0b993802fa3cd6525..0c39e68f814f91d7d946742f634daca3fd106c78 100644 (file)
@@ -6,6 +6,7 @@
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_Definitions.h>
 #include <XGUI_Command.h>
+#include <XGUI_ViewerFilters.h>
 #include <ModelAPI_Feature.h>
 
 #include <QMap>
@@ -144,6 +145,9 @@ Q_OBJECT
   PartSet_Listener* myListener;
 
   std::map<std::string, std::string> myFeaturesInFiles;
+
+  /// A filter which provides selection within a current document or whole PartSet
+  Handle(XGUI_ShapeDocumentFilter) myDocumentShapeFilter;
 };
 
 #endif
index e8f081e4d581d19beab5a3cf4f46dc48dd91e42d..2ce61d8efc8250d67e8182a00f91f7dcc1ad34c0 100644 (file)
@@ -6,6 +6,10 @@
 #include <PartSet_Tools.h>
 #include <ModelAPI_ResultBody.h>
 
+#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_WidgetValueFeature.h>
+
 #include <SketchPlugin_Feature.h>
 #include <V3d_View.hxx>
 #include <AIS_Shape.hxx>
@@ -104,3 +108,28 @@ void PartSet_OperationSketchBase::restartOperation(const std::string& theType, O
   }
   emit restartRequired(theType, theFeature);
 }
+
+
+
+void PartSet_OperationSketchBase::activateByPreselection()
+{
+  if (!myPropertyPanel)
+    return;
+  ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+  if ((myPreSelection.size() > 0) && aActiveWgt) {
+    const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
+    ModuleBase_WidgetValueFeature aValue;
+    aValue.setObject(aPrs.object());
+    if (aActiveWgt->setValue(&aValue)) {
+      myPreSelection.remove(aPrs);
+      if(isValid()) {
+        //myActiveWidget = NULL;
+        commit();
+      } else {
+        myPropertyPanel->activateNextWidget();
+        //emit activateNextWidget(myActiveWidget);
+      }
+    }
+    // If preselection is enough to make a valid feature - apply it immediately
+  }
+}
index 356765cc43046f32ce120f140a6289a68320e399..25f71483089973ff0bf6ddc9117db2f68676eee6 100644 (file)
@@ -149,6 +149,9 @@ signals:
   /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
   virtual FeaturePtr createFeature(const bool theFlushMessage = true);
+
+  /// Activates widgets by preselection if it is accepted
+  virtual void activateByPreselection();
 };
 
 #endif
index 0a07539a44b075b2805d7a9701310ff92948d9a2..ace172c50ba2bf627bdc74de745c5b0437eab4fa 100644 (file)
@@ -33,6 +33,7 @@ SET(PROJECT_HEADERS
        XGUI_Preferences.h
        XGUI_IPrefMgr.h
        XGUI_QtEvents.h
+       XGUI_ViewerFilters.h
 )
 
 SET(PROJECT_AUTOMOC 
@@ -66,6 +67,7 @@ SET(PROJECT_SOURCES
        XGUI_Selection.cpp
        XGUI_Preferences.cpp
        XGUI_QtEvents.cpp
+       XGUI_ViewerFilters.cpp
 )
 
 SET(PROJECT_RESOURCES 
index 9552fd6d365460379d36709319878e0b83dd3716..25b1cdfa204cbb892a4edafc5699c03ac7533ba5 100644 (file)
@@ -45,10 +45,6 @@ class XGUI_EXPORT XGUI_Displayer
   /// Destructor
   virtual ~XGUI_Displayer();
 
-  /// Set AIS_InteractiveContext object in case if it was changed
-  /// or can not be initialized in constructor
-  void setAISContext(const Handle(AIS_InteractiveContext)& theAIS);
-
   /// Returns the feature visibility state.
   /// \param theFeature a feature instance
   bool isVisible(ObjectPtr theObject) const;
diff --git a/src/XGUI/XGUI_ViewerFilters.cpp b/src/XGUI/XGUI_ViewerFilters.cpp
new file mode 100644 (file)
index 0000000..c99c5bb
--- /dev/null
@@ -0,0 +1,34 @@
+// File:        XGUI_ViewerFilters.cpp
+// Created:     07 Okt 2014
+// Author:      Vitaly SMETANNIKOV
+
+
+#include "XGUI_ViewerFilters.h"
+#include "XGUI_Displayer.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Document.h>
+
+#include <AIS_InteractiveObject.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
+IMPLEMENT_STANDARD_RTTIEXT(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
+
+
+//TODO (VSV): Check bug in OCCT: Filter result is ignored
+Standard_Boolean XGUI_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+  if (theOwner->HasSelectable()) {
+    Handle(AIS_InteractiveObject) aAisObj = 
+      Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+    if (!aAisObj.IsNull()) {
+      ObjectPtr aObj = myDisplayer->getObject(aAisObj);
+      if (aObj) {
+        DocumentPtr aDoc = aObj->document();
+        SessionPtr aMgr = ModelAPI_Session::get();
+        return (aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument());
+      }
+    }
+  }
+  return Standard_False;
+}
\ No newline at end of file
diff --git a/src/XGUI/XGUI_ViewerFilters.h b/src/XGUI/XGUI_ViewerFilters.h
new file mode 100644 (file)
index 0000000..f30f400
--- /dev/null
@@ -0,0 +1,31 @@
+// File:        XGUI_ViewerFilters.h
+// Created:     07 Okt 2014
+// Author:      Vitaly SMETANNIKOV
+
+
+#ifndef XGUI_ViewerFilters_H
+#define XGUI_ViewerFilters_H
+
+#include <SelectMgr_Filter.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+
+class XGUI_Displayer;
+
+DEFINE_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
+
+class XGUI_ShapeDocumentFilter: public SelectMgr_Filter
+{
+public:
+  Standard_EXPORT XGUI_ShapeDocumentFilter(XGUI_Displayer* myDisp): SelectMgr_Filter(),
+    myDisplayer(myDisp) {}
+
+  Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+  DEFINE_STANDARD_RTTI(XGUI_ShapeDocumentFilter)
+
+private:
+  XGUI_Displayer* myDisplayer;
+};
+
+#endif
\ No newline at end of file