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_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>
78 #include <AIS_Drawer.hxx>
79 #include <AIS_ListOfInteractive.hxx>
80 #include <AIS_ListIteratorOfListOfInteractive.hxx>
81 #include <Prs3d_Drawer.hxx>
82 #include <Prs3d_IsoAspect.hxx>
83 #include <Aspect_TypeOfMarker.hxx>
84 #include <OSD_SharedLibrary.hxx>
85 #include <NCollection_DataMap.hxx>
86 #include <Graphic3d_HArray1OfBytes.hxx>
88 #include <utilities.h>
90 #include <vtkCamera.h>
91 #include <vtkRenderer.h>
93 #include "GEOMImpl_Types.hxx"
96 Standard_EXPORT CAM_Module* createModule() {
97 return new GeometryGUI();
101 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
103 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
105 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
107 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
108 if (CORBA::is_nil(myComponentGeom))
110 return GeometryGUI::myComponentGeom;
113 bool GeometryGUI::InitGeomGen()
116 if( CORBA::is_nil( myComponentGeom ) ) return false;
120 //=======================================================================
121 // function : ClientSObjectToObject
123 //=======================================================================
124 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
126 _PTR(GenericAttribute) anAttr;
127 CORBA::Object_var anObj;
129 std::string aValue = theSObject->GetIOR();
130 if (strcmp(aValue.c_str(), "") != 0) {
131 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
132 anObj = anORB->string_to_object(aValue.c_str());
135 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
137 return anObj._retn();
140 //=======================================================================
141 // function : ClientStudyToStudy
143 //=======================================================================
144 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
146 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
147 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
148 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
149 int aStudyID = theStudy->StudyId();
150 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
151 return aDSStudy._retn();
154 void GeometryGUI::Modified( bool theIsUpdateActions )
156 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
157 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
158 appStudy->Modified();
159 if( theIsUpdateActions )
160 app->updateActions();
165 //=======================================================================
166 // function : GeometryGUI::GeometryGUI()
167 // purpose : Constructor
168 //=======================================================================
169 GeometryGUI::GeometryGUI() :
170 SalomeApp_Module( "GEOM" ),
171 LightApp_Module( "GEOM" )
173 if ( CORBA::is_nil( myComponentGeom ) )
175 Engines::EngineComponent_var comp =
176 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
177 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
180 myActiveDialogBox = 0;
182 gp_Pnt origin = gp_Pnt(0., 0., 0.);
183 gp_Dir direction = gp_Dir(0., 0., 1.);
184 myWorkingPlane = gp_Ax3(origin, direction);
187 myLocalSelectionMode = GEOM_ALLOBJECTS;
190 //=======================================================================
191 // function : GeometryGUI::~GeometryGUI()
192 // purpose : Destructor
193 //=======================================================================
194 GeometryGUI::~GeometryGUI()
196 while (!myOCCSelectors.isEmpty())
197 delete myOCCSelectors.takeFirst();
199 while (!myVTKSelectors.isEmpty())
200 delete myVTKSelectors.takeFirst();
202 qDeleteAll(myGUIMap);
205 //=======================================================================
206 // function : GeometryGUI::getLibrary()
207 // purpose : get or load GUI library by name [ internal ]
208 //=======================================================================
209 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
210 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
212 if ( !myGUIMap.contains( libraryName ) ) {
213 // try to load library if it is not loaded yet
215 QString dirs = getenv( "LD_LIBRARY_PATH" );
218 QString dirs = getenv( "PATH" );
221 if ( !dirs.isEmpty() ) {
222 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
223 QListIterator<QString> it( dirList ); it.toBack();
224 while ( it.hasPrevious() ) {
225 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
227 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
228 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
230 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
231 continue; // continue search further
233 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
234 if ( osdF != NULL ) {
235 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
236 GEOMGUI* libGUI = (*func)( this );
238 myGUIMap[ libraryName ] = libGUI;
239 break; // found and loaded!
246 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
249 //=======================================================================
250 // function : GeometryGUI::ActiveWorkingPlane()
251 // purpose : Activate Working Plane View
252 //=======================================================================
253 void GeometryGUI::ActiveWorkingPlane()
255 gp_Dir DZ = myWorkingPlane.Direction();
256 gp_Dir DY = myWorkingPlane.YDirection();
258 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
259 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
260 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
263 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
265 Handle(V3d_View) view3d = vw->getViewPort()->getView();
267 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
268 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
274 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
276 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
278 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
279 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
280 camera->SetFocalPoint(0,0,0);
287 //=======================================================================
288 // function : GeometryGUI::SetActiveDialogBox()
289 // purpose : Set active dialog box
290 //=======================================================================
291 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
293 myActiveDialogBox = (QDialog*)aDlg;
296 //=======================================================================
297 // function : GeometryGUI::EmitSignalDeactivateDialog()
298 // purpose : Emit a signal to deactivate the active dialog Box
299 //=======================================================================
300 void GeometryGUI::EmitSignalDeactivateDialog()
302 emit SignalDeactivateActiveDialog();
305 //=======================================================================
306 // function : GeometryGUI::EmitSignalCloseAllDialogs()
307 // purpose : Emit a signal to close all non modal dialogs box
308 //=======================================================================
309 void GeometryGUI::EmitSignalCloseAllDialogs()
311 emit SignalCloseAllDialogs();
314 //=======================================================================
315 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
316 // purpose : Emit a signal to inform that default real spin box step has
318 //=======================================================================
319 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
321 emit SignalDefaultStepValueChanged(newVal);
324 //=======================================================================
325 // function : GeometryGUI::OnGUIEvent()
326 // purpose : common slot for all menu/toolbar actions
327 //=======================================================================
328 void GeometryGUI::OnGUIEvent()
330 const QObject* obj = sender();
331 if ( !obj || !obj->inherits( "QAction" ) )
333 int id = actionId((QAction*)obj);
338 //=======================================================================
339 // function : GeometryGUI::OnGUIEvent()
340 // purpose : manage all events on GUI [static]
341 //=======================================================================
342 void GeometryGUI::OnGUIEvent( int id )
344 SUIT_Application* anApp = application();
346 SUIT_Desktop* desk = anApp->desktop();
348 // check type of the active viewframe
349 SUIT_ViewWindow* window = desk->activeWindow();
350 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
351 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
352 // if current viewframe is not of OCC and not of VTK type - return immediately
353 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
354 QList<int> NotViewerDependentCommands;
355 NotViewerDependentCommands << GEOMOp::OpRename
358 << GEOMOp::OpShowOnly
359 << GEOMOp::OpShowChildren
360 << GEOMOp::OpHideChildren
361 << GEOMOp::OpPointMarker;
362 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
365 // fix for IPAL9103, point 2
366 if ( CORBA::is_nil( GetGeomGen() ) ) {
367 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
372 // find corresponding GUI library
374 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
375 createOriginAndBaseVectors(); // internal operation
377 case GEOMOp::OpImport: // MENU FILE - IMPORT
378 case GEOMOp::OpExport: // MENU FILE - EXPORT
379 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
380 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
381 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
382 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
383 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
384 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
385 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
386 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
387 case GEOMOp::OpDelete: // MENU EDIT - DELETE
388 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
389 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
390 case GEOMOp::OpColor: // POPUP MENU - COLOR
391 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
392 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
393 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
394 case GEOMOp::OpIsos: // POPUP MENU - ISOS
395 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
396 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
397 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
398 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
399 case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
400 case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN
401 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
402 case GEOMOp::OpRename: // POPUP MENU - RENAME
403 libName = "GEOMToolsGUI";
405 case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
406 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
407 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
408 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
409 case GEOMOp::OpHide: // MENU VIEW - ERASE
410 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
411 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
412 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
413 case GEOMOp::OpShading: // POPUP MENU - SHADING
414 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
415 libName = "DisplayGUI";
417 case GEOMOp::OpPoint: // MENU BASIC - POINT
418 case GEOMOp::OpLine: // MENU BASIC - LINE
419 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
420 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
421 case GEOMOp::OpArc: // MENU BASIC - ARC
422 case GEOMOp::OpVector: // MENU BASIC - VECTOR
423 case GEOMOp::OpPlane: // MENU BASIC - PLANE
424 case GEOMOp::OpCurve: // MENU BASIC - CURVE
425 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
426 libName = "BasicGUI";
428 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
429 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
430 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
431 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
432 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
433 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
434 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
435 libName = "PrimitiveGUI";
437 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
438 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
439 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
440 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
441 libName = "GenerationGUI";
443 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
444 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
445 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
446 libName = "EntityGUI";
448 case GEOMOp::OpEdge: // MENU BUILD - EDGE
449 case GEOMOp::OpWire: // MENU BUILD - WIRE
450 case GEOMOp::OpFace: // MENU BUILD - FACE
451 case GEOMOp::OpShell: // MENU BUILD - SHELL
452 case GEOMOp::OpSolid: // MENU BUILD - SOLID
453 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
454 libName = "BuildGUI";
456 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
457 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
458 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
459 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
460 libName = "BooleanGUI";
462 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
463 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
464 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
465 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
466 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
467 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
468 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
469 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
470 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
471 libName = "TransformationGUI";
473 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
474 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
475 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
476 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
477 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
478 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
479 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
480 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
481 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
482 libName = "OperationGUI";
484 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
485 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
486 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
487 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
488 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
489 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
490 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
491 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
492 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
493 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
494 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
495 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
496 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
497 libName = "RepairGUI";
499 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
500 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
501 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
502 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
503 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
504 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
505 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
506 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
507 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
508 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
509 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
510 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
511 libName = "MeasureGUI";
513 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
514 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
515 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
516 libName = "GroupGUI";
518 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
519 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
520 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
521 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
522 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
523 libName = "BlocksGUI";
525 case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
526 case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
527 // case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
528 //@@ 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 @@//
529 libName = "AdvancedGUI";
535 GEOMGUI* library = 0;
536 if ( !libName.isEmpty() ) {
538 libName = QString( "lib" ) + libName + ".so";
540 libName = libName + ".dll";
542 library = getLibrary( libName );
545 // call method of corresponding GUI library
547 library->OnGUIEvent( id, desk );
549 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
552 //=================================================================================
553 // function : GeometryGUI::OnKeyPress()
554 // purpose : Called when any key is pressed by user [static]
555 //=================================================================================
556 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
558 if ( !application() )
560 foreach ( GEOMGUI* lib, myGUIMap )
561 lib->OnKeyPress( e, application()->desktop(), w );
564 //=================================================================================
565 // function : GeometryGUI::OnMouseMove()
566 // purpose : Manages mouse move events [static]
567 //=================================================================================
568 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
570 if ( !application() )
572 foreach ( GEOMGUI* lib, myGUIMap )
573 lib->OnMouseMove( e, application()->desktop(), w );
576 //=================================================================================
577 // function : GeometryGUI::OnMousePress()
578 // purpose : Manage mouse press events [static]
579 //=================================================================================
580 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
582 if ( !application() )
584 foreach ( GEOMGUI* lib, myGUIMap )
585 lib->OnMousePress( e, application()->desktop(), w );
588 //=======================================================================
589 // function : createGeomAction
591 //=======================================================================
592 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
593 const int accel, const bool toggle, const QString& shortcutAction )
595 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
596 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
597 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
599 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
601 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
602 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
604 application()->desktop(),
606 this, SLOT( OnGUIEvent() ),
610 //=======================================================================
611 // function : createOriginAndBaseVectors
613 //=======================================================================
614 void GeometryGUI::createOriginAndBaseVectors()
616 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
618 _PTR(Study) studyDS = appStudy->studyDS();
619 if( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
620 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
621 if( !aBasicOperations->_is_nil() ) {
622 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
623 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
624 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
625 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
626 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
627 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
629 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
630 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
631 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
632 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
633 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
635 getApp()->updateObjectBrowser( false );
641 //=======================================================================
642 // function : GeometryGUI::initialize()
643 // purpose : Called when GEOM module is created
644 //=======================================================================
645 void GeometryGUI::initialize( CAM_Application* app )
647 SalomeApp_Module::initialize( app );
649 // ----- create actions --------------
651 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
652 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
654 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
656 createGeomAction( GEOMOp::OpPoint, "POINT" );
657 createGeomAction( GEOMOp::OpLine, "LINE" );
658 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
659 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
660 createGeomAction( GEOMOp::OpArc, "ARC" );
661 createGeomAction( GEOMOp::OpCurve, "CURVE" );
662 createGeomAction( GEOMOp::OpVector, "VECTOR" );
663 createGeomAction( GEOMOp::OpPlane, "PLANE" );
664 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
665 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
667 createGeomAction( GEOMOp::OpBox, "BOX" );
668 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
669 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
670 createGeomAction( GEOMOp::OpTorus, "TORUS" );
671 createGeomAction( GEOMOp::OpCone, "CONE" );
672 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
673 createGeomAction( GEOMOp::OpDisk, "DISK" );
675 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
676 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
677 createGeomAction( GEOMOp::OpFilling, "FILLING" );
678 createGeomAction( GEOMOp::OpPipe, "PIPE" );
680 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
681 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
683 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
685 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
686 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
688 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
689 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
690 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
692 createGeomAction( GEOMOp::OpEdge, "EDGE" );
693 createGeomAction( GEOMOp::OpWire, "WIRE" );
694 createGeomAction( GEOMOp::OpFace, "FACE" );
695 createGeomAction( GEOMOp::OpShell, "SHELL" );
696 createGeomAction( GEOMOp::OpSolid, "SOLID" );
697 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
699 createGeomAction( GEOMOp::OpFuse, "FUSE" );
700 createGeomAction( GEOMOp::OpCommon, "COMMON" );
701 createGeomAction( GEOMOp::OpCut, "CUT" );
702 createGeomAction( GEOMOp::OpSection, "SECTION" );
704 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
705 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
706 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
707 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
708 createGeomAction( GEOMOp::OpScale, "SCALE" );
709 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
710 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
711 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
713 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
714 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
715 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
716 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
717 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
718 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
719 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
720 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
721 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
723 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
724 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
725 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
727 createGeomAction( GEOMOp::OpSewing, "SEWING" );
728 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
729 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
730 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
731 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
732 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
733 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
734 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
735 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
736 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
737 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
738 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
739 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
741 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
742 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
743 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
744 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
745 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
746 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
747 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
748 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
750 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
751 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
752 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
753 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
755 #ifdef _DEBUG_ // PAL16821
756 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
759 createGeomAction( GEOMOp::OpDisplayMode, "SHADING" );
760 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
761 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
762 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
763 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
764 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
765 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
766 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
767 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
768 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
769 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
770 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
771 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
772 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
773 createGeomAction( GEOMOp::OpHide, "ERASE" );
775 createGeomAction( GEOMOp::OpRename, "POP_RENAME", "", Qt::Key_F2 );
776 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
777 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
778 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
779 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
780 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
781 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
782 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
783 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
784 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
785 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
786 createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" );
787 createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" );
788 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
790 createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
792 // Create actions for increase/decrease transparency shortcuts
793 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
794 "Geometry:Increase transparency");
795 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
796 "Geometry:Decrease transparency");
798 // Create actions for increase/decrease number of isolines
799 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
800 "Geometry:Increase number of isolines");
801 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
802 "Geometry:Decrease number of isolines");
804 // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
805 //@@ 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 @@//
807 // ---- create menus --------------------------
809 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
810 createMenu( separator(), fileId, 10 );
811 createMenu( GEOMOp::OpImport, fileId, 10 );
812 createMenu( GEOMOp::OpExport, fileId, 10 );
813 createMenu( separator(), fileId, -1 );
815 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
816 createMenu( GEOMOp::OpDelete, editId, -1 );
818 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
820 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
821 createMenu( GEOMOp::OpPoint, basicId, -1 );
822 createMenu( GEOMOp::OpLine, basicId, -1 );
823 createMenu( GEOMOp::OpCircle, basicId, -1 );
824 createMenu( GEOMOp::OpEllipse, basicId, -1 );
825 createMenu( GEOMOp::OpArc, basicId, -1 );
826 createMenu( GEOMOp::OpCurve, basicId, -1 );
827 createMenu( separator(), basicId, -1 );
828 createMenu( GEOMOp::OpVector, basicId, -1 );
829 createMenu( GEOMOp::OpPlane, basicId, -1 );
830 createMenu( GEOMOp::OpLCS, basicId, -1 );
831 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
833 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
834 createMenu( GEOMOp::OpBox, primId, -1 );
835 createMenu( GEOMOp::OpCylinder, primId, -1 );
836 createMenu( GEOMOp::OpSphere, primId, -1 );
837 createMenu( GEOMOp::OpTorus, primId, -1 );
838 createMenu( GEOMOp::OpCone, primId, -1 );
839 createMenu( GEOMOp::OpRectangle, primId, -1 );
840 createMenu( GEOMOp::OpDisk, primId, -1 );
842 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
843 createMenu( GEOMOp::OpPrism, genId, -1 );
844 createMenu( GEOMOp::OpRevolution, genId, -1 );
845 createMenu( GEOMOp::OpFilling, genId, -1 );
846 createMenu( GEOMOp::OpPipe, genId, -1 );
848 int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
849 createMenu( GEOMOp::OpPipeTShape, advId, -1 );
850 // createMenu( GEOMOp::OpPipeTShapeGroups, advId, -1 );
851 //@@ 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 @@//
853 createMenu( separator(), newEntId, -1 );
855 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
856 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
857 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
859 createMenu( separator(), newEntId, -1 );
861 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
862 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
863 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
865 createMenu( separator(), newEntId, -1 );
867 createMenu( GEOMOp::Op2dSketcher, newEntId, -1 );
868 createMenu( GEOMOp::Op3dSketcher, newEntId, -1 );
870 createMenu( separator(), newEntId, -1 );
872 createMenu( GEOMOp::OpExplode, newEntId, -1 );
874 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
875 createMenu( GEOMOp::OpEdge, buildId, -1 );
876 createMenu( GEOMOp::OpWire, buildId, -1 );
877 createMenu( GEOMOp::OpFace, buildId, -1 );
878 createMenu( GEOMOp::OpShell, buildId, -1 );
879 createMenu( GEOMOp::OpSolid, buildId, -1 );
880 createMenu( GEOMOp::OpCompound, buildId, -1 );
882 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
884 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
885 createMenu( GEOMOp::OpFuse, boolId, -1 );
886 createMenu( GEOMOp::OpCommon, boolId, -1 );
887 createMenu( GEOMOp::OpCut, boolId, -1 );
888 createMenu( GEOMOp::OpSection, boolId, -1 );
890 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
891 createMenu( GEOMOp::OpTranslate, transId, -1 );
892 createMenu( GEOMOp::OpRotate, transId, -1 );
893 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
894 createMenu( GEOMOp::OpMirror, transId, -1 );
895 createMenu( GEOMOp::OpScale, transId, -1 );
896 createMenu( GEOMOp::OpOffset, transId, -1 );
897 createMenu( separator(), transId, -1 );
898 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
899 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
901 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
902 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
903 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
904 createMenu( GEOMOp::OpPropagate, blockId, -1 );
906 createMenu( separator(), operId, -1 );
908 createMenu( GEOMOp::OpPartition, operId, -1 );
909 createMenu( GEOMOp::OpArchimede, operId, -1 );
910 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
911 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
913 createMenu( separator(), operId, -1 );
915 createMenu( GEOMOp::OpFillet1d, operId, -1 );
916 createMenu( GEOMOp::OpFillet2d, operId, -1 );
917 createMenu( GEOMOp::OpFillet3d, operId, -1 );
918 createMenu( GEOMOp::OpChamfer, operId, -1 );
919 //createMenu( GEOMOp::OpClipping, operId, -1 );
921 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
922 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
923 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
924 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
925 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
926 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
927 createMenu( GEOMOp::OpSewing, repairId, -1 );
928 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
929 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
930 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
931 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
932 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
933 createMenu( GEOMOp::OpOrientation, repairId, -1 );
934 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
936 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
937 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
938 createMenu( GEOMOp::OpProperties, measurId, -1 );
939 createMenu( separator(), measurId, -1 );
940 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
941 createMenu( GEOMOp::OpInertia, measurId, -1 );
942 createMenu( GEOMOp::OpNormale, measurId, -1 );
943 createMenu( separator(), measurId, -1 );
944 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
945 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
946 createMenu( separator(), measurId, -1 );
948 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
949 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
950 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
951 createMenu( GEOMOp::OpAngle, dimId, -1 );
953 createMenu( separator(), measurId, -1 );
954 createMenu( GEOMOp::OpTolerance, measurId, -1 );
955 createMenu( separator(), measurId, -1 );
956 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
957 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
958 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
960 #ifdef _DEBUG_ // PAL16821
961 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
962 createMenu( separator(), toolsId, -1 );
963 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
966 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
967 createMenu( separator(), viewId, -1 );
969 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
970 createMenu( GEOMOp::OpDisplayMode, dispmodeId, -1 );
971 createMenu( separator(), dispmodeId, -1 );
972 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
974 createMenu( separator(), viewId, -1 );
975 createMenu( GEOMOp::OpShowAll, viewId, -1 );
976 createMenu( GEOMOp::OpHideAll, viewId, -1 );
977 createMenu( separator(), viewId, -1 );
981 because of these items are accessible through object browser and viewers
982 we have removed they from main menu
984 createMenu( GEOMOp::OpShow, viewId, -1 );
985 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
986 createMenu( GEOMOp::OpHide, viewId, -1 );
989 // ---- create toolbars --------------------------
991 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
992 createTool( GEOMOp::OpPoint, basicTbId );
993 createTool( GEOMOp::OpLine, basicTbId );
994 createTool( GEOMOp::OpCircle, basicTbId );
995 createTool( GEOMOp::OpEllipse, basicTbId );
996 createTool( GEOMOp::OpArc, basicTbId );
997 createTool( GEOMOp::OpCurve, basicTbId );
998 createTool( GEOMOp::OpVector, basicTbId );
999 createTool( GEOMOp::OpPlane, basicTbId );
1000 createTool( GEOMOp::OpLCS, basicTbId );
1001 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1003 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1004 createTool( GEOMOp::OpBox, primTbId );
1005 createTool( GEOMOp::OpCylinder, primTbId );
1006 createTool( GEOMOp::OpSphere, primTbId );
1007 createTool( GEOMOp::OpTorus, primTbId );
1008 createTool( GEOMOp::OpCone, primTbId );
1009 createTool( GEOMOp::OpRectangle, primTbId );
1010 createTool( GEOMOp::OpDisk, primTbId );
1012 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1013 createTool( GEOMOp::OpFuse, boolTbId );
1014 createTool( GEOMOp::OpCommon, boolTbId );
1015 createTool( GEOMOp::OpCut, boolTbId );
1016 createTool( GEOMOp::OpSection, boolTbId );
1018 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1019 createTool( GEOMOp::OpPrism, genTbId );
1020 createTool( GEOMOp::OpRevolution, genTbId );
1021 createTool( GEOMOp::OpFilling, genTbId );
1022 createTool( GEOMOp::OpPipe, genTbId );
1024 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1025 createTool( GEOMOp::OpTranslate, transTbId );
1026 createTool( GEOMOp::OpRotate, transTbId );
1027 createTool( GEOMOp::OpChangeLoc, transTbId );
1028 createTool( GEOMOp::OpMirror, transTbId );
1029 createTool( GEOMOp::OpScale, transTbId );
1030 createTool( GEOMOp::OpOffset, transTbId );
1031 createTool( separator(), transTbId );
1032 createTool( GEOMOp::OpMultiTranslate, transTbId );
1033 createTool( GEOMOp::OpMultiRotate, transTbId );
1035 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1036 createTool( GEOMOp::Op2dSketcher, operTbId );
1037 createTool( GEOMOp::Op3dSketcher, operTbId );
1038 createTool( separator(), operTbId );
1039 createTool( GEOMOp::OpExplode, operTbId );
1040 createTool( separator(), operTbId );
1041 createTool( GEOMOp::OpPartition, operTbId );
1042 createTool( GEOMOp::OpArchimede, operTbId );
1043 createTool( GEOMOp::OpShapesOnShape, operTbId );
1044 createTool( GEOMOp::OpSharedShapes, operTbId );
1045 createTool( separator(), operTbId );
1046 createTool( GEOMOp::OpFillet1d, operTbId );
1047 createTool( GEOMOp::OpFillet2d, operTbId );
1048 createTool( GEOMOp::OpFillet3d, operTbId );
1049 createTool( GEOMOp::OpChamfer, operTbId );
1051 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1052 createTool( GEOMOp::OpEdge, buildTbId );
1053 createTool( GEOMOp::OpWire, buildTbId );
1054 createTool( GEOMOp::OpFace, buildTbId );
1055 createTool( GEOMOp::OpShell, buildTbId );
1056 createTool( GEOMOp::OpSolid, buildTbId );
1057 createTool( GEOMOp::OpCompound, buildTbId );
1059 int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1060 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1061 createTool( GEOMOp::OpProperties, measureTbId );
1062 createTool( GEOMOp::OpCenterMass, measureTbId );
1063 createTool( GEOMOp::OpInertia, measureTbId );
1064 createTool( GEOMOp::OpNormale, measureTbId );
1065 createTool( separator(), measureTbId );
1066 createTool( GEOMOp::OpBoundingBox, measureTbId );
1067 createTool( GEOMOp::OpMinDistance, measureTbId );
1068 createTool( GEOMOp::OpAngle, measureTbId );
1069 createTool( GEOMOp::OpTolerance , measureTbId );
1070 createTool( separator(), measureTbId );
1071 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1072 createTool( GEOMOp::OpFreeFaces, measureTbId );
1073 createTool( separator(), measureTbId );
1074 createTool( GEOMOp::OpWhatIs, measureTbId );
1075 createTool( GEOMOp::OpCheckShape, measureTbId );
1076 createTool( GEOMOp::OpCheckCompound, measureTbId );
1078 int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1079 createTool( GEOMOp::OpPipeTShape, advancedTbId );
1080 //@@ 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 @@//
1082 // ---- create popup menus --------------------------
1084 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1085 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1087 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1088 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1090 QString autoColorPrefix =
1091 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1093 QtxPopupMgr* mgr = popupMgr();
1094 mgr->insert( action( GEOMOp::OpRename ), -1, -1 ); // rename
1095 mgr->setRule( action( GEOMOp::OpRename ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
1096 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1097 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1098 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1099 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1100 mgr->insert( action( GEOMOp::OpShowChildren ), -1, -1 ); // show children
1101 mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
1102 mgr->insert( action( GEOMOp::OpHideChildren ), -1, -1 ); // hide children
1103 mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
1104 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1105 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1106 mgr->insert( separator(), -1, -1 ); // -----------
1107 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1108 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1109 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1110 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1111 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1112 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1113 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1114 mgr->insert( separator(), dispmodeId, -1 );
1115 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1116 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1117 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1118 mgr->insert( separator(), -1, -1 ); // -----------
1119 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1120 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1121 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1122 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1123 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1124 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1125 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1126 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1127 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1128 //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1129 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1130 mgr->insert( separator(), -1, -1 ); // -----------
1131 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1132 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1133 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1134 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1135 mgr->insert( separator(), -1, -1 ); // -----------
1137 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1138 onlyComponent = "((type='Component') and selcount=1)",
1139 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1140 types = "'Shape' 'Group'";
1142 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1143 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1145 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1146 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1148 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1149 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1151 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1153 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1154 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1155 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1156 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1157 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1158 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1159 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1160 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1161 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1162 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1163 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1164 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1165 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1166 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1167 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1168 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1169 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1170 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1171 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1172 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1173 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1174 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1175 mgr->insert( separator(), selectonlyId, -1);
1176 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1177 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1178 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1179 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1180 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1181 mgr->insert( separator(), -1, -1 );
1183 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1186 //=======================================================================
1187 // function : GeometryGUI::activateModule()
1188 // purpose : Called when GEOM module is activated
1189 //=======================================================================
1190 bool GeometryGUI::activateModule( SUIT_Study* study )
1192 if ( CORBA::is_nil( myComponentGeom ) )
1195 bool res = SalomeApp_Module::activateModule( study );
1200 setMenuShown( true );
1201 setToolShown( true );
1203 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1204 PyGILState_STATE gstate = PyGILState_Ensure();
1205 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
1206 if(pluginsmanager==NULL)
1210 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());
1215 PyGILState_Release(gstate);
1216 // end of GEOM plugins loading
1218 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1219 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1221 // Reset actions accelerator keys
1222 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1223 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1224 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1225 action(GEOMOp::OpRename)->setEnabled( true ); // Rename: Key_F2
1227 GUIMap::Iterator it;
1228 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1229 it.value()->activate( application()->desktop() );
1231 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1233 SUIT_ViewManager* vm;
1234 ViewManagerList OCCViewManagers, VTKViewManagers;
1236 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1237 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1238 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1239 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1241 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1242 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1243 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1244 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1247 SALOME_ListIO selected;
1248 sm->selectedObjects( selected );
1249 sm->clearSelected();
1251 // disable OCC selectors
1252 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1253 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1254 while ( itOCCSel.hasNext() )
1255 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1256 sr->setEnabled(true);
1258 // disable VTK selectors
1259 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1260 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1261 while ( itVTKSel.hasNext() )
1262 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1263 sr->setEnabled(true);
1265 sm->setSelectedObjects( selected, true ); //NPAL 19674
1267 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1269 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1271 // 0020836 (Basic vectors and origin)
1272 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1273 if( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1274 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1276 _PTR(Study) studyDS = appStudy->studyDS();
1278 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1279 if( !aSComponent ) // create objects automatically only if there is no GEOM component
1280 createOriginAndBaseVectors();
1289 //=======================================================================
1290 // function : GeometryGUI::deactivateModule()
1291 // purpose : Called when GEOM module is deactivated
1292 //=======================================================================
1293 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1295 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1297 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1299 setMenuShown( false );
1300 setToolShown( false );
1302 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1303 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1305 EmitSignalCloseAllDialogs();
1307 GUIMap::Iterator it;
1308 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1309 it.value()->deactivate();
1311 // Unset actions accelerator keys
1312 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1313 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1314 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1315 action(GEOMOp::OpRename)->setEnabled( false ); // Rename: Key_F2
1317 qDeleteAll(myOCCSelectors);
1318 myOCCSelectors.clear();
1319 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1321 qDeleteAll(myVTKSelectors);
1322 myVTKSelectors.clear();
1323 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1325 return SalomeApp_Module::deactivateModule( study );
1328 //=======================================================================
1329 // function : onWindowActivated()
1330 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1331 //=======================================================================
1332 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1337 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1338 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1340 // disable non-OCC viewframe menu commands
1341 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1342 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1343 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1344 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1345 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1346 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1347 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1349 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1350 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1352 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1355 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1357 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1358 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1361 void GeometryGUI::viewManagers( QStringList& lst ) const
1363 lst.append( OCCViewer_Viewer::Type() );
1366 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1368 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1370 qDebug( "connect" );
1371 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1372 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1373 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1374 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1375 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1376 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1378 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1379 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1381 // disable OCC selectors
1382 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1383 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1384 while ( itOCCSel.hasNext() )
1385 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1386 sr->setEnabled(true);
1388 else if ( vm->getType() == SVTK_Viewer::Type() )
1390 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1391 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1393 // disable VTK selectors
1394 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1395 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1396 while ( itVTKSel.hasNext() )
1397 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1398 sr->setEnabled(true);
1402 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1404 SUIT_ViewModel* viewer = vm->getViewModel();
1405 if ( vm->getType() == OCCViewer_Viewer::Type() )
1407 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1408 while ( itOCCSel.hasNext() )
1409 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1410 if ( sr->viewer() == viewer )
1412 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1416 if ( vm->getType() == SVTK_Viewer::Type() )
1418 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1419 while ( itVTKSel.hasNext() )
1420 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1421 if ( sr->viewer() == viewer )
1423 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1429 QString GeometryGUI::engineIOR() const
1431 if ( !CORBA::is_nil( GetGeomGen() ) )
1432 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1436 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture( SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight )
1438 theWidth = theHeight = 0;
1439 Handle(Graphic3d_HArray1OfBytes) aTexture;
1441 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1442 aTexture = aTextureMap[ theId ];
1443 if ( aTexture.IsNull() ) {
1444 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1445 if ( !aInsOp->_is_nil() ) {
1446 CORBA::Long aWidth, aHeight;
1447 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1448 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1450 theHeight = aHeight;
1451 aTexture = new Graphic3d_HArray1OfBytes( 1, aStream->length() );
1452 for ( int i = 0; i < aStream->length(); i++ )
1453 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1454 aTextureMap[ theId ] = aTexture;
1462 LightApp_Selection* GeometryGUI::createSelection() const
1464 return new GEOMGUI_Selection();
1467 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1469 SalomeApp_Module::contextMenuPopup(client, menu, title);
1472 getApp()->selectionMgr()->selectedObjects(lst);
1473 if (lst.Extent() < 1)
1476 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1477 _PTR(Study) study = appStudy->studyDS();
1479 bool isImported = true;
1480 SALOME_ListIteratorOfListIO anIt (lst);
1481 for (; anIt.More() && isImported; anIt.Next()) {
1482 Handle(SALOME_InteractiveObject) io = anIt.Value();
1483 _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1485 if (lst.Extent() == 1) {
1486 // Set context menu title
1487 if (client == "OCCViewer" || client == "VTKViewer")
1488 title = QString(aSObj->GetName().c_str());
1491 CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1492 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1493 if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1501 menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
1505 void GeometryGUI::createPreferences()
1507 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1509 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1510 setPreferenceProperty( genGroup, "columns", 2 );
1512 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1513 LightApp_Preferences::Selector,
1514 "Geometry", "display_mode" );
1516 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1517 LightApp_Preferences::Color, "Geometry", "shading_color" );
1519 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1520 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1522 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1523 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1525 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1526 LightApp_Preferences::Color, "Geometry", "line_color" );
1528 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1529 LightApp_Preferences::Color, "Geometry", "point_color" );
1531 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1532 LightApp_Preferences::Color, "Geometry", "isos_color" );
1534 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1535 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1537 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1538 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1540 // Quantities with individual precision settings
1541 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1542 setPreferenceProperty( precGroup, "columns", 2 );
1544 const int nbQuantities = 8;
1545 int prec[nbQuantities], ii = 0;
1546 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1547 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1548 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1549 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1550 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1551 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1552 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1553 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1554 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1555 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1556 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1557 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1558 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1559 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1560 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1561 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1563 // Set property for precision value for spinboxes
1564 for ( ii = 0; ii < nbQuantities; ii++ ){
1565 setPreferenceProperty( prec[ii], "min", -14 );
1566 setPreferenceProperty( prec[ii], "max", 14 );
1567 setPreferenceProperty( prec[ii], "precision", 2 );
1570 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1571 setPreferenceProperty( VertexGroup, "columns", 2 );
1573 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1574 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1576 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1577 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1579 // Set property for default display mode
1580 QStringList aModesList;
1581 aModesList.append( tr("MEN_WIREFRAME") );
1582 aModesList.append( tr("MEN_SHADING") );
1584 QList<QVariant> anIndexesList;
1585 anIndexesList.append(0);
1586 anIndexesList.append(1);
1588 setPreferenceProperty( dispmode, "strings", aModesList );
1589 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1591 // Set property for step value for spinboxes
1592 setPreferenceProperty( step, "min", 1 );
1593 setPreferenceProperty( step, "max", 10000 );
1594 setPreferenceProperty( step, "precision", 3 );
1596 // Set property for deflection value for spinboxes
1597 setPreferenceProperty( defl, "min", DEFLECTION_MIN );
1598 setPreferenceProperty( defl, "max", 1.0 );
1599 setPreferenceProperty( defl, "step", 1.0e-04 );
1600 setPreferenceProperty( defl, "precision", 6 );
1602 // Set property vertex marker type
1603 QList<QVariant> aMarkerTypeIndicesList;
1604 QList<QVariant> aMarkerTypeIconsList;
1606 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1607 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1608 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1609 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1610 aMarkerTypeIndicesList << (i-1);
1611 aMarkerTypeIconsList << pixmap;
1614 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1615 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
1617 // Set property for vertex marker scale
1618 QList<QVariant> aMarkerScaleIndicesList;
1619 QStringList aMarkerScaleValuesList;
1621 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
1622 aMarkerScaleIndicesList << iii;
1623 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
1626 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1627 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1629 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
1630 setPreferenceProperty( originGroup, "columns", 2 );
1632 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
1633 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
1634 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
1635 setPreferenceProperty( baseVectorsLength, "max", 1000 );
1637 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
1638 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
1642 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1644 if (section == "Geometry") {
1645 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1646 if (param == QString("SettingsGeomStep")) {
1647 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1648 EmitSignalDefaultStepValueChanged(spin_step);
1653 LightApp_Displayer* GeometryGUI::displayer()
1656 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1660 void GeometryGUI::setLocalSelectionMode(const int mode)
1662 myLocalSelectionMode = mode;
1664 int GeometryGUI::getLocalSelectionMode() const
1666 return myLocalSelectionMode;
1669 const char gSeparator = '_'; // character used to separate parameter names
1670 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1673 * \brief Store visual parameters
1675 * This method is called just before the study document is saved.
1676 * Store visual parameters in AttributeParameter attribue(s)
1678 void GeometryGUI::storeVisualParameters (int savePoint)
1680 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1681 if (!appStudy || !appStudy->studyDS())
1683 _PTR(Study) studyDS = appStudy->studyDS();
1685 // componentName is used for encoding of entries when storing them in IParameters
1686 std::string componentName = myComponentGeom->ComponentDataType();
1687 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1688 //if (!aSComponent) return;
1691 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1692 componentName.c_str(),
1694 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1696 QList<SUIT_ViewManager*> lst;
1697 QList<SUIT_ViewManager*>::Iterator it;
1699 // main cycle to store parameters of displayed objects
1701 getApp()->viewManagers(lst);
1702 for (it = lst.begin(); it != lst.end(); it++) {
1703 SUIT_ViewManager* vman = *it;
1704 QString vType = vman->getType();
1705 int aMgrId = vman->getGlobalId();
1706 // saving VTK actors properties
1707 QVector<SUIT_ViewWindow*> views = vman->getViews();
1708 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
1709 const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
1710 ObjMap::ConstIterator o_it = anObjects.begin();
1711 for( ;o_it != anObjects.end(); o_it++ ) {
1712 const PropMap aProps = o_it.value();
1714 //Check that object exists in the study
1715 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
1718 // entry is "encoded" = it does NOT contain component adress, since it is a
1719 // subject to change on next component loading
1721 std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
1723 _PTR(GenericAttribute) anAttr;
1724 if( !obj->FindAttribute(anAttr, "AttributeIOR"))
1727 std::string param, occParam = vType.toLatin1().data();
1728 occParam += NAME_SEPARATOR;
1729 occParam += QString::number(aMgrId).toLatin1().data();
1730 occParam += NAME_SEPARATOR;
1732 param = occParam + VISIBILITY_PROP;
1733 ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
1735 param = occParam + DISPLAY_MODE_PROP;
1737 ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
1739 QColor c = aProps.value(COLOR_PROP).value<QColor>();
1740 QString colorStr = QString::number(c.red()/255.);
1741 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
1742 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
1743 param = occParam + COLOR_PROP;
1744 ip->setParameter(entry, param, colorStr.toLatin1().data());
1746 if(vType == SVTK_Viewer::Type()) {
1747 param = occParam + OPACITY_PROP;
1748 ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1749 } else if (vType == SOCC_Viewer::Type()) {
1750 param = occParam + TRANSPARENCY_PROP;
1751 ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1754 param = occParam + ISOS_PROP;
1755 ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
1757 param = occParam + VECTOR_MODE_PROP;
1758 ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
1760 param = occParam + DEFLECTION_COEFF_PROP;
1761 ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
1763 param = occParam + DEFLECTION_COEFF_PROP;
1764 ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
1766 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
1767 if(aProps.contains(MARKER_TYPE_PROP)) {
1768 param = occParam + MARKER_TYPE_PROP;
1769 ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
1772 } // object iterator
1774 } // for (viewManagers)
1777 * \brief Restore visual parameters
1779 * This method is called after the study document is opened.
1780 * Restore visual parameters from AttributeParameter attribue(s)
1782 void GeometryGUI::restoreVisualParameters (int savePoint)
1784 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1785 if (!appStudy || !appStudy->studyDS())
1787 _PTR(Study) studyDS = appStudy->studyDS();
1789 // componentName is used for encoding of entries when storing them in IParameters
1790 std::string componentName = myComponentGeom->ComponentDataType();
1791 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1792 //if (!aSComponent) return;
1795 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1796 componentName.c_str(),
1798 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1800 std::vector<std::string> entries = ip->getEntries();
1802 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
1804 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1805 QString entry (ip->decodeEntry(*entIt).c_str());
1807 // Check that the entry corresponds to a real object in the Study
1808 // as the object may be deleted or modified after the visual state is saved.
1809 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1810 if (!so) continue; //Skip the not existent entry
1812 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1813 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1815 std::vector<std::string>::iterator namesIt = paramNames.begin();
1816 std::vector<std::string>::iterator valuesIt = paramValues.begin();
1818 // actors are stored in a map after displaying of them for
1819 // quicker access in the future: map < viewID to actor >
1820 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
1821 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
1823 QString viewerTypStr;
1824 QString viewIndexStr;
1826 QVector<PropMap> aListOfMap;
1828 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
1830 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
1831 // '_' is used as separator and should not be used in viewer type or parameter names.
1832 QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts);
1833 if (lst.size() != 3)
1836 viewerTypStr = lst[0];
1837 viewIndexStr = lst[1];
1838 QString paramNameStr = lst[2];
1841 viewIndex = viewIndexStr.toUInt(&ok);
1842 if (!ok) // bad conversion of view index to integer
1845 if((viewIndex + 1) > aListOfMap.count()) {
1846 aListOfMap.resize(viewIndex + 1);
1849 QString val((*valuesIt).c_str());
1850 if(paramNameStr == VISIBILITY_PROP){
1851 aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0);
1853 } else if(paramNameStr == OPACITY_PROP) {
1854 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
1856 } else if(paramNameStr == TRANSPARENCY_PROP) {
1857 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, val.toDouble());
1859 } else if(paramNameStr == DISPLAY_MODE_PROP) {
1860 aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
1862 } else if(paramNameStr == ISOS_PROP) {
1863 aListOfMap[viewIndex].insert( ISOS_PROP, val);
1865 } else if(paramNameStr == COLOR_PROP) {
1866 QStringList rgb = val.split(DIGIT_SEPARATOR);
1867 if(rgb.count() == 3) {
1868 QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255));
1869 aListOfMap[viewIndex].insert( COLOR_PROP, c);
1871 } else if(paramNameStr == VECTOR_MODE_PROP) {
1872 aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt());
1874 } else if(paramNameStr == DEFLECTION_COEFF_PROP) {
1875 aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
1876 } else if(paramNameStr == MARKER_TYPE_PROP) {
1877 aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
1880 } // for names/parameters iterator
1882 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
1884 for (int index = 0 ; index < aListOfMap.count(); index++) {
1886 appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
1888 QColor c = aListOfMap[index].value(COLOR_PROP).value<QColor>();
1889 //Get Visibility property of the current PropMap
1890 if (aListOfMap[index].value(VISIBILITY_PROP) == 1) {
1891 SUIT_ViewManager* vman = lst.at(index);
1892 SUIT_ViewModel* vmodel = vman->getViewModel();
1893 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
1897 } // for entries iterator
1899 // update all VTK and OCC views
1900 QList<SUIT_ViewManager*> lst;
1901 getApp()->viewManagers(lst);
1902 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
1903 SUIT_ViewModel* vmodel = (*it)->getViewModel();
1906 if (vmodel->getType() == SVTK_Viewer::Type()) {
1907 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
1908 vtkView->getRenderer()->ResetCameraClippingRange();
1911 else if (vmodel->getType() == SOCC_Viewer::Type()) {
1912 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
1913 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
1920 void GeometryGUI::onViewAboutToShow()
1922 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
1923 QAction* a = action( GEOMOp::OpSwitchVectors );
1925 a->setEnabled(true);
1926 bool vmode = window->getCustomData("VectorsMode").toBool();
1927 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
1929 a->setText ( tr("MEN_VECTOR_MODE_ON") );
1930 a->setEnabled(false);