]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #688, #689: bugs fixes.
authormkr <mkr@opencascade.com>
Tue, 17 Nov 2015 12:49:11 +0000 (15:49 +0300)
committermkr <mkr@opencascade.com>
Tue, 17 Nov 2015 12:49:11 +0000 (15:49 +0300)
src/HYDROGUI/HYDROGUI_LandCoverMapDlg.cxx
src/HYDROGUI/HYDROGUI_LandCoverMapDlg.h
src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx
src/HYDROGUI/HYDROGUI_LandCoverMapOp.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 57bcaff7f1760f529b5ee8e4ebbbdfa7ce3cef70..be0bb55c7eed6f1f8ec0271df2f3fca2c5b327a4 100644 (file)
@@ -68,9 +68,15 @@ HYDROGUI_LandCoverMapDlg::HYDROGUI_LandCoverMapDlg( HYDROGUI_Module* theModule,
   aParamLayout->addWidget( myStricklerTypesLabel, 1, 0, 1, 1 );
   aParamLayout->addWidget( myStricklerTypes, 1, 1, 1, 1 );
 
+  // Label indicated the number of selected land covers
+  QString aDefaultLabel( "0" );
+  mySelectedLandCoversLabel = new QLabel( tr( "LAND_COVER_MAP_SELECTED_FACES" ) + aDefaultLabel, myParamGroup );  
+  mySelectedLandCoversLabel->setStyleSheet("QLabel { font: italic; color : red; }");
+
   // Common
   addWidget( myObjectNameGroup );
   addWidget( myParamGroup );
+  addWidget( mySelectedLandCoversLabel );
 
   addStretch();
 
@@ -147,6 +153,17 @@ QString HYDROGUI_LandCoverMapDlg::getSelectedStricklerTypeName() const
   return myStricklerTypes->getSelectedStricklerTypeName();
 }
 
+void HYDROGUI_LandCoverMapDlg::updateSelectedLandCoversLabel( int theNbSelected )
+{
+  QString aLabel;
+  aLabel.setNum( theNbSelected );
+  if ( theNbSelected == 0 )
+    mySelectedLandCoversLabel->setStyleSheet("QLabel { font: italic; color : red; }");
+  else
+    mySelectedLandCoversLabel->setStyleSheet("QLabel { font: italic; color : black; }");
+  mySelectedLandCoversLabel->setText( tr( "LAND_COVER_MAP_SELECTED_FACES" ) + aLabel );
+}
+
 bool HYDROGUI_LandCoverMapDlg::isOk( const Handle(HYDROData_Entity)& theEntity ) const
 {
   Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast(theEntity);
@@ -193,6 +210,11 @@ void HYDROGUI_LandCoverMapDlg::updateState( bool theInitialConfigure )
                                       myOperationId == ChangeLandCoverTypeId );
     myStricklerTypesLabel->setVisible( aShowStricklerTypesCtrls );
     myStricklerTypes->setVisible( aShowStricklerTypesCtrls );
+
+    bool aShowSelectedLandCoversLabel = ( myOperationId == RemoveLandCoverId ||
+                                          myOperationId == MergeLandCoverId ||
+                                          myOperationId == ChangeLandCoverTypeId );
+    mySelectedLandCoversLabel->setVisible( aShowSelectedLandCoversLabel );
   }
   else
   {
index 62fd560189cbe13d4ea2ac8008bac54dacd6e649..2334a61a894cfa7bc12aef8770a1e0ff08dfb8f5 100644 (file)
@@ -52,6 +52,8 @@ public:
   void                     setSelectedStricklerTypeName( const QString& theName );
   QString                  getSelectedStricklerTypeName() const;
 
+  void                     updateSelectedLandCoversLabel( int theNbSelected );
+
   virtual bool             isOk( const Handle(HYDROData_Entity)& ) const;
 
 signals:
@@ -75,6 +77,7 @@ private:
   HYDROGUI_ObjComboBox*           myPolylinesFaces;
   QLabel*                         myStricklerTypesLabel;
   HYDROGUI_StricklerTypeComboBox* myStricklerTypes;
+  QLabel*                         mySelectedLandCoversLabel;
 };
 
 #endif
index 777ebf39782efe16c250ac0db4ed4d962ec2da7c..213256f6de8af9fe61ebff680711517cf5dc53fa 100644 (file)
@@ -221,11 +221,8 @@ bool HYDROGUI_LandCoverMapOp::processApply( int& theUpdateFlags,
             myOperationId == ChangeLandCoverTypeId )
   {
     if ( myPreviewPrs )
-    {
       // Fill in aFacesSelectedInViewer list
-      Handle(AIS_InteractiveContext) aCtx;
-      getSelectedShapes( aFacesSelectedInViewer, aCtx );
-    }
+      getSelectedShapes( aFacesSelectedInViewer );
   }
 
   // Get selected Strickler type
@@ -440,15 +437,14 @@ void HYDROGUI_LandCoverMapOp::onCreatePreview()
 
   if ( aViewManager && myPreviewPrs && !myEditedObject.IsNull() )
   {
-    TopoDS_Shape aLandCoverMapShape = myEditedObject->GetShape();
-    if( !aLandCoverMapShape.IsNull() )
-    {
-      if ( myOperationId == RemoveLandCoverId ||
-           myOperationId == MergeLandCoverId ||
-           myOperationId == ChangeLandCoverTypeId )
-        myPreviewPrs->setSelectionMode( AIS_Shape::SelectionMode( TopAbs_FACE ) ); 
-      myPreviewPrs->setShape( aLandCoverMapShape );      
-    }
+    if ( myOperationId == RemoveLandCoverId || 
+         myOperationId == MergeLandCoverId ||
+         myOperationId == ChangeLandCoverTypeId )
+      myPreviewPrs->setSelectionMode( AIS_Shape::SelectionMode( TopAbs_FACE ) ); 
+    myPreviewPrs->update( false, false );
+    
+    if ( myOperationId == ChangeLandCoverTypeId )
+      selectLandCoverInPreview();
   }
   
   module()->update( UF_OCCViewer | UF_FitAll );
@@ -462,33 +458,32 @@ void HYDROGUI_LandCoverMapOp::onViewerSelectionChanged()
   if ( !aPanel )
     return;
 
-  Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
-  if ( !aCtx.IsNull() )
-  {
-    int aNbSelected = aCtx->NbSelected();
+  int aNbSelected = getNbSelected();
 
-    if ( myOperationId == RemoveLandCoverId || myOperationId == ChangeLandCoverTypeId )
-      // Enable Apply, Apply and Close buttons only if at least one face (land cover) is selected in the 3d viewer
-      aPanel->setApplyEnabled( aNbSelected > 0 );
-    else if ( myOperationId == MergeLandCoverId )
-      // Enable Apply, Apply and Close buttons only if at least two faces (land covers) are selected in the 3d viewer
-      aPanel->setApplyEnabled( aNbSelected > 1 );
+  if ( myOperationId == RemoveLandCoverId || myOperationId == ChangeLandCoverTypeId )
+    // Enable Apply, Apply and Close buttons only if at least one face (land cover) is selected in the 3d viewer
+    aPanel->setApplyEnabled( aNbSelected > 0 );
+  else if ( myOperationId == MergeLandCoverId )
+    // Enable Apply, Apply and Close buttons only if at least two faces (land covers) are selected in the 3d viewer
+    aPanel->setApplyEnabled( aNbSelected > 1 );
 
-    if ( myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
+  if ( myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
+  {
+    if ( aNbSelected == 1 && !myEditedObject.IsNull() )
     {
-      if ( aNbSelected == 1 && !myEditedObject.IsNull() )
+      TopTools_ListOfShape aFacesSelectedInViewer;
+      getSelectedShapes( aFacesSelectedInViewer );
+      if ( aFacesSelectedInViewer.Extent() == 1 )
       {
-        TopTools_ListOfShape aFacesSelectedInViewer;
-        getSelectedShapes( aFacesSelectedInViewer, aCtx );
-        if ( aFacesSelectedInViewer.Extent() == 1 )
-        {
-          QString aType = myEditedObject->StricklerType( TopoDS::Face( aFacesSelectedInViewer.First() ) );
-          if ( !aType.isEmpty() )
-            aPanel->setSelectedStricklerTypeName( aType );
-        }
+        QString aType = myEditedObject->StricklerType( TopoDS::Face( aFacesSelectedInViewer.First() ) );
+        if ( !aType.isEmpty() )
+          aPanel->setSelectedStricklerTypeName( aType );
       }
     }
   }
+
+  if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
+    aPanel->updateSelectedLandCoversLabel( aNbSelected );
 }
 
 void HYDROGUI_LandCoverMapOp::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
@@ -616,17 +611,14 @@ Handle(AIS_InteractiveContext) HYDROGUI_LandCoverMapOp::getInteractiveContext()
   return aCtx;
 }
 
-void HYDROGUI_LandCoverMapOp::getSelectedShapes( TopTools_ListOfShape& theSelectedShapes,
-                                                 Handle(AIS_InteractiveContext)& theCtx )
+void HYDROGUI_LandCoverMapOp::getSelectedShapes( TopTools_ListOfShape& theSelectedShapes )
 {
-  if ( theCtx.IsNull() )
-    theCtx = getInteractiveContext();
-
-  if ( !theCtx.IsNull() && theCtx->NbSelected() > 0 )
+  Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
+  if ( !aCtx.IsNull() )
   {
-    for ( theCtx->InitSelected(); theCtx->MoreSelected(); theCtx->NextSelected() )
+    for ( aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected() )
     {
-      TopoDS_Shape aSelectedShape = theCtx->SelectedShape();
+      TopoDS_Shape aSelectedShape = aCtx->SelectedShape();
       if ( aSelectedShape.IsNull() )
         continue;
 
@@ -634,3 +626,52 @@ void HYDROGUI_LandCoverMapOp::getSelectedShapes( TopTools_ListOfShape& theSelect
     }
   }
 }
+
+int HYDROGUI_LandCoverMapOp::getNbSelected()
+{
+  int aNbSelected = 0;
+
+  Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
+  if ( !aCtx.IsNull() )
+  {
+    for ( aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected() )
+    {
+      TopoDS_Shape aSelectedShape = aCtx->SelectedShape();
+      if ( aSelectedShape.IsNull() )
+        continue;
+      aNbSelected++;
+    }
+  }
+
+  return aNbSelected;
+}
+
+void HYDROGUI_LandCoverMapOp::selectLandCoverInPreview()
+{
+  if ( myPreviewPrs && !myEditedObject.IsNull() && myEditedObject->GetLCCount() == 1 )
+  {
+    OCCViewer_ViewManager* aViewManager = getPreviewManager();
+    if ( !aViewManager )
+      return;
+    
+    Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
+    if ( aCtx.IsNull() )
+      return;
+    
+    OCCViewer_ViewWindow* aViewWindow = (OCCViewer_ViewWindow*)aViewManager->getActiveView();
+    if ( !aViewWindow )
+      return;
+
+    OCCViewer_ViewPort3d* aViewPort = aViewWindow->getViewPort();
+    if ( !aViewPort )
+      return;
+
+    Handle(V3d_View) aView = aViewPort->getView();
+    if ( aView.IsNull() )
+      return;
+
+    aCtx->ShiftSelect( 0, 0, aViewPort->width(), aViewPort->height(), aView, Standard_False );
+    aCtx->UpdateCurrentViewer();
+    emit selectionChanged();
+  }
+}
index 0c08817e7e3211266589f2618268e3d7b43a5dbb..d5c7e6405ec246413e07cfda4b5c76f8d68cf135 100644 (file)
@@ -63,8 +63,9 @@ private:
   void                           closePreview();
 
   Handle(AIS_InteractiveContext) getInteractiveContext();
-  void                           getSelectedShapes( TopTools_ListOfShape& theSelectedShapes,
-                                                    Handle(AIS_InteractiveContext)& theCtx );
+  void                           getSelectedShapes( TopTools_ListOfShape& theSelectedShapes );
+  int                            getNbSelected();
+  void                           selectLandCoverInPreview();
 
 private:
   int                             myOperationId;
index cf5b2b4de5aa950fb54b27683db4af16538c75e5..371a019959a1cf7f8f9ee5517ef7afe1dc1855e3 100644 (file)
@@ -2900,6 +2900,14 @@ Polyline should consist from one not closed curve.</translation>
       <source>LAND_COVER_MAP_STRICKLER_TYPE</source>
       <translation>Strickler type</translation>
     </message>
+    <message>
+      <source>LAND_COVER_MAP_SELECTED_FACES</source>
+      <translation>
+        
+  This operation is performed on a set of land covers selected in the 3D Viewer.
+        
+  Number of selected land covers: </translation>
+    </message>
   </context>
 
   <context>