]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Implementation of the Point 2 of the 20948: EDF 1468 SMESH: Histogram of the quality...
authorrnv <rnv@opencascade.com>
Thu, 20 Jan 2011 15:41:36 +0000 (15:41 +0000)
committerrnv <rnv@opencascade.com>
Thu, 20 Jan 2011 15:41:36 +0000 (15:41 +0000)
14 files changed:
doc/salome/gui/SMESH/images/controls_popup.png
doc/salome/gui/SMESH/input/about_quality_controls.doc
resources/SalomeApp.xml
src/OBJECT/Makefile.am
src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_Actor.h
src/OBJECT/SMESH_ActorDef.h
src/SMESHGUI/Makefile.am
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx
src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h
src/SMESHGUI/SMESHGUI_VTKUtils.cxx
src/SMESHGUI/SMESHGUI_VTKUtils.h
src/SMESHGUI/SMESH_msg_en.ts

index b0bd01fb9aa0a7abf50480a84e69439a29d91b18..c32f9eada9a7e9cdf1b919c1994cb27529f93997 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/controls_popup.png and b/doc/salome/gui/SMESH/images/controls_popup.png differ
index ee57c8c815b01523d07956b01af44ce04383e322..374db90a93cc66b76c55b0a398f6ec21efbd689c 100644 (file)
@@ -64,8 +64,9 @@ To manage the quality controls call pop-up in the VTK viewer and select "Control
 <li> <b>Face Controls</b> provides access to the face quality controls;</li>
 <li> <b>Volume Controls</b> provides access to the volume quality controls;</li>
 <li> <b>Scalar Bar Properties</b> allows setting \subpage scalar_bar_dlg;</li>
-<li> <b>Export Distribution...</b> allows saving the distribution of quality control values in the text file;</li>
-<li> <b>Show Distribution</b> Shows/Hides the distribution histogram of the quality control values in the VTK Viewer.</li>
+<li> <b>Distribution -> Export ...</b> allows saving the distribution of quality control values in the text file;</li>
+<li> <b>Distribution -> Show </b> Shows/Hides the distribution histogram of the quality control values in the VTK Viewer.</li>
+<li> <b>Distribution -> Plot </b> Plots the distribution histogram of the quality control values in the Plot 2D Viewer.</li>
 </ul>
 
 
index ea6daa0bfc4d0bbdfde8951d46e084b30a3666b8..f6aef7f785fa344ca2ccc0c2c215d5f473eef65a 100644 (file)
@@ -67,7 +67,7 @@
     <parameter name="scalar_bar_vertical_y"        value="0.1" />
     <parameter name="distribution_visibility"      value="false" />
     <parameter name="distribution_coloring_type"   value="0" />
-    <parameter name="distribution_color"           value="255, 255, 255" />
+    <parameter name="distribution_color"           value="0, 85, 0" />
     <parameter name="DisplayMode"                  value="true" />
     <parameter name="auto_update"                  value="true" />
     <parameter name="update_limit"                 value="500000" />
index 88dd738fde9076d5222de75aa6f92281ff8d3284..eec2a6c0e9db3c9c27f87f624eb0c4992feab8fc 100644 (file)
@@ -55,6 +55,7 @@ libSMESHObject_la_CPPFLAGS = \
         $(KERNEL_CXXFLAGS) \
         $(GUI_CXXFLAGS) \
        $(MED_CXXFLAGS) \
+       $(QWT_INCLUDES) \
        $(GEOM_CXXFLAGS) \
        $(CAS_CPPFLAGS) \
         $(VTK_INCLUDES) \
index cafd4b00045fe5cd1a883905e8a4c51a10b5f4b9..91d5002836d2af36d35702b5e6a0d7a4ba876bc8 100644 (file)
 #include "SUIT_Session.h"
 #include "SUIT_ResourceMgr.h"
 
+#ifndef DISABLE_PLOT2DVIEWER
+#include <SPlot2d_Histogram.h>
+#endif
+
 #include <vtkProperty.h>
 #include <vtkTimeStamp.h>
 #include <vtkObjectFactory.h>
@@ -517,6 +521,11 @@ SMESH_ActorDef::SMESH_ActorDef()
   myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
   SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
   myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
+
+#ifndef DISABLE_PLOT2DVIEWER
+  my2dHistogram = 0;
+#endif
+
 }
 
 
@@ -608,6 +617,10 @@ SMESH_ActorDef::~SMESH_ActorDef()
   myImplicitBoolean->Delete();
 
   myTimeStamp->Delete();
+#ifndef DISABLE_PLOT2DVIEWER
+  if(my2dHistogram)
+    delete my2dHistogram;
+#endif 
 }
 
 
@@ -2097,3 +2110,57 @@ void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMa
   myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
   myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
 }
+
+#ifndef DISABLE_PLOT2DVIEWER
+SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
+
+  if(my2dHistogram)
+    my2dHistogram->clearAllPoints();
+  
+  if(SMESH::Controls::NumericalFunctor* fun =
+     dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
+  {
+    
+    if(!my2dHistogram) {
+      my2dHistogram = new SPlot2d_Histogram();
+      Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
+      my2dHistogram->setIO(anIO);
+    }
+    
+    int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
+    std::vector<int> nbEvents;
+    std::vector<double> funValues;
+    SMESH_VisualObjDef::TEntityList elems;
+    if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
+      dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
+    std::vector<int> elemIds;
+    
+    for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
+      elemIds.push_back( (*e)->GetID());
+
+    vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
+    double * range = lookupTable->GetRange();
+    fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
+
+    for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ ) 
+      my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
+
+    if(funValues.size() >= 2)
+      my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
+
+  }
+  
+  //Color of the histogram
+  if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
+    my2dHistogram->setAutoAssign(true);
+  else {
+    double rgb[3];
+    myScalarBarActor->GetDistributionColor(rgb);
+    QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
+    my2dHistogram->setColor(aColor);
+
+  }
+      
+  return my2dHistogram;
+}
+#endif
index 744571e41360280a92dbb6cfd3a50821ad74b496..95c6c79f32c9eb72f3161c3ed8198a885db7edc2 100644 (file)
@@ -40,6 +40,10 @@ class SMESH_ScalarBarActor;
 class vtkPlane;
 class vtkImplicitBoolean;
 
+#ifndef DISABLE_PLOT2DVIEWER
+class SPlot2d_Histogram;
+#endif
+
 namespace SMESH
 {
   const vtkIdType DeleteActorEvent = vtkCommand::UserEvent + 100;
@@ -143,6 +147,11 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor
 
   virtual void UpdateScalarBar() = 0;
   virtual void UpdateDistribution() = 0;
+
+#ifndef DISABLE_PLOT2DVIEWER
+  virtual SPlot2d_Histogram* GetPlot2Histogram() = 0;
+  virtual SPlot2d_Histogram* UpdatePlot2Histogram() = 0;
+#endif
 };
 
 
index 53001f4efbf9f7c62519b1036095426900b62c45..162203bb3c3d76450c733ad93fb74d7fef107d1e 100644 (file)
@@ -74,6 +74,10 @@ class VTKViewer_CellCenters;
 class SMESH_DeviceActor;
 class SMESH_ScalarBarActor;
 
+#ifndef DISABLE_PLOT2DVIEWER
+class SPlot2d_Histogram;
+#endif
+
 
 class SMESH_ActorDef : public SMESH_Actor
 {
@@ -198,6 +202,11 @@ class SMESH_ActorDef : public SMESH_Actor
   virtual void UpdateScalarBar();
   virtual void UpdateDistribution();
 
+#ifndef DISABLE_PLOT2DVIEWER
+  virtual SPlot2d_Histogram* GetPlot2Histogram() { return my2dHistogram; }
+  virtual SPlot2d_Histogram* UpdatePlot2Histogram();
+#endif
+
 
   virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation);
   virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation();
@@ -279,6 +288,10 @@ class SMESH_ActorDef : public SMESH_Actor
   TCippingPlaneCont myCippingPlaneCont;
   long myControlsPrecision;
 
+#ifndef DISABLE_PLOT2DVIEWER
+  SPlot2d_Histogram* my2dHistogram;
+#endif
+
   bool myIsFacesOriented;
 
   VTK::MarkerTexture myMarkerTexture;
index 6da5d4076cf01594987c4cd99be7576a2cad4112..a7104237cebc64e51c3c9522be0319487bcb6237 100644 (file)
@@ -241,6 +241,7 @@ libSMESH_la_CPPFLAGS = \
        $(PYTHON_INCLUDES) \
        $(KERNEL_CXXFLAGS)  \
        $(GUI_CXXFLAGS) \
+       $(QWT_INCLUDES) \
        $(GEOM_CXXFLAGS) \
        $(MED_CXXFLAGS) \
        $(BOOST_CPPFLAGS) \
index 2d3f45190cf995e996e097a1b4652a6cccb579a4..f314db7f8614574a5a1fd3555aa921021de76dfa 100644 (file)
 #include <SALOME_ListIO.hxx>
 #include <SALOME_ListIteratorOfListIO.hxx>
 
+#ifndef DISABLE_PLOT2DVIEWER
+#include <SPlot2d_ViewModel.h>
+#include <SPlot2d_Histogram.h>
+#endif
+
 // IDL includes
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
     }
   }
 
+#ifndef DISABLE_PLOT2DVIEWER
+ void PlotDistribution() {
+   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+   if( !app )
+     return;
+
+   LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
+   SALOME_ListIO selected;
+   if ( aSel )
+     aSel->selectedObjects( selected );
+    
+   if ( selected.Extent() == 1 ) {
+     Handle(SALOME_InteractiveObject) anIO = selected.First();
+     if ( anIO->hasEntry() ) {
+       //Find Actor by entry before getting Plot2d viewer,
+       //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
+       SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
+
+       SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
+
+       if( !aViewManager )
+        return;
+       
+       SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
+       if ( !aView )
+        return;
+
+       Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
+       if ( !aPlot )
+        return;
+
+       if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
+        SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
+        QString functorName = functorToString( anActor->GetFunctor());
+        QString aHistogramName("%1 : %2");
+        aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
+        aHistogram->setName(aHistogramName);
+        aHistogram->setHorTitle(functorName);
+        aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
+        aPlot->displayObject(aHistogram, true);
+       }
+     }
+   }
+ }
+#endif //DISABLE_PLOT2DVIEWER
+
   void DisableAutoColor(){
     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
     SALOME_ListIO selected;
           anActor->SetControlMode(aControl);
           anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
           SMESH::RepaintCurrentView();
+#ifndef DISABLE_PLOT2DVIEWER
+         if(anActor->GetPlot2Histogram()) {
+           SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
+           QString functorName = functorToString( anActor->GetFunctor());
+           QString aHistogramName("%1 : %2");
+           aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
+           aHistogram->setName(aHistogramName);
+           aHistogram->setHorTitle(functorName);
+           SMESH::ProcessIn2DViewers(anActor);
+         }
+#endif
         }
       }
     }
@@ -1849,6 +1911,9 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
         if( anIO->hasEntry() ) {
           if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
             anActor->SetControlMode( SMESH_Actor::eNone );
+#ifndef DISABLE_PLOT2DVIEWER
+           SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
+#endif
           }
         }
       }
@@ -1859,20 +1924,29 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
       break;
     }
-  case 202:
+  case 2021:
     {
       // dump control distribution data to the text file
       ::SaveDistribution();
       break;
     }
 
-  case 203:
+  case 2022:
     {
       // show/ distribution
       ::ShowDistribution();
       break;
     }
 
+#ifndef DISABLE_PLOT2DVIEWER
+  case 2023:
+    {
+      // plot distribution
+      ::PlotDistribution();
+      break;
+    }
+#endif
+
     // Auto-color
   case 1136:
     ::AutoColor();
@@ -3319,8 +3393,11 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction(  419, "SPLIT_TO_TETRA",  "ICON_SPLIT_TO_TETRA" );
   createSMESHAction(  200, "RESET" );
   createSMESHAction(  201, "SCALAR_BAR_PROP" );
-  createSMESHAction(  202, "SAVE_DISTRIBUTION" );
-  createSMESHAction(  203, "SHOW_DISTRIBUTION","",0, true );
+  createSMESHAction(  2021, "SAVE_DISTRIBUTION" );
+  createSMESHAction(  2022, "SHOW_DISTRIBUTION","",0, true );
+#ifndef DISABLE_PLOT2DVIEWER
+  createSMESHAction(  2023, "PLOT_DISTRIBUTION" );
+#endif
   createSMESHAction(  211, "WIRE",           "ICON_WIRE", 0, true );
   createSMESHAction(  212, "SHADE",          "ICON_SHADE", 0, true );
   createSMESHAction(  213, "SHRINK",         "ICON_SHRINK", 0, true );
@@ -3947,19 +4024,24 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   popupMgr()->insert( separator(), anId, -1 );
 
-  popupMgr()->insert( action( 202 ), anId, -1 ); // SAVE_DISTRIBUTION
-  popupMgr()->setRule( action( 202 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
+  aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
 
-  popupMgr()->insert( action( 203 ), anId, -1 ); // SHOW_DISTRIBUTION
-  popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
-  popupMgr()->setRule( action( 203 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
+  popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
+  popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
 
+  popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
+  popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
+  popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
 
-  popupMgr()->insert( separator(), -1, -1 );
+#ifndef DISABLE_PLOT2DVIEWER
+  popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
+  popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
+#endif
 
   //-------------------------------------------------
   // Display / Erase
   //-------------------------------------------------
+  popupMgr()->insert( separator(), -1, -1 );
   QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
     aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
   popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
index b1f9284c6497d6276433710b5d935f51611772ad..c566a3cf9fff8c3dbd5e74307ac6bc44eece09d0 100644 (file)
@@ -410,11 +410,12 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
 
   int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
   if( coloringType == SMESH_MONOCOLOR_TYPE ) {
+    myDMonoColor->setChecked(true);
+    onDistributionChanged(myDistribColorGrp->id(myDMonoColor));    
+  } else {
     myDMultiColor->setChecked(true);
     onDistributionChanged(myDistribColorGrp->id(myDMultiColor));
-  } else {
-    myDMonoColor->setChecked(true);
-    onDistributionChanged(myDistribColorGrp->id(myDMonoColor));
+
   }
   
   QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
@@ -435,6 +436,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
   connect( myXSpin,             SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
   connect( myYSpin,             SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
   connect( aOrientationGrp,     SIGNAL( buttonClicked( int ) ),   this, SLOT( onOrientationChanged() ) );
+  connect( myDistributionGrp,   SIGNAL( toggled(bool) ), this, SLOT(onDistributionActivated(bool)) );
   connect( myDistribColorGrp,   SIGNAL( buttonClicked( int ) ),   this, SLOT( onDistributionChanged( int ) ) );
   connect( mySelectionMgr,      SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
   connect( mySMESHGUI,          SIGNAL( SignalCloseAllDialogs() ),   this, SLOT( onCancel() ) );
@@ -520,17 +522,24 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
   myScalarBarActor->SetHeight( myHeightSpin->value() );
 
   // Distribution
+  bool distributionTypeChanged = false, colorChanged=false;
   myScalarBarActor->SetDistributionVisibility((int)myDistributionGrp->isChecked());
   if( myDistributionGrp->isChecked() ) {
     int ColoringType = myDMultiColor->isChecked() ? SMESH_MULTICOLOR_TYPE : SMESH_MONOCOLOR_TYPE;
-    myScalarBarActor->SetDistributionColoringType(ColoringType);
+    distributionTypeChanged = (ColoringType != myScalarBarActor->GetDistributionColoringType());
+    if(distributionTypeChanged)      
+      myScalarBarActor->SetDistributionColoringType(ColoringType);
+    
     if( !myDMultiColor->isChecked() ) {
       QColor aTColor = myMonoColorBtn->color();
-      double rgb[3];
+      double rgb[3], oldRgb[3];;
       rgb [0] = aTColor.red()/255.;
       rgb [1] = aTColor.green()/255.;
       rgb [2] = aTColor.blue()/255.;
-      myScalarBarActor->SetDistributionColor(rgb);
+      myScalarBarActor->GetDistributionColor(oldRgb);
+      colorChanged = (rgb[0] != oldRgb[0] || rgb[1] != oldRgb[1] || rgb[2] != oldRgb[2]);
+      if(colorChanged)
+       myScalarBarActor->SetDistributionColor(rgb);
     }
   }
 
@@ -553,6 +562,17 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
 
   if( nbColorsChanged || rangeChanges)
     myActor->UpdateDistribution();
+  
+#ifndef DISABLE_PLOT2DVIEWER
+  if( myActor->GetPlot2Histogram() && 
+      (nbColorsChanged || 
+       rangeChanges ||
+       distributionTypeChanged || 
+       colorChanged ))
+    SMESH::ProcessIn2DViewers(myActor);
+#endif
+    
+    
 
   SMESH::RepaintCurrentView();
   return true;
@@ -656,17 +676,20 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
         myIniH = myScalarBarActor->GetHeight();
         setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
 
-        myDistributionGrp->setChecked((bool)myScalarBarActor->GetDistributionVisibility());
         int coloringType = myScalarBarActor->GetDistributionColoringType();
         myScalarBarActor->GetDistributionColor( aTColor );
         myMonoColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) );
         if ( coloringType == SMESH_MONOCOLOR_TYPE ) {
           myDMonoColor->setChecked(true);
-          onDistributionChanged(myDistribColorGrp->id(myDMonoColor));    
+         onDistributionChanged(myDistribColorGrp->id(myDMonoColor));    
         } else {
           myDMultiColor->setChecked(true);
           onDistributionChanged(myDistribColorGrp->id(myDMultiColor));
         }
+        myDistributionGrp->setChecked((bool)myScalarBarActor->GetDistributionVisibility());
+       onDistributionActivated(myScalarBarActor->GetDistributionVisibility());
+       
+       
         myRangeGrp->setEnabled( true );
         myFontGrp->setEnabled( true );
         myLabColorGrp->setEnabled( true );
@@ -674,6 +697,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
         myOriginDimGrp->setEnabled( true );
         myOkBtn->setEnabled( true );
         myApplyBtn->setEnabled( true );
+       myDistributionGrp->setEnabled( true );
         return;
       }
     }
@@ -686,6 +710,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
   myOriginDimGrp->setEnabled( false );
   myOkBtn->setEnabled( false );
   myApplyBtn->setEnabled( false );
+  myDistributionGrp->setEnabled( false );
 }
 
 //=================================================================================================
@@ -746,10 +771,33 @@ void SMESHGUI_Preferences_ScalarBarDlg::setOriginAndSize( const double x,
  */
 //=================================================================================================
 void SMESHGUI_Preferences_ScalarBarDlg::onDistributionChanged( int id ) {
-  myMonoColorBtn->setEnabled(myDistribColorGrp->id(myDMonoColor) == id);
-  myDistributionColorLbl->setEnabled(myDistribColorGrp->id(myDMonoColor) == id);
+
+  bool isActive = myDistribColorGrp->id(myDMonoColor) == id;
+
+  myMonoColorBtn->setEnabled(isActive);
+  myDistributionColorLbl->setEnabled(isActive);
+}
+//=================================================================================================
+/*!
+ *  SMESHGUI_Preferences_ScalarBarDlg::onDistributionActivated
+ *
+ *  Called when distribution group check box is changed
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onDistributionActivated(bool on) {
+  if(on) {
+    if(myDMonoColor->isChecked())
+      onDistributionChanged(myDistribColorGrp->id(myDMonoColor)  );
+    else if(myDMultiColor->isChecked())
+      onDistributionChanged(myDistribColorGrp->id(myDMultiColor) );
+  }
+  else {
+    myMonoColorBtn->setEnabled(false);
+    myDistributionColorLbl->setEnabled(false);
+  }
 }
 
+
 //=================================================================================================
 /*!
  *  SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged
index 42058ee2b144bae6d006a58257ce35c93b87e038..208e88cd7d13027e1cee2233c0552c92ccf86032 100644 (file)
@@ -80,6 +80,7 @@ protected slots:
   void                     onXYChanged();
   void                     onOrientationChanged();
   void                     onDistributionChanged( int );
+  void                     onDistributionActivated( bool );
 
 private:
   SMESHGUI*                mySMESHGUI;
index 450aca68d574750dd2338a4f3ecfee207965a26b..184eb903cb05f34e53a23b96a6d746761d2155fb 100644 (file)
@@ -30,6 +30,7 @@
 #include "SMESHGUI.h"
 #include "SMESHGUI_Utils.h"
 #include "SMESHGUI_Filter.h"
+#include "SMESH_ControlsDef.hxx"
 
 #include <SMESH_Actor.h>
 #include <SMESH_ActorUtils.h>
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
 
+#ifndef DISABLE_PLOT2DVIEWER
+#include <SPlot2d_ViewModel.h>
+#include <SPlot2d_Histogram.h>
+#include <Plot2d_ViewManager.h>
+#endif
+
 // SALOME KERNEL includes
 #include <utilities.h>
 
@@ -652,6 +659,9 @@ namespace SMESH
           VISUAL_OBJ_CONT.erase(aKey);
         }
       }
+#ifndef DISABLE_PLOT2DVIEWER
+       ProcessIn2DViewers(theActor,RemoveFrom2dViewer);
+#endif
       theActor->Delete();
       vtkWnd->Repaint();
     }
@@ -1303,4 +1313,44 @@ namespace SMESH
     DistanceToPosition( theBounds, theNormal, theDist, theOrigin );
     return true;
   }
+
+#ifndef DISABLE_PLOT2DVIEWER
+  //=======================================================================
+  /**
+     Get histogram from the input actor
+     Repaint/Remove the histogram in/from each opened Plot2D Viewer 
+  */
+  //=======================================================================
+  void ProcessIn2DViewers( SMESH_Actor *theActor, Viewer2dActionType aType ) {
+    SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
+    
+    if(!anApp || !theActor)
+      return;
+
+    SPlot2d_Histogram* aHistogram = 0;
+    if(theActor->GetPlot2Histogram())
+      aHistogram = theActor->UpdatePlot2Histogram();
+    else 
+      return;
+      
+     ViewManagerList aViewManagerList;
+     anApp->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
+     
+     aType = aHistogram->getPointList().empty() ? RemoveFrom2dViewer : aType;
+     
+     SUIT_ViewManager* aViewManager;
+     foreach( aViewManager, aViewManagerList ) {
+       if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
+        if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel())) {
+          if (Plot2d_ViewFrame* aViewFrame = aViewer->getActiveViewFrame()) {
+            if(aType == UpdateIn2dViewer )
+              aViewFrame->displayObject(aHistogram, true);
+            else if (aType == RemoveFrom2dViewer)
+              aViewFrame->eraseObject(aHistogram, true);
+          }
+        }
+       }
+     }
+  }
+#endif //DISABLE_PLOT2DVIEWER
 } // end of namespace SMESH
index 712e33a054fb3ce7bf9407b670e6cba5f1fcdb62..6b49b44ebd33f3db13f553419079c260369b8ed2 100644 (file)
 #include <SALOME_InteractiveObject.hxx>
 #include <VTKViewer_Filter.h>
 
+#ifndef DISABLE_PLOT2DVIEWER
+class SPlot2d_Histogram;
+#endif
+
+
 class TColStd_IndexedMapOfInteger;
 
 class SALOMEDSClient_Study;
@@ -198,6 +203,16 @@ SMESHGUI_EXPORT
                                        vtkFloatingPointType theDist,
                                        vtkFloatingPointType theBounds[6],
                                        vtkFloatingPointType theOrigin[3] );
+
+#ifndef DISABLE_PLOT2DVIEWER
+ typedef enum {UpdateIn2dViewer = 0, RemoveFrom2dViewer } Viewer2dActionType;
+ SMESHGUI_EXPORT
+   void ProcessIn2DViewers( SMESH_Actor* theActor, Viewer2dActionType = UpdateIn2dViewer );
+#endif
+
 };
 
 #endif // SMESHGUI_VTKUTILS_H
index 9352f1cef4a60f6e56de92142a69e405859a163b..f0e73f1fedad2743ec2dcd75e5b69317a59ee8eb 100644 (file)
     <message>
         <source>MEN_RESET</source>
         <translation>Reset</translation>
+    </message>
+        <message>
+        <source>MEN_DISTRIBUTION_CTRL</source>
+        <translation>Distribution</translation>
     </message>
     <message>
         <source>MEN_SAVE_DISTRIBUTION</source>
-        <translation>Export Distribution...</translation>
+        <translation>Export ...</translation>
     </message>
     <message>
         <source>MEN_SHOW_DISTRIBUTION</source>
-        <translation>Show Distribution</translation>
+        <translation>Show</translation>
+    </message>
+    <message>
+        <source>MEN_PLOT_DISTRIBUTION</source>
+        <translation>Plot</translation>
+    </message>
+    <message>
+        <source>DISTRIBUTION_NB_ENT</source>
+        <translation>Number of entities</translation>
     </message>
     <message>
         <source>MEN_REVOLUTION</source>