From: rnv Date: Thu, 20 Jan 2011 15:41:36 +0000 (+0000) Subject: Implementation of the Point 2 of the 20948: EDF 1468 SMESH: Histogram of the quality... X-Git-Tag: StartingPortingMED3~130 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=18e0bef9d9707917ea1b354d83830c9e2bedf1a3;p=modules%2Fsmesh.git Implementation of the Point 2 of the 20948: EDF 1468 SMESH: Histogram of the quality controls. --- diff --git a/doc/salome/gui/SMESH/images/controls_popup.png b/doc/salome/gui/SMESH/images/controls_popup.png index b0bd01fb9..c32f9eada 100755 Binary files a/doc/salome/gui/SMESH/images/controls_popup.png and b/doc/salome/gui/SMESH/images/controls_popup.png differ diff --git a/doc/salome/gui/SMESH/input/about_quality_controls.doc b/doc/salome/gui/SMESH/input/about_quality_controls.doc index ee57c8c81..374db90a9 100644 --- a/doc/salome/gui/SMESH/input/about_quality_controls.doc +++ b/doc/salome/gui/SMESH/input/about_quality_controls.doc @@ -64,8 +64,9 @@ To manage the quality controls call pop-up in the VTK viewer and select "Control
  • Face Controls provides access to the face quality controls;
  • Volume Controls provides access to the volume quality controls;
  • Scalar Bar Properties allows setting \subpage scalar_bar_dlg;
  • -
  • Export Distribution... allows saving the distribution of quality control values in the text file;
  • -
  • Show Distribution Shows/Hides the distribution histogram of the quality control values in the VTK Viewer.
  • +
  • Distribution -> Export ... allows saving the distribution of quality control values in the text file;
  • +
  • Distribution -> Show Shows/Hides the distribution histogram of the quality control values in the VTK Viewer.
  • +
  • Distribution -> Plot Plots the distribution histogram of the quality control values in the Plot 2D Viewer.
  • diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index ea6daa0bf..f6aef7f78 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -67,7 +67,7 @@ - + diff --git a/src/OBJECT/Makefile.am b/src/OBJECT/Makefile.am index 88dd738fd..eec2a6c0e 100644 --- a/src/OBJECT/Makefile.am +++ b/src/OBJECT/Makefile.am @@ -55,6 +55,7 @@ libSMESHObject_la_CPPFLAGS = \ $(KERNEL_CXXFLAGS) \ $(GUI_CXXFLAGS) \ $(MED_CXXFLAGS) \ + $(QWT_INCLUDES) \ $(GEOM_CXXFLAGS) \ $(CAS_CPPFLAGS) \ $(VTK_INCLUDES) \ diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index cafd4b000..91d500283 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -40,6 +40,10 @@ #include "SUIT_Session.h" #include "SUIT_ResourceMgr.h" +#ifndef DISABLE_PLOT2DVIEWER +#include +#endif + #include #include #include @@ -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(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 nbEvents; + std::vector funValues; + SMESH_VisualObjDef::TEntityList elems; + if ( ! dynamic_cast(myVisualObj.get())) + dynamic_cast(myVisualObj.get())->GetEntities( fun->GetType(), elems ); + std::vector elemIds; + + for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e) + elemIds.push_back( (*e)->GetID()); + + vtkLookupTable* lookupTable = static_cast(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(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 diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index 744571e41..95c6c79f3 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -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 }; diff --git a/src/OBJECT/SMESH_ActorDef.h b/src/OBJECT/SMESH_ActorDef.h index 53001f4ef..162203bb3 100644 --- a/src/OBJECT/SMESH_ActorDef.h +++ b/src/OBJECT/SMESH_ActorDef.h @@ -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; diff --git a/src/SMESHGUI/Makefile.am b/src/SMESHGUI/Makefile.am index 6da5d4076..a7104237c 100644 --- a/src/SMESHGUI/Makefile.am +++ b/src/SMESHGUI/Makefile.am @@ -241,6 +241,7 @@ libSMESH_la_CPPFLAGS = \ $(PYTHON_INCLUDES) \ $(KERNEL_CXXFLAGS) \ $(GUI_CXXFLAGS) \ + $(QWT_INCLUDES) \ $(GEOM_CXXFLAGS) \ $(MED_CXXFLAGS) \ $(BOOST_CPPFLAGS) \ diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 2d3f45190..f314db7f8 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -123,6 +123,11 @@ #include #include +#ifndef DISABLE_PLOT2DVIEWER +#include +#include +#endif + // IDL includes #include #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) @@ -861,6 +866,52 @@ } } +#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(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; @@ -1220,6 +1271,17 @@ 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 diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx index b1f9284c6..c566a3cf9 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx @@ -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 diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h index 42058ee2b..208e88cd7 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h @@ -80,6 +80,7 @@ protected slots: void onXYChanged(); void onOrientationChanged(); void onDistributionChanged( int ); + void onDistributionActivated( bool ); private: SMESHGUI* mySMESHGUI; diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index 450aca68d..184eb903c 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -30,6 +30,7 @@ #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_Filter.h" +#include "SMESH_ControlsDef.hxx" #include #include @@ -56,6 +57,12 @@ #include #include +#ifndef DISABLE_PLOT2DVIEWER +#include +#include +#include +#endif + // SALOME KERNEL includes #include @@ -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(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(aViewManager)) { + if (SPlot2d_Viewer* aViewer = dynamic_cast(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 diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.h b/src/SMESHGUI/SMESHGUI_VTKUtils.h index 712e33a05..6b49b44eb 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.h +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.h @@ -40,6 +40,11 @@ #include #include +#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 diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 9352f1cef..f0e73f1fe 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -654,14 +654,26 @@ MEN_RESET Reset + + + MEN_DISTRIBUTION_CTRL + Distribution MEN_SAVE_DISTRIBUTION - Export Distribution... + Export ... MEN_SHOW_DISTRIBUTION - Show Distribution + Show + + + MEN_PLOT_DISTRIBUTION + Plot + + + DISTRIBUTION_NB_ENT + Number of entities MEN_REVOLUTION