]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Distribution curve visibility and filtering by scalars
authorrkv <rkv@opencascade.com>
Fri, 30 May 2008 15:42:37 +0000 (15:42 +0000)
committerrkv <rkv@opencascade.com>
Fri, 30 May 2008 15:42:37 +0000 (15:42 +0000)
resources/SalomeApp.xml
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI_Prs3dDlg.cxx
src/VISUGUI/VisuGUI_Prs3dDlg.h
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_ScalarMap_i.cc

index b7e6fed16cb84be23c509e8553b8a76a9a8d37cf..1c2049a335abf731f18f9cb299125c7d9d5f8771 100644 (file)
     <parameter name="scalar_bar_label_font"   value="Arial,Bold,Italic,Underline,12"/>
     <parameter name="scalar_bar_label_format" value="%-#6.3g" />
     <parameter name="scalar_bar_logarithmic"  value="false"/>
+    <!-- RKV : Begin -->
+    <!-- Do filter by scalars or don't -->
+    <parameter name="scalar_bar_filter_by_scalars"  value="false"/>
+    <!-- Show distribution curve or don't -->
+    <parameter name="scalar_bar_show_distribution"  value="false"/>
+    <!-- RKV : End -->
     <parameter name="scalar_bar_mode"         value="0" />
     <parameter name="scalar_bar_num_colors"   value="64"/>
     <parameter name="scalar_bar_num_labels"   value="5" />
index ff36f3371974d29ee7297274d4fa2d050c446e23..4e10ca2dbed2922f7cad8687551e3f61097172be 100644 (file)
@@ -2746,6 +2746,14 @@ Please, provide non-empty resulting presentation.</translation>
             <source>LBL_SHOW_PREVIEW</source>
             <translation>Show preview</translation>
         </message>
+        <message>
+            <source>SHOW_DISTRIBUTION</source>
+            <translation>Show distribution</translation>
+        </message>
+        <message>
+            <source>FILTER_BY_SCALARS</source>
+            <translation>Filter by scalars</translation>
+        </message>
         <message>
             <source>LBL_WIDTH</source>
             <translation>Width:</translation>
index fcabb88a1d556ebef3663040f94a3fe00d601230..3b422fd737d1373307e5350d79a980118192cfd1 100644 (file)
@@ -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;
index 86c0705a9e01fd0caea568b8daa385a4b65fd73a..4923b6263d9fe34639952af919fc80ff4331436a 100644 (file)
@@ -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();
index 82cc566e4c1726917a068d28ecf503d02065b8b0..cb97985fe34fbdee4d51d2642d7995639ffc717c 100644 (file)
@@ -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<VISU_ColoredPL, vtkFloatingPointType*, bool>
+/* RKV  ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_ColoredPL, vtkFloatingPointType*, bool>
                   (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, false));
-
+*/
+// RKV : Begin
+  ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_ColoredPL, vtkFloatingPointType*, bool>
+                  (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<VISU_ColoredPL, vtkFloatingPointType*, bool>
+                  (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, isFilter));
+
+  UseFixedRange(true);
+}
+
+//----------------------------------------------------------------------------
+// RKV : End
index cb22f72dd1a218e66299e48f31e30c030d4d148a..1215ac7b16eef03f5bf121b0599b452cb2797937 100644 (file)
@@ -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
+
   };
 
 
index 0208d7a0f01b13303a314403ed70d6bea49ae2e0..14897bde3d55c461eb0ee2da3d5760cb87727f04 100644 (file)
@@ -426,6 +426,10 @@ VISU::ScalarMap_i
   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(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();