1 // Copyright (C) 2007-2011 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>
42 #include <SUIT_Desktop.h>
43 #include <SUIT_MessageBox.h>
44 #include <SUIT_ResourceMgr.h>
45 #include <SUIT_Session.h>
46 #include <SUIT_ViewManager.h>
48 #include <OCCViewer_ViewWindow.h>
49 #include <OCCViewer_ViewPort3d.h>
50 #include <OCCViewer_ViewModel.h>
51 #include <OCCViewer_ViewManager.h>
53 #include <SOCC_ViewModel.h>
54 #include <SOCC_ViewWindow.h>
56 #include <SVTK_ViewWindow.h>
57 #include <SVTK_RenderWindowInteractor.h>
58 #include <SVTK_InteractorStyle.h>
59 #include <SVTK_ViewModel.h>
61 #include <SalomeApp_Application.h>
62 #include <SalomeApp_DataObject.h>
63 #include <SalomeApp_Study.h>
65 #include <LightApp_SelectionMgr.h>
66 #include <LightApp_VTKSelector.h>
67 #include <LightApp_DataObject.h>
68 #include <LightApp_Preferences.h>
70 #include <SALOME_LifeCycleCORBA.hxx>
71 #include <SALOME_ListIO.hxx>
72 #include <SALOME_ListIteratorOfListIO.hxx>
74 #include <SALOMEDSClient_ClientFactory.hxx>
75 #include <SALOMEDSClient_IParameters.hxx>
77 #include <Basics_OCCTVersion.hxx>
87 #include <AIS_Drawer.hxx>
88 #include <AIS_ListOfInteractive.hxx>
89 #include <AIS_ListIteratorOfListOfInteractive.hxx>
90 #include <Prs3d_Drawer.hxx>
91 #include <Prs3d_IsoAspect.hxx>
92 #include <Aspect_TypeOfMarker.hxx>
93 #include <OSD_SharedLibrary.hxx>
94 #include <NCollection_DataMap.hxx>
96 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
97 #include <TColStd_HArray1OfByte.hxx>
99 #include <Graphic3d_HArray1OfBytes.hxx>
102 #include <utilities.h>
104 #include <vtkCamera.h>
105 #include <vtkRenderer.h>
107 #include <GEOM_version.h>
110 #include "GEOMImpl_Types.hxx"
113 Standard_EXPORT CAM_Module* createModule() {
114 return new GeometryGUI();
117 Standard_EXPORT char* getModuleVersion() {
118 return (char*)GEOM_VERSION_STR;
122 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
124 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
126 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
128 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
129 if (CORBA::is_nil(myComponentGeom))
131 return GeometryGUI::myComponentGeom;
134 bool GeometryGUI::InitGeomGen()
137 if( CORBA::is_nil( myComponentGeom ) ) return false;
141 //=======================================================================
142 // function : ClientSObjectToObject
144 //=======================================================================
145 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
147 _PTR(GenericAttribute) anAttr;
148 CORBA::Object_var anObj;
150 std::string aValue = theSObject->GetIOR();
151 if (strcmp(aValue.c_str(), "") != 0) {
152 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
153 anObj = anORB->string_to_object(aValue.c_str());
156 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
158 return anObj._retn();
161 //=======================================================================
162 // function : ClientStudyToStudy
164 //=======================================================================
165 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
167 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
168 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
169 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
170 int aStudyID = theStudy->StudyId();
171 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
172 return aDSStudy._retn();
175 void GeometryGUI::Modified( bool theIsUpdateActions )
177 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
178 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
179 appStudy->Modified();
180 if( theIsUpdateActions )
181 app->updateActions();
186 //=======================================================================
187 // function : GeometryGUI::GeometryGUI()
188 // purpose : Constructor
189 //=======================================================================
190 GeometryGUI::GeometryGUI() :
191 SalomeApp_Module( "GEOM" ),
192 LightApp_Module( "GEOM" )
194 if ( CORBA::is_nil( myComponentGeom ) )
196 Engines::EngineComponent_var comp =
197 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
198 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
201 myActiveDialogBox = 0;
203 gp_Pnt origin = gp_Pnt(0., 0., 0.);
204 gp_Dir direction = gp_Dir(0., 0., 1.);
205 myWorkingPlane = gp_Ax3(origin, direction);
208 myLocalSelectionMode = GEOM_ALLOBJECTS;
211 //=======================================================================
212 // function : GeometryGUI::~GeometryGUI()
213 // purpose : Destructor
214 //=======================================================================
215 GeometryGUI::~GeometryGUI()
217 while (!myOCCSelectors.isEmpty())
218 delete myOCCSelectors.takeFirst();
220 while (!myVTKSelectors.isEmpty())
221 delete myVTKSelectors.takeFirst();
223 qDeleteAll(myGUIMap);
226 //=======================================================================
227 // function : GeometryGUI::getLibrary()
228 // purpose : get or load GUI library by name [ internal ]
229 //=======================================================================
230 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
231 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
233 if ( !myGUIMap.contains( libraryName ) ) {
234 // try to load library if it is not loaded yet
236 QString dirs = getenv( "LD_LIBRARY_PATH" );
239 QString dirs = getenv( "PATH" );
242 if ( !dirs.isEmpty() ) {
243 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
244 QListIterator<QString> it( dirList ); it.toBack();
245 while ( it.hasPrevious() ) {
246 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
248 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
249 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
251 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
252 continue; // continue search further
254 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
255 if ( osdF != NULL ) {
256 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
257 GEOMGUI* libGUI = (*func)( this );
259 myGUIMap[ libraryName ] = libGUI;
260 break; // found and loaded!
267 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
270 //=======================================================================
271 // function : GeometryGUI::ActiveWorkingPlane()
272 // purpose : Activate Working Plane View
273 //=======================================================================
274 void GeometryGUI::ActiveWorkingPlane()
276 gp_Dir DZ = myWorkingPlane.Direction();
277 gp_Dir DY = myWorkingPlane.YDirection();
279 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
280 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
281 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
284 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
286 Handle(V3d_View) view3d = vw->getViewPort()->getView();
288 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
289 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
294 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
296 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
298 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
299 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
300 camera->SetFocalPoint(0,0,0);
307 //=======================================================================
308 // function : GeometryGUI::SetActiveDialogBox()
309 // purpose : Set active dialog box
310 //=======================================================================
311 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
313 myActiveDialogBox = (QDialog*)aDlg;
316 //=======================================================================
317 // function : GeometryGUI::EmitSignalDeactivateDialog()
318 // purpose : Emit a signal to deactivate the active dialog Box
319 //=======================================================================
320 void GeometryGUI::EmitSignalDeactivateDialog()
322 emit SignalDeactivateActiveDialog();
325 //=======================================================================
326 // function : GeometryGUI::EmitSignalCloseAllDialogs()
327 // purpose : Emit a signal to close all non modal dialogs box
328 //=======================================================================
329 void GeometryGUI::EmitSignalCloseAllDialogs()
331 emit SignalCloseAllDialogs();
334 //=======================================================================
335 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
336 // purpose : Emit a signal to inform that default real spin box step has
338 //=======================================================================
339 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
341 emit SignalDefaultStepValueChanged(newVal);
344 //=======================================================================
345 // function : GeometryGUI::OnGUIEvent()
346 // purpose : common slot for all menu/toolbar actions
347 //=======================================================================
348 void GeometryGUI::OnGUIEvent()
350 const QObject* obj = sender();
351 if ( !obj || !obj->inherits( "QAction" ) )
353 int id = actionId((QAction*)obj);
358 //=======================================================================
359 // function : GeometryGUI::OnGUIEvent()
360 // purpose : manage all events on GUI [static]
361 //=======================================================================
362 void GeometryGUI::OnGUIEvent( int id )
364 SUIT_Application* anApp = application();
366 SUIT_Desktop* desk = anApp->desktop();
368 // check type of the active viewframe
369 SUIT_ViewWindow* window = desk->activeWindow();
370 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
371 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
372 // if current viewframe is not of OCC and not of VTK type - return immediately
373 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
374 QList<int> NotViewerDependentCommands;
375 NotViewerDependentCommands << GEOMOp::OpDelete
377 << GEOMOp::OpShowOnly
378 << GEOMOp::OpShowChildren
379 << GEOMOp::OpHideChildren
380 << GEOMOp::OpUnpublishObject
381 << GEOMOp::OpPublishObject
382 << GEOMOp::OpPointMarker;
383 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
386 // fix for IPAL9103, point 2
387 if ( CORBA::is_nil( GetGeomGen() ) ) {
388 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
393 // find corresponding GUI library
395 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
396 createOriginAndBaseVectors(); // internal operation
398 case GEOMOp::OpImport: // MENU FILE - IMPORT
399 case GEOMOp::OpExport: // MENU FILE - EXPORT
400 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
401 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
402 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
403 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
404 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
405 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
406 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
407 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
408 case GEOMOp::OpDelete: // MENU EDIT - DELETE
409 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
410 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
411 case GEOMOp::OpColor: // POPUP MENU - COLOR
412 case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
413 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
414 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
415 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
416 case GEOMOp::OpIsos: // POPUP MENU - ISOS
417 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
418 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
419 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
420 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
421 case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
422 case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN
423 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
424 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
425 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
426 case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
427 libName = "GEOMToolsGUI";
429 case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
430 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
431 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
432 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
433 case GEOMOp::OpHide: // MENU VIEW - ERASE
434 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
435 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
436 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
437 case GEOMOp::OpShading: // POPUP MENU - SHADING
438 case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
439 case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
440 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
441 libName = "DisplayGUI";
443 case GEOMOp::OpPoint: // MENU BASIC - POINT
444 case GEOMOp::OpLine: // MENU BASIC - LINE
445 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
446 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
447 case GEOMOp::OpArc: // MENU BASIC - ARC
448 case GEOMOp::OpVector: // MENU BASIC - VECTOR
449 case GEOMOp::OpPlane: // MENU BASIC - PLANE
450 case GEOMOp::OpCurve: // MENU BASIC - CURVE
451 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
452 libName = "BasicGUI";
454 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
455 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
456 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
457 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
458 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
459 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
460 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
461 libName = "PrimitiveGUI";
463 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
464 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
465 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
466 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
467 libName = "GenerationGUI";
469 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
470 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
471 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
473 case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
475 case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
476 libName = "EntityGUI";
478 case GEOMOp::OpEdge: // MENU BUILD - EDGE
479 case GEOMOp::OpWire: // MENU BUILD - WIRE
480 case GEOMOp::OpFace: // MENU BUILD - FACE
481 case GEOMOp::OpShell: // MENU BUILD - SHELL
482 case GEOMOp::OpSolid: // MENU BUILD - SOLID
483 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
484 libName = "BuildGUI";
486 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
487 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
488 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
489 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
490 libName = "BooleanGUI";
492 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
493 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
494 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
495 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
496 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
497 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
498 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
499 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
500 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
501 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
502 libName = "TransformationGUI";
504 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
505 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
506 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
507 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
508 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
509 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
510 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
511 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
512 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
513 libName = "OperationGUI";
515 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
516 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
517 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
518 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
519 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
520 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
521 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
522 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
523 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
524 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
525 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
526 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
527 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
528 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
529 libName = "RepairGUI";
531 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
532 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
533 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
534 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
535 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
536 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
537 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
538 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
539 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
540 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
541 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
542 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
543 case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
544 libName = "MeasureGUI";
546 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
547 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
548 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
549 libName = "GroupGUI";
551 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
552 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
553 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
554 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
555 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
556 libName = "BlocksGUI";
558 case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
559 case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
560 // case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
561 //@@ 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 @@//
562 libName = "AdvancedGUI";
568 GEOMGUI* library = 0;
569 if ( !libName.isEmpty() ) {
571 libName = QString( "lib" ) + libName + ".so";
573 libName = libName + ".dll";
575 library = getLibrary( libName );
578 // call method of corresponding GUI library
580 library->OnGUIEvent( id, desk );
582 // Update a list of materials for "Preferences" dialog
583 if ( id == GEOMOp::OpMaterialProperties ) {
584 LightApp_Preferences* pref = preferences();
586 Material_ResourceMgr aMatResMgr;
587 QStringList aPerfMatNames = aMatResMgr.getPreferenceMaterialsNames();
588 setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_FRONT_MATERIAL" ), true )->id(),
591 setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_BACK_MATERIAL" ), true )->id(),
598 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
601 //=================================================================================
602 // function : GeometryGUI::OnKeyPress()
603 // purpose : Called when any key is pressed by user [static]
604 //=================================================================================
605 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
607 if ( !application() )
609 foreach ( GEOMGUI* lib, myGUIMap )
610 lib->OnKeyPress( e, application()->desktop(), w );
613 //=================================================================================
614 // function : GeometryGUI::OnMouseMove()
615 // purpose : Manages mouse move events [static]
616 //=================================================================================
617 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
619 if ( !application() )
621 foreach ( GEOMGUI* lib, myGUIMap )
622 lib->OnMouseMove( e, application()->desktop(), w );
625 //=================================================================================
626 // function : GeometryGUI::OnMouseRelease()
627 // purpose : Manages mouse release events [static]
628 //=================================================================================
629 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
631 if ( !application() )
633 foreach ( GEOMGUI* lib, myGUIMap )
634 lib->OnMouseRelease( e, application()->desktop(), w );
637 //=================================================================================
638 // function : GeometryGUI::OnMousePress()
639 // purpose : Manage mouse press events [static]
640 //=================================================================================
641 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
643 if ( !application() )
645 foreach ( GEOMGUI* lib, myGUIMap )
646 lib->OnMousePress( e, application()->desktop(), w );
649 //=======================================================================
650 // function : createGeomAction
652 //=======================================================================
653 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
654 const int accel, const bool toggle, const QString& shortcutAction )
656 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
657 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
658 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
660 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
662 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
663 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
665 application()->desktop(),
667 this, SLOT( OnGUIEvent() ),
671 //=======================================================================
672 // function : createOriginAndBaseVectors
674 //=======================================================================
675 void GeometryGUI::createOriginAndBaseVectors()
677 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
679 _PTR(Study) studyDS = appStudy->studyDS();
680 if( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
681 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
682 if( !aBasicOperations->_is_nil() ) {
683 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
684 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
685 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
686 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
687 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
688 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
690 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
691 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
692 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
693 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
694 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
696 getApp()->updateObjectBrowser( false );
702 //=======================================================================
703 // function : GeometryGUI::initialize()
704 // purpose : Called when GEOM module is created
705 //=======================================================================
706 void GeometryGUI::initialize( CAM_Application* app )
708 SalomeApp_Module::initialize( app );
710 // ----- create actions --------------
712 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
713 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
715 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
717 createGeomAction( GEOMOp::OpPoint, "POINT" );
718 createGeomAction( GEOMOp::OpLine, "LINE" );
719 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
720 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
721 createGeomAction( GEOMOp::OpArc, "ARC" );
722 createGeomAction( GEOMOp::OpCurve, "CURVE" );
723 createGeomAction( GEOMOp::OpVector, "VECTOR" );
724 createGeomAction( GEOMOp::OpPlane, "PLANE" );
725 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
726 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
728 createGeomAction( GEOMOp::OpBox, "BOX" );
729 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
730 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
731 createGeomAction( GEOMOp::OpTorus, "TORUS" );
732 createGeomAction( GEOMOp::OpCone, "CONE" );
733 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
734 createGeomAction( GEOMOp::OpDisk, "DISK" );
736 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
737 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
738 createGeomAction( GEOMOp::OpFilling, "FILLING" );
739 createGeomAction( GEOMOp::OpPipe, "PIPE" );
741 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
742 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
744 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
746 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
747 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
749 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
750 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
751 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
753 createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
755 createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
757 createGeomAction( GEOMOp::OpEdge, "EDGE" );
758 createGeomAction( GEOMOp::OpWire, "WIRE" );
759 createGeomAction( GEOMOp::OpFace, "FACE" );
760 createGeomAction( GEOMOp::OpShell, "SHELL" );
761 createGeomAction( GEOMOp::OpSolid, "SOLID" );
762 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
764 createGeomAction( GEOMOp::OpFuse, "FUSE" );
765 createGeomAction( GEOMOp::OpCommon, "COMMON" );
766 createGeomAction( GEOMOp::OpCut, "CUT" );
767 createGeomAction( GEOMOp::OpSection, "SECTION" );
769 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
770 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
771 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
772 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
773 createGeomAction( GEOMOp::OpScale, "SCALE" );
774 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
775 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
776 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
777 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
779 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
780 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
781 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
782 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
783 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
784 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
785 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
786 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
787 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
789 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
790 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
791 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
793 createGeomAction( GEOMOp::OpSewing, "SEWING" );
794 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
795 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
796 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
797 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
798 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
799 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
800 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
801 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
802 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
803 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
804 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
805 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
806 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
808 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
809 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
810 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
811 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
812 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
813 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
814 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
815 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
817 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
818 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
819 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
820 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
821 createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
823 #ifdef _DEBUG_ // PAL16821
824 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
827 createGeomAction( GEOMOp::OpDisplayMode, "SHADING" );
828 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
829 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
830 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
831 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
832 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
833 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
834 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
835 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
836 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
837 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
838 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
839 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
840 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
841 createGeomAction( GEOMOp::OpHide, "ERASE" );
843 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
844 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
845 createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
846 createGeomAction( GEOMOp::OpTexture, "POP_TEXTURE", "", 0, true );
847 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
848 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
849 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
850 createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
851 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
852 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
853 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
854 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
855 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
856 createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" );
857 createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" );
858 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
859 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
860 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
861 createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
863 createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
865 // Create actions for increase/decrease transparency shortcuts
866 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
867 "Geometry:Increase transparency");
868 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
869 "Geometry:Decrease transparency");
871 // Create actions for increase/decrease number of isolines
872 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
873 "Geometry:Increase number of isolines");
874 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
875 "Geometry:Decrease number of isolines");
877 // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
878 //@@ 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 @@//
880 // ---- create menus --------------------------
882 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
883 createMenu( separator(), fileId, 10 );
884 createMenu( GEOMOp::OpImport, fileId, 10 );
885 createMenu( GEOMOp::OpExport, fileId, 10 );
886 createMenu( separator(), fileId, -1 );
888 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
889 createMenu( GEOMOp::OpDelete, editId, -1 );
891 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
893 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
894 createMenu( GEOMOp::OpPoint, basicId, -1 );
895 createMenu( GEOMOp::OpLine, basicId, -1 );
896 createMenu( GEOMOp::OpCircle, basicId, -1 );
897 createMenu( GEOMOp::OpEllipse, basicId, -1 );
898 createMenu( GEOMOp::OpArc, basicId, -1 );
899 createMenu( GEOMOp::OpCurve, basicId, -1 );
900 createMenu( separator(), basicId, -1 );
901 createMenu( GEOMOp::OpVector, basicId, -1 );
902 createMenu( GEOMOp::OpPlane, basicId, -1 );
903 createMenu( GEOMOp::OpLCS, basicId, -1 );
904 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
906 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
907 createMenu( GEOMOp::OpBox, primId, -1 );
908 createMenu( GEOMOp::OpCylinder, primId, -1 );
909 createMenu( GEOMOp::OpSphere, primId, -1 );
910 createMenu( GEOMOp::OpTorus, primId, -1 );
911 createMenu( GEOMOp::OpCone, primId, -1 );
912 createMenu( GEOMOp::OpRectangle, primId, -1 );
913 createMenu( GEOMOp::OpDisk, primId, -1 );
915 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
916 createMenu( GEOMOp::OpPrism, genId, -1 );
917 createMenu( GEOMOp::OpRevolution, genId, -1 );
918 createMenu( GEOMOp::OpFilling, genId, -1 );
919 createMenu( GEOMOp::OpPipe, genId, -1 );
921 int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
922 createMenu( GEOMOp::OpPipeTShape, advId, -1 );
923 // createMenu( GEOMOp::OpPipeTShapeGroups, advId, -1 );
924 //@@ 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 @@//
926 createMenu( separator(), newEntId, -1 );
928 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
929 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
930 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
932 createMenu( separator(), newEntId, -1 );
934 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
935 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
936 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
938 createMenu( separator(), newEntId, -1 );
940 createMenu( GEOMOp::Op2dSketcher, newEntId, -1 );
941 createMenu( GEOMOp::Op3dSketcher, newEntId, -1 );
943 createMenu( separator(), newEntId, -1 );
945 createMenu( GEOMOp::OpExplode, newEntId, -1 );
947 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
948 createMenu( GEOMOp::OpEdge, buildId, -1 );
949 createMenu( GEOMOp::OpWire, buildId, -1 );
950 createMenu( GEOMOp::OpFace, buildId, -1 );
951 createMenu( GEOMOp::OpShell, buildId, -1 );
952 createMenu( GEOMOp::OpSolid, buildId, -1 );
953 createMenu( GEOMOp::OpCompound, buildId, -1 );
955 createMenu( separator(), newEntId, -1 );
957 createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
959 createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
962 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
964 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
965 createMenu( GEOMOp::OpFuse, boolId, -1 );
966 createMenu( GEOMOp::OpCommon, boolId, -1 );
967 createMenu( GEOMOp::OpCut, boolId, -1 );
968 createMenu( GEOMOp::OpSection, boolId, -1 );
970 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
971 createMenu( GEOMOp::OpTranslate, transId, -1 );
972 createMenu( GEOMOp::OpRotate, transId, -1 );
973 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
974 createMenu( GEOMOp::OpMirror, transId, -1 );
975 createMenu( GEOMOp::OpScale, transId, -1 );
976 createMenu( GEOMOp::OpOffset, transId, -1 );
977 createMenu( GEOMOp::OpProjection, transId, -1 );
978 createMenu( separator(), transId, -1 );
979 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
980 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
982 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
983 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
984 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
985 createMenu( GEOMOp::OpPropagate, blockId, -1 );
987 createMenu( separator(), operId, -1 );
989 createMenu( GEOMOp::OpPartition, operId, -1 );
990 createMenu( GEOMOp::OpArchimede, operId, -1 );
991 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
992 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
994 createMenu( separator(), operId, -1 );
996 createMenu( GEOMOp::OpFillet1d, operId, -1 );
997 createMenu( GEOMOp::OpFillet2d, operId, -1 );
998 createMenu( GEOMOp::OpFillet3d, operId, -1 );
999 createMenu( GEOMOp::OpChamfer, operId, -1 );
1000 //createMenu( GEOMOp::OpClipping, operId, -1 );
1002 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1003 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
1004 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
1005 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
1006 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
1007 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
1008 createMenu( GEOMOp::OpSewing, repairId, -1 );
1009 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
1010 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
1011 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
1012 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
1013 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
1014 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
1015 createMenu( GEOMOp::OpOrientation, repairId, -1 );
1016 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1018 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1019 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1020 createMenu( GEOMOp::OpProperties, measurId, -1 );
1021 createMenu( separator(), measurId, -1 );
1022 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
1023 createMenu( GEOMOp::OpInertia, measurId, -1 );
1024 createMenu( GEOMOp::OpNormale, measurId, -1 );
1025 createMenu( separator(), measurId, -1 );
1026 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
1027 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
1028 createMenu( separator(), measurId, -1 );
1030 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1031 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1032 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1033 createMenu( GEOMOp::OpAngle, dimId, -1 );
1035 createMenu( separator(), measurId, -1 );
1036 createMenu( GEOMOp::OpTolerance, measurId, -1 );
1037 createMenu( separator(), measurId, -1 );
1038 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
1039 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
1040 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
1041 createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1043 #ifdef _DEBUG_ // PAL16821
1044 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1045 createMenu( separator(), toolsId, -1 );
1046 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1049 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1050 createMenu( separator(), viewId, -1 );
1052 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1053 createMenu( GEOMOp::OpDisplayMode, dispmodeId, -1 );
1054 createMenu( separator(), dispmodeId, -1 );
1055 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1057 createMenu( separator(), viewId, -1 );
1058 createMenu( GEOMOp::OpShowAll, viewId, -1 );
1059 createMenu( GEOMOp::OpHideAll, viewId, -1 );
1060 createMenu( separator(), viewId, -1 );
1061 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1062 createMenu( separator(), viewId, -1 );
1066 because of these items are accessible through object browser and viewers
1067 we have removed they from main menu
1069 createMenu( GEOMOp::OpShow, viewId, -1 );
1070 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1071 createMenu( GEOMOp::OpHide, viewId, -1 );
1074 // ---- create toolbars --------------------------
1076 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1077 createTool( GEOMOp::OpPoint, basicTbId );
1078 createTool( GEOMOp::OpLine, basicTbId );
1079 createTool( GEOMOp::OpCircle, basicTbId );
1080 createTool( GEOMOp::OpEllipse, basicTbId );
1081 createTool( GEOMOp::OpArc, basicTbId );
1082 createTool( GEOMOp::OpCurve, basicTbId );
1083 createTool( GEOMOp::OpVector, basicTbId );
1084 createTool( GEOMOp::OpPlane, basicTbId );
1085 createTool( GEOMOp::OpLCS, basicTbId );
1086 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1088 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1089 createTool( GEOMOp::OpBox, primTbId );
1090 createTool( GEOMOp::OpCylinder, primTbId );
1091 createTool( GEOMOp::OpSphere, primTbId );
1092 createTool( GEOMOp::OpTorus, primTbId );
1093 createTool( GEOMOp::OpCone, primTbId );
1094 createTool( GEOMOp::OpRectangle, primTbId );
1095 createTool( GEOMOp::OpDisk, primTbId );
1097 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1098 createTool( GEOMOp::OpFuse, boolTbId );
1099 createTool( GEOMOp::OpCommon, boolTbId );
1100 createTool( GEOMOp::OpCut, boolTbId );
1101 createTool( GEOMOp::OpSection, boolTbId );
1103 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1104 createTool( GEOMOp::OpPrism, genTbId );
1105 createTool( GEOMOp::OpRevolution, genTbId );
1106 createTool( GEOMOp::OpFilling, genTbId );
1107 createTool( GEOMOp::OpPipe, genTbId );
1109 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1110 createTool( GEOMOp::OpTranslate, transTbId );
1111 createTool( GEOMOp::OpRotate, transTbId );
1112 createTool( GEOMOp::OpChangeLoc, transTbId );
1113 createTool( GEOMOp::OpMirror, transTbId );
1114 createTool( GEOMOp::OpScale, transTbId );
1115 createTool( GEOMOp::OpOffset, transTbId );
1116 createTool( GEOMOp::OpProjection, transTbId );
1117 createTool( separator(), transTbId );
1118 createTool( GEOMOp::OpMultiTranslate, transTbId );
1119 createTool( GEOMOp::OpMultiRotate, transTbId );
1121 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1122 createTool( GEOMOp::Op2dSketcher, operTbId );
1123 createTool( GEOMOp::Op3dSketcher, operTbId );
1124 createTool( separator(), operTbId );
1125 createTool( GEOMOp::OpExplode, operTbId );
1126 createTool( separator(), operTbId );
1128 createTool( GEOMOp::OpFeatureDetect, operTbId );
1130 createTool( GEOMOp::OpPictureImport, operTbId );
1131 createTool( separator(), operTbId );
1133 createTool( GEOMOp::OpPartition, operTbId );
1134 createTool( GEOMOp::OpArchimede, operTbId );
1135 createTool( GEOMOp::OpShapesOnShape, operTbId );
1136 createTool( GEOMOp::OpSharedShapes, operTbId );
1137 createTool( separator(), operTbId );
1138 createTool( GEOMOp::OpFillet1d, operTbId );
1139 createTool( GEOMOp::OpFillet2d, operTbId );
1140 createTool( GEOMOp::OpFillet3d, operTbId );
1141 createTool( GEOMOp::OpChamfer, operTbId );
1143 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1144 createTool( GEOMOp::OpEdge, buildTbId );
1145 createTool( GEOMOp::OpWire, buildTbId );
1146 createTool( GEOMOp::OpFace, buildTbId );
1147 createTool( GEOMOp::OpShell, buildTbId );
1148 createTool( GEOMOp::OpSolid, buildTbId );
1149 createTool( GEOMOp::OpCompound, buildTbId );
1151 int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1152 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1153 createTool( GEOMOp::OpProperties, measureTbId );
1154 createTool( GEOMOp::OpCenterMass, measureTbId );
1155 createTool( GEOMOp::OpInertia, measureTbId );
1156 createTool( GEOMOp::OpNormale, measureTbId );
1157 createTool( separator(), measureTbId );
1158 createTool( GEOMOp::OpBoundingBox, measureTbId );
1159 createTool( GEOMOp::OpMinDistance, measureTbId );
1160 createTool( GEOMOp::OpAngle, measureTbId );
1161 createTool( GEOMOp::OpTolerance , measureTbId );
1162 createTool( separator(), measureTbId );
1163 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1164 createTool( GEOMOp::OpFreeFaces, measureTbId );
1165 createTool( separator(), measureTbId );
1166 createTool( GEOMOp::OpWhatIs, measureTbId );
1167 createTool( GEOMOp::OpCheckShape, measureTbId );
1168 createTool( GEOMOp::OpCheckCompound, measureTbId );
1169 createTool( GEOMOp::OpCheckSelfInters, measureTbId );
1171 int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1172 createTool( GEOMOp::OpPipeTShape, advancedTbId );
1173 //@@ 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 @@//
1175 // ---- create popup menus --------------------------
1177 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1178 QString clientOCC = "(client='OCCViewer')";
1179 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1180 QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1182 QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1183 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1184 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1185 QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1187 QString autoColorPrefix =
1188 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1190 QtxPopupMgr* mgr = popupMgr();
1192 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1193 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1194 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1195 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1196 mgr->insert( action( GEOMOp::OpShowChildren ), -1, -1 ); // show children
1197 mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
1199 mgr->insert( action( GEOMOp::OpHideChildren ), -1, -1 ); // hide children
1200 mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
1201 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1202 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1203 mgr->insert( separator(), -1, -1 ); // -----------
1204 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1205 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1206 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1207 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1208 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1209 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1210 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1211 mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1212 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1213 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1214 mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1215 mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1216 mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1217 mgr->insert( separator(), dispmodeId, -1 );
1218 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1219 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1220 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1221 mgr->insert( separator(), -1, -1 ); // -----------
1222 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1223 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1224 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1225 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1226 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1227 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1228 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1229 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1230 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1231 //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1232 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1233 mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); // material properties
1234 mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1235 mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 ); // texture
1236 mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1237 mgr->insert( separator(), -1, -1 ); // -----------
1238 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1239 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1240 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1241 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1242 mgr->insert( separator(), -1, -1 ); // -----------
1244 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1245 onlyComponent = "((type='Component') and selcount=1)",
1246 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1247 types = "'Shape' 'Group'";
1249 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1250 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1252 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1253 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1255 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1256 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1258 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1260 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1261 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1262 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1263 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1264 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1265 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1266 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1267 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1268 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1269 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1270 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1271 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1272 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1273 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1274 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1275 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1276 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1277 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1278 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1279 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1280 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1281 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1282 mgr->insert( separator(), selectonlyId, -1);
1283 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1284 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1285 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1286 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1287 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1288 mgr->insert( separator(), -1, -1 );
1290 mgr->insert( separator(), -1, -1 ); // -----------
1291 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1292 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1295 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1296 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1298 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1299 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1301 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1304 //=======================================================================
1305 // function : GeometryGUI::activateModule()
1306 // purpose : Called when GEOM module is activated
1307 //=======================================================================
1308 bool GeometryGUI::activateModule( SUIT_Study* study )
1310 if ( CORBA::is_nil( myComponentGeom ) )
1313 bool res = SalomeApp_Module::activateModule( study );
1317 setMenuShown( true );
1318 setToolShown( true );
1320 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1321 PyGILState_STATE gstate = PyGILState_Ensure();
1322 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1323 if(pluginsmanager==NULL)
1327 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"geom",tr("MEN_NEW_ENTITY").toStdString().c_str(),tr("GEOM_PLUGINS_OTHER").toStdString().c_str());
1332 PyGILState_Release(gstate);
1333 // end of GEOM plugins loading
1335 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1336 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1338 // Reset actions accelerator keys
1339 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1340 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1341 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1343 GUIMap::Iterator it;
1344 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1345 it.value()->activate( application()->desktop() );
1347 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1349 SUIT_ViewManager* vm;
1350 ViewManagerList OCCViewManagers, VTKViewManagers;
1352 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1353 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1354 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1355 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1357 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1358 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1359 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1360 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1363 SALOME_ListIO selected;
1364 sm->selectedObjects( selected );
1365 sm->clearSelected();
1367 // disable OCC selectors
1368 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1369 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1370 while ( itOCCSel.hasNext() )
1371 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1372 sr->setEnabled(true);
1374 // disable VTK selectors
1375 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1376 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1377 while ( itVTKSel.hasNext() )
1378 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1379 sr->setEnabled(true);
1381 sm->setSelectedObjects( selected, true ); //NPAL 19674
1383 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1385 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1387 // 0020836 (Basic vectors and origin)
1388 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1389 if( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1390 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1392 _PTR(Study) studyDS = appStudy->studyDS();
1394 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1395 if( !aSComponent ) // create objects automatically only if there is no GEOM component
1396 createOriginAndBaseVectors();
1405 //=======================================================================
1406 // function : GeometryGUI::deactivateModule()
1407 // purpose : Called when GEOM module is deactivated
1408 //=======================================================================
1409 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1411 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1413 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1415 setMenuShown( false );
1416 setToolShown( false );
1418 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1419 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1421 EmitSignalCloseAllDialogs();
1423 GUIMap::Iterator it;
1424 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1425 it.value()->deactivate();
1427 // Unset actions accelerator keys
1428 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1429 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1430 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1432 qDeleteAll(myOCCSelectors);
1433 myOCCSelectors.clear();
1434 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1436 qDeleteAll(myVTKSelectors);
1437 myVTKSelectors.clear();
1438 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1440 return SalomeApp_Module::deactivateModule( study );
1443 //=======================================================================
1444 // function : onWindowActivated()
1445 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1446 //=======================================================================
1447 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1452 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1453 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1455 // disable non-OCC viewframe menu commands
1456 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1457 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1458 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1459 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1460 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1461 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1462 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1464 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1465 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1467 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1470 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1472 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1473 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1476 void GeometryGUI::viewManagers( QStringList& lst ) const
1478 lst.append( OCCViewer_Viewer::Type() );
1481 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1483 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1485 qDebug( "connect" );
1486 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1487 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1488 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1489 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1490 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1491 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1492 connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
1493 this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
1495 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1496 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1498 // disable OCC selectors
1499 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1500 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1501 while ( itOCCSel.hasNext() )
1502 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1503 sr->setEnabled(true);
1505 else if ( vm->getType() == SVTK_Viewer::Type() )
1507 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1508 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1510 // disable VTK selectors
1511 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1512 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1513 while ( itVTKSel.hasNext() )
1514 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1515 sr->setEnabled(true);
1519 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1521 SUIT_ViewModel* viewer = vm->getViewModel();
1522 if ( vm->getType() == OCCViewer_Viewer::Type() )
1524 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1525 while ( itOCCSel.hasNext() )
1526 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1527 if ( sr->viewer() == viewer )
1529 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1533 if ( vm->getType() == SVTK_Viewer::Type() )
1535 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1536 while ( itVTKSel.hasNext() )
1537 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1538 if ( sr->viewer() == viewer )
1540 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1546 QString GeometryGUI::engineIOR() const
1548 if ( !CORBA::is_nil( GetGeomGen() ) )
1549 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1553 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1554 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
1556 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture
1558 (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
1560 theWidth = theHeight = 0;
1562 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1563 Handle(TColStd_HArray1OfByte) aTexture;
1565 Handle(Graphic3d_HArray1OfBytes) aTexture;
1569 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1570 aTexture = aTextureMap[ theId ];
1571 if ( aTexture.IsNull() ) {
1572 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1573 if ( !aInsOp->_is_nil() ) {
1574 CORBA::Long aWidth, aHeight;
1575 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1576 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1578 theHeight = aHeight;
1580 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1581 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
1583 aTexture = new Graphic3d_HArray1OfBytes (1, aStream->length());
1586 for (int i = 0; i < aStream->length(); i++)
1587 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1588 aTextureMap[ theId ] = aTexture;
1596 LightApp_Selection* GeometryGUI::createSelection() const
1598 return new GEOMGUI_Selection();
1601 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1603 SalomeApp_Module::contextMenuPopup( client, menu, title );
1607 getApp()->selectionMgr()->selectedObjects(lst);
1608 if (lst.Extent() < 1)
1611 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1612 _PTR(Study) study = appStudy->studyDS();
1614 bool isImported = true;
1615 SALOME_ListIteratorOfListIO anIt (lst);
1616 for (; anIt.More() && isImported; anIt.Next()) {
1617 Handle(SALOME_InteractiveObject) io = anIt.Value();
1618 _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1620 if (lst.Extent() == 1) {
1621 // Set context menu title
1622 if (client == "OCCViewer" || client == "VTKViewer")
1623 title = QString(aSObj->GetName().c_str());
1626 CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1627 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1628 if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1636 menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
1641 void GeometryGUI::createPreferences()
1643 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1645 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1646 setPreferenceProperty( genGroup, "columns", 2 );
1648 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1649 LightApp_Preferences::Selector,
1650 "Geometry", "display_mode" );
1652 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1653 LightApp_Preferences::Color, "Geometry", "shading_color" );
1655 addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
1656 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
1658 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1659 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1661 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1662 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1664 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1665 LightApp_Preferences::Color, "Geometry", "line_color" );
1667 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1668 LightApp_Preferences::Color, "Geometry", "point_color" );
1670 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1671 LightApp_Preferences::Color, "Geometry", "isos_color" );
1673 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1674 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1676 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1677 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1679 int front_material = addPreference( tr( "PREF_FRONT_MATERIAL" ), genGroup,
1680 LightApp_Preferences::Selector,
1681 "Geometry", "front_material" );
1683 int back_material = addPreference( tr( "PREF_BACK_MATERIAL" ), genGroup,
1684 LightApp_Preferences::Selector,
1685 "Geometry", "back_material" );
1687 // Quantities with individual precision settings
1688 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1689 setPreferenceProperty( precGroup, "columns", 2 );
1691 const int nbQuantities = 8;
1692 int prec[nbQuantities], ii = 0;
1693 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1694 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1695 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1696 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1697 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1698 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1699 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1700 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1701 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1702 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1703 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1704 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1705 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1706 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1707 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1708 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1710 // Set property for precision value for spinboxes
1711 for ( ii = 0; ii < nbQuantities; ii++ ){
1712 setPreferenceProperty( prec[ii], "min", -14 );
1713 setPreferenceProperty( prec[ii], "max", 14 );
1714 setPreferenceProperty( prec[ii], "precision", 2 );
1717 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1718 setPreferenceProperty( VertexGroup, "columns", 2 );
1720 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1721 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1723 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1724 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1726 // Set property for default display mode
1727 QStringList aModesList;
1728 aModesList.append( tr("MEN_WIREFRAME") );
1729 aModesList.append( tr("MEN_SHADING") );
1730 aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
1732 QList<QVariant> anIndexesList;
1733 anIndexesList.append(0);
1734 anIndexesList.append(1);
1735 anIndexesList.append(2);
1737 setPreferenceProperty( dispmode, "strings", aModesList );
1738 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1740 // Set property for step value for spinboxes
1741 setPreferenceProperty( step, "min", 1 );
1742 setPreferenceProperty( step, "max", 10000 );
1743 setPreferenceProperty( step, "precision", 3 );
1745 // Set property for deflection value for spinboxes
1746 setPreferenceProperty( defl, "min", DEFLECTION_MIN );
1747 setPreferenceProperty( defl, "max", 1.0 );
1748 setPreferenceProperty( defl, "step", 1.0e-04 );
1749 setPreferenceProperty( defl, "precision", 6 );
1751 // Set property for default material
1752 Material_ResourceMgr aMatResMgr;
1753 QStringList aPrefMatNames = aMatResMgr.getPreferenceMaterialsNames();
1754 setPreferenceProperty( front_material, "strings", aPrefMatNames );
1755 setPreferenceProperty( back_material, "strings", aPrefMatNames );
1757 // Set property vertex marker type
1758 QList<QVariant> aMarkerTypeIndicesList;
1759 QList<QVariant> aMarkerTypeIconsList;
1761 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1762 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1763 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1764 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1765 aMarkerTypeIndicesList << (i-1);
1766 aMarkerTypeIconsList << pixmap;
1769 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1770 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
1772 // Set property for vertex marker scale
1773 QList<QVariant> aMarkerScaleIndicesList;
1774 QStringList aMarkerScaleValuesList;
1776 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
1777 aMarkerScaleIndicesList << iii;
1778 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
1781 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1782 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1784 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
1785 setPreferenceProperty( originGroup, "columns", 2 );
1787 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
1788 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
1789 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
1790 setPreferenceProperty( baseVectorsLength, "max", 1000 );
1792 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
1793 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
1796 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
1797 setPreferenceProperty( operationsGroup, "columns", 2 );
1799 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
1800 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
1803 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1805 if (section == "Geometry") {
1806 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1807 if (param == QString("SettingsGeomStep")) {
1808 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1809 EmitSignalDefaultStepValueChanged(spin_step);
1814 LightApp_Displayer* GeometryGUI::displayer()
1817 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1821 void GeometryGUI::setLocalSelectionMode(const int mode)
1823 myLocalSelectionMode = mode;
1825 int GeometryGUI::getLocalSelectionMode() const
1827 return myLocalSelectionMode;
1830 const char gSeparator = '_'; // character used to separate parameter names
1831 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1834 * \brief Store visual parameters
1836 * This method is called just before the study document is saved.
1837 * Store visual parameters in AttributeParameter attribute(s)
1839 void GeometryGUI::storeVisualParameters (int savePoint)
1841 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1842 if ( !appStudy || !appStudy->studyDS() )
1844 _PTR(Study) studyDS = appStudy->studyDS();
1846 // componentName is used for encoding of entries when storing them in IParameters
1847 std::string componentName = myComponentGeom->ComponentDataType();
1848 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1849 //if (!aSComponent) return;
1852 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1853 componentName.c_str(),
1855 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1857 QList<SUIT_ViewManager*> lst;
1858 QList<SUIT_ViewManager*>::Iterator it;
1860 // main cycle to store parameters of displayed objects
1862 getApp()->viewManagers(lst);
1863 for (it = lst.begin(); it != lst.end(); it++) {
1864 SUIT_ViewManager* vman = *it;
1865 QString vType = vman->getType();
1866 int aMgrId = vman->getGlobalId();
1867 // saving VTK actors properties
1868 QVector<SUIT_ViewWindow*> views = vman->getViews();
1869 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
1870 const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
1871 ObjMap::ConstIterator o_it = anObjects.begin();
1872 for (; o_it != anObjects.end(); o_it++) {
1873 const PropMap aProps = o_it.value();
1875 //Check that object exists in the study
1876 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
1877 if ( !obj || !(aProps.count() > 0))
1879 // entry is "encoded" = it does NOT contain component adress, since it is a
1880 // subject to change on next component loading
1882 std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
1884 _PTR(GenericAttribute) anAttr;
1885 if( !obj->FindAttribute(anAttr, "AttributeIOR"))
1888 std::string param,occParam = vType.toLatin1().data();
1889 occParam += NAME_SEPARATOR;
1890 occParam += QString::number(aMgrId).toLatin1().data();
1891 occParam += NAME_SEPARATOR;
1893 if(aProps.contains(VISIBILITY_PROP)) {
1894 param = occParam + VISIBILITY_PROP;
1895 ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
1898 if(aProps.contains(DISPLAY_MODE_PROP)) {
1899 param = occParam + DISPLAY_MODE_PROP;
1900 ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
1903 if(aProps.contains(COLOR_PROP)) {
1904 QColor c = aProps.value(COLOR_PROP).value<QColor>();
1905 QString colorStr = QString::number(c.red()/255.);
1906 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
1907 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
1908 param = occParam + COLOR_PROP;
1909 ip->setParameter(entry, param, colorStr.toLatin1().data());
1912 if(vType == SVTK_Viewer::Type()) {
1913 if(aProps.contains(OPACITY_PROP)) {
1914 param = occParam + OPACITY_PROP;
1915 ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1917 } else if (vType == SOCC_Viewer::Type()) {
1918 if(aProps.contains(TRANSPARENCY_PROP)) {
1919 param = occParam + TRANSPARENCY_PROP;
1920 ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1924 if(aProps.contains(ISOS_PROP)) {
1925 param = occParam + ISOS_PROP;
1926 ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
1929 if(aProps.contains(VECTOR_MODE_PROP)) {
1930 param = occParam + VECTOR_MODE_PROP;
1931 ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
1934 if(aProps.contains(DEFLECTION_COEFF_PROP)) {
1935 param = occParam + DEFLECTION_COEFF_PROP;
1936 ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
1939 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
1940 if(aProps.contains(MARKER_TYPE_PROP)) {
1941 param = occParam + MARKER_TYPE_PROP;
1942 ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
1945 if(aProps.contains(FRONT_MATERIAL_PROP)) {
1946 param = occParam + FRONT_MATERIAL_PROP;
1947 ip->setParameter(entry, param, aProps.value(FRONT_MATERIAL_PROP).toString().toLatin1().data());
1950 if(aProps.contains(BACK_MATERIAL_PROP)) {
1951 param = occParam + BACK_MATERIAL_PROP;
1952 ip->setParameter(entry, param, aProps.value(BACK_MATERIAL_PROP).toString().toLatin1().data());
1954 } // object iterator
1956 } // for (viewManagers)
1960 * \brief Restore visual parameters
1962 * This method is called after the study document is opened.
1963 * Restore visual parameters from AttributeParameter attribute(s)
1965 void GeometryGUI::restoreVisualParameters (int savePoint)
1967 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1968 if (!appStudy || !appStudy->studyDS())
1970 _PTR(Study) studyDS = appStudy->studyDS();
1972 // componentName is used for encoding of entries when storing them in IParameters
1973 std::string componentName = myComponentGeom->ComponentDataType();
1974 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1975 //if (!aSComponent) return;
1978 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1979 componentName.c_str(),
1981 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1983 std::vector<std::string> entries = ip->getEntries();
1985 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
1987 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1988 QString entry (ip->decodeEntry(*entIt).c_str());
1990 // Check that the entry corresponds to a real object in the Study
1991 // as the object may be deleted or modified after the visual state is saved.
1992 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1993 if (!so) continue; //Skip the not existent entry
1995 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1996 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1998 std::vector<std::string>::iterator namesIt = paramNames.begin();
1999 std::vector<std::string>::iterator valuesIt = paramValues.begin();
2001 // actors are stored in a map after displaying of them for
2002 // quicker access in the future: map < viewID to actor >
2003 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
2004 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
2006 QString viewerTypStr;
2007 QString viewIndexStr;
2009 QVector<PropMap> aListOfMap;
2011 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
2013 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
2014 // '_' is used as separator and should not be used in viewer type or parameter names.
2015 QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts);
2016 if (lst.size() != 3)
2019 viewerTypStr = lst[0];
2020 viewIndexStr = lst[1];
2021 QString paramNameStr = lst[2];
2024 viewIndex = viewIndexStr.toUInt(&ok);
2025 if (!ok) // bad conversion of view index to integer
2028 if((viewIndex + 1) > aListOfMap.count()) {
2029 aListOfMap.resize(viewIndex + 1);
2032 QString val((*valuesIt).c_str());
2033 if(paramNameStr == VISIBILITY_PROP){
2034 aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0);
2036 } else if(paramNameStr == OPACITY_PROP) {
2037 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
2039 } else if(paramNameStr == TRANSPARENCY_PROP) {
2040 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, val.toDouble());
2042 } else if(paramNameStr == DISPLAY_MODE_PROP) {
2043 aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
2045 } else if(paramNameStr == ISOS_PROP) {
2046 aListOfMap[viewIndex].insert( ISOS_PROP, val);
2048 } else if(paramNameStr == COLOR_PROP) {
2049 QStringList rgb = val.split(DIGIT_SEPARATOR);
2050 if(rgb.count() == 3) {
2051 QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255));
2052 aListOfMap[viewIndex].insert( COLOR_PROP, c);
2054 } else if(paramNameStr == VECTOR_MODE_PROP) {
2055 aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt());
2057 } else if(paramNameStr == DEFLECTION_COEFF_PROP) {
2058 aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
2059 } else if(paramNameStr == MARKER_TYPE_PROP) {
2060 aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
2061 } else if(paramNameStr == FRONT_MATERIAL_PROP) {
2062 aListOfMap[viewIndex].insert( FRONT_MATERIAL_PROP, val);
2063 } else if(paramNameStr == BACK_MATERIAL_PROP) {
2064 aListOfMap[viewIndex].insert( BACK_MATERIAL_PROP, val);
2067 } // for names/parameters iterator
2069 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
2071 for (int index = 0; index < aListOfMap.count(); index++) {
2073 appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
2075 //Get Visibility property of the current PropMap
2076 if (aListOfMap[index].value(VISIBILITY_PROP) == 1) {
2077 SUIT_ViewManager* vman = lst.at(index);
2078 SUIT_ViewModel* vmodel = vman->getViewModel();
2079 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
2083 } // for entries iterator
2085 // update all VTK and OCC views
2086 QList<SUIT_ViewManager*> lst;
2087 getApp()->viewManagers(lst);
2088 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
2089 SUIT_ViewModel* vmodel = (*it)->getViewModel();
2092 if (vmodel->getType() == SVTK_Viewer::Type()) {
2093 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
2094 vtkView->getRenderer()->ResetCameraClippingRange();
2097 else if (vmodel->getType() == SOCC_Viewer::Type()) {
2098 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
2099 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
2106 void GeometryGUI::onViewAboutToShow()
2108 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
2109 QAction* a = action( GEOMOp::OpSwitchVectors );
2111 a->setEnabled(true);
2112 bool vmode = window->property("VectorsMode").toBool();
2113 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
2115 a->setText ( tr("MEN_VECTOR_MODE_ON") );
2116 a->setEnabled(false);
2121 Rename object by entry.
2122 \param entry entry of the object
2123 \param name new name of the object
2124 \brief Return \c true if rename operation finished successfully, \c false otherwise.
2126 bool GeometryGUI::renameObject( const QString& entry, const QString& name) {
2128 bool appRes = SalomeApp_Module::renameObject(entry,name);
2132 bool result = false;
2134 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
2135 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2140 _PTR(Study) aStudy = appStudy->studyDS();
2145 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
2146 _PTR(GenericAttribute) anAttr;
2148 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
2149 _PTR(AttributeName) aName (anAttr);
2151 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
2152 if (!CORBA::is_nil(anObj)) {
2153 aName->SetValue( name.toLatin1().data() ); // rename the SObject
2154 anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object