Salome HOME
Update copyright information
[modules/visu.git] / src / VISU_I / VISU_GaussPoints_i.cc
index 6c5efd3f72f1d461c77dca64d8f94f012060f357..aa43cba635bed67cefd7a4807d5a8f7aac32a9c1 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU OBJECT : interactive object for VISU entities implementation
 //  File   :
 //  Author :
@@ -139,7 +140,8 @@ VISU::GaussPoints_i
   myIsActiveLocalScalarBar(true),
   myIsDispGlobalScalarBar(true),
   mySpacing(0.01),
-  myFaceLimit(50000)
+  myFaceLimit(50000),
+  myShowBar(true)
 {
   if(MYDEBUG) MESSAGE("GaussPoints_i::GaussPoints_i - this = "<<this);
 }
@@ -215,6 +217,8 @@ VISU::GaussPoints_i
   anAlphaTexture = aResourceMgr->stringValue( "VISU", "point_sprite_alpha_texture", anAlphaTexture );
 
   SetTextures( aMainTexture.toLatin1().data(), anAlphaTexture.toLatin1().data() );
+  
+  myShowBar = true;
 
   return this;
 }
@@ -239,6 +243,8 @@ VISU::GaussPoints_i
 
     SetColor(anOrigin->GetColor());
 
+    SetBarVisible(anOrigin->IsBarVisible());
+
     SetTextures(anOrigin->GetMainTexture(), anOrigin->GetAlphaTexture());
   }
 }
@@ -270,6 +276,9 @@ VISU::GaussPoints_i
   CORBA::String_var aPixMapName = aPixmap->GetPixMap();
   if(strcmp(GetIconName(), aPixMapName.in()) != 0)
     aPixmap->SetPixMap(GetIconName());
+    
+  QString aVal = VISU::Storable::FindValue(theMap,"myShowBar", "1");
+  SetBarVisible((aVal.toInt() == 1)? true : false);
 
   SetIsActiveLocalScalarBar(Storable::FindValue(theMap,"myIsActiveLocalScalarBar").toInt());
   SetIsDispGlobalScalarBar(Storable::FindValue(theMap,"myIsDispGlobalScalarBar").toInt());
@@ -345,6 +354,7 @@ VISU::GaussPoints_i
   Storable::DataToStream( theStr, "myAlphaTexture", GetQAlphaTexture() );
 
   Storable::DataToStream( theStr, "myResolution", GetResolution() );
+  Storable::DataToStream( theStr, "myShowBar",    (IsBarVisible()? 1:0) );
 }
 
 
@@ -724,12 +734,15 @@ VISU::GaussPoints_i
   if(anIDMapper){
     int aNbGroups  = myGroupNames.size();
     if(myGroupNames.find(theGroupName) == myGroupNames.end()){
-      GetSpecificPL()->AddGeometry(anIDMapper->GetOutput());
+      GetSpecificPL()->AddGeometry(anIDMapper->GetOutput(), theGroupName);
       myGroupNames.insert(theGroupName);
       /*
       if(aNbGroups == 0)
        UpdateIcon();
       */
+      // To update scalar range according to the new input (IPAL21305)
+      if(!IsRangeFixed())
+        SetSourceRange();
     }
   }
 }
@@ -787,7 +800,15 @@ VISU::GaussPoints_i
   return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
 }
 
-
+void VISU::GaussPoints_i::SetBarVisible(CORBA::Boolean theVisible) 
+{ 
+  if (myShowBar == theVisible)
+    return;
+  VISU::TSetModified aModified(this);
+  myShowBar = theVisible; 
+  myParamsTime.Modified();
+}
+      
 //----------------------------------------------------------------------------
 void
 VISU::GaussPoints_i
@@ -856,6 +877,7 @@ VISU::GaussPoints_i
 ::CreateActor() 
 {
   VISU_GaussPtsAct* anActor = VISU_GaussPtsAct::New();
+  anActor->SetBarVisibility(myShowBar);
   if(OnCreateActor(anActor))
     return anActor;
   return NULL;
@@ -928,7 +950,6 @@ VISU::GaussPoints_i
   if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
     VISU_ScalarBarCtrl *aScalarBarCtrl = anActor->GetScalarBarCtrl();
     if(GetIsColored()){
-      anActor->SetBarVisibility(true);
       GetPipeLine()->GetMapper()->SetScalarVisibility(1);
 
       if(IsRangeFixed()){
@@ -988,14 +1009,14 @@ VISU::GaussPoints_i
 
       aScalarBarCtrl->Update();
     }else{
-      anActor->SetBarVisibility(false);
-
       GetPipeLine()->GetMapper()->SetScalarVisibility(0);
 
       anActor->GetProperty()->SetColor(myColor.red() / 255.0,
                                       myColor.green() / 255.0,
                                       myColor.blue() / 255.0);
     }
+    
+    anActor->SetBarVisibility(myShowBar && GetIsColored()); 
 
     if( GetSpecificPL()->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
       theActor->SetRepresentation( VTK_POINTS );
@@ -1143,7 +1164,8 @@ struct TGetSourceMin: public SALOME_Event
       myColoredPrs3d->GetSpecificPL()->GetSourceRange(aRange);
       myResult = aRange[0];
     }else{
-      VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode() );
+      VISU::TNames aGroupNames = myColoredPrs3d->GetSpecificPL()->GetGeometryNames();
+      VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode(), aGroupNames );
       myResult = aTMinMax.first;
     }
   }
@@ -1180,7 +1202,8 @@ struct TGetSourceMax: public SALOME_Event
       myColoredPrs3d->GetSpecificPL()->GetSourceRange(aRange);
       myResult = aRange[1];
     }else{
-      VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode() );
+      VISU::TNames aGroupNames = myColoredPrs3d->GetSpecificPL()->GetGeometryNames();
+      VISU::TMinMax aTMinMax = myColoredPrs3d->GetField()->GetMinMax( myColoredPrs3d->GetScalarMode(), aGroupNames );
       myResult = aTMinMax.second;
     }
   }
@@ -1242,7 +1265,7 @@ VISU::GaussPoints_i
 }
 
 //----------------------------------------------------------------------------
-struct TGetComponentMin: public SALOME_Event
+struct TGaussGetComponentMin: public SALOME_Event
 {
   VISU::ColoredPrs3d_i* myColoredPrs3d;
   vtkIdType myCompID;
@@ -1250,8 +1273,8 @@ struct TGetComponentMin: public SALOME_Event
   typedef CORBA::Double TResult;
   TResult myResult;
   
-  TGetComponentMin( VISU::ColoredPrs3d_i* theColoredPrs3d,
-                   vtkIdType theCompID ):
+  TGaussGetComponentMin( VISU::ColoredPrs3d_i* theColoredPrs3d,
+                        vtkIdType theCompID ):
     myColoredPrs3d( theColoredPrs3d ),
     myCompID( theCompID )
   {}
@@ -1260,11 +1283,15 @@ struct TGetComponentMin: public SALOME_Event
   void
   Execute()
   {
+    VISU::TNames aGroupNames;
+    if(VISU::GaussPoints_i* aPrs3d = dynamic_cast<VISU::GaussPoints_i*>(myColoredPrs3d))
+      aGroupNames = aPrs3d->GetSpecificPL()->GetGeometryNames();
+
     VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
     if ( aMinMaxController ) {
       myResult = aMinMaxController->GetComponentMin( myCompID );
     } else {
-      VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
+      VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID, aGroupNames );
       myResult = aTMinMax.first;
     }
   }
@@ -1276,11 +1303,11 @@ vtkFloatingPointType
 VISU::GaussPoints_i
 ::GetComponentMin(vtkIdType theCompID)
 {
-  return ProcessEvent( new TGetComponentMin( this, theCompID ) );
+  return ProcessEvent( new TGaussGetComponentMin( this, theCompID ) );
 }
 
 //----------------------------------------------------------------------------
-struct TGetComponentMax: public SALOME_Event
+struct TGaussGetComponentMax: public SALOME_Event
 {
   VISU::ColoredPrs3d_i* myColoredPrs3d;
   vtkIdType myCompID;
@@ -1288,8 +1315,8 @@ struct TGetComponentMax: public SALOME_Event
   typedef CORBA::Double TResult;
   TResult myResult;
   
-  TGetComponentMax( VISU::ColoredPrs3d_i* theColoredPrs3d,
-                   vtkIdType theCompID ):
+  TGaussGetComponentMax( VISU::ColoredPrs3d_i* theColoredPrs3d,
+                        vtkIdType theCompID ):
     myColoredPrs3d( theColoredPrs3d ),
     myCompID( theCompID )
   {}
@@ -1298,11 +1325,15 @@ struct TGetComponentMax: public SALOME_Event
   void
   Execute()
   {
+    VISU::TNames aGroupNames;
+    if(VISU::GaussPoints_i* aPrs3d = dynamic_cast<VISU::GaussPoints_i*>(myColoredPrs3d))
+      aGroupNames = aPrs3d->GetSpecificPL()->GetGeometryNames();
+
     VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
     if ( aMinMaxController ) {
       myResult = aMinMaxController->GetComponentMax( myCompID );
     } else {
-      VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
+      VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID, aGroupNames );
       myResult = aTMinMax.second;
     }
   }
@@ -1314,5 +1345,5 @@ vtkFloatingPointType
 VISU::GaussPoints_i
 ::GetComponentMax(vtkIdType theCompID)
 {
-  return ProcessEvent( new TGetComponentMax( this, theCompID ) );
+  return ProcessEvent( new TGaussGetComponentMax( this, theCompID ) );
 }