1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : GeometryGUI.cxx
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #include "GeometryGUI.h"
28 #include "GeometryGUI_Operations.h"
29 #include "GEOMGUI_OCCSelector.h"
30 #include "GEOMGUI_Selection.h"
31 #include "GEOM_Displayer.h"
32 #include "GEOM_AISShape.hxx"
34 #include "GEOM_Actor.h"
36 #include <SUIT_Desktop.h>
37 #include <SUIT_MessageBox.h>
38 #include <SUIT_ResourceMgr.h>
39 #include <SUIT_Session.h>
40 #include <SUIT_ViewManager.h>
42 #include <OCCViewer_ViewWindow.h>
43 #include <OCCViewer_ViewPort3d.h>
44 #include <OCCViewer_ViewModel.h>
45 #include <OCCViewer_ViewManager.h>
47 #include <SOCC_ViewModel.h>
48 #include <SOCC_ViewWindow.h>
50 #include <SVTK_ViewWindow.h>
51 #include <SVTK_RenderWindowInteractor.h>
52 #include <SVTK_InteractorStyle.h>
53 #include <SVTK_ViewModel.h>
55 #include <SalomeApp_Application.h>
56 #include <SalomeApp_DataObject.h>
57 #include <SalomeApp_Study.h>
59 #include <LightApp_SelectionMgr.h>
60 #include <LightApp_VTKSelector.h>
61 #include <LightApp_DataObject.h>
62 #include <LightApp_Preferences.h>
64 #include <SALOME_LifeCycleCORBA.hxx>
65 #include <SALOME_ListIO.hxx>
66 #include <SALOME_ListIteratorOfListIO.hxx>
68 #include <SALOMEDSClient_ClientFactory.hxx>
69 #include <SALOMEDSClient_IParameters.hxx>
71 #include <CASCatch_OCCTVersion.hxx>
81 #include <AIS_Drawer.hxx>
82 #include <AIS_ListOfInteractive.hxx>
83 #include <AIS_ListIteratorOfListOfInteractive.hxx>
84 #include <Prs3d_Drawer.hxx>
85 #include <Prs3d_IsoAspect.hxx>
86 #include <Aspect_TypeOfMarker.hxx>
87 #include <OSD_SharedLibrary.hxx>
88 #include <NCollection_DataMap.hxx>
90 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
91 #include <TColStd_HArray1OfByte.hxx>
93 #include <Graphic3d_HArray1OfBytes.hxx>
96 #include <utilities.h>
98 #include <vtkCamera.h>
99 #include <vtkRenderer.h>
101 #include "GEOMImpl_Types.hxx"
104 Standard_EXPORT CAM_Module* createModule() {
105 return new GeometryGUI();
109 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
111 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
113 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
115 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
116 if (CORBA::is_nil(myComponentGeom))
118 return GeometryGUI::myComponentGeom;
121 bool GeometryGUI::InitGeomGen()
124 if( CORBA::is_nil( myComponentGeom ) ) return false;
128 //=======================================================================
129 // function : ClientSObjectToObject
131 //=======================================================================
132 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
134 _PTR(GenericAttribute) anAttr;
135 CORBA::Object_var anObj;
137 std::string aValue = theSObject->GetIOR();
138 if (strcmp(aValue.c_str(), "") != 0) {
139 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
140 anObj = anORB->string_to_object(aValue.c_str());
143 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
145 return anObj._retn();
148 //=======================================================================
149 // function : ClientStudyToStudy
151 //=======================================================================
152 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
154 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
155 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
156 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
157 int aStudyID = theStudy->StudyId();
158 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
159 return aDSStudy._retn();
162 void GeometryGUI::Modified( bool theIsUpdateActions )
164 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
165 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
166 appStudy->Modified();
167 if( theIsUpdateActions )
168 app->updateActions();
173 //=======================================================================
174 // function : GeometryGUI::GeometryGUI()
175 // purpose : Constructor
176 //=======================================================================
177 GeometryGUI::GeometryGUI() :
178 SalomeApp_Module( "GEOM" ),
179 LightApp_Module( "GEOM" )
181 if ( CORBA::is_nil( myComponentGeom ) )
183 Engines::EngineComponent_var comp =
184 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
185 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
188 myActiveDialogBox = 0;
190 gp_Pnt origin = gp_Pnt(0., 0., 0.);
191 gp_Dir direction = gp_Dir(0., 0., 1.);
192 myWorkingPlane = gp_Ax3(origin, direction);
195 myLocalSelectionMode = GEOM_ALLOBJECTS;
198 //=======================================================================
199 // function : GeometryGUI::~GeometryGUI()
200 // purpose : Destructor
201 //=======================================================================
202 GeometryGUI::~GeometryGUI()
204 while (!myOCCSelectors.isEmpty())
205 delete myOCCSelectors.takeFirst();
207 while (!myVTKSelectors.isEmpty())
208 delete myVTKSelectors.takeFirst();
210 qDeleteAll(myGUIMap);
213 //=======================================================================
214 // function : GeometryGUI::getLibrary()
215 // purpose : get or load GUI library by name [ internal ]
216 //=======================================================================
217 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
218 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
220 if ( !myGUIMap.contains( libraryName ) ) {
221 // try to load library if it is not loaded yet
223 QString dirs = getenv( "LD_LIBRARY_PATH" );
226 QString dirs = getenv( "PATH" );
229 if ( !dirs.isEmpty() ) {
230 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
231 QListIterator<QString> it( dirList ); it.toBack();
232 while ( it.hasPrevious() ) {
233 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
235 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
236 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
238 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
239 continue; // continue search further
241 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
242 if ( osdF != NULL ) {
243 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
244 GEOMGUI* libGUI = (*func)( this );
246 myGUIMap[ libraryName ] = libGUI;
247 break; // found and loaded!
254 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
257 //=======================================================================
258 // function : GeometryGUI::ActiveWorkingPlane()
259 // purpose : Activate Working Plane View
260 //=======================================================================
261 void GeometryGUI::ActiveWorkingPlane()
263 gp_Dir DZ = myWorkingPlane.Direction();
264 gp_Dir DY = myWorkingPlane.YDirection();
266 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
267 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
268 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
271 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
273 Handle(V3d_View) view3d = vw->getViewPort()->getView();
275 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
276 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
282 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
284 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
286 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
287 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
288 camera->SetFocalPoint(0,0,0);
295 //=======================================================================
296 // function : GeometryGUI::SetActiveDialogBox()
297 // purpose : Set active dialog box
298 //=======================================================================
299 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
301 myActiveDialogBox = (QDialog*)aDlg;
304 //=======================================================================
305 // function : GeometryGUI::EmitSignalDeactivateDialog()
306 // purpose : Emit a signal to deactivate the active dialog Box
307 //=======================================================================
308 void GeometryGUI::EmitSignalDeactivateDialog()
310 emit SignalDeactivateActiveDialog();
313 //=======================================================================
314 // function : GeometryGUI::EmitSignalCloseAllDialogs()
315 // purpose : Emit a signal to close all non modal dialogs box
316 //=======================================================================
317 void GeometryGUI::EmitSignalCloseAllDialogs()
319 emit SignalCloseAllDialogs();
322 //=======================================================================
323 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
324 // purpose : Emit a signal to inform that default real spin box step has
326 //=======================================================================
327 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
329 emit SignalDefaultStepValueChanged(newVal);
332 //=======================================================================
333 // function : GeometryGUI::OnGUIEvent()
334 // purpose : common slot for all menu/toolbar actions
335 //=======================================================================
336 void GeometryGUI::OnGUIEvent()
338 const QObject* obj = sender();
339 if ( !obj || !obj->inherits( "QAction" ) )
341 int id = actionId((QAction*)obj);
346 //=======================================================================
347 // function : GeometryGUI::OnGUIEvent()
348 // purpose : manage all events on GUI [static]
349 //=======================================================================
350 void GeometryGUI::OnGUIEvent( int id )
352 SUIT_Application* anApp = application();
354 SUIT_Desktop* desk = anApp->desktop();
356 // check type of the active viewframe
357 SUIT_ViewWindow* window = desk->activeWindow();
358 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
359 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
360 // if current viewframe is not of OCC and not of VTK type - return immediately
361 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
362 QList<int> NotViewerDependentCommands;
363 NotViewerDependentCommands << GEOMOp::OpDelete
365 << GEOMOp::OpShowOnly
366 << GEOMOp::OpShowChildren
367 << GEOMOp::OpHideChildren
368 << GEOMOp::OpUnpublishObject
369 << GEOMOp::OpPublishObject
370 << GEOMOp::OpPointMarker;
371 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
374 // fix for IPAL9103, point 2
375 if ( CORBA::is_nil( GetGeomGen() ) ) {
376 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
381 // find corresponding GUI library
383 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
384 createOriginAndBaseVectors(); // internal operation
386 case GEOMOp::OpImport: // MENU FILE - IMPORT
387 case GEOMOp::OpExport: // MENU FILE - EXPORT
388 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
389 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
390 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
391 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
392 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
393 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
394 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
395 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
396 case GEOMOp::OpDelete: // MENU EDIT - DELETE
397 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
398 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
399 case GEOMOp::OpColor: // POPUP MENU - COLOR
400 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
401 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
402 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
403 case GEOMOp::OpIsos: // POPUP MENU - ISOS
404 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
405 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
406 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
407 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
408 case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
409 case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN
410 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
411 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
412 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
413 libName = "GEOMToolsGUI";
415 case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
416 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
417 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
418 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
419 case GEOMOp::OpHide: // MENU VIEW - ERASE
420 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
421 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
422 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
423 case GEOMOp::OpShading: // POPUP MENU - SHADING
424 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
425 libName = "DisplayGUI";
427 case GEOMOp::OpPoint: // MENU BASIC - POINT
428 case GEOMOp::OpLine: // MENU BASIC - LINE
429 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
430 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
431 case GEOMOp::OpArc: // MENU BASIC - ARC
432 case GEOMOp::OpVector: // MENU BASIC - VECTOR
433 case GEOMOp::OpPlane: // MENU BASIC - PLANE
434 case GEOMOp::OpCurve: // MENU BASIC - CURVE
435 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
436 libName = "BasicGUI";
438 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
439 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
440 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
441 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
442 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
443 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
444 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
445 libName = "PrimitiveGUI";
447 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
448 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
449 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
450 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
451 libName = "GenerationGUI";
453 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
454 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
455 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
456 libName = "EntityGUI";
458 case GEOMOp::OpEdge: // MENU BUILD - EDGE
459 case GEOMOp::OpWire: // MENU BUILD - WIRE
460 case GEOMOp::OpFace: // MENU BUILD - FACE
461 case GEOMOp::OpShell: // MENU BUILD - SHELL
462 case GEOMOp::OpSolid: // MENU BUILD - SOLID
463 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
464 libName = "BuildGUI";
466 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
467 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
468 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
469 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
470 libName = "BooleanGUI";
472 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
473 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
474 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
475 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
476 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
477 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
478 case GEOMOp::OpProjection: // MENU TRANSFORMATION - PROJECTION
479 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
480 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
481 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
482 libName = "TransformationGUI";
484 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
485 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
486 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
487 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
488 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
489 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
490 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
491 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
492 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
493 libName = "OperationGUI";
495 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
496 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
497 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
498 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
499 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
500 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
501 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
502 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
503 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
504 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
505 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
506 case GEOMOp::OpGlueEdges: // MENU REPAIR - GLUE EDGES
507 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
508 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
509 libName = "RepairGUI";
511 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
512 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
513 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
514 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
515 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
516 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
517 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
518 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
519 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
520 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
521 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
522 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
523 libName = "MeasureGUI";
525 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
526 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
527 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
528 libName = "GroupGUI";
530 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
531 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
532 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
533 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
534 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
535 libName = "BlocksGUI";
537 case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
538 case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
539 // case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
540 //@@ 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 @@//
541 libName = "AdvancedGUI";
547 GEOMGUI* library = 0;
548 if ( !libName.isEmpty() ) {
550 libName = QString( "lib" ) + libName + ".so";
552 libName = libName + ".dll";
554 library = getLibrary( libName );
557 // call method of corresponding GUI library
559 library->OnGUIEvent( id, desk );
561 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
564 //=================================================================================
565 // function : GeometryGUI::OnKeyPress()
566 // purpose : Called when any key is pressed by user [static]
567 //=================================================================================
568 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
570 if ( !application() )
572 foreach ( GEOMGUI* lib, myGUIMap )
573 lib->OnKeyPress( e, application()->desktop(), w );
576 //=================================================================================
577 // function : GeometryGUI::OnMouseMove()
578 // purpose : Manages mouse move events [static]
579 //=================================================================================
580 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
582 if ( !application() )
584 foreach ( GEOMGUI* lib, myGUIMap )
585 lib->OnMouseMove( e, application()->desktop(), w );
588 //=================================================================================
589 // function : GeometryGUI::OnMousePress()
590 // purpose : Manage mouse press events [static]
591 //=================================================================================
592 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
594 if ( !application() )
596 foreach ( GEOMGUI* lib, myGUIMap )
597 lib->OnMousePress( e, application()->desktop(), w );
600 //=======================================================================
601 // function : createGeomAction
603 //=======================================================================
604 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
605 const int accel, const bool toggle, const QString& shortcutAction )
607 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
608 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
609 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
611 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
613 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
614 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
616 application()->desktop(),
618 this, SLOT( OnGUIEvent() ),
622 //=======================================================================
623 // function : createOriginAndBaseVectors
625 //=======================================================================
626 void GeometryGUI::createOriginAndBaseVectors()
628 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
630 _PTR(Study) studyDS = appStudy->studyDS();
631 if( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
632 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
633 if( !aBasicOperations->_is_nil() ) {
634 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
635 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
636 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
637 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
638 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
639 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
641 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
642 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
643 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
644 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
645 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
647 getApp()->updateObjectBrowser( false );
653 //=======================================================================
654 // function : GeometryGUI::initialize()
655 // purpose : Called when GEOM module is created
656 //=======================================================================
657 void GeometryGUI::initialize( CAM_Application* app )
659 SalomeApp_Module::initialize( app );
661 // ----- create actions --------------
663 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
664 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
666 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
668 createGeomAction( GEOMOp::OpPoint, "POINT" );
669 createGeomAction( GEOMOp::OpLine, "LINE" );
670 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
671 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
672 createGeomAction( GEOMOp::OpArc, "ARC" );
673 createGeomAction( GEOMOp::OpCurve, "CURVE" );
674 createGeomAction( GEOMOp::OpVector, "VECTOR" );
675 createGeomAction( GEOMOp::OpPlane, "PLANE" );
676 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
677 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
679 createGeomAction( GEOMOp::OpBox, "BOX" );
680 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
681 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
682 createGeomAction( GEOMOp::OpTorus, "TORUS" );
683 createGeomAction( GEOMOp::OpCone, "CONE" );
684 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
685 createGeomAction( GEOMOp::OpDisk, "DISK" );
687 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
688 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
689 createGeomAction( GEOMOp::OpFilling, "FILLING" );
690 createGeomAction( GEOMOp::OpPipe, "PIPE" );
692 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
693 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
695 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
697 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
698 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
700 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
701 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
702 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
704 createGeomAction( GEOMOp::OpEdge, "EDGE" );
705 createGeomAction( GEOMOp::OpWire, "WIRE" );
706 createGeomAction( GEOMOp::OpFace, "FACE" );
707 createGeomAction( GEOMOp::OpShell, "SHELL" );
708 createGeomAction( GEOMOp::OpSolid, "SOLID" );
709 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
711 createGeomAction( GEOMOp::OpFuse, "FUSE" );
712 createGeomAction( GEOMOp::OpCommon, "COMMON" );
713 createGeomAction( GEOMOp::OpCut, "CUT" );
714 createGeomAction( GEOMOp::OpSection, "SECTION" );
716 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
717 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
718 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
719 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
720 createGeomAction( GEOMOp::OpScale, "SCALE" );
721 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
722 createGeomAction( GEOMOp::OpProjection, "PROJECTION" );
723 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
724 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
726 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
727 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
728 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
729 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
730 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
731 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
732 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
733 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
734 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
736 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
737 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
738 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
740 createGeomAction( GEOMOp::OpSewing, "SEWING" );
741 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
742 createGeomAction( GEOMOp::OpGlueEdges, "GLUE_EDGES" );
743 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
744 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
745 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
746 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
747 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
748 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
749 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
750 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
751 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
752 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
753 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
755 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
756 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
757 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
758 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
759 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
760 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
761 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
762 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
764 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
765 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
766 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
767 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
769 #ifdef _DEBUG_ // PAL16821
770 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
773 createGeomAction( GEOMOp::OpDisplayMode, "SHADING" );
774 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
775 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
776 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
777 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
778 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
779 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
780 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
781 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
782 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
783 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
784 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
785 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
786 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
787 createGeomAction( GEOMOp::OpHide, "ERASE" );
789 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
790 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
791 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
792 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
793 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
794 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
795 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
796 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
797 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
798 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
799 createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" );
800 createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" );
801 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
802 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
803 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
805 createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
807 // Create actions for increase/decrease transparency shortcuts
808 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
809 "Geometry:Increase transparency");
810 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
811 "Geometry:Decrease transparency");
813 // Create actions for increase/decrease number of isolines
814 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
815 "Geometry:Increase number of isolines");
816 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
817 "Geometry:Decrease number of isolines");
819 // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
820 //@@ 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 @@//
822 // ---- create menus --------------------------
824 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
825 createMenu( separator(), fileId, 10 );
826 createMenu( GEOMOp::OpImport, fileId, 10 );
827 createMenu( GEOMOp::OpExport, fileId, 10 );
828 createMenu( separator(), fileId, -1 );
830 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
831 createMenu( GEOMOp::OpDelete, editId, -1 );
833 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
835 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
836 createMenu( GEOMOp::OpPoint, basicId, -1 );
837 createMenu( GEOMOp::OpLine, basicId, -1 );
838 createMenu( GEOMOp::OpCircle, basicId, -1 );
839 createMenu( GEOMOp::OpEllipse, basicId, -1 );
840 createMenu( GEOMOp::OpArc, basicId, -1 );
841 createMenu( GEOMOp::OpCurve, basicId, -1 );
842 createMenu( separator(), basicId, -1 );
843 createMenu( GEOMOp::OpVector, basicId, -1 );
844 createMenu( GEOMOp::OpPlane, basicId, -1 );
845 createMenu( GEOMOp::OpLCS, basicId, -1 );
846 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
848 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
849 createMenu( GEOMOp::OpBox, primId, -1 );
850 createMenu( GEOMOp::OpCylinder, primId, -1 );
851 createMenu( GEOMOp::OpSphere, primId, -1 );
852 createMenu( GEOMOp::OpTorus, primId, -1 );
853 createMenu( GEOMOp::OpCone, primId, -1 );
854 createMenu( GEOMOp::OpRectangle, primId, -1 );
855 createMenu( GEOMOp::OpDisk, primId, -1 );
857 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
858 createMenu( GEOMOp::OpPrism, genId, -1 );
859 createMenu( GEOMOp::OpRevolution, genId, -1 );
860 createMenu( GEOMOp::OpFilling, genId, -1 );
861 createMenu( GEOMOp::OpPipe, genId, -1 );
863 int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
864 createMenu( GEOMOp::OpPipeTShape, advId, -1 );
865 // createMenu( GEOMOp::OpPipeTShapeGroups, advId, -1 );
866 //@@ 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 @@//
868 createMenu( separator(), newEntId, -1 );
870 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
871 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
872 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
874 createMenu( separator(), newEntId, -1 );
876 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
877 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
878 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
880 createMenu( separator(), newEntId, -1 );
882 createMenu( GEOMOp::Op2dSketcher, newEntId, -1 );
883 createMenu( GEOMOp::Op3dSketcher, newEntId, -1 );
885 createMenu( separator(), newEntId, -1 );
887 createMenu( GEOMOp::OpExplode, newEntId, -1 );
889 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
890 createMenu( GEOMOp::OpEdge, buildId, -1 );
891 createMenu( GEOMOp::OpWire, buildId, -1 );
892 createMenu( GEOMOp::OpFace, buildId, -1 );
893 createMenu( GEOMOp::OpShell, buildId, -1 );
894 createMenu( GEOMOp::OpSolid, buildId, -1 );
895 createMenu( GEOMOp::OpCompound, buildId, -1 );
897 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
899 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
900 createMenu( GEOMOp::OpFuse, boolId, -1 );
901 createMenu( GEOMOp::OpCommon, boolId, -1 );
902 createMenu( GEOMOp::OpCut, boolId, -1 );
903 createMenu( GEOMOp::OpSection, boolId, -1 );
905 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
906 createMenu( GEOMOp::OpTranslate, transId, -1 );
907 createMenu( GEOMOp::OpRotate, transId, -1 );
908 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
909 createMenu( GEOMOp::OpMirror, transId, -1 );
910 createMenu( GEOMOp::OpScale, transId, -1 );
911 createMenu( GEOMOp::OpOffset, transId, -1 );
912 createMenu( GEOMOp::OpProjection, transId, -1 );
913 createMenu( separator(), transId, -1 );
914 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
915 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
917 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
918 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
919 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
920 createMenu( GEOMOp::OpPropagate, blockId, -1 );
922 createMenu( separator(), operId, -1 );
924 createMenu( GEOMOp::OpPartition, operId, -1 );
925 createMenu( GEOMOp::OpArchimede, operId, -1 );
926 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
927 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
929 createMenu( separator(), operId, -1 );
931 createMenu( GEOMOp::OpFillet1d, operId, -1 );
932 createMenu( GEOMOp::OpFillet2d, operId, -1 );
933 createMenu( GEOMOp::OpFillet3d, operId, -1 );
934 createMenu( GEOMOp::OpChamfer, operId, -1 );
935 //createMenu( GEOMOp::OpClipping, operId, -1 );
937 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
938 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
939 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
940 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
941 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
942 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
943 createMenu( GEOMOp::OpSewing, repairId, -1 );
944 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
945 createMenu( GEOMOp::OpGlueEdges, repairId, -1 );
946 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
947 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
948 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
949 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
950 createMenu( GEOMOp::OpOrientation, repairId, -1 );
951 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
953 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
954 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
955 createMenu( GEOMOp::OpProperties, measurId, -1 );
956 createMenu( separator(), measurId, -1 );
957 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
958 createMenu( GEOMOp::OpInertia, measurId, -1 );
959 createMenu( GEOMOp::OpNormale, measurId, -1 );
960 createMenu( separator(), measurId, -1 );
961 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
962 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
963 createMenu( separator(), measurId, -1 );
965 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
966 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
967 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
968 createMenu( GEOMOp::OpAngle, dimId, -1 );
970 createMenu( separator(), measurId, -1 );
971 createMenu( GEOMOp::OpTolerance, measurId, -1 );
972 createMenu( separator(), measurId, -1 );
973 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
974 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
975 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
977 #ifdef _DEBUG_ // PAL16821
978 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
979 createMenu( separator(), toolsId, -1 );
980 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
983 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
984 createMenu( separator(), viewId, -1 );
986 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
987 createMenu( GEOMOp::OpDisplayMode, dispmodeId, -1 );
988 createMenu( separator(), dispmodeId, -1 );
989 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
991 createMenu( separator(), viewId, -1 );
992 createMenu( GEOMOp::OpShowAll, viewId, -1 );
993 createMenu( GEOMOp::OpHideAll, viewId, -1 );
994 createMenu( separator(), viewId, -1 );
995 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
996 createMenu( separator(), viewId, -1 );
1000 because of these items are accessible through object browser and viewers
1001 we have removed they from main menu
1003 createMenu( GEOMOp::OpShow, viewId, -1 );
1004 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1005 createMenu( GEOMOp::OpHide, viewId, -1 );
1008 // ---- create toolbars --------------------------
1010 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1011 createTool( GEOMOp::OpPoint, basicTbId );
1012 createTool( GEOMOp::OpLine, basicTbId );
1013 createTool( GEOMOp::OpCircle, basicTbId );
1014 createTool( GEOMOp::OpEllipse, basicTbId );
1015 createTool( GEOMOp::OpArc, basicTbId );
1016 createTool( GEOMOp::OpCurve, basicTbId );
1017 createTool( GEOMOp::OpVector, basicTbId );
1018 createTool( GEOMOp::OpPlane, basicTbId );
1019 createTool( GEOMOp::OpLCS, basicTbId );
1020 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1022 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1023 createTool( GEOMOp::OpBox, primTbId );
1024 createTool( GEOMOp::OpCylinder, primTbId );
1025 createTool( GEOMOp::OpSphere, primTbId );
1026 createTool( GEOMOp::OpTorus, primTbId );
1027 createTool( GEOMOp::OpCone, primTbId );
1028 createTool( GEOMOp::OpRectangle, primTbId );
1029 createTool( GEOMOp::OpDisk, primTbId );
1031 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1032 createTool( GEOMOp::OpFuse, boolTbId );
1033 createTool( GEOMOp::OpCommon, boolTbId );
1034 createTool( GEOMOp::OpCut, boolTbId );
1035 createTool( GEOMOp::OpSection, boolTbId );
1037 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1038 createTool( GEOMOp::OpPrism, genTbId );
1039 createTool( GEOMOp::OpRevolution, genTbId );
1040 createTool( GEOMOp::OpFilling, genTbId );
1041 createTool( GEOMOp::OpPipe, genTbId );
1043 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1044 createTool( GEOMOp::OpTranslate, transTbId );
1045 createTool( GEOMOp::OpRotate, transTbId );
1046 createTool( GEOMOp::OpChangeLoc, transTbId );
1047 createTool( GEOMOp::OpMirror, transTbId );
1048 createTool( GEOMOp::OpScale, transTbId );
1049 createTool( GEOMOp::OpOffset, transTbId );
1050 createTool( GEOMOp::OpProjection, transTbId );
1051 createTool( separator(), transTbId );
1052 createTool( GEOMOp::OpMultiTranslate, transTbId );
1053 createTool( GEOMOp::OpMultiRotate, transTbId );
1055 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1056 createTool( GEOMOp::Op2dSketcher, operTbId );
1057 createTool( GEOMOp::Op3dSketcher, operTbId );
1058 createTool( separator(), operTbId );
1059 createTool( GEOMOp::OpExplode, operTbId );
1060 createTool( separator(), operTbId );
1061 createTool( GEOMOp::OpPartition, operTbId );
1062 createTool( GEOMOp::OpArchimede, operTbId );
1063 createTool( GEOMOp::OpShapesOnShape, operTbId );
1064 createTool( GEOMOp::OpSharedShapes, operTbId );
1065 createTool( separator(), operTbId );
1066 createTool( GEOMOp::OpFillet1d, operTbId );
1067 createTool( GEOMOp::OpFillet2d, operTbId );
1068 createTool( GEOMOp::OpFillet3d, operTbId );
1069 createTool( GEOMOp::OpChamfer, operTbId );
1071 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1072 createTool( GEOMOp::OpEdge, buildTbId );
1073 createTool( GEOMOp::OpWire, buildTbId );
1074 createTool( GEOMOp::OpFace, buildTbId );
1075 createTool( GEOMOp::OpShell, buildTbId );
1076 createTool( GEOMOp::OpSolid, buildTbId );
1077 createTool( GEOMOp::OpCompound, buildTbId );
1079 int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1080 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1081 createTool( GEOMOp::OpProperties, measureTbId );
1082 createTool( GEOMOp::OpCenterMass, measureTbId );
1083 createTool( GEOMOp::OpInertia, measureTbId );
1084 createTool( GEOMOp::OpNormale, measureTbId );
1085 createTool( separator(), measureTbId );
1086 createTool( GEOMOp::OpBoundingBox, measureTbId );
1087 createTool( GEOMOp::OpMinDistance, measureTbId );
1088 createTool( GEOMOp::OpAngle, measureTbId );
1089 createTool( GEOMOp::OpTolerance , measureTbId );
1090 createTool( separator(), measureTbId );
1091 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1092 createTool( GEOMOp::OpFreeFaces, measureTbId );
1093 createTool( separator(), measureTbId );
1094 createTool( GEOMOp::OpWhatIs, measureTbId );
1095 createTool( GEOMOp::OpCheckShape, measureTbId );
1096 createTool( GEOMOp::OpCheckCompound, measureTbId );
1098 int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1099 createTool( GEOMOp::OpPipeTShape, advancedTbId );
1100 //@@ 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 @@//
1102 // ---- create popup menus --------------------------
1104 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1105 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1107 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1108 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1110 QString autoColorPrefix =
1111 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1113 QtxPopupMgr* mgr = popupMgr();
1115 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1116 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1117 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1118 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1119 mgr->insert( action( GEOMOp::OpShowChildren ), -1, -1 ); // show children
1120 mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
1122 mgr->insert( action( GEOMOp::OpHideChildren ), -1, -1 ); // hide children
1123 mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
1124 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1125 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1126 mgr->insert( separator(), -1, -1 ); // -----------
1127 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1128 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1129 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1130 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1131 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1132 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1133 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1134 mgr->insert( separator(), dispmodeId, -1 );
1135 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1136 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1137 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1138 mgr->insert( separator(), -1, -1 ); // -----------
1139 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1140 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1141 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1142 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1143 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1144 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1145 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1146 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1147 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1148 //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1149 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1150 mgr->insert( separator(), -1, -1 ); // -----------
1151 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1152 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1153 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1154 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1155 mgr->insert( separator(), -1, -1 ); // -----------
1157 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1158 onlyComponent = "((type='Component') and selcount=1)",
1159 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1160 types = "'Shape' 'Group'";
1162 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1163 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1165 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1166 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1168 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1169 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1171 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1173 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1174 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1175 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1176 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1177 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1178 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1179 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1180 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1181 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1182 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1183 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1184 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1185 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1186 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1187 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1188 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1189 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1190 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1191 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1192 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1193 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1194 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1195 mgr->insert( separator(), selectonlyId, -1);
1196 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1197 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1198 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1199 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1200 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1201 mgr->insert( separator(), -1, -1 );
1203 mgr->insert( separator(), -1, -1 ); // -----------
1204 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1205 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1208 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1209 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1211 mgr->insert( action( GEOMOp::OpReimport ), -1, -1 ); // delete
1212 mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1214 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1217 //=======================================================================
1218 // function : GeometryGUI::activateModule()
1219 // purpose : Called when GEOM module is activated
1220 //=======================================================================
1221 bool GeometryGUI::activateModule( SUIT_Study* study )
1223 if ( CORBA::is_nil( myComponentGeom ) )
1226 bool res = SalomeApp_Module::activateModule( study );
1230 setMenuShown( true );
1231 setToolShown( true );
1233 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1234 PyGILState_STATE gstate = PyGILState_Ensure();
1235 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1236 if(pluginsmanager==NULL)
1240 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"geom",tr("MEN_NEW_ENTITY").toStdString().c_str(),tr("GEOM_PLUGINS_OTHER").toStdString().c_str());
1245 PyGILState_Release(gstate);
1246 // end of GEOM plugins loading
1248 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1249 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1251 // Reset actions accelerator keys
1252 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1253 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1254 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1256 GUIMap::Iterator it;
1257 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1258 it.value()->activate( application()->desktop() );
1260 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1262 SUIT_ViewManager* vm;
1263 ViewManagerList OCCViewManagers, VTKViewManagers;
1265 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1266 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1267 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1268 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1270 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1271 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1272 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1273 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1276 SALOME_ListIO selected;
1277 sm->selectedObjects( selected );
1278 sm->clearSelected();
1280 // disable OCC selectors
1281 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1282 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1283 while ( itOCCSel.hasNext() )
1284 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1285 sr->setEnabled(true);
1287 // disable VTK selectors
1288 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1289 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1290 while ( itVTKSel.hasNext() )
1291 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1292 sr->setEnabled(true);
1294 sm->setSelectedObjects( selected, true ); //NPAL 19674
1296 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1298 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1300 // 0020836 (Basic vectors and origin)
1301 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1302 if( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1303 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1305 _PTR(Study) studyDS = appStudy->studyDS();
1307 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1308 if( !aSComponent ) // create objects automatically only if there is no GEOM component
1309 createOriginAndBaseVectors();
1318 //=======================================================================
1319 // function : GeometryGUI::deactivateModule()
1320 // purpose : Called when GEOM module is deactivated
1321 //=======================================================================
1322 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1324 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1326 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1328 setMenuShown( false );
1329 setToolShown( false );
1331 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1332 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1334 EmitSignalCloseAllDialogs();
1336 GUIMap::Iterator it;
1337 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1338 it.value()->deactivate();
1340 // Unset actions accelerator keys
1341 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1342 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1343 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1345 qDeleteAll(myOCCSelectors);
1346 myOCCSelectors.clear();
1347 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1349 qDeleteAll(myVTKSelectors);
1350 myVTKSelectors.clear();
1351 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1353 return SalomeApp_Module::deactivateModule( study );
1356 //=======================================================================
1357 // function : onWindowActivated()
1358 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1359 //=======================================================================
1360 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1365 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1366 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1368 // disable non-OCC viewframe menu commands
1369 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1370 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1371 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1372 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1373 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1374 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1375 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1377 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1378 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1380 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1383 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1385 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1386 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1389 void GeometryGUI::viewManagers( QStringList& lst ) const
1391 lst.append( OCCViewer_Viewer::Type() );
1394 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1396 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1398 qDebug( "connect" );
1399 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1400 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1401 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1402 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1403 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1404 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1406 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1407 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1409 // disable OCC selectors
1410 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1411 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1412 while ( itOCCSel.hasNext() )
1413 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1414 sr->setEnabled(true);
1416 else if ( vm->getType() == SVTK_Viewer::Type() )
1418 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1419 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1421 // disable VTK selectors
1422 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1423 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1424 while ( itVTKSel.hasNext() )
1425 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1426 sr->setEnabled(true);
1430 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1432 SUIT_ViewModel* viewer = vm->getViewModel();
1433 if ( vm->getType() == OCCViewer_Viewer::Type() )
1435 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1436 while ( itOCCSel.hasNext() )
1437 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1438 if ( sr->viewer() == viewer )
1440 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1444 if ( vm->getType() == SVTK_Viewer::Type() )
1446 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1447 while ( itVTKSel.hasNext() )
1448 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1449 if ( sr->viewer() == viewer )
1451 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1457 QString GeometryGUI::engineIOR() const
1459 if ( !CORBA::is_nil( GetGeomGen() ) )
1460 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1464 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1465 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
1467 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture
1469 (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
1471 theWidth = theHeight = 0;
1473 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1474 Handle(TColStd_HArray1OfByte) aTexture;
1476 Handle(Graphic3d_HArray1OfBytes) aTexture;
1480 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1481 aTexture = aTextureMap[ theId ];
1482 if ( aTexture.IsNull() ) {
1483 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1484 if ( !aInsOp->_is_nil() ) {
1485 CORBA::Long aWidth, aHeight;
1486 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1487 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1489 theHeight = aHeight;
1491 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1492 aTexture = new TColStd_HArray1OfByte (1, aStream->length());
1494 aTexture = new Graphic3d_HArray1OfBytes (1, aStream->length());
1497 for (int i = 0; i < aStream->length(); i++)
1498 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1499 aTextureMap[ theId ] = aTexture;
1507 LightApp_Selection* GeometryGUI::createSelection() const
1509 return new GEOMGUI_Selection();
1512 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1514 SalomeApp_Module::contextMenuPopup( client, menu, title );
1518 getApp()->selectionMgr()->selectedObjects(lst);
1519 if (lst.Extent() < 1)
1522 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1523 _PTR(Study) study = appStudy->studyDS();
1525 bool isImported = true;
1526 SALOME_ListIteratorOfListIO anIt (lst);
1527 for (; anIt.More() && isImported; anIt.Next()) {
1528 Handle(SALOME_InteractiveObject) io = anIt.Value();
1529 _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1531 if (lst.Extent() == 1) {
1532 // Set context menu title
1533 if (client == "OCCViewer" || client == "VTKViewer")
1534 title = QString(aSObj->GetName().c_str());
1537 CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1538 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1539 if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1547 menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
1552 void GeometryGUI::createPreferences()
1554 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1556 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1557 setPreferenceProperty( genGroup, "columns", 2 );
1559 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1560 LightApp_Preferences::Selector,
1561 "Geometry", "display_mode" );
1563 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1564 LightApp_Preferences::Color, "Geometry", "shading_color" );
1566 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1567 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1569 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1570 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1572 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1573 LightApp_Preferences::Color, "Geometry", "line_color" );
1575 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1576 LightApp_Preferences::Color, "Geometry", "point_color" );
1578 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1579 LightApp_Preferences::Color, "Geometry", "isos_color" );
1581 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1582 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1584 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1585 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1587 // Quantities with individual precision settings
1588 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1589 setPreferenceProperty( precGroup, "columns", 2 );
1591 const int nbQuantities = 8;
1592 int prec[nbQuantities], ii = 0;
1593 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1594 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1595 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1596 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1597 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1598 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1599 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1600 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1601 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1602 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1603 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1604 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1605 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1606 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1607 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1608 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1610 // Set property for precision value for spinboxes
1611 for ( ii = 0; ii < nbQuantities; ii++ ){
1612 setPreferenceProperty( prec[ii], "min", -14 );
1613 setPreferenceProperty( prec[ii], "max", 14 );
1614 setPreferenceProperty( prec[ii], "precision", 2 );
1617 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1618 setPreferenceProperty( VertexGroup, "columns", 2 );
1620 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1621 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1623 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1624 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1626 // Set property for default display mode
1627 QStringList aModesList;
1628 aModesList.append( tr("MEN_WIREFRAME") );
1629 aModesList.append( tr("MEN_SHADING") );
1631 QList<QVariant> anIndexesList;
1632 anIndexesList.append(0);
1633 anIndexesList.append(1);
1635 setPreferenceProperty( dispmode, "strings", aModesList );
1636 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1638 // Set property for step value for spinboxes
1639 setPreferenceProperty( step, "min", 1 );
1640 setPreferenceProperty( step, "max", 10000 );
1641 setPreferenceProperty( step, "precision", 3 );
1643 // Set property for deflection value for spinboxes
1644 setPreferenceProperty( defl, "min", DEFLECTION_MIN );
1645 setPreferenceProperty( defl, "max", 1.0 );
1646 setPreferenceProperty( defl, "step", 1.0e-04 );
1647 setPreferenceProperty( defl, "precision", 6 );
1649 // Set property vertex marker type
1650 QList<QVariant> aMarkerTypeIndicesList;
1651 QList<QVariant> aMarkerTypeIconsList;
1653 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1654 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1655 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1656 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1657 aMarkerTypeIndicesList << (i-1);
1658 aMarkerTypeIconsList << pixmap;
1661 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1662 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
1664 // Set property for vertex marker scale
1665 QList<QVariant> aMarkerScaleIndicesList;
1666 QStringList aMarkerScaleValuesList;
1668 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
1669 aMarkerScaleIndicesList << iii;
1670 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
1673 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1674 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1676 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
1677 setPreferenceProperty( originGroup, "columns", 2 );
1679 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
1680 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
1681 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
1682 setPreferenceProperty( baseVectorsLength, "max", 1000 );
1684 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
1685 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
1688 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
1689 setPreferenceProperty( operationsGroup, "columns", 2 );
1691 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
1692 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
1695 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1697 if (section == "Geometry") {
1698 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1699 if (param == QString("SettingsGeomStep")) {
1700 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1701 EmitSignalDefaultStepValueChanged(spin_step);
1706 LightApp_Displayer* GeometryGUI::displayer()
1709 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1713 void GeometryGUI::setLocalSelectionMode(const int mode)
1715 myLocalSelectionMode = mode;
1717 int GeometryGUI::getLocalSelectionMode() const
1719 return myLocalSelectionMode;
1722 const char gSeparator = '_'; // character used to separate parameter names
1723 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1726 * \brief Store visual parameters
1728 * This method is called just before the study document is saved.
1729 * Store visual parameters in AttributeParameter attribue(s)
1731 void GeometryGUI::storeVisualParameters (int savePoint)
1733 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1734 if ( !appStudy || !appStudy->studyDS() )
1736 _PTR(Study) studyDS = appStudy->studyDS();
1738 // componentName is used for encoding of entries when storing them in IParameters
1739 std::string componentName = myComponentGeom->ComponentDataType();
1740 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1741 //if (!aSComponent) return;
1744 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1745 componentName.c_str(),
1747 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1749 QList<SUIT_ViewManager*> lst;
1750 QList<SUIT_ViewManager*>::Iterator it;
1752 // main cycle to store parameters of displayed objects
1754 getApp()->viewManagers(lst);
1755 for (it = lst.begin(); it != lst.end(); it++) {
1756 SUIT_ViewManager* vman = *it;
1757 QString vType = vman->getType();
1758 int aMgrId = vman->getGlobalId();
1759 // saving VTK actors properties
1760 QVector<SUIT_ViewWindow*> views = vman->getViews();
1761 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
1762 const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
1763 ObjMap::ConstIterator o_it = anObjects.begin();
1764 for (; o_it != anObjects.end(); o_it++) {
1765 const PropMap aProps = o_it.value();
1767 //Check that object exists in the study
1768 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
1769 if ( !obj || !(aProps.count() > 0))
1771 // entry is "encoded" = it does NOT contain component adress, since it is a
1772 // subject to change on next component loading
1774 std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
1776 _PTR(GenericAttribute) anAttr;
1777 if( !obj->FindAttribute(anAttr, "AttributeIOR"))
1780 std::string param,occParam = vType.toLatin1().data();
1781 occParam += NAME_SEPARATOR;
1782 occParam += QString::number(aMgrId).toLatin1().data();
1783 occParam += NAME_SEPARATOR;
1785 if(aProps.contains(VISIBILITY_PROP)) {
1786 param = occParam + VISIBILITY_PROP;
1787 ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
1790 if(aProps.contains(DISPLAY_MODE_PROP)) {
1791 param = occParam + DISPLAY_MODE_PROP;
1792 ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
1795 if(aProps.contains(COLOR_PROP)) {
1796 QColor c = aProps.value(COLOR_PROP).value<QColor>();
1797 QString colorStr = QString::number(c.red()/255.);
1798 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
1799 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
1800 param = occParam + COLOR_PROP;
1801 ip->setParameter(entry, param, colorStr.toLatin1().data());
1804 if(vType == SVTK_Viewer::Type()) {
1805 if(aProps.contains(OPACITY_PROP)) {
1806 param = occParam + OPACITY_PROP;
1807 ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1809 } else if (vType == SOCC_Viewer::Type()) {
1810 if(aProps.contains(TRANSPARENCY_PROP)) {
1811 param = occParam + TRANSPARENCY_PROP;
1812 ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1816 if(aProps.contains(ISOS_PROP)) {
1817 param = occParam + ISOS_PROP;
1818 ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
1821 if(aProps.contains(VECTOR_MODE_PROP)) {
1822 param = occParam + VECTOR_MODE_PROP;
1823 ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
1826 if(aProps.contains(DEFLECTION_COEFF_PROP)) {
1827 param = occParam + DEFLECTION_COEFF_PROP;
1828 ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
1831 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
1832 if(aProps.contains(MARKER_TYPE_PROP)) {
1833 param = occParam + MARKER_TYPE_PROP;
1834 ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
1836 } // object iterator
1838 } // for (viewManagers)
1842 * \brief Restore visual parameters
1844 * This method is called after the study document is opened.
1845 * Restore visual parameters from AttributeParameter attribue(s)
1847 void GeometryGUI::restoreVisualParameters (int savePoint)
1849 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1850 if (!appStudy || !appStudy->studyDS())
1852 _PTR(Study) studyDS = appStudy->studyDS();
1854 // componentName is used for encoding of entries when storing them in IParameters
1855 std::string componentName = myComponentGeom->ComponentDataType();
1856 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1857 //if (!aSComponent) return;
1860 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1861 componentName.c_str(),
1863 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1865 std::vector<std::string> entries = ip->getEntries();
1867 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
1869 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1870 QString entry (ip->decodeEntry(*entIt).c_str());
1872 // Check that the entry corresponds to a real object in the Study
1873 // as the object may be deleted or modified after the visual state is saved.
1874 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1875 if (!so) continue; //Skip the not existent entry
1877 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1878 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1880 std::vector<std::string>::iterator namesIt = paramNames.begin();
1881 std::vector<std::string>::iterator valuesIt = paramValues.begin();
1883 // actors are stored in a map after displaying of them for
1884 // quicker access in the future: map < viewID to actor >
1885 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
1886 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
1888 QString viewerTypStr;
1889 QString viewIndexStr;
1891 QVector<PropMap> aListOfMap;
1893 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
1895 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
1896 // '_' is used as separator and should not be used in viewer type or parameter names.
1897 QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts);
1898 if (lst.size() != 3)
1901 viewerTypStr = lst[0];
1902 viewIndexStr = lst[1];
1903 QString paramNameStr = lst[2];
1906 viewIndex = viewIndexStr.toUInt(&ok);
1907 if (!ok) // bad conversion of view index to integer
1910 if((viewIndex + 1) > aListOfMap.count()) {
1911 aListOfMap.resize(viewIndex + 1);
1914 QString val((*valuesIt).c_str());
1915 if(paramNameStr == VISIBILITY_PROP){
1916 aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0);
1918 } else if(paramNameStr == OPACITY_PROP) {
1919 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
1921 } else if(paramNameStr == TRANSPARENCY_PROP) {
1922 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, val.toDouble());
1924 } else if(paramNameStr == DISPLAY_MODE_PROP) {
1925 aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
1927 } else if(paramNameStr == ISOS_PROP) {
1928 aListOfMap[viewIndex].insert( ISOS_PROP, val);
1930 } else if(paramNameStr == COLOR_PROP) {
1931 QStringList rgb = val.split(DIGIT_SEPARATOR);
1932 if(rgb.count() == 3) {
1933 QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255));
1934 aListOfMap[viewIndex].insert( COLOR_PROP, c);
1936 } else if(paramNameStr == VECTOR_MODE_PROP) {
1937 aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt());
1939 } else if(paramNameStr == DEFLECTION_COEFF_PROP) {
1940 aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
1941 } else if(paramNameStr == MARKER_TYPE_PROP) {
1942 aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
1945 } // for names/parameters iterator
1947 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
1949 for (int index = 0; index < aListOfMap.count(); index++) {
1951 appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
1953 //Get Visibility property of the current PropMap
1954 if (aListOfMap[index].value(VISIBILITY_PROP) == 1) {
1955 SUIT_ViewManager* vman = lst.at(index);
1956 SUIT_ViewModel* vmodel = vman->getViewModel();
1957 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
1961 } // for entries iterator
1963 // update all VTK and OCC views
1964 QList<SUIT_ViewManager*> lst;
1965 getApp()->viewManagers(lst);
1966 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
1967 SUIT_ViewModel* vmodel = (*it)->getViewModel();
1970 if (vmodel->getType() == SVTK_Viewer::Type()) {
1971 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
1972 vtkView->getRenderer()->ResetCameraClippingRange();
1975 else if (vmodel->getType() == SOCC_Viewer::Type()) {
1976 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
1977 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
1984 void GeometryGUI::onViewAboutToShow()
1986 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
1987 QAction* a = action( GEOMOp::OpSwitchVectors );
1989 a->setEnabled(true);
1990 bool vmode = window->property("VectorsMode").toBool();
1991 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
1993 a->setText ( tr("MEN_VECTOR_MODE_ON") );
1994 a->setEnabled(false);
1999 Rename object by entry.
2000 \param entry entry of the object
2001 \param name new name of the object
2002 \brief Return \c true if rename operation finished successfully, \c false otherwise.
2004 bool GeometryGUI::renameObject( const QString& entry, const QString& name) {
2006 bool appRes = SalomeApp_Module::renameObject(entry,name);
2010 bool result = false;
2012 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
2013 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2018 _PTR(Study) aStudy = appStudy->studyDS();
2023 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
2024 _PTR(GenericAttribute) anAttr;
2026 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
2027 _PTR(AttributeName) aName (anAttr);
2029 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
2030 if (!CORBA::is_nil(anObj)) {
2031 aName->SetValue( name.toLatin1().data() ); // rename the SObject
2032 anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object