From ba61af65209e3cb696f035280761e89c26910ecf Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 30 Sep 2008 08:07:29 +0000 Subject: [PATCH] 0019970: create groups automatically --- .../gui/SMESH/input/creating_groups.doc | 10 + resources/Makefile.am | 1 + src/SMESHGUI/Makefile.am | 2 + src/SMESHGUI/SMESHGUI.cxx | 13 + src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx | 477 ++++++++++++++++++ src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.h | 150 ++++++ src/SMESHGUI/SMESH_images.po | 3 + src/SMESHGUI/SMESH_msg_en.po | 14 + 8 files changed, 670 insertions(+) create mode 100644 src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.h diff --git a/doc/salome/gui/SMESH/input/creating_groups.doc b/doc/salome/gui/SMESH/input/creating_groups.doc index d21a4d78e..2cfc648e8 100644 --- a/doc/salome/gui/SMESH/input/creating_groups.doc +++ b/doc/salome/gui/SMESH/input/creating_groups.doc @@ -74,6 +74,16 @@ a new group of mesh elements will be created. \image html a-creategroup.png +

+To create multiple groups on geometry of both nodes and elements of +any type at once, in the \b Mesh menu select Create Groups from +Geometry.
+Unique group names are generated by appending a number to \b Name. +Type of group of mesh elements is defined automatically by +Geometrical object nature. + +\image html create_groups_from_geometry.png + \image html image132.gif
In this picture the cells which belong to a certain face are selected in green.
diff --git a/resources/Makefile.am b/resources/Makefile.am index f660266d2..9dc98ed75 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -109,6 +109,7 @@ dist_salomeres_DATA = \ mesh_tree_group.png \ mesh_edit_group.png \ mesh_make_group.png \ + mesh_groups_from_gemetry.png \ mesh_union2tri.png \ mesh_uniontri.png \ mesh_cutquad.png \ diff --git a/src/SMESHGUI/Makefile.am b/src/SMESHGUI/Makefile.am index de6c6c9cc..da9f82040 100644 --- a/src/SMESHGUI/Makefile.am +++ b/src/SMESHGUI/Makefile.am @@ -109,6 +109,7 @@ dist_libSMESH_la_SOURCES = \ SMESHGUI_ComputeDlg.cxx \ SMESHGUI_MakeNodeAtPointDlg.cxx \ SMESHGUI_MeshEditPreview.cxx \ + SMESHGUI_GroupOnShapeDlg.cxx \ SMESHGUI_FileInfoDlg.cxx MOC_FILES = \ @@ -162,6 +163,7 @@ MOC_FILES = \ SMESHGUI_BuildCompoundDlg_moc.cxx \ SMESHGUI_ComputeDlg_moc.cxx \ SMESHGUI_MakeNodeAtPointDlg_moc.cxx \ + SMESHGUI_GroupOnShapeDlg_moc.cxx \ SMESHGUI_FileInfoDlg_moc.cxx nodist_libSMESH_la_SOURCES= \ diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 0721eaeaa..924bdf96c 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -69,6 +69,7 @@ #include "SMESHGUI_BuildCompoundDlg.h" #include "SMESHGUI_ComputeDlg.h" #include "SMESHGUI_FileInfoDlg.h" +#include "SMESHGUI_GroupOnShapeDlg.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_GEOMGenUtils.h" @@ -1719,6 +1720,11 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) }*/ break; } + case 806: // CREATE GEO GROUP + { + startOperation( 806 ); + break; + } case 801: // CREATE GROUP { if ( !vtkwnd ) @@ -2606,6 +2612,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" ); createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" ); createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" ); + createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_GEO_GROUP" ); createSMESHAction( 801, "CREATE_GROUP", "ICON_SMESH_TREE_GROUP" ); createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" ); createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" ); @@ -2741,6 +2748,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createMenu( 701, meshId, -1 ); createMenu( separator(), meshId, -1 ); createMenu( 801, meshId, -1 ); + createMenu( 806, meshId, -1 ); createMenu( 802, meshId, -1 ); createMenu( 803, meshId, -1 ); createMenu( separator(), meshId, -1 ); @@ -2835,6 +2843,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( 701, meshTb ); createTool( separator(), meshTb ); createTool( 801, meshTb ); + createTool( 806, meshTb ); createTool( 802, meshTb ); createTool( 803, meshTb ); createTool( separator(), meshTb ); @@ -2944,6 +2953,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createPopupItem( 903, OB, mesh_group ); // WHAT_IS popupMgr()->insert( separator(), -1, 0 ); createPopupItem( 801, OB, mesh ); // CREATE_GROUP + createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP popupMgr()->insert( separator(), -1, 0 ); createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS @@ -3631,6 +3641,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const case 704: // Edit mesh/sub-mesh op = new SMESHGUI_MeshOp( false ); break; + case 806: // Create group on geom + op = new SMESHGUI_GroupOnShapeOp(); + break; case 417: //convert to quadratic op = new SMESHGUI_ConvToQuadOp(); break; diff --git a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx new file mode 100644 index 000000000..c0409901b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx @@ -0,0 +1,477 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : SMESHGUI_GroupOnShapeDlg.cxx +// Created : Wed Sep 17 18:36:51 2008 +// Author : Edward AGAPOV (eap) +// Module : SMESH + + +// IDL Headers +#include "SMESHGUI_GroupOnShapeDlg.h" + +#include "SMESH_TypeFilter.hxx" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_GEOMGenUtils.h" + +#include +#include + +#include +#include +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Group) + +#include +#include +#include +#include +#include +#include +#include + +enum { _MESH, _ELEM_GEOM, _NODE_GEOM }; + +SMESHGUI_GroupOnShapeDlg::SMESHGUI_GroupOnShapeDlg() + : SMESHGUI_Dialog( 0, false, true ) +{ + QPixmap image (resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + + QGroupBox* aGrp = new QGroupBox( 3, Qt::Horizontal, mainFrame() ); + aGrp->setFrameStyle( QFrame::NoFrame ); + aGrp->setInsideMargin( 0 ); + + // Name + new QLabel( tr( "SMESH_NAME" ), aGrp ); new QLabel( "", aGrp ); + myGrpNameLine = new QLineEdit( aGrp, "myGrpNameLine" ); + + // Mesh + new QLabel( tr( "SMESH_OBJECT_MESH" ), aGrp ); + myMeshBtn = new QPushButton( aGrp, "myMeshBtn"); + myMeshBtn->setToggleButton(true); + myMeshBtn->setPixmap(image); + myMeshLine = new QLineEdit( aGrp, "myMeshLine" ); + myMeshLine->setReadOnly(true); + + // Elem geom + + QGroupBox* elemsGrp = new QGroupBox( 1, Qt::Horizontal, tr( "SMESH_ELEMENTS" ), mainFrame() ); + QFrame* elemFr = new QFrame(elemsGrp, "elemFr"); + + QLabel* label = new QLabel( tr( "SMESH_OBJECT_GEOM" ), elemFr ); + myElemGeomBtn = new QPushButton( elemFr, "myElemGeomBtn"); + myElemGeomBtn->setToggleButton(true); + myElemGeomBtn->setPixmap(image); + myElemGeomList = new QListBox( elemFr, "myElemGeomList" ); + myElemGeomList->setSelectionMode(QListBox::NoSelection); + + QGridLayout* elemLay = new QGridLayout(elemFr, 2, 3); + elemLay->setSpacing(6); + elemLay->setAutoAdd(false); + elemLay->setRowStretch( 1, 1 ); + elemLay->addWidget( label, 0, 0 ); + elemLay->addWidget( myElemGeomBtn, 0, 1 ); + elemLay->addMultiCellWidget(myElemGeomList, 0, 1, 2, 2); + + // Node geom + + QGroupBox* nodesGrp = new QGroupBox( 1, Qt::Horizontal, tr( "SMESH_NODES" ), mainFrame() ); + QFrame* nodeFr = new QFrame(nodesGrp, "nodeFr"); + + label = new QLabel( tr( "SMESH_OBJECT_GEOM" ), nodeFr ); + myNodeGeomBtn = new QPushButton( nodeFr, "myNodeGeomBtn"); + myNodeGeomBtn->setToggleButton(true); + myNodeGeomBtn->setPixmap(image); + myNodeGeomList = new QListBox( nodeFr, "myNodeGeomList" ); + myNodeGeomList->setSelectionMode(QListBox::NoSelection); + + QGridLayout* nodeLay = new QGridLayout(nodeFr, 2, 3); + nodeLay->setSpacing(6); + nodeLay->setAutoAdd(false); + nodeLay->setRowStretch( 1, 1 ); + nodeLay->addWidget( label, 0, 0 ); + nodeLay->addWidget( myNodeGeomBtn, 0, 1 ); + nodeLay->addMultiCellWidget(myNodeGeomList, 0, 1, 2, 2); + + // Fill layout + QVBoxLayout* aLay = new QVBoxLayout( mainFrame(), 0, 5 ); + aLay->addWidget( aGrp ); + aLay->addWidget( elemsGrp ); + aLay->addWidget( nodesGrp ); + + setCaption( tr( "SMESH_CREATE_GROUP_FROM_GEOM" ) ); +} + +//================================================================================ +/*! + * \brief slot to enable/diable [Apply] + */ +//================================================================================ + +void SMESHGUI_GroupOnShapeDlg::updateButtons() +{ + bool enable = + !myGrpNameLine->text().isEmpty() && myElemGeomList->count() + myNodeGeomList->count(); + + button(Apply)->setEnabled( enable ); + button(OK)->setEnabled( enable ); +} + +//================================================================================ +/*! + * \brief initialization + */ +//================================================================================ + +void SMESHGUI_GroupOnShapeDlg::init() +{ + myGrpNameLine->setText(""); + + myMeshBtn->setOn( true ); + myMeshLine->setText(""); + + myElemGeomBtn->setOn(false); + myElemGeomBtn->setEnabled(false); + myElemGeomList->clear(); + myNodeGeomBtn->setOn(false); + myNodeGeomBtn->setEnabled(false); + myNodeGeomList->clear(); + + updateButtons(); +} + +//================================================================================ +/*! + * \brief operation constructor + */ +//================================================================================ + +SMESHGUI_GroupOnShapeOp::SMESHGUI_GroupOnShapeOp() + : SMESHGUI_SelectionOp(ActorSelection), + myDlg( 0 ) +{ + myHelpFileName = "creating_groups_page.html"; +} + +SMESHGUI_GroupOnShapeOp::~SMESHGUI_GroupOnShapeOp() +{ + if ( myDlg ) + delete myDlg; +} +//================================================================================ +/*! + * \brief Gets dialog of this operation + * \retval LightApp_Dialog* - pointer to dialog of this operation +*/ +//================================================================================ + +LightApp_Dialog* SMESHGUI_GroupOnShapeOp::dlg() const +{ + return myDlg; +} + +//================================================================================ +/*! + * \brief return type of mesh group by geom object + */ +//================================================================================ + +static SMESH::ElementType elementType(GEOM::GEOM_Object_var& geom) +{ + if ( !geom->_is_nil() ) { + switch ( geom->GetShapeType() ) { + case GEOM::VERTEX: return SMESH::NODE; + case GEOM::EDGE: return SMESH::EDGE; + case GEOM::WIRE: return SMESH::EDGE; + case GEOM::FACE: return SMESH::FACE; + case GEOM::SHELL: return SMESH::FACE; + case GEOM::SOLID: return SMESH::VOLUME; + case GEOM::COMPSOLID:return SMESH::VOLUME; + case GEOM::COMPOUND: break; + default: return SMESH::ALL; + } + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IShapesOperations_var aShapeOp = + SMESH::GetGEOMGen()->GetIShapesOperations(aStudy->StudyId()); + + if ( geom->GetType() == 37 ) { // geom group + GEOM::GEOM_IGroupOperations_var aGroupOp = + SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + if ( !aGroupOp->_is_nil() ) { + GEOM::GEOM_Object_var mainShape = aGroupOp->GetMainShape( geom ); + GEOM::ListOfLong_var ids = aGroupOp->GetObjects( geom ); + if ( ids->length() && !mainShape->_is_nil() && !aShapeOp->_is_nil() ) { + GEOM::GEOM_Object_var member = aShapeOp->GetSubShape( mainShape, ids[0] ); + return elementType( member ); + } + } + } + else if ( !aShapeOp->_is_nil() ) { // just a compoud shape + GEOM::ListOfLong_var ids = aShapeOp->SubShapeAllIDs( geom, GEOM::SHAPE, false ); + if ( ids->length() ) { + GEOM::GEOM_Object_var member = aShapeOp->GetSubShape( geom, ids[0] ); + return elementType( member ); + } + } + } + return SMESH::ALL; +} + +//================================================================================ +/*! + * \brief initialization + */ +//================================================================================ + +void SMESHGUI_GroupOnShapeOp::init() +{ + myMeshID=""; + myElemGeoIDs.clear(); + myNodeGeoIDs.clear(); + + myDlg->init(); + removeCustomFilters(); + onActivateObject( _MESH ); // install filter +} + +//================================================================================ +/*! + * \brief start operation + */ +//================================================================================ + +void SMESHGUI_GroupOnShapeOp::startOperation() +{ + if (!myDlg) + { + myDlg = new SMESHGUI_GroupOnShapeDlg(); + connect(myDlg->myMeshBtn, SIGNAL(clicked()), this, SLOT(onButtonClick())); + connect(myDlg->myElemGeomBtn, SIGNAL(clicked()), this, SLOT(onButtonClick())); + connect(myDlg->myNodeGeomBtn, SIGNAL(clicked()), this, SLOT(onButtonClick())); + connect(myDlg->myGrpNameLine, SIGNAL(textChanged(const QString&)),myDlg,SLOT(updateButtons())); + } + SMESHGUI_SelectionOp::startOperation(); + + init(); + myDlg->show(); +} + +//================================================================================ +/*! + * \brief create groups + */ +//================================================================================ + +bool SMESHGUI_GroupOnShapeOp::onApply() +{ + SUIT_OverrideCursor aWaitCursor; + + if (isStudyLocked()) + return false; + + // study + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + if ( !aStudy ) return false; + + // mesh + _PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID ); + SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface( meshSO ); + if ( mesh->_is_nil() ) return false; + + // names of all existing groups + SMESH::ListOfGroups_var groups = mesh->GetGroups(); + QStringList groupNames; + for ( int i = 0; i < groups->length(); ++i ) { + CORBA::String_var name = groups[i]->GetName(); + groupNames.append( name.in() ); + } + + // create groups + SMESH::SMESH_GroupOnGeom_var group; + for ( int isNode = 0; isNode < 2; ++isNode ) // elems and then nodes + { + QStringList::iterator geomID = isNode ? myNodeGeoIDs.begin() : myElemGeoIDs.begin(); + QStringList::iterator geomEnd = isNode ? myNodeGeoIDs.end() : myElemGeoIDs.end(); + + for ( ; geomID != geomEnd; ++geomID ) + { + // selected geom + _PTR(SObject) geomSO = aStudy->FindObjectID( *geomID ); + GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface(geomSO); + if ( geom->_is_nil() ) continue; + + // group type + SMESH::ElementType elemType = isNode ? SMESH::NODE : elementType( geom ); + if ( elemType == SMESH::ALL ) + continue; + + // make a unique name + int nb = 1; + QString name = myDlg->myGrpNameLine->text() + "_" + QString::number(nb); + while ( groupNames.contains( name )) + name = myDlg->myGrpNameLine->text() + "_" + QString::number(++nb); + groupNames.append( name ); + + //printf( "apply() %s %s\n", (*geomID).latin1(), name.latin1() ); + group = mesh->CreateGroupFromGEOM( elemType, name, geom ); + } + } + update( UF_ObjBrowser | UF_Model ); + + init(); + + return !group->_is_nil(); +} + +//================================================================================ +/*! + * \brief slot connected to selection buttons + */ +//================================================================================ + +void SMESHGUI_GroupOnShapeOp::onButtonClick() +{ + removeCustomFilters(); + + if ( sender() == myDlg->myMeshBtn && myDlg->myMeshBtn->isOn() ) + { + myDlg->myElemGeomBtn->setOn(false); + myDlg->myNodeGeomBtn->setOn(false); + onActivateObject( _MESH ); // install filter + } + else if ( sender() == myDlg->myElemGeomBtn && myDlg->myElemGeomBtn->isOn() ) + { + myDlg->myMeshBtn->setOn(false); + myDlg->myNodeGeomBtn->setOn(false); + onActivateObject( _ELEM_GEOM ); // install filter + } + else if ( sender() == myDlg->myNodeGeomBtn && myDlg->myNodeGeomBtn->isOn() ) + { + myDlg->myMeshBtn->setOn(false); + myDlg->myElemGeomBtn->setOn(false); + onActivateObject( _NODE_GEOM ); // install filter + } + //selectionDone(); +} + +//================================================================================ +/*! + * \brief Creates selection filter + * \param theId - identifier of current selection widget + * \retval SUIT_SelectionFilter* - pointer to the created filter or null + * + * Creates selection filter in accordance with identifier of current selection widget + */ +//================================================================================ +SUIT_SelectionFilter* SMESHGUI_GroupOnShapeOp::createFilter( const int theId ) const +{ + if ( theId == _ELEM_GEOM || theId == _NODE_GEOM ) + return new GEOM_SelectionFilter( (SalomeApp_Study*)study(), true ); + else if ( theId == _MESH ) + return new SMESH_TypeFilter( MESH ); + else + return ( SUIT_SelectionFilter*) 0; +} +//================================================================================ +/*! + * \brief Updates dialog's look and feel + * + * Virtual method redefined from the base class updates dialog's look and feel + */ +//================================================================================ +void SMESHGUI_GroupOnShapeOp::selectionDone() +{ + QStringList names, ids; + LightApp_Dialog::TypesList types; + selected( names, types, ids ); + int nbSelected = names.size(); + + if ( myDlg->myMeshBtn->isOn() ) // mesh selected + { + myDlg->myMeshLine->setText(""); + myMeshID = ""; + if ( nbSelected == 1 ) { + myDlg->myMeshLine->setText( names.front() ); + myMeshID = ids.front(); + } + myDlg->myElemGeomList->clear(); + myDlg->myElemGeomBtn->setEnabled( nbSelected == 1 ); + myDlg->myNodeGeomList->clear(); + myDlg->myNodeGeomBtn->setEnabled( nbSelected == 1 ); + return; + } + + // Filter off inappropriate shapes + + QStringList goodNames, goodIds; + if (nbSelected > 0) { + // study + if (_PTR(Study) aStudy = SMESH::GetActiveStudyDocument()) { + // mesh + if (_PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID )) { + // shape to mesh + _PTR(SObject) anObj, shapeToMesh; + if (meshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(shapeToMesh)) { + // loop on selected + QStringList::iterator name = names.begin(), id = ids.begin(), idEnd = ids.end(); + for (; id != idEnd; ++id, ++name ) { + // shape SO + if (_PTR(SObject) shapeSO = aStudy->FindObjectID( *id )) { + // check if shape SO is a child of shape to mesh + while ( shapeSO && shapeSO->GetID() != shapeToMesh->GetID() ) + if ( shapeSO->Depth() < 2 ) + shapeSO.reset(); + else + shapeSO = shapeSO->GetFather(); + if ( shapeSO ) { + //printf( "selectionDone() %s %s\n", (*id).latin1(), (*name).latin1() ); + if ( !goodIds.contains( *id )) { + goodIds.append( *id ); + goodNames.append( *name ); + } + } + } + } + } + } + } + } + + if ( myDlg->myElemGeomBtn->isOn() ) // elem geomerty selection + { + myDlg->myElemGeomList->clear(); + myDlg->myElemGeomList->insertStringList( goodNames ); + myElemGeoIDs = goodIds; + } + else if ( myDlg->myNodeGeomBtn->isOn() ) // Node geomerty selection + { + myDlg->myNodeGeomList->clear(); + myDlg->myNodeGeomList->insertStringList( goodNames ); + myNodeGeoIDs = goodIds; + } + + // enable/diable Apply, which can change at selection + myDlg->updateButtons(); +} diff --git a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.h b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.h new file mode 100644 index 000000000..7a270c089 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.h @@ -0,0 +1,150 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : SMESHGUI_GroupOnShapeDlg.h +// Author : Edard AGAPOV +// Module : SMESH + +#ifndef SMESHGUI_GroupOnShapeDlg_H_H +#define SMESHGUI_GroupOnShapeDlg_H_H + +#include "SMESH_SMESHGUI.hxx" + +// #include "LightApp_SelectionMgr.h" +// //#include "SMESH_TypeFilter.hxx" +// #include "SUIT_SelectionFilter.h" +#include "SMESHGUI_SelectionOp.h" + +// // QT Includes +// #include +// #include + +class QLineEdit; +class QButtonGroup; +class QGroupBox; +class QListBox; +class QPopupMenu; +class QPushButton; +class QToolButton; +class QCheckBox; +class QWidgetStack; +class QtxIntSpinBox; +class SMESHGUI; +class SMESH_Actor; +class SMESHGUI_FilterDlg; +class SMESHGUI_ShapeByMeshOp; +class SUIT_Operation; +class SVTK_Selector; +class SVTK_ViewWindow; +class SMESHGUI_GroupOnShapeDlg; + +//================================================================================= +// class : SMESHGUI_GroupOnShapeOp +// purpose : create groups on shapes of nodes and element at once, Issue 19970 +//================================================================================= + +class SMESHGUI_EXPORT SMESHGUI_GroupOnShapeOp : public SMESHGUI_SelectionOp +{ + Q_OBJECT + +public: + SMESHGUI_GroupOnShapeOp(); + ~SMESHGUI_GroupOnShapeOp(); + + virtual LightApp_Dialog* dlg() const; + static QString GetDefaultName(const QString& theOperation); + +public slots: + +protected: + + virtual void startOperation(); + virtual void selectionDone(); + virtual SUIT_SelectionFilter* createFilter( const int ) const; + //virtual bool isValid( SUIT_Operation* ) const; + +private slots: + + bool onApply(); + void onButtonClick(); + + + void onSelectColor(); + void onAdd(); + void onRemove(); + + +private: + + void init(); + void setGroupColor( const SALOMEDS::Color& ); + SALOMEDS::Color getGroupColor() const; + + void setGroupQColor( const QColor& ); + QColor getGroupQColor() const; + + void setDefaultGroupColor(); + +private: + + SMESHGUI_GroupOnShapeDlg* myDlg; + + QString myMeshID; + QStringList myElemGeoIDs, myNodeGeoIDs; + //GEOM::ListOfGO_var myElemGObj; +}; + +class SMESHGUI_EXPORT SMESHGUI_GroupOnShapeDlg : public SMESHGUI_Dialog +{ + Q_OBJECT + +public: + SMESHGUI_GroupOnShapeDlg(); + +public slots: + + void updateButtons(); + void init(); + +private: + + QLineEdit* myGrpNameLine; + + QPushButton* myMeshBtn; + QLineEdit* myMeshLine; + + QPushButton* myElemGeomBtn; + QListBox* myElemGeomList; + + QPushButton* myNodeGeomBtn; + QListBox* myNodeGeomList; + +// QPushButton* myColorBtn; + +// bool myCreate, myIsBusy; + +// QString myHelpFileName; + + friend class SMESHGUI_GroupOnShapeOp; +}; + +#endif // SMESHGUI_GroupOnShapeDlg_H_H diff --git a/src/SMESHGUI/SMESH_images.po b/src/SMESHGUI/SMESH_images.po index aa4e9d782..64d9964ab 100644 --- a/src/SMESHGUI/SMESH_images.po +++ b/src/SMESHGUI/SMESH_images.po @@ -269,6 +269,9 @@ msgstr "mesh_edit_group.png" msgid "ICON_CONSTRUCT_GROUP" msgstr "mesh_make_group.png" +msgid "ICON_GEO_GROUP" +msgstr "mesh_groups_from_gemetry.png" + #----------------------------------------------------------- # Mesh pattern #----------------------------------------------------------- diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po index 41f9bd121..25beb47b1 100644 --- a/src/SMESHGUI/SMESH_msg_en.po +++ b/src/SMESHGUI/SMESH_msg_en.po @@ -368,6 +368,8 @@ msgstr "Mesh" msgid "SMESH_SUBMESH" msgstr "SubMesh" +msgid "SMESH_GEOM" +msgstr "Geometry" # -------------- Hypothesis / Algorithm -------------- @@ -972,6 +974,9 @@ msgstr "Used" msgid "SMESH_CREATE_GROUP_TITLE" msgstr "Create Group" +msgid "SMESH_CREATE_GROUP_FROM_GEOM" +msgstr "Create Groups from Geometry" + #Edit Group msgid "SMESH_EDIT_GROUP_TITLE" msgstr "Edit Group" @@ -2237,6 +2242,9 @@ msgstr "Edit Hypothesis" msgid "MEN_CREATE_GROUP" msgstr "Create Group" +msgid "MEN_CREATE_GEO_GROUP" +msgstr "Create Groups from Geometry" + msgid "MEN_CONSTRUCT_GROUP" msgstr "Construct Group" @@ -2611,6 +2619,9 @@ msgstr "Edit Hypothesis" msgid "TOP_CREATE_GROUP" msgstr "Create Group" +msgid "TOP_CREATE_GEO_GROUP" +msgstr "Create Groups from Geometry" + msgid "TOP_CONSTRUCT_GROUP" msgstr "Construct Group" @@ -2936,6 +2947,9 @@ msgstr "Edit Hypothesis" msgid "STB_CREATE_GROUP" msgstr "Create Group" +msgid "STB_CREATE_GEO_GROUP" +msgstr "Create Groups from Geometry" + msgid "STB_CONSTRUCT_GROUP" msgstr "Construct Group" -- 2.39.2