]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Fix for "0023306: [EDF 8444] Mesh controls behavior" issue.
authorana <ana@opencascade.com>
Mon, 8 Aug 2016 16:34:54 +0000 (19:34 +0300)
committerana <ana@opencascade.com>
Mon, 8 Aug 2016 16:34:54 +0000 (19:34 +0300)
src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_Actor.h
src/OBJECT/SMESH_ActorDef.h
src/OBJECT/SMESH_ScalarBarActor.cxx
src/OBJECT/SMESH_ScalarBarActor.h
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESH_msg_en.ts

index b0136d8e4f62a00ca5e9409bbc50b65eef3f6244..4006b506df86350067c6e2e3daca7fd29ff5ef93 100644 (file)
@@ -988,28 +988,33 @@ SetControlMode( eControl theMode, bool theCheckEntityMode )
 
     vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
     vtkIdType aNbCells = aGrid->GetNumberOfCells();
+    bool aShowOnlyScalarBarTitle = false;
     if(aNbCells){
       myControlMode = theMode;
       switch(myControlMode){
       case eFreeNodes:
       case eCoincidentNodes:
         myNodeExtActor->SetExtControlMode(myFunctor);
+        aShowOnlyScalarBarTitle = true;
         break;
       case eFreeEdges:
       case eFreeBorders:
       case eCoincidentElems1D:
         my1DExtActor->SetExtControlMode(myFunctor);
+        aShowOnlyScalarBarTitle = true;
         break;
       case eFreeFaces:
       case eBareBorderFace:
       case eOverConstrainedFace:
       case eCoincidentElems2D:
         my2DExtActor->SetExtControlMode(myFunctor);
+        aShowOnlyScalarBarTitle = true;
         break;
       case eBareBorderVolume:
       case eOverConstrainedVolume:
       case eCoincidentElems3D:
         my3DExtActor->SetExtControlMode(myFunctor);
+        aShowOnlyScalarBarTitle = true;
         break;
       case eLength2D:
       case eMultiConnection2D:
@@ -1020,6 +1025,7 @@ SetControlMode( eControl theMode, bool theCheckEntityMode )
         myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
         UpdateDistribution();
       }
+      myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
     }
 
     if(theCheckEntityMode) {
@@ -1057,6 +1063,9 @@ SetControlMode( eControl theMode, bool theCheckEntityMode )
         SetEntityMode(eVolumes);
     }
     }
+    QString aTitle = QString(myScalarBarActor->GetTitle());
+    aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
+    myScalarBarActor->SetTitle(aTitle.toLatin1().constData());
 
   }
   else {
@@ -1081,6 +1090,34 @@ SetControlMode( eControl theMode, bool theCheckEntityMode )
   Update();
 }
 
+int
+SMESH_ActorDef::
+GetNumberControlEntities(){
+  SMESH_DeviceActor* anAct = NULL;
+  switch(myControlMode){
+    case eFreeNodes:
+    case eCoincidentNodes:
+      anAct = myNodeExtActor;
+      break;
+    case eFreeEdges:
+    case eFreeBorders:
+    case eCoincidentElems1D:
+      anAct = my1DExtActor;
+      break;
+    case eFreeFaces:
+    case eBareBorderFace:
+    case eOverConstrainedFace:
+    case eCoincidentElems2D:
+      anAct = my2DExtActor;
+      break;
+    case eBareBorderVolume:
+    case eOverConstrainedVolume:
+    case eCoincidentElems3D:
+      anAct = my3DExtActor;
+      break;
+  }
+  return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
+}
 
 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
 
@@ -1424,10 +1461,10 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
       case eLength2D:
       case eMultiConnection2D:
         my1DExtActor->VisibilityOn();
-      default:
-        if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
-          myScalarBarActor->VisibilityOn();
+        break;
       }
+      if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
+        myScalarBarActor->VisibilityOn();
     }
 
     if(myRepresentation != ePoint)
index 5fc9a92b9abe99ed9f495ef7d316b0d04dfa71b1..abe27bb4e3a8adf901fe64df8ae9699127952002 100644 (file)
@@ -150,6 +150,7 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor
   virtual void SetControlMode(eControl theMode) = 0;
   virtual eControl GetControlMode() = 0;
   virtual SMESH::Controls::FunctorPtr GetFunctor() = 0;
+  virtual int GetNumberControlEntities() = 0;
 
   virtual SMESH_ScalarBarActor* GetScalarBarActor() = 0;
 
index 927199488bd9e8edc0d6a79906edde0eb7721f47..eb3654ab2054ea4c7159d7e4c34b95dbb7245dfb 100644 (file)
@@ -207,6 +207,7 @@ class SMESH_ActorDef : public SMESH_Actor
   virtual bool GetFacesOrientation3DVectors();
 
   virtual void SetControlMode(eControl theMode);
+  virtual int GetNumberControlEntities();
   virtual eControl GetControlMode(){ return myControlMode;}
   virtual SMESH::Controls::FunctorPtr GetFunctor() { return myFunctor; }
 
index 92a8a94b4d98a463b8c4fae8b133fa029b8df50d..1f5b00b63a5ee13e16f5c72587cd3addce35024e 100644 (file)
@@ -115,6 +115,9 @@ SMESH_ScalarBarActor::SMESH_ScalarBarActor() {
 
   // By default monocolor
   myDistributionColoringType = SMESH_MONOCOLOR_TYPE;
+
+  // By default scalar map is shown
+  myTitleOnlyVisibility = false;
   // rnv end
 }
 
@@ -194,19 +197,20 @@ int SMESH_ScalarBarActor::RenderOverlay(vtkViewport *viewport)
     {
     renderedSomething += this->TitleActor->RenderOverlay(viewport);
     }
-  this->ScalarBarActor->RenderOverlay(viewport);
-  this->myDistributionActor->RenderOverlay(viewport);
-  if( this->TextActors == NULL)
-    {
-     vtkWarningMacro(<<"Need a mapper to render a scalar bar");
-     return renderedSomething;
-    }
+  if (!myTitleOnlyVisibility) {
+    this->ScalarBarActor->RenderOverlay(viewport);
+    this->myDistributionActor->RenderOverlay(viewport);
+    if( this->TextActors == NULL)
+      {
+       vtkWarningMacro(<<"Need a mapper to render a scalar bar");
+       return renderedSomething;
+      }
   
-  for (i=0; i<this->NumberOfLabels; i++)
-    {
-    renderedSomething += this->TextActors[i]->RenderOverlay(viewport);
-    }
-
+    for (i=0; i<this->NumberOfLabels; i++)
+      {
+      renderedSomething += this->TextActors[i]->RenderOverlay(viewport);
+      }
+  }  
   renderedSomething = (renderedSomething > 0)?(1):(0);
 
   return renderedSomething;
@@ -574,7 +578,7 @@ int SMESH_ScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
       
       // rnv begin
       // Customization of the vtkScalarBarActor to show distribution histogram.
-      if(myNbValues[i] && myDistributionColoringType == SMESH_MULTICOLOR_TYPE && GetDistributionVisibility() && distrVisibility)
+      if(myDistributionColoringType == SMESH_MULTICOLOR_TYPE && GetDistributionVisibility() && distrVisibility)
         {
           rgb = distColors->GetPointer(3*dcCount); //write into array directly
           rgb[0] = rgba[0];
@@ -920,3 +924,11 @@ void SMESH_ScalarBarActor::SetDistributionColor (double rgb[3]) {
 void SMESH_ScalarBarActor::GetDistributionColor (double rgb[3]) {
   myDistributionActor->GetProperty()->GetColor(rgb);
 }
+
+void SMESH_ScalarBarActor::SetTitleOnlyVisibility( bool theTitleOnlyVisibility) {
+  myTitleOnlyVisibility = theTitleOnlyVisibility;
+}
+
+bool SMESH_ScalarBarActor::GetTitleOnlyVisibility() {
+  return myTitleOnlyVisibility;
+}
index 4dda0ad52e2fc16ff8c98f2d1427c22e9154481e..ffc91bb118b54aef89cd046e5d3c5991ad9ef377 100644 (file)
@@ -192,7 +192,13 @@ class SMESHOBJECT_EXPORT SMESH_ScalarBarActor: public vtkActor2D {
   // Get Distribution Color
   void GetDistributionColor (double rgb[3]);
   
+  // Description:
+  // Set visibility status of scalar map 
+  void SetTitleOnlyVisibility( bool );
 
+  // Description:
+  // Get visibility status of scalar map 
+  bool GetTitleOnlyVisibility();
 
  protected:
   SMESH_ScalarBarActor();
@@ -237,6 +243,7 @@ class SMESHOBJECT_EXPORT SMESH_ScalarBarActor: public vtkActor2D {
   vtkPolyDataMapper2D*   myDistributionMapper;       //Distribution mapper
   std::vector<int>       myNbValues;                 //Nb values for the range
   int                    myDistributionColoringType; //Distribution color type (monocolor or multicolor)
+  bool                   myTitleOnlyVisibility;      //Show scalar map or not
   
  private:
   SMESH_ScalarBarActor(const SMESH_ScalarBarActor&);  // Not implemented.
index 075b3eb5407dda8a03de370552eb56664be5f74a..6aff7a098e72518fe77f222f19df7c02e812077d 100644 (file)
@@ -1668,6 +1668,9 @@ namespace
                 if ( anActor->GetControlMode() != aControl )
                   anActor->SetControlMode( aControl );
                 QString functorName = functorToString( anActor->GetFunctor() );
+                int anEntitiesCount = anActor->GetNumberControlEntities();
+                if (anEntitiesCount >= 0)
+                  functorName = functorName + ": " + QString::number(anEntitiesCount);
                 anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() );
                 SMESH::RepaintCurrentView();
 #ifndef DISABLE_PLOT2DVIEWER
index 5392e5504824dca2ca47f8831639e096f329bed0..76a91b73bb8743b8677063f291b06dd0efd21f7a 100644 (file)
         <source>AREA_ELEMENTS</source>
         <translation>Area</translation>
     </message>
+    <message>
+        <source>FREE_NODES</source>
+        <translation>Free nodes</translation>
+    </message>
+    <message>
+        <source>FREE_EDGES</source>
+        <translation>Free edges</translation>
+    </message>
+    <message>
+        <source>FREE_FACES</source>
+        <translation>Free faces</translation>
+    </message>
+    <message>
+        <source>BARE_BORDER_FACE</source>
+        <translation>Faces with bare border</translation>
+    </message>
+    <message>
+        <source>OVER_CONSTRAINED_FACE</source>
+        <translation>Over-constrained faces</translation>
+    </message>
+    <message>
+        <source>BARE_BORDER_VOLUME</source>
+        <translation>Volumes with bare border</translation>
+    </message>
+    <message>
+        <source>OVER_CONSTRAINED_VOLUME</source>
+        <translation>Over-constrained volumes</translation>
+    </message>
     <message>
         <source>MIN_DIAG_ELEMENTS</source>
         <translation>Minimum diagonal</translation>