0021920: [CEA 689] Get some measure functions on groups available in GUI and TUI
@ -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 \
|
||||
|
34
doc/salome/examples/measurements_ex03.py
Normal file
@ -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
|
BIN
doc/salome/gui/SMESH/images/basic_props.png
Normal file
After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 16 KiB |
@ -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".
|
||||
|
||||
|
@ -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}
|
||||
|
||||
*/
|
||||
|
@ -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);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
BIN
resources/mesh_measure_area.png
Normal file
After Width: | Height: | Size: 806 B |
BIN
resources/mesh_measure_basic_props.png
Normal file
After Width: | Height: | Size: 331 B |
BIN
resources/mesh_measure_length.png
Normal file
After Width: | Height: | Size: 914 B |
BIN
resources/mesh_measure_volume.png
Normal file
After Width: | Height: | Size: 1018 B |
@ -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 --------------
|
||||
|
@ -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 );
|
||||
|
@ -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
|
||||
|
@ -559,6 +559,22 @@
|
||||
<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>
|
||||
|
@ -712,6 +712,46 @@
|
||||
<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>
|
||||
|
@ -748,6 +748,46 @@
|
||||
<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>
|
||||
|
@ -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()) );
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|