Back to index

salome-geom  6.5.0
GeometryGUI.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  File   : GeometryGUI.cxx
00023 //  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00024 
00025 #include <Standard_math.hxx>  // E.A. must be included before Python.h to fix compilation on windows
00026 #ifdef HAVE_FINITE
00027 #undef HAVE_FINITE            // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
00028 #endif
00029 #include "Python.h"
00030 #include "GeometryGUI.h"
00031 #include "GeometryGUI_Operations.h"
00032 #include "GEOMGUI_OCCSelector.h"
00033 #include "GEOMGUI_Selection.h"
00034 #include "GEOM_Constants.h"
00035 #include "GEOM_Displayer.h"
00036 #include "GEOM_AISShape.hxx"
00037 
00038 #include "GEOM_Actor.h"
00039 
00040 #include <Material_ResourceMgr.h>
00041 
00042 #include <SUIT_Desktop.h>
00043 #include <SUIT_MessageBox.h>
00044 #include <SUIT_ResourceMgr.h>
00045 #include <SUIT_Session.h>
00046 #include <SUIT_ViewManager.h>
00047 
00048 #include <OCCViewer_ViewWindow.h>
00049 #include <OCCViewer_ViewPort3d.h>
00050 #include <OCCViewer_ViewModel.h>
00051 #include <OCCViewer_ViewManager.h>
00052 
00053 #include <SOCC_ViewModel.h>
00054 #include <SOCC_ViewWindow.h>
00055 
00056 #include <SVTK_ViewWindow.h>
00057 #include <SVTK_RenderWindowInteractor.h>
00058 #include <SVTK_InteractorStyle.h>
00059 #include <SVTK_ViewModel.h>
00060 
00061 #include <SalomeApp_Application.h>
00062 #include <SalomeApp_DataObject.h>
00063 #include <SalomeApp_Study.h>
00064 
00065 #include <LightApp_SelectionMgr.h>
00066 #include <LightApp_VTKSelector.h>
00067 #include <LightApp_DataObject.h>
00068 #include <LightApp_Preferences.h>
00069 
00070 #include <SALOME_LifeCycleCORBA.hxx>
00071 #include <SALOME_ListIO.hxx>
00072 #include <SALOME_ListIteratorOfListIO.hxx>
00073 
00074 #include <SALOMEDSClient_ClientFactory.hxx>
00075 #include <SALOMEDSClient_IParameters.hxx>
00076 
00077 #include <Basics_OCCTVersion.hxx>
00078 
00079 // External includes
00080 #include <QMenu>
00081 #include <QTime>
00082 #include <QAction>
00083 #include <QFileInfo>
00084 #include <QString>
00085 #include <QPainter>
00086 
00087 #include <AIS_Drawer.hxx>
00088 #include <AIS_ListOfInteractive.hxx>
00089 #include <AIS_ListIteratorOfListOfInteractive.hxx>
00090 #include <Prs3d_Drawer.hxx>
00091 #include <Prs3d_IsoAspect.hxx>
00092 #include <Aspect_TypeOfMarker.hxx>
00093 #include <OSD_SharedLibrary.hxx>
00094 #include <NCollection_DataMap.hxx>
00095 
00096 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
00097 #include <TColStd_HArray1OfByte.hxx>
00098 #else
00099 #include <Graphic3d_HArray1OfBytes.hxx>
00100 #endif
00101 
00102 #include <utilities.h>
00103 
00104 #include <vtkCamera.h>
00105 #include <vtkRenderer.h>
00106 
00107 #include <GEOM_version.h>
00108 
00109 
00110 #include "GEOMImpl_Types.hxx"
00111 
00112 extern "C" {
00113   Standard_EXPORT CAM_Module* createModule() {
00114     return new GeometryGUI();
00115   }
00116 
00117   Standard_EXPORT char* getModuleVersion() {
00118     return (char*)GEOM_VERSION_STR;
00119   }
00120 }
00121 
00122 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
00123 
00124 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
00125 
00126 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
00127 {
00128   // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
00129   if (CORBA::is_nil(myComponentGeom))
00130     InitGeomGen();
00131   return GeometryGUI::myComponentGeom;
00132 }
00133 
00134 bool GeometryGUI::InitGeomGen()
00135 {
00136   GeometryGUI aGG;
00137   if( CORBA::is_nil( myComponentGeom ) ) return false;
00138   return true;
00139 }
00140 
00141 //=======================================================================
00142 // function : ClientSObjectToObject
00143 // purpose  :
00144 //=======================================================================
00145 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
00146 {
00147   _PTR(GenericAttribute) anAttr;
00148   CORBA::Object_var anObj;
00149   try {
00150     std::string aValue = theSObject->GetIOR();
00151     if (strcmp(aValue.c_str(), "") != 0) {
00152       CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
00153       anObj = anORB->string_to_object(aValue.c_str());
00154     }
00155   } catch(...) {
00156     INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
00157   }
00158   return anObj._retn();
00159 }
00160 
00161 //=======================================================================
00162 // function : ClientStudyToStudy
00163 // purpose  :
00164 //=======================================================================
00165 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
00166 {
00167   SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
00168   CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
00169   SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
00170   int aStudyID = theStudy->StudyId();
00171   SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
00172   return aDSStudy._retn();
00173 }
00174 
00175 void GeometryGUI::Modified( bool theIsUpdateActions )
00176 {
00177   if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
00178     if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
00179       appStudy->Modified();
00180       if( theIsUpdateActions )
00181         app->updateActions();
00182     }
00183   }
00184 }
00185 
00186 //=======================================================================
00187 // function : GeometryGUI::GeometryGUI()
00188 // purpose  : Constructor
00189 //=======================================================================
00190 GeometryGUI::GeometryGUI() :
00191   SalomeApp_Module( "GEOM" ),
00192   LightApp_Module( "GEOM" )
00193 {
00194   if ( CORBA::is_nil( myComponentGeom ) )
00195   {
00196     Engines::EngineComponent_var comp =
00197       SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
00198     myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
00199   }
00200 
00201   myActiveDialogBox = 0;
00202 
00203   gp_Pnt origin = gp_Pnt(0., 0., 0.);
00204   gp_Dir direction = gp_Dir(0., 0., 1.);
00205   myWorkingPlane = gp_Ax3(origin, direction);
00206 
00207   myDisplayer = 0;
00208   myLocalSelectionMode = GEOM_ALLOBJECTS;
00209 }
00210 
00211 //=======================================================================
00212 // function : GeometryGUI::~GeometryGUI()
00213 // purpose  : Destructor
00214 //=======================================================================
00215 GeometryGUI::~GeometryGUI()
00216 {
00217   while (!myOCCSelectors.isEmpty())
00218     delete myOCCSelectors.takeFirst();
00219 
00220   while (!myVTKSelectors.isEmpty())
00221     delete myVTKSelectors.takeFirst();
00222 
00223   qDeleteAll(myGUIMap);
00224 }
00225 
00226 //=======================================================================
00227 // function : GeometryGUI::getLibrary()
00228 // purpose  : get or load GUI library by name [ internal ]
00229 //=======================================================================
00230 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
00231 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
00232 {
00233   if ( !myGUIMap.contains( libraryName ) ) {
00234     // try to load library if it is not loaded yet
00235 #ifndef WNT
00236     QString dirs = getenv( "LD_LIBRARY_PATH" );
00237     QString sep  = ":";
00238 #else
00239     QString dirs = getenv( "PATH" );
00240     QString sep  = ";";
00241 #endif
00242     if ( !dirs.isEmpty() ) {
00243       QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
00244       QListIterator<QString> it( dirList ); it.toBack();
00245       while ( it.hasPrevious() ) {
00246         QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
00247         if ( fi.exists() ) {
00248           OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
00249           bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
00250           if ( !res ) {
00251             MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
00252             continue; // continue search further
00253           }
00254           OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
00255           if ( osdF != NULL ) {
00256             LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
00257             GEOMGUI* libGUI = (*func)( this );
00258             if ( libGUI ) {
00259               myGUIMap[ libraryName ] = libGUI;
00260               break; // found and loaded!
00261             }
00262           }
00263         }
00264       }
00265     }
00266   }
00267   return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
00268 }
00269 
00270 //=======================================================================
00271 // function : GeometryGUI::ActiveWorkingPlane()
00272 // purpose  : Activate Working Plane View
00273 //=======================================================================
00274 void GeometryGUI::ActiveWorkingPlane()
00275 {
00276   gp_Dir DZ = myWorkingPlane.Direction();
00277   gp_Dir DY = myWorkingPlane.YDirection();
00278 
00279   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
00280   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
00281   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
00282 
00283   if( ViewOCC ) {
00284     OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
00285     if ( vw ) {
00286       Handle(V3d_View) view3d =  vw->getViewPort()->getView();
00287 
00288       view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
00289       view3d->SetUp(DY.X(), DY.Y(), DY.Z());
00290       vw->onViewFitAll(); 
00291     }
00292   }
00293   else if( ViewVTK ) {
00294     SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
00295     if ( vw ) {
00296       vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
00297 
00298       camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
00299       camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
00300       camera->SetFocalPoint(0,0,0);
00301 
00302       vw->onFitAll();
00303     }
00304   }
00305 }
00306 
00307 //=======================================================================
00308 // function : GeometryGUI::SetActiveDialogBox()
00309 // purpose  : Set active dialog box
00310 //=======================================================================
00311 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
00312 {
00313   myActiveDialogBox = (QDialog*)aDlg;
00314 }
00315 
00316 //=======================================================================
00317 // function : GeometryGUI::EmitSignalDeactivateDialog()
00318 // purpose  : Emit a signal to deactivate the active dialog Box
00319 //=======================================================================
00320 void GeometryGUI::EmitSignalDeactivateDialog()
00321 {
00322   emit SignalDeactivateActiveDialog();
00323 }
00324 
00325 //=======================================================================
00326 // function : GeometryGUI::EmitSignalCloseAllDialogs()
00327 // purpose  : Emit a signal to close all non modal dialogs box
00328 //=======================================================================
00329 void GeometryGUI::EmitSignalCloseAllDialogs()
00330 {
00331   emit SignalCloseAllDialogs();
00332 }
00333 
00334 //=======================================================================
00335 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
00336 // purpose  : Emit a signal to inform that default real spin box step has
00337 //            been changed
00338 //=======================================================================
00339 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
00340 {
00341   emit SignalDefaultStepValueChanged(newVal);
00342 }
00343 
00344 //=======================================================================
00345 // function : GeometryGUI::OnGUIEvent()
00346 // purpose  : common slot for all menu/toolbar actions
00347 //=======================================================================
00348 void GeometryGUI::OnGUIEvent()
00349 {
00350   const QObject* obj = sender();
00351   if ( !obj || !obj->inherits( "QAction" ) )
00352     return;
00353   int id = actionId((QAction*)obj);
00354   if ( id != -1 )
00355     OnGUIEvent( id );
00356 }
00357 
00358 //=======================================================================
00359 // function : GeometryGUI::OnGUIEvent()
00360 // purpose  : manage all events on GUI [static]
00361 //=======================================================================
00362 void GeometryGUI::OnGUIEvent( int id )
00363 {
00364   SUIT_Application* anApp = application();
00365   if (!anApp) return;
00366   SUIT_Desktop* desk = anApp->desktop();
00367 
00368   // check type of the active viewframe
00369   SUIT_ViewWindow* window = desk->activeWindow();
00370   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
00371   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
00372   // if current viewframe is not of OCC and not of VTK type - return immediately
00373   // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
00374   QList<int> NotViewerDependentCommands;
00375   NotViewerDependentCommands << GEOMOp::OpDelete
00376                              << GEOMOp::OpShow
00377                              << GEOMOp::OpShowOnly
00378                              << GEOMOp::OpShowChildren
00379                              << GEOMOp::OpHideChildren
00380                              << GEOMOp::OpUnpublishObject
00381                              << GEOMOp::OpPublishObject
00382                              << GEOMOp::OpPointMarker;
00383   if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
00384       return;
00385 
00386   // fix for IPAL9103, point 2
00387   if ( CORBA::is_nil( GetGeomGen() ) ) {
00388     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
00389     return;
00390   }
00391 
00392   QString libName;
00393   // find corresponding GUI library
00394   switch ( id ) {
00395   case GEOMOp::OpOriginAndVectors:   // MENU BASIC - ORIGIN AND BASE VECTORS
00396     createOriginAndBaseVectors(); // internal operation
00397     return;
00398   case GEOMOp::OpImport:             // MENU FILE - IMPORT
00399   case GEOMOp::OpExport:             // MENU FILE - EXPORT
00400   case GEOMOp::OpSelectVertex:       // POPUP MENU - SELECT ONLY - VERTEX
00401   case GEOMOp::OpSelectEdge:         // POPUP MENU - SELECT ONLY - EDGE
00402   case GEOMOp::OpSelectWire:         // POPUP MENU - SELECT ONLY - WIRE
00403   case GEOMOp::OpSelectFace:         // POPUP MENU - SELECT ONLY - FACE
00404   case GEOMOp::OpSelectShell:        // POPUP MENU - SELECT ONLY - SHELL
00405   case GEOMOp::OpSelectSolid:        // POPUP MENU - SELECT ONLY - SOLID
00406   case GEOMOp::OpSelectCompound:     // POPUP MENU - SELECT ONLY - COMPOUND
00407   case GEOMOp::OpSelectAll:          // POPUP MENU - SELECT ONLY - SELECT ALL
00408   case GEOMOp::OpDelete:             // MENU EDIT - DELETE
00409   case GEOMOp::OpCheckGeom:          // MENU TOOLS - CHECK GEOMETRY
00410   case GEOMOp::OpDeflection:         // POPUP MENU - DEFLECTION COEFFICIENT
00411   case GEOMOp::OpColor:              // POPUP MENU - COLOR
00412   case GEOMOp::OpSetTexture:         // POPUP MENU - SETTEXTURE
00413   case GEOMOp::OpTransparency:       // POPUP MENU - TRANSPARENCY
00414   case GEOMOp::OpIncrTransparency:   // SHORTCUT   - INCREASE TRANSPARENCY
00415   case GEOMOp::OpDecrTransparency:   // SHORTCUT   - DECREASE TRANSPARENCY
00416   case GEOMOp::OpIsos:               // POPUP MENU - ISOS
00417   case GEOMOp::OpIncrNbIsos:         // SHORTCUT   - INCREASE NB ISOS
00418   case GEOMOp::OpDecrNbIsos:         // SHORTCUT   - DECREASE NB ISOS
00419   case GEOMOp::OpAutoColor:          // POPUP MENU - AUTO COLOR
00420   case GEOMOp::OpNoAutoColor:        // POPUP MENU - DISABLE AUTO COLOR
00421   case GEOMOp::OpShowChildren:       // POPUP MENU - SHOW CHILDREN
00422   case GEOMOp::OpHideChildren:       // POPUP MENU - HIDE CHILDREN
00423   case GEOMOp::OpUnpublishObject:    // POPUP MENU - UNPUBLISH
00424   case GEOMOp::OpPublishObject:      // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
00425   case GEOMOp::OpPointMarker:        // POPUP MENU - POINT MARKER
00426   case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
00427   case GEOMOp::OpEdgeWidth:          // POPUP MENU - LINE WIDTH - EDGE WIDTH
00428   case GEOMOp::OpIsosWidth:          // POPUP MENU - LINE WIDTH - ISOS WIDTH
00429   case GEOMOp::OpBringToFront:       // POPUP MENU - BRING TO FRONT
00430   case GEOMOp::OpClsBringToFront:    //
00431     libName = "GEOMToolsGUI";
00432     break;
00433   case GEOMOp::OpDMWireframe:        // MENU VIEW - WIREFRAME
00434   case GEOMOp::OpDMShading:          // MENU VIEW - SHADING
00435   case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
00436   case GEOMOp::OpShowAll:            // MENU VIEW - SHOW ALL
00437   case GEOMOp::OpShowOnly:           // MENU VIEW - DISPLAY ONLY
00438   case GEOMOp::OpHideAll:            // MENU VIEW - ERASE ALL
00439   case GEOMOp::OpHide:               // MENU VIEW - ERASE
00440   case GEOMOp::OpShow:               // MENU VIEW - DISPLAY
00441   case GEOMOp::OpSwitchVectors:      // MENU VIEW - VECTOR MODE
00442   case GEOMOp::OpWireframe:          // POPUP MENU - WIREFRAME
00443   case GEOMOp::OpShading:            // POPUP MENU - SHADING
00444   case GEOMOp::OpShadingWithEdges:   // POPUP MENU - SHADING WITH EDGES
00445   case GEOMOp::OpTexture:            // POPUP MENU - TEXTURE
00446   case GEOMOp::OpVectors:            // POPUP MENU - VECTORS
00447     libName = "DisplayGUI";
00448     break;
00449   case GEOMOp::OpPoint:              // MENU BASIC - POINT
00450   case GEOMOp::OpLine:               // MENU BASIC - LINE
00451   case GEOMOp::OpCircle:             // MENU BASIC - CIRCLE
00452   case GEOMOp::OpEllipse:            // MENU BASIC - ELLIPSE
00453   case GEOMOp::OpArc:                // MENU BASIC - ARC
00454   case GEOMOp::OpVector:             // MENU BASIC - VECTOR
00455   case GEOMOp::OpPlane:              // MENU BASIC - PLANE
00456   case GEOMOp::OpCurve:              // MENU BASIC - CURVE
00457   case GEOMOp::OpLCS:                // MENU BASIC - LOCAL COORDINATE SYSTEM
00458     libName = "BasicGUI";
00459     break;
00460   case GEOMOp::OpBox:                // MENU PRIMITIVE - BOX
00461   case GEOMOp::OpCylinder:           // MENU PRIMITIVE - CYLINDER
00462   case GEOMOp::OpSphere:             // MENU PRIMITIVE - SPHERE
00463   case GEOMOp::OpTorus:              // MENU PRIMITIVE - TORUS
00464   case GEOMOp::OpCone:               // MENU PRIMITIVE - CONE
00465   case GEOMOp::OpRectangle:          // MENU PRIMITIVE - FACE
00466   case GEOMOp::OpDisk:               // MENU PRIMITIVE - DISK
00467     libName = "PrimitiveGUI";
00468     break;
00469   case GEOMOp::OpPrism:              // MENU GENERATION - PRISM
00470   case GEOMOp::OpRevolution:         // MENU GENERATION - REVOLUTION
00471   case GEOMOp::OpFilling:            // MENU GENERATION - FILLING
00472   case GEOMOp::OpPipe:               // MENU GENERATION - PIPE
00473     libName = "GenerationGUI";
00474     break;
00475   case GEOMOp::Op2dSketcher:         // MENU ENTITY - SKETCHER
00476   case GEOMOp::Op3dSketcher:         // MENU ENTITY - 3D SKETCHER
00477   case GEOMOp::OpExplode:            // MENU ENTITY - EXPLODE
00478 #ifdef WITH_OPENCV
00479   case GEOMOp::OpFeatureDetect:      // MENU ENTITY - FEATURE DETECTION
00480 #endif
00481   case GEOMOp::OpPictureImport:      // MENU ENTITY - IMPORT PICTURE IN VIEWER
00482     libName = "EntityGUI";
00483     break;
00484   case GEOMOp::OpEdge:               // MENU BUILD - EDGE
00485   case GEOMOp::OpWire:               // MENU BUILD - WIRE
00486   case GEOMOp::OpFace:               // MENU BUILD - FACE
00487   case GEOMOp::OpShell:              // MENU BUILD - SHELL
00488   case GEOMOp::OpSolid:              // MENU BUILD - SOLID
00489   case GEOMOp::OpCompound:           // MENU BUILD - COMPUND
00490     libName = "BuildGUI";
00491     break;
00492   case GEOMOp::OpFuse:               // MENU BOOLEAN - FUSE
00493   case GEOMOp::OpCommon:             // MENU BOOLEAN - COMMON
00494   case GEOMOp::OpCut:                // MENU BOOLEAN - CUT
00495   case GEOMOp::OpSection:            // MENU BOOLEAN - SECTION
00496     libName = "BooleanGUI";
00497     break;
00498   case GEOMOp::OpTranslate:          // MENU TRANSFORMATION - TRANSLATION
00499   case GEOMOp::OpRotate:             // MENU TRANSFORMATION - ROTATION
00500   case GEOMOp::OpChangeLoc:          // MENU TRANSFORMATION - LOCATION
00501   case GEOMOp::OpMirror:             // MENU TRANSFORMATION - MIRROR
00502   case GEOMOp::OpScale:              // MENU TRANSFORMATION - SCALE
00503   case GEOMOp::OpOffset:             // MENU TRANSFORMATION - OFFSET
00504   case GEOMOp::OpProjection:         // MENU TRANSFORMATION - PROJECTION
00505   case GEOMOp::OpMultiTranslate:     // MENU TRANSFORMATION - MULTI-TRANSLATION
00506   case GEOMOp::OpMultiRotate:        // MENU TRANSFORMATION - MULTI-ROTATION
00507   case GEOMOp::OpReimport:           // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
00508     libName = "TransformationGUI";
00509     break;
00510   case GEOMOp::OpPartition:          // MENU OPERATION - PARTITION
00511   case GEOMOp::OpArchimede:          // MENU OPERATION - ARCHIMEDE
00512   case GEOMOp::OpFillet3d:           // MENU OPERATION - FILLET
00513   case GEOMOp::OpChamfer:            // MENU OPERATION - CHAMFER
00514   case GEOMOp::OpClipping:           // MENU OPERATION - CLIPPING RANGE
00515   case GEOMOp::OpShapesOnShape:      // MENU OPERATION - GET SHAPES ON SHAPE
00516   case GEOMOp::OpFillet2d:           // MENU OPERATION - FILLET 2D
00517   case GEOMOp::OpFillet1d:           // MENU OPERATION - FILLET 1D
00518   case GEOMOp::OpSharedShapes:       // MENU OPERATION - GET SHARED SHAPES
00519   case GEOMOp::OpExtrudedBoss:       // MENU OPERATION - EXTRUDED BOSS
00520   case GEOMOp::OpExtrudedCut:        // MENU OPERATION - EXTRUDED CUT
00521     libName = "OperationGUI";
00522     break;
00523   case GEOMOp::OpSewing:             // MENU REPAIR - SEWING
00524   case GEOMOp::OpSuppressFaces:      // MENU REPAIR - SUPPRESS FACES
00525   case GEOMOp::OpSuppressHoles:      // MENU REPAIR - SUPPRESS HOLE
00526   case GEOMOp::OpShapeProcess:       // MENU REPAIR - SHAPE PROCESSING
00527   case GEOMOp::OpCloseContour:       // MENU REPAIR - CLOSE CONTOUR
00528   case GEOMOp::OpRemoveIntWires:     // MENU REPAIR - REMOVE INTERNAL WIRES
00529   case GEOMOp::OpAddPointOnEdge:     // MENU REPAIR - ADD POINT ON EDGE
00530   case GEOMOp::OpFreeBoundaries:     // MENU MEASURE - FREE BOUNDARIES
00531   case GEOMOp::OpFreeFaces:          // MENU MEASURE - FREE FACES
00532   case GEOMOp::OpOrientation:        // MENU REPAIR - CHANGE ORIENTATION
00533   case GEOMOp::OpGlueFaces:          // MENU REPAIR - GLUE FACES
00534   case GEOMOp::OpGlueEdges:          // MENU REPAIR - GLUE EDGES
00535   case GEOMOp::OpLimitTolerance:     // MENU REPAIR - LIMIT TOLERANCE
00536   case GEOMOp::OpRemoveExtraEdges:   // MENU REPAIR - REMOVE EXTRA EDGES
00537     libName = "RepairGUI";
00538     break;
00539   case GEOMOp::OpProperties:         // MENU MEASURE - PROPERTIES
00540   case GEOMOp::OpCenterMass:         // MENU MEASURE - CDG
00541   case GEOMOp::OpInertia:            // MENU MEASURE - INERTIA
00542   case GEOMOp::OpNormale:            // MENU MEASURE - NORMALE
00543   case GEOMOp::OpBoundingBox:        // MENU MEASURE - BOUNDING BOX
00544   case GEOMOp::OpMinDistance:        // MENU MEASURE - MIN DISTANCE
00545   case GEOMOp::OpAngle:              // MENU MEASURE - ANGLE
00546   case GEOMOp::OpTolerance:          // MENU MEASURE - TOLERANCE
00547   case GEOMOp::OpWhatIs:             // MENU MEASURE - WHATIS
00548   case GEOMOp::OpCheckShape:         // MENU MEASURE - CHECK
00549   case GEOMOp::OpCheckCompound:      // MENU MEASURE - CHECK COMPOUND OF BLOCKS
00550   case GEOMOp::OpPointCoordinates:   // MENU MEASURE - POINT COORDINATES
00551   case GEOMOp::OpCheckSelfInters:    // MENU MEASURE - CHECK SELF INTERSECTIONS
00552     libName = "MeasureGUI";
00553     break;
00554   case GEOMOp::OpGroupCreate:        // MENU GROUP - CREATE
00555   case GEOMOp::OpGroupCreatePopup:   // POPUP MENU - CREATE GROUP
00556   case GEOMOp::OpGroupEdit:          // MENU GROUP - EDIT
00557     libName = "GroupGUI";
00558     break;
00559   case GEOMOp::OpHexaSolid:          // MENU BLOCKS - HEXAHEDRAL SOLID
00560   case GEOMOp::OpMultiTransform:     // MENU BLOCKS - MULTI-TRANSFORMATION
00561   case GEOMOp::OpQuadFace:           // MENU BLOCKS - QUADRANGLE FACE
00562   case GEOMOp::OpPropagate:          // MENU BLOCKS - PROPAGATE
00563   case GEOMOp::OpExplodeBlock:       // MENU BLOCKS - EXPLODE ON BLOCKS
00564     libName = "BlocksGUI";
00565     break;
00566   case GEOMOp::OpAdvancedNoOp:       // NO OPERATION (advanced operations base)
00567   case GEOMOp::OpPipeTShape:         // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
00568 //   case GEOMOp::OpPipeTShapeGroups:     // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
00569     //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
00570     libName = "AdvancedGUI";
00571     break;
00572   default:
00573     break;
00574   }
00575 
00576   GEOMGUI* library = 0;
00577   if ( !libName.isEmpty() ) {
00578 #ifndef WNT
00579     libName = QString( "lib" ) + libName + ".so";
00580 #else
00581     libName = libName + ".dll";
00582 #endif
00583     library = getLibrary( libName );
00584   }
00585 
00586   // call method of corresponding GUI library
00587   if ( library ) {
00588     library->OnGUIEvent( id, desk );
00589     
00590     // Update a list of materials for "Preferences" dialog
00591     if ( id == GEOMOp::OpMaterialProperties ) {
00592       LightApp_Preferences* pref = preferences();
00593       if ( pref ) {
00594        Material_ResourceMgr aMatResMgr;
00595        setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true )->id(),
00596                             "strings",
00597                             aMatResMgr.materials() );
00598       }
00599     }
00600   }
00601   else
00602     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
00603 }
00604 
00605 //=================================================================================
00606 // function : GeometryGUI::OnKeyPress()
00607 // purpose  : Called when any key is pressed by user [static]
00608 //=================================================================================
00609 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
00610 {
00611   if ( !application() )
00612     return;
00613   foreach ( GEOMGUI* lib, myGUIMap )
00614     lib->OnKeyPress( e, application()->desktop(), w );
00615 }
00616 
00617 //=================================================================================
00618 // function : GeometryGUI::OnMouseMove()
00619 // purpose  : Manages mouse move events [static]
00620 //=================================================================================
00621 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
00622 {
00623   if ( !application() )
00624     return;
00625   foreach ( GEOMGUI* lib, myGUIMap )
00626     lib->OnMouseMove( e, application()->desktop(), w );
00627 }
00628 
00629 //=================================================================================
00630 // function : GeometryGUI::OnMouseRelease()
00631 // purpose  : Manages mouse release events [static]
00632 //=================================================================================
00633 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
00634 {
00635   if ( !application() )
00636     return;
00637   foreach ( GEOMGUI* lib, myGUIMap )
00638     lib->OnMouseRelease( e, application()->desktop(), w );
00639 }
00640 
00641 //=================================================================================
00642 // function : GeometryGUI::OnMousePress()
00643 // purpose  : Manage mouse press events [static]
00644 //=================================================================================
00645 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
00646 {
00647   if ( !application() )
00648     return;
00649   foreach ( GEOMGUI* lib, myGUIMap )
00650     lib->OnMousePress( e, application()->desktop(), w );
00651 }
00652 
00653 //=======================================================================
00654 // function : createGeomAction
00655 // purpose  :
00656 //=======================================================================
00657 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
00658                                     const int accel, const bool toggle, const QString& shortcutAction )
00659 {
00660   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
00661   QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
00662                                     : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
00663   createAction( id,
00664                 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
00665                 icon,
00666                 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
00667                 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
00668                 accel,
00669                 application()->desktop(),
00670                 toggle,
00671                 this, SLOT( OnGUIEvent() ),
00672                 shortcutAction );
00673 }
00674 
00675 //=======================================================================
00676 // function : createOriginAndBaseVectors
00677 // purpose  :
00678 //=======================================================================
00679 void GeometryGUI::createOriginAndBaseVectors()
00680 {
00681   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
00682   if( appStudy ) {
00683     _PTR(Study) studyDS = appStudy->studyDS();
00684     if( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
00685       GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
00686       if( !aBasicOperations->_is_nil() ) {
00687         SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
00688         double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
00689         GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
00690         GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
00691         GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
00692         GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
00693 
00694         SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
00695         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
00696         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
00697         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
00698         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
00699 
00700         getApp()->updateObjectBrowser( false );
00701       }
00702     }
00703   }
00704 }
00705 
00706 //=======================================================================
00707 // function : GeometryGUI::initialize()
00708 // purpose  : Called when GEOM module is created
00709 //=======================================================================
00710 void GeometryGUI::initialize( CAM_Application* app )
00711 {
00712   SalomeApp_Module::initialize( app );
00713 
00714   // ----- create actions --------------
00715 
00716   createGeomAction( GEOMOp::OpImport,     "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
00717   createGeomAction( GEOMOp::OpExport,     "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
00718 
00719   createGeomAction( GEOMOp::OpDelete,     "DELETE", "", Qt::Key_Delete );
00720 
00721   createGeomAction( GEOMOp::OpPoint,      "POINT" );
00722   createGeomAction( GEOMOp::OpLine,       "LINE" );
00723   createGeomAction( GEOMOp::OpCircle,     "CIRCLE" );
00724   createGeomAction( GEOMOp::OpEllipse,    "ELLIPSE" );
00725   createGeomAction( GEOMOp::OpArc,        "ARC" );
00726   createGeomAction( GEOMOp::OpCurve,      "CURVE" );
00727   createGeomAction( GEOMOp::OpVector,     "VECTOR" );
00728   createGeomAction( GEOMOp::OpPlane,      "PLANE" );
00729   createGeomAction( GEOMOp::OpLCS,        "LOCAL_CS" );
00730   createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
00731 
00732   createGeomAction( GEOMOp::OpBox,        "BOX" );
00733   createGeomAction( GEOMOp::OpCylinder,   "CYLINDER" );
00734   createGeomAction( GEOMOp::OpSphere,     "SPHERE" );
00735   createGeomAction( GEOMOp::OpTorus,      "TORUS" );
00736   createGeomAction( GEOMOp::OpCone,       "CONE" );
00737   createGeomAction( GEOMOp::OpRectangle,  "RECTANGLE" );
00738   createGeomAction( GEOMOp::OpDisk,       "DISK" );
00739 
00740   createGeomAction( GEOMOp::OpPrism,       "EXTRUSION" );
00741   createGeomAction( GEOMOp::OpRevolution,  "REVOLUTION" );
00742   createGeomAction( GEOMOp::OpFilling,     "FILLING" );
00743   createGeomAction( GEOMOp::OpPipe,        "PIPE" );
00744 
00745   createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
00746   createGeomAction( GEOMOp::OpGroupEdit,   "GROUP_EDIT" );
00747 
00748   createGeomAction( GEOMOp::OpReimport,    "RELOAD_IMPORTED" );
00749 
00750   createGeomAction( GEOMOp::OpQuadFace,    "Q_FACE" );
00751   createGeomAction( GEOMOp::OpHexaSolid,   "HEX_SOLID" );
00752 
00753   createGeomAction( GEOMOp::Op2dSketcher,  "SKETCH" );
00754   createGeomAction( GEOMOp::Op3dSketcher,  "3DSKETCH" );
00755   createGeomAction( GEOMOp::OpExplode,     "EXPLODE" );
00756 #ifdef WITH_OPENCV
00757   createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
00758 #endif
00759   createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
00760 
00761   createGeomAction( GEOMOp::OpEdge,        "EDGE" );
00762   createGeomAction( GEOMOp::OpWire,        "WIRE" );
00763   createGeomAction( GEOMOp::OpFace,        "FACE" );
00764   createGeomAction( GEOMOp::OpShell,       "SHELL" );
00765   createGeomAction( GEOMOp::OpSolid,       "SOLID" );
00766   createGeomAction( GEOMOp::OpCompound,    "COMPOUND" );
00767 
00768   createGeomAction( GEOMOp::OpFuse,        "FUSE" );
00769   createGeomAction( GEOMOp::OpCommon,      "COMMON" );
00770   createGeomAction( GEOMOp::OpCut,         "CUT" );
00771   createGeomAction( GEOMOp::OpSection,     "SECTION" );
00772 
00773   createGeomAction( GEOMOp::OpTranslate,      "TRANSLATION" );
00774   createGeomAction( GEOMOp::OpRotate,         "ROTATION" );
00775   createGeomAction( GEOMOp::OpChangeLoc,      "MODIFY_LOCATION" );
00776   createGeomAction( GEOMOp::OpMirror,         "MIRROR" );
00777   createGeomAction( GEOMOp::OpScale,          "SCALE" );
00778   createGeomAction( GEOMOp::OpOffset,         "OFFSET" );
00779   createGeomAction( GEOMOp::OpProjection,     "PROJECTION" );
00780   createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
00781   createGeomAction( GEOMOp::OpMultiRotate,    "MUL_ROTATION" );
00782 
00783   createGeomAction( GEOMOp::OpPartition,      "PARTITION" );
00784   createGeomAction( GEOMOp::OpArchimede,      "ARCHIMEDE" );
00785   createGeomAction( GEOMOp::OpFillet3d,       "FILLET" );
00786   createGeomAction( GEOMOp::OpChamfer,        "CHAMFER" );
00787   //createGeomAction( GEOMOp::OpClipping,        "CLIPPING" );
00788   createGeomAction( GEOMOp::OpShapesOnShape,  "GET_SHAPES_ON_SHAPE" );
00789   createGeomAction( GEOMOp::OpSharedShapes,   "GET_SHARED_SHAPES" );
00790   createGeomAction( GEOMOp::OpExtrudedCut,    "EXTRUDED_CUT" );
00791   createGeomAction( GEOMOp::OpExtrudedBoss,   "EXTRUDED_BOSS" );
00792   createGeomAction( GEOMOp::OpFillet1d,       "FILLET_1D" );
00793   createGeomAction( GEOMOp::OpFillet2d,       "FILLET_2D" );
00794 
00795   createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
00796   createGeomAction( GEOMOp::OpExplodeBlock,   "EXPLODE_BLOCKS" );
00797   createGeomAction( GEOMOp::OpPropagate,      "PROPAGATE" );
00798 
00799   createGeomAction( GEOMOp::OpSewing,           "SEWING" );
00800   createGeomAction( GEOMOp::OpGlueFaces,        "GLUE_FACES" );
00801   createGeomAction( GEOMOp::OpGlueEdges,        "GLUE_EDGES" );
00802   createGeomAction( GEOMOp::OpLimitTolerance,   "LIMIT_TOLERANCE" );
00803   createGeomAction( GEOMOp::OpSuppressFaces,    "SUPPRESS_FACES" );
00804   createGeomAction( GEOMOp::OpSuppressHoles,    "SUPPERSS_HOLES" );
00805   createGeomAction( GEOMOp::OpShapeProcess,     "SHAPE_PROCESS" );
00806   createGeomAction( GEOMOp::OpCloseContour,     "CLOSE_CONTOUR" );
00807   createGeomAction( GEOMOp::OpRemoveIntWires,   "SUPPRESS_INT_WIRES" );
00808   createGeomAction( GEOMOp::OpAddPointOnEdge,   "POINT_ON_EDGE" );
00809   createGeomAction( GEOMOp::OpFreeBoundaries,   "CHECK_FREE_BNDS" );
00810   createGeomAction( GEOMOp::OpFreeFaces,        "CHECK_FREE_FACES" );
00811   createGeomAction( GEOMOp::OpOrientation,      "CHANGE_ORIENTATION" );
00812   createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
00813 
00814   createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
00815   createGeomAction( GEOMOp::OpProperties,       "BASIC_PROPS" );
00816   createGeomAction( GEOMOp::OpCenterMass,       "MASS_CENTER" );
00817   createGeomAction( GEOMOp::OpInertia,          "INERTIA" );
00818   createGeomAction( GEOMOp::OpNormale,          "NORMALE" );
00819   createGeomAction( GEOMOp::OpBoundingBox,      "BND_BOX" );
00820   createGeomAction( GEOMOp::OpMinDistance,      "MIN_DIST" );
00821   createGeomAction( GEOMOp::OpAngle,            "MEASURE_ANGLE" );
00822 
00823   createGeomAction( GEOMOp::OpTolerance,        "TOLERANCE" );
00824   createGeomAction( GEOMOp::OpWhatIs,           "WHAT_IS" );
00825   createGeomAction( GEOMOp::OpCheckShape,       "CHECK" );
00826   createGeomAction( GEOMOp::OpCheckCompound,    "CHECK_COMPOUND" );
00827   createGeomAction( GEOMOp::OpCheckSelfInters,  "CHECK_SELF_INTERSECTIONS" );
00828 
00829 #ifdef _DEBUG_ // PAL16821
00830   createGeomAction( GEOMOp::OpCheckGeom,        "CHECK_GEOMETRY" );
00831 #endif
00832 
00833   createGeomAction( GEOMOp::OpDMWireframe,        "WIREFRAME" );
00834   createGeomAction( GEOMOp::OpDMShading,          "SHADING" );
00835   createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
00836   createGeomAction( GEOMOp::OpShowAll,          "DISPLAY_ALL" );
00837   createGeomAction( GEOMOp::OpHideAll,          "ERASE_ALL" );
00838   createGeomAction( GEOMOp::OpShow,             "DISPLAY" );
00839   createGeomAction( GEOMOp::OpSwitchVectors,    "VECTOR_MODE");
00840   createGeomAction( GEOMOp::OpSelectVertex,     "VERTEX_SEL_ONLY" ,"", 0, true );
00841   createGeomAction( GEOMOp::OpSelectEdge,       "EDGE_SEL_ONLY", "", 0, true );
00842   createGeomAction( GEOMOp::OpSelectWire,       "WIRE_SEL_ONLY", "",  0, true );
00843   createGeomAction( GEOMOp::OpSelectFace,       "FACE_SEL_ONLY", "", 0, true );
00844   createGeomAction( GEOMOp::OpSelectShell,      "SHELL_SEL_ONLY", "",  0, true );
00845   createGeomAction( GEOMOp::OpSelectSolid,      "SOLID_SEL_ONLY", "", 0, true );
00846   createGeomAction( GEOMOp::OpSelectCompound,   "COMPOUND_SEL_ONLY", "",  0, true );
00847   createGeomAction( GEOMOp::OpSelectAll,        "ALL_SEL_ONLY", "",  0, true );
00848   createGeomAction( GEOMOp::OpShowOnly,         "DISPLAY_ONLY" );
00849   createGeomAction( GEOMOp::OpBringToFront,     "BRING_TO_FRONT", "", 0, true );
00850   createGeomAction( GEOMOp::OpClsBringToFront,  "CLS_BRING_TO_FRONT" );
00851   createGeomAction( GEOMOp::OpHide,             "ERASE" );
00852 
00853   createGeomAction( GEOMOp::OpWireframe,        "POP_WIREFRAME", "", 0, true );
00854   createGeomAction( GEOMOp::OpShading,          "POP_SHADING", "", 0, true );
00855   createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
00856   createGeomAction( GEOMOp::OpTexture,          "POP_TEXTURE", "", 0, true );
00857   createGeomAction( GEOMOp::OpEdgeWidth,        "EDGE_WIDTH");
00858   createGeomAction( GEOMOp::OpIsosWidth,        "ISOS_WIDTH");
00859   createGeomAction( GEOMOp::OpVectors,          "POP_VECTORS", "", 0, true );
00860   createGeomAction( GEOMOp::OpDeflection,       "POP_DEFLECTION" );
00861   createGeomAction( GEOMOp::OpColor,            "POP_COLOR" );
00862   createGeomAction( GEOMOp::OpSetTexture,       "POP_SETTEXTURE" );
00863   createGeomAction( GEOMOp::OpTransparency,     "POP_TRANSPARENCY" );
00864   createGeomAction( GEOMOp::OpIsos,             "POP_ISOS" );
00865   createGeomAction( GEOMOp::OpAutoColor,        "POP_AUTO_COLOR" );
00866   createGeomAction( GEOMOp::OpNoAutoColor,      "POP_DISABLE_AUTO_COLOR" );
00867   createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
00868   createGeomAction( GEOMOp::OpShowChildren,     "POP_SHOW_CHILDREN" );
00869   createGeomAction( GEOMOp::OpHideChildren,     "POP_HIDE_CHILDREN" );
00870   createGeomAction( GEOMOp::OpUnpublishObject,  "POP_UNPUBLISH_OBJ" );
00871   createGeomAction( GEOMOp::OpPublishObject,    "POP_PUBLISH_OBJ" );
00872   createGeomAction( GEOMOp::OpPointMarker,      "POP_POINT_MARKER" );
00873   createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
00874 
00875   createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
00876 
00877   // Create actions for increase/decrease transparency shortcuts
00878   createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
00879                     "Geometry:Increase transparency");
00880   createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
00881                     "Geometry:Decrease transparency");
00882 
00883   // Create actions for increase/decrease number of isolines
00884   createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
00885                     "Geometry:Increase number of isolines");
00886   createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
00887                     "Geometry:Decrease number of isolines");
00888 
00889 //   createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
00890   //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
00891 
00892   // ---- create menus --------------------------
00893 
00894   int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
00895   createMenu( separator(),      fileId, 10 );
00896   createMenu( GEOMOp::OpImport, fileId, 10 );
00897   createMenu( GEOMOp::OpExport, fileId, 10 );
00898   createMenu( separator(),      fileId, -1 );
00899 
00900   int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
00901   createMenu( GEOMOp::OpDelete, editId, -1 );
00902 
00903   int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
00904 
00905   int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
00906   createMenu( GEOMOp::OpPoint,   basicId, -1 );
00907   createMenu( GEOMOp::OpLine,    basicId, -1 );
00908   createMenu( GEOMOp::OpCircle,  basicId, -1 );
00909   createMenu( GEOMOp::OpEllipse, basicId, -1 );
00910   createMenu( GEOMOp::OpArc,     basicId, -1 );
00911   createMenu( GEOMOp::OpCurve,   basicId, -1 );
00912   createMenu( separator(),       basicId, -1 );
00913   createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
00914   createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
00915   createMenu( GEOMOp::OpVector,  basicId, -1 );
00916   createMenu( GEOMOp::OpPlane,   basicId, -1 );
00917   createMenu( GEOMOp::OpLCS,     basicId, -1 );
00918   createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
00919 
00920   int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
00921   createMenu( GEOMOp::OpBox,       primId, -1 );
00922   createMenu( GEOMOp::OpCylinder,  primId, -1 );
00923   createMenu( GEOMOp::OpSphere,    primId, -1 );
00924   createMenu( GEOMOp::OpTorus,     primId, -1 );
00925   createMenu( GEOMOp::OpCone,      primId, -1 );
00926   createMenu( GEOMOp::OpRectangle, primId, -1 );
00927   createMenu( GEOMOp::OpDisk,      primId, -1 );
00928   createMenu( GEOMOp::OpPipeTShape,primId, -1 );
00929 
00930   int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
00931   createMenu( GEOMOp::OpPrism,      genId, -1 );
00932   createMenu( GEOMOp::OpRevolution, genId, -1 );
00933   createMenu( GEOMOp::OpFilling,    genId, -1 );
00934   createMenu( GEOMOp::OpPipe,       genId, -1 );
00935 
00936 //   int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
00937 //   createMenu( GEOMOp::OpPipeTShape, advId, -1 );
00938 //   createMenu( GEOMOp::OpPipeTShapeGroups, advId, -1 );
00939   //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
00940 
00941   createMenu( separator(), newEntId, -1 );
00942 
00943   int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
00944   createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
00945   createMenu( GEOMOp::OpGroupEdit,   groupId, -1 );
00946 
00947   createMenu( separator(), newEntId, -1 );
00948 
00949   int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
00950   createMenu( GEOMOp::OpQuadFace,  blocksId, -1 );
00951   createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
00952 
00953   createMenu( separator(),          newEntId, -1 );
00954 
00955   createMenu( GEOMOp::OpExplode,    newEntId, -1 );
00956 
00957   int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
00958   createMenu( GEOMOp::OpEdge,     buildId, -1 );
00959   createMenu( GEOMOp::OpWire,     buildId, -1 );
00960   createMenu( GEOMOp::OpFace,     buildId, -1 );
00961   createMenu( GEOMOp::OpShell,    buildId, -1 );
00962   createMenu( GEOMOp::OpSolid,    buildId, -1 );
00963   createMenu( GEOMOp::OpCompound, buildId, -1 );
00964   
00965   createMenu( separator(),          newEntId, -1 );
00966   
00967   createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
00968 #ifdef WITH_OPENCV
00969   createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
00970 #endif
00971 
00972   int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
00973 
00974   int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
00975   createMenu( GEOMOp::OpFuse,    boolId, -1 );
00976   createMenu( GEOMOp::OpCommon,  boolId, -1 );
00977   createMenu( GEOMOp::OpCut,     boolId, -1 );
00978   createMenu( GEOMOp::OpSection, boolId, -1 );
00979 
00980   int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
00981   createMenu( GEOMOp::OpTranslate,      transId, -1 );
00982   createMenu( GEOMOp::OpRotate,         transId, -1 );
00983   createMenu( GEOMOp::OpChangeLoc,      transId, -1 );
00984   createMenu( GEOMOp::OpMirror,         transId, -1 );
00985   createMenu( GEOMOp::OpScale,          transId, -1 );
00986   createMenu( GEOMOp::OpOffset,         transId, -1 );
00987   createMenu( GEOMOp::OpProjection,     transId, -1 );
00988   createMenu( separator(),              transId, -1 );
00989   createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
00990   createMenu( GEOMOp::OpMultiRotate,    transId, -1 );
00991 
00992   int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
00993   createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
00994   createMenu( GEOMOp::OpExplodeBlock,   blockId, -1 );
00995   createMenu( GEOMOp::OpPropagate,      blockId, -1 );
00996 
00997   createMenu( separator(), operId, -1 );
00998 
00999   createMenu( GEOMOp::OpPartition,     operId, -1 );
01000   createMenu( GEOMOp::OpArchimede,     operId, -1 );
01001   createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
01002   createMenu( GEOMOp::OpSharedShapes,  operId, -1 );
01003 
01004   createMenu( separator(), operId, -1 );
01005 
01006   createMenu( GEOMOp::OpFillet1d,      operId, -1 );
01007   createMenu( GEOMOp::OpFillet2d,      operId, -1 );
01008   createMenu( GEOMOp::OpFillet3d,      operId, -1 );
01009   createMenu( GEOMOp::OpChamfer,       operId, -1 );
01010   createMenu( GEOMOp::OpExtrudedBoss,  operId, -1 );
01011   createMenu( GEOMOp::OpExtrudedCut,   operId, -1 );
01012   //createMenu( GEOMOp::OpClipping,      operId, -1 );
01013 
01014   int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
01015   createMenu( GEOMOp::OpShapeProcess,    repairId, -1 );
01016   createMenu( GEOMOp::OpSuppressFaces,   repairId, -1 );
01017   createMenu( GEOMOp::OpCloseContour,    repairId, -1 );
01018   createMenu( GEOMOp::OpRemoveIntWires,  repairId, -1 );
01019   createMenu( GEOMOp::OpSuppressHoles,   repairId, -1 );
01020   createMenu( GEOMOp::OpSewing,          repairId, -1 );
01021   createMenu( GEOMOp::OpGlueFaces,       repairId, -1 );
01022   createMenu( GEOMOp::OpGlueEdges,       repairId, -1 );
01023   createMenu( GEOMOp::OpLimitTolerance,  repairId, -1 );
01024   createMenu( GEOMOp::OpAddPointOnEdge,  repairId, -1 );
01025   //createMenu( GEOMOp::OpFreeBoundaries,  repairId, -1 );
01026   //createMenu( GEOMOp::OpFreeFaces,       repairId, -1 );
01027   createMenu( GEOMOp::OpOrientation,      repairId, -1 );
01028   createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
01029 
01030   int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
01031   createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
01032   createMenu( GEOMOp::OpProperties,       measurId, -1 );
01033   createMenu( separator(),                measurId, -1 );
01034   createMenu( GEOMOp::OpCenterMass,       measurId, -1 );
01035   createMenu( GEOMOp::OpInertia,          measurId, -1 );
01036   createMenu( GEOMOp::OpNormale,          measurId, -1 );
01037   createMenu( separator(),                measurId, -1 );
01038   createMenu( GEOMOp::OpFreeBoundaries,   measurId, -1 );
01039   createMenu( GEOMOp::OpFreeFaces,        measurId, -1 );
01040   createMenu( separator(),                measurId, -1 );
01041 
01042   int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
01043   createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
01044   createMenu( GEOMOp::OpMinDistance, dimId, -1 );
01045   createMenu( GEOMOp::OpAngle,       dimId, -1 );
01046 
01047   createMenu( separator(),               measurId, -1 );
01048   createMenu( GEOMOp::OpTolerance,       measurId, -1 );
01049   createMenu( separator(),               measurId, -1 );
01050   createMenu( GEOMOp::OpWhatIs,          measurId, -1 );
01051   createMenu( GEOMOp::OpCheckShape,      measurId, -1 );
01052   createMenu( GEOMOp::OpCheckCompound,   measurId, -1 );
01053   createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
01054 
01055 #ifdef _DEBUG_ // PAL16821
01056   int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
01057   createMenu( separator(),         toolsId, -1 );
01058   createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
01059 #endif
01060 
01061   int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
01062   createMenu( separator(),       viewId, -1 );
01063 
01064   int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
01065   createMenu( GEOMOp::OpDMWireframe,        dispmodeId, -1 );
01066   createMenu( GEOMOp::OpDMShading,          dispmodeId, -1 );
01067   createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
01068   createMenu( separator(),                  dispmodeId, -1 );
01069   createMenu( GEOMOp::OpSwitchVectors,      dispmodeId, -1 );
01070 
01071   createMenu( separator(),       viewId, -1 );
01072   createMenu( GEOMOp::OpShowAll, viewId, -1 );
01073   createMenu( GEOMOp::OpHideAll, viewId, -1 );
01074   createMenu( separator(),       viewId, -1 );
01075   createMenu( GEOMOp::OpPublishObject, viewId, -1 );
01076   createMenu( separator(),       viewId, -1 );
01077 
01078 /*
01079   PAL9111:
01080   because of these items are accessible through object browser and viewers
01081   we have removed they from main menu
01082 
01083   createMenu( GEOMOp::OpShow, viewId, -1 );
01084   createMenu( GEOMOp::OpShowOnly, viewId, -1 );
01085   createMenu( GEOMOp::OpHide, viewId, -1 );
01086 */
01087 
01088   // ---- create toolbars --------------------------
01089   
01090   int basicTbId = createTool( tr( "TOOL_BASIC" ) );
01091   createTool( GEOMOp::OpPoint,      basicTbId );
01092   createTool( GEOMOp::OpLine,       basicTbId );
01093   createTool( GEOMOp::OpCircle,     basicTbId );
01094   createTool( GEOMOp::OpEllipse,    basicTbId );
01095   createTool( GEOMOp::OpArc,        basicTbId );
01096   createTool( GEOMOp::OpCurve,      basicTbId );
01097   createTool( GEOMOp::OpVector,     basicTbId );
01098   createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
01099   createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
01100   createTool( GEOMOp::OpPlane,      basicTbId );
01101   createTool( GEOMOp::OpLCS,        basicTbId );
01102   createTool( GEOMOp::OpOriginAndVectors, basicTbId );
01103   
01104 //   int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
01105 //   createTool( GEOMOp::Op2dSketcher,  sketchTbId );
01106 //   createTool( GEOMOp::Op3dSketcher,  sketchTbId );
01107   
01108   int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
01109   createTool( GEOMOp::OpBox,        primTbId );
01110   createTool( GEOMOp::OpCylinder,   primTbId );
01111   createTool( GEOMOp::OpSphere,     primTbId );
01112   createTool( GEOMOp::OpTorus,      primTbId );
01113   createTool( GEOMOp::OpCone,       primTbId );
01114   createTool( GEOMOp::OpRectangle,  primTbId );
01115   createTool( GEOMOp::OpDisk,       primTbId );
01116   createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
01117   
01118 //   int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc
01119 //   createTool( GEOMOp::OpPipeTShape, advancedTbId );
01120   
01121   int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
01122   createTool( GEOMOp::OpFuse,       boolTbId );
01123   createTool( GEOMOp::OpCommon,     boolTbId );
01124   createTool( GEOMOp::OpCut,        boolTbId );
01125   createTool( GEOMOp::OpSection,    boolTbId );
01126   
01127    int genTbId = createTool( tr( "TOOL_GENERATION" ) );
01128   createTool( GEOMOp::OpPrism,      genTbId );
01129   createTool( GEOMOp::OpRevolution, genTbId );
01130   createTool( GEOMOp::OpFilling,    genTbId );
01131   createTool( GEOMOp::OpPipe,       genTbId );
01132   
01133   int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
01134   createTool( GEOMOp::OpTranslate,      transTbId );
01135   createTool( GEOMOp::OpRotate,         transTbId );
01136   createTool( GEOMOp::OpChangeLoc,      transTbId );
01137   createTool( GEOMOp::OpMirror,         transTbId );
01138   createTool( GEOMOp::OpScale,          transTbId );
01139   createTool( GEOMOp::OpOffset,         transTbId );
01140   createTool( GEOMOp::OpProjection,     transTbId );
01141   createTool( separator(),              transTbId );
01142   createTool( GEOMOp::OpMultiTranslate, transTbId );
01143   createTool( GEOMOp::OpMultiRotate,    transTbId );
01144   
01145   int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
01146   createTool( GEOMOp::OpExplode,         operTbId );
01147   createTool( GEOMOp::OpPartition,       operTbId );
01148   createTool( GEOMOp::OpArchimede,       operTbId );
01149   createTool( GEOMOp::OpShapesOnShape,   operTbId );
01150   createTool( GEOMOp::OpSharedShapes,    operTbId );
01151   
01152   int featTbId = createTool( tr( "TOOL_FEATURES" ) );
01153   createTool( GEOMOp::OpFillet1d,        featTbId );
01154   createTool( GEOMOp::OpFillet2d,        featTbId );
01155   createTool( GEOMOp::OpFillet3d,        featTbId );
01156   createTool( GEOMOp::OpChamfer,         featTbId );
01157   createTool( GEOMOp::OpExtrudedBoss,    featTbId );
01158   createTool( GEOMOp::OpExtrudedCut,     featTbId );
01159   
01160   int buildTbId = createTool( tr( "TOOL_BUILD" ) );
01161   createTool( GEOMOp::OpEdge,     buildTbId );
01162   createTool( GEOMOp::OpWire,     buildTbId );
01163   createTool( GEOMOp::OpFace,     buildTbId );
01164   createTool( GEOMOp::OpShell,    buildTbId );
01165   createTool( GEOMOp::OpSolid,    buildTbId );
01166   createTool( GEOMOp::OpCompound, buildTbId );
01167 
01168   int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
01169   createTool( GEOMOp::OpPointCoordinates, measureTbId );
01170   createTool( GEOMOp::OpProperties,       measureTbId );
01171   createTool( GEOMOp::OpCenterMass,       measureTbId );
01172   createTool( GEOMOp::OpInertia,          measureTbId );
01173   createTool( GEOMOp::OpNormale,          measureTbId );
01174   createTool( separator(),                measureTbId );
01175   createTool( GEOMOp::OpBoundingBox,      measureTbId );
01176   createTool( GEOMOp::OpMinDistance,      measureTbId );
01177   createTool( GEOMOp::OpAngle,            measureTbId );
01178   createTool( GEOMOp::OpTolerance  ,      measureTbId );
01179   createTool( separator(),                measureTbId );
01180   createTool( GEOMOp::OpFreeBoundaries,   measureTbId );
01181   createTool( GEOMOp::OpFreeFaces,        measureTbId );
01182   createTool( separator(),                measureTbId );
01183   createTool( GEOMOp::OpWhatIs,           measureTbId );
01184   createTool( GEOMOp::OpCheckShape,       measureTbId );
01185   createTool( GEOMOp::OpCheckCompound,    measureTbId );
01186   createTool( GEOMOp::OpCheckSelfInters,  measureTbId );
01187   
01188   int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
01189   createTool( GEOMOp::OpPictureImport,    picturesTbId );
01190   #ifdef WITH_OPENCV
01191     createTool( GEOMOp::OpFeatureDetect,  picturesTbId );
01192   #endif
01193 
01194   //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
01195 
01196   // ---- create popup menus --------------------------
01197 
01198   QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
01199   QString clientOCC = "(client='OCCViewer')";
01200   QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
01201   QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
01202 
01203   QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
01204   QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
01205   QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
01206   QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
01207 
01208   QString autoColorPrefix =
01209     "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
01210 
01211   QtxPopupMgr* mgr = popupMgr();
01212 
01213   mgr->insert( action(  GEOMOp::OpDelete ), -1, -1 );  // delete
01214   mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
01215   mgr->insert( action(  GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
01216   mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
01217   mgr->insert( action(  GEOMOp::OpShowChildren ), -1, -1 ); // show children
01218   mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
01219 
01220   mgr->insert( action(  GEOMOp::OpHideChildren ), -1, -1 ); // hide children
01221   mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
01222   mgr->insert( action(  GEOMOp::OpGroupEdit ), -1, -1 );  // edit group
01223   mgr->setRule( action( GEOMOp::OpGroupEdit ),  QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
01224   mgr->insert( separator(), -1, -1 );     // -----------
01225 
01226 #if OCC_VERSION_LARGE > 0x06050200
01227   //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
01228   QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true";
01229   mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
01230   mgr->setRule(action(GEOMOp::OpBringToFront), bringRule, QtxPopupMgr::VisibleRule );
01231   mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
01232   mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
01233   mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule );  
01234 #endif
01235   mgr->insert( separator(), -1, -1 );     // -----------
01236   dispmodeId = mgr->insert(  tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
01237   mgr->insert( action(  GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
01238   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
01239   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
01240   mgr->insert( action(  GEOMOp::OpShading ), dispmodeId, -1 ); // shading
01241   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
01242   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
01243   mgr->insert( action(  GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
01244   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
01245   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
01246   mgr->insert( action(  GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
01247   mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
01248   mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
01249   mgr->insert( separator(), dispmodeId, -1 );
01250   mgr->insert( action(  GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
01251   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
01252   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
01253   mgr->insert( separator(), -1, -1 );     // -----------
01254   mgr->insert( action(  GEOMOp::OpColor ), -1, -1 ); // color
01255   mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
01256   mgr->insert( action(  GEOMOp::OpTransparency ), -1, -1 ); // transparency
01257   mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
01258   mgr->insert( action(  GEOMOp::OpIsos ), -1, -1 ); // isos
01259   mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
01260   mgr->insert( action(  GEOMOp::OpDeflection ), -1, -1 ); // deflection
01261   mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
01262   mgr->insert( action(  GEOMOp::OpPointMarker ), -1, -1 ); // point marker
01263   //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
01264   mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
01265   mgr->insert( action(  GEOMOp::OpMaterialProperties ), -1, -1 ); // material properties  
01266   mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
01267   mgr->insert( action(  GEOMOp::OpSetTexture ), -1, -1 ); // texture
01268   mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
01269 
01270   int lineW = mgr->insert(  tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
01271   mgr->insert( action(  GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
01272   mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
01273 
01274   mgr->insert( action(  GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
01275   mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
01276   
01277   mgr->insert( separator(), -1, -1 );     // -----------
01278   mgr->insert( action(  GEOMOp::OpAutoColor ), -1, -1 ); // auto color
01279   mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
01280   mgr->insert( action(  GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
01281   mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
01282   mgr->insert( separator(), -1, -1 );     // -----------
01283 
01284   QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
01285           onlyComponent = "((type='Component') and selcount=1)",
01286           rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
01287           types = "'Shape' 'Group'";
01288 
01289   mgr->insert( action(  GEOMOp::OpShow ), -1, -1 ); // display
01290   mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
01291 
01292   mgr->insert( action(  GEOMOp::OpHide ), -1, -1 ); // erase
01293   mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
01294 
01295   mgr->insert( action(  GEOMOp::OpHideAll ), -1, -1 ); // erase All
01296   mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
01297 
01298   QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
01299 
01300   int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1);                //select only menu
01301   mgr->insert( action(GEOMOp::OpSelectVertex),   selectonlyId, -1);                                  //Vertex
01302   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly, QtxPopupMgr::VisibleRule);
01303   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
01304   mgr->insert( action(GEOMOp::OpSelectEdge),     selectonlyId, -1);                                  //Edge
01305   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly, QtxPopupMgr::VisibleRule);
01306   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
01307   mgr->insert( action(GEOMOp::OpSelectWire),     selectonlyId, -1);                                  //Wire
01308   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly, QtxPopupMgr::VisibleRule);
01309   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
01310   mgr->insert( action(GEOMOp::OpSelectFace),     selectonlyId, -1);                                  //Face
01311   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly, QtxPopupMgr::VisibleRule);
01312   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
01313   mgr->insert( action(GEOMOp::OpSelectShell),    selectonlyId, -1);                                  //Shell
01314   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly, QtxPopupMgr::VisibleRule);
01315   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
01316   mgr->insert( action(GEOMOp::OpSelectSolid),    selectonlyId, -1);                                  //Solid
01317   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly, QtxPopupMgr::VisibleRule);
01318   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
01319   mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1);                                  //Compound
01320   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
01321   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
01322   mgr->insert( separator(), selectonlyId, -1);
01323   mgr->insert( action(GEOMOp::OpSelectAll),      selectonlyId, -1);                                  //Clear selection filter
01324   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly, QtxPopupMgr::VisibleRule);
01325   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
01326   mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
01327   mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
01328 
01329   mgr->insert( separator(), -1, -1 );     // -----------
01330   mgr->insert( action(  GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
01331   mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
01332 
01333 
01334   mgr->insert( action(  GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
01335   mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
01336 
01337   mgr->insert( action(  GEOMOp::OpReimport ), -1, -1 );  // delete
01338   mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
01339 
01340   mgr->hide( mgr->actionId( action( myEraseAll ) ) );
01341 }
01342 
01343 //=======================================================================
01344 // function : GeometryGUI::activateModule()
01345 // purpose  : Called when GEOM module is activated
01346 //=======================================================================
01347 bool GeometryGUI::activateModule( SUIT_Study* study )
01348 {
01349   if ( CORBA::is_nil( myComponentGeom ) )
01350     return false;
01351 
01352   bool res = SalomeApp_Module::activateModule( study );
01353 
01354   if ( !res )
01355     return false;
01356   setMenuShown( true );
01357   setToolShown( true );
01358 
01359   // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
01360   PyGILState_STATE gstate = PyGILState_Ensure();
01361   PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
01362   if(pluginsmanager==NULL)
01363     PyErr_Print();
01364   else
01365     {
01366       PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"geom",tr("MEN_NEW_ENTITY").toStdString().c_str(),tr("GEOM_PLUGINS_OTHER").toStdString().c_str());
01367       if(result==NULL)
01368         PyErr_Print();
01369       Py_XDECREF(result);
01370     }
01371   PyGILState_Release(gstate);
01372   // end of GEOM plugins loading
01373 
01374   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
01375           this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
01376 
01377   // Reset actions accelerator keys
01378   action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
01379   action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
01380   action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
01381 
01382   GUIMap::Iterator it;
01383   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
01384     it.value()->activate( application()->desktop() );
01385 
01386   LightApp_SelectionMgr* sm = getApp()->selectionMgr();
01387 
01388   SUIT_ViewManager* vm;
01389   ViewManagerList OCCViewManagers, VTKViewManagers;
01390 
01391   application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
01392   QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
01393   while ( itOCC.hasNext() && (vm = itOCC.next()) )
01394     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
01395 
01396   application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
01397   QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
01398   while ( itVTK.hasNext() && (vm = itVTK.next()) )
01399     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
01400 
01401   //NPAL 19674
01402   SALOME_ListIO selected;
01403   sm->selectedObjects( selected );
01404   sm->clearSelected();
01405 
01406   // disable OCC selectors
01407   getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
01408   QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
01409   while ( itOCCSel.hasNext() )
01410     if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
01411       sr->setEnabled(true);
01412 
01413   // disable VTK selectors
01414   getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
01415   QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
01416   while ( itVTKSel.hasNext() )
01417     if ( LightApp_VTKSelector* sr = itVTKSel.next() )
01418       sr->setEnabled(true);
01419 
01420   sm->setSelectedObjects( selected, true );   //NPAL 19674
01421 
01422   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
01423   if ( viewMenu )
01424     connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
01425 
01426   // 0020836 (Basic vectors and origin)
01427   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
01428   if( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
01429     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
01430     if( appStudy ) {
01431       _PTR(Study) studyDS = appStudy->studyDS();
01432       if( studyDS ) {
01433         _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
01434         if( !aSComponent ) // create objects automatically only if there is no GEOM component
01435           createOriginAndBaseVectors();
01436       }
01437     }
01438   }
01439 
01440   return true;
01441 }
01442 
01443 
01444 //=======================================================================
01445 // function : GeometryGUI::deactivateModule()
01446 // purpose  : Called when GEOM module is deactivated
01447 //=======================================================================
01448 bool GeometryGUI::deactivateModule( SUIT_Study* study )
01449 {
01450   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
01451   if ( viewMenu )
01452     disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
01453 
01454   setMenuShown( false );
01455   setToolShown( false );
01456 
01457   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
01458              this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
01459 
01460   EmitSignalCloseAllDialogs();
01461 
01462   GUIMap::Iterator it;
01463   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
01464     it.value()->deactivate();
01465 
01466   // Unset actions accelerator keys
01467   action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
01468   action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
01469   action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
01470 
01471   qDeleteAll(myOCCSelectors);
01472   myOCCSelectors.clear();
01473   getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
01474 
01475   qDeleteAll(myVTKSelectors);
01476   myVTKSelectors.clear();
01477   getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
01478 
01479   return SalomeApp_Module::deactivateModule( study );
01480 }
01481 
01482 //=======================================================================
01483 // function : onWindowActivated()
01484 // purpose  : update menu items' status - disable non-OCC-viewer-compatible actions
01485 //=======================================================================
01486 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
01487 {
01488   if ( !win )
01489     return;
01490 
01491   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
01492   //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
01493 
01494   // disable non-OCC viewframe menu commands
01495 //  action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
01496   action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
01497   action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
01498   action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
01499   action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
01500   action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
01501 //  action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
01502 
01503   action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
01504   action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
01505 
01506   action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
01507 }
01508 
01509 void GeometryGUI::windows( QMap<int, int>& mappa ) const
01510 {
01511   mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
01512   mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
01513 }
01514 
01515 void GeometryGUI::viewManagers( QStringList& lst ) const
01516 {
01517   lst.append( OCCViewer_Viewer::Type() );
01518 }
01519 
01520 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
01521 {
01522   if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
01523   {
01524     qDebug( "connect" );
01525     connect( vm, SIGNAL( keyPress  ( SUIT_ViewWindow*, QKeyEvent* ) ),
01526              this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
01527     connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
01528              this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
01529     connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
01530              this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
01531     connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
01532              this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
01533     
01534     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
01535     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
01536 
01537     // disable OCC selectors
01538     getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
01539     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
01540     while ( itOCCSel.hasNext() )
01541       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
01542         sr->setEnabled(true);
01543   }
01544   else if ( vm->getType() == SVTK_Viewer::Type() )
01545   {
01546     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
01547     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
01548 
01549     // disable VTK selectors
01550     getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
01551     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
01552     while ( itVTKSel.hasNext() )
01553       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
01554         sr->setEnabled(true);
01555   }
01556 }
01557 
01558 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
01559 {
01560   SUIT_ViewModel* viewer = vm->getViewModel();
01561   if ( vm->getType() == OCCViewer_Viewer::Type() )
01562   {
01563     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
01564     while ( itOCCSel.hasNext() )
01565       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
01566         if ( sr->viewer() == viewer )
01567         {
01568           delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
01569           break;
01570         }
01571   }
01572   if ( vm->getType() == SVTK_Viewer::Type() )
01573   {
01574     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
01575     while ( itVTKSel.hasNext() )
01576       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
01577         if ( sr->viewer() == viewer )
01578         {
01579           delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
01580           break;
01581         }
01582   }
01583 }
01584 
01585 QString GeometryGUI::engineIOR() const
01586 {
01587   if ( !CORBA::is_nil( GetGeomGen() ) )
01588     return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
01589   return "";
01590 }
01591 
01592 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
01593 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
01594 #else
01595 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture
01596 #endif
01597       (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
01598 {
01599   theWidth = theHeight = 0;
01600 
01601 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
01602   Handle(TColStd_HArray1OfByte) aTexture;
01603 #else
01604   Handle(Graphic3d_HArray1OfBytes) aTexture;
01605 #endif
01606 
01607   if (theStudy) {
01608     TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
01609     aTexture = aTextureMap[ theId ];
01610     if ( aTexture.IsNull() ) {
01611       GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
01612       if ( !aInsOp->_is_nil() ) {
01613         CORBA::Long aWidth, aHeight;
01614         SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
01615         if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
01616           theWidth  = aWidth;
01617           theHeight = aHeight;
01618 
01619 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
01620           aTexture  = new TColStd_HArray1OfByte (1, aStream->length());
01621 #else
01622           aTexture  = new Graphic3d_HArray1OfBytes (1, aStream->length());
01623 #endif
01624 
01625           for (int i = 0; i < aStream->length(); i++)
01626             aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
01627           aTextureMap[ theId ] = aTexture;
01628         }
01629       }
01630     }
01631   }
01632   return aTexture;
01633 }
01634 
01635 LightApp_Selection* GeometryGUI::createSelection() const
01636 {
01637   return new GEOMGUI_Selection();
01638 }
01639 
01640 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
01641 {
01642   SalomeApp_Module::contextMenuPopup( client, menu, title );
01643 
01644   /*
01645   SALOME_ListIO lst;
01646   getApp()->selectionMgr()->selectedObjects(lst);
01647   if (lst.Extent() < 1)
01648     return;
01649 
01650   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
01651   _PTR(Study) study = appStudy->studyDS();
01652 
01653   bool isImported = true;
01654   SALOME_ListIteratorOfListIO anIt (lst);
01655   for (; anIt.More() && isImported; anIt.Next()) {
01656     Handle(SALOME_InteractiveObject) io = anIt.Value();
01657     _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
01658     if (aSObj) {
01659       if (lst.Extent() == 1) {
01660         // Set context menu title
01661         if (client == "OCCViewer" || client == "VTKViewer")
01662           title = QString(aSObj->GetName().c_str());
01663       }
01664 
01665       CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
01666       GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
01667       if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
01668         isImported = false;
01669     } else {
01670       isImported = false;
01671     }
01672   }
01673 
01674   if (isImported) {
01675     menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
01676   }
01677   */
01678 }
01679 
01680 void GeometryGUI::createPreferences()
01681 {
01682   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
01683 
01684   int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
01685   setPreferenceProperty( genGroup, "columns", 2 );
01686 
01687   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
01688                                 LightApp_Preferences::Selector,
01689                                 "Geometry", "display_mode" );
01690 
01691   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
01692                  LightApp_Preferences::Color, "Geometry", "shading_color" );
01693 
01694   addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
01695                  LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
01696 
01697   addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
01698                  LightApp_Preferences::Color, "Geometry", "wireframe_color" );
01699 
01700   addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
01701                  LightApp_Preferences::Color, "Geometry", "free_bound_color" );
01702 
01703   addPreference( tr( "PREF_LINE_COLOR"), genGroup,
01704                  LightApp_Preferences::Color, "Geometry", "line_color" );
01705 
01706   addPreference( tr( "PREF_POINT_COLOR"), genGroup,
01707                  LightApp_Preferences::Color, "Geometry", "point_color" );
01708 
01709   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
01710                  LightApp_Preferences::Color, "Geometry", "isos_color" );
01711 
01712   addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
01713                  LightApp_Preferences::Color, "Geometry", "toplevel_color" );
01714 
01715   addPreference( "", genGroup, LightApp_Preferences::Space );
01716 
01717 
01718   int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
01719                             LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
01720 
01721   int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
01722                             LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
01723 
01724   int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
01725                                   LightApp_Preferences::Selector,
01726                                   "Geometry", "material" );
01727   
01728   const int nb = 4;
01729   int wd[nb];
01730   int iter=0;
01731 
01732   wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
01733                            LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
01734 
01735   wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
01736                            LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
01737 
01738   wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
01739                                  LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
01740   
01741   wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
01742                            LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
01743 
01744   for(int i = 0; i < nb; i++) {
01745     setPreferenceProperty( wd[i], "min", 1 );    
01746     setPreferenceProperty( wd[i], "max", 5 );
01747   }
01748 
01749 
01750   // Quantities with individual precision settings
01751   int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
01752   setPreferenceProperty( precGroup, "columns", 2 );
01753 
01754   const int nbQuantities = 8;
01755   int prec[nbQuantities], ii = 0;
01756   prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
01757                               LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
01758   prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
01759                               LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
01760   prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
01761                               LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
01762   prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
01763                               LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
01764   prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
01765                               LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
01766   prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
01767                               LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
01768   prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
01769                               LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
01770   prec[ii  ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
01771                               LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
01772 
01773   // Set property for precision value for spinboxes
01774   for ( ii = 0; ii < nbQuantities; ii++ ){
01775     setPreferenceProperty( prec[ii], "min", -14 );
01776     setPreferenceProperty( prec[ii], "max", 14 );
01777     setPreferenceProperty( prec[ii], "precision", 2 );
01778   }
01779 
01780   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
01781   setPreferenceProperty( VertexGroup, "columns", 2 );
01782 
01783   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
01784                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
01785 
01786   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
01787                                    LightApp_Preferences::Selector, "Geometry", "marker_scale" );
01788 
01789   // Set property for default display mode
01790   QStringList aModesList;
01791   aModesList.append( tr("MEN_WIREFRAME") );
01792   aModesList.append( tr("MEN_SHADING") );
01793   aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
01794 
01795   QList<QVariant> anIndexesList;
01796   anIndexesList.append(0);
01797   anIndexesList.append(1);
01798   anIndexesList.append(2);
01799 
01800   setPreferenceProperty( dispmode, "strings", aModesList );
01801   setPreferenceProperty( dispmode, "indexes", anIndexesList );
01802 
01803   // Set property for step value for spinboxes
01804   setPreferenceProperty( step, "min", 1 );
01805   setPreferenceProperty( step, "max", 10000 );
01806   setPreferenceProperty( step, "precision", 3 );
01807 
01808   // Set property for deflection value for spinboxes
01809   setPreferenceProperty( defl, "min", DEFLECTION_MIN );
01810   setPreferenceProperty( defl, "max", 1.0 );
01811   setPreferenceProperty( defl, "step", 1.0e-04 );
01812   setPreferenceProperty( defl, "precision", 6 );
01813 
01814   // Set property for default material
01815   Material_ResourceMgr aMatResMgr;
01816   setPreferenceProperty( material, "strings", aMatResMgr.materials() );
01817 
01818   // Set property vertex marker type
01819   QList<QVariant> aMarkerTypeIndicesList;
01820   QList<QVariant> aMarkerTypeIconsList;
01821 
01822   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
01823   for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
01824     QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
01825     QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
01826     aMarkerTypeIndicesList << (i-1);
01827     aMarkerTypeIconsList << pixmap;
01828   }
01829 
01830   setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
01831   setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
01832 
01833   // Set property for vertex marker scale
01834   QList<QVariant> aMarkerScaleIndicesList;
01835   QStringList     aMarkerScaleValuesList;
01836 
01837   for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
01838     aMarkerScaleIndicesList << iii;
01839     aMarkerScaleValuesList  << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
01840   }
01841 
01842   setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
01843   setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
01844 
01845   int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
01846   setPreferenceProperty( originGroup, "columns", 2 );
01847 
01848   int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
01849                                          LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
01850   setPreferenceProperty( baseVectorsLength, "min", 0.01 );
01851   setPreferenceProperty( baseVectorsLength, "max", 1000 );
01852 
01853   addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
01854                  LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
01855 
01856 
01857   int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
01858   setPreferenceProperty( operationsGroup, "columns", 2 );
01859 
01860   addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
01861                  LightApp_Preferences::Bool, "Geometry", "geom_preview" );
01862 }
01863 
01864 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
01865 {
01866   if (section == "Geometry") {
01867     SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
01868     if (param == QString("SettingsGeomStep")) {
01869       double spin_step = aResourceMgr->doubleValue(section, param, 100.);
01870       EmitSignalDefaultStepValueChanged(spin_step);
01871     }
01872   }
01873 }
01874 
01875 LightApp_Displayer* GeometryGUI::displayer()
01876 {
01877   if( !myDisplayer )
01878     myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
01879   return myDisplayer;
01880 }
01881 
01882 void GeometryGUI::setLocalSelectionMode(const int mode)
01883 {
01884   myLocalSelectionMode = mode;
01885 }
01886 int GeometryGUI::getLocalSelectionMode() const
01887 {
01888   return myLocalSelectionMode;
01889 }
01890 
01891 const char gSeparator = '_'; // character used to separate parameter names
01892 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
01893 
01900 void GeometryGUI::storeVisualParameters (int savePoint)
01901 {
01902   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
01903   if ( !appStudy || !appStudy->studyDS() )
01904     return;
01905   _PTR(Study) studyDS = appStudy->studyDS();
01906 
01907   // componentName is used for encoding of entries when storing them in IParameters
01908   std::string componentName = myComponentGeom->ComponentDataType();
01909   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
01910   //if (!aSComponent) return;
01911 
01912   // IParameters
01913   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
01914                                                              componentName.c_str(),
01915                                                              savePoint);
01916   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
01917 
01918   QList<SUIT_ViewManager*> lst;
01919   QList<SUIT_ViewManager*>::Iterator it;
01920 
01921   // main cycle to store parameters of displayed objects
01922   lst.clear();
01923   getApp()->viewManagers(lst);
01924   for (it = lst.begin(); it != lst.end(); it++) {
01925     SUIT_ViewManager* vman = *it;
01926     QString vType = vman->getType();
01927     int aMgrId = vman->getGlobalId();
01928     // saving VTK actors properties
01929     QVector<SUIT_ViewWindow*> views = vman->getViews();
01930     for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
01931       const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
01932       ObjMap::ConstIterator o_it = anObjects.begin();
01933       for (; o_it != anObjects.end(); o_it++) {
01934         const PropMap aProps = o_it.value();
01935 
01936         //Check that object exists in the study
01937         _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
01938         if ( !obj || !(aProps.count() > 0))
01939           continue;
01940         // entry is "encoded" = it does NOT contain component adress, since it is a
01941         // subject to change on next component loading
01942 
01943         std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
01944 
01945         _PTR(GenericAttribute) anAttr;
01946         if( !obj->FindAttribute(anAttr, "AttributeIOR"))
01947           continue;
01948 
01949         std::string param,occParam = vType.toLatin1().data();
01950         occParam += NAME_SEPARATOR;
01951         occParam += QString::number(aMgrId).toLatin1().data();
01952         occParam += NAME_SEPARATOR;
01953 
01954         if(aProps.contains(VISIBILITY_PROP)) {
01955           param = occParam + VISIBILITY_PROP;
01956           ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
01957         }
01958 
01959         if(aProps.contains(DISPLAY_MODE_PROP)) {
01960           param = occParam + DISPLAY_MODE_PROP;
01961           ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
01962         }
01963 
01964         if(aProps.contains(COLOR_PROP)) {
01965           QColor c = aProps.value(COLOR_PROP).value<QColor>();
01966           QString colorStr = QString::number(c.red()/255.);
01967           colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
01968           colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
01969           param = occParam + COLOR_PROP;
01970           ip->setParameter(entry, param, colorStr.toLatin1().data());
01971         }
01972 
01973         if(vType == SVTK_Viewer::Type()) {
01974           if(aProps.contains(OPACITY_PROP)) {
01975             param = occParam + OPACITY_PROP;
01976             ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
01977           }
01978         } else if (vType == SOCC_Viewer::Type()) {
01979           if(aProps.contains(TRANSPARENCY_PROP)) {
01980             param = occParam + TRANSPARENCY_PROP;
01981             ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
01982           }
01983 
01984           if(aProps.contains(TOP_LEVEL_PROP)) {
01985             param = occParam + TOP_LEVEL_PROP;
01986            Standard_Boolean val = aProps.value(TOP_LEVEL_PROP).value<Standard_Boolean>();
01987            if (val == Standard_True) 
01988              ip->setParameter(entry, param, "1");
01989           }     
01990         }
01991 
01992         if(aProps.contains(ISOS_PROP)) {
01993           param = occParam + ISOS_PROP;
01994           ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
01995         }
01996 
01997         if(aProps.contains(VECTOR_MODE_PROP)) {
01998           param = occParam + VECTOR_MODE_PROP;
01999           ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
02000         }
02001 
02002         if(aProps.contains(DEFLECTION_COEFF_PROP)) {
02003           param = occParam + DEFLECTION_COEFF_PROP;
02004           ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
02005         }
02006 
02007         //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
02008         if(aProps.contains(MARKER_TYPE_PROP)) {
02009           param = occParam + MARKER_TYPE_PROP;
02010           ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
02011         }
02012 
02013        if(aProps.contains(MATERIAL_PROP)) {
02014           param = occParam + MATERIAL_PROP;
02015           ip->setParameter(entry, param, aProps.value(MATERIAL_PROP).toString().toLatin1().data());
02016         }
02017 
02018        if(aProps.contains( EDGE_WIDTH_PROP )) {
02019              param = occParam + EDGE_WIDTH_PROP;
02020            ip->setParameter(entry, param, aProps.value(EDGE_WIDTH_PROP).toString().toLatin1().data());                             
02021         }
02022        
02023        if(aProps.contains( ISOS_WIDTH_PROP )) {
02024          param = occParam + ISOS_WIDTH_PROP;
02025          ip->setParameter(entry, param, aProps.value(ISOS_WIDTH_PROP).toString().toLatin1().data());
02026         }
02027       } // object iterator
02028     } // for (views)
02029   } // for (viewManagers)
02030 }
02031 
02038 void GeometryGUI::restoreVisualParameters (int savePoint)
02039 {
02040   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
02041   if (!appStudy || !appStudy->studyDS())
02042     return;
02043   _PTR(Study) studyDS = appStudy->studyDS();
02044 
02045   // componentName is used for encoding of entries when storing them in IParameters
02046   std::string componentName = myComponentGeom->ComponentDataType();
02047   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
02048   //if (!aSComponent) return;
02049 
02050   // IParameters
02051   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
02052                                                              componentName.c_str(),
02053                                                              savePoint);
02054   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
02055 
02056   std::vector<std::string> entries = ip->getEntries();
02057 
02058   for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
02059   {
02060     // entry is a normal entry - it should be "decoded" (setting base adress of component)
02061     QString entry (ip->decodeEntry(*entIt).c_str());
02062 
02063     // Check that the entry corresponds to a real object in the Study
02064     // as the object may be deleted or modified after the visual state is saved.
02065     _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
02066     if (!so) continue; //Skip the not existent entry
02067 
02068     std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
02069     std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
02070 
02071     std::vector<std::string>::iterator namesIt = paramNames.begin();
02072     std::vector<std::string>::iterator valuesIt = paramValues.begin();
02073 
02074     // actors are stored in a map after displaying of them for
02075     // quicker access in the future: map < viewID to actor >
02076     NCollection_DataMap<int, GEOM_Actor*          > vtkActors;
02077     NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
02078 
02079     QString viewerTypStr;
02080     QString viewIndexStr;
02081     int viewIndex;
02082     QVector<PropMap> aListOfMap;
02083 
02084     for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
02085     {
02086       // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
02087       // '_' is used as separator and should not be used in viewer type or parameter names.
02088       QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts);
02089       if (lst.size() != 3)
02090         continue;
02091 
02092       viewerTypStr = lst[0];
02093       viewIndexStr = lst[1];
02094       QString paramNameStr = lst[2];
02095 
02096       bool ok;
02097       viewIndex = viewIndexStr.toUInt(&ok);
02098       if (!ok) // bad conversion of view index to integer
02099         continue;
02100 
02101       if((viewIndex + 1) > aListOfMap.count()) {
02102         aListOfMap.resize(viewIndex + 1);
02103       }
02104 
02105       QString val((*valuesIt).c_str());
02106       if(paramNameStr == VISIBILITY_PROP){
02107         aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0);
02108 
02109       } else if(paramNameStr == OPACITY_PROP) {
02110         aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
02111 
02112       } else if(paramNameStr == TRANSPARENCY_PROP) {
02113         aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val.toDouble() );
02114 
02115       }       else if(paramNameStr == TOP_LEVEL_PROP) {
02116          aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val == "1" ? Standard_True : Standard_False );
02117          
02118       } else if(paramNameStr == DISPLAY_MODE_PROP) {
02119         aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
02120 
02121       } else if(paramNameStr == ISOS_PROP) {
02122         aListOfMap[viewIndex].insert( ISOS_PROP, val);
02123 
02124       } else if(paramNameStr == COLOR_PROP) {
02125         QStringList rgb = val.split(DIGIT_SEPARATOR);
02126         if(rgb.count() == 3) {
02127           QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255));
02128           aListOfMap[viewIndex].insert( COLOR_PROP, c);
02129         }
02130       } else if(paramNameStr == VECTOR_MODE_PROP) {
02131         aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt());
02132 
02133       }  else if(paramNameStr == DEFLECTION_COEFF_PROP) {
02134         aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
02135       }  else if(paramNameStr == MARKER_TYPE_PROP) {
02136         aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
02137       } else if(paramNameStr == MATERIAL_PROP) {
02138         aListOfMap[viewIndex].insert( MATERIAL_PROP, val);
02139       }  else if(paramNameStr == EDGE_WIDTH_PROP) {
02140        aListOfMap[viewIndex].insert( EDGE_WIDTH_PROP , val);
02141       }  else if(paramNameStr == ISOS_WIDTH_PROP) {
02142        aListOfMap[viewIndex].insert( ISOS_WIDTH_PROP , val);
02143       }
02144 
02145                   
02146 
02147     } // for names/parameters iterator
02148 
02149     QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
02150 
02151     for (int index = 0; index < aListOfMap.count(); index++) {
02152 
02153       appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
02154 
02155       //Get Visibility property of the current PropMap
02156       if (aListOfMap[index].value(VISIBILITY_PROP) == 1) {
02157         SUIT_ViewManager* vman = lst.at(index);
02158         SUIT_ViewModel* vmodel = vman->getViewModel();
02159         displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
02160       }
02161     }
02162 
02163   } // for entries iterator
02164 
02165   // update all VTK and OCC views
02166   QList<SUIT_ViewManager*> lst;
02167   getApp()->viewManagers(lst);
02168   for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
02169     SUIT_ViewModel* vmodel = (*it)->getViewModel();
02170     if (!vmodel)
02171       continue;
02172     if (vmodel->getType() == SVTK_Viewer::Type()) {
02173       SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
02174       vtkView->getRenderer()->ResetCameraClippingRange();
02175       vtkView->Repaint();
02176     }
02177     else if (vmodel->getType() == SOCC_Viewer::Type()) {
02178       //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
02179       SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
02180       if (occVMod)
02181         occVMod->Repaint();
02182     }
02183   }
02184 }
02185 
02186 void GeometryGUI::onViewAboutToShow()
02187 {
02188   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
02189   QAction* a = action( GEOMOp::OpSwitchVectors );
02190   if ( window ) {
02191     a->setEnabled(true);
02192     bool vmode = window->property("VectorsMode").toBool();
02193     a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
02194   } else {
02195     a->setText ( tr("MEN_VECTOR_MODE_ON") );
02196     a->setEnabled(false);
02197   }
02198 }
02199 
02205 QAction* GeometryGUI::getAction(const int id) {
02206   return action(id);
02207 }
02208 
02218 bool GeometryGUI::renameAllowed( const QString& entry) const {
02219 
02220   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
02221   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0; 
02222   SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
02223   
02224   return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
02225 }
02226 
02227 
02234 bool GeometryGUI::renameObject( const QString& entry, const QString& name) {
02235   
02236   bool result = false;
02237   
02238   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
02239   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
02240   
02241   if(!appStudy)
02242     return result;
02243   
02244   _PTR(Study) aStudy = appStudy->studyDS();
02245   
02246   if(!aStudy)
02247     return result;
02248 
02249   bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
02250   if ( aLocked ) {
02251     SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
02252     return result;
02253   }
02254 
02255   _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
02256   _PTR(GenericAttribute) anAttr;
02257   if ( obj ) {
02258     if ( obj->FindAttribute(anAttr, "AttributeName") ) {
02259       _PTR(AttributeName) aName (anAttr);
02260 
02261       GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
02262       if (!CORBA::is_nil(anObj)) {
02263         aName->SetValue( name.toLatin1().data() ); // rename the SObject
02264         anObj->SetName( name.toLatin1().data() );  // Rename the corresponding GEOM_Object
02265         result = true;
02266       }
02267     }
02268   }
02269   return result;
02270 }
02271