]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0021920: [CEA 689] Get some measure functions on groups available in GUI and TUI
authorvsr <vsr@opencascade.com>
Thu, 8 Aug 2013 15:17:00 +0000 (15:17 +0000)
committervsr <vsr@opencascade.com>
Thu, 8 Aug 2013 15:17:00 +0000 (15:17 +0000)
22 files changed:
doc/salome/examples/Makefile.am
doc/salome/examples/measurements_ex03.py [new file with mode: 0644]
doc/salome/gui/SMESH/images/basic_props.png [new file with mode: 0644]
doc/salome/gui/SMESH/images/bnd_box.png
doc/salome/gui/SMESH/images/min_distance.png
doc/salome/gui/SMESH/input/measurements.doc
doc/salome/gui/SMESH/input/tui_measurements.doc
idl/SMESH_Measurements.idl
resources/Makefile.am
resources/mesh_measure_area.png [new file with mode: 0644]
resources/mesh_measure_basic_props.png [new file with mode: 0644]
resources/mesh_measure_length.png [new file with mode: 0644]
resources/mesh_measure_volume.png [new file with mode: 0644]
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_Measurements.cxx
src/SMESHGUI/SMESHGUI_Measurements.h
src/SMESHGUI/SMESH_images.ts
src/SMESHGUI/SMESH_msg_en.ts
src/SMESHGUI/SMESH_msg_fr.ts
src/SMESH_I/SMESH_Measurements_i.cxx
src/SMESH_I/SMESH_Measurements_i.hxx
src/SMESH_SWIG/smeshBuilder.py

index 94c233a75455c8c62e9fd1bdfc53f0c86f2f493f..1846b16a27d5d5cc847a26ebe67ce9d66299b390 100644 (file)
@@ -110,6 +110,7 @@ GOOD_TESTS = \
        grouping_elements_ex08.py \
        measurements_ex01.py \
        measurements_ex02.py \
+       measurements_ex03.py \
        modifying_meshes_ex01.py \
        modifying_meshes_ex02.py \
        modifying_meshes_ex03.py \
diff --git a/doc/salome/examples/measurements_ex03.py b/doc/salome/examples/measurements_ex03.py
new file mode 100644 (file)
index 0000000..ef15e7e
--- /dev/null
@@ -0,0 +1,34 @@
+# Basic Properties
+
+
+import salome
+salome.salome_init()
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
+
+import SMESH, SALOMEDS
+from salome.smesh import smeshBuilder
+smesh =  smeshBuilder.New(salome.myStudy)
+import salome_notebook
+
+from SMESH_mechanic import mesh as mesh1
+
+mesh1.Compute()
+
+# compute length for mesh1
+length = mesh1.GetLength()
+
+# compute area for mesh1
+area = mesh1.GetArea()
+
+# compute volume for mesh1
+volume = mesh1.GetVolume()
+
+# print basic properties
+print
+print "Basic Properties for mesh:"
+print "* length =", length
+print "* area   =", area
+print "* volume =", volume
+print
diff --git a/doc/salome/gui/SMESH/images/basic_props.png b/doc/salome/gui/SMESH/images/basic_props.png
new file mode 100644 (file)
index 0000000..bba200d
Binary files /dev/null and b/doc/salome/gui/SMESH/images/basic_props.png differ
index 6761a76ff1eaa5729b6a473af5cf6772a65a2f72..d079eaaa4b38a970146d8aa085201a8ade3eec78 100644 (file)
Binary files a/doc/salome/gui/SMESH/images/bnd_box.png and b/doc/salome/gui/SMESH/images/bnd_box.png differ
index 765522e88ce9db0187dce03a7a27df54c41f5601..486dab376e386fffbaba4798aa49939daef52d5e 100644 (file)
Binary files a/doc/salome/gui/SMESH/images/min_distance.png and b/doc/salome/gui/SMESH/images/min_distance.png differ
index 6514cf287ddd2dcb712b6866dc4203abf0cf0fcf..0787b7c2083c929fb158ac1dade11715f7f3fcf5 100644 (file)
@@ -64,6 +64,32 @@ viewer.
 
 \image html bnd_box_preview.png
 
+\section basic_properties_anchor Basic Properties
+
+This operation allows calculation of length, area or volume for the the selected
+object:
+- Length is calculated as a sum of length of all 1D elements;
+- Area id a sum of area of all 2D elements
+- Volume is a sum of volume of all 3D elements. 
+
+To start one of <b>Basic Properties</b> calculations, select <b>Length</b>, <b>Area</b> 
+or <b>Volume</b> item from <b>Measurements - Basic Properties</b> menu.
+
+\image html basic_props.png
+
+In the dialog box select the required type of calculation (length, area or volume), select
+the the object (mesh, sub-mesh or group) and press \em Compute button.
+
+The result of calculation will be shown in the bottom area of the
+dialog box.
+
+\note
+- If mesh consists of 3D elements only, its "length" and "area" will be 0.
+- As calculation result is a sum of length, area and volume of all mesh elements,
+  duplications are not taken into account; i.e. all duplicated elements
+  (elements built on the same set of nodes) will be included into the result.
+- Similarly, intersection of elements is not taken into account.
+
 <b>See Also</b> a sample TUI Script of a 
 \ref tui_measurements_page "Measurement operations".
 
index 4d25c73584fc30d33a76068e5c7fbd7c175470f4..950cc2aba8a9d7e37b47f70a4e71f00cb40db7b1 100644 (file)
@@ -8,4 +8,7 @@
 \section tui_bounding_box Bounding Box
 \tui_script{measurements_ex02.py}
 
+\section tui_bounding_box Basic Properties
+\tui_script{measurements_ex03.py}
+
 */
index becc67547d64e4d0e1f69bc439201e387a9e1a0c..43e5bf2bcfbc4a66a515c566d33eb5c41bfa4b4d 100644 (file)
@@ -55,6 +55,21 @@ module SMESH
      * common bounding box of entities
      */
     Measure BoundingBox(in ListOfIDSources sources);
+
+    /*!
+     * sum of length of 1D elements of the source
+     */
+    double Length(in SMESH_IDSource source);
+
+    /*!
+     * sum of area of 2D elements of the source
+     */
+    double Area(in SMESH_IDSource source);
+
+    /*!
+     * sum of volume of 3D elements of the source
+     */
+    double Volume(in SMESH_IDSource source);
   };
 };    
 
index 7a057d2026d056c1df1ebca84fda7f7d13c77e23..786c3cd48659320cf426d4850662d00fe61596b8 100644 (file)
@@ -208,7 +208,11 @@ dist_salomeres_DATA = \
        mesh_min_dist.png \
        reorient_faces_point.png \
        reorient_faces_face.png \
-       mesh_ball.png
+       mesh_ball.png \
+       mesh_measure_basic_props.png \
+       mesh_measure_length.png \
+       mesh_measure_area.png \
+       mesh_measure_volume.png
 
 # VSR: little trick to avoid putting if SMESHCatalog.xml to the distribution archive
 nodist_salomeres_SCRIPTS = SMESHCatalog.xml SalomeApp.xml
diff --git a/resources/mesh_measure_area.png b/resources/mesh_measure_area.png
new file mode 100644 (file)
index 0000000..72d292b
Binary files /dev/null and b/resources/mesh_measure_area.png differ
diff --git a/resources/mesh_measure_basic_props.png b/resources/mesh_measure_basic_props.png
new file mode 100644 (file)
index 0000000..4d7ed13
Binary files /dev/null and b/resources/mesh_measure_basic_props.png differ
diff --git a/resources/mesh_measure_length.png b/resources/mesh_measure_length.png
new file mode 100644 (file)
index 0000000..996f7c3
Binary files /dev/null and b/resources/mesh_measure_length.png differ
diff --git a/resources/mesh_measure_volume.png b/resources/mesh_measure_volume.png
new file mode 100644 (file)
index 0000000..7e4ae01
Binary files /dev/null and b/resources/mesh_measure_volume.png differ
index 5d3cac68f37f2c56cc3a460fd5cf7126ad213baf..11eb2b89eeaa3ad656520d0773550255d81528c2 100644 (file)
@@ -3541,8 +3541,20 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     }
   case 501:
   case 502:
+  case 503:
+  case 504:
+  case 505:
     {
-      int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
+      int page = SMESHGUI_MeasureDlg::MinDistance;
+      if ( theCommandID == 502 )
+       page = SMESHGUI_MeasureDlg::BoundingBox;
+      else if ( theCommandID == 503 )
+       page = SMESHGUI_MeasureDlg::Length;
+      else if ( theCommandID == 504 )
+       page = SMESHGUI_MeasureDlg::Area;
+      else if ( theCommandID == 505 )
+       page = SMESHGUI_MeasureDlg::Volume;
+
       EmitSignalDeactivateDialog();
       SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
       dlg->show();
@@ -3844,6 +3856,9 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
   createSMESHAction( 502, "MEASURE_BND_BOX",  "ICON_MEASURE_BND_BOX" );
+  createSMESHAction( 503, "MEASURE_LENGTH",   "ICON_MEASURE_LENGTH" );
+  createSMESHAction( 504, "MEASURE_AREA",     "ICON_MEASURE_AREA" );
+  createSMESHAction( 505, "MEASURE_VOLUME",   "ICON_MEASURE_VOLUME" );
 
   createSMESHAction( 300, "HIDE" );
   createSMESHAction( 301, "SHOW" );
@@ -3872,7 +3887,8 @@ void SMESHGUI::initialize( CAM_Application* app )
       addId    = createMenu( tr( "MEN_ADD" ),    modifyId, 402 ),
       removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
       renumId  = createMenu( tr( "MEN_RENUM" ),  modifyId, 404 ),
-      transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
+      transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
+      basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
 
   //createMenu( 111, importId, -1 );
   createMenu( 112, importId, -1 );
@@ -4020,6 +4036,9 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   createMenu( 501, measureId, -1 );
   createMenu( 502, measureId, -1 );
+  createMenu( 503, basicPropId, -1 );
+  createMenu( 504, basicPropId, -1 );
+  createMenu( 505, basicPropId, -1 );
   createMenu( 214, viewId, -1 );
 
   // ----- create toolbars --------------
index a5580dd65ee5461c0181ddf0f233323c57a196fa..8cbf403640db511eb99eed6e368f1024b4afa339 100644 (file)
@@ -1085,6 +1085,219 @@ void SMESHGUI_BoundingBox::clear()
   erasePreview();
 }
 
+/*!
+  \class SMESHGUI_BasicProperties
+  \brief basic properties measurement widget.
+  
+  Widget to calculate length, area or volume for the selected object(s).
+*/
+
+/*!
+  \brief Constructor.
+  \param parent parent widget
+*/
+SMESHGUI_BasicProperties::SMESHGUI_BasicProperties( QWidget* parent )
+: QWidget( parent )
+{
+  // Property (length, area or volume)
+  QGroupBox* aPropertyGrp = new QGroupBox( tr( "PROPERTY" ), this );
+
+  QRadioButton* aLength = new QRadioButton( tr( "LENGTH" ), aPropertyGrp );
+  QRadioButton* anArea = new QRadioButton( tr( "AREA" ), aPropertyGrp );
+  QRadioButton* aVolume = new QRadioButton( tr( "VOLUME" ), aPropertyGrp );
+
+  myMode = new QButtonGroup( this );
+  myMode->addButton( aLength, Length );
+  myMode->addButton( anArea, Area );
+  myMode->addButton( aVolume, Volume );
+
+  QHBoxLayout* aPropertyLayout = new QHBoxLayout;
+  aPropertyLayout->addWidget( aLength );
+  aPropertyLayout->addWidget( anArea );
+  aPropertyLayout->addWidget( aVolume );
+
+  aPropertyGrp->setLayout( aPropertyLayout );
+
+  // Source object
+  QGroupBox* aSourceGrp = new QGroupBox( tr( "SOURCE_MESH_SUBMESH_GROUP" ), this );
+
+  mySource = new QLineEdit( aSourceGrp );
+  mySource->setReadOnly( true );
+    
+  QHBoxLayout* aSourceLayout = new QHBoxLayout;
+  aSourceLayout->addWidget( mySource );
+  
+  aSourceGrp->setLayout( aSourceLayout );
+
+  // Compute button
+  QPushButton* aCompute = new QPushButton( tr( "COMPUTE" ), this );
+
+  // Result of computation (length, area or volume)
+  myResultGrp = new QGroupBox( this );
+
+  myResult = new QLineEdit;
+  myResult->setReadOnly( true );
+
+  QHBoxLayout* aResultLayout = new QHBoxLayout;
+  aResultLayout->addWidget( myResult );
+  
+  myResultGrp->setLayout( aResultLayout );
+
+  // Layout
+  QGridLayout* aMainLayout = new QGridLayout( this );
+  aMainLayout->setMargin( MARGIN );
+  aMainLayout->setSpacing( SPACING );
+
+  aMainLayout->addWidget( aPropertyGrp, 0, 0, 1, 2 );
+  aMainLayout->addWidget( aSourceGrp, 1, 0, 1, 2 );
+  aMainLayout->addWidget( aCompute,   2, 0 );
+  aMainLayout->addWidget( myResultGrp, 3, 0, 1, 2 );
+  aMainLayout->setColumnStretch( 1, 5 );
+  aMainLayout->setRowStretch( 4, 5 );
+
+  // Initial state
+  setMode( Length );
+  
+  // Connections
+  connect( myMode, SIGNAL( buttonClicked( int ) ),  this, SLOT( modeChanged( int ) ) );
+  connect( aCompute, SIGNAL( clicked() ), this, SLOT( compute() ) );
+  
+  // Selection filter
+  QList<SUIT_SelectionFilter*> filters;
+  filters.append( new SMESH_TypeFilter( SMESH::MESHorSUBMESH ) );
+  filters.append( new SMESH_TypeFilter( SMESH::GROUP ) );
+  myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
+}
+
+/*!
+  \brief Destructor
+*/
+SMESHGUI_BasicProperties::~SMESHGUI_BasicProperties()
+{
+}
+
+/*!
+  \brief Sets the measurement mode.
+  \param theMode the mode to set (length, area or volume meausurement)
+*/
+void SMESHGUI_BasicProperties::setMode( const Mode theMode )
+{
+  QRadioButton* aButton = qobject_cast<QRadioButton*>( myMode->button( theMode ) );
+  if ( aButton ) {
+    aButton->setChecked( true );
+    modeChanged( theMode );
+  }
+}
+
+/*!
+  \brief Setup the selection mode.
+*/
+void SMESHGUI_BasicProperties::updateSelection()
+{
+  LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
+
+  disconnect( selMgr, 0, this, 0 );
+  selMgr->clearFilters();
+  
+  SMESH::SetPointRepresentation( false );
+  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() ) {
+    aViewWindow->SetSelectionMode( ActorSelection );
+  }
+  selMgr->installFilter( myFilter );
+  
+  connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) );
+}
+
+/*!
+  \brief Deactivate widget
+*/
+void SMESHGUI_BasicProperties::deactivate()
+{
+  disconnect( SMESHGUI::selectionMgr(), 0, this, 0 );
+}
+
+/*!
+  \brief Called when selection is changed
+*/
+void SMESHGUI_BasicProperties::selectionChanged()
+{
+  SUIT_OverrideCursor wc;
+
+  SALOME_ListIO selected;
+  SMESHGUI::selectionMgr()->selectedObjects( selected );
+
+  if ( selected.Extent() == 1 ) {
+    Handle(SALOME_InteractiveObject) IO = selected.First();
+    SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
+    if ( !CORBA::is_nil( obj ) ) {
+      mySrc = obj;
+
+      QString aName;
+      SMESH::GetNameOfSelectedIObjects( SMESHGUI::selectionMgr(), aName );
+      mySource->setText( aName );
+    }
+  }
+
+  clear();
+}
+
+/*!
+  \brief Called when the measurement mode selection is changed.
+  \param theMode the selected mode
+*/
+void SMESHGUI_BasicProperties::modeChanged( int theMode )
+{
+  clear();
+
+  if ( theMode == Length ) {
+    myResultGrp->setTitle( tr("LENGTH") );
+  } else if ( theMode == Area ) {
+    myResultGrp->setTitle( tr("AREA") );
+  } else if ( theMode == Volume ) {
+    myResultGrp->setTitle( tr("VOLUME") );
+  }
+}
+
+/*!
+  \brief Calculate length, area or volume for the selected object(s)
+*/
+void SMESHGUI_BasicProperties::compute()
+{
+  SUIT_OverrideCursor wc;
+
+  SMESH::SMESH_IDSource_var source;
+
+  if ( !CORBA::is_nil( mySrc ) ) {
+    // compute
+    int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
+    SMESH::Measurements_var measure = SMESHGUI::GetSMESHGen()->CreateMeasurements();
+
+    double result = 0;
+
+    if ( myMode->checkedId() == Length ) {
+      result = measure->Length( mySrc.in() );
+    } else if ( myMode->checkedId() == Area ) {
+      result = measure->Area( mySrc.in() );
+    } else if ( myMode->checkedId() == Volume ) {
+      result = measure->Volume( mySrc.in() );
+    }
+    
+    measure->UnRegister();
+
+    myResult->setText( QString::number( result, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+  } else {
+    clear();
+  }
+}
+
+/*!
+  \brief Reset the widget to the initial state (nullify the result field)
+*/
+void SMESHGUI_BasicProperties::clear()
+{
+  myResult->clear();
+}
+
 /*!
   \class SMESHGUI_MeshInfoDlg
   \brief Centralized dialog box for the measurements
@@ -1110,12 +1323,17 @@ SMESHGUI_MeasureDlg::SMESHGUI_MeasureDlg( QWidget* parent, int page )
   // min distance
 
   myMinDist = new SMESHGUI_MinDistance( myTabWidget );
-  myTabWidget->addTab( myMinDist, resMgr->loadPixmap( "SMESH", tr( "ICON_MEASURE_MIN_DIST" ) ), tr( "MIN_DIST" ) );
+  int aMinDistInd = myTabWidget->addTab( myMinDist, resMgr->loadPixmap( "SMESH", tr( "ICON_MEASURE_MIN_DIST" ) ), tr( "MIN_DIST" ) );
 
   // bounding box
   
   myBndBox = new SMESHGUI_BoundingBox( myTabWidget );
-  myTabWidget->addTab( myBndBox, resMgr->loadPixmap( "SMESH", tr( "ICON_MEASURE_BND_BOX" ) ), tr( "BND_BOX" ) );
+  int aBndBoxInd = myTabWidget->addTab( myBndBox, resMgr->loadPixmap( "SMESH", tr( "ICON_MEASURE_BND_BOX" ) ), tr( "BND_BOX" ) );
+
+  // basic properties
+  
+  myBasicProps = new SMESHGUI_BasicProperties( myTabWidget );
+  int aBasicPropInd = myTabWidget->addTab( myBasicProps, resMgr->loadPixmap( "SMESH", tr( "ICON_MEASURE_BASIC_PROPS" ) ), tr( "BASIC_PROPERTIES" ) );
 
   // buttons
   QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this );
@@ -1139,7 +1357,19 @@ SMESHGUI_MeasureDlg::SMESHGUI_MeasureDlg( QWidget* parent, int page )
   l->addStretch();
   l->addLayout( btnLayout );
 
-  myTabWidget->setCurrentIndex( qMax( (int)MinDistance, qMin( (int)BoundingBox, page ) ) );
+  int anInd = -1;
+  if ( page == MinDistance ) {
+    anInd = aMinDistInd;
+  } else if ( page == BoundingBox ) {
+    anInd = aBndBoxInd;
+  } else if ( page == Length || page == Area || page == Volume ) {
+    myBasicProps->setMode( (SMESHGUI_BasicProperties::Mode)(page - Length) );
+    anInd = aBasicPropInd;
+  }
+
+  if ( anInd >= 0 ) {
+    myTabWidget->setCurrentIndex( anInd );
+  }
 
   connect( okBtn,       SIGNAL( clicked() ),              this, SLOT( reject() ) );
   connect( helpBtn,     SIGNAL( clicked() ),              this, SLOT( help() ) );
@@ -1200,7 +1430,10 @@ void SMESHGUI_MeasureDlg::updateSelection()
     myMinDist->updateSelection();
   else if ( myTabWidget->currentIndex() == BoundingBox )
     myBndBox->updateSelection();
-    
+  else {
+    myBndBox->erasePreview();
+    myBasicProps->updateSelection();
+  }
 }
 
 /*!
@@ -1208,9 +1441,16 @@ void SMESHGUI_MeasureDlg::updateSelection()
 */
 void SMESHGUI_MeasureDlg::help()
 {
-  SMESH::ShowHelpFile( myTabWidget->currentIndex() == MinDistance ?
-                       "measurements_page.html#min_distance_anchor" : 
-                       "measurements_page.html#bounding_box_anchor" );
+  QString aHelpFile;
+  if ( myTabWidget->currentIndex() == MinDistance ) {
+    aHelpFile = "measurements_page.html#min_distance_anchor";
+  } else if ( myTabWidget->currentIndex() == BoundingBox ) {
+    aHelpFile = "measurements_page.html#bounding_box_anchor";
+  } else {
+    aHelpFile = "measurements_page.html#basic_properties_anchor";
+  }
+
+  SMESH::ShowHelpFile( aHelpFile );
 }
 
 /*!
@@ -1229,6 +1469,7 @@ void SMESHGUI_MeasureDlg::activate()
 */
 void SMESHGUI_MeasureDlg::deactivate()
 {
+  myBasicProps->deactivate();
   myMinDist->deactivate();
   myBndBox->deactivate();
   myTabWidget->setEnabled( false );
index f4cd672fb9632faa7159003dee7b99a72507646e..65e3539cde8cf404a7673828ff4dc240c62c0fc1 100644 (file)
@@ -32,6 +32,7 @@
 class QButtonGroup;
 class QLineEdit;
 class QTabWidget;
+class QGroupBox;
 class SUIT_SelectionFilter;
 class SALOME_Actor;
 class SMESH_Actor;
@@ -101,9 +102,9 @@ public:
 
   void updateSelection();
   void deactivate();
+  void erasePreview();
 
 private:
-  void erasePreview();
   void displayPreview();
   void createPreview( double, double, double, double, double, double );
 
@@ -135,6 +136,37 @@ private:
   SALOME_Actor*             myPreview;
 };
 
+class SMESHGUI_EXPORT SMESHGUI_BasicProperties : public QWidget
+{
+  Q_OBJECT;
+  
+public:
+  //! Property type
+  enum Mode { Length, Area, Volume };
+
+  SMESHGUI_BasicProperties( QWidget* = 0 );
+  ~SMESHGUI_BasicProperties();
+
+  void setMode( const Mode );
+
+  void updateSelection();
+  void deactivate();
+
+private slots:
+  void selectionChanged();
+  void modeChanged( int);
+  void compute();
+  void clear();
+
+private:
+  QButtonGroup*             myMode;
+  QLineEdit*                mySource;
+  QGroupBox*                myResultGrp;
+  QLineEdit*                myResult;
+  SMESH::SMESH_IDSource_var mySrc;
+  SUIT_SelectionFilter*     myFilter;
+};
+
 class SMESHGUI_EXPORT SMESHGUI_MeasureDlg : public QDialog
 { 
   Q_OBJECT;
@@ -145,7 +177,10 @@ public:
   //! Measurement type
   enum { 
     MinDistance,   //!< minimum distance
-    BoundingBox    //!< bounding box
+    BoundingBox,   //!< bounding box
+    Length,        //!< length
+    Area,          //!< area
+    Volume         //!< volume
   };
 
   SMESHGUI_MeasureDlg( QWidget* = 0, int = MinDistance );
@@ -167,6 +202,7 @@ private:
   QTabWidget*           myTabWidget;
   SMESHGUI_MinDistance* myMinDist;   
   SMESHGUI_BoundingBox* myBndBox;
+  SMESHGUI_BasicProperties* myBasicProps;
 };
 
 #endif // SMESHGUI_MEASUREMENTS_H
index a8fa7fd738cb47ab5724c14d31933bdc1d13ab55..c985f167e22847b3fcbd038587df8ad91dd37f9a 100644 (file)
             <source>ICON_SPLIT_TO_TETRA</source>
             <translation>split_into_tetra.png</translation>
         </message>
+       <message>
+            <source>ICON_MEASURE_LENGTH</source>
+            <translation>mesh_measure_length.png</translation>
+        </message>
+        <message>
+            <source>ICON_MEASURE_AREA</source>
+            <translation>mesh_measure_area.png</translation>
+        </message>     
+        <message>
+            <source>ICON_MEASURE_VOLUME</source>
+            <translation>mesh_measure_volume.png</translation>
+        </message>
+        <message>
+            <source>ICON_MEASURE_BASIC_PROPS</source>
+            <translation>mesh_measure_basic_props.png</translation>
+        </message>
         <message>
             <source>ICON_MEASURE_MIN_DIST</source>
             <translation>mesh_min_dist.png</translation>
index ba6d7aedf500f69acfc48a3b8ae1fbc379579d48..e989562ed2709af2f56e4b19746b636d2a855ed6 100644 (file)
         <source>TOP_MEASURE_BND_BOX</source>
         <translation>Bounding box</translation>
     </message>
+    <message>
+        <source>MEN_BASIC_PROPERTIES</source>
+        <translation>Basic Properties</translation>
+    </message>
+    <message>
+        <source>MEN_MEASURE_LENGTH</source>
+        <translation>Length</translation>
+    </message>
+    <message>
+        <source>STB_MEASURE_LENGTH</source>
+        <translation>Calculate sum of length of all 1D elements of the selected object(s)</translation>
+    </message>
+    <message>
+        <source>TOP_MEASURE_LENGTH</source>
+        <translation>Length</translation>
+    </message>
+    <message>
+        <source>MEN_MEASURE_AREA</source>
+        <translation>Area</translation>
+    </message>
+    <message>
+        <source>STB_MEASURE_AREA</source>
+        <translation>Calculate sum of area of all 2D elements of the selected object(s)</translation>
+    </message>
+    <message>
+        <source>TOP_MEASURE_AREA</source>
+        <translation>Area</translation>
+    </message>
+     <message>
+        <source>MEN_MEASURE_VOLUME</source>
+        <translation>Volume</translation>
+    </message>
+    <message>
+        <source>STB_MEASURE_VOLUME</source>
+        <translation>Calculate sum of volume of all 3D elements of the selected object(s)</translation>
+    </message>
+    <message>
+        <source>TOP_MEASURE_VOLUME</source>
+        <translation>Volume</translation>
+    </message>
     <message>
         <source>MEN_MOVE</source>
         <translation>Move Node</translation>
@@ -7308,6 +7348,33 @@ as they are of improper type:
         <translation>Distance</translation>
     </message>
 </context>
+<context>
+    <name>SMESHGUI_BasicProperties</name>
+    <message>
+        <source>PROPERTY</source>
+        <translation>Property</translation>
+    </message>
+    <message>
+        <source>LENGTH</source>
+        <translation>Length</translation>
+    </message>
+    <message>
+        <source>AREA</source>
+        <translation>Area</translation>
+    </message>
+    <message>
+        <source>VOLUME</source>
+        <translation>Volume</translation>
+    </message>
+    <message>
+        <source>SOURCE_MESH_SUBMESH_GROUP</source>
+        <translation>Source (mesh, sub-mesh or group)</translation>
+    </message>
+    <message>
+        <source>COMPUTE</source>
+        <translation>Compute</translation>
+    </message>
+</context>
 <context>
     <name>SMESHGUI_CopyMeshDlg</name>
     <message>
@@ -7337,6 +7404,10 @@ as they are of improper type:
         <source>BND_BOX</source>
         <translation>Bounding Box</translation>
     </message>
+    <message>
+        <source>BASIC_PROPERTIES</source>
+        <translation>Basic Properties</translation>
+    </message>
 </context>
 <context>
     <name>SMESHGUI_BoundingBox</name>
index bc0d57a4df3518d22d75328795798865f99151f6..6f409879b565f3968178f14ae901e747035bd28a 100755 (executable)
         <source>TOP_MEASURE_BND_BOX</source>
         <translation>Boîte englobante</translation>
     </message>
+    <message>
+        <source>MEN_BASIC_PROPERTIES</source>
+        <translation type="unfinished">Basic Properties</translation>
+    </message>
+    <message>
+        <source>MEN_MEASURE_LENGTH</source>
+        <translation type="unfinished">Length</translation>
+    </message>
+    <message>
+        <source>STB_MEASURE_LENGTH</source>
+        <translation type="unfinished">Calculate sum of length of all 1D elements of the selected object(s)</translation>
+    </message>
+    <message>
+        <source>TOP_MEASURE_LENGTH</source>
+        <translation type="unfinished">Length</translation>
+    </message>
+    <message>
+        <source>MEN_MEASURE_AREA</source>
+        <translation type="unfinished">Area</translation>
+    </message>
+    <message>
+        <source>STB_MEASURE_AREA</source>
+        <translation type="unfinished">Calculate sum of area of all 2D elements of the selected object(s)</translation>
+    </message>
+    <message>
+        <source>TOP_MEASURE_AREA</source>
+        <translation type="unfinished">Area</translation>
+    </message>
+     <message>
+        <source>MEN_MEASURE_VOLUME</source>
+        <translation type="unfinished">Volume</translation>
+    </message>
+    <message>
+        <source>STB_MEASURE_VOLUME</source>
+        <translation type="unfinished">Calculate sum of volume of all 3D elements of the selected object(s)</translation>
+    </message>
+    <message>
+        <source>TOP_MEASURE_VOLUME</source>
+        <translation type="unfinished">Volume</translation>
+    </message>
     <message>
         <source>MEN_MOVE</source>
         <translation>Déplacer un nœud</translation>
@@ -7294,6 +7334,33 @@ en raison de leurs types incompatibles:
         <translation>Distance</translation>
     </message>
 </context>
+<context>
+    <name>SMESHGUI_BasicProperties</name>
+    <message>
+        <source>PROPERTY</source>
+        <translation type="unfinished">Property</translation>
+    </message>
+    <message>
+        <source>LENGTH</source>
+        <translation type="unfinished">Length</translation>
+    </message>
+    <message>
+        <source>AREA</source>
+        <translation type="unfinished">Area</translation>
+    </message>
+    <message>
+        <source>VOLUME</source>
+        <translation type="unfinished">Volume</translation>
+    </message>
+    <message>
+        <source>SOURCE_MESH_SUBMESH_GROUP</source>
+        <translation type="unfinished">Source (mesh, sub-mesh or group)</translation>
+    </message>
+    <message>
+        <source>COMPUTE</source>
+        <translation type="unfinished">Compute</translation>
+    </message>
+</context>
 <context>
     <name>SMESHGUI_CopyMeshDlg</name>
     <message>
@@ -7323,6 +7390,10 @@ en raison de leurs types incompatibles:
         <source>BND_BOX</source>
         <translation>Boîte englobante</translation>
     </message>
+    <message>
+        <source>BASIC_PROPERTIES</source>
+        <translation type="unfinished">Basic Properties</translation>
+    </message>
 </context>
 <context>
     <name>SMESHGUI_BoundingBox</name>
index 9a9d439aaeda9dd74364eeaabf7b2da9d61c2b0e..9bb687fc3ccc2f852fb2f4784e7ab75890169471 100644 (file)
@@ -25,6 +25,7 @@
 #include "SMESH_Measurements_i.hxx"
 
 #include "SMESH_Gen_i.hxx"
+#include "SMESH_Filter_i.hxx"
 #include "SMESH_PythonDump.hxx"
 
 #include "SMDS_Mesh.hxx"
@@ -131,6 +132,24 @@ static bool isNodeType (SMESH::array_of_ElementType_var theTypes)
   return theTypes->length() > 0 && theTypes[0] == SMESH::NODE;
 }
 
+static double getNumericalValue(SMESH::SMESH_IDSource_ptr theSource, SMESH::Controls::NumericalFunctorPtr theFunctor)
+{
+  double value = 0;
+
+  if ( !CORBA::is_nil( theSource ) ) {
+    const SMESHDS_Mesh* aMesh = getMesh( theSource );
+    if ( aMesh ) {
+      theFunctor->SetMesh( aMesh );
+      
+      SMESH::long_array_var anElementsId = theSource->GetIDs();
+      for (int i = 0; i < anElementsId->length(); i++) {
+       value += theFunctor->GetValue( anElementsId[i] );
+      }
+    }
+  }
+  return value;
+}
+
 //=======================================================================
 // name    : MinDistance
 // Purpose : minimal distance between two given entities
@@ -257,3 +276,30 @@ SMESH::Measure Measurements_i::BoundingBox (const SMESH::ListOfIDSources& theSou
 
   return aMeasure;
 }
+
+//=======================================================================
+// name    : Length
+// Purpose : sum of length of 1D elements of the source
+//=======================================================================
+double Measurements_i::Length(SMESH::SMESH_IDSource_ptr theSource)
+{
+  return getNumericalValue( theSource, SMESH::Controls::NumericalFunctorPtr(new SMESH::Controls::Length()) );
+}
+
+//=======================================================================
+// name    : Area
+// Purpose : sum of area of 2D elements of the source
+//=======================================================================
+double Measurements_i::Area(SMESH::SMESH_IDSource_ptr theSource)
+{
+  return getNumericalValue( theSource, SMESH::Controls::NumericalFunctorPtr(new SMESH::Controls::Area()) );
+}
+
+//=======================================================================
+// name    : Volume
+// Purpose : sum of volume of 3D elements of the source
+//=======================================================================
+double Measurements_i::Volume(SMESH::SMESH_IDSource_ptr theSource)
+{
+  return getNumericalValue( theSource, SMESH::Controls::NumericalFunctorPtr(new SMESH::Controls::Volume()) );
+}
index 0f1bbadacc89888520970a6fdbdf34170250413f..f7135ae44c970ffc127ab995fe59e1cbce0593dd 100644 (file)
@@ -57,6 +57,22 @@ namespace SMESH
      * common bounding box of entities
      */
     SMESH::Measure BoundingBox(const SMESH::ListOfIDSources& theSources);
+
+
+    /*!
+     * sum of length of 1D elements of the source
+     */
+    double Length(SMESH::SMESH_IDSource_ptr theSource);
+
+    /*!
+     * sum of area of 2D elements of the source
+     */
+    double Area(SMESH::SMESH_IDSource_ptr);
+
+    /*!
+     * sum of volume of 3D elements of the source
+     */
+    double Volume(SMESH::SMESH_IDSource_ptr);
   };
 }
 
index d0471ca0ff90a870e80a34a55b9941959d7f4efd..b0f55e498660c71cfcb4443b44cf7255cf1da657 100644 (file)
@@ -4398,25 +4398,46 @@ class Mesh:
         return val
 
     ## Get length of 1D element.
-    #  @param elemId mesh element ID
+    #  @param elemId mesh element ID (if not defined - sum of length of all 1D elements will be calculated)
     #  @return element's length value
     #  @ingroup l1_measurements
-    def GetLength(self, elemId):
-        return self._valueFromFunctor(SMESH.FT_Length, elemId)
+    def GetLength(self, elemId=None):
+        length = 0
+        if elemId == None:
+            aMeasurements = self.smeshpyD.CreateMeasurements()
+            length = aMeasurements.Length(self.GetMesh())
+            aMeasurements.UnRegister()
+        else:
+            length = self._valueFromFunctor(SMESH.FT_Length, elemId)
+        return length
 
     ## Get area of 2D element.
-    #  @param elemId mesh element ID
+    #  @param elemId mesh element ID (if not defined - sum of area of all 2D elements will be calculated)
     #  @return element's area value
     #  @ingroup l1_measurements
-    def GetArea(self, elemId):
-        return self._valueFromFunctor(SMESH.FT_Area, elemId)
+    def GetArea(self, elemId=None):
+        area = 0
+        if elemId == None:
+            aMeasurements = self.smeshpyD.CreateMeasurements()
+            area = aMeasurements.Area(self.GetMesh())
+            aMeasurements.UnRegister()
+        else:
+            area = self._valueFromFunctor(SMESH.FT_Area, elemId)
+        return area
 
     ## Get volume of 3D element.
-    #  @param elemId mesh element ID
+    #  @param elemId mesh element ID (if not defined - sum of volume of all 3D elements will be calculated)
     #  @return element's volume value
     #  @ingroup l1_measurements
-    def GetVolume(self, elemId):
-        return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
+    def GetVolume(self, elemId=None):
+        volume = 0
+        if elemId == None:
+            aMeasurements = self.smeshpyD.CreateMeasurements()
+            volume = aMeasurements.Volume(self.GetMesh())
+            aMeasurements.UnRegister()
+        else:
+            volume = self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
+        return volume
 
     ## Get maximum element length.
     #  @param elemId mesh element ID