1 // Copyright (C) 2007-2010 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 // GEOM GEOMGUI : GUI for Geometry component
23 // File : GeometryGUI.cxx
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
26 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
28 #include "GeometryGUI.h"
29 #include "GeometryGUI_Operations.h"
30 #include "GEOMGUI_OCCSelector.h"
31 #include "GEOMGUI_Selection.h"
32 #include "GEOM_Displayer.h"
33 #include "GEOM_AISShape.hxx"
35 #include "GEOM_Actor.h"
37 #include <SUIT_Desktop.h>
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_ResourceMgr.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_ViewManager.h>
43 #include <OCCViewer_ViewWindow.h>
44 #include <OCCViewer_ViewPort3d.h>
45 #include <OCCViewer_ViewModel.h>
46 #include <OCCViewer_ViewManager.h>
48 #include <SOCC_ViewModel.h>
49 #include <SOCC_ViewWindow.h>
51 #include <SVTK_ViewWindow.h>
52 #include <SVTK_RenderWindowInteractor.h>
53 #include <SVTK_InteractorStyle.h>
54 #include <SVTK_ViewModel.h>
56 #include <SalomeApp_Application.h>
57 #include <SalomeApp_DataObject.h>
58 #include <SalomeApp_Study.h>
60 #include <LightApp_SelectionMgr.h>
61 #include <LightApp_VTKSelector.h>
62 #include <LightApp_DataObject.h>
63 #include <LightApp_Preferences.h>
65 #include <SALOME_LifeCycleCORBA.hxx>
66 #include <SALOME_ListIO.hxx>
67 #include <SALOME_ListIteratorOfListIO.hxx>
69 #include <SALOMEDSClient_ClientFactory.hxx>
70 #include <SALOMEDSClient_IParameters.hxx>
79 #include <AIS_Drawer.hxx>
80 #include <AIS_ListOfInteractive.hxx>
81 #include <AIS_ListIteratorOfListOfInteractive.hxx>
82 #include <Prs3d_Drawer.hxx>
83 #include <Prs3d_IsoAspect.hxx>
84 #include <Aspect_TypeOfMarker.hxx>
85 #include <OSD_SharedLibrary.hxx>
86 #include <NCollection_DataMap.hxx>
87 #include <Graphic3d_HArray1OfBytes.hxx>
89 #include <utilities.h>
91 #include <vtkCamera.h>
92 #include <vtkRenderer.h>
94 #include "GEOMImpl_Types.hxx"
97 Standard_EXPORT CAM_Module* createModule() {
98 return new GeometryGUI();
102 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
104 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
106 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
108 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
109 if (CORBA::is_nil(myComponentGeom))
111 return GeometryGUI::myComponentGeom;
114 bool GeometryGUI::InitGeomGen()
117 if( CORBA::is_nil( myComponentGeom ) ) return false;
121 //=======================================================================
122 // function : ClientSObjectToObject
124 //=======================================================================
125 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
127 _PTR(GenericAttribute) anAttr;
128 CORBA::Object_var anObj;
130 std::string aValue = theSObject->GetIOR();
131 if (strcmp(aValue.c_str(), "") != 0) {
132 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
133 anObj = anORB->string_to_object(aValue.c_str());
136 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
138 return anObj._retn();
141 //=======================================================================
142 // function : ClientStudyToStudy
144 //=======================================================================
145 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
147 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
148 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
149 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
150 int aStudyID = theStudy->StudyId();
151 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
152 return aDSStudy._retn();
155 void GeometryGUI::Modified( bool theIsUpdateActions )
157 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
158 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
159 appStudy->Modified();
160 if( theIsUpdateActions )
161 app->updateActions();
166 //=======================================================================
167 // function : GeometryGUI::GeometryGUI()
168 // purpose : Constructor
169 //=======================================================================
170 GeometryGUI::GeometryGUI() :
171 SalomeApp_Module( "GEOM" ),
172 LightApp_Module( "GEOM" )
174 if ( CORBA::is_nil( myComponentGeom ) )
176 Engines::EngineComponent_var comp =
177 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
178 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
181 myActiveDialogBox = 0;
183 gp_Pnt origin = gp_Pnt(0., 0., 0.);
184 gp_Dir direction = gp_Dir(0., 0., 1.);
185 myWorkingPlane = gp_Ax3(origin, direction);
188 myLocalSelectionMode = GEOM_ALLOBJECTS;
191 //=======================================================================
192 // function : GeometryGUI::~GeometryGUI()
193 // purpose : Destructor
194 //=======================================================================
195 GeometryGUI::~GeometryGUI()
197 while (!myOCCSelectors.isEmpty())
198 delete myOCCSelectors.takeFirst();
200 while (!myVTKSelectors.isEmpty())
201 delete myVTKSelectors.takeFirst();
203 qDeleteAll(myGUIMap);
206 //=======================================================================
207 // function : GeometryGUI::getLibrary()
208 // purpose : get or load GUI library by name [ internal ]
209 //=======================================================================
210 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
211 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
213 if ( !myGUIMap.contains( libraryName ) ) {
214 // try to load library if it is not loaded yet
216 QString dirs = getenv( "LD_LIBRARY_PATH" );
219 QString dirs = getenv( "PATH" );
222 if ( !dirs.isEmpty() ) {
223 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
224 QListIterator<QString> it( dirList ); it.toBack();
225 while ( it.hasPrevious() ) {
226 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
228 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
229 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
231 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
232 continue; // continue search further
234 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
235 if ( osdF != NULL ) {
236 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
237 GEOMGUI* libGUI = (*func)( this );
239 myGUIMap[ libraryName ] = libGUI;
240 break; // found and loaded!
247 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
250 //=======================================================================
251 // function : GeometryGUI::ActiveWorkingPlane()
252 // purpose : Activate Working Plane View
253 //=======================================================================
254 void GeometryGUI::ActiveWorkingPlane()
256 gp_Dir DZ = myWorkingPlane.Direction();
257 gp_Dir DY = myWorkingPlane.YDirection();
259 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
260 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
261 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
264 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
266 Handle(V3d_View) view3d = vw->getViewPort()->getView();
268 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
269 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
275 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
277 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
279 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
280 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
281 camera->SetFocalPoint(0,0,0);
288 //=======================================================================
289 // function : GeometryGUI::SetActiveDialogBox()
290 // purpose : Set active dialog box
291 //=======================================================================
292 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
294 myActiveDialogBox = (QDialog*)aDlg;
297 //=======================================================================
298 // function : GeometryGUI::EmitSignalDeactivateDialog()
299 // purpose : Emit a signal to deactivate the active dialog Box
300 //=======================================================================
301 void GeometryGUI::EmitSignalDeactivateDialog()
303 emit SignalDeactivateActiveDialog();
306 //=======================================================================
307 // function : GeometryGUI::EmitSignalCloseAllDialogs()
308 // purpose : Emit a signal to close all non modal dialogs box
309 //=======================================================================
310 void GeometryGUI::EmitSignalCloseAllDialogs()
312 emit SignalCloseAllDialogs();
315 //=======================================================================
316 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
317 // purpose : Emit a signal to inform that default real spin box step has
319 //=======================================================================
320 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
322 emit SignalDefaultStepValueChanged(newVal);
325 //=======================================================================
326 // function : GeometryGUI::OnGUIEvent()
327 // purpose : common slot for all menu/toolbar actions
328 //=======================================================================
329 void GeometryGUI::OnGUIEvent()
331 const QObject* obj = sender();
332 if ( !obj || !obj->inherits( "QAction" ) )
334 int id = actionId((QAction*)obj);
339 //=======================================================================
340 // function : GeometryGUI::OnGUIEvent()
341 // purpose : manage all events on GUI [static]
342 //=======================================================================
343 void GeometryGUI::OnGUIEvent( int id )
345 SUIT_Application* anApp = application();
347 SUIT_Desktop* desk = anApp->desktop();
349 // check type of the active viewframe
350 SUIT_ViewWindow* window = desk->activeWindow();
351 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
352 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
353 // if current viewframe is not of OCC and not of VTK type - return immediately
354 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
355 QList<int> NotViewerDependentCommands;
356 NotViewerDependentCommands << GEOMOp::OpDelete
358 << GEOMOp::OpShowOnly
359 << GEOMOp::OpShowChildren
360 << GEOMOp::OpHideChildren
361 << GEOMOp::OpUnpublishObject
362 << GEOMOp::OpPublishObject
363 << GEOMOp::OpPointMarker;
364 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
367 // fix for IPAL9103, point 2
368 if ( CORBA::is_nil( GetGeomGen() ) ) {
369 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
374 // find corresponding GUI library
376 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
377 createOriginAndBaseVectors(); // internal operation
379 case GEOMOp::OpImport: // MENU FILE - IMPORT
380 case GEOMOp::OpExport: // MENU FILE - EXPORT
381 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
382 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
383 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
384 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
385 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
386 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
387 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
388 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
389 case GEOMOp::OpDelete: // MENU EDIT - DELETE
390 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
391 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
392 case GEOMOp::OpColor: // POPUP MENU - COLOR
393 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
394 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
395 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
396 case GEOMOp::OpIsos: // POPUP MENU - ISOS
397 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
398 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
399 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
400 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
401 case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
402 case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN
403 case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
404 case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
405 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
406 libName = "GEOMToolsGUI";
408 case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
409 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
410 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
411 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
412 case GEOMOp::OpHide: // MENU VIEW - ERASE
413 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
414 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
415 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
416 case GEOMOp::OpShading: // POPUP MENU - SHADING
417 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
418 libName = "DisplayGUI";
420 case GEOMOp::OpPoint: // MENU BASIC - POINT
421 case GEOMOp::OpLine: // MENU BASIC - LINE
422 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
423 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
424 case GEOMOp::OpArc: // MENU BASIC - ARC
425 case GEOMOp::OpVector: // MENU BASIC - VECTOR
426 case GEOMOp::OpPlane: // MENU BASIC - PLANE
427 case GEOMOp::OpCurve: // MENU BASIC - CURVE
428 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
429 libName = "BasicGUI";
431 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
432 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
433 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
434 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
435 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
436 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
437 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
438 libName = "PrimitiveGUI";
440 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
441 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
442 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
443 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
444 libName = "GenerationGUI";
446 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
447 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
448 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
449 libName = "EntityGUI";
451 case GEOMOp::OpEdge: // MENU BUILD - EDGE
452 case GEOMOp::OpWire: // MENU BUILD - WIRE
453 case GEOMOp::OpFace: // MENU BUILD - FACE
454 case GEOMOp::OpShell: // MENU BUILD - SHELL
455 case GEOMOp::OpSolid: // MENU BUILD - SOLID
456 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
457 libName = "BuildGUI";
459 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
460 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
461 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
462 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
463 libName = "BooleanGUI";
465 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
466 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
467 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
468 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
469 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
470 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
471 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
472 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
473 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
474 libName = "TransformationGUI";
476 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
477 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
478 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
479 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
480 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
481 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
482 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
483 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
484 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
485 libName = "OperationGUI";
487 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
488 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
489 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
490 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
491 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
492 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
493 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
494 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
495 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
496 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
497 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
498 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
499 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
500 libName = "RepairGUI";
502 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
503 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
504 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
505 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
506 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
507 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
508 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
509 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
510 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
511 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
512 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
513 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
514 libName = "MeasureGUI";
516 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
517 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
518 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
519 libName = "GroupGUI";
521 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
522 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
523 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
524 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
525 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
526 libName = "BlocksGUI";
528 case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
529 case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
530 // case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
531 //@@ 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 @@//
532 libName = "AdvancedGUI";
538 GEOMGUI* library = 0;
539 if ( !libName.isEmpty() ) {
541 libName = QString( "lib" ) + libName + ".so";
543 libName = libName + ".dll";
545 library = getLibrary( libName );
548 // call method of corresponding GUI library
550 library->OnGUIEvent( id, desk );
552 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
555 //=================================================================================
556 // function : GeometryGUI::OnKeyPress()
557 // purpose : Called when any key is pressed by user [static]
558 //=================================================================================
559 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
561 if ( !application() )
563 foreach ( GEOMGUI* lib, myGUIMap )
564 lib->OnKeyPress( e, application()->desktop(), w );
567 //=================================================================================
568 // function : GeometryGUI::OnMouseMove()
569 // purpose : Manages mouse move events [static]
570 //=================================================================================
571 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
573 if ( !application() )
575 foreach ( GEOMGUI* lib, myGUIMap )
576 lib->OnMouseMove( e, application()->desktop(), w );
579 //=================================================================================
580 // function : GeometryGUI::OnMousePress()
581 // purpose : Manage mouse press events [static]
582 //=================================================================================
583 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
585 if ( !application() )
587 foreach ( GEOMGUI* lib, myGUIMap )
588 lib->OnMousePress( e, application()->desktop(), w );
591 //=======================================================================
592 // function : createGeomAction
594 //=======================================================================
595 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
596 const int accel, const bool toggle, const QString& shortcutAction )
598 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
599 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
600 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
602 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
604 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
605 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
607 application()->desktop(),
609 this, SLOT( OnGUIEvent() ),
613 //=======================================================================
614 // function : createOriginAndBaseVectors
616 //=======================================================================
617 void GeometryGUI::createOriginAndBaseVectors()
619 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
621 _PTR(Study) studyDS = appStudy->studyDS();
622 if( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
623 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
624 if( !aBasicOperations->_is_nil() ) {
625 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
626 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
627 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
628 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
629 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
630 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
632 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
633 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
634 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
635 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
636 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
638 getApp()->updateObjectBrowser( false );
644 //=======================================================================
645 // function : GeometryGUI::initialize()
646 // purpose : Called when GEOM module is created
647 //=======================================================================
648 void GeometryGUI::initialize( CAM_Application* app )
650 SalomeApp_Module::initialize( app );
652 // ----- create actions --------------
654 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
655 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
657 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
659 createGeomAction( GEOMOp::OpPoint, "POINT" );
660 createGeomAction( GEOMOp::OpLine, "LINE" );
661 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
662 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
663 createGeomAction( GEOMOp::OpArc, "ARC" );
664 createGeomAction( GEOMOp::OpCurve, "CURVE" );
665 createGeomAction( GEOMOp::OpVector, "VECTOR" );
666 createGeomAction( GEOMOp::OpPlane, "PLANE" );
667 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
668 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
670 createGeomAction( GEOMOp::OpBox, "BOX" );
671 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
672 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
673 createGeomAction( GEOMOp::OpTorus, "TORUS" );
674 createGeomAction( GEOMOp::OpCone, "CONE" );
675 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
676 createGeomAction( GEOMOp::OpDisk, "DISK" );
678 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
679 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
680 createGeomAction( GEOMOp::OpFilling, "FILLING" );
681 createGeomAction( GEOMOp::OpPipe, "PIPE" );
683 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
684 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
686 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
688 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
689 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
691 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
692 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
693 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
695 createGeomAction( GEOMOp::OpEdge, "EDGE" );
696 createGeomAction( GEOMOp::OpWire, "WIRE" );
697 createGeomAction( GEOMOp::OpFace, "FACE" );
698 createGeomAction( GEOMOp::OpShell, "SHELL" );
699 createGeomAction( GEOMOp::OpSolid, "SOLID" );
700 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
702 createGeomAction( GEOMOp::OpFuse, "FUSE" );
703 createGeomAction( GEOMOp::OpCommon, "COMMON" );
704 createGeomAction( GEOMOp::OpCut, "CUT" );
705 createGeomAction( GEOMOp::OpSection, "SECTION" );
707 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
708 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
709 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
710 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
711 createGeomAction( GEOMOp::OpScale, "SCALE" );
712 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
713 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
714 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
716 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
717 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
718 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
719 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
720 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
721 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
722 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
723 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
724 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
726 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
727 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
728 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
730 createGeomAction( GEOMOp::OpSewing, "SEWING" );
731 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
732 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
733 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
734 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
735 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
736 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
737 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
738 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
739 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
740 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
741 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
742 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
744 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
745 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
746 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
747 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
748 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
749 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
750 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
751 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
753 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
754 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
755 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
756 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
758 #ifdef _DEBUG_ // PAL16821
759 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
762 createGeomAction( GEOMOp::OpDisplayMode, "SHADING" );
763 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
764 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
765 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
766 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
767 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
768 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
769 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
770 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
771 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
772 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
773 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
774 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
775 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
776 createGeomAction( GEOMOp::OpHide, "ERASE" );
778 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
779 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
780 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
781 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
782 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
783 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
784 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
785 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
786 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
787 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
788 createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" );
789 createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" );
790 createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
791 createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
792 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
794 createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
796 // Create actions for increase/decrease transparency shortcuts
797 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
798 "Geometry:Increase transparency");
799 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
800 "Geometry:Decrease transparency");
802 // Create actions for increase/decrease number of isolines
803 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
804 "Geometry:Increase number of isolines");
805 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
806 "Geometry:Decrease number of isolines");
808 // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
809 //@@ 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 @@//
811 // ---- create menus --------------------------
813 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
814 createMenu( separator(), fileId, 10 );
815 createMenu( GEOMOp::OpImport, fileId, 10 );
816 createMenu( GEOMOp::OpExport, fileId, 10 );
817 createMenu( separator(), fileId, -1 );
819 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
820 createMenu( GEOMOp::OpDelete, editId, -1 );
822 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
824 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
825 createMenu( GEOMOp::OpPoint, basicId, -1 );
826 createMenu( GEOMOp::OpLine, basicId, -1 );
827 createMenu( GEOMOp::OpCircle, basicId, -1 );
828 createMenu( GEOMOp::OpEllipse, basicId, -1 );
829 createMenu( GEOMOp::OpArc, basicId, -1 );
830 createMenu( GEOMOp::OpCurve, basicId, -1 );
831 createMenu( separator(), basicId, -1 );
832 createMenu( GEOMOp::OpVector, basicId, -1 );
833 createMenu( GEOMOp::OpPlane, basicId, -1 );
834 createMenu( GEOMOp::OpLCS, basicId, -1 );
835 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
837 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
838 createMenu( GEOMOp::OpBox, primId, -1 );
839 createMenu( GEOMOp::OpCylinder, primId, -1 );
840 createMenu( GEOMOp::OpSphere, primId, -1 );
841 createMenu( GEOMOp::OpTorus, primId, -1 );
842 createMenu( GEOMOp::OpCone, primId, -1 );
843 createMenu( GEOMOp::OpRectangle, primId, -1 );
844 createMenu( GEOMOp::OpDisk, primId, -1 );
846 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
847 createMenu( GEOMOp::OpPrism, genId, -1 );
848 createMenu( GEOMOp::OpRevolution, genId, -1 );
849 createMenu( GEOMOp::OpFilling, genId, -1 );
850 createMenu( GEOMOp::OpPipe, genId, -1 );
852 int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
853 createMenu( GEOMOp::OpPipeTShape, advId, -1 );
854 // createMenu( GEOMOp::OpPipeTShapeGroups, advId, -1 );
855 //@@ 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 @@//
857 createMenu( separator(), newEntId, -1 );
859 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
860 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
861 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
863 createMenu( separator(), newEntId, -1 );
865 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
866 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
867 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
869 createMenu( separator(), newEntId, -1 );
871 createMenu( GEOMOp::Op2dSketcher, newEntId, -1 );
872 createMenu( GEOMOp::Op3dSketcher, newEntId, -1 );
874 createMenu( separator(), newEntId, -1 );
876 createMenu( GEOMOp::OpExplode, newEntId, -1 );
878 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
879 createMenu( GEOMOp::OpEdge, buildId, -1 );
880 createMenu( GEOMOp::OpWire, buildId, -1 );
881 createMenu( GEOMOp::OpFace, buildId, -1 );
882 createMenu( GEOMOp::OpShell, buildId, -1 );
883 createMenu( GEOMOp::OpSolid, buildId, -1 );
884 createMenu( GEOMOp::OpCompound, buildId, -1 );
886 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
888 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
889 createMenu( GEOMOp::OpFuse, boolId, -1 );
890 createMenu( GEOMOp::OpCommon, boolId, -1 );
891 createMenu( GEOMOp::OpCut, boolId, -1 );
892 createMenu( GEOMOp::OpSection, boolId, -1 );
894 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
895 createMenu( GEOMOp::OpTranslate, transId, -1 );
896 createMenu( GEOMOp::OpRotate, transId, -1 );
897 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
898 createMenu( GEOMOp::OpMirror, transId, -1 );
899 createMenu( GEOMOp::OpScale, transId, -1 );
900 createMenu( GEOMOp::OpOffset, transId, -1 );
901 createMenu( separator(), transId, -1 );
902 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
903 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
905 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
906 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
907 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
908 createMenu( GEOMOp::OpPropagate, blockId, -1 );
910 createMenu( separator(), operId, -1 );
912 createMenu( GEOMOp::OpPartition, operId, -1 );
913 createMenu( GEOMOp::OpArchimede, operId, -1 );
914 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
915 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
917 createMenu( separator(), operId, -1 );
919 createMenu( GEOMOp::OpFillet1d, operId, -1 );
920 createMenu( GEOMOp::OpFillet2d, operId, -1 );
921 createMenu( GEOMOp::OpFillet3d, operId, -1 );
922 createMenu( GEOMOp::OpChamfer, operId, -1 );
923 //createMenu( GEOMOp::OpClipping, operId, -1 );
925 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
926 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
927 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
928 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
929 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
930 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
931 createMenu( GEOMOp::OpSewing, repairId, -1 );
932 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
933 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
934 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
935 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
936 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
937 createMenu( GEOMOp::OpOrientation, repairId, -1 );
938 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
940 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
941 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
942 createMenu( GEOMOp::OpProperties, measurId, -1 );
943 createMenu( separator(), measurId, -1 );
944 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
945 createMenu( GEOMOp::OpInertia, measurId, -1 );
946 createMenu( GEOMOp::OpNormale, measurId, -1 );
947 createMenu( separator(), measurId, -1 );
948 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
949 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
950 createMenu( separator(), measurId, -1 );
952 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
953 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
954 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
955 createMenu( GEOMOp::OpAngle, dimId, -1 );
957 createMenu( separator(), measurId, -1 );
958 createMenu( GEOMOp::OpTolerance, measurId, -1 );
959 createMenu( separator(), measurId, -1 );
960 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
961 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
962 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
964 #ifdef _DEBUG_ // PAL16821
965 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
966 createMenu( separator(), toolsId, -1 );
967 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
970 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
971 createMenu( separator(), viewId, -1 );
973 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
974 createMenu( GEOMOp::OpDisplayMode, dispmodeId, -1 );
975 createMenu( separator(), dispmodeId, -1 );
976 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
978 createMenu( separator(), viewId, -1 );
979 createMenu( GEOMOp::OpShowAll, viewId, -1 );
980 createMenu( GEOMOp::OpHideAll, viewId, -1 );
981 createMenu( separator(), viewId, -1 );
982 createMenu( GEOMOp::OpPublishObject, viewId, -1 );
983 createMenu( separator(), viewId, -1 );
987 because of these items are accessible through object browser and viewers
988 we have removed they from main menu
990 createMenu( GEOMOp::OpShow, viewId, -1 );
991 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
992 createMenu( GEOMOp::OpHide, viewId, -1 );
995 // ---- create toolbars --------------------------
997 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
998 createTool( GEOMOp::OpPoint, basicTbId );
999 createTool( GEOMOp::OpLine, basicTbId );
1000 createTool( GEOMOp::OpCircle, basicTbId );
1001 createTool( GEOMOp::OpEllipse, basicTbId );
1002 createTool( GEOMOp::OpArc, basicTbId );
1003 createTool( GEOMOp::OpCurve, basicTbId );
1004 createTool( GEOMOp::OpVector, basicTbId );
1005 createTool( GEOMOp::OpPlane, basicTbId );
1006 createTool( GEOMOp::OpLCS, basicTbId );
1007 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1009 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1010 createTool( GEOMOp::OpBox, primTbId );
1011 createTool( GEOMOp::OpCylinder, primTbId );
1012 createTool( GEOMOp::OpSphere, primTbId );
1013 createTool( GEOMOp::OpTorus, primTbId );
1014 createTool( GEOMOp::OpCone, primTbId );
1015 createTool( GEOMOp::OpRectangle, primTbId );
1016 createTool( GEOMOp::OpDisk, primTbId );
1018 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1019 createTool( GEOMOp::OpFuse, boolTbId );
1020 createTool( GEOMOp::OpCommon, boolTbId );
1021 createTool( GEOMOp::OpCut, boolTbId );
1022 createTool( GEOMOp::OpSection, boolTbId );
1024 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1025 createTool( GEOMOp::OpPrism, genTbId );
1026 createTool( GEOMOp::OpRevolution, genTbId );
1027 createTool( GEOMOp::OpFilling, genTbId );
1028 createTool( GEOMOp::OpPipe, genTbId );
1030 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1031 createTool( GEOMOp::OpTranslate, transTbId );
1032 createTool( GEOMOp::OpRotate, transTbId );
1033 createTool( GEOMOp::OpChangeLoc, transTbId );
1034 createTool( GEOMOp::OpMirror, transTbId );
1035 createTool( GEOMOp::OpScale, transTbId );
1036 createTool( GEOMOp::OpOffset, transTbId );
1037 createTool( separator(), transTbId );
1038 createTool( GEOMOp::OpMultiTranslate, transTbId );
1039 createTool( GEOMOp::OpMultiRotate, transTbId );
1041 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1042 createTool( GEOMOp::Op2dSketcher, operTbId );
1043 createTool( GEOMOp::Op3dSketcher, operTbId );
1044 createTool( separator(), operTbId );
1045 createTool( GEOMOp::OpExplode, operTbId );
1046 createTool( separator(), operTbId );
1047 createTool( GEOMOp::OpPartition, operTbId );
1048 createTool( GEOMOp::OpArchimede, operTbId );
1049 createTool( GEOMOp::OpShapesOnShape, operTbId );
1050 createTool( GEOMOp::OpSharedShapes, operTbId );
1051 createTool( separator(), operTbId );
1052 createTool( GEOMOp::OpFillet1d, operTbId );
1053 createTool( GEOMOp::OpFillet2d, operTbId );
1054 createTool( GEOMOp::OpFillet3d, operTbId );
1055 createTool( GEOMOp::OpChamfer, operTbId );
1057 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1058 createTool( GEOMOp::OpEdge, buildTbId );
1059 createTool( GEOMOp::OpWire, buildTbId );
1060 createTool( GEOMOp::OpFace, buildTbId );
1061 createTool( GEOMOp::OpShell, buildTbId );
1062 createTool( GEOMOp::OpSolid, buildTbId );
1063 createTool( GEOMOp::OpCompound, buildTbId );
1065 int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1066 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1067 createTool( GEOMOp::OpProperties, measureTbId );
1068 createTool( GEOMOp::OpCenterMass, measureTbId );
1069 createTool( GEOMOp::OpInertia, measureTbId );
1070 createTool( GEOMOp::OpNormale, measureTbId );
1071 createTool( separator(), measureTbId );
1072 createTool( GEOMOp::OpBoundingBox, measureTbId );
1073 createTool( GEOMOp::OpMinDistance, measureTbId );
1074 createTool( GEOMOp::OpAngle, measureTbId );
1075 createTool( GEOMOp::OpTolerance , measureTbId );
1076 createTool( separator(), measureTbId );
1077 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1078 createTool( GEOMOp::OpFreeFaces, measureTbId );
1079 createTool( separator(), measureTbId );
1080 createTool( GEOMOp::OpWhatIs, measureTbId );
1081 createTool( GEOMOp::OpCheckShape, measureTbId );
1082 createTool( GEOMOp::OpCheckCompound, measureTbId );
1084 int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1085 createTool( GEOMOp::OpPipeTShape, advancedTbId );
1086 //@@ 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 @@//
1088 // ---- create popup menus --------------------------
1090 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1091 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1093 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1094 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1096 QString autoColorPrefix =
1097 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1099 QtxPopupMgr* mgr = popupMgr();
1101 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1102 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1103 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1104 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1105 mgr->insert( action( GEOMOp::OpShowChildren ), -1, -1 ); // show children
1106 mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
1108 mgr->insert( action( GEOMOp::OpHideChildren ), -1, -1 ); // hide children
1109 mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
1110 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1111 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1112 mgr->insert( separator(), -1, -1 ); // -----------
1113 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1114 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1115 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1116 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1117 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1118 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1119 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1120 mgr->insert( separator(), dispmodeId, -1 );
1121 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1122 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1123 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1124 mgr->insert( separator(), -1, -1 ); // -----------
1125 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1126 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1127 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1128 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1129 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1130 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1131 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1132 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1133 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1134 //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1135 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1136 mgr->insert( separator(), -1, -1 ); // -----------
1137 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1138 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1139 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1140 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1141 mgr->insert( separator(), -1, -1 ); // -----------
1143 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1144 onlyComponent = "((type='Component') and selcount=1)",
1145 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1146 types = "'Shape' 'Group'";
1148 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1149 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1151 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1152 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1154 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1155 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1157 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1159 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1160 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1161 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1162 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1163 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1164 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1165 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1166 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1167 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1168 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1169 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1170 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1171 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1172 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1173 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1174 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1175 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1176 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1177 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1178 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1179 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1180 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1181 mgr->insert( separator(), selectonlyId, -1);
1182 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1183 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1184 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1185 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1186 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1187 mgr->insert( separator(), -1, -1 );
1189 mgr->insert( separator(), -1, -1 ); // -----------
1190 mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1191 mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1194 mgr->insert( action( GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1195 mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1198 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1201 //=======================================================================
1202 // function : GeometryGUI::activateModule()
1203 // purpose : Called when GEOM module is activated
1204 //=======================================================================
1205 bool GeometryGUI::activateModule( SUIT_Study* study )
1207 if ( CORBA::is_nil( myComponentGeom ) )
1210 bool res = SalomeApp_Module::activateModule( study );
1214 setMenuShown( true );
1215 setToolShown( true );
1217 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1218 PyGILState_STATE gstate = PyGILState_Ensure();
1219 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
1220 if(pluginsmanager==NULL)
1224 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());
1229 PyGILState_Release(gstate);
1230 // end of GEOM plugins loading
1232 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1233 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1235 // Reset actions accelerator keys
1236 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1237 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1238 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1240 GUIMap::Iterator it;
1241 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1242 it.value()->activate( application()->desktop() );
1244 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1246 SUIT_ViewManager* vm;
1247 ViewManagerList OCCViewManagers, VTKViewManagers;
1249 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1250 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1251 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1252 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1254 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1255 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1256 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1257 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1260 SALOME_ListIO selected;
1261 sm->selectedObjects( selected );
1262 sm->clearSelected();
1264 // disable OCC selectors
1265 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1266 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1267 while ( itOCCSel.hasNext() )
1268 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1269 sr->setEnabled(true);
1271 // disable VTK selectors
1272 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1273 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1274 while ( itVTKSel.hasNext() )
1275 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1276 sr->setEnabled(true);
1278 sm->setSelectedObjects( selected, true ); //NPAL 19674
1280 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1282 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1284 // 0020836 (Basic vectors and origin)
1285 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1286 if( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1287 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1289 _PTR(Study) studyDS = appStudy->studyDS();
1291 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1292 if( !aSComponent ) // create objects automatically only if there is no GEOM component
1293 createOriginAndBaseVectors();
1302 //=======================================================================
1303 // function : GeometryGUI::deactivateModule()
1304 // purpose : Called when GEOM module is deactivated
1305 //=======================================================================
1306 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1308 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1310 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1312 setMenuShown( false );
1313 setToolShown( false );
1315 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1316 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1318 EmitSignalCloseAllDialogs();
1320 GUIMap::Iterator it;
1321 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1322 it.value()->deactivate();
1324 // Unset actions accelerator keys
1325 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1326 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1327 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1329 qDeleteAll(myOCCSelectors);
1330 myOCCSelectors.clear();
1331 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1333 qDeleteAll(myVTKSelectors);
1334 myVTKSelectors.clear();
1335 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1337 return SalomeApp_Module::deactivateModule( study );
1340 //=======================================================================
1341 // function : onWindowActivated()
1342 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1343 //=======================================================================
1344 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1349 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1350 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1352 // disable non-OCC viewframe menu commands
1353 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1354 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1355 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1356 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1357 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1358 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1359 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1361 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1362 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1364 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1367 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1369 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1370 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1373 void GeometryGUI::viewManagers( QStringList& lst ) const
1375 lst.append( OCCViewer_Viewer::Type() );
1378 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1380 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1382 qDebug( "connect" );
1383 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1384 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1385 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1386 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1387 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1388 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1390 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1391 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1393 // disable OCC selectors
1394 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1395 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1396 while ( itOCCSel.hasNext() )
1397 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1398 sr->setEnabled(true);
1400 else if ( vm->getType() == SVTK_Viewer::Type() )
1402 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1403 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1405 // disable VTK selectors
1406 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1407 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1408 while ( itVTKSel.hasNext() )
1409 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1410 sr->setEnabled(true);
1414 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1416 SUIT_ViewModel* viewer = vm->getViewModel();
1417 if ( vm->getType() == OCCViewer_Viewer::Type() )
1419 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1420 while ( itOCCSel.hasNext() )
1421 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1422 if ( sr->viewer() == viewer )
1424 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1428 if ( vm->getType() == SVTK_Viewer::Type() )
1430 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1431 while ( itVTKSel.hasNext() )
1432 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1433 if ( sr->viewer() == viewer )
1435 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1441 QString GeometryGUI::engineIOR() const
1443 if ( !CORBA::is_nil( GetGeomGen() ) )
1444 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1448 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture( SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight )
1450 theWidth = theHeight = 0;
1451 Handle(Graphic3d_HArray1OfBytes) aTexture;
1453 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1454 aTexture = aTextureMap[ theId ];
1455 if ( aTexture.IsNull() ) {
1456 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1457 if ( !aInsOp->_is_nil() ) {
1458 CORBA::Long aWidth, aHeight;
1459 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1460 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1462 theHeight = aHeight;
1463 aTexture = new Graphic3d_HArray1OfBytes( 1, aStream->length() );
1464 for ( int i = 0; i < aStream->length(); i++ )
1465 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1466 aTextureMap[ theId ] = aTexture;
1474 LightApp_Selection* GeometryGUI::createSelection() const
1476 return new GEOMGUI_Selection();
1479 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1481 SalomeApp_Module::contextMenuPopup(client, menu, title);
1484 getApp()->selectionMgr()->selectedObjects(lst);
1485 if (lst.Extent() < 1)
1488 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1489 _PTR(Study) study = appStudy->studyDS();
1491 bool isImported = true;
1492 SALOME_ListIteratorOfListIO anIt (lst);
1493 for (; anIt.More() && isImported; anIt.Next()) {
1494 Handle(SALOME_InteractiveObject) io = anIt.Value();
1495 _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1497 if (lst.Extent() == 1) {
1498 // Set context menu title
1499 if (client == "OCCViewer" || client == "VTKViewer")
1500 title = QString(aSObj->GetName().c_str());
1503 CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1504 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1505 if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1513 menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
1517 void GeometryGUI::createPreferences()
1519 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1521 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1522 setPreferenceProperty( genGroup, "columns", 2 );
1524 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1525 LightApp_Preferences::Selector,
1526 "Geometry", "display_mode" );
1528 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1529 LightApp_Preferences::Color, "Geometry", "shading_color" );
1531 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1532 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1534 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1535 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1537 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1538 LightApp_Preferences::Color, "Geometry", "line_color" );
1540 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1541 LightApp_Preferences::Color, "Geometry", "point_color" );
1543 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1544 LightApp_Preferences::Color, "Geometry", "isos_color" );
1546 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1547 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1549 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1550 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1552 // Quantities with individual precision settings
1553 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1554 setPreferenceProperty( precGroup, "columns", 2 );
1556 const int nbQuantities = 8;
1557 int prec[nbQuantities], ii = 0;
1558 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1559 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1560 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1561 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1562 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1563 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1564 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1565 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1566 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1567 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1568 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1569 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1570 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1571 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1572 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1573 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1575 // Set property for precision value for spinboxes
1576 for ( ii = 0; ii < nbQuantities; ii++ ){
1577 setPreferenceProperty( prec[ii], "min", -14 );
1578 setPreferenceProperty( prec[ii], "max", 14 );
1579 setPreferenceProperty( prec[ii], "precision", 2 );
1582 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1583 setPreferenceProperty( VertexGroup, "columns", 2 );
1585 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1586 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1588 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1589 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1591 // Set property for default display mode
1592 QStringList aModesList;
1593 aModesList.append( tr("MEN_WIREFRAME") );
1594 aModesList.append( tr("MEN_SHADING") );
1596 QList<QVariant> anIndexesList;
1597 anIndexesList.append(0);
1598 anIndexesList.append(1);
1600 setPreferenceProperty( dispmode, "strings", aModesList );
1601 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1603 // Set property for step value for spinboxes
1604 setPreferenceProperty( step, "min", 1 );
1605 setPreferenceProperty( step, "max", 10000 );
1606 setPreferenceProperty( step, "precision", 3 );
1608 // Set property for deflection value for spinboxes
1609 setPreferenceProperty( defl, "min", DEFLECTION_MIN );
1610 setPreferenceProperty( defl, "max", 1.0 );
1611 setPreferenceProperty( defl, "step", 1.0e-04 );
1612 setPreferenceProperty( defl, "precision", 6 );
1614 // Set property vertex marker type
1615 QList<QVariant> aMarkerTypeIndicesList;
1616 QList<QVariant> aMarkerTypeIconsList;
1618 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1619 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1620 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1621 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1622 aMarkerTypeIndicesList << (i-1);
1623 aMarkerTypeIconsList << pixmap;
1626 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1627 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
1629 // Set property for vertex marker scale
1630 QList<QVariant> aMarkerScaleIndicesList;
1631 QStringList aMarkerScaleValuesList;
1633 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
1634 aMarkerScaleIndicesList << iii;
1635 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
1638 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1639 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1641 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
1642 setPreferenceProperty( originGroup, "columns", 2 );
1644 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
1645 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
1646 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
1647 setPreferenceProperty( baseVectorsLength, "max", 1000 );
1649 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
1650 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
1653 int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
1654 setPreferenceProperty( operationsGroup, "columns", 2 );
1656 addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
1657 LightApp_Preferences::Bool, "Geometry", "geom_preview" );
1661 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1663 if (section == "Geometry") {
1664 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1665 if (param == QString("SettingsGeomStep")) {
1666 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1667 EmitSignalDefaultStepValueChanged(spin_step);
1672 LightApp_Displayer* GeometryGUI::displayer()
1675 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1679 void GeometryGUI::setLocalSelectionMode(const int mode)
1681 myLocalSelectionMode = mode;
1683 int GeometryGUI::getLocalSelectionMode() const
1685 return myLocalSelectionMode;
1688 const char gSeparator = '_'; // character used to separate parameter names
1689 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1692 * \brief Store visual parameters
1694 * This method is called just before the study document is saved.
1695 * Store visual parameters in AttributeParameter attribue(s)
1697 void GeometryGUI::storeVisualParameters (int savePoint)
1699 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1700 if (!appStudy || !appStudy->studyDS())
1702 _PTR(Study) studyDS = appStudy->studyDS();
1704 // componentName is used for encoding of entries when storing them in IParameters
1705 std::string componentName = myComponentGeom->ComponentDataType();
1706 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1707 //if (!aSComponent) return;
1710 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1711 componentName.c_str(),
1713 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1715 QList<SUIT_ViewManager*> lst;
1716 QList<SUIT_ViewManager*>::Iterator it;
1718 // main cycle to store parameters of displayed objects
1720 getApp()->viewManagers(lst);
1721 for (it = lst.begin(); it != lst.end(); it++) {
1722 SUIT_ViewManager* vman = *it;
1723 QString vType = vman->getType();
1724 int aMgrId = vman->getGlobalId();
1725 // saving VTK actors properties
1726 QVector<SUIT_ViewWindow*> views = vman->getViews();
1727 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
1728 const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
1729 ObjMap::ConstIterator o_it = anObjects.begin();
1730 for( ;o_it != anObjects.end(); o_it++ ) {
1731 const PropMap aProps = o_it.value();
1733 //Check that object exists in the study
1734 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
1737 // entry is "encoded" = it does NOT contain component adress, since it is a
1738 // subject to change on next component loading
1740 std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
1742 _PTR(GenericAttribute) anAttr;
1743 if( !obj->FindAttribute(anAttr, "AttributeIOR"))
1746 std::string param, occParam = vType.toLatin1().data();
1747 occParam += NAME_SEPARATOR;
1748 occParam += QString::number(aMgrId).toLatin1().data();
1749 occParam += NAME_SEPARATOR;
1751 param = occParam + VISIBILITY_PROP;
1752 ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
1754 param = occParam + DISPLAY_MODE_PROP;
1756 ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
1758 QColor c = aProps.value(COLOR_PROP).value<QColor>();
1759 QString colorStr = QString::number(c.red()/255.);
1760 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
1761 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
1762 param = occParam + COLOR_PROP;
1763 ip->setParameter(entry, param, colorStr.toLatin1().data());
1765 if(vType == SVTK_Viewer::Type()) {
1766 param = occParam + OPACITY_PROP;
1767 ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1768 } else if (vType == SOCC_Viewer::Type()) {
1769 param = occParam + TRANSPARENCY_PROP;
1770 ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1773 param = occParam + ISOS_PROP;
1774 ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
1776 param = occParam + VECTOR_MODE_PROP;
1777 ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
1779 param = occParam + DEFLECTION_COEFF_PROP;
1780 ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
1782 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
1783 if(aProps.contains(MARKER_TYPE_PROP)) {
1784 param = occParam + MARKER_TYPE_PROP;
1785 ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
1788 } // object iterator
1790 } // for (viewManagers)
1793 * \brief Restore visual parameters
1795 * This method is called after the study document is opened.
1796 * Restore visual parameters from AttributeParameter attribue(s)
1798 void GeometryGUI::restoreVisualParameters (int savePoint)
1800 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1801 if (!appStudy || !appStudy->studyDS())
1803 _PTR(Study) studyDS = appStudy->studyDS();
1805 // componentName is used for encoding of entries when storing them in IParameters
1806 std::string componentName = myComponentGeom->ComponentDataType();
1807 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1808 //if (!aSComponent) return;
1811 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1812 componentName.c_str(),
1814 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1816 std::vector<std::string> entries = ip->getEntries();
1818 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
1820 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1821 QString entry (ip->decodeEntry(*entIt).c_str());
1823 // Check that the entry corresponds to a real object in the Study
1824 // as the object may be deleted or modified after the visual state is saved.
1825 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1826 if (!so) continue; //Skip the not existent entry
1828 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1829 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1831 std::vector<std::string>::iterator namesIt = paramNames.begin();
1832 std::vector<std::string>::iterator valuesIt = paramValues.begin();
1834 // actors are stored in a map after displaying of them for
1835 // quicker access in the future: map < viewID to actor >
1836 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
1837 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
1839 QString viewerTypStr;
1840 QString viewIndexStr;
1842 QVector<PropMap> aListOfMap;
1844 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
1846 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
1847 // '_' is used as separator and should not be used in viewer type or parameter names.
1848 QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts);
1849 if (lst.size() != 3)
1852 viewerTypStr = lst[0];
1853 viewIndexStr = lst[1];
1854 QString paramNameStr = lst[2];
1857 viewIndex = viewIndexStr.toUInt(&ok);
1858 if (!ok) // bad conversion of view index to integer
1861 if((viewIndex + 1) > aListOfMap.count()) {
1862 aListOfMap.resize(viewIndex + 1);
1865 QString val((*valuesIt).c_str());
1866 if(paramNameStr == VISIBILITY_PROP){
1867 aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0);
1869 } else if(paramNameStr == OPACITY_PROP) {
1870 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
1872 } else if(paramNameStr == TRANSPARENCY_PROP) {
1873 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, val.toDouble());
1875 } else if(paramNameStr == DISPLAY_MODE_PROP) {
1876 aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
1878 } else if(paramNameStr == ISOS_PROP) {
1879 aListOfMap[viewIndex].insert( ISOS_PROP, val);
1881 } else if(paramNameStr == COLOR_PROP) {
1882 QStringList rgb = val.split(DIGIT_SEPARATOR);
1883 if(rgb.count() == 3) {
1884 QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255));
1885 aListOfMap[viewIndex].insert( COLOR_PROP, c);
1887 } else if(paramNameStr == VECTOR_MODE_PROP) {
1888 aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt());
1890 } else if(paramNameStr == DEFLECTION_COEFF_PROP) {
1891 aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
1892 } else if(paramNameStr == MARKER_TYPE_PROP) {
1893 aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
1896 } // for names/parameters iterator
1898 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
1900 for (int index = 0 ; index < aListOfMap.count(); index++) {
1902 appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
1904 QColor c = aListOfMap[index].value(COLOR_PROP).value<QColor>();
1905 //Get Visibility property of the current PropMap
1906 if (aListOfMap[index].value(VISIBILITY_PROP) == 1) {
1907 SUIT_ViewManager* vman = lst.at(index);
1908 SUIT_ViewModel* vmodel = vman->getViewModel();
1909 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
1913 } // for entries iterator
1915 // update all VTK and OCC views
1916 QList<SUIT_ViewManager*> lst;
1917 getApp()->viewManagers(lst);
1918 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
1919 SUIT_ViewModel* vmodel = (*it)->getViewModel();
1922 if (vmodel->getType() == SVTK_Viewer::Type()) {
1923 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
1924 vtkView->getRenderer()->ResetCameraClippingRange();
1927 else if (vmodel->getType() == SOCC_Viewer::Type()) {
1928 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
1929 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
1936 void GeometryGUI::onViewAboutToShow()
1938 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
1939 QAction* a = action( GEOMOp::OpSwitchVectors );
1941 a->setEnabled(true);
1942 bool vmode = window->property("VectorsMode").toBool();
1943 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
1945 a->setText ( tr("MEN_VECTOR_MODE_ON") );
1946 a->setEnabled(false);
1951 Rename object by entry.
1952 \param entry entry of the object
1953 \param name new name of the object
1954 \brief Return \c true if rename operation finished successfully, \c false otherwise.
1956 bool GeometryGUI::renameObject( const QString& entry, const QString& name) {
1958 bool appRes = SalomeApp_Module::renameObject(entry,name);
1962 bool result = false;
1964 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
1965 SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
1970 _PTR(Study) aStudy = appStudy->studyDS();
1975 _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
1976 _PTR(GenericAttribute) anAttr;
1978 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
1979 _PTR(AttributeName) aName (anAttr);
1981 GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
1982 if (!CORBA::is_nil(anObj)) {
1983 aName->SetValue( name.toLatin1().data() ); // rename the SObject
1984 anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object