1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : GeometryGUI.cxx
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
30 #include "GeometryGUI.h"
31 #include "GeometryGUI_Operations.h"
32 #include "GEOMPluginGUI.h"
33 #include "GEOMGUI_XmlHandler.h"
34 #include "GEOMGUI_OCCSelector.h"
35 #include "GEOMGUI_Selection.h"
36 #include "GEOMGUI_CreationInfoWdg.h"
37 #include "GEOMGUI_DimensionProperty.h"
38 #include "GEOM_Constants.h"
39 #include "GEOM_Displayer.h"
40 #include "GEOM_AISShape.hxx"
42 #include "GEOM_Actor.h"
44 #include <Material_ResourceMgr.h>
45 #include <Material_Model.h>
47 #include <SUIT_Desktop.h>
48 #include <SUIT_MessageBox.h>
49 #include <SUIT_ResourceMgr.h>
50 #include <SUIT_Session.h>
51 #include <SUIT_ViewManager.h>
53 #include <PyInterp_Interp.h>
55 #include <OCCViewer_ViewWindow.h>
56 #include <OCCViewer_ViewPort3d.h>
57 #include <OCCViewer_ViewModel.h>
58 #include <OCCViewer_ViewManager.h>
60 #include <SOCC_ViewModel.h>
61 #include <SOCC_ViewWindow.h>
63 #include <SVTK_ViewWindow.h>
64 #include <SVTK_RenderWindowInteractor.h>
65 #include <SVTK_InteractorStyle.h>
66 #include <SVTK_ViewModel.h>
68 #include <GraphicsView_Viewer.h>
70 #include <SalomeApp_Application.h>
71 #include <SalomeApp_DataObject.h>
72 #include <SalomeApp_Study.h>
73 #include <SalomeApp_Tools.h>
75 #include <LightApp_SelectionMgr.h>
76 #include <LightApp_VTKSelector.h>
77 #include <LightApp_DataObject.h>
78 #include <LightApp_Preferences.h>
80 #include <SALOME_LifeCycleCORBA.hxx>
81 // #include <SALOME_ListIO.hxx>
82 #include <SALOME_ListIteratorOfListIO.hxx>
84 #include <SALOMEDSClient_ClientFactory.hxx>
85 #include <SALOMEDSClient_IParameters.hxx>
87 #include <SALOMEDS_SObject.hxx>
89 #include <Basics_OCCTVersion.hxx>
100 #include <QSignalMapper>
102 #include <AIS_Drawer.hxx>
103 #include <AIS_ListOfInteractive.hxx>
104 #include <AIS_ListIteratorOfListOfInteractive.hxx>
105 #include <Prs3d_Drawer.hxx>
106 #include <Prs3d_IsoAspect.hxx>
107 #include <Aspect_TypeOfMarker.hxx>
108 #include <OSD_SharedLibrary.hxx>
109 #include <NCollection_DataMap.hxx>
111 #include <TColStd_HArray1OfByte.hxx>
113 #include <utilities.h>
115 #include <vtkCamera.h>
116 #include <vtkRenderer.h>
118 #include <Standard_Failure.hxx>
119 #include <Standard_ErrorHandler.hxx>
121 #include "GEOM_version.h"
122 #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
125 Standard_EXPORT CAM_Module* createModule() {
126 return new GeometryGUI();
129 Standard_EXPORT char* getModuleVersion() {
130 return (char*)GEOM_VERSION_STR;
134 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
136 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
138 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
140 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
141 if (CORBA::is_nil(myComponentGeom))
143 return GeometryGUI::myComponentGeom;
146 bool GeometryGUI::InitGeomGen()
149 if ( CORBA::is_nil( myComponentGeom ) ) return false;
153 //=======================================================================
154 // function : ClientSObjectToObject
156 //=======================================================================
157 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
159 _PTR(GenericAttribute) anAttr;
160 CORBA::Object_var anObj;
162 std::string aValue = theSObject->GetIOR();
163 if (strcmp(aValue.c_str(), "") != 0) {
164 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
165 anObj = anORB->string_to_object(aValue.c_str());
168 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
170 return anObj._retn();
173 //=======================================================================
174 // function : ClientStudyToStudy
176 //=======================================================================
177 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
179 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
180 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
181 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
182 int aStudyID = theStudy->StudyId();
183 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
184 return aDSStudy._retn();
187 void GeometryGUI::Modified (bool theIsUpdateActions)
189 if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
190 if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
191 appStudy->Modified();
192 if ( theIsUpdateActions )
193 app->updateActions();
198 //=======================================================================
199 // function : GeometryGUI::GeometryGUI()
200 // purpose : Constructor
201 //=======================================================================
202 GeometryGUI::GeometryGUI() :
203 SalomeApp_Module( "GEOM" ),
206 if ( CORBA::is_nil( myComponentGeom ) )
208 Engines::EngineComponent_var comp =
209 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
210 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
213 myActiveDialogBox = 0;
215 gp_Pnt origin = gp_Pnt(0., 0., 0.);
216 gp_Dir direction = gp_Dir(0., 0., 1.);
217 myWorkingPlane = gp_Ax3(origin, direction);
220 myLocalSelectionMode = GEOM_ALLOBJECTS;
222 myCreationInfoWdg = 0;
224 connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
226 Q_INIT_RESOURCE( GEOMGUI );
229 //=======================================================================
230 // function : GeometryGUI::~GeometryGUI()
231 // purpose : Destructor
232 //=======================================================================
233 GeometryGUI::~GeometryGUI()
235 while (!myOCCSelectors.isEmpty())
236 delete myOCCSelectors.takeFirst();
238 while (!myVTKSelectors.isEmpty())
239 delete myVTKSelectors.takeFirst();
241 qDeleteAll(myGUIMap);
244 //=======================================================================
245 // function : GeometryGUI::getLibrary()
246 // purpose : get or load GUI library by name [ internal ]
247 //=======================================================================
248 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
249 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
251 if ( !myGUIMap.contains( libraryName ) ) {
252 // try to load library if it is not loaded yet
254 QString dirs = getenv( "LD_LIBRARY_PATH" );
257 QString dirs = getenv( "PATH" );
260 if ( !dirs.isEmpty() ) {
261 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
262 QListIterator<QString> it( dirList ); it.toBack();
263 while ( it.hasPrevious() ) {
264 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
266 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
267 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
269 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
270 continue; // continue search further
272 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
273 if ( osdF != NULL ) {
274 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
275 GEOMGUI* libGUI = (*func)( this );
277 myGUIMap[ libraryName ] = libGUI;
278 break; // found and loaded!
285 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
288 //=======================================================================
289 // function : GeometryGUI::getPluginLibrary()
290 // purpose : get or load GUI Plugin library by name [ internal ]
291 //=======================================================================
292 typedef GEOMPluginGUI* (*PluginLibraryGUI)( GeometryGUI* );
293 GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName )
295 if ( !myGUIMap.contains( libraryName ) ) {
296 // try to load library if it is not loaded yet
298 QString dirs = getenv( "LD_LIBRARY_PATH" );
301 QString dirs = getenv( "PATH" );
304 if ( !dirs.isEmpty() ) {
305 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
306 QListIterator<QString> it( dirList ); it.toBack();
307 while ( it.hasPrevious() ) {
308 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
310 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
311 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
313 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
314 continue; // continue search further
316 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
317 if ( osdF != NULL ) {
318 PluginLibraryGUI func = (GEOMPluginGUI* (*) (GeometryGUI*))osdF;
319 GEOMPluginGUI* libGUI = (*func)( this );
321 myGUIMap[ libraryName ] = libGUI;
322 break; // found and loaded!
329 return myGUIMap.contains( libraryName ) ? (GEOMPluginGUI*)myGUIMap[ libraryName ] : 0;
332 //=======================================================================
333 // function : GeometryGUI::ActiveWorkingPlane()
334 // purpose : Activate Working Plane View
335 //=======================================================================
336 void GeometryGUI::ActiveWorkingPlane()
338 gp_Dir DZ = myWorkingPlane.Direction();
339 gp_Dir DY = myWorkingPlane.YDirection();
341 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
342 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
343 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
346 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
348 Handle(V3d_View) view3d = vw->getViewPort()->getView();
350 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
351 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
355 else if ( ViewVTK ) {
356 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
358 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
360 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
361 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
362 camera->SetFocalPoint(0,0,0);
369 //=======================================================================
370 // function : GeometryGUI::SetActiveDialogBox()
371 // purpose : Set active dialog box
372 //=======================================================================
373 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
375 myActiveDialogBox = (QDialog*)aDlg;
378 //=======================================================================
379 // function : GeometryGUI::EmitSignalDeactivateDialog()
380 // purpose : Emit a signal to deactivate the active dialog Box
381 //=======================================================================
382 void GeometryGUI::EmitSignalDeactivateDialog()
384 emit SignalDeactivateActiveDialog();
387 //=======================================================================
388 // function : GeometryGUI::EmitSignalCloseAllDialogs()
389 // purpose : Emit a signal to close all non modal dialogs box
390 //=======================================================================
391 void GeometryGUI::EmitSignalCloseAllDialogs()
393 emit SignalCloseAllDialogs();
396 //=======================================================================
397 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
398 // purpose : Emit a signal to inform that default real spin box step has
400 //=======================================================================
401 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
403 emit SignalDefaultStepValueChanged(newVal);
406 //=======================================================================
407 // function : GeometryGUI::OnGUIEvent()
408 // purpose : common slot for all menu/toolbar actions
409 //=======================================================================
410 void GeometryGUI::OnGUIEvent()
412 const QObject* obj = sender();
413 if ( !obj || !obj->inherits( "QAction" ) )
415 int id = actionId((QAction*)obj);
420 //=======================================================================
421 // function : GeometryGUI::OnGUIEvent()
422 // purpose : manage all events on GUI [static]
423 //=======================================================================
424 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
426 SUIT_Application* anApp = application();
428 SUIT_Desktop* desk = anApp->desktop();
430 // check type of the active viewframe
431 SUIT_ViewWindow* window = desk->activeWindow();
432 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
433 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
434 bool ViewDep = ( window && window->getViewManager()->getType() == GraphicsView_Viewer::Type() );
435 // if current viewframe is not of OCC and not of VTK type - return immediately
436 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
437 QList<int> NotViewerDependentCommands;
438 NotViewerDependentCommands << GEOMOp::OpDelete
440 << GEOMOp::OpShowOnly
441 << GEOMOp::OpShowOnlyChildren
442 << GEOMOp::OpDiscloseChildren
443 << GEOMOp::OpConcealChildren
444 << GEOMOp::OpUnpublishObject
445 << GEOMOp::OpPublishObject
446 << GEOMOp::OpPointMarker
447 << GEOMOp::OpCreateFolder
448 << GEOMOp::OpSortChildren;
449 if ( !ViewOCC && !ViewVTK && !ViewDep && !NotViewerDependentCommands.contains( id ) ) {
450 // activate OCC viewer
451 getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true);
454 // fix for IPAL9103, point 2
455 if ( CORBA::is_nil( GetGeomGen() ) ) {
456 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
461 // find corresponding GUI library
463 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
464 createOriginAndBaseVectors(); // internal operation
466 case GEOMOp::OpImport: // MENU FILE - IMPORT
467 case GEOMOp::OpExport: // MENU FILE - EXPORT
468 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
469 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
470 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
471 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
472 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
473 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
474 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
475 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
476 case GEOMOp::OpDelete: // MENU EDIT - DELETE
477 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
478 case GEOMOp::OpMaterialsLibrary: // MENU TOOLS - MATERIALS LIBRARY
479 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
480 case GEOMOp::OpColor: // POPUP MENU - COLOR
481 case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
482 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
483 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
484 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
485 case GEOMOp::OpIsos: // POPUP MENU - ISOS
486 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
487 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
488 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
489 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
490 case GEOMOp::OpDiscloseChildren: // POPUP MENU - DISCLOSE CHILD ITEMS
491 case GEOMOp::OpConcealChildren: // POPUP MENU - CONCEAL CHILD ITEMS
492 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
493 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
494 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
495 case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
496 case GEOMOp::OpPredefMaterial: // POPUP MENU - <SOME MATERIAL>
497 case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
498 case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
499 case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
500 case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
501 case GEOMOp::OpClsBringToFront: //
502 case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER
503 case GEOMOp::OpSortChildren: // POPUP MENU - SORT CHILD ITEMS
504 case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE
505 case GEOMOp::OpReduceStudy: // POPUP MENU - REDUCE STUDY
506 libName = "GEOMToolsGUI";
508 case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
509 case GEOMOp::OpDMShading: // MENU VIEW - SHADING
510 case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
511 case GEOMOp::OpDMTexture: // MENU VIEW - TEXTURE
512 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
513 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
514 case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
515 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
516 case GEOMOp::OpHide: // MENU VIEW - ERASE
517 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
518 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
519 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
520 case GEOMOp::OpShading: // POPUP MENU - SHADING
521 case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
522 case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
523 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
524 libName = "DisplayGUI";
526 case GEOMOp::OpPoint: // MENU BASIC - POINT
527 case GEOMOp::OpLine: // MENU BASIC - LINE
528 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
529 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
530 case GEOMOp::OpArc: // MENU BASIC - ARC
531 case GEOMOp::OpVector: // MENU BASIC - VECTOR
532 case GEOMOp::OpPlane: // MENU BASIC - PLANE
533 case GEOMOp::OpCurve: // MENU BASIC - CURVE
534 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
535 libName = "BasicGUI";
537 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
538 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
539 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
540 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
541 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
542 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
543 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
544 libName = "PrimitiveGUI";
546 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
547 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
548 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
549 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
550 case GEOMOp::OpPipePath: // MENU GENERATION - RESTORE PATH
551 libName = "GenerationGUI";
553 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
554 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
555 case GEOMOp::OpIsoline: // MENU BASIC - ISOLINE
556 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
558 case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
560 case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
561 case GEOMOp::OpCreateField: // MENU FIELD - CREATE FIELD
562 case GEOMOp::OpEditField: // MENU FIELD - EDIT FIELD
563 case GEOMOp::OpEditFieldPopup: // POPUP MENU - EDIT FIELD
564 libName = "EntityGUI";
566 case GEOMOp::OpEdge: // MENU BUILD - EDGE
567 case GEOMOp::OpWire: // MENU BUILD - WIRE
568 case GEOMOp::OpFace: // MENU BUILD - FACE
569 case GEOMOp::OpShell: // MENU BUILD - SHELL
570 case GEOMOp::OpSolid: // MENU BUILD - SOLID
571 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
572 libName = "BuildGUI";
574 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
575 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
576 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
577 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
578 libName = "BooleanGUI";
580 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
581 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
582 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
583 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
584 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
585 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
586 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
587 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
588 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
589 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
590 libName = "TransformationGUI";
592 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
593 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
594 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
595 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
596 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
597 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
598 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
599 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
600 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
601 case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
602 case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
603 #ifdef DEBUG_CURVE_CREATOR
604 // for debug purposes, to be removed
605 case GEOMOp::OpCurveCreator: // MENU OPERATION - CURVE CREATOR
607 libName = "OperationGUI";
609 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
610 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
611 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
612 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
613 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
614 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
615 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
616 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
617 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
618 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
619 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
620 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
621 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
622 case GEOMOp::OpRemoveWebs: // MENU REPAIR - REMOVE INTERNAL FACES
623 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
624 case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES
625 case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES
626 libName = "RepairGUI";
628 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
629 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
630 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
631 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
632 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
633 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
634 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
635 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
636 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
637 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
638 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
639 case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS
640 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
641 case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
642 case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
643 case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS
644 case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS
645 libName = "MeasureGUI";
647 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
648 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
649 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
650 case GEOMOp::OpGroupUnion: // MENU GROUP - UNION
651 case GEOMOp::OpGroupIntersect: // MENU GROUP - INTERSECT
652 case GEOMOp::OpGroupCut: // MENU GROUP - CUT
653 libName = "GroupGUI";
655 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
656 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
657 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
658 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
659 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
660 libName = "BlocksGUI";
662 case GEOMOp::OpExportXAO: // MENU NEW ENTITY - IMPORTEXPORT - EXPORTXAO
663 case GEOMOp::OpImportXAO: // MENU NEW ENTITY - IMPORTEXPORT - IMPORTXAO
664 libName = "ImportExportGUI";
666 //case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
667 //case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
668 //case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
669 //case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
670 //case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
671 //case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
672 //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
673 //libName = "AdvancedGUI";
676 if (myPluginActions.contains(id)) {
677 libName = myPluginActions[id].first;
679 GEOMPluginGUI* library = 0;
680 if ( !libName.isEmpty() ) {
682 libName = QString( "lib" ) + libName + ".so";
684 libName = libName + ".dll";
686 library = getPluginLibrary( libName );
689 // call method of corresponding GUI library
691 //QString action ("%1");
692 //action = action.arg(id);
694 //if( !theParam.isValid() )
695 library->OnGUIEvent( myPluginActions[id].second, desk );
697 // library->OnGUIEvent( id, desk, theParam);
700 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
702 updateCreationInfo();
708 GEOMGUI* library = 0;
709 if ( !libName.isEmpty() ) {
711 libName = QString( "lib" ) + libName + ".so";
713 libName = libName + ".dll";
715 library = getLibrary( libName );
718 // call method of corresponding GUI library
720 if( !theParam.isValid() )
721 library->OnGUIEvent( id, desk );
723 library->OnGUIEvent( id, desk, theParam);
726 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
728 updateCreationInfo();
731 //=================================================================================
732 // function : GeometryGUI::activateOperation()
734 //=================================================================================
735 bool GeometryGUI::activateOperation( int actionId )
737 OnGUIEvent(actionId);
741 //=================================================================================
742 // function : GeometryGUI::activateOperation()
744 //=================================================================================
745 bool GeometryGUI::activateOperation( const QString& actionId )
749 int id = actionId.toInt(&isOk);
756 //=================================================================================
757 // function : GeometryGUI::activateOperation()
759 //=================================================================================
760 bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin )
764 QString pluginLib = plugin;
765 // TODO: if <plugin> is a plugin name, find plugin library name
766 if (myPluginLibs.contains(plugin))
767 pluginLib = myPluginLibs[plugin];
769 QMap<int, PluginAction>::iterator actionsIter = myPluginActions.begin();
770 for (; actionsIter != myPluginActions.end(); ++actionsIter) {
771 const PluginAction& anAction = actionsIter.value();
772 if (anAction.first == pluginLib && anAction.second == actionId) {
773 // activate operation
774 OnGUIEvent(actionsIter.key());
782 //=================================================================================
783 // function : GeometryGUI::OnKeyPress()
784 // purpose : Called when any key is pressed by user [static]
785 //=================================================================================
786 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
788 if ( !application() )
790 foreach ( GEOMGUI* lib, myGUIMap )
791 lib->OnKeyPress( e, application()->desktop(), w );
794 //=================================================================================
795 // function : GeometryGUI::OnMouseMove()
796 // purpose : Manages mouse move events [static]
797 //=================================================================================
798 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
800 if ( !application() )
802 foreach ( GEOMGUI* lib, myGUIMap )
803 lib->OnMouseMove( e, application()->desktop(), w );
806 //=================================================================================
807 // function : GeometryGUI::OnMouseRelease()
808 // purpose : Manages mouse release events [static]
809 //=================================================================================
810 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
812 if ( !application() )
814 foreach ( GEOMGUI* lib, myGUIMap )
815 lib->OnMouseRelease( e, application()->desktop(), w );
818 //=================================================================================
819 // function : GeometryGUI::OnMousePress()
820 // purpose : Manage mouse press events [static]
821 //=================================================================================
822 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
824 if ( !application() )
826 foreach ( GEOMGUI* lib, myGUIMap )
827 lib->OnMousePress( e, application()->desktop(), w );
830 //=======================================================================
831 // function : createGeomAction
833 //=======================================================================
834 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
835 const int accel, const bool toggle, const QString& shortcutAction )
837 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
838 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
839 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
841 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
843 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
844 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
846 application()->desktop(),
848 this, SLOT( OnGUIEvent() ),
852 //=======================================================================
853 // function : createOriginAndBaseVectors
855 //=======================================================================
856 void GeometryGUI::createOriginAndBaseVectors()
858 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
859 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
861 SUIT_MessageBox::warning ( application()->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
865 _PTR(Study) studyDS = appStudy->studyDS();
866 if ( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
867 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
868 if ( !aBasicOperations->_is_nil() ) {
869 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
870 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
871 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
872 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
873 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
874 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
876 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
877 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
878 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
879 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
880 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
882 getApp()->updateObjectBrowser( true );
888 //=======================================================================
889 // function : GeometryGUI::initialize()
890 // purpose : Called when GEOM module is created
891 //=======================================================================
892 void GeometryGUI::initialize( CAM_Application* app )
894 SalomeApp_Module::initialize( app );
896 // ----- create actions --------------
898 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
899 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
901 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
903 createGeomAction( GEOMOp::OpPoint, "POINT" );
904 createGeomAction( GEOMOp::OpLine, "LINE" );
905 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
906 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
907 createGeomAction( GEOMOp::OpArc, "ARC" );
908 createGeomAction( GEOMOp::OpCurve, "CURVE" );
909 createGeomAction( GEOMOp::OpIsoline, "ISOLINE" );
910 createGeomAction( GEOMOp::OpVector, "VECTOR" );
911 createGeomAction( GEOMOp::OpPlane, "PLANE" );
912 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
913 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
915 createGeomAction( GEOMOp::OpBox, "BOX" );
916 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
917 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
918 createGeomAction( GEOMOp::OpTorus, "TORUS" );
919 createGeomAction( GEOMOp::OpCone, "CONE" );
920 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
921 createGeomAction( GEOMOp::OpDisk, "DISK" );
923 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
924 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
925 createGeomAction( GEOMOp::OpFilling, "FILLING" );
926 createGeomAction( GEOMOp::OpPipe, "PIPE" );
927 createGeomAction( GEOMOp::OpPipePath, "PIPE_PATH" );
929 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
930 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
931 createGeomAction( GEOMOp::OpGroupUnion, "GROUP_UNION" );
932 createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
933 createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" );
935 createGeomAction( GEOMOp::OpCreateField, "FIELD_CREATE" );
936 createGeomAction( GEOMOp::OpEditField, "FIELD_EDIT" );
938 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
940 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
941 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
943 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
944 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
945 createGeomAction( GEOMOp::OpIsoline, "ISOLINE" );
946 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
948 createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
950 createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
952 createGeomAction( GEOMOp::OpEdge, "EDGE" );
953 createGeomAction( GEOMOp::OpWire, "WIRE" );
954 createGeomAction( GEOMOp::OpFace, "FACE" );
955 createGeomAction( GEOMOp::OpShell, "SHELL" );
956 createGeomAction( GEOMOp::OpSolid, "SOLID" );
957 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
959 createGeomAction( GEOMOp::OpFuse, "FUSE" );
960 createGeomAction( GEOMOp::OpCommon, "COMMON" );
961 createGeomAction( GEOMOp::OpCut, "CUT" );
962 createGeomAction( GEOMOp::OpSection, "SECTION" );
964 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
965 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
966 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
967 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
968 createGeomAction( GEOMOp::OpScale, "SCALE" );
969 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
970 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
971 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
972 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
974 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
975 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
976 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
977 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
978 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
979 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
980 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
981 createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
982 createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
983 #ifdef DEBUG_CURVE_CREATOR
984 // for debug purposes, to be removed
985 createGeomAction( GEOMOp::OpCurveCreator, "CURVE_CREATOR" );
987 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
988 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
990 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
991 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
992 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
994 createGeomAction( GEOMOp::OpSewing, "SEWING" );
995 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
996 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
997 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
998 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
999 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
1000 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
1001 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
1002 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
1003 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
1004 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
1005 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
1006 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
1007 createGeomAction( GEOMOp::OpRemoveWebs, "REMOVE_WEBS" );
1008 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
1009 createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" );
1010 createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" );
1012 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
1013 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
1014 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
1015 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
1016 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
1017 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
1018 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
1019 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
1020 createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
1022 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
1023 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
1024 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
1025 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
1026 createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
1027 createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
1029 #ifdef _DEBUG_ // PAL16821
1030 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
1033 createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" );
1034 createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" );
1035 createGeomAction( GEOMOp::OpDMShading, "SHADING" );
1036 createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
1037 createGeomAction( GEOMOp::OpDMTexture, "TEXTURE" );
1038 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
1039 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
1040 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
1041 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
1042 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
1043 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
1044 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
1045 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
1046 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
1047 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
1048 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
1049 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
1050 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
1051 createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
1052 createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
1053 createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
1054 createGeomAction( GEOMOp::OpHide, "ERASE" );
1056 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
1057 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
1058 createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
1059 createGeomAction( GEOMOp::OpTexture, "POP_TEXTURE", "", 0, true );
1060 createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH");
1061 createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH");
1062 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
1063 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
1064 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
1065 createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
1066 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
1067 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
1068 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
1069 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
1070 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
1071 createGeomAction( GEOMOp::OpEditFieldPopup, "POP_EDIT_FIELD" );
1072 createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
1073 createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
1074 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
1075 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
1076 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
1077 createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
1078 createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
1079 createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
1080 createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
1081 createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
1082 createGeomAction( GEOMOp::OpReduceStudy, "POP_REDUCE_STUDY" );
1083 createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
1084 createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
1086 // Create actions for increase/decrease transparency shortcuts
1087 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
1088 "Geometry:Increase transparency");
1089 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
1090 "Geometry:Decrease transparency");
1092 // Create actions for increase/decrease number of isolines
1093 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
1094 "Geometry:Increase number of isolines");
1095 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
1096 "Geometry:Decrease number of isolines");
1098 // Import/Export XAO
1099 createGeomAction( GEOMOp::OpExportXAO, "EXPORTXAO" );
1100 createGeomAction( GEOMOp::OpImportXAO, "IMPORTXAO" );
1102 //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
1103 //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
1104 //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
1105 //createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
1106 //@@ 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 @@//
1108 // ---- create menus --------------------------
1110 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
1111 createMenu( separator(), fileId, 10 );
1112 createMenu( GEOMOp::OpImport, fileId, 10 );
1113 createMenu( GEOMOp::OpExport, fileId, 10 );
1114 int impexpId = createMenu( tr( "MEN_IMPORTEXPORT" ), fileId, -1, 10 );
1115 createMenu( GEOMOp::OpExportXAO, impexpId, -1 );
1116 createMenu( GEOMOp::OpImportXAO, impexpId, -1 );
1117 createMenu( separator(), fileId, -1 );
1119 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
1120 createMenu( GEOMOp::OpDelete, editId, -1 );
1122 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
1124 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
1125 createMenu( GEOMOp::OpPoint, basicId, -1 );
1126 createMenu( GEOMOp::OpLine, basicId, -1 );
1127 createMenu( GEOMOp::OpCircle, basicId, -1 );
1128 createMenu( GEOMOp::OpEllipse, basicId, -1 );
1129 createMenu( GEOMOp::OpArc, basicId, -1 );
1130 createMenu( GEOMOp::OpCurve, basicId, -1 );
1131 createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
1132 createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
1133 createMenu( GEOMOp::OpIsoline, basicId, -1 );
1134 createMenu( separator(), basicId, -1 );
1135 createMenu( GEOMOp::OpVector, basicId, -1 );
1136 createMenu( GEOMOp::OpPlane, basicId, -1 );
1137 createMenu( GEOMOp::OpLCS, basicId, -1 );
1138 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
1140 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
1141 createMenu( GEOMOp::OpBox, primId, -1 );
1142 createMenu( GEOMOp::OpCylinder, primId, -1 );
1143 createMenu( GEOMOp::OpSphere, primId, -1 );
1144 createMenu( GEOMOp::OpTorus, primId, -1 );
1145 createMenu( GEOMOp::OpCone, primId, -1 );
1146 createMenu( GEOMOp::OpRectangle, primId, -1 );
1147 createMenu( GEOMOp::OpDisk, primId, -1 );
1148 //createMenu( GEOMOp::OpPipeTShape,primId, -1 );
1150 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
1151 createMenu( GEOMOp::OpPrism, genId, -1 );
1152 createMenu( GEOMOp::OpRevolution, genId, -1 );
1153 createMenu( GEOMOp::OpFilling, genId, -1 );
1154 createMenu( GEOMOp::OpPipe, genId, -1 );
1155 createMenu( GEOMOp::OpPipePath, genId, -1 );
1157 //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
1158 //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
1159 //@@ 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 @@//
1161 createMenu( separator(), newEntId, -1 );
1163 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
1164 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
1165 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
1166 createMenu( GEOMOp::OpGroupUnion, groupId, -1 );
1167 createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
1168 createMenu( GEOMOp::OpGroupCut, groupId, -1 );
1170 createMenu( separator(), newEntId, -1 );
1172 int fieldId = createMenu( tr( "MEN_FIELD" ), newEntId, -1 );
1173 createMenu( GEOMOp::OpCreateField, fieldId, -1 );
1174 createMenu( GEOMOp::OpEditField, fieldId, -1 );
1176 createMenu( separator(), newEntId, -1 );
1178 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
1179 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
1180 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
1181 //createMenu( GEOMOp::OpDividedDisk, blocksId, -1 );
1182 //createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
1184 createMenu( separator(), newEntId, -1 );
1186 createMenu( GEOMOp::OpExplode, newEntId, -1 );
1188 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
1189 createMenu( GEOMOp::OpEdge, buildId, -1 );
1190 createMenu( GEOMOp::OpWire, buildId, -1 );
1191 createMenu( GEOMOp::OpFace, buildId, -1 );
1192 createMenu( GEOMOp::OpShell, buildId, -1 );
1193 createMenu( GEOMOp::OpSolid, buildId, -1 );
1194 createMenu( GEOMOp::OpCompound, buildId, -1 );
1196 createMenu( separator(), newEntId, -1 );
1198 createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1200 createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1203 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1205 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1206 createMenu( GEOMOp::OpFuse, boolId, -1 );
1207 createMenu( GEOMOp::OpCommon, boolId, -1 );
1208 createMenu( GEOMOp::OpCut, boolId, -1 );
1209 createMenu( GEOMOp::OpSection, boolId, -1 );
1211 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1212 createMenu( GEOMOp::OpTranslate, transId, -1 );
1213 createMenu( GEOMOp::OpRotate, transId, -1 );
1214 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
1215 createMenu( GEOMOp::OpMirror, transId, -1 );
1216 createMenu( GEOMOp::OpScale, transId, -1 );
1217 createMenu( GEOMOp::OpOffset, transId, -1 );
1218 createMenu( GEOMOp::OpProjection, transId, -1 );
1219 createMenu( separator(), transId, -1 );
1220 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1221 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
1223 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1224 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1225 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
1226 createMenu( GEOMOp::OpPropagate, blockId, -1 );
1228 createMenu( separator(), operId, -1 );
1230 createMenu( GEOMOp::OpPartition, operId, -1 );
1231 createMenu( GEOMOp::OpArchimede, operId, -1 );
1232 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1233 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
1235 createMenu( separator(), operId, -1 );
1237 createMenu( GEOMOp::OpFillet1d, operId, -1 );
1238 createMenu( GEOMOp::OpFillet2d, operId, -1 );
1239 createMenu( GEOMOp::OpFillet3d, operId, -1 );
1240 createMenu( GEOMOp::OpChamfer, operId, -1 );
1241 createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
1242 createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
1243 #ifdef DEBUG_CURVE_CREATOR
1244 // for debug purposes, to be removed
1245 createMenu( separator(), operId, -1 );
1246 createMenu( GEOMOp::OpCurveCreator, operId, -1 );
1248 //createMenu( GEOMOp::OpClipping, operId, -1 );
1250 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1251 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
1252 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
1253 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
1254 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
1255 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
1256 createMenu( GEOMOp::OpSewing, repairId, -1 );
1257 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
1258 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
1259 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
1260 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
1261 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
1262 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
1263 createMenu( GEOMOp::OpOrientation, repairId, -1 );
1264 createMenu( GEOMOp::OpRemoveWebs, repairId, -1 );
1265 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1266 createMenu( GEOMOp::OpFuseEdges, repairId, -1 );
1267 createMenu( GEOMOp::OpUnionFaces, repairId, -1 );
1269 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1270 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1271 createMenu( GEOMOp::OpProperties, measurId, -1 );
1272 createMenu( separator(), measurId, -1 );
1273 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
1274 createMenu( GEOMOp::OpInertia, measurId, -1 );
1275 createMenu( GEOMOp::OpNormale, measurId, -1 );
1276 createMenu( separator(), measurId, -1 );
1277 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
1278 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
1279 createMenu( separator(), measurId, -1 );
1281 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1282 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1283 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1284 createMenu( GEOMOp::OpAngle, dimId, -1 );
1285 createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
1287 createMenu( separator(), measurId, -1 );
1288 createMenu( GEOMOp::OpTolerance, measurId, -1 );
1289 createMenu( separator(), measurId, -1 );
1290 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
1291 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
1292 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
1293 createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
1294 createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1296 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1297 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1298 createMenu( separator(), toolsId, -1 );
1299 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1302 createMenu( separator(), toolsId, -1 );
1303 createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1304 createMenu( separator(), toolsId, -1 );
1306 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1307 createMenu( separator(), viewId, -1 );
1309 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1310 createMenu( GEOMOp::OpDMWireframe, dispmodeId, -1 );
1311 createMenu( GEOMOp::OpDMShading, dispmodeId, -1 );
1312 createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1313 createMenu( GEOMOp::OpDMTexture, dispmodeId, -1 );
1314 createMenu( separator(), dispmodeId, -1 );
1315 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1317 createMenu( separator(), viewId, -1 );
1318 createMenu( GEOMOp::OpShowAll, viewId, -1 );
1319 createMenu( GEOMOp::OpHideAll, viewId, -1 );
1320 createMenu( separator(), viewId, -1 );
1321 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1322 createMenu( separator(), viewId, -1 );
1326 because of these items are accessible through object browser and viewers
1327 we have removed they from main menu
1329 createMenu( GEOMOp::OpShow, viewId, -1 );
1330 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1331 createMenu( GEOMOp::OpHide, viewId, -1 );
1334 // ---- create toolbars --------------------------
1336 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1337 createTool( GEOMOp::OpPoint, basicTbId );
1338 createTool( GEOMOp::OpLine, basicTbId );
1339 createTool( GEOMOp::OpCircle, basicTbId );
1340 createTool( GEOMOp::OpEllipse, basicTbId );
1341 createTool( GEOMOp::OpArc, basicTbId );
1342 createTool( GEOMOp::OpCurve, basicTbId );
1343 createTool( GEOMOp::OpVector, basicTbId );
1344 createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1345 createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1346 createTool( GEOMOp::OpIsoline, basicTbId );
1347 createTool( GEOMOp::OpPlane, basicTbId );
1348 createTool( GEOMOp::OpLCS, basicTbId );
1349 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1351 // int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
1352 // createTool( GEOMOp::Op2dSketcher, sketchTbId );
1353 // createTool( GEOMOp::Op3dSketcher, sketchTbId );
1355 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1356 createTool( GEOMOp::OpBox, primTbId );
1357 createTool( GEOMOp::OpCylinder, primTbId );
1358 createTool( GEOMOp::OpSphere, primTbId );
1359 createTool( GEOMOp::OpTorus, primTbId );
1360 createTool( GEOMOp::OpCone, primTbId );
1361 createTool( GEOMOp::OpRectangle, primTbId );
1362 createTool( GEOMOp::OpDisk, primTbId );
1363 //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1365 //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) );
1366 //createTool( GEOMOp::OpDividedDisk, blocksTbId );
1367 //createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1369 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1370 createTool( GEOMOp::OpFuse, boolTbId );
1371 createTool( GEOMOp::OpCommon, boolTbId );
1372 createTool( GEOMOp::OpCut, boolTbId );
1373 createTool( GEOMOp::OpSection, boolTbId );
1375 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1376 createTool( GEOMOp::OpPrism, genTbId );
1377 createTool( GEOMOp::OpRevolution, genTbId );
1378 createTool( GEOMOp::OpFilling, genTbId );
1379 createTool( GEOMOp::OpPipe, genTbId );
1380 createTool( GEOMOp::OpPipePath, genTbId );
1382 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1383 createTool( GEOMOp::OpTranslate, transTbId );
1384 createTool( GEOMOp::OpRotate, transTbId );
1385 createTool( GEOMOp::OpChangeLoc, transTbId );
1386 createTool( GEOMOp::OpMirror, transTbId );
1387 createTool( GEOMOp::OpScale, transTbId );
1388 createTool( GEOMOp::OpOffset, transTbId );
1389 createTool( GEOMOp::OpProjection, transTbId );
1390 createTool( separator(), transTbId );
1391 createTool( GEOMOp::OpMultiTranslate, transTbId );
1392 createTool( GEOMOp::OpMultiRotate, transTbId );
1394 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1395 createTool( GEOMOp::OpExplode, operTbId );
1396 createTool( GEOMOp::OpPartition, operTbId );
1397 createTool( GEOMOp::OpArchimede, operTbId );
1398 createTool( GEOMOp::OpShapesOnShape, operTbId );
1399 createTool( GEOMOp::OpSharedShapes, operTbId );
1401 int featTbId = createTool( tr( "TOOL_FEATURES" ) );
1402 createTool( GEOMOp::OpFillet1d, featTbId );
1403 createTool( GEOMOp::OpFillet2d, featTbId );
1404 createTool( GEOMOp::OpFillet3d, featTbId );
1405 createTool( GEOMOp::OpChamfer, featTbId );
1406 createTool( GEOMOp::OpExtrudedBoss, featTbId );
1407 createTool( GEOMOp::OpExtrudedCut, featTbId );
1408 #ifdef DEBUG_CURVE_CREATOR
1409 // for debug purposes, to be removed
1410 createTool( GEOMOp::OpCurveCreator, featTbId );
1413 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1414 createTool( GEOMOp::OpEdge, buildTbId );
1415 createTool( GEOMOp::OpWire, buildTbId );
1416 createTool( GEOMOp::OpFace, buildTbId );
1417 createTool( GEOMOp::OpShell, buildTbId );
1418 createTool( GEOMOp::OpSolid, buildTbId );
1419 createTool( GEOMOp::OpCompound, buildTbId );
1421 int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1422 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1423 createTool( GEOMOp::OpProperties, measureTbId );
1424 createTool( GEOMOp::OpCenterMass, measureTbId );
1425 createTool( GEOMOp::OpInertia, measureTbId );
1426 createTool( GEOMOp::OpNormale, measureTbId );
1427 createTool( separator(), measureTbId );
1428 createTool( GEOMOp::OpBoundingBox, measureTbId );
1429 createTool( GEOMOp::OpMinDistance, measureTbId );
1430 createTool( GEOMOp::OpAngle, measureTbId );
1431 createTool( GEOMOp::OpTolerance , measureTbId );
1432 createTool( separator(), measureTbId );
1433 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1434 createTool( GEOMOp::OpFreeFaces, measureTbId );
1435 createTool( separator(), measureTbId );
1436 createTool( GEOMOp::OpWhatIs, measureTbId );
1437 createTool( GEOMOp::OpCheckShape, measureTbId );
1438 createTool( GEOMOp::OpCheckCompound, measureTbId );
1439 createTool( GEOMOp::OpGetNonBlocks, measureTbId );
1440 createTool( GEOMOp::OpCheckSelfInters, measureTbId );
1442 int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
1443 createTool( GEOMOp::OpPictureImport, picturesTbId );
1445 createTool( GEOMOp::OpFeatureDetect, picturesTbId );
1448 int impexpTbId = createTool( tr( "TOOL_IMPORTEXPORT" ) );
1449 createTool( GEOMOp::OpExportXAO, impexpTbId );
1450 createTool( GEOMOp::OpImportXAO, impexpTbId );
1452 //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1453 //createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1454 //@@ 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 @@//
1456 // ---- create popup menus --------------------------
1458 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1459 QString clientOCC = "(client='OCCViewer')";
1460 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1461 QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1463 QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1464 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1465 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1466 QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1468 QString autoColorPrefix =
1469 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1471 QtxPopupMgr* mgr = popupMgr();
1473 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1474 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1475 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1476 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1477 mgr->insert( action( GEOMOp::OpEditFieldPopup ), -1, -1 ); // edit field
1478 mgr->setRule( action( GEOMOp::OpEditFieldPopup ), QString("(type='Field' or type='FieldStep') and isOCC=true"), QtxPopupMgr::VisibleRule );
1479 mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1480 mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1482 mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal child items
1483 mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1484 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1485 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1486 mgr->insert( separator(), -1, -1 ); // -----------
1488 //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1489 QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and isFolder=false and (selcount>0) and isOCC=true";
1490 mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1491 mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1492 mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1493 mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1494 mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1495 mgr->insert( separator(), -1, -1 ); // -----------
1496 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1497 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1498 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1499 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1500 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1501 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1502 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1503 mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1504 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1505 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1506 mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1507 mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1508 mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1509 mgr->insert( separator(), dispmodeId, -1 );
1510 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1511 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1512 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1513 mgr->insert( separator(), -1, -1 ); // -----------
1515 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1516 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1517 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1518 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1519 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1520 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1521 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1522 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1523 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1524 //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1525 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1527 // material properties
1528 mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
1529 mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1532 mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
1533 mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1535 int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1536 mgr->insert( action( GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1537 mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1539 mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1540 mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1542 mgr->insert( separator(), -1, -1 ); // -----------
1543 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1544 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1545 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1546 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1547 mgr->insert( separator(), -1, -1 ); // -----------
1549 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1550 onlyComponent = "((type='Component') and selcount=1)",
1551 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1552 types = "'Shape' 'Group' 'FieldStep'";
1554 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1555 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1557 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1558 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1560 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1561 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1563 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1565 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1566 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1567 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1568 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1569 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1570 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1571 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1572 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1573 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1574 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1575 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1576 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1577 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1578 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1579 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1580 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1581 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1582 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1583 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1584 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1585 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1586 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1587 mgr->insert( separator(), selectonlyId, -1);
1588 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1589 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1590 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1591 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1592 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1593 mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1594 mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1596 QString aDimensionRule = "($component={'GEOM'}) and selcount=1 and isVisible and type='Shape' and %1";
1598 mgr->insert( separator(), -1, -1 ); // -----------
1599 mgr->insert( action( GEOMOp::OpShowAllDimensions ), -1, -1 ); // show all dimensions
1600 mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
1601 mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
1602 mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
1604 mgr->insert( separator(), -1, -1 ); // -----------
1605 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1606 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1608 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1609 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1611 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1612 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1614 mgr->insert( separator(), -1, -1 ); // -----------
1615 mgr->insert( action( GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
1616 mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and $component={'GEOM'} and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
1618 mgr->insert( separator(), -1, -1 ); // -----------
1619 mgr->insert( action( GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
1620 mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
1622 mgr->insert( separator(), -1, -1 ); // -----------
1623 mgr->insert( action( GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree
1624 mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1626 mgr->insert( separator(), -1, -1 ); // -----------
1627 mgr->insert( action( GEOMOp::OpReduceStudy ), -1, -1 ); // Reduce Study
1628 mgr->setRule( action( GEOMOp::OpReduceStudy ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1630 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1632 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1634 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1635 QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1636 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1639 // create plugin actions and menus
1643 //=======================================================================
1644 // function : GeometryGUI::addPluginActions()
1646 //=======================================================================
1647 void GeometryGUI::addPluginActions()
1650 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1651 if (!resMgr) return;
1653 // Find names of a resource XML files ("GEOMActions.xml" and others);
1655 char* cenv = getenv("GEOM_PluginsList");
1657 PluginsXml.sprintf("%s", cenv);
1659 QStringList PluginsXmlList = PluginsXml.split(":", QString::SkipEmptyParts);
1660 if (PluginsXmlList.count() == 0) return;
1662 // get full names of xml files from PluginsXmlList
1663 QStringList xmlFiles;
1664 xmlFiles.append(QDir::home().filePath("CustomGeomPlugins.xml")); // may be inexistent
1665 for (int i = 0; i < PluginsXmlList.count(); i++) {
1666 PluginsXml = PluginsXmlList[ i ];
1668 // Find full path to the resource XML file
1669 QString xmlFile = resMgr->path("resources", "GEOM", PluginsXml + ".xml");
1670 if ( xmlFile.isEmpty() ) // try PLUGIN resources
1671 xmlFile = resMgr->path("resources", PluginsXml, PluginsXml + ".xml");
1672 if ( !xmlFile.isEmpty() )
1673 xmlFiles.append( xmlFile );
1676 // create "Advanced Operations" menu and corresponding toolbar
1677 //int advancedMenuId = createMenu(tr("MEN_ADVANCED"), -1, -1, 10);
1678 //int advancedTbarId = createTool(tr("TOOL_ADVANCED"));
1679 int id = GEOMOp::OpLastOperationID; // TODO?
1682 QString aNoAccessFiles;
1683 for (int i = 0; i < xmlFiles.count(); i++) {
1684 QString xmlFile = xmlFiles[ i ];
1686 QFile file (xmlFile);
1687 if (file.exists() && file.open(QIODevice::ReadOnly)) {
1690 GEOMGUI_XmlHandler* aXmlHandler = new GEOMGUI_XmlHandler();
1691 ASSERT(aXmlHandler);
1693 QXmlInputSource source (&file);
1694 QXmlSimpleReader reader;
1695 reader.setContentHandler(aXmlHandler);
1696 reader.setErrorHandler(aXmlHandler);
1697 bool ok = reader.parse(source);
1701 // bind action lib and label to its ID for activateOperation() method proper work
1702 myPluginLibs[aXmlHandler->myPluginData.myName] = aXmlHandler->myPluginData.myClientLib;
1704 QListIterator<GEOMGUI_ActionData> anActionsIter (aXmlHandler->myPluginData.myListOfActions);
1705 while (anActionsIter.hasNext()) {
1706 GEOMGUI_ActionData anActionData = anActionsIter.next();
1708 //QPixmap icon = resMgr->loadPixmap("GEOM", tr(anActionData.myIcon.toLatin1().constData()));
1709 QPixmap icon = resMgr->loadPixmap(aXmlHandler->myPluginData.myName,
1710 anActionData.myIcon.toLatin1().constData());
1712 // path to action in menu
1713 QStringList smenus = anActionData.myMenu.split( "/" );
1714 QString actionName = smenus.last();
1715 actionName = actionName.toUpper().prepend("MEN_");
1716 smenus.removeLast();
1718 // path to action in toolbar
1719 QStringList stools = anActionData.myTooltip.split( "/" );
1720 QString actionTool = stools.last();
1721 actionTool = actionTool.toUpper().prepend("TOP_");
1722 stools.removeLast();
1724 QString actionStat = anActionData.myStatusBar;
1725 actionStat = actionStat.toUpper().prepend("STB_");
1727 createAction(id, // ~ anActionData.myLabel
1728 tr(actionTool.toLatin1().constData()),
1730 tr(actionName.toLatin1().constData()),
1731 tr(actionStat.toLatin1().constData()),
1733 application()->desktop(),
1735 this, SLOT(OnGUIEvent()),
1736 QString() /*shortcutAction*/);
1739 foreach (QString subMenu, smenus) {
1740 subMenu = subMenu.toUpper().prepend("MEN_");
1741 menuId = createMenu(tr(subMenu.toLatin1().constData()), menuId, -1);
1743 //createMenu(id, pluginMenuId, -1);
1744 createMenu(id, menuId, -1);
1746 QString subTool = stools[0];
1747 subTool = subTool.toUpper().prepend("TOOL_");
1748 int toolId = createTool(tr(subTool.toLatin1().constData()));
1749 //createTool(id, advancedTbarId);
1750 createTool(id, toolId);
1752 // add action id to map
1753 PluginAction anAction (aXmlHandler->myPluginData.myClientLib, anActionData.myLabel);
1754 myPluginActions[id] = anAction;
1760 SUIT_MessageBox::critical(application()->desktop(),
1761 tr("INF_PARSE_ERROR"),
1762 tr(aXmlHandler->errorProtocol().toLatin1().data()));
1766 else if ( i > 0 ) { // 1st is ~/CustomGeomPlugins.xml
1767 if (aNoAccessFiles.isEmpty())
1768 aNoAccessFiles = xmlFile;
1770 aNoAccessFiles += ", " + xmlFile;
1772 } // end loop on xmlFiles
1774 if (!aNoAccessFiles.isEmpty()) {
1775 QString aMess = QObject::tr("PLUGIN_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n";
1776 aMess += QObject::tr("PLUGIN_FILE_CHECK_VARIABLE");
1777 SUIT_MessageBox::warning(application()->desktop(), tr("GEOM_WRN_WARNING"), aMess);
1781 //=======================================================================
1782 // function : GeometryGUI::activateModule()
1783 // purpose : Called when GEOM module is activated
1784 //=======================================================================
1785 bool GeometryGUI::activateModule( SUIT_Study* study )
1787 if ( CORBA::is_nil( myComponentGeom ) )
1790 bool res = SalomeApp_Module::activateModule( study );
1794 setMenuShown( true );
1795 setToolShown( true );
1797 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1798 PyGILState_STATE gstate = PyGILState_Ensure();
1799 PyObjWrapper pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1800 if ( !pluginsmanager ) {
1804 PyObjWrapper result =
1805 PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1806 tr("MEN_NEW_ENTITY").toStdString().c_str(),
1807 tr("GEOM_PLUGINS_OTHER").toStdString().c_str());
1811 PyGILState_Release(gstate);
1812 // end of GEOM plugins loading
1814 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1815 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1817 // Reset actions accelerator keys
1818 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1819 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1820 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1822 GUIMap::Iterator it;
1823 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1824 it.value()->activate( application()->desktop() );
1826 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1828 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1829 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ));
1830 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
1832 if ( !myCreationInfoWdg )
1833 myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1834 getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1835 getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1838 SALOME_ListIO selected;
1839 sm->selectedObjects( selected );
1840 sm->clearSelected();
1842 SUIT_ViewManager* vm;
1843 ViewManagerList OCCViewManagers, VTKViewManagers;
1845 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1846 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1847 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1848 onViewManagerAdded(vm);
1850 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1851 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1852 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1853 onViewManagerAdded(vm);
1855 sm->setSelectedObjects( selected, true ); //NPAL 19674
1857 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1859 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1861 // 0020836 (Basic vectors and origin)
1862 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1863 if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1864 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1866 _PTR(Study) studyDS = appStudy->studyDS();
1868 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1869 if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1870 createOriginAndBaseVectors();
1878 //=======================================================================
1879 // function : GeometryGUI::deactivateModule()
1880 // purpose : Called when GEOM module is deactivated
1881 //=======================================================================
1882 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1884 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1886 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1888 setMenuShown( false );
1889 setToolShown( false );
1891 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1892 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1894 LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
1896 disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1897 disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
1898 getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
1899 myCreationInfoWdg = 0;
1901 EmitSignalCloseAllDialogs();
1903 GUIMap::Iterator it;
1904 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1905 it.value()->deactivate();
1907 // Unset actions accelerator keys
1908 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1909 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1910 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1912 qDeleteAll(myOCCSelectors);
1913 myOCCSelectors.clear();
1914 selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
1916 qDeleteAll(myVTKSelectors);
1917 myVTKSelectors.clear();
1918 selMrg->setEnabled( true, SVTK_Viewer::Type() );
1920 return SalomeApp_Module::deactivateModule( study );
1923 //=======================================================================
1924 // function : onWindowActivated()
1925 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1926 //=======================================================================
1927 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1932 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1933 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1935 // disable non-OCC viewframe menu commands
1936 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1937 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1938 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1939 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1940 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1941 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1942 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1944 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1945 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1946 action( GEOMOp::OpCreateField )->setEnabled( ViewOCC ); // Create Field
1947 action( GEOMOp::OpEditField )->setEnabled( ViewOCC ); // Edit Field
1949 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1952 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1954 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1955 mappa.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
1956 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1957 if ( myCreationInfoWdg )
1958 mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1961 void GeometryGUI::viewManagers( QStringList& lst ) const
1963 lst.append( OCCViewer_Viewer::Type() );
1966 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1968 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1970 qDebug( "connect" );
1971 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1972 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1973 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1974 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1975 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1976 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1977 connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
1978 this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
1980 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1981 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1983 // disable OCC selectors
1984 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1985 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1986 while ( itOCCSel.hasNext() )
1987 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1988 sr->setEnabled(true);
1990 else if ( vm->getType() == SVTK_Viewer::Type() )
1992 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1993 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1995 // disable VTK selectors
1996 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1997 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1998 while ( itVTKSel.hasNext() )
1999 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2000 sr->setEnabled(true);
2004 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
2006 SUIT_ViewModel* viewer = vm->getViewModel();
2007 if ( vm->getType() == OCCViewer_Viewer::Type() )
2009 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2010 while ( itOCCSel.hasNext() )
2011 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2012 if ( sr->viewer() == viewer )
2014 /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
2018 if ( vm->getType() == SVTK_Viewer::Type() )
2020 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2021 while ( itVTKSel.hasNext() )
2022 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2023 if ( sr->viewer() == viewer )
2025 /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
2031 //================================================================================
2033 * \brief Slot called when selection changed. Shows creation info of a selected object
2035 //================================================================================
2037 void GeometryGUI::updateCreationInfo()
2039 if ( myCreationInfoWdg )
2040 myCreationInfoWdg->clear();
2042 // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
2043 // if ( !myCreationInfoWdg->isVisible() )
2046 // look for a sole selected GEOM_Object
2047 GEOM::GEOM_BaseObject_var geomObj;
2049 SALOME_ListIO selected;
2050 getApp()->selectionMgr()->selectedObjects( selected );
2052 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
2053 SALOME_ListIteratorOfListIO selIt( selected );
2054 for ( ; selIt.More(); selIt.Next() )
2056 Handle(SALOME_InteractiveObject) io = selIt.Value();
2057 if ( !io->hasEntry() ) continue;
2058 _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
2059 if ( !sobj ) continue;
2060 CORBA::Object_var obj = GeometryGUI::ClientSObjectToObject( sobj );
2061 GEOM::GEOM_BaseObject_var gobj = GEOM::GEOM_BaseObject::_narrow( obj );
2062 if ( !gobj->_is_nil() )
2064 if ( !geomObj->_is_nil() )
2065 return; // several GEOM objects selected
2069 if ( geomObj->_is_nil() ) return;
2071 // pass creation info of geomObj to myCreationInfoWdg
2073 if ( myCreationInfoWdg ) {
2075 QString operationName;
2076 myCreationInfoWdg->setOperation( icon, operationName );
2080 GEOM::CreationInformation_var info = geomObj->GetCreationInformation();
2082 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2083 QString name = info->operationName.in();
2084 if ( !name.isEmpty() ) {
2085 icon = resMgr->loadPixmap( "GEOM", tr( ("ICO_"+name).toLatin1().constData() ), false );
2086 operationName = tr( ("MEN_"+name).toLatin1().constData() );
2087 if ( operationName.startsWith( "MEN_" ))
2088 operationName = name; // no translation
2089 myCreationInfoWdg->setOperation( icon, operationName );
2091 for ( size_t i = 0; i < info->params.length(); ++i )
2092 myCreationInfoWdg->addParam( info->params[i].name.in(),
2093 info->params[i].value.in() );
2102 void GeometryGUI::onAutoBringToFront()
2104 bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" );
2105 if( !isAutoBringToFront )
2108 SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
2109 if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
2112 SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
2113 if (!appStudy) return;
2115 GEOM_Displayer displayer( appStudy );
2117 SALOME_View* window = displayer.GetActiveView();
2118 if ( !window ) return;
2120 int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
2122 SALOME_ListIO selected;
2123 getApp()->selectionMgr()->selectedObjects( selected );
2124 if (!myTopLevelIOList.IsEmpty())
2126 for( SALOME_ListIteratorOfListIO It( myTopLevelIOList ); It.More(); It.Next() )
2128 Handle( SALOME_InteractiveObject ) io = It.Value();
2129 bool isSelected = false;
2130 for( SALOME_ListIteratorOfListIO It_sel( selected ); It_sel.More(); It_sel.Next() )
2132 Handle( SALOME_InteractiveObject ) sel_io = It_sel.Value();
2133 if( io->isSame( sel_io ) )
2136 if (!isSelected && appStudy->findObjectByEntry(io->getEntry()))
2138 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
2139 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2144 myTopLevelIOList.Assign(selected);
2145 for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
2147 Handle( SALOME_InteractiveObject ) io = It.Value();
2148 appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
2149 if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
2152 displayer.UpdateViewer();
2153 GeometryGUI::Modified();
2156 void GeometryGUI::updateFieldColorScale()
2158 if( SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) )
2160 GEOM_Displayer aDisplayer( aStudy );
2161 aDisplayer.UpdateColorScale();
2165 QString GeometryGUI::engineIOR() const
2167 if ( !CORBA::is_nil( GetGeomGen() ) )
2168 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
2172 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
2173 (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
2175 theWidth = theHeight = 0;
2177 Handle(TColStd_HArray1OfByte) aTexture;
2180 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
2181 aTexture = aTextureMap[ theId ];
2182 if ( aTexture.IsNull() ) {
2183 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
2184 if ( !aInsOp->_is_nil() ) {
2185 CORBA::Long aWidth, aHeight;
2186 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
2187 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
2189 theHeight = aHeight;
2191 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
2193 for (int i = 0; i < aStream->length(); i++)
2194 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
2195 aTextureMap[ theId ] = aTexture;
2203 LightApp_Selection* GeometryGUI::createSelection() const
2205 return new GEOMGUI_Selection();
2208 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
2210 SalomeApp_Module::contextMenuPopup( client, menu, title );
2212 getApp()->selectionMgr()->selectedObjects( lst );
2214 //Add submenu for predefined materials
2215 bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
2216 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
2217 QtxPopupMgr* mgr = popupMgr();
2218 //get parrent for submenu
2219 QAction* act = mgr->action( mgr->actionId( action( GEOMOp::OpMaterialProperties ) ) );
2221 QMenu* oldMenu = act->menu() ;
2226 QMenu* matMenu = new QMenu();
2227 QSignalMapper* signalMapper = new QSignalMapper( matMenu );
2229 //Get current material model for the object
2231 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
2232 if ( anApp && anApp->activeViewManager() ) {
2233 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
2235 v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
2238 QString curModel = "";
2239 if ( v.canConvert<QString>() ) curModel = v.toString();
2240 // get list of all predefined materials
2241 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2243 foreach ( QString material, materials )
2245 QAction* menAct = matMenu->addAction( material );
2246 connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
2247 signalMapper->setMapping( menAct, material );
2248 menAct->setCheckable( true );
2249 // Set checked if this material is current
2250 Material_Model aModel;
2251 aModel.fromResources( material );
2252 if ( !found && aModel.toProperties() == curModel ) {
2253 menAct->setChecked( true );
2257 matMenu->insertAction( matMenu->addSeparator(), action( GEOMOp::OpPredefMaterCustom ) );
2258 matMenu->insertSeparator( action( GEOMOp::OpPredefMaterCustom ) );
2259 connect( signalMapper, SIGNAL( mapped( const QString & ) ),
2260 this, SLOT( OnSetMaterial( const QString & ) ) );
2261 act->setMenu( matMenu );
2265 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
2266 Handle(SALOME_InteractiveObject) io = lst.First();
2267 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2268 _PTR(Study) study = appStudy->studyDS();
2269 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
2271 QString aName = QString( obj->GetName().c_str() );
2272 aName.remove( QRegExp("\\s+$") );
2278 void GeometryGUI::OnSetMaterial(const QString& theName)
2280 OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
2284 void GeometryGUI::createPreferences()
2286 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
2288 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
2289 setPreferenceProperty( genGroup, "columns", 2 );
2291 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
2292 LightApp_Preferences::Selector,
2293 "Geometry", "display_mode" );
2295 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
2296 LightApp_Preferences::Color, "Geometry", "shading_color" );
2298 addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
2299 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
2301 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
2302 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
2304 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
2305 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
2307 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
2308 LightApp_Preferences::Color, "Geometry", "line_color" );
2310 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
2311 LightApp_Preferences::Color, "Geometry", "point_color" );
2313 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
2314 LightApp_Preferences::Color, "Geometry", "isos_color" );
2316 addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
2317 LightApp_Preferences::Color, "Geometry", "toplevel_color" );
2319 int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
2320 LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
2322 int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup,
2323 LightApp_Preferences::IntSpin, "Geometry", "transparency" );
2325 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
2326 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
2328 addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
2329 LightApp_Preferences::Bool, "Geometry", "predef_materials" );
2331 int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
2332 LightApp_Preferences::Selector,
2333 "Geometry", "material" );
2335 addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
2336 LightApp_Preferences::Color, "Geometry", "editgroup_color" );
2342 wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
2343 LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
2345 wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
2346 LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
2348 wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
2349 LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
2351 wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
2352 LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
2354 for (int i = 0; i < nb; i++) {
2355 setPreferenceProperty( wd[i], "min", 1 );
2356 setPreferenceProperty( wd[i], "max", 5 );
2359 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
2360 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
2362 addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
2363 LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
2365 int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
2366 setPreferenceProperty( aDimGroupId, "columns", 2 );
2368 addPreference( tr( "PREF_DIMENSIONS_COLOR" ), aDimGroupId,
2369 LightApp_Preferences::Color, "Geometry", "dimensions_color" );
2371 int aDimLineWidthId = addPreference( tr( "PREF_DIMENSIONS_LINE_WIDTH" ), aDimGroupId,
2372 LightApp_Preferences::IntSpin, "Geometry", "dimensions_line_width" );
2374 setPreferenceProperty( aDimLineWidthId, "min", 1 );
2375 setPreferenceProperty( aDimLineWidthId, "max", 5 );
2377 int aDimFontHeightId = addPreference( tr( "PREF_DIMENSIONS_FONT_HEIGHT" ), aDimGroupId,
2378 LightApp_Preferences::DblSpin, "Geometry", "dimensions_font_height" );
2380 setPreferenceProperty( aDimFontHeightId, "min", 1e-9 );
2381 setPreferenceProperty( aDimFontHeightId, "max", 1e+9 );
2382 setPreferenceProperty( aDimFontHeightId, "precision", 9 );
2384 int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
2385 LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
2387 setPreferenceProperty( aDimArrLengthId, "min", 1e-9 );
2388 setPreferenceProperty( aDimArrLengthId, "max", 1e+9 );
2389 setPreferenceProperty( aDimArrLengthId, "precision", 9 );
2391 int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId,
2392 LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" );
2394 int anAngUnitsId = addPreference( tr( "PREF_DIMENSIONS_ANGLE_UNITS" ), aDimGroupId,
2395 LightApp_Preferences::Selector, "Geometry", "dimensions_angle_units" );
2397 addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
2398 LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
2400 QStringList aListOfLengthUnits;
2401 aListOfLengthUnits << "m";
2402 aListOfLengthUnits << "cm";
2403 aListOfLengthUnits << "mm";
2404 aListOfLengthUnits << "in.";
2405 aListOfLengthUnits << "ft.";
2407 QStringList aListOfAngUnits;
2408 aListOfAngUnits << "rad";
2409 aListOfAngUnits << "deg";
2411 setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
2412 setPreferenceProperty( anAngUnitsId, "strings", aListOfAngUnits );
2414 int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
2415 LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
2417 setPreferenceProperty( aDimDefFlyout, "min", 1e-9 );
2418 setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
2419 setPreferenceProperty( aDimDefFlyout, "precision", 9 );
2421 int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
2422 setPreferenceProperty( isoGroup, "columns", 2 );
2423 int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2424 LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
2425 setPreferenceProperty( isoU, "min", 0 );
2426 setPreferenceProperty( isoU, "max", 100000 );
2427 int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2428 LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
2429 setPreferenceProperty( isoV, "min", 0 );
2430 setPreferenceProperty( isoV, "max", 100000 );
2432 // Quantities with individual precision settings
2433 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
2434 setPreferenceProperty( precGroup, "columns", 2 );
2436 const int nbQuantities = 8;
2437 int prec[nbQuantities], ii = 0;
2438 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
2439 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
2440 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
2441 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
2442 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
2443 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
2444 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
2445 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
2446 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
2447 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
2448 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
2449 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
2450 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
2451 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
2452 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
2453 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
2455 // Set property for precision value for spinboxes
2456 for ( ii = 0; ii < nbQuantities; ii++ ){
2457 setPreferenceProperty( prec[ii], "min", -14 );
2458 setPreferenceProperty( prec[ii], "max", 14 );
2459 setPreferenceProperty( prec[ii], "precision", 2 );
2462 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
2463 setPreferenceProperty( VertexGroup, "columns", 2 );
2465 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2466 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2468 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2469 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2471 // Set property for default display mode
2472 QStringList aModesList;
2473 aModesList.append( tr("MEN_WIREFRAME") );
2474 aModesList.append( tr("MEN_SHADING") );
2475 aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2476 aModesList.append( tr("MEN_TEXTURE") );
2478 QList<QVariant> anIndexesList;
2479 anIndexesList.append(0);
2480 anIndexesList.append(1);
2481 anIndexesList.append(2);
2482 anIndexesList.append(3);
2484 setPreferenceProperty( dispmode, "strings", aModesList );
2485 setPreferenceProperty( dispmode, "indexes", anIndexesList );
2487 // Set property for top level display mode
2488 QStringList aTopModesList;
2489 aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2490 aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2491 aTopModesList.append( tr("MEN_WIREFRAME") );
2492 aTopModesList.append( tr("MEN_SHADING") );
2493 aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2495 QList<QVariant> aTopIndexesList;
2496 aTopIndexesList.append(0);
2497 aTopIndexesList.append(1);
2498 aTopIndexesList.append(2);
2499 aTopIndexesList.append(3);
2500 aTopIndexesList.append(4);
2502 setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2503 setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2505 // Set property for step value for spinboxes
2506 setPreferenceProperty( step, "min", 1 );
2507 setPreferenceProperty( step, "max", 10000 );
2508 setPreferenceProperty( step, "precision", 3 );
2510 // Set property for trandparency value for spinboxes
2511 setPreferenceProperty( transparency, "min", 0 );
2512 setPreferenceProperty( transparency, "max", 100 );
2514 // Set property for deflection value for spinboxes
2515 setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2516 setPreferenceProperty( defl, "max", 1.0 );
2517 setPreferenceProperty( defl, "step", 1.0e-04 );
2518 setPreferenceProperty( defl, "precision", 6 );
2520 // Set property for default material
2521 setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2523 // Set property vertex marker type
2524 QList<QVariant> aMarkerTypeIndicesList;
2525 QList<QVariant> aMarkerTypeIconsList;
2527 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2528 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2529 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2530 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2531 aMarkerTypeIndicesList << (i-1);
2532 aMarkerTypeIconsList << pixmap;
2535 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2536 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
2538 // Set property for vertex marker scale
2539 QList<QVariant> aMarkerScaleIndicesList;
2540 QStringList aMarkerScaleValuesList;
2542 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2543 aMarkerScaleIndicesList << iii;
2544 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2547 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2548 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2550 // Scalar bar for field step presentation
2551 int scalarBarGroup = addPreference( tr( "PREF_GROUP_SCALAR_BAR" ), tabId );
2552 setPreferenceProperty( scalarBarGroup, "columns", 2 );
2554 int sbXPosition = addPreference( tr( "PREF_SCALAR_BAR_X_POSITION" ), scalarBarGroup,
2555 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_x_position" );
2556 setPreferenceProperty( sbXPosition, "min", 0 );
2557 setPreferenceProperty( sbXPosition, "max", 1 );
2558 setPreferenceProperty( sbXPosition, "step", 0.05 );
2560 int sbYPosition = addPreference( tr( "PREF_SCALAR_BAR_Y_POSITION" ), scalarBarGroup,
2561 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_y_position" );
2562 setPreferenceProperty( sbYPosition, "min", 0 );
2563 setPreferenceProperty( sbYPosition, "max", 1 );
2564 setPreferenceProperty( sbYPosition, "step", 0.05 );
2566 int sbWidth = addPreference( tr( "PREF_SCALAR_BAR_WIDTH" ), scalarBarGroup,
2567 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_width" );
2568 setPreferenceProperty( sbWidth, "min", 0 );
2569 setPreferenceProperty( sbWidth, "max", 1 );
2570 setPreferenceProperty( sbWidth, "step", 0.05 );
2572 int sbHeight = addPreference( tr( "PREF_SCALAR_BAR_HEIGHT" ), scalarBarGroup,
2573 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_height" );
2574 setPreferenceProperty( sbHeight, "min", 0 );
2575 setPreferenceProperty( sbHeight, "max", 1 );
2576 setPreferenceProperty( sbHeight, "step", 0.05 );
2578 int sbTextHeight = addPreference( tr( "PREF_SCALAR_BAR_TEXT_HEIGHT" ), scalarBarGroup,
2579 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_text_height" );
2580 setPreferenceProperty( sbTextHeight, "min", 6 );
2581 setPreferenceProperty( sbTextHeight, "max", 24 );
2582 setPreferenceProperty( sbTextHeight, "step", 1 );
2584 int sbNbIntervals = addPreference( tr( "PREF_SCALAR_BAR_NUMBER_OF_INTERVALS" ), scalarBarGroup,
2585 LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_nb_intervals" );
2586 setPreferenceProperty( sbNbIntervals, "min", 2 );
2587 setPreferenceProperty( sbNbIntervals, "max", 64 );
2588 setPreferenceProperty( sbNbIntervals, "step", 1 );
2590 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2591 setPreferenceProperty( originGroup, "columns", 2 );
2593 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2594 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2595 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2596 setPreferenceProperty( baseVectorsLength, "max", 1000 );
2598 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2599 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2601 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2602 setPreferenceProperty( operationsGroup, "columns", 2 );
2604 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2605 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2607 int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) );
2609 int treeGeneralGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), DependencyViewId );
2611 int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), treeGeneralGroup,
2612 LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" );
2614 QStringList aHierarchyTypeList;
2615 aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") );
2616 aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") );
2617 aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") );
2619 QList<QVariant> aHierarchyTypeIndexesList;
2620 aHierarchyTypeIndexesList.append(0);
2621 aHierarchyTypeIndexesList.append(1);
2622 aHierarchyTypeIndexesList.append(2);
2624 setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList );
2625 setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList );
2627 addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), treeGeneralGroup,
2628 LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" );
2630 int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId );
2632 addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup,
2633 LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" );
2635 addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup,
2636 LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" );
2637 addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup,
2638 LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" );
2639 addPreference( tr( "PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR"), treeColorGroup,
2640 LightApp_Preferences::Color, "Geometry", "dependency_tree_unpublish_node_color" );
2641 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup,
2642 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" );
2644 addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup,
2645 LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" );
2646 addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup,
2647 LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" );
2648 addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup,
2649 LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" );
2656 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2658 if (section == "Geometry") {
2659 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2660 if (param == QString("SettingsGeomStep")) {
2661 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2662 EmitSignalDefaultStepValueChanged(spin_step);
2664 else if (param == QString("toplevel_color")) {
2665 QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2666 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2668 else if (param == QString("toplevel_dm")) {
2669 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2671 else if (param == QString("scalar_bar_x_position") ||
2672 param == QString("scalar_bar_y_position") ||
2673 param == QString("scalar_bar_width") ||
2674 param == QString("scalar_bar_height") ||
2675 param == QString("scalar_bar_text_height") ||
2676 param == QString("scalar_bar_nb_intervals")) {
2677 if( SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) )
2679 GEOM_Displayer aDisplayer( aStudy );
2680 bool anIsRedisplayFieldSteps = param == QString("scalar_bar_nb_intervals");
2681 aDisplayer.UpdateColorScale( anIsRedisplayFieldSteps, true );
2684 else if ( param == QString("dimensions_color") ||
2685 param == QString("dimensions_line_width") ||
2686 param == QString("dimensions_font_height") ||
2687 param == QString("dimensions_arrow_length") ||
2688 param == QString("dimensions_show_units") ||
2689 param == QString("dimensions_length_units") ||
2690 param == QString("dimensions_angle_units") )
2692 SalomeApp_Application* anApp = getApp();
2698 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
2704 GEOM_Displayer aDisplayer( aStudy );
2706 ViewManagerList aVMs;
2707 anApp->viewManagers( OCCViewer_Viewer::Type(), aVMs );
2708 ViewManagerList::Iterator anIt = aVMs.begin();
2709 for ( ; anIt != aVMs.end(); ++anIt )
2711 SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>( (*anIt)->getViewModel() );
2717 SALOME_ListIO aVisible;
2718 aViewer->GetVisible( aVisible );
2719 aDisplayer.Redisplay( aVisible, false, aViewer );
2722 aDisplayer.UpdateViewer();
2724 else if ( param.startsWith( "dependency_tree") )
2725 emit SignalDependencyTreeParamChanged( section, param );
2729 LightApp_Displayer* GeometryGUI::displayer()
2732 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
2736 void GeometryGUI::setLocalSelectionMode(const int mode)
2738 myLocalSelectionMode = mode;
2741 int GeometryGUI::getLocalSelectionMode() const
2743 return myLocalSelectionMode;
2746 const char gSeparator = '_'; // character used to separate parameter names
2747 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2750 * \brief Store visual parameters
2752 * This method is called just before the study document is saved.
2753 * Store visual parameters in AttributeParameter attribute(s)
2755 void GeometryGUI::storeVisualParameters (int savePoint)
2757 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2758 if ( !appStudy || !appStudy->studyDS() )
2760 _PTR(Study) studyDS = appStudy->studyDS();
2762 // componentName is used for encoding of entries when storing them in IParameters
2763 std::string componentName = myComponentGeom->ComponentDataType();
2764 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2765 //if (!aSComponent) return;
2768 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2769 componentName.c_str(),
2771 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2773 QSet<QString> anEntriesToStoreShared;
2774 QList<SUIT_ViewManager*> lst;
2775 QList<SUIT_ViewManager*>::Iterator it;
2777 // main cycle to store parameters of displayed objects
2779 getApp()->viewManagers(lst);
2780 for (it = lst.begin(); it != lst.end(); it++) {
2781 SUIT_ViewManager* vman = *it;
2782 QString vType = vman->getType();
2783 int aMgrId = vman->getGlobalId();
2784 // saving VTK actors properties
2785 QVector<SUIT_ViewWindow*> views = vman->getViews();
2786 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
2787 const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
2788 ObjMap::ConstIterator o_it = anObjects.begin();
2789 for (; o_it != anObjects.end(); o_it++) {
2790 const PropMap aProps = o_it.value();
2792 //Check that object exists in the study
2793 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
2794 if ( !obj || !(aProps.count() > 0))
2796 // entry is "encoded" = it does NOT contain component adress, since it is a
2797 // subject to change on next component loading
2799 std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
2801 _PTR(GenericAttribute) anAttr;
2802 if (!obj->FindAttribute(anAttr, "AttributeIOR"))
2805 // remember entry of object to store shared GEOM properties
2806 // (e.g. dimension properties).
2807 if ( vType == OCCViewer_Viewer::Type() )
2809 anEntriesToStoreShared.insert( o_it.key() );
2812 QString param, occParam = vType;
2813 occParam += GEOM::sectionSeparator();
2814 occParam += QString::number(aMgrId);
2815 occParam += GEOM::sectionSeparator();
2817 if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
2818 param = occParam + GEOM::propertyName( GEOM::Visibility );
2819 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
2822 if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
2823 param = occParam + GEOM::propertyName( GEOM::DisplayMode );
2824 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
2827 if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
2828 QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
2830 val << QString::number(c.redF());
2831 val << QString::number(c.greenF());
2832 val << QString::number(c.blueF());
2833 param = occParam + GEOM::propertyName( GEOM::Color );
2834 ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
2837 if (aProps.contains(GEOM::propertyName( GEOM::Texture ))) {
2838 param = occParam + GEOM::propertyName( GEOM::Texture );
2839 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Texture )).toString().toStdString());
2842 if (vType == SVTK_Viewer::Type()) {
2843 if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
2844 param = occParam + GEOM::propertyName( GEOM::Opacity );
2845 ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
2847 } else if (vType == SOCC_Viewer::Type()) {
2848 if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
2849 param = occParam + GEOM::propertyName( GEOM::Transparency );
2850 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
2853 if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
2854 param = occParam + GEOM::propertyName( GEOM::TopLevel );
2855 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
2859 if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
2860 param = occParam + GEOM::propertyName( GEOM::NbIsos );
2861 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
2864 if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
2865 param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
2866 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
2869 if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
2870 param = occParam + GEOM::propertyName( GEOM::Deflection );
2871 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
2874 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
2875 if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
2876 param = occParam + GEOM::propertyName( GEOM::PointMarker );
2877 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
2880 if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
2881 param = occParam + GEOM::propertyName( GEOM::Material );
2882 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
2885 if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
2886 param = occParam + GEOM::propertyName( GEOM::LineWidth );
2887 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
2890 if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
2891 param = occParam + GEOM::propertyName( GEOM::IsosWidth );
2892 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
2894 } // object iterator
2896 } // for (viewManagers)
2898 // store dimension attributes of objects:
2899 // since the displayed object always persists in property map, we remember the object entries
2900 // on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
2901 QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
2902 QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
2903 for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
2905 std::string aStudyEntry = (*aEntryIt).toLatin1().data();
2906 std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName);
2908 GEOMGUI_DimensionProperty aDimensions( appStudy, aStudyEntry );
2910 if ( aDimensions.GetNumber() == 0 )
2915 ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toLatin1().data() );
2920 * \brief Restore visual parameters
2922 * This method is called after the study document is opened.
2923 * Restore visual parameters from AttributeParameter attribute(s)
2925 void GeometryGUI::restoreVisualParameters (int savePoint)
2927 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2928 if (!appStudy || !appStudy->studyDS())
2930 _PTR(Study) studyDS = appStudy->studyDS();
2932 // componentName is used for encoding of entries when storing them in IParameters
2933 std::string componentName = myComponentGeom->ComponentDataType();
2934 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2935 //if (!aSComponent) return;
2938 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2939 componentName.c_str(),
2941 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2943 std::vector<std::string> entries = ip->getEntries();
2945 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
2947 // entry is a normal entry - it should be "decoded" (setting base adress of component)
2948 QString entry (ip->decodeEntry(*entIt).c_str());
2950 // Check that the entry corresponds to a real object in the Study
2951 // as the object may be deleted or modified after the visual state is saved.
2952 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
2953 if (!so) continue; //Skip the not existent entry
2955 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
2956 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
2958 std::vector<std::string>::iterator namesIt = paramNames.begin();
2959 std::vector<std::string>::iterator valuesIt = paramValues.begin();
2961 // actors are stored in a map after displaying of them for
2962 // quicker access in the future: map < viewID to actor >
2963 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
2964 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
2966 QString viewerTypStr;
2967 QString viewIndexStr;
2969 QVector<PropMap> aListOfMap;
2971 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
2973 // visual parameters are stored in strings as follows:
2974 // 1) ViewerType_ViewIndex_ParamName
2975 // 2) ViewerType_ParamName (shared for GEOM module)
2976 // '_' is used as separator and should not be used in viewer type or parameter names.
2977 QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
2979 bool isShared = lst.size() == 2;
2980 bool isViewer = lst.size() == 3;
2981 if ( !isShared && !isViewer )
2986 // shared visual parameters
2989 QString aParamNameStr( lst[1] );
2990 QString aValuesStr( (*valuesIt).c_str() );
2992 // shared dimension properties are stored as attribute
2993 if ( aParamNameStr == GEOM::propertyName( GEOM::Dimensions ) )
2995 GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
2996 aDimensionProp.SaveToAttribute( appStudy, entry.toLatin1().data() );
3002 // per view visual parameters
3003 viewerTypStr = lst[0];
3004 viewIndexStr = lst[1];
3005 QString paramNameStr = lst[2];
3008 viewIndex = viewIndexStr.toUInt(&ok);
3009 if (!ok) // bad conversion of view index to integer
3012 if ((viewIndex + 1) > aListOfMap.count()) {
3013 aListOfMap.resize(viewIndex + 1);
3016 QString val((*valuesIt).c_str());
3017 if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
3018 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
3019 } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
3020 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
3021 } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
3022 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
3023 } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
3024 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
3025 } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
3026 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
3027 } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
3028 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
3029 } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
3030 QStringList rgb = val.split(GEOM::subSectionSeparator());
3031 if (rgb.count() == 3) {
3032 QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
3033 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
3035 } else if (paramNameStr == GEOM::propertyName( GEOM::Texture )) {
3036 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val );
3037 } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
3038 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
3039 } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
3040 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
3041 } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
3042 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
3043 } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
3044 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
3045 } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
3046 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
3047 } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
3048 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
3050 } // for names/parameters iterator
3052 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
3054 for (int index = 0; index < aListOfMap.count(); index++) {
3056 appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
3058 //Get Visibility property of the current PropMap
3059 if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
3060 SUIT_ViewManager* vman = lst.at(index);
3061 SUIT_ViewModel* vmodel = vman->getViewModel();
3062 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
3065 } // for entries iterator
3067 // update all VTK and OCC views
3068 QList<SUIT_ViewManager*> lst;
3069 getApp()->viewManagers(lst);
3070 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
3071 SUIT_ViewModel* vmodel = (*it)->getViewModel();
3074 if (vmodel->getType() == SVTK_Viewer::Type()) {
3075 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
3076 vtkView->getRenderer()->ResetCameraClippingRange();
3079 else if (vmodel->getType() == SOCC_Viewer::Type()) {
3080 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
3081 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
3088 void GeometryGUI::onViewAboutToShow()
3090 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
3091 QAction* a = action( GEOMOp::OpSwitchVectors );
3093 a->setEnabled(true);
3094 bool vmode = window->property("VectorsMode").toBool();
3095 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
3097 a->setText ( tr("MEN_VECTOR_MODE_ON") );
3098 a->setEnabled(false);
3103 \brief Return action by id
3104 \param id identifier of the action
3107 QAction* GeometryGUI::getAction(const int id) {
3112 \brief GEOM module message handler
3114 This method can be re-implemented in the subclasses.
3115 This is a GEOM module message handler.
3117 \param msg the message received.
3119 void GeometryGUI::message(const QString& msg)
3122 QStringList data = msg.split("/");
3123 const int nbStrings = data.count();
3125 if (nbStrings > 0) {
3126 if (data[0] == "modified") {
3128 QString anIOR = nbStrings > 1 ? data[1] : QString();
3130 if ( anIOR.isEmpty() ) {
3134 // Get the geom object.
3135 GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
3137 // Clear the shape buffer
3138 GeometryGUI::ClearShapeBuffer (anObj);
3144 \brief Clears the shape buffer.
3146 This is a static method. It clears the shape buffer.
3148 \param theObj the object
3150 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
3152 if ( CORBA::is_nil( theObj ) )
3155 CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
3156 TCollection_AsciiString asciiIOR( (char *)IOR.in() );
3157 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3159 SALOMEDSClient_StudyManager *aManager = SalomeApp_Application::studyMgr();
3164 _PTR(Study) aStudy = aManager->GetStudyByID(theObj->GetStudyID());
3169 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
3173 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
3174 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
3175 _PTR(GenericAttribute) anAttr;
3176 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
3177 _PTR(AttributeIOR) anIOR ( anAttr );
3178 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
3179 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3185 \brief Returns the object from IOR.
3187 This is a static method. It returns the object from its IOR.
3189 \param IOR object IOR
3190 \return GEOM object.
3192 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
3194 GEOM::GEOM_Object_var geomObj;
3195 if ( !IOR.isEmpty() ) {
3196 CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
3197 ( IOR.toLatin1().constData() );
3198 if ( !CORBA::is_nil( corbaObj ) )
3199 geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
3201 return geomObj._retn();
3205 \brief Returns IOR of the object.
3207 This is a static method. It returns the object's IOR.
3209 \param object the GEOM object.
3210 \return object's IOR.
3212 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
3215 if ( !CORBA::is_nil( object ) ) {
3216 CORBA::String_var anIOR =
3217 SalomeApp_Application::orb()->object_to_string( object );
3224 \brief Check if this object is can't be renamed in place
3226 This method can be re-implemented in the subclasses.
3227 Return true in case if object isn't reference or component (module root).
3229 \param entry column id
3230 \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
3232 bool GeometryGUI::renameAllowed( const QString& entry) const {
3234 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
3235 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3236 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
3238 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
3242 Rename object by entry.
3243 \param entry entry of the object
3244 \param name new name of the object
3245 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3247 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
3249 bool result = false;
3251 SalomeApp_Application* app =
3252 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3253 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3258 _PTR(Study) aStudy = appStudy->studyDS();
3263 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
3265 SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
3269 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
3270 _PTR(GenericAttribute) anAttr;
3272 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
3273 _PTR(AttributeName) aName (anAttr);
3275 aName->SetValue( name.toLatin1().data() ); // rename the SObject
3276 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
3277 if (!CORBA::is_nil(anObj)) {
3278 anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object
3279 emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
3287 void GeometryGUI::updateMaterials()
3289 LightApp_Preferences* pref = preferences();
3291 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
3292 QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
3293 if ( !materials.contains( currentMaterial ) )
3294 // user material set as default in the preferences, might be removed
3295 SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
3297 QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
3299 setPreferenceProperty( prefItem->id(),
3300 "strings", materials );
3301 prefItem->retrieve();
3307 \brief Check if the module allows "drag" operation of its objects.
3309 Overloaded from LightApp_Module class.
3311 This function is a part of the general drag-n-drop mechanism.
3312 The goal of this function is to check data object passed as a parameter
3313 and decide if it can be dragged or no.
3315 \param what data object being tested for drag operation
3316 \return \c true if module allows dragging of the specified object
3317 \sa isDropAccepted(), dropObjects()
3319 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
3321 // we allow dragging object under root and object from folder
3322 int aLevel = what->level();
3323 bool anObjectInFolder = false;
3325 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
3327 _PTR(SObject) aSO = dataObj->object();
3329 _PTR(GenericAttribute) anAttr;
3330 _PTR(SObject) aFatherSO = aSO->GetStudy()->GetUseCaseBuilder()->GetFather( aSO );
3331 if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3332 _PTR(AttributeLocalID) aLocalID( anAttr );
3333 anObjectInFolder = aLocalID->Value() == 999;
3338 return aLevel == 2 || anObjectInFolder;
3342 \brief Check if the module allows "drop" operation on the given object.
3344 Overloaded from LightApp_Module class.
3346 This function is a part of the general drag-n-drop mechanism.
3347 The goal of this function is to check data object passed as a parameter
3348 and decide if it can be used as a target for the "drop" operation.
3349 The processing of the drop operation itself is done in the dropObjects() function.
3351 \param where target data object
3352 \return \c true if module supports dropping on the \a where data object
3353 \sa isDraggable(), dropObjects()
3355 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
3357 // we allow dropping into folder and top-level GEOM object
3358 int aLevel = where->level();
3359 bool isFolder = false;
3361 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
3363 _PTR(SObject) aSO = dataObj->object();
3365 _PTR(GenericAttribute) anAttr;
3366 if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3367 _PTR(AttributeLocalID) aLocalID( anAttr );
3368 isFolder = aLocalID->Value() == 999;
3373 return aLevel == 1 || isFolder;
3377 \brief Complete drag-n-drop operation.
3379 Overloaded from LightApp_Module class.
3381 This function is a part of the general drag-n-drop mechanism.
3382 Its goal is to handle dropping of the objects being dragged according
3383 to the chosen operation (move). The dropping is performed in the
3384 context of the parent data object \a where and the \a row (position in the
3385 children index) at which the data should be dropped. If \a row is equal to -1,
3386 this means that objects are added to the end of the children list.
3388 \param what objects being dropped
3389 \param where target data object
3390 \param row child index at which the drop operation is performed
3391 \param action drag-n-drop operation (Qt::DropAction) - move
3393 \sa isDraggable(), isDropAccepted()
3395 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
3396 const int row, Qt::DropAction action )
3398 if (action != Qt::CopyAction && action != Qt::MoveAction)
3399 return; // unsupported action
3401 // get parent object
3402 SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
3403 if ( !dataObj ) return; // wrong parent
3404 _PTR(SObject) parentObj = dataObj->object();
3406 // Find the current Study and StudyBuilder
3407 _PTR(Study) aStudy = parentObj->GetStudy();
3408 _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
3409 // collect all parents of the target node
3410 QStringList parentIDs;
3411 _PTR(SObject) parent = parentObj;
3412 while( !parent->IsNull() ) {
3413 parentIDs << parent->GetID().c_str();
3414 parent = aUseCaseBuilder->GetFather(parent);
3417 // collect objects being dropped
3418 GEOM::object_list_var objects = new GEOM::object_list();
3419 objects->length( what.count() );
3421 for ( int i = 0; i < what.count(); i++ ) {
3422 dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
3423 if ( !dataObj ) continue; // skip wrong objects
3424 _PTR(SObject) sobj = dataObj->object();
3425 // check that dropped object is not a parent of target object
3426 if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
3427 return; // it's not allowed to move node into it's child
3429 objects[i] = _CAST(SObject, sobj)->GetSObject();
3432 objects->length( count );
3434 // call engine function
3435 GetGeomGen()->Move( objects.in(), // what
3436 _CAST(SObject, parentObj)->GetSObject(), // where
3439 // update Object browser
3440 getApp()->updateObjectBrowser( false );