]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom into Dev_0.7.1
authornds <natalia.donis@opencascade.com>
Thu, 29 Jan 2015 09:58:05 +0000 (12:58 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 29 Jan 2015 09:58:05 +0000 (12:58 +0300)
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Workshop.cpp

index e44ee809d41445db6e624d3b3c6f8ab862377cb4..fd2686df308b3bc672761701127e048f974182b7 100644 (file)
@@ -109,6 +109,11 @@ void ModuleBase_IModule::actionCreated(QAction* theFeature)
   connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
 }
 
+bool ModuleBase_IModule::canDisplayObject(const ObjectPtr& theObject) const
+{
+  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+  return anOperation && anOperation->hasObject(theObject);
+}
 
 void ModuleBase_IModule::onFeatureTriggered()
 {
index 191b02e5f744c0528a680602c77dc22a62bd3898..9420d1e74d8818724ca2547c8e02fb9a9a5213a4 100644 (file)
@@ -88,6 +88,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// It is called as on clearing of property panel as on filling with new widgets\r
   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}\r
 \r
+  /// Returns whether the object can be displayed at the bounds of the active operation.\r
+  /// Display only current operation results\r
+  /// \param theObject a model object\r
+  virtual bool canDisplayObject(const ObjectPtr& theObject) const;\r
+\r
 public slots:\r
   /// Called on call of command corresponded to a feature\r
   void onFeatureTriggered();\r
index c0ea09cd9a950e132fbc553375d3b07e8ef7ff1c..b05715c3847463a83df72c4fdda44ae894ae3c8d 100644 (file)
@@ -187,6 +187,26 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
   myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
 }
 
+bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
+{
+  bool aCanDisplay = false;
+  if (mySketchMgr->activeSketch()) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+
+    if (aFeature.get() != NULL) {
+      if (aFeature == mySketchMgr->activeSketch()) {
+        aCanDisplay = false;
+      }
+      else {
+        aCanDisplay = mySketchMgr->sketchOperationIdList().contains(aFeature->getKind().c_str());
+      }
+    }
+  }
+  else {
+    aCanDisplay = ModuleBase_IModule::canDisplayObject(theObject);
+  }
+  return aCanDisplay;
+}
 
 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
 {
@@ -219,6 +239,7 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
   } else {
     // Start editing constraint
     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()) ||
index 651b0b4e6e14e32ee51084ebdfe79cfdc2bf70b4..326866c9fd16917a5163ffec8ba13394046375d6 100644 (file)
@@ -77,6 +77,12 @@ public:
   /// \param theOperation a stopped operation
   virtual void operationStopped(ModuleBase_Operation* theOperation);
 
+  /// 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
+  virtual bool canDisplayObject(const ObjectPtr& theObject) const;
+
 public slots:
   /// SLOT, that is called by no more widget signal emitted by property panel
   /// Set a specific flag to restart the sketcher operation
index 06fcc33712e6d31008c3e7b463d68acd00013550..018001423cf4587155181f284f09482fffc8b65f 100644 (file)
@@ -45,6 +45,9 @@
 #include <SelectMgr_IndexedMapOfOwner.hxx>
 #include <StdSelect_BRepOwner.hxx>
 
+//#include <AIS_DimensionSelectionMode.hxx>
+//#include <AIS_Shape.hxx>
+
 #include <ModelAPI_Events.h>
 
 #include <QMouseEvent>
@@ -137,7 +140,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
 {
   get2dPoint(theWnd, theEvent, myClickedPoint);
 
-  // 
   if (!(theEvent->buttons() & Qt::LeftButton))
     return;
 
@@ -425,6 +427,12 @@ void PartSet_SketcherMgr::launchEditing()
   // point
   QIntList aModes;
   aModes << TopAbs_VERTEX << TopAbs_EDGE;
+  // TODO: #391 - to be uncommented
+  /*aModes.append(AIS_DSM_Text);
+  aModes.append(AIS_DSM_Line);
+  aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
+  aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));*/
+
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
   aConnector->activateSubShapesSelection(aModes);
 
index b1b9fd4917f28383768faff890f75cd1e0155e83..1507f92e98926f64a60d7ca38feb4210ca6e74f7 100644 (file)
@@ -33,6 +33,9 @@ class QMouseEvent;
 /**
 * \ingroup Modules
 * A class for management of sketch operations
+  At the time of the sketcher operation active, only the sketch sub-feature results are
+  displayed in the viewer. After the sketch create/edit operation is finished, the sub-feature
+  are hidden, the sketch feature result is displayed
 */
 class PARTSET_EXPORT PartSet_SketcherMgr : public QObject
 {
index cab65bc08482e14ab69d345d0552761245f01289..b68482a9dfb77b2f0936225be42c61327d596213 100644 (file)
@@ -41,6 +41,7 @@
 
 const int MOUSE_SENSITIVITY_IN_PIXEL = 10;  ///< defines the local context mouse selection sensitivity
 
+//#ifdef DEBUG_DISPLAY
 
 // Workaround for bug #25637
 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
@@ -85,6 +86,14 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
   if (isVisible(theObject)) {
     redisplay(theObject, isUpdateViewer);
   } else {
+#ifdef DEBUG_DISPLAY
+    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+    if (aFeature.get() != NULL) {
+      qDebug(QString("display feature: %1, displayed: %2").
+        arg(aFeature->data()->name().c_str()).
+        arg(displayedObjects().size()).toStdString().c_str());
+    }
+#endif
     AISObjectPtr anAIS;
 
     GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
index a246538cb279167e6c2781f2a21c8041d3e66192..4022d7fc70d4e4cb0750393b73cddf4e75dbbad9 100644 (file)
@@ -480,6 +480,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectU
   std::set<ObjectPtr>::const_iterator aIt;
   for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
     ObjectPtr aObj = (*aIt);
+
     bool aHide = !aObj->data() || !aObj->data()->isValid();
     if (!aHide) { // check that this is not hidden result
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
@@ -499,8 +500,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectU
       } else {
         if (myOperationMgr->hasOperation()) {
           ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-          // Display only current operation results if operation has preview
-          if (aOperation->hasObject(aObj)/* && aOperation->hasPreview()*/) {
+          if (myModule->canDisplayObject(aObj)) {
             displayObject(aObj);
             // Deactivate object of current operation from selection
             if (myDisplayer->isActive(aObj))
@@ -522,17 +522,15 @@ void XGUI_Workshop::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpd
   bool aHasPart = false;
   bool isDisplayed = false;
   for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
+
     ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
     if (aPart) {
       aHasPart = true;
       // If a feature is created from the aplication's python console  
       // it doesn't stored in the operation mgr and doesn't displayed
-    } else if (myOperationMgr->hasOperation()) {
-      ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-      if (aOperation->hasObject(*aIt)) {  // Display only current operation results
-        displayObject(*aIt);
-        isDisplayed = true;
-      }
+    } else if (myModule->canDisplayObject(*aIt)) {
+      displayObject(*aIt);
+      isDisplayed = true;
     }
   }
   if (myObjectBrowser)