Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
authorsbh <sergey.belash@opencascade.com>
Thu, 12 Feb 2015 14:36:11 +0000 (17:36 +0300)
committersbh <sergey.belash@opencascade.com>
Thu, 12 Feb 2015 14:36:11 +0000 (17:36 +0300)
Conflicts:
src/AppElements/AppElements_Command.cpp

36 files changed:
src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Session.cpp
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetBoolValue.h
src/ModuleBase/ModuleBase_WidgetChoice.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetFileSelector.h
src/ModuleBase/ModuleBase_WidgetLabel.h
src/ModuleBase/ModuleBase_WidgetLineEdit.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.h
src/NewGeom/NewGeom_SalomeViewer.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h
src/PartSet/PartSet_WidgetPoint2dDistance.cpp
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/PartSet/PartSet_WidgetShapeSelector.h
src/PartSet/PartSet_WidgetSketchLabel.h
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 9f2768e4c68f875ee6a74bfc80fa07615238529e..26ab3ca9fd49099ae27ac15dd0198b381852be41 100644 (file)
@@ -84,10 +84,11 @@ class ExportFeature(ModelAPI.ModelAPI_Feature):
         for anIndex in range(0, aFeaturesNum):
             aFeature = self.Part.object("Features", anIndex)
             aSelectionList = aFeature.data().selectionList("group_list")
+            aName = aFeature.data().name()
             # if a group has been found
             if aSelectionList:
                 groupIndex = groupIndex + 1
-                self.createGroupFromList(aSelectionList, "NewGeomGroup_{0}".format(groupIndex))
+                self.createGroupFromList(aSelectionList, aName)
                      
     ## Creates a group by given list of selected objects and the name
     #  @param theSelectionList: list of selected objects
index c923ee4cad78d53dfacebda4f7b09fea0cb6999f..762dff5fa852d28b61d29b066954bba52def6e91 100644 (file)
@@ -291,7 +291,7 @@ void Model_Document::startOperation()
 {
   if (myDoc->HasOpenCommand()) {  // start of nested command
     if (myDoc->CommitCommand()) { // commit the current: it will contain all nested after compactification
-      (*myTransactions.rbegin())++; // if has open command, the list is not empty
+      myTransactions.rbegin()->myOCAFNum++; // if has open command, the list is not empty
     }
     myNestedNum.push_back(0); // start of nested operation with zero transactions inside yet
     myDoc->OpenCommand();
@@ -299,7 +299,7 @@ void Model_Document::startOperation()
     myDoc->NewCommand();
   }
   // starts a new operation
-  myTransactions.push_back(0);
+  myTransactions.push_back(Transaction());
   if (!myNestedNum.empty())
     (*myNestedNum.rbegin())++;
   myRedos.clear();
@@ -316,11 +316,11 @@ void Model_Document::compactNested()
     int aNumToCompact = *(myNestedNum.rbegin());
     int aSumOfTransaction = 0;
     for(int a = 0; a < aNumToCompact; a++) {
-      aSumOfTransaction += *(myTransactions.rbegin());
+      aSumOfTransaction += myTransactions.rbegin()->myOCAFNum;
       myTransactions.pop_back();
     }
     // the latest transaction is the start of lower-level operation which startes the nested
-    *(myTransactions.rbegin()) += aSumOfTransaction;
+    myTransactions.rbegin()->myOCAFNum += aSumOfTransaction;
     myNestedNum.pop_back();
   }
 }
@@ -360,7 +360,7 @@ bool Model_Document::finishOperation()
 
   // transaction may be empty if this document was created during this transaction (create part)
   if (!myTransactions.empty() && myDoc->CommitCommand()) { // if commit is successfull, just increment counters
-    (*myTransactions.rbegin())++;
+    myTransactions.rbegin()->myOCAFNum++;
     aResult = true;
   }
 
@@ -368,7 +368,7 @@ bool Model_Document::finishOperation()
     compactNested();
   }
   if (!aResult && !myTransactions.empty() /* it can be for just created part document */)
-    aResult = *(myTransactions.rbegin()) != 0;
+    aResult = myTransactions.rbegin()->myOCAFNum != 0;
 
   if (!aResult && Model_Session::get()->moduleDocument().get() == this) {
     // nothing inside in all documents, so remove this transaction from the transactions list
@@ -387,7 +387,7 @@ void Model_Document::abortOperation()
     myDoc->ClearRedos();
     myRedos.clear();
   } else { // abort the current
-    int aNumTransactions = *myTransactions.rbegin();
+    int aNumTransactions = myTransactions.rbegin()->myOCAFNum;
     myTransactions.pop_back();
     if (!myNestedNum.empty())
       (*myNestedNum.rbegin())--;
@@ -433,9 +433,9 @@ bool Model_Document::canUndo()
 
 void Model_Document::undoInternal(const bool theWithSubs, const bool theSynchronize)
 {
-  int aNumTransactions = *myTransactions.rbegin();
+  int aNumTransactions = myTransactions.rbegin()->myOCAFNum;
+  myRedos.push_back(*myTransactions.rbegin());
   myTransactions.pop_back();
-  myRedos.push_back(aNumTransactions);
   if (!myNestedNum.empty())
     (*myNestedNum.rbegin())--;
   // roll back the needed number of transactions
@@ -475,9 +475,9 @@ void Model_Document::redo()
 {
   if (!myNestedNum.empty())
     (*myNestedNum.rbegin())++;
-  int aNumRedos = *myRedos.rbegin();
+  int aNumRedos = myRedos.rbegin()->myOCAFNum;
+  myTransactions.push_back(*myRedos.rbegin());
   myRedos.pop_back();
-  myTransactions.push_back(aNumRedos);
   for(int a = 0; a < aNumRedos; a++)
     myDoc->Redo();
 
@@ -489,6 +489,34 @@ void Model_Document::redo()
     subDoc(*aSubIter)->redo();
 }
 
+std::list<std::string> Model_Document::undoList() const
+{
+  std::list<std::string> aResult;
+  std::list<Transaction>::const_reverse_iterator aTrIter = myTransactions.crbegin();
+  int aNumUndo = myTransactions.size();
+  if (!myNestedNum.empty())
+    aNumUndo = *myNestedNum.rbegin();
+  for( ; aNumUndo > 0; aTrIter++, aNumUndo--) {
+    aResult.push_back(aTrIter->myId);
+  }
+  return aResult;
+}
+
+std::list<std::string> Model_Document::redoList() const
+{
+  std::list<std::string> aResult;
+  std::list<Transaction>::const_reverse_iterator aTrIter = myRedos.crbegin();
+  for( ; aTrIter != myRedos.crend(); aTrIter++) {
+    aResult.push_back(aTrIter->myId);
+  }
+  return aResult;
+}
+
+void Model_Document::operationId(const std::string& theId)
+{
+  myTransactions.rbegin()->myId = theId;
+}
+
 /// Append to the array of references a new referenced label
 static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced)
 {
index cb99181f9ddb8a9ce6b1d2233d0f6c508701edb6..62bd3ad40710380d92ebddb4c99ac84c967808b4 100644 (file)
@@ -199,6 +199,15 @@ class Model_Document : public ModelAPI_Document
   //! The implementation of undo: with or without recoursive calls in the sub-documents
   void undoInternal(const bool theWithSubs, const bool theSynchronize);
 
+  //! Stores the Id of the current operation (normally is called for the root document)
+  void operationId(const std::string& theId);
+
+  //! Returns the list of Ids of the operations that can be undoed (called for the root document)
+  std::list<std::string> undoList() const;
+
+  //! Returns the list of Ids of the operations that can be redoed (called for the root document)
+  std::list<std::string> redoList() const;
+
   friend class Model_Application;
   friend class Model_Session;
   friend class Model_Update;
@@ -216,11 +225,19 @@ class Model_Document : public ModelAPI_Document
   /// the list is empty if not nested transaction is performed
   std::list<int> myNestedNum;
 
-  /// transaction indexes (related to myTransactionsAfterSave) and number of real transactions 
+  /// Information related to the every user-transaction
+  struct Transaction {
+    int myOCAFNum; ///< number of OCAF transactions related to each "this" transaction, may be 0
+    std::string myId; ///< user-identifier string of transaction
+    /// default constructor with default Id
+    Transaction(): myOCAFNum(0), myId("") {}
+  };
+
+  /// transaction indexes (related to myTransactionsAfterSave) and info about the real transactions
   /// in myDocument connected to this operation (may be zero for empty transaction)
-  std::list<int> myTransactions;
-  /// list of numbers of real document transactions undone (first is oldest undone)
-  std::list<int> myRedos;
+  std::list<Transaction> myTransactions;
+  /// list of info about transactions undone (first is oldest undone)
+  std::list<Transaction> myRedos;
   /// All features managed by this document (not only in history of OB)
   /// For optimization mapped by labels
   NCollection_DataMap<TDF_Label, FeaturePtr> myObjs;
index e9edb8856c2c0d1c9ba490caa0c8400951cbc07e..8b81240a2bcc185126d3b6f582bce8cdc9059396 100644 (file)
@@ -53,6 +53,7 @@ void Model_Session::closeAll()
 void Model_Session::startOperation(const std::string& theId)
 {
   ROOT_DOC->startOperation();
+  ROOT_DOC->operationId(theId);
   static std::shared_ptr<Events_Message> aStartedMsg
     (new Events_Message(Events_Loop::eventByName("StartOperation")));
   Events_Loop::loop()->send(aStartedMsg);
@@ -121,17 +122,12 @@ void Model_Session::redo()
 //! Returns stack of performed operations
 std::list<std::string> Model_Session::undoList()
 {
-  std::list<std::string> temp;
-  temp.push_front("Part");
-  temp.push_front("Sketch");
-  temp.push_front("Extrusion");
-  return temp;
+  return ROOT_DOC->undoList();
 }
 //! Returns stack of rolled back operations
 std::list<std::string> Model_Session::redoList()
 {
-  std::list<std::string> temp;
-  return temp;
+  return ROOT_DOC->redoList();
 }
 
 FeaturePtr Model_Session::createFeature(string theFeatureID)
index 096e6eaaa0caa053d812baa90274c95cbfa65378..aea5e669a1fdb02c3487a7bed0714da7bfc3ad1e 100644 (file)
@@ -12,6 +12,7 @@ SET(PROJECT_HEADERS
        ModuleBase_FilterLinearEdge.h
        ModuleBase_FilterMulti.h
        ModuleBase_FilterNoConsructionSubShapes.h
+       ModuleBase_FilterNoDegeneratedEdge.h
        ModuleBase_FilterShapeType.h
        ModuleBase_Tools.h
        ModuleBase_IModule.h
@@ -53,6 +54,7 @@ SET(PROJECT_SOURCES
        ModuleBase_FilterLinearEdge.cpp
        ModuleBase_FilterMulti.cpp
        ModuleBase_FilterNoConsructionSubShapes.cpp
+       ModuleBase_FilterNoDegeneratedEdge.cpp
        ModuleBase_FilterShapeType.cpp
        ModuleBase_Tools.cpp
        ModuleBase_IModule.cpp
diff --git a/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.cpp b/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.cpp
new file mode 100644 (file)
index 0000000..1fb5a57
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_ViewerFilters.cpp
+// Created:     10 Feb 2015
+// Author:      Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterNoDegeneratedEdge.h"
+
+#include <StdSelect_BRepOwner.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <BRep_Tool.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter);
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter);
+
+ModuleBase_FilterNoDegeneratedEdge::ModuleBase_FilterNoDegeneratedEdge()
+: StdSelect_EdgeFilter(StdSelect_AnyEdge)
+{
+}
+
+Standard_Boolean ModuleBase_FilterNoDegeneratedEdge::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+  bool isEdge = StdSelect_EdgeFilter::IsOk(theOwner);
+  if (isEdge) {
+    Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+    if (!anOwner.IsNull() && anOwner->HasShape()) {
+      const TopoDS_Shape& aShape = anOwner->Shape();
+      if (BRep_Tool::Degenerated(TopoDS::Edge(aShape)))
+        return Standard_False;
+    }
+  }
+  return isEdge;
+}
+
diff --git a/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.h b/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.h
new file mode 100644 (file)
index 0000000..b61f001
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_ViewerFilters.h
+// Created:     10 Feb 2015
+// Author:      Natalia ERMOLAEVA
+
+
+#ifndef ModuleBase_FilterNoDegeneratedEdge_H
+#define ModuleBase_FilterNoDegeneratedEdge_H
+
+#include <QStringList>
+
+#include <StdSelect_EdgeFilter.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+/**
+* \ingroup GUI
+* \class ModuleBase_FilterNoDegeneratedEdge
+* An edge filter, which additionally filters degenerative edges.
+*/
+DEFINE_STANDARD_HANDLE(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter);
+class ModuleBase_FilterNoDegeneratedEdge: public StdSelect_EdgeFilter
+{
+public:
+  /// Constructor
+  Standard_EXPORT ModuleBase_FilterNoDegeneratedEdge();
+
+  /**
+   * Returns true if the owner is computed from decomposition(it is global selection, not the sub-shapes)
+   * of if the selected result is a construction and the result feature is composite and has sub-elements.
+   * \param theOwner the result of selection
+   * \return whether the owner is selectable in the viewer
+  */
+  Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+  DEFINE_STANDARD_RTTI(ModuleBase_FilterNoDegeneratedEdge)
+
+protected:
+};
+
+#endif
\ No newline at end of file
index 73a422d94a6a58a84b0d6cc42ff87202533f945c..f9e894085c34d2bc6c973178d6584be3ffbfebdc 100644 (file)
@@ -30,6 +30,8 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_
   myIsValueDefault = !theData->getProperty(ATTR_DEFAULT).empty();
   myIsComputedDefault = false;
   myAttributeID = theData ? theData->widgetId() : "";
+
+  connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
 }
 
 bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
@@ -71,6 +73,13 @@ void ModuleBase_ModelWidget::setHighlighted(bool isHighlighted)
   }
 }
 
+void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool theToStoreValue)
+{
+  myFeature = theFeature;
+  if (theToStoreValue)
+    storeValue();
+}
+
 bool ModuleBase_ModelWidget::focusTo()
 {
   QList<QWidget*> aControls = getControls();
@@ -122,3 +131,9 @@ bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
 
   return QObject::eventFilter(theObject, theEvent);
 }
+
+//**************************************************************
+void ModuleBase_ModelWidget::onWidgetValuesChanged()
+{
+  storeValue();
+}
index 44b43e4620d47749a322ad3b23e4f6c4175eb81a..6a3e63894a6f429627cd907f80534c228fa390c6 100644 (file)
@@ -72,9 +72,6 @@ Q_OBJECT
     return false;
   }
 
-  /// Saves the internal parameters to the given feature
-  virtual bool storeValue() const = 0;
-
   /// Restore value from attribute data to the widget's control
   virtual bool restoreValue() = 0;
 
@@ -127,10 +124,8 @@ Q_OBJECT
   }
 
   /// Set feature which is processing by active operation
-  void setFeature(const FeaturePtr& theFeature)
-  {
-    myFeature = theFeature;
-  }
+  /// \param theToStoreValue a value about necessity to store the widget value to the feature
+  void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false);
 
   /// Editing mode depends on mode of current operation. This value is defined by it.
   void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
@@ -155,6 +150,10 @@ signals:
   void focusOutWidget(ModuleBase_ModelWidget* theWidget);
 
  protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const = 0;
+
   /// \brief Set the attribute name
   /// \param theAttribute the string value with attribute name
   void setAttributeID(const std::string& theAttribute)
@@ -173,6 +172,10 @@ signals:
   /// \param theObj is object for moving
   void moveObject(ObjectPtr theObj) const;
 
+protected slots:
+  /// Processing of values changed in model widget by store the current value to the feature
+  void onWidgetValuesChanged();
+
  protected:
 
   /// The attribute name of the model feature
index 37b15780d73760d05dccff2b9e064d807683dfe6..518d9a163698df418347103b689569e117be080d 100644 (file)
@@ -31,14 +31,17 @@ Q_OBJECT
 
   virtual ~ModuleBase_WidgetBoolValue();
 
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   virtual QList<QWidget*> getControls() const;
 
   QWidget* getControl() const;
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
  private:
    /// The check box
   QCheckBox* myCheckBox;
index 3f13cc4afdbfdea772f9190c4835bd14a12515c0..18fcb55bdadc55c6550681cd89f2685a5709afc7 100644 (file)
@@ -39,8 +39,6 @@ Q_OBJECT
 
   virtual ~ModuleBase_WidgetChoice();
   
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   virtual bool focusTo();
@@ -56,6 +54,11 @@ Q_OBJECT
   /// \return a controls list
   virtual QList<QWidget*> getControls() const;
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
 private slots:
   /// Slot called on combo box index change
   void onCurrentIndexChanged(int theIndex);
index c9032e66a3943fd31541e0a1bc365ff59a004854..9c7804bf9f09850aabe79dea14dd659f8469831d 100644 (file)
@@ -37,10 +37,6 @@ Q_OBJECT
 
   virtual ~ModuleBase_WidgetDoubleValue();
 
-  //! Saves the internal parameters to the given feature
-  // \return True in success
-  virtual bool storeValue() const;
-
   //! Read value of corresponded attribute from data model to the input control
   // \return True in success
   virtual bool restoreValue();
@@ -61,7 +57,12 @@ Q_OBJECT
  // it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
 //  void onValueChanged();
 
- protected:
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
+protected:
    /// Container for thw widget controls
   QWidget* myContainer;
 
index 3b183d7031a83f71c86059d3143d45d99fd09382..5a628286dde694aa8bc4a3dc1aefa176b95b366b 100644 (file)
@@ -46,8 +46,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelW
                                 const std::string& theParentId);
   virtual ~ModuleBase_WidgetFileSelector();
 
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   QWidget* getControl() const;
@@ -65,6 +63,11 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelW
   /// Processing of path changing
   void onPathChanged();
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
  protected:
    /// Returns string containing formats
   QString formatsString() const;
index 8d7d4281f9e490cadf1808040be4ad266d3480c5..fd0112ff19b88c3b24a4ec8cd0d8e3a07daf0050 100644 (file)
@@ -33,11 +33,6 @@ Q_OBJECT
   /// It returns false because this is an info widget
   virtual bool canSetValue() const { return false; };
 
-  virtual bool storeValue() const
-  {
-    return true;
-  }
-
   virtual bool restoreValue()
   {
     return true;
@@ -50,6 +45,14 @@ Q_OBJECT
   /// This control doesn't accept focus
   virtual bool focusTo() { return false; }
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const
+  {
+    return true;
+  }
+
 private:
   /// A label control
   QLabel* myLabel;
index a5955f84c3ee86f606bccdd267f29c6d6bfd683d..657b22be05064ebbd4f867e7909c4d2aab363f60 100644 (file)
@@ -38,8 +38,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetLineEdit : public ModuleBase_ModelWidge
                                 const std::string& theParentId);
   virtual ~ModuleBase_WidgetLineEdit();
 
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   QWidget* getControl() const;
@@ -50,7 +48,12 @@ class MODULEBASE_EXPORT ModuleBase_WidgetLineEdit : public ModuleBase_ModelWidge
    /// A slot for processing text changed event
   void onTextChanged();
 
- private:
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
+private:
    /// A line edit control
   QLineEdit* myLineEdit;
 
index 5ee8ac64a38bd0bab91c132eb4b3a475fdebfac9..a11725988706e55c0ce67527a6d1ef867f5afe36 100644 (file)
@@ -9,8 +9,10 @@
 
 #include <ModuleBase_WidgetMultiSelector.h>
 #include <ModuleBase_WidgetShapeSelector.h>
+#include <ModuleBase_FilterNoDegeneratedEdge.h>
 #include <ModuleBase_ISelection.h>
 #include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IViewer.h>
 #include <ModuleBase_Tools.h>
 
 #include <ModelAPI_Data.h>
@@ -167,6 +169,8 @@ void ModuleBase_WidgetMultiSelector::activateSelection(bool toActivate)
   } else {
     disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
     myWorkshop->deactivateSubShapesSelection();
+
+    myWorkshop->viewer()->removeSelectionFilter(myEdgesTypeFilter);
   }
 }
 
@@ -258,6 +262,17 @@ void ModuleBase_WidgetMultiSelector::activateShapeSelection()
   QIntList aList;
   aList.append(ModuleBase_WidgetShapeSelector::shapeType(aNewType));
   myWorkshop->activateSubShapesSelection(aList);
+
+  // it is necessary to filter the selected edges to be non-degenerated
+  // it is not possible to build naming name for such edges
+  if (aNewType == "Edges") {
+    myEdgesTypeFilter = new ModuleBase_FilterNoDegeneratedEdge();
+    ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+    aViewer->addSelectionFilter(myEdgesTypeFilter);
+  }
+  else {
+    myWorkshop->viewer()->removeSelectionFilter(myEdgesTypeFilter);
+  }
 }
 
 //********************************************************************
index fa73d37590badcdc8f17d95f39031b73357c7837..3b092d424c0c7720e5a920743247ca4737e5c6c0 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <ModuleBase.h>
 #include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_FilterNoDegeneratedEdge.h>
 
 #include <GeomAPI_Shape.h>
 #include <ModelAPI_Result.h>
@@ -61,9 +62,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Model
                                  const std::string& theParentId);
   virtual ~ModuleBase_WidgetMultiSelector();
 
-  /// Saves the internal parameters to the given feature
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   /// Returns the internal parent wiget control, that can be shown anywhere
@@ -94,7 +92,11 @@ protected slots:
   void onListSelection();
 
  protected:
-   /// Provide filtering of selected shapes
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
+  /// Provide filtering of selected shapes
    /// \param theShapesToFilter source list of shapes
    /// \param theResult result list of shapes
   void filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
@@ -133,6 +135,9 @@ protected slots:
 
   /// An action for pop-up menu in a list control
   QAction* myCopyAction;
+
+  /// A filter for the Edges type, which avoid the generated edges selection
+  Handle(ModuleBase_FilterNoDegeneratedEdge) myEdgesTypeFilter;
 };
 
 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
index b4885d240a566e6c070aeb846f3bdee503c2dc8d..aa0c75f13f662a5c7ee5fdf01f9ee223a341f938 100644 (file)
@@ -71,9 +71,6 @@ Q_OBJECT
 
   virtual ~ModuleBase_WidgetShapeSelector();
 
-  /// Saves the internal parameters to the given feature
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   /// Defines if it is supposed that the widget should interact with the viewer.
@@ -116,6 +113,10 @@ Q_OBJECT
   void onSelectionChanged();
 
  protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
   /// The methiod called when widget is activated
   virtual void activateCustom();
 
index c3c887ae8e71763f04ae01fdc30409815be02ff5..e68c971ec737c65036659610c2ba598e2caed995 100644 (file)
@@ -162,7 +162,12 @@ void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow* theView, QMouseEvent* th
 bool NewGeom_SalomeViewer::canDragByMouse() const
 {
   OCCViewer_Viewer* aViewer = mySelector->viewer();
-  return (aViewer->interactionStyle() != 0);
+  SUIT_ViewWindow* aWnd = aViewer->getViewManager()->getActiveView();
+  OCCViewer_ViewWindow* aViewWnd = dynamic_cast<OCCViewer_ViewWindow*>(aWnd);
+  if (aViewWnd) {
+    return (aViewWnd->interactionStyle() == 0);
+  }
+  return true;
 }
 
 
index 8c0eff95509abcfe7d2d04ecaad31d1ecb94be5e..280c107f6d893509c408498e56716c5cdc59ff5c 100644 (file)
@@ -74,6 +74,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
                     ${CMAKE_SOURCE_DIR}/src/SketchPlugin
                     ${CMAKE_SOURCE_DIR}/src/FeaturesPlugin
                     ${CMAKE_SOURCE_DIR}/src/GeomAPI
+                    ${CMAKE_SOURCE_DIR}/src/AppElements
                     ${CAS_INCLUDE_DIRS}
                                        ${SUIT_INCLUDE}
 )
index c3b59579668d445b63acc6eff22d7ab3a6dac072..f3ccdf4f7d2dc0c570b1778f5f1d737252b2cfc4 100644 (file)
@@ -186,9 +186,13 @@ void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
 {
-  if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+  if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
     mySketchMgr->startSketch(theOperation);
   }
+  else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+    mySketchMgr->startNestedSketch(theOperation);
+  }
+
   if (myDocumentShapeFilter.IsNull())
     myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
   myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
@@ -196,15 +200,20 @@ void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
 {
-  if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+  if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
     mySketchMgr->stopSketch(theOperation);
   }
+  else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+    mySketchMgr->stopNestedSketch(theOperation);
+  }
   myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
 }
 
 bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
 {
   bool aCanDisplay = false;
+  if (!mySketchMgr->canDisplayObject(theObject))
+    return aCanDisplay;
   CompositeFeaturePtr aSketchFeature = mySketchMgr->activeSketch();
   if (aSketchFeature.get() != NULL) {
     FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
@@ -238,7 +247,8 @@ bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
 
 void PartSet_Module::addViewerItems(QMenu* theMenu) const
 {
-  if (!isSketchOperationActive() && !isSketchFeatureOperationActive())
+  if (!PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation()) &&
+      !isSketchFeatureOperationActive())
     return;
   ModuleBase_ISelection* aSelection = myWorkshop->selection();
   QObjectPtrList aObjects = aSelection->selectedPresentations();
@@ -259,8 +269,7 @@ void PartSet_Module::addViewerItems(QMenu* theMenu) const
 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
 {
   ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
-  if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) && 
-    (theOperation->isEditOperation())) {
+  if (PartSet_SketcherMgr::isSketchOperation(theOperation) &&  (theOperation->isEditOperation())) {
     // we have to manually activate the sketch label in edit mode
       aPanel->activateWidget(aPanel->modelWidgets().first());
       return;
@@ -289,20 +298,17 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
     if (theOperation->isEditOperation()) {
       // TODO: #391 - to be removed
       std::string aId = theOperation->id().toStdString();
-      if (PartSet_SketcherMgr::sketchOperationIdList().contains(QString(aId.c_str()))) {
-        if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
-            (aId == SketchPlugin_ConstraintLength::ID()) || 
-            (aId == SketchPlugin_ConstraintDistance::ID())) {
-          // Find and activate widget for management of point for dimension line position
-          QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
-          foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
-            PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
-            if (aPntWgt) {
-              aPanel->activateWidget(aPntWgt);
-              return;
-            }
+      if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
+          PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
+        // Find and activate widget for management of point for dimension line position
+        QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+        foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+          PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
+          if (aPntWgt) {
+            aPanel->activateWidget(aPntWgt);
+            return;
           }
-        } 
+        }
       }
     }
   }
@@ -319,7 +325,7 @@ void PartSet_Module::onSelectionChanged()
   // An edit operation is enable only if the current opeation is the sketch operation
   if (mySketchMgr->activeSketch()) {
     if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
-      isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
+      isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
   }
   if (isSketcherOp) {
     // Editing of constraints can be done on selection
@@ -442,14 +448,6 @@ QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget*
     return 0;
 }
 
-bool PartSet_Module::isSketchOperationActive() const
-{
-  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
-
-  bool isSketchOp = aOperation && aOperation->id().toStdString() == SketchPlugin_Sketch::ID();
-  return isSketchOp;
-}
-
 bool PartSet_Module::isSketchFeatureOperationActive() const
 {
   bool isCurrentSketchOp = false;
@@ -497,7 +495,7 @@ void PartSet_Module::onAction(bool isChecked)
 
 void PartSet_Module::deleteObjects()
 {
-  bool isSketchOp = isSketchOperationActive();
+  bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation());
   if (!isSketchOp && !isSketchFeatureOperationActive())
     return;
 
index 80fd683fef3c97a3d289cdb4cbced777e9b0fc52..d601d5a6f258baebc05fdcb4acb9d09198f525b3 100644 (file)
@@ -18,6 +18,8 @@
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_PropertyPanel.h>
 
+#include <AppElements_MainWindow.h>
+
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_IViewWindow.h>
@@ -106,7 +108,8 @@ void fillFeature2Attribute(const QList<ModuleBase_ViewerPrs>& theList,
 
 
 PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
-  : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false)
+  : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
+     myIsMouseOverWindow(false), myIsPropertyPanelValueChanged(false)
 {
   ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
   ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
@@ -136,6 +139,22 @@ PartSet_SketcherMgr::~PartSet_SketcherMgr()
     myPlaneFilter.Nullify();
 }
 
+void PartSet_SketcherMgr::onMouseMoveOverWindow(bool theOverWindow)
+{
+  myIsMouseOverWindow = theOverWindow;
+  if (theOverWindow)
+    myIsPropertyPanelValueChanged = false;
+
+  updateVisibilityOfCreatedFeature();
+}
+
+void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
+{
+  myIsPropertyPanelValueChanged = true;
+
+  updateVisibilityOfCreatedFeature();
+}
+
 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
   get2dPoint(theWnd, theEvent, myClickedPoint);
@@ -166,8 +185,8 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
     if (!PartSet_Tools::sketchPlane(myCurrentSketch))
       return;
 
-    bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
-    bool isSketchOpe = sketchOperationIdList().contains(aOperation->id());
+    bool isSketcher = isSketchOperation(aOperation);
+    bool isSketchOpe = isNestedSketchOperation(aOperation);
 
     // Avoid non-sketch operations
     if ((!isSketchOpe) && (!isSketcher))
@@ -234,8 +253,8 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
     return;
   ModuleBase_Operation* aOp = aWorkshop->currentOperation();
   if (aOp) {
-    if (sketchOperationIdList().contains(aOp->id())) {
-  get2dPoint(theWnd, theEvent, myClickedPoint);
+    if (isNestedSketchOperation(aOp)) {
+      get2dPoint(theWnd, theEvent, myClickedPoint);
 
       // Only for sketcher operations
       if (myIsDragging) {
@@ -277,7 +296,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
     if (!aOperation)
       return;
-    if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
+    if (isSketchOperation(aOperation))
       return; // No edit operation activated
 
     Handle(V3d_View) aView = theWnd->v3dView();
@@ -387,6 +406,9 @@ void PartSet_SketcherMgr::onApplicationStarted()
     connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)),
             this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*)));
   }
+
+  AppElements_MainWindow* aMainWindow = aWorkshop->mainWindow();
+  connect(aMainWindow, SIGNAL(mouseMoveOverWindow(bool)), this, SLOT(onMouseMoveOverWindow(bool)));
 }
 
 void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget)
@@ -407,15 +429,6 @@ void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWid
   }
 }
 
-bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation) const
-{
-  std::string aId = theOperation ? theOperation->id().toStdString() : "";
-
-  return (aId == SketchPlugin_ConstraintLength::ID()) ||
-         (aId == SketchPlugin_ConstraintDistance::ID()) ||
-         (aId == SketchPlugin_ConstraintRadius::ID());
-}
-
 void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
                                      Point& thePoint)
 {
@@ -471,6 +484,26 @@ QStringList PartSet_SketcherMgr::sketchOperationIdList()
   return aIds;
 }
 
+bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
+{
+  return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
+}
+
+bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation)
+{
+  return theOperation &&
+         PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id());
+}
+
+bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
+{
+  std::string aId = theOperation ? theOperation->id().toStdString() : "";
+
+  return (aId == SketchPlugin_ConstraintLength::ID()) ||
+         (aId == SketchPlugin_ConstraintDistance::ID()) ||
+         (aId == SketchPlugin_ConstraintRadius::ID());
+}
+
 void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
 {
   // Display all sketcher sub-Objects
@@ -553,6 +586,20 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
   aDisplayer->updateViewer();
 }
 
+void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* )
+{
+  connectToPropertyPanel(true);
+}
+
+void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* )
+{
+  connectToPropertyPanel(false);
+}
+
+bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
+{
+  return myIsMouseOverWindow || myIsPropertyPanelValueChanged;
+}
 
 void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
 {
@@ -679,3 +726,43 @@ void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
     }
   }
 }
+
+void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
+{
+  ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
+  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
+  if (aPropertyPanel) {
+    const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+    foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+      if (isToConnect)
+        connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+      else
+        disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+    }
+  }
+}
+
+void PartSet_SketcherMgr::updateVisibilityOfCreatedFeature()
+{
+  ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+  ModuleBase_Operation* aOperation = aWorkshop->currentOperation();
+  if (!aOperation || aOperation->isEditOperation())
+    return;
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+  XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+  FeaturePtr aFeature = aOperation->feature();
+  std::list<ResultPtr> aResults = aFeature->results();
+  std::list<ResultPtr>::const_iterator aIt;
+  for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+    if (canDisplayObject(aFeature)) {
+      aDisplayer->display(*aIt, false);
+    }
+    else {
+      aDisplayer->erase(*aIt, false);
+    }
+  }
+  aDisplayer->updateViewer();
+}
\ No newline at end of file
index 1507f92e98926f64a60d7ca38feb4210ca6e74f7..a08cf394162255f2f5aa3e2caf9c8fa076b644fb 100644 (file)
@@ -77,8 +77,20 @@ public:
 
   virtual ~PartSet_SketcherMgr();
 
-  /// Returns list of strings which contains id's of sketch operations
-  static QStringList sketchOperationIdList();
+  /// Returns true if the operation is the sketch
+  /// \param theOperation an operation
+  /// \return the boolean result
+  static bool isSketchOperation(ModuleBase_Operation* theOperation);
+
+  /// Returns true if the operation id is in the sketch operation id list
+  /// \param theOperation an operation
+  /// \return the boolean result
+  static bool isNestedSketchOperation(ModuleBase_Operation* theOperation);
+
+  /// Returns whethe the current operation is a sketch distance - lenght, distance or radius
+  /// \param the operation
+  /// \return a boolean value
+  static bool isDistanceOperation(ModuleBase_Operation* theOperation);
 
   /// Launches the operation from current highlighting
   void launchEditing();
@@ -92,12 +104,28 @@ public:
   /// Stops sketch operation
   void stopSketch(ModuleBase_Operation* );
 
+  /// Starts sketch operation
+  void startNestedSketch(ModuleBase_Operation* );
+
+  /// Stops sketch operation
+  void stopNestedSketch(ModuleBase_Operation* );
+
+  /// Returns whether the object can be displayed at the bounds of the active operation.
+  /// Display only current operation results for usual operation and ask the sketcher manager
+  /// if it is a sketch operation
+  /// \param theObject a model object
+  bool canDisplayObject(const ObjectPtr& theObject) const;
+
 public slots:
   /// Process sketch plane selected event
   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
 
 
 private slots:
+  /// Process the signal about mouse moving into or out of the window
+  /// \param heOverWindow true, if the moving happens to window
+  void onMouseMoveOverWindow(bool theOverWindow);
+  void onValuesChangedInPropertyPanel();
   void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*);
   void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*);
   void onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*);
@@ -106,10 +134,8 @@ private slots:
   void onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget);
 
 private:
-  /// Returns whethe the current operation is a sketch distance - lenght, distance or radius
-  /// \param the operation
-  /// \return a boolean value
-  bool isDistanceOperation(ModuleBase_Operation* theOperation) const;
+  /// Returns list of strings which contains id's of sketch operations
+  static QStringList sketchOperationIdList();
 
   /// Converts mouse position to 2d coordinates. 
   /// Member myCurrentSketch has to be correctly defined
@@ -163,12 +189,20 @@ private:
                                   const FeatureToSelectionMap& theSelection,
                                   SelectMgr_IndexedMapOfOwner& anOwnersToSelect);
 
+  /// Connects or disconnects to the value changed signal of the property panel widgets
+  /// \param isToConnect a boolean value whether connect or disconnect
+  void connectToPropertyPanel(const bool isToConnect);
+
+  void updateVisibilityOfCreatedFeature();
+
 private:
   PartSet_Module* myModule;
 
   bool myPreviousSelectionEnabled; // the previous selection enabled state in the viewer
   bool myIsDragging;
   bool myDragDone;
+  bool myIsMouseOverWindow; /// the state that mouse is over view
+  bool myIsPropertyPanelValueChanged; /// the state that value in the property panel is changed
   Point myCurrentPoint;
   Point myClickedPoint;
 
index 0b07da7e75db47c670207a7138059a3b9048c0fe..e32410baf76b329c388dacd6047c739ba22456ee 100644 (file)
@@ -425,15 +425,7 @@ std::shared_ptr<GeomAPI_Pnt> PartSet_Tools::point3D(std::shared_ptr<GeomAPI_Pnt2
   return thePoint2D->to3D(aC->pnt(), aX->dir(), aY->dir());
 }
 
-bool PartSet_Tools::isConstraintFeature(const std::string& theKind)
-{
-  return theKind == SketchPlugin_ConstraintDistance::ID()
-      || theKind == SketchPlugin_ConstraintLength::ID()
-      || theKind == SketchPlugin_ConstraintRadius::ID()
-      || theKind == SketchPlugin_ConstraintRigid::ID();
-}
-
-ResultPtr PartSet_Tools::createFixedObjectByEdge(const TopoDS_Shape& theShape, 
+ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape, 
                                                  const ObjectPtr& theObject, 
                                                  CompositeFeaturePtr theSketch)
 {
index 31508cb9a32ca2e58a95f48b851481f81830133d..854dd3b0eb1d5b5ae86e9c48bdf71b520ba75188 100644 (file)
@@ -144,10 +144,6 @@ class PARTSET_EXPORT PartSet_Tools
   /// \return API object of point 3D
   static std::shared_ptr<GeomAPI_Pnt> point3D(std::shared_ptr<GeomAPI_Pnt2d> thePoint2D,
                                                 CompositeFeaturePtr theSketch);
-  /// Check whether there is a constraint with the feature kind given
-  /// \param theKind a feature kind
-  /// \return the boolean value
-  static bool isConstraintFeature(const std::string& theKind);
 
   /// Creates a line (arc or circle) by given edge
   /// Created line will have fixed constraint
@@ -155,9 +151,9 @@ class PARTSET_EXPORT PartSet_Tools
   /// \param theObject a selected result object
   /// \param theSketch a sketch feature
   /// \return result of created feature
-  static ResultPtr createFixedObjectByEdge(const TopoDS_Shape& theShape, 
-                                           const ObjectPtr& theObject, 
-                                           CompositeFeaturePtr theSketch);
+  static ResultPtr createFixedObjectByExternal(const TopoDS_Shape& theShape, 
+                                               const ObjectPtr& theObject, 
+                                               CompositeFeaturePtr theSketch);
 
   /// Checks whether the list of selected presentations contains the given one
   /// \param theSelected a list of presentations
index e8796669b9cc529bd2b625a8dc9de2e5d61aeca1..ed4064004e2d96022409facd2a723067ae4972b0 100644 (file)
@@ -30,6 +30,8 @@
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Pnt2d.h>
 
+#include <SketchPlugin_Feature.h>
+
 #include <QGroupBox>
 #include <QGridLayout>
 #include <QLabel>
@@ -122,7 +124,7 @@ bool PartSet_WidgetPoint2D::setPoint(double theX, double theY)
   myYSpin->blockSignals(false);
   this->blockSignals(isBlocked);
 
-  emit valuesChanged();
+  storeValue();
   return true;
 }
 
@@ -234,45 +236,56 @@ bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
 void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
   XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+  Handle(V3d_View) aView = theWnd->v3dView();
   // TODO: This fragment doesn't work because bug in OCC Viewer. It can be used after fixing.
-  //NCollection_List<TopoDS_Shape> aShapes;
-  //std::list<ObjectPtr> aObjects;
-  //aSelection->selectedShapes(aShapes, aObjects);
-  //if (aShapes.Extent() > 0) {
-  //  TopoDS_Shape aShape = aShapes.First();
-  //  double aX, aY;
-  //  if (getPoint2d(theWnd->v3dView(), aShape, aX, aY)) {
-  //    setPoint(aX, aY);
-
-  //    PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY);
-  //    emit vertexSelected(aObjects.front(), aShape);
-  //    emit focusOutWidget(this);
-  //    return;
-  //  }
-  //}
+  NCollection_List<TopoDS_Shape> aShapes;
+  std::list<ObjectPtr> aObjects;
+  aSelection->selectedShapes(aShapes, aObjects);
+  // if we have selection
+  if (aShapes.Extent() > 0) {
+    TopoDS_Shape aShape = aShapes.First();
+    ObjectPtr aObject = aObjects.front();
+    FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aObject);
+    if (aSelectedFeature.get() != NULL) {
+      std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+              std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
+      if ((!aSPFeature) && (!aShape.IsNull()))
+        PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
+    }
+    double aX, aY;
+    if (getPoint2d(aView, aShape, aX, aY)) {
+      setPoint(aX, aY);
+
+      PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY);
+      emit vertexSelected();
+      emit focusOutWidget(this);
+      return;
+    }
+  }
   // End of Bug dependent fragment
 
   // A case when point is taken from mouse event
   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
   double aX, anY;
-  Handle(V3d_View) aView = theWnd->v3dView();
   PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, anY);
   if (!setPoint(aX, anY))
     return;
 
-  std::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint = std::dynamic_pointer_cast<
-      GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID()));
-  QList<FeaturePtr> aIgnore;
-  aIgnore.append(feature());
-
-  double aTolerance = aView->Convert(7);
-  std::shared_ptr<GeomDataAPI_Point2D> aAttrPnt = 
-    PartSet_Tools::findAttributePoint(mySketch, aX, anY, aTolerance, aIgnore);
-  if (aAttrPnt.get() != NULL) {
-    aFeaturePoint->setValue(aAttrPnt->pnt());
-    PartSet_Tools::createConstraint(mySketch, aAttrPnt, aFeaturePoint);
-    emit vertexSelected();
-  }
+  /// Start alternative code
+  //std::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint = std::dynamic_pointer_cast<
+  //    GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID()));
+  //QList<FeaturePtr> aIgnore;
+  //aIgnore.append(feature());
+
+  //double aTolerance = aView->Convert(7);
+  //std::shared_ptr<GeomDataAPI_Point2D> aAttrPnt = 
+  //  PartSet_Tools::findAttributePoint(mySketch, aX, anY, aTolerance, aIgnore);
+  //if (aAttrPnt.get() != NULL) {
+  //  aFeaturePoint->setValue(aAttrPnt->pnt());
+  //  PartSet_Tools::createConstraint(mySketch, aAttrPnt, aFeaturePoint);
+  //  emit vertexSelected();
+  //}
+  /// End alternative code
   emit focusOutWidget(this);
 }
 
index def3b2bb73e503ccfb416f05d9e691ae453aa167..a4e7323856d38073c4390954c4d8b7f8cb8f92e6 100644 (file)
@@ -52,8 +52,6 @@ Q_OBJECT
   /// \param theValue the wrapped widget value
   virtual bool setSelection(ModuleBase_ViewerPrs theValue);
 
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   /// Returns the internal parent wiget control, that can be shown anywhere
@@ -109,6 +107,10 @@ protected slots:
   void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
 protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
   /// The methiod called when widget is activated
   virtual void activateCustom();
 
index be108103444444fb9defbfc239b8f925efcddc31..54887f018cc199c568914bd356ced275ec60ae39 100644 (file)
@@ -56,7 +56,7 @@ void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
     mySpinBox->blockSignals(true);
     mySpinBox->setValue(aRadius);
     mySpinBox->blockSignals(false);
-    emit valuesChanged();
+    storeValue();
   }
 }
 
index cd69a1998d2e0620624667848994846ae8003549..2f9bb3e95ee310ef5b436e456599d03fabc224e7 100644 (file)
@@ -28,8 +28,8 @@ bool PartSet_WidgetShapeSelector::storeValue() const
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
   if ((!aSPFeature) && (!myShape->isNull())) {
     // Processing of external (non-sketch) object
-    ObjectPtr aObj = PartSet_Tools::createFixedObjectByEdge(myShape->impl<TopoDS_Shape>(),
-                                                            mySelectedObject, mySketch);
+    ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl<TopoDS_Shape>(),
+                                                                mySelectedObject, mySketch);
     if (aObj) {
       PartSet_WidgetShapeSelector* that = (PartSet_WidgetShapeSelector*) this;
       that->mySelectedObject = aObj;
@@ -133,8 +133,8 @@ bool PartSet_WidgetConstraintShapeSelector::storeValue() const
     std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
             std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
     if ((!aSPFeature) && (!myShape->isNull())) {
-      ObjectPtr aObj = PartSet_Tools::createFixedObjectByEdge(myShape->impl<TopoDS_Shape>(),
-                                                              mySelectedObject, mySketch);
+      ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl<TopoDS_Shape>(),
+                                                                  mySelectedObject, mySketch);
       if (aObj) {
         PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this;
         that->mySelectedObject = aObj;
index 222bac774861dde14ece55b7fa51f81fe96a6433..f8e9d75b1d7915cc3d9c2326ed43141222c155a5 100644 (file)
@@ -35,8 +35,6 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetShapeSelector() {}
 
-  virtual bool storeValue() const;
-
   /// Set sketcher
   /// \param theSketch a sketcher object
   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
@@ -45,6 +43,10 @@ Q_OBJECT
   CompositeFeaturePtr sketch() const { return mySketch; }
 
 protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
   /// Check the selected with validators if installed
   virtual bool isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape);
 
@@ -73,9 +75,6 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetConstraintShapeSelector() {}
 
-  /// Saves the internal parameters to the given feature
-  virtual bool storeValue() const;
-
   /// Set sketcher
   /// \param theSketch a sketcher object
   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
@@ -83,6 +82,11 @@ Q_OBJECT
   /// Retrurns installed sketcher
   CompositeFeaturePtr sketch() const { return mySketch; }
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
 private:
   /// Pointer to a sketch 
   CompositeFeaturePtr mySketch;
index d7b412f16b0024dffdfa9951693193d55c2595ca..0fa5c18f0372ca342b139a377c9a8ea5a94e4ffc 100644 (file)
@@ -48,11 +48,6 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetSketchLabel();
 
-  virtual bool storeValue() const
-  {
-    return true;
-  }
-
   virtual bool restoreValue()
   {
     return true;
@@ -82,6 +77,13 @@ signals:
   void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
 
 protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const
+  {
+    return true;
+  }
+
   /// The methiod called when widget is activated
   virtual void activateCustom();
 
index b89f5d42563a44a380f72f4cdbc9f7fd1c62c1af..5842df8a0968939413d98fd409be090d7e116fa9 100644 (file)
@@ -8,20 +8,21 @@
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_ResultConstruction.h>
 
+/// It is important.
+///
+/// Before writing a new method implementation in this file, please check the next rule:
+/// exported public methods must not be implemented in this source file. They should be inline and
+/// placed in the header file.
+/// Because it leads to the runtime problem on the Linux OS.
+///
+/// The reason is that this is an abstract interface. An interface of this class can be used in
+/// outside libraries through casting without a link to the current library.
+
 SketchPlugin_Feature::SketchPlugin_Feature()
 {
   mySketch = 0;
 }
 
-void SketchPlugin_Feature::erase()
-{
-  SketchPlugin_Sketch* aSketch = sketch();
-  if (aSketch)
-    aSketch->removeFeature(this);
-
-  ModelAPI_Feature::erase();
-}
-
 SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
 {
   if (!mySketch) {
index 66d59467b5682dfb6fc6ebcf95a0aeb1083edb73..7a50ef4e3369b1cc7b372a6ff1c36be91012851e 100644 (file)
@@ -79,7 +79,14 @@ class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs
   }
 
   /// removes also all sub-sketch elements
-  SKETCHPLUGIN_EXPORT virtual void erase();
+  SKETCHPLUGIN_EXPORT virtual void erase()
+  {
+    /*SketchPlugin_Sketch* aSketch = sketch();
+    if (aSketch)
+      aSketch->removeFeature(this);
+      */
+    ModelAPI_Feature::erase();
+  }
 
   /// Returns the sketch of this feature
   SketchPlugin_Sketch* sketch();
index bda3bd879fbf7b681a6ae81cf9ef89b1ea0e4cab..67fd1be899f23b7c4835f135abe87ed7b749f1b7 100644 (file)
@@ -135,6 +135,8 @@ std::shared_ptr<ModelAPI_Feature> SketchPlugin_Sketch::addFeature(std::string th
 
 void SketchPlugin_Sketch::removeFeature(ModelAPI_Feature* theFeature)
 {
+  if (!data().get()) // sketch is already removed (case on undo of sketch), sync is not needed
+    return;
   list<ObjectPtr> aSubs = data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
   list<ObjectPtr>::iterator aSubIt = aSubs.begin(), aLastIt = aSubs.end();
   bool isRemoved = false;
@@ -151,7 +153,7 @@ void SketchPlugin_Sketch::removeFeature(ModelAPI_Feature* theFeature)
   // if the object is not found in the sketch sub-elements, that means that the object is removed already.
   // Find the first empty element and remove it
   if (!isRemoved && aHasEmtpyFeature)
-    data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(NULL);
+    data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(ObjectPtr());
 }
 
 int SketchPlugin_Sketch::numberOfSubs() const
@@ -238,46 +240,6 @@ std::shared_ptr<GeomAPI_Pln> SketchPlugin_Sketch::plane()
   return std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir()));
 }
 
-//void addPlane(double theX, double theY, double theZ,
-//              std::list<std::shared_ptr<GeomAPI_Shape> >& theShapes)
-//{
-//  std::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
-//  std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
-//  double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE);
-//  std::shared_ptr<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal,
-//                                                                           aSize);
-//  theShapes.push_back(aFace);
-//}
-
-//AISObjectPtr SketchPlugin_Sketch::getAISObject(AISObjectPtr thePrevious)
-//{
-//  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-//      data()->attribute(SketchPlugin_Sketch::NORM_ID()));
-//
-//  if (!aNorm || (aNorm->x() == 0 && aNorm->y() == 0 && aNorm->z() == 0)) {
-//    AISObjectPtr aAIS = thePrevious;
-//    if (!aAIS) {
-//      std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
-//
-//      addPlane(1, 0, 0, aFaces);  // YZ plane
-//      addPlane(0, 1, 0, aFaces);  // XZ plane
-//      addPlane(0, 0, 1, aFaces);  // XY plane
-//      std::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
-//      aAIS = AISObjectPtr(new GeomAPI_AISObject());
-//      aAIS->createShape(aCompound);
-//
-//      std::vector<int> aRGB = Config_PropManager::color("Sketch planes", "planes_color",
-//      SKETCH_PLANE_COLOR);
-//      aAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
-//
-//      aAIS->setWidth(Config_PropManager::integer("Sketch planes", "planes_thickness",
-//      SKETCH_WIDTH));
-//    }
-//    return aAIS;
-//  }
-//  return AISObjectPtr();
-//}
-
 void SketchPlugin_Sketch::erase()
 {
   std::shared_ptr<ModelAPI_AttributeRefList> aRefList = std::dynamic_pointer_cast<
index 07624e29aa6d37b00beb9c1e9af70aaa2bb4569b..34d3a42bfbe5a826135e622e71170bcb204b303e 100644 (file)
@@ -652,13 +652,10 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
 
   QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
   foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
-    aWidget->setFeature(theOperation->feature());
+    bool isStoreValue = !theOperation->isEditOperation() &&
+                        aWidget->isValueDefault() && !aWidget->isComputedDefault();
+    aWidget->setFeature(theOperation->feature(), isStoreValue);
     aWidget->enableFocusProcessing();
-    QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
-    // Init default values
-    if (!theOperation->isEditOperation() && aWidget->isValueDefault() && !aWidget->isComputedDefault()) {
-      aWidget->storeValue();
-    }
   }
   
   myPropertyPanel->setModelWidgets(aWidgets);
@@ -1279,24 +1276,6 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
   }
 }
 
-//**************************************************************
-void XGUI_Workshop::onWidgetValuesChanged()
-{
-  ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
-  FeaturePtr aFeature = anOperation->feature();
-
-  ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
-
-  const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
-  QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
-  for (; anIt != aLast; anIt++) {
-    ModuleBase_ModelWidget* aCustom = *anIt;
-    if (aCustom && (aCustom == aSenderWidget)) {
-      aCustom->storeValue();
-    }
-  }
-}
-
 //**************************************************************
 void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
 {
index 1cf400d0f89a52956cf8e9d05516641cfea30c80..b492fa1134d3bf225c9ef7dd0b4a19d7feb88f15 100644 (file)
@@ -351,9 +351,6 @@ signals:
   /// \param isChecked a state of toggle if the action is checkable
   void onContextMenuCommand(const QString& theId, bool isChecked);
 
-  /// Processing of values changed in model widget
-  void onWidgetValuesChanged();
-
   /// Set waiting cursor
   void onStartWaiting();