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::Component_var comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
176 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
179 myActiveDialogBox = 0;
181 gp_Pnt origin = gp_Pnt(0., 0., 0.);
182 gp_Dir direction = gp_Dir(0., 0., 1.);
183 myWorkingPlane = gp_Ax3(origin, direction);
186 myLocalSelectionMode = GEOM_ALLOBJECTS;
189 //=======================================================================
190 // function : GeometryGUI::~GeometryGUI()
191 // purpose : Destructor
192 //=======================================================================
193 GeometryGUI::~GeometryGUI()
195 while (!myOCCSelectors.isEmpty())
196 delete myOCCSelectors.takeFirst();
198 while (!myVTKSelectors.isEmpty())
199 delete myVTKSelectors.takeFirst();
201 qDeleteAll(myGUIMap);
204 //=======================================================================
205 // function : GeometryGUI::getLibrary()
206 // purpose : get or load GUI library by name [ internal ]
207 //=======================================================================
208 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
209 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
211 if ( !myGUIMap.contains( libraryName ) ) {
212 // try to load library if it is not loaded yet
214 QString dirs = getenv( "LD_LIBRARY_PATH" );
217 QString dirs = getenv( "PATH" );
220 if ( !dirs.isEmpty() ) {
221 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
222 QListIterator<QString> it( dirList ); it.toBack();
223 while ( it.hasPrevious() ) {
224 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
226 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
227 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
229 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
230 continue; // continue search further
232 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
233 if ( osdF != NULL ) {
234 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
235 GEOMGUI* libGUI = (*func)( this );
237 myGUIMap[ libraryName ] = libGUI;
238 break; // found and loaded!
245 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
248 //=======================================================================
249 // function : GeometryGUI::ActiveWorkingPlane()
250 // purpose : Activate Working Plane View
251 //=======================================================================
252 void GeometryGUI::ActiveWorkingPlane()
254 gp_Dir DZ = myWorkingPlane.Direction();
255 gp_Dir DY = myWorkingPlane.YDirection();
257 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
258 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
259 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
262 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
264 Handle(V3d_View) view3d = vw->getViewPort()->getView();
266 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
267 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
273 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
275 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
277 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
278 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
279 camera->SetFocalPoint(0,0,0);
286 //=======================================================================
287 // function : GeometryGUI::SetActiveDialogBox()
288 // purpose : Set active dialog box
289 //=======================================================================
290 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
292 myActiveDialogBox = (QDialog*)aDlg;
295 //=======================================================================
296 // function : GeometryGUI::EmitSignalDeactivateDialog()
297 // purpose : Emit a signal to deactivate the active dialog Box
298 //=======================================================================
299 void GeometryGUI::EmitSignalDeactivateDialog()
301 emit SignalDeactivateActiveDialog();
304 //=======================================================================
305 // function : GeometryGUI::EmitSignalCloseAllDialogs()
306 // purpose : Emit a signal to close all non modal dialogs box
307 //=======================================================================
308 void GeometryGUI::EmitSignalCloseAllDialogs()
310 emit SignalCloseAllDialogs();
313 //=======================================================================
314 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
315 // purpose : Emit a signal to inform that default real spin box step has
317 //=======================================================================
318 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
320 emit SignalDefaultStepValueChanged(newVal);
323 //=======================================================================
324 // function : GeometryGUI::OnGUIEvent()
325 // purpose : common slot for all menu/toolbar actions
326 //=======================================================================
327 void GeometryGUI::OnGUIEvent()
329 const QObject* obj = sender();
330 if ( !obj || !obj->inherits( "QAction" ) )
332 int id = actionId((QAction*)obj);
337 //=======================================================================
338 // function : GeometryGUI::OnGUIEvent()
339 // purpose : manage all events on GUI [static]
340 //=======================================================================
341 void GeometryGUI::OnGUIEvent( int id )
343 SUIT_Application* anApp = application();
345 SUIT_Desktop* desk = anApp->desktop();
347 // check type of the active viewframe
348 SUIT_ViewWindow* window = desk->activeWindow();
349 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
350 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
351 // if current viewframe is not of OCC and not of VTK type - return immediately
352 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
353 QList<int> NotViewerDependentCommands;
354 NotViewerDependentCommands << GEOMOp::OpRename
357 << GEOMOp::OpShowOnly
358 << GEOMOp::OpShowChildren
359 << GEOMOp::OpHideChildren
360 << GEOMOp::OpPointMarker;
361 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
364 // fix for IPAL9103, point 2
365 if ( CORBA::is_nil( GetGeomGen() ) ) {
366 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
371 // find corresponding GUI library
373 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
374 createOriginAndBaseVectors(); // internal operation
376 case GEOMOp::OpImport: // MENU FILE - IMPORT
377 case GEOMOp::OpExport: // MENU FILE - EXPORT
378 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
379 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
380 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
381 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
382 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
383 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
384 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
385 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
386 case GEOMOp::OpDelete: // MENU EDIT - DELETE
387 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
388 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
389 case GEOMOp::OpColor: // POPUP MENU - COLOR
390 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
391 case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
392 case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
393 case GEOMOp::OpIsos: // POPUP MENU - ISOS
394 case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
395 case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
396 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
397 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
398 case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
399 case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN
400 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
401 case GEOMOp::OpRename: // POPUP MENU - RENAME
402 libName = "GEOMToolsGUI";
404 case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
405 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
406 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
407 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
408 case GEOMOp::OpHide: // MENU VIEW - ERASE
409 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
410 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
411 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
412 case GEOMOp::OpShading: // POPUP MENU - SHADING
413 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
414 libName = "DisplayGUI";
416 case GEOMOp::OpPoint: // MENU BASIC - POINT
417 case GEOMOp::OpLine: // MENU BASIC - LINE
418 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
419 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
420 case GEOMOp::OpArc: // MENU BASIC - ARC
421 case GEOMOp::OpVector: // MENU BASIC - VECTOR
422 case GEOMOp::OpPlane: // MENU BASIC - PLANE
423 case GEOMOp::OpCurve: // MENU BASIC - CURVE
424 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
425 libName = "BasicGUI";
427 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
428 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
429 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
430 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
431 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
432 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
433 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
434 libName = "PrimitiveGUI";
436 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
437 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
438 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
439 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
440 libName = "GenerationGUI";
442 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
443 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
444 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
445 libName = "EntityGUI";
447 case GEOMOp::OpEdge: // MENU BUILD - EDGE
448 case GEOMOp::OpWire: // MENU BUILD - WIRE
449 case GEOMOp::OpFace: // MENU BUILD - FACE
450 case GEOMOp::OpShell: // MENU BUILD - SHELL
451 case GEOMOp::OpSolid: // MENU BUILD - SOLID
452 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
453 libName = "BuildGUI";
455 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
456 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
457 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
458 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
459 libName = "BooleanGUI";
461 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
462 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
463 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
464 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
465 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
466 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
467 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
468 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
469 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
470 libName = "TransformationGUI";
472 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
473 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
474 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
475 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
476 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
477 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
478 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
479 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
480 case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
481 libName = "OperationGUI";
483 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
484 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
485 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
486 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
487 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
488 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
489 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
490 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
491 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
492 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
493 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
494 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
495 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
496 libName = "RepairGUI";
498 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
499 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
500 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
501 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
502 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
503 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
504 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
505 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
506 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
507 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
508 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
509 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
510 libName = "MeasureGUI";
512 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
513 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
514 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
515 libName = "GroupGUI";
517 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
518 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
519 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
520 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
521 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
522 libName = "BlocksGUI";
524 case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
525 case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
526 // case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
527 //@@ 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 @@//
528 libName = "AdvancedGUI";
534 GEOMGUI* library = 0;
535 if ( !libName.isEmpty() ) {
537 libName = QString( "lib" ) + libName + ".so";
539 libName = libName + ".dll";
541 library = getLibrary( libName );
544 // call method of corresponding GUI library
546 library->OnGUIEvent( id, desk );
548 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
551 //=================================================================================
552 // function : GeometryGUI::OnKeyPress()
553 // purpose : Called when any key is pressed by user [static]
554 //=================================================================================
555 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
557 if ( !application() )
559 foreach ( GEOMGUI* lib, myGUIMap )
560 lib->OnKeyPress( e, application()->desktop(), w );
563 //=================================================================================
564 // function : GeometryGUI::OnMouseMove()
565 // purpose : Manages mouse move events [static]
566 //=================================================================================
567 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
569 if ( !application() )
571 foreach ( GEOMGUI* lib, myGUIMap )
572 lib->OnMouseMove( e, application()->desktop(), w );
575 //=================================================================================
576 // function : GeometryGUI::OnMousePress()
577 // purpose : Manage mouse press events [static]
578 //=================================================================================
579 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
581 if ( !application() )
583 foreach ( GEOMGUI* lib, myGUIMap )
584 lib->OnMousePress( e, application()->desktop(), w );
587 //=======================================================================
588 // function : createGeomAction
590 //=======================================================================
591 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
592 const int accel, const bool toggle, const QString& shortcutAction )
594 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
595 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
596 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
598 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
600 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
601 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
603 application()->desktop(),
605 this, SLOT( OnGUIEvent() ),
609 //=======================================================================
610 // function : createOriginAndBaseVectors
612 //=======================================================================
613 void GeometryGUI::createOriginAndBaseVectors()
615 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
617 _PTR(Study) studyDS = appStudy->studyDS();
618 if( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
619 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
620 if( !aBasicOperations->_is_nil() ) {
621 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
622 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
623 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
624 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
625 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
626 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
628 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
629 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
630 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
631 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
632 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
634 getApp()->updateObjectBrowser( false );
640 //=======================================================================
641 // function : GeometryGUI::initialize()
642 // purpose : Called when GEOM module is created
643 //=======================================================================
644 void GeometryGUI::initialize( CAM_Application* app )
646 SalomeApp_Module::initialize( app );
648 // ----- create actions --------------
650 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
651 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
653 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
655 createGeomAction( GEOMOp::OpPoint, "POINT" );
656 createGeomAction( GEOMOp::OpLine, "LINE" );
657 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
658 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
659 createGeomAction( GEOMOp::OpArc, "ARC" );
660 createGeomAction( GEOMOp::OpCurve, "CURVE" );
661 createGeomAction( GEOMOp::OpVector, "VECTOR" );
662 createGeomAction( GEOMOp::OpPlane, "PLANE" );
663 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
664 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
666 createGeomAction( GEOMOp::OpBox, "BOX" );
667 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
668 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
669 createGeomAction( GEOMOp::OpTorus, "TORUS" );
670 createGeomAction( GEOMOp::OpCone, "CONE" );
671 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
672 createGeomAction( GEOMOp::OpDisk, "DISK" );
674 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
675 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
676 createGeomAction( GEOMOp::OpFilling, "FILLING" );
677 createGeomAction( GEOMOp::OpPipe, "PIPE" );
679 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
680 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
682 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
684 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
685 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
687 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
688 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
689 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
691 createGeomAction( GEOMOp::OpEdge, "EDGE" );
692 createGeomAction( GEOMOp::OpWire, "WIRE" );
693 createGeomAction( GEOMOp::OpFace, "FACE" );
694 createGeomAction( GEOMOp::OpShell, "SHELL" );
695 createGeomAction( GEOMOp::OpSolid, "SOLID" );
696 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
698 createGeomAction( GEOMOp::OpFuse, "FUSE" );
699 createGeomAction( GEOMOp::OpCommon, "COMMON" );
700 createGeomAction( GEOMOp::OpCut, "CUT" );
701 createGeomAction( GEOMOp::OpSection, "SECTION" );
703 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
704 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
705 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
706 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
707 createGeomAction( GEOMOp::OpScale, "SCALE" );
708 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
709 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
710 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
712 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
713 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
714 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
715 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
716 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
717 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
718 createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
719 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
720 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
722 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
723 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
724 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
726 createGeomAction( GEOMOp::OpSewing, "SEWING" );
727 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
728 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
729 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
730 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
731 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
732 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
733 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
734 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
735 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
736 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
737 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
738 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
740 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
741 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
742 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
743 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
744 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
745 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
746 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
747 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
749 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
750 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
751 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
752 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
754 #ifdef _DEBUG_ // PAL16821
755 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
758 createGeomAction( GEOMOp::OpDisplayMode, "SHADING" );
759 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
760 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
761 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
762 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
763 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
764 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
765 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
766 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
767 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
768 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
769 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
770 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
771 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
772 createGeomAction( GEOMOp::OpHide, "ERASE" );
774 createGeomAction( GEOMOp::OpRename, "POP_RENAME", "", Qt::Key_F2 );
775 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
776 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
777 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
778 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
779 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
780 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
781 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
782 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
783 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
784 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
785 createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" );
786 createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" );
787 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
789 createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
791 // Create actions for increase/decrease transparency shortcuts
792 createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
793 "Geometry:Increase transparency");
794 createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
795 "Geometry:Decrease transparency");
797 // Create actions for increase/decrease number of isolines
798 createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
799 "Geometry:Increase number of isolines");
800 createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
801 "Geometry:Decrease number of isolines");
803 // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
804 //@@ 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 @@//
806 // ---- create menus --------------------------
808 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
809 createMenu( separator(), fileId, 10 );
810 createMenu( GEOMOp::OpImport, fileId, 10 );
811 createMenu( GEOMOp::OpExport, fileId, 10 );
812 createMenu( separator(), fileId, -1 );
814 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
815 createMenu( GEOMOp::OpDelete, editId, -1 );
817 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
819 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
820 createMenu( GEOMOp::OpPoint, basicId, -1 );
821 createMenu( GEOMOp::OpLine, basicId, -1 );
822 createMenu( GEOMOp::OpCircle, basicId, -1 );
823 createMenu( GEOMOp::OpEllipse, basicId, -1 );
824 createMenu( GEOMOp::OpArc, basicId, -1 );
825 createMenu( GEOMOp::OpCurve, basicId, -1 );
826 createMenu( separator(), basicId, -1 );
827 createMenu( GEOMOp::OpVector, basicId, -1 );
828 createMenu( GEOMOp::OpPlane, basicId, -1 );
829 createMenu( GEOMOp::OpLCS, basicId, -1 );
830 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
832 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
833 createMenu( GEOMOp::OpBox, primId, -1 );
834 createMenu( GEOMOp::OpCylinder, primId, -1 );
835 createMenu( GEOMOp::OpSphere, primId, -1 );
836 createMenu( GEOMOp::OpTorus, primId, -1 );
837 createMenu( GEOMOp::OpCone, primId, -1 );
838 createMenu( GEOMOp::OpRectangle, primId, -1 );
839 createMenu( GEOMOp::OpDisk, primId, -1 );
841 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
842 createMenu( GEOMOp::OpPrism, genId, -1 );
843 createMenu( GEOMOp::OpRevolution, genId, -1 );
844 createMenu( GEOMOp::OpFilling, genId, -1 );
845 createMenu( GEOMOp::OpPipe, genId, -1 );
847 int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
848 createMenu( GEOMOp::OpPipeTShape, advId, -1 );
849 // createMenu( GEOMOp::OpPipeTShapeGroups, advId, -1 );
850 //@@ 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 @@//
852 createMenu( separator(), newEntId, -1 );
854 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
855 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
856 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
858 createMenu( separator(), newEntId, -1 );
860 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
861 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
862 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
864 createMenu( separator(), newEntId, -1 );
866 createMenu( GEOMOp::Op2dSketcher, newEntId, -1 );
867 createMenu( GEOMOp::Op3dSketcher, newEntId, -1 );
869 createMenu( separator(), newEntId, -1 );
871 createMenu( GEOMOp::OpExplode, newEntId, -1 );
873 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
874 createMenu( GEOMOp::OpEdge, buildId, -1 );
875 createMenu( GEOMOp::OpWire, buildId, -1 );
876 createMenu( GEOMOp::OpFace, buildId, -1 );
877 createMenu( GEOMOp::OpShell, buildId, -1 );
878 createMenu( GEOMOp::OpSolid, buildId, -1 );
879 createMenu( GEOMOp::OpCompound, buildId, -1 );
881 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
883 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
884 createMenu( GEOMOp::OpFuse, boolId, -1 );
885 createMenu( GEOMOp::OpCommon, boolId, -1 );
886 createMenu( GEOMOp::OpCut, boolId, -1 );
887 createMenu( GEOMOp::OpSection, boolId, -1 );
889 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
890 createMenu( GEOMOp::OpTranslate, transId, -1 );
891 createMenu( GEOMOp::OpRotate, transId, -1 );
892 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
893 createMenu( GEOMOp::OpMirror, transId, -1 );
894 createMenu( GEOMOp::OpScale, transId, -1 );
895 createMenu( GEOMOp::OpOffset, transId, -1 );
896 createMenu( separator(), transId, -1 );
897 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
898 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
900 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
901 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
902 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
903 createMenu( GEOMOp::OpPropagate, blockId, -1 );
905 createMenu( separator(), operId, -1 );
907 createMenu( GEOMOp::OpPartition, operId, -1 );
908 createMenu( GEOMOp::OpArchimede, operId, -1 );
909 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
910 createMenu( GEOMOp::OpSharedShapes, operId, -1 );
912 createMenu( separator(), operId, -1 );
914 createMenu( GEOMOp::OpFillet1d, operId, -1 );
915 createMenu( GEOMOp::OpFillet2d, operId, -1 );
916 createMenu( GEOMOp::OpFillet3d, operId, -1 );
917 createMenu( GEOMOp::OpChamfer, operId, -1 );
918 //createMenu( GEOMOp::OpClipping, operId, -1 );
920 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
921 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
922 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
923 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
924 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
925 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
926 createMenu( GEOMOp::OpSewing, repairId, -1 );
927 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
928 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
929 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
930 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
931 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
932 createMenu( GEOMOp::OpOrientation, repairId, -1 );
933 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
935 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
936 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
937 createMenu( GEOMOp::OpProperties, measurId, -1 );
938 createMenu( separator(), measurId, -1 );
939 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
940 createMenu( GEOMOp::OpInertia, measurId, -1 );
941 createMenu( GEOMOp::OpNormale, measurId, -1 );
942 createMenu( separator(), measurId, -1 );
943 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
944 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
945 createMenu( separator(), measurId, -1 );
947 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
948 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
949 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
950 createMenu( GEOMOp::OpAngle, dimId, -1 );
952 createMenu( separator(), measurId, -1 );
953 createMenu( GEOMOp::OpTolerance, measurId, -1 );
954 createMenu( separator(), measurId, -1 );
955 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
956 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
957 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
959 #ifdef _DEBUG_ // PAL16821
960 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
961 createMenu( separator(), toolsId, -1 );
962 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
965 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
966 createMenu( separator(), viewId, -1 );
968 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
969 createMenu( GEOMOp::OpDisplayMode, dispmodeId, -1 );
970 createMenu( separator(), dispmodeId, -1 );
971 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
973 createMenu( separator(), viewId, -1 );
974 createMenu( GEOMOp::OpShowAll, viewId, -1 );
975 createMenu( GEOMOp::OpHideAll, viewId, -1 );
976 createMenu( separator(), viewId, -1 );
980 because of these items are accessible through object browser and viewers
981 we have removed they from main menu
983 createMenu( GEOMOp::OpShow, viewId, -1 );
984 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
985 createMenu( GEOMOp::OpHide, viewId, -1 );
988 // ---- create toolbars --------------------------
990 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
991 createTool( GEOMOp::OpPoint, basicTbId );
992 createTool( GEOMOp::OpLine, basicTbId );
993 createTool( GEOMOp::OpCircle, basicTbId );
994 createTool( GEOMOp::OpEllipse, basicTbId );
995 createTool( GEOMOp::OpArc, basicTbId );
996 createTool( GEOMOp::OpCurve, basicTbId );
997 createTool( GEOMOp::OpVector, basicTbId );
998 createTool( GEOMOp::OpPlane, basicTbId );
999 createTool( GEOMOp::OpLCS, basicTbId );
1000 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1002 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1003 createTool( GEOMOp::OpBox, primTbId );
1004 createTool( GEOMOp::OpCylinder, primTbId );
1005 createTool( GEOMOp::OpSphere, primTbId );
1006 createTool( GEOMOp::OpTorus, primTbId );
1007 createTool( GEOMOp::OpCone, primTbId );
1008 createTool( GEOMOp::OpRectangle, primTbId );
1009 createTool( GEOMOp::OpDisk, primTbId );
1011 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1012 createTool( GEOMOp::OpFuse, boolTbId );
1013 createTool( GEOMOp::OpCommon, boolTbId );
1014 createTool( GEOMOp::OpCut, boolTbId );
1015 createTool( GEOMOp::OpSection, boolTbId );
1017 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1018 createTool( GEOMOp::OpPrism, genTbId );
1019 createTool( GEOMOp::OpRevolution, genTbId );
1020 createTool( GEOMOp::OpFilling, genTbId );
1021 createTool( GEOMOp::OpPipe, genTbId );
1023 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1024 createTool( GEOMOp::OpTranslate, transTbId );
1025 createTool( GEOMOp::OpRotate, transTbId );
1026 createTool( GEOMOp::OpChangeLoc, transTbId );
1027 createTool( GEOMOp::OpMirror, transTbId );
1028 createTool( GEOMOp::OpScale, transTbId );
1029 createTool( GEOMOp::OpOffset, transTbId );
1030 createTool( separator(), transTbId );
1031 createTool( GEOMOp::OpMultiTranslate, transTbId );
1032 createTool( GEOMOp::OpMultiRotate, transTbId );
1034 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1035 createTool( GEOMOp::Op2dSketcher, operTbId );
1036 createTool( GEOMOp::Op3dSketcher, operTbId );
1037 createTool( separator(), operTbId );
1038 createTool( GEOMOp::OpExplode, operTbId );
1039 createTool( separator(), operTbId );
1040 createTool( GEOMOp::OpPartition, operTbId );
1041 createTool( GEOMOp::OpArchimede, operTbId );
1042 createTool( GEOMOp::OpShapesOnShape, operTbId );
1043 createTool( GEOMOp::OpSharedShapes, operTbId );
1044 createTool( separator(), operTbId );
1045 createTool( GEOMOp::OpFillet1d, operTbId );
1046 createTool( GEOMOp::OpFillet2d, operTbId );
1047 createTool( GEOMOp::OpFillet3d, operTbId );
1048 createTool( GEOMOp::OpChamfer, operTbId );
1050 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1051 createTool( GEOMOp::OpEdge, buildTbId );
1052 createTool( GEOMOp::OpWire, buildTbId );
1053 createTool( GEOMOp::OpFace, buildTbId );
1054 createTool( GEOMOp::OpShell, buildTbId );
1055 createTool( GEOMOp::OpSolid, buildTbId );
1056 createTool( GEOMOp::OpCompound, buildTbId );
1058 int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1059 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1060 createTool( GEOMOp::OpProperties, measureTbId );
1061 createTool( GEOMOp::OpCenterMass, measureTbId );
1062 createTool( GEOMOp::OpInertia, measureTbId );
1063 createTool( GEOMOp::OpNormale, measureTbId );
1064 createTool( separator(), measureTbId );
1065 createTool( GEOMOp::OpBoundingBox, measureTbId );
1066 createTool( GEOMOp::OpMinDistance, measureTbId );
1067 createTool( GEOMOp::OpAngle, measureTbId );
1068 createTool( GEOMOp::OpTolerance , measureTbId );
1069 createTool( separator(), measureTbId );
1070 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1071 createTool( GEOMOp::OpFreeFaces, measureTbId );
1072 createTool( separator(), measureTbId );
1073 createTool( GEOMOp::OpWhatIs, measureTbId );
1074 createTool( GEOMOp::OpCheckShape, measureTbId );
1075 createTool( GEOMOp::OpCheckCompound, measureTbId );
1077 int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1078 createTool( GEOMOp::OpPipeTShape, advancedTbId );
1079 //@@ 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 @@//
1081 // ---- create popup menus --------------------------
1083 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1084 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1086 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1087 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1089 QString autoColorPrefix =
1090 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1092 QtxPopupMgr* mgr = popupMgr();
1093 mgr->insert( action( GEOMOp::OpRename ), -1, -1 ); // rename
1094 mgr->setRule( action( GEOMOp::OpRename ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
1095 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1096 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1097 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1098 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1099 mgr->insert( action( GEOMOp::OpShowChildren ), -1, -1 ); // show children
1100 mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
1101 mgr->insert( action( GEOMOp::OpHideChildren ), -1, -1 ); // hide children
1102 mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
1103 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1104 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1105 mgr->insert( separator(), -1, -1 ); // -----------
1106 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1107 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1108 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1109 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1110 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1111 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1112 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1113 mgr->insert( separator(), dispmodeId, -1 );
1114 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1115 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1116 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1117 mgr->insert( separator(), -1, -1 ); // -----------
1118 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1119 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1120 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1121 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1122 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1123 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1124 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1125 mgr->setRule( action( GEOMOp::OpDeflection ), "selcount>0 and isVisible and client='OCCViewer'", QtxPopupMgr::VisibleRule );
1126 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1127 //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1128 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1129 mgr->insert( separator(), -1, -1 ); // -----------
1130 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1131 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1132 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1133 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1134 mgr->insert( separator(), -1, -1 ); // -----------
1136 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1137 onlyComponent = "((type='Component') and selcount=1)",
1138 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1139 types = "'Shape' 'Group'";
1141 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1142 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1144 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1145 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1147 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1148 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1150 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1152 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1153 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1154 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1155 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1156 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1157 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1158 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1159 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1160 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1161 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1162 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1163 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1164 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1165 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1166 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1167 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1168 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1169 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1170 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1171 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1172 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1173 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1174 mgr->insert( separator(), selectonlyId, -1);
1175 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1176 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1177 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1178 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1179 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1180 mgr->insert( separator(), -1, -1 );
1182 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1185 //=======================================================================
1186 // function : GeometryGUI::activateModule()
1187 // purpose : Called when GEOM module is activated
1188 //=======================================================================
1189 bool GeometryGUI::activateModule( SUIT_Study* study )
1191 if ( CORBA::is_nil( myComponentGeom ) )
1194 bool res = SalomeApp_Module::activateModule( study );
1199 setMenuShown( true );
1200 setToolShown( true );
1202 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1203 PyGILState_STATE gstate = PyGILState_Ensure();
1204 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
1205 if(pluginsmanager==NULL)
1209 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());
1214 PyGILState_Release(gstate);
1215 // end of GEOM plugins loading
1217 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1218 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1220 // Reset actions accelerator keys
1221 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1222 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1223 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1224 action(GEOMOp::OpRename)->setEnabled( true ); // Rename: Key_F2
1226 GUIMap::Iterator it;
1227 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1228 it.value()->activate( application()->desktop() );
1230 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1232 SUIT_ViewManager* vm;
1233 ViewManagerList OCCViewManagers, VTKViewManagers;
1235 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1236 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1237 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1238 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1240 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1241 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1242 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1243 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1246 SALOME_ListIO selected;
1247 sm->selectedObjects( selected );
1248 sm->clearSelected();
1250 // disable OCC selectors
1251 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1252 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1253 while ( itOCCSel.hasNext() )
1254 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1255 sr->setEnabled(true);
1257 // disable VTK selectors
1258 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1259 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1260 while ( itVTKSel.hasNext() )
1261 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1262 sr->setEnabled(true);
1264 sm->setSelectedObjects( selected, true ); //NPAL 19674
1266 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1268 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1270 // 0020836 (Basic vectors and origin)
1271 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1272 if( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1273 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1275 _PTR(Study) studyDS = appStudy->studyDS();
1277 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1278 if( !aSComponent ) // create objects automatically only if there is no GEOM component
1279 createOriginAndBaseVectors();
1288 //=======================================================================
1289 // function : GeometryGUI::deactivateModule()
1290 // purpose : Called when GEOM module is deactivated
1291 //=======================================================================
1292 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1294 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1296 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1298 setMenuShown( false );
1299 setToolShown( false );
1301 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1302 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1304 EmitSignalCloseAllDialogs();
1306 GUIMap::Iterator it;
1307 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1308 it.value()->deactivate();
1310 // Unset actions accelerator keys
1311 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1312 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1313 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1314 action(GEOMOp::OpRename)->setEnabled( false ); // Rename: Key_F2
1316 qDeleteAll(myOCCSelectors);
1317 myOCCSelectors.clear();
1318 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1320 qDeleteAll(myVTKSelectors);
1321 myVTKSelectors.clear();
1322 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1324 return SalomeApp_Module::deactivateModule( study );
1327 //=======================================================================
1328 // function : onWindowActivated()
1329 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1330 //=======================================================================
1331 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1336 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1337 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1339 // disable non-OCC viewframe menu commands
1340 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1341 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1342 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1343 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1344 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1345 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1346 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1348 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1349 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1351 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1354 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1356 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1357 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1360 void GeometryGUI::viewManagers( QStringList& lst ) const
1362 lst.append( OCCViewer_Viewer::Type() );
1365 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1367 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1369 qDebug( "connect" );
1370 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1371 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1372 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1373 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1374 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1375 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1377 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1378 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1380 // disable OCC selectors
1381 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1382 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1383 while ( itOCCSel.hasNext() )
1384 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1385 sr->setEnabled(true);
1387 else if ( vm->getType() == SVTK_Viewer::Type() )
1389 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1390 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1392 // disable VTK selectors
1393 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1394 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1395 while ( itVTKSel.hasNext() )
1396 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1397 sr->setEnabled(true);
1401 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1403 SUIT_ViewModel* viewer = vm->getViewModel();
1404 if ( vm->getType() == OCCViewer_Viewer::Type() )
1406 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1407 while ( itOCCSel.hasNext() )
1408 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1409 if ( sr->viewer() == viewer )
1411 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1415 if ( vm->getType() == SVTK_Viewer::Type() )
1417 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1418 while ( itVTKSel.hasNext() )
1419 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1420 if ( sr->viewer() == viewer )
1422 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1428 QString GeometryGUI::engineIOR() const
1430 if ( !CORBA::is_nil( GetGeomGen() ) )
1431 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1435 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture( SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight )
1437 theWidth = theHeight = 0;
1438 Handle(Graphic3d_HArray1OfBytes) aTexture;
1440 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1441 aTexture = aTextureMap[ theId ];
1442 if ( aTexture.IsNull() ) {
1443 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1444 if ( !aInsOp->_is_nil() ) {
1445 CORBA::Long aWidth, aHeight;
1446 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1447 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1449 theHeight = aHeight;
1450 aTexture = new Graphic3d_HArray1OfBytes( 1, aStream->length() );
1451 for ( int i = 0; i < aStream->length(); i++ )
1452 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1453 aTextureMap[ theId ] = aTexture;
1461 LightApp_Selection* GeometryGUI::createSelection() const
1463 return new GEOMGUI_Selection();
1466 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1468 SalomeApp_Module::contextMenuPopup(client, menu, title);
1471 getApp()->selectionMgr()->selectedObjects(lst);
1472 if (lst.Extent() < 1)
1475 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1476 _PTR(Study) study = appStudy->studyDS();
1478 bool isImported = true;
1479 SALOME_ListIteratorOfListIO anIt (lst);
1480 for (; anIt.More() && isImported; anIt.Next()) {
1481 Handle(SALOME_InteractiveObject) io = anIt.Value();
1482 _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1484 if (lst.Extent() == 1) {
1485 // Set context menu title
1486 if (client == "OCCViewer" || client == "VTKViewer")
1487 title = QString(aSObj->GetName().c_str());
1490 CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1491 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1492 if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1500 menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
1504 void GeometryGUI::createPreferences()
1506 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1508 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1509 setPreferenceProperty( genGroup, "columns", 2 );
1511 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1512 LightApp_Preferences::Selector,
1513 "Geometry", "display_mode" );
1515 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1516 LightApp_Preferences::Color, "Geometry", "shading_color" );
1518 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1519 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1521 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1522 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1524 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1525 LightApp_Preferences::Color, "Geometry", "line_color" );
1527 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1528 LightApp_Preferences::Color, "Geometry", "point_color" );
1530 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1531 LightApp_Preferences::Color, "Geometry", "isos_color" );
1533 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1534 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1536 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1537 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1539 // Quantities with individual precision settings
1540 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1541 setPreferenceProperty( precGroup, "columns", 2 );
1543 const int nbQuantities = 8;
1544 int prec[nbQuantities], ii = 0;
1545 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1546 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1547 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1548 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1549 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1550 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1551 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1552 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1553 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1554 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1555 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1556 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1557 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1558 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1559 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1560 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1562 // Set property for precision value for spinboxes
1563 for ( ii = 0; ii < nbQuantities; ii++ ){
1564 setPreferenceProperty( prec[ii], "min", -14 );
1565 setPreferenceProperty( prec[ii], "max", 14 );
1566 setPreferenceProperty( prec[ii], "precision", 2 );
1569 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1570 setPreferenceProperty( VertexGroup, "columns", 2 );
1572 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1573 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1575 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1576 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1578 // Set property for default display mode
1579 QStringList aModesList;
1580 aModesList.append( tr("MEN_WIREFRAME") );
1581 aModesList.append( tr("MEN_SHADING") );
1583 QList<QVariant> anIndexesList;
1584 anIndexesList.append(0);
1585 anIndexesList.append(1);
1587 setPreferenceProperty( dispmode, "strings", aModesList );
1588 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1590 // Set property for step value for spinboxes
1591 setPreferenceProperty( step, "min", 1 );
1592 setPreferenceProperty( step, "max", 10000 );
1593 setPreferenceProperty( step, "precision", 3 );
1595 // Set property for deflection value for spinboxes
1596 setPreferenceProperty( defl, "min", DEFLECTION_MIN );
1597 setPreferenceProperty( defl, "max", 1.0 );
1598 setPreferenceProperty( defl, "step", 1.0e-04 );
1599 setPreferenceProperty( defl, "precision", 6 );
1601 // Set property vertex marker type
1602 QList<QVariant> aMarkerTypeIndicesList;
1603 QList<QVariant> aMarkerTypeIconsList;
1605 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1606 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1607 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1608 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1609 aMarkerTypeIndicesList << (i-1);
1610 aMarkerTypeIconsList << pixmap;
1613 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1614 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
1616 // Set property for vertex marker scale
1617 QList<QVariant> aMarkerScaleIndicesList;
1618 QStringList aMarkerScaleValuesList;
1620 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
1621 aMarkerScaleIndicesList << iii;
1622 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
1625 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1626 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1628 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
1629 setPreferenceProperty( originGroup, "columns", 2 );
1631 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
1632 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
1633 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
1634 setPreferenceProperty( baseVectorsLength, "max", 1000 );
1636 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
1637 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
1641 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1643 if (section == "Geometry") {
1644 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1645 if (param == QString("SettingsGeomStep")) {
1646 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1647 EmitSignalDefaultStepValueChanged(spin_step);
1652 LightApp_Displayer* GeometryGUI::displayer()
1655 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1659 void GeometryGUI::setLocalSelectionMode(const int mode)
1661 myLocalSelectionMode = mode;
1663 int GeometryGUI::getLocalSelectionMode() const
1665 return myLocalSelectionMode;
1668 const char gSeparator = '_'; // character used to separate parameter names
1669 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1672 * \brief Store visual parameters
1674 * This method is called just before the study document is saved.
1675 * Store visual parameters in AttributeParameter attribue(s)
1677 void GeometryGUI::storeVisualParameters (int savePoint)
1679 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1680 if (!appStudy || !appStudy->studyDS())
1682 _PTR(Study) studyDS = appStudy->studyDS();
1684 // componentName is used for encoding of entries when storing them in IParameters
1685 std::string componentName = myComponentGeom->ComponentDataType();
1686 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1687 //if (!aSComponent) return;
1690 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1691 componentName.c_str(),
1693 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1695 QList<SUIT_ViewManager*> lst;
1696 QList<SUIT_ViewManager*>::Iterator it;
1698 // main cycle to store parameters of displayed objects
1700 getApp()->viewManagers(lst);
1701 for (it = lst.begin(); it != lst.end(); it++) {
1702 SUIT_ViewManager* vman = *it;
1703 QString vType = vman->getType();
1704 int aMgrId = vman->getGlobalId();
1705 // saving VTK actors properties
1706 QVector<SUIT_ViewWindow*> views = vman->getViews();
1707 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
1708 const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
1709 ObjMap::ConstIterator o_it = anObjects.begin();
1710 for( ;o_it != anObjects.end(); o_it++ ) {
1711 const PropMap aProps = o_it.value();
1713 //Check that object exists in the study
1714 _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
1717 // entry is "encoded" = it does NOT contain component adress, since it is a
1718 // subject to change on next component loading
1720 std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
1722 _PTR(GenericAttribute) anAttr;
1723 if( !obj->FindAttribute(anAttr, "AttributeIOR"))
1726 std::string param, occParam = vType.toLatin1().data();
1727 occParam += NAME_SEPARATOR;
1728 occParam += QString::number(aMgrId).toLatin1().data();
1729 occParam += NAME_SEPARATOR;
1731 param = occParam + VISIBILITY_PROP;
1732 ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
1734 param = occParam + DISPLAY_MODE_PROP;
1736 ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
1738 QColor c = aProps.value(COLOR_PROP).value<QColor>();
1739 QString colorStr = QString::number(c.red()/255.);
1740 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
1741 colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
1742 param = occParam + COLOR_PROP;
1743 ip->setParameter(entry, param, colorStr.toLatin1().data());
1745 if(vType == SVTK_Viewer::Type()) {
1746 param = occParam + OPACITY_PROP;
1747 ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1748 } else if (vType == SOCC_Viewer::Type()) {
1749 param = occParam + TRANSPARENCY_PROP;
1750 ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1753 param = occParam + ISOS_PROP;
1754 ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
1756 param = occParam + VECTOR_MODE_PROP;
1757 ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
1759 param = occParam + DEFLECTION_COEFF_PROP;
1760 ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
1762 param = occParam + DEFLECTION_COEFF_PROP;
1763 ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
1765 //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
1766 if(aProps.contains(MARKER_TYPE_PROP)) {
1767 param = occParam + MARKER_TYPE_PROP;
1768 ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
1771 } // object iterator
1773 } // for (viewManagers)
1776 * \brief Restore visual parameters
1778 * This method is called after the study document is opened.
1779 * Restore visual parameters from AttributeParameter attribue(s)
1781 void GeometryGUI::restoreVisualParameters (int savePoint)
1783 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1784 if (!appStudy || !appStudy->studyDS())
1786 _PTR(Study) studyDS = appStudy->studyDS();
1788 // componentName is used for encoding of entries when storing them in IParameters
1789 std::string componentName = myComponentGeom->ComponentDataType();
1790 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1791 //if (!aSComponent) return;
1794 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1795 componentName.c_str(),
1797 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1799 std::vector<std::string> entries = ip->getEntries();
1801 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
1803 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1804 QString entry (ip->decodeEntry(*entIt).c_str());
1806 // Check that the entry corresponds to a real object in the Study
1807 // as the object may be deleted or modified after the visual state is saved.
1808 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1809 if (!so) continue; //Skip the not existent entry
1811 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1812 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1814 std::vector<std::string>::iterator namesIt = paramNames.begin();
1815 std::vector<std::string>::iterator valuesIt = paramValues.begin();
1817 // actors are stored in a map after displaying of them for
1818 // quicker access in the future: map < viewID to actor >
1819 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
1820 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
1822 QString viewerTypStr;
1823 QString viewIndexStr;
1825 QVector<PropMap> aListOfMap;
1827 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
1829 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
1830 // '_' is used as separator and should not be used in viewer type or parameter names.
1831 QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts);
1832 if (lst.size() != 3)
1835 viewerTypStr = lst[0];
1836 viewIndexStr = lst[1];
1837 QString paramNameStr = lst[2];
1840 viewIndex = viewIndexStr.toUInt(&ok);
1841 if (!ok) // bad conversion of view index to integer
1844 if((viewIndex + 1) > aListOfMap.count()) {
1845 aListOfMap.resize(viewIndex + 1);
1848 QString val((*valuesIt).c_str());
1849 if(paramNameStr == VISIBILITY_PROP){
1850 aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0);
1852 } else if(paramNameStr == OPACITY_PROP) {
1853 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
1855 } else if(paramNameStr == TRANSPARENCY_PROP) {
1856 aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, val.toDouble());
1858 } else if(paramNameStr == DISPLAY_MODE_PROP) {
1859 aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
1861 } else if(paramNameStr == ISOS_PROP) {
1862 aListOfMap[viewIndex].insert( ISOS_PROP, val);
1864 } else if(paramNameStr == COLOR_PROP) {
1865 QStringList rgb = val.split(DIGIT_SEPARATOR);
1866 if(rgb.count() == 3) {
1867 QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255));
1868 aListOfMap[viewIndex].insert( COLOR_PROP, c);
1870 } else if(paramNameStr == VECTOR_MODE_PROP) {
1871 aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt());
1873 } else if(paramNameStr == DEFLECTION_COEFF_PROP) {
1874 aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
1875 } else if(paramNameStr == MARKER_TYPE_PROP) {
1876 aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
1879 } // for names/parameters iterator
1881 QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
1883 for (int index = 0 ; index < aListOfMap.count(); index++) {
1885 appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
1887 QColor c = aListOfMap[index].value(COLOR_PROP).value<QColor>();
1888 //Get Visibility property of the current PropMap
1889 if(aListOfMap[index].value(VISIBILITY_PROP) == 1) {
1890 SUIT_ViewManager* vman = lst.at(index);
1891 SUIT_ViewModel* vmodel = vman->getViewModel();
1892 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
1896 } // for entries iterator
1898 // update all VTK and OCC views
1899 QList<SUIT_ViewManager*> lst;
1900 getApp()->viewManagers(lst);
1901 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
1902 SUIT_ViewModel* vmodel = (*it)->getViewModel();
1905 if (vmodel->getType() == SVTK_Viewer::Type()) {
1906 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
1907 vtkView->getRenderer()->ResetCameraClippingRange();
1910 else if (vmodel->getType() == SOCC_Viewer::Type()) {
1911 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
1912 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
1919 void GeometryGUI::onViewAboutToShow()
1921 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
1922 QAction* a = action( GEOMOp::OpSwitchVectors );
1924 a->setEnabled(true);
1925 bool vmode = window->getCustomData("VectorsMode").toBool();
1926 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
1928 a->setText ( tr("MEN_VECTOR_MODE_ON") );
1929 a->setEnabled(false);