Salome HOME
Compilation SALOME on Windows
[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           QString actionStat = anActionData.myStatusBar;
1638           actionStat = actionStat.toUpper().prepend("STB_");
1639
1640           createAction(id, // ~ anActionData.myLabel
1641                        tr(actionTool.toLatin1().constData()),
1642                        icon,
1643                        tr(actionName.toLatin1().constData()),
1644                        tr(actionStat.toLatin1().constData()),
1645                        0 /*accel*/,
1646                        application()->desktop(),
1647                        false /*toggle*/,
1648                        this, SLOT(OnGUIEvent()),
1649                        QString() /*shortcutAction*/);
1650
1651           int menuId = -1;
1652           foreach (QString subMenu, smenus) {
1653             subMenu = subMenu.toUpper().prepend("MEN_");
1654             menuId = createMenu(tr(subMenu.toLatin1().constData()), menuId, -1);
1655           }
1656           //createMenu(id, pluginMenuId, -1);
1657           createMenu(id, menuId, -1);
1658
1659           QString subTool = stools[0];
1660           subTool = subTool.toUpper().prepend("TOOL_");
1661           int toolId = createTool(tr(subTool.toLatin1().constData()));
1662           //createTool(id, advancedTbarId);
1663           createTool(id, toolId);
1664
1665           // add action id to map
1666           PluginAction anAction (aXmlHandler->myPluginData.myClientLib, anActionData.myLabel);
1667           myPluginActions[id] = anAction;
1668
1669           id++;
1670         }
1671       }
1672       else {
1673         SUIT_MessageBox::critical(application()->desktop(),
1674                                   tr("INF_PARSE_ERROR"),
1675                                   tr(aXmlHandler->errorProtocol().toLatin1().data()));
1676       }
1677       delete aXmlHandler;
1678     }
1679     else if ( i > 0 ) { // 1st is ~/CustomGeomPlugins.xml
1680       if (aNoAccessFiles.isEmpty())
1681         aNoAccessFiles = xmlFile;
1682       else
1683         aNoAccessFiles += ", " + xmlFile;
1684     }
1685   } // end loop on xmlFiles
1686
1687   if (!aNoAccessFiles.isEmpty()) {
1688     QString aMess = QObject::tr("PLUGIN_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n";
1689     aMess += QObject::tr("PLUGIN_FILE_CHECK_VARIABLE");
1690     SUIT_MessageBox::warning(application()->desktop(), tr("GEOM_WRN_WARNING"), aMess);
1691   }
1692 }
1693
1694 //=======================================================================
1695 // function : GeometryGUI::activateModule()
1696 // purpose  : Called when GEOM module is activated
1697 //=======================================================================
1698 bool GeometryGUI::activateModule( SUIT_Study* study )
1699 {
1700   if ( CORBA::is_nil( myComponentGeom ) )
1701     return false;
1702
1703   bool res = SalomeApp_Module::activateModule( study );
1704
1705   if ( !res )
1706     return false;
1707   setMenuShown( true );
1708   setToolShown( true );
1709
1710   // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1711   PyGILState_STATE gstate = PyGILState_Ensure();
1712   PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1713   if (pluginsmanager == NULL)
1714     PyErr_Print();
1715   else {
1716     PyObject* result =
1717       PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1718                           tr("MEN_NEW_ENTITY").toStdString().c_str(),
1719                           tr("GEOM_PLUGINS_OTHER").toStdString().c_str());
1720     if (result == NULL)
1721       PyErr_Print();
1722     Py_XDECREF(result);
1723   }
1724   PyGILState_Release(gstate);
1725   // end of GEOM plugins loading
1726
1727   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1728           this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1729
1730   // Reset actions accelerator keys
1731   action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1732   action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1733   action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1734
1735   GUIMap::Iterator it;
1736   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1737     it.value()->activate( application()->desktop() );
1738
1739   LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1740
1741   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1742   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ));
1743
1744   if ( !myCreationInfoWdg )
1745     myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1746   getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1747   getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1748
1749   SUIT_ViewManager* vm;
1750   ViewManagerList OCCViewManagers, VTKViewManagers;
1751
1752   application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1753   QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1754   while ( itOCC.hasNext() && (vm = itOCC.next()) )
1755     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1756
1757   application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1758   QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1759   while ( itVTK.hasNext() && (vm = itVTK.next()) )
1760     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1761
1762   //NPAL 19674
1763   SALOME_ListIO selected;
1764   sm->selectedObjects( selected );
1765   sm->clearSelected();
1766
1767   // disable OCC selectors
1768   getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1769   QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1770   while ( itOCCSel.hasNext() )
1771     if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1772       sr->setEnabled(true);
1773
1774   // disable VTK selectors
1775   getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1776   QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1777   while ( itVTKSel.hasNext() )
1778     if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1779       sr->setEnabled(true);
1780
1781   sm->setSelectedObjects( selected, true );   //NPAL 19674
1782
1783   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1784   if ( viewMenu )
1785     connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1786
1787   // 0020836 (Basic vectors and origin)
1788   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1789   if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1790     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1791     if ( appStudy ) {
1792       _PTR(Study) studyDS = appStudy->studyDS();
1793       if ( studyDS ) {
1794         _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1795         if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1796           createOriginAndBaseVectors();
1797       }
1798     }
1799   }
1800
1801   return true;
1802 }
1803
1804 //=======================================================================
1805 // function : GeometryGUI::deactivateModule()
1806 // purpose  : Called when GEOM module is deactivated
1807 //=======================================================================
1808 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1809 {
1810   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1811   if ( viewMenu )
1812     disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1813
1814   setMenuShown( false );
1815   setToolShown( false );
1816
1817   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1818              this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1819
1820   LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
1821
1822   disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1823   getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
1824   myCreationInfoWdg = 0;
1825
1826   EmitSignalCloseAllDialogs();
1827
1828   GUIMap::Iterator it;
1829   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1830     it.value()->deactivate();
1831
1832   // Unset actions accelerator keys
1833   action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1834   action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1835   action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1836
1837   qDeleteAll(myOCCSelectors);
1838   myOCCSelectors.clear();
1839   selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
1840
1841   qDeleteAll(myVTKSelectors);
1842   myVTKSelectors.clear();
1843   selMrg->setEnabled( true, SVTK_Viewer::Type() );
1844
1845   return SalomeApp_Module::deactivateModule( study );
1846 }
1847
1848 //=======================================================================
1849 // function : onWindowActivated()
1850 // purpose  : update menu items' status - disable non-OCC-viewer-compatible actions
1851 //=======================================================================
1852 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1853 {
1854   if ( !win )
1855     return;
1856
1857   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1858   //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1859
1860   // disable non-OCC viewframe menu commands
1861 //  action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1862   action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1863   action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1864   action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1865   action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1866   action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1867 //  action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1868
1869   action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1870   action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1871
1872   action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1873 }
1874
1875 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1876 {
1877   mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1878   mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1879   if ( myCreationInfoWdg )
1880     mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1881 }
1882
1883 void GeometryGUI::viewManagers( QStringList& lst ) const
1884 {
1885   lst.append( OCCViewer_Viewer::Type() );
1886 }
1887
1888 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1889 {
1890   if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1891   {
1892     qDebug( "connect" );
1893     connect( vm, SIGNAL( keyPress  ( SUIT_ViewWindow*, QKeyEvent* ) ),
1894              this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1895     connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1896              this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1897     connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1898              this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1899     connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
1900              this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
1901
1902     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1903     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1904
1905     // disable OCC selectors
1906     getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1907     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1908     while ( itOCCSel.hasNext() )
1909       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1910         sr->setEnabled(true);
1911   }
1912   else if ( vm->getType() == SVTK_Viewer::Type() )
1913   {
1914     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1915     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1916
1917     // disable VTK selectors
1918     getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1919     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1920     while ( itVTKSel.hasNext() )
1921       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1922         sr->setEnabled(true);
1923   }
1924 }
1925
1926 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1927 {
1928   SUIT_ViewModel* viewer = vm->getViewModel();
1929   if ( vm->getType() == OCCViewer_Viewer::Type() )
1930   {
1931     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1932     while ( itOCCSel.hasNext() )
1933       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1934         if ( sr->viewer() == viewer )
1935         {
1936           /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1937           break;
1938         }
1939   }
1940   if ( vm->getType() == SVTK_Viewer::Type() )
1941   {
1942     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1943     while ( itVTKSel.hasNext() )
1944       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1945         if ( sr->viewer() == viewer )
1946         {
1947           /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1948           break;
1949         }
1950   }
1951 }
1952
1953 //================================================================================
1954 /*!
1955  * \brief Slot called when selection changed. Shows creation info of a selected object
1956  */
1957 //================================================================================
1958
1959 void GeometryGUI::updateCreationInfo()
1960 {
1961   if ( myCreationInfoWdg )
1962     myCreationInfoWdg->clear();
1963
1964   // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
1965   // if ( !myCreationInfoWdg->isVisible() )
1966   //   return;
1967
1968   // look for a sole selected GEOM_Object
1969   GEOM::GEOM_Object_var geomObj;
1970
1971   SALOME_ListIO selected;
1972   getApp()->selectionMgr()->selectedObjects( selected );
1973
1974   _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
1975   SALOME_ListIteratorOfListIO selIt( selected );
1976   for ( ; selIt.More(); selIt.Next() )
1977   {
1978     Handle(SALOME_InteractiveObject) io = selIt.Value();
1979     if ( !io->hasEntry() ) continue;
1980     _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
1981     if ( !sobj ) continue;
1982     CORBA::Object_var      obj = GeometryGUI::ClientSObjectToObject( sobj );
1983     GEOM::GEOM_Object_var gobj = GEOM::GEOM_Object::_narrow( obj );
1984     if ( !gobj->_is_nil() )
1985     {
1986       if ( !geomObj->_is_nil() )
1987         return; // several GEOM objects selected
1988       geomObj = gobj;
1989     }
1990   }
1991   if ( geomObj->_is_nil() ) return;
1992
1993   // pass creation info of geomObj to myCreationInfoWdg
1994
1995   if ( myCreationInfoWdg ) {
1996     QPixmap icon;
1997     QString operationName;
1998     myCreationInfoWdg->setOperation( icon, operationName );
1999
2000     try {
2001       OCC_CATCH_SIGNALS;
2002       GEOM::CreationInformation_var info = geomObj->GetCreationInformation();
2003       if ( &info.in() ) {
2004         SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2005         QString name = info->operationName.in();
2006         if ( !name.isEmpty() ) {
2007           icon = resMgr->loadPixmap( "GEOM", tr( ("ICO_"+name).toLatin1().constData() ), false );
2008           operationName = tr( ("MEN_"+name).toLatin1().constData() );
2009           if ( operationName.startsWith( "MEN_" ))
2010             operationName = name; // no translation
2011           myCreationInfoWdg->setOperation( icon, operationName );
2012
2013           for ( size_t i = 0; i < info->params.length(); ++i )
2014             myCreationInfoWdg->addParam( info->params[i].name.in(),
2015                                          info->params[i].value.in() );
2016         }
2017       }
2018     }
2019     catch (...) {
2020     }
2021   }
2022 }
2023
2024 void GeometryGUI::onAutoBringToFront()
2025 {
2026   bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" );
2027   if( !isAutoBringToFront )
2028     return;
2029
2030   SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
2031   if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
2032         return;
2033
2034   SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
2035   if (!appStudy) return;
2036
2037   GEOM_Displayer displayer( appStudy );
2038
2039   SALOME_View* window = displayer.GetActiveView();
2040   if ( !window ) return;
2041
2042   int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
2043
2044   SALOME_ListIO selected;
2045   getApp()->selectionMgr()->selectedObjects( selected );
2046   SALOME_ListIO allObjects;
2047   window->GetVisible( allObjects );
2048
2049   for ( SALOME_ListIteratorOfListIO It( allObjects ); It.More(); It.Next() ) {
2050     Handle( SALOME_InteractiveObject ) io = It.Value();
2051     bool isSelected = false;
2052     for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
2053       Handle( SALOME_InteractiveObject ) ioSelected = It.Value();
2054       if( io->isSame( ioSelected ) )
2055         isSelected = true;
2056     }
2057     QVariant v = appStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), QVariant() );
2058     bool isTopLevel =  v.isValid() ? v.toBool() : false;
2059     if( isSelected && !isTopLevel ) {
2060       appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
2061       if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2062     }
2063     else if( !isSelected ) {
2064       appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
2065       if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2066     }
2067   }
2068   displayer.UpdateViewer();
2069   GeometryGUI::Modified();
2070 }
2071
2072 QString GeometryGUI::engineIOR() const
2073 {
2074   if ( !CORBA::is_nil( GetGeomGen() ) )
2075     return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
2076   return "";
2077 }
2078
2079 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
2080 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
2081 #else
2082 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture
2083 #endif
2084       (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
2085 {
2086   theWidth = theHeight = 0;
2087
2088 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
2089   Handle(TColStd_HArray1OfByte) aTexture;
2090 #else
2091   Handle(Graphic3d_HArray1OfBytes) aTexture;
2092 #endif
2093
2094   if (theStudy) {
2095     TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
2096     aTexture = aTextureMap[ theId ];
2097     if ( aTexture.IsNull() ) {
2098       GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
2099       if ( !aInsOp->_is_nil() ) {
2100         CORBA::Long aWidth, aHeight;
2101         SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
2102         if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
2103           theWidth  = aWidth;
2104           theHeight = aHeight;
2105
2106 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
2107           aTexture  = new TColStd_HArray1OfByte (1, aStream->length());
2108 #else
2109           aTexture  = new Graphic3d_HArray1OfBytes (1, aStream->length());
2110 #endif
2111
2112           for (int i = 0; i < aStream->length(); i++)
2113             aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
2114           aTextureMap[ theId ] = aTexture;
2115         }
2116       }
2117     }
2118   }
2119   return aTexture;
2120 }
2121
2122 LightApp_Selection* GeometryGUI::createSelection() const
2123 {
2124   return new GEOMGUI_Selection();
2125 }
2126
2127 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
2128 {
2129   SalomeApp_Module::contextMenuPopup( client, menu, title );
2130   SALOME_ListIO lst;
2131   getApp()->selectionMgr()->selectedObjects( lst );
2132
2133   //Add submenu for predefined materials
2134   bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
2135   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
2136     QtxPopupMgr* mgr = popupMgr();
2137     //get parrent for submenu
2138     QAction* act = mgr->action( mgr->actionId( action(  GEOMOp::OpMaterialProperties ) ) );
2139     //Clear old  menu
2140     QMenu* oldMenu = act->menu() ;
2141     if( oldMenu ) {
2142       delete oldMenu;
2143     }
2144     if( isPredefMat ){
2145       QMenu* matMenu = new QMenu();
2146       QSignalMapper* signalMapper = new QSignalMapper( matMenu );
2147
2148       //Get current material model for the object
2149       QVariant v;
2150       LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
2151       if ( anApp && anApp->activeViewManager() ) {
2152         LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
2153         if( aStudy ) {
2154           v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
2155         }
2156       }
2157       QString curModel = "";
2158       if ( v.canConvert<QString>() ) curModel = v.toString();
2159       // get list of all predefined materials
2160       QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2161       bool found = false;
2162       foreach ( QString material, materials )
2163       {
2164         QAction* menAct = matMenu->addAction( material );
2165         connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
2166         signalMapper->setMapping( menAct, material );
2167         menAct->setCheckable( true );
2168         // Set checked if this material is current
2169         Material_Model aModel;
2170         aModel.fromResources( material );
2171         if ( !found && aModel.toProperties() == curModel ) {
2172           menAct->setChecked( true );
2173           found = true;
2174         }
2175       }
2176       matMenu->insertAction( matMenu->addSeparator(), action(  GEOMOp::OpPredefMaterCustom ) );
2177       matMenu->insertSeparator( action(  GEOMOp::OpPredefMaterCustom ) );
2178       connect( signalMapper, SIGNAL( mapped( const QString & ) ),
2179                  this, SLOT( OnSetMaterial( const QString & ) ) );
2180       act->setMenu( matMenu );
2181     }
2182   }
2183   //Set name
2184   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
2185     Handle(SALOME_InteractiveObject) io = lst.First();
2186     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2187     _PTR(Study) study = appStudy->studyDS();
2188     _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
2189     if ( obj ) {
2190       QString aName = QString( obj->GetName().c_str() );
2191       aName.remove( QRegExp("\\s+$") );
2192       title = aName;
2193     }
2194   }
2195 }
2196
2197 void GeometryGUI::OnSetMaterial(const QString& theName)
2198 {
2199   OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
2200 }
2201
2202
2203 void GeometryGUI::createPreferences()
2204 {
2205   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
2206
2207   int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
2208   setPreferenceProperty( genGroup, "columns", 2 );
2209
2210   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
2211                                 LightApp_Preferences::Selector,
2212                                 "Geometry", "display_mode" );
2213
2214   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
2215                  LightApp_Preferences::Color, "Geometry", "shading_color" );
2216
2217   addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
2218                  LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
2219
2220   addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
2221                  LightApp_Preferences::Color, "Geometry", "wireframe_color" );
2222
2223   addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
2224                  LightApp_Preferences::Color, "Geometry", "free_bound_color" );
2225
2226   addPreference( tr( "PREF_LINE_COLOR"), genGroup,
2227                  LightApp_Preferences::Color, "Geometry", "line_color" );
2228
2229   addPreference( tr( "PREF_POINT_COLOR"), genGroup,
2230                  LightApp_Preferences::Color, "Geometry", "point_color" );
2231
2232   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
2233                  LightApp_Preferences::Color, "Geometry", "isos_color" );
2234
2235   addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
2236                  LightApp_Preferences::Color, "Geometry", "toplevel_color" );
2237
2238   int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
2239                       LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
2240
2241   int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
2242                             LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
2243
2244   int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
2245                             LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
2246
2247   addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
2248                  LightApp_Preferences::Bool, "Geometry", "predef_materials" );
2249
2250   int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
2251                                 LightApp_Preferences::Selector,
2252                                 "Geometry", "material" );
2253
2254   addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
2255                  LightApp_Preferences::Color, "Geometry", "editgroup_color" );
2256
2257   const int nb = 4;
2258   int wd[nb];
2259   int iter=0;
2260
2261   wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
2262                               LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
2263
2264   wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
2265                               LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
2266
2267   wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
2268                                      LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
2269
2270   wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
2271                               LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
2272
2273   for (int i = 0; i < nb; i++) {
2274     setPreferenceProperty( wd[i], "min", 1 );
2275     setPreferenceProperty( wd[i], "max", 5 );
2276   }
2277
2278   addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
2279                  LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
2280
2281   int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
2282   setPreferenceProperty( isoGroup, "columns", 2 );
2283   int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2284                             LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
2285   setPreferenceProperty( isoU, "min", 0 );
2286   setPreferenceProperty( isoU, "max", 100000 );
2287   int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2288                             LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
2289   setPreferenceProperty( isoV, "min", 0 );
2290   setPreferenceProperty( isoV, "max", 100000 );
2291
2292   // Quantities with individual precision settings
2293   int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
2294   setPreferenceProperty( precGroup, "columns", 2 );
2295
2296   const int nbQuantities = 8;
2297   int prec[nbQuantities], ii = 0;
2298   prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
2299                               LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
2300   prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
2301                               LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
2302   prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
2303                               LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
2304   prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
2305                               LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
2306   prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
2307                               LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
2308   prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
2309                               LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
2310   prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
2311                               LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
2312   prec[ii  ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
2313                               LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
2314
2315   // Set property for precision value for spinboxes
2316   for ( ii = 0; ii < nbQuantities; ii++ ){
2317     setPreferenceProperty( prec[ii], "min", -14 );
2318     setPreferenceProperty( prec[ii], "max", 14 );
2319     setPreferenceProperty( prec[ii], "precision", 2 );
2320   }
2321
2322   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
2323   setPreferenceProperty( VertexGroup, "columns", 2 );
2324
2325   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2326                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2327
2328   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2329                                    LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2330
2331   // Set property for default display mode
2332   QStringList aModesList;
2333   aModesList.append( tr("MEN_WIREFRAME") );
2334   aModesList.append( tr("MEN_SHADING") );
2335   aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2336
2337   QList<QVariant> anIndexesList;
2338   anIndexesList.append(0);
2339   anIndexesList.append(1);
2340   anIndexesList.append(2);
2341
2342   setPreferenceProperty( dispmode, "strings", aModesList );
2343   setPreferenceProperty( dispmode, "indexes", anIndexesList );
2344
2345   // Set property for top level display mode
2346   QStringList aTopModesList;
2347   aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2348   aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2349   aTopModesList.append( tr("MEN_WIREFRAME") );
2350   aTopModesList.append( tr("MEN_SHADING") );
2351   aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2352
2353   QList<QVariant> aTopIndexesList;
2354   aTopIndexesList.append(0);
2355   aTopIndexesList.append(1);
2356   aTopIndexesList.append(2);
2357   aTopIndexesList.append(3);
2358   aTopIndexesList.append(4);
2359
2360   setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2361   setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2362
2363   // Set property for step value for spinboxes
2364   setPreferenceProperty( step, "min", 1 );
2365   setPreferenceProperty( step, "max", 10000 );
2366   setPreferenceProperty( step, "precision", 3 );
2367
2368   // Set property for deflection value for spinboxes
2369   setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2370   setPreferenceProperty( defl, "max", 1.0 );
2371   setPreferenceProperty( defl, "step", 1.0e-04 );
2372   setPreferenceProperty( defl, "precision", 6 );
2373
2374   // Set property for default material
2375   setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2376
2377   // Set property vertex marker type
2378   QList<QVariant> aMarkerTypeIndicesList;
2379   QList<QVariant> aMarkerTypeIconsList;
2380
2381   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2382   for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2383     QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2384     QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2385     aMarkerTypeIndicesList << (i-1);
2386     aMarkerTypeIconsList << pixmap;
2387   }
2388
2389   setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2390   setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
2391
2392   // Set property for vertex marker scale
2393   QList<QVariant> aMarkerScaleIndicesList;
2394   QStringList     aMarkerScaleValuesList;
2395
2396   for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2397     aMarkerScaleIndicesList << iii;
2398     aMarkerScaleValuesList  << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2399   }
2400
2401   setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2402   setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2403
2404   int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2405   setPreferenceProperty( originGroup, "columns", 2 );
2406
2407   int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2408                                          LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2409   setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2410   setPreferenceProperty( baseVectorsLength, "max", 1000 );
2411
2412   addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2413                  LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2414
2415   int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2416   setPreferenceProperty( operationsGroup, "columns", 2 );
2417
2418   addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2419                  LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2420 }
2421
2422 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2423 {
2424   if (section == "Geometry") {
2425     SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2426     if (param == QString("SettingsGeomStep")) {
2427       double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2428       EmitSignalDefaultStepValueChanged(spin_step);
2429     }
2430     else if (param == QString("toplevel_color")) {
2431       QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2432       GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2433     }
2434     else if (param == QString("toplevel_dm")) {
2435       GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2436     }
2437   }
2438 }
2439
2440 LightApp_Displayer* GeometryGUI::displayer()
2441 {
2442   if ( !myDisplayer )
2443     myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
2444   return myDisplayer;
2445 }
2446
2447 void GeometryGUI::setLocalSelectionMode(const int mode)
2448 {
2449   myLocalSelectionMode = mode;
2450 }
2451
2452 int GeometryGUI::getLocalSelectionMode() const
2453 {
2454   return myLocalSelectionMode;
2455 }
2456
2457 const char gSeparator = '_'; // character used to separate parameter names
2458 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2459
2460 /*!
2461  * \brief Store visual parameters
2462  *
2463  * This method is called just before the study document is saved.
2464  * Store visual parameters in AttributeParameter attribute(s)
2465  */
2466 void GeometryGUI::storeVisualParameters (int savePoint)
2467 {
2468   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2469   if ( !appStudy || !appStudy->studyDS() )
2470     return;
2471   _PTR(Study) studyDS = appStudy->studyDS();
2472
2473   // componentName is used for encoding of entries when storing them in IParameters
2474   std::string componentName = myComponentGeom->ComponentDataType();
2475   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2476   //if (!aSComponent) return;
2477
2478   // IParameters
2479   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2480                                                              componentName.c_str(),
2481                                                              savePoint);
2482   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2483
2484   QList<SUIT_ViewManager*> lst;
2485   QList<SUIT_ViewManager*>::Iterator it;
2486
2487   // main cycle to store parameters of displayed objects
2488   lst.clear();
2489   getApp()->viewManagers(lst);
2490   for (it = lst.begin(); it != lst.end(); it++) {
2491     SUIT_ViewManager* vman = *it;
2492     QString vType = vman->getType();
2493     int aMgrId = vman->getGlobalId();
2494     // saving VTK actors properties
2495     QVector<SUIT_ViewWindow*> views = vman->getViews();
2496     for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
2497       const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
2498       ObjMap::ConstIterator o_it = anObjects.begin();
2499       for (; o_it != anObjects.end(); o_it++) {
2500         const PropMap aProps = o_it.value();
2501
2502         //Check that object exists in the study
2503         _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
2504         if ( !obj || !(aProps.count() > 0))
2505           continue;
2506         // entry is "encoded" = it does NOT contain component adress, since it is a
2507         // subject to change on next component loading
2508
2509         std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
2510
2511         _PTR(GenericAttribute) anAttr;
2512         if (!obj->FindAttribute(anAttr, "AttributeIOR"))
2513           continue;
2514
2515         QString param, occParam = vType;
2516         occParam += GEOM::sectionSeparator();
2517         occParam += QString::number(aMgrId);
2518         occParam += GEOM::sectionSeparator();
2519
2520         if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
2521           param = occParam + GEOM::propertyName( GEOM::Visibility );
2522           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
2523         }
2524
2525         if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
2526           param = occParam + GEOM::propertyName( GEOM::DisplayMode );
2527           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
2528         }
2529
2530         if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
2531           QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
2532           QStringList val;
2533           val << QString::number(c.redF());
2534           val << QString::number(c.greenF());
2535           val << QString::number(c.blueF());
2536           param = occParam + GEOM::propertyName( GEOM::Color );
2537           ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
2538         }
2539
2540         if (vType == SVTK_Viewer::Type()) {
2541           if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
2542             param = occParam + GEOM::propertyName( GEOM::Opacity );
2543             ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
2544           }
2545         } else if (vType == SOCC_Viewer::Type()) {
2546           if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
2547             param = occParam + GEOM::propertyName( GEOM::Transparency );
2548             ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
2549           }
2550
2551           if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
2552             param = occParam + GEOM::propertyName( GEOM::TopLevel );
2553             ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
2554           }
2555         }
2556
2557         if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
2558           param = occParam + GEOM::propertyName( GEOM::NbIsos );
2559           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
2560         }
2561
2562         if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
2563           param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
2564           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
2565         }
2566
2567         if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
2568           param = occParam + GEOM::propertyName( GEOM::Deflection );
2569           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
2570         }
2571
2572         //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
2573         if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
2574           param = occParam + GEOM::propertyName( GEOM::PointMarker );
2575           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
2576         }
2577
2578         if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
2579           param = occParam + GEOM::propertyName( GEOM::Material );
2580           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
2581         }
2582
2583         if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
2584              param = occParam + GEOM::propertyName( GEOM::LineWidth );
2585            ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
2586         }
2587
2588         if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
2589           param = occParam + GEOM::propertyName( GEOM::IsosWidth );
2590           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
2591         }
2592       } // object iterator
2593     } // for (views)
2594   } // for (viewManagers)
2595 }
2596
2597 /*!
2598  * \brief Restore visual parameters
2599  *
2600  * This method is called after the study document is opened.
2601  * Restore visual parameters from AttributeParameter attribute(s)
2602  */
2603 void GeometryGUI::restoreVisualParameters (int savePoint)
2604 {
2605   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2606   if (!appStudy || !appStudy->studyDS())
2607     return;
2608   _PTR(Study) studyDS = appStudy->studyDS();
2609
2610   // componentName is used for encoding of entries when storing them in IParameters
2611   std::string componentName = myComponentGeom->ComponentDataType();
2612   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2613   //if (!aSComponent) return;
2614
2615   // IParameters
2616   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2617                                                              componentName.c_str(),
2618                                                              savePoint);
2619   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2620
2621   std::vector<std::string> entries = ip->getEntries();
2622
2623   for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
2624   {
2625     // entry is a normal entry - it should be "decoded" (setting base adress of component)
2626     QString entry (ip->decodeEntry(*entIt).c_str());
2627
2628     // Check that the entry corresponds to a real object in the Study
2629     // as the object may be deleted or modified after the visual state is saved.
2630     _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
2631     if (!so) continue; //Skip the not existent entry
2632
2633     std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
2634     std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
2635
2636     std::vector<std::string>::iterator namesIt = paramNames.begin();
2637     std::vector<std::string>::iterator valuesIt = paramValues.begin();
2638
2639     // actors are stored in a map after displaying of them for
2640     // quicker access in the future: map < viewID to actor >
2641     NCollection_DataMap<int, GEOM_Actor*          > vtkActors;
2642     NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
2643
2644     QString viewerTypStr;
2645     QString viewIndexStr;
2646     int viewIndex;
2647     QVector<PropMap> aListOfMap;
2648
2649     for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
2650     {
2651       // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
2652       // '_' is used as separator and should not be used in viewer type or parameter names.
2653       QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
2654       if (lst.size() != 3)
2655         continue;
2656
2657       viewerTypStr = lst[0];
2658       viewIndexStr = lst[1];
2659       QString paramNameStr = lst[2];
2660
2661       bool ok;
2662       viewIndex = viewIndexStr.toUInt(&ok);
2663       if (!ok) // bad conversion of view index to integer
2664         continue;
2665
2666       if ((viewIndex + 1) > aListOfMap.count()) {
2667         aListOfMap.resize(viewIndex + 1);
2668       }
2669
2670       QString val((*valuesIt).c_str());
2671       if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
2672         aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
2673       } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
2674         aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
2675       } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
2676         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
2677       } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
2678         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
2679       } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
2680         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
2681       } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
2682         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
2683       } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
2684         QStringList rgb = val.split(GEOM::subSectionSeparator());
2685         if (rgb.count() == 3) {
2686           QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
2687           aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
2688         }
2689       } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
2690         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
2691       } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
2692         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
2693       } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
2694         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
2695       } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
2696         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
2697       } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
2698         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
2699       } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
2700         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
2701       }
2702     } // for names/parameters iterator
2703
2704     QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
2705
2706     for (int index = 0; index < aListOfMap.count(); index++) {
2707
2708       appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
2709
2710       //Get Visibility property of the current PropMap
2711       if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
2712         SUIT_ViewManager* vman = lst.at(index);
2713         SUIT_ViewModel* vmodel = vman->getViewModel();
2714         displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
2715       }
2716     }
2717   } // for entries iterator
2718
2719   // update all VTK and OCC views
2720   QList<SUIT_ViewManager*> lst;
2721   getApp()->viewManagers(lst);
2722   for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
2723     SUIT_ViewModel* vmodel = (*it)->getViewModel();
2724     if (!vmodel)
2725       continue;
2726     if (vmodel->getType() == SVTK_Viewer::Type()) {
2727       SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
2728       vtkView->getRenderer()->ResetCameraClippingRange();
2729       vtkView->Repaint();
2730     }
2731     else if (vmodel->getType() == SOCC_Viewer::Type()) {
2732       //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
2733       SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
2734       if (occVMod)
2735         occVMod->Repaint();
2736     }
2737   }
2738 }
2739
2740 void GeometryGUI::onViewAboutToShow()
2741 {
2742   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
2743   QAction* a = action( GEOMOp::OpSwitchVectors );
2744   if ( window ) {
2745     a->setEnabled(true);
2746     bool vmode = window->property("VectorsMode").toBool();
2747     a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
2748   } else {
2749     a->setText ( tr("MEN_VECTOR_MODE_ON") );
2750     a->setEnabled(false);
2751   }
2752 }
2753
2754 /*!
2755   \brief Return action by id
2756   \param id identifier of the action
2757   \return action
2758 */
2759 QAction* GeometryGUI::getAction(const int id) {
2760   return action(id);
2761 }
2762
2763 /*!
2764   \brief GEOM module message handler
2765
2766   This method can be re-implemented in the subclasses.
2767   This is a GEOM module message handler.
2768
2769   \param msg the message received.
2770 */
2771 void GeometryGUI::message(const QString& msg)
2772 {
2773   // dispatch message
2774   QStringList data = msg.split("/");
2775   const int nbStrings = data.count();
2776
2777   if (nbStrings > 0) {
2778     if (data[0] == "modified") {
2779       // get mesh entry
2780       QString anIOR = nbStrings > 1 ? data[1] : QString();
2781
2782       if ( anIOR.isEmpty() ) {
2783         return;
2784       }
2785
2786       // Get the geom object.
2787       GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
2788
2789       // Clear the shape buffer
2790       GeometryGUI::ClearShapeBuffer (anObj);
2791     }
2792   }
2793 }
2794
2795 /*!
2796   \brief Clears the shape buffer.
2797
2798   This is a static method. It clears the shape buffer.
2799
2800   \param theObj the object
2801 */
2802 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
2803 {
2804   if ( CORBA::is_nil( theObj ) )
2805     return;
2806
2807   CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
2808   TCollection_AsciiString asciiIOR( (char *)IOR.in() );
2809   GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
2810
2811   SALOMEDSClient_StudyManager *aManager = SalomeApp_Application::studyMgr();
2812
2813   if (!aManager)
2814     return;
2815
2816   _PTR(Study) aStudy = aManager->GetStudyByID(theObj->GetStudyID());
2817
2818   if ( !aStudy )
2819     return;
2820
2821   _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
2822   if ( !aSObj )
2823     return;
2824
2825   _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
2826   for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
2827     _PTR(GenericAttribute) anAttr;
2828     if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
2829       _PTR(AttributeIOR) anIOR ( anAttr );
2830       TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
2831       GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
2832     }
2833   }
2834 }
2835
2836 /*!
2837   \brief Returns the object from IOR.
2838
2839   This is a static method. It returns the object from its IOR.
2840
2841   \param IOR object IOR
2842   \return GEOM object.
2843 */
2844 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
2845 {
2846   GEOM::GEOM_Object_var geomObj;
2847   if ( !IOR.isEmpty() ) {
2848     CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
2849       ( IOR.toLatin1().constData() );
2850     if ( !CORBA::is_nil( corbaObj ) )
2851       geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2852   }
2853   return geomObj._retn();
2854 }
2855
2856 /*!
2857   \brief Returns IOR of the object.
2858
2859   This is a static method. It returns the object's IOR.
2860
2861   \param object the GEOM object.
2862   \return object's IOR.
2863 */
2864 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
2865 {
2866   QString IOR;
2867   if ( !CORBA::is_nil( object ) ) {
2868     CORBA::String_var anIOR =
2869       SalomeApp_Application::orb()->object_to_string( object );
2870     IOR = anIOR.in();
2871   }
2872   return IOR;
2873 }
2874
2875 /*!
2876   \brief Check if this object is can't be renamed in place
2877
2878   This method can be re-implemented in the subclasses.
2879   Return true in case if object isn't reference or component (module root).
2880
2881   \param entry column id
2882   \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
2883 */
2884 bool GeometryGUI::renameAllowed( const QString& entry) const {
2885
2886   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2887   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2888   SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
2889
2890   return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
2891 }
2892
2893 /*!
2894   Rename object by entry.
2895   \param entry entry of the object
2896   \param name new name of the object
2897   \brief Return \c true if rename operation finished successfully, \c false otherwise.
2898 */
2899 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
2900 {
2901   bool result = false;
2902
2903   SalomeApp_Application* app =
2904     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
2905   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2906
2907   if (!appStudy)
2908     return result;
2909
2910   _PTR(Study) aStudy = appStudy->studyDS();
2911
2912   if (!aStudy)
2913     return result;
2914
2915   bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
2916   if ( aLocked ) {
2917     SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
2918     return result;
2919   }
2920
2921   _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
2922   _PTR(GenericAttribute) anAttr;
2923   if ( obj ) {
2924     if ( obj->FindAttribute(anAttr, "AttributeName") ) {
2925       _PTR(AttributeName) aName (anAttr);
2926
2927       aName->SetValue( name.toLatin1().data() ); // rename the SObject
2928       GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
2929       if (!CORBA::is_nil(anObj)) {
2930         anObj->SetName( name.toLatin1().data() );  // Rename the corresponding GEOM_Object
2931       }
2932       result = true;
2933     }
2934   }
2935   return result;
2936 }
2937
2938 void GeometryGUI::updateMaterials()
2939 {
2940   LightApp_Preferences* pref = preferences();
2941   if ( pref ) {
2942     QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2943     QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
2944     if ( !materials.contains( currentMaterial ) )
2945       // user material set as default in the preferences, might be removed
2946       SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
2947
2948     QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
2949     if ( prefItem ) {
2950       setPreferenceProperty( prefItem->id(),
2951                              "strings", materials );
2952       prefItem->retrieve();
2953     }
2954   }
2955 }
2956
2957 /*!
2958   \brief Check if the module allows "drag" operation of its objects.
2959
2960   Overloaded from LightApp_Module class.
2961   
2962   This function is a part of the general drag-n-drop mechanism.
2963   The goal of this function is to check data object passed as a parameter
2964   and decide if it can be dragged or no.
2965
2966   \param what data object being tested for drag operation
2967   \return \c true if module allows dragging of the specified object
2968   \sa isDropAccepted(), dropObjects()
2969 */
2970 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
2971 {
2972   // we allow dragging object under root and object from folder
2973   int aLevel = what->level();
2974   bool anObjectInFolder = false;
2975   if ( aLevel > 2 ) {
2976     const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
2977     if ( dataObj ) {
2978       _PTR(SObject) aSO = dataObj->object();
2979       if ( aSO ) {
2980         _PTR(GenericAttribute) anAttr;
2981         _PTR(SObject) aFatherSO = aSO->GetStudy()->GetUseCaseBuilder()->GetFather( aSO );
2982         if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
2983           _PTR(AttributeLocalID) aLocalID( anAttr );
2984           anObjectInFolder = aLocalID->Value() == 999;
2985         }
2986       }
2987     }
2988   }
2989   return aLevel == 2 || anObjectInFolder;
2990 }
2991
2992 /*!
2993   \brief Check if the module allows "drop" operation on the given object.
2994
2995   Overloaded from LightApp_Module class.
2996
2997   This function is a part of the general drag-n-drop mechanism.
2998   The goal of this function is to check data object passed as a parameter
2999   and decide if it can be used as a target for the "drop" operation.
3000   The processing of the drop operation itself is done in the dropObjects() function.
3001
3002   \param where target data object
3003   \return \c true if module supports dropping on the \a where data object
3004   \sa isDraggable(), dropObjects()
3005 */
3006 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
3007 {
3008   // we allow dropping into folder and top-level GEOM object
3009   int aLevel = where->level();
3010   bool isFolder = false;
3011   if ( aLevel > 1 ) {
3012     const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
3013     if ( dataObj ) {
3014       _PTR(SObject) aSO = dataObj->object();
3015       if ( aSO ) {
3016         _PTR(GenericAttribute) anAttr;
3017         if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3018           _PTR(AttributeLocalID) aLocalID( anAttr );
3019           isFolder = aLocalID->Value() == 999;
3020         }
3021       }
3022     }
3023   }
3024   return aLevel == 1 || isFolder;
3025 }
3026
3027 /*!
3028   \brief Complete drag-n-drop operation.
3029   
3030   Overloaded from LightApp_Module class.
3031
3032   This function is a part of the general drag-n-drop mechanism.
3033   Its goal is to handle dropping of the objects being dragged according
3034   to the chosen operation (move). The dropping is performed in the
3035   context of the parent data object \a where and the \a row (position in the 
3036   children index) at which the data should be dropped. If \a row is equal to -1,
3037   this means that objects are added to the end of the children list.
3038
3039   \param what objects being dropped
3040   \param where target data object
3041   \param row child index at which the drop operation is performed
3042   \param action drag-n-drop operation (Qt::DropAction) - move
3043
3044   \sa isDraggable(), isDropAccepted()
3045 */
3046 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
3047                                const int row, Qt::DropAction action )
3048 {
3049   if (action != Qt::CopyAction && action != Qt::MoveAction)
3050     return; // unsupported action
3051
3052   // get parent object
3053   SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
3054   if ( !dataObj ) return; // wrong parent
3055   _PTR(SObject) parentObj = dataObj->object();
3056
3057   // Find the current Study and StudyBuilder
3058   _PTR(Study) aStudy = parentObj->GetStudy();
3059   _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
3060   // collect all parents of the target node
3061   QStringList parentIDs;
3062   _PTR(SObject) parent = parentObj;
3063   while( !parent->IsNull() ) {
3064     parentIDs << parent->GetID().c_str();
3065     parent = aUseCaseBuilder->GetFather(parent);
3066   }
3067
3068   // collect objects being dropped
3069   GEOM::object_list_var objects = new GEOM::object_list();
3070   objects->length( what.count() );
3071   int count = 0;
3072   for ( int i = 0; i < what.count(); i++ ) {
3073     dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
3074     if ( !dataObj ) continue;  // skip wrong objects
3075     _PTR(SObject) sobj = dataObj->object();
3076     // check that dropped object is not a parent of target object
3077     if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
3078       return; // it's not allowed to move node into it's child 
3079     }
3080     objects[i] = _CAST(SObject, sobj)->GetSObject();
3081     count++;
3082   }
3083   objects->length( count );
3084
3085   // call engine function
3086   GetGeomGen()->Move( objects.in(),                              // what
3087                       _CAST(SObject, parentObj)->GetSObject(),   // where
3088                       row );                                     // row
3089
3090   // update Object browser
3091   getApp()->updateObjectBrowser( false );
3092 }