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 "GEOMGUI_CreationInfoWdg.h"
35 #include "GEOM_Constants.h"
36 #include "GEOM_Displayer.h"
37 #include "GEOM_AISShape.hxx"
39 #include "GEOM_Actor.h"
41 #include <Material_ResourceMgr.h>
42 #include <Material_Model.h>
44 #include <SUIT_Desktop.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_ResourceMgr.h>
47 #include <SUIT_Session.h>
48 #include <SUIT_ViewManager.h>
50 #include <OCCViewer_ViewWindow.h>
51 #include <OCCViewer_ViewPort3d.h>
52 #include <OCCViewer_ViewModel.h>
53 #include <OCCViewer_ViewManager.h>
55 #include <SOCC_ViewModel.h>
56 #include <SOCC_ViewWindow.h>
58 #include <SVTK_ViewWindow.h>
59 #include <SVTK_RenderWindowInteractor.h>
60 #include <SVTK_InteractorStyle.h>
61 #include <SVTK_ViewModel.h>
63 #include <SalomeApp_Application.h>
64 #include <SalomeApp_DataObject.h>
65 #include <SalomeApp_Study.h>
66 #include <SalomeApp_Tools.h>
68 #include <LightApp_SelectionMgr.h>
69 #include <LightApp_VTKSelector.h>
70 #include <LightApp_DataObject.h>
71 #include <LightApp_Preferences.h>
73 #include <SALOME_LifeCycleCORBA.hxx>
74 #include <SALOME_ListIO.hxx>
75 #include <SALOME_ListIteratorOfListIO.hxx>
77 #include <SALOMEDSClient_ClientFactory.hxx>
78 #include <SALOMEDSClient_IParameters.hxx>
80 #include <SALOMEDS_SObject.hxx>
82 #include <Basics_OCCTVersion.hxx>
91 #include <QSignalMapper>
93 #include <AIS_Drawer.hxx>
94 #include <AIS_ListOfInteractive.hxx>
95 #include <AIS_ListIteratorOfListOfInteractive.hxx>
96 #include <Prs3d_Drawer.hxx>
97 #include <Prs3d_IsoAspect.hxx>
98 #include <Aspect_TypeOfMarker.hxx>
99 #include <OSD_SharedLibrary.hxx>
100 #include <NCollection_DataMap.hxx>
102 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
103 #include <TColStd_HArray1OfByte.hxx>
105 #include <Graphic3d_HArray1OfBytes.hxx>
108 #include <utilities.h>
110 #include <vtkCamera.h>
111 #include <vtkRenderer.h>
113 #include <Standard_Failure.hxx>
114 #include <Standard_ErrorHandler.hxx>
116 #include "GEOM_version.h"
117 #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
120 Standard_EXPORT CAM_Module* createModule() {
121 return new GeometryGUI();
124 Standard_EXPORT char* getModuleVersion() {
125 return (char*)GEOM_VERSION_STR;
129 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
131 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
133 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
135 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
136 if (CORBA::is_nil(myComponentGeom))
138 return GeometryGUI::myComponentGeom;
141 bool GeometryGUI::InitGeomGen()
144 if ( CORBA::is_nil( myComponentGeom ) ) return false;
148 //=======================================================================
149 // function : ClientSObjectToObject
151 //=======================================================================
152 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
154 _PTR(GenericAttribute) anAttr;
155 CORBA::Object_var anObj;
157 std::string aValue = theSObject->GetIOR();
158 if (strcmp(aValue.c_str(), "") != 0) {
159 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
160 anObj = anORB->string_to_object(aValue.c_str());
163 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
165 return anObj._retn();
168 //=======================================================================
169 // function : ClientStudyToStudy
171 //=======================================================================
172 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
174 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
175 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
176 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
177 int aStudyID = theStudy->StudyId();
178 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
179 return aDSStudy._retn();
182 void GeometryGUI::Modified (bool theIsUpdateActions)
184 if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
185 if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
186 appStudy->Modified();
187 if ( theIsUpdateActions )
188 app->updateActions();
193 //=======================================================================
194 // function : GeometryGUI::GeometryGUI()
195 // purpose : Constructor
196 //=======================================================================
197 GeometryGUI::GeometryGUI() :
198 SalomeApp_Module( "GEOM" )
200 if ( CORBA::is_nil( myComponentGeom ) )
202 Engines::EngineComponent_var comp =
203 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
204 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
207 myActiveDialogBox = 0;
209 gp_Pnt origin = gp_Pnt(0., 0., 0.);
210 gp_Dir direction = gp_Dir(0., 0., 1.);
211 myWorkingPlane = gp_Ax3(origin, direction);
214 myLocalSelectionMode = GEOM_ALLOBJECTS;
216 myCreationInfoWdg = 0;
218 connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
221 //=======================================================================
222 // function : GeometryGUI::~GeometryGUI()
223 // purpose : Destructor
224 //=======================================================================
225 GeometryGUI::~GeometryGUI()
227 while (!myOCCSelectors.isEmpty())
228 delete myOCCSelectors.takeFirst();
230 while (!myVTKSelectors.isEmpty())
231 delete myVTKSelectors.takeFirst();
233 qDeleteAll(myGUIMap);
236 //=======================================================================
237 // function : GeometryGUI::getLibrary()
238 // purpose : get or load GUI library by name [ internal ]
239 //=======================================================================
240 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
241 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
243 if ( !myGUIMap.contains( libraryName ) ) {
244 // try to load library if it is not loaded yet
246 QString dirs = getenv( "LD_LIBRARY_PATH" );
249 QString dirs = getenv( "PATH" );
252 if ( !dirs.isEmpty() ) {
253 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
254 QListIterator<QString> it( dirList ); it.toBack();
255 while ( it.hasPrevious() ) {
256 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
258 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
259 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
261 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
262 continue; // continue search further
264 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
265 if ( osdF != NULL ) {
266 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
267 GEOMGUI* libGUI = (*func)( this );
269 myGUIMap[ libraryName ] = libGUI;
270 break; // found and loaded!
277 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
280 //=======================================================================
281 // function : GeometryGUI::ActiveWorkingPlane()
282 // purpose : Activate Working Plane View
283 //=======================================================================
284 void GeometryGUI::ActiveWorkingPlane()
286 gp_Dir DZ = myWorkingPlane.Direction();
287 gp_Dir DY = myWorkingPlane.YDirection();
289 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
290 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
291 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
294 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
296 Handle(V3d_View) view3d = vw->getViewPort()->getView();
298 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
299 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
303 else if ( ViewVTK ) {
304 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
306 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
308 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
309 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
310 camera->SetFocalPoint(0,0,0);
317 //=======================================================================
318 // function : GeometryGUI::SetActiveDialogBox()
319 // purpose : Set active dialog box
320 //=======================================================================
321 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
323 myActiveDialogBox = (QDialog*)aDlg;
326 //=======================================================================
327 // function : GeometryGUI::EmitSignalDeactivateDialog()
328 // purpose : Emit a signal to deactivate the active dialog Box
329 //=======================================================================
330 void GeometryGUI::EmitSignalDeactivateDialog()
332 emit SignalDeactivateActiveDialog();
335 //=======================================================================
336 // function : GeometryGUI::EmitSignalCloseAllDialogs()
337 // purpose : Emit a signal to close all non modal dialogs box
338 //=======================================================================
339 void GeometryGUI::EmitSignalCloseAllDialogs()
341 emit SignalCloseAllDialogs();
344 //=======================================================================
345 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
346 // purpose : Emit a signal to inform that default real spin box step has
348 //=======================================================================
349 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
351 emit SignalDefaultStepValueChanged(newVal);
354 //=======================================================================
355 // function : GeometryGUI::OnGUIEvent()
356 // purpose : common slot for all menu/toolbar actions
357 //=======================================================================
358 void GeometryGUI::OnGUIEvent()
360 const QObject* obj = sender();
361 if ( !obj || !obj->inherits( "QAction" ) )
363 int id = actionId((QAction*)obj);
368 //=======================================================================
369 // function : GeometryGUI::OnGUIEvent()
370 // purpose : manage all events on GUI [static]
371 //=======================================================================
372 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
374 SUIT_Application* anApp = application();
376 SUIT_Desktop* desk = anApp->desktop();
378 // check type of the active viewframe
379 SUIT_ViewWindow* window = desk->activeWindow();
380 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
381 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
382 // if current viewframe is not of OCC and not of VTK type - return immediately
383 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
384 QList<int> NotViewerDependentCommands;
385 NotViewerDependentCommands << GEOMOp::OpDelete
387 << GEOMOp::OpShowOnly
388 << GEOMOp::OpShowOnlyChildren
389 << GEOMOp::OpDiscloseChildren
390 << GEOMOp::OpConcealChildren
391 << GEOMOp::OpUnpublishObject
392 << GEOMOp::OpPublishObject
393 << GEOMOp::OpPointMarker
394 << GEOMOp::OpCreateFolder;
395 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
398 // fix for IPAL9103, point 2
399 if ( CORBA::is_nil( GetGeomGen() ) ) {
400 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
405 // find corresponding GUI library
407 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
408 createOriginAndBaseVectors(); // internal operation
410 case GEOMOp::OpImport: // MENU FILE - IMPORT
411 case GEOMOp::OpExport: // MENU FILE - EXPORT
412 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
413 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
414 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
415 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
416 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
417 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
418 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
419 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
420 case GEOMOp::OpDelete: // MENU EDIT - DELETE
421 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
422 case GEOMOp::OpMaterialsLibrary: // MENU TOOLS - MATERIALS LIBRARY
423 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
424 case GEOMOp::OpColor: // POPUP MENU - COLOR
425 case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
426 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
427 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
428 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
429 case GEOMOp::OpIsos: // POPUP MENU - ISOS
430 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
431 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
432 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
433 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
434 case GEOMOp::OpDiscloseChildren: // POPUP MENU - DISCLOSE CHILD ITEMS
435 case GEOMOp::OpConcealChildren: // POPUP MENU - CONCEAL CHILD ITEMS
436 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
437 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
438 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
439 case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
440 case GEOMOp::OpPredefMaterial: // POPUP MENU - <SOME MATERIAL>
441 case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
442 case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH
443 case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH
444 case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT
445 case GEOMOp::OpClsBringToFront: //
446 case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER
447 libName = "GEOMToolsGUI";
449 case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
450 case GEOMOp::OpDMShading: // MENU VIEW - SHADING
451 case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
452 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
453 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
454 case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
455 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
456 case GEOMOp::OpHide: // MENU VIEW - ERASE
457 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
458 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
459 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
460 case GEOMOp::OpShading: // POPUP MENU - SHADING
461 case GEOMOp::OpShadingWithEdges: // POPUP MENU - SHADING WITH EDGES
462 case GEOMOp::OpTexture: // POPUP MENU - TEXTURE
463 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
464 libName = "DisplayGUI";
466 case GEOMOp::OpPoint: // MENU BASIC - POINT
467 case GEOMOp::OpLine: // MENU BASIC - LINE
468 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
469 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
470 case GEOMOp::OpArc: // MENU BASIC - ARC
471 case GEOMOp::OpVector: // MENU BASIC - VECTOR
472 case GEOMOp::OpPlane: // MENU BASIC - PLANE
473 case GEOMOp::OpCurve: // MENU BASIC - CURVE
474 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
475 libName = "BasicGUI";
477 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
478 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
479 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
480 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
481 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
482 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
483 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
484 libName = "PrimitiveGUI";
486 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
487 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
488 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
489 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
490 case GEOMOp::OpPipePath: // MENU GENERATION - RESTORE PATH
491 libName = "GenerationGUI";
493 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
494 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
495 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
497 case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
499 case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
500 libName = "EntityGUI";
502 case GEOMOp::OpEdge: // MENU BUILD - EDGE
503 case GEOMOp::OpWire: // MENU BUILD - WIRE
504 case GEOMOp::OpFace: // MENU BUILD - FACE
505 case GEOMOp::OpShell: // MENU BUILD - SHELL
506 case GEOMOp::OpSolid: // MENU BUILD - SOLID
507 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
508 libName = "BuildGUI";
510 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
511 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
512 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
513 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
514 libName = "BooleanGUI";
516 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
517 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
518 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
519 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
520 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
521 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
522 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
523 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
524 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
525 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
526 libName = "TransformationGUI";
528 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
529 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
530 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
531 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
532 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
533 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
534 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
535 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
536 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
537 case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
538 case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
539 libName = "OperationGUI";
541 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
542 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
543 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
544 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
545 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
546 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
547 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
548 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
549 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
550 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
551 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
552 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
553 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
554 case GEOMOp::OpRemoveWebs: // MENU REPAIR - REMOVE INTERNAL FACES
555 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
556 case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES
557 case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES
558 libName = "RepairGUI";
560 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
561 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
562 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
563 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
564 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
565 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
566 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
567 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
568 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
569 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
570 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
571 case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS
572 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
573 case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
574 libName = "MeasureGUI";
576 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
577 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
578 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
579 case GEOMOp::OpGroupUnion: // MENU GROUP - UNION
580 case GEOMOp::OpGroupIntersect: // MENU GROUP - INTERSECT
581 case GEOMOp::OpGroupCut: // MENU GROUP - CUT
582 libName = "GroupGUI";
584 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
585 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
586 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
587 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
588 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
589 libName = "BlocksGUI";
591 case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
592 case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
593 // case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
594 case GEOMOp::OpDividedDisk: // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
595 case GEOMOp::OpDividedCylinder: // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
596 case GEOMOp::OpSmoothingSurface: // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
597 //@@ 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 @@//
598 libName = "AdvancedGUI";
604 GEOMGUI* library = 0;
605 if ( !libName.isEmpty() ) {
607 libName = QString( "lib" ) + libName + ".so";
609 libName = libName + ".dll";
611 library = getLibrary( libName );
614 // call method of corresponding GUI library
616 if( !theParam.isValid() )
617 library->OnGUIEvent( id, desk );
619 library->OnGUIEvent( id, desk, theParam);
622 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
624 updateCreationInfo();
627 //=================================================================================
628 // function : GeometryGUI::OnKeyPress()
629 // purpose : Called when any key is pressed by user [static]
630 //=================================================================================
631 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
633 if ( !application() )
635 foreach ( GEOMGUI* lib, myGUIMap )
636 lib->OnKeyPress( e, application()->desktop(), w );
639 //=================================================================================
640 // function : GeometryGUI::OnMouseMove()
641 // purpose : Manages mouse move events [static]
642 //=================================================================================
643 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
645 if ( !application() )
647 foreach ( GEOMGUI* lib, myGUIMap )
648 lib->OnMouseMove( e, application()->desktop(), w );
651 //=================================================================================
652 // function : GeometryGUI::OnMouseRelease()
653 // purpose : Manages mouse release events [static]
654 //=================================================================================
655 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
657 if ( !application() )
659 foreach ( GEOMGUI* lib, myGUIMap )
660 lib->OnMouseRelease( e, application()->desktop(), w );
663 //=================================================================================
664 // function : GeometryGUI::OnMousePress()
665 // purpose : Manage mouse press events [static]
666 //=================================================================================
667 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
669 if ( !application() )
671 foreach ( GEOMGUI* lib, myGUIMap )
672 lib->OnMousePress( e, application()->desktop(), w );
675 //=======================================================================
676 // function : createGeomAction
678 //=======================================================================
679 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
680 const int accel, const bool toggle, const QString& shortcutAction )
682 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
683 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
684 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
686 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
688 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
689 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
691 application()->desktop(),
693 this, SLOT( OnGUIEvent() ),
697 //=======================================================================
698 // function : createOriginAndBaseVectors
700 //=======================================================================
701 void GeometryGUI::createOriginAndBaseVectors()
703 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
705 _PTR(Study) studyDS = appStudy->studyDS();
706 if ( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
707 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
708 if ( !aBasicOperations->_is_nil() ) {
709 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
710 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
711 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
712 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
713 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
714 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
716 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
717 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
718 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
719 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
720 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
722 getApp()->updateObjectBrowser( true );
728 //=======================================================================
729 // function : GeometryGUI::initialize()
730 // purpose : Called when GEOM module is created
731 //=======================================================================
732 void GeometryGUI::initialize( CAM_Application* app )
734 SalomeApp_Module::initialize( app );
736 // ----- create actions --------------
738 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
739 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
741 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
743 createGeomAction( GEOMOp::OpPoint, "POINT" );
744 createGeomAction( GEOMOp::OpLine, "LINE" );
745 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
746 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
747 createGeomAction( GEOMOp::OpArc, "ARC" );
748 createGeomAction( GEOMOp::OpCurve, "CURVE" );
749 createGeomAction( GEOMOp::OpVector, "VECTOR" );
750 createGeomAction( GEOMOp::OpPlane, "PLANE" );
751 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
752 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
754 createGeomAction( GEOMOp::OpBox, "BOX" );
755 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
756 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
757 createGeomAction( GEOMOp::OpTorus, "TORUS" );
758 createGeomAction( GEOMOp::OpCone, "CONE" );
759 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
760 createGeomAction( GEOMOp::OpDisk, "DISK" );
762 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
763 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
764 createGeomAction( GEOMOp::OpFilling, "FILLING" );
765 createGeomAction( GEOMOp::OpPipe, "PIPE" );
766 createGeomAction( GEOMOp::OpPipePath, "PIPE_PATH" );
768 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
769 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
770 createGeomAction( GEOMOp::OpGroupUnion, "GROUP_UNION" );
771 createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
772 createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" );
774 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
776 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
777 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
779 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
780 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
781 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
783 createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
785 createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
787 createGeomAction( GEOMOp::OpEdge, "EDGE" );
788 createGeomAction( GEOMOp::OpWire, "WIRE" );
789 createGeomAction( GEOMOp::OpFace, "FACE" );
790 createGeomAction( GEOMOp::OpShell, "SHELL" );
791 createGeomAction( GEOMOp::OpSolid, "SOLID" );
792 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
794 createGeomAction( GEOMOp::OpFuse, "FUSE" );
795 createGeomAction( GEOMOp::OpCommon, "COMMON" );
796 createGeomAction( GEOMOp::OpCut, "CUT" );
797 createGeomAction( GEOMOp::OpSection, "SECTION" );
799 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
800 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
801 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
802 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
803 createGeomAction( GEOMOp::OpScale, "SCALE" );
804 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
805 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
806 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
807 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
809 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
810 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
811 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
812 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
813 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
814 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
815 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
816 createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
817 createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
818 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
819 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
821 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
822 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
823 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
825 createGeomAction( GEOMOp::OpSewing, "SEWING" );
826 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
827 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
828 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
829 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
830 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
831 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
832 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
833 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
834 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
835 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
836 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
837 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
838 createGeomAction( GEOMOp::OpRemoveWebs, "REMOVE_WEBS" );
839 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
840 createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" );
841 createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" );
843 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
844 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
845 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
846 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
847 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
848 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
849 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
850 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
852 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
853 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
854 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
855 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
856 createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
857 createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
859 #ifdef _DEBUG_ // PAL16821
860 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
863 createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" );
864 createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" );
865 createGeomAction( GEOMOp::OpDMShading, "SHADING" );
866 createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
867 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
868 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
869 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
870 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
871 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
872 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
873 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
874 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
875 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
876 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
877 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
878 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
879 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
880 createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
881 createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
882 createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
883 createGeomAction( GEOMOp::OpHide, "ERASE" );
885 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
886 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
887 createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
888 createGeomAction( GEOMOp::OpTexture, "POP_TEXTURE", "", 0, true );
889 createGeomAction( GEOMOp::OpEdgeWidth, "EDGE_WIDTH");
890 createGeomAction( GEOMOp::OpIsosWidth, "ISOS_WIDTH");
891 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
892 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
893 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
894 createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
895 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
896 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
897 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
898 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
899 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
900 createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
901 createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
902 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
903 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
904 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
905 createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
906 createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
907 createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
909 createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
911 // Create actions for increase/decrease transparency shortcuts
912 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
913 "Geometry:Increase transparency");
914 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
915 "Geometry:Decrease transparency");
917 // Create actions for increase/decrease number of isolines
918 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
919 "Geometry:Increase number of isolines");
920 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
921 "Geometry:Decrease number of isolines");
923 // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
924 createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
925 createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
926 createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
927 //@@ 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 @@//
929 // ---- create menus --------------------------
931 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
932 createMenu( separator(), fileId, 10 );
933 createMenu( GEOMOp::OpImport, fileId, 10 );
934 createMenu( GEOMOp::OpExport, fileId, 10 );
935 createMenu( separator(), fileId, -1 );
937 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
938 createMenu( GEOMOp::OpDelete, editId, -1 );
940 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
942 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
943 createMenu( GEOMOp::OpPoint, basicId, -1 );
944 createMenu( GEOMOp::OpLine, basicId, -1 );
945 createMenu( GEOMOp::OpCircle, basicId, -1 );
946 createMenu( GEOMOp::OpEllipse, basicId, -1 );
947 createMenu( GEOMOp::OpArc, basicId, -1 );
948 createMenu( GEOMOp::OpCurve, basicId, -1 );
949 createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
950 createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
951 createMenu( separator(), basicId, -1 );
952 createMenu( GEOMOp::OpVector, basicId, -1 );
953 createMenu( GEOMOp::OpPlane, basicId, -1 );
954 createMenu( GEOMOp::OpLCS, basicId, -1 );
955 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
957 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
958 createMenu( GEOMOp::OpBox, primId, -1 );
959 createMenu( GEOMOp::OpCylinder, primId, -1 );
960 createMenu( GEOMOp::OpSphere, primId, -1 );
961 createMenu( GEOMOp::OpTorus, primId, -1 );
962 createMenu( GEOMOp::OpCone, primId, -1 );
963 createMenu( GEOMOp::OpRectangle, primId, -1 );
964 createMenu( GEOMOp::OpDisk, primId, -1 );
965 createMenu( GEOMOp::OpPipeTShape,primId, -1 );
967 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
968 createMenu( GEOMOp::OpPrism, genId, -1 );
969 createMenu( GEOMOp::OpRevolution, genId, -1 );
970 createMenu( GEOMOp::OpFilling, genId, -1 );
971 createMenu( GEOMOp::OpPipe, genId, -1 );
972 #if OCC_VERSION_LARGE > 0x06050300
973 createMenu( GEOMOp::OpPipePath, genId, -1 );
976 int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
977 createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
978 //@@ 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 @@//
980 createMenu( separator(), newEntId, -1 );
982 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
983 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
984 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
985 createMenu( GEOMOp::OpGroupUnion, groupId, -1 );
986 createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
987 createMenu( GEOMOp::OpGroupCut, groupId, -1 );
989 createMenu( separator(), newEntId, -1 );
991 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
992 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
993 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
994 createMenu( GEOMOp::OpDividedDisk, blocksId, -1 );
995 createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
997 createMenu( separator(), newEntId, -1 );
999 createMenu( GEOMOp::OpExplode, newEntId, -1 );
1001 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
1002 createMenu( GEOMOp::OpEdge, buildId, -1 );
1003 createMenu( GEOMOp::OpWire, buildId, -1 );
1004 createMenu( GEOMOp::OpFace, buildId, -1 );
1005 createMenu( GEOMOp::OpShell, buildId, -1 );
1006 createMenu( GEOMOp::OpSolid, buildId, -1 );
1007 createMenu( GEOMOp::OpCompound, buildId, -1 );
1009 createMenu( separator(), newEntId, -1 );
1011 createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1013 createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1016 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1018 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1019 createMenu( GEOMOp::OpFuse, boolId, -1 );
1020 createMenu( GEOMOp::OpCommon, boolId, -1 );
1021 createMenu( GEOMOp::OpCut, boolId, -1 );
1022 createMenu( GEOMOp::OpSection, boolId, -1 );
1024 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1025 createMenu( GEOMOp::OpTranslate, transId, -1 );
1026 createMenu( GEOMOp::OpRotate, transId, -1 );
1027 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
1028 createMenu( GEOMOp::OpMirror, transId, -1 );
1029 createMenu( GEOMOp::OpScale, transId, -1 );
1030 createMenu( GEOMOp::OpOffset, transId, -1 );
1031 createMenu( GEOMOp::OpProjection, transId, -1 );
1032 createMenu( separator(), transId, -1 );
1033 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1034 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
1036 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1037 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1038 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
1039 createMenu( GEOMOp::OpPropagate, blockId, -1 );
1041 createMenu( separator(), operId, -1 );
1043 createMenu( GEOMOp::OpPartition, operId, -1 );
1044 createMenu( GEOMOp::OpArchimede, operId, -1 );
1045 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1046 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
1048 createMenu( separator(), operId, -1 );
1050 createMenu( GEOMOp::OpFillet1d, operId, -1 );
1051 createMenu( GEOMOp::OpFillet2d, operId, -1 );
1052 createMenu( GEOMOp::OpFillet3d, operId, -1 );
1053 createMenu( GEOMOp::OpChamfer, operId, -1 );
1054 createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
1055 createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
1056 //createMenu( GEOMOp::OpClipping, operId, -1 );
1058 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1059 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
1060 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
1061 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
1062 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
1063 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
1064 createMenu( GEOMOp::OpSewing, repairId, -1 );
1065 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
1066 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
1067 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
1068 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
1069 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
1070 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
1071 createMenu( GEOMOp::OpOrientation, repairId, -1 );
1072 createMenu( GEOMOp::OpRemoveWebs, repairId, -1 );
1073 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1074 createMenu( GEOMOp::OpFuseEdges, repairId, -1 );
1075 createMenu( GEOMOp::OpUnionFaces, repairId, -1 );
1077 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1078 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1079 createMenu( GEOMOp::OpProperties, measurId, -1 );
1080 createMenu( separator(), measurId, -1 );
1081 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
1082 createMenu( GEOMOp::OpInertia, measurId, -1 );
1083 createMenu( GEOMOp::OpNormale, measurId, -1 );
1084 createMenu( separator(), measurId, -1 );
1085 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
1086 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
1087 createMenu( separator(), measurId, -1 );
1089 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1090 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1091 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1092 createMenu( GEOMOp::OpAngle, dimId, -1 );
1094 createMenu( separator(), measurId, -1 );
1095 createMenu( GEOMOp::OpTolerance, measurId, -1 );
1096 createMenu( separator(), measurId, -1 );
1097 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
1098 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
1099 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
1100 createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
1101 createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1103 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1104 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1105 createMenu( separator(), toolsId, -1 );
1106 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1109 createMenu( separator(), toolsId, -1 );
1110 createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1111 createMenu( separator(), toolsId, -1 );
1113 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1114 createMenu( separator(), viewId, -1 );
1116 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1117 createMenu( GEOMOp::OpDMWireframe, dispmodeId, -1 );
1118 createMenu( GEOMOp::OpDMShading, dispmodeId, -1 );
1119 createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1120 createMenu( separator(), dispmodeId, -1 );
1121 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1123 createMenu( separator(), viewId, -1 );
1124 createMenu( GEOMOp::OpShowAll, viewId, -1 );
1125 createMenu( GEOMOp::OpHideAll, viewId, -1 );
1126 createMenu( separator(), viewId, -1 );
1127 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1128 createMenu( separator(), viewId, -1 );
1132 because of these items are accessible through object browser and viewers
1133 we have removed they from main menu
1135 createMenu( GEOMOp::OpShow, viewId, -1 );
1136 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1137 createMenu( GEOMOp::OpHide, viewId, -1 );
1140 // ---- create toolbars --------------------------
1142 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1143 createTool( GEOMOp::OpPoint, basicTbId );
1144 createTool( GEOMOp::OpLine, basicTbId );
1145 createTool( GEOMOp::OpCircle, basicTbId );
1146 createTool( GEOMOp::OpEllipse, basicTbId );
1147 createTool( GEOMOp::OpArc, basicTbId );
1148 createTool( GEOMOp::OpCurve, basicTbId );
1149 createTool( GEOMOp::OpVector, basicTbId );
1150 createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1151 createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1152 createTool( GEOMOp::OpPlane, basicTbId );
1153 createTool( GEOMOp::OpLCS, basicTbId );
1154 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1156 // int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
1157 // createTool( GEOMOp::Op2dSketcher, sketchTbId );
1158 // createTool( GEOMOp::Op3dSketcher, sketchTbId );
1160 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1161 createTool( GEOMOp::OpBox, primTbId );
1162 createTool( GEOMOp::OpCylinder, primTbId );
1163 createTool( GEOMOp::OpSphere, primTbId );
1164 createTool( GEOMOp::OpTorus, primTbId );
1165 createTool( GEOMOp::OpCone, primTbId );
1166 createTool( GEOMOp::OpRectangle, primTbId );
1167 createTool( GEOMOp::OpDisk, primTbId );
1168 createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1170 int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) );
1171 createTool( GEOMOp::OpDividedDisk, blocksTbId );
1172 createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1174 // int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc
1175 // createTool( GEOMOp::OpPipeTShape, advancedTbId );
1177 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1178 createTool( GEOMOp::OpFuse, boolTbId );
1179 createTool( GEOMOp::OpCommon, boolTbId );
1180 createTool( GEOMOp::OpCut, boolTbId );
1181 createTool( GEOMOp::OpSection, boolTbId );
1183 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1184 createTool( GEOMOp::OpPrism, genTbId );
1185 createTool( GEOMOp::OpRevolution, genTbId );
1186 createTool( GEOMOp::OpFilling, genTbId );
1187 createTool( GEOMOp::OpPipe, genTbId );
1188 #if OCC_VERSION_LARGE > 0x06050300
1189 createTool( GEOMOp::OpPipePath, genTbId );
1192 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1193 createTool( GEOMOp::OpTranslate, transTbId );
1194 createTool( GEOMOp::OpRotate, transTbId );
1195 createTool( GEOMOp::OpChangeLoc, transTbId );
1196 createTool( GEOMOp::OpMirror, transTbId );
1197 createTool( GEOMOp::OpScale, transTbId );
1198 createTool( GEOMOp::OpOffset, transTbId );
1199 createTool( GEOMOp::OpProjection, transTbId );
1200 createTool( separator(), transTbId );
1201 createTool( GEOMOp::OpMultiTranslate, transTbId );
1202 createTool( GEOMOp::OpMultiRotate, transTbId );
1204 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1205 createTool( GEOMOp::OpExplode, operTbId );
1206 createTool( GEOMOp::OpPartition, operTbId );
1207 createTool( GEOMOp::OpArchimede, operTbId );
1208 createTool( GEOMOp::OpShapesOnShape, operTbId );
1209 createTool( GEOMOp::OpSharedShapes, operTbId );
1211 int featTbId = createTool( tr( "TOOL_FEATURES" ) );
1212 createTool( GEOMOp::OpFillet1d, featTbId );
1213 createTool( GEOMOp::OpFillet2d, featTbId );
1214 createTool( GEOMOp::OpFillet3d, featTbId );
1215 createTool( GEOMOp::OpChamfer, featTbId );
1216 createTool( GEOMOp::OpExtrudedBoss, featTbId );
1217 createTool( GEOMOp::OpExtrudedCut, featTbId );
1219 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1220 createTool( GEOMOp::OpEdge, buildTbId );
1221 createTool( GEOMOp::OpWire, buildTbId );
1222 createTool( GEOMOp::OpFace, buildTbId );
1223 createTool( GEOMOp::OpShell, buildTbId );
1224 createTool( GEOMOp::OpSolid, buildTbId );
1225 createTool( GEOMOp::OpCompound, buildTbId );
1227 int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1228 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1229 createTool( GEOMOp::OpProperties, measureTbId );
1230 createTool( GEOMOp::OpCenterMass, measureTbId );
1231 createTool( GEOMOp::OpInertia, measureTbId );
1232 createTool( GEOMOp::OpNormale, measureTbId );
1233 createTool( separator(), measureTbId );
1234 createTool( GEOMOp::OpBoundingBox, measureTbId );
1235 createTool( GEOMOp::OpMinDistance, measureTbId );
1236 createTool( GEOMOp::OpAngle, measureTbId );
1237 createTool( GEOMOp::OpTolerance , measureTbId );
1238 createTool( separator(), measureTbId );
1239 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1240 createTool( GEOMOp::OpFreeFaces, measureTbId );
1241 createTool( separator(), measureTbId );
1242 createTool( GEOMOp::OpWhatIs, measureTbId );
1243 createTool( GEOMOp::OpCheckShape, measureTbId );
1244 createTool( GEOMOp::OpCheckCompound, measureTbId );
1245 createTool( GEOMOp::OpGetNonBlocks, measureTbId );
1246 createTool( GEOMOp::OpCheckSelfInters, measureTbId );
1248 int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
1249 createTool( GEOMOp::OpPictureImport, picturesTbId );
1251 createTool( GEOMOp::OpFeatureDetect, picturesTbId );
1254 int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1255 createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1256 //@@ 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 @@//
1258 // ---- create popup menus --------------------------
1260 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1261 QString clientOCC = "(client='OCCViewer')";
1262 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1263 QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1265 QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1266 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1267 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1268 QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1270 QString autoColorPrefix =
1271 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1273 QtxPopupMgr* mgr = popupMgr();
1275 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1276 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder'} and selcount>0"), QtxPopupMgr::VisibleRule );
1277 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1278 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1279 mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1280 mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1282 mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal shild items
1283 mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1284 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1285 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1286 mgr->insert( separator(), -1, -1 ); // -----------
1288 #if OCC_VERSION_LARGE > 0x06050200
1289 //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1290 QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and isFolder=false and (selcount>0) and isOCC=true";
1291 mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1292 mgr->setRule(action(GEOMOp::OpBringToFront), bringRule, QtxPopupMgr::VisibleRule );
1293 mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1294 mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1295 mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule );
1297 mgr->insert( separator(), -1, -1 ); // -----------
1298 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1299 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1300 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1301 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1302 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1303 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1304 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1305 mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1306 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1307 mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1308 mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1309 mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1310 mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1311 mgr->insert( separator(), dispmodeId, -1 );
1312 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1313 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1314 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1315 mgr->insert( separator(), -1, -1 ); // -----------
1317 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1318 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1319 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1320 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1321 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1322 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1323 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1324 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1325 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1326 //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1327 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1329 // material properties
1330 mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 );
1331 mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1334 mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 );
1335 mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1337 int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1338 mgr->insert( action( GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1339 mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1341 mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1342 mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1344 mgr->insert( separator(), -1, -1 ); // -----------
1345 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1346 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1347 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1348 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1349 mgr->insert( separator(), -1, -1 ); // -----------
1351 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1352 onlyComponent = "((type='Component') and selcount=1)",
1353 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1354 types = "'Shape' 'Group'";
1356 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1357 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1359 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1360 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1362 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1363 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1365 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1367 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1368 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1369 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1370 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1371 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1372 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1373 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1374 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1375 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1376 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1377 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1378 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1379 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1380 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1381 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1382 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1383 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1384 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1385 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1386 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1387 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1388 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1389 mgr->insert( separator(), selectonlyId, -1);
1390 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1391 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1392 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1393 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1394 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1395 mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1396 mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1398 mgr->insert( separator(), -1, -1 ); // -----------
1399 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1400 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1402 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1403 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1405 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1406 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1408 mgr->insert( separator(), -1, -1 ); // -----------
1409 mgr->insert( action( GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
1410 mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
1412 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1414 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1416 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1417 QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1418 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1422 //=======================================================================
1423 // function : GeometryGUI::activateModule()
1424 // purpose : Called when GEOM module is activated
1425 //=======================================================================
1426 bool GeometryGUI::activateModule( SUIT_Study* study )
1428 if ( CORBA::is_nil( myComponentGeom ) )
1431 bool res = SalomeApp_Module::activateModule( study );
1435 setMenuShown( true );
1436 setToolShown( true );
1438 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1439 PyGILState_STATE gstate = PyGILState_Ensure();
1440 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1441 if (pluginsmanager == NULL)
1445 PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1446 tr("MEN_NEW_ENTITY").toStdString().c_str(),
1447 tr("GEOM_PLUGINS_OTHER").toStdString().c_str());
1452 PyGILState_Release(gstate);
1453 // end of GEOM plugins loading
1455 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1456 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1458 // Reset actions accelerator keys
1459 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1460 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1461 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1463 GUIMap::Iterator it;
1464 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1465 it.value()->activate( application()->desktop() );
1467 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1469 connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1470 if ( !myCreationInfoWdg )
1471 myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1472 getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1473 getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1475 SUIT_ViewManager* vm;
1476 ViewManagerList OCCViewManagers, VTKViewManagers;
1478 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1479 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1480 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1481 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1483 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1484 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1485 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1486 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1489 SALOME_ListIO selected;
1490 sm->selectedObjects( selected );
1491 sm->clearSelected();
1493 // disable OCC selectors
1494 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1495 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1496 while ( itOCCSel.hasNext() )
1497 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1498 sr->setEnabled(true);
1500 // disable VTK selectors
1501 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1502 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1503 while ( itVTKSel.hasNext() )
1504 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1505 sr->setEnabled(true);
1507 sm->setSelectedObjects( selected, true ); //NPAL 19674
1509 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1511 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1513 // 0020836 (Basic vectors and origin)
1514 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1515 if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1516 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1518 _PTR(Study) studyDS = appStudy->studyDS();
1520 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1521 if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1522 createOriginAndBaseVectors();
1530 //=======================================================================
1531 // function : GeometryGUI::deactivateModule()
1532 // purpose : Called when GEOM module is deactivated
1533 //=======================================================================
1534 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1536 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1538 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1540 setMenuShown( false );
1541 setToolShown( false );
1543 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1544 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1546 LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
1548 disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1549 getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
1550 myCreationInfoWdg = 0;
1552 EmitSignalCloseAllDialogs();
1554 GUIMap::Iterator it;
1555 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1556 it.value()->deactivate();
1558 // Unset actions accelerator keys
1559 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1560 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1561 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1563 qDeleteAll(myOCCSelectors);
1564 myOCCSelectors.clear();
1565 selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
1567 qDeleteAll(myVTKSelectors);
1568 myVTKSelectors.clear();
1569 selMrg->setEnabled( true, SVTK_Viewer::Type() );
1571 return SalomeApp_Module::deactivateModule( study );
1574 //=======================================================================
1575 // function : onWindowActivated()
1576 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1577 //=======================================================================
1578 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1583 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1584 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1586 // disable non-OCC viewframe menu commands
1587 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1588 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1589 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1590 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1591 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1592 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1593 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1595 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1596 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1598 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1601 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1603 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1604 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1605 if ( myCreationInfoWdg )
1606 mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1609 void GeometryGUI::viewManagers( QStringList& lst ) const
1611 lst.append( OCCViewer_Viewer::Type() );
1614 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1616 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1618 qDebug( "connect" );
1619 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1620 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1621 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1622 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1623 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1624 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1625 connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
1626 this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
1628 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1629 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1631 // disable OCC selectors
1632 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1633 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1634 while ( itOCCSel.hasNext() )
1635 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1636 sr->setEnabled(true);
1638 else if ( vm->getType() == SVTK_Viewer::Type() )
1640 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1641 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1643 // disable VTK selectors
1644 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1645 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1646 while ( itVTKSel.hasNext() )
1647 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1648 sr->setEnabled(true);
1652 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1654 SUIT_ViewModel* viewer = vm->getViewModel();
1655 if ( vm->getType() == OCCViewer_Viewer::Type() )
1657 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1658 while ( itOCCSel.hasNext() )
1659 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1660 if ( sr->viewer() == viewer )
1662 /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1666 if ( vm->getType() == SVTK_Viewer::Type() )
1668 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1669 while ( itVTKSel.hasNext() )
1670 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1671 if ( sr->viewer() == viewer )
1673 /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1679 //================================================================================
1681 * \brief Slot called when selection changed. Shows creation info of a selected object
1683 //================================================================================
1685 void GeometryGUI::updateCreationInfo()
1687 myCreationInfoWdg->clear();
1689 // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
1690 // if ( !myCreationInfoWdg->isVisible() )
1693 // look for a sole selected GEOM_Object
1694 GEOM::GEOM_Object_var geomObj;
1696 SALOME_ListIO selected;
1697 getApp()->selectionMgr()->selectedObjects( selected );
1699 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
1700 SALOME_ListIteratorOfListIO selIt( selected );
1701 for ( ; selIt.More(); selIt.Next() )
1703 Handle(SALOME_InteractiveObject) io = selIt.Value();
1704 if ( !io->hasEntry() ) continue;
1705 _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
1706 if ( !sobj ) continue;
1707 CORBA::Object_var obj = GeometryGUI::ClientSObjectToObject( sobj );
1708 GEOM::GEOM_Object_var gobj = GEOM::GEOM_Object::_narrow( obj );
1709 if ( !gobj->_is_nil() )
1711 if ( !geomObj->_is_nil() )
1712 return; // several GEOM objects selected
1716 if ( geomObj->_is_nil() ) return;
1718 // pass creation info of geomObj to myCreationInfoWdg
1721 QString operationName;
1722 myCreationInfoWdg->setOperation( icon, operationName );
1727 GEOM::CreationInformation_var info = geomObj->GetCreationInformation();
1730 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1731 QString name = info->operationName.in();
1732 if ( !name.isEmpty() )
1734 icon = resMgr->loadPixmap( "GEOM", tr( ("ICO_"+name).toLatin1().constData() ), false );
1735 operationName = tr( ("MEN_"+name).toLatin1().constData() );
1736 if ( operationName.startsWith( "MEN_" ))
1737 operationName = name; // no translation
1738 myCreationInfoWdg->setOperation( icon, operationName );
1740 for ( size_t i = 0; i < info->params.length(); ++i )
1741 myCreationInfoWdg->addParam( info->params[i].name.in(),
1742 info->params[i].value.in() );
1751 QString GeometryGUI::engineIOR() const
1753 if ( !CORBA::is_nil( GetGeomGen() ) )
1754 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1758 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1759 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
1761 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture
1763 (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
1765 theWidth = theHeight = 0;
1767 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1768 Handle(TColStd_HArray1OfByte) aTexture;
1770 Handle(Graphic3d_HArray1OfBytes) aTexture;
1774 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1775 aTexture = aTextureMap[ theId ];
1776 if ( aTexture.IsNull() ) {
1777 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1778 if ( !aInsOp->_is_nil() ) {
1779 CORBA::Long aWidth, aHeight;
1780 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1781 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1783 theHeight = aHeight;
1785 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1786 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
1788 aTexture = new Graphic3d_HArray1OfBytes (1, aStream->length());
1791 for (int i = 0; i < aStream->length(); i++)
1792 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1793 aTextureMap[ theId ] = aTexture;
1801 LightApp_Selection* GeometryGUI::createSelection() const
1803 return new GEOMGUI_Selection();
1806 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1808 SalomeApp_Module::contextMenuPopup( client, menu, title );
1810 getApp()->selectionMgr()->selectedObjects( lst );
1812 //Add submenu for predefined materials
1813 bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
1814 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
1815 QtxPopupMgr* mgr = popupMgr();
1816 //get parrent for submenu
1817 QAction* act = mgr->action( mgr->actionId( action( GEOMOp::OpMaterialProperties ) ) );
1819 QMenu* oldMenu = act->menu() ;
1824 QMenu* matMenu = new QMenu();
1825 QSignalMapper* signalMapper = new QSignalMapper( matMenu );
1827 //Get current material model for the object
1829 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
1830 if ( anApp && anApp->activeViewManager() ) {
1831 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
1833 v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
1836 QString curModel = "";
1837 if ( v.canConvert<QString>() ) curModel = v.toString();
1838 // get list of all predefined materials
1839 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
1841 foreach ( QString material, materials )
1843 QAction* menAct = matMenu->addAction( material );
1844 connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
1845 signalMapper->setMapping( menAct, material );
1846 menAct->setCheckable( true );
1847 // Set checked if this material is current
1848 Material_Model aModel;
1849 aModel.fromResources( material );
1850 if ( !found && aModel.toProperties() == curModel ) {
1851 menAct->setChecked( true );
1855 matMenu->insertAction( matMenu->addSeparator(), action( GEOMOp::OpPredefMaterCustom ) );
1856 matMenu->insertSeparator( action( GEOMOp::OpPredefMaterCustom ) );
1857 connect( signalMapper, SIGNAL( mapped( const QString & ) ),
1858 this, SLOT( OnSetMaterial( const QString & ) ) );
1859 act->setMenu( matMenu );
1863 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
1864 Handle(SALOME_InteractiveObject) io = lst.First();
1865 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1866 _PTR(Study) study = appStudy->studyDS();
1867 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
1869 QString aName = QString( obj->GetName().c_str() );
1870 aName.remove( QRegExp("\\s+$") );
1876 void GeometryGUI::OnSetMaterial(const QString& theName)
1878 OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
1882 void GeometryGUI::createPreferences()
1884 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1886 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1887 setPreferenceProperty( genGroup, "columns", 2 );
1889 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1890 LightApp_Preferences::Selector,
1891 "Geometry", "display_mode" );
1893 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1894 LightApp_Preferences::Color, "Geometry", "shading_color" );
1896 addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
1897 LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
1899 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1900 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1902 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1903 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1905 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1906 LightApp_Preferences::Color, "Geometry", "line_color" );
1908 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1909 LightApp_Preferences::Color, "Geometry", "point_color" );
1911 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1912 LightApp_Preferences::Color, "Geometry", "isos_color" );
1914 addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
1915 LightApp_Preferences::Color, "Geometry", "toplevel_color" );
1917 int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
1918 LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
1920 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1921 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1923 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1924 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1926 addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
1927 LightApp_Preferences::Bool, "Geometry", "predef_materials" );
1929 int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
1930 LightApp_Preferences::Selector,
1931 "Geometry", "material" );
1933 addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
1934 LightApp_Preferences::Color, "Geometry", "editgroup_color" );
1940 wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
1941 LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
1943 wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
1944 LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
1946 wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
1947 LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
1949 wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
1950 LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
1952 for (int i = 0; i < nb; i++) {
1953 setPreferenceProperty( wd[i], "min", 1 );
1954 setPreferenceProperty( wd[i], "max", 5 );
1957 int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
1958 setPreferenceProperty( isoGroup, "columns", 2 );
1959 int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
1960 LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
1961 setPreferenceProperty( isoU, "min", 0 );
1962 setPreferenceProperty( isoU, "max", 100000 );
1963 int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
1964 LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
1965 setPreferenceProperty( isoV, "min", 0 );
1966 setPreferenceProperty( isoV, "max", 100000 );
1968 // Quantities with individual precision settings
1969 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1970 setPreferenceProperty( precGroup, "columns", 2 );
1972 const int nbQuantities = 8;
1973 int prec[nbQuantities], ii = 0;
1974 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1975 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1976 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1977 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1978 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1979 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1980 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1981 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1982 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1983 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1984 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1985 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1986 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1987 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1988 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1989 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1991 // Set property for precision value for spinboxes
1992 for ( ii = 0; ii < nbQuantities; ii++ ){
1993 setPreferenceProperty( prec[ii], "min", -14 );
1994 setPreferenceProperty( prec[ii], "max", 14 );
1995 setPreferenceProperty( prec[ii], "precision", 2 );
1998 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1999 setPreferenceProperty( VertexGroup, "columns", 2 );
2001 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2002 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2004 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2005 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2007 // Set property for default display mode
2008 QStringList aModesList;
2009 aModesList.append( tr("MEN_WIREFRAME") );
2010 aModesList.append( tr("MEN_SHADING") );
2011 aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2013 QList<QVariant> anIndexesList;
2014 anIndexesList.append(0);
2015 anIndexesList.append(1);
2016 anIndexesList.append(2);
2018 setPreferenceProperty( dispmode, "strings", aModesList );
2019 setPreferenceProperty( dispmode, "indexes", anIndexesList );
2021 // Set property for top level display mode
2022 QStringList aTopModesList;
2023 aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2024 aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2025 aTopModesList.append( tr("MEN_WIREFRAME") );
2026 aTopModesList.append( tr("MEN_SHADING") );
2027 aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2029 QList<QVariant> aTopIndexesList;
2030 aTopIndexesList.append(0);
2031 aTopIndexesList.append(1);
2032 aTopIndexesList.append(2);
2033 aTopIndexesList.append(3);
2034 aTopIndexesList.append(4);
2036 setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2037 setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2039 // Set property for step value for spinboxes
2040 setPreferenceProperty( step, "min", 1 );
2041 setPreferenceProperty( step, "max", 10000 );
2042 setPreferenceProperty( step, "precision", 3 );
2044 // Set property for deflection value for spinboxes
2045 setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2046 setPreferenceProperty( defl, "max", 1.0 );
2047 setPreferenceProperty( defl, "step", 1.0e-04 );
2048 setPreferenceProperty( defl, "precision", 6 );
2050 // Set property for default material
2051 setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2053 // Set property vertex marker type
2054 QList<QVariant> aMarkerTypeIndicesList;
2055 QList<QVariant> aMarkerTypeIconsList;
2057 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2058 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2059 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2060 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2061 aMarkerTypeIndicesList << (i-1);
2062 aMarkerTypeIconsList << pixmap;
2065 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2066 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
2068 // Set property for vertex marker scale
2069 QList<QVariant> aMarkerScaleIndicesList;
2070 QStringList aMarkerScaleValuesList;
2072 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2073 aMarkerScaleIndicesList << iii;
2074 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2077 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2078 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2080 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2081 setPreferenceProperty( originGroup, "columns", 2 );
2083 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2084 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2085 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2086 setPreferenceProperty( baseVectorsLength, "max", 1000 );
2088 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2089 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2091 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2092 setPreferenceProperty( operationsGroup, "columns", 2 );
2094 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2095 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2098 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2100 if (section == "Geometry") {
2101 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2102 if (param == QString("SettingsGeomStep")) {
2103 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2104 EmitSignalDefaultStepValueChanged(spin_step);
2106 else if (param == QString("toplevel_color")) {
2107 QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2108 GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2110 else if (param == QString("toplevel_dm")) {
2111 GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2116 LightApp_Displayer* GeometryGUI::displayer()
2119 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
2123 void GeometryGUI::setLocalSelectionMode(const int mode)
2125 myLocalSelectionMode = mode;
2128 int GeometryGUI::getLocalSelectionMode() const
2130 return myLocalSelectionMode;
2133 const char gSeparator = '_'; // character used to separate parameter names
2134 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2137 * \brief Store visual parameters
2139 * This method is called just before the study document is saved.
2140 * Store visual parameters in AttributeParameter attribute(s)
2142 void GeometryGUI::storeVisualParameters (int savePoint)
2144 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2145 if ( !appStudy || !appStudy->studyDS() )
2147 _PTR(Study) studyDS = appStudy->studyDS();
2149 // componentName is used for encoding of entries when storing them in IParameters
2150 std::string componentName = myComponentGeom->ComponentDataType();
2151 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2152 //if (!aSComponent) return;
2155 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2156 componentName.c_str(),
2158 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2160 QList<SUIT_ViewManager*> lst;
2161 QList<SUIT_ViewManager*>::Iterator it;
2163 // main cycle to store parameters of displayed objects
2165 getApp()->viewManagers(lst);
2166 for (it = lst.begin(); it != lst.end(); it++) {
2167 SUIT_ViewManager* vman = *it;
2168 QString vType = vman->getType();
2169 int aMgrId = vman->getGlobalId();
2170 // saving VTK actors properties
2171 QVector<SUIT_ViewWindow*> views = vman->getViews();
2172 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
2173 const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
2174 ObjMap::ConstIterator o_it = anObjects.begin();
2175 for (; o_it != anObjects.end(); o_it++) {
2176 const PropMap aProps = o_it.value();
2178 //Check that object exists in the study
2179 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
2180 if ( !obj || !(aProps.count() > 0))
2182 // entry is "encoded" = it does NOT contain component adress, since it is a
2183 // subject to change on next component loading
2185 std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
2187 _PTR(GenericAttribute) anAttr;
2188 if (!obj->FindAttribute(anAttr, "AttributeIOR"))
2191 QString param, occParam = vType;
2192 occParam += GEOM::sectionSeparator();
2193 occParam += QString::number(aMgrId);
2194 occParam += GEOM::sectionSeparator();
2196 if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
2197 param = occParam + GEOM::propertyName( GEOM::Visibility );
2198 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
2201 if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
2202 param = occParam + GEOM::propertyName( GEOM::DisplayMode );
2203 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
2206 if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
2207 QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
2209 val << QString::number(c.redF());
2210 val << QString::number(c.greenF());
2211 val << QString::number(c.blueF());
2212 param = occParam + GEOM::propertyName( GEOM::Color );
2213 ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
2216 if (vType == SVTK_Viewer::Type()) {
2217 if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
2218 param = occParam + GEOM::propertyName( GEOM::Opacity );
2219 ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
2221 } else if (vType == SOCC_Viewer::Type()) {
2222 if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
2223 param = occParam + GEOM::propertyName( GEOM::Transparency );
2224 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
2227 if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
2228 param = occParam + GEOM::propertyName( GEOM::TopLevel );
2229 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
2233 if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
2234 param = occParam + GEOM::propertyName( GEOM::NbIsos );
2235 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
2238 if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
2239 param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
2240 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
2243 if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
2244 param = occParam + GEOM::propertyName( GEOM::Deflection );
2245 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
2248 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
2249 if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
2250 param = occParam + GEOM::propertyName( GEOM::PointMarker );
2251 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
2254 if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
2255 param = occParam + GEOM::propertyName( GEOM::Material );
2256 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
2259 if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
2260 param = occParam + GEOM::propertyName( GEOM::LineWidth );
2261 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
2264 if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
2265 param = occParam + GEOM::propertyName( GEOM::IsosWidth );
2266 ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
2268 } // object iterator
2270 } // for (viewManagers)
2274 * \brief Restore visual parameters
2276 * This method is called after the study document is opened.
2277 * Restore visual parameters from AttributeParameter attribute(s)
2279 void GeometryGUI::restoreVisualParameters (int savePoint)
2281 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2282 if (!appStudy || !appStudy->studyDS())
2284 _PTR(Study) studyDS = appStudy->studyDS();
2286 // componentName is used for encoding of entries when storing them in IParameters
2287 std::string componentName = myComponentGeom->ComponentDataType();
2288 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2289 //if (!aSComponent) return;
2292 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2293 componentName.c_str(),
2295 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2297 std::vector<std::string> entries = ip->getEntries();
2299 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
2301 // entry is a normal entry - it should be "decoded" (setting base adress of component)
2302 QString entry (ip->decodeEntry(*entIt).c_str());
2304 // Check that the entry corresponds to a real object in the Study
2305 // as the object may be deleted or modified after the visual state is saved.
2306 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
2307 if (!so) continue; //Skip the not existent entry
2309 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
2310 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
2312 std::vector<std::string>::iterator namesIt = paramNames.begin();
2313 std::vector<std::string>::iterator valuesIt = paramValues.begin();
2315 // actors are stored in a map after displaying of them for
2316 // quicker access in the future: map < viewID to actor >
2317 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
2318 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
2320 QString viewerTypStr;
2321 QString viewIndexStr;
2323 QVector<PropMap> aListOfMap;
2325 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
2327 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
2328 // '_' is used as separator and should not be used in viewer type or parameter names.
2329 QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
2330 if (lst.size() != 3)
2333 viewerTypStr = lst[0];
2334 viewIndexStr = lst[1];
2335 QString paramNameStr = lst[2];
2338 viewIndex = viewIndexStr.toUInt(&ok);
2339 if (!ok) // bad conversion of view index to integer
2342 if ((viewIndex + 1) > aListOfMap.count()) {
2343 aListOfMap.resize(viewIndex + 1);
2346 QString val((*valuesIt).c_str());
2347 if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
2348 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
2349 } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
2350 aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
2351 } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
2352 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
2353 } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
2354 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
2355 } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
2356 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
2357 } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
2358 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
2359 } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
2360 QStringList rgb = val.split(GEOM::subSectionSeparator());
2361 if (rgb.count() == 3) {
2362 QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
2363 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
2365 } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
2366 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
2367 } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
2368 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
2369 } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
2370 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
2371 } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
2372 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
2373 } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
2374 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
2375 } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
2376 aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
2378 } // for names/parameters iterator
2380 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
2382 for (int index = 0; index < aListOfMap.count(); index++) {
2384 appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
2386 //Get Visibility property of the current PropMap
2387 if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
2388 SUIT_ViewManager* vman = lst.at(index);
2389 SUIT_ViewModel* vmodel = vman->getViewModel();
2390 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
2393 } // for entries iterator
2395 // update all VTK and OCC views
2396 QList<SUIT_ViewManager*> lst;
2397 getApp()->viewManagers(lst);
2398 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
2399 SUIT_ViewModel* vmodel = (*it)->getViewModel();
2402 if (vmodel->getType() == SVTK_Viewer::Type()) {
2403 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
2404 vtkView->getRenderer()->ResetCameraClippingRange();
2407 else if (vmodel->getType() == SOCC_Viewer::Type()) {
2408 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
2409 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
2416 void GeometryGUI::onViewAboutToShow()
2418 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
2419 QAction* a = action( GEOMOp::OpSwitchVectors );
2421 a->setEnabled(true);
2422 bool vmode = window->property("VectorsMode").toBool();
2423 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
2425 a->setText ( tr("MEN_VECTOR_MODE_ON") );
2426 a->setEnabled(false);
2431 \brief Return action by id
2432 \param id identifier of the action
2435 QAction* GeometryGUI::getAction(const int id) {
2440 \brief GEOM module message handler
2442 This method can be re-implemented in the subclasses.
2443 This is a GEOM module message handler.
2445 \param msg the message received.
2447 void GeometryGUI::message(const QString& msg)
2450 QStringList data = msg.split("/");
2451 const int nbStrings = data.count();
2453 if (nbStrings > 0) {
2454 if (data[0] == "modified") {
2456 QString anIOR = nbStrings > 1 ? data[1] : QString();
2458 if ( anIOR.isEmpty() ) {
2462 // Get the geom object.
2463 GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
2465 // Clear the shape buffer
2466 GeometryGUI::ClearShapeBuffer (anObj);
2472 \brief Clears the shape buffer.
2474 This is a static method. It clears the shape buffer.
2476 \param theObj the object
2478 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
2480 if ( CORBA::is_nil( theObj ) )
2483 CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
2484 TCollection_AsciiString asciiIOR( (char *)IOR.in() );
2485 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
2487 SALOMEDSClient_StudyManager *aManager = SalomeApp_Application::studyMgr();
2492 _PTR(Study) aStudy = aManager->GetStudyByID(theObj->GetStudyID());
2497 _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
2501 _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
2502 for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
2503 _PTR(GenericAttribute) anAttr;
2504 if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
2505 _PTR(AttributeIOR) anIOR ( anAttr );
2506 TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
2507 GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
2513 \brief Returns the object from IOR.
2515 This is a static method. It returns the object from its IOR.
2517 \param IOR object IOR
2518 \return GEOM object.
2520 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
2522 GEOM::GEOM_Object_var geomObj;
2523 if ( !IOR.isEmpty() ) {
2524 CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
2525 ( IOR.toLatin1().constData() );
2526 if ( !CORBA::is_nil( corbaObj ) )
2527 geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2529 return geomObj._retn();
2533 \brief Returns IOR of the object.
2535 This is a static method. It returns the object's IOR.
2537 \param object the GEOM object.
2538 \return object's IOR.
2540 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
2543 if ( !CORBA::is_nil( object ) ) {
2544 CORBA::String_var anIOR =
2545 SalomeApp_Application::orb()->object_to_string( object );
2552 \brief Check if this object is can't be renamed in place
2554 This method can be re-implemented in the subclasses.
2555 Return true in case if object isn't reference or component (module root).
2557 \param entry column id
2558 \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
2560 bool GeometryGUI::renameAllowed( const QString& entry) const {
2562 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2563 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2564 SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
2566 return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
2570 Rename object by entry.
2571 \param entry entry of the object
2572 \param name new name of the object
2573 \brief Return \c true if rename operation finished successfully, \c false otherwise.
2575 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
2577 bool result = false;
2579 SalomeApp_Application* app =
2580 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
2581 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2586 _PTR(Study) aStudy = appStudy->studyDS();
2591 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
2593 SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
2597 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
2598 _PTR(GenericAttribute) anAttr;
2600 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
2601 _PTR(AttributeName) aName (anAttr);
2603 aName->SetValue( name.toLatin1().data() ); // rename the SObject
2604 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
2605 if (!CORBA::is_nil(anObj)) {
2606 anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object
2614 void GeometryGUI::updateMaterials()
2616 LightApp_Preferences* pref = preferences();
2618 QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2619 QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
2620 if ( !materials.contains( currentMaterial ) )
2621 // user material set as default in the preferences, might be removed
2622 SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
2624 QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
2626 setPreferenceProperty( prefItem->id(),
2627 "strings", materials );
2628 prefItem->retrieve();
2634 \brief Check if the module allows "drag" operation of its objects.
2636 Overloaded from LightApp_Module class.
2638 This function is a part of the general drag-n-drop mechanism.
2639 The goal of this function is to check data object passed as a parameter
2640 and decide if it can be dragged or no.
2642 \param what data object being tested for drag operation
2643 \return \c true if module allows dragging of the specified object
2644 \sa isDropAccepted(), dropObjects()
2646 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
2648 // we allow dragging object under root and object from folder
2649 int aLevel = what->level();
2650 bool anObjectInFolder = false;
2652 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
2654 _PTR(SObject) aSO = dataObj->object();
2656 _PTR(GenericAttribute) anAttr;
2657 _PTR(SObject) aFatherSO = aSO->GetStudy()->GetUseCaseBuilder()->GetFather( aSO );
2658 if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
2659 _PTR(AttributeLocalID) aLocalID( anAttr );
2660 anObjectInFolder = aLocalID->Value() == 999;
2665 return aLevel == 2 || anObjectInFolder;
2669 \brief Check if the module allows "drop" operation on the given object.
2671 Overloaded from LightApp_Module class.
2673 This function is a part of the general drag-n-drop mechanism.
2674 The goal of this function is to check data object passed as a parameter
2675 and decide if it can be used as a target for the "drop" operation.
2676 The processing of the drop operation itself is done in the dropObjects() function.
2678 \param where target data object
2679 \return \c true if module supports dropping on the \a where data object
2680 \sa isDraggable(), dropObjects()
2682 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
2684 // we allow dropping into folder and top-level GEOM object
2685 int aLevel = where->level();
2686 bool isFolder = false;
2688 const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
2690 _PTR(SObject) aSO = dataObj->object();
2692 _PTR(GenericAttribute) anAttr;
2693 if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
2694 _PTR(AttributeLocalID) aLocalID( anAttr );
2695 isFolder = aLocalID->Value() == 999;
2700 return aLevel == 1 || isFolder;
2704 \brief Complete drag-n-drop operation.
2706 Overloaded from LightApp_Module class.
2708 This function is a part of the general drag-n-drop mechanism.
2709 Its goal is to handle dropping of the objects being dragged according
2710 to the chosen operation (move). The dropping is performed in the
2711 context of the parent data object \a where and the \a row (position in the
2712 children index) at which the data should be dropped. If \a row is equal to -1,
2713 this means that objects are added to the end of the children list.
2715 \param what objects being dropped
2716 \param where target data object
2717 \param row child index at which the drop operation is performed
2718 \param action drag-n-drop operation (Qt::DropAction) - move
2720 \sa isDraggable(), isDropAccepted()
2722 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
2723 const int row, Qt::DropAction action )
2725 if (action != Qt::CopyAction && action != Qt::MoveAction)
2726 return; // unsupported action
2728 // get parent object
2729 SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
2730 if ( !dataObj ) return; // wrong parent
2731 _PTR(SObject) parentObj = dataObj->object();
2733 // Find the current Study and StudyBuilder
2734 _PTR(Study) aStudy = parentObj->GetStudy();
2735 _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
2736 // collect all parents of the target node
2737 QStringList parentIDs;
2738 _PTR(SObject) parent = parentObj;
2739 while( !parent->IsNull() ) {
2740 parentIDs << parent->GetID().c_str();
2741 parent = aUseCaseBuilder->GetFather(parent);
2744 // collect objects being dropped
2745 GEOM::object_list_var objects = new GEOM::object_list();
2746 objects->length( what.count() );
2748 for ( int i = 0; i < what.count(); i++ ) {
2749 dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
2750 if ( !dataObj ) continue; // skip wrong objects
2751 _PTR(SObject) sobj = dataObj->object();
2752 // check that dropped object is not a parent of target object
2753 if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
2754 return; // it's not allowed to move node into it's child
2756 objects[i] = _CAST(SObject, sobj)->GetSObject();
2759 objects->length( count );
2761 // call engine function
2762 GetGeomGen()->Move( objects.in(), // what
2763 _CAST(SObject, parentObj)->GetSObject(), // where
2766 // update Object browser
2767 getApp()->updateObjectBrowser( false );