From 18e0bef9d9707917ea1b354d83830c9e2bedf1a3 Mon Sep 17 00:00:00 2001 From: rnv Date: Thu, 20 Jan 2011 15:41:36 +0000 Subject: [PATCH] Implementation of the Point 2 of the 20948: EDF 1468 SMESH: Histogram of the quality controls. --- .../gui/SMESH/images/controls_popup.png | Bin 1900 -> 3441 bytes .../SMESH/input/about_quality_controls.doc | 5 +- resources/SalomeApp.xml | 2 +- src/OBJECT/Makefile.am | 1 + src/OBJECT/SMESH_Actor.cxx | 67 ++++++++++++ src/OBJECT/SMESH_Actor.h | 9 ++ src/OBJECT/SMESH_ActorDef.h | 13 +++ src/SMESHGUI/Makefile.am | 1 + src/SMESHGUI/SMESHGUI.cxx | 102 ++++++++++++++++-- .../SMESHGUI_Preferences_ScalarBarDlg.cxx | 68 ++++++++++-- .../SMESHGUI_Preferences_ScalarBarDlg.h | 1 + src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 50 +++++++++ src/SMESHGUI/SMESHGUI_VTKUtils.h | 15 +++ src/SMESHGUI/SMESH_msg_en.ts | 16 ++- 14 files changed, 325 insertions(+), 25 deletions(-) diff --git a/doc/salome/gui/SMESH/images/controls_popup.png b/doc/salome/gui/SMESH/images/controls_popup.png index b0bd01fb9aa0a7abf50480a84e69439a29d91b18..c32f9eada9a7e9cdf1b919c1994cb27529f93997 100755 GIT binary patch literal 3441 zcmb7Hc{r478&~K!s7Z@LQNmbe`9 zMyS_1wi5;C=j-~D@@-7>y;lv|LSjg9T7 zzTR~+C@w?KAlG5&UCN!90|gEzEh8;9w$JfAyZ1PueUkduwQdJs7e|kJjG#_DGF{^I z7O}(4Xb0t1>c%O?u{#M;j`5y-@?}`~it@K?vjnq*Q#(o#Y1fSsPHkCA`x!2V?fJ0= zj%xVCeib>`pPU~k_BsDY`*$16s#6JH1%@|sjbB>Z=PG|NgZlZ24F`lW)XmVq)z7R-`41Q3bBk2nmA&b@xS+{gyzMUyt(+21Isut1-TlrSD{!QX`cqCEB#N#U7m(2e=3 zA?`8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ZZ^z%qODwN$doIpPC+-+s@L+6hoBaCn{}RAKhOxw(BK+2U@LFyhZ)s#!&b* z1l+B9ztr7{mDG0;oyD7XH975j22C&1#8WypbryTNEA||YAA4p_Y03QBD(720HRNL} zh3|4)lNgLCWt@#mcn+2`R(lte+jS@C?37noewMBO6~v@=@P+ByswvYK6?Ozo=(#%-oZBt0^%@ZdvEC}KjQ<4uuXXWLjge%*masT&8c+iLXZYia z11=yL&YQbUqyGgNMZ3ai^~H-`DUcXrSIbB06?7RZJ~ig_GMUTcebt%g!W(O3RxRA% z(&V~0tfR6XxaPTzo);~{ka7K`$^Mc1;$=MNex!3gLxlKVf^!3Ghhfb_ZB+EKi;SoS9dj1aB>3)lJ4PK1M)cQ+(PchdK5{^8 zZ|=+J=h^?VGe4@qI>0f8jY8tfiyVPzZiAFNlSxyhwe`i1v=gsbk>fbVg}!PTWVrn= zyh&Sj(@)7zX%^w;T%{2tSau^XG~$VA_;Ot=rzth#@hf=Z8FZvj1-?u2iMt#fy)SX^ zm6NCYVH6>1GmaCzOn#SaC^sIKzS9&Q5$`V?;IB}}y87!ab+@*l-CE=dJ3m5+`-5}h z_%kr9v${rfTN#5SjK#yH|2#gQ=9v|j34YmNS~R%0!G3BqC-t9e0#SyYAGTLrR)ey1 bep5}Ipqq<4t?NHHp8%UnS1l 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 -- 2.39.2