to be extracted from the main object. In this mode the user can select sub-shapes
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
variety of ways:
- <em>geompy.ExtractShapes(Shape, Type, isSorted)</em> explodes a
<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>
</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>
<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. If the <b>Second Shape</b> is used, the elements are added
according to <b>Main Shape Selection restriction</b> settings. To delete elements
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>Finally, confirm your selection by clicking <b>Apply and Close
</b> (also closes the Menu) or \b Apply (leaves the Menu open for
\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,
ShapeType),</em> where MainShape is a shape for which the group is
created, ShapeType is a type of shapes in the created group.
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
+#include <GEOMUtils.hxx>
#include <OCCViewer_ViewModel.h>
#include <SVTK_ViewModel.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SUIT_MessageBox.h>
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
#include <TColStd_IndexedMapOfInteger.hxx>
-#include <QMessageBox>
-
#include <GEOMImpl_Types.hxx>
namespace
"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 index = 0;
GroupPoints->PushButton4->setText(tr("SHOW_ALL_SUB_SHAPES"));
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());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
+ layout->addWidget(myFilterGrp);
/***************************************************************/
setIsOptimizedBrowsing(true);
//=================================================================================
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 */
myDmMode = -1;
myEditCurrentArgument = GroupPoints->LineEdit1;
connect(GroupPoints->PushButton3, 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(),
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
resize(100,100);
SelectionIntoArgument();
SubShapeToggled();
+ MeasureToggled();
}
//=================================================================================
/* More than 30 sub-shapes : ask confirmation */
unsigned int nb = NumberOfSubShapes(myShape, shapeType());
if (nb > 30) {
- const QString caption = tr("GEOM_CONFIRM");
- const QString text = tr("GEOM_CONFIRM_INFO").arg(nb);
- const QString button0 = tr("GEOM_BUT_EXPLODE");
- const QString button1 = tr("GEOM_BUT_CANCEL");
-
- if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
+ if (SUIT_MessageBox::question( this,
+ tr("GEOM_CONFIRM"),
+ tr("GEOM_CONFIRM_INFO").arg(nb),
+ tr("GEOM_BUT_EXPLODE"),
+ tr("GEOM_BUT_CANCEL") ) != 0 )
isOk = false; /* aborted */
}
}
/* More than 30 sub-shapes : ask confirmation */
unsigned int nb = NumberOfSubShapes(myShape, shapeType());
if (nb > 30) {
- const QString caption = tr("GEOM_CONFIRM");
- const QString text = tr("GEOM_CONFIRM_INFO").arg(nb);
- const QString button0 = tr("GEOM_BUT_EXPLODE");
- const QString button1 = tr("GEOM_BUT_CANCEL");
-
- if (QMessageBox::warning(this, caption, text, button0, button1) != 0)
+ if (SUIT_MessageBox::question( this,
+ tr("GEOM_CONFIRM"),
+ tr("GEOM_CONFIRM_INFO").arg(nb),
+ tr("GEOM_BUT_EXPLODE"),
+ tr("GEOM_BUT_CANCEL") ) != 0 )
return false; /* aborted */
}
}
GroupPoints->PushButton2->setEnabled(!isAllSubShapes());
GroupPoints->PushButton3->setEnabled(!isAllSubShapes());
GroupPoints->PushButton4->setEnabled(!isAllSubShapes());
+ myFilterGrp->setEnabled(GroupPoints->CheckButton1->isEnabled() &&
+ GroupPoints->CheckButton1->isChecked() &&
+ shapeType() < GEOM::VERTEX);
activateSelection();
}
GroupPoints->CheckButton1->setChecked( false );
GroupPoints->CheckButton1->setEnabled( false );
}
+ myFilterGrp->setEnabled(GroupPoints->CheckButton1->isEnabled() && GroupPoints->CheckButton1->isChecked());
}
//=================================================================================
{
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());
+}
#include <TColStd_IndexedMapOfInteger.hxx>
+class QCheckBox;
+class QComboBox;
+class QGroupBox;
+class QPushButton;
+class SalomeApp_DoubleSpinBox;
class DlgRef_1Sel1List1Check3Btn;
//=================================================================================
void ComboTextChanged();
void showOnlySelected();
+ void ClickOnOkFilter();
+ void MeasureToggled();
private:
void Init();
bool myIsHiddenMain;
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
<source>CC_PNT_ITEM_X_Y_Z</source>
<translation>X=%1, Y=%2, Z=%3</translation>
</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>
<name>GeometryGUI</name>
<source>CC_PNT_ITEM_X_Y_Z</source>
<translation>X=%1, Y=%2, Z=%3</translation>
</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>
<name>GeometryGUI</name>
<source>CC_PNT_ITEM_X_Y_Z</source>
<translation>X=%1, Y=%2, Z=%3</translation>
</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>
<name>GeometryGUI</name>
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 )
{
treeStr.append( "{" );
}
+//=======================================================================
+//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
//purpose :
typedef std::vector<LevelInfo> LevelsList;
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.
*
${PROJECT_BINARY_DIR}/idl
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src/OBJECT
+ ${PROJECT_SOURCE_DIR}/src/GEOMUtils
${PROJECT_SOURCE_DIR}/src/GEOMClient
${PROJECT_SOURCE_DIR}/src/GEOMImpl
${PROJECT_SOURCE_DIR}/src/GEOMGUI
# libraries to link to
SET(_link_LIBRARIES
GEOMBase
+ GEOMUtils
)
# --- resources ---
#include <GEOMBase.h>
#include <GeometryGUI.h>
#include <GEOM_Displayer.h>
+#include <GEOMUtils.hxx>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#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
-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)
: GEOMBase_Skeleton(theGeometryGUI, parent, false),
aMedLayout->setRowStretch(5, 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());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupMedium);
+ layout->addWidget(myFilterGrp);
setHelpFileName("work_with_groups_page.html");
//=================================================================================
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;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
connect(myShowAllBtn, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
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());
myBusy = true; // just activate but do not select in the list
activateSelection();
myBusy = false;
+ MeasureToggled();
}
//=================================================================================
myRemBtn->setEnabled(hasSel);
myRestrictGroupBox->setEnabled(!CORBA::is_nil(myMainObj));
mySelAllBtn->setEnabled(!CORBA::is_nil(myMainObj));
-
+
mySelBtn2->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)
setInPlaceObj(GEOM::GEOM_Object::_nil());
}
}
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());
+}
#include <TColStd_DataMapOfIntegerInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
+class QCheckBox;
+class QComboBox;
+class QPushButton;
class QGroupBox;
class QLineEdit;
class QListWidget;
class QButtonGroup;
+class SalomeApp_DoubleSpinBox;
//=================================================================================
// class : GroupGUI_GroupDlg
void remove();
void showOnlySelected();
void selectionChanged();
+ void ClickOnOkFilter();
+ void MeasureToggled();
private:
void Init();
QPushButton* myHideSelBtn;
QPushButton* myShowAllBtn;
QListWidget* myIdList;
+ QCheckBox* myLessFilterCheck;
+ QCheckBox* myGreaterFilterCheck;
+ QComboBox* myLessFilterCombo;
+ QComboBox* myGreaterFilterCombo;
+ SalomeApp_DoubleSpinBox* myLessFilterSpin;
+ SalomeApp_DoubleSpinBox* myGreaterFilterSpin;
+ QPushButton* myApplyFilterButton;
+ QGroupBox* myFilterGrp;
};
#endif