Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_WhatIsDlg.cxx
index 2e62e9c5c43fbeafca5fb419e2419a14578f22f4..8806dd7060513c033d34b85392c412ec00cbf4b1 100755 (executable)
@@ -1,24 +1,22 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 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 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.
 //
-//  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
 //
-//  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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // SMESH SMESHGUI : GUI for SMESH component
 // File   : SMESHGUI_WhatIsDlg.cxx
 // Author : Vladimir TURIN, Open CASCADE S.A.S.
@@ -132,11 +130,12 @@ SMESHGUI_WhatIsDlg::SMESHGUI_WhatIsDlg( SMESHGUI* theModule )
 
   LineEditElements  = new QLineEdit(GroupArguments);
   LineEditElements->setValidator(new SMESHGUI_IdValidator(this));
+  LineEditElements->setMaxLength(-1);
   GroupArgumentsLayout->addWidget(LineEditElements, 0, 1);
 
   // information text browser
   Info = new QTextBrowser(GroupArguments);
-  Info->setMinimumSize(200, 150);
+  Info->setMinimumSize(300, 200);
   GroupArgumentsLayout->addWidget(Info, 1, 0, 1, 2);
 
   /***************************************************************/
@@ -242,14 +241,14 @@ void SMESHGUI_WhatIsDlg::SelectionsClicked (int selectionId)
     {
       SMESH::SetPointRepresentation(true);
       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-       aViewWindow->SetSelectionMode( NodeSelection );
+        aViewWindow->SetSelectionMode( NodeSelection );
       break;
     }    
   case 1:
     {
       SMESH::SetPointRepresentation(false);
       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
-       aViewWindow->SetSelectionMode( CellSelection );
+        aViewWindow->SetSelectionMode( CellSelection );
       break;
     }
   }
@@ -299,10 +298,10 @@ void SMESHGUI_WhatIsDlg::ClickOnHelp()
     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
   else {
     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
-                            tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
-                            arg(app->resourceMgr()->stringValue("ExternalBrowser",
-                                                                "application")).
-                            arg(myHelpFileName));
+                             tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                             arg(app->resourceMgr()->stringValue("ExternalBrowser",
+                                                                 "application")).
+                             arg(myHelpFileName));
   }
 }
 
@@ -329,10 +328,10 @@ void SMESHGUI_WhatIsDlg::onTextChange (const QString& theNewText)
 
     for (int i = 0; i < aListId.count(); i++) {
       const SMDS_MeshElement * e = RadioButtonNodes->isChecked()?
-       aMesh->FindNode(aListId[ i ].toInt()):
-       aMesh->FindElement(aListId[ i ].toInt());
+        aMesh->FindNode(aListId[ i ].toInt()):
+        aMesh->FindElement(aListId[ i ].toInt());
       if (e)
-       newIndices.Add(e->GetID());
+        newIndices.Add(e->GetID());
     }
 
     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
@@ -439,91 +438,111 @@ void SMESHGUI_WhatIsDlg::SelectionIntoArgument()
     myActor->GetObject()->GetMesh()->FindElement(aString.toInt());
   if (e) {
     QString anInfo;
-    anInfo=tr("ENTITY_TYPE") + ": ";
+    anInfo="<b>" + tr("ENTITY_TYPE") + ":</b> ";
     if(e->GetType() == SMDSAbs_Node) {
-      anInfo+=tr("MESH_NODE")+"\n";
+      anInfo+=tr("MESH_NODE")+"<br>";
       //const SMDS_MeshNode *en = (SMDS_MeshNode*) e; // VSR: not used!
+    } else if (e->GetType() == SMDSAbs_0DElement) {
+      anInfo+=tr("SMESH_ELEM0D")+"<br>";
     } else if(e->GetType() == SMDSAbs_Edge) {
-      anInfo+=tr("SMESH_EDGE")+"\n";
-      anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
+      anInfo+=tr("SMESH_EDGE")+"<br>";
+      anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";
       const SMDS_MeshEdge *ee = (SMDS_MeshEdge*) e;
-      anInfo+=(ee->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+"\n";
+      anInfo+=(ee->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+"<br>";
     } else if(e->GetType() == SMDSAbs_Face) {
       const SMDS_MeshFace *ef = (SMDS_MeshFace*) e;
-      anInfo+=tr("SMESH_FACE")+"\n";
-      anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
+      anInfo+=tr("SMESH_FACE")+"<br>";
+      anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";
       if(!ef->IsPoly())
-       anInfo+=(ef->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
+        anInfo+=(ef->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
       switch(ef->NbNodes()) {
       case 3:
       case 6:
-       {
-         anInfo+=tr("SMESH_TRIANGLE");
-         break;
-       }
+        {
+          anInfo+=tr("SMESH_TRIANGLE");
+          break;
+        }
       case 4:
       case 8:
-       {
-         anInfo+=tr("SMESH_QUADRANGLE");
-         break;
-       }
+        {
+          anInfo+=tr("SMESH_QUADRANGLE");
+          break;
+        }
       default:
-       break;
+        break;
       }
-      anInfo+="\n";
+      anInfo+="<br>";
     } else if(e->GetType() == SMDSAbs_Volume) {
-      anInfo+=tr("SMESH_VOLUME")+"\n";
-      anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
+      anInfo+=tr("SMESH_VOLUME")+"<br>";
+      anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";
       const SMDS_MeshVolume *ev = (SMDS_MeshVolume*) e;
       SMDS_VolumeTool vt(ev);
       if(vt.GetVolumeType() != SMDS_VolumeTool::POLYHEDA)
-       anInfo+=(ev->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
+        anInfo+=(ev->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
       switch(vt.GetVolumeType()) {
       case SMDS_VolumeTool::TETRA:
       case SMDS_VolumeTool::QUAD_TETRA:
-       {
-         anInfo+=tr("SMESH_TETRAS");
-         break;
-       }
+        {
+          anInfo+=tr("SMESH_TETRAS");
+          break;
+        }
       case SMDS_VolumeTool::PYRAM:
       case SMDS_VolumeTool::QUAD_PYRAM:
-       {
-         anInfo+=tr("SMESH_PYRAMID");
-         break;
-       }
+        {
+          anInfo+=tr("SMESH_PYRAMID");
+          break;
+        }
       case SMDS_VolumeTool::PENTA:
       case SMDS_VolumeTool::QUAD_PENTA:
-       {
-         anInfo+=tr("SMESH_PRISM");
-         break;
-       }
+        {
+          anInfo+=tr("SMESH_PRISM");
+          break;
+        }
       case SMDS_VolumeTool::HEXA:
       case SMDS_VolumeTool::QUAD_HEXA:
-       {
-         anInfo+=tr("SMESH_HEXAS");
-         break;
-       }
+        {
+          anInfo+=tr("SMESH_HEXAS");
+          break;
+        }
       case SMDS_VolumeTool::POLYHEDA:
-       {
-         anInfo+=tr("SMESH_POLYEDRON");
-         break;
-       }
+        {
+          anInfo+=tr("SMESH_POLYEDRON");
+          break;
+        }
       default:
-       break;
+        break;
       }
-      anInfo+="\n";
+      anInfo+="<br>";
     }
-    if(e->GetType() != SMDSAbs_Node)
-      anInfo+=tr("GRAVITY_CENTER") + ":\n";
     gp_XYZ anXYZ(0.,0.,0.);
     SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
     int nbNodes = 0;
+    QString aNodesInfo="";
     for( ; nodeIt->more(); nbNodes++) {
       const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
       anXYZ.Add( gp_XYZ( node->X(), node->Y(), node->Z() ) );
+      if(e->GetType() != SMDSAbs_Node)
+        aNodesInfo+=QString("<b>Node %1:</b><br>Id=%2, X=%3, Y=%4, Z=%5<br>").arg(nbNodes+1).arg(node->GetID()).arg(node->X()).arg(node->Y()).arg(node->Z());
+      // Calculate Connectivity
+      SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
+      if (it) {
+        aNodesInfo+="<b>" + tr("CONNECTED_ELEMENTS") + ":</b>";
+        while (it->more()) {
+          const SMDS_MeshElement* elem = it->next();
+          aNodesInfo+=QString(" %1").arg(elem->GetID());
+        }
+        if ( (nbNodes+1) != e->NbNodes())
+          aNodesInfo+=QString("<br><br>");
+      }
     }
+    if(e->GetType() != SMDSAbs_Node)
+      anInfo+="<b>" + tr("GRAVITY_CENTER") + ":</b><br>";
     anXYZ.Divide(e->NbNodes());
-    anInfo+=QString("X=%1\nY=%2\nZ=%3\n").arg(anXYZ.X()).arg(anXYZ.Y()).arg(anXYZ.Z());
+    anInfo+=QString("X=%1, Y=%2, Z=%3").arg(anXYZ.X()).arg(anXYZ.Y()).arg(anXYZ.Z());
+    if(e->GetType() != SMDSAbs_Node)
+      anInfo+="<br>";
+    if (aNodesInfo!="")
+      anInfo+= "<br>" + aNodesInfo;
     Info->setText(anInfo);
   }