1 // Copyright (C) 2007-2013 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.
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 "GEOMGUI_OCCSelector.h"
33 #include "GEOMGUI_Selection.h"
34 #include "GEOM_Constants.h"
35 #include "GEOM_Displayer.h"
36 #include "GEOM_AISShape.hxx"
38 #include "GEOM_Actor.h"
40 #include <Material_ResourceMgr.h>
41 #include <Material_Model.h>
43 #include <SUIT_Desktop.h>
44 #include <SUIT_MessageBox.h>
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_Session.h>
47 #include <SUIT_ViewManager.h>
49 #include <OCCViewer_ViewWindow.h>
50 #include <OCCViewer_ViewPort3d.h>
51 #include <OCCViewer_ViewModel.h>
52 #include <OCCViewer_ViewManager.h>
54 #include <SOCC_ViewModel.h>
55 #include <SOCC_ViewWindow.h>
57 #include <SVTK_ViewWindow.h>
58 #include <SVTK_RenderWindowInteractor.h>
59 #include <SVTK_InteractorStyle.h>
60 #include <SVTK_ViewModel.h>
62 #include <SalomeApp_Application.h>
63 #include <SalomeApp_DataObject.h>
64 #include <SalomeApp_Study.h>
65 #include <SalomeApp_Tools.h>
67 #include <LightApp_SelectionMgr.h>
68 #include <LightApp_VTKSelector.h>
69 #include <LightApp_DataObject.h>
70 #include <LightApp_Preferences.h>
72 #include <SALOME_LifeCycleCORBA.hxx>
73 #include <SALOME_ListIO.hxx>
74 #include <SALOME_ListIteratorOfListIO.hxx>
76 #include <SALOMEDSClient_ClientFactory.hxx>
77 #include <SALOMEDSClient_IParameters.hxx>
79 #include <Basics_OCCTVersion.hxx>
88 #include <QSignalMapper>
90 #include <AIS_Drawer.hxx>
91 #include <AIS_ListOfInteractive.hxx>
92 #include <AIS_ListIteratorOfListOfInteractive.hxx>
93 #include <Prs3d_Drawer.hxx>
94 #include <Prs3d_IsoAspect.hxx>
95 #include <Aspect_TypeOfMarker.hxx>
96 #include <OSD_SharedLibrary.hxx>
97 #include <NCollection_DataMap.hxx>
99 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
100 #include <TColStd_HArray1OfByte.hxx>
102 #include <Graphic3d_HArray1OfBytes.hxx>
105 #include <utilities.h>
107 #include <vtkCamera.h>
108 #include <vtkRenderer.h>
110 #include <GEOM_version.h>
112 #include "GEOMImpl_Types.hxx"
115 Standard_EXPORT CAM_Module* createModule() {
116 return new GeometryGUI();
119 Standard_EXPORT char* getModuleVersion() {
120 return (char*)GEOM_VERSION_STR;
124 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
126 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
128 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
130 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
131 if (CORBA::is_nil(myComponentGeom))
133 return GeometryGUI::myComponentGeom;
136 bool GeometryGUI::InitGeomGen()
139 if ( CORBA::is_nil( myComponentGeom ) ) return false;
143 //=======================================================================
144 // function : ClientSObjectToObject
146 //=======================================================================
147 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
149 _PTR(GenericAttribute) anAttr;
150 CORBA::Object_var anObj;
152 std::string aValue = theSObject->GetIOR();
153 if (strcmp(aValue.c_str(), "") != 0) {
154 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
155 anObj = anORB->string_to_object(aValue.c_str());
158 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
160 return anObj._retn();
163 //=======================================================================
164 // function : ClientStudyToStudy
166 //=======================================================================
167 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
169 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
170 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
171 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
172 int aStudyID = theStudy->StudyId();
173 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
174 return aDSStudy._retn();
177 void GeometryGUI::Modified (bool theIsUpdateActions)
179 if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
180 if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
181 appStudy->Modified();
182 if ( theIsUpdateActions )
183 app->updateActions();
188 //=======================================================================
189 // function : GeometryGUI::GeometryGUI()
190 // purpose : Constructor
191 //=======================================================================
192 GeometryGUI::GeometryGUI() :
193 SalomeApp_Module( "GEOM" )
195 if ( CORBA::is_nil( myComponentGeom ) )
197 Engines::EngineComponent_var comp =
198 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
199 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
202 myActiveDialogBox = 0;
204 gp_Pnt origin = gp_Pnt(0., 0., 0.);
205 gp_Dir direction = gp_Dir(0., 0., 1.);
206 myWorkingPlane = gp_Ax3(origin, direction);
209 myLocalSelectionMode = GEOM_ALLOBJECTS;
211 connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
214 //=======================================================================
215 // function : GeometryGUI::~GeometryGUI()
216 // purpose : Destructor
217 //=======================================================================
218 GeometryGUI::~GeometryGUI()
220 while (!myOCCSelectors.isEmpty())
221 delete myOCCSelectors.takeFirst();
223 while (!myVTKSelectors.isEmpty())
224 delete myVTKSelectors.takeFirst();
226 qDeleteAll(myGUIMap);
229 //=======================================================================
230 // function : GeometryGUI::getLibrary()
231 // purpose : get or load GUI library by name [ internal ]
232 //=======================================================================
233 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
234 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
236 if ( !myGUIMap.contains( libraryName ) ) {
237 // try to load library if it is not loaded yet
239 QString dirs = getenv( "LD_LIBRARY_PATH" );
242 QString dirs = getenv( "PATH" );
245 if ( !dirs.isEmpty() ) {
246 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
247 QListIterator<QString> it( dirList ); it.toBack();
248 while ( it.hasPrevious() ) {
249 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
251 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
252 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
254 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
255 continue; // continue search further
257 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
258 if ( osdF != NULL ) {
259 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
260 GEOMGUI* libGUI = (*func)( this );
262 myGUIMap[ libraryName ] = libGUI;
263 break; // found and loaded!
270 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
273 //=======================================================================
274 // function : GeometryGUI::ActiveWorkingPlane()
275 // purpose : Activate Working Plane View
276 //=======================================================================
277 void GeometryGUI::ActiveWorkingPlane()
279 gp_Dir DZ = myWorkingPlane.Direction();
280 gp_Dir DY = myWorkingPlane.YDirection();
282 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
283 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
284 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
287 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
289 Handle(V3d_View) view3d = vw->getViewPort()->getView();
291 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
292 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
296 else if ( ViewVTK ) {
297 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
299 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
301 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
302 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
303 camera->SetFocalPoint(0,0,0);
310 //=======================================================================
311 // function : GeometryGUI::SetActiveDialogBox()
312 // purpose : Set active dialog box
313 //=======================================================================
314 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
316 myActiveDialogBox = (QDialog*)aDlg;
319 //=======================================================================
320 // function : GeometryGUI::EmitSignalDeactivateDialog()
321 // purpose : Emit a signal to deactivate the active dialog Box
322 //=======================================================================
323 void GeometryGUI::EmitSignalDeactivateDialog()
325 emit SignalDeactivateActiveDialog();
328 //=======================================================================
329 // function : GeometryGUI::EmitSignalCloseAllDialogs()
330 // purpose : Emit a signal to close all non modal dialogs box
331 //=======================================================================
332 void GeometryGUI::EmitSignalCloseAllDialogs()
334 emit SignalCloseAllDialogs();
337 //=======================================================================
338 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
339 // purpose : Emit a signal to inform that default real spin box step has
341 //=======================================================================
342 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
344 emit SignalDefaultStepValueChanged(newVal);
347 //=======================================================================
348 // function : GeometryGUI::OnGUIEvent()
349 // purpose : common slot for all menu/toolbar actions
350 //=======================================================================
351 void GeometryGUI::OnGUIEvent()
353 const QObject* obj = sender();
354 if ( !obj || !obj->inherits( "QAction" ) )
356 int id = actionId((QAction*)obj);
361 //=======================================================================
362 // function : GeometryGUI::OnGUIEvent()
363 // purpose : manage all events on GUI [static]
364 //=======================================================================
365 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
367 SUIT_Application* anApp = application();
369 SUIT_Desktop* desk = anApp->desktop();
371 // check type of the active viewframe
372 SUIT_ViewWindow* window = desk->activeWindow();
373 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
374 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
375 // if current viewframe is not of OCC and not of VTK type - return immediately
376 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
377 QList<int> NotViewerDependentCommands;
378 NotViewerDependentCommands << GEOMOp::OpDelete
380 << GEOMOp::OpShowOnly
381 << GEOMOp::OpShowOnlyChildren
382 << GEOMOp::OpDiscloseChildren
383 << GEOMOp::OpConcealChildren
384 << GEOMOp::OpUnpublishObject
385 << GEOMOp::OpPublishObject
386 << GEOMOp::OpPointMarker;
387 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
390 // fix for IPAL9103, point 2
391 if ( CORBA::is_nil( GetGeomGen() ) ) {
392 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
397 // find corresponding GUI library
399 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
400 createOriginAndBaseVectors(); // internal operation
402 case GEOMOp::OpImport: // MENU FILE - IMPORT
403 case GEOMOp::OpExport: // MENU FILE - EXPORT
404 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
405 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
406 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
407 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
408 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
409 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
410 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
411 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
412 case GEOMOp::OpDelete: // MENU EDIT - DELETE
413 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
414 case GEOMOp::OpMaterialsLibrary: // MENU TOOLS - MATERIALS LIBRARY
415 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
416 case GEOMOp::OpColor: // POPUP MENU - COLOR
417 case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
418 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
419 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
420 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
421 case GEOMOp::OpIsos: // POPUP MENU - ISOS
422 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
423 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
424 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
425 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
426 case GEOMOp::OpDiscloseChildren: // POPUP MENU - DISCLOSE CHILD ITEMS
427 case GEOMOp::OpConcealChildren: // POPUP MENU - CONCEAL CHILD ITEMS
428 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
429 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
430 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
431 case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
432 case GEOMOp::OpPredefMaterial: // POPUP MENU - <SOME MATERIAL>
433 case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
434 case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
435 case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
436 case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
437 case GEOMOp::OpClsBringToFront: //
438 libName = "GEOMToolsGUI";
440 case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
441 case GEOMOp::OpDMShading: // MENU VIEW - SHADING
442 case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
443 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
444 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
445 case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
446 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
447 case GEOMOp::OpHide: // MENU VIEW - ERASE
448 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
449 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
450 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
451 case GEOMOp::OpShading: // POPUP MENU - SHADING
452 case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
453 case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
454 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
455 libName = "DisplayGUI";
457 case GEOMOp::OpPoint: // MENU BASIC - POINT
458 case GEOMOp::OpLine: // MENU BASIC - LINE
459 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
460 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
461 case GEOMOp::OpArc: // MENU BASIC - ARC
462 case GEOMOp::OpVector: // MENU BASIC - VECTOR
463 case GEOMOp::OpPlane: // MENU BASIC - PLANE
464 case GEOMOp::OpCurve: // MENU BASIC - CURVE
465 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
466 libName = "BasicGUI";
468 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
469 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
470 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
471 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
472 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
473 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
474 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
475 libName = "PrimitiveGUI";
477 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
478 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
479 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
480 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
481 case GEOMOp::OpPipePath: // MENU GENERATION - RESTORE PATH
482 libName = "GenerationGUI";
484 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
485 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
486 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
488 case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
490 case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
491 libName = "EntityGUI";
493 case GEOMOp::OpEdge: // MENU BUILD - EDGE
494 case GEOMOp::OpWire: // MENU BUILD - WIRE
495 case GEOMOp::OpFace: // MENU BUILD - FACE
496 case GEOMOp::OpShell: // MENU BUILD - SHELL
497 case GEOMOp::OpSolid: // MENU BUILD - SOLID
498 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
499 libName = "BuildGUI";
501 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
502 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
503 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
504 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
505 libName = "BooleanGUI";
507 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
508 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
509 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
510 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
511 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
512 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
513 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
514 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
515 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
516 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
517 libName = "TransformationGUI";
519 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
520 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
521 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
522 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
523 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
524 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
525 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
526 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
527 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
528 case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
529 case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
530 libName = "OperationGUI";
532 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
533 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
534 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
535 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
536 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
537 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
538 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
539 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
540 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
541 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
542 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
543 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
544 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
545 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
546 case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES
547 case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES
548 libName = "RepairGUI";
550 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
551 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
552 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
553 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
554 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
555 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
556 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
557 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
558 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
559 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
560 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
561 case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS
562 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
563 case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
564 libName = "MeasureGUI";
566 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
567 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
568 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
569 case GEOMOp::OpGroupUnion: // MENU GROUP - UNION
570 case GEOMOp::OpGroupIntersect: // MENU GROUP - INTERSECT
571 case GEOMOp::OpGroupCut: // MENU GROUP - CUT
572 libName = "GroupGUI";
574 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
575 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
576 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
577 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
578 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
579 libName = "BlocksGUI";
581 case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
582 case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
583 // case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
584 case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
585 case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
586 case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
587 //@@ 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 @@//
588 libName = "AdvancedGUI";
594 GEOMGUI* library = 0;
595 if ( !libName.isEmpty() ) {
597 libName = QString( "lib" ) + libName + ".so";
599 libName = libName + ".dll";
601 library = getLibrary( libName );
604 // call method of corresponding GUI library
606 if( !theParam.isValid() )
607 library->OnGUIEvent( id, desk );
609 library->OnGUIEvent( id, desk, theParam);
612 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
615 //=================================================================================
616 // function : GeometryGUI::OnKeyPress()
617 // purpose : Called when any key is pressed by user [static]
618 //=================================================================================
619 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
621 if ( !application() )
623 foreach ( GEOMGUI* lib, myGUIMap )
624 lib->OnKeyPress( e, application()->desktop(), w );
627 //=================================================================================
628 // function : GeometryGUI::OnMouseMove()
629 // purpose : Manages mouse move events [static]
630 //=================================================================================
631 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
633 if ( !application() )
635 foreach ( GEOMGUI* lib, myGUIMap )
636 lib->OnMouseMove( e, application()->desktop(), w );
639 //=================================================================================
640 // function : GeometryGUI::OnMouseRelease()
641 // purpose : Manages mouse release events [static]
642 //=================================================================================
643 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
645 if ( !application() )
647 foreach ( GEOMGUI* lib, myGUIMap )
648 lib->OnMouseRelease( e, application()->desktop(), w );
651 //=================================================================================
652 // function : GeometryGUI::OnMousePress()
653 // purpose : Manage mouse press events [static]
654 //=================================================================================
655 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
657 if ( !application() )
659 foreach ( GEOMGUI* lib, myGUIMap )
660 lib->OnMousePress( e, application()->desktop(), w );
663 //=======================================================================
664 // function : createGeomAction
666 //=======================================================================
667 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
668 const int accel, const bool toggle, const QString& shortcutAction )
670 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
671 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
672 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
674 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
676 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
677 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
679 application()->desktop(),
681 this, SLOT( OnGUIEvent() ),
685 //=======================================================================
686 // function : createOriginAndBaseVectors
688 //=======================================================================
689 void GeometryGUI::createOriginAndBaseVectors()
691 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
693 _PTR(Study) studyDS = appStudy->studyDS();
694 if ( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
695 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
696 if ( !aBasicOperations->_is_nil() ) {
697 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
698 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
699 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
700 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
701 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
702 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
704 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
705 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
706 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
707 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
708 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
710 getApp()->updateObjectBrowser( false );
716 //=======================================================================
717 // function : GeometryGUI::initialize()
718 // purpose : Called when GEOM module is created
719 //=======================================================================
720 void GeometryGUI::initialize( CAM_Application* app )
722 SalomeApp_Module::initialize( app );
724 // ----- create actions --------------
726 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
727 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
729 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
731 createGeomAction( GEOMOp::OpPoint, "POINT" );
732 createGeomAction( GEOMOp::OpLine, "LINE" );
733 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
734 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
735 createGeomAction( GEOMOp::OpArc, "ARC" );
736 createGeomAction( GEOMOp::OpCurve, "CURVE" );
737 createGeomAction( GEOMOp::OpVector, "VECTOR" );
738 createGeomAction( GEOMOp::OpPlane, "PLANE" );
739 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
740 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
742 createGeomAction( GEOMOp::OpBox, "BOX" );
743 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
744 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
745 createGeomAction( GEOMOp::OpTorus, "TORUS" );
746 createGeomAction( GEOMOp::OpCone, "CONE" );
747 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
748 createGeomAction( GEOMOp::OpDisk, "DISK" );
750 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
751 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
752 createGeomAction( GEOMOp::OpFilling, "FILLING" );
753 createGeomAction( GEOMOp::OpPipe, "PIPE" );
754 createGeomAction( GEOMOp::OpPipePath, "PIPE_PATH" );
756 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
757 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
758 createGeomAction( GEOMOp::OpGroupUnion, "GROUP_UNION" );
759 createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
760 createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" );
762 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
764 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
765 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
767 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
768 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
769 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
771 createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
773 createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
775 createGeomAction( GEOMOp::OpEdge, "EDGE" );
776 createGeomAction( GEOMOp::OpWire, "WIRE" );
777 createGeomAction( GEOMOp::OpFace, "FACE" );
778 createGeomAction( GEOMOp::OpShell, "SHELL" );
779 createGeomAction( GEOMOp::OpSolid, "SOLID" );
780 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
782 createGeomAction( GEOMOp::OpFuse, "FUSE" );
783 createGeomAction( GEOMOp::OpCommon, "COMMON" );
784 createGeomAction( GEOMOp::OpCut, "CUT" );
785 createGeomAction( GEOMOp::OpSection, "SECTION" );
787 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
788 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
789 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
790 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
791 createGeomAction( GEOMOp::OpScale, "SCALE" );
792 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
793 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
794 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
795 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
797 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
798 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
799 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
800 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
801 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
802 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
803 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
804 createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
805 createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
806 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
807 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
809 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
810 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
811 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
813 createGeomAction( GEOMOp::OpSewing, "SEWING" );
814 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
815 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
816 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
817 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
818 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
819 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
820 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
821 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
822 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
823 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
824 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
825 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
826 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
827 createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" );
828 createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" );
830 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
831 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
832 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
833 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
834 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
835 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
836 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
837 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
839 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
840 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
841 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
842 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
843 createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
844 createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
846 #ifdef _DEBUG_ // PAL16821
847 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
850 createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" );
851 createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" );
852 createGeomAction( GEOMOp::OpDMShading, "SHADING" );
853 createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
854 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
855 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
856 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
857 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
858 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
859 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
860 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
861 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
862 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
863 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
864 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
865 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
866 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
867 createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
868 createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
869 createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
870 createGeomAction( GEOMOp::OpHide, "ERASE" );
872 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
873 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
874 createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
875 createGeomAction( GEOMOp::OpTexture, "POP_TEXTURE", "", 0, true );
876 createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH");
877 createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH");
878 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
879 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
880 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
881 createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
882 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
883 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
884 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
885 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
886 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
887 createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
888 createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
889 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
890 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
891 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
892 createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
893 createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
895 createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
897 // Create actions for increase/decrease transparency shortcuts
898 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
899 "Geometry:Increase transparency");
900 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
901 "Geometry:Decrease transparency");
903 // Create actions for increase/decrease number of isolines
904 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
905 "Geometry:Increase number of isolines");
906 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
907 "Geometry:Decrease number of isolines");
909 // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
910 createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
911 createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
912 createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
913 //@@ 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 @@//
915 // ---- create menus --------------------------
917 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
918 createMenu( separator(), fileId, 10 );
919 createMenu( GEOMOp::OpImport, fileId, 10 );
920 createMenu( GEOMOp::OpExport, fileId, 10 );
921 createMenu( separator(), fileId, -1 );
923 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
924 createMenu( GEOMOp::OpDelete, editId, -1 );
926 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
928 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
929 createMenu( GEOMOp::OpPoint, basicId, -1 );
930 createMenu( GEOMOp::OpLine, basicId, -1 );
931 createMenu( GEOMOp::OpCircle, basicId, -1 );
932 createMenu( GEOMOp::OpEllipse, basicId, -1 );
933 createMenu( GEOMOp::OpArc, basicId, -1 );
934 createMenu( GEOMOp::OpCurve, basicId, -1 );
935 createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
936 createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
937 createMenu( separator(), basicId, -1 );
938 createMenu( GEOMOp::OpVector, basicId, -1 );
939 createMenu( GEOMOp::OpPlane, basicId, -1 );
940 createMenu( GEOMOp::OpLCS, basicId, -1 );
941 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
943 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
944 createMenu( GEOMOp::OpBox, primId, -1 );
945 createMenu( GEOMOp::OpCylinder, primId, -1 );
946 createMenu( GEOMOp::OpSphere, primId, -1 );
947 createMenu( GEOMOp::OpTorus, primId, -1 );
948 createMenu( GEOMOp::OpCone, primId, -1 );
949 createMenu( GEOMOp::OpRectangle, primId, -1 );
950 createMenu( GEOMOp::OpDisk, primId, -1 );
951 createMenu( GEOMOp::OpPipeTShape,primId, -1 );
953 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
954 createMenu( GEOMOp::OpPrism, genId, -1 );
955 createMenu( GEOMOp::OpRevolution, genId, -1 );
956 createMenu( GEOMOp::OpFilling, genId, -1 );
957 createMenu( GEOMOp::OpPipe, genId, -1 );
958 #if OCC_VERSION_LARGE > 0x06050300
959 createMenu( GEOMOp::OpPipePath, genId, -1 );
962 int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
963 createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
964 //@@ 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 @@//
966 createMenu( separator(), newEntId, -1 );
968 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
969 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
970 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
971 createMenu( GEOMOp::OpGroupUnion, groupId, -1 );
972 createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
973 createMenu( GEOMOp::OpGroupCut, groupId, -1 );
975 createMenu( separator(), newEntId, -1 );
977 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
978 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
979 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
980 createMenu( GEOMOp::OpDividedDisk, blocksId, -1 );
981 createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
983 createMenu( separator(), newEntId, -1 );
985 createMenu( GEOMOp::OpExplode, newEntId, -1 );
987 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
988 createMenu( GEOMOp::OpEdge, buildId, -1 );
989 createMenu( GEOMOp::OpWire, buildId, -1 );
990 createMenu( GEOMOp::OpFace, buildId, -1 );
991 createMenu( GEOMOp::OpShell, buildId, -1 );
992 createMenu( GEOMOp::OpSolid, buildId, -1 );
993 createMenu( GEOMOp::OpCompound, buildId, -1 );
995 createMenu( separator(), newEntId, -1 );
997 createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
999 createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1002 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1004 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1005 createMenu( GEOMOp::OpFuse, boolId, -1 );
1006 createMenu( GEOMOp::OpCommon, boolId, -1 );
1007 createMenu( GEOMOp::OpCut, boolId, -1 );
1008 createMenu( GEOMOp::OpSection, boolId, -1 );
1010 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1011 createMenu( GEOMOp::OpTranslate, transId, -1 );
1012 createMenu( GEOMOp::OpRotate, transId, -1 );
1013 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
1014 createMenu( GEOMOp::OpMirror, transId, -1 );
1015 createMenu( GEOMOp::OpScale, transId, -1 );
1016 createMenu( GEOMOp::OpOffset, transId, -1 );
1017 createMenu( GEOMOp::OpProjection, transId, -1 );
1018 createMenu( separator(), transId, -1 );
1019 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1020 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
1022 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1023 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1024 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
1025 createMenu( GEOMOp::OpPropagate, blockId, -1 );
1027 createMenu( separator(), operId, -1 );
1029 createMenu( GEOMOp::OpPartition, operId, -1 );
1030 createMenu( GEOMOp::OpArchimede, operId, -1 );
1031 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1032 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
1034 createMenu( separator(), operId, -1 );
1036 createMenu( GEOMOp::OpFillet1d, operId, -1 );
1037 createMenu( GEOMOp::OpFillet2d, operId, -1 );
1038 createMenu( GEOMOp::OpFillet3d, operId, -1 );
1039 createMenu( GEOMOp::OpChamfer, operId, -1 );
1040 createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
1041 createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
1042 //createMenu( GEOMOp::OpClipping, operId, -1 );
1044 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1045 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
1046 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
1047 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
1048 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
1049 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
1050 createMenu( GEOMOp::OpSewing, repairId, -1 );
1051 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
1052 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
1053 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
1054 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
1055 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
1056 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
1057 createMenu( GEOMOp::OpOrientation, repairId, -1 );
1058 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1059 createMenu( GEOMOp::OpFuseEdges, repairId, -1 );
1060 createMenu( GEOMOp::OpUnionFaces, repairId, -1 );
1062 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1063 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1064 createMenu( GEOMOp::OpProperties, measurId, -1 );
1065 createMenu( separator(), measurId, -1 );
1066 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
1067 createMenu( GEOMOp::OpInertia, measurId, -1 );
1068 createMenu( GEOMOp::OpNormale, measurId, -1 );
1069 createMenu( separator(), measurId, -1 );
1070 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
1071 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
1072 createMenu( separator(), measurId, -1 );
1074 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1075 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1076 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1077 createMenu( GEOMOp::OpAngle, dimId, -1 );
1079 createMenu( separator(), measurId, -1 );
1080 createMenu( GEOMOp::OpTolerance, measurId, -1 );
1081 createMenu( separator(), measurId, -1 );
1082 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
1083 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
1084 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
1085 createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
1086 createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1088 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1089 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1090 createMenu( separator(), toolsId, -1 );
1091 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1094 createMenu( separator(), toolsId, -1 );
1095 createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1096 createMenu( separator(), toolsId, -1 );
1098 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1099 createMenu( separator(), viewId, -1 );
1101 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1102 createMenu( GEOMOp::OpDMWireframe, dispmodeId, -1 );
1103 createMenu( GEOMOp::OpDMShading, dispmodeId, -1 );
1104 createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1105 createMenu( separator(), dispmodeId, -1 );
1106 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1108 createMenu( separator(), viewId, -1 );
1109 createMenu( GEOMOp::OpShowAll, viewId, -1 );
1110 createMenu( GEOMOp::OpHideAll, viewId, -1 );
1111 createMenu( separator(), viewId, -1 );
1112 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1113 createMenu( separator(), viewId, -1 );
1117 because of these items are accessible through object browser and viewers
1118 we have removed they from main menu
1120 createMenu( GEOMOp::OpShow, viewId, -1 );
1121 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1122 createMenu( GEOMOp::OpHide, viewId, -1 );
1125 // ---- create toolbars --------------------------
1127 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1128 createTool( GEOMOp::OpPoint, basicTbId );
1129 createTool( GEOMOp::OpLine, basicTbId );
1130 createTool( GEOMOp::OpCircle, basicTbId );
1131 createTool( GEOMOp::OpEllipse, basicTbId );
1132 createTool( GEOMOp::OpArc, basicTbId );
1133 createTool( GEOMOp::OpCurve, basicTbId );
1134 createTool( GEOMOp::OpVector, basicTbId );
1135 createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1136 createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1137 createTool( GEOMOp::OpPlane, basicTbId );
1138 createTool( GEOMOp::OpLCS, basicTbId );
1139 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1141 // int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
1142 // createTool( GEOMOp::Op2dSketcher, sketchTbId );
1143 // createTool( GEOMOp::Op3dSketcher, sketchTbId );
1145 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1146 createTool( GEOMOp::OpBox, primTbId );
1147 createTool( GEOMOp::OpCylinder, primTbId );
1148 createTool( GEOMOp::OpSphere, primTbId );
1149 createTool( GEOMOp::OpTorus, primTbId );
1150 createTool( GEOMOp::OpCone, primTbId );
1151 createTool( GEOMOp::OpRectangle, primTbId );
1152 createTool( GEOMOp::OpDisk, primTbId );
1153 createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1155 int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) );
1156 createTool( GEOMOp::OpDividedDisk, blocksTbId );
1157 createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1159 // int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc
1160 // createTool( GEOMOp::OpPipeTShape, advancedTbId );
1162 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1163 createTool( GEOMOp::OpFuse, boolTbId );
1164 createTool( GEOMOp::OpCommon, boolTbId );
1165 createTool( GEOMOp::OpCut, boolTbId );
1166 createTool( GEOMOp::OpSection, boolTbId );
1168 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1169 createTool( GEOMOp::OpPrism, genTbId );
1170 createTool( GEOMOp::OpRevolution, genTbId );
1171 createTool( GEOMOp::OpFilling, genTbId );
1172 createTool( GEOMOp::OpPipe, genTbId );
1173 #if OCC_VERSION_LARGE > 0x06050300
1174 createTool( GEOMOp::OpPipePath, genTbId );
1177 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1178 createTool( GEOMOp::OpTranslate, transTbId );
1179 createTool( GEOMOp::OpRotate, transTbId );
1180 createTool( GEOMOp::OpChangeLoc, transTbId );
1181 createTool( GEOMOp::OpMirror, transTbId );
1182 createTool( GEOMOp::OpScale, transTbId );
1183 createTool( GEOMOp::OpOffset, transTbId );
1184 createTool( GEOMOp::OpProjection, transTbId );
1185 createTool( separator(), transTbId );
1186 createTool( GEOMOp::OpMultiTranslate, transTbId );
1187 createTool( GEOMOp::OpMultiRotate, transTbId );
1189 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1190 createTool( GEOMOp::OpExplode, operTbId );
1191 createTool( GEOMOp::OpPartition, operTbId );
1192 createTool( GEOMOp::OpArchimede, operTbId );
1193 createTool( GEOMOp::OpShapesOnShape, operTbId );
1194 createTool( GEOMOp::OpSharedShapes, operTbId );
1196 int featTbId = createTool( tr( "TOOL_FEATURES" ) );
1197 createTool( GEOMOp::OpFillet1d, featTbId );
1198 createTool( GEOMOp::OpFillet2d, featTbId );
1199 createTool( GEOMOp::OpFillet3d, featTbId );
1200 createTool( GEOMOp::OpChamfer, featTbId );
1201 createTool( GEOMOp::OpExtrudedBoss, featTbId );
1202 createTool( GEOMOp::OpExtrudedCut, featTbId );
1204 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1205 createTool( GEOMOp::OpEdge, buildTbId );
1206 createTool( GEOMOp::OpWire, buildTbId );
1207 createTool( GEOMOp::OpFace, buildTbId );
1208 createTool( GEOMOp::OpShell, buildTbId );
1209 createTool( GEOMOp::OpSolid, buildTbId );
1210 createTool( GEOMOp::OpCompound, buildTbId );
1212 int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1213 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1214 createTool( GEOMOp::OpProperties, measureTbId );
1215 createTool( GEOMOp::OpCenterMass, measureTbId );
1216 createTool( GEOMOp::OpInertia, measureTbId );
1217 createTool( GEOMOp::OpNormale, measureTbId );
1218 createTool( separator(), measureTbId );
1219 createTool( GEOMOp::OpBoundingBox, measureTbId );
1220 createTool( GEOMOp::OpMinDistance, measureTbId );
1221 createTool( GEOMOp::OpAngle, measureTbId );
1222 createTool( GEOMOp::OpTolerance , measureTbId );
1223 createTool( separator(), measureTbId );
1224 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1225 createTool( GEOMOp::OpFreeFaces, measureTbId );
1226 createTool( separator(), measureTbId );
1227 createTool( GEOMOp::OpWhatIs, measureTbId );
1228 createTool( GEOMOp::OpCheckShape, measureTbId );
1229 createTool( GEOMOp::OpCheckCompound, measureTbId );
1230 createTool( GEOMOp::OpGetNonBlocks, measureTbId );
1231 createTool( GEOMOp::OpCheckSelfInters, measureTbId );
1233 int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
1234 createTool( GEOMOp::OpPictureImport, picturesTbId );
1236 createTool( GEOMOp::OpFeatureDetect, picturesTbId );
1239 int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1240 createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1241 //@@ 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 @@//
1243 // ---- create popup menus --------------------------
1245 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1246 QString clientOCC = "(client='OCCViewer')";
1247 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1248 QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1250 QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1251 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1252 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1253 QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1255 QString autoColorPrefix =
1256 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1258 QtxPopupMgr* mgr = popupMgr();
1260 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1261 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1262 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1263 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1264 mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1265 mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1267 mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal shild items
1268 mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1269 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1270 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1271 mgr->insert( separator(), -1, -1 ); // -----------
1273 #if OCC_VERSION_LARGE > 0x06050200
1274 //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1275 QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true";
1276 mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1277 mgr->setRule(action(GEOMOp::OpBringToFront), bringRule, QtxPopupMgr::VisibleRule );
1278 mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1279 mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1280 mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule );
1282 mgr->insert( separator(), -1, -1 ); // -----------
1283 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1284 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1285 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1286 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1287 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1288 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1289 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1290 mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1291 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1292 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1293 mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1294 mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1295 mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1296 mgr->insert( separator(), dispmodeId, -1 );
1297 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1298 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1299 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1300 mgr->insert( separator(), -1, -1 ); // -----------
1302 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1303 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1304 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1305 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1306 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1307 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1308 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1309 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1310 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1311 //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1312 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1314 // material properties
1315 mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
1316 mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1319 mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
1320 mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1322 int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1323 mgr->insert( action( GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1324 mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1326 mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1327 mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1329 mgr->insert( separator(), -1, -1 ); // -----------
1330 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1331 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1332 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1333 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1334 mgr->insert( separator(), -1, -1 ); // -----------
1336 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1337 onlyComponent = "((type='Component') and selcount=1)",
1338 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1339 types = "'Shape' 'Group'";
1341 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1342 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1344 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1345 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1347 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1348 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1350 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1352 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1353 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1354 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1355 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1356 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1357 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1358 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1359 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1360 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1361 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1362 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1363 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1364 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1365 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1366 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1367 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1368 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1369 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1370 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1371 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1372 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1373 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1374 mgr->insert( separator(), selectonlyId, -1);
1375 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1376 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1377 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1378 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1379 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1380 mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1381 mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1383 mgr->insert( separator(), -1, -1 ); // -----------
1384 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1385 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1387 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1388 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1390 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1391 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1393 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1395 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1397 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1398 QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1399 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1403 //=======================================================================
1404 // function : GeometryGUI::activateModule()
1405 // purpose : Called when GEOM module is activated
1406 //=======================================================================
1407 bool GeometryGUI::activateModule( SUIT_Study* study )
1409 if ( CORBA::is_nil( myComponentGeom ) )
1412 bool res = SalomeApp_Module::activateModule( study );
1416 setMenuShown( true );
1417 setToolShown( true );
1419 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1420 PyGILState_STATE gstate = PyGILState_Ensure();
1421 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1422 if (pluginsmanager == NULL)
1426 PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1427 tr("MEN_NEW_ENTITY").toStdString().c_str(),
1428 tr("GEOM_PLUGINS_OTHER").toStdString().c_str());
1433 PyGILState_Release(gstate);
1434 // end of GEOM plugins loading
1436 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1437 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1439 // Reset actions accelerator keys
1440 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1441 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1442 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1444 GUIMap::Iterator it;
1445 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1446 it.value()->activate( application()->desktop() );
1448 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1450 SUIT_ViewManager* vm;
1451 ViewManagerList OCCViewManagers, VTKViewManagers;
1453 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1454 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1455 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1456 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1458 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1459 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1460 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1461 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1464 SALOME_ListIO selected;
1465 sm->selectedObjects( selected );
1466 sm->clearSelected();
1468 // disable OCC selectors
1469 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1470 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1471 while ( itOCCSel.hasNext() )
1472 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1473 sr->setEnabled(true);
1475 // disable VTK selectors
1476 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1477 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1478 while ( itVTKSel.hasNext() )
1479 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1480 sr->setEnabled(true);
1482 sm->setSelectedObjects( selected, true ); //NPAL 19674
1484 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1486 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1488 // 0020836 (Basic vectors and origin)
1489 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1490 if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1491 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1493 _PTR(Study) studyDS = appStudy->studyDS();
1495 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1496 if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1497 createOriginAndBaseVectors();
1505 //=======================================================================
1506 // function : GeometryGUI::deactivateModule()
1507 // purpose : Called when GEOM module is deactivated
1508 //=======================================================================
1509 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1511 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1513 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1515 setMenuShown( false );
1516 setToolShown( false );
1518 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1519 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1521 EmitSignalCloseAllDialogs();
1523 GUIMap::Iterator it;
1524 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1525 it.value()->deactivate();
1527 // Unset actions accelerator keys
1528 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1529 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1530 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1532 qDeleteAll(myOCCSelectors);
1533 myOCCSelectors.clear();
1534 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1536 qDeleteAll(myVTKSelectors);
1537 myVTKSelectors.clear();
1538 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1540 return SalomeApp_Module::deactivateModule( study );
1543 //=======================================================================
1544 // function : onWindowActivated()
1545 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1546 //=======================================================================
1547 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1552 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1553 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1555 // disable non-OCC viewframe menu commands
1556 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1557 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1558 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1559 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1560 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1561 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1562 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1564 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1565 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1567 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1570 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1572 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1573 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1576 void GeometryGUI::viewManagers( QStringList& lst ) const
1578 lst.append( OCCViewer_Viewer::Type() );
1581 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1583 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1585 qDebug( "connect" );
1586 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1587 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1588 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1589 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1590 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1591 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1592 connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
1593 this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
1595 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1596 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1598 // disable OCC selectors
1599 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1600 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1601 while ( itOCCSel.hasNext() )
1602 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1603 sr->setEnabled(true);
1605 else if ( vm->getType() == SVTK_Viewer::Type() )
1607 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1608 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1610 // disable VTK selectors
1611 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1612 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1613 while ( itVTKSel.hasNext() )
1614 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1615 sr->setEnabled(true);
1619 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1621 SUIT_ViewModel* viewer = vm->getViewModel();
1622 if ( vm->getType() == OCCViewer_Viewer::Type() )
1624 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1625 while ( itOCCSel.hasNext() )
1626 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1627 if ( sr->viewer() == viewer )
1629 /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1633 if ( vm->getType() == SVTK_Viewer::Type() )
1635 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1636 while ( itVTKSel.hasNext() )
1637 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1638 if ( sr->viewer() == viewer )
1640 /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1646 QString GeometryGUI::engineIOR() const
1648 if ( !CORBA::is_nil( GetGeomGen() ) )
1649 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1653 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1654 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
1656 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture
1658 (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
1660 theWidth = theHeight = 0;
1662 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1663 Handle(TColStd_HArray1OfByte) aTexture;
1665 Handle(Graphic3d_HArray1OfBytes) aTexture;
1669 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1670 aTexture = aTextureMap[ theId ];
1671 if ( aTexture.IsNull() ) {
1672 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1673 if ( !aInsOp->_is_nil() ) {
1674 CORBA::Long aWidth, aHeight;
1675 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1676 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1678 theHeight = aHeight;
1680 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1681 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
1683 aTexture = new Graphic3d_HArray1OfBytes (1, aStream->length());
1686 for (int i = 0; i < aStream->length(); i++)
1687 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1688 aTextureMap[ theId ] = aTexture;
1696 LightApp_Selection* GeometryGUI::createSelection() const
1698 return new GEOMGUI_Selection();
1701 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1703 SalomeApp_Module::contextMenuPopup( client, menu, title );
1705 getApp()->selectionMgr()->selectedObjects( lst );
1707 //Add submenu for predefined materials
1708 bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
1709 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
1710 QtxPopupMgr* mgr = popupMgr();
1711 //get parrent for submenu
1712 QAction* act = mgr->action( mgr->actionId( action( GEOMOp::OpMaterialProperties ) ) );
1714 QMenu* oldMenu = act->menu() ;
1719 QMenu* matMenu = new QMenu();
1720 QSignalMapper* signalMapper = new QSignalMapper( matMenu );
1722 //Get current material model for the object
1724 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
1725 if ( anApp && anApp->activeViewManager() ) {
1726 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
1728 v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
1731 QString curModel = "";
1732 if ( v.canConvert<QString>() ) curModel = v.toString();
1733 // get list of all predefined materials
1734 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
1736 foreach ( QString material, materials )
1738 QAction* menAct = matMenu->addAction( material );
1739 connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
1740 signalMapper->setMapping( menAct, material );
1741 menAct->setCheckable( true );
1742 // Set checked if this material is current
1743 Material_Model aModel;
1744 aModel.fromResources( material );
1745 if ( !found && aModel.toProperties() == curModel ) {
1746 menAct->setChecked( true );
1750 matMenu->insertAction( matMenu->addSeparator(), action( GEOMOp::OpPredefMaterCustom ) );
1751 matMenu->insertSeparator( action( GEOMOp::OpPredefMaterCustom ) );
1752 connect( signalMapper, SIGNAL( mapped( const QString & ) ),
1753 this, SLOT( OnSetMaterial( const QString & ) ) );
1754 act->setMenu( matMenu );
1758 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
1759 Handle(SALOME_InteractiveObject) io = lst.First();
1760 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1761 _PTR(Study) study = appStudy->studyDS();
1762 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
1764 QString aName = QString( obj->GetName().c_str() );
1765 aName.remove( QRegExp("\\s+$") );
1771 void GeometryGUI::OnSetMaterial(const QString& theName)
1773 OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
1777 void GeometryGUI::createPreferences()
1779 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1781 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1782 setPreferenceProperty( genGroup, "columns", 2 );
1784 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1785 LightApp_Preferences::Selector,
1786 "Geometry", "display_mode" );
1788 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1789 LightApp_Preferences::Color, "Geometry", "shading_color" );
1791 addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
1792 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
1794 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1795 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1797 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1798 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1800 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1801 LightApp_Preferences::Color, "Geometry", "line_color" );
1803 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1804 LightApp_Preferences::Color, "Geometry", "point_color" );
1806 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1807 LightApp_Preferences::Color, "Geometry", "isos_color" );
1809 addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
1810 LightApp_Preferences::Color, "Geometry", "toplevel_color" );
1812 int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
1813 LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
1815 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1816 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1818 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1819 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1821 addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
1822 LightApp_Preferences::Bool, "Geometry", "predef_materials" );
1824 int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
1825 LightApp_Preferences::Selector,
1826 "Geometry", "material" );
1828 addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
1829 LightApp_Preferences::Color, "Geometry", "editgroup_color" );
1835 wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
1836 LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
1838 wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
1839 LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
1841 wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
1842 LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
1844 wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
1845 LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
1847 for (int i = 0; i < nb; i++) {
1848 setPreferenceProperty( wd[i], "min", 1 );
1849 setPreferenceProperty( wd[i], "max", 5 );
1852 int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
1853 setPreferenceProperty( isoGroup, "columns", 2 );
1854 int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
1855 LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
1856 setPreferenceProperty( isoU, "min", 0 );
1857 setPreferenceProperty( isoU, "max", 100000 );
1858 int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
1859 LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
1860 setPreferenceProperty( isoV, "min", 0 );
1861 setPreferenceProperty( isoV, "max", 100000 );
1863 // Quantities with individual precision settings
1864 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1865 setPreferenceProperty( precGroup, "columns", 2 );
1867 const int nbQuantities = 8;
1868 int prec[nbQuantities], ii = 0;
1869 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1870 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1871 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1872 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1873 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1874 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1875 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1876 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1877 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1878 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1879 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1880 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1881 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1882 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1883 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1884 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1886 // Set property for precision value for spinboxes
1887 for ( ii = 0; ii < nbQuantities; ii++ ){
1888 setPreferenceProperty( prec[ii], "min", -14 );
1889 setPreferenceProperty( prec[ii], "max", 14 );
1890 setPreferenceProperty( prec[ii], "precision", 2 );
1893 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1894 setPreferenceProperty( VertexGroup, "columns", 2 );
1896 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1897 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1899 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1900 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1902 // Set property for default display mode
1903 QStringList aModesList;
1904 aModesList.append( tr("MEN_WIREFRAME") );
1905 aModesList.append( tr("MEN_SHADING") );
1906 aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
1908 QList<QVariant> anIndexesList;
1909 anIndexesList.append(0);
1910 anIndexesList.append(1);
1911 anIndexesList.append(2);
1913 setPreferenceProperty( dispmode, "strings", aModesList );
1914 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1916 // Set property for top level display mode
1917 QStringList aTopModesList;
1918 aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
1919 aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
1920 aTopModesList.append( tr("MEN_WIREFRAME") );
1921 aTopModesList.append( tr("MEN_SHADING") );
1922 aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
1924 QList<QVariant> aTopIndexesList;
1925 aTopIndexesList.append(0);
1926 aTopIndexesList.append(1);
1927 aTopIndexesList.append(2);
1928 aTopIndexesList.append(3);
1929 aTopIndexesList.append(4);
1931 setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
1932 setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
1934 // Set property for step value for spinboxes
1935 setPreferenceProperty( step, "min", 1 );
1936 setPreferenceProperty( step, "max", 10000 );
1937 setPreferenceProperty( step, "precision", 3 );
1939 // Set property for deflection value for spinboxes
1940 setPreferenceProperty( defl, "min", GEOM::minDeflection() );
1941 setPreferenceProperty( defl, "max", 1.0 );
1942 setPreferenceProperty( defl, "step", 1.0e-04 );
1943 setPreferenceProperty( defl, "precision", 6 );
1945 // Set property for default material
1946 setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
1948 // Set property vertex marker type
1949 QList<QVariant> aMarkerTypeIndicesList;
1950 QList<QVariant> aMarkerTypeIconsList;
1952 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1953 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1954 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1955 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1956 aMarkerTypeIndicesList << (i-1);
1957 aMarkerTypeIconsList << pixmap;
1960 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1961 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
1963 // Set property for vertex marker scale
1964 QList<QVariant> aMarkerScaleIndicesList;
1965 QStringList aMarkerScaleValuesList;
1967 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
1968 aMarkerScaleIndicesList << iii;
1969 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
1972 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1973 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1975 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
1976 setPreferenceProperty( originGroup, "columns", 2 );
1978 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
1979 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
1980 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
1981 setPreferenceProperty( baseVectorsLength, "max", 1000 );
1983 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
1984 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
1986 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
1987 setPreferenceProperty( operationsGroup, "columns", 2 );
1989 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
1990 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
1993 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1995 if (section == "Geometry") {
1996 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1997 if (param == QString("SettingsGeomStep")) {
1998 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1999 EmitSignalDefaultStepValueChanged(spin_step);
2001 else if (param == QString("toplevel_color")) {
2002 QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2003 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2005 else if (param == QString("toplevel_dm")) {
2006 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2011 LightApp_Displayer* GeometryGUI::displayer()
2014 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
2018 void GeometryGUI::setLocalSelectionMode(const int mode)
2020 myLocalSelectionMode = mode;
2023 int GeometryGUI::getLocalSelectionMode() const
2025 return myLocalSelectionMode;
2028 const char gSeparator = '_'; // character used to separate parameter names
2029 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2032 * \brief Store visual parameters
2034 * This method is called just before the study document is saved.
2035 * Store visual parameters in AttributeParameter attribute(s)
2037 void GeometryGUI::storeVisualParameters (int savePoint)
2039 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2040 if ( !appStudy || !appStudy->studyDS() )
2042 _PTR(Study) studyDS = appStudy->studyDS();
2044 // componentName is used for encoding of entries when storing them in IParameters
2045 std::string componentName = myComponentGeom->ComponentDataType();
2046 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2047 //if (!aSComponent) return;
2050 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2051 componentName.c_str(),
2053 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2055 QList<SUIT_ViewManager*> lst;
2056 QList<SUIT_ViewManager*>::Iterator it;
2058 // main cycle to store parameters of displayed objects
2060 getApp()->viewManagers(lst);
2061 for (it = lst.begin(); it != lst.end(); it++) {
2062 SUIT_ViewManager* vman = *it;
2063 QString vType = vman->getType();
2064 int aMgrId = vman->getGlobalId();
2065 // saving VTK actors properties
2066 QVector<SUIT_ViewWindow*> views = vman->getViews();
2067 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
2068 const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
2069 ObjMap::ConstIterator o_it = anObjects.begin();
2070 for (; o_it != anObjects.end(); o_it++) {
2071 const PropMap aProps = o_it.value();
2073 //Check that object exists in the study
2074 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
2075 if ( !obj || !(aProps.count() > 0))
2077 // entry is "encoded" = it does NOT contain component adress, since it is a
2078 // subject to change on next component loading
2080 std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
2082 _PTR(GenericAttribute) anAttr;
2083 if (!obj->FindAttribute(anAttr, "AttributeIOR"))
2086 QString param, occParam = vType;
2087 occParam += GEOM::sectionSeparator();
2088 occParam += QString::number(aMgrId);
2089 occParam += GEOM::sectionSeparator();
2091 if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
2092 param = occParam + GEOM::propertyName( GEOM::Visibility );
2093 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
2096 if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
2097 param = occParam + GEOM::propertyName( GEOM::DisplayMode );
2098 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
2101 if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
2102 QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
2104 val << QString::number(c.redF());
2105 val << QString::number(c.greenF());
2106 val << QString::number(c.blueF());
2107 param = occParam + GEOM::propertyName( GEOM::Color );
2108 ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
2111 if (vType == SVTK_Viewer::Type()) {
2112 if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
2113 param = occParam + GEOM::propertyName( GEOM::Opacity );
2114 ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
2116 } else if (vType == SOCC_Viewer::Type()) {
2117 if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
2118 param = occParam + GEOM::propertyName( GEOM::Transparency );
2119 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
2122 if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
2123 param = occParam + GEOM::propertyName( GEOM::TopLevel );
2124 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
2128 if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
2129 param = occParam + GEOM::propertyName( GEOM::NbIsos );
2130 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
2133 if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
2134 param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
2135 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
2138 if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
2139 param = occParam + GEOM::propertyName( GEOM::Deflection );
2140 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
2143 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
2144 if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
2145 param = occParam + GEOM::propertyName( GEOM::PointMarker );
2146 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
2149 if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
2150 param = occParam + GEOM::propertyName( GEOM::Material );
2151 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
2154 if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
2155 param = occParam + GEOM::propertyName( GEOM::LineWidth );
2156 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
2159 if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
2160 param = occParam + GEOM::propertyName( GEOM::IsosWidth );
2161 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
2163 } // object iterator
2165 } // for (viewManagers)
2169 * \brief Restore visual parameters
2171 * This method is called after the study document is opened.
2172 * Restore visual parameters from AttributeParameter attribute(s)
2174 void GeometryGUI::restoreVisualParameters (int savePoint)
2176 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2177 if (!appStudy || !appStudy->studyDS())
2179 _PTR(Study) studyDS = appStudy->studyDS();
2181 // componentName is used for encoding of entries when storing them in IParameters
2182 std::string componentName = myComponentGeom->ComponentDataType();
2183 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2184 //if (!aSComponent) return;
2187 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2188 componentName.c_str(),
2190 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2192 std::vector<std::string> entries = ip->getEntries();
2194 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
2196 // entry is a normal entry - it should be "decoded" (setting base adress of component)
2197 QString entry (ip->decodeEntry(*entIt).c_str());
2199 // Check that the entry corresponds to a real object in the Study
2200 // as the object may be deleted or modified after the visual state is saved.
2201 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
2202 if (!so) continue; //Skip the not existent entry
2204 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
2205 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
2207 std::vector<std::string>::iterator namesIt = paramNames.begin();
2208 std::vector<std::string>::iterator valuesIt = paramValues.begin();
2210 // actors are stored in a map after displaying of them for
2211 // quicker access in the future: map < viewID to actor >
2212 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
2213 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
2215 QString viewerTypStr;
2216 QString viewIndexStr;
2218 QVector<PropMap> aListOfMap;
2220 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
2222 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
2223 // '_' is used as separator and should not be used in viewer type or parameter names.
2224 QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
2225 if (lst.size() != 3)
2228 viewerTypStr = lst[0];
2229 viewIndexStr = lst[1];
2230 QString paramNameStr = lst[2];
2233 viewIndex = viewIndexStr.toUInt(&ok);
2234 if (!ok) // bad conversion of view index to integer
2237 if ((viewIndex + 1) > aListOfMap.count()) {
2238 aListOfMap.resize(viewIndex + 1);
2241 QString val((*valuesIt).c_str());
2242 if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
2243 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
2244 } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
2245 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
2246 } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
2247 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
2248 } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
2249 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
2250 } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
2251 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
2252 } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
2253 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
2254 } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
2255 QStringList rgb = val.split(GEOM::subSectionSeparator());
2256 if (rgb.count() == 3) {
2257 QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
2258 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
2260 } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
2261 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
2262 } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
2263 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
2264 } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
2265 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
2266 } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
2267 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
2268 } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
2269 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
2270 } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
2271 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
2273 } // for names/parameters iterator
2275 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
2277 for (int index = 0; index < aListOfMap.count(); index++) {
2279 appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
2281 //Get Visibility property of the current PropMap
2282 if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
2283 SUIT_ViewManager* vman = lst.at(index);
2284 SUIT_ViewModel* vmodel = vman->getViewModel();
2285 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
2288 } // for entries iterator
2290 // update all VTK and OCC views
2291 QList<SUIT_ViewManager*> lst;
2292 getApp()->viewManagers(lst);
2293 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
2294 SUIT_ViewModel* vmodel = (*it)->getViewModel();
2297 if (vmodel->getType() == SVTK_Viewer::Type()) {
2298 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
2299 vtkView->getRenderer()->ResetCameraClippingRange();
2302 else if (vmodel->getType() == SOCC_Viewer::Type()) {
2303 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
2304 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
2311 void GeometryGUI::onViewAboutToShow()
2313 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
2314 QAction* a = action( GEOMOp::OpSwitchVectors );
2316 a->setEnabled(true);
2317 bool vmode = window->property("VectorsMode").toBool();
2318 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
2320 a->setText ( tr("MEN_VECTOR_MODE_ON") );
2321 a->setEnabled(false);
2326 \brief Return action by id
2327 \param id identifier of the action
2330 QAction* GeometryGUI::getAction(const int id) {
2335 \brief GEOM module message handler
2337 This method can be re-implemented in the subclasses.
2338 This is a GEOM module message handler.
2340 \param msg the message received.
2342 void GeometryGUI::message(const QString& msg)
2345 QStringList data = msg.split("/");
2346 const int nbStrings = data.count();
2348 if (nbStrings > 0) {
2349 if (data[0] == "modified") {
2351 QString anIOR = nbStrings > 1 ? data[1] : QString();
2353 if ( anIOR.isEmpty() ) {
2357 // Get the geom object.
2358 GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
2360 // Clear the shape buffer
2361 GeometryGUI::ClearShapeBuffer (anObj);
2367 \brief Clears the shape buffer.
2369 This is a static method. It clears the shape buffer.
2371 \param theObj the object
2373 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
2375 if ( CORBA::is_nil( theObj ) )
2378 CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
2379 TCollection_AsciiString asciiIOR( (char *)IOR.in() );
2380 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
2382 SALOMEDSClient_StudyManager *aManager = SalomeApp_Application::studyMgr();
2387 _PTR(Study) aStudy = aManager->GetStudyByID(theObj->GetStudyID());
2392 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
2396 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
2397 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
2398 _PTR(GenericAttribute) anAttr;
2399 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
2400 _PTR(AttributeIOR) anIOR ( anAttr );
2401 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
2402 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
2408 \brief Returns the object from IOR.
2410 This is a static method. It returns the object from its IOR.
2412 \param IOR object IOR
2413 \return GEOM object.
2415 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
2417 GEOM::GEOM_Object_var geomObj;
2418 if ( !IOR.isEmpty() ) {
2419 CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
2420 ( IOR.toLatin1().constData() );
2421 if ( !CORBA::is_nil( corbaObj ) )
2422 geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2424 return geomObj._retn();
2428 \brief Returns IOR of the object.
2430 This is a static method. It returns the object's IOR.
2432 \param object the GEOM object.
2433 \return object's IOR.
2435 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
2438 if ( !CORBA::is_nil( object ) ) {
2439 CORBA::String_var anIOR =
2440 SalomeApp_Application::orb()->object_to_string( object );
2447 \brief Check if this object is can't be renamed in place
2449 This method can be re-implemented in the subclasses.
2450 Return true in case if object isn't reference or component (module root).
2452 \param entry column id
2453 \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
2455 bool GeometryGUI::renameAllowed( const QString& entry) const {
2457 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2458 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2459 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
2461 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
2465 Rename object by entry.
2466 \param entry entry of the object
2467 \param name new name of the object
2468 \brief Return \c true if rename operation finished successfully, \c false otherwise.
2470 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
2472 bool result = false;
2474 SalomeApp_Application* app =
2475 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
2476 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2481 _PTR(Study) aStudy = appStudy->studyDS();
2486 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
2488 SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
2492 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
2493 _PTR(GenericAttribute) anAttr;
2495 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
2496 _PTR(AttributeName) aName (anAttr);
2498 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
2499 if (!CORBA::is_nil(anObj)) {
2500 aName->SetValue( name.toLatin1().data() ); // rename the SObject
2501 anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object
2509 void GeometryGUI::updateMaterials()
2511 LightApp_Preferences* pref = preferences();
2513 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2514 QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
2515 if ( !materials.contains( currentMaterial ) )
2516 // user material set as default in the preferences, might be removed
2517 SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
2519 QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
2521 setPreferenceProperty( prefItem->id(),
2522 "strings", materials );
2523 prefItem->retrieve();