Back to index

salome-smesh  6.5.0
SMESHGUI.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  File   : SMESHGUI.cxx
00023 //  Author : Nicolas REJNERI, Open CASCADE S.A.S.
00024 
00025 #include <Standard_math.hxx>  // E.A. must be included before Python.h to fix compilation on windows
00026 #ifdef HAVE_FINITE
00027 #undef HAVE_FINITE            // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
00028 #endif
00029 #include "Python.h"
00030 //  SMESH includes
00031 #include "SMESHGUI.h"
00032 #include "SMESHGUI_AddMeshElementDlg.h"
00033 #include "SMESHGUI_AddQuadraticElementDlg.h"
00034 #include "SMESHGUI_BuildCompoundDlg.h"
00035 #include "SMESHGUI_ClippingDlg.h"
00036 #include "SMESHGUI_ComputeDlg.h"
00037 #include "SMESHGUI_ConvToQuadOp.h"
00038 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
00039 #include "SMESHGUI_DeleteGroupDlg.h"
00040 #include "SMESHGUI_Displayer.h"
00041 #include "SMESHGUI_MergeDlg.h"
00042 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
00043 #include "SMESHGUI_ExtrusionDlg.h"
00044 #include "SMESHGUI_FileInfoDlg.h"
00045 #include "SMESHGUI_FileValidator.h"
00046 #include "SMESHGUI_FilterDlg.h"
00047 #include "SMESHGUI_FilterLibraryDlg.h"
00048 #include "SMESHGUI_FindElemByPointDlg.h"
00049 #include "SMESHGUI_GroupDlg.h"
00050 #include "SMESHGUI_GroupOnShapeDlg.h"
00051 #include "SMESHGUI_GroupOpDlg.h"
00052 #include "SMESHGUI_Hypotheses.h"
00053 #include "SMESHGUI_Make2DFrom3DOp.h"
00054 #include "SMESHGUI_MakeNodeAtPointDlg.h"
00055 #include "SMESHGUI_Measurements.h"
00056 #include "SMESHGUI_MeshInfo.h"
00057 #include "SMESHGUI_MeshOp.h"
00058 #include "SMESHGUI_MeshOrderOp.h"
00059 #include "SMESHGUI_MeshPatternDlg.h"
00060 #include "SMESHGUI_MultiEditDlg.h"
00061 #include "SMESHGUI_NodesDlg.h"
00062 #include "SMESHGUI_Preferences_ColorDlg.h"
00063 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
00064 #include "SMESHGUI_RemoveElementsDlg.h"
00065 #include "SMESHGUI_RemoveNodesDlg.h"
00066 #include "SMESHGUI_RenumberingDlg.h"
00067 #include "SMESHGUI_RevolutionDlg.h"
00068 #include "SMESHGUI_RotationDlg.h"
00069 #include "SMESHGUI_Selection.h"
00070 #include "SMESHGUI_SewingDlg.h"
00071 #include "SMESHGUI_SingleEditDlg.h"
00072 #include "SMESHGUI_SmoothingDlg.h"
00073 #include "SMESHGUI_SymmetryDlg.h"
00074 #include "SMESHGUI_TranslationDlg.h"
00075 #include "SMESHGUI_ScaleDlg.h"
00076 #include "SMESHGUI_TransparencyDlg.h"
00077 #include "SMESHGUI_DuplicateNodesDlg.h"
00078 #include "SMESHGUI_CopyMeshDlg.h"
00079 
00080 #include "SMESHGUI_Utils.h"
00081 #include "SMESHGUI_MeshUtils.h"
00082 #include "SMESHGUI_GroupUtils.h"
00083 #include "SMESHGUI_FilterUtils.h"
00084 #include "SMESHGUI_PatternUtils.h"
00085 #include "SMESHGUI_VTKUtils.h"
00086 #include "SMESHGUI_HypothesesUtils.h"
00087 
00088 #include <SMESH_version.h>
00089 
00090 #include <SMESH_Client.hxx>
00091 #include <SMESH_Actor.h>
00092 #include <SMESH_ScalarBarActor.h>
00093 #include <SMESH_ActorUtils.h>
00094 #include <SMESH_TypeFilter.hxx>
00095 #include "SMESH_ControlsDef.hxx"
00096 
00097 // SALOME GUI includes
00098 #include <SalomeApp_Tools.h>
00099 #include <SalomeApp_Study.h>
00100 #include <SalomeApp_Application.h>
00101 #include <SalomeApp_CheckFileDlg.h>
00102 #include <SalomeApp_DataObject.h>
00103 
00104 #include <LightApp_DataOwner.h>
00105 #include <LightApp_Preferences.h>
00106 #include <LightApp_SelectionMgr.h>
00107 #include <LightApp_UpdateFlags.h>
00108 #include <LightApp_NameDlg.h>
00109 
00110 #include <SVTK_ViewWindow.h>
00111 #include <SVTK_ViewModel.h>
00112 #include <SVTK_ViewManager.h>
00113 
00114 #include <VTKViewer_Algorithm.h>
00115 
00116 #include <SUIT_MessageBox.h>
00117 #include <SUIT_ResourceMgr.h>
00118 #include <SUIT_FileDlg.h>
00119 #include <SUIT_Desktop.h>
00120 #include <SUIT_OverrideCursor.h>
00121 #include <SUIT_Session.h>
00122 
00123 #include <QtxPopupMgr.h>
00124 #include <QtxFontEdit.h>
00125 
00126 #include <SALOME_ListIO.hxx>
00127 #include <SALOME_ListIteratorOfListIO.hxx>
00128 
00129 #ifndef DISABLE_PLOT2DVIEWER
00130 #include <SPlot2d_ViewModel.h>
00131 #include <SPlot2d_Histogram.h>
00132 #endif
00133 
00134 // IDL includes
00135 #include <SALOMEconfig.h>
00136 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
00137 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
00138 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
00139 
00140 // Qt includes
00141 // #define       INCLUDE_MENUITEM_DEF // VSR commented ????????
00142 #include <QApplication>
00143 #include <QMenu>
00144 #include <QTextStream>
00145 
00146 // BOOST includes
00147 #include <boost/shared_ptr.hpp>
00148 
00149 // VTK includes
00150 #include <vtkCamera.h>
00151 #include <vtkRenderer.h>
00152 #include <vtkPlane.h>
00153 #include <vtkCallbackCommand.h>
00154 #include <vtkLookupTable.h>
00155 
00156 // SALOME KERNEL includes
00157 #include <SALOMEDS_Study.hxx>
00158 #include <SALOMEDSClient_StudyBuilder.hxx>
00159 #include <SALOMEDSClient_SComponent.hxx>
00160 #include <SALOMEDSClient_ClientFactory.hxx>
00161 #include <SALOMEDSClient_IParameters.hxx>
00162 
00163 // OCCT includes
00164 #include <Standard_ErrorHandler.hxx>
00165 #include <NCollection_DataMap.hxx>
00166 
00167 //To disable automatic genericobj management, the following line should be commented.
00168 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
00169 #define WITHGENERICOBJ
00170 
00171 //namespace{
00172   // Declarations
00173   //=============================================================
00174   void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
00175                             int theCommandID);
00176 
00177   void ExportMeshToFile(int theCommandID);
00178 
00179   void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
00180 
00181   void SetDisplayEntity(int theCommandID);
00182 
00183   void Control( int theCommandID );
00184 
00185 
00186   // Definitions
00187   //=============================================================
00188   void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
00189                              int theCommandID )
00190   {
00191     QStringList filter;
00192     std::string myExtension;
00193 
00194     if ( theCommandID == 113 ) {
00195       filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
00196       filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
00197     }
00198     else if ( theCommandID == 112 ) {
00199       filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
00200     }
00201     else if ( theCommandID == 111 ) {
00202       filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
00203     }
00204     else if ( theCommandID == 115 ) {
00205       filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
00206     }
00207     else if ( theCommandID == 116 ) {
00208       filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
00209     }
00210     else if ( theCommandID == 117 ) {
00211       filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
00212       filter.append( QObject::tr( "All files (*)" ) );
00213     }
00214 
00215     QString anInitialPath = "";
00216     if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
00217       anInitialPath = QDir::currentPath();
00218 
00219     QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
00220                                                             anInitialPath,
00221                                                             filter,
00222                                                             QObject::tr( "SMESH_IMPORT_MESH" ) );
00223     if ( filenames.count() > 0 ) {
00224       SUIT_OverrideCursor wc;
00225       _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
00226 
00227       QStringList errors;
00228       QStringList anEntryList;
00229       bool isEmpty = false;
00230       for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
00231         QString filename = *it;
00232         SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
00233         try {
00234           switch ( theCommandID ) {
00235           case 111:
00236             {
00237               // DAT format (currently unsupported)
00238               errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
00239                              arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
00240               break;
00241             }
00242           case 112:
00243             {
00244               // UNV format
00245               aMeshes->length( 1 );
00246               aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
00247               if ( aMeshes[0]->_is_nil() )
00248                 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
00249                                arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
00250               break;
00251             }
00252           case 113:
00253             {
00254               // MED format
00255               SMESH::DriverMED_ReadStatus res;
00256               aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
00257               if ( res != SMESH::DRS_OK ) {
00258                 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
00259                                arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
00260               }
00261               break;
00262             }
00263           case 115:
00264             {
00265               // STL format
00266               aMeshes->length( 1 );
00267               aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
00268               if ( aMeshes[0]->_is_nil() ) {
00269                 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
00270                                arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
00271               }
00272               break;
00273             }
00274           case 116:
00275             {
00276               // CGNS format
00277               SMESH::DriverMED_ReadStatus res;
00278               aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
00279               if ( res != SMESH::DRS_OK ) {
00280                 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
00281                                arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
00282               }
00283               break;
00284             }
00285           case 117:
00286             {
00287               // SAUV format
00288               SMESH::DriverMED_ReadStatus res;
00289               aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
00290               if ( res != SMESH::DRS_OK ) {
00291                 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
00292                                arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
00293               }
00294               break;
00295             }
00296           }
00297         }
00298         catch ( const SALOME::SALOME_Exception& S_ex ) {
00299           errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
00300                          arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
00301         }
00302 
00303         for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
00304           _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
00305           if ( aMeshSO ) {
00306             _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
00307             _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
00308             aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
00309             if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
00310               SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
00311 
00312             anEntryList.append( aMeshSO->GetID().c_str() );
00313 
00314 #ifdef WITHGENERICOBJ
00315             // obj has been published in study. Its refcount has been incremented.
00316             // It is safe to decrement its refcount
00317             // so that it will be destroyed when the entry in study will be removed
00318             aMeshes[i]->UnRegister();
00319 #endif
00320           }
00321           else {
00322             isEmpty = true;
00323           }
00324         }
00325       }
00326 
00327       // update Object browser
00328       SMESHGUI::GetSMESHGUI()->updateObjBrowser();
00329 
00330       // browse to the published meshes
00331       if( LightApp_Application* anApp =
00332           dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
00333         anApp->browseObjects( anEntryList );
00334 
00335       // show Error message box if there were errors
00336       if ( errors.count() > 0 ) {
00337         SUIT_MessageBox::critical( SMESHGUI::desktop(),
00338                                    QObject::tr( "SMESH_ERROR" ),
00339                                    QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
00340       }
00341 
00342       // show warning message box, if some imported mesh is empty
00343       if ( isEmpty ) {
00344           SUIT_MessageBox::warning( SMESHGUI::desktop(),
00345                                     QObject::tr( "SMESH_WRN_WARNING" ),
00346                                     QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
00347       }
00348     }
00349   }
00350 
00351   //================================================================================
00355   //================================================================================
00356 
00357   void ExportMeshToFile( int theCommandID )
00358   {
00359     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
00360     SALOME_ListIO selected;
00361     if( aSel )
00362       aSel->selectedObjects( selected );
00363 
00364     const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
00365     const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
00366     const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
00367     const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
00368     const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
00369     const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
00370 
00371     // actually, the following condition can't be met (added for insurance)
00372     if( selected.Extent() == 0 ||
00373         ( selected.Extent() > 1 && !isMED && !isSTL ))
00374       return;
00375 
00376     // get mesh object from selection and check duplication of their names
00377     bool hasDuplicatedMeshNames = false;
00378     QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
00379     QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
00380     SALOME_ListIteratorOfListIO It( selected );
00381     for( ; It.More(); It.Next() )
00382     {
00383       Handle(SALOME_InteractiveObject) anIObject = It.Value();
00384       SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
00385       if ( aMeshItem->_is_nil() ) {
00386         SUIT_MessageBox::warning( SMESHGUI::desktop(),
00387                                   QObject::tr( "SMESH_WRN_WARNING" ),
00388                                   QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
00389         return;
00390       }
00391 
00392       QString aMeshName = anIObject->getName();
00393 
00394       // check for name duplications
00395       if ( !hasDuplicatedMeshNames )
00396         for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
00397           if( aMeshName == (*aMeshIter).second ) {
00398             hasDuplicatedMeshNames = true;
00399             break;
00400           }
00401         }
00402 
00403       aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
00404     }
00405 
00406     if( hasDuplicatedMeshNames && isMED ) {
00407       int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
00408                                           QObject::tr("SMESH_WRN_WARNING"),
00409                                           QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
00410                                           QObject::tr("SMESH_BUT_YES"),
00411                                           QObject::tr("SMESH_BUT_NO"), 0, 1);
00412       if (aRet != 0)
00413         return;
00414     }
00415 
00416     aMeshIter = aMeshList.begin();
00417     SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
00418     SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
00419     QString aMeshName = (*aMeshIter).second;
00420 
00421     if ( isMED || isCGNS || isSAUV )
00422     {
00423       // check for equal group names within each mesh
00424       for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
00425         SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
00426         if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
00427           int aRet = SUIT_MessageBox::warning
00428             (SMESHGUI::desktop(),
00429              QObject::tr("SMESH_WRN_WARNING"),
00430              QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
00431              QObject::tr("SMESH_BUT_YES"),
00432              QObject::tr("SMESH_BUT_NO"), 0, 1);
00433           if (aRet != 0)
00434             return;
00435         }
00436       }
00437     }
00438     else if ( isUNV )
00439     {
00440       // warn the user about presence of not supported elements
00441       SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
00442       int nbNotSupported = ( nbElems[ SMESH::Entity_Pyramid ] +
00443                              nbElems[ SMESH::Entity_Quad_Pyramid ] +
00444                              nbElems[ SMESH::Entity_Hexagonal_Prism ] +
00445                              nbElems[ SMESH::Entity_Polygon ] +
00446                              nbElems[ SMESH::Entity_Polyhedra ] );
00447       if ( nbNotSupported > 0 ) {
00448         int aRet = SUIT_MessageBox::warning
00449           (SMESHGUI::desktop(),
00450            QObject::tr("SMESH_WRN_WARNING"),
00451            QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
00452            QObject::tr("SMESH_BUT_YES"),
00453            QObject::tr("SMESH_BUT_NO"), 0, 1);
00454         if (aRet != 0)
00455           return;
00456       }
00457     }
00458 
00459     // Get parameters of export operation
00460 
00461     QString aFilename;
00462     SMESH::MED_VERSION aFormat;
00463     // Init the parameters with the default values
00464     bool aIsASCII_STL = true;
00465     bool toCreateGroups = false;
00466     SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
00467     if ( resMgr )
00468       toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
00469     bool toOverwrite = true;
00470 
00471     QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
00472     QString anInitialPath = "";
00473     if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
00474       anInitialPath = QDir::currentPath();
00475 
00476     if ( isUNV || isDAT )
00477     {
00478       if ( isUNV )
00479         aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
00480       else
00481         aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
00482       if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
00483       aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
00484                                             anInitialPath + QString("/") + aMeshName,
00485                                             aFilter, aTitle, false);
00486     }
00487     else if ( isCGNS )// Export to CGNS
00488     {
00489       SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
00490       fd->setWindowTitle( aTitle );
00491       fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
00492       if ( !anInitialPath.isEmpty() )
00493         fd->setDirectory( anInitialPath );
00494       fd->selectFile(aMeshName);
00495       SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
00496       fd->setValidator( fv );
00497 
00498       if ( fd->exec() )
00499         aFilename = fd->selectedFile();
00500       toOverwrite = fv->isOverwrite();
00501 
00502       delete fd;
00503     }
00504     else if ( isSTL ) // Export to STL
00505     {
00506       QMap<QString, int> aFilterMap;
00507       aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
00508       aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" )   + " (*.stl)", 0 );
00509 
00510       QStringList filters;
00511       QMap<QString, int>::const_iterator it = aFilterMap.begin();
00512       for ( ; it != aFilterMap.end(); ++it )
00513         filters.push_back( it.key() );
00514 
00515       SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
00516       fd->setWindowTitle( aTitle );
00517       fd->setNameFilters( filters );
00518       fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
00519       if ( !anInitialPath.isEmpty() )
00520         fd->setDirectory( anInitialPath );
00521       fd->selectFile(aMeshName);
00522       bool is_ok = false;
00523       while (!is_ok) {
00524         if ( fd->exec() )
00525           aFilename = fd->selectedFile();
00526         aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
00527         is_ok = true;
00528       }
00529       delete fd;
00530     }
00531     else if ( isMED || isSAUV ) // Export to MED or SAUV
00532     {
00533       QMap<QString, SMESH::MED_VERSION> aFilterMap;
00534       //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
00535       if ( isMED ) {
00536         QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
00537         //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
00538         aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
00539       }
00540       else { // isSAUV
00541         aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
00542         aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
00543         aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
00544       }
00545 
00546       QStringList filters;
00547       QString aDefaultFilter;
00548       QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
00549       for ( ; it != aFilterMap.end(); ++it ) {
00550         filters.push_back( it.key() );
00551         if (it.value() == SMESH::MED_V2_2)
00552           aDefaultFilter = it.key();
00553       }
00554 
00555       SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
00556         ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
00557       fd->setWindowTitle( aTitle );
00558       fd->setNameFilters( filters );
00559       fd->selectNameFilter(aDefaultFilter);
00560       fd->SetChecked(toCreateGroups);
00561       if ( !anInitialPath.isEmpty() )
00562         fd->setDirectory( anInitialPath );
00563       fd->selectFile(aMeshName);
00564 
00565       SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
00566       fd->setValidator( fv );
00567 
00568       bool is_ok = false;
00569       while (!is_ok) {
00570         if ( fd->exec() )
00571           aFilename = fd->selectedFile();
00572         else {
00573           aFilename = QString::null;
00574           break;
00575         }
00576         aFormat = aFilterMap[fd->selectedNameFilter()];
00577         toOverwrite = fv->isOverwrite();
00578         is_ok = true;
00579         if ( !aFilename.isEmpty() ) {
00580           // med-2.1 does not support poly elements
00581           if ( aFormat==SMESH::MED_V2_1 )
00582             for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
00583               SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
00584               SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
00585               if ( nbElems[ SMESH::Entity_Polygon   ] + nbElems[ SMESH::Entity_Quad_Polygon   ] +
00586                    nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
00587               {
00588                 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
00589                                                     QObject::tr("SMESH_WRN_WARNING"),
00590                                                     QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
00591                                                     QObject::tr("SMESH_BUT_YES"),
00592                                                     QObject::tr("SMESH_BUT_NO"), 0, 1);
00593                 if (aRet != 0) {
00594                   is_ok = false;
00595                   break;
00596                 }
00597               }
00598             }
00599           if( !toOverwrite ) {
00600             // can't append to an existing using other format
00601             SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
00602             bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
00603             if( !isVersionOk || aVersion != aFormat ) {
00604               int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
00605                                                   QObject::tr("SMESH_WRN_WARNING"),
00606                                                   QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
00607                                                   QObject::tr("SMESH_BUT_YES"),
00608                                                   QObject::tr("SMESH_BUT_NO"), 0, 1);
00609               if (aRet == 0)
00610                 toOverwrite = true;
00611               else
00612                 is_ok = false;
00613             }
00614 
00615             QStringList aMeshNamesCollisionList;
00616             SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
00617             for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
00618               QString anExistingMeshName( aMeshNames[ i ] );
00619               for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
00620                 QString anExportMeshName = (*aMeshIter).second;
00621                 if( anExportMeshName == anExistingMeshName ) {
00622                   aMeshNamesCollisionList.append( anExportMeshName );
00623                   break;
00624                 }
00625               }
00626             }
00627             if( !aMeshNamesCollisionList.isEmpty() ) {
00628               QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
00629               int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
00630                                                   QObject::tr("SMESH_WRN_WARNING"),
00631                                                   QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
00632                                                   QObject::tr("SMESH_BUT_YES"),
00633                                                   QObject::tr("SMESH_BUT_NO"),
00634                                                   QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
00635               if (aRet == 0)
00636                 toOverwrite = true;
00637               else if (aRet == 2)
00638                 is_ok = false;
00639             }
00640           }
00641         }
00642       }
00643       toCreateGroups = fd->IsChecked();
00644       delete fd;
00645     }
00646     else
00647     {
00648       return;
00649     }
00650 
00651     // Perform export
00652 
00653     if ( !aFilename.isEmpty() ) {
00654       // Check whether the file already exists and delete it if yes
00655       QFile aFile( aFilename );
00656       if ( aFile.exists() && toOverwrite )
00657         aFile.remove();
00658       SUIT_OverrideCursor wc;
00659 
00660       try {
00661         // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
00662 //         bool Renumber = false;
00663 //         // PAL 14172  : Check of we have to renumber or not from the preferences before export
00664 //         if (resMgr)
00665 //           Renumber= resMgr->booleanValue("SMESH","renumbering");
00666 //         if (Renumber){
00667 //           SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
00668 //           aMeshEditor->RenumberNodes();
00669 //           aMeshEditor->RenumberElements();
00670 //           if ( SMESHGUI::automaticUpdate() )
00671 //             SMESH::UpdateView();
00672 //         }
00673         if ( isMED )
00674         {
00675           aMeshIter = aMeshList.begin();
00676           for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
00677           {
00678             SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
00679             SMESH::SMESH_Mesh_var        aMeshItem = aMeshOrGroup->GetMesh();
00680             if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
00681               aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
00682                                        aFormat, toOverwrite && aMeshIndex == 0 );
00683             else
00684               aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
00685                                           aFormat, toOverwrite && aMeshIndex == 0 );
00686           }
00687         }
00688         else if ( isSAUV )
00689         {
00690           for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
00691           {
00692             SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
00693             if( !aMeshItem->_is_nil() )
00694               aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
00695           }
00696         }
00697         else if ( isDAT )
00698         {
00699           if ( aMeshOrGroup->_is_equivalent( aMesh ))
00700             aMesh->ExportDAT( aFilename.toLatin1().data() );
00701           else
00702             aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
00703         }
00704         else if ( isUNV )
00705         {
00706           if ( aMeshOrGroup->_is_equivalent( aMesh ))
00707             aMesh->ExportUNV( aFilename.toLatin1().data() );
00708           else
00709             aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
00710         }
00711         else if ( isSTL )
00712         {
00713           if ( aMeshOrGroup->_is_equivalent( aMesh ))
00714             aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
00715           else
00716             aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
00717         }
00718         else if ( isCGNS )
00719         {
00720           aMeshIter = aMeshList.begin();
00721           for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
00722           {
00723             SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
00724             SMESH::SMESH_Mesh_var        aMeshItem = aMeshOrGroup->GetMesh();
00725             aMeshItem->ExportCGNS( aMeshOrGroup,
00726                                    aFilename.toLatin1().data(),
00727                                    toOverwrite && aMeshIndex == 0 );
00728           }
00729         }
00730       }
00731       catch (const SALOME::SALOME_Exception& S_ex){
00732         wc.suspend();
00733         SUIT_MessageBox::warning(SMESHGUI::desktop(),
00734                                  QObject::tr("SMESH_WRN_WARNING"),
00735                                  QObject::tr("SMESH_EXPORT_FAILED"));
00736         wc.resume();
00737       }
00738     }
00739   }
00740 
00741   inline void InverseEntityMode(unsigned int& theOutputMode,
00742                                 unsigned int theMode)
00743   {
00744     bool anIsNotPresent = ~theOutputMode & theMode;
00745     if(anIsNotPresent)
00746       theOutputMode |= theMode;
00747     else
00748       theOutputMode &= ~theMode;
00749   }
00750 
00751   void SetDisplayEntity(int theCommandID){
00752     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
00753     SALOME_ListIO selected;
00754     if( aSel )
00755       aSel->selectedObjects( selected );
00756 
00757     if(selected.Extent() >= 1){
00758       SALOME_ListIteratorOfListIO It( selected );
00759       for( ; It.More(); It.Next()){
00760         Handle(SALOME_InteractiveObject) IObject = It.Value();
00761         if(IObject->hasEntry()){
00762           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
00763             unsigned int aMode = anActor->GetEntityMode();
00764             switch(theCommandID){
00765             case 216:
00766               InverseEntityMode(aMode,SMESH_Actor::e0DElements);
00767               break;
00768             case 217:
00769               InverseEntityMode(aMode,SMESH_Actor::eEdges);
00770               break;
00771             case 218:
00772               InverseEntityMode(aMode,SMESH_Actor::eFaces);
00773               break;
00774             case 219:
00775               InverseEntityMode(aMode,SMESH_Actor::eVolumes);
00776               break;
00777             case 220:
00778               aMode = SMESH_Actor::eAllEntity;
00779               break;
00780             }
00781             if(aMode)
00782               anActor->SetEntityMode(aMode);
00783           }
00784         }
00785       }
00786     }
00787   }
00788 
00789   void AutoColor(){
00790     SALOME_ListIO selected;
00791     SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
00792     if( !app )
00793       return;
00794 
00795     LightApp_SelectionMgr* aSel = app->selectionMgr();
00796     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
00797     if( !aSel || !appStudy )
00798       return;
00799 
00800     aSel->selectedObjects( selected );
00801     if( selected.IsEmpty() )
00802       return;
00803 
00804     Handle(SALOME_InteractiveObject) anIObject = selected.First();
00805 
00806     _PTR(Study) aStudy = appStudy->studyDS();
00807     _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
00808     SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
00809     if( aMainObject->_is_nil() )
00810       return;
00811 
00812     aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
00813 
00814     SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
00815     for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
00816     {
00817       SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
00818       SALOMEDS::Color aColor = aGroupObject->GetColor();
00819       _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
00820       if (aGroupSObject) {
00821         if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
00822           if( aGroupObject->GetType() == SMESH::NODE )
00823             anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
00824           else if( aGroupObject->GetType() == SMESH::EDGE )
00825             anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
00826           else if( aGroupObject->GetType() == SMESH::ELEM0D )
00827             anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
00828           else {
00829             QColor c;
00830             int delta;
00831             SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
00832             anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
00833           }
00834         }
00835       }
00836     }
00837 
00838     SMESH::RepaintCurrentView();
00839   }
00840 
00841   QString functorToString( SMESH::Controls::FunctorPtr f )
00842   {
00843     QString type = QObject::tr( "UNKNOWN_CONTROL" );
00844     if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
00845       type = QObject::tr( "VOLUME_3D_ELEMENTS" );
00846     else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
00847       type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
00848     else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
00849       type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
00850     else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
00851       type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
00852     else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
00853       type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
00854     else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
00855       type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
00856     else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
00857       type = QObject::tr( "WARP_ELEMENTS" );
00858     else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
00859       type = QObject::tr( "TAPER_ELEMENTS" );
00860     else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
00861       type = QObject::tr( "SKEW_ELEMENTS" );
00862     else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
00863       type = QObject::tr( "AREA_ELEMENTS" );
00864     else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
00865       type = QObject::tr( "LENGTH_EDGES" );
00866     else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
00867       type = QObject::tr( "LENGTH2D_EDGES" );
00868     else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
00869       type = QObject::tr( "MULTI_BORDERS" );
00870     else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
00871       type = QObject::tr( "MULTI2D_BORDERS" );
00872     else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
00873       type = QObject::tr( "FREE_NODES" );
00874     else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
00875       type = QObject::tr( "FREE_EDGES" );
00876     else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
00877       type = QObject::tr( "FREE_BORDERS" );
00878     else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
00879       type = QObject::tr( "FREE_FACES" );
00880     else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
00881       type = QObject::tr( "BARE_BORDER_VOLUME" );
00882     else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
00883       type = QObject::tr( "BARE_BORDER_FACE" );
00884     else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
00885       type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
00886     else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
00887       type = QObject::tr( "OVER_CONSTRAINED_FACE" );
00888     else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
00889       type = QObject::tr( "EQUAL_NODE" );
00890     else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
00891       type = QObject::tr( "EQUAL_EDGE" );
00892     else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
00893       type = QObject::tr( "EQUAL_FACE" );
00894     else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
00895       type = QObject::tr( "EQUAL_VOLUME" );
00896     return type;
00897   }
00898 
00899   void SaveDistribution()
00900   {
00901     LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
00902     SALOME_ListIO selected;
00903     if ( aSel )
00904       aSel->selectedObjects( selected );
00905 
00906     if ( selected.Extent() == 1 ) {
00907       Handle(SALOME_InteractiveObject) anIO = selected.First();
00908       if ( anIO->hasEntry() ) {
00909         SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
00910         if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
00911           SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
00912           SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
00913           if ( aScalarBarActor && aFunctor ) {
00914             SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
00915             if ( aNumFun ) {
00916               std::vector<int> elements;
00917               SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
00918               if ( mesh->_is_nil() ) {
00919                 SMESH::SMESH_IDSource_var idSource =
00920                   SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
00921                 if ( !idSource->_is_nil() )
00922                 {
00923                   SMESH::long_array_var ids = idSource->GetIDs();
00924                   elements.resize( ids->length() );
00925                   for ( unsigned i = 0; i < elements.size(); ++i )
00926                     elements[i] = ids[i];
00927                 }
00928               }
00929               int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
00930               vtkLookupTable* lookupTable =
00931                 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
00932               double * minmax = lookupTable->GetRange();
00933               std::vector<int>    nbEvents;
00934               std::vector<double> funValues;
00935               aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
00936               QString anInitialPath = "";
00937               if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
00938                 anInitialPath = QDir::currentPath();
00939               QString aMeshName = anIO->getName();
00940               QStringList filter;
00941               filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
00942               filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
00943               QString aFilename = anInitialPath + "/" + aMeshName + "_" + 
00944                 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
00945               aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
00946                                                      aFilename,
00947                                                      filter,
00948                                                      QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
00949                                                      false );
00950               if ( !aFilename.isEmpty() ) {
00951                 QFile f( aFilename );
00952                 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
00953                   QTextStream out( &f );
00954                   out << "# Mesh: " << aMeshName << endl;
00955                   out << "# Control: " << functorToString( aFunctor ) << endl;
00956                   out << "#" << endl;
00957                   out.setFieldWidth( 10 );
00958                   for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
00959                     out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
00960                   f.close();
00961                 }
00962               }
00963             }
00964           }
00965         }
00966       }
00967     }
00968   }
00969 
00970   void ShowDistribution() {
00971     LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
00972     SALOME_ListIO selected;
00973     if ( aSel )
00974       aSel->selectedObjects( selected );
00975     
00976     if ( selected.Extent() == 1 ) {
00977       Handle(SALOME_InteractiveObject) anIO = selected.First();
00978       if ( anIO->hasEntry() ) {
00979         SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
00980         if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
00981           SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
00982           aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
00983         }
00984       }
00985     }
00986   }
00987 
00988 #ifndef DISABLE_PLOT2DVIEWER
00989  void PlotDistribution() {
00990    SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
00991    if( !app )
00992      return;
00993 
00994    LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
00995    SALOME_ListIO selected;
00996    if ( aSel )
00997      aSel->selectedObjects( selected );
00998     
00999    if ( selected.Extent() == 1 ) {
01000      Handle(SALOME_InteractiveObject) anIO = selected.First();
01001      if ( anIO->hasEntry() ) {
01002        //Find Actor by entry before getting Plot2d viewer,
01003        //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
01004        SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
01005 
01006        SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
01007 
01008        if( !aViewManager )
01009          return;
01010        
01011        SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
01012        if ( !aView )
01013          return;
01014 
01015        Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
01016        if ( !aPlot )
01017          return;
01018 
01019        if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
01020          SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
01021          QString functorName = functorToString( anActor->GetFunctor());
01022          QString aHistogramName("%1 : %2");
01023          aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
01024          aHistogram->setName(aHistogramName);
01025          aHistogram->setHorTitle(functorName);
01026          aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
01027          aPlot->displayObject(aHistogram, true);
01028        }
01029      }
01030    }
01031  }
01032 #endif //DISABLE_PLOT2DVIEWER
01033 
01034   void DisableAutoColor(){
01035     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
01036     SALOME_ListIO selected;
01037     if( aSel )
01038       aSel->selectedObjects( selected );
01039 
01040     if(selected.Extent()){
01041       Handle(SALOME_InteractiveObject) anIObject = selected.First();
01042       SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
01043       if ( !aMesh->_is_nil() ) {
01044         aMesh->SetAutoColor( false );
01045       }
01046     }
01047   }
01048 
01049   void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
01050     SALOME_ListIO selected;
01051     SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
01052     if( !app )
01053       return;
01054 
01055     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
01056     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
01057     if( !aSel || !appStudy )
01058       return;
01059 
01060     if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
01061       if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
01062         aModule->EmitSignalDeactivateDialog();
01063         if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
01064           (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
01065       }
01066       return;
01067     }
01068 
01069     _PTR(Study) aStudy = appStudy->studyDS();
01070 
01071     aSel->selectedObjects( selected );
01072 
01073     if(selected.Extent() >= 1){
01074       switch(theCommandID){
01075       case 1133:{
01076         SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
01077         (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
01078         return;
01079       }
01080       case 1132:{
01081         QColor c, e, b, n, c0D, o, outl, selection, preselection;
01082         int delta;
01083         int size0D = 0;
01084         int Edgewidth = 0;
01085         vtkFloatingPointType Shrink = 0.0;
01086         vtkFloatingPointType faces_orientation_scale = 0.0;
01087         bool faces_orientation_3dvectors = false;
01088 
01089         VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
01090         VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
01091         int aMarkerTextureCurrent = 0;
01092 
01093         SALOME_ListIteratorOfListIO It( selected );
01094         for( ; It.More(); It.Next()){
01095           Handle(SALOME_InteractiveObject) IObject = It.Value();
01096           if(IObject->hasEntry()){
01097             if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
01098               vtkFloatingPointType color[3];
01099               anActor->GetSufaceColor(color[0], color[1], color[2],delta);
01100               int c0 = int (color[0] * 255);
01101               int c1 = int (color[1] * 255);
01102               int c2 = int (color[2] * 255);
01103               c.setRgb(c0, c1, c2);
01104 
01105               vtkFloatingPointType edgecolor[3];
01106               anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
01107               c0 = int (edgecolor[0] * 255);
01108               c1 = int (edgecolor[1] * 255);
01109               c2 = int (edgecolor[2] * 255);
01110               e.setRgb(c0, c1, c2);
01111 
01112               vtkFloatingPointType nodecolor[3];
01113               anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
01114               c0 = int (nodecolor[0] * 255);
01115               c1 = int (nodecolor[1] * 255);
01116               c2 = int (nodecolor[2] * 255);
01117               n.setRgb(c0, c1, c2);
01118 
01119               vtkFloatingPointType color0D[3];
01120               anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
01121               c0 = int (color0D[0] * 255);
01122               c1 = int (color0D[1] * 255);
01123               c2 = int (color0D[2] * 255);
01124               c0D.setRgb(c0, c1, c2);
01125 
01126               vtkFloatingPointType outlineColor[3];
01127               anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
01128               c0 = int (outlineColor[0] * 255);
01129               c1 = int (outlineColor[1] * 255);
01130               c2 = int (outlineColor[2] * 255);
01131               outl.setRgb(c0, c1, c2);
01132 
01133               vtkFloatingPointType hColor[3];
01134               anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
01135               c0 = int (hColor[0] * 255);
01136               c1 = int (hColor[1] * 255);
01137               c2 = int (hColor[2] * 255);
01138               selection.setRgb(c0, c1, c2);
01139 
01140               vtkFloatingPointType phColor[3];
01141               anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
01142               c0 = int (phColor[0] * 255);
01143               c1 = int (phColor[1] * 255);
01144               c2 = int (phColor[2] * 255);
01145               preselection.setRgb(c0, c1, c2);
01146 
01147               size0D = (int)anActor->Get0DSize();
01148               if(size0D == 0)
01149                 size0D = 1;
01150               Edgewidth = (int)anActor->GetLineWidth();
01151               if(Edgewidth == 0)
01152                 Edgewidth = 1;
01153               Shrink = anActor->GetShrinkFactor();
01154 
01155               vtkFloatingPointType faces_orientation_color[3];
01156               anActor->GetFacesOrientationColor(faces_orientation_color);
01157               c0 = int (faces_orientation_color[0] * 255);
01158               c1 = int (faces_orientation_color[1] * 255);
01159               c2 = int (faces_orientation_color[2] * 255);
01160               o.setRgb(c0, c1, c2);
01161 
01162               faces_orientation_scale = anActor->GetFacesOrientationScale();
01163               faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
01164 
01165               aMarkerTypeCurrent = anActor->GetMarkerType();
01166               aMarkerScaleCurrent = anActor->GetMarkerScale();
01167               aMarkerTextureCurrent = anActor->GetMarkerTexture();
01168 
01169               // even if there are multiple objects in the selection,
01170               // we need only the first one to get values for the dialog
01171               break;
01172             }
01173           }
01174         }
01175 
01176         SMESHGUI_Preferences_ColorDlg *aDlg =
01177           new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
01178         aDlg->SetColor(1, c);
01179         aDlg->SetColor(2, e);
01180         aDlg->SetColor(3, n);
01181         aDlg->SetColor(4, outl);
01182         aDlg->SetDeltaBrightness(delta);
01183         aDlg->SetColor(5, c0D);
01184         aDlg->SetColor(6, o);
01185         aDlg->SetIntValue(1, Edgewidth);
01186         aDlg->SetIntValue(2, int(Shrink*100.));
01187         aDlg->SetIntValue(3, size0D);
01188         aDlg->SetDoubleValue(1, faces_orientation_scale);
01189         aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
01190         aDlg->SetColor(7, selection);
01191         aDlg->SetColor(8, preselection);
01192  
01193         aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
01194 
01195         if( aMarkerTypeCurrent != VTK::MT_USER )
01196           aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
01197         else
01198           aDlg->setCustomMarker( aMarkerTextureCurrent );
01199 
01200         if(aDlg->exec()){
01201           QColor color = aDlg->GetColor(1);
01202           QColor edgecolor = aDlg->GetColor(2);
01203           QColor nodecolor = aDlg->GetColor(3);
01204           QColor outlinecolor = aDlg->GetColor(4);
01205           QColor color0D = aDlg->GetColor(5);
01206           QColor faces_orientation_color = aDlg->GetColor(6);
01207           QColor selectioncolor = aDlg->GetColor(7);
01208           QColor preSelectioncolor = aDlg->GetColor(8);
01209           int delta = aDlg->GetDeltaBrightness();
01210 
01211           /* Point marker */
01212           theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
01213 
01214           SALOME_ListIteratorOfListIO It( selected );
01215           for( ; It.More(); It.Next()){
01216             Handle(SALOME_InteractiveObject) IObject = It.Value();
01217             if(IObject->hasEntry()){
01218               if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
01219                 /* actor color and backface color */
01220                 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
01221                                         vtkFloatingPointType (color.green()) / 255.,
01222                                         vtkFloatingPointType (color.blue()) / 255.,
01223                                         delta);
01224                 /* edge color */
01225                 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
01226                                       vtkFloatingPointType (edgecolor.green()) / 255.,
01227                                       vtkFloatingPointType (edgecolor.blue()) / 255.);
01228                 /* edge outline */
01229                 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
01230                                          vtkFloatingPointType (outlinecolor.green()) / 255.,
01231                                          vtkFloatingPointType (outlinecolor.blue()) / 255.);
01232 
01233                 /* selection */
01234                 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
01235                                            vtkFloatingPointType (selectioncolor.green()) / 255.,
01236                                            vtkFloatingPointType (selectioncolor.blue()) / 255.);
01237                 /* pre-selection */
01238                 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
01239                                               vtkFloatingPointType (preSelectioncolor.green()) / 255.,
01240                                               vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
01241                 
01242 
01243                 /* Shrink factor and size edges */
01244                 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
01245                 anActor->SetLineWidth(aDlg->GetIntValue(1));
01246 
01247                 /* Nodes color and size */
01248                 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
01249                                       vtkFloatingPointType (nodecolor.green()) / 255.,
01250                                       vtkFloatingPointType (nodecolor.blue()) / 255.);
01251 
01252                 /* 0D elements */
01253                 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
01254                                     vtkFloatingPointType (color0D.green()) / 255.,
01255                                     vtkFloatingPointType (color0D.blue()) / 255.);
01256                 anActor->Set0DSize(aDlg->GetIntValue(3));
01257 
01258                 /* Faces orientation */
01259                 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
01260                                              vtkFloatingPointType(faces_orientation_color.greenF()),
01261                                              vtkFloatingPointType(faces_orientation_color.blueF())};
01262                 anActor->SetFacesOrientationColor(c);
01263                 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
01264                 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
01265 
01266                 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
01267                 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
01268                 int aMarkerTextureNew = aDlg->getCustomMarkerID();
01269                 if( aMarkerTypeNew != VTK::MT_USER )
01270                   anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
01271                 else {
01272                   const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
01273                   VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
01274                   if( anIter != aMarkerMap.end() )
01275                     anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
01276                 }
01277 
01278                 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
01279                 if( !aGroupObject->_is_nil() )
01280                 {
01281                   SMESH::ElementType anElementType = aGroupObject->GetType();
01282                   QColor aColor;
01283                   switch( anElementType )
01284                   {
01285                     case SMESH::NODE: aColor = nodecolor; break;
01286                     case SMESH::EDGE: aColor = edgecolor; break;
01287                     default: aColor = color; break;
01288                   }
01289 
01290                   SALOMEDS::Color aGroupColor;
01291                   aGroupColor.R = (float)aColor.red() / 255.0;
01292                   aGroupColor.G = (float)aColor.green() / 255.0;
01293                   aGroupColor.B = (float)aColor.blue() / 255.0;
01294                   aGroupObject->SetColor( aGroupColor );
01295                 }
01296               }
01297             }
01298           }
01299           SMESH::RepaintCurrentView();
01300         }
01301         delete aDlg;
01302         return;
01303       }
01304       }
01305       SALOME_ListIteratorOfListIO It( selected );
01306       for( ; It.More(); It.Next()){
01307         Handle(SALOME_InteractiveObject) IObject = It.Value();
01308         if(IObject->hasEntry()){
01309           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
01310             switch(theCommandID){
01311             case 211:
01312               anActor->SetRepresentation(SMESH_Actor::eEdge);
01313               break;
01314             case 212:
01315               anActor->SetRepresentation(SMESH_Actor::eSurface);
01316               break;
01317             case 213:
01318               if(anActor->IsShrunk())
01319                 anActor->UnShrink();
01320               else
01321                 anActor->SetShrink();
01322               break;
01323             case 215:
01324               anActor->SetRepresentation(SMESH_Actor::ePoint);
01325               break;
01326             case 231:
01327               if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
01328                 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
01329               break;
01330             case 232:
01331               if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
01332                 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
01333               break;
01334             }
01335           }
01336         }
01337       }
01338       SMESH::RepaintCurrentView();
01339     }
01340   }
01341 
01342   void Control( int theCommandID )
01343   {
01344     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
01345     SALOME_ListIO selected;
01346     if( aSel )
01347       aSel->selectedObjects( selected );
01348 
01349     if( !selected.IsEmpty() ){
01350       Handle(SALOME_InteractiveObject) anIO = selected.First();
01351       if(!anIO.IsNull()){
01352         SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
01353         if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
01354           switch ( theCommandID ){
01355           case 6001:
01356             aControl = SMESH_Actor::eLength;
01357             break;
01358           case 6018:
01359             aControl = SMESH_Actor::eLength2D;
01360             break;
01361           case 6002:
01362             aControl = SMESH_Actor::eFreeEdges;
01363             break;
01364           case 6003:
01365             aControl = SMESH_Actor::eFreeBorders;
01366             break;
01367           case 6004:
01368             aControl = SMESH_Actor::eMultiConnection;
01369             break;
01370           case 6005:
01371             aControl = SMESH_Actor::eFreeNodes;
01372             break;
01373           case 6019:
01374             aControl = SMESH_Actor::eMultiConnection2D;
01375             break;
01376           case 6011:
01377             aControl = SMESH_Actor::eArea;
01378             break;
01379           case 6012:
01380             aControl = SMESH_Actor::eTaper;
01381             break;
01382           case 6013:
01383             aControl = SMESH_Actor::eAspectRatio;
01384             break;
01385           case 6017:
01386             aControl = SMESH_Actor::eAspectRatio3D;
01387             break;
01388           case 6014:
01389             aControl = SMESH_Actor::eMinimumAngle;
01390             break;
01391           case 6015:
01392             aControl = SMESH_Actor::eWarping;
01393             break;
01394           case 6016:
01395             aControl = SMESH_Actor::eSkew;
01396             break;
01397           case 6009:
01398             aControl = SMESH_Actor::eVolume3D;
01399             break;
01400           case 6021:
01401             aControl = SMESH_Actor::eFreeFaces;
01402             break;
01403           case 6022:
01404             aControl = SMESH_Actor::eMaxElementLength2D;
01405             break;
01406           case 6023:
01407             aControl = SMESH_Actor::eMaxElementLength3D;
01408             break;
01409           case 6024:
01410             aControl = SMESH_Actor::eBareBorderVolume;
01411             break;
01412           case 6025:
01413             aControl = SMESH_Actor::eBareBorderFace;
01414             break;
01415           case 6026:
01416             aControl = SMESH_Actor::eOverConstrainedVolume;
01417             break;
01418           case 6027:
01419             aControl = SMESH_Actor::eOverConstrainedFace;
01420             break;
01421           case 6028:
01422             aControl = SMESH_Actor::eCoincidentNodes;
01423             break;
01424           case 6029:
01425             aControl = SMESH_Actor::eCoincidentElems1D;
01426             break;
01427           case 6030:
01428             aControl = SMESH_Actor:: eCoincidentElems2D;
01429             break;
01430           case 6031:
01431             aControl = SMESH_Actor::eCoincidentElems3D;
01432             break;
01433           }
01434             
01435           anActor->SetControlMode(aControl);
01436           anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
01437           SMESH::RepaintCurrentView();
01438 #ifndef DISABLE_PLOT2DVIEWER
01439           if(anActor->GetPlot2Histogram()) {
01440             SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
01441             QString functorName = functorToString( anActor->GetFunctor());
01442             QString aHistogramName("%1 : %2");
01443             aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
01444             aHistogram->setName(aHistogramName);
01445             aHistogram->setHorTitle(functorName);
01446             SMESH::ProcessIn2DViewers(anActor);
01447           }
01448 #endif
01449         }
01450       }
01451     }
01452   }
01453 
01454 
01455   bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
01456                    MeshObjectType                           theType,
01457                    const QString                            theInTypeName,
01458                    QString &                                theOutTypeName)
01459   {
01460     SMESH_TypeFilter aTypeFilter( theType );
01461     QString entry;
01462     if( !theIO.IsNull() )
01463     {
01464       entry = theIO->getEntry();
01465       LightApp_DataOwner owner( entry );
01466       if ( aTypeFilter.isOk( &owner )) {
01467         theOutTypeName = theInTypeName;
01468         return true;
01469       }
01470     }
01471     return false;
01472   }
01473 
01474 
01475   QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
01476   {
01477     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
01478     _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
01479     if (aSObj) {
01480       _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
01481       CORBA::String_var anID = aSComp->GetID().c_str();
01482       if (!strcmp(anID.in(),theIO->getEntry()))
01483         return "Component";
01484     }
01485 
01486     QString aTypeName;
01487     if (
01488         CheckOIType ( theIO, HYPOTHESIS,    "Hypothesis", aTypeName ) ||
01489         CheckOIType ( theIO, ALGORITHM,     "Algorithm",  aTypeName ) ||
01490         CheckOIType ( theIO, MESH,          "Mesh",       aTypeName ) ||
01491         CheckOIType ( theIO, SUBMESH,       "SubMesh",    aTypeName ) ||
01492         CheckOIType ( theIO, GROUP,         "Group",      aTypeName )
01493         )
01494       return aTypeName;
01495 
01496     return "NoType";
01497   }
01498 
01499 
01500   QString CheckHomogeneousSelection()
01501   {
01502     //SUIT_Study* aStudy = SMESH::GetActiveStudy();
01503     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
01504     SALOME_ListIO selected;
01505     if( aSel )
01506       aSel->selectedObjects( selected );
01507 
01508     QString RefType = CheckTypeObject(selected.First());
01509     SALOME_ListIteratorOfListIO It(selected);
01510     for ( ; It.More(); It.Next())
01511       {
01512         Handle(SALOME_InteractiveObject) IObject = It.Value();
01513         QString Type = CheckTypeObject(IObject);
01514         if (Type.compare(RefType) != 0)
01515           return "Heterogeneous Selection";
01516       }
01517 
01518     return RefType;
01519   }
01520 
01521 
01522   void SMESHGUI::OnEditDelete()
01523   {
01524     // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
01525     LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
01526     SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
01527 
01528     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
01529     _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
01530     _PTR(GenericAttribute) anAttr;
01531     _PTR(AttributeIOR) anIOR;
01532 
01533     int objectCount = 0;
01534     QString aNameList;
01535     QString aParentComponent = QString::null;
01536     Handle(SALOME_InteractiveObject) anIO;
01537     for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
01538     {
01539       anIO = anIt.Value();
01540       QString cur = anIO->getComponentDataType();
01541       _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
01542       if (aSO) {
01543         // check if object is reference
01544         _PTR(SObject) aRefSObj;
01545         aNameList.append("\n    - ");
01546         if ( aSO->ReferencedObject( aRefSObj ) ) {
01547           QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
01548           aNameList.append( aRefName );
01549           cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
01550         }
01551         else
01552           aNameList.append(anIO->getName());
01553         objectCount++;
01554       }
01555 
01556       if( aParentComponent.isNull() )
01557         aParentComponent = cur;
01558       else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
01559         aParentComponent = "";
01560     }
01561 
01562     if ( objectCount == 0 )
01563       return; // No Valid Objects Selected
01564 
01565     if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() )  {
01566       SUIT_MessageBox::warning( SMESHGUI::desktop(),
01567                                 QObject::tr("ERR_ERROR"),
01568                                 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
01569       return;
01570     }
01571     // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
01572     if (SUIT_MessageBox::warning
01573         (SMESHGUI::desktop(),
01574          QObject::tr("SMESH_WRN_WARNING"),
01575          QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
01576          SUIT_MessageBox::Yes | SUIT_MessageBox::No,
01577          SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
01578       return;
01579 
01580     SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
01581 
01582     // Put the whole hierarchy of sub-objects of the selected SO's into a list and
01583     // then treat them all starting from the deepest objects (at list back)
01584     std::list< _PTR(SObject) > listSO;
01585     SALOME_ListIteratorOfListIO It(selected);
01586     for( ; It.More(); It.Next()) // loop on selected IO's
01587     {
01588       Handle(SALOME_InteractiveObject) IObject = It.Value();
01589       if(IObject->hasEntry()) {
01590         _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
01591 
01592         // disable removal of "SMESH" component object
01593         if(aSO->FindAttribute(anAttr, "AttributeIOR")){
01594           anIOR = anAttr;
01595           if ( engineIOR() == anIOR->Value().c_str() )
01596             continue;
01597         }
01598         //Check the referenced object
01599         _PTR(SObject) aRefSObject;
01600         if ( aSO && aSO->ReferencedObject( aRefSObject ) )
01601           aSO = aRefSObject; // Delete main Object instead of reference
01602 
01603         listSO.push_back( aSO );
01604         std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
01605         for ( ; itSO != listSO.end(); ++itSO ) {
01606           _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
01607           for (it->InitEx(false); it->More(); it->Next())
01608             listSO.push_back( it->Value() );
01609         }
01610       }
01611     }
01612     // Check if none of objects to delete is referred from outside
01613     std::list< _PTR(SObject) >::reverse_iterator ritSO;
01614     for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
01615     {
01616       _PTR(SObject) SO = *ritSO;
01617       if ( !SO ) continue;
01618       std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO  );
01619       for (size_t i = 0; i < aReferences.size(); i++) {
01620         _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
01621         std::string type = aComponent->ComponentDataType();
01622         if ( type != "SMESH" )
01623         {
01624           SUIT_MessageBox::warning( anApp->desktop(),
01625                                     QObject::tr("WRN_WARNING"),
01626                                     QObject::tr("DEP_OBJECT") );
01627           return; // outside SMESH, there is an object depending on a SMESH object 
01628         }
01629       }
01630     }
01631 
01632     // Treat SO's in the list starting from the back
01633     aStudyBuilder->NewCommand();  // There is a transaction
01634     for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
01635     {
01636       _PTR(SObject) SO = *ritSO;
01637       if ( !SO ) continue;
01638       std::string anEntry = SO->GetID();
01639 
01641       if(SO->FindAttribute(anAttr, "AttributeIOR")){
01642         ViewManagerList aViewMenegers = anApp->viewManagers();
01643         ViewManagerList::const_iterator it = aViewMenegers.begin();
01644         for( ; it != aViewMenegers.end(); it++) {         
01645           SUIT_ViewManager* vm = *it;
01646           int nbSf = vm ? vm->getViewsCount() : 0;
01647           if(vm) {
01648             QVector<SUIT_ViewWindow*> aViews = vm->getViews();
01649             for(int i = 0; i < nbSf; i++){
01650               SUIT_ViewWindow *sf = aViews[i];
01651               if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
01652                 SMESH::RemoveActor(sf,anActor);
01653               }
01654             }
01655           }
01656         }
01657       }
01659       SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
01660       SMESH::SMESH_subMesh_var   aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
01661       if ( !aGroup->_is_nil() ) {                          // DELETE GROUP
01662         SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
01663         aMesh->RemoveGroup( aGroup );
01664       }
01665       else if ( !aSubMesh->_is_nil() ) {                   // DELETE SUBMESH
01666         SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
01667         aMesh->RemoveSubMesh( aSubMesh );
01668 
01669         _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
01670         if (aMeshSO)
01671           SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
01672       }
01673       else {
01674         Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
01675           ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
01676         QString objType = CheckTypeObject(IObject);
01677         if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
01678           SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
01679           aStudyBuilder->RemoveObjectWithChildren( SO );
01680         }
01681         else {// default action: remove SObject from the study
01682               // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
01683               //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
01684               //op->start();
01685           aStudyBuilder->RemoveObjectWithChildren( SO );
01686           //op->finish();
01687         }
01688       }
01689     } /* listSO back loop */
01690 
01691     aStudyBuilder->CommitCommand();
01692 
01693     /* Clear any previous selection */
01694     SALOME_ListIO l1;
01695     aSel->setSelectedObjects( l1 );
01696 
01697     SMESHGUI::GetSMESHGUI()->updateObjBrowser();
01698   }
01699 //} namespace
01700 
01701 extern "C" {
01702   SMESHGUI_EXPORT CAM_Module* createModule()
01703   {
01704     return new SMESHGUI();
01705   }
01706 
01707   SMESHGUI_EXPORT  char* getModuleVersion() {
01708     return (char*)SMESH_VERSION_STR;
01709   }
01710 }
01711 
01712 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
01713 
01714 //=============================================================================
01718 //=============================================================================
01719 SMESHGUI::SMESHGUI() :
01720 SalomeApp_Module( "SMESH" ),
01721 LightApp_Module( "SMESH" )
01722 {
01723   if ( CORBA::is_nil( myComponentSMESH ) )
01724   {
01725     CORBA::Boolean anIsEmbeddedMode;
01726     myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
01727     MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
01728 
01729     //  0019923: EDF 765 SMESH : default values of hypothesis
01730     SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
01731     int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
01732     myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
01733     nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
01734     myComponentSMESH->SetDefaultNbSegments( nbSeg );
01735 
01736     const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
01737     for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
01738       if ( aResourceMgr->hasValue( "SMESH", options[i] ))
01739       {
01740         QString val = aResourceMgr->stringValue( "SMESH", options[i] );
01741         myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
01742       }
01743   }
01744 
01745   myActiveDialogBox = 0;
01746   myFilterLibraryDlg = 0;
01747   myState = -1;
01748   myDisplayer = 0;
01749 
01750   myEventCallbackCommand = vtkCallbackCommand::New();
01751   myEventCallbackCommand->Delete();
01752   myEventCallbackCommand->SetClientData( this );
01753   myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
01754   myPriority = 0.0;
01755 
01756   SMESH::GetFilterManager();
01757   SMESH::GetPattern();
01758   SMESH::GetMeasurements();
01759 
01760   /* load resources for all available meshers */
01761   SMESH::InitAvailableHypotheses();
01762 }
01763 
01764 //=============================================================================
01768 //=============================================================================
01769 SMESHGUI::~SMESHGUI()
01770 {
01771 #ifdef WITHGENERICOBJ
01772   SMESH::GetFilterManager()->UnRegister();
01773   SMESH::GetMeasurements()->UnRegister();
01774 #endif
01775   SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
01776   SMESH::GetMeasurements() = SMESH::Measurements::_nil();
01777 }
01778 
01779 //=============================================================================
01783 //=============================================================================
01784 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
01785 {
01786   SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
01787   if( anApp )
01788     return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
01789   else
01790     return 0;
01791 }
01792 
01793 //=============================================================================
01797 //=============================================================================
01798 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
01799 {
01800   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
01801   if ( !resMgr )
01802     return false;
01803 
01804   bool autoUpdate  = resMgr->booleanValue( "SMESH", "auto_update",  false );
01805   long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
01806   bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
01807   if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
01808   return autoUpdate && !exceeded;
01809 }
01810 
01811 //=============================================================================
01815 //=============================================================================
01816 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
01817 {
01818   return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
01819 }
01820 
01821 //=============================================================================
01825 //=============================================================================
01826 SMESHGUI* SMESHGUI::GetSMESHGUI()
01827 {
01828   SMESHGUI* smeshMod = 0;
01829   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
01830   if ( app )
01831   {
01832     CAM_Module* module = app->module( "Mesh" );
01833     smeshMod = dynamic_cast<SMESHGUI*>( module );
01834   }
01835 
01836   if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
01837   {
01838     SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
01839     if ( study )
01840     {
01841       _PTR(Study) aStudy = study->studyDS();
01842       if ( aStudy )
01843         GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
01844     }
01845   }
01846 
01847   return smeshMod;
01848 }
01849 
01850 extern "C"
01851 {
01852   Standard_EXPORT SMESHGUI* GetComponentGUI()
01853   {
01854     return SMESHGUI::GetSMESHGUI();
01855   }
01856 }
01857 
01858 //=============================================================================
01862 //=============================================================================
01863 void SMESHGUI::SetState(int aState)
01864 {
01865   myState = aState;
01866 }
01867 
01868 //=============================================================================
01872 //=============================================================================
01873 void SMESHGUI::ResetState()
01874 {
01875   myState = -1;
01876 }
01877 
01878 //=============================================================================
01882 //=============================================================================
01883 void SMESHGUI::EmitSignalDeactivateDialog()
01884 {
01885   emit SignalDeactivateActiveDialog();
01886 }
01887 
01888 //=============================================================================
01892 //=============================================================================
01893 void SMESHGUI::EmitSignalStudyFrameChanged()
01894 {
01895   emit SignalStudyFrameChanged();
01896 }
01897 
01898 //=============================================================================
01902 //=============================================================================
01903 void SMESHGUI::EmitSignalCloseAllDialogs()
01904 {
01905   emit SignalCloseAllDialogs();
01906 }
01907 
01908 //=============================================================================
01912 //=============================================================================
01913 void SMESHGUI::EmitSignalVisibilityChanged()
01914 {
01915   emit SignalVisibilityChanged();
01916 }
01917 
01918 //=============================================================================
01922 //=============================================================================
01923 QDialog *SMESHGUI::GetActiveDialogBox()
01924 {
01925   return myActiveDialogBox;
01926 }
01927 
01928 //=============================================================================
01932 //=============================================================================
01933 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
01934 {
01935   myActiveDialogBox = (QDialog *) aDlg;
01936   return;
01937 }
01938 
01939 //=============================================================================
01943 //=============================================================================
01944 SUIT_Desktop* SMESHGUI::desktop()
01945 {
01946   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
01947   if( app )
01948     return app->desktop();
01949   else
01950     return 0;
01951 }
01952 
01953 //=============================================================================
01957 //=============================================================================
01958 SalomeApp_Study* SMESHGUI::activeStudy()
01959 {
01960   SUIT_Application* app = SUIT_Session::session()->activeApplication();
01961   if( app )
01962     return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
01963   else
01964     return NULL;
01965 }
01966 
01967 //=============================================================================
01971 //=============================================================================
01972 void SMESHGUI::Modified( bool theIsUpdateActions )
01973 {
01974   if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
01975     if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
01976       appStudy->Modified();
01977       if( theIsUpdateActions )
01978         app->updateActions();
01979     }
01980   }
01981 }
01982 
01983 //=============================================================================
01987 //=============================================================================
01988 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
01989 {
01990   /* Here the position is on the bottom right corner - 10 */
01991   // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
01992   aDlg->adjustSize();
01993   SUIT_Desktop *PP = desktop();
01994   x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
01995   y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
01996   return true;
01997 }
01998 
01999 //=============================================================================
02003 //=============================================================================
02004 static int isStudyLocked(_PTR(Study) theStudy){
02005   return theStudy->GetProperties()->IsLocked();
02006 }
02007 
02008 static bool checkLock(_PTR(Study) theStudy) {
02009   if (isStudyLocked(theStudy)) {
02010     SUIT_MessageBox::warning( SMESHGUI::desktop(),
02011                               QObject::tr("WRN_WARNING"),
02012                               QObject::tr("WRN_STUDY_LOCKED") );
02013     return true;
02014   }
02015   return false;
02016 }
02017 
02018 //=======================================================================
02019 //function : CheckActiveStudyLocked
02020 //purpose  :
02021 //=======================================================================
02022 
02023 bool SMESHGUI::isActiveStudyLocked()
02024 {
02025   _PTR(Study) aStudy = activeStudy()->studyDS();
02026   return checkLock( aStudy );
02027 }
02028 
02029 //=============================================================================
02033 //=============================================================================
02034 bool SMESHGUI::OnGUIEvent( int theCommandID )
02035 {
02036   SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
02037   if( !anApp )
02038     return false;
02039 
02040   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
02041   SUIT_ResourceMgr* mgr = resourceMgr();
02042   if( !mgr )
02043     return false;
02044 
02045   if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
02046     GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
02047   }
02048 
02049   SUIT_ViewWindow* view = application()->desktop()->activeWindow();
02050   SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
02051 
02052   //QAction* act = action( theCommandID );
02053 
02054   switch (theCommandID) {
02055   case 33:                                      // DELETE
02056     if(checkLock(aStudy)) break;
02057     OnEditDelete();
02058     break;
02059 
02060   case 116:
02061   case 115:
02062   case 117:
02063   case 113:
02064   case 112:
02065   case 111:                                     // IMPORT
02066     {
02067       if(checkLock(aStudy)) break;
02068       ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
02069       break;
02070     }
02071 
02072   case 150:    //MED FILE INFORMATION
02073     {
02074       SALOME_ListIO selected;
02075       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02076       if( aSel )
02077         aSel->selectedObjects( selected );
02078       if( selected.Extent() )
02079       {
02080         Handle(SALOME_InteractiveObject) anIObject = selected.First();
02081         SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
02082         if ( !aMesh->_is_nil() )
02083         {
02084           SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
02085           dlg.exec();
02086         }
02087       }
02088       break;
02089     }
02090 
02091   case 122:                                     // EXPORT MED
02092   case 121:
02093   case 123:
02094   case 124:
02095   case 125:
02096   case 126:
02097   case 140:
02098   case 141:
02099   case 142:
02100   case 143:
02101   case 144:
02102   case 145:
02103     {
02104       ::ExportMeshToFile(theCommandID);
02105       break;
02106     }
02107 
02108   case 200:                                     // SCALAR BAR
02109     {
02110       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02111       SALOME_ListIO selected;
02112       if( aSel )
02113         aSel->selectedObjects( selected );
02114 
02115       if( selected.Extent() ) {
02116         Handle(SALOME_InteractiveObject) anIO = selected.First();
02117         if( anIO->hasEntry() ) {
02118           if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
02119             anActor->SetControlMode( SMESH_Actor::eNone );
02120 #ifndef DISABLE_PLOT2DVIEWER
02121             SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
02122 #endif
02123           }
02124         }
02125       }
02126       break;
02127     }
02128   case 201:
02129     {
02130       SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
02131       break;
02132     }
02133   case 2021:
02134     {
02135       // dump control distribution data to the text file
02136       ::SaveDistribution();
02137       break;
02138     }
02139 
02140   case 2022:
02141     {
02142       // show/ distribution
02143       ::ShowDistribution();
02144       break;
02145     }
02146 
02147 #ifndef DISABLE_PLOT2DVIEWER
02148   case 2023:
02149     {
02150       // plot distribution
02151       ::PlotDistribution();
02152       break;
02153     }
02154 #endif
02155 
02156     // Auto-color
02157   case 1136:
02158     ::AutoColor();
02159   break;
02160 
02161   case 1137:
02162     ::DisableAutoColor();
02163   break;
02164 
02165   case 1134: // Clipping
02166   case 1133: // Tranparency
02167   case 1132: // Display preferences (colors, shrink size, line width, ...)
02168 
02169     // Display Mode
02170   case 215: // Nodes
02171   case 213: // Nodes
02172   case 212: // Nodes
02173   case 211: // Nodes
02174     ::SetDisplayMode(theCommandID, myMarkerMap);
02175   break;
02176 
02177   //2D quadratic representation
02178   case 231:
02179   case 232:
02180     ::SetDisplayMode(theCommandID, myMarkerMap);
02181   break;
02182 
02183   // Display Entity
02184   case 216: // 0D elements
02185   case 217: // Edges
02186   case 218: // Faces
02187   case 219: // Volumes
02188   case 220: // All Entity
02189     ::SetDisplayEntity(theCommandID);
02190   break;
02191 
02192   case 221: // Orientation of faces
02193     {
02194       LightApp_SelectionMgr* mgr = selectionMgr();
02195       SALOME_ListIO selected; mgr->selectedObjects( selected );
02196 
02197       SALOME_ListIteratorOfListIO it(selected);
02198       for( ; it.More(); it.Next()) {
02199         Handle(SALOME_InteractiveObject) anIObject = it.Value();
02200         if(anIObject->hasEntry()) {
02201           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
02202             anActor->SetFacesOriented( !anActor->GetFacesOriented() );
02203           }
02204         }
02205       }
02206       break;
02207     }
02208 
02209   case 214:                                     // UPDATE
02210     {
02211       if(checkLock(aStudy)) break;
02212       try {
02213 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
02214         OCC_CATCH_SIGNALS;
02215 #endif
02216         SMESH::UpdateView();
02217       }
02218       catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
02219         SMESH::OnVisuException();
02220       }
02221       catch (...) { // PAL16774 (Crash after display of many groups)
02222         SMESH::OnVisuException();
02223       }
02224 
02225       SALOME_ListIO l;
02226       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02227       aSel->selectedObjects( l );
02228       aSel->setSelectedObjects( l );
02229       break;
02230     }
02231 
02232   case 300:                                     // ERASE
02233   case 301:                                     // DISPLAY
02234   case 302:                                     // DISPLAY ONLY
02235     {
02236       SMESH::EDisplaing anAction;
02237       switch (theCommandID) {
02238       case 300: anAction = SMESH::eErase; break;
02239       case 301: anAction = SMESH::eDisplay; break;
02240       case 302: anAction = SMESH::eDisplayOnly; break;
02241       }
02242 
02243       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02244       SALOME_ListIO sel_objects, to_process;
02245       if (aSel)
02246         aSel->selectedObjects( sel_objects );
02247 
02248       if( theCommandID==302 )
02249       {
02250         MESSAGE("anAction = SMESH::eDisplayOnly");
02251         startOperation( myEraseAll );
02252       }
02253 
02254       extractContainers( sel_objects, to_process );
02255 
02256       try {
02257 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
02258         OCC_CATCH_SIGNALS;
02259 #endif
02260         if (vtkwnd) {
02261           SALOME_ListIteratorOfListIO It( to_process );
02262           for ( ; It.More(); It.Next()) {
02263                 MESSAGE("---");
02264             Handle(SALOME_InteractiveObject) IOS = It.Value();
02265             if (IOS->hasEntry()) {
02266                 MESSAGE("---");
02267               if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
02268                 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
02269                 break; // PAL16774 (Crash after display of many groups)
02270               }
02271               if (anAction == SMESH::eDisplayOnly)
02272               {
02273                 MESSAGE("anAction = SMESH::eDisplayOnly");
02274                 anAction = SMESH::eDisplay;
02275               }
02276             }
02277           }
02278         }
02279 
02280         // PAL13338 + PAL15161 -->
02281         if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
02282                 MESSAGE("anAction = SMESH::eDisplayOnly");
02283           SMESH::UpdateView();
02284           SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
02285         }
02286         // PAL13338 + PAL15161 <--
02287       }
02288       catch (...) { // PAL16774 (Crash after display of many groups)
02289         SMESH::OnVisuException();
02290       }
02291 
02292       if (anAction == SMESH::eErase) {
02293         MESSAGE("anAction == SMESH::eErase");
02294         SALOME_ListIO l1;
02295         aSel->setSelectedObjects( l1 );
02296       }
02297       else
02298         aSel->setSelectedObjects( to_process );
02299 
02300       break;
02301     }
02302 
02303   case 4000:                                    // NODES
02304     {
02305       if(checkLock(aStudy)) break;
02306 
02307       if ( vtkwnd ) {
02308         EmitSignalDeactivateDialog();
02309 
02310         ( new SMESHGUI_NodesDlg( this ) )->show();
02311       }
02312       else {
02313         SUIT_MessageBox::warning(desktop(),
02314                                  tr("SMESH_WRN_WARNING"),
02315                                  tr("SMESH_WRN_VIEWER_VTK"));
02316       }
02317       break;
02318     }
02319 
02320   case 2151:  // FILTER
02321   {
02322     if ( vtkwnd )
02323     {
02324       EmitSignalDeactivateDialog();
02325       ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
02326     }
02327     break;
02328   }
02329 
02330   case 701:                                     // COMPUTE MESH
02331   case 711:                                     // PRECOMPUTE MESH
02332   case 712:                                     // EVALUATE MESH
02333   case 713:                                     // MESH ORDER
02334     {
02335       if (checkLock(aStudy)) break;
02336       startOperation( theCommandID );
02337     }
02338     break;
02339 
02340   case 702: // Create mesh
02341   case 703: // Create sub-mesh
02342   case 704: // Edit mesh/sub-mesh
02343     startOperation( theCommandID );
02344     break;
02345   case 705: // copy mesh
02346     {
02347       if (checkLock(aStudy)) break;
02348       EmitSignalDeactivateDialog();
02349       ( new SMESHGUI_CopyMeshDlg( this ) )->show();
02350     }
02351     break;
02352   case 710: // Build compound mesh
02353     {
02354       if (checkLock(aStudy)) break;
02355       EmitSignalDeactivateDialog();
02356       ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
02357     }
02358     break;
02359 
02360   case 407: // DIAGONAL INVERSION
02361   case 408: // Delete diagonal
02362     {
02363       if ( !vtkwnd )
02364       {
02365         SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
02366                                   tr( "NOT_A_VTK_VIEWER" ) );
02367         break;
02368       }
02369 
02370       if ( checkLock( aStudy ) )
02371         break;
02372 
02373       /*Standard_Boolean aRes;
02374       SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
02375       if ( aMesh->_is_nil() )
02376       {
02377         SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
02378           tr( "SMESH_BAD_SELECTION" ) );
02379         break;
02380       }
02381       */
02382       EmitSignalDeactivateDialog();
02383       if ( theCommandID == 407 )
02384         ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
02385       else
02386         ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
02387       break;
02388     }
02389   case 409: // Change orientation
02390   case 410: // Union of triangles
02391   case 411: // Cutting of quadrangles
02392   case 419: // Splitting volumes into tetrahedra
02393     {
02394       if ( !vtkwnd )
02395       {
02396         SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
02397                                   tr( "NOT_A_VTK_VIEWER" ) );
02398         break;
02399       }
02400 
02401       if ( checkLock( aStudy ) )
02402         break;
02403 
02404       EmitSignalDeactivateDialog();
02405       SMESHGUI_MultiEditDlg* aDlg = NULL;
02406       if ( theCommandID == 409 )
02407         aDlg = new SMESHGUI_ChangeOrientationDlg(this);
02408       else if ( theCommandID == 410 )
02409         aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
02410       else if ( theCommandID == 419 )
02411         aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
02412       else
02413         aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
02414 
02415       aDlg->show();
02416       break;
02417     }
02418   case 412: // Smoothing
02419     {
02420       if(checkLock(aStudy)) break;
02421       if( vtkwnd ) {
02422         EmitSignalDeactivateDialog();
02423         ( new SMESHGUI_SmoothingDlg( this ) )->show();
02424       }
02425       else {
02426         SUIT_MessageBox::warning(desktop(),
02427                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02428       }
02429       break;
02430     }
02431   case 413: // Extrusion
02432     {
02433       if (checkLock(aStudy)) break;
02434       if (vtkwnd) {
02435         EmitSignalDeactivateDialog();
02436         ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
02437       } else {
02438         SUIT_MessageBox::warning(desktop(),
02439                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02440       }
02441       break;
02442     }
02443   case 414: // Revolution
02444     {
02445       if(checkLock(aStudy)) break;
02446       if( vtkwnd ) {
02447         EmitSignalDeactivateDialog();
02448         ( new SMESHGUI_RevolutionDlg( this ) )->show();
02449       }
02450       else {
02451         SUIT_MessageBox::warning(desktop(),
02452                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02453       }
02454       break;
02455     }
02456   case 415: // Pattern mapping
02457     {
02458       if ( checkLock( aStudy ) )
02459         break;
02460       if ( vtkwnd )
02461       {
02462         EmitSignalDeactivateDialog();
02463         ( new SMESHGUI_MeshPatternDlg( this ) )->show();
02464       }
02465       else {
02466         SUIT_MessageBox::warning(desktop(),
02467                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02468       }
02469       break;
02470     }
02471   case 416: // Extrusion along a path
02472     {
02473       if (checkLock(aStudy)) break;
02474       if (vtkwnd) {
02475         EmitSignalDeactivateDialog();
02476         ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
02477       } else {
02478         SUIT_MessageBox::warning(desktop(),
02479                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02480       }
02481       break;
02482     }
02483   case 417: // Convert mesh to quadratic
02484     {
02485     startOperation( 417 );
02486       /*      if (checkLock(aStudy)) break;
02487       if (vtkwnd) {
02488         EmitSignalDeactivateDialog();
02489         new SMESHGUI_ConvToQuadDlg();
02490       } else {
02491         SUIT_MessageBox::warning(desktop(),
02492                                tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02493                                }*/
02494       break;
02495     }
02496   case 418: // create 2D mesh from 3D
02497     {
02498       startOperation( 418 );
02499       break;
02500     }
02501   case 806:                                     // CREATE GEO GROUP
02502     {
02503       startOperation( 806 );
02504       break;
02505     }
02506   case 801:                                     // CREATE GROUP
02507     {
02508       if ( !vtkwnd )
02509       {
02510         SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
02511                                   tr( "NOT_A_VTK_VIEWER" ) );
02512         break;
02513       }
02514 
02515       if(checkLock(aStudy)) break;
02516       EmitSignalDeactivateDialog();
02517       SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
02518 
02519       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02520       SALOME_ListIO selected;
02521       if( aSel )
02522         aSel->selectedObjects( selected );
02523 
02524       int nbSel = selected.Extent();
02525       if (nbSel == 1) {
02526         // check if mesh is selected
02527         aMesh = SMESH::GetMeshByIO( selected.First() );
02528       }
02529       SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
02530       aDlg->show();
02531       break;
02532     }
02533 
02534   case 802:                                     // CONSTRUCT GROUP
02535     {
02536       if ( !vtkwnd )
02537       {
02538         SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
02539                                   tr( "NOT_A_VTK_VIEWER" ) );
02540         break;
02541       }
02542 
02543       if(checkLock(aStudy)) break;
02544       EmitSignalDeactivateDialog();
02545 
02546       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02547       SALOME_ListIO selected;
02548       if( aSel )
02549         aSel->selectedObjects( selected );
02550 
02551       int nbSel = selected.Extent();
02552       if (nbSel == 1) {
02553         // check if submesh is selected
02554         Handle(SALOME_InteractiveObject) IObject = selected.First();
02555         if (IObject->hasEntry()) {
02556           _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
02557           if( aSObj ) {
02558             SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
02559             if (!aSubMesh->_is_nil()) {
02560               try {
02561                 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
02562                 // get submesh elements list by types
02563                 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
02564                 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
02565                 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
02566                 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
02567                 // create group for each type o elements
02568                 QString aName = IObject->getName();
02569                 QStringList anEntryList;
02570                 if (aNodes->length() > 0) {
02571                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
02572                   aGroup->Add(aNodes.inout());
02573                   if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
02574                     anEntryList.append( aSObject->GetID().c_str() );
02575                 }
02576                 if (aEdges->length() > 0) {
02577                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
02578                   aGroup->Add(aEdges.inout());
02579                   if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
02580                     anEntryList.append( aSObject->GetID().c_str() );
02581                 }
02582                 if (aFaces->length() > 0) {
02583                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
02584                   aGroup->Add(aFaces.inout());
02585                   if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
02586                     anEntryList.append( aSObject->GetID().c_str() );
02587                 }
02588                 if (aVolumes->length() > 0) {
02589                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
02590                   aGroup->Add(aVolumes.inout());
02591                   if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
02592                     anEntryList.append( aSObject->GetID().c_str() );
02593                 }
02594                 updateObjBrowser();
02595                 anApp->browseObjects( anEntryList );
02596               }
02597               catch(const SALOME::SALOME_Exception & S_ex){
02598                 SalomeApp_Tools::QtCatchCorbaException(S_ex);
02599               }
02600             }
02601           }
02602         }
02603       }
02604       else if(nbSel==0) {
02605         SUIT_MessageBox::warning(desktop(),
02606                                  tr("SMESH_WRN_WARNING"),
02607                                  tr("SMESH_WRN_NO_AVAILABLE_DATA"));
02608       }
02609       break;
02610     }
02611 
02612   case 803:                                     // EDIT GROUP
02613     {
02614       if ( !vtkwnd )
02615       {
02616         SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
02617                                   tr( "NOT_A_VTK_VIEWER" ) );
02618         break;
02619       }
02620 
02621       if(checkLock(aStudy)) break;
02622       EmitSignalDeactivateDialog();
02623 
02624       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02625       SALOME_ListIO selected;
02626       if( aSel )
02627         aSel->selectedObjects( selected );
02628 
02629       SALOME_ListIteratorOfListIO It (selected);
02630       int nbSelectedGroups = 0;
02631       for ( ; It.More(); It.Next() )
02632       {
02633         SMESH::SMESH_GroupBase_var aGroup =
02634           SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
02635         if (!aGroup->_is_nil()) {
02636           nbSelectedGroups++;
02637           SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
02638           aDlg->show();
02639         }
02640       }
02641       if (nbSelectedGroups == 0)
02642         {
02643           SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
02644           aDlg->show();
02645         }
02646       break;
02647     }
02648 
02649   case 804:                                     // Add elements to group
02650     {
02651       if(checkLock(aStudy)) break;
02652       if (myState == 800) {
02653         SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
02654         if (aDlg) aDlg->onAdd();
02655       }
02656       break;
02657     }
02658 
02659   case 805:                                     // Remove elements from group
02660     {
02661       if(checkLock(aStudy)) break;
02662       if (myState == 800) {
02663         SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
02664         if (aDlg) aDlg->onRemove();
02665       }
02666       break;
02667     }
02668 
02669   case 815:                                     // Edit GEOM GROUP as standalone
02670     {
02671       if ( !vtkwnd )
02672       {
02673         SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
02674                                   tr( "NOT_A_VTK_VIEWER" ) );
02675         break;
02676       }
02677 
02678       if(checkLock(aStudy)) break;
02679       EmitSignalDeactivateDialog();
02680 
02681       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02682       SALOME_ListIO selected;
02683       if( aSel )
02684         aSel->selectedObjects( selected );
02685 
02686       SALOME_ListIteratorOfListIO It (selected);
02687       for ( ; It.More(); It.Next() )
02688       {
02689         SMESH::SMESH_GroupOnGeom_var aGroup =
02690           SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
02691         if (!aGroup->_is_nil()) {
02692           SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
02693           aDlg->show();
02694         }
02695         else
02696         {
02697           SMESH::SMESH_GroupOnFilter_var aGroup =
02698             SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
02699           if (!aGroup->_is_nil()) {
02700             SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
02701             aDlg->show();
02702           }
02703         }
02704       }
02705       break;
02706     }
02707 
02708     case 810: // Union Groups
02709     case 811: // Intersect groups
02710     case 812: // Cut groups
02711     {
02712       if ( !vtkwnd )
02713       {
02714         SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
02715                                   tr( "NOT_A_VTK_VIEWER" ) );
02716         break;
02717       }
02718 
02719       if ( checkLock( aStudy ) )
02720         break;
02721 
02722       EmitSignalDeactivateDialog();
02723 
02724       SMESHGUI_GroupOpDlg* aDlg = 0;
02725       if ( theCommandID == 810 )
02726         aDlg = new SMESHGUI_UnionGroupsDlg( this );
02727       else if ( theCommandID == 811 )
02728         aDlg = new SMESHGUI_IntersectGroupsDlg( this );
02729       else
02730         aDlg = new SMESHGUI_CutGroupsDlg( this );
02731 
02732       aDlg->show();
02733 
02734       break;
02735     }
02736 
02737     case 814: // Create groups of entities from existing groups of superior dimensions
02738     {
02739       if ( checkLock( aStudy ) )
02740         break;
02741 
02742       EmitSignalDeactivateDialog();
02743       SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
02744       aDlg->show();
02745 
02746       break;
02747     }
02748 
02749     case 813: // Delete groups with their contents
02750     {
02751       if ( !vtkwnd )
02752       {
02753         SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
02754                                   tr( "NOT_A_VTK_VIEWER" ) );
02755         break;
02756       }
02757 
02758       if ( checkLock( aStudy ) )
02759         break;
02760 
02761       EmitSignalDeactivateDialog();
02762 
02763       ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
02764       break;
02765     }
02766 
02767   case 900:                                     // MESH INFOS
02768   case 903:                                     // WHAT IS
02769     {
02770       int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
02771       EmitSignalDeactivateDialog();
02772       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02773       SALOME_ListIO selected;
02774       if( aSel )
02775         aSel->selectedObjects( selected );
02776 
02777       if ( selected.Extent() > 1 ) { // a dlg for each IO
02778         SALOME_ListIteratorOfListIO It( selected );
02779         for ( ; It.More(); It.Next() ) {
02780           SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
02781           dlg->showInfo( It.Value() ); 
02782           dlg->show();
02783         }
02784       }
02785       else {
02786         SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
02787         dlg->show();
02788       }
02789       break;
02790     }
02791 
02792   case 904:                                     // FIND ELEM
02793     {
02794       startOperation( theCommandID );
02795       break;
02796     }
02797 
02798   case 1100:                                    // EDIT HYPOTHESIS
02799     {
02800       if(checkLock(aStudy)) break;
02801 
02802       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02803       SALOME_ListIO selected;
02804       if( aSel )
02805         aSel->selectedObjects( selected );
02806 
02807       int nbSel = selected.Extent();
02808 
02809       if (nbSel == 1) {
02810         Handle(SALOME_InteractiveObject) anIObject = selected.First();
02811         SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
02812 
02813         /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
02814         /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects                   */
02815         /* Warning : however by internal mechanism all subMeshes icons are changed !                     */
02816         if ( !aHypothesis->_is_nil() )
02817         {
02818           // BUG 0020378
02819           //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
02820           SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
02821           if (aCreator) {
02822             aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
02823           }
02824           else
02825           {
02826             // report error
02827           }
02828         }
02829       }
02830       break;
02831     }
02832   case 1102:                                    // REMOVE HYPOTHESIS / ALGORITHMS
02833     {
02834       if(checkLock(aStudy)) break;
02835       SUIT_OverrideCursor wc;
02836 
02837       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
02838       SALOME_ListIO selected;
02839       if( aSel )
02840         aSel->selectedObjects( selected, QString::null, false );
02841 
02842       SALOME_ListIteratorOfListIO It(selected);
02843       for (int i = 0; It.More(); It.Next(), i++) {
02844         Handle(SALOME_InteractiveObject) IObject = It.Value();
02845         SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
02846       }
02847       SALOME_ListIO l1;
02848       aSel->setSelectedObjects( l1 );
02849       updateObjBrowser();
02850       break;
02851     }
02852 
02853   case 4009:                                    // ELEM0D
02854   case 4010:                                    // EDGE
02855   case 4021:                                    // TRIANGLE
02856   case 4022:                                    // QUAD
02857   case 4023:                                    // POLYGON
02858   case 4031:                                    // TETRA
02859   case 4032:                                    // HEXA
02860   case 4133:                                    // PENTA
02861   case 4134:                                    // PYRAMID
02862   case 4135:                                    // OCTA12
02863     {
02864       if(checkLock(aStudy)) break;
02865       if ( vtkwnd ) {
02866         EmitSignalDeactivateDialog();
02867         SMDSAbs_EntityType type = SMDSEntity_Edge;
02868         switch (theCommandID) {
02869         case 4009:
02870           type = SMDSEntity_0D; break;
02871         case 4021:
02872           type = SMDSEntity_Triangle; break;
02873         case 4022:
02874           type = SMDSEntity_Quadrangle; break;
02875         case 4031:
02876           type = SMDSEntity_Tetra; break;
02877         case 4023:
02878           type = SMDSEntity_Polygon; break;
02879         case 4032:
02880           type = SMDSEntity_Hexa; break;
02881         case 4133:
02882           type = SMDSEntity_Penta; break;
02883         case 4134:
02884           type = SMDSEntity_Pyramid; break;
02885         case 4135:
02886           type = SMDSEntity_Hexagonal_Prism; break;
02887         default:;
02888         }
02889         ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
02890       }
02891       else {
02892         SUIT_MessageBox::warning(desktop(),
02893                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02894       }
02895       break;
02896     }
02897   case 4033:                                    // POLYHEDRON
02898     {
02899       if(checkLock(aStudy)) break;
02900       if ( vtkwnd ) {
02901         EmitSignalDeactivateDialog();
02902         ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
02903       }
02904       else {
02905         SUIT_MessageBox::warning(SMESHGUI::desktop(),
02906                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02907       }
02908       break;
02909     }
02910   case 4034:     // QUADRATIC EDGE
02911   case 4035:     // QUADRATIC TRIANGLE
02912   case 4036:     // QUADRATIC QUADRANGLE
02913   case 4136:     // BIQUADRATIC QUADRANGLE
02914   case 4037:     // QUADRATIC TETRAHEDRON
02915   case 4038:     // QUADRATIC PYRAMID
02916   case 4039:     // QUADRATIC PENTAHEDRON
02917   case 4040:     // QUADRATIC HEXAHEDRON
02918   case 4140:     // TRIQUADRATIC HEXAHEDRON
02919     {
02920       if(checkLock(aStudy)) break;
02921       if ( vtkwnd ) {
02922         EmitSignalDeactivateDialog();
02923         SMDSAbs_EntityType type;
02924 
02925         switch (theCommandID) {
02926         case 4034:
02927           type = SMDSEntity_Quad_Edge; break;
02928         case 4035:
02929           type = SMDSEntity_Quad_Triangle; break;
02930         case 4036:
02931           type = SMDSEntity_Quad_Quadrangle; break;
02932         case 4136:
02933           type = SMDSEntity_BiQuad_Quadrangle; break;
02934         case 4037:
02935           type = SMDSEntity_Quad_Tetra; break;
02936         case 4038:
02937           type = SMDSEntity_Quad_Pyramid; break;
02938         case 4039:
02939           type = SMDSEntity_Quad_Penta; break;
02940         case 4040:
02941           type = SMDSEntity_Quad_Hexa;
02942         case 4140:
02943           type = SMDSEntity_TriQuad_Hexa;
02944           break;
02945         default:;
02946         }
02947          ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
02948       }
02949       else {
02950         SUIT_MessageBox::warning(SMESHGUI::desktop(),
02951                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02952       }
02953       break;
02954     }
02955   case 4041:                                    // REMOVES NODES
02956     {
02957       if(checkLock(aStudy)) break;
02958       if ( vtkwnd ) {
02959         EmitSignalDeactivateDialog();
02960         ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
02961       }
02962       else {
02963         SUIT_MessageBox::warning(SMESHGUI::desktop(),
02964                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02965       }
02966       break;
02967     }
02968   case 4042:                                    // REMOVES ELEMENTS
02969     {
02970       if(checkLock(aStudy)) break;
02971       if( vtkwnd ) {
02972         EmitSignalDeactivateDialog();
02973         ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
02974       }
02975       else
02976         {
02977           SUIT_MessageBox::warning(SMESHGUI::desktop(),
02978                                    tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
02979         }
02980       break;
02981     }
02982   case 4043: {                                // CLEAR_MESH
02983 
02984     if(checkLock(aStudy)) break;
02985 
02986     SALOME_ListIO selected;
02987     if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
02988       aSel->selectedObjects( selected );
02989 
02990     SUIT_OverrideCursor wc;
02991     SALOME_ListIteratorOfListIO It (selected);
02992     for ( ; It.More(); It.Next() )
02993     {
02994       Handle(SALOME_InteractiveObject) IOS = It.Value();
02995       SMESH::SMESH_Mesh_var aMesh =
02996         SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
02997       if ( aMesh->_is_nil()) continue;
02998       try {
02999         SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
03000         aMesh->Clear();
03001         _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
03002         SMESH::ModifiedMesh( aMeshSObj, false, true);
03003         // hide groups and submeshes
03004         _PTR(ChildIterator) anIter =
03005           SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
03006         for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
03007         {
03008           _PTR(SObject) so = anIter->Value();
03009           SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
03010         }
03011       }
03012       catch (const SALOME::SALOME_Exception& S_ex){
03013         wc.suspend();
03014         SalomeApp_Tools::QtCatchCorbaException(S_ex);
03015         wc.resume();
03016       }
03017     }
03018     SMESH::UpdateView();
03019     updateObjBrowser();
03020     break;
03021   }
03022   case 4044:                                     // REMOVE ORPHAN NODES
03023     {
03024       if(checkLock(aStudy)) break;
03025       SALOME_ListIO selected;
03026       if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
03027         aSel->selectedObjects( selected );
03028       if ( selected.Extent() == 1 ) {
03029         Handle(SALOME_InteractiveObject) anIO = selected.First();
03030         SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
03031         if ( !aMesh->_is_nil() ) {
03032           bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
03033                                                     tr( "SMESH_WARNING" ),
03034                                                     tr( "REMOVE_ORPHAN_NODES_QUESTION"),
03035                                                     SUIT_MessageBox::Yes |
03036                                                     SUIT_MessageBox::No,
03037                                                     SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
03038           if( confirm ) {
03039             try {
03040               SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
03041               int removed = aMeshEditor->RemoveOrphanNodes();
03042               SUIT_MessageBox::information(SMESHGUI::desktop(),
03043                                            tr("SMESH_INFORMATION"),
03044                                            tr("NB_NODES_REMOVED").arg(removed));
03045               if ( removed > 0 ) {
03046                 SMESH::UpdateView();
03047                 SMESHGUI::Modified();
03048               }
03049             }
03050             catch (const SALOME::SALOME_Exception& S_ex) {
03051               SalomeApp_Tools::QtCatchCorbaException(S_ex);
03052             }
03053             catch (...) {
03054             }
03055           }
03056         }
03057       }
03058       break;
03059     }
03060   case 4051:                                    // RENUMBERING NODES
03061     {
03062       if(checkLock(aStudy)) break;
03063       if( vtkwnd ) {
03064         EmitSignalDeactivateDialog();
03065         ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
03066       }
03067       else
03068         {
03069           SUIT_MessageBox::warning(SMESHGUI::desktop(),
03070                                    tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03071         }
03072       break;
03073     }
03074   case 4052:                                    // RENUMBERING ELEMENTS
03075     {
03076       if(checkLock(aStudy)) break;
03077       if ( vtkwnd ) {
03078         EmitSignalDeactivateDialog();
03079         ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
03080       }
03081       else
03082         {
03083           SUIT_MessageBox::warning(SMESHGUI::desktop(),
03084                                    tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03085         }
03086       break;
03087     }
03088   case 4061:                                   // TRANSLATION
03089     {
03090       if(checkLock(aStudy)) break;
03091       if ( vtkwnd ) {
03092         EmitSignalDeactivateDialog();
03093         ( new SMESHGUI_TranslationDlg( this ) )->show();
03094       }
03095       else {
03096         SUIT_MessageBox::warning(SMESHGUI::desktop(),
03097                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03098       }
03099       break;
03100     }
03101   case 4062:                                   // ROTATION
03102     {
03103       if(checkLock(aStudy)) break;
03104       if( vtkwnd ) {
03105         EmitSignalDeactivateDialog();
03106         ( new SMESHGUI_RotationDlg( this ) )->show();
03107       }
03108       else {
03109         SUIT_MessageBox::warning(SMESHGUI::desktop(),
03110                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03111       }
03112       break;
03113     }
03114   case 4063:                                   // SYMMETRY
03115     {
03116       if(checkLock(aStudy)) break;
03117       if(vtkwnd) {
03118         EmitSignalDeactivateDialog();
03119         ( new SMESHGUI_SymmetryDlg( this ) )->show();
03120       }
03121       else {
03122         SUIT_MessageBox::warning(SMESHGUI::desktop(),
03123                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03124       }
03125       break;
03126     }
03127   case 4064:                                   // SEWING
03128     {
03129       if(checkLock(aStudy)) break;
03130       if(vtkwnd) {
03131         EmitSignalDeactivateDialog();
03132         ( new SMESHGUI_SewingDlg( this ) )->show();
03133       }
03134       else {
03135         SUIT_MessageBox::warning(SMESHGUI::desktop(),
03136                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03137       }
03138       break;
03139     }
03140   case 4065:                                   // MERGE NODES
03141     {
03142       if(checkLock(aStudy)) break;
03143       if(vtkwnd) {
03144         EmitSignalDeactivateDialog();
03145         ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
03146       }
03147       else {
03148         SUIT_MessageBox::warning(SMESHGUI::desktop(),
03149                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03150       }
03151       break;
03152     }
03153   case 4066:                                   // MERGE EQUAL ELEMENTS
03154     {
03155       if (checkLock(aStudy)) break;
03156       if (vtkwnd) {
03157         EmitSignalDeactivateDialog();
03158         ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
03159       } else {
03160         SUIT_MessageBox::warning(SMESHGUI::desktop(),
03161                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03162       }
03163       break;
03164     }
03165 
03166   case 4067: // MAKE MESH PASS THROUGH POINT
03167     startOperation( 4067 );
03168     break;
03169 
03170   case 4068: // SCALE
03171     {
03172       if(checkLock(aStudy)) break;
03173       if ( vtkwnd ) {
03174         EmitSignalDeactivateDialog();
03175         ( new SMESHGUI_ScaleDlg( this ) )->show();
03176       }
03177       else {
03178         SUIT_MessageBox::warning(SMESHGUI::desktop(),
03179                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03180       }
03181       break;
03182     }
03183 
03184   case 4069: // DUPLICATE NODES
03185     {
03186       if(checkLock(aStudy)) break;
03187       if ( vtkwnd ) {
03188         EmitSignalDeactivateDialog();
03189         ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
03190       }
03191       else {
03192         SUIT_MessageBox::warning(SMESHGUI::desktop(),
03193                                  tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
03194       }
03195       break;
03196     }
03197 
03198   case 5105: // Library of selection filters
03199   {
03200     static QList<int> aTypes;
03201     if ( aTypes.isEmpty() )
03202     {
03203       aTypes.append( SMESH::NODE );
03204       aTypes.append( SMESH::EDGE );
03205       aTypes.append( SMESH::FACE );
03206       aTypes.append( SMESH::VOLUME );
03207     }
03208     if (!myFilterLibraryDlg)
03209       myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
03210     else if (myFilterLibraryDlg->isHidden())
03211       myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
03212     myFilterLibraryDlg->raise();
03213   }
03214   break;
03215 
03216   case 6017:                                    // CONTROLS
03217   case 6016:
03218   case 6015:
03219   case 6014:
03220   case 6013:
03221   case 6012:
03222   case 6011:
03223   case 6001:
03224   case 6018:
03225   case 6019:
03226   case 6002:
03227   case 6003:
03228   case 6004:
03229   case 6005:
03230   case 6009:
03231   case 6021:
03232   case 6022:
03233   case 6023:
03234   case 6024:
03235   case 6025:
03236   case 6026:
03237   case 6027:
03238   case 6028:
03239   case 6029:
03240   case 6030:
03241   case 6031:
03242     if ( vtkwnd ) {
03243 
03244       LightApp_SelectionMgr* mgr = selectionMgr();
03245       SALOME_ListIO selected; mgr->selectedObjects( selected );
03246 
03247       if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
03248         _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
03249         if ( SO ) {
03250           CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
03251           SMESH::SMESH_Mesh_var      aMesh    = SMESH::SMESH_Mesh::_narrow( aObject );
03252           SMESH::SMESH_subMesh_var   aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
03253           SMESH::SMESH_GroupBase_var aGroup   = SMESH::SMESH_GroupBase::_narrow( aObject );
03254           if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
03255             ::Control( theCommandID );
03256             break;
03257           }
03258         }
03259       }
03260       SUIT_MessageBox::warning(desktop(),
03261                                tr( "SMESH_WRN_WARNING" ),
03262                                tr( "SMESH_BAD_SELECTION" ) );
03263       break;
03264     }
03265     else {
03266       SUIT_MessageBox::warning(desktop(),
03267                                tr( "SMESH_WRN_WARNING" ),
03268                                tr( "NOT_A_VTK_VIEWER" ) );
03269     }
03270     break;
03271   case 9010:
03272     {
03273       LightApp_SelectionMgr* mgr = selectionMgr();
03274       SALOME_ListIO selected; mgr->selectedObjects( selected );
03275 
03276       SALOME_ListIteratorOfListIO it(selected);
03277       for( ; it.More(); it.Next()) {
03278         Handle(SALOME_InteractiveObject) anIObject = it.Value();
03279         if(anIObject->hasEntry()) {
03280           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
03281             anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
03282           }
03283         }
03284       }
03285       break;
03286     }
03287   case 9011:
03288     {
03289       LightApp_SelectionMgr* mgr = selectionMgr();
03290       SALOME_ListIO selected; mgr->selectedObjects( selected );
03291 
03292       SALOME_ListIteratorOfListIO it(selected);
03293       for( ; it.More(); it.Next()) {
03294         Handle(SALOME_InteractiveObject) anIObject = it.Value();
03295         if(anIObject->hasEntry())
03296           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
03297             anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
03298           }
03299       }
03300       break;
03301     }
03302   case 501:
03303   case 502:
03304     {
03305       int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
03306       EmitSignalDeactivateDialog();
03307       SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
03308       dlg->show();
03309       break;
03310     }
03311   }
03312 
03313   anApp->updateActions(); //SRN: To update a Save button in the toolbar
03314   //updateObjBrowser();
03315   return true;
03316 }
03317 
03318 //=============================================================================
03322 //=============================================================================
03323 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
03324 {
03325   return false;
03326 }
03327 
03328 //=============================================================================
03332 //=============================================================================
03333 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
03334 {
03335   return true;
03336 }
03337 
03338 //=============================================================================
03342 //=============================================================================
03343 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
03344 {
03345   return true;
03346 }
03347 
03348 //=============================================================================
03352 //=============================================================================
03353 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
03354                                   SUIT_ViewWindow* wnd )
03355 {
03356   if(theIO->hasEntry()){
03357     //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
03358     SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
03359   }
03360 }
03361 
03362 //=======================================================================
03363 // function : createSMESHAction
03364 // purpose  :
03365 //=======================================================================
03366 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
03367                                   const int key, const bool toggle, const QString& shortcutAction  )
03368 {
03369   QIcon icon;
03370   QWidget* parent = application()->desktop();
03371   SUIT_ResourceMgr* resMgr = resourceMgr();
03372   QPixmap pix;
03373   if ( !icon_id.isEmpty() )
03374     pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
03375   else
03376     pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
03377   if ( !pix.isNull() )
03378     icon = QIcon( pix );
03379 
03380   QString tooltip    = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
03381           menu       = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
03382           status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
03383 
03384   createAction( id, tooltip, icon, menu, status_bar, key, parent,
03385                 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
03386 }
03387 
03388 //=======================================================================
03389 // function : createPopupItem
03390 // purpose  :
03391 //=======================================================================
03392 void SMESHGUI::createPopupItem( const int id,
03393                                 const QString& clients,
03394                                 const QString& types,
03395                                 const QString& theRule,
03396                                 const int pId )
03397 {
03398   int parentId = pId;
03399   if( pId!=-1 )
03400     parentId = popupMgr()->actionId( action( pId ) );
03401 
03402   if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
03403     popupMgr()->insert( action( id ), parentId, 0 );
03404 
03405   QString lc = "$";        // VSR : instead of QtxPopupSelection::defEquality();
03406   QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
03407   QString rule = "(%1) and (%2) and (%3)";
03408   rule = rule.arg( QString( "%1>0" ).arg( dc ) );
03409   if( clients.isEmpty() )
03410     rule = rule.arg( QString( "true" ) );
03411   else
03412     rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
03413   rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
03414   rule += theRule;
03415 
03416   bool cont = myRules.contains( id );
03417   if( cont )
03418     rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
03419 
03420   popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
03421   myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
03422 }
03423 
03424 //=======================================================================
03425 // function : initialize
03426 // purpose  :
03427 //=======================================================================
03428 void SMESHGUI::initialize( CAM_Application* app )
03429 {
03430   SalomeApp_Module::initialize( app );
03431 
03432 //   SUIT_ResourceMgr* mgr = app->resourceMgr();
03433 //   if ( mgr )
03434   /* Automatic Update flag */
03435 //     myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
03436 
03437   // ----- create actions --------------
03438 
03439   createSMESHAction(  111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
03440   createSMESHAction(  112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
03441   createSMESHAction(  113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
03442   createSMESHAction(  114, "NUM" );
03443   createSMESHAction(  115, "IMPORT_STL" );
03444   createSMESHAction(  116, "IMPORT_CGNS" );
03445   createSMESHAction(  117, "IMPORT_SAUV" );
03446   createSMESHAction(  121, "DAT" );
03447   createSMESHAction(  122, "MED" );
03448   createSMESHAction(  123, "UNV" );
03449   createSMESHAction(  140, "STL" );
03450   createSMESHAction(  142, "CGNS" );
03451   createSMESHAction(  144, "SAUV" );
03452   createSMESHAction(  124, "EXPORT_DAT" );
03453   createSMESHAction(  125, "EXPORT_MED" );
03454   createSMESHAction(  126, "EXPORT_UNV" );
03455   createSMESHAction(  141, "EXPORT_STL" );
03456   createSMESHAction(  143, "EXPORT_CGNS" );
03457   createSMESHAction(  145, "EXPORT_SAUV" );
03458   createSMESHAction(  150, "FILE_INFO" );
03459   createSMESHAction(   33, "DELETE",          "ICON_DELETE", Qt::Key_Delete );
03460   createSMESHAction( 5105, "SEL_FILTER_LIB" );
03461   createSMESHAction(  701, "COMPUTE",         "ICON_COMPUTE" );
03462   createSMESHAction(  702, "CREATE_MESH",     "ICON_DLG_INIT_MESH" );
03463   createSMESHAction(  703, "CREATE_SUBMESH",  "ICON_DLG_ADD_SUBMESH" );
03464   createSMESHAction(  704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
03465   createSMESHAction(  705, "COPY_MESH",       "ICON_COPY_MESH" );
03466   createSMESHAction(  710, "BUILD_COMPOUND",  "ICON_BUILD_COMPOUND" );
03467   createSMESHAction(  711, "PRECOMPUTE",      "ICON_PRECOMPUTE" );
03468   createSMESHAction(  712, "EVALUATE",        "ICON_COMPUTE" );
03469   createSMESHAction(  713, "MESH_ORDER",      "ICON_COMPUTE" );
03470   createSMESHAction(  806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
03471   createSMESHAction(  801, "CREATE_GROUP",    "ICON_CREATE_GROUP" );
03472   createSMESHAction(  802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
03473   createSMESHAction(  803, "EDIT_GROUP",      "ICON_EDIT_GROUP" );
03474   createSMESHAction(  815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
03475   createSMESHAction(  804, "ADD" );
03476   createSMESHAction(  805, "REMOVE" );
03477   createSMESHAction(  810, "UN_GROUP",        "ICON_UNION" );
03478   createSMESHAction(  811, "INT_GROUP",       "ICON_INTERSECT" );
03479   createSMESHAction(  812, "CUT_GROUP",       "ICON_CUT" );
03480   createSMESHAction(  814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
03481   createSMESHAction(  813, "DEL_GROUP",       "ICON_DEL_GROUP" );
03482   createSMESHAction(  900, "ADV_INFO",        "ICON_ADV_INFO" );
03483   //createSMESHAction(  902, "STD_INFO",        "ICON_STD_INFO" );
03484   //createSMESHAction(  903, "WHAT_IS",         "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
03485   createSMESHAction(  904, "FIND_ELEM",       "ICON_FIND_ELEM" );
03486   createSMESHAction( 6001, "LENGTH",          "ICON_LENGTH",        0, true );
03487   createSMESHAction( 6002, "FREE_EDGE",       "ICON_FREE_EDGE",     0, true );
03488   createSMESHAction( 6021, "FREE_FACES",      "ICON_FREE_FACES",    0, true );
03489   createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D",  "ICON_MAX_ELEMENT_LENGTH_2D",   0, true );
03490   createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D",  "ICON_MAX_ELEMENT_LENGTH_3D",   0, true );
03491   createSMESHAction( 6024, "BARE_BORDER_VOLUME",     "ICON_BARE_BORDER_VOLUME",      0, true );
03492   createSMESHAction( 6025, "BARE_BORDER_FACE",       "ICON_BARE_BORDER_FACE",        0, true );
03493   createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
03494   createSMESHAction( 6027, "OVER_CONSTRAINED_FACE",  "ICON_OVER_CONSTRAINED_FACE",   0, true );
03495   createSMESHAction( 6028, "EQUAL_NODE",      "ICON_EQUAL_NODE",    0, true );
03496   createSMESHAction( 6029, "EQUAL_EDGE",      "ICON_EQUAL_EDGE",    0, true );
03497   createSMESHAction( 6030, "EQUAL_FACE",      "ICON_EQUAL_FACE",    0, true );
03498   createSMESHAction( 6031, "EQUAL_VOLUME",    "ICON_EQUAL_VOLUME",  0, true );
03499   createSMESHAction( 6003, "FREE_BORDER",     "ICON_FREE_EDGE_2D",  0, true );
03500   createSMESHAction( 6004, "CONNECTION",      "ICON_CONNECTION",    0, true );
03501   createSMESHAction( 6005, "FREE_NODE",       "ICON_FREE_NODE",     0, true );
03502   createSMESHAction( 6011, "AREA",            "ICON_AREA",          0, true );
03503   createSMESHAction( 6012, "TAPER",           "ICON_TAPER",         0, true );
03504   createSMESHAction( 6013, "ASPECT",          "ICON_ASPECT",        0, true );
03505   createSMESHAction( 6014, "MIN_ANG",         "ICON_ANGLE",         0, true );
03506   createSMESHAction( 6015, "WARP",            "ICON_WARP",          0, true );
03507   createSMESHAction( 6016, "SKEW",            "ICON_SKEW",          0, true );
03508   createSMESHAction( 6017, "ASPECT_3D",       "ICON_ASPECT_3D",     0, true );
03509   createSMESHAction( 6018, "LENGTH_2D",       "ICON_LENGTH_2D",     0, true );
03510   createSMESHAction( 6019, "CONNECTION_2D",   "ICON_CONNECTION_2D", 0, true );
03511   createSMESHAction( 6009, "VOLUME_3D",       "ICON_VOLUME_3D",     0, true );
03512   createSMESHAction( 4000, "NODE",            "ICON_DLG_NODE" );
03513   createSMESHAction( 4009, "ELEM0D",          "ICON_DLG_ELEM0D" );
03514   createSMESHAction( 4010, "EDGE",            "ICON_DLG_EDGE" );
03515   createSMESHAction( 4021, "TRIANGLE",        "ICON_DLG_TRIANGLE" );
03516   createSMESHAction( 4022, "QUAD",            "ICON_DLG_QUADRANGLE" );
03517   createSMESHAction( 4023, "POLYGON",         "ICON_DLG_POLYGON" );
03518   createSMESHAction( 4031, "TETRA",           "ICON_DLG_TETRAS" );
03519   createSMESHAction( 4032, "HEXA",            "ICON_DLG_HEXAS" );
03520   createSMESHAction( 4133, "PENTA",           "ICON_DLG_PENTA" );
03521   createSMESHAction( 4134, "PYRAMID",         "ICON_DLG_PYRAMID" );
03522   createSMESHAction( 4135, "OCTA",            "ICON_DLG_OCTA" );
03523   createSMESHAction( 4033, "POLYHEDRON",              "ICON_DLG_POLYHEDRON" );
03524   createSMESHAction( 4034, "QUADRATIC_EDGE",          "ICON_DLG_QUADRATIC_EDGE" );
03525   createSMESHAction( 4035, "QUADRATIC_TRIANGLE",      "ICON_DLG_QUADRATIC_TRIANGLE" );
03526   createSMESHAction( 4036, "QUADRATIC_QUADRANGLE",    "ICON_DLG_QUADRATIC_QUADRANGLE" );
03527   createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE",  "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
03528   createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON",   "ICON_DLG_QUADRATIC_TETRAHEDRON" );
03529   createSMESHAction( 4038, "QUADRATIC_PYRAMID",       "ICON_DLG_QUADRATIC_PYRAMID" );
03530   createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON",   "ICON_DLG_QUADRATIC_PENTAHEDRON" );
03531   createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON",    "ICON_DLG_QUADRATIC_HEXAHEDRON" );
03532   createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
03533   createSMESHAction( 4041, "REMOVE_NODES",          "ICON_DLG_REM_NODE" );
03534   createSMESHAction( 4042, "REMOVE_ELEMENTS",       "ICON_DLG_REM_ELEMENT" );
03535   createSMESHAction( 4044, "REMOVE_ORPHAN_NODES",   "ICON_DLG_REM_ORPHAN_NODES" );
03536   createSMESHAction( 4043, "CLEAR_MESH"    ,  "ICON_CLEAR_MESH" );
03537   createSMESHAction( 4051, "RENUM_NODES",     "ICON_DLG_RENUMBERING_NODES" );
03538   createSMESHAction( 4052, "RENUM_ELEMENTS",  "ICON_DLG_RENUMBERING_ELEMENTS" );
03539   createSMESHAction( 4061, "TRANS",           "ICON_SMESH_TRANSLATION_VECTOR" );
03540   createSMESHAction( 4062, "ROT",             "ICON_DLG_MESH_ROTATION" );
03541   createSMESHAction( 4063, "SYM",             "ICON_SMESH_SYMMETRY_PLANE" );
03542   createSMESHAction( 4064, "SEW",             "ICON_SMESH_SEWING_FREEBORDERS" );
03543   createSMESHAction( 4065, "MERGE",           "ICON_SMESH_MERGE_NODES" );
03544   createSMESHAction( 4066, "MERGE_ELEMENTS",  "ICON_DLG_MERGE_ELEMENTS" );
03545   createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
03546   createSMESHAction( 4068, "SCALE",           "ICON_DLG_MESH_SCALE" );
03547   createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
03548   createSMESHAction(  407, "INV",             "ICON_DLG_MESH_DIAGONAL" );
03549   createSMESHAction(  408, "UNION2",          "ICON_UNION2TRI" );
03550   createSMESHAction(  409, "ORIENT",          "ICON_DLG_MESH_ORIENTATION" );
03551   createSMESHAction(  410, "UNION",           "ICON_UNIONTRI" );
03552   createSMESHAction(  411, "CUT",             "ICON_CUTQUAD" );
03553   createSMESHAction(  412, "SMOOTH",          "ICON_DLG_SMOOTHING" );
03554   createSMESHAction(  413, "EXTRUSION",       "ICON_EXTRUSION" );
03555   createSMESHAction(  414, "REVOLUTION",      "ICON_REVOLUTION" );
03556   createSMESHAction(  415, "MAP",             "ICON_MAP" );
03557   createSMESHAction(  416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
03558   createSMESHAction(  417, "CONV_TO_QUAD",    "ICON_CONV_TO_QUAD" );
03559   createSMESHAction(  418, "2D_FROM_3D",      "ICON_2D_FROM_3D" );
03560   createSMESHAction(  419, "SPLIT_TO_TETRA",  "ICON_SPLIT_TO_TETRA" );
03561   createSMESHAction(  200, "RESET" );
03562   createSMESHAction(  201, "SCALAR_BAR_PROP" );
03563   createSMESHAction(  2021, "SAVE_DISTRIBUTION" );
03564   createSMESHAction(  2022, "SHOW_DISTRIBUTION","",0, true );
03565 #ifndef DISABLE_PLOT2DVIEWER
03566   createSMESHAction(  2023, "PLOT_DISTRIBUTION" );
03567 #endif
03568   createSMESHAction(  211, "WIRE",           "ICON_WIRE", 0, true );
03569   createSMESHAction(  212, "SHADE",          "ICON_SHADE", 0, true );
03570   createSMESHAction(  213, "SHRINK",         "ICON_SHRINK", 0, true );
03571   createSMESHAction(  214, "UPDATE",         "ICON_UPDATE" );
03572   createSMESHAction(  215, "NODES",          "ICON_POINTS", 0, true );
03573   createSMESHAction(  216, "ELEMS0D",        "ICON_DLG_ELEM0D", 0, true );
03574   createSMESHAction(  217, "EDGES",          "ICON_DLG_EDGE", 0, true );
03575   createSMESHAction(  218, "FACES",          "ICON_DLG_TRIANGLE", 0, true );
03576   createSMESHAction(  219, "VOLUMES",        "ICON_DLG_TETRAS", 0, true );
03577   createSMESHAction(  220, "ALL" );
03578   createSMESHAction(  221, "FACE_ORIENTATION", "", 0, true );
03579 
03580   createSMESHAction(  231, "LINE_REPRESENTATION", "", 0, true );
03581   createSMESHAction(  232, "ARC_REPRESENTATION", "", 0, true );
03582 
03583   createSMESHAction( 1100, "EDIT_HYPO" );
03584   createSMESHAction( 1102, "UNASSIGN" );
03585   createSMESHAction( 9010, "NUM_NODES", "", 0, true );
03586   createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
03587   createSMESHAction( 1131, "DISPMODE" );
03588   createSMESHAction( 1132, "COLORS" );
03589   createSMESHAction( 1133, "TRANSP" );
03590   createSMESHAction( 1134, "CLIP" );
03591   createSMESHAction( 1135, "DISP_ENT" );
03592   createSMESHAction( 1136, "AUTO_COLOR" );
03593   createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
03594   createSMESHAction( 2000, "CTRL" );
03595 
03596   createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
03597   createSMESHAction( 502, "MEASURE_BND_BOX",  "ICON_MEASURE_BND_BOX" );
03598 
03599   createSMESHAction( 300, "HIDE" );
03600   createSMESHAction( 301, "SHOW" );
03601   createSMESHAction( 302, "DISPLAY_ONLY" );
03602 
03603   // ----- create menu --------------
03604   int fileId    = createMenu( tr( "MEN_FILE" ),    -1,  1 ),
03605       editId    = createMenu( tr( "MEN_EDIT" ),    -1,  3 ),
03606       toolsId   = createMenu( tr( "MEN_TOOLS" ),   -1,  5, 50 ),
03607       meshId    = createMenu( tr( "MEN_MESH" ),    -1, 70, 10 ),
03608       ctrlId    = createMenu( tr( "MEN_CTRL" ),    -1, 60, 10 ),
03609       modifyId  = createMenu( tr( "MEN_MODIFY" ),  -1, 40, 10 ),
03610       measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
03611       viewId    = createMenu( tr( "MEN_VIEW" ),    -1,  2 );
03612 
03613   createMenu( separator(), fileId );
03614 
03615   int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
03616       exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
03617       nodeId   = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
03618       edgeId   = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
03619       faceId   = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
03620       volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
03621       addId    = createMenu( tr( "MEN_ADD" ),    modifyId, 402 ),
03622       removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
03623       renumId  = createMenu( tr( "MEN_RENUM" ),  modifyId, 404 ),
03624       transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
03625 
03626   createMenu( 111, importId, -1 );
03627   createMenu( 112, importId, -1 );
03628   createMenu( 113, importId, -1 );
03629   createMenu( 115, importId, -1 );
03630 #ifdef WITH_CGNS
03631   createMenu( 116, importId, -1 );
03632 #endif
03633   createMenu( 117, importId, -1 );
03634   createMenu( 121, exportId, -1 );
03635   createMenu( 122, exportId, -1 );
03636   createMenu( 123, exportId, -1 );
03637   createMenu( 140, exportId, -1 ); // export to STL
03638 #ifdef WITH_CGNS
03639   createMenu( 142, exportId, -1 ); // export to CGNS
03640 #endif
03641   createMenu( 144, exportId, -1 ); // export to SAUV
03642   createMenu( separator(), fileId, 10 );
03643 
03644   createMenu( 33, editId, -1 );
03645 
03646   createMenu( 5105, toolsId, -1 );
03647 
03648   createMenu( 702, meshId, -1 ); // "Mesh" menu
03649   createMenu( 703, meshId, -1 );
03650   createMenu( 704, meshId, -1 );
03651   createMenu( 710, meshId, -1 );
03652   createMenu( 705, meshId, -1 );
03653   createMenu( separator(), meshId, -1 );
03654   createMenu( 701, meshId, -1 );
03655   createMenu( 711, meshId, -1 );
03656   createMenu( 712, meshId, -1 );
03657   createMenu( 713, meshId, -1 );
03658   createMenu( separator(), meshId, -1 );
03659   createMenu( 801, meshId, -1 );
03660   createMenu( 806, meshId, -1 );
03661   createMenu( 802, meshId, -1 );
03662   createMenu( 803, meshId, -1 );
03663   createMenu( 815, meshId, -1 );
03664   createMenu( separator(), meshId, -1 );
03665   createMenu( 810, meshId, -1 );
03666   createMenu( 811, meshId, -1 );
03667   createMenu( 812, meshId, -1 );
03668   createMenu( separator(), meshId, -1 );
03669   createMenu( 814, meshId, -1 );
03670   createMenu( separator(), meshId, -1 );
03671   createMenu( 900, meshId, -1 );
03672   //createMenu( 902, meshId, -1 );
03673   //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
03674   createMenu( 904, meshId, -1 );
03675   createMenu( separator(), meshId, -1 );
03676 
03677   createMenu( 6005, nodeId, -1 );
03678   createMenu( 6028, nodeId, -1 );
03679   createMenu( 6002, edgeId, -1 );
03680   createMenu( 6003, edgeId, -1 );
03681   createMenu( 6001, edgeId, -1 );
03682   createMenu( 6004, edgeId, -1 );
03683   createMenu( 6029, edgeId, -1 );
03684   createMenu( 6021, faceId, -1 );
03685   createMenu( 6025, faceId, -1 );
03686   createMenu( 6027, faceId, -1 );
03687   createMenu( 6018, faceId, -1 );
03688   createMenu( 6019, faceId, -1 );
03689   createMenu( 6011, faceId, -1 );
03690   createMenu( 6012, faceId, -1 );
03691   createMenu( 6013, faceId, -1 );
03692   createMenu( 6014, faceId, -1 );
03693   createMenu( 6015, faceId, -1 );
03694   createMenu( 6016, faceId, -1 );
03695   createMenu( 6022, faceId, -1 );
03696   createMenu( 6030, faceId, -1 );
03697   createMenu( 6017, volumeId, -1 );
03698   createMenu( 6009, volumeId, -1 );
03699   createMenu( 6023, volumeId, -1 );
03700   createMenu( 6024, volumeId, -1 );
03701   createMenu( 6026, volumeId, -1 );
03702   createMenu( 6031, volumeId, -1 );
03703 
03704   createMenu( 4000, addId, -1 );
03705   createMenu( 4009, addId, -1 );
03706   createMenu( 4010, addId, -1 );
03707   createMenu( 4021, addId, -1 );
03708   createMenu( 4022, addId, -1 );
03709   createMenu( 4023, addId, -1 );
03710   createMenu( 4031, addId, -1 );
03711   createMenu( 4032, addId, -1 );
03712   createMenu( 4133, addId, -1 );
03713   createMenu( 4134, addId, -1 );
03714   createMenu( 4135, addId, -1 );
03715   createMenu( 4033, addId, -1 );
03716   createMenu( separator(), addId, -1 );
03717   createMenu( 4034, addId, -1 );
03718   createMenu( 4035, addId, -1 );
03719   createMenu( 4036, addId, -1 );
03720   createMenu( 4136, addId, -1 );
03721   createMenu( 4037, addId, -1 );
03722   createMenu( 4038, addId, -1 );
03723   createMenu( 4039, addId, -1 );
03724   createMenu( 4040, addId, -1 );
03725   createMenu( 4140, addId, -1 );
03726 
03727   createMenu( 4041, removeId, -1 );
03728   createMenu( 4042, removeId, -1 );
03729   createMenu( 4044, removeId, -1 );
03730   createMenu( separator(), removeId, -1 );
03731   createMenu( 813, removeId, -1 );
03732   createMenu( separator(), removeId, -1 );
03733   createMenu( 4043, removeId, -1 );
03734 
03735   createMenu( 4051, renumId, -1 );
03736   createMenu( 4052, renumId, -1 );
03737 
03738   createMenu( 4061, transfId, -1 );
03739   createMenu( 4062, transfId, -1 );
03740   createMenu( 4063, transfId, -1 );
03741   createMenu( 4068, transfId, -1 );
03742   createMenu( 4064, transfId, -1 );
03743   createMenu( 4065, transfId, -1 );
03744   createMenu( 4066, transfId, -1 );
03745   createMenu( 4069, transfId, -1 );
03746 
03747   createMenu( 4067,modifyId, -1 );
03748   createMenu( 407, modifyId, -1 );
03749   createMenu( 408, modifyId, -1 );
03750   createMenu( 409, modifyId, -1 );
03751   createMenu( 410, modifyId, -1 );
03752   createMenu( 411, modifyId, -1 );
03753   createMenu( 419, modifyId, -1 );
03754   createMenu( 412, modifyId, -1 );
03755   createMenu( 413, modifyId, -1 );
03756   createMenu( 416, modifyId, -1 );
03757   createMenu( 414, modifyId, -1 );
03758   createMenu( 415, modifyId, -1 );
03759   createMenu( 417, modifyId, -1 );
03760   createMenu( 418, modifyId, -1 );
03761 
03762   createMenu( 501, measureId, -1 );
03763   createMenu( 502, measureId, -1 );
03764   createMenu( 214, viewId, -1 );
03765 
03766   // ----- create toolbars --------------
03767   int meshTb     = createTool( tr( "TB_MESH" ) ),
03768       ctrlTb     = createTool( tr( "TB_CTRL" ) ),
03769       addRemTb   = createTool( tr( "TB_ADD_REMOVE" ) ),
03770       modifyTb   = createTool( tr( "TB_MODIFY" ) ),
03771       dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
03772 
03773   createTool( 702, meshTb );
03774   createTool( 703, meshTb );
03775   createTool( 704, meshTb );
03776   createTool( 710, meshTb );
03777   createTool( 705, meshTb );
03778   createTool( separator(), meshTb );
03779   createTool( 701, meshTb );
03780   createTool( 711, meshTb );
03781   createTool( 712, meshTb );
03782   createTool( 713, meshTb );
03783   createTool( separator(), meshTb );
03784   createTool( 801, meshTb );
03785   createTool( 806, meshTb );
03786   createTool( 802, meshTb );
03787   createTool( 803, meshTb );
03788   //createTool( 815, meshTb );
03789   createTool( separator(), meshTb );
03790   createTool( 900, meshTb );
03791   //createTool( 902, meshTb );
03792   //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
03793   createTool( 904, meshTb );
03794   createTool( separator(), meshTb );
03795 
03796   createTool( 6005, ctrlTb );
03797   createTool( 6028, ctrlTb );
03798   createTool( separator(), ctrlTb );
03799   createTool( 6002, ctrlTb );
03800   createTool( 6003, ctrlTb );
03801   createTool( 6001, ctrlTb );
03802   createTool( 6004, ctrlTb );
03803   createTool( 6029, ctrlTb );
03804   createTool( separator(), ctrlTb );
03805   createTool( 6021, ctrlTb );
03806   createTool( 6025, ctrlTb );
03807   createTool( 6027, ctrlTb );
03808   createTool( 6018, ctrlTb );
03809   createTool( 6019, ctrlTb );
03810   createTool( 6011, ctrlTb );
03811   createTool( 6012, ctrlTb );
03812   createTool( 6013, ctrlTb );
03813   createTool( 6014, ctrlTb );
03814   createTool( 6015, ctrlTb );
03815   createTool( 6016, ctrlTb );
03816   createTool( 6022, ctrlTb );
03817   createTool( 6030, ctrlTb );
03818   createTool( separator(), ctrlTb );
03819   createTool( 6017, ctrlTb );
03820   createTool( 6009, ctrlTb );
03821   createTool( 6023, ctrlTb );
03822   createTool( 6024, ctrlTb );
03823   createTool( 6026, ctrlTb );
03824   createTool( 6031, ctrlTb );
03825   createTool( separator(), ctrlTb );
03826 
03827   createTool( 4000, addRemTb );
03828   createTool( 4009, addRemTb );
03829   createTool( 4010, addRemTb );
03830   createTool( 4021, addRemTb );
03831   createTool( 4022, addRemTb );
03832   createTool( 4023, addRemTb );
03833   createTool( 4031, addRemTb );
03834   createTool( 4032, addRemTb );
03835   createTool( 4133, addRemTb );
03836   createTool( 4134, addRemTb );
03837   createTool( 4135, addRemTb );
03838   createTool( 4033, addRemTb );
03839   createTool( separator(), addRemTb );
03840   createTool( 4034, addRemTb );
03841   createTool( 4035, addRemTb );
03842   createTool( 4036, addRemTb );
03843   createTool( 4136, addRemTb );
03844   createTool( 4037, addRemTb );
03845   createTool( 4038, addRemTb );
03846   createTool( 4039, addRemTb );
03847   createTool( 4040, addRemTb );
03848   createTool( 4140, addRemTb );
03849   createTool( separator(), addRemTb );
03850   createTool( 4041, addRemTb );
03851   createTool( 4042, addRemTb );
03852   createTool( 4044, addRemTb );
03853   createTool( 4043, addRemTb );
03854   createTool( separator(), addRemTb );
03855   createTool( 4051, addRemTb );
03856   createTool( 4052, addRemTb );
03857   createTool( separator(), addRemTb );
03858   createTool( 4061, addRemTb );
03859   createTool( 4062, addRemTb );
03860   createTool( 4063, addRemTb );
03861   createTool( 4068, addRemTb );
03862   createTool( 4064, addRemTb );
03863   createTool( 4065, addRemTb );
03864   createTool( 4066, addRemTb );
03865   createTool( 4069, addRemTb );
03866   createTool( separator(), addRemTb );
03867 
03868   createTool( 4067,modifyTb );
03869   createTool( 407, modifyTb );
03870   createTool( 408, modifyTb );
03871   createTool( 409, modifyTb );
03872   createTool( 410, modifyTb );
03873   createTool( 411, modifyTb );
03874   createTool( 419, modifyTb );
03875   createTool( 412, modifyTb );
03876   createTool( 413, modifyTb );
03877   createTool( 416, modifyTb );
03878   createTool( 414, modifyTb );
03879   createTool( 415, modifyTb );
03880   createTool( 417, modifyTb );
03881   createTool( 418, modifyTb );
03882 
03883   createTool( 214, dispModeTb );
03884 
03885   QString lc = "$";        // VSR : instead of QtxPopupSelection::defEquality();
03886   QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
03887 
03888   myRules.clear();
03889   QString OB = "'ObjectBrowser'",
03890           View = "'" + SVTK_Viewer::Type() + "'",
03891           pat = "'%1'",
03892           mesh    = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
03893           group   = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
03894           hypo    = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
03895           algo    = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
03896           elems   = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
03897                        arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
03898                        arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
03899                        arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
03900                        arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
03901                        arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
03902                        arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
03903           subMesh = elems,
03904           mesh_part = mesh + " " + subMesh + " " + group,
03905           mesh_group = mesh + " " + group,
03906           hyp_alg = hypo + " " + algo;
03907 
03908   // popup for object browser
03909   QString
03910     isInvisible("not( isVisible )"),
03911     isEmpty("numberOfNodes = 0"),
03912     isNotEmpty("numberOfNodes <> 0"),
03913 
03914     // has nodes, edges, etc in VISIBLE! actor
03915     hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
03916     hasElems("(count( elemTypes ) > 0)"),
03917     hasDifferentElems("(count( elemTypes ) > 1)"),
03918     hasElems0d("({'Elem0d'} in elemTypes)"),
03919     hasEdges("({'Edge'} in elemTypes)"),
03920     hasFaces("({'Face'} in elemTypes)"),
03921     hasVolumes("({'Volume'} in elemTypes)");
03922 
03923   createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" );      // FILE INFORMATION
03924   createPopupItem( 703, OB, mesh, "&& isComputable");      // CREATE_SUBMESH
03925   createPopupItem( 704, OB, mesh, "&& isComputable");      // EDIT_MESHSUBMESH
03926   createPopupItem( 704, OB, subMesh, "&& isComputable" );  // EDIT_MESHSUBMESH
03927   createPopupItem( 803, OB, group );                       // EDIT_GROUP
03928   createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
03929 
03930   popupMgr()->insert( separator(), -1, 0 );
03931   createPopupItem( 701, OB, mesh, "&& isComputable" );     // COMPUTE
03932   createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
03933   createPopupItem( 712, OB, mesh, "&& isComputable" );     // EVALUATE
03934   createPopupItem( 713, OB, mesh, "&& isComputable" );     // MESH ORDER
03935   createPopupItem( 214, OB, mesh_part );                   // UPDATE
03936   createPopupItem( 900, OB, mesh_part );                   // ADV_INFO
03937   createPopupItem( 904, OB, mesh_group );                  // FIND_ELEM
03938   popupMgr()->insert( separator(), -1, 0 );
03939   createPopupItem( 801, OB, mesh );                        // CREATE_GROUP
03940   createPopupItem( 806, OB, mesh );                        // CREATE_GEO_GROUP
03941   createPopupItem( 802, OB, subMesh );                     // CONSTRUCT_GROUP
03942   popupMgr()->insert( separator(), -1, 0 );
03943   createPopupItem( 1100, OB, hypo);                        // EDIT HYPOTHESIS
03944   createPopupItem( 1102, OB, hyp_alg );                    // REMOVE HYPOTHESIS / ALGORITHMS
03945   popupMgr()->insert( separator(), -1, 0 );
03946   createPopupItem( 4043, OB, mesh );                       // CLEAR_MESH
03947   popupMgr()->insert( separator(), -1, 0 );
03948   createPopupItem( 417, OB, mesh + " " + subMesh );        // convert to quadratic
03949   createPopupItem( 418, OB, mesh + " " + group,            // create 2D mesh from 3D
03950                    "&& dim>=2");
03951   popupMgr()->insert( separator(), -1, 0 );
03952 
03953   QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
03954   QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
03955   QString only_one_2D        = only_one_non_empty + " && dim>1";
03956 
03957   createPopupItem( 125, OB, mesh_group, multiple_non_empty );   // EXPORT_MED
03958   createPopupItem( 126, OB, mesh_group, only_one_non_empty );   // EXPORT_UNV
03959   createPopupItem( 141, OB, mesh_group, only_one_2D );          // EXPORT_STL
03960 #ifdef WITH_CGNS
03961   createPopupItem( 143, OB, mesh_group, multiple_non_empty );   // EXPORT_CGNS
03962 #endif
03963   createPopupItem( 145, OB, mesh_group, multiple_non_empty );   // EXPORT_SAUV
03964   createPopupItem(  33, OB, mesh_part + " " + hyp_alg );        // DELETE
03965   createPopupItem( 813, OB, group );                            // DEL_GROUP with contents
03966   popupMgr()->insert( separator(), -1, 0 );
03967 
03968   // popup for viewer
03969   createPopupItem( 803, View, group ); // EDIT_GROUP
03970   createPopupItem( 804, View, elems ); // ADD
03971   createPopupItem( 805, View, elems ); // REMOVE
03972 
03973   popupMgr()->insert( separator(), -1, 0 );
03974   createPopupItem( 214, View, mesh_part );  // UPDATE
03975   createPopupItem( 900, View, mesh_part );  // ADV_INFO
03976   createPopupItem( 904, View, mesh );       // FIND_ELEM
03977   popupMgr()->insert( separator(), -1, 0 );
03978 
03979   createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
03980   createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" );       // DISABLE_AUTO_COLOR
03981   popupMgr()->insert( separator(), -1, 0 );
03982 
03983   int anId;
03984   QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
03985   QString aType = QString( "%1type in {%2}" ).arg( lc );
03986   aType = aType.arg( mesh_part );
03987   QString aMeshInVTK = aClient + "&&" + aType;
03988 
03989   aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
03990   QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
03991   QString aSelCount = QString( "%1 > 0" ).arg( dc );
03992 
03993   //-------------------------------------------------
03994   // Numbering
03995   //-------------------------------------------------
03996   anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
03997 
03998   popupMgr()->insert( action( 9010 ), anId, -1 );
03999   popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
04000   popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
04001 
04002   popupMgr()->insert( action( 9011 ), anId, -1 );
04003   popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
04004   popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
04005 
04006   popupMgr()->insert( separator(), -1, -1 );
04007 
04008   //-------------------------------------------------
04009   // Display Mode
04010   //-------------------------------------------------
04011   anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
04012 
04013   popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
04014   popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
04015   popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
04016 
04017   popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
04018   popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
04019   popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
04020 
04021   popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
04022   popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
04023   popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
04024 
04025   popupMgr()->insert( separator(), anId, -1 );
04026 
04027   popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
04028   popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
04029   popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
04030 
04031   //-------------------------------------------------
04032   // Display Entity
04033   //-------------------------------------------------
04034   QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
04035 
04036   anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
04037 
04038   popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
04039   popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
04040   popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
04041 
04042   popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
04043   popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
04044   popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
04045 
04046   popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
04047   popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
04048   popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
04049 
04050   popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
04051   popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
04052   popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
04053 
04054   popupMgr()->insert( separator(), anId, -1 );
04055 
04056   popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
04057   popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
04058 
04059 
04060   //-------------------------------------------------
04061   // Representation of the 2D Quadratic elements
04062   //-------------------------------------------------
04063   anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
04064   popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
04065   popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
04066   popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
04067 
04068   popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
04069   popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
04070   popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
04071 
04072   //-------------------------------------------------
04073   // Orientation of faces
04074   //-------------------------------------------------
04075   popupMgr()->insert( action( 221 ), -1, -1 );
04076   popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
04077   popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
04078 
04079   //-------------------------------------------------
04080   // Color / Size
04081   //-------------------------------------------------
04082   popupMgr()->insert( action( 1132 ), -1, -1 );
04083   popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
04084 
04085   //-------------------------------------------------
04086   // Transparency
04087   //-------------------------------------------------
04088   popupMgr()->insert( action( 1133 ), -1, -1 );
04089   popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
04090 
04091   //-------------------------------------------------
04092   // Controls
04093   //-------------------------------------------------
04094   QString
04095     aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
04096     aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
04097     aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
04098     aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
04099 
04100   anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
04101 
04102   popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
04103   popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
04104 
04105   popupMgr()->insert( separator(), anId, -1 );
04106 
04107   int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
04108 
04109   popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
04110   popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
04111   popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
04112 
04113   popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
04114   popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
04115   popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
04116 
04117   aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
04118 
04119   popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
04120   popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
04121   popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
04122 
04123   popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
04124   popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
04125   popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
04126 
04127   popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
04128   popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
04129   popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
04130 
04131   popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
04132   popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
04133   popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
04134   popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
04135   popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
04136   popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
04137 
04138   aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
04139 
04140   popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
04141   popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
04142                                        QtxPopupMgr::VisibleRule );
04143   popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
04144 
04145   popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
04146   popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04147   popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
04148 
04149   popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
04150   popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04151   popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
04152 
04153   popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
04154   popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04155   popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
04156 
04157   popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
04158   popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04159   popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
04160 
04161   popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
04162   popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04163   popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
04164 
04165   popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
04166   popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04167   popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
04168 
04169   popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
04170   popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04171   popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
04172 
04173   popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
04174   popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04175   popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
04176 
04177   popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
04178   popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04179   popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
04180 
04181   popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
04182   popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04183   popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
04184 
04185   popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
04186   popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04187   popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
04188   popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
04189   popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
04190   popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
04191 
04192   aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
04193 
04194   popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
04195   popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
04196   popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
04197 
04198   popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
04199   popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
04200   popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
04201 
04202   popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
04203   popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
04204   popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
04205 
04206   popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
04207   popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
04208   popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
04209 
04210   popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
04211   popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
04212   popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
04213 
04214   popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
04215   popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
04216   popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
04217 
04218   popupMgr()->insert( separator(), anId, -1 );
04219 
04220   popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
04221   popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
04222 
04223   popupMgr()->insert( separator(), anId, -1 );
04224 
04225   aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
04226 
04227   popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
04228   popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
04229 
04230   popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
04231   popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
04232   popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
04233 
04234 #ifndef DISABLE_PLOT2DVIEWER
04235   popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
04236   popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
04237 #endif
04238 
04239   //-------------------------------------------------
04240   // Display / Erase
04241   //-------------------------------------------------
04242   popupMgr()->insert( separator(), -1, -1 );
04243   QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
04244     aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
04245   popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
04246   popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
04247 
04248   popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
04249   popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
04250 
04251   popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
04252   popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
04253 
04254   popupMgr()->insert( separator(), -1, -1 );
04255 
04256   //-------------------------------------------------
04257   // Clipping
04258   //-------------------------------------------------
04259   popupMgr()->insert( action( 1134 ), -1, -1 );
04260   popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
04261 
04262   popupMgr()->insert( separator(), -1, -1 );
04263 
04264   connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
04265            this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
04266 
04267   connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
04268            this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
04269 }
04270 
04271 //================================================================================
04277 //================================================================================
04278 
04279 bool SMESHGUI::isSelectionCompatible()
04280 {
04281   bool isCompatible = true;
04282   SALOME_ListIO selected;
04283   if ( LightApp_SelectionMgr *Sel = selectionMgr() )
04284     Sel->selectedObjects( selected );
04285 
04286   SALOME_ListIteratorOfListIO It( selected );
04287   for ( ; isCompatible && It.More(); It.Next())
04288     isCompatible =
04289       ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
04290       ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
04291 
04292   return isCompatible;
04293 }
04294 
04295 
04296 bool SMESHGUI::reusableOperation( const int id )
04297 {
04298   // compute, evaluate and precompute are not reusable operations
04299   return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
04300 }
04301 
04302 bool SMESHGUI::activateModule( SUIT_Study* study )
04303 {
04304   bool res = SalomeApp_Module::activateModule( study );
04305 
04306   setMenuShown( true );
04307   setToolShown( true );
04308 
04309   // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
04310   PyGILState_STATE gstate = PyGILState_Ensure();
04311   PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
04312   if(pluginsmanager==NULL)
04313     PyErr_Print();
04314   else
04315     {
04316       PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
04317       if(result==NULL)
04318         PyErr_Print();
04319       Py_XDECREF(result);
04320     }
04321   PyGILState_Release(gstate);
04322   // end of GEOM plugins loading
04323 
04324   // Reset actions accelerator keys
04325   action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
04326   action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
04327   action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
04328 
04329   action(  33)->setEnabled(true); // Delete: Key_Delete
04330 
04331   //  0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
04332   GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
04333   if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
04334     if ( _PTR(Study) aStudy = s->studyDS()) {
04335       GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
04336       updateObjBrowser(); // objects can be removed
04337     }
04338 
04339   // get all view currently opened in the study and connect their signals  to
04340   // the corresponding slots of the class.
04341   SUIT_Desktop* aDesk = study->application()->desktop();
04342   if ( aDesk ) {
04343     QList<SUIT_ViewWindow*> wndList = aDesk->windows();
04344     SUIT_ViewWindow* wnd;
04345     foreach ( wnd, wndList )
04346       connectView( wnd );
04347   }
04348 
04349   return res;
04350 }
04351 
04352 bool SMESHGUI::deactivateModule( SUIT_Study* study )
04353 {
04354   setMenuShown( false );
04355   setToolShown( false );
04356 
04357   EmitSignalCloseAllDialogs();
04358 
04359   // Unset actions accelerator keys
04360   action(111)->setShortcut(QKeySequence()); // Import DAT
04361   action(112)->setShortcut(QKeySequence()); // Import UNV
04362   action(113)->setShortcut(QKeySequence()); // Import MED
04363 
04364   action(  33)->setEnabled(false); // Delete: Key_Delete
04365 
04366   return SalomeApp_Module::deactivateModule( study );
04367 }
04368 
04369 void SMESHGUI::studyClosed( SUIT_Study* s )
04370 {
04371   SMESH::RemoveVisuData( s->id() );
04372   SalomeApp_Module::studyClosed( s );
04373 }
04374 
04375 void SMESHGUI::OnGUIEvent()
04376 {
04377   const QObject* obj = sender();
04378   if ( !obj || !obj->inherits( "QAction" ) )
04379     return;
04380   int id = actionId((QAction*)obj);
04381   if ( id != -1 )
04382     OnGUIEvent( id );
04383 }
04384 
04385 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
04386 {
04387   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
04388   if ( CORBA::is_nil( myComponentSMESH ) )
04389     {
04390       SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
04391       if ( aStudy )
04392         aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
04393       return aGUI.myComponentSMESH;
04394     }
04395   if ( aStudy )
04396     myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
04397   return myComponentSMESH;
04398 }
04399 
04400 QString SMESHGUI::engineIOR() const
04401 {
04402   CORBA::ORB_var anORB = getApp()->orb();
04403   CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
04404   return QString( anIOR.in() );
04405 }
04406 
04407 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
04408 {
04409   SalomeApp_Module::contextMenuPopup( client, menu, title );
04410   SALOME_ListIO lst;
04411   selectionMgr()->selectedObjects( lst );
04412   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
04413     Handle(SALOME_InteractiveObject) io = lst.First();
04414     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
04415     _PTR(Study) study = appStudy->studyDS();
04416     _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
04417     if ( obj ) {
04418       QString aName = QString( obj->GetName().c_str() );
04419       while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
04420           aName.remove( (aName.length() - 1), 1 );
04421       title = aName;
04422     }
04423   }
04424 }
04425 
04426 LightApp_Selection* SMESHGUI::createSelection() const
04427 {
04428   return new SMESHGUI_Selection();
04429 }
04430 
04431 void SMESHGUI::windows( QMap<int, int>& aMap ) const
04432 {
04433   aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
04434   aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
04435 }
04436 
04437 void SMESHGUI::viewManagers( QStringList& list ) const
04438 {
04439   list.append( SVTK_Viewer::Type() );
04440 }
04441 
04442 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
04443 {
04444   if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
04445     SMESH::UpdateSelectionProp( this );
04446 
04447     QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
04448     for(int i = 0; i < aViews.count() ; i++){
04449       SUIT_ViewWindow *sf = aViews[i];
04450       connectView( sf );
04451     }
04452   }
04453 }
04454 
04455 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
04456 {
04457   if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
04458     myClippingPlaneInfoMap.erase( theViewManager );
04459 }
04460 
04461 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
04462 {
04463   theActor->AddObserver( SMESH::DeleteActorEvent,
04464                          myEventCallbackCommand.GetPointer(),
04465                          myPriority );
04466 }
04467 
04468 void SMESHGUI::ProcessEvents( vtkObject* theObject,
04469                               unsigned long theEvent,
04470                               void* theClientData,
04471                               void* theCallData )
04472 {
04473   if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
04474     if( theObject && theEvent == SMESH::DeleteActorEvent ) {
04475       if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
04476         SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
04477         SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
04478         for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
04479           SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
04480           SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
04481           for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
04482             SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
04483             std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
04484             SMESH::TActorList::iterator anIter3 = anActorList.begin();
04485             for ( ; anIter3 != anActorList.end(); anIter3++ ) {
04486               if( anActor == *anIter3 ) {
04487                 anActorList.erase( anIter3 );
04488                 break;
04489               }
04490             }
04491           }
04492         }
04493       }
04494     }
04495   }
04496 }
04497 
04498 void SMESHGUI::createPreferences()
04499 {
04500   // General tab ------------------------------------------------------------------------
04501   int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
04502 
04503   int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
04504   int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
04505   setPreferenceProperty( lim, "min",  0 );
04506   setPreferenceProperty( lim, "max",  100000000 );
04507   setPreferenceProperty( lim, "step", 1000 );
04508   setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
04509 
04510   int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
04511   setPreferenceProperty( qaGroup, "columns", 2 );
04512   addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
04513   addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
04514   int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
04515   setPreferenceProperty( prec, "min", 0 );
04516   setPreferenceProperty( prec, "max", 16 );
04517   int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
04518   setPreferenceProperty( doubleNodesTol, "precision", 10 );
04519   setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
04520   setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
04521   setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
04522 
04523   int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
04524   setPreferenceProperty( dispgroup, "columns", 2 );
04525   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
04526   QStringList modes;
04527   modes.append( tr("MEN_WIRE") );
04528   modes.append( tr("MEN_SHADE") );
04529   modes.append( tr("MEN_NODES") );
04530   modes.append( tr("MEN_SHRINK") );
04531   QList<QVariant> indices;
04532   indices.append( 0 );
04533   indices.append( 1 );
04534   indices.append( 2 );
04535   indices.append( 3 );
04536   setPreferenceProperty( dispmode, "strings", modes );
04537   setPreferenceProperty( dispmode, "indexes", indices );
04538 
04539   int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
04540   setPreferenceProperty( arcgroup, "columns", 2 );
04541   int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
04542   QStringList quadraticModes;
04543   quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
04544   quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
04545   indices.clear();
04546   indices.append( 0 );
04547   indices.append( 1 );
04548   setPreferenceProperty( quadraticmode, "strings", quadraticModes );
04549   setPreferenceProperty( quadraticmode, "indexes", indices );
04550 
04551   int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
04552                               "SMESH", "max_angle" );
04553   setPreferenceProperty( maxAngle, "min", 1 );
04554   setPreferenceProperty( maxAngle, "max", 90 );
04555 
04556 
04557 
04558   int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
04559   setPreferenceProperty( exportgroup, "columns", 2 );
04560   addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
04561   addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
04562 
04563   int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
04564   setPreferenceProperty( computeGroup, "columns", 2 );
04565   int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
04566   modes.clear();
04567   modes.append( tr( "PREF_NOTIFY_NEVER" ) );
04568   modes.append( tr( "PREF_NOTIFY_ERROR" ) );
04569   modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
04570   indices.clear();
04571   indices.append( 0 );
04572   indices.append( 1 );
04573   indices.append( 2 );
04574   setPreferenceProperty( notifyMode, "strings", modes );
04575   setPreferenceProperty( notifyMode, "indexes", indices );
04576 
04577   int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
04578   setPreferenceProperty( infoGroup, "columns", 4 );
04579   int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
04580   modes.clear();
04581   modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
04582   modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
04583   indices.clear();
04584   indices.append( 0 );
04585   indices.append( 1 );
04586   setPreferenceProperty( elemInfo, "strings", modes );
04587   setPreferenceProperty( elemInfo, "indexes", indices );
04588   int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
04589   setPreferenceProperty( nodesLim, "min", 0 );
04590   setPreferenceProperty( nodesLim, "max", 10000000 );
04591   setPreferenceProperty( nodesLim, "step", 10000 );
04592   setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
04593 
04594   int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
04595   setPreferenceProperty( segGroup, "columns", 2 );
04596   int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
04597                               "SMESH", "segmentation" );
04598   setPreferenceProperty( segLen, "min", 1 );
04599   setPreferenceProperty( segLen, "max", 10000000 );
04600   int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
04601                              "SMESH", "nb_segments_per_edge" );
04602   setPreferenceProperty( nbSeg, "min", 1 );
04603   setPreferenceProperty( nbSeg, "max", 10000000 );
04604 
04605   int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
04606   addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
04607                  "SMESH", "forget_mesh_on_hyp_modif" );
04608 
04609 
04610   // Quantities with individual precision settings
04611   int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
04612   setPreferenceProperty( precGroup, "columns", 2 );
04613 
04614   const int nbQuantities = 6;
04615   int precs[nbQuantities], ii = 0;
04616   precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
04617                             LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
04618   precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
04619                             LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
04620   precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
04621                             LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
04622   precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
04623                             LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
04624   precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
04625                             LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
04626   precs[ii  ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
04627                             LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
04628 
04629   // Set property for precision value for spinboxes
04630   for ( ii = 0; ii < nbQuantities; ii++ ){
04631     setPreferenceProperty( precs[ii], "min", -14 );
04632     setPreferenceProperty( precs[ii], "max", 14 );
04633     setPreferenceProperty( precs[ii], "precision", 2 );
04634   }
04635 
04636   int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
04637   setPreferenceProperty( previewGroup, "columns", 2 );
04638   int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
04639   setPreferenceProperty( chunkSize, "min",  0 );
04640   setPreferenceProperty( chunkSize, "max",  1000 );
04641   setPreferenceProperty( chunkSize, "step", 50 );
04642 
04643   int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
04644   addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
04645 
04646   // Mesh tab ------------------------------------------------------------------------
04647   int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
04648   int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
04649   setPreferenceProperty( nodeGroup, "columns", 3 );
04650 
04651   addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
04652 
04653   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
04654 
04655   SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
04656   QList<QVariant> aMarkerTypeIndicesList;
04657   QList<QVariant> aMarkerTypeIconsList;
04658   for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
04659     QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
04660     QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
04661     aMarkerTypeIndicesList << i;
04662     aMarkerTypeIconsList << pixmap;
04663   }
04664   setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
04665   setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
04666 
04667   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
04668 
04669   QList<QVariant> aMarkerScaleIndicesList;
04670   QStringList     aMarkerScaleValuesList;
04671   for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
04672     aMarkerScaleIndicesList << i;
04673     aMarkerScaleValuesList  << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
04674   }
04675   setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
04676   setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
04677 
04678   int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
04679   setPreferenceProperty( elemGroup, "columns", 2 );
04680 
04681   int ColorId = addPreference( tr( "PREF_FILL"     ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
04682   addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
04683 
04684   addPreference( tr( "PREF_OUTLINE"  ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
04685   addPreference( tr( "PREF_WIREFRAME"  ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
04686 
04687   setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
04688 
04689   int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
04690   setPreferenceProperty( grpGroup, "columns", 2 );
04691 
04692   addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
04693 
04694   int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
04695                              LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
04696   int elemW  = addPreference(tr("PREF_WIDTH"), elemGroup,
04697                              LightApp_Preferences::IntSpin, "SMESH", "element_width");
04698   int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
04699                              LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
04700 
04701   setPreferenceProperty( size0d, "min", 1 );
04702   setPreferenceProperty( size0d, "max", 10 );
04703 
04704   setPreferenceProperty( elemW, "min", 1 );
04705   setPreferenceProperty( elemW, "max", 5 );
04706 
04707   setPreferenceProperty( shrink, "min", 0 );
04708   setPreferenceProperty( shrink, "max", 100 );
04709 
04710   int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
04711   setPreferenceProperty( orientGroup, "columns", 1 );
04712 
04713   addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
04714   int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
04715 
04716   setPreferenceProperty( orientScale, "min", 0.05 );
04717   setPreferenceProperty( orientScale, "max", 0.5 );
04718   setPreferenceProperty( orientScale, "step", 0.05 );
04719 
04720   addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
04721 
04722   // Selection tab ------------------------------------------------------------------------
04723   int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
04724 
04725   int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
04726   setPreferenceProperty( selGroup, "columns", 2 );
04727 
04728   addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
04729   addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
04730 
04731   int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
04732   setPreferenceProperty( preGroup, "columns", 2 );
04733 
04734   addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
04735 
04736   int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
04737   setPreferenceProperty( precSelGroup, "columns", 2 );
04738 
04739   addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
04740   addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
04741   addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
04742 
04743   // Scalar Bar tab ------------------------------------------------------------------------
04744   int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
04745   int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
04746   setPreferenceProperty( fontGr, "columns", 2 );
04747 
04748   addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
04749   addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
04750 
04751   addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
04752   addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
04753 
04754   int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
04755   setPreferenceProperty( colorsLabelsGr, "columns", 2 );
04756 
04757   int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
04758   setPreferenceProperty( numcol, "min", 2 );
04759   setPreferenceProperty( numcol, "max", 256 );
04760 
04761   int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
04762   setPreferenceProperty( numlab, "min", 2 );
04763   setPreferenceProperty( numlab, "max", 65 );
04764 
04765   int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
04766   setPreferenceProperty( orientGr, "columns", 2 );
04767   int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
04768   QStringList orients;
04769   orients.append( tr( "SMESH_VERTICAL" ) );
04770   orients.append( tr( "SMESH_HORIZONTAL" ) );
04771   indices.clear(); indices.append( 0 ); indices.append( 1 );
04772   setPreferenceProperty( orient, "strings", orients );
04773   setPreferenceProperty( orient, "indexes", indices );
04774 
04775   int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
04776   setPreferenceProperty( posVSizeGr, "columns", 2 );
04777   int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
04778   int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
04779   int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
04780   int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
04781   setPreferenceProperty( xv, "step", 0.1 );
04782   setPreferenceProperty( xv, "min", 0.0 );
04783   setPreferenceProperty( xv, "max", 1.0 );
04784   setPreferenceProperty( yv, "step", 0.1 );
04785   setPreferenceProperty( yv, "min", 0.0 );
04786   setPreferenceProperty( yv, "max", 1.0 );
04787   setPreferenceProperty( wv, "step", 0.1 );
04788   setPreferenceProperty( wv, "min", 0.0 );
04789   setPreferenceProperty( wv, "max", 1.0 );
04790   setPreferenceProperty( hv, "min", 0.0 );
04791   setPreferenceProperty( hv, "max", 1.0 );
04792   setPreferenceProperty( hv, "step", 0.1 );
04793 
04794   int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
04795   setPreferenceProperty( posHSizeGr, "columns", 2 );
04796   int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
04797   int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
04798   int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
04799   int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
04800   setPreferenceProperty( xv, "min", 0.0 );
04801   setPreferenceProperty( xv, "max", 1.0 );
04802   setPreferenceProperty( xv, "step", 0.1 );
04803   setPreferenceProperty( xh, "min", 0.0 );
04804   setPreferenceProperty( xh, "max", 1.0 );
04805   setPreferenceProperty( xh, "step", 0.1 );
04806   setPreferenceProperty( yh, "min", 0.0 );
04807   setPreferenceProperty( yh, "max", 1.0 );
04808   setPreferenceProperty( yh, "step", 0.1 );
04809   setPreferenceProperty( wh, "min", 0.0 );
04810   setPreferenceProperty( wh, "max", 1.0 );
04811   setPreferenceProperty( wh, "step", 0.1 );
04812   setPreferenceProperty( hh, "min", 0.0 );
04813   setPreferenceProperty( hh, "max", 1.0 );
04814   setPreferenceProperty( hh, "step", 0.1 );
04815 
04816   int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
04817   int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
04818   setPreferenceProperty( distributionGr, "columns", 3 );
04819   QStringList types;
04820   types.append( tr( "SMESH_MONOCOLOR" ) );
04821   types.append( tr( "SMESH_MULTICOLOR" ) );
04822   indices.clear(); indices.append( 0 ); indices.append( 1 );
04823   setPreferenceProperty( coloringType, "strings", types );
04824   setPreferenceProperty( coloringType, "indexes", indices );
04825   addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
04826 
04827 }
04828 
04829 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
04830 {
04831   if( sect=="SMESH" ) {
04832     float sbX1,sbY1,sbW,sbH;
04833     float aTol = 1.00000009999999;
04834     std::string aWarning;
04835     SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
04836     if( name=="selection_object_color" || name=="selection_element_color" ||
04837         name=="highlight_color" ||
04838         name=="selection_precision_node" || name=="selection_precision_element" ||
04839         name=="selection_precision_object")
04840       SMESH::UpdateSelectionProp( this );
04841     else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
04842       sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
04843       sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
04844       if(sbX1+sbW > aTol){
04845         aWarning = "Origin and Size Vertical: X+Width > 1\n";
04846         sbX1=0.01;
04847         sbW=0.08;
04848         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
04849         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
04850       }
04851     }
04852     else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
04853       sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
04854       sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
04855       if(sbY1+sbH > aTol){
04856         aWarning = "Origin and Size Vertical: Y+Height > 1\n";
04857         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
04858         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
04859       }
04860     }
04861     else if(name ==  QString("scalar_bar_horizontal_x") || name ==  QString("scalar_bar_horizontal_width")){
04862       sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
04863       sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
04864       if(sbX1+sbW > aTol){
04865         aWarning = "Origin and Size Horizontal: X+Width > 1\n";
04866         sbX1=0.1;
04867         sbW=0.08;
04868         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
04869         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
04870       }
04871     }
04872     else if(name ==  QString("scalar_bar_horizontal_y") || name ==  QString("scalar_bar_horizontal_height")){
04873       sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
04874       sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
04875       if(sbY1+sbH > aTol){
04876         aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
04877         sbY1=0.01;
04878         sbH=0.08;
04879         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
04880         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
04881       }
04882     }
04883     else if ( name == "segmentation" ) {
04884       int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
04885       myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
04886     }
04887     else if ( name == "nb_segments_per_edge" ) {
04888       int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
04889       myComponentSMESH->SetDefaultNbSegments( nbSeg );
04890     }
04891     else if ( name == "historical_python_dump" ||
04892               name == "forget_mesh_on_hyp_modif") {
04893       QString val = aResourceMgr->stringValue( "SMESH", name );
04894       myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
04895     }
04896 
04897     if(aWarning.size() != 0){
04898       aWarning += "The default values are applied instead.";
04899       SUIT_MessageBox::warning(SMESHGUI::desktop(),
04900                                QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
04901                                QObject::tr(aWarning.c_str()));
04902     }
04903   }
04904 }
04905 
04906 //================================================================================
04914 //================================================================================
04915 void SMESHGUI::update( const int flags )
04916 {
04917   if ( (flags & UF_Viewer) | (flags & UF_Forced) )
04918     SMESH::UpdateView();
04919   else
04920     SalomeApp_Module::update( flags );
04921 }
04922 
04923 //================================================================================
04929 //================================================================================
04930 void SMESHGUI::onOperationCommited( SUIT_Operation* )
04931 {
04932   SVTK_ViewWindow* vtkWnd =
04933     dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
04934   if ( vtkWnd )
04935     vtkWnd->SetSelectionMode( ActorSelection );
04936 }
04937 
04938 //================================================================================
04944 //================================================================================
04945 void SMESHGUI::onOperationAborted( SUIT_Operation* )
04946 {
04947   SVTK_ViewWindow* vtkWnd =
04948     dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
04949   if ( vtkWnd )
04950     vtkWnd->SetSelectionMode( ActorSelection );
04951 }
04952 
04953 //================================================================================
04962 //================================================================================
04963 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
04964 {
04965   LightApp_Operation* op = 0;
04966   // to do : create operation here
04967   switch( id )
04968   {
04969     case 417: //convert to quadratic
04970       op = new SMESHGUI_ConvToQuadOp();
04971     break;
04972     case 418: // create 2D mesh as boundary on 3D
04973       op = new SMESHGUI_Make2DFrom3DOp();
04974     break;
04975     case 701: // Compute mesh
04976       op = new SMESHGUI_ComputeOp();
04977     break;
04978     case 702: // Create mesh
04979       op = new SMESHGUI_MeshOp( true, true );
04980     break;
04981     case 703: // Create sub-mesh
04982       op = new SMESHGUI_MeshOp( true, false );
04983     break;
04984     case 704: // Edit mesh/sub-mesh
04985       op = new SMESHGUI_MeshOp( false );
04986     break;
04987     case 711: // Precompute mesh
04988       op = new SMESHGUI_PrecomputeOp();
04989     break;
04990     case 712: // Evaluate mesh
04991       op = new SMESHGUI_EvaluateOp();
04992     break;
04993     case 713: // Evaluate mesh
04994       op = new SMESHGUI_MeshOrderOp();
04995     break;
04996     case 806: // Create group on geom
04997       op = new SMESHGUI_GroupOnShapeOp();
04998       break;
04999     case 904: // Find element
05000       op = new SMESHGUI_FindElemByPointOp();
05001       break;
05002     case 4067: // make mesh pass through point
05003       op = new SMESHGUI_MakeNodeAtPointOp();
05004       break;
05005     default:
05006     break;
05007   }
05008 
05009   if( !op )
05010     op = SalomeApp_Module::createOperation( id );
05011   return op;
05012 }
05013 
05014 //================================================================================
05019 //================================================================================
05020 
05021 void SMESHGUI::switchToOperation(int id)
05022 {
05023   if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
05024     activeStudy()->abortAllOperations();
05025   startOperation( id );
05026 }
05027 
05028 LightApp_Displayer* SMESHGUI::displayer()
05029 {
05030   if( !myDisplayer )
05031     myDisplayer = new SMESHGUI_Displayer( getApp() );
05032   return myDisplayer;
05033 }
05034 
05035 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
05036 {
05037   int aHue = -1;
05038   int aTolerance = 64;
05039   int anIterations = 0;
05040   int aPeriod = 5;
05041 
05042   while( 1 )
05043   {
05044     anIterations++;
05045     if( anIterations % aPeriod == 0 )
05046     {
05047       aTolerance /= 2;
05048       if( aTolerance < 1 )
05049         break;
05050     }
05051 
05052     aHue = (int)( 360.0 * rand() / RAND_MAX );
05053 
05054     bool ok = true;
05055     QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
05056     QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
05057     for( ; it != itEnd; ++it )
05058     {
05059       SALOMEDS::Color anAutoColor = *it;
05060       QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
05061 
05062       int h, s, v;
05063       aQColor.getHsv( &h, &s, &v );
05064       if( abs( h - aHue ) < aTolerance )
05065       {
05066         ok = false;
05067         break;
05068       }
05069     }
05070 
05071     if( ok )
05072       break;
05073   }
05074 
05075   QColor aColor;
05076   aColor.setHsv( aHue, 255, 255 );
05077 
05078   SALOMEDS::Color aSColor;
05079   aSColor.R = (double)aColor.red() / 255.0;
05080   aSColor.G = (double)aColor.green() / 255.0;
05081   aSColor.B = (double)aColor.blue() / 255.0;
05082 
05083   return aSColor;
05084 }
05085 
05086 const char gSeparator = '_'; // character used to separate parameter names
05087 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
05088 const char gPathSep   = '|'; // character used to separate paths
05089 
05096 void SMESHGUI::storeVisualParameters (int savePoint)
05097 {
05098   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
05099   if (!appStudy || !appStudy->studyDS())
05100     return;
05101   _PTR(Study) studyDS = appStudy->studyDS();
05102 
05103   // componentName is used for encoding of entries when storing them in IParameters
05104   std::string componentName = myComponentSMESH->ComponentDataType();
05105   //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
05106   //if (!aSComponent) return;
05107 
05108   // IParameters
05109   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
05110                                                              componentName.c_str(),
05111                                                              savePoint);
05112   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
05113 
05114   // store map of custom markers
05115   const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
05116   if( !aMarkerMap.empty() )
05117   {
05118     VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
05119     for( ; anIter != aMarkerMap.end(); anIter++ )
05120     {
05121       int anId = anIter->first;
05122       VTK::MarkerData aMarkerData = anIter->second;
05123       std::string aMarkerFileName = aMarkerData.first;
05124       VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
05125       if( aMarkerTexture.size() < 3 )
05126         continue; // should contain at least width, height and the first value
05127 
05128       QString aPropertyName( "texture" );
05129       aPropertyName += gSeparator;
05130       aPropertyName += QString::number( anId );
05131 
05132       QString aPropertyValue = aMarkerFileName.c_str();
05133       aPropertyValue += gPathSep;
05134 
05135       VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
05136       ushort aWidth = *aTextureIter++;
05137       ushort aHeight = *aTextureIter++;
05138       aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
05139       aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
05140       for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
05141         aPropertyValue += QString::number( *aTextureIter );
05142 
05143       ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
05144     }
05145   }
05146 
05147   // viewers counters are used for storing view_numbers in IParameters
05148   int vtkViewers = 0;
05149 
05150   // main cycle to store parameters of displayed objects
05151   QList<SUIT_ViewManager*> lst;
05152   QList<SUIT_ViewManager*>::Iterator it;
05153   getApp()->viewManagers(lst);
05154   for (it = lst.begin(); it != lst.end(); it++)
05155   {
05156     SUIT_ViewManager* vman = *it;
05157     QString vType = vman->getType();
05158 
05159     // saving VTK actors properties
05160     if (vType == SVTK_Viewer::Type())
05161     {
05162       // store the clipping planes attached to the view manager
05163       SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
05164       SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
05165       if( anIter != myClippingPlaneInfoMap.end() )
05166         aClippingPlaneInfoList = anIter->second;
05167 
05168       if( !aClippingPlaneInfoList.empty() ) {
05169         SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
05170         for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
05171         {
05172           const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
05173           SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
05174 
05175           QString aPropertyName( "ClippingPlane" );
05176           aPropertyName += gSeparator;
05177           aPropertyName += QString::number( vtkViewers );
05178           aPropertyName += gSeparator;
05179           aPropertyName += QString::number( anId );
05180 
05181           QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
05182           aPropertyValue += gDigitsSep;
05183           aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
05184           aPropertyValue += gDigitsSep;
05185           aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
05186           aPropertyValue += gDigitsSep;
05187           aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
05188 
05189           ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
05190         }
05191       }
05192 
05193       QVector<SUIT_ViewWindow*> views = vman->getViews();
05194       for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
05195       {
05196         if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
05197         {
05198           VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
05199           vtkActorCollection* allActors = aCopy.GetActors();
05200           allActors->InitTraversal();
05201           while (vtkActor* actor = allActors->GetNextActor())
05202           {
05203             if (actor->GetVisibility()) // store only visible actors
05204             {
05205               SMESH_Actor* aSmeshActor = 0;
05206               if (actor->IsA("SMESH_Actor"))
05207                 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
05208               if (aSmeshActor && aSmeshActor->hasIO())
05209               {
05210                 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
05211                 if (io->hasEntry())
05212                 {
05213                   // entry is "encoded" = it does NOT contain component adress,
05214                   // since it is a subject to change on next component loading
05215                   std::string entry = ip->encodeEntry(io->getEntry(), componentName);
05216 
05217                   std::string param, vtkParam = vType.toLatin1().data();
05218                   vtkParam += gSeparator;
05219                   vtkParam += QString::number(vtkViewers).toLatin1().data();
05220                   vtkParam += gSeparator;
05221 
05222                   // Visibility
05223                   param = vtkParam + "Visibility";
05224                   ip->setParameter(entry, param, "On");
05225 
05226                   // Representation
05227                   param = vtkParam + "Representation";
05228                   ip->setParameter(entry, param, QString::number
05229                                    ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
05230 
05231                   // IsShrunk
05232                   param = vtkParam + "IsShrunk";
05233                   ip->setParameter(entry, param, QString::number
05234                                    ((int)aSmeshActor->IsShrunk()).toLatin1().data());
05235 
05236                   // Displayed entities
05237                   unsigned int aMode = aSmeshActor->GetEntityMode();
05238                   bool isE = aMode & SMESH_Actor::eEdges;
05239                   bool isF = aMode & SMESH_Actor::eFaces;
05240                   bool isV = aMode & SMESH_Actor::eVolumes;
05241 
05242                   QString modeStr ("e");
05243                   modeStr += gDigitsSep; modeStr += QString::number(isE);
05244                   modeStr += gDigitsSep; modeStr += "f";
05245                   modeStr += gDigitsSep; modeStr += QString::number(isF);
05246                   modeStr += gDigitsSep; modeStr += "v";
05247                   modeStr += gDigitsSep; modeStr += QString::number(isV);
05248 
05249                   param = vtkParam + "Entities";
05250                   ip->setParameter(entry, param, modeStr.toLatin1().data());
05251 
05252                   // Colors (surface:edge:)
05253                   vtkFloatingPointType r, g, b;
05254                   int delta;
05255 
05256                   aSmeshActor->GetSufaceColor(r, g, b, delta);
05257                   QString colorStr ("surface");
05258                   colorStr += gDigitsSep; colorStr += QString::number(r);
05259                   colorStr += gDigitsSep; colorStr += QString::number(g);
05260                   colorStr += gDigitsSep; colorStr += QString::number(b);
05261 
05262                   colorStr += gDigitsSep; colorStr += "backsurface";
05263                   colorStr += gDigitsSep; colorStr += QString::number(delta);
05264 
05265 
05266                   aSmeshActor->GetEdgeColor(r, g, b);
05267                   colorStr += gDigitsSep; colorStr += "edge";
05268                   colorStr += gDigitsSep; colorStr += QString::number(r);
05269                   colorStr += gDigitsSep; colorStr += QString::number(g);
05270                   colorStr += gDigitsSep; colorStr += QString::number(b);
05271 
05272                   aSmeshActor->GetNodeColor(r, g, b);
05273                   colorStr += gDigitsSep; colorStr += "node";
05274                   colorStr += gDigitsSep; colorStr += QString::number(r);
05275                   colorStr += gDigitsSep; colorStr += QString::number(g);
05276                   colorStr += gDigitsSep; colorStr += QString::number(b);
05277 
05278                   aSmeshActor->GetOutlineColor(r, g, b);
05279                   colorStr += gDigitsSep; colorStr += "outline";
05280                   colorStr += gDigitsSep; colorStr += QString::number(r);
05281                   colorStr += gDigitsSep; colorStr += QString::number(g);
05282                   colorStr += gDigitsSep; colorStr += QString::number(b);
05283 
05284                   param = vtkParam + "Colors";
05285                   ip->setParameter(entry, param, colorStr.toLatin1().data());
05286 
05287                   // Sizes of lines and points
05288                   QString sizeStr ("line");
05289                   sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
05290                   sizeStr += gDigitsSep; sizeStr += "shrink";
05291                   sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
05292 
05293                   param = vtkParam + "Sizes";
05294                   ip->setParameter(entry, param, sizeStr.toLatin1().data());
05295 
05296                   // Point marker
05297                   QString markerStr;
05298 
05299                   VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
05300                   if( aMarkerType == VTK::MT_USER ) {
05301                     markerStr += "custom";
05302                     markerStr += gDigitsSep;
05303                     markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
05304                   }
05305                   else {
05306                     markerStr += "std";
05307                     markerStr += gDigitsSep;
05308                     markerStr += QString::number( (int)aMarkerType );
05309                     markerStr += gDigitsSep;
05310                     markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
05311                   }
05312 
05313                   param = vtkParam + "PointMarker";
05314                   ip->setParameter(entry, param, markerStr.toLatin1().data());
05315 
05316                   // Opacity
05317                   param = vtkParam + "Opacity";
05318                   ip->setParameter(entry, param,
05319                                    QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
05320 
05321                   // Clipping
05322                   param = vtkParam + "ClippingPlane";
05323                   int aPlaneId = 0;
05324                   if( !aClippingPlaneInfoList.empty() ) {
05325                     SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
05326                     for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
05327                     {
05328                       const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
05329                       std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
05330                       SMESH::TActorList::iterator anIter2 = anActorList.begin();
05331                       for ( ; anIter2 != anActorList.end(); anIter2++ ) {
05332                         if( aSmeshActor == *anIter2 ) {
05333                           ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
05334                                             QString::number( anId ).toLatin1().constData() );
05335                           break;
05336                         }
05337                       }
05338                     }
05339                   }
05340                   if( aPlaneId == 0 )
05341                     ip->setParameter( entry, param, "Off" );
05342                 } // if (io->hasEntry())
05343               } // SMESH_Actor && hasIO
05344             } // isVisible
05345           } // while.. actors traversal
05346         } // if (vtkView)
05347       } // for (views)
05348       vtkViewers++;
05349     } // if (SVTK view model)
05350   } // for (viewManagers)
05351 }
05352 
05353 // data structures for clipping planes processing
05354 typedef struct {
05355   int Id;
05356   vtkIdType Orientation;
05357   vtkFloatingPointType Distance;
05358   vtkFloatingPointType Angle[2];
05359 } TPlaneData;
05360 typedef std::list<TPlaneData>         TPlaneDataList;
05361 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
05362 
05363 typedef std::list<vtkActor*>          TActorList;
05364 typedef struct {
05365   int PlaneId;
05366   TActorList ActorList;
05367   SUIT_ViewManager* ViewManager;
05368 } TPlaneInfo;
05369 typedef std::list<TPlaneInfo>         TPlaneInfoList;
05370 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
05371 
05378 void SMESHGUI::restoreVisualParameters (int savePoint)
05379 {
05380   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
05381   if (!appStudy || !appStudy->studyDS())
05382     return;
05383   _PTR(Study) studyDS = appStudy->studyDS();
05384 
05385   // componentName is used for encoding of entries when storing them in IParameters
05386   std::string componentName = myComponentSMESH->ComponentDataType();
05387   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
05388   //if (!aSComponent) return;
05389 
05390   // IParameters
05391   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
05392                                                              componentName.c_str(),
05393                                                              savePoint);
05394   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
05395 
05396   // restore map of custom markers and map of clipping planes
05397   VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
05398   TPlaneDataMap aPlaneDataMap;
05399 
05400   std::vector<std::string> properties = ip->getProperties();
05401   for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
05402   {
05403     std::string property = *propIt;
05404     QString aPropertyName( property.c_str() );
05405     QString aPropertyValue( ip->getProperty( property ).c_str() );
05406 
05407     QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
05408     if( aPropertyNameList.isEmpty() )
05409       continue;
05410 
05411     QString aPropertyType = aPropertyNameList[0];
05412     if( aPropertyType == "texture" )
05413     {
05414       if( aPropertyNameList.size() != 2 )
05415         continue;
05416 
05417       bool ok = false;
05418       int anId = aPropertyNameList[1].toInt( &ok );
05419       if( !ok || anId < 1 )
05420         continue;
05421 
05422       QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
05423       if( aPropertyValueList.size() != 2 )
05424         continue;
05425 
05426       std::string aMarkerFileName = aPropertyValueList[0].toStdString();
05427       QString aMarkerTextureString = aPropertyValueList[1];
05428       QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
05429       if( aMarkerTextureStringList.size() != 3 )
05430         continue;
05431 
05432       ok = false;
05433       ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
05434       if( !ok )
05435         continue;
05436 
05437       ok = false;
05438       ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
05439       if( !ok )
05440         continue;
05441 
05442       VTK::MarkerTexture aMarkerTexture;
05443       aMarkerTexture.push_back( aWidth );
05444       aMarkerTexture.push_back( aHeight );
05445 
05446       QString aMarkerTextureData = aMarkerTextureStringList[2];
05447       for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
05448       {
05449         QChar aChar = aMarkerTextureData.at( i );
05450         if( aChar.isDigit() )
05451           aMarkerTexture.push_back( aChar.digitValue() );
05452       }
05453 
05454       aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
05455     }
05456     else if( aPropertyType == "ClippingPlane" )
05457     {
05458       if( aPropertyNameList.size() != 3 )
05459         continue;
05460 
05461       bool ok = false;
05462       int aViewId = aPropertyNameList[1].toInt( &ok );
05463       if( !ok || aViewId < 0 )
05464         continue;
05465 
05466       ok = false;
05467       int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
05468       if( !ok || aClippingPlaneId < 0 )
05469         continue;
05470 
05471       QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
05472       if( aPropertyValueList.size() != 4 )
05473         continue;
05474 
05475       TPlaneData aPlaneData;
05476       aPlaneData.Id = aClippingPlaneId;
05477 
05478       ok = false;
05479       aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
05480       if( !ok )
05481         continue;
05482 
05483       ok = false;
05484       aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
05485       if( !ok )
05486         continue;
05487 
05488       ok = false;
05489       aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
05490       if( !ok )
05491         continue;
05492 
05493       ok = false;
05494       aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
05495       if( !ok )
05496         continue;
05497 
05498       TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
05499       aPlaneDataList.push_back( aPlaneData );
05500     }
05501   }
05502 
05503   TPlaneInfoMap aPlaneInfoMap;
05504 
05505   std::vector<std::string> entries = ip->getEntries();
05506 
05507   for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
05508   {
05509     // entry is a normal entry - it should be "decoded" (setting base adress of component)
05510     QString entry (ip->decodeEntry(*entIt).c_str());
05511 
05512     // Check that the entry corresponds to a real object in the Study
05513     // as the object may be deleted or modified after the visual state is saved.
05514     _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
05515     if (!so) continue; //Skip the not existent entry
05516 
05517     std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
05518     std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
05519 
05520     std::vector<std::string>::iterator namesIt = paramNames.begin();
05521     std::vector<std::string>::iterator valuesIt = paramValues.begin();
05522 
05523     // actors are stored in a map after displaying of them for
05524     // quicker access in the future: map < viewID to actor >
05525     NCollection_DataMap<int, SMESH_Actor*> vtkActors;
05526 
05527     for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
05528     {
05529       // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
05530       // '_' is used as separator and should not be used in viewer type or parameter names.
05531       QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
05532       if (lst.size() != 3)
05533         continue;
05534 
05535       QString viewerTypStr = lst[0];
05536       QString viewIndexStr = lst[1];
05537       QString paramNameStr = lst[2];
05538 
05539       bool ok;
05540       int viewIndex = viewIndexStr.toUInt(&ok);
05541       if (!ok) // bad conversion of view index to integer
05542         continue;
05543 
05544       // viewers
05545       if (viewerTypStr == SVTK_Viewer::Type())
05546       {
05547         SMESH_Actor* aSmeshActor = 0;
05548         if (vtkActors.IsBound(viewIndex))
05549           aSmeshActor = vtkActors.Find(viewIndex);
05550 
05551         QList<SUIT_ViewManager*> lst;
05552         getApp()->viewManagers(viewerTypStr, lst);
05553 
05554         // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
05555         SUIT_ViewManager* vman = NULL;
05556         if (viewIndex >= 0 && viewIndex < lst.count())
05557           vman = lst.at(viewIndex);
05558 
05559         if (paramNameStr == "Visibility")
05560         {
05561           if (!aSmeshActor && displayer() && vman)
05562           {
05563             SUIT_ViewModel* vmodel = vman->getViewModel();
05564             // SVTK view model can be casted to SALOME_View
05565             displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
05566 
05567             // store displayed actor in a temporary map for quicker
05568             // access later when restoring other parameters
05569             SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
05570             vtkRenderer* Renderer = vtkView->getRenderer();
05571             VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
05572             vtkActorCollection* theActors = aCopy.GetActors();
05573             theActors->InitTraversal();
05574             bool isFound = false;
05575             vtkActor *ac = theActors->GetNextActor();
05576             for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
05577               if (ac->IsA("SMESH_Actor")) {
05578                 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
05579                 if (aGeomAc->hasIO()) {
05580                   Handle(SALOME_InteractiveObject) io =
05581                     Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
05582                   if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
05583                     isFound = true;
05584                     vtkActors.Bind(viewIndex, aGeomAc);
05585                   }
05586                 }
05587               }
05588             }
05589           }
05590         } // if (paramNameStr == "Visibility")
05591         else
05592         {
05593           // the rest properties "work" with SMESH_Actor
05594           if (aSmeshActor)
05595           {
05596             QString val ((*valuesIt).c_str());
05597 
05598             // Representation
05599             if (paramNameStr == "Representation") {
05600               aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
05601             }
05602             // IsShrunk
05603             else if (paramNameStr == "IsShrunk") {
05604               if (val.toInt()) {
05605                 if (!aSmeshActor->IsShrunk())
05606                   aSmeshActor->SetShrink();
05607               }
05608               else {
05609                 if (aSmeshActor->IsShrunk())
05610                   aSmeshActor->UnShrink();
05611               }
05612             }
05613             // Displayed entities
05614             else if (paramNameStr == "Entities") {
05615               QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
05616               if (mode.count() == 6) {
05617                 if (mode[0] != "e" || mode[2]  != "f" || mode[4] != "v") {
05618                   MESSAGE("Invalid order of data in Entities, must be: "
05619                           "e:0/1:f:0/1:v:0/1");
05620                 }
05621                 else {
05622                   unsigned int aMode = aSmeshActor->GetEntityMode();
05623                   unsigned int aNewMode =
05624                     (int(SMESH_Actor::eEdges  ) * mode[1].toInt()) |
05625                     (int(SMESH_Actor::eFaces  ) * mode[3].toInt()) |
05626                     (int(SMESH_Actor::eVolumes) * mode[5].toInt());
05627                   if (aNewMode != aMode)
05628                     aSmeshActor->SetEntityMode(aNewMode);
05629                 }
05630               }
05631             }
05632             // Colors
05633             else if (paramNameStr == "Colors") {
05634               QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
05635               if (colors.count() == 16 || colors.count() == 18 ) {
05636                 if (colors[0] != "surface" || colors[4]  != "backsurface" ||
05637                     (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node") ||
05638                     (colors.count() == 18 && colors[14] != "outline")) {
05639                   MESSAGE("Invalid order of data in Colors, must be: "
05640                           "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b or surface:r:g:b:backsurface:delta:edge:r:g:b:node:r:g:b:outline:r:g:b");
05641                 }
05642                 else {
05643                   int delta = 0;
05644                   float er,eg,eb;
05645                   float nr,ng,nb;
05646                   vtkFloatingPointType otr,otg,otb;
05647                   //Old case backsurface color is independent
05648                   if( colors.count() == 16 ) {
05649                     QColor ffc;
05650                     SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
05651                     er = colors[9].toFloat();
05652                     eg = colors[10].toFloat();
05653                     eb = colors[11].toFloat();
05654 
05655                     nr = colors[13].toFloat();
05656                     ng = colors[14].toFloat();
05657                     nb = colors[15].toFloat();
05658                     SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
05659                   } else {
05660                     //New case backsurface color depends on surface color
05661                     delta = colors[5].toInt();
05662 
05663                     er = colors[7].toFloat();
05664                     eg = colors[8].toFloat();
05665                     eb = colors[9].toFloat();
05666 
05667                     nr = colors[11].toFloat();
05668                     ng = colors[12].toFloat();
05669                     nb = colors[13].toFloat();
05670 
05671                     otr = colors[15].toFloat();
05672                     otg = colors[16].toFloat();
05673                     otb = colors[17].toFloat();
05674                   }
05675                   aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
05676                   aSmeshActor->SetEdgeColor(er,eg,eb);
05677                   aSmeshActor->SetNodeColor(nr,ng,nb);
05678                   aSmeshActor->SetOutlineColor(otr,otg,otb);
05679                 }
05680               }
05681             }
05682             // Sizes of lines and points
05683             else if (paramNameStr == "Sizes") {
05684               QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
05685               if (sizes.count() == 4) {
05686                 if (sizes[0] != "line" || sizes[2] != "shrink") {
05687                   MESSAGE("Invalid order of data in Sizes, must be: "
05688                           "line:int:shrink:float");
05689                 }
05690                 else {
05691                   aSmeshActor->SetLineWidth(sizes[1].toInt());
05692                   aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
05693                 }
05694               }
05695               else if (sizes.count() == 6) { // just to support old format
05696                 if (sizes[0] != "line" || sizes[2]  != "node" || sizes[4] != "shrink") {
05697                   MESSAGE("Invalid order of data in Sizes, must be: "
05698                           "line:int:node:int:shrink:float");
05699                 }
05700                 else {
05701                   aSmeshActor->SetLineWidth(sizes[1].toInt());
05702                   //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
05703                   aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
05704                 }
05705               }
05706             }
05707             // Point marker
05708             else if (paramNameStr == "PointMarker") {
05709               QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
05710               if( data.count() >= 2 ) {
05711                 bool ok = false;
05712                 int aParam1 = data[1].toInt( &ok );
05713                 if( ok ) {
05714                   if( data[0] == "std" && data.count() == 3 ) {
05715                     int aParam2 = data[2].toInt( &ok );
05716                     aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
05717                   }
05718                   else if( data[0] == "custom" ) {
05719                     VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
05720                     if( markerIt != aMarkerMap.end() ) {
05721                       VTK::MarkerData aMarkerData = markerIt->second;
05722                       aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
05723                     }
05724                   }
05725                 }
05726               }
05727             }
05728             // Opacity
05729             else if (paramNameStr == "Opacity") {
05730               aSmeshActor->SetOpacity(val.toFloat());
05731             }
05732             // Clipping
05733             else if (paramNameStr.startsWith("ClippingPlane")) {
05734               QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
05735               // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
05736               // new format - val looks like "Off" or "0" (plane id)
05737               // (note: in new format "Off" value is used only for consistency,
05738               //  so it is processed together with values in old format)
05739               bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
05740               if( anIsOldFormat ) {
05741                 if (paramNameStr == "ClippingPlane1" || val == "Off")
05742                   aSmeshActor->RemoveAllClippingPlanes();
05743                 if (val != "Off") {
05744                   SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
05745                   double aDistance = vals[1].toFloat();
05746                   vtkFloatingPointType anAngle[2];
05747                   anAngle[0] = vals[2].toFloat();
05748                   anAngle[1] = vals[3].toFloat();
05749 
05750                   QList<SUIT_ViewManager*> lst;
05751                   getApp()->viewManagers(viewerTypStr, lst);
05752                   // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
05753                   if (viewIndex >= 0 && viewIndex < lst.count()) {
05754                     SUIT_ViewManager* vman = lst.at(viewIndex);
05755                     SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
05756 
05757                     SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
05758 
05759                     SMESH::TActorList anActorList;
05760                     anActorList.push_back( aSmeshActor );
05761                     SMESH::OrientedPlane* aPlane =
05762                       SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
05763                     if( aPlane ) {
05764                       SMESH::ClippingPlaneInfo aClippingPlaneInfo;
05765                       aClippingPlaneInfo.Plane = aPlane;
05766                       aClippingPlaneInfo.ActorList = anActorList;
05767                       aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
05768                     }
05769                   }
05770                 }
05771               }
05772               else {
05773                 bool ok = false;
05774                 int aPlaneId = val.toInt( &ok );
05775                 if( ok && aPlaneId >= 0 ) {
05776                   bool anIsDefinedPlane = false;
05777                   TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
05778                   TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
05779                   for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
05780                     TPlaneInfo& aPlaneInfo = *anIter;
05781                     if( aPlaneInfo.PlaneId == aPlaneId ) {
05782                       aPlaneInfo.ActorList.push_back( aSmeshActor );
05783                       anIsDefinedPlane = true;
05784                       break;
05785                     }
05786                   }
05787                   if( !anIsDefinedPlane ) {
05788                     TPlaneInfo aPlaneInfo;
05789                     aPlaneInfo.PlaneId = aPlaneId;
05790                     aPlaneInfo.ActorList.push_back( aSmeshActor );
05791                     aPlaneInfo.ViewManager = vman;
05792 
05793                     // to make the list sorted by plane id
05794                     anIter = aPlaneInfoList.begin();
05795                     for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
05796                       const TPlaneInfo& aPlaneInfoRef = *anIter;
05797                       if( aPlaneInfoRef.PlaneId > aPlaneId )
05798                         break;
05799                     }
05800                     aPlaneInfoList.insert( anIter, aPlaneInfo );
05801                   }
05802                 }
05803               }
05804             }
05805           } // if (aSmeshActor)
05806         } // other parameters than Visibility
05807       }
05808     } // for names/parameters iterator
05809   } // for entries iterator
05810 
05811   // take into account planes with empty list of actors referred to them
05812   QList<SUIT_ViewManager*> aVMList;
05813   getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
05814 
05815   TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
05816   for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
05817     int aViewId = aPlaneDataIter->first;
05818     if( aViewId >= 0 && aViewId < aVMList.count() ) {
05819       SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
05820 
05821       const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
05822 
05823       TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
05824       TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
05825       for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
05826         const TPlaneData& aPlaneData = *anIter2;
05827         int aPlaneId = aPlaneData.Id;
05828 
05829         bool anIsFound = false;
05830         TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
05831         for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
05832           const TPlaneInfo& aPlaneInfo = *anIter3;
05833           if( aPlaneInfo.PlaneId == aPlaneId ) {
05834             anIsFound = true;
05835             break;
05836           }
05837         }
05838 
05839         if( !anIsFound ) {
05840           TPlaneInfo aPlaneInfo; // ActorList field is empty
05841           aPlaneInfo.PlaneId = aPlaneId;
05842           aPlaneInfo.ViewManager = aViewManager;
05843 
05844           // to make the list sorted by plane id
05845           TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
05846           for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
05847             const TPlaneInfo& aPlaneInfoRef = *anIter4;
05848             if( aPlaneInfoRef.PlaneId > aPlaneId )
05849               break;
05850           }
05851           aPlaneInfoList.insert( anIter4, aPlaneInfo );
05852         }
05853       }
05854     }
05855   }
05856 
05857   // add clipping planes to actors according to the restored parameters
05858   // and update the clipping plane map
05859   TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
05860   for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
05861     int aViewId = anIter1->first;
05862     const TPlaneInfoList& aPlaneInfoList = anIter1->second;
05863 
05864     TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
05865     if( anIter2 == aPlaneDataMap.end() )
05866       continue;
05867     const TPlaneDataList& aPlaneDataList = anIter2->second;
05868 
05869     TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
05870     for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
05871       const TPlaneInfo& aPlaneInfo = *anIter3;
05872       int aPlaneId = aPlaneInfo.PlaneId;
05873       const TActorList& anActorList = aPlaneInfo.ActorList;
05874       SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
05875       if( !aViewManager )
05876         continue;
05877 
05878       SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
05879       if( !aViewWindow )
05880         continue;
05881 
05882       SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
05883 
05884       TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
05885       for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
05886         const TPlaneData& aPlaneData = *anIter4;
05887         if( aPlaneData.Id == aPlaneId ) {
05888           SMESH::OrientedPlane* aPlane =
05889             SMESHGUI_ClippingDlg::AddPlane( anActorList,
05890                                             aViewWindow,
05891                                             (SMESH::Orientation)aPlaneData.Orientation,
05892                                             aPlaneData.Distance,
05893                                             aPlaneData.Angle );
05894           if( aPlane ) {
05895             SMESH::ClippingPlaneInfo aClippingPlaneInfo;
05896             aClippingPlaneInfo.Plane = aPlane;
05897             aClippingPlaneInfo.ActorList = anActorList;
05898             aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
05899           }
05900           break;
05901         }
05902       }
05903     }
05904   }
05905 
05906   // update all VTK views
05907   QList<SUIT_ViewManager*> lst;
05908   getApp()->viewManagers(lst);
05909   for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
05910     SUIT_ViewModel* vmodel = (*it)->getViewModel();
05911     if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
05912       SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
05913       vtkView->getRenderer()->ResetCameraClippingRange();
05914       vtkView->Repaint();
05915     }
05916   }
05917 }
05918 
05926 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
05927 {
05928   int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
05929 
05930   setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
05931 
05932   QStringList fam;
05933   fam.append( tr( "SMESH_FONT_ARIAL" ) );
05934   fam.append( tr( "SMESH_FONT_COURIER" ) );
05935   fam.append( tr( "SMESH_FONT_TIMES" ) );
05936 
05937   setPreferenceProperty( tfont, "fonts", fam );
05938 
05939   int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
05940   setPreferenceProperty( tfont, "features", f );
05941 
05942   return tfont;
05943 }
05944 
05949 void SMESHGUI::onHypothesisEdit( int result )
05950 {
05951   if( result == 1 )
05952     SMESHGUI::Modified();
05953   updateObjBrowser( true );
05954 }
05955 
05956 
05961 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
05962 #ifndef DISABLE_PLOT2DVIEWER
05963   //Crear all Plot2d Viewers if need.
05964   SMESH::ClearPlot2Viewers(pview);
05965 #endif
05966 }
05967 
05968 void SMESHGUI::message( const QString& msg )
05969 {
05970   // dispatch message
05971   QStringList data = msg.split("/");
05972   if ( data.count() > 0 ) {
05973     if ( data.first() == "mesh_loading" ) {
05974       // get mesh entry
05975       QString entry = data.count() > 1 ? data[1] : QString();
05976       if ( entry.isEmpty() )
05977         return;
05978       // get study
05979       _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
05980       // get mesh name
05981       _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
05982       QString name;
05983       if ( obj )
05984         name = obj->GetName().c_str();
05985       if ( name.isEmpty() )
05986         return;
05987       
05988       if ( data.last() == "stop" )
05989         application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
05990       else
05991         application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
05992       QApplication::processEvents();
05993     }
05994   }
05995 }
05996 
06001 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
06002   if(!pview)
06003     return;
06004 
06005   SUIT_ViewManager* viewMgr = pview->getViewManager();
06006   if ( viewMgr ) {
06007     disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
06008                 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
06009 
06010     connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
06011              this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
06012   }
06013 }
06014 
06018 bool SMESHGUI::renameAllowed( const QString& entry) const {
06019   SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
06020   if( !anApp )
06021     return false;
06022 
06023   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
06024   if( !appStudy )
06025     return false;
06026 
06027   SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
06028   
06029   if(!obj)
06030     return false;
06031 
06032   if(appStudy->isComponent(entry) || obj->isReference())
06033     return false;
06034 
06035   // check type to prevent renaming of inappropriate objects
06036   int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
06037   if (aType == MESH || aType == GROUP ||
06038       aType == SUBMESH || aType == SUBMESH_COMPOUND ||
06039       aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
06040       aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
06041       aType == HYPOTHESIS || aType == ALGORITHM)
06042     return true;
06043 
06044   return false;
06045 }
06046 
06053 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
06054 
06055   SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
06056   if( !anApp )
06057     return false;
06058     
06059   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
06060 
06061   if(!appStudy)
06062     return false;
06063   
06064   _PTR(Study) aStudy = appStudy->studyDS();
06065   
06066   if(!aStudy)
06067     return false;
06068   
06069   bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
06070   if ( aLocked ) {
06071     SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
06072     return false;
06073   }
06074 
06075 
06076   _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
06077   _PTR(GenericAttribute) anAttr;
06078   _PTR(AttributeName) aName;
06079   if ( obj ) {
06080     if ( obj->FindAttribute(anAttr, "AttributeName") ) {
06081       aName = anAttr;
06082       // check type to prevent renaming of inappropriate objects
06083       int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
06084       if (aType == MESH || aType == GROUP ||
06085           aType == SUBMESH || aType == SUBMESH_COMPOUND ||
06086           aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
06087           aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
06088           aType == HYPOTHESIS || aType == ALGORITHM) {
06089         if ( !name.isEmpty() ) {
06090           SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
06091 
06092           // update name of group object and its actor
06093           Handle(SALOME_InteractiveObject) IObject =
06094             new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
06095 
06096           SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
06097           if( !aGroupObject->_is_nil() ) {
06098             aGroupObject->SetName( qPrintable(name) );
06099             if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
06100               anActor->setName( qPrintable(name) );
06101           }
06102           return true;
06103         }
06104       }
06105     }
06106   }
06107   return false;
06108 }