From 045c1a95c1890fd7d9f7651643c0acb3aa350cb5 Mon Sep 17 00:00:00 2001 From: rkv Date: Fri, 30 May 2008 15:42:37 +0000 Subject: [PATCH] Distribution curve visibility and filtering by scalars --- resources/SalomeApp.xml | 6 +++ src/VISUGUI/VISU_msg_en.ts | 8 ++++ src/VISUGUI/VisuGUI_Prs3dDlg.cxx | 75 ++++++++++++++++++++++++++++-- src/VISUGUI/VisuGUI_Prs3dDlg.h | 12 +++++ src/VISU_I/VISU_ColoredPrs3d_i.cc | 77 ++++++++++++++++++++++++++++--- src/VISU_I/VISU_ColoredPrs3d_i.hh | 26 +++++++++++ src/VISU_I/VISU_ScalarMap_i.cc | 4 ++ 7 files changed, 199 insertions(+), 9 deletions(-) diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index b7e6fed1..1c2049a3 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -41,6 +41,12 @@ + + + + + + diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index ff36f337..4e10ca2d 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -2746,6 +2746,14 @@ Please, provide non-empty resulting presentation. LBL_SHOW_PREVIEW Show preview + + SHOW_DISTRIBUTION + Show distribution + + + FILTER_BY_SCALARS + Filter by scalars + LBL_WIDTH Width: diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index fcabb88a..3b422fd7 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -624,6 +624,11 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), aGB); CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); +// RKV : Begin + CBFilter = new QCheckBox (tr("FILTER_BY_SCALARS"), aGB); + CBFilter->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); +// RKV : End + RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), aGB); RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), aGB); RangeGroup->addButton( RBFrange, 0 ); @@ -648,7 +653,9 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) RangeGroupLayout->addWidget( myModeLbl, 0, 0 ); RangeGroupLayout->addWidget( myModeCombo, 0, 1, 1, 4); - RangeGroupLayout->addWidget( CBLog, 1, 0, 1, 4); +// RKV RangeGroupLayout->addWidget( CBLog, 1, 0, 1, 4); + RangeGroupLayout->addWidget( CBLog, 1, 0, 1, 2); // RKV + RangeGroupLayout->addWidget( CBFilter, 1, 2, 1, 2); // RKV RangeGroupLayout->addWidget( RBFrange, 2, 0, 1, 2); RangeGroupLayout->addWidget( RBIrange, 2, 2, 1, 2); RangeGroupLayout->addWidget( MinLabel, 3, 0 ); @@ -805,7 +812,15 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup); myPreviewCheck->setChecked(false); + +// RKV : Begin + myPreviewCheck->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + CBDistr = new QCheckBox (tr("SHOW_DISTRIBUTION"), CheckGroup); + CBDistr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); +// RKV : End + CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 ); + CheckGroupLayout->addWidget(CBDistr , 0, 2 ); // RKV if ( thePreview ) { myPreviewCheck->hide(); @@ -833,6 +848,10 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) ); connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) ); connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) ); + + connect( CBFilter, SIGNAL( toggled( bool ) ), this, SLOT( onFilterByScalars( bool ) )); // RKV + connect( CBDistr, SIGNAL( toggled( bool ) ), this, SLOT( onShowDistribution( bool ) )); // RKV + connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() )); @@ -903,6 +922,8 @@ void VisuGUI_ScalarBarPane::storeToResources() { aResourceMgr->setValue("VISU", "scalar_range_type", 0); aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic()); + aResourceMgr->setValue("VISU", "scalar_bar_filter_by_scalars", isFilteredByScalars()); // RKV + aResourceMgr->setValue("VISU", "scalar_bar_show_distribution", isShowDistribution()); // RKV //// @@ -1040,6 +1061,11 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) setRange( myScalarMap->GetMin(), myScalarMap->GetMax(), myScalarMap->IsRangeFixed() ); setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() ); +// RKV : Begin + setFilteredByScalars( myScalarMap->IsFilteredByScalars() ); + setShowDistribution( myScalarMap->GetIsDistributionVisible() ); +// RKV : End + // "Title" CORBA::String_var aTitle = myScalarMap->GetTitle(); @@ -1157,12 +1183,17 @@ void VisuGUI_ScalarBarPane::createScalarBar() theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble(); theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble(); } - myScalarMapPL->SetScalarRange(theRange, false); +// RKV myScalarMapPL->SetScalarRange(theRange, false); + myScalarMapPL->SetScalarRange(theRange, isFilteredByScalars()); // RKV myScalarMapPL->SetNbColors(sbCol); myScalarMapPL->Update(); aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable()); +// RKV : Begin + aScalarBarActor->SetDistribution(myScalarMapPL->GetDistribution()); + aScalarBarActor->SetDistributionVisibility(isShowDistribution()); +// RKV : End if (!myTextDlg->getTitleText().isEmpty()) { VISU::PValForTime aValForTime; @@ -1299,10 +1330,12 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { if (RBFrange->isChecked()) { myScalarMap->SetSourceRange(); } else { - myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); +// RKV myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); + myScalarMap->SetRangeAndFilter(MinEdit->text().toDouble(), MaxEdit->text().toDouble(), isFilteredByScalars()); // RKV } myScalarMap->SetNbColors(ColorSpin->value()); myScalarMap->SetLabels(LabelSpin->value()); + myScalarMap->SetIsDistributionVisible(isShowDistribution()); // RKV if (isToSave()) storeToResources(); @@ -1396,7 +1429,19 @@ void VisuGUI_ScalarBarPane::onImposedRange( bool isOn ) changeScalarMode(myModeCombo->currentIndex()); } } +// RKV : Begin +void VisuGUI_ScalarBarPane::onFilterByScalars( bool isOn ) +{ + myScalarMap->SetRangeAndFilter(myScalarMap->GetMin(), myScalarMap->GetMax(), isOn); + updatePreview(); +} +void VisuGUI_ScalarBarPane::onShowDistribution( bool isOn ) +{ + myScalarMap->SetIsDistributionVisible(isOn); + updatePreview(); +} +// RKV : End void VisuGUI_ScalarBarPane::changeRange( int ) { if ( RBFrange->isChecked() ) { @@ -1532,6 +1577,30 @@ void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) { CBLog->setChecked( on ); } +// RKV : Begin +//---------------------------------------------------------------------------- +bool VisuGUI_ScalarBarPane::isFilteredByScalars() { + return CBFilter->isChecked(); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_ScalarBarPane::setFilteredByScalars( bool on ) { + CBFilter->setChecked( on ); +} + +//---------------------------------------------------------------------------- +bool VisuGUI_ScalarBarPane::isShowDistribution() { + return CBDistr->isChecked(); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_ScalarBarPane::setShowDistribution( bool on ) { + CBDistr->setChecked( on ); +} + +// RKV : End //---------------------------------------------------------------------------- bool VisuGUI_ScalarBarPane::isToSave() { return CBSave ? CBSave->isChecked() : false; diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.h b/src/VISUGUI/VisuGUI_Prs3dDlg.h index 86c0705a..4923b626 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.h +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.h @@ -175,6 +175,12 @@ class VisuGUI_ScalarBarPane : public QWidget//QVBox int getNbLabels(); bool isLogarithmic(); void setLogarithmic( bool on ); + // RKV : Begin + bool isFilteredByScalars(); + void setFilteredByScalars( bool on ); + bool isShowDistribution(); + void setShowDistribution( bool on ); + // RKV : End bool isToSave(); void storeToResources(); @@ -205,6 +211,10 @@ class VisuGUI_ScalarBarPane : public QWidget//QVBox QCheckBox* CBSave; QCheckBox* CBLog; + // RKV : Begin + QCheckBox* CBFilter; + QCheckBox* CBDistr; + // RKV : End QLabel* myModeLbl; QComboBox* myModeCombo; QPushButton* myTextBtn; @@ -229,6 +239,8 @@ class VisuGUI_ScalarBarPane : public QWidget//QVBox void onBarPref(); void onPreviewCheck(bool thePreview); void updatePreview(); + void onFilterByScalars(bool); // RKV + void onShowDistribution(bool); // RKV private: void createScalarBar(); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 82cc566e..cb97985f 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -172,7 +172,8 @@ ColoredPrs3d_i(EPublishInStudyMode thePublishInStudyMode) : myIsTimeStampFixed(thePublishInStudyMode == EPublishUnderTimeStamp), myColoredPL(NULL), myIsFixedRange(false), - myIsRestored(true) + myIsRestored(true)/* RKV : Begin*/, + myIsDistributionVisible(false)/* RKV : End*/ {} //--------------------------------------------------------------- @@ -686,6 +687,7 @@ VISU::ColoredPrs3d_i SetNbColors(anOrigin->GetNbColors()); SetUnitsVisible(anOrigin->IsUnitsVisible()); + SetIsDistributionVisible(anOrigin->GetIsDistributionVisible()); // RKV SetLabelsFormat(anOrigin->GetLabelsFormat()); SetBarOrientation(anOrigin->GetBarOrientation()); @@ -693,7 +695,8 @@ VISU::ColoredPrs3d_i SetMinMaxController( anOrigin ); if(anOrigin->IsRangeFixed()) - SetRange(anOrigin->GetMin(), anOrigin->GetMax()); +// RKV SetRange(anOrigin->GetMin(), anOrigin->GetMax()); + SetRangeAndFilter(anOrigin->GetMin(), anOrigin->GetMax(), anOrigin->IsFilteredByScalars()); // RKV else SetSourceRange(); @@ -778,9 +781,13 @@ VISU::ColoredPrs3d_i VISU::TSetModified aModified(this); vtkFloatingPointType aScalarRange[2] = {theMin, theMax}; - ProcessVoidEvent(new TVoidMemFun2ArgEvent +/* RKV ProcessVoidEvent(new TVoidMemFun2ArgEvent (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, false)); - +*/ +// RKV : Begin + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, myColoredPL->IsFiltered())); +// RKV : End UseFixedRange(true); } @@ -1502,7 +1509,9 @@ VISU::ColoredPrs3d_i if(aRangeType == 1){ float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0); float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0); - SetRange(aMin, aMax); +// RKV SetRange(aMin, aMax); + bool isFiltered = aResourceMgr->booleanValue("VISU", "scalar_bar_filter_by_scalars", false); // RKV + SetRangeAndFilter(aMin, aMax, isFiltered); } UseFixedRange(aRangeType == 1); @@ -1512,6 +1521,8 @@ VISU::ColoredPrs3d_i bool isUnits = aResourceMgr->booleanValue( "VISU", "scalar_bar_display_units", true ); SetUnitsVisible(isUnits); + SetIsDistributionVisible( aResourceMgr->booleanValue("VISU", "scalar_bar_show_distribution", false) ); // RKV + QString aLabelsFormat = aResourceMgr->stringValue( "VISU", "scalar_bar_label_format", "%-#6.3g" ); SetLabelsFormat(aLabelsFormat.toLatin1().data()); @@ -1668,7 +1679,12 @@ VISU::ColoredPrs3d_i SetScalarMode(VISU::Storable::FindValue(theMap,"myScalarMode").toInt()); float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble(); float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble(); - SetRange(aMin, aMax); +// RKV SetRange(aMin, aMax); + // RKV : Begin + bool isFiltered = VISU::Storable::FindValue(theMap,"myIsFilteredByScalars", "0").toInt(); + SetRangeAndFilter(aMin, aMax, isFiltered); + SetIsDistributionVisible(VISU::Storable::FindValue(theMap,"myIsDistributionVisible", "0").toInt()); + // RKV : End UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt()); @@ -1738,6 +1754,9 @@ VISU::ColoredPrs3d_i Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() ); Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() ); Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() ); + + Storable::DataToStream( theStr, "myIsFilteredByScalars", IsFilteredByScalars() ); // RKV + Storable::DataToStream( theStr, "myIsDistributionVisible", GetIsDistributionVisible() ); // RKV Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) ); Storable::DataToStream( theStr, "myOrientation", myOrientation ); @@ -1894,3 +1913,49 @@ VISU::ColoredPrs3d_i aStudyBuilder->CommitCommand(); return this; } + +// RKV : Begin +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::SetIsDistributionVisible(CORBA::Boolean isVisible) +{ + if( myIsDistributionVisible != isVisible ){ + VISU::TSetModified aModified(this); + myIsDistributionVisible = isVisible; + myParamsTime.Modified(); + } +} + +//---------------------------------------------------------------------------- +CORBA::Boolean +VISU::ColoredPrs3d_i +::GetIsDistributionVisible() +{ + return myIsDistributionVisible; +} + +//---------------------------------------------------------------------------- +CORBA::Boolean +VISU::ColoredPrs3d_i +::IsFilteredByScalars() +{ + return myColoredPL->IsFiltered(); +} + +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::SetRangeAndFilter(CORBA::Double theMin, CORBA::Double theMax, CORBA::Boolean isFilter) +{ + VISU::TSetModified aModified(this); + + vtkFloatingPointType aScalarRange[2] = {theMin, theMax}; + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, isFilter)); + + UseFixedRange(true); +} + +//---------------------------------------------------------------------------- +// RKV : End diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index cb22f72d..1215ac7b 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -355,6 +355,30 @@ namespace VISU CORBA::Boolean IsUnitsVisible(); +// RKV : Begin + /*! + * Set the visibility of a distribution curve. + * \param theIs is used to switch on/off the visibility of a distribution curve. + */ + virtual void SetIsDistributionVisible(CORBA::Boolean theIs); + + //! Gets current visibility of a distribution curve + virtual CORBA::Boolean GetIsDistributionVisible(); + + //! Gets current filtering by scalars mode + virtual CORBA::Boolean IsFilteredByScalars(); + + /*! + * Sets scalar range - min and max boundaries of the scalar bar. + * \param theMin Min boundary of the scalar bar. + * \param theMax Max boundary of the scalar bar. + * \param theIsFilter if true then filter by scalars. + */ + virtual + void + SetRangeAndFilter(CORBA::Double theMin, CORBA::Double theMax, CORBA::Boolean theIs); +// RKV : End + //---------------------------------------------------------------------------- //! Gets memory size actually used by the presentation (Mb). virtual @@ -673,6 +697,8 @@ namespace VISU VISU_ColoredPL* myColoredPL; bool myIsFixedRange; + bool myIsDistributionVisible; // RKV + }; diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 0208d7a0..14897bde 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -426,6 +426,10 @@ VISU::ScalarMap_i if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)){ VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar(); aScalarBar->SetLookupTable(GetSpecificPL()->GetBarTable()); + // RKV : Begin + aScalarBar->SetDistribution(GetSpecificPL()->GetDistribution()); + aScalarBar->SetDistributionVisibility(GetIsDistributionVisible()); + // RKV : End aScalarBar->SetTitle(GetScalarBarTitle().c_str()); aScalarBar->SetOrientation(GetBarOrientation()); aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); -- 2.39.2