Salome HOME
Provide hasPreview method for operations with preview
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 26 Sep 2014 12:24:19 +0000 (16:24 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 26 Sep 2014 12:24:19 +0000 (16:24 +0400)
src/ModuleBase/ModuleBase_Operation.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.h
src/XGUI/XGUI_Workshop.cpp

index 8e36a770463e439e5905ba01eea507fe27937502..17be4cba4286a6e6e63ea45c6ed6e3ec622c681a 100644 (file)
@@ -79,6 +79,10 @@ Q_OBJECT
 
   virtual void activateNextToCurrentWidget() {};
 
+  /// If operation needs to redisplay its result during operation
+  /// then this method has to return True
+  virtual bool hasPreview() const { return false; }
+
  public slots:
   /// Slots which listen the mode widget activation
   /// \param theWidget the model widget
index fe04a7f98c2e30535bf96eaa1a05f4c3a6e8f442..b2387c238bdcc42db0e62fee2e657e99ef6fd42b 100644 (file)
@@ -376,28 +376,6 @@ void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
   if (isDisplay)
     ModelAPI_EventCreator::get()->sendUpdated(
         theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
-  /*  bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
-   // TODO visualizePreview(theFeature, isDisplay, false);
-   if (!isDisplay) {
-   ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
-   FeaturePtr aSketch;
-   PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
-   if (aPrevOp) {
-   std::list<FeaturePtr> aList = aPrevOp->subFeatures();
-   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-   std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
-
-   std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
-   aLast = aList.end();
-   //TODO for (; anIt != aLast; anIt++)
-   //  visualizePreview((*anIt), false, false);
-   //aDisplayer->updateViewer();
-   }
-   }
-
-   if (theMode == PartSet_OperationSketchBase::FM_Activation ||
-   theMode == PartSet_OperationSketchBase::FM_Deactivation)
-   activateFeature(theFeature, true);*/
 }
 
 ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
@@ -485,35 +463,6 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
   Events_Loop::loop()->send(aMessage);
 }
 
-/*void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
- const bool isUpdateViewer)
- {
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- if (!anOperation)
- return;
-
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (!aPreviewOp)
- return;
-
- ResultPtr aResult = theFeature->firstResult();
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- if (isDisplay) {
- boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
- if (aSPFeature) {
- PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
- if (aSketchOp && !aSketchOp->hasSketchPlane())
- showPlanes();
- }
- }
- else
- aDisplayer->erase(aResult, false);
-
- if (isUpdateViewer)
- aDisplayer->updateViewer();
- }*/
-
 void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
@@ -611,26 +560,6 @@ void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& the
                                 aPoint->y());
 }
 
-/*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const
- {
- XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
- XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr();
-
- ModuleBase_Operation* aOperation = aOpMgr->currentOperation();
- if (!aOperation)
- return !aActMgr->isNested(theCmdId);
-
- PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast<PartSet_OperationFeatureEdit*>(aOperation);
- if (aSketchEdtOp) {
- QStringList aConstraintList;
- aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength"
- <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular";
- return aConstraintList.contains(theCmdId);
- }
- QStringList aList = aActMgr->nestedCommands(aOperation->id());
- return aList.contains(theCmdId);
- }*/
-
 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
                                             Config_WidgetAPI* theWidgetApi,
                                             QList<ModuleBase_ModelWidget*>& theModelWidgets)
index 1a90c5b88a493e925cb94276bfeb78b7d4b30c1b..72338efffb68d0017d4fde211a7b2bd4cdc3d84c 100644 (file)
@@ -166,12 +166,11 @@ void PartSet_OperationSketch::stopOperation()
   FeaturePtr aFeature = feature();
   std::list<ResultPtr> aResults = aFeature->results();
   std::list<ResultPtr>::const_iterator aIt;
+  Events_ID anEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TOSHOW);
   for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-    ModelAPI_EventCreator::get()->sendUpdated(
-        *aIt, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+    ModelAPI_EventCreator::get()->sendUpdated(*aIt, anEvent);
   }
-  //ModelAPI_EventCreator::get()->sendUpdated(aFeature, 
-  //  Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  Events_Loop::loop()->flush(anEvent);
 }
 
 bool PartSet_OperationSketch::isNestedOperationsEnabled() const
index 0cdf593ac3ee572ceb2cab4cc56dec06078a6c2a..862c6a4bf3ab7a9e5907074a441cb2b7fd67c929 100644 (file)
@@ -97,6 +97,10 @@ Q_OBJECT
   /// \param theShape the shape
   void setSketchPlane(const TopoDS_Shape& theShape);
 
+  /// If operation needs to redisplay its result during operation
+  /// then this method has to return True
+  virtual bool hasPreview() const { return false; }
+
 signals:
   /// signal about the sketch plane is selected
   /// \param theX the value in the X direction of the plane
index 878c56dd4e92fac0d02156403dc7576a0b29fd42..9b43039eaeff0754ec8f71daee153722f56a92f8 100644 (file)
@@ -120,6 +120,10 @@ Q_OBJECT
   /// theFeature the operation argument
   void restartOperation(const std::string& theType, ObjectPtr theFeature = ObjectPtr());
 
+  /// If operation needs to redisplay its result during operation
+  /// then this method has to return True
+  virtual bool hasPreview() const { return true; }
+
 signals:
   /// signal about the request to launch operation
   /// theName the operation name
index 1b48c4e081c1d7fc1f2c17e73c3f2782cfd49d62..def3e45ace97b9d180c94a64c64582f8daa74d9a 100644 (file)
@@ -419,9 +419,9 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const boost::shared_ptr<ModelAPI_Objec
       else {
         if (myOperationMgr->hasOperation()) {
           ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-          if (aOperation->hasObject(aObj)) {  // Display only current operation results
+          // Display only current operation results if operation has preview
+          if (aOperation->hasObject(aObj) && aOperation->hasPreview())
             myDisplayer->display(aObj, false);
-          }
         }
       }
     }