]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Tue, 2 Sep 2014 15:45:18 +0000 (19:45 +0400)
committersbh <sergey.belash@opencascade.com>
Tue, 2 Sep 2014 15:45:18 +0000 (19:45 +0400)
17 files changed:
src/Config/Config_FeatureMessage.h
src/ModuleBase/ModuleBase_IOperation.cpp
src/ModuleBase/ModuleBase_IOperation.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureCreate.h
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationFeatureEdit.h
src/PartSet/PartSet_OperationFeatureEditMulti.cpp
src/PartSet/PartSet_OperationFeatureEditMulti.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index ea6bd4f8cea0e92a7abeeaf334b3b6991fa2912d..0cfe67defd21562858db600406824cc3b8e126d9 100644 (file)
@@ -61,4 +61,4 @@ class Config_FeatureMessage : public Events_Message
   CONFIG_EXPORT void setInternal(bool isInternal);\r
 };\r
 \r
-#endif // CONFIG_MESSAGE_H\r
\ No newline at end of file
+#endif // CONFIG_MESSAGE_H\r
index f8aacb9c18e37adf10b8aef650a1741f13b4eca7..e873562e5c4fc930f423a112c082e22aadd9c56f 100644 (file)
@@ -39,11 +39,6 @@ bool ModuleBase_IOperation::canBeCommitted() const
   return true;
 }
 
-bool ModuleBase_IOperation::isGranted(ModuleBase_IOperation* /*theOperation*/) const
-{
-  return false;
-}
-
 /*void ModuleBase_IOperation::setModelWidgets(const std::string& theXmlRepresentation,
  QList<ModuleBase_ModelWidget*> theWidgets)
  {
index 8d738763e0ae598d39e412c9ea1f779462232112..28822efa51b9cda21a4ed3a221641271020d7c69 100644 (file)
@@ -13,6 +13,7 @@
 #include <QObject>
 #include <QString>
 #include <QList>
+#include <QStringList>
 
 #include <boost/shared_ptr.hpp>
 
@@ -56,14 +57,20 @@ Q_OBJECT
   /// /returns the instance of the description class
   ModuleBase_OperationDescription* getDescription() const;
 
-  /// Verifies whether this operator can be always started above any already running one
-  /// \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
-  /// This method must be redefined in derived operation if operation of derived class
-  /// must be always can start above any launched one. Default impl returns FALSE,
-  /// so it is being checked for IsValid, but some operations may overload IsGranted()
-  /// In this case they will always start, no matter what operation is running.
-  /// \param theOperation the previous running operation
-  virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
+  /**
+  * Must return true if this operation can be launched as nested for any current operation
+  * and it is not necessary to check this operation on validity. By default 
+  * the operation is not granted.
+  * The method has to be redefined for granted operations.
+  */
+  virtual bool isGranted() const  { return false; }
+
+  /**
+  * Must return True if the given opertation can be launched as nested to current one.
+  * By default it returns false and it has to be redefined for operations which expect
+  * launching of nested operations
+  */
+  virtual bool isValid(ModuleBase_IOperation* theOperation) const { return false; }
 
   /// Sets a list of model widgets, according to the operation feature xml definition
   /// \param theXmlRepresentation an xml feature definition
@@ -83,6 +90,12 @@ Q_OBJECT
     return myIsEditing;
   }
 
+  /// Returns list of nested features
+  QStringList nestedFeatures() const { return myNestedFeatures; }
+
+  /// Sets list of nested features
+  void setNestedFeatures(const QStringList& theList) { myNestedFeatures = theList; }
+
 signals:
   void started();  /// the operation is started
   void aborted();  /// the operation is aborted
@@ -157,6 +170,8 @@ signals:
 
  private:
   ModuleBase_OperationDescription* myDescription;  /// the container to have the operation description
+
+  QStringList myNestedFeatures;
 };
 
 #endif
index ec21e026619bcc21858f88d50e4c5a3254956d19..993d467577ebcdba596dbb8499f0e7a071c1756f 100644 (file)
@@ -49,6 +49,9 @@
 #include <GeomAPI_AISObject.h>
 #include <AIS_Shape.hxx>
 
+#include <StdSelect_FaceFilter.hxx>
+#include <StdSelect_TypeOfFace.hxx>
+
 #include <QObject>
 #include <QMouseEvent>
 #include <QString>
@@ -347,6 +350,7 @@ void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
 void PartSet_Module::onCloseLocalContext()
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+  aDisplayer->deactivateObjectsOutOfContext();
   aDisplayer->closeLocalContexts();
 }
 
@@ -519,6 +523,13 @@ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateVi
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
     std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
     aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
+
+    // If this is a Sketcher then activate objects (planar faces) outside of context
+    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+    if (aSketchOp) {
+      Handle(StdSelect_FaceFilter) aFilter = new StdSelect_FaceFilter(StdSelect_Plane);
+      aDisplayer->activateObjectsOutOfContext(aModes, aFilter);
+    }
   }
 }
 
index a673476898429619f4a57143cfcf2f10287415ad..6a405901a8ae558c41676590daa307bede32c862 100644 (file)
@@ -73,12 +73,6 @@ bool PartSet_OperationFeatureCreate::canBeCommitted() const
   return false;
 }
 
-bool PartSet_OperationFeatureCreate::isGranted(ModuleBase_IOperation* theOperation) const
-{
-  return theOperation->getDescription()->operationId().toStdString()
-      == PartSet_OperationSketch::Type();
-}
-
 std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFeature) const
 {
   std::list<int> aModes;
index cedf301a76eb51b4aa8b1b8ed9abc058e95d57e9..a6e3aa8771c80fc2691f4da2440609eaa8f2d944 100644 (file)
@@ -39,11 +39,6 @@ Q_OBJECT
   /// Destructor
   virtual ~PartSet_OperationFeatureCreate();
 
-  /// Returns that this operator can be started above already running one.
-  /// The runned operation should be the sketch feature modified operation
-  /// \param theOperation the previous running operation
-  virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
-
   /// Returns the operation local selection mode
   /// \param theFeature the feature object to get the selection mode
   /// \return the selection mode
index b1752472582bc3851b56da996d92d26bb0a99fce..4d3edb9e917ea7362bed23aa90faa4e73151ff67 100644 (file)
@@ -49,12 +49,6 @@ PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit()
 {
 }
 
-bool PartSet_OperationFeatureEdit::isGranted(ModuleBase_IOperation* theOperation) const
-{
-  return theOperation->getDescription()->operationId().toStdString()
-      == PartSet_OperationSketch::Type();
-}
-
 std::list<int> PartSet_OperationFeatureEdit::getSelectionModes(ObjectPtr theFeature) const
 {
   return PartSet_OperationSketchBase::getSelectionModes(theFeature);
index eadd73f10f9802aa3260ae61b7863bbcd9441815..3d73b3bd388ce8600be5b417edfafd0093dc72d6 100644 (file)
@@ -69,11 +69,6 @@ Q_OBJECT
   /// Destructor
   virtual ~PartSet_OperationFeatureEdit();
 
-  /// Returns that this operator can be started above already running one.
-  /// The runned operation should be the sketch feature modified operation
-  /// \param theOperation the previous running operation
-  virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
-
   /// Returns the operation local selection mode
   /// \param theFeature the feature object to get the selection mode
   /// \return the selection mode
index 0c4a71697d6aca7e5234d1a919a76a8d563e668f..cd0de892541cc01ab7374816c9431d9f165cf55a 100644 (file)
@@ -45,11 +45,6 @@ PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti()
 {
 }
 
-bool PartSet_OperationFeatureEditMulti::isGranted(ModuleBase_IOperation* theOperation) const
-{
-  return theOperation->getDescription()->operationId().toStdString()
-      == PartSet_OperationSketch::Type();
-}
 
 void PartSet_OperationFeatureEditMulti::initSelection(
     const std::list<ModuleBase_ViewerPrs>& theSelected,
index f49d0480bcbcb2763f060373759526ca4db50c5e..0f21f34ab0dd099c7b432dde41526778fc3919b8 100644 (file)
@@ -70,11 +70,6 @@ Q_OBJECT
   /// Destructor
   virtual ~PartSet_OperationFeatureEditMulti();
 
-  /// Returns that this operator can be started above already running one.
-  /// The runned operation should be the sketch feature modified operation
-  /// \param theOperation the previous running operation
-  virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
-
   /// Initializes the operation with previously created feature. It is used in sequental operations
   virtual void initFeature(FeaturePtr theFeature);
 
index 4ff87cae1414d760c31a3e2f7bcddacf5b8df636..acd79461dc773c4fb58ba4c62a7b4c97329fe1e3 100644 (file)
@@ -113,9 +113,10 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
     /// It is empty and we have to use the process mouse release to start edition operation
     /// for these objects
     if (theSelected.size() == 1) {
-      ObjectPtr aFeature = theSelected.front().object();
-      if (aFeature)
-        restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
+      ObjectPtr aObject = theSelected.front().object();
+      if (aObject) {
+        restartOperation(PartSet_OperationFeatureEdit::Type(), aObject);
+      }
     }
   }
 }
@@ -250,3 +251,11 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
   emit closeLocalContext();
   emit planeSelected(aDir->x(), aDir->y(), aDir->z());
 }
+
+
+bool PartSet_OperationSketch::isValid(ModuleBase_IOperation* theOperation) const
+{
+  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
+  return aPreviewOp != NULL;
+}
+
index 04604ef0cce20d7856488eb80e51c3df5617b2cf..cc11518779a435404e7f152dbb846b0ab72f21bc 100644 (file)
@@ -37,6 +37,10 @@ Q_OBJECT
   /// Destructor
   virtual ~PartSet_OperationSketch();
 
+  /// Returns True if the given operation is a Sketcher operation
+  virtual bool isValid(ModuleBase_IOperation* theOperation) const;
+
+
   /// Returns the operation local selection mode
   /// \param theFeature the feature object to get the selection mode
   /// \return the selection mode
index d90de1d2902bfa87aa78305a1f297c36cb329ab7..9272c8c9e6c8dd48dc84c8e59c51b20d6b6df01e 100644 (file)
@@ -124,5 +124,15 @@ void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* th
 
 void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
 {
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
+  if (aFeature) {
+    QStringList aNested = this->nestedFeatures();
+    if (!aNested.isEmpty()) {
+      if (aNested.contains(QString(aFeature->getKind().c_str()))) 
+        emit launchOperation(theType, theFeature);
+      else
+        return;
+    }
+  }
   emit launchOperation(theType, theFeature);
 }
index 57befeb24cb8958c3aac8acd0b1f935a1452cf8d..26def2f04855d27112bc55dee573509876f2d47d 100644 (file)
@@ -20,7 +20,6 @@
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <AIS_DimensionSelectionMode.hxx>
-
 #include <AIS_Shape.hxx>
 
 #include <set>
@@ -169,7 +168,9 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, const std::list
   // Open local context if there is no one
   if (!aContext->HasOpenedContext()) {
     aContext->ClearCurrents(false);
-    aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+    //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+    aContext->OpenLocalContext();
+    aContext->NotUseDisplayedObjects();
   }
   // display or redisplay presentation
   Handle(AIS_InteractiveObject) anAIS;
@@ -329,6 +330,7 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
 
 void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
 {
+  AISContext()->ClearSelected(false);
   closeAllContexts(true);
 }
 
@@ -396,3 +398,32 @@ void XGUI_Displayer::erase(boost::shared_ptr<GeomAPI_AISObject> theAIS, const bo
   }
 }
 
+void XGUI_Displayer::activateObjectsOutOfContext(const std::list<int>& theModes, 
+                                                 Handle(SelectMgr_Filter) theFilter)
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  // Open local context if there is no one
+  if (!aContext->HasOpenedContext()) 
+    return;
+
+  aContext->UseDisplayedObjects();
+  std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
+  for (; anIt != aLast; anIt++) {
+    aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt));
+  }
+
+  if (!theFilter.IsNull())
+    aContext->AddFilter(theFilter);
+}
+
+
+void XGUI_Displayer::deactivateObjectsOutOfContext()
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  // Open local context if there is no one
+  if (!aContext->HasOpenedContext()) 
+    return;
+
+  aContext->RemoveFilters();
+  aContext->NotUseDisplayedObjects();
+}
\ No newline at end of file
index ef3a3308db2a6c046469782c7d27c50e25a80595..5c54857d07bf4cab3ef6ca813907ce91e2703f94 100644 (file)
@@ -124,6 +124,14 @@ class XGUI_EXPORT XGUI_Displayer
 
   void activate(ObjectPtr theFeature);
 
+  /// Activates in local context displayed outside of the context.
+  /// \param theModes - selection modes to activate
+  /// \param theFilter - filter for selection
+  void activateObjectsOutOfContext(const std::list<int>& theModes, 
+                                   Handle(SelectMgr_Filter) theFilter);
+
+  void deactivateObjectsOutOfContext();
+
  protected:
   /// Deactivate local selection
   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
index 4a93b9d47c770272bb5eb4a3c35c3e06e9369460..e6855819a4a9853dc5f9062215183edd0296a8a8 100644 (file)
@@ -133,11 +133,15 @@ bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation)
 {
   bool aCanStart = true;
   ModuleBase_Operation* aCurrentOp = currentOperation();
-  if (aCurrentOp && !theOperation->isGranted(aCurrentOp)) {
-    if (canStopOperation()) {
-      aCurrentOp->abort();
-    } else {
-      aCanStart = false;
+  if (aCurrentOp) {
+    if (!theOperation->isGranted()) {
+      if (!aCurrentOp->isValid(theOperation)) {
+        if (canStopOperation()) {
+          aCurrentOp->abort();
+        } else {
+          aCanStart = false;
+        }
+      }
     }
   }
   return aCanStart;
index ad35f6f8106b90f4139421454325e3c0c9a470e8..d91f4d98e759ccfa0493909f562e566e544df7f3 100644 (file)
@@ -395,6 +395,7 @@ void XGUI_Workshop::onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theM
 void XGUI_Workshop::onOperationStarted()
 {
   ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+  aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
 
   if (aOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
     connectWithOperation(aOperation);