]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Sketcher bugfixing
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 4 Jul 2014 13:57:09 +0000 (17:57 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 4 Jul 2014 13:57:09 +0000 (17:57 +0400)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_Workshop.cpp

index b12db997bcf4473aa1b46a556b8cfb48fe66d3fe..990c9e44bceeb1625de372a8ebb795fc0eaec4d2 100644 (file)
@@ -183,8 +183,7 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp)
-  {
+  if (aPreviewOp) {
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
     std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
     std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
index a1652fc482c575cebb7274b876077ddd138c7aaf..b2f445505d96762b2a7b2e9e214c46bc433ab823 100644 (file)
@@ -113,9 +113,9 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
     return;
   }
 
-  double aX = 0, anY = 0;
-
   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+  double aX = aPoint.X(), anY = aPoint.Y();
+
   if (theSelected.empty()) {
     PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
   }
index 87f7635a58c1798cff6f4ec9b5fd86b94778829b..eff5a65ee5c3ef40a63277311a59cf5652958fc2 100644 (file)
@@ -226,7 +226,7 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
   boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
 
   flushUpdated();
-
+  
   emit featureConstructed(feature(), FM_Hide);
   emit closeLocalContext();
   emit planeSelected(aDir->x(), aDir->y(), aDir->z());
index fe49f74423c37445fb969957afe4bbb8d65944a1..fc9159a91a8f417dbbefa65184d37493ebae7660 100644 (file)
@@ -41,7 +41,7 @@ bool XGUI_Displayer::isVisible(FeaturePtr theFeature)
   return myFeature2AISObjectMap.find(aFeature) != myFeature2AISObjectMap.end();
 }
 
-void XGUI_Displayer::display(FeaturePtr theFeature, bool isUpdateViewer)
+bool XGUI_Displayer::display(FeaturePtr theFeature, bool isUpdateViewer)
 {
   FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature);
   boost::shared_ptr<GeomAPI_Shape> aShapePtr = aFeature->data()->shape();
@@ -49,20 +49,23 @@ void XGUI_Displayer::display(FeaturePtr theFeature, bool isUpdateViewer)
   if (aShapePtr) {
     boost::shared_ptr<GeomAPI_AISObject> anAIS(new GeomAPI_AISObject());
     anAIS->createShape(aShapePtr);
-    display(aFeature, anAIS, isUpdateViewer);
+    return display(aFeature, anAIS, isUpdateViewer);
   }
+  return false;
 }
 
-void XGUI_Displayer::display(FeaturePtr theFeature,
+bool XGUI_Displayer::display(FeaturePtr theFeature,
                              boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
-  myFeature2AISObjectMap[theFeature] = theAIS;
-
   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
-  if (!anAISIO.IsNull())
+  if (!anAISIO.IsNull()) {
+    myFeature2AISObjectMap[theFeature] = theAIS;
     aContext->Display(anAISIO, isUpdateViewer);
+    return true;
+  }
+  return false;
 }
 
 
@@ -136,11 +139,12 @@ void XGUI_Displayer::erase(FeaturePtr theFeature,
 
   Handle(AIS_InteractiveContext) aContext = AISContext();
   boost::shared_ptr<GeomAPI_AISObject> anObject = myFeature2AISObjectMap[aFeature];
-  if (anObject)
-  {
+  if (anObject)  {
     Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
-    if (!anAIS.IsNull())
+    if (!anAIS.IsNull()) {
       aContext->Erase(anAIS, isUpdateViewer);
+      
+    }
   }
   myFeature2AISObjectMap.erase(aFeature);
 }
@@ -178,22 +182,23 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
   return isCreated;
 }
 
-void XGUI_Displayer::redisplay(FeaturePtr theFeature, bool isUpdateViewer)
+bool XGUI_Displayer::redisplay(FeaturePtr theFeature, bool isUpdateViewer)
 {
   FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature);
   if (!isVisible(aFeature))
-    return;
+    return false;
 
   boost::shared_ptr<GeomAPI_Shape> aShapePtr = aFeature->data()->shape();
   if (aShapePtr) {
     boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(aFeature);
     Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
-    if (aAISShape.IsNull())
-      return;
-
-    aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
-    AISContext()->Redisplay(aAISShape);
+    if (!aAISShape.IsNull()) {
+      aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
+      AISContext()->Redisplay(aAISShape);
+      return true;
+    }
   }
+  return false;
 }
 
 void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature,
index 2ce31b14d440ff367f09b444ffa16d647e05acc4..a9a7fb36f744b652492889f93a20d015be5ca38d 100644 (file)
@@ -54,13 +54,15 @@ public:
   /// Display the feature. Obtain the visualized object from the feature.
   /// \param theFeature a feature instance
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void display(FeaturePtr theFeature, bool isUpdateViewer = true);
+  /// Returns true if the Feature succesfully displayed
+  bool display(FeaturePtr theFeature, bool isUpdateViewer = true);
 
   /// Display the feature and a shape. This shape would be associated to the given feature
   /// \param theFeature a feature instance
   /// \param theAIS AIS presentation
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void display(FeaturePtr theFeature, boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer = true);
+  /// Returns true if the Feature succesfully displayed
+  bool display(FeaturePtr theFeature, boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer = true);
   
   /// Returns a list of viewer selected presentations
   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
@@ -90,7 +92,7 @@ public:
   * \param theFeature a feature instance
   * \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   */
-  void redisplay(FeaturePtr theFeature, bool isUpdateViewer = true);
+  bool redisplay(FeaturePtr theFeature, bool isUpdateViewer = true);
 
   /// Redisplay the shape and activate selection of sub-shapes
   /// \param theFeature a feature instance
index e9383b4d71bfef5cce48587573e689dba4419087..adf7b27481b978ee2bf0799d1970bcb80d068e33 100644 (file)
@@ -72,17 +72,8 @@ XGUI_PropertyPanel::~XGUI_PropertyPanel()
 
 void XGUI_PropertyPanel::cleanContent()
 {
-  myWidgets.clear();
-  
-  QLayoutItem* aItem = myMainLayout->takeAt(myMainLayout->count() - 1);
-  delete aItem;
-
-  myMainLayout->removeWidget(myCustomWidget);
-  delete myCustomWidget;
-
-  myCustomWidget = new QWidget(widget());
-  myMainLayout->addWidget(myCustomWidget);
-  myMainLayout->addStretch(1);
+  myWidgets.clear(); 
+  qDeleteAll(myCustomWidget->children());
 }
 
 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
@@ -165,8 +156,7 @@ void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(),
                                                  aLast = myWidgets.end();
   bool isFoundWidget = false;
-  for (;anIt != aLast && !aNextWidget; anIt++)
-  {
+  for (;anIt != aLast && !aNextWidget; anIt++) {
     if (isFoundWidget || !theWidget) {
       if ((*anIt)->focusTo()) {
         aNextWidget = *anIt;
index ed05647f4bed4f0ac2d8a88abfcc195a9adb3d57..0b13ba5144359dd18a585d9fcc08e14530b1a273 100644 (file)
@@ -245,7 +245,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
   //An operation passed by message. Start it, process and commit.
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
     const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
-    myPropertyPanel->cleanContent();
+    //myPropertyPanel->cleanContent();
     ModuleBase_Operation* anOperation = (ModuleBase_Operation*)aPartSetMsg->pointer();
 
     if (myOperationMgr->startOperation(anOperation)) {
@@ -287,16 +287,15 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* the
 {
   std::set<FeaturePtr> aFeatures = theMsg->features();
   std::set<FeaturePtr>::const_iterator aIt;
+  bool isDisplayed = false;
   for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
     FeaturePtr aFeature = (*aIt);
     if (aFeature->getKind() != PARTSET_PART_KIND) {
-      if (myDisplayer->isVisible(aFeature))
-        myDisplayer->redisplay(aFeature, false);
-      else 
-        myDisplayer->display(aFeature, false);
+      isDisplayed = myDisplayer->redisplay(aFeature, false);
     }
   }
-  myDisplayer->updateViewer();
+  if (isDisplayed)
+    myDisplayer->updateViewer();
 }
 
 //******************************************************
@@ -306,16 +305,18 @@ void XGUI_Workshop::onFeatureCreatedMsg(const Model_FeatureUpdatedMessage* theMs
 
   std::set<FeaturePtr>::const_iterator aIt;
   bool aHasPart = false;
+  bool isDisplayed = false;
   for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
     FeaturePtr aFeature = (*aIt);
     if (aFeature->getKind() == PARTSET_PART_KIND) {
       aHasPart = true;
       //break;
     } else {
-      myDisplayer->display(aFeature, false);
+      isDisplayed = myDisplayer->display(aFeature, false);
     }
   }
-  myDisplayer->updateViewer();
+  if (isDisplayed)
+    myDisplayer->updateViewer();
   if (aHasPart) {
     //The created part will be created in Object Browser later and we have to activate it
     // only when it is created everywere
@@ -334,9 +335,9 @@ void XGUI_Workshop::onOperationStarted()
     showPropertyPanel();
     QString aXmlRepr = aOperation->getDescription()->xmlRepresentation();
     ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(), myModuleConnector);
-    QWidget* aContent = myPropertyPanel->contentWidget();
-    qDeleteAll(aContent->children());
-    aFactory.createWidget(aContent);
+
+    myPropertyPanel->cleanContent();
+    aFactory.createWidget(myPropertyPanel->contentWidget());
     
     QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
     QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
@@ -364,7 +365,7 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   //!< No need for property panel
   updateCommandStatus();
   hidePropertyPanel();
-  //myPropertyPanel->cleanContent();
+  myPropertyPanel->cleanContent();
 }
 
 /*