Version: 6.3.1

src/SMESHGUI/SMESHGUI.cxx

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