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