Salome HOME
Creation of GUI part
[modules/geom.git] / src / GEOMGUI / GeometryGUI.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : GeometryGUI.cxx
23 //  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24
25 #include <Standard_math.hxx>  // E.A. must be included before Python.h to fix compilation on windows
26 #ifdef HAVE_FINITE
27 #undef HAVE_FINITE            // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
28 #endif
29 #include "Python.h"
30 #include "GeometryGUI.h"
31 #include "GeometryGUI_Operations.h"
32 #include "GEOMPluginGUI.h"
33 #include "GEOMGUI_XmlHandler.h"
34 #include "GEOMGUI_OCCSelector.h"
35 #include "GEOMGUI_Selection.h"
36 #include "GEOMGUI_CreationInfoWdg.h"
37 #include "GEOMGUI_DimensionProperty.h"
38 #include "GEOM_Constants.h"
39 #include "GEOM_Displayer.h"
40 #include "GEOM_AISShape.hxx"
41
42 #include "GEOM_Actor.h"
43
44 #include <Material_ResourceMgr.h>
45 #include <Material_Model.h>
46
47 #include <SUIT_Desktop.h>
48 #include <SUIT_MessageBox.h>
49 #include <SUIT_ResourceMgr.h>
50 #include <SUIT_Session.h>
51 #include <SUIT_ViewManager.h>
52
53 #include <PyInterp_Interp.h>
54
55 #include <OCCViewer_ViewWindow.h>
56 #include <OCCViewer_ViewPort3d.h>
57 #include <OCCViewer_ViewModel.h>
58 #include <OCCViewer_ViewManager.h>
59
60 #include <SOCC_ViewModel.h>
61 #include <SOCC_ViewWindow.h>
62
63 #include <SVTK_ViewWindow.h>
64 #include <SVTK_RenderWindowInteractor.h>
65 #include <SVTK_InteractorStyle.h>
66 #include <SVTK_ViewModel.h>
67
68 #include <SalomeApp_Application.h>
69 #include <SalomeApp_DataObject.h>
70 #include <SalomeApp_Study.h>
71 #include <SalomeApp_Tools.h>
72
73 #include <LightApp_SelectionMgr.h>
74 #include <LightApp_VTKSelector.h>
75 #include <LightApp_DataObject.h>
76 #include <LightApp_Preferences.h>
77
78 #include <GraphicsView_Viewer.h>
79 #include <DependencyTree_View.h>
80 #include <DependencyTree_ViewModel.h>
81
82 #include <SALOME_LifeCycleCORBA.hxx>
83 // #include <SALOME_ListIO.hxx>
84 #include <SALOME_ListIteratorOfListIO.hxx>
85
86 #include <SALOMEDSClient_ClientFactory.hxx>
87 #include <SALOMEDSClient_IParameters.hxx>
88
89 #include <SALOMEDS_SObject.hxx>
90
91 #include <Basics_OCCTVersion.hxx>
92
93 // External includes
94 #include <QDir>
95 #include <QSet>
96 #include <QMenu>
97 #include <QTime>
98 #include <QAction>
99 #include <QFileInfo>
100 #include <QString>
101 #include <QPainter>
102 #include <QSignalMapper>
103
104 #include <AIS_Drawer.hxx>
105 #include <AIS_ListOfInteractive.hxx>
106 #include <AIS_ListIteratorOfListOfInteractive.hxx>
107 #include <Prs3d_Drawer.hxx>
108 #include <Prs3d_IsoAspect.hxx>
109 #include <Aspect_TypeOfMarker.hxx>
110 #include <OSD_SharedLibrary.hxx>
111 #include <NCollection_DataMap.hxx>
112
113 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
114 #include <TColStd_HArray1OfByte.hxx>
115 #else
116 #include <Graphic3d_HArray1OfBytes.hxx>
117 #endif
118
119 #include <utilities.h>
120
121 #include <vtkCamera.h>
122 #include <vtkRenderer.h>
123
124 #include <Standard_Failure.hxx>
125 #include <Standard_ErrorHandler.hxx>
126
127 #include "GEOM_version.h"
128 #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
129
130 extern "C" {
131   Standard_EXPORT CAM_Module* createModule() {
132     return new GeometryGUI();
133   }
134
135   Standard_EXPORT char* getModuleVersion() {
136     return (char*)GEOM_VERSION_STR;
137   }
138 }
139
140 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
141
142 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
143
144 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
145 {
146   // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
147   if (CORBA::is_nil(myComponentGeom))
148     InitGeomGen();
149   return GeometryGUI::myComponentGeom;
150 }
151
152 bool GeometryGUI::InitGeomGen()
153 {
154   GeometryGUI aGG;
155   if ( CORBA::is_nil( myComponentGeom ) ) return false;
156   return true;
157 }
158
159 //=======================================================================
160 // function : ClientSObjectToObject
161 // purpose  :
162 //=======================================================================
163 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
164 {
165   _PTR(GenericAttribute) anAttr;
166   CORBA::Object_var anObj;
167   try {
168     std::string aValue = theSObject->GetIOR();
169     if (strcmp(aValue.c_str(), "") != 0) {
170       CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
171       anObj = anORB->string_to_object(aValue.c_str());
172     }
173   } catch(...) {
174     INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
175   }
176   return anObj._retn();
177 }
178
179 //=======================================================================
180 // function : ClientStudyToStudy
181 // purpose  :
182 //=======================================================================
183 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
184 {
185   SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
186   CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
187   SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
188   int aStudyID = theStudy->StudyId();
189   SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
190   return aDSStudy._retn();
191 }
192
193 void GeometryGUI::Modified (bool theIsUpdateActions)
194 {
195   if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
196     if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
197       appStudy->Modified();
198       if ( theIsUpdateActions )
199         app->updateActions();
200     }
201   }
202 }
203
204 //=======================================================================
205 // function : GeometryGUI::GeometryGUI()
206 // purpose  : Constructor
207 //=======================================================================
208 GeometryGUI::GeometryGUI() :
209   SalomeApp_Module( "GEOM" ),
210   myTopLevelIOList()
211 {
212   if ( CORBA::is_nil( myComponentGeom ) )
213   {
214     Engines::EngineComponent_var comp =
215       SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
216     myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
217   }
218
219   myActiveDialogBox = 0;
220
221   gp_Pnt origin = gp_Pnt(0., 0., 0.);
222   gp_Dir direction = gp_Dir(0., 0., 1.);
223   myWorkingPlane = gp_Ax3(origin, direction);
224
225   myDisplayer = 0;
226   myLocalSelectionMode = GEOM_ALLOBJECTS;
227
228   myCreationInfoWdg = 0;
229
230   connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
231
232   Q_INIT_RESOURCE( GEOMGUI );
233 }
234
235 //=======================================================================
236 // function : GeometryGUI::~GeometryGUI()
237 // purpose  : Destructor
238 //=======================================================================
239 GeometryGUI::~GeometryGUI()
240 {
241   while (!myOCCSelectors.isEmpty())
242     delete myOCCSelectors.takeFirst();
243
244   while (!myVTKSelectors.isEmpty())
245     delete myVTKSelectors.takeFirst();
246
247   qDeleteAll(myGUIMap);
248 }
249
250 //=======================================================================
251 // function : GeometryGUI::getLibrary()
252 // purpose  : get or load GUI library by name [ internal ]
253 //=======================================================================
254 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
255 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
256 {
257   if ( !myGUIMap.contains( libraryName ) ) {
258     // try to load library if it is not loaded yet
259 #ifndef WIN32
260     QString dirs = getenv( "LD_LIBRARY_PATH" );
261     QString sep  = ":";
262 #else
263     QString dirs = getenv( "PATH" );
264     QString sep  = ";";
265 #endif
266     if ( !dirs.isEmpty() ) {
267       QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
268       QListIterator<QString> it( dirList ); it.toBack();
269       while ( it.hasPrevious() ) {
270         QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
271         if ( fi.exists() ) {
272           OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
273           bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
274           if ( !res ) {
275             MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
276             continue; // continue search further
277           }
278           OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
279           if ( osdF != NULL ) {
280             LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
281             GEOMGUI* libGUI = (*func)( this );
282             if ( libGUI ) {
283               myGUIMap[ libraryName ] = libGUI;
284               break; // found and loaded!
285             }
286           }
287         }
288       }
289     }
290   }
291   return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
292 }
293
294 //=======================================================================
295 // function : GeometryGUI::getPluginLibrary()
296 // purpose  : get or load GUI Plugin library by name [ internal ]
297 //=======================================================================
298 typedef GEOMPluginGUI* (*PluginLibraryGUI)( GeometryGUI* );
299 GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName )
300 {
301   if ( !myGUIMap.contains( libraryName ) ) {
302     // try to load library if it is not loaded yet
303 #ifndef WIN32
304     QString dirs = getenv( "LD_LIBRARY_PATH" );
305     QString sep  = ":";
306 #else
307     QString dirs = getenv( "PATH" );
308     QString sep  = ";";
309 #endif
310     if ( !dirs.isEmpty() ) {
311       QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
312       QListIterator<QString> it( dirList ); it.toBack();
313       while ( it.hasPrevious() ) {
314         QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
315         if ( fi.exists() ) {
316           OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
317           bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
318           if ( !res ) {
319             MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
320             continue; // continue search further
321           }
322           OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
323           if ( osdF != NULL ) {
324             PluginLibraryGUI func = (GEOMPluginGUI* (*) (GeometryGUI*))osdF;
325             GEOMPluginGUI* libGUI = (*func)( this );
326             if ( libGUI ) {
327               myGUIMap[ libraryName ] = libGUI;
328               break; // found and loaded!
329             }
330           }
331         }
332       }
333     }
334   }
335   return myGUIMap.contains( libraryName ) ? (GEOMPluginGUI*)myGUIMap[ libraryName ] : 0;
336 }
337
338 //=======================================================================
339 // function : GeometryGUI::ActiveWorkingPlane()
340 // purpose  : Activate Working Plane View
341 //=======================================================================
342 void GeometryGUI::ActiveWorkingPlane()
343 {
344   gp_Dir DZ = myWorkingPlane.Direction();
345   gp_Dir DY = myWorkingPlane.YDirection();
346
347   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
348   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
349   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
350
351   if ( ViewOCC ) {
352     OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
353     if ( vw ) {
354       Handle(V3d_View) view3d =  vw->getViewPort()->getView();
355
356       view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
357       view3d->SetUp(DY.X(), DY.Y(), DY.Z());
358       vw->onViewFitAll();
359     }
360   }
361   else if ( ViewVTK ) {
362     SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
363     if ( vw ) {
364       vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
365
366       camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
367       camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
368       camera->SetFocalPoint(0,0,0);
369
370       vw->onFitAll();
371     }
372   }
373 }
374
375 //=======================================================================
376 // function : GeometryGUI::SetActiveDialogBox()
377 // purpose  : Set active dialog box
378 //=======================================================================
379 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
380 {
381   myActiveDialogBox = (QDialog*)aDlg;
382 }
383
384 //=======================================================================
385 // function : GeometryGUI::EmitSignalDeactivateDialog()
386 // purpose  : Emit a signal to deactivate the active dialog Box
387 //=======================================================================
388 void GeometryGUI::EmitSignalDeactivateDialog()
389 {
390   emit SignalDeactivateActiveDialog();
391 }
392
393 //=======================================================================
394 // function : GeometryGUI::EmitSignalCloseAllDialogs()
395 // purpose  : Emit a signal to close all non modal dialogs box
396 //=======================================================================
397 void GeometryGUI::EmitSignalCloseAllDialogs()
398 {
399   emit SignalCloseAllDialogs();
400 }
401
402 //=======================================================================
403 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
404 // purpose  : Emit a signal to inform that default real spin box step has
405 //            been changed
406 //=======================================================================
407 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
408 {
409   emit SignalDefaultStepValueChanged(newVal);
410 }
411
412 //=======================================================================
413 // function : GeometryGUI::OnGUIEvent()
414 // purpose  : common slot for all menu/toolbar actions
415 //=======================================================================
416 void GeometryGUI::OnGUIEvent()
417 {
418   const QObject* obj = sender();
419   if ( !obj || !obj->inherits( "QAction" ) )
420     return;
421   int id = actionId((QAction*)obj);
422   if ( id != -1 )
423     OnGUIEvent( id );
424 }
425
426 //=======================================================================
427 // function : GeometryGUI::OnGUIEvent()
428 // purpose  : manage all events on GUI [static]
429 //=======================================================================
430 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
431 {
432   SUIT_Application* anApp = application();
433   if (!anApp) return;
434   SUIT_Desktop* desk = anApp->desktop();
435
436   // check type of the active viewframe
437   SUIT_ViewWindow* window = desk->activeWindow();
438   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
439   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
440   // if current viewframe is not of OCC and not of VTK type - return immediately
441   // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
442   QList<int> NotViewerDependentCommands;
443   NotViewerDependentCommands << GEOMOp::OpDelete
444                              << GEOMOp::OpShow
445                              << GEOMOp::OpShowOnly
446                              << GEOMOp::OpShowOnlyChildren
447                              << GEOMOp::OpDiscloseChildren
448                              << GEOMOp::OpConcealChildren
449                              << GEOMOp::OpUnpublishObject
450                              << GEOMOp::OpPublishObject
451                              << GEOMOp::OpPointMarker
452                              << GEOMOp::OpCreateFolder
453                              << GEOMOp::OpSortChildren;
454   if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) ) {
455     // activate OCC viewer
456     getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true);
457   }
458
459   // fix for IPAL9103, point 2
460   if ( CORBA::is_nil( GetGeomGen() ) ) {
461     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
462     return;
463   }
464
465   QString libName;
466   // find corresponding GUI library
467   switch ( id ) {
468   case GEOMOp::OpOriginAndVectors:   // MENU BASIC - ORIGIN AND BASE VECTORS
469     createOriginAndBaseVectors(); // internal operation
470     return;
471   case GEOMOp::OpImport:             // MENU FILE - IMPORT
472   case GEOMOp::OpExport:             // MENU FILE - EXPORT
473   case GEOMOp::OpSelectVertex:       // POPUP MENU - SELECT ONLY - VERTEX
474   case GEOMOp::OpSelectEdge:         // POPUP MENU - SELECT ONLY - EDGE
475   case GEOMOp::OpSelectWire:         // POPUP MENU - SELECT ONLY - WIRE
476   case GEOMOp::OpSelectFace:         // POPUP MENU - SELECT ONLY - FACE
477   case GEOMOp::OpSelectShell:        // POPUP MENU - SELECT ONLY - SHELL
478   case GEOMOp::OpSelectSolid:        // POPUP MENU - SELECT ONLY - SOLID
479   case GEOMOp::OpSelectCompound:     // POPUP MENU - SELECT ONLY - COMPOUND
480   case GEOMOp::OpSelectAll:          // POPUP MENU - SELECT ONLY - SELECT ALL
481   case GEOMOp::OpDelete:             // MENU EDIT - DELETE
482   case GEOMOp::OpCheckGeom:          // MENU TOOLS - CHECK GEOMETRY
483   case GEOMOp::OpMaterialsLibrary:   // MENU TOOLS - MATERIALS LIBRARY
484   case GEOMOp::OpDeflection:         // POPUP MENU - DEFLECTION COEFFICIENT
485   case GEOMOp::OpColor:              // POPUP MENU - COLOR
486   case GEOMOp::OpSetTexture:         // POPUP MENU - SETTEXTURE
487   case GEOMOp::OpTransparency:       // POPUP MENU - TRANSPARENCY
488   case GEOMOp::OpIncrTransparency:   // SHORTCUT   - INCREASE TRANSPARENCY
489   case GEOMOp::OpDecrTransparency:   // SHORTCUT   - DECREASE TRANSPARENCY
490   case GEOMOp::OpIsos:               // POPUP MENU - ISOS
491   case GEOMOp::OpIncrNbIsos:         // SHORTCUT   - INCREASE NB ISOS
492   case GEOMOp::OpDecrNbIsos:         // SHORTCUT   - DECREASE NB ISOS
493   case GEOMOp::OpAutoColor:          // POPUP MENU - AUTO COLOR
494   case GEOMOp::OpNoAutoColor:        // POPUP MENU - DISABLE AUTO COLOR
495   case GEOMOp::OpDiscloseChildren:   // POPUP MENU - DISCLOSE CHILD ITEMS
496   case GEOMOp::OpConcealChildren:    // POPUP MENU - CONCEAL CHILD ITEMS
497   case GEOMOp::OpUnpublishObject:    // POPUP MENU - UNPUBLISH
498   case GEOMOp::OpPublishObject:      // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
499   case GEOMOp::OpPointMarker:        // POPUP MENU - POINT MARKER
500   case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
501   case GEOMOp::OpPredefMaterial:     // POPUP MENU - <SOME MATERIAL>
502   case GEOMOp::OpPredefMaterCustom:  // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
503   case GEOMOp::OpEdgeWidth:          // POPUP MENU - LINE WIDTH - EDGE WIDTH
504   case GEOMOp::OpIsosWidth:          // POPUP MENU - LINE WIDTH - ISOS WIDTH
505   case GEOMOp::OpBringToFront:       // POPUP MENU - BRING TO FRONT
506   case GEOMOp::OpClsBringToFront:    //
507   case GEOMOp::OpCreateFolder:       // POPUP MENU - CREATE FOLDER
508   case GEOMOp::OpSortChildren:       // POPUP MENU - SORT CHILD ITEMS
509   case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE
510     libName = "GEOMToolsGUI";
511     break;
512   case GEOMOp::OpDMWireframe:        // MENU VIEW - WIREFRAME
513   case GEOMOp::OpDMShading:          // MENU VIEW - SHADING
514   case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
515   case GEOMOp::OpDMTexture:          // MENU VIEW - TEXTURE
516   case GEOMOp::OpShowAll:            // MENU VIEW - SHOW ALL
517   case GEOMOp::OpShowOnly:           // MENU VIEW - DISPLAY ONLY
518   case GEOMOp::OpShowOnlyChildren:   // MENU VIEW - SHOW ONLY CHILDREN
519   case GEOMOp::OpHideAll:            // MENU VIEW - ERASE ALL
520   case GEOMOp::OpHide:               // MENU VIEW - ERASE
521   case GEOMOp::OpShow:               // MENU VIEW - DISPLAY
522   case GEOMOp::OpSwitchVectors:      // MENU VIEW - VECTOR MODE
523   case GEOMOp::OpWireframe:          // POPUP MENU - WIREFRAME
524   case GEOMOp::OpShading:            // POPUP MENU - SHADING
525   case GEOMOp::OpShadingWithEdges:   // POPUP MENU - SHADING WITH EDGES
526   case GEOMOp::OpTexture:            // POPUP MENU - TEXTURE
527   case GEOMOp::OpVectors:            // POPUP MENU - VECTORS
528     libName = "DisplayGUI";
529     break;
530   case GEOMOp::OpPoint:              // MENU BASIC - POINT
531   case GEOMOp::OpLine:               // MENU BASIC - LINE
532   case GEOMOp::OpCircle:             // MENU BASIC - CIRCLE
533   case GEOMOp::OpEllipse:            // MENU BASIC - ELLIPSE
534   case GEOMOp::OpArc:                // MENU BASIC - ARC
535   case GEOMOp::OpVector:             // MENU BASIC - VECTOR
536   case GEOMOp::OpPlane:              // MENU BASIC - PLANE
537   case GEOMOp::OpCurve:              // MENU BASIC - CURVE
538   case GEOMOp::OpLCS:                // MENU BASIC - LOCAL COORDINATE SYSTEM
539     libName = "BasicGUI";
540     break;
541   case GEOMOp::OpBox:                // MENU PRIMITIVE - BOX
542   case GEOMOp::OpCylinder:           // MENU PRIMITIVE - CYLINDER
543   case GEOMOp::OpSphere:             // MENU PRIMITIVE - SPHERE
544   case GEOMOp::OpTorus:              // MENU PRIMITIVE - TORUS
545   case GEOMOp::OpCone:               // MENU PRIMITIVE - CONE
546   case GEOMOp::OpRectangle:          // MENU PRIMITIVE - FACE
547   case GEOMOp::OpDisk:               // MENU PRIMITIVE - DISK
548     libName = "PrimitiveGUI";
549     break;
550   case GEOMOp::OpPrism:              // MENU GENERATION - PRISM
551   case GEOMOp::OpRevolution:         // MENU GENERATION - REVOLUTION
552   case GEOMOp::OpFilling:            // MENU GENERATION - FILLING
553   case GEOMOp::OpPipe:               // MENU GENERATION - PIPE
554   case GEOMOp::OpPipePath:           // MENU GENERATION - RESTORE PATH
555     libName = "GenerationGUI";
556     break;
557   case GEOMOp::Op2dSketcher:         // MENU ENTITY - SKETCHER
558   case GEOMOp::Op3dSketcher:         // MENU ENTITY - 3D SKETCHER
559   case GEOMOp::OpIsoline:            // MENU BASIC  - ISOLINE
560   case GEOMOp::OpExplode:            // MENU ENTITY - EXPLODE
561 #ifdef WITH_OPENCV
562   case GEOMOp::OpFeatureDetect:      // MENU ENTITY - FEATURE DETECTION
563 #endif
564   case GEOMOp::OpPictureImport:      // MENU ENTITY - IMPORT PICTURE IN VIEWER
565   case GEOMOp::OpCreateField:        // MENU FIELD - CREATE FIELD
566   case GEOMOp::OpEditField:          // MENU FIELD - EDIT FIELD
567   case GEOMOp::OpEditFieldPopup:     // POPUP MENU - EDIT FIELD
568     libName = "EntityGUI";
569     break;
570   case GEOMOp::OpEdge:               // MENU BUILD - EDGE
571   case GEOMOp::OpWire:               // MENU BUILD - WIRE
572   case GEOMOp::OpFace:               // MENU BUILD - FACE
573   case GEOMOp::OpShell:              // MENU BUILD - SHELL
574   case GEOMOp::OpSolid:              // MENU BUILD - SOLID
575   case GEOMOp::OpCompound:           // MENU BUILD - COMPUND
576     libName = "BuildGUI";
577     break;
578   case GEOMOp::OpFuse:               // MENU BOOLEAN - FUSE
579   case GEOMOp::OpCommon:             // MENU BOOLEAN - COMMON
580   case GEOMOp::OpCut:                // MENU BOOLEAN - CUT
581   case GEOMOp::OpSection:            // MENU BOOLEAN - SECTION
582     libName = "BooleanGUI";
583     break;
584   case GEOMOp::OpTranslate:          // MENU TRANSFORMATION - TRANSLATION
585   case GEOMOp::OpRotate:             // MENU TRANSFORMATION - ROTATION
586   case GEOMOp::OpChangeLoc:          // MENU TRANSFORMATION - LOCATION
587   case GEOMOp::OpMirror:             // MENU TRANSFORMATION - MIRROR
588   case GEOMOp::OpScale:              // MENU TRANSFORMATION - SCALE
589   case GEOMOp::OpOffset:             // MENU TRANSFORMATION - OFFSET
590   case GEOMOp::OpProjection:         // MENU TRANSFORMATION - PROJECTION
591   case GEOMOp::OpMultiTranslate:     // MENU TRANSFORMATION - MULTI-TRANSLATION
592   case GEOMOp::OpMultiRotate:        // MENU TRANSFORMATION - MULTI-ROTATION
593   case GEOMOp::OpReimport:           // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
594     libName = "TransformationGUI";
595     break;
596   case GEOMOp::OpPartition:          // MENU OPERATION - PARTITION
597   case GEOMOp::OpArchimede:          // MENU OPERATION - ARCHIMEDE
598   case GEOMOp::OpFillet3d:           // MENU OPERATION - FILLET
599   case GEOMOp::OpChamfer:            // MENU OPERATION - CHAMFER
600   case GEOMOp::OpClipping:           // MENU OPERATION - CLIPPING RANGE
601   case GEOMOp::OpShapesOnShape:      // MENU OPERATION - GET SHAPES ON SHAPE
602   case GEOMOp::OpFillet2d:           // MENU OPERATION - FILLET 2D
603   case GEOMOp::OpFillet1d:           // MENU OPERATION - FILLET 1D
604   case GEOMOp::OpSharedShapes:       // MENU OPERATION - GET SHARED SHAPES
605   case GEOMOp::OpExtrudedBoss:       // MENU OPERATION - EXTRUDED BOSS
606   case GEOMOp::OpExtrudedCut:        // MENU OPERATION - EXTRUDED CUT
607 #ifdef DEBUG_CURVE_CREATOR  
608   // for debug purposes, to be removed
609   case GEOMOp::OpCurveCreator:       // MENU OPERATION - CURVE CREATOR
610 #endif
611     libName = "OperationGUI";
612     break;
613   case GEOMOp::OpSewing:             // MENU REPAIR - SEWING
614   case GEOMOp::OpSuppressFaces:      // MENU REPAIR - SUPPRESS FACES
615   case GEOMOp::OpSuppressHoles:      // MENU REPAIR - SUPPRESS HOLE
616   case GEOMOp::OpShapeProcess:       // MENU REPAIR - SHAPE PROCESSING
617   case GEOMOp::OpCloseContour:       // MENU REPAIR - CLOSE CONTOUR
618   case GEOMOp::OpRemoveIntWires:     // MENU REPAIR - REMOVE INTERNAL WIRES
619   case GEOMOp::OpAddPointOnEdge:     // MENU REPAIR - ADD POINT ON EDGE
620   case GEOMOp::OpFreeBoundaries:     // MENU MEASURE - FREE BOUNDARIES
621   case GEOMOp::OpFreeFaces:          // MENU MEASURE - FREE FACES
622   case GEOMOp::OpOrientation:        // MENU REPAIR - CHANGE ORIENTATION
623   case GEOMOp::OpGlueFaces:          // MENU REPAIR - GLUE FACES
624   case GEOMOp::OpGlueEdges:          // MENU REPAIR - GLUE EDGES
625   case GEOMOp::OpLimitTolerance:     // MENU REPAIR - LIMIT TOLERANCE
626   case GEOMOp::OpRemoveWebs:         // MENU REPAIR - REMOVE INTERNAL FACES
627   case GEOMOp::OpRemoveExtraEdges:   // MENU REPAIR - REMOVE EXTRA EDGES
628   case GEOMOp::OpFuseEdges:          // MENU REPAIR - FUSE COLLINEAR EDGES
629   case GEOMOp::OpUnionFaces:         // MENU REPAIR - UNION FACES
630     libName = "RepairGUI";
631     break;
632   case GEOMOp::OpProperties:         // MENU MEASURE - PROPERTIES
633   case GEOMOp::OpCenterMass:         // MENU MEASURE - CDG
634   case GEOMOp::OpInertia:            // MENU MEASURE - INERTIA
635   case GEOMOp::OpNormale:            // MENU MEASURE - NORMALE
636   case GEOMOp::OpBoundingBox:        // MENU MEASURE - BOUNDING BOX
637   case GEOMOp::OpMinDistance:        // MENU MEASURE - MIN DISTANCE
638   case GEOMOp::OpAngle:              // MENU MEASURE - ANGLE
639   case GEOMOp::OpTolerance:          // MENU MEASURE - TOLERANCE
640   case GEOMOp::OpWhatIs:             // MENU MEASURE - WHATIS
641   case GEOMOp::OpCheckShape:         // MENU MEASURE - CHECK
642   case GEOMOp::OpCheckCompound:      // MENU MEASURE - CHECK COMPOUND OF BLOCKS
643   case GEOMOp::OpGetNonBlocks:       // MENU MEASURE - Get NON BLOCKS
644   case GEOMOp::OpPointCoordinates:   // MENU MEASURE - POINT COORDINATES
645   case GEOMOp::OpCheckSelfInters:    // MENU MEASURE - CHECK SELF INTERSECTIONS
646   case GEOMOp::OpManageDimensions:   // MENU MEASURE - MANAGE DIMENSIONS
647   case GEOMOp::OpShowAllDimensions:  // POPUP MENU - SHOW ALL DIMENSIONS
648   case GEOMOp::OpHideAllDimensions:  // POPUP MENU - HIDE ALL DIMENSIONS
649     libName = "MeasureGUI";
650     break;
651   case GEOMOp::OpGroupCreate:        // MENU GROUP - CREATE
652   case GEOMOp::OpGroupCreatePopup:   // POPUP MENU - CREATE GROUP
653   case GEOMOp::OpGroupEdit:          // MENU GROUP - EDIT
654   case GEOMOp::OpGroupUnion:         // MENU GROUP - UNION
655   case GEOMOp::OpGroupIntersect:     // MENU GROUP - INTERSECT
656   case GEOMOp::OpGroupCut:           // MENU GROUP - CUT
657     libName = "GroupGUI";
658     break;
659   case GEOMOp::OpHexaSolid:          // MENU BLOCKS - HEXAHEDRAL SOLID
660   case GEOMOp::OpMultiTransform:     // MENU BLOCKS - MULTI-TRANSFORMATION
661   case GEOMOp::OpQuadFace:           // MENU BLOCKS - QUADRANGLE FACE
662   case GEOMOp::OpPropagate:          // MENU BLOCKS - PROPAGATE
663   case GEOMOp::OpExplodeBlock:       // MENU BLOCKS - EXPLODE ON BLOCKS
664     libName = "BlocksGUI";
665     break;
666   case GEOMOp::OpExportXAO:          // MENU NEW ENTITY - IMPORTEXPORT - EXPORTXAO
667   case GEOMOp::OpImportXAO:          // MENU NEW ENTITY - IMPORTEXPORT - IMPORTXAO
668     libName = "ImportExportGUI";
669     break;
670   //case GEOMOp::OpAdvancedNoOp:       // NO OPERATION (advanced operations base)
671   //case GEOMOp::OpPipeTShape:         // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
672   //case GEOMOp::OpPipeTShapeGroups:     // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
673   //case GEOMOp::OpDividedDisk:           // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
674   //case GEOMOp::OpDividedCylinder:           // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
675   //case GEOMOp::OpSmoothingSurface:           // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
676     //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
677     //libName = "AdvancedGUI";
678     //break;
679   default:
680     if (myPluginActions.contains(id)) {
681       libName = myPluginActions[id].first;
682
683       GEOMPluginGUI* library = 0;
684       if ( !libName.isEmpty() ) {
685 #ifndef WIN32
686         libName = QString( "lib" ) + libName + ".so";
687 #else
688         libName = libName + ".dll";
689 #endif
690         library = getPluginLibrary( libName );
691       }
692
693       // call method of corresponding GUI library
694       if ( library ) {
695         //QString action ("%1");
696         //action = action.arg(id);
697
698         //if( !theParam.isValid() )
699           library->OnGUIEvent( myPluginActions[id].second, desk );
700         //else
701         //  library->OnGUIEvent( id, desk, theParam);
702       }
703       else
704         SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
705
706       updateCreationInfo();
707       return;
708     }
709     break;
710   }
711
712   GEOMGUI* library = 0;
713   if ( !libName.isEmpty() ) {
714 #ifndef WIN32
715     libName = QString( "lib" ) + libName + ".so";
716 #else
717     libName = libName + ".dll";
718 #endif
719     library = getLibrary( libName );
720   }
721
722   // call method of corresponding GUI library
723   if ( library ) {
724     if( !theParam.isValid() )
725       library->OnGUIEvent( id, desk );
726     else
727       library->OnGUIEvent( id, desk, theParam);
728   }
729   else
730     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
731
732   updateCreationInfo();
733 }
734
735 //=================================================================================
736 // function : GeometryGUI::activateOperation()
737 // purpose  :
738 //=================================================================================
739 bool GeometryGUI::activateOperation( int actionId )
740 {
741   OnGUIEvent(actionId);
742   return true;
743 }
744
745 //=================================================================================
746 // function : GeometryGUI::activateOperation()
747 // purpose  :
748 //=================================================================================
749 bool GeometryGUI::activateOperation( const QString& actionId )
750 {
751   bool isOk = false;
752
753   int id = actionId.toInt(&isOk);
754   if (isOk)
755     OnGUIEvent(id);
756
757   return isOk;
758 }
759
760 //=================================================================================
761 // function : GeometryGUI::activateOperation()
762 // purpose  :
763 //=================================================================================
764 bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin )
765 {
766   bool isOk = false;
767
768   QString pluginLib = plugin;
769   // TODO: if <plugin> is a plugin name, find plugin library name
770   if (myPluginLibs.contains(plugin))
771     pluginLib = myPluginLibs[plugin];
772
773   QMap<int, PluginAction>::iterator actionsIter = myPluginActions.begin();
774   for (; actionsIter != myPluginActions.end(); ++actionsIter) {
775     const PluginAction& anAction = actionsIter.value();
776     if (anAction.first == pluginLib && anAction.second == actionId) {
777       // activate operation
778       OnGUIEvent(actionsIter.key());
779       isOk = true;
780     }
781   }
782
783   return isOk;
784 }
785
786 //=================================================================================
787 // function : GeometryGUI::OnKeyPress()
788 // purpose  : Called when any key is pressed by user [static]
789 //=================================================================================
790 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
791 {
792   if ( !application() )
793     return;
794   foreach ( GEOMGUI* lib, myGUIMap )
795     lib->OnKeyPress( e, application()->desktop(), w );
796 }
797
798 //=================================================================================
799 // function : GeometryGUI::OnMouseMove()
800 // purpose  : Manages mouse move events [static]
801 //=================================================================================
802 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
803 {
804   if ( !application() )
805     return;
806   foreach ( GEOMGUI* lib, myGUIMap )
807     lib->OnMouseMove( e, application()->desktop(), w );
808 }
809
810 //=================================================================================
811 // function : GeometryGUI::OnMouseRelease()
812 // purpose  : Manages mouse release events [static]
813 //=================================================================================
814 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
815 {
816   if ( !application() )
817     return;
818   foreach ( GEOMGUI* lib, myGUIMap )
819     lib->OnMouseRelease( e, application()->desktop(), w );
820 }
821
822 //=================================================================================
823 // function : GeometryGUI::OnMousePress()
824 // purpose  : Manage mouse press events [static]
825 //=================================================================================
826 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
827 {
828   if ( !application() )
829     return;
830   foreach ( GEOMGUI* lib, myGUIMap )
831     lib->OnMousePress( e, application()->desktop(), w );
832 }
833
834 //=======================================================================
835 // function : createGeomAction
836 // purpose  :
837 //=======================================================================
838 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
839                                     const int accel, const bool toggle, const QString& shortcutAction )
840 {
841   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
842   QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
843                                     : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
844   createAction( id,
845                 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
846                 icon,
847                 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
848                 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
849                 accel,
850                 application()->desktop(),
851                 toggle,
852                 this, SLOT( OnGUIEvent() ),
853                 shortcutAction );
854 }
855
856 //=======================================================================
857 // function : createOriginAndBaseVectors
858 // purpose  :
859 //=======================================================================
860 void GeometryGUI::createOriginAndBaseVectors()
861 {
862   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
863   bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
864   if ( aLocked ) {
865     SUIT_MessageBox::warning ( application()->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
866     return;
867   }
868   if ( appStudy ) {
869     _PTR(Study) studyDS = appStudy->studyDS();
870     if ( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
871       GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
872       if ( !aBasicOperations->_is_nil() ) {
873         SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
874         double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
875         GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
876         GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
877         GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
878         GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
879
880         SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
881         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
882         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
883         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
884         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
885
886         getApp()->updateObjectBrowser( true );
887       }
888     }
889   }
890 }
891
892 //=======================================================================
893 // function : GeometryGUI::initialize()
894 // purpose  : Called when GEOM module is created
895 //=======================================================================
896 void GeometryGUI::initialize( CAM_Application* app )
897 {
898   SalomeApp_Module::initialize( app );
899
900   // ----- create actions --------------
901
902   createGeomAction( GEOMOp::OpImport,     "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
903   createGeomAction( GEOMOp::OpExport,     "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
904
905   createGeomAction( GEOMOp::OpDelete,     "DELETE", "", Qt::Key_Delete );
906
907   createGeomAction( GEOMOp::OpPoint,      "POINT" );
908   createGeomAction( GEOMOp::OpLine,       "LINE" );
909   createGeomAction( GEOMOp::OpCircle,     "CIRCLE" );
910   createGeomAction( GEOMOp::OpEllipse,    "ELLIPSE" );
911   createGeomAction( GEOMOp::OpArc,        "ARC" );
912   createGeomAction( GEOMOp::OpCurve,      "CURVE" );
913   createGeomAction( GEOMOp::OpIsoline,    "ISOLINE" );
914   createGeomAction( GEOMOp::OpVector,     "VECTOR" );
915   createGeomAction( GEOMOp::OpPlane,      "PLANE" );
916   createGeomAction( GEOMOp::OpLCS,        "LOCAL_CS" );
917   createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
918
919   createGeomAction( GEOMOp::OpBox,        "BOX" );
920   createGeomAction( GEOMOp::OpCylinder,   "CYLINDER" );
921   createGeomAction( GEOMOp::OpSphere,     "SPHERE" );
922   createGeomAction( GEOMOp::OpTorus,      "TORUS" );
923   createGeomAction( GEOMOp::OpCone,       "CONE" );
924   createGeomAction( GEOMOp::OpRectangle,  "RECTANGLE" );
925   createGeomAction( GEOMOp::OpDisk,       "DISK" );
926
927   createGeomAction( GEOMOp::OpPrism,       "EXTRUSION" );
928   createGeomAction( GEOMOp::OpRevolution,  "REVOLUTION" );
929   createGeomAction( GEOMOp::OpFilling,     "FILLING" );
930   createGeomAction( GEOMOp::OpPipe,        "PIPE" );
931   createGeomAction( GEOMOp::OpPipePath,    "PIPE_PATH" );
932
933   createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
934   createGeomAction( GEOMOp::OpGroupEdit,   "GROUP_EDIT" );
935   createGeomAction( GEOMOp::OpGroupUnion,  "GROUP_UNION" );
936   createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
937   createGeomAction( GEOMOp::OpGroupCut,    "GROUP_CUT" );
938
939   createGeomAction( GEOMOp::OpCreateField, "FIELD_CREATE" );
940   createGeomAction( GEOMOp::OpEditField,   "FIELD_EDIT" );
941
942   createGeomAction( GEOMOp::OpReimport,    "RELOAD_IMPORTED" );
943
944   createGeomAction( GEOMOp::OpQuadFace,    "Q_FACE" );
945   createGeomAction( GEOMOp::OpHexaSolid,   "HEX_SOLID" );
946
947   createGeomAction( GEOMOp::Op2dSketcher,  "SKETCH" );
948   createGeomAction( GEOMOp::Op3dSketcher,  "3DSKETCH" );
949   createGeomAction( GEOMOp::OpIsoline,     "ISOLINE" );
950   createGeomAction( GEOMOp::OpExplode,     "EXPLODE" );
951 #ifdef WITH_OPENCV
952   createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
953 #endif
954   createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
955
956   createGeomAction( GEOMOp::OpEdge,        "EDGE" );
957   createGeomAction( GEOMOp::OpWire,        "WIRE" );
958   createGeomAction( GEOMOp::OpFace,        "FACE" );
959   createGeomAction( GEOMOp::OpShell,       "SHELL" );
960   createGeomAction( GEOMOp::OpSolid,       "SOLID" );
961   createGeomAction( GEOMOp::OpCompound,    "COMPOUND" );
962
963   createGeomAction( GEOMOp::OpFuse,        "FUSE" );
964   createGeomAction( GEOMOp::OpCommon,      "COMMON" );
965   createGeomAction( GEOMOp::OpCut,         "CUT" );
966   createGeomAction( GEOMOp::OpSection,     "SECTION" );
967
968   createGeomAction( GEOMOp::OpTranslate,      "TRANSLATION" );
969   createGeomAction( GEOMOp::OpRotate,         "ROTATION" );
970   createGeomAction( GEOMOp::OpChangeLoc,      "MODIFY_LOCATION" );
971   createGeomAction( GEOMOp::OpMirror,         "MIRROR" );
972   createGeomAction( GEOMOp::OpScale,          "SCALE" );
973   createGeomAction( GEOMOp::OpOffset,         "OFFSET" );
974   createGeomAction( GEOMOp::OpProjection,     "PROJECTION" );
975   createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
976   createGeomAction( GEOMOp::OpMultiRotate,    "MUL_ROTATION" );
977
978   createGeomAction( GEOMOp::OpPartition,      "PARTITION" );
979   createGeomAction( GEOMOp::OpArchimede,      "ARCHIMEDE" );
980   createGeomAction( GEOMOp::OpFillet3d,       "FILLET" );
981   createGeomAction( GEOMOp::OpChamfer,        "CHAMFER" );
982   //createGeomAction( GEOMOp::OpClipping,        "CLIPPING" );
983   createGeomAction( GEOMOp::OpShapesOnShape,  "GET_SHAPES_ON_SHAPE" );
984   createGeomAction( GEOMOp::OpSharedShapes,   "GET_SHARED_SHAPES" );
985   createGeomAction( GEOMOp::OpExtrudedCut,    "EXTRUDED_CUT" );
986   createGeomAction( GEOMOp::OpExtrudedBoss,   "EXTRUDED_BOSS" );
987 #ifdef DEBUG_CURVE_CREATOR
988   // for debug purposes, to be removed
989   createGeomAction( GEOMOp::OpCurveCreator,   "CURVE_CREATOR" );
990 #endif
991   createGeomAction( GEOMOp::OpFillet1d,       "FILLET_1D" );
992   createGeomAction( GEOMOp::OpFillet2d,       "FILLET_2D" );
993
994   createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
995   createGeomAction( GEOMOp::OpExplodeBlock,   "EXPLODE_BLOCKS" );
996   createGeomAction( GEOMOp::OpPropagate,      "PROPAGATE" );
997
998   createGeomAction( GEOMOp::OpSewing,           "SEWING" );
999   createGeomAction( GEOMOp::OpGlueFaces,        "GLUE_FACES" );
1000   createGeomAction( GEOMOp::OpGlueEdges,        "GLUE_EDGES" );
1001   createGeomAction( GEOMOp::OpLimitTolerance,   "LIMIT_TOLERANCE" );
1002   createGeomAction( GEOMOp::OpSuppressFaces,    "SUPPRESS_FACES" );
1003   createGeomAction( GEOMOp::OpSuppressHoles,    "SUPPERSS_HOLES" );
1004   createGeomAction( GEOMOp::OpShapeProcess,     "SHAPE_PROCESS" );
1005   createGeomAction( GEOMOp::OpCloseContour,     "CLOSE_CONTOUR" );
1006   createGeomAction( GEOMOp::OpRemoveIntWires,   "SUPPRESS_INT_WIRES" );
1007   createGeomAction( GEOMOp::OpAddPointOnEdge,   "POINT_ON_EDGE" );
1008   createGeomAction( GEOMOp::OpFreeBoundaries,   "CHECK_FREE_BNDS" );
1009   createGeomAction( GEOMOp::OpFreeFaces,        "CHECK_FREE_FACES" );
1010   createGeomAction( GEOMOp::OpOrientation,      "CHANGE_ORIENTATION" );
1011   createGeomAction( GEOMOp::OpRemoveWebs,       "REMOVE_WEBS" );
1012   createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
1013   createGeomAction( GEOMOp::OpFuseEdges,        "FUSE_EDGES" );
1014   createGeomAction( GEOMOp::OpUnionFaces,       "UNION_FACES" );
1015
1016   createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
1017   createGeomAction( GEOMOp::OpProperties,       "BASIC_PROPS" );
1018   createGeomAction( GEOMOp::OpCenterMass,       "MASS_CENTER" );
1019   createGeomAction( GEOMOp::OpInertia,          "INERTIA" );
1020   createGeomAction( GEOMOp::OpNormale,          "NORMALE" );
1021   createGeomAction( GEOMOp::OpBoundingBox,      "BND_BOX" );
1022   createGeomAction( GEOMOp::OpMinDistance,      "MIN_DIST" );
1023   createGeomAction( GEOMOp::OpAngle,            "MEASURE_ANGLE" );
1024   createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
1025
1026   createGeomAction( GEOMOp::OpTolerance,        "TOLERANCE" );
1027   createGeomAction( GEOMOp::OpWhatIs,           "WHAT_IS" );
1028   createGeomAction( GEOMOp::OpCheckShape,       "CHECK" );
1029   createGeomAction( GEOMOp::OpCheckCompound,    "CHECK_COMPOUND" );
1030   createGeomAction( GEOMOp::OpGetNonBlocks,     "GET_NON_BLOCKS" );
1031   createGeomAction( GEOMOp::OpCheckSelfInters,  "CHECK_SELF_INTERSECTIONS" );
1032
1033 #ifdef _DEBUG_ // PAL16821
1034   createGeomAction( GEOMOp::OpCheckGeom,        "CHECK_GEOMETRY" );
1035 #endif
1036
1037   createGeomAction( GEOMOp::OpMaterialsLibrary,   "MATERIALS_LIBRARY" );
1038   createGeomAction( GEOMOp::OpDMWireframe,        "WIREFRAME" );
1039   createGeomAction( GEOMOp::OpDMShading,          "SHADING" );
1040   createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
1041   createGeomAction( GEOMOp::OpDMTexture,          "TEXTURE" );
1042   createGeomAction( GEOMOp::OpShowAll,          "DISPLAY_ALL" );
1043   createGeomAction( GEOMOp::OpHideAll,          "ERASE_ALL" );
1044   createGeomAction( GEOMOp::OpShow,             "DISPLAY" );
1045   createGeomAction( GEOMOp::OpSwitchVectors,    "VECTOR_MODE");
1046   createGeomAction( GEOMOp::OpSelectVertex,     "VERTEX_SEL_ONLY" ,"", 0, true );
1047   createGeomAction( GEOMOp::OpSelectEdge,       "EDGE_SEL_ONLY", "", 0, true );
1048   createGeomAction( GEOMOp::OpSelectWire,       "WIRE_SEL_ONLY", "",  0, true );
1049   createGeomAction( GEOMOp::OpSelectFace,       "FACE_SEL_ONLY", "", 0, true );
1050   createGeomAction( GEOMOp::OpSelectShell,      "SHELL_SEL_ONLY", "",  0, true );
1051   createGeomAction( GEOMOp::OpSelectSolid,      "SOLID_SEL_ONLY", "", 0, true );
1052   createGeomAction( GEOMOp::OpSelectCompound,   "COMPOUND_SEL_ONLY", "",  0, true );
1053   createGeomAction( GEOMOp::OpSelectAll,        "ALL_SEL_ONLY", "",  0, true );
1054   createGeomAction( GEOMOp::OpShowOnly,         "DISPLAY_ONLY" );
1055   createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
1056   createGeomAction( GEOMOp::OpBringToFront,     "BRING_TO_FRONT", "", 0, true );
1057   createGeomAction( GEOMOp::OpClsBringToFront,  "CLS_BRING_TO_FRONT" );
1058   createGeomAction( GEOMOp::OpHide,             "ERASE" );
1059
1060   createGeomAction( GEOMOp::OpWireframe,        "POP_WIREFRAME", "", 0, true );
1061   createGeomAction( GEOMOp::OpShading,          "POP_SHADING", "", 0, true );
1062   createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
1063   createGeomAction( GEOMOp::OpTexture,          "POP_TEXTURE", "", 0, true );
1064   createGeomAction( GEOMOp::OpEdgeWidth,        "EDGE_WIDTH");
1065   createGeomAction( GEOMOp::OpIsosWidth,        "ISOS_WIDTH");
1066   createGeomAction( GEOMOp::OpVectors,          "POP_VECTORS", "", 0, true );
1067   createGeomAction( GEOMOp::OpDeflection,       "POP_DEFLECTION" );
1068   createGeomAction( GEOMOp::OpColor,            "POP_COLOR" );
1069   createGeomAction( GEOMOp::OpSetTexture,       "POP_SETTEXTURE" );
1070   createGeomAction( GEOMOp::OpTransparency,     "POP_TRANSPARENCY" );
1071   createGeomAction( GEOMOp::OpIsos,             "POP_ISOS" );
1072   createGeomAction( GEOMOp::OpAutoColor,        "POP_AUTO_COLOR" );
1073   createGeomAction( GEOMOp::OpNoAutoColor,      "POP_DISABLE_AUTO_COLOR" );
1074   createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
1075   createGeomAction( GEOMOp::OpEditFieldPopup,   "POP_EDIT_FIELD" );
1076   createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
1077   createGeomAction( GEOMOp::OpConcealChildren,  "POP_CONCEAL_CHILDREN" );
1078   createGeomAction( GEOMOp::OpUnpublishObject,  "POP_UNPUBLISH_OBJ" );
1079   createGeomAction( GEOMOp::OpPublishObject,    "POP_PUBLISH_OBJ" );
1080   createGeomAction( GEOMOp::OpPointMarker,      "POP_POINT_MARKER" );
1081   createGeomAction( GEOMOp::OpMaterialProperties,   "POP_MATERIAL_PROPERTIES" );
1082   createGeomAction( GEOMOp::OpPredefMaterCustom,    "POP_PREDEF_MATER_CUSTOM" );
1083   createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
1084   createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
1085   createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
1086   createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
1087   createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
1088
1089   // Create actions for increase/decrease transparency shortcuts
1090   createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
1091                     "Geometry:Increase transparency");
1092   createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
1093                     "Geometry:Decrease transparency");
1094
1095   // Create actions for increase/decrease number of isolines
1096   createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
1097                     "Geometry:Increase number of isolines");
1098   createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
1099                     "Geometry:Decrease number of isolines");
1100
1101   // Import/Export XAO
1102   createGeomAction( GEOMOp::OpExportXAO, "EXPORTXAO" );
1103   createGeomAction( GEOMOp::OpImportXAO, "IMPORTXAO" );
1104
1105   //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
1106   //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
1107   //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
1108   //createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
1109   //@@ 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 @@//
1110
1111   // ---- create menus --------------------------
1112
1113   int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
1114   createMenu( separator(),      fileId, 10 );
1115   createMenu( GEOMOp::OpImport, fileId, 10 );
1116   createMenu( GEOMOp::OpExport, fileId, 10 );
1117   int impexpId = createMenu( tr( "MEN_IMPORTEXPORT" ), fileId, -1, 10 );
1118   createMenu( GEOMOp::OpExportXAO, impexpId, -1 );
1119   createMenu( GEOMOp::OpImportXAO, impexpId, -1 );
1120   createMenu( separator(),      fileId, -1 );
1121
1122   int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
1123   createMenu( GEOMOp::OpDelete, editId, -1 );
1124
1125   int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
1126
1127   int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
1128   createMenu( GEOMOp::OpPoint,   basicId, -1 );
1129   createMenu( GEOMOp::OpLine,    basicId, -1 );
1130   createMenu( GEOMOp::OpCircle,  basicId, -1 );
1131   createMenu( GEOMOp::OpEllipse, basicId, -1 );
1132   createMenu( GEOMOp::OpArc,     basicId, -1 );
1133   createMenu( GEOMOp::OpCurve,   basicId, -1 );
1134   createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
1135   createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
1136   createMenu( GEOMOp::OpIsoline, basicId, -1 );
1137   createMenu( separator(),       basicId, -1 );
1138   createMenu( GEOMOp::OpVector,  basicId, -1 );
1139   createMenu( GEOMOp::OpPlane,   basicId, -1 );
1140   createMenu( GEOMOp::OpLCS,     basicId, -1 );
1141   createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
1142
1143   int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
1144   createMenu( GEOMOp::OpBox,       primId, -1 );
1145   createMenu( GEOMOp::OpCylinder,  primId, -1 );
1146   createMenu( GEOMOp::OpSphere,    primId, -1 );
1147   createMenu( GEOMOp::OpTorus,     primId, -1 );
1148   createMenu( GEOMOp::OpCone,      primId, -1 );
1149   createMenu( GEOMOp::OpRectangle, primId, -1 );
1150   createMenu( GEOMOp::OpDisk,      primId, -1 );
1151   //createMenu( GEOMOp::OpPipeTShape,primId, -1 );
1152
1153   int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
1154   createMenu( GEOMOp::OpPrism,      genId, -1 );
1155   createMenu( GEOMOp::OpRevolution, genId, -1 );
1156   createMenu( GEOMOp::OpFilling,    genId, -1 );
1157   createMenu( GEOMOp::OpPipe,       genId, -1 );
1158 #if OCC_VERSION_LARGE > 0x06050300
1159   createMenu( GEOMOp::OpPipePath,   genId, -1 );
1160 #endif
1161
1162   //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
1163   //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
1164   //@@ 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 @@//
1165
1166   createMenu( separator(), newEntId, -1 );
1167
1168   int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
1169   createMenu( GEOMOp::OpGroupCreate,    groupId, -1 );
1170   createMenu( GEOMOp::OpGroupEdit,      groupId, -1 );
1171   createMenu( GEOMOp::OpGroupUnion,     groupId, -1 );
1172   createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
1173   createMenu( GEOMOp::OpGroupCut,       groupId, -1 );
1174
1175   createMenu( separator(), newEntId, -1 );
1176
1177   int fieldId = createMenu( tr( "MEN_FIELD" ), newEntId, -1 );
1178   createMenu( GEOMOp::OpCreateField,    fieldId, -1 );
1179   createMenu( GEOMOp::OpEditField,      fieldId, -1 );
1180
1181   createMenu( separator(), newEntId, -1 );
1182
1183   int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
1184   createMenu( GEOMOp::OpQuadFace,        blocksId, -1 );
1185   createMenu( GEOMOp::OpHexaSolid,       blocksId, -1 );
1186   //createMenu( GEOMOp::OpDividedDisk,     blocksId, -1 );
1187   //createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
1188
1189   createMenu( separator(),          newEntId, -1 );
1190
1191   createMenu( GEOMOp::OpExplode,    newEntId, -1 );
1192
1193   int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
1194   createMenu( GEOMOp::OpEdge,     buildId, -1 );
1195   createMenu( GEOMOp::OpWire,     buildId, -1 );
1196   createMenu( GEOMOp::OpFace,     buildId, -1 );
1197   createMenu( GEOMOp::OpShell,    buildId, -1 );
1198   createMenu( GEOMOp::OpSolid,    buildId, -1 );
1199   createMenu( GEOMOp::OpCompound, buildId, -1 );
1200
1201   createMenu( separator(),          newEntId, -1 );
1202
1203   createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1204 #ifdef WITH_OPENCV
1205   createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1206 #endif
1207
1208   int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1209
1210   int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1211   createMenu( GEOMOp::OpFuse,    boolId, -1 );
1212   createMenu( GEOMOp::OpCommon,  boolId, -1 );
1213   createMenu( GEOMOp::OpCut,     boolId, -1 );
1214   createMenu( GEOMOp::OpSection, boolId, -1 );
1215
1216   int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1217   createMenu( GEOMOp::OpTranslate,      transId, -1 );
1218   createMenu( GEOMOp::OpRotate,         transId, -1 );
1219   createMenu( GEOMOp::OpChangeLoc,      transId, -1 );
1220   createMenu( GEOMOp::OpMirror,         transId, -1 );
1221   createMenu( GEOMOp::OpScale,          transId, -1 );
1222   createMenu( GEOMOp::OpOffset,         transId, -1 );
1223   createMenu( GEOMOp::OpProjection,     transId, -1 );
1224   createMenu( separator(),              transId, -1 );
1225   createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1226   createMenu( GEOMOp::OpMultiRotate,    transId, -1 );
1227
1228   int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1229   createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1230   createMenu( GEOMOp::OpExplodeBlock,   blockId, -1 );
1231   createMenu( GEOMOp::OpPropagate,      blockId, -1 );
1232
1233   createMenu( separator(), operId, -1 );
1234
1235   createMenu( GEOMOp::OpPartition,     operId, -1 );
1236   createMenu( GEOMOp::OpArchimede,     operId, -1 );
1237   createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1238   createMenu( GEOMOp::OpSharedShapes,  operId, -1 );
1239
1240   createMenu( separator(), operId, -1 );
1241
1242   createMenu( GEOMOp::OpFillet1d,      operId, -1 );
1243   createMenu( GEOMOp::OpFillet2d,      operId, -1 );
1244   createMenu( GEOMOp::OpFillet3d,      operId, -1 );
1245   createMenu( GEOMOp::OpChamfer,       operId, -1 );
1246   createMenu( GEOMOp::OpExtrudedBoss,  operId, -1 );
1247   createMenu( GEOMOp::OpExtrudedCut,   operId, -1 );
1248 #ifdef DEBUG_CURVE_CREATOR
1249   // for debug purposes, to be removed
1250   createMenu( separator(), operId, -1 );
1251   createMenu( GEOMOp::OpCurveCreator,   operId, -1 );
1252 #endif
1253   //createMenu( GEOMOp::OpClipping,      operId, -1 );
1254
1255   int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1256   createMenu( GEOMOp::OpShapeProcess,    repairId, -1 );
1257   createMenu( GEOMOp::OpSuppressFaces,   repairId, -1 );
1258   createMenu( GEOMOp::OpCloseContour,    repairId, -1 );
1259   createMenu( GEOMOp::OpRemoveIntWires,  repairId, -1 );
1260   createMenu( GEOMOp::OpSuppressHoles,   repairId, -1 );
1261   createMenu( GEOMOp::OpSewing,          repairId, -1 );
1262   createMenu( GEOMOp::OpGlueFaces,       repairId, -1 );
1263   createMenu( GEOMOp::OpGlueEdges,       repairId, -1 );
1264   createMenu( GEOMOp::OpLimitTolerance,  repairId, -1 );
1265   createMenu( GEOMOp::OpAddPointOnEdge,  repairId, -1 );
1266   //createMenu( GEOMOp::OpFreeBoundaries,  repairId, -1 );
1267   //createMenu( GEOMOp::OpFreeFaces,       repairId, -1 );
1268   createMenu( GEOMOp::OpOrientation,      repairId, -1 );
1269   createMenu( GEOMOp::OpRemoveWebs,       repairId, -1 );
1270   createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1271   createMenu( GEOMOp::OpFuseEdges,        repairId, -1 );
1272   createMenu( GEOMOp::OpUnionFaces,       repairId, -1 );
1273
1274   int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1275   createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1276   createMenu( GEOMOp::OpProperties,       measurId, -1 );
1277   createMenu( separator(),                measurId, -1 );
1278   createMenu( GEOMOp::OpCenterMass,       measurId, -1 );
1279   createMenu( GEOMOp::OpInertia,          measurId, -1 );
1280   createMenu( GEOMOp::OpNormale,          measurId, -1 );
1281   createMenu( separator(),                measurId, -1 );
1282   createMenu( GEOMOp::OpFreeBoundaries,   measurId, -1 );
1283   createMenu( GEOMOp::OpFreeFaces,        measurId, -1 );
1284   createMenu( separator(),                measurId, -1 );
1285
1286   int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1287   createMenu( GEOMOp::OpBoundingBox,      dimId, -1 );
1288   createMenu( GEOMOp::OpMinDistance,      dimId, -1 );
1289   createMenu( GEOMOp::OpAngle,            dimId, -1 );
1290   createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
1291
1292   createMenu( separator(),               measurId, -1 );
1293   createMenu( GEOMOp::OpTolerance,       measurId, -1 );
1294   createMenu( separator(),               measurId, -1 );
1295   createMenu( GEOMOp::OpWhatIs,          measurId, -1 );
1296   createMenu( GEOMOp::OpCheckShape,      measurId, -1 );
1297   createMenu( GEOMOp::OpCheckCompound,   measurId, -1 );
1298   createMenu( GEOMOp::OpGetNonBlocks,    measurId, -1 );
1299   createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1300
1301   int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1302 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1303   createMenu( separator(),         toolsId, -1 );
1304   createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1305 #endif
1306
1307   createMenu( separator(),         toolsId, -1 );
1308   createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1309   createMenu( separator(),         toolsId, -1 );
1310
1311   int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1312   createMenu( separator(),       viewId, -1 );
1313
1314   int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1315   createMenu( GEOMOp::OpDMWireframe,        dispmodeId, -1 );
1316   createMenu( GEOMOp::OpDMShading,          dispmodeId, -1 );
1317   createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1318   createMenu( GEOMOp::OpDMTexture,          dispmodeId, -1 );
1319   createMenu( separator(),                  dispmodeId, -1 );
1320   createMenu( GEOMOp::OpSwitchVectors,      dispmodeId, -1 );
1321
1322   createMenu( separator(),       viewId, -1 );
1323   createMenu( GEOMOp::OpShowAll, viewId, -1 );
1324   createMenu( GEOMOp::OpHideAll, viewId, -1 );
1325   createMenu( separator(),       viewId, -1 );
1326   createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1327   createMenu( separator(),       viewId, -1 );
1328
1329 /*
1330   PAL9111:
1331   because of these items are accessible through object browser and viewers
1332   we have removed they from main menu
1333
1334   createMenu( GEOMOp::OpShow, viewId, -1 );
1335   createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1336   createMenu( GEOMOp::OpHide, viewId, -1 );
1337 */
1338
1339   // ---- create toolbars --------------------------
1340
1341   int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1342   createTool( GEOMOp::OpPoint,      basicTbId );
1343   createTool( GEOMOp::OpLine,       basicTbId );
1344   createTool( GEOMOp::OpCircle,     basicTbId );
1345   createTool( GEOMOp::OpEllipse,    basicTbId );
1346   createTool( GEOMOp::OpArc,        basicTbId );
1347   createTool( GEOMOp::OpCurve,      basicTbId );
1348   createTool( GEOMOp::OpVector,     basicTbId );
1349   createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1350   createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1351   createTool( GEOMOp::OpIsoline,    basicTbId );
1352   createTool( GEOMOp::OpPlane,      basicTbId );
1353   createTool( GEOMOp::OpLCS,        basicTbId );
1354   createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1355
1356 //   int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
1357 //   createTool( GEOMOp::Op2dSketcher,  sketchTbId );
1358 //   createTool( GEOMOp::Op3dSketcher,  sketchTbId );
1359
1360   int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1361   createTool( GEOMOp::OpBox,        primTbId );
1362   createTool( GEOMOp::OpCylinder,   primTbId );
1363   createTool( GEOMOp::OpSphere,     primTbId );
1364   createTool( GEOMOp::OpTorus,      primTbId );
1365   createTool( GEOMOp::OpCone,       primTbId );
1366   createTool( GEOMOp::OpRectangle,  primTbId );
1367   createTool( GEOMOp::OpDisk,       primTbId );
1368   //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1369
1370   //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) );
1371   //createTool( GEOMOp::OpDividedDisk, blocksTbId );
1372   //createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1373
1374   int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1375   createTool( GEOMOp::OpFuse,       boolTbId );
1376   createTool( GEOMOp::OpCommon,     boolTbId );
1377   createTool( GEOMOp::OpCut,        boolTbId );
1378   createTool( GEOMOp::OpSection,    boolTbId );
1379
1380   int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1381   createTool( GEOMOp::OpPrism,      genTbId );
1382   createTool( GEOMOp::OpRevolution, genTbId );
1383   createTool( GEOMOp::OpFilling,    genTbId );
1384   createTool( GEOMOp::OpPipe,       genTbId );
1385 #if OCC_VERSION_LARGE > 0x06050300
1386   createTool( GEOMOp::OpPipePath,   genTbId );
1387 #endif
1388
1389   int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1390   createTool( GEOMOp::OpTranslate,      transTbId );
1391   createTool( GEOMOp::OpRotate,         transTbId );
1392   createTool( GEOMOp::OpChangeLoc,      transTbId );
1393   createTool( GEOMOp::OpMirror,         transTbId );
1394   createTool( GEOMOp::OpScale,          transTbId );
1395   createTool( GEOMOp::OpOffset,         transTbId );
1396   createTool( GEOMOp::OpProjection,     transTbId );
1397   createTool( separator(),              transTbId );
1398   createTool( GEOMOp::OpMultiTranslate, transTbId );
1399   createTool( GEOMOp::OpMultiRotate,    transTbId );
1400
1401   int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1402   createTool( GEOMOp::OpExplode,         operTbId );
1403   createTool( GEOMOp::OpPartition,       operTbId );
1404   createTool( GEOMOp::OpArchimede,       operTbId );
1405   createTool( GEOMOp::OpShapesOnShape,   operTbId );
1406   createTool( GEOMOp::OpSharedShapes,    operTbId );
1407
1408   int featTbId = createTool( tr( "TOOL_FEATURES" ) );
1409   createTool( GEOMOp::OpFillet1d,        featTbId );
1410   createTool( GEOMOp::OpFillet2d,        featTbId );
1411   createTool( GEOMOp::OpFillet3d,        featTbId );
1412   createTool( GEOMOp::OpChamfer,         featTbId );
1413   createTool( GEOMOp::OpExtrudedBoss,    featTbId );
1414   createTool( GEOMOp::OpExtrudedCut,     featTbId );
1415 #ifdef DEBUG_CURVE_CREATOR
1416   // for debug purposes, to be removed
1417   createTool( GEOMOp::OpCurveCreator,    featTbId ); 
1418 #endif
1419
1420   int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1421   createTool( GEOMOp::OpEdge,     buildTbId );
1422   createTool( GEOMOp::OpWire,     buildTbId );
1423   createTool( GEOMOp::OpFace,     buildTbId );
1424   createTool( GEOMOp::OpShell,    buildTbId );
1425   createTool( GEOMOp::OpSolid,    buildTbId );
1426   createTool( GEOMOp::OpCompound, buildTbId );
1427
1428   int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1429   createTool( GEOMOp::OpPointCoordinates, measureTbId );
1430   createTool( GEOMOp::OpProperties,       measureTbId );
1431   createTool( GEOMOp::OpCenterMass,       measureTbId );
1432   createTool( GEOMOp::OpInertia,          measureTbId );
1433   createTool( GEOMOp::OpNormale,          measureTbId );
1434   createTool( separator(),                measureTbId );
1435   createTool( GEOMOp::OpBoundingBox,      measureTbId );
1436   createTool( GEOMOp::OpMinDistance,      measureTbId );
1437   createTool( GEOMOp::OpAngle,            measureTbId );
1438   createTool( GEOMOp::OpTolerance  ,      measureTbId );
1439   createTool( separator(),                measureTbId );
1440   createTool( GEOMOp::OpFreeBoundaries,   measureTbId );
1441   createTool( GEOMOp::OpFreeFaces,        measureTbId );
1442   createTool( separator(),                measureTbId );
1443   createTool( GEOMOp::OpWhatIs,           measureTbId );
1444   createTool( GEOMOp::OpCheckShape,       measureTbId );
1445   createTool( GEOMOp::OpCheckCompound,    measureTbId );
1446   createTool( GEOMOp::OpGetNonBlocks,     measureTbId );
1447   createTool( GEOMOp::OpCheckSelfInters,  measureTbId );
1448
1449   int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
1450   createTool( GEOMOp::OpPictureImport,    picturesTbId );
1451 #ifdef WITH_OPENCV
1452   createTool( GEOMOp::OpFeatureDetect,  picturesTbId );
1453 #endif
1454
1455    int impexpTbId = createTool( tr( "TOOL_IMPORTEXPORT" ) );
1456    createTool( GEOMOp::OpExportXAO, impexpTbId );
1457    createTool( GEOMOp::OpImportXAO, impexpTbId );
1458
1459   //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1460   //createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1461   //@@ 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 @@//
1462
1463   // ---- create popup menus --------------------------
1464
1465   QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1466   QString clientOCC = "(client='OCCViewer')";
1467   QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1468   QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1469
1470   QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1471   QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1472   QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1473   QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1474
1475   QString autoColorPrefix =
1476     "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1477
1478   QtxPopupMgr* mgr = popupMgr();
1479
1480   mgr->insert( action(  GEOMOp::OpDelete ), -1, -1 );  // delete
1481   mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1482   mgr->insert( action(  GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1483   mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1484   mgr->insert( action(  GEOMOp::OpEditFieldPopup ), -1, -1 ); // edit field
1485   mgr->setRule( action( GEOMOp::OpEditFieldPopup ), QString("(type='Field' or type='FieldStep') and isOCC=true"), QtxPopupMgr::VisibleRule );
1486   mgr->insert( action(  GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1487   mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1488
1489   mgr->insert( action(  GEOMOp::OpConcealChildren ), -1, -1 ); // conceal child items
1490   mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1491   mgr->insert( action(  GEOMOp::OpGroupEdit ), -1, -1 );  // edit group
1492   mgr->setRule( action( GEOMOp::OpGroupEdit ),  QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1493   mgr->insert( separator(), -1, -1 );     // -----------
1494
1495 #if OCC_VERSION_LARGE > 0x06050200
1496   //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1497   QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and isFolder=false and (selcount>0) and isOCC=true";
1498   mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1499   mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1500   mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1501   mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1502   mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1503 #endif
1504   mgr->insert( separator(), -1, -1 );     // -----------
1505   dispmodeId = mgr->insert(  tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1506   mgr->insert( action(  GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1507   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1508   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1509   mgr->insert( action(  GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1510   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1511   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1512   mgr->insert( action(  GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1513   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1514   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1515   mgr->insert( action(  GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1516   mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1517   mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1518   mgr->insert( separator(), dispmodeId, -1 );
1519   mgr->insert( action(  GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1520   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible  + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1521   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1522   mgr->insert( separator(), -1, -1 );     // -----------
1523
1524   mgr->insert( action(  GEOMOp::OpColor ), -1, -1 ); // color
1525   mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1526   mgr->insert( action(  GEOMOp::OpTransparency ), -1, -1 ); // transparency
1527   mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1528   mgr->insert( action(  GEOMOp::OpIsos ), -1, -1 ); // isos
1529   mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1530   mgr->insert( action(  GEOMOp::OpDeflection ), -1, -1 ); // deflection
1531   mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1532   mgr->insert( action(  GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1533   //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1534   mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1535
1536   // material properties
1537   mgr->insert( action(  GEOMOp::OpMaterialProperties ), -1, -1 );
1538   mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1539
1540  // texture
1541   mgr->insert( action(  GEOMOp::OpSetTexture ), -1, -1 );
1542   mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1543
1544   int lineW = mgr->insert(  tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1545   mgr->insert( action(  GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1546   mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1547
1548   mgr->insert( action(  GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1549   mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1550
1551   mgr->insert( separator(), -1, -1 );     // -----------
1552   mgr->insert( action(  GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1553   mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1554   mgr->insert( action(  GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1555   mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1556   mgr->insert( separator(), -1, -1 );     // -----------
1557
1558   QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1559           onlyComponent = "((type='Component') and selcount=1)",
1560           rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1561           types = "'Shape' 'Group' 'FieldStep'";
1562
1563   mgr->insert( action(  GEOMOp::OpShow ), -1, -1 ); // display
1564   mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1565
1566   mgr->insert( action(  GEOMOp::OpHide ), -1, -1 ); // erase
1567   mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1568
1569   mgr->insert( action(  GEOMOp::OpHideAll ), -1, -1 ); // erase All
1570   mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1571
1572   QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1573
1574   int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1);                //select only menu
1575   mgr->insert( action(GEOMOp::OpSelectVertex),   selectonlyId, -1);                                  //Vertex
1576   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly, QtxPopupMgr::VisibleRule);
1577   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1578   mgr->insert( action(GEOMOp::OpSelectEdge),     selectonlyId, -1);                                  //Edge
1579   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly, QtxPopupMgr::VisibleRule);
1580   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1581   mgr->insert( action(GEOMOp::OpSelectWire),     selectonlyId, -1);                                  //Wire
1582   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly, QtxPopupMgr::VisibleRule);
1583   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1584   mgr->insert( action(GEOMOp::OpSelectFace),     selectonlyId, -1);                                  //Face
1585   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly, QtxPopupMgr::VisibleRule);
1586   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1587   mgr->insert( action(GEOMOp::OpSelectShell),    selectonlyId, -1);                                  //Shell
1588   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly, QtxPopupMgr::VisibleRule);
1589   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1590   mgr->insert( action(GEOMOp::OpSelectSolid),    selectonlyId, -1);                                  //Solid
1591   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly, QtxPopupMgr::VisibleRule);
1592   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1593   mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1);                                  //Compound
1594   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1595   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1596   mgr->insert( separator(), selectonlyId, -1);
1597   mgr->insert( action(GEOMOp::OpSelectAll),      selectonlyId, -1);                                  //Clear selection filter
1598   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly, QtxPopupMgr::VisibleRule);
1599   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1600   mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1601   mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1602   mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1603   mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1604
1605   QString aDimensionRule = "($component={'GEOM'}) and selcount=1 and isVisible and type='Shape' and %1";
1606
1607   mgr->insert( separator(), -1, -1 ); // -----------
1608   mgr->insert( action( GEOMOp::OpShowAllDimensions ), -1, -1 ); // show all dimensions
1609   mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
1610   mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
1611   mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
1612
1613   mgr->insert( separator(), -1, -1 );     // -----------
1614   mgr->insert( action(  GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1615   mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1616
1617   mgr->insert( action(  GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1618   mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1619
1620   mgr->insert( action(  GEOMOp::OpReimport ), -1, -1 );  // delete
1621   mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1622
1623   mgr->insert( separator(), -1, -1 );     // -----------
1624   mgr->insert( action(  GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
1625   mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and $component={'GEOM'} and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
1626
1627   mgr->insert( separator(), -1, -1 );     // -----------
1628   mgr->insert( action(  GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
1629   mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
1630
1631   mgr->insert( separator(), -1, -1 );     // -----------
1632   mgr->insert( action(  GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree
1633   mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1634
1635   mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1636
1637   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1638   if (resMgr) {
1639     GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1640     QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1641     GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1642   }
1643
1644   // create plugin actions and menus
1645   addPluginActions();
1646 }
1647
1648 //=======================================================================
1649 // function : GeometryGUI::addPluginActions()
1650 // purpose  :
1651 //=======================================================================
1652 void GeometryGUI::addPluginActions()
1653 {
1654   // Resource manager
1655   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1656   if (!resMgr) return;
1657
1658   // Find names of a resource XML files ("GEOMActions.xml" and others);
1659   QString PluginsXml;
1660   char* cenv = getenv("GEOM_PluginsList");
1661   if (cenv)
1662     PluginsXml.sprintf("%s", cenv);
1663
1664   QStringList PluginsXmlList = PluginsXml.split(":", QString::SkipEmptyParts);
1665   if (PluginsXmlList.count() == 0) return;
1666
1667   // get full names of xml files from PluginsXmlList
1668   QStringList xmlFiles;
1669   xmlFiles.append(QDir::home().filePath("CustomGeomPlugins.xml")); // may be inexistent
1670   for (int i = 0; i < PluginsXmlList.count(); i++) {
1671     PluginsXml = PluginsXmlList[ i ];
1672
1673     // Find full path to the resource XML file
1674     QString xmlFile = resMgr->path("resources", "GEOM", PluginsXml + ".xml");
1675     if ( xmlFile.isEmpty() ) // try PLUGIN resources
1676       xmlFile = resMgr->path("resources", PluginsXml, PluginsXml + ".xml");
1677     if ( !xmlFile.isEmpty() )
1678       xmlFiles.append( xmlFile );
1679   }
1680
1681   // create "Advanced Operations" menu and corresponding toolbar
1682   //int advancedMenuId = createMenu(tr("MEN_ADVANCED"), -1, -1, 10);
1683   //int advancedTbarId = createTool(tr("TOOL_ADVANCED"));
1684   int id = GEOMOp::OpLastOperationID; // TODO?
1685
1686   // loop on xmlFiles
1687   QString aNoAccessFiles;
1688   for (int i = 0; i < xmlFiles.count(); i++) {
1689     QString xmlFile = xmlFiles[ i ];
1690
1691     QFile file (xmlFile);
1692     if (file.exists() && file.open(QIODevice::ReadOnly)) {
1693       file.close();
1694
1695       GEOMGUI_XmlHandler* aXmlHandler = new GEOMGUI_XmlHandler();
1696       ASSERT(aXmlHandler);
1697
1698       QXmlInputSource source (&file);
1699       QXmlSimpleReader reader;
1700       reader.setContentHandler(aXmlHandler);
1701       reader.setErrorHandler(aXmlHandler);
1702       bool ok = reader.parse(source);
1703       file.close();
1704
1705       if (ok) {
1706         // bind action lib and label to its ID for activateOperation() method proper work
1707         myPluginLibs[aXmlHandler->myPluginData.myName] = aXmlHandler->myPluginData.myClientLib;
1708
1709         QListIterator<GEOMGUI_ActionData> anActionsIter (aXmlHandler->myPluginData.myListOfActions);
1710         while (anActionsIter.hasNext()) {
1711           GEOMGUI_ActionData anActionData = anActionsIter.next();
1712
1713           //QPixmap icon = resMgr->loadPixmap("GEOM", tr(anActionData.myIcon.toLatin1().constData()));
1714           QPixmap icon = resMgr->loadPixmap(aXmlHandler->myPluginData.myName,
1715                                             anActionData.myIcon.toLatin1().constData());
1716
1717           // path to action in menu
1718           QStringList smenus = anActionData.myMenu.split( "/" );
1719           QString actionName = smenus.last();
1720           actionName = actionName.toUpper().prepend("MEN_");
1721           smenus.removeLast();
1722
1723           // path to action in toolbar
1724           QStringList stools = anActionData.myTooltip.split( "/" );
1725           QString actionTool = stools.last();
1726           actionTool = actionTool.toUpper().prepend("TOP_");
1727           stools.removeLast();
1728
1729           QString actionStat = anActionData.myStatusBar;
1730           actionStat = actionStat.toUpper().prepend("STB_");
1731
1732           createAction(id, // ~ anActionData.myLabel
1733                        tr(actionTool.toLatin1().constData()),
1734                        icon,
1735                        tr(actionName.toLatin1().constData()),
1736                        tr(actionStat.toLatin1().constData()),
1737                        0 /*accel*/,
1738                        application()->desktop(),
1739                        false /*toggle*/,
1740                        this, SLOT(OnGUIEvent()),
1741                        QString() /*shortcutAction*/);
1742
1743           int menuId = -1;
1744           foreach (QString subMenu, smenus) {
1745             subMenu = subMenu.toUpper().prepend("MEN_");
1746             menuId = createMenu(tr(subMenu.toLatin1().constData()), menuId, -1);
1747           }
1748           //createMenu(id, pluginMenuId, -1);
1749           createMenu(id, menuId, -1);
1750
1751           QString subTool = stools[0];
1752           subTool = subTool.toUpper().prepend("TOOL_");
1753           int toolId = createTool(tr(subTool.toLatin1().constData()));
1754           //createTool(id, advancedTbarId);
1755           createTool(id, toolId);
1756
1757           // add action id to map
1758           PluginAction anAction (aXmlHandler->myPluginData.myClientLib, anActionData.myLabel);
1759           myPluginActions[id] = anAction;
1760
1761           id++;
1762         }
1763       }
1764       else {
1765         SUIT_MessageBox::critical(application()->desktop(),
1766                                   tr("INF_PARSE_ERROR"),
1767                                   tr(aXmlHandler->errorProtocol().toLatin1().data()));
1768       }
1769       delete aXmlHandler;
1770     }
1771     else if ( i > 0 ) { // 1st is ~/CustomGeomPlugins.xml
1772       if (aNoAccessFiles.isEmpty())
1773         aNoAccessFiles = xmlFile;
1774       else
1775         aNoAccessFiles += ", " + xmlFile;
1776     }
1777   } // end loop on xmlFiles
1778
1779   if (!aNoAccessFiles.isEmpty()) {
1780     QString aMess = QObject::tr("PLUGIN_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n";
1781     aMess += QObject::tr("PLUGIN_FILE_CHECK_VARIABLE");
1782     SUIT_MessageBox::warning(application()->desktop(), tr("GEOM_WRN_WARNING"), aMess);
1783   }
1784 }
1785
1786 //=======================================================================
1787 // function : GeometryGUI::activateModule()
1788 // purpose  : Called when GEOM module is activated
1789 //=======================================================================
1790 bool GeometryGUI::activateModule( SUIT_Study* study )
1791 {
1792   if ( CORBA::is_nil( myComponentGeom ) )
1793     return false;
1794
1795   bool res = SalomeApp_Module::activateModule( study );
1796
1797   if ( !res )
1798     return false;
1799   setMenuShown( true );
1800   setToolShown( true );
1801
1802   // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1803   PyGILState_STATE gstate = PyGILState_Ensure();
1804   PyObjWrapper pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1805   if ( !pluginsmanager ) {
1806     PyErr_Print();
1807   }
1808   else {
1809     PyObjWrapper result =
1810       PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1811                           tr("MEN_NEW_ENTITY").toStdString().c_str(),
1812                           tr("GEOM_PLUGINS_OTHER").toStdString().c_str());
1813     if ( !result )
1814       PyErr_Print();
1815   }
1816   PyGILState_Release(gstate);
1817   // end of GEOM plugins loading
1818
1819   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1820           this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1821
1822   // Reset actions accelerator keys
1823   action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1824   action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1825   action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1826
1827   GUIMap::Iterator it;
1828   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1829     it.value()->activate( application()->desktop() );
1830
1831   LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1832
1833   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1834   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ));
1835   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
1836
1837   if ( !myCreationInfoWdg )
1838     myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1839   getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1840   getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1841
1842   SUIT_ViewManager* vm;
1843   ViewManagerList OCCViewManagers, VTKViewManagers;
1844
1845   application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1846   QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1847   while ( itOCC.hasNext() && (vm = itOCC.next()) )
1848     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1849
1850   application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1851   QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1852   while ( itVTK.hasNext() && (vm = itVTK.next()) )
1853     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1854
1855   //NPAL 19674
1856   SALOME_ListIO selected;
1857   sm->selectedObjects( selected );
1858   sm->clearSelected();
1859
1860   // disable OCC selectors
1861   getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1862   QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1863   while ( itOCCSel.hasNext() )
1864     if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1865       sr->setEnabled(true);
1866
1867   // disable VTK selectors
1868   getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1869   QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1870   while ( itVTKSel.hasNext() )
1871     if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1872       sr->setEnabled(true);
1873
1874   sm->setSelectedObjects( selected, true );   //NPAL 19674
1875
1876   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1877   if ( viewMenu )
1878     connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1879
1880   // 0020836 (Basic vectors and origin)
1881   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1882   if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1883     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1884     if ( appStudy ) {
1885       _PTR(Study) studyDS = appStudy->studyDS();
1886       if ( studyDS ) {
1887         _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1888         if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1889           createOriginAndBaseVectors();
1890       }
1891     }
1892   }
1893
1894   return true;
1895 }
1896
1897 //=======================================================================
1898 // function : GeometryGUI::deactivateModule()
1899 // purpose  : Called when GEOM module is deactivated
1900 //=======================================================================
1901 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1902 {
1903   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1904   if ( viewMenu )
1905     disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1906
1907   setMenuShown( false );
1908   setToolShown( false );
1909
1910   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1911              this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1912
1913   LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
1914
1915   disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1916   disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
1917   getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
1918   myCreationInfoWdg = 0;
1919
1920   EmitSignalCloseAllDialogs();
1921
1922   GUIMap::Iterator it;
1923   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1924     it.value()->deactivate();
1925
1926   // Unset actions accelerator keys
1927   action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1928   action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1929   action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1930
1931   qDeleteAll(myOCCSelectors);
1932   myOCCSelectors.clear();
1933   selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
1934
1935   qDeleteAll(myVTKSelectors);
1936   myVTKSelectors.clear();
1937   selMrg->setEnabled( true, SVTK_Viewer::Type() );
1938
1939   return SalomeApp_Module::deactivateModule( study );
1940 }
1941
1942 //=======================================================================
1943 // function : onWindowActivated()
1944 // purpose  : update menu items' status - disable non-OCC-viewer-compatible actions
1945 //=======================================================================
1946 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1947 {
1948   if ( !win )
1949     return;
1950
1951   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1952   //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1953
1954   // disable non-OCC viewframe menu commands
1955 //  action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1956   action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1957   action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1958   action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1959   action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1960   action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1961 //  action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1962
1963   action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1964   action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1965   action( GEOMOp::OpCreateField )->setEnabled( ViewOCC ); // Create Field
1966   action( GEOMOp::OpEditField )->setEnabled( ViewOCC ); // Edit Field
1967
1968   action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1969 }
1970
1971 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1972 {
1973   mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1974   mappa.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
1975   mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1976   if ( myCreationInfoWdg )
1977     mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1978 }
1979
1980 void GeometryGUI::viewManagers( QStringList& lst ) const
1981 {
1982   lst.append( OCCViewer_Viewer::Type() );
1983 }
1984
1985 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1986 {
1987   if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1988   {
1989     qDebug( "connect" );
1990     connect( vm, SIGNAL( keyPress  ( SUIT_ViewWindow*, QKeyEvent* ) ),
1991              this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1992     connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1993              this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1994     connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1995              this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1996     connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
1997              this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
1998
1999     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2000     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
2001
2002     // disable OCC selectors
2003     getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
2004     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2005     while ( itOCCSel.hasNext() )
2006       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2007         sr->setEnabled(true);
2008   }
2009   else if ( vm->getType() == SVTK_Viewer::Type() )
2010   {
2011     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2012     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
2013
2014     // disable VTK selectors
2015     getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
2016     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2017     while ( itVTKSel.hasNext() )
2018       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2019         sr->setEnabled(true);
2020   }
2021 }
2022
2023 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
2024 {
2025   SUIT_ViewModel* viewer = vm->getViewModel();
2026   if ( vm->getType() == OCCViewer_Viewer::Type() )
2027   {
2028     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2029     while ( itOCCSel.hasNext() )
2030       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2031         if ( sr->viewer() == viewer )
2032         {
2033           /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
2034           break;
2035         }
2036   }
2037   if ( vm->getType() == SVTK_Viewer::Type() )
2038   {
2039     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2040     while ( itVTKSel.hasNext() )
2041       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2042         if ( sr->viewer() == viewer )
2043         {
2044           /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
2045           break;
2046         }
2047   }
2048 }
2049
2050 //================================================================================
2051 /*!
2052  * \brief Slot called when selection changed. Shows creation info of a selected object
2053  */
2054 //================================================================================
2055
2056 void GeometryGUI::updateCreationInfo()
2057 {
2058   if ( myCreationInfoWdg )
2059     myCreationInfoWdg->clear();
2060
2061   // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
2062   // if ( !myCreationInfoWdg->isVisible() )
2063   //   return;
2064
2065   // look for a sole selected GEOM_Object
2066   GEOM::GEOM_BaseObject_var geomObj;
2067
2068   SALOME_ListIO selected;
2069   getApp()->selectionMgr()->selectedObjects( selected );
2070
2071   _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
2072   SALOME_ListIteratorOfListIO selIt( selected );
2073   for ( ; selIt.More(); selIt.Next() )
2074   {
2075     Handle(SALOME_InteractiveObject) io = selIt.Value();
2076     if ( !io->hasEntry() ) continue;
2077     _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
2078     if ( !sobj ) continue;
2079     CORBA::Object_var          obj = GeometryGUI::ClientSObjectToObject( sobj );
2080     GEOM::GEOM_BaseObject_var gobj = GEOM::GEOM_BaseObject::_narrow( obj );
2081     if ( !gobj->_is_nil() )
2082     {
2083       if ( !geomObj->_is_nil() )
2084         return; // several GEOM objects selected
2085       geomObj = gobj;
2086     }
2087   }
2088   if ( geomObj->_is_nil() ) return;
2089
2090   // pass creation info of geomObj to myCreationInfoWdg
2091
2092   if ( myCreationInfoWdg ) {
2093     QPixmap icon;
2094     QString operationName;
2095     myCreationInfoWdg->setOperation( icon, operationName );
2096
2097     try {
2098       OCC_CATCH_SIGNALS;
2099       GEOM::CreationInformation_var info = geomObj->GetCreationInformation();
2100       if ( &info.in() ) {
2101         SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2102         QString name = info->operationName.in();
2103         if ( !name.isEmpty() ) {
2104           icon = resMgr->loadPixmap( "GEOM", tr( ("ICO_"+name).toLatin1().constData() ), false );
2105           operationName = tr( ("MEN_"+name).toLatin1().constData() );
2106           if ( operationName.startsWith( "MEN_" ))
2107             operationName = name; // no translation
2108           myCreationInfoWdg->setOperation( icon, operationName );
2109
2110           for ( size_t i = 0; i < info->params.length(); ++i )
2111             myCreationInfoWdg->addParam( info->params[i].name.in(),
2112                                          info->params[i].value.in() );
2113         }
2114       }
2115     }
2116     catch (...) {
2117     }
2118   }
2119 }
2120
2121 void GeometryGUI::onAutoBringToFront()
2122 {
2123   bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" );
2124   if( !isAutoBringToFront )
2125     return;
2126   
2127   SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
2128   if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
2129         return;
2130
2131   SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
2132   if (!appStudy) return;
2133
2134   GEOM_Displayer displayer( appStudy );
2135   
2136   SALOME_View* window = displayer.GetActiveView();
2137   if ( !window ) return;
2138   
2139   int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
2140   
2141   SALOME_ListIO selected;
2142   getApp()->selectionMgr()->selectedObjects( selected );
2143   if (!myTopLevelIOList.IsEmpty())
2144   {
2145     for( SALOME_ListIteratorOfListIO It( myTopLevelIOList ); It.More(); It.Next() )
2146     {
2147       Handle( SALOME_InteractiveObject ) io = It.Value();
2148       bool isSelected = false;
2149       for( SALOME_ListIteratorOfListIO It_sel( selected ); It_sel.More(); It_sel.Next() )
2150       {
2151         Handle( SALOME_InteractiveObject ) sel_io = It_sel.Value();
2152         if( io->isSame( sel_io ) )
2153           isSelected = true;
2154       }
2155       if (!isSelected && appStudy->findObjectByEntry(io->getEntry()))
2156       {
2157         appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
2158         if ( window->isVisible( io ) ) displayer.Redisplay( io, false );     
2159       }
2160     }
2161   }
2162   
2163   myTopLevelIOList.Assign(selected);
2164   for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
2165   {
2166     Handle( SALOME_InteractiveObject ) io = It.Value();
2167     appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
2168     if ( window->isVisible( io ) ) displayer.Redisplay( io, false );     
2169   }
2170     
2171   displayer.UpdateViewer();
2172   GeometryGUI::Modified();
2173 }
2174
2175 void GeometryGUI::updateFieldColorScale()
2176 {
2177   if( SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) )
2178   {
2179     GEOM_Displayer aDisplayer( aStudy );
2180     aDisplayer.UpdateColorScale();
2181   }
2182 }
2183
2184 QString GeometryGUI::engineIOR() const
2185 {
2186   if ( !CORBA::is_nil( GetGeomGen() ) )
2187     return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
2188   return "";
2189 }
2190
2191 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
2192 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
2193 #else
2194 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture
2195 #endif
2196       (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
2197 {
2198   theWidth = theHeight = 0;
2199
2200 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
2201   Handle(TColStd_HArray1OfByte) aTexture;
2202 #else
2203   Handle(Graphic3d_HArray1OfBytes) aTexture;
2204 #endif
2205
2206   if (theStudy) {
2207     TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
2208     aTexture = aTextureMap[ theId ];
2209     if ( aTexture.IsNull() ) {
2210       GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
2211       if ( !aInsOp->_is_nil() ) {
2212         CORBA::Long aWidth, aHeight;
2213         SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
2214         if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
2215           theWidth  = aWidth;
2216           theHeight = aHeight;
2217
2218 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
2219           aTexture  = new TColStd_HArray1OfByte (1, aStream->length());
2220 #else
2221           aTexture  = new Graphic3d_HArray1OfBytes (1, aStream->length());
2222 #endif
2223
2224           for (int i = 0; i < aStream->length(); i++)
2225             aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
2226           aTextureMap[ theId ] = aTexture;
2227         }
2228       }
2229     }
2230   }
2231   return aTexture;
2232 }
2233
2234 LightApp_Selection* GeometryGUI::createSelection() const
2235 {
2236   return new GEOMGUI_Selection();
2237 }
2238
2239 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
2240 {
2241   SalomeApp_Module::contextMenuPopup( client, menu, title );
2242   SALOME_ListIO lst;
2243   getApp()->selectionMgr()->selectedObjects( lst );
2244
2245   //Add submenu for predefined materials
2246   bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
2247   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
2248     QtxPopupMgr* mgr = popupMgr();
2249     //get parrent for submenu
2250     QAction* act = mgr->action( mgr->actionId( action(  GEOMOp::OpMaterialProperties ) ) );
2251     //Clear old  menu
2252     QMenu* oldMenu = act->menu() ;
2253     if( oldMenu ) {
2254       delete oldMenu;
2255     }
2256     if( isPredefMat ){
2257       QMenu* matMenu = new QMenu();
2258       QSignalMapper* signalMapper = new QSignalMapper( matMenu );
2259
2260       //Get current material model for the object
2261       QVariant v;
2262       LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
2263       if ( anApp && anApp->activeViewManager() ) {
2264         LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
2265         if( aStudy ) {
2266           v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
2267         }
2268       }
2269       QString curModel = "";
2270       if ( v.canConvert<QString>() ) curModel = v.toString();
2271       // get list of all predefined materials
2272       QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2273       bool found = false;
2274       foreach ( QString material, materials )
2275       {
2276         QAction* menAct = matMenu->addAction( material );
2277         connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
2278         signalMapper->setMapping( menAct, material );
2279         menAct->setCheckable( true );
2280         // Set checked if this material is current
2281         Material_Model aModel;
2282         aModel.fromResources( material );
2283         if ( !found && aModel.toProperties() == curModel ) {
2284           menAct->setChecked( true );
2285           found = true;
2286         }
2287       }
2288       matMenu->insertAction( matMenu->addSeparator(), action(  GEOMOp::OpPredefMaterCustom ) );
2289       matMenu->insertSeparator( action(  GEOMOp::OpPredefMaterCustom ) );
2290       connect( signalMapper, SIGNAL( mapped( const QString & ) ),
2291                  this, SLOT( OnSetMaterial( const QString & ) ) );
2292       act->setMenu( matMenu );
2293     }
2294   }
2295   //Set name
2296   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
2297     Handle(SALOME_InteractiveObject) io = lst.First();
2298     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2299     _PTR(Study) study = appStudy->studyDS();
2300     _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
2301     if ( obj ) {
2302       QString aName = QString( obj->GetName().c_str() );
2303       aName.remove( QRegExp("\\s+$") );
2304       title = aName;
2305     }
2306   }
2307 }
2308
2309 void GeometryGUI::OnSetMaterial(const QString& theName)
2310 {
2311   OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
2312 }
2313
2314
2315 void GeometryGUI::createPreferences()
2316 {
2317   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
2318
2319   int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
2320   setPreferenceProperty( genGroup, "columns", 2 );
2321
2322   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
2323                                 LightApp_Preferences::Selector,
2324                                 "Geometry", "display_mode" );
2325
2326   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
2327                  LightApp_Preferences::Color, "Geometry", "shading_color" );
2328
2329   addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
2330                  LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
2331
2332   addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
2333                  LightApp_Preferences::Color, "Geometry", "wireframe_color" );
2334
2335   addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
2336                  LightApp_Preferences::Color, "Geometry", "free_bound_color" );
2337
2338   addPreference( tr( "PREF_LINE_COLOR"), genGroup,
2339                  LightApp_Preferences::Color, "Geometry", "line_color" );
2340
2341   addPreference( tr( "PREF_POINT_COLOR"), genGroup,
2342                  LightApp_Preferences::Color, "Geometry", "point_color" );
2343
2344   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
2345                  LightApp_Preferences::Color, "Geometry", "isos_color" );
2346
2347   addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
2348                  LightApp_Preferences::Color, "Geometry", "toplevel_color" );
2349
2350   int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
2351                       LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
2352
2353   int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
2354                             LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
2355
2356   int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
2357                             LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
2358
2359   addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
2360                  LightApp_Preferences::Bool, "Geometry", "predef_materials" );
2361
2362   int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
2363                                 LightApp_Preferences::Selector,
2364                                 "Geometry", "material" );
2365
2366   addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
2367                  LightApp_Preferences::Color, "Geometry", "editgroup_color" );
2368
2369   const int nb = 4;
2370   int wd[nb];
2371   int iter=0;
2372
2373   wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
2374                               LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
2375
2376   wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
2377                               LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
2378
2379   wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
2380                                      LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
2381
2382   wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
2383                               LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
2384
2385   for (int i = 0; i < nb; i++) {
2386     setPreferenceProperty( wd[i], "min", 1 );
2387     setPreferenceProperty( wd[i], "max", 5 );
2388   }
2389
2390   addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
2391                  LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
2392
2393   int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
2394   setPreferenceProperty( aDimGroupId, "columns", 2 );
2395
2396   addPreference( tr( "PREF_DIMENSIONS_COLOR" ), aDimGroupId,
2397                  LightApp_Preferences::Color, "Geometry", "dimensions_color" );
2398
2399   int aDimLineWidthId = addPreference( tr( "PREF_DIMENSIONS_LINE_WIDTH" ), aDimGroupId, 
2400                                        LightApp_Preferences::IntSpin, "Geometry", "dimensions_line_width" );
2401
2402   setPreferenceProperty( aDimLineWidthId, "min", 1 );
2403   setPreferenceProperty( aDimLineWidthId, "max", 5 );
2404
2405   int aDimFontHeightId = addPreference( tr( "PREF_DIMENSIONS_FONT_HEIGHT" ), aDimGroupId,
2406                                         LightApp_Preferences::DblSpin, "Geometry", "dimensions_font_height" );
2407
2408   setPreferenceProperty( aDimFontHeightId, "min", 1e-9 );
2409   setPreferenceProperty( aDimFontHeightId, "max", 1e+9 );
2410   setPreferenceProperty( aDimFontHeightId, "precision", 9 );
2411
2412   int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
2413                                        LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
2414
2415   setPreferenceProperty( aDimArrLengthId, "min", 1e-9 );
2416   setPreferenceProperty( aDimArrLengthId, "max", 1e+9 );
2417   setPreferenceProperty( aDimArrLengthId, "precision", 9 );
2418
2419   int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId,
2420                                       LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" );
2421
2422   int anAngUnitsId = addPreference( tr( "PREF_DIMENSIONS_ANGLE_UNITS" ), aDimGroupId,
2423                                    LightApp_Preferences::Selector, "Geometry", "dimensions_angle_units" );
2424
2425   addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
2426                  LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
2427
2428   QStringList aListOfLengthUnits;
2429   aListOfLengthUnits << "m";
2430   aListOfLengthUnits << "cm";
2431   aListOfLengthUnits << "mm";
2432   aListOfLengthUnits << "in.";
2433   aListOfLengthUnits << "ft.";
2434
2435   QStringList aListOfAngUnits;
2436   aListOfAngUnits << "rad";
2437   aListOfAngUnits << "deg";
2438
2439   setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
2440   setPreferenceProperty( anAngUnitsId,   "strings", aListOfAngUnits );
2441
2442   int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
2443                                      LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
2444
2445   setPreferenceProperty( aDimDefFlyout, "min", 1e-9 );
2446   setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
2447   setPreferenceProperty( aDimDefFlyout, "precision", 9 );
2448
2449   int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
2450   setPreferenceProperty( isoGroup, "columns", 2 );
2451   int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2452                             LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
2453   setPreferenceProperty( isoU, "min", 0 );
2454   setPreferenceProperty( isoU, "max", 100000 );
2455   int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2456                             LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
2457   setPreferenceProperty( isoV, "min", 0 );
2458   setPreferenceProperty( isoV, "max", 100000 );
2459
2460   // Quantities with individual precision settings
2461   int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
2462   setPreferenceProperty( precGroup, "columns", 2 );
2463
2464   const int nbQuantities = 8;
2465   int prec[nbQuantities], ii = 0;
2466   prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
2467                               LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
2468   prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
2469                               LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
2470   prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
2471                               LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
2472   prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
2473                               LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
2474   prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
2475                               LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
2476   prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
2477                               LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
2478   prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
2479                               LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
2480   prec[ii  ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
2481                               LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
2482
2483   // Set property for precision value for spinboxes
2484   for ( ii = 0; ii < nbQuantities; ii++ ){
2485     setPreferenceProperty( prec[ii], "min", -14 );
2486     setPreferenceProperty( prec[ii], "max", 14 );
2487     setPreferenceProperty( prec[ii], "precision", 2 );
2488   }
2489
2490   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
2491   setPreferenceProperty( VertexGroup, "columns", 2 );
2492
2493   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2494                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2495
2496   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2497                                    LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2498
2499   // Set property for default display mode
2500   QStringList aModesList;
2501   aModesList.append( tr("MEN_WIREFRAME") );
2502   aModesList.append( tr("MEN_SHADING") );
2503   aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2504   aModesList.append( tr("MEN_TEXTURE") );
2505
2506   QList<QVariant> anIndexesList;
2507   anIndexesList.append(0);
2508   anIndexesList.append(1);
2509   anIndexesList.append(2);
2510   anIndexesList.append(3);
2511
2512   setPreferenceProperty( dispmode, "strings", aModesList );
2513   setPreferenceProperty( dispmode, "indexes", anIndexesList );
2514
2515   // Set property for top level display mode
2516   QStringList aTopModesList;
2517   aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2518   aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2519   aTopModesList.append( tr("MEN_WIREFRAME") );
2520   aTopModesList.append( tr("MEN_SHADING") );
2521   aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2522
2523   QList<QVariant> aTopIndexesList;
2524   aTopIndexesList.append(0);
2525   aTopIndexesList.append(1);
2526   aTopIndexesList.append(2);
2527   aTopIndexesList.append(3);
2528   aTopIndexesList.append(4);
2529
2530   setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2531   setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2532
2533   // Set property for step value for spinboxes
2534   setPreferenceProperty( step, "min", 1 );
2535   setPreferenceProperty( step, "max", 10000 );
2536   setPreferenceProperty( step, "precision", 3 );
2537
2538   // Set property for deflection value for spinboxes
2539   setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2540   setPreferenceProperty( defl, "max", 1.0 );
2541   setPreferenceProperty( defl, "step", 1.0e-04 );
2542   setPreferenceProperty( defl, "precision", 6 );
2543
2544   // Set property for default material
2545   setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2546
2547   // Set property vertex marker type
2548   QList<QVariant> aMarkerTypeIndicesList;
2549   QList<QVariant> aMarkerTypeIconsList;
2550
2551   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2552   for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2553     QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2554     QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2555     aMarkerTypeIndicesList << (i-1);
2556     aMarkerTypeIconsList << pixmap;
2557   }
2558
2559   setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2560   setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
2561
2562   // Set property for vertex marker scale
2563   QList<QVariant> aMarkerScaleIndicesList;
2564   QStringList     aMarkerScaleValuesList;
2565
2566   for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2567     aMarkerScaleIndicesList << iii;
2568     aMarkerScaleValuesList  << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2569   }
2570
2571   setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2572   setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2573
2574   // Scalar bar for field step presentation
2575   int scalarBarGroup = addPreference( tr( "PREF_GROUP_SCALAR_BAR" ), tabId );
2576   setPreferenceProperty( scalarBarGroup, "columns", 2 );
2577
2578   int sbXPosition = addPreference( tr( "PREF_SCALAR_BAR_X_POSITION" ), scalarBarGroup,
2579                                    LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_x_position" );
2580   setPreferenceProperty( sbXPosition, "min", 0 );
2581   setPreferenceProperty( sbXPosition, "max", 1 );
2582   setPreferenceProperty( sbXPosition, "step", 0.05 );
2583
2584   int sbYPosition = addPreference( tr( "PREF_SCALAR_BAR_Y_POSITION" ), scalarBarGroup,
2585                                    LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_y_position" );
2586   setPreferenceProperty( sbYPosition, "min", 0 );
2587   setPreferenceProperty( sbYPosition, "max", 1 );
2588   setPreferenceProperty( sbYPosition, "step", 0.05 );
2589
2590   int sbWidth = addPreference( tr( "PREF_SCALAR_BAR_WIDTH" ), scalarBarGroup,
2591                                LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_width" );
2592   setPreferenceProperty( sbWidth, "min", 0 );
2593   setPreferenceProperty( sbWidth, "max", 1 );
2594   setPreferenceProperty( sbWidth, "step", 0.05 );
2595
2596   int sbHeight = addPreference( tr( "PREF_SCALAR_BAR_HEIGHT" ), scalarBarGroup,
2597                                 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_height" );
2598   setPreferenceProperty( sbHeight, "min", 0 );
2599   setPreferenceProperty( sbHeight, "max", 1 );
2600   setPreferenceProperty( sbHeight, "step", 0.05 );
2601
2602   int sbTextHeight = addPreference( tr( "PREF_SCALAR_BAR_TEXT_HEIGHT" ), scalarBarGroup,
2603                                     LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_text_height" );
2604   setPreferenceProperty( sbTextHeight, "min", 6 );
2605   setPreferenceProperty( sbTextHeight, "max", 24 );
2606   setPreferenceProperty( sbTextHeight, "step", 1 );
2607
2608   int sbNbIntervals = addPreference( tr( "PREF_SCALAR_BAR_NUMBER_OF_INTERVALS" ), scalarBarGroup,
2609                                      LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_nb_intervals" );
2610   setPreferenceProperty( sbNbIntervals, "min", 2 );
2611   setPreferenceProperty( sbNbIntervals, "max", 64 );
2612   setPreferenceProperty( sbNbIntervals, "step", 1 );
2613
2614   int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2615   setPreferenceProperty( originGroup, "columns", 2 );
2616
2617   int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2618                                          LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2619   setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2620   setPreferenceProperty( baseVectorsLength, "max", 1000 );
2621
2622   addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2623                  LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2624
2625   int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2626   setPreferenceProperty( operationsGroup, "columns", 2 );
2627
2628   addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2629                  LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2630
2631   int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) );
2632
2633   int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), DependencyViewId,
2634                       LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" );
2635
2636   QStringList aHierarchyTypeList;
2637   aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") );
2638   aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") );
2639   aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") );
2640
2641   QList<QVariant> aHierarchyTypeIndexesList;
2642   aHierarchyTypeIndexesList.append(0);
2643   aHierarchyTypeIndexesList.append(1);
2644   aHierarchyTypeIndexesList.append(2);
2645
2646   setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList );
2647   setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList );
2648
2649   addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), DependencyViewId,
2650                  LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" );
2651
2652   int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId );
2653
2654   addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup,
2655                  LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" );
2656
2657   addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup,
2658                  LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" );
2659   addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup,
2660                  LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" );
2661   addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup,
2662                  LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" );
2663
2664   addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup,
2665                  LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" );
2666   addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup,
2667                  LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" );
2668   addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup,
2669                  LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" );
2670
2671
2672
2673
2674 }
2675
2676 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2677 {
2678   if (section == "Geometry") {
2679     SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2680     if (param == QString("SettingsGeomStep")) {
2681       double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2682       EmitSignalDefaultStepValueChanged(spin_step);
2683     }
2684     else if (param == QString("toplevel_color")) {
2685       QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2686       GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2687     }
2688     else if (param == QString("toplevel_dm")) {
2689       GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2690     }
2691     else if (param == QString("scalar_bar_x_position") ||
2692              param == QString("scalar_bar_y_position") ||
2693              param == QString("scalar_bar_width") ||
2694              param == QString("scalar_bar_height") ||
2695              param == QString("scalar_bar_text_height") ||
2696              param == QString("scalar_bar_nb_intervals")) {
2697       if( SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) )
2698       {
2699         GEOM_Displayer aDisplayer( aStudy );
2700         bool anIsRedisplayFieldSteps = param == QString("scalar_bar_nb_intervals");
2701         aDisplayer.UpdateColorScale( anIsRedisplayFieldSteps, true );
2702       }
2703     }
2704     else if ( param == QString("dimensions_color")        ||
2705               param == QString("dimensions_line_width")   ||
2706               param == QString("dimensions_font_height")  ||
2707               param == QString("dimensions_arrow_length") ||
2708               param == QString("dimensions_show_units")   ||
2709               param == QString("dimensions_length_units") ||
2710               param == QString("dimensions_angle_units") )
2711     {
2712       SalomeApp_Application* anApp = getApp();
2713       if ( !anApp )
2714       {
2715         return;
2716       }
2717
2718       SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
2719       if ( !aStudy )
2720       {
2721         return;
2722       }
2723
2724       GEOM_Displayer aDisplayer( aStudy );
2725
2726       ViewManagerList aVMs;
2727       anApp->viewManagers( OCCViewer_Viewer::Type(), aVMs );
2728       ViewManagerList::Iterator anIt = aVMs.begin();
2729       for ( ; anIt != aVMs.end(); ++anIt )
2730       {
2731         SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>( (*anIt)->getViewModel() );
2732         if ( !aViewer )
2733         {
2734           continue;
2735         }
2736
2737         SALOME_ListIO aVisible;
2738         aViewer->GetVisible( aVisible );
2739         aDisplayer.Redisplay( aVisible, false, aViewer );
2740       }
2741
2742       aDisplayer.UpdateViewer();
2743     }
2744     else if ( param.startsWith( "dependency_tree") )
2745     {
2746       SalomeApp_Application* app = getApp();
2747       if ( !app ) return;
2748
2749       SUIT_ViewManager *svm = app->getViewManager( GraphicsView_Viewer::Type(), false );
2750       if( !svm ) return;
2751
2752       if( DependencyTree_ViewModel* viewModel = dynamic_cast<DependencyTree_ViewModel*>( svm->getViewModel() ) )
2753         if( DependencyTree_View* view = dynamic_cast<DependencyTree_View*>( viewModel->getActiveViewPort() ) ) {
2754           if( param == QString("dependency_tree_hierarchy_type") ) {
2755             int hierarchyType = aResourceMgr->integerValue( section, param, 0);
2756             view->setHierarchyType( hierarchyType );
2757           }
2758           else if(  param == QString("dependency_tree_move_nodes") ) {
2759             bool isNodesMovable = aResourceMgr->booleanValue( section, param, true);
2760             view->setNodesMovable( isNodesMovable );
2761           }
2762           else if(  param == QString("dependency_tree_background_color") ) {
2763             QColor c = aResourceMgr->colorValue( section, param, QColor( 255, 255, 255 ) );
2764             view->setPrefBackgroundColor( c );
2765           }
2766           else if(  param == QString("dependency_tree_node_color") ) {
2767             QColor c = aResourceMgr->colorValue( section, param, QColor( 62, 180, 238 ) );
2768             view->setNodeColor( c );
2769           }
2770           else if(  param == QString("dependency_tree_main_node_color") ) {
2771             QColor c = aResourceMgr->colorValue( section, param, QColor( 238, 90, 125 ) );
2772             view->setMainNodeColor( c );
2773           }
2774           else if(  param == QString("dependency_tree_select_node_color") ) {
2775             QColor c = aResourceMgr->colorValue( section, param, QColor( 237, 243, 58 ) );
2776             view->setSelectNodeColor( c );
2777           }
2778           else if(  param == QString("dependency_tree_arrow_color") ) {
2779             QColor c = aResourceMgr->colorValue( section, param, QColor( 0, 0, 130 ) );
2780             view->setArrowColor( c );
2781           }
2782           else if(  param == QString("dependency_tree_highlight_arrow_color") ) {
2783             QColor c = aResourceMgr->colorValue( section, param, QColor( 0, 0, 255 ) );
2784             view->setHighlightArrowColor( c );
2785           }
2786           else if(  param == QString("dependency_tree_select_arrow_color") ) {
2787             QColor c = aResourceMgr->colorValue( section, param, QColor( 255, 0, 0 ) );
2788             view->setSelectArrowColor( c );
2789           }
2790
2791       }
2792     }
2793   }
2794 }
2795
2796 LightApp_Displayer* GeometryGUI::displayer()
2797 {
2798   if ( !myDisplayer )
2799     myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
2800   return myDisplayer;
2801 }
2802
2803 void GeometryGUI::setLocalSelectionMode(const int mode)
2804 {
2805   myLocalSelectionMode = mode;
2806 }
2807
2808 int GeometryGUI::getLocalSelectionMode() const
2809 {
2810   return myLocalSelectionMode;
2811 }
2812
2813 const char gSeparator = '_'; // character used to separate parameter names
2814 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2815
2816 /*!
2817  * \brief Store visual parameters
2818  *
2819  * This method is called just before the study document is saved.
2820  * Store visual parameters in AttributeParameter attribute(s)
2821  */
2822 void GeometryGUI::storeVisualParameters (int savePoint)
2823 {
2824   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2825   if ( !appStudy || !appStudy->studyDS() )
2826     return;
2827   _PTR(Study) studyDS = appStudy->studyDS();
2828
2829   // componentName is used for encoding of entries when storing them in IParameters
2830   std::string componentName = myComponentGeom->ComponentDataType();
2831   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2832   //if (!aSComponent) return;
2833
2834   // IParameters
2835   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2836                                                              componentName.c_str(),
2837                                                              savePoint);
2838   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2839
2840   QSet<QString> anEntriesToStoreShared;
2841   QList<SUIT_ViewManager*> lst;
2842   QList<SUIT_ViewManager*>::Iterator it;
2843
2844   // main cycle to store parameters of displayed objects
2845   lst.clear();
2846   getApp()->viewManagers(lst);
2847   for (it = lst.begin(); it != lst.end(); it++) {
2848     SUIT_ViewManager* vman = *it;
2849     QString vType = vman->getType();
2850     int aMgrId = vman->getGlobalId();
2851     // saving VTK actors properties
2852     QVector<SUIT_ViewWindow*> views = vman->getViews();
2853     for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
2854       const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
2855       ObjMap::ConstIterator o_it = anObjects.begin();
2856       for (; o_it != anObjects.end(); o_it++) {
2857         const PropMap aProps = o_it.value();
2858
2859         //Check that object exists in the study
2860         _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
2861         if ( !obj || !(aProps.count() > 0))
2862           continue;
2863         // entry is "encoded" = it does NOT contain component adress, since it is a
2864         // subject to change on next component loading
2865
2866         std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
2867
2868         _PTR(GenericAttribute) anAttr;
2869         if (!obj->FindAttribute(anAttr, "AttributeIOR"))
2870           continue;
2871
2872         // remember entry of object to store shared GEOM properties
2873         // (e.g. dimension properties).
2874         if ( vType == OCCViewer_Viewer::Type() )
2875         {
2876           anEntriesToStoreShared.insert( o_it.key() );
2877         }
2878
2879         QString param, occParam = vType;
2880         occParam += GEOM::sectionSeparator();
2881         occParam += QString::number(aMgrId);
2882         occParam += GEOM::sectionSeparator();
2883
2884         if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
2885           param = occParam + GEOM::propertyName( GEOM::Visibility );
2886           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
2887         }
2888
2889         if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
2890           param = occParam + GEOM::propertyName( GEOM::DisplayMode );
2891           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
2892         }
2893
2894         if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
2895           QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
2896           QStringList val;
2897           val << QString::number(c.redF());
2898           val << QString::number(c.greenF());
2899           val << QString::number(c.blueF());
2900           param = occParam + GEOM::propertyName( GEOM::Color );
2901           ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
2902         }
2903         
2904         if (aProps.contains(GEOM::propertyName( GEOM::Texture ))) {
2905           param = occParam + GEOM::propertyName( GEOM::Texture );
2906           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Texture )).toString().toStdString());
2907         }
2908
2909         if (vType == SVTK_Viewer::Type()) {
2910           if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
2911             param = occParam + GEOM::propertyName( GEOM::Opacity );
2912             ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
2913           }
2914         } else if (vType == SOCC_Viewer::Type()) {
2915           if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
2916             param = occParam + GEOM::propertyName( GEOM::Transparency );
2917             ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
2918           }
2919
2920           if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
2921             param = occParam + GEOM::propertyName( GEOM::TopLevel );
2922             ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
2923           }
2924         }
2925
2926         if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
2927           param = occParam + GEOM::propertyName( GEOM::NbIsos );
2928           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
2929         }
2930
2931         if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
2932           param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
2933           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
2934         }
2935
2936         if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
2937           param = occParam + GEOM::propertyName( GEOM::Deflection );
2938           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
2939         }
2940
2941         //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
2942         if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
2943           param = occParam + GEOM::propertyName( GEOM::PointMarker );
2944           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
2945         }
2946
2947         if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
2948           param = occParam + GEOM::propertyName( GEOM::Material );
2949           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
2950         }
2951
2952         if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
2953              param = occParam + GEOM::propertyName( GEOM::LineWidth );
2954            ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
2955         }
2956
2957         if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
2958           param = occParam + GEOM::propertyName( GEOM::IsosWidth );
2959           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
2960         }
2961       } // object iterator
2962     } // for (views)
2963   } // for (viewManagers)
2964
2965   // store dimension attributes of objects:
2966   // since the displayed object always persists in property map, we remember the object entries
2967   // on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
2968   QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
2969   QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
2970   for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
2971   {
2972     std::string aStudyEntry = (*aEntryIt).toLatin1().data();
2973     std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName);
2974
2975     GEOMGUI_DimensionProperty aDimensions( appStudy, aStudyEntry );
2976
2977     if ( aDimensions.GetNumber() == 0 )
2978     {
2979       continue;
2980     }
2981
2982     ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toLatin1().data() );
2983   }
2984 }
2985
2986 /*!
2987  * \brief Restore visual parameters
2988  *
2989  * This method is called after the study document is opened.
2990  * Restore visual parameters from AttributeParameter attribute(s)
2991  */
2992 void GeometryGUI::restoreVisualParameters (int savePoint)
2993 {
2994   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2995   if (!appStudy || !appStudy->studyDS())
2996     return;
2997   _PTR(Study) studyDS = appStudy->studyDS();
2998
2999   // componentName is used for encoding of entries when storing them in IParameters
3000   std::string componentName = myComponentGeom->ComponentDataType();
3001   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
3002   //if (!aSComponent) return;
3003
3004   // IParameters
3005   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3006                                                              componentName.c_str(),
3007                                                              savePoint);
3008   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3009
3010   std::vector<std::string> entries = ip->getEntries();
3011
3012   for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
3013   {
3014     // entry is a normal entry - it should be "decoded" (setting base adress of component)
3015     QString entry (ip->decodeEntry(*entIt).c_str());
3016
3017     // Check that the entry corresponds to a real object in the Study
3018     // as the object may be deleted or modified after the visual state is saved.
3019     _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
3020     if (!so) continue; //Skip the not existent entry
3021
3022     std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
3023     std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
3024
3025     std::vector<std::string>::iterator namesIt = paramNames.begin();
3026     std::vector<std::string>::iterator valuesIt = paramValues.begin();
3027
3028     // actors are stored in a map after displaying of them for
3029     // quicker access in the future: map < viewID to actor >
3030     NCollection_DataMap<int, GEOM_Actor*          > vtkActors;
3031     NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
3032
3033     QString viewerTypStr;
3034     QString viewIndexStr;
3035     int viewIndex;
3036     QVector<PropMap> aListOfMap;
3037
3038     for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
3039     {
3040       // visual parameters are stored in strings as follows: 
3041       //   1) ViewerType_ViewIndex_ParamName
3042       //   2) ViewerType_ParamName (shared for GEOM module)
3043       // '_' is used as separator and should not be used in viewer type or parameter names.
3044       QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
3045
3046       bool isShared = lst.size() == 2;
3047       bool isViewer = lst.size() == 3;
3048       if ( !isShared && !isViewer )
3049       {
3050         continue;
3051       }
3052
3053       // shared visual parameters
3054       if ( isShared )
3055       {
3056         QString aParamNameStr( lst[1] );
3057         QString aValuesStr( (*valuesIt).c_str() );
3058
3059         // shared dimension properties are stored as attribute
3060         if ( aParamNameStr == GEOM::propertyName( GEOM::Dimensions ) )
3061         {
3062           GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
3063           aDimensionProp.SaveToAttribute( appStudy, entry.toLatin1().data() );
3064         }
3065
3066         continue;
3067       }
3068
3069       // per view visual parameters
3070       viewerTypStr = lst[0];
3071       viewIndexStr = lst[1];
3072       QString paramNameStr = lst[2];
3073
3074       bool ok;
3075       viewIndex = viewIndexStr.toUInt(&ok);
3076       if (!ok) // bad conversion of view index to integer
3077         continue;
3078
3079       if ((viewIndex + 1) > aListOfMap.count()) {
3080         aListOfMap.resize(viewIndex + 1);
3081       }
3082
3083       QString val((*valuesIt).c_str());
3084       if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
3085         aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
3086       } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
3087         aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
3088       } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
3089         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
3090       } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
3091         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
3092       } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
3093         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
3094       } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
3095         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
3096       } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
3097         QStringList rgb = val.split(GEOM::subSectionSeparator());
3098         if (rgb.count() == 3) {
3099           QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
3100           aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
3101         }
3102       } else if (paramNameStr == GEOM::propertyName( GEOM::Texture )) {
3103         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val );
3104       } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
3105         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
3106       } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
3107         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
3108       } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
3109         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
3110       } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
3111         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
3112       } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
3113         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
3114       } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
3115         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
3116       }
3117     } // for names/parameters iterator
3118
3119     QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
3120
3121     for (int index = 0; index < aListOfMap.count(); index++) {
3122
3123       appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
3124
3125       //Get Visibility property of the current PropMap
3126       if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
3127         SUIT_ViewManager* vman = lst.at(index);
3128         SUIT_ViewModel* vmodel = vman->getViewModel();
3129         displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
3130       }
3131     }
3132   } // for entries iterator
3133
3134   // update all VTK and OCC views
3135   QList<SUIT_ViewManager*> lst;
3136   getApp()->viewManagers(lst);
3137   for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
3138     SUIT_ViewModel* vmodel = (*it)->getViewModel();
3139     if (!vmodel)
3140       continue;
3141     if (vmodel->getType() == SVTK_Viewer::Type()) {
3142       SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
3143       vtkView->getRenderer()->ResetCameraClippingRange();
3144       vtkView->Repaint();
3145     }
3146     else if (vmodel->getType() == SOCC_Viewer::Type()) {
3147       //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
3148       SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
3149       if (occVMod)
3150         occVMod->Repaint();
3151     }
3152   }
3153 }
3154
3155 void GeometryGUI::onViewAboutToShow()
3156 {
3157   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
3158   QAction* a = action( GEOMOp::OpSwitchVectors );
3159   if ( window ) {
3160     a->setEnabled(true);
3161     bool vmode = window->property("VectorsMode").toBool();
3162     a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
3163   } else {
3164     a->setText ( tr("MEN_VECTOR_MODE_ON") );
3165     a->setEnabled(false);
3166   }
3167 }
3168
3169 /*!
3170   \brief Return action by id
3171   \param id identifier of the action
3172   \return action
3173 */
3174 QAction* GeometryGUI::getAction(const int id) {
3175   return action(id);
3176 }
3177
3178 /*!
3179   \brief GEOM module message handler
3180
3181   This method can be re-implemented in the subclasses.
3182   This is a GEOM module message handler.
3183
3184   \param msg the message received.
3185 */
3186 void GeometryGUI::message(const QString& msg)
3187 {
3188   // dispatch message
3189   QStringList data = msg.split("/");
3190   const int nbStrings = data.count();
3191
3192   if (nbStrings > 0) {
3193     if (data[0] == "modified") {
3194       // get mesh entry
3195       QString anIOR = nbStrings > 1 ? data[1] : QString();
3196
3197       if ( anIOR.isEmpty() ) {
3198         return;
3199       }
3200
3201       // Get the geom object.
3202       GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
3203
3204       // Clear the shape buffer
3205       GeometryGUI::ClearShapeBuffer (anObj);
3206     }
3207   }
3208 }
3209
3210 /*!
3211   \brief Clears the shape buffer.
3212
3213   This is a static method. It clears the shape buffer.
3214
3215   \param theObj the object
3216 */
3217 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
3218 {
3219   if ( CORBA::is_nil( theObj ) )
3220     return;
3221
3222   CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
3223   TCollection_AsciiString asciiIOR( (char *)IOR.in() );
3224   GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3225
3226   SALOMEDSClient_StudyManager *aManager = SalomeApp_Application::studyMgr();
3227
3228   if (!aManager)
3229     return;
3230
3231   _PTR(Study) aStudy = aManager->GetStudyByID(theObj->GetStudyID());
3232
3233   if ( !aStudy )
3234     return;
3235
3236   _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
3237   if ( !aSObj )
3238     return;
3239
3240   _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
3241   for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
3242     _PTR(GenericAttribute) anAttr;
3243     if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
3244       _PTR(AttributeIOR) anIOR ( anAttr );
3245       TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
3246       GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3247     }
3248   }
3249 }
3250
3251 /*!
3252   \brief Returns the object from IOR.
3253
3254   This is a static method. It returns the object from its IOR.
3255
3256   \param IOR object IOR
3257   \return GEOM object.
3258 */
3259 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
3260 {
3261   GEOM::GEOM_Object_var geomObj;
3262   if ( !IOR.isEmpty() ) {
3263     CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
3264       ( IOR.toLatin1().constData() );
3265     if ( !CORBA::is_nil( corbaObj ) )
3266       geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
3267   }
3268   return geomObj._retn();
3269 }
3270
3271 /*!
3272   \brief Returns IOR of the object.
3273
3274   This is a static method. It returns the object's IOR.
3275
3276   \param object the GEOM object.
3277   \return object's IOR.
3278 */
3279 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
3280 {
3281   QString IOR;
3282   if ( !CORBA::is_nil( object ) ) {
3283     CORBA::String_var anIOR =
3284       SalomeApp_Application::orb()->object_to_string( object );
3285     IOR = anIOR.in();
3286   }
3287   return IOR;
3288 }
3289
3290 /*!
3291   \brief Check if this object is can't be renamed in place
3292
3293   This method can be re-implemented in the subclasses.
3294   Return true in case if object isn't reference or component (module root).
3295
3296   \param entry column id
3297   \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
3298 */
3299 bool GeometryGUI::renameAllowed( const QString& entry) const {
3300
3301   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
3302   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3303   SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
3304
3305   return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
3306 }
3307
3308 /*!
3309   Rename object by entry.
3310   \param entry entry of the object
3311   \param name new name of the object
3312   \brief Return \c true if rename operation finished successfully, \c false otherwise.
3313 */
3314 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
3315 {
3316   bool result = false;
3317
3318   SalomeApp_Application* app =
3319     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3320   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3321
3322   if (!appStudy)
3323     return result;
3324
3325   _PTR(Study) aStudy = appStudy->studyDS();
3326
3327   if (!aStudy)
3328     return result;
3329
3330   bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
3331   if ( aLocked ) {
3332     SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
3333     return result;
3334   }
3335
3336   _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
3337   _PTR(GenericAttribute) anAttr;
3338   if ( obj ) {
3339     if ( obj->FindAttribute(anAttr, "AttributeName") ) {
3340       _PTR(AttributeName) aName (anAttr);
3341
3342       aName->SetValue( name.toLatin1().data() ); // rename the SObject
3343       GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
3344       if (!CORBA::is_nil(anObj)) {
3345         anObj->SetName( name.toLatin1().data() );  // Rename the corresponding GEOM_Object
3346       }
3347       result = true;
3348     }
3349   }
3350   return result;
3351 }
3352
3353 void GeometryGUI::updateMaterials()
3354 {
3355   LightApp_Preferences* pref = preferences();
3356   if ( pref ) {
3357     QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
3358     QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
3359     if ( !materials.contains( currentMaterial ) )
3360       // user material set as default in the preferences, might be removed
3361       SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
3362
3363     QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
3364     if ( prefItem ) {
3365       setPreferenceProperty( prefItem->id(),
3366                              "strings", materials );
3367       prefItem->retrieve();
3368     }
3369   }
3370 }
3371
3372 /*!
3373   \brief Check if the module allows "drag" operation of its objects.
3374
3375   Overloaded from LightApp_Module class.
3376   
3377   This function is a part of the general drag-n-drop mechanism.
3378   The goal of this function is to check data object passed as a parameter
3379   and decide if it can be dragged or no.
3380
3381   \param what data object being tested for drag operation
3382   \return \c true if module allows dragging of the specified object
3383   \sa isDropAccepted(), dropObjects()
3384 */
3385 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
3386 {
3387   // we allow dragging object under root and object from folder
3388   int aLevel = what->level();
3389   bool anObjectInFolder = false;
3390   if ( aLevel > 2 ) {
3391     const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
3392     if ( dataObj ) {
3393       _PTR(SObject) aSO = dataObj->object();
3394       if ( aSO ) {
3395         _PTR(GenericAttribute) anAttr;
3396         _PTR(SObject) aFatherSO = aSO->GetStudy()->GetUseCaseBuilder()->GetFather( aSO );
3397         if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3398           _PTR(AttributeLocalID) aLocalID( anAttr );
3399           anObjectInFolder = aLocalID->Value() == 999;
3400         }
3401       }
3402     }
3403   }
3404   return aLevel == 2 || anObjectInFolder;
3405 }
3406
3407 /*!
3408   \brief Check if the module allows "drop" operation on the given object.
3409
3410   Overloaded from LightApp_Module class.
3411
3412   This function is a part of the general drag-n-drop mechanism.
3413   The goal of this function is to check data object passed as a parameter
3414   and decide if it can be used as a target for the "drop" operation.
3415   The processing of the drop operation itself is done in the dropObjects() function.
3416
3417   \param where target data object
3418   \return \c true if module supports dropping on the \a where data object
3419   \sa isDraggable(), dropObjects()
3420 */
3421 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
3422 {
3423   // we allow dropping into folder and top-level GEOM object
3424   int aLevel = where->level();
3425   bool isFolder = false;
3426   if ( aLevel > 1 ) {
3427     const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
3428     if ( dataObj ) {
3429       _PTR(SObject) aSO = dataObj->object();
3430       if ( aSO ) {
3431         _PTR(GenericAttribute) anAttr;
3432         if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3433           _PTR(AttributeLocalID) aLocalID( anAttr );
3434           isFolder = aLocalID->Value() == 999;
3435         }
3436       }
3437     }
3438   }
3439   return aLevel == 1 || isFolder;
3440 }
3441
3442 /*!
3443   \brief Complete drag-n-drop operation.
3444   
3445   Overloaded from LightApp_Module class.
3446
3447   This function is a part of the general drag-n-drop mechanism.
3448   Its goal is to handle dropping of the objects being dragged according
3449   to the chosen operation (move). The dropping is performed in the
3450   context of the parent data object \a where and the \a row (position in the 
3451   children index) at which the data should be dropped. If \a row is equal to -1,
3452   this means that objects are added to the end of the children list.
3453
3454   \param what objects being dropped
3455   \param where target data object
3456   \param row child index at which the drop operation is performed
3457   \param action drag-n-drop operation (Qt::DropAction) - move
3458
3459   \sa isDraggable(), isDropAccepted()
3460 */
3461 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
3462                                const int row, Qt::DropAction action )
3463 {
3464   if (action != Qt::CopyAction && action != Qt::MoveAction)
3465     return; // unsupported action
3466
3467   // get parent object
3468   SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
3469   if ( !dataObj ) return; // wrong parent
3470   _PTR(SObject) parentObj = dataObj->object();
3471
3472   // Find the current Study and StudyBuilder
3473   _PTR(Study) aStudy = parentObj->GetStudy();
3474   _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
3475   // collect all parents of the target node
3476   QStringList parentIDs;
3477   _PTR(SObject) parent = parentObj;
3478   while( !parent->IsNull() ) {
3479     parentIDs << parent->GetID().c_str();
3480     parent = aUseCaseBuilder->GetFather(parent);
3481   }
3482
3483   // collect objects being dropped
3484   GEOM::object_list_var objects = new GEOM::object_list();
3485   objects->length( what.count() );
3486   int count = 0;
3487   for ( int i = 0; i < what.count(); i++ ) {
3488     dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
3489     if ( !dataObj ) continue;  // skip wrong objects
3490     _PTR(SObject) sobj = dataObj->object();
3491     // check that dropped object is not a parent of target object
3492     if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
3493       return; // it's not allowed to move node into it's child 
3494     }
3495     objects[i] = _CAST(SObject, sobj)->GetSObject();
3496     count++;
3497   }
3498   objects->length( count );
3499
3500   // call engine function
3501   GetGeomGen()->Move( objects.in(),                              // what
3502                       _CAST(SObject, parentObj)->GetSObject(),   // where
3503                       row );                                     // row
3504
3505   // update Object browser
3506   getApp()->updateObjectBrowser( false );
3507 }