Version: 6.3.1

src/SMESHGUI/SMESHGUI_WhatIsDlg.cxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // SMESH SMESHGUI : GUI for SMESH component
00021 // File   : SMESHGUI_WhatIsDlg.cxx
00022 // Author : Vladimir TURIN, Open CASCADE S.A.S.
00023 // SMESH includes
00024 //
00025 #include "SMESHGUI_WhatIsDlg.h"
00026 
00027 #include "SMESHGUI.h"
00028 #include "SMESHGUI_Utils.h"
00029 #include "SMESHGUI_VTKUtils.h"
00030 #include "SMESHGUI_MeshUtils.h"
00031 #include "SMESHGUI_IdValidator.h"
00032 
00033 #include "SMESH_Actor.h"
00034 #include "SMESH_TypeFilter.hxx"
00035 #include "SMESH_LogicalFilter.hxx"
00036 #include "SMDS_Mesh.hxx"
00037 #include "SMDS_VolumeTool.hxx"
00038 
00039 // SALOME GUI includes
00040 #include <SUIT_Desktop.h>
00041 #include <SUIT_ResourceMgr.h>
00042 #include <SUIT_Session.h>
00043 #include <SUIT_MessageBox.h>
00044 
00045 #include <LightApp_Application.h>
00046 #include <LightApp_SelectionMgr.h>
00047 
00048 #include <SVTK_ViewModel.h>
00049 #include <SVTK_Selection.h>
00050 #include <SVTK_ViewWindow.h>
00051 #include <SALOME_ListIO.hxx>
00052 #include <SALOME_ListIteratorOfListIO.hxx>
00053 
00054 // OCCT includes
00055 #include <TColStd_MapOfInteger.hxx>
00056 #include <gp_XYZ.hxx>
00057 
00058 // Qt includes
00059 #include <QButtonGroup>
00060 #include <QGroupBox>
00061 #include <QLabel>
00062 #include <QLineEdit>
00063 #include <QPushButton>
00064 #include <QRadioButton>
00065 #include <QTextBrowser>
00066 #include <QHBoxLayout>
00067 #include <QVBoxLayout>
00068 #include <QGridLayout>
00069 #include <QKeyEvent>
00070 
00071 // IDL includes
00072 #include <SALOMEconfig.h>
00073 #include CORBA_SERVER_HEADER(SMESH_Group)
00074 
00075 #define SPACING 6
00076 #define MARGIN  11
00077 
00078 //=================================================================================
00079 // class    : SMESHGUI_WhatIsDlg()
00080 // purpose  :
00081 //=================================================================================
00082 SMESHGUI_WhatIsDlg::SMESHGUI_WhatIsDlg( SMESHGUI* theModule )
00083   : QDialog( SMESH::GetDesktop( theModule ) ),
00084     mySMESHGUI( theModule ),
00085     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
00086 {
00087   setModal( false );
00088   setAttribute( Qt::WA_DeleteOnClose, true );
00089   setWindowTitle(tr("SMESH_WHAT_IS_TITLE"));
00090   setSizeGripEnabled(true);
00091   QVBoxLayout* SMESHGUI_WhatIsDlgLayout = new QVBoxLayout(this);
00092   SMESHGUI_WhatIsDlgLayout->setSpacing(SPACING);
00093   SMESHGUI_WhatIsDlgLayout->setMargin(MARGIN);
00094   
00095   /***************************************************************/
00096   GroupMesh = new QGroupBox(this);
00097   QHBoxLayout* GroupMeshLayout = new QHBoxLayout(GroupMesh);
00098   GroupMeshLayout->setSpacing(SPACING);
00099   GroupMeshLayout->setMargin(MARGIN);
00100 
00101   MeshLabel = new QLabel(tr("SMESH_NAME"), GroupMesh);
00102   GroupMeshLayout->addWidget(MeshLabel);
00103   MeshName = new QLineEdit(GroupMesh);
00104   MeshName->setReadOnly(true);
00105   GroupMeshLayout->addWidget(MeshName);
00106 
00107   /***************************************************************/
00108   GroupSelections = new QGroupBox(tr("ENTITY_TYPE"), this);
00109   QButtonGroup* GroupSel = new QButtonGroup(this);
00110   QHBoxLayout* GroupSelectionsLayout = new QHBoxLayout(GroupSelections);
00111   GroupSelectionsLayout->setSpacing(SPACING);
00112   GroupSelectionsLayout->setMargin(MARGIN);
00113 
00114   RadioButtonNodes = new QRadioButton(tr("SMESH_NODES"), GroupSelections);
00115   GroupSelectionsLayout->addWidget(RadioButtonNodes);
00116   GroupSel->addButton(RadioButtonNodes, 0);
00117   RadioButtonElements = new QRadioButton(tr("SMESH_ELEMENTS"), GroupSelections);
00118   GroupSelectionsLayout->addWidget(RadioButtonElements);
00119   GroupSel->addButton(RadioButtonElements, 1);
00120 
00121   /***************************************************************/
00122   GroupArguments = new QGroupBox(tr("SMESH_INFORMATION"), this);
00123   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
00124   GroupArgumentsLayout->setSpacing(SPACING);
00125   GroupArgumentsLayout->setMargin(MARGIN);
00126 
00127   // Controls for elements selection
00128   TextLabelElements  = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
00129   GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
00130 
00131   LineEditElements  = new QLineEdit(GroupArguments);
00132   LineEditElements->setValidator(new SMESHGUI_IdValidator(this));
00133   LineEditElements->setMaxLength(-1);
00134   GroupArgumentsLayout->addWidget(LineEditElements, 0, 1);
00135 
00136   // information text browser
00137   Info = new QTextBrowser(GroupArguments);
00138   Info->setMinimumSize(300, 200);
00139   GroupArgumentsLayout->addWidget(Info, 1, 0, 1, 2);
00140 
00141   /***************************************************************/
00142   GroupButtons = new QGroupBox(this);
00143   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
00144   GroupButtonsLayout->setSpacing(SPACING);
00145   GroupButtonsLayout->setMargin(MARGIN);
00146 
00147   buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons);
00148   buttonOk->setAutoDefault(true);
00149   buttonOk->setDefault(true);
00150   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
00151   buttonHelp->setAutoDefault(true);
00152 
00153   GroupButtonsLayout->addWidget(buttonOk);
00154   GroupButtonsLayout->addSpacing(10);
00155   GroupButtonsLayout->addStretch();
00156   GroupButtonsLayout->addWidget(buttonHelp);
00157 
00158   SMESHGUI_WhatIsDlgLayout->addWidget(GroupMesh);
00159   SMESHGUI_WhatIsDlgLayout->addWidget(GroupSelections);
00160   SMESHGUI_WhatIsDlgLayout->addWidget(GroupArguments);
00161   SMESHGUI_WhatIsDlgLayout->addWidget(GroupButtons);
00162 
00163   RadioButtonNodes->setChecked(true);
00164 
00165   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
00166 
00167   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
00168 
00169   // Costruction of the logical filter
00170   SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
00171   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
00172 
00173   QList<SUIT_SelectionFilter*> aListOfFilters;
00174   if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
00175   if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
00176 
00177   myMeshOrSubMeshOrGroupFilter =
00178     new SMESH_LogicalFilter(aListOfFilters, SMESH_LogicalFilter::LO_OR);
00179 
00180   myHelpFileName = "mesh_infos_page.html#mesh_element_info_anchor";
00181 
00182   Init();
00183 
00184   /* signals and slots connections */
00185   connect(buttonOk,         SIGNAL(clicked()),     this, SLOT(ClickOnOk()));
00186   connect(buttonHelp,       SIGNAL(clicked()),     this, SLOT(ClickOnHelp()));
00187   connect(GroupSel,         SIGNAL(buttonClicked(int)), SLOT(SelectionsClicked(int)));
00188 
00189   connect(mySMESHGUI,       SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
00190   connect(mySelectionMgr,   SIGNAL(currentSelectionChanged()),      this, SLOT(SelectionIntoArgument()));
00191   /* to close dialog if study change */
00192   connect(mySMESHGUI,       SIGNAL(SignalCloseAllDialogs()),  this, SLOT(ClickOnCancel()));
00193   connect(LineEditElements, SIGNAL(textChanged(const QString&)),    SLOT(onTextChange(const QString&)));
00194 
00195   SelectionsClicked(0);
00196   SelectionIntoArgument();
00197 }
00198 
00199 //=================================================================================
00200 // function : ~SMESHGUI_WhatIsDlg()
00201 // purpose  : Destroys the object and frees any allocated resources
00202 //=================================================================================
00203 SMESHGUI_WhatIsDlg::~SMESHGUI_WhatIsDlg()
00204 {
00205 }
00206 
00207 //=================================================================================
00208 // function : Init()
00209 // purpose  :
00210 //=================================================================================
00211 void SMESHGUI_WhatIsDlg::Init (bool ResetControls)
00212 {
00213   myBusy = false;
00214 
00215   LineEditElements->clear();
00216 
00217   myActor = 0;
00218   myMesh = SMESH::SMESH_Mesh::_nil();
00219 
00220   if (ResetControls) {
00221     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00222       aViewWindow->SetSelectionMode( CellSelection );
00223     onTextChange(LineEditElements->text());
00224     
00225     SelectionIntoArgument();
00226   }
00227 }
00228 
00229 //=================================================================================
00230 // function : SelectionsClicked()
00231 // purpose  : Radio button management
00232 //=================================================================================
00233 void SMESHGUI_WhatIsDlg::SelectionsClicked (int selectionId)
00234 {
00235   disconnect(mySelectionMgr, 0, this, 0);
00236 
00237   mySelectionMgr->clearFilters();
00238 
00239   switch (selectionId) {
00240   case 0:
00241     {
00242       SMESH::SetPointRepresentation(true);
00243       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00244         aViewWindow->SetSelectionMode( NodeSelection );
00245       break;
00246     }    
00247   case 1:
00248     {
00249       SMESH::SetPointRepresentation(false);
00250       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00251         aViewWindow->SetSelectionMode( CellSelection );
00252       break;
00253     }
00254   }
00255 
00256   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
00257   SelectionIntoArgument();
00258 }
00259 
00260 //=================================================================================
00261 // function : ClickOnOk()
00262 // purpose  :
00263 //=================================================================================
00264 void SMESHGUI_WhatIsDlg::ClickOnOk()
00265 {
00266   if (mySMESHGUI->isActiveStudyLocked())
00267     return;
00268 
00269   SMESH::UpdateView();
00270   Init(false);
00271   SelectionIntoArgument();
00272   ClickOnCancel();
00273 }
00274 
00275 //=================================================================================
00276 // function : ClickOnCancel()
00277 // purpose  :
00278 //=================================================================================
00279 void SMESHGUI_WhatIsDlg::ClickOnCancel()
00280 {
00281   disconnect(mySelectionMgr, 0, this, 0);
00282   mySelectionMgr->clearFilters();
00283   SMESH::SetPointRepresentation(false);
00284   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00285     aViewWindow->SetSelectionMode( ActorSelection );
00286   mySMESHGUI->ResetState();
00287   reject();
00288 }
00289 
00290 //=================================================================================
00291 // function : ClickOnHelp()
00292 // purpose  :
00293 //=================================================================================
00294 void SMESHGUI_WhatIsDlg::ClickOnHelp()
00295 {
00296   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
00297   if (app) 
00298     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
00299   else {
00300     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
00301                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
00302                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
00303                                                                  "application")).
00304                              arg(myHelpFileName));
00305   }
00306 }
00307 
00308 //=======================================================================
00309 // function : onTextChange()
00310 // purpose  :
00311 //=======================================================================
00312 void SMESHGUI_WhatIsDlg::onTextChange (const QString& theNewText)
00313 {
00314   if (myBusy) return;
00315   myBusy = true;
00316 
00317   // hilight entered elements
00318   SMDS_Mesh* aMesh = 0;
00319   if (myActor)
00320     aMesh = myActor->GetObject()->GetMesh();
00321 
00322   if (aMesh) {
00323     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
00324     
00325     TColStd_MapOfInteger newIndices;
00326 
00327     QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
00328 
00329     for (int i = 0; i < aListId.count(); i++) {
00330       const SMDS_MeshElement * e = RadioButtonNodes->isChecked()?
00331         aMesh->FindNode(aListId[ i ].toInt()):
00332         aMesh->FindElement(aListId[ i ].toInt());
00333       if (e)
00334         newIndices.Add(e->GetID());
00335     }
00336 
00337     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
00338     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00339       aViewWindow->highlight( anIO, true, true );
00340   }
00341 
00342   SelectionIntoArgument();
00343 
00344   myBusy = false;
00345 }
00346 
00347 //=================================================================================
00348 // function : SelectionIntoArgument()
00349 // purpose  : Called when selection as changed or other case
00350 //=================================================================================
00351 void SMESHGUI_WhatIsDlg::SelectionIntoArgument()
00352 {
00353   int curBusy = myBusy;
00354 
00355   // clear
00356   myActor = 0;
00357   QString aString = "";
00358 
00359   myBusy = true;
00360   if(!curBusy)
00361     LineEditElements->setText(aString);
00362   MeshName->setText(aString);
00363   GroupMesh->setTitle(tr(""));
00364   Info->clear();
00365   myBusy = curBusy;
00366 
00367   if (!GroupButtons->isEnabled()) // inactive
00368     return;
00369 
00370   // get selected mesh
00371   SALOME_ListIO aList;
00372   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
00373 
00374   int nbSel = aList.Extent();
00375 
00376   if (nbSel < 1)
00377     return;
00378 
00379   Handle(SALOME_InteractiveObject) IO = aList.First();
00380   myMesh = SMESH::GetMeshByIO(IO);
00381   if (myMesh->_is_nil())
00382     return;
00383 
00384   if (nbSel != 1) {
00385     //check if all selected objects belongs to one mesh
00386     SALOME_ListIteratorOfListIO io( aList );
00387     for (io.Next(); io.More(); io.Next() ) {
00388       SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(io.Value());
00389       if (!mesh->_is_nil() && !mesh->_is_equivalent( myMesh ))
00390         return;
00391     }
00392     // select IO with any element selected (for case of selection by rectangle)
00393     IO.Nullify();
00394     for (io.Initialize(aList); io.More() && IO.IsNull(); io.Next() )
00395       if ( mySelector->HasIndex( io.Value() ))
00396         IO = io.Value();
00397     if ( IO.IsNull() ) return;
00398     // unhilight others
00399     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
00400       for (io.Initialize(aList); io.More(); io.Next() )
00401         if ( !IO->isSame( io.Value() ))
00402           aViewWindow->highlight( io.Value(), false, true );
00403     }
00404   }
00405 
00406   myActor = SMESH::FindActorByObject(myMesh);
00407   if (!myActor)
00408     myActor = SMESH::FindActorByEntry(IO->getEntry());
00409   if (!myActor)
00410     return;
00411 
00412   QString aName = IO->getName();
00413   // cut off wite spaces from tail, else meaningful head is not visible
00414   int size = aName.length();
00415   while (size && aName.at(size-1).isSpace() )
00416     --size;
00417   if ( size != aName.length() )
00418     aName.truncate( size );
00419   MeshName->setText(aName); // can be something like "2 objects"
00420 
00421   if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) {
00422     GroupMesh->setTitle(tr("SMESH_MESH"));
00423   } else if(!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) {
00424     GroupMesh->setTitle(tr("SMESH_SUBMESH"));
00425   } else if(!SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) {
00426     GroupMesh->setTitle(tr("SMESH_GROUP"));
00427   }
00428 
00429   int aNbUnits = 0;
00430   
00431   aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
00432   
00433   if (aNbUnits < 1)
00434     return;
00435 
00436   const SMDS_MeshElement * e = RadioButtonNodes->isChecked()?
00437     myActor->GetObject()->GetMesh()->FindNode(aString.toInt()):
00438     myActor->GetObject()->GetMesh()->FindElement(aString.toInt());
00439   if (e) {
00440     QString anInfo;
00441     anInfo="<b>" + tr("ENTITY_TYPE") + ":</b> ";
00442     if(e->GetType() == SMDSAbs_Node) {
00443       anInfo+=tr("MESH_NODE")+"<br>";
00444       //const SMDS_MeshNode *en = (SMDS_MeshNode*) e; // VSR: not used!
00445     } else if (e->GetType() == SMDSAbs_0DElement) {
00446       anInfo+=tr("SMESH_ELEM0D")+"<br>";
00447     } else if(e->GetType() == SMDSAbs_Edge) {
00448       anInfo+=tr("SMESH_EDGE")+"<br>";
00449       anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";
00450       const SMDS_MeshEdge *ee = (SMDS_MeshEdge*) e;
00451       anInfo+=(ee->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+"<br>";
00452     } else if(e->GetType() == SMDSAbs_Face) {
00453       const SMDS_MeshFace *ef = (SMDS_MeshFace*) e;
00454       anInfo+=tr("SMESH_FACE")+"<br>";
00455       anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";
00456       if(!ef->IsPoly())
00457         anInfo+=(ef->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
00458       switch(ef->NbNodes()) {
00459       case 3:
00460       case 6:
00461         {
00462           anInfo+=tr("SMESH_TRIANGLE");
00463           break;
00464         }
00465       case 4:
00466       case 8:
00467         {
00468           anInfo+=tr("SMESH_QUADRANGLE");
00469           break;
00470         }
00471       default:
00472         break;
00473       }
00474       anInfo+="<br>";
00475     } else if(e->GetType() == SMDSAbs_Volume) {
00476       anInfo+=tr("SMESH_VOLUME")+"<br>";
00477       anInfo+="<b>" + tr("SMESH_MESHINFO_TYPE")+":</b> ";
00478       const SMDS_MeshVolume *ev = (SMDS_MeshVolume*) e;
00479       SMDS_VolumeTool vt(ev);
00480       if(vt.GetVolumeType() != SMDS_VolumeTool::POLYHEDA)
00481         anInfo+=(ev->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
00482       switch(vt.GetVolumeType()) {
00483       case SMDS_VolumeTool::TETRA:
00484       case SMDS_VolumeTool::QUAD_TETRA:
00485         {
00486           anInfo+=tr("SMESH_TETRAS");
00487           break;
00488         }
00489       case SMDS_VolumeTool::PYRAM:
00490       case SMDS_VolumeTool::QUAD_PYRAM:
00491         {
00492           anInfo+=tr("SMESH_PYRAMID");
00493           break;
00494         }
00495       case SMDS_VolumeTool::PENTA:
00496       case SMDS_VolumeTool::QUAD_PENTA:
00497         {
00498           anInfo+=tr("SMESH_PRISM");
00499           break;
00500         }
00501       case SMDS_VolumeTool::HEXA:
00502       case SMDS_VolumeTool::QUAD_HEXA:
00503         {
00504           anInfo+=tr("SMESH_HEXAS");
00505           break;
00506         }
00507       case SMDS_VolumeTool::POLYHEDA:
00508         {
00509           anInfo+=tr("SMESH_POLYEDRON");
00510           break;
00511         }
00512       default:
00513         break;
00514       }
00515       anInfo+="<br>";
00516     }
00517     gp_XYZ anXYZ(0.,0.,0.);
00518     SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
00519     int nbNodes = 0;
00520     QString aNodesInfo="";
00521     for( ; nodeIt->more(); nbNodes++) {
00522       const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
00523       anXYZ.Add( gp_XYZ( node->X(), node->Y(), node->Z() ) );
00524       if(e->GetType() != SMDSAbs_Node)
00525         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());
00526       // Calculate Connectivity
00527       SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
00528       if (it) {
00529         aNodesInfo+="<b>" + tr("CONNECTED_ELEMENTS") + ":</b>";
00530         while (it->more()) {
00531           const SMDS_MeshElement* elem = it->next();
00532           aNodesInfo+=QString(" %1").arg(elem->GetID());
00533         }
00534         if ( (nbNodes+1) != e->NbNodes())
00535           aNodesInfo+=QString("<br><br>");
00536       }
00537     }
00538     if(e->GetType() != SMDSAbs_Node)
00539       anInfo+="<b>" + tr("GRAVITY_CENTER") + ":</b><br>";
00540     anXYZ.Divide(e->NbNodes());
00541     anInfo+=QString("X=%1, Y=%2, Z=%3").arg(anXYZ.X()).arg(anXYZ.Y()).arg(anXYZ.Z());
00542     if(e->GetType() != SMDSAbs_Node)
00543       anInfo+="<br>";
00544     if (aNodesInfo!="")
00545       anInfo+= "<br>" + aNodesInfo;
00546     Info->setText(anInfo);
00547   }
00548 
00549   if(!curBusy) {
00550     myBusy = true;
00551     LineEditElements->setText(aString);
00552     myBusy = false;
00553   }
00554 }
00555 
00556 //=================================================================================
00557 // function : DeactivateActiveDialog()
00558 // purpose  :
00559 //=================================================================================
00560 void SMESHGUI_WhatIsDlg::DeactivateActiveDialog()
00561 {
00562   if (GroupArguments->isEnabled()) {
00563     GroupSelections->setEnabled(false);
00564     GroupMesh->setEnabled(false);
00565     GroupArguments->setEnabled(false);
00566     GroupButtons->setEnabled(false);
00567     mySMESHGUI->ResetState();
00568     mySMESHGUI->SetActiveDialogBox(0);
00569   }
00570 }
00571 
00572 //=================================================================================
00573 // function : ActivateThisDialog()
00574 // purpose  :
00575 //=================================================================================
00576 void SMESHGUI_WhatIsDlg::ActivateThisDialog()
00577 {
00578   /* Emit a signal to deactivate the active dialog */
00579   mySMESHGUI->EmitSignalDeactivateDialog();
00580   GroupArguments->setEnabled(true);
00581   GroupButtons->setEnabled(true);
00582   GroupSelections->setEnabled(true);
00583   GroupMesh->setEnabled(true);
00584 
00585   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
00586 
00587   if ( SMESH::GetViewWindow( mySMESHGUI ))
00588     SelectionsClicked(RadioButtonNodes->isChecked()?0:1);
00589 
00590   SelectionIntoArgument();
00591 }
00592 
00593 //=================================================================================
00594 // function : enterEvent()
00595 // purpose  :
00596 //=================================================================================
00597 void SMESHGUI_WhatIsDlg::enterEvent (QEvent*)
00598 {
00599   if (!GroupArguments->isEnabled())
00600     ActivateThisDialog();
00601 }
00602 
00603 //=================================================================================
00604 // function : closeEvent()
00605 // purpose  :
00606 //=================================================================================
00607 void SMESHGUI_WhatIsDlg::closeEvent (QCloseEvent*)
00608 {
00609   /* same than click on cancel button */
00610   ClickOnCancel();
00611 }
00612 
00613 //=======================================================================
00614 //function : hideEvent
00615 //purpose  : caused by ESC key
00616 //=======================================================================
00617 void SMESHGUI_WhatIsDlg::hideEvent (QHideEvent*)
00618 {
00619   if (!isMinimized())
00620     ClickOnCancel();
00621 }
00622 
00623 //=================================================================================
00624 // function : keyPressEvent()
00625 // purpose  :
00626 //=================================================================================
00627 void SMESHGUI_WhatIsDlg::keyPressEvent( QKeyEvent* e )
00628 {
00629   QDialog::keyPressEvent( e );
00630   if ( e->isAccepted() )
00631     return;
00632 
00633   if ( e->key() == Qt::Key_F1 ) {
00634     e->accept();
00635     ClickOnHelp();
00636   }
00637 }
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS