0022764: [EDF] Filtering operators in Group and Explode dialog boxes

This commit is contained in:
vsr 2014-11-12 19:40:11 +03:00
parent 110596005f
commit 436b149763
15 changed files with 462 additions and 58 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -42,6 +42,27 @@ Switching on <b>Select Sub-shapes</b> check box allows manual selection of sub-s
to be extracted from the main object. In this mode the user can select sub-shapes to be extracted from the main object. In this mode the user can select sub-shapes
directly in 3D viewer. directly in 3D viewer.
When <b>Select Sub-shapes</b> check box is switched on, additional \b Filter controls
allow to automatically pick up entites which satisfy specified threshold value(s).
The numerical functor for each sub-shape that is compared with threshold value(s)
is computed according to the shape's topological properties:
- length for edges and wires
- area for faces and shells
- volume for solids, compounds, compsolids
Filtering capabilities are not available for vertices.
In order to filter out some entities:
- Activate one or two filtering controls by switching on corresponding check boxes;
- Select required threshold comparator type; the following choices are available:
- <b>Less Than</b> or <b>Equal or Less Than</b> for the first comparator;
- <b>Greater Than</b> or <b>Equal or Greater Than</b> for the second comparator;
- Enter required threshold value (values);
- Press \b Apply button in the \b Filter group.
The entities which satisfy entered filtering parameters will be automatically highlighted
in the 3D viewer.
Using <b>TUI Commands</b> you can perform this operation in a Using <b>TUI Commands</b> you can perform this operation in a
variety of ways: variety of ways:
- <em>geompy.ExtractShapes(Shape, Type, isSorted)</em> explodes a - <em>geompy.ExtractShapes(Shape, Type, isSorted)</em> explodes a

View File

@ -57,7 +57,7 @@ to the main and the second shape.</li>
<li><b>Hide selected</b> - hides the sub-shapes selected in the list box.</li> <li><b>Hide selected</b> - hides the sub-shapes selected in the list box.</li>
<li><b>Show all sub-shapes</b> - displays only the sub-shapes of the Main Shape.</li> <li><b>Show all sub-shapes</b> - displays only the sub-shapes of the Main Shape.</li>
</ul> </ul>
<li> You can select the elements of your group in two ways: <li> You can select the elements of your group in several ways:
<ul> <ul>
<li>You can select them manually in the 3D Viewer, and add to the <li>You can select them manually in the 3D Viewer, and add to the
group by clicking the \b Add button (keep down the Shift button on the group by clicking the \b Add button (keep down the Shift button on the
@ -70,7 +70,9 @@ elements of a certain type in the list of the elements of the
group. If the <b>Second Shape</b> is used, the elements are added group. If the <b>Second Shape</b> is used, the elements are added
according to <b>Main Shape Selection restriction</b> settings. To delete elements according to <b>Main Shape Selection restriction</b> settings. To delete elements
from the list, select them and click \b Remove button. from the list, select them and click \b Remove button.
</li></ul> </li>
<li>Filtering out some entities according to the specified threshold value or values
(see below).</li></ul>
</li> </li>
<li>Finally, confirm your selection by clicking <b>Apply and Close <li>Finally, confirm your selection by clicking <b>Apply and Close
</b> (also closes the Menu) or \b Apply (leaves the Menu open for </b> (also closes the Menu) or \b Apply (leaves the Menu open for
@ -79,6 +81,26 @@ creation of other groups), or skip it by clicking \b Close button.
\n The Result of the operation will be a \b GEOM_Object. \n The Result of the operation will be a \b GEOM_Object.
The \b Filter controls allow to automatically pick up entites which satisfy specified
threshold value(s). The numerical functor for each sub-shape that is compared with
threshold value(s) is computed according to the shape's topological properties:
- length for edges and wires
- area for faces and shells
- volume for solids, compounds, compsolids
Filtering capabilities are not available for vertices.
In order to filter out some entities:
- Activate one or two filtering controls by switching on corresponding check boxes;
- Select required threshold comparator type; the following choices are available:
- <b>Less Than</b> or <b>Equal or Less Than</b> for the first comparator;
- <b>Greater Than</b> or <b>Equal or Greater Than</b> for the second comparator;
- Enter required threshold value (values);
- Press \b Apply button in the \b Filter group.
The entities which satisfy entered filtering parameters will be automatically highlighted
in the 3D viewer.
\n <b>TUI Command:</b> <em>geompy.CreateGroup(MainShape, \n <b>TUI Command:</b> <em>geompy.CreateGroup(MainShape,
ShapeType),</em> where MainShape is a shape for which the group is ShapeType),</em> where MainShape is a shape for which the group is
created, ShapeType is a type of shapes in the created group. created, ShapeType is a type of shapes in the created group.

View File

@ -29,6 +29,7 @@
#include <DlgRef.h> #include <DlgRef.h>
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <GEOMUtils.hxx>
#include <OCCViewer_ViewModel.h> #include <OCCViewer_ViewModel.h>
#include <SVTK_ViewModel.h> #include <SVTK_ViewModel.h>
@ -36,6 +37,7 @@
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <SALOME_ListIteratorOfListIO.hxx> #include <SALOME_ListIteratorOfListIO.hxx>
#include <SUIT_MessageBox.h>
#include <SUIT_Desktop.h> #include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
@ -51,8 +53,6 @@
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
#include <QMessageBox>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
namespace namespace
@ -70,6 +70,8 @@ namespace
"Flat" "Flat"
}; };
enum { Filter_LT, Filter_LE, Filter_GT, Filter_GE };
unsigned int NumberOfSubShapes(const TopoDS_Shape& S, const int shapeType, TopTools_MapOfShape& M) unsigned int NumberOfSubShapes(const TopoDS_Shape& S, const int shapeType, TopTools_MapOfShape& M)
{ {
unsigned int index = 0; unsigned int index = 0;
@ -149,9 +151,34 @@ EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg(GeometryGUI* theGeometryGUI, QWidge
GroupPoints->PushButton4->setText(tr("SHOW_ALL_SUB_SHAPES")); GroupPoints->PushButton4->setText(tr("SHOW_ALL_SUB_SHAPES"));
GroupPoints->LineEdit1->setReadOnly(true); GroupPoints->LineEdit1->setReadOnly(true);
//filter group
myFilterGrp = new QGroupBox(tr("GEOM_FILTER"), centralWidget());
myLessFilterCheck = new QCheckBox(myFilterGrp);
myLessFilterCombo = new QComboBox(myFilterGrp);
myLessFilterCombo->addItem( tr("GEOM_LESS_THAN"), Filter_LT );
myLessFilterCombo->addItem( tr("GEOM_LESSOREQUAL_THAN"), Filter_LE );
myGreaterFilterCheck = new QCheckBox(myFilterGrp);
myGreaterFilterCombo = new QComboBox(myFilterGrp);
myGreaterFilterCombo->addItem( tr("GEOM_GREAT_THAN"), Filter_GT );
myGreaterFilterCombo->addItem( tr("GEOM_GREATOREQUAL_THAN"), Filter_GE );
myLessFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
myGreaterFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
myApplyFilterButton = new QPushButton(tr("GEOM_BUT_APPLY"), myFilterGrp);
QGridLayout* filterLayout = new QGridLayout(myFilterGrp);
filterLayout->addWidget(myLessFilterCheck, 0, 0);
filterLayout->addWidget(myLessFilterCombo, 0, 1);
filterLayout->addWidget(myLessFilterSpin, 0, 2);
filterLayout->addWidget(myGreaterFilterCheck, 1, 0);
filterLayout->addWidget(myGreaterFilterCombo, 1, 1);
filterLayout->addWidget(myGreaterFilterSpin, 1, 2);
filterLayout->addWidget(myApplyFilterButton, 0, 3);
QVBoxLayout* layout = new QVBoxLayout(centralWidget()); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints); layout->addWidget(GroupPoints);
layout->addWidget(myFilterGrp);
/***************************************************************/ /***************************************************************/
setIsOptimizedBrowsing(true); setIsOptimizedBrowsing(true);
@ -183,6 +210,16 @@ EntityGUI_SubShapeDlg::~EntityGUI_SubShapeDlg()
//================================================================================= //=================================================================================
void EntityGUI_SubShapeDlg::Init() void EntityGUI_SubShapeDlg::Init()
{ {
// Get setting of step value from file configuration
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
// min, max, step and decimals for spin boxes
initSpinBox(myLessFilterSpin, 0., COORD_MAX, step, "length_precision" );
initSpinBox(myGreaterFilterSpin, 0., COORD_MAX, step, "length_precision" );
myLessFilterSpin->setValue( 0. );
myGreaterFilterSpin->setValue( 0. );
/* init variables */ /* init variables */
myDmMode = -1; myDmMode = -1;
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
@ -212,6 +249,10 @@ void EntityGUI_SubShapeDlg::Init()
connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(showOnlySelected())); connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(showOnlySelected())); connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
connect(myApplyFilterButton, SIGNAL(clicked()), this, SLOT(ClickOnOkFilter()));
connect(myLessFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
connect(myGreaterFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
connect(myGeomGUI->getApp()->selectionMgr(), connect(myGeomGUI->getApp()->selectionMgr(),
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
@ -219,6 +260,7 @@ void EntityGUI_SubShapeDlg::Init()
resize(100,100); resize(100,100);
SelectionIntoArgument(); SelectionIntoArgument();
SubShapeToggled(); SubShapeToggled();
MeasureToggled();
} }
//================================================================================= //=================================================================================
@ -270,12 +312,11 @@ void EntityGUI_SubShapeDlg::ClickOnOk()
/* More than 30 sub-shapes : ask confirmation */ /* More than 30 sub-shapes : ask confirmation */
unsigned int nb = NumberOfSubShapes(myShape, shapeType()); unsigned int nb = NumberOfSubShapes(myShape, shapeType());
if (nb > 30) { if (nb > 30) {
const QString caption = tr("GEOM_CONFIRM"); if (SUIT_MessageBox::question( this,
const QString text = tr("GEOM_CONFIRM_INFO").arg(nb); tr("GEOM_CONFIRM"),
const QString button0 = tr("GEOM_BUT_EXPLODE"); tr("GEOM_CONFIRM_INFO").arg(nb),
const QString button1 = tr("GEOM_BUT_CANCEL"); tr("GEOM_BUT_EXPLODE"),
tr("GEOM_BUT_CANCEL") ) != 0 )
if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
isOk = false; /* aborted */ isOk = false; /* aborted */
} }
} }
@ -300,12 +341,11 @@ bool EntityGUI_SubShapeDlg::ClickOnApply()
/* More than 30 sub-shapes : ask confirmation */ /* More than 30 sub-shapes : ask confirmation */
unsigned int nb = NumberOfSubShapes(myShape, shapeType()); unsigned int nb = NumberOfSubShapes(myShape, shapeType());
if (nb > 30) { if (nb > 30) {
const QString caption = tr("GEOM_CONFIRM"); if (SUIT_MessageBox::question( this,
const QString text = tr("GEOM_CONFIRM_INFO").arg(nb); tr("GEOM_CONFIRM"),
const QString button0 = tr("GEOM_BUT_EXPLODE"); tr("GEOM_CONFIRM_INFO").arg(nb),
const QString button1 = tr("GEOM_BUT_CANCEL"); tr("GEOM_BUT_EXPLODE"),
tr("GEOM_BUT_CANCEL") ) != 0 )
if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
return false; /* aborted */ return false; /* aborted */
} }
} }
@ -447,6 +487,9 @@ void EntityGUI_SubShapeDlg::SubShapeToggled()
GroupPoints->PushButton2->setEnabled(!isAllSubShapes()); GroupPoints->PushButton2->setEnabled(!isAllSubShapes());
GroupPoints->PushButton3->setEnabled(!isAllSubShapes()); GroupPoints->PushButton3->setEnabled(!isAllSubShapes());
GroupPoints->PushButton4->setEnabled(!isAllSubShapes()); GroupPoints->PushButton4->setEnabled(!isAllSubShapes());
myFilterGrp->setEnabled(GroupPoints->CheckButton1->isEnabled() &&
GroupPoints->CheckButton1->isChecked() &&
shapeType() < GEOM::VERTEX);
activateSelection(); activateSelection();
} }
@ -479,6 +522,7 @@ void EntityGUI_SubShapeDlg::updateButtonState()
GroupPoints->CheckButton1->setChecked( false ); GroupPoints->CheckButton1->setChecked( false );
GroupPoints->CheckButton1->setEnabled( false ); GroupPoints->CheckButton1->setEnabled( false );
} }
myFilterGrp->setEnabled(GroupPoints->CheckButton1->isEnabled() && GroupPoints->CheckButton1->isChecked());
} }
//================================================================================= //=================================================================================
@ -834,3 +878,73 @@ QString EntityGUI_SubShapeDlg::getNewObjectName (int) const
{ {
return QString::null; return QString::null;
} }
//=================================================================================
// function : ClickOnOkFilter()
// purpose : highlight and select entities which parameters (length, area or volume) are less than the value specified by the user
//=================================================================================
void EntityGUI_SubShapeDlg::ClickOnOkFilter()
{
if (CORBA::is_nil(myObject) || isAllSubShapes() || shapeType() >= GEOM::VERTEX)
return;
TopTools_IndexedMapOfShape aSubShapesMap;
TopExp::MapShapes(myShape, aSubShapesMap);
SALOME_View* view = GEOM_Displayer::GetActiveView();
getDisplayer()->Erase(myObject, false, false);
CORBA::String_var aMainEntry = myObject->GetStudyEntry();
QString anEntryBase = aMainEntry.in();
SALOME_ListIO toSelect;
TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
for (; anExp.More(); anExp.Next())
{
TopoDS_Shape aSubShape = anExp.Current();
int index = aSubShapesMap.FindIndex(aSubShape);
QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
if ( !getDisplayer()->IsDisplayed( anEntry ) )
continue;
double factor = GEOMUtils::ShapeToDouble(aSubShape).second;
double v1 = myLessFilterSpin->value();
double v2 = myGreaterFilterSpin->value();
bool isLess = myLessFilterCombo->itemData(myLessFilterCombo->currentIndex()).toInt() == Filter_LT ? factor < v1 : factor <= v1;
bool isGreater = myGreaterFilterCombo->itemData(myGreaterFilterCombo->currentIndex()).toInt() == Filter_GT ? factor > v2 : factor >= v2;
if ( ( myLessFilterCheck->isChecked() && myGreaterFilterCheck->isChecked() && isLess && isGreater ) ||
( myLessFilterCheck->isChecked() && !myGreaterFilterCheck->isChecked() && isLess ) ||
( myGreaterFilterCheck->isChecked() && !myLessFilterCheck->isChecked() && isGreater ) ) {
Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject();
io->setEntry( anEntry.toLatin1().constData() );
toSelect.Append(io);
}
}
if ( toSelect.Extent() > 0 ) {
myGeomGUI->getApp()->selectionMgr()->setSelectedObjects(toSelect);
SUIT_MessageBox::information( this,
tr( "INF_INFO" ),
tr( "GEOM_SOME_SHAPES_SELECTED").arg( toSelect.Extent() ),
tr( "BUT_OK" ) );
}
else {
SUIT_MessageBox::information( this,
tr( "INF_INFO" ),
tr( "GEOM_NO_SHAPES_SELECTED" ),
tr( "BUT_OK" ) );
}
updateButtonState();
}
//=================================================================================
// function : MeasureToggled()
// purpose :
// : Called when 'myLessFilterCheck' or 'myGreaterFilterCheck' state change
//=================================================================================
void EntityGUI_SubShapeDlg::MeasureToggled()
{
myLessFilterSpin->setEnabled(myLessFilterCheck->isChecked());
myLessFilterCombo->setEnabled(myLessFilterCheck->isChecked());
myGreaterFilterSpin->setEnabled(myGreaterFilterCheck->isChecked());
myGreaterFilterCombo->setEnabled(myGreaterFilterCheck->isChecked());
myApplyFilterButton->setEnabled(myLessFilterCheck->isChecked() || myGreaterFilterCheck->isChecked());
}

View File

@ -31,6 +31,11 @@
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
class QCheckBox;
class QComboBox;
class QGroupBox;
class QPushButton;
class SalomeApp_DoubleSpinBox;
class DlgRef_1Sel1List1Check3Btn; class DlgRef_1Sel1List1Check3Btn;
//================================================================================= //=================================================================================
@ -66,6 +71,8 @@ private slots:
void ComboTextChanged(); void ComboTextChanged();
void showOnlySelected(); void showOnlySelected();
void ClickOnOkFilter();
void MeasureToggled();
private: private:
void Init(); void Init();
@ -87,6 +94,14 @@ private:
bool myIsHiddenMain; bool myIsHiddenMain;
DlgRef_1Sel1List1Check3Btn* GroupPoints; DlgRef_1Sel1List1Check3Btn* GroupPoints;
QCheckBox* myLessFilterCheck;
QCheckBox* myGreaterFilterCheck;
QComboBox* myLessFilterCombo;
QComboBox* myGreaterFilterCombo;
SalomeApp_DoubleSpinBox* myLessFilterSpin;
SalomeApp_DoubleSpinBox* myGreaterFilterSpin;
QPushButton* myApplyFilterButton;
QGroupBox* myFilterGrp;
}; };
#endif // ENTITYGUI_SUBSHAPEDLG_H #endif // ENTITYGUI_SUBSHAPEDLG_H

View File

@ -5152,6 +5152,34 @@ shells and solids on the other hand.</translation>
<source>CC_PNT_ITEM_X_Y_Z</source> <source>CC_PNT_ITEM_X_Y_Z</source>
<translation>X=%1, Y=%2, Z=%3</translation> <translation>X=%1, Y=%2, Z=%3</translation>
</message> </message>
<message>
<source>GEOM_FILTER</source>
<translation>Filter</translation>
</message>
<message>
<source>GEOM_LESS_THAN</source>
<translation>Less Than</translation>
</message>
<message>
<source>GEOM_LESSOREQUAL_THAN</source>
<translation>Equal or Less Than</translation>
</message>
<message>
<source>GEOM_GREAT_THAN</source>
<translation>Greater Than</translation>
</message>
<message>
<source>GEOM_GREATOREQUAL_THAN</source>
<translation>Equal or Greater Than</translation>
</message>
<message>
<source>GEOM_SOME_SHAPES_SELECTED</source>
<translation>%1 shape(s) has(have) been selected</translation>
</message>
<message>
<source>GEOM_NO_SHAPES_SELECTED</source>
<translation>There are no shapes that meet filtering parameters</translation>
</message>
</context> </context>
<context> <context>
<name>GeometryGUI</name> <name>GeometryGUI</name>

View File

@ -5108,6 +5108,34 @@ le paramètre &apos;%1&apos; aux préférences du module Géométrie.</translati
<source>CC_PNT_ITEM_X_Y_Z</source> <source>CC_PNT_ITEM_X_Y_Z</source>
<translation>X=%1, Y=%2, Z=%3</translation> <translation>X=%1, Y=%2, Z=%3</translation>
</message> </message>
<message>
<source>GEOM_FILTER</source>
<translation type="unfinished">Filter</translation>
</message>
<message>
<source>GEOM_LESS_THAN</source>
<translation type="unfinished">Less Than</translation>
</message>
<message>
<source>GEOM_LESSOREQUAL_THAN</source>
<translation type="unfinished">Equal or Less Than</translation>
</message>
<message>
<source>GEOM_GREAT_THAN</source>
<translation type="unfinished">Greater Than</translation>
</message>
<message>
<source>GEOM_GREATOREQUAL_THAN</source>
<translation type="unfinished">Equal or Greater Than</translation>
</message>
<message>
<source>GEOM_SOME_SHAPES_SELECTED</source>
<translation type="unfinished">%1 shape(s) has(have) been selected</translation>
</message>
<message>
<source>GEOM_NO_SHAPES_SELECTED</source>
<translation type="unfinished">There are no shapes that meet filtering parameters</translation>
</message>
</context> </context>
<context> <context>
<name>GeometryGUI</name> <name>GeometryGUI</name>

View File

@ -5095,6 +5095,34 @@
<source>CC_PNT_ITEM_X_Y_Z</source> <source>CC_PNT_ITEM_X_Y_Z</source>
<translation>X=%1, Y=%2, Z=%3</translation> <translation>X=%1, Y=%2, Z=%3</translation>
</message> </message>
<message>
<source>GEOM_FILTER</source>
<translation type="unfinished">Filter</translation>
</message>
<message>
<source>GEOM_LESS_THAN</source>
<translation type="unfinished">Less Than</translation>
</message>
<message>
<source>GEOM_LESSOREQUAL_THAN</source>
<translation type="unfinished">Equal or Less Than</translation>
</message>
<message>
<source>GEOM_GREAT_THAN</source>
<translation type="unfinished">Greater Than</translation>
</message>
<message>
<source>GEOM_GREATOREQUAL_THAN</source>
<translation type="unfinished">Equal or Greater Than</translation>
</message>
<message>
<source>GEOM_SOME_SHAPES_SELECTED</source>
<translation type="unfinished">%1 shape(s) has(have) been selected</translation>
</message>
<message>
<source>GEOM_NO_SHAPES_SELECTED</source>
<translation type="unfinished">There are no shapes that meet filtering parameters</translation>
</message>
</context> </context>
<context> <context>
<name>GeometryGUI</name> <name>GeometryGUI</name>

View File

@ -212,46 +212,6 @@ namespace
return isModified; return isModified;
} }
//=======================================================================
//function : ShapeToDouble
//purpose : used by CompareShapes::operator()
//=======================================================================
std::pair<double, double> ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting)
{
// Computing of CentreOfMass
gp_Pnt GPoint;
double Len;
if (S.ShapeType() == TopAbs_VERTEX) {
GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S));
Len = (double)S.Orientation();
}
else {
GProp_GProps GPr;
// BEGIN: fix for Mantis issue 0020842
if (isOldSorting) {
BRepGProp::LinearProperties(S, GPr);
}
else {
if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) {
BRepGProp::LinearProperties(S, GPr);
}
else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) {
BRepGProp::SurfaceProperties(S, GPr);
}
else {
BRepGProp::VolumeProperties(S, GPr);
}
}
// END: fix for Mantis issue 0020842
GPoint = GPr.CentreOfMass();
Len = GPr.Mass();
}
double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9;
return std::make_pair(dMidXYZ, Len);
}
void parseWard( const GEOMUtils::LevelsList &theLevelList, std::string &treeStr ) void parseWard( const GEOMUtils::LevelsList &theLevelList, std::string &treeStr )
{ {
treeStr.append( "{" ); treeStr.append( "{" );
@ -324,6 +284,46 @@ namespace
} }
//=======================================================================
//function : ShapeToDouble
//purpose : used by CompareShapes::operator()
//=======================================================================
std::pair<double, double> GEOMUtils::ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting)
{
// Computing of CentreOfMass
gp_Pnt GPoint;
double Len;
if (S.ShapeType() == TopAbs_VERTEX) {
GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S));
Len = (double)S.Orientation();
}
else {
GProp_GProps GPr;
// BEGIN: fix for Mantis issue 0020842
if (isOldSorting) {
BRepGProp::LinearProperties(S, GPr);
}
else {
if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) {
BRepGProp::LinearProperties(S, GPr);
}
else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) {
BRepGProp::SurfaceProperties(S, GPr);
}
else {
BRepGProp::VolumeProperties(S, GPr);
}
}
// END: fix for Mantis issue 0020842
GPoint = GPr.CentreOfMass();
Len = GPr.Mass();
}
double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9;
return std::make_pair(dMidXYZ, Len);
}
//======================================================================= //=======================================================================
//function : GetPosition //function : GetPosition
//purpose : //purpose :

View File

@ -60,6 +60,28 @@ namespace GEOMUtils
typedef std::vector<LevelInfo> LevelsList; typedef std::vector<LevelInfo> LevelsList;
typedef std::map<std::string,std::pair<LevelsList,LevelsList> > TreeModel; typedef std::map<std::string,std::pair<LevelsList,LevelsList> > TreeModel;
/*!
* \brief Compute numerical functor for the shape.
*
* Resulting value can be used to sort out shapes according to some parameter.
*
* Returns a pair of two values (dist, functor) where
* - \a dist is a some value that is computed according to the center of mass of given shape;
* - \a functor is a numerical functor value
*
* The numerical functor is computed according to the shape's topological properties as follows:
* - orientation for vertices
* - length for edges and wires
* - area for faces and shells
* - volume for solids, compounds, compsolids
*
* If \a isOldSorting parameter is set to \c true, for all cases linear properties of the shape
* are used (to support backward compatibility in some methods). By default, this parameter is
* set to \c false.
*/
Standard_EXPORT std::pair<double, double> ShapeToDouble (const TopoDS_Shape& theShape,
bool isOldSorting = false);
/*! /*!
* \brief Get Local Coordinate System, corresponding to the given shape. * \brief Get Local Coordinate System, corresponding to the given shape.
* *

View File

@ -34,6 +34,7 @@ INCLUDE_DIRECTORIES(
${PROJECT_BINARY_DIR}/idl ${PROJECT_BINARY_DIR}/idl
${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src/OBJECT ${PROJECT_SOURCE_DIR}/src/OBJECT
${PROJECT_SOURCE_DIR}/src/GEOMUtils
${PROJECT_SOURCE_DIR}/src/GEOMClient ${PROJECT_SOURCE_DIR}/src/GEOMClient
${PROJECT_SOURCE_DIR}/src/GEOMImpl ${PROJECT_SOURCE_DIR}/src/GEOMImpl
${PROJECT_SOURCE_DIR}/src/GEOMGUI ${PROJECT_SOURCE_DIR}/src/GEOMGUI
@ -54,6 +55,7 @@ ADD_DEFINITIONS(
# libraries to link to # libraries to link to
SET(_link_LIBRARIES SET(_link_LIBRARIES
GEOMBase GEOMBase
GEOMUtils
) )
# --- resources --- # --- resources ---

View File

@ -30,6 +30,7 @@
#include <GEOMBase.h> #include <GEOMBase.h>
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOM_Displayer.h> #include <GEOM_Displayer.h>
#include <GEOMUtils.hxx>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <SalomeApp_Study.h> #include <SalomeApp_Study.h>
@ -71,7 +72,10 @@
#define GROUP_IDLST_COLOR Qt::blue // Specific color for the IDs of subShapes in the dialog box #define GROUP_IDLST_COLOR Qt::blue // Specific color for the IDs of subShapes in the dialog box
#define GROUP_NEWIDLST_COLOR Qt::red // Specific color for the new IDs of subShapes in the dialog box #define GROUP_NEWIDLST_COLOR Qt::red // Specific color for the new IDs of subShapes in the dialog box
enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2, SUBSHAPES_OF_INVISIBLE_SHAPE2 }; namespace {
enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2, SUBSHAPES_OF_INVISIBLE_SHAPE2 };
enum { Filter_LT, Filter_LE, Filter_GT, Filter_GE };
}
GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent) GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent)
: GEOMBase_Skeleton(theGeometryGUI, parent, false), : GEOMBase_Skeleton(theGeometryGUI, parent, false),
@ -180,9 +184,34 @@ GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QW
aMedLayout->setRowStretch(5, 5); aMedLayout->setRowStretch(5, 5);
aMedLayout->setRowStretch(8, 5); aMedLayout->setRowStretch(8, 5);
//filter group
myFilterGrp = new QGroupBox(tr("GEOM_FILTER"), centralWidget());
myLessFilterCheck = new QCheckBox(myFilterGrp);
myLessFilterCombo = new QComboBox(myFilterGrp);
myLessFilterCombo->addItem( tr("GEOM_LESS_THAN"), Filter_LT );
myLessFilterCombo->addItem( tr("GEOM_LESSOREQUAL_THAN"), Filter_LE );
myGreaterFilterCheck = new QCheckBox(myFilterGrp);
myGreaterFilterCombo = new QComboBox(myFilterGrp);
myGreaterFilterCombo->addItem( tr("GEOM_GREAT_THAN"), Filter_GT );
myGreaterFilterCombo->addItem( tr("GEOM_GREATOREQUAL_THAN"), Filter_GE );
myLessFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
myGreaterFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
myApplyFilterButton = new QPushButton(tr("GEOM_BUT_APPLY"), myFilterGrp);
QGridLayout* filterLayout = new QGridLayout(myFilterGrp);
filterLayout->addWidget(myLessFilterCheck, 0, 0);
filterLayout->addWidget(myLessFilterCombo, 0, 1);
filterLayout->addWidget(myLessFilterSpin, 0, 2);
filterLayout->addWidget(myGreaterFilterCheck, 1, 0);
filterLayout->addWidget(myGreaterFilterCombo, 1, 1);
filterLayout->addWidget(myGreaterFilterSpin, 1, 2);
filterLayout->addWidget(myApplyFilterButton, 0, 3);
QVBoxLayout* layout = new QVBoxLayout(centralWidget()); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupMedium); layout->addWidget(GroupMedium);
layout->addWidget(myFilterGrp);
setHelpFileName("work_with_groups_page.html"); setHelpFileName("work_with_groups_page.html");
@ -210,6 +239,16 @@ GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
//================================================================================= //=================================================================================
void GroupGUI_GroupDlg::Init() void GroupGUI_GroupDlg::Init()
{ {
// Get setting of step value from file configuration
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
// min, max, step and decimals for spin boxes
initSpinBox(myLessFilterSpin, 0., COORD_MAX, step, "length_precision" );
initSpinBox(myGreaterFilterSpin, 0., COORD_MAX, step, "length_precision" );
myLessFilterSpin->setValue( 0. );
myGreaterFilterSpin->setValue( 0. );
myDmMode = -1; myDmMode = -1;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@ -282,11 +321,16 @@ void GroupGUI_GroupDlg::Init()
connect(myShowAllBtn, SIGNAL(clicked()), this, SLOT(showOnlySelected())); connect(myShowAllBtn, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
connect(myIdList, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged())); connect(myIdList, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()));
connect(myApplyFilterButton, SIGNAL(clicked()), this, SLOT(ClickOnOkFilter()));
connect(myLessFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
connect(myGreaterFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
setInPlaceObj(GEOM::GEOM_Object::_nil()); setInPlaceObj(GEOM::GEOM_Object::_nil());
myBusy = true; // just activate but do not select in the list myBusy = true; // just activate but do not select in the list
activateSelection(); activateSelection();
myBusy = false; myBusy = false;
MeasureToggled();
} }
//================================================================================= //=================================================================================
@ -1083,6 +1127,10 @@ void GroupGUI_GroupDlg::updateState (bool isAdd)
mySelBtn2->setEnabled(subSelectionWay() != ALL_SUBSHAPES); mySelBtn2->setEnabled(subSelectionWay() != ALL_SUBSHAPES);
myShape2Name->setEnabled(subSelectionWay() != ALL_SUBSHAPES); myShape2Name->setEnabled(subSelectionWay() != ALL_SUBSHAPES);
myFilterGrp->setEnabled(!CORBA::is_nil(myMainObj) &&
subSelectionWay() == ALL_SUBSHAPES &&
myIsShapeType &&
getShapeType() != TopAbs_VERTEX);
if (subSelectionWay() == ALL_SUBSHAPES) if (subSelectionWay() == ALL_SUBSHAPES)
setInPlaceObj(GEOM::GEOM_Object::_nil()); setInPlaceObj(GEOM::GEOM_Object::_nil());
} }
@ -1317,3 +1365,65 @@ GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather(GEOM::GEOM_Object_ptr theObj)
} }
return aFatherObj._retn(); return aFatherObj._retn();
} }
void GroupGUI_GroupDlg::ClickOnOkFilter()
{
if (CORBA::is_nil(myMainObj) || subSelectionWay() != ALL_SUBSHAPES || !myIsShapeType || getShapeType() == TopAbs_VERTEX)
return;
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
TopTools_IndexedMapOfShape aSubShapesMap;
TopExp::MapShapes(aMainShape, aSubShapesMap);
SALOME_View* view = GEOM_Displayer::GetActiveView();
getDisplayer()->Erase(myMainObj, false, false);
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
QString anEntryBase = aMainEntry.in();
SALOME_ListIO toSelect;
TopExp_Explorer anExp (aMainShape, (TopAbs_ShapeEnum)getShapeType());
for (; anExp.More(); anExp.Next())
{
TopoDS_Shape aSubShape = anExp.Current();
int index = aSubShapesMap.FindIndex(aSubShape);
QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
if ( !getDisplayer()->IsDisplayed( anEntry ) )
continue;
double factor = GEOMUtils::ShapeToDouble(aSubShape).second;
double v1 = myLessFilterSpin->value();
double v2 = myGreaterFilterSpin->value();
bool isLess = myLessFilterCombo->itemData(myLessFilterCombo->currentIndex()).toInt() == Filter_LT ? factor < v1 : factor <= v1;
bool isGreater = myGreaterFilterCombo->itemData(myGreaterFilterCombo->currentIndex()).toInt() == Filter_GT ? factor > v2 : factor >= v2;
if ( ( myLessFilterCheck->isChecked() && myGreaterFilterCheck->isChecked() && isLess && isGreater ) ||
( myLessFilterCheck->isChecked() && !myGreaterFilterCheck->isChecked() && isLess ) ||
( myGreaterFilterCheck->isChecked() && !myLessFilterCheck->isChecked() && isGreater ) ) {
Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject();
io->setEntry( anEntry.toLatin1().constData() );
toSelect.Append(io);
}
}
if ( toSelect.Extent() > 0 ) {
myGeomGUI->getApp()->selectionMgr()->setSelectedObjects(toSelect);
SUIT_MessageBox::information( this,
tr( "INF_INFO" ),
tr( "GEOM_SOME_SHAPES_SELECTED").arg( toSelect.Extent() ),
tr( "BUT_OK" ) );
}
else {
SUIT_MessageBox::information( this,
tr( "INF_INFO" ),
tr( "GEOM_NO_SHAPES_SELECTED" ),
tr( "BUT_OK" ) );
}
updateState(true);
}
void GroupGUI_GroupDlg::MeasureToggled()
{
myLessFilterSpin->setEnabled(myLessFilterCheck->isChecked());
myLessFilterCombo->setEnabled(myLessFilterCheck->isChecked());
myGreaterFilterSpin->setEnabled(myGreaterFilterCheck->isChecked());
myGreaterFilterCombo->setEnabled(myGreaterFilterCheck->isChecked());
myApplyFilterButton->setEnabled(myLessFilterCheck->isChecked() || myGreaterFilterCheck->isChecked());
}

View File

@ -33,10 +33,14 @@
#include <TColStd_DataMapOfIntegerInteger.hxx> #include <TColStd_DataMapOfIntegerInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
class QCheckBox;
class QComboBox;
class QPushButton;
class QGroupBox; class QGroupBox;
class QLineEdit; class QLineEdit;
class QListWidget; class QListWidget;
class QButtonGroup; class QButtonGroup;
class SalomeApp_DoubleSpinBox;
//================================================================================= //=================================================================================
// class : GroupGUI_GroupDlg // class : GroupGUI_GroupDlg
@ -77,6 +81,8 @@ private slots:
void remove(); void remove();
void showOnlySelected(); void showOnlySelected();
void selectionChanged(); void selectionChanged();
void ClickOnOkFilter();
void MeasureToggled();
private: private:
void Init(); void Init();
@ -119,6 +125,14 @@ private:
QPushButton* myHideSelBtn; QPushButton* myHideSelBtn;
QPushButton* myShowAllBtn; QPushButton* myShowAllBtn;
QListWidget* myIdList; QListWidget* myIdList;
QCheckBox* myLessFilterCheck;
QCheckBox* myGreaterFilterCheck;
QComboBox* myLessFilterCombo;
QComboBox* myGreaterFilterCombo;
SalomeApp_DoubleSpinBox* myLessFilterSpin;
SalomeApp_DoubleSpinBox* myGreaterFilterSpin;
QPushButton* myApplyFilterButton;
QGroupBox* myFilterGrp;
}; };
#endif #endif