1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHGUI_StandardMeshInfosOp.cxx
25 // Author : Alexander SOLOVYOV
29 #include "SMESHGUI_StandardMeshInfosOp.h"
30 #include <SMESHGUI_StandardMeshInfosDlg.h>
31 #include <SMESHGUI_Utils.h>
34 #include <SMESH_TypeFilter.hxx>
36 #include <SUIT_OverrideCursor.h>
38 #include CORBA_SERVER_HEADER(SMESH_Gen)
39 #include CORBA_SERVER_HEADER(SMESH_Group)
41 #include <SALOMEDS_SObject.hxx>
43 //=================================================================================
44 // function : SMESHGUI_StandardMeshInfosOp()
45 // purpose : constructor
46 //=================================================================================
47 SMESHGUI_StandardMeshInfosOp::SMESHGUI_StandardMeshInfosOp()
48 : SMESHGUI_SelectionOp(),
53 //=================================================================================
54 // function : ~SMESHGUI_StandardMeshInfosOp()
55 // purpose : destructor
56 //=================================================================================
57 SMESHGUI_StandardMeshInfosOp::~SMESHGUI_StandardMeshInfosOp()
63 //=================================================================================
66 //=================================================================================
67 SalomeApp_Dialog* SMESHGUI_StandardMeshInfosOp::dlg() const
72 //=================================================================================
73 // function : startOperation
75 //=================================================================================
76 void SMESHGUI_StandardMeshInfosOp::startOperation()
79 myDlg = new SMESHGUI_StandardMeshInfosDlg();
81 SMESHGUI_SelectionOp::startOperation();
86 //=================================================================================
87 // function : createFilter
89 //=================================================================================
90 SUIT_SelectionFilter* SMESHGUI_StandardMeshInfosOp::createFilter( const int ) const
92 return new SMESH_TypeFilter( MESH );
95 //=================================================================================
96 // function : fillMeshInfos
98 //=================================================================================
99 void SMESHGUI_StandardMeshInfosOp::fillMeshInfos()
104 SUIT_OverrideCursor wc;
106 QStringList ids; myDlg->selectedObject( 0, ids );
109 myDlg->setInfo( "" );
113 _PTR(SObject) SO = studyDS()->FindObjectID( ids.first() ), anObj;
116 myDlg->setInfo( "" );
120 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( _CAST(SObject,SO)->GetObject() );
122 if( aMesh->_is_nil() )
124 myDlg->setInfo( "" );
130 int aNbNodes = (int)aMesh->NbNodes();
131 int aNbEdges = (int)aMesh->NbEdges();
132 int aNbFaces = (int)aMesh->NbFaces();
133 int aNbVolumes = (int)aMesh->NbVolumes();
136 double aNbDimElements = 0;
139 aNbDimElements = aNbVolumes;
142 else if( aNbFaces > 0 )
144 aNbDimElements = aNbFaces;
147 else if( aNbEdges > 0 )
149 aNbDimElements = aNbEdges;
152 else if( aNbNodes > 0 )
154 aNbDimElements = aNbNodes;
158 // information about the mesh
159 anInfo.append(QString("Nb of element of dimension %1:<b> %2</b><br>").arg(aDimension).arg(aNbDimElements));
160 anInfo.append(QString("Nb of nodes: <b>%1</b><br><br>").arg(aNbNodes));
162 bool hasGroup = false;
164 // info about groups on nodes
165 SO->FindSubObject( Tag_NodeGroups, anObj );
168 _PTR(ChildIterator) it = studyDS()->NewChildIterator(anObj);
171 anInfo.append(QString("Groups:<br><br>"));
174 for( ; it->More(); it->Next() )
176 _PTR(SObject) subObj = it->Value();
177 CORBA::Object_var anObject = SMESH::SObjectToObject(subObj);
178 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject);
179 if( !aGroup->_is_nil() )
181 anInfo.append(QString("- <b>%1</b><br>").arg(aGroup->GetName()));
182 anInfo.append(QString("%1<br>").arg("on nodes"));
183 anInfo.append(QString("%1<br>").arg(aGroup->Size()));
184 // check if the group based on geometry
185 SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup);
186 if (!aGroupOnGeom->_is_nil())
188 GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape();
189 QString aShapeName = "<unknown>";
190 _PTR(SObject) aGeomObj, aRef;
191 if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef))
192 aShapeName = aRef->GetName().c_str();
193 anInfo.append(QString("based on <i>%1</i> geometry object<br><br>").arg(aShapeName));
196 anInfo.append(QString("<br>"));
201 // info about groups on edges
203 SO->FindSubObject(Tag_EdgeGroups, anObj);
206 _PTR(ChildIterator) it = studyDS()->NewChildIterator(anObj);
207 if( !hasGroup && it->More() )
209 anInfo.append(QString("Groups:<br><br>"));
212 for( ; it->More(); it->Next() )
214 _PTR(SObject) subObj = it->Value();
215 CORBA::Object_var anObject = SMESH::SObjectToObject(subObj);
216 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject);
217 if( !aGroup->_is_nil() )
219 anInfo.append(QString("- <b>%1</b><br>").arg(aGroup->GetName()));
220 anInfo.append(QString("%1<br>").arg("on edges"));
221 anInfo.append(QString("%1<br>").arg(aGroup->Size()));
222 // check if the group based on geometry
223 SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup);
224 if( !aGroupOnGeom->_is_nil() )
226 GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape();
227 QString aShapeName = "<unknown>";
228 _PTR(SObject) aGeomObj, aRef;
229 if( subObj->FindSubObject( 1, aGeomObj ) && aGeomObj->ReferencedObject( aRef ) )
230 aShapeName = aRef->GetName().c_str();
231 anInfo.append(QString("based on <i>%1</i> geometry object<br><br>").arg(aShapeName));
234 anInfo.append(QString("<br>"));
239 // info about groups on faces
241 SO->FindSubObject( Tag_FaceGroups, anObj );
244 _PTR(ChildIterator) it = studyDS()->NewChildIterator(anObj);
245 if( !hasGroup && it->More() )
247 anInfo.append(QString("Groups:<br><br>"));
250 for( ; it->More(); it->Next() )
252 _PTR(SObject) subObj = it->Value();
253 CORBA::Object_var anObject = SMESH::SObjectToObject(subObj);
254 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject);
255 if( !aGroup->_is_nil() )
257 anInfo.append(QString("- <b>%1</b><br>").arg(aGroup->GetName()));
258 anInfo.append(QString("%1<br>").arg("on faces"));
259 anInfo.append(QString("%1<br>").arg(aGroup->Size()));
260 // check if the group based on geometry
261 SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup);
262 if( !aGroupOnGeom->_is_nil() )
264 GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape();
265 QString aShapeName = "<unknown>";
266 _PTR(SObject) aGeomObj, aRef;
267 if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef))
268 aShapeName = aRef->GetName().c_str();
269 anInfo.append(QString("based on <i>%1</i> geometry object<br><br>").arg(aShapeName));
272 anInfo.append(QString("<br>"));
277 // info about groups on volumes
279 SO->FindSubObject( Tag_VolumeGroups, anObj );
282 _PTR(ChildIterator) it = studyDS()->NewChildIterator(anObj);
283 if( !hasGroup && it->More() )
284 anInfo.append(QString("Groups:<br>"));
285 for( ; it->More(); it->Next() )
287 _PTR(SObject) subObj = it->Value();
288 CORBA::Object_var anObject = SMESH::SObjectToObject(subObj);
289 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject);
290 if( !aGroup->_is_nil() )
292 anInfo.append(QString("- <b>%1</b><br>").arg(aGroup->GetName()));
293 anInfo.append(QString("%1<br>").arg("on volumes"));
294 anInfo.append(QString("%1<br>").arg(aGroup->Size()));
295 // check if the group based on geometry
296 SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup);
297 if( !aGroupOnGeom->_is_nil() )
299 GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape();
300 QString aShapeName = "<unknown>";
301 _PTR(SObject) aGeomObj, aRef;
302 if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef))
303 aShapeName = aRef->GetName().c_str();
304 anInfo.append(QString("based on <i>%1</i> geometry object<br><br>").arg(aShapeName));
307 anInfo.append(QString("<br>"));
312 myDlg->setInfo(anInfo);
315 //=================================================================================
318 //=================================================================================
319 void SMESHGUI_StandardMeshInfosOp::onOk()
324 //=================================================================================
325 // function : onSelectionChanged
327 //=================================================================================
328 void SMESHGUI_StandardMeshInfosOp::onSelectionChanged( int )