1 // Copyright (C) 2007-2008 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 "GeometryGUI.h"
27 #include "GeometryGUI_Operations.h"
28 #include "GEOMGUI_OCCSelector.h"
29 #include "GEOMGUI_Selection.h"
30 #include "GEOM_Displayer.h"
31 #include "GEOM_AISShape.hxx"
33 #include "GEOM_Actor.h"
35 #include <SUIT_Desktop.h>
36 #include <SUIT_MessageBox.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_ViewManager.h>
41 #include <OCCViewer_ViewWindow.h>
42 #include <OCCViewer_ViewPort3d.h>
43 #include <OCCViewer_ViewModel.h>
44 #include <OCCViewer_ViewManager.h>
46 #include <SOCC_ViewModel.h>
47 #include <SOCC_ViewWindow.h>
49 #include <SVTK_ViewWindow.h>
50 #include <SVTK_RenderWindowInteractor.h>
51 #include <SVTK_InteractorStyle.h>
52 #include <SVTK_ViewModel.h>
54 #include <SalomeApp_Application.h>
55 #include <SalomeApp_Study.h>
57 #include <LightApp_SelectionMgr.h>
58 #include <LightApp_VTKSelector.h>
59 #include <LightApp_DataObject.h>
60 #include <LightApp_Preferences.h>
62 #include <SALOME_LifeCycleCORBA.hxx>
63 #include <SALOME_ListIO.hxx>
64 #include <SALOME_ListIteratorOfListIO.hxx>
66 #include <SALOMEDSClient_ClientFactory.hxx>
67 #include <SALOMEDSClient_IParameters.hxx>
76 #include <AIS_Drawer.hxx>
77 #include <AIS_ListOfInteractive.hxx>
78 #include <AIS_ListIteratorOfListOfInteractive.hxx>
79 #include <Prs3d_Drawer.hxx>
80 #include <Prs3d_IsoAspect.hxx>
81 #include <Aspect_TypeOfMarker.hxx>
82 #include <OSD_SharedLibrary.hxx>
83 #include <NCollection_DataMap.hxx>
84 #include <Graphic3d_HArray1OfBytes.hxx>
86 #include <utilities.h>
88 #include <vtkCamera.h>
89 #include <vtkRenderer.h>
91 #include "GEOMImpl_Types.hxx"
94 Standard_EXPORT CAM_Module* createModule() {
95 return new GeometryGUI();
99 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
101 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
103 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
105 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
106 if (CORBA::is_nil(myComponentGeom))
108 return GeometryGUI::myComponentGeom;
111 bool GeometryGUI::InitGeomGen()
114 if( CORBA::is_nil( myComponentGeom ) ) return false;
118 //=======================================================================
119 // function : ClientSObjectToObject
121 //=======================================================================
122 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
124 _PTR(GenericAttribute) anAttr;
125 CORBA::Object_var anObj;
127 std::string aValue = theSObject->GetIOR();
128 if (strcmp(aValue.c_str(), "") != 0) {
129 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
130 anObj = anORB->string_to_object(aValue.c_str());
133 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
135 return anObj._retn();
138 //=======================================================================
139 // function : ClientStudyToStudy
141 //=======================================================================
142 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
144 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
145 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
146 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
147 int aStudyID = theStudy->StudyId();
148 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
149 return aDSStudy._retn();
152 //=======================================================================
153 // function : GeometryGUI::GeometryGUI()
154 // purpose : Constructor
155 //=======================================================================
156 GeometryGUI::GeometryGUI() :
157 SalomeApp_Module( "GEOM" ),
158 LightApp_Module( "GEOM" )
160 if ( CORBA::is_nil( myComponentGeom ) )
162 Engines::Component_var comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
163 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
166 myActiveDialogBox = 0;
168 gp_Pnt origin = gp_Pnt(0., 0., 0.);
169 gp_Dir direction = gp_Dir(0., 0., 1.);
170 myWorkingPlane = gp_Ax3(origin, direction);
173 myLocalSelectionMode = GEOM_ALLOBJECTS;
176 //=======================================================================
177 // function : GeometryGUI::~GeometryGUI()
178 // purpose : Destructor
179 //=======================================================================
180 GeometryGUI::~GeometryGUI()
182 while (!myOCCSelectors.isEmpty())
183 delete myOCCSelectors.takeFirst();
185 while (!myVTKSelectors.isEmpty())
186 delete myVTKSelectors.takeFirst();
188 qDeleteAll(myGUIMap);
191 //=======================================================================
192 // function : GeometryGUI::getLibrary()
193 // purpose : get or load GUI library by name [ internal ]
194 //=======================================================================
195 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
196 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
198 if ( !myGUIMap.contains( libraryName ) ) {
199 // try to load library if it is not loaded yet
201 QString dirs = getenv( "LD_LIBRARY_PATH" );
204 QString dirs = getenv( "PATH" );
207 if ( !dirs.isEmpty() ) {
208 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
209 QListIterator<QString> it( dirList ); it.toBack();
210 while ( it.hasPrevious() ) {
211 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
213 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
214 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
216 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
217 continue; // continue search further
219 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
220 if ( osdF != NULL ) {
221 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
222 GEOMGUI* libGUI = (*func)( this );
224 myGUIMap[ libraryName ] = libGUI;
225 break; // found and loaded!
232 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
235 //=======================================================================
236 // function : GeometryGUI::ActiveWorkingPlane()
237 // purpose : Activate Working Plane View
238 //=======================================================================
239 void GeometryGUI::ActiveWorkingPlane()
241 gp_Dir DZ = myWorkingPlane.Direction();
242 gp_Dir DY = myWorkingPlane.YDirection();
244 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
245 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
246 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
249 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
251 Handle(V3d_View) view3d = vw->getViewPort()->getView();
253 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
254 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
260 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
262 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
264 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
265 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
266 camera->SetFocalPoint(0,0,0);
273 //=======================================================================
274 // function : GeometryGUI::SetActiveDialogBox()
275 // purpose : Set active dialog box
276 //=======================================================================
277 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
279 myActiveDialogBox = (QDialog*)aDlg;
282 //=======================================================================
283 // function : GeometryGUI::EmitSignalDeactivateDialog()
284 // purpose : Emit a signal to deactivate the active dialog Box
285 //=======================================================================
286 void GeometryGUI::EmitSignalDeactivateDialog()
288 emit SignalDeactivateActiveDialog();
291 //=======================================================================
292 // function : GeometryGUI::EmitSignalCloseAllDialogs()
293 // purpose : Emit a signal to close all non modal dialogs box
294 //=======================================================================
295 void GeometryGUI::EmitSignalCloseAllDialogs()
297 emit SignalCloseAllDialogs();
300 //=======================================================================
301 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
302 // purpose : Emit a signal to inform that default real spin box step has
304 //=======================================================================
305 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
307 emit SignalDefaultStepValueChanged(newVal);
310 //=======================================================================
311 // function : GeometryGUI::OnGUIEvent()
312 // purpose : common slot for all menu/toolbar actions
313 //=======================================================================
314 void GeometryGUI::OnGUIEvent()
316 const QObject* obj = sender();
317 if ( !obj || !obj->inherits( "QAction" ) )
319 int id = actionId((QAction*)obj);
324 //=======================================================================
325 // function : GeometryGUI::OnGUIEvent()
326 // purpose : manage all events on GUI [static]
327 //=======================================================================
328 void GeometryGUI::OnGUIEvent( int id )
330 SUIT_Application* anApp = application();
332 SUIT_Desktop* desk = anApp->desktop();
334 // check type of the active viewframe
335 SUIT_ViewWindow* window = desk->activeWindow();
336 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
337 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
338 // if current viewframe is not of OCC and not of VTK type - return immediately
339 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
340 QList<int> NotViewerDependentCommands;
341 NotViewerDependentCommands << GEOMOp::OpRename
344 << GEOMOp::OpShowOnly
345 << GEOMOp::OpShowChildren
346 << GEOMOp::OpHideChildren
347 << GEOMOp::OpPointMarker;
348 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
351 // fix for IPAL9103, point 2
352 if ( CORBA::is_nil( GetGeomGen() ) ) {
353 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
358 // find corresponding GUI library
360 case GEOMOp::OpImport: // MENU FILE - IMPORT
361 case GEOMOp::OpExport: // MENU FILE - EXPORT
362 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
363 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
364 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
365 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
366 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
367 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
368 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
369 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
370 case GEOMOp::OpDelete: // MENU EDIT - DELETE
371 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
372 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
373 case GEOMOp::OpColor: // POPUP MENU - COLOR
374 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
375 case GEOMOp::OpIsos: // POPUP MENU - ISOS
376 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
377 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
378 case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
379 case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN
380 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
381 case GEOMOp::OpRename: // POPUP MENU - RENAME
382 libName = "GEOMToolsGUI";
384 case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
385 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
386 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
387 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
388 case GEOMOp::OpHide: // MENU VIEW - ERASE
389 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
390 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
391 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
392 case GEOMOp::OpShading: // POPUP MENU - SHADING
393 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
394 libName = "DisplayGUI";
396 case GEOMOp::OpPoint: // MENU BASIC - POINT
397 case GEOMOp::OpLine: // MENU BASIC - LINE
398 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
399 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
400 case GEOMOp::OpArc: // MENU BASIC - ARC
401 case GEOMOp::OpVector: // MENU BASIC - VECTOR
402 case GEOMOp::OpPlane: // MENU BASIC - PLANE
403 case GEOMOp::OpCurve: // MENU BASIC - CURVE
404 case GEOMOp::OpLCS: // MENU BASIC - REPAIR
405 libName = "BasicGUI";
407 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
408 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
409 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
410 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
411 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
412 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
413 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
414 libName = "PrimitiveGUI";
416 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
417 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
418 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
419 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
420 libName = "GenerationGUI";
422 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
423 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
424 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
425 libName = "EntityGUI";
427 case GEOMOp::OpEdge: // MENU BUILD - EDGE
428 case GEOMOp::OpWire: // MENU BUILD - WIRE
429 case GEOMOp::OpFace: // MENU BUILD - FACE
430 case GEOMOp::OpShell: // MENU BUILD - SHELL
431 case GEOMOp::OpSolid: // MENU BUILD - SOLID
432 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
433 libName = "BuildGUI";
435 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
436 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
437 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
438 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
439 libName = "BooleanGUI";
441 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
442 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
443 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
444 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
445 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
446 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
447 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
448 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
449 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
450 libName = "TransformationGUI";
452 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
453 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
454 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
455 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
456 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
457 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
458 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
459 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
460 libName = "OperationGUI";
462 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
463 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
464 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
465 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
466 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
467 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
468 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
469 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
470 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
471 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
472 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
473 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
474 libName = "RepairGUI";
476 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
477 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
478 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
479 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
480 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
481 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
482 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
483 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
484 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
485 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
486 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
487 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
488 libName = "MeasureGUI";
490 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
491 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
492 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
493 libName = "GroupGUI";
495 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
496 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
497 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
498 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
499 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
500 libName = "BlocksGUI";
506 GEOMGUI* library = 0;
507 if ( !libName.isEmpty() ) {
509 libName = QString( "lib" ) + libName + ".so";
511 libName = libName + ".dll";
513 library = getLibrary( libName );
516 // call method of corresponding GUI library
518 library->OnGUIEvent( id, desk );
520 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
523 //=================================================================================
524 // function : GeometryGUI::OnKeyPress()
525 // purpose : Called when any key is pressed by user [static]
526 //=================================================================================
527 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
529 if ( !application() )
531 foreach ( GEOMGUI* lib, myGUIMap )
532 lib->OnKeyPress( e, application()->desktop(), w );
535 //=================================================================================
536 // function : GeometryGUI::OnMouseMove()
537 // purpose : Manages mouse move events [static]
538 //=================================================================================
539 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
541 if ( !application() )
543 foreach ( GEOMGUI* lib, myGUIMap )
544 lib->OnMouseMove( e, application()->desktop(), w );
547 //=================================================================================
548 // function : GeometryGUI::OnMousePress()
549 // purpose : Manage mouse press events [static]
550 //=================================================================================
551 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
553 if ( !application() )
555 foreach ( GEOMGUI* lib, myGUIMap )
556 lib->OnMousePress( e, application()->desktop(), w );
559 //=======================================================================
560 // function : createGeomAction
562 //=======================================================================
563 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel, const int accel, const bool toggle )
565 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
566 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
567 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
569 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
571 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
572 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
574 application()->desktop(),
576 this, SLOT( OnGUIEvent() ) );
581 //=======================================================================
582 // function : GeometryGUI::initialize()
583 // purpose : Called when GEOM module is created
584 //=======================================================================
585 void GeometryGUI::initialize( CAM_Application* app )
587 SalomeApp_Module::initialize( app );
589 // ----- create actions --------------
591 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
592 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
594 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
596 createGeomAction( GEOMOp::OpPoint, "POINT" );
597 createGeomAction( GEOMOp::OpLine, "LINE" );
598 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
599 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
600 createGeomAction( GEOMOp::OpArc, "ARC" );
601 createGeomAction( GEOMOp::OpCurve, "CURVE" );
602 createGeomAction( GEOMOp::OpVector, "VECTOR" );
603 createGeomAction( GEOMOp::OpPlane, "PLANE" );
604 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
606 createGeomAction( GEOMOp::OpBox, "BOX" );
607 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
608 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
609 createGeomAction( GEOMOp::OpTorus, "TORUS" );
610 createGeomAction( GEOMOp::OpCone, "CONE" );
611 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
612 createGeomAction( GEOMOp::OpDisk, "DISK" );
614 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
615 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
616 createGeomAction( GEOMOp::OpFilling, "FILLING" );
617 createGeomAction( GEOMOp::OpPipe, "PIPE" );
619 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
620 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
622 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
624 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
625 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
627 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
628 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
629 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
631 createGeomAction( GEOMOp::OpEdge, "EDGE" );
632 createGeomAction( GEOMOp::OpWire, "WIRE" );
633 createGeomAction( GEOMOp::OpFace, "FACE" );
634 createGeomAction( GEOMOp::OpShell, "SHELL" );
635 createGeomAction( GEOMOp::OpSolid, "SOLID" );
636 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
638 createGeomAction( GEOMOp::OpFuse, "FUSE" );
639 createGeomAction( GEOMOp::OpCommon, "COMMON" );
640 createGeomAction( GEOMOp::OpCut, "CUT" );
641 createGeomAction( GEOMOp::OpSection, "SECTION" );
643 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
644 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
645 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
646 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
647 createGeomAction( GEOMOp::OpScale, "SCALE" );
648 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
649 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
650 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
652 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
653 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
654 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
655 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
656 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
657 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPES" );
658 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
659 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
661 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
662 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
663 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
665 createGeomAction( GEOMOp::OpSewing, "SEWING" );
666 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
667 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
668 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
669 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
670 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
671 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
672 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
673 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
674 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
675 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
676 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
678 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
679 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
680 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
681 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
682 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
683 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
684 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
685 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
687 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
688 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
689 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
690 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
692 #ifdef _DEBUG_ // PAL16821
693 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
696 createGeomAction( GEOMOp::OpDisplayMode, "SHADING" );
697 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
698 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
699 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
700 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
701 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
702 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
703 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
704 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
705 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
706 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
707 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
708 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
709 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
710 createGeomAction( GEOMOp::OpHide, "ERASE" );
712 createGeomAction( GEOMOp::OpRename, "POP_RENAME", "", Qt::Key_F2 );
713 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
714 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
715 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
716 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
717 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
718 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
719 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
720 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
721 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
722 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
723 createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" );
724 createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" );
725 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
727 // ---- create menus --------------------------
729 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
730 createMenu( separator(), fileId, 10 );
731 createMenu( GEOMOp::OpImport, fileId, 10 );
732 createMenu( GEOMOp::OpExport, fileId, 10 );
733 createMenu( separator(), fileId, -1 );
735 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
736 createMenu( GEOMOp::OpDelete, editId, -1 );
738 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
740 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
741 createMenu( GEOMOp::OpPoint, basicId, -1 );
742 createMenu( GEOMOp::OpLine, basicId, -1 );
743 createMenu( GEOMOp::OpCircle, basicId, -1 );
744 createMenu( GEOMOp::OpEllipse, basicId, -1 );
745 createMenu( GEOMOp::OpArc, basicId, -1 );
746 createMenu( GEOMOp::OpCurve, basicId, -1 );
747 createMenu( separator(), basicId, -1 );
748 createMenu( GEOMOp::OpVector, basicId, -1 );
749 createMenu( GEOMOp::OpPlane, basicId, -1 );
750 createMenu( GEOMOp::OpLCS, basicId, -1 );
752 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
753 createMenu( GEOMOp::OpBox, primId, -1 );
754 createMenu( GEOMOp::OpCylinder, primId, -1 );
755 createMenu( GEOMOp::OpSphere, primId, -1 );
756 createMenu( GEOMOp::OpTorus, primId, -1 );
757 createMenu( GEOMOp::OpCone, primId, -1 );
758 createMenu( GEOMOp::OpRectangle, primId, -1 );
759 createMenu( GEOMOp::OpDisk, primId, -1 );
761 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
762 createMenu( GEOMOp::OpPrism, genId, -1 );
763 createMenu( GEOMOp::OpRevolution, genId, -1 );
764 createMenu( GEOMOp::OpFilling, genId, -1 );
765 createMenu( GEOMOp::OpPipe, genId, -1 );
767 createMenu( separator(), newEntId, -1 );
769 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
770 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
771 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
773 createMenu( separator(), newEntId, -1 );
775 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
776 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
777 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
779 createMenu( separator(), newEntId, -1 );
781 createMenu( GEOMOp::Op2dSketcher, newEntId, -1 );
782 createMenu( GEOMOp::Op3dSketcher, newEntId, -1 );
784 createMenu( separator(), newEntId, -1 );
786 createMenu( GEOMOp::OpExplode, newEntId, -1 );
788 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
789 createMenu( GEOMOp::OpEdge, buildId, -1 );
790 createMenu( GEOMOp::OpWire, buildId, -1 );
791 createMenu( GEOMOp::OpFace, buildId, -1 );
792 createMenu( GEOMOp::OpShell, buildId, -1 );
793 createMenu( GEOMOp::OpSolid, buildId, -1 );
794 createMenu( GEOMOp::OpCompound, buildId, -1 );
796 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
798 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
799 createMenu( GEOMOp::OpFuse, boolId, -1 );
800 createMenu( GEOMOp::OpCommon, boolId, -1 );
801 createMenu( GEOMOp::OpCut, boolId, -1 );
802 createMenu( GEOMOp::OpSection, boolId, -1 );
804 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
805 createMenu( GEOMOp::OpTranslate, transId, -1 );
806 createMenu( GEOMOp::OpRotate, transId, -1 );
807 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
808 createMenu( GEOMOp::OpMirror, transId, -1 );
809 createMenu( GEOMOp::OpScale, transId, -1 );
810 createMenu( GEOMOp::OpOffset, transId, -1 );
811 createMenu( separator(), transId, -1 );
812 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
813 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
815 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
816 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
817 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
818 createMenu( GEOMOp::OpPropagate, blockId, -1 );
820 createMenu( separator(), operId, -1 );
822 createMenu( GEOMOp::OpPartition, operId, -1 );
823 createMenu( GEOMOp::OpArchimede, operId, -1 );
824 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
826 createMenu( separator(), operId, -1 );
828 createMenu( GEOMOp::OpFillet1d, operId, -1 );
829 createMenu( GEOMOp::OpFillet2d, operId, -1 );
830 createMenu( GEOMOp::OpFillet3d, operId, -1 );
831 createMenu( GEOMOp::OpChamfer, operId, -1 );
832 //createMenu( GEOMOp::OpClipping, operId, -1 );
834 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
835 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
836 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
837 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
838 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
839 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
840 createMenu( GEOMOp::OpSewing, repairId, -1 );
841 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
842 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
843 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
844 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
845 createMenu( GEOMOp::OpOrientation, repairId, -1 );
846 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
848 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
849 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
850 createMenu( GEOMOp::OpProperties, measurId, -1 );
851 createMenu( separator(), measurId, -1 );
852 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
853 createMenu( GEOMOp::OpInertia, measurId, -1 );
854 createMenu( GEOMOp::OpNormale, measurId, -1 );
855 createMenu( separator(), measurId, -1 );
856 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
857 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
858 createMenu( separator(), measurId, -1 );
860 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
861 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
862 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
863 createMenu( GEOMOp::OpAngle, dimId, -1 );
865 createMenu( separator(), measurId, -1 );
866 createMenu( GEOMOp::OpTolerance, measurId, -1 );
867 createMenu( separator(), measurId, -1 );
868 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
869 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
870 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
872 #ifdef _DEBUG_ // PAL16821
873 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
874 createMenu( separator(), toolsId, -1 );
875 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
878 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
879 createMenu( separator(), viewId, -1 );
881 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
882 createMenu( GEOMOp::OpDisplayMode, dispmodeId, -1 );
883 createMenu( separator(), dispmodeId, -1 );
884 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
886 createMenu( separator(), viewId, -1 );
887 createMenu( GEOMOp::OpShowAll, viewId, -1 );
888 createMenu( GEOMOp::OpHideAll, viewId, -1 );
889 createMenu( separator(), viewId, -1 );
893 because of these items are accessible through object browser and viewers
894 we have removed they from main menu
896 createMenu( GEOMOp::OpShow, viewId, -1 );
897 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
898 createMenu( GEOMOp::OpHide, viewId, -1 );
901 // ---- create toolbars --------------------------
903 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
904 createTool( GEOMOp::OpPoint, basicTbId );
905 createTool( GEOMOp::OpLine, basicTbId );
906 createTool( GEOMOp::OpCircle, basicTbId );
907 createTool( GEOMOp::OpEllipse, basicTbId );
908 createTool( GEOMOp::OpArc, basicTbId );
909 createTool( GEOMOp::OpCurve, basicTbId );
910 createTool( GEOMOp::OpVector, basicTbId );
911 createTool( GEOMOp::OpPlane, basicTbId );
912 createTool( GEOMOp::OpLCS, basicTbId );
914 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
915 createTool( GEOMOp::OpBox, primTbId );
916 createTool( GEOMOp::OpCylinder, primTbId );
917 createTool( GEOMOp::OpSphere, primTbId );
918 createTool( GEOMOp::OpTorus, primTbId );
919 createTool( GEOMOp::OpCone, primTbId );
920 createTool( GEOMOp::OpRectangle, primTbId );
921 createTool( GEOMOp::OpDisk, primTbId );
923 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
924 createTool( GEOMOp::OpFuse, boolTbId );
925 createTool( GEOMOp::OpCommon, boolTbId );
926 createTool( GEOMOp::OpCut, boolTbId );
927 createTool( GEOMOp::OpSection, boolTbId );
929 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
930 createTool( GEOMOp::OpPrism, genTbId );
931 createTool( GEOMOp::OpRevolution, genTbId );
932 createTool( GEOMOp::OpFilling, genTbId );
933 createTool( GEOMOp::OpPipe, genTbId );
935 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
936 createTool( GEOMOp::OpTranslate, transTbId );
937 createTool( GEOMOp::OpRotate, transTbId );
938 createTool( GEOMOp::OpChangeLoc, transTbId );
939 createTool( GEOMOp::OpMirror, transTbId );
940 createTool( GEOMOp::OpScale, transTbId );
941 createTool( GEOMOp::OpOffset, transTbId );
942 createTool( separator(), transTbId );
943 createTool( GEOMOp::OpMultiTranslate, transTbId );
944 createTool( GEOMOp::OpMultiRotate, transTbId );
946 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
947 createTool( GEOMOp::Op2dSketcher, operTbId );
948 createTool( GEOMOp::Op3dSketcher, operTbId );
949 createTool( separator(), operTbId );
950 createTool( GEOMOp::OpExplode, operTbId );
951 createTool( separator(), operTbId );
952 createTool( GEOMOp::OpPartition, operTbId );
953 createTool( GEOMOp::OpArchimede, operTbId );
954 createTool( GEOMOp::OpShapesOnShape, operTbId );
955 createTool( separator(), operTbId );
956 createTool( GEOMOp::OpFillet1d, operTbId );
957 createTool( GEOMOp::OpFillet2d, operTbId );
958 createTool( GEOMOp::OpFillet3d, operTbId );
959 createTool( GEOMOp::OpChamfer, operTbId );
961 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
962 createTool( GEOMOp::OpEdge, buildTbId );
963 createTool( GEOMOp::OpWire, buildTbId );
964 createTool( GEOMOp::OpFace, buildTbId );
965 createTool( GEOMOp::OpShell, buildTbId );
966 createTool( GEOMOp::OpSolid, buildTbId );
967 createTool( GEOMOp::OpCompound, buildTbId );
969 // ---- create popup menus --------------------------
971 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
972 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
974 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
975 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
977 QString autoColorPrefix =
978 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
980 QtxPopupMgr* mgr = popupMgr();
981 mgr->insert( action( GEOMOp::OpRename ), -1, -1 ); // rename
982 mgr->setRule( action( GEOMOp::OpRename ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
983 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
984 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
985 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
986 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
987 mgr->insert( action( GEOMOp::OpShowChildren ), -1, -1 ); // show children
988 mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
989 mgr->insert( action( GEOMOp::OpHideChildren ), -1, -1 ); // hide children
990 mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
991 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
992 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
993 mgr->insert( separator(), -1, -1 ); // -----------
994 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
995 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
996 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
997 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
998 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
999 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1000 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1001 mgr->insert( separator(), dispmodeId, -1 );
1002 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1003 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1004 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1005 mgr->insert( separator(), -1, -1 ); // -----------
1006 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1007 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1008 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1009 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1010 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1011 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1012 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1013 mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1014 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1015 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg( GEOM_POINT ), QtxPopupMgr::VisibleRule );
1016 mgr->insert( separator(), -1, -1 ); // -----------
1017 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1018 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1019 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1020 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1021 mgr->insert( separator(), -1, -1 ); // -----------
1023 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1024 onlyComponent = "((type='Component') and selcount=1)",
1025 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1026 types = "'Shape' 'Group'";
1028 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1029 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1031 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1032 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1034 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1035 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1037 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1039 int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1040 mgr->insert( action(GEOMOp::OpSelectVertex), selectolnyId, -1); //Vertex
1041 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1042 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1043 mgr->insert( action(GEOMOp::OpSelectEdge), selectolnyId, -1); //Edge
1044 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1045 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1046 mgr->insert( action(GEOMOp::OpSelectWire), selectolnyId, -1); //Wire
1047 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1048 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1049 mgr->insert( action(GEOMOp::OpSelectFace), selectolnyId, -1); //Face
1050 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1051 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1052 mgr->insert( action(GEOMOp::OpSelectShell), selectolnyId, -1); //Shell
1053 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1054 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1055 mgr->insert( action(GEOMOp::OpSelectSolid), selectolnyId, -1); //Solid
1056 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1057 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1058 mgr->insert( action(GEOMOp::OpSelectCompound), selectolnyId, -1); //Compound
1059 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1060 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1061 mgr->insert( separator(), selectolnyId, -1);
1062 mgr->insert( action(GEOMOp::OpSelectAll), selectolnyId, -1); //Clear selection filter
1063 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1064 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1065 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1066 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1067 mgr->insert( separator(), -1, -1 );
1069 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1072 //=======================================================================
1073 // function : GeometryGUI::activateModule()
1074 // purpose : Called when GEOM module is activated
1075 //=======================================================================
1076 bool GeometryGUI::activateModule( SUIT_Study* study )
1078 if ( CORBA::is_nil( myComponentGeom ) )
1081 bool res = SalomeApp_Module::activateModule( study );
1086 setMenuShown( true );
1087 setToolShown( true );
1089 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1090 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1092 // Reset actions accelerator keys
1093 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1094 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1095 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1096 action(GEOMOp::OpRename)->setEnabled( true ); // Rename: Key_F2
1098 GUIMap::Iterator it;
1099 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1100 it.value()->activate( application()->desktop() );
1102 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1104 SUIT_ViewManager* vm;
1105 ViewManagerList OCCViewManagers, VTKViewManagers;
1107 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1108 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1109 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1110 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1112 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1113 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1114 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1115 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1118 SALOME_ListIO selected;
1119 sm->selectedObjects( selected );
1120 sm->clearSelected();
1122 // disable OCC selectors
1123 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1124 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1125 while ( itOCCSel.hasNext() )
1126 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1127 sr->setEnabled(true);
1129 // disable VTK selectors
1130 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1131 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1132 while ( itVTKSel.hasNext() )
1133 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1134 sr->setEnabled(true);
1136 sm->setSelectedObjects( selected, true ); //NPAL 19674
1138 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1140 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1146 //=======================================================================
1147 // function : GeometryGUI::deactivateModule()
1148 // purpose : Called when GEOM module is deactivated
1149 //=======================================================================
1150 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1152 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1154 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1156 setMenuShown( false );
1157 setToolShown( false );
1159 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1160 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1162 EmitSignalCloseAllDialogs();
1164 GUIMap::Iterator it;
1165 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1166 it.value()->deactivate();
1168 // Unset actions accelerator keys
1169 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1170 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1171 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1172 action(GEOMOp::OpRename)->setEnabled( false ); // Rename: Key_F2
1174 qDeleteAll(myOCCSelectors);
1175 myOCCSelectors.clear();
1176 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1178 qDeleteAll(myVTKSelectors);
1179 myVTKSelectors.clear();
1180 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1182 return SalomeApp_Module::deactivateModule( study );
1185 //=======================================================================
1186 // function : onWindowActivated()
1187 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1188 //=======================================================================
1189 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1194 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1195 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1197 // disable non-OCC viewframe menu commands
1198 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1199 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1200 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1201 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1202 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1203 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1204 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1206 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1207 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1209 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1212 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1214 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1215 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1218 void GeometryGUI::viewManagers( QStringList& lst ) const
1220 lst.append( OCCViewer_Viewer::Type() );
1223 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1225 if ( vm->getType() == OCCViewer_Viewer::Type() )
1227 qDebug( "connect" );
1228 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1229 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1230 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1231 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1232 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1233 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1235 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1236 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1238 // disable OCC selectors
1239 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1240 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1241 while ( itOCCSel.hasNext() )
1242 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1243 sr->setEnabled(true);
1245 else if ( vm->getType() == SVTK_Viewer::Type() )
1247 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1248 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1250 // disable VTK selectors
1251 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1252 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1253 while ( itVTKSel.hasNext() )
1254 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1255 sr->setEnabled(true);
1259 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1261 SUIT_ViewModel* viewer = vm->getViewModel();
1262 if ( vm->getType() == OCCViewer_Viewer::Type() )
1264 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1265 while ( itOCCSel.hasNext() )
1266 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1267 if ( sr->viewer() == viewer )
1269 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1273 if ( vm->getType() == SVTK_Viewer::Type() )
1275 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1276 while ( itVTKSel.hasNext() )
1277 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1278 if ( sr->viewer() == viewer )
1280 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1286 QString GeometryGUI::engineIOR() const
1288 if ( !CORBA::is_nil( GetGeomGen() ) )
1289 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1293 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture( SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight )
1295 theWidth = theHeight = 0;
1296 Handle(Graphic3d_HArray1OfBytes) aTexture;
1298 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1299 aTexture = aTextureMap[ theId ];
1300 if ( aTexture.IsNull() ) {
1301 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1302 if ( !aInsOp->_is_nil() ) {
1303 CORBA::Long aWidth, aHeight;
1304 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1305 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1307 theHeight = aHeight;
1308 aTexture = new Graphic3d_HArray1OfBytes( 1, aStream->length() );
1309 for ( int i = 0; i < aStream->length(); i++ )
1310 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1311 aTextureMap[ theId ] = aTexture;
1319 LightApp_Selection* GeometryGUI::createSelection() const
1321 return new GEOMGUI_Selection();
1324 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1326 SalomeApp_Module::contextMenuPopup(client, menu, title);
1329 getApp()->selectionMgr()->selectedObjects(lst);
1330 if (lst.Extent() < 1)
1333 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1334 _PTR(Study) study = appStudy->studyDS();
1336 bool isImported = true;
1337 SALOME_ListIteratorOfListIO anIt (lst);
1338 for (; anIt.More() && isImported; anIt.Next()) {
1339 Handle(SALOME_InteractiveObject) io = anIt.Value();
1340 _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1342 if (lst.Extent() == 1) {
1343 // Set context menu title
1344 if (client == "OCCViewer" || client == "VTKViewer")
1345 title = QString(aSObj->GetName().c_str());
1348 CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1349 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1350 if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1358 menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
1362 void GeometryGUI::createPreferences()
1364 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1366 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1367 setPreferenceProperty( genGroup, "columns", 2 );
1369 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1370 LightApp_Preferences::Selector,
1371 "Geometry", "display_mode" );
1373 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1374 LightApp_Preferences::Color, "Geometry", "shading_color" );
1376 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1377 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1379 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1380 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1382 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1383 LightApp_Preferences::Color, "Geometry", "line_color" );
1385 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1386 LightApp_Preferences::Color, "Geometry", "point_color" );
1388 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1389 LightApp_Preferences::Color, "Geometry", "isos_color" );
1391 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1392 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1394 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1395 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1397 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1398 setPreferenceProperty( VertexGroup, "columns", 2 );
1400 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1401 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1403 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1404 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1406 // Set property for default display mode
1407 QStringList aModesList;
1408 aModesList.append( tr("MEN_WIREFRAME") );
1409 aModesList.append( tr("MEN_SHADING") );
1411 QList<QVariant> anIndexesList;
1412 anIndexesList.append(0);
1413 anIndexesList.append(1);
1415 setPreferenceProperty( dispmode, "strings", aModesList );
1416 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1418 // Set property for step value for spinboxes
1419 setPreferenceProperty( step, "min", 1 );
1420 setPreferenceProperty( step, "max", 10000 );
1421 setPreferenceProperty( step, "precision", 3 );
1423 // Set property for deflection value for spinboxes
1424 setPreferenceProperty( defl, "min", DEFLECTION_MIN );
1425 setPreferenceProperty( defl, "max", 1.0 );
1426 setPreferenceProperty( defl, "step", 1.0e-04 );
1427 setPreferenceProperty( defl, "precision", 6 );
1429 // Set property vertex marker type
1430 QList<QVariant> aMarkerTypeIndicesList;
1431 QList<QVariant> aMarkerTypeIconsList;
1433 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1434 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1435 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1436 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1437 aMarkerTypeIndicesList << (i-1);
1438 aMarkerTypeIconsList << pixmap;
1441 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1442 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
1444 // Set property for vertex marker scale
1445 QList<QVariant> aMarkerScaleIndicesList;
1446 QStringList aMarkerScaleValuesList;
1448 for ( int i = GEOM::MS_10; i <= GEOM::MS_70; i++ ) {
1449 aMarkerScaleIndicesList << i;
1450 aMarkerScaleValuesList << QString::number( (i-(int)GEOM::MS_10)*0.5 + 1.0 );
1453 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1454 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1457 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1459 if (section == "Geometry") {
1460 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1461 if (param == QString("SettingsGeomStep")) {
1462 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1463 EmitSignalDefaultStepValueChanged(spin_step);
1468 LightApp_Displayer* GeometryGUI::displayer()
1471 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1475 void GeometryGUI::setLocalSelectionMode(const int mode)
1477 myLocalSelectionMode = mode;
1479 int GeometryGUI::getLocalSelectionMode() const
1481 return myLocalSelectionMode;
1484 const char gSeparator = '_'; // character used to separate parameter names
1485 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1488 * \brief Store visual parameters
1490 * This method is called just before the study document is saved.
1491 * Store visual parameters in AttributeParameter attribue(s)
1493 void GeometryGUI::storeVisualParameters (int savePoint)
1495 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1496 if (!appStudy || !appStudy->studyDS())
1498 _PTR(Study) studyDS = appStudy->studyDS();
1500 // componentName is used for encoding of entries when storing them in IParameters
1501 std::string componentName = myComponentGeom->ComponentDataType();
1502 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1503 //if (!aSComponent) return;
1506 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1507 componentName.c_str(),
1509 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1511 // viewers counters are used for storing view_numbers in IParameters
1512 int vtkViewers(0), occViewers(0);
1514 QList<SUIT_ViewManager*> lst;
1515 QList<SUIT_ViewManager*>::Iterator it;
1517 // main cycle to store parameters of displayed objects
1519 vtkViewers = occViewers = 0;
1520 getApp()->viewManagers(lst);
1521 for (it = lst.begin(); it != lst.end(); it++)
1523 SUIT_ViewManager* vman = *it;
1524 QString vType = vman->getType();
1526 // saving VTK actors properties
1527 if (vType == SVTK_Viewer::Type())
1529 QVector<SUIT_ViewWindow*> views = vman->getViews();
1530 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
1532 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
1534 vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
1535 allActors->InitTraversal();
1536 while (vtkActor* actor = allActors->GetNextActor())
1538 if (actor->GetVisibility()) // store only visible actors
1540 GEOM_Actor* aGeomActor = 0;
1541 if (actor->IsA("GEOM_Actor"))
1542 aGeomActor = GEOM_Actor::SafeDownCast(actor);
1543 if (aGeomActor && aGeomActor->hasIO())
1545 Handle(SALOME_InteractiveObject) io = aGeomActor->getIO();
1548 // entry is "encoded" = it does NOT contain component adress, since it is a
1549 // subject to change on next component loading
1550 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
1552 std::string param, occParam = vType.toLatin1().data();
1553 occParam += gSeparator;
1554 occParam += QString::number(vtkViewers).toLatin1().data();
1555 occParam += gSeparator;
1557 param = occParam + "Visibility";
1558 ip->setParameter(entry, param, "On");
1560 param = occParam + "DisplayMode";
1561 ip->setParameter(entry, param, QString::number
1562 (aGeomActor->getDisplayMode()).toLatin1().data());
1564 vtkFloatingPointType r, g, b;
1565 aGeomActor->GetColor(r, g, b);
1566 QString colorStr = QString::number(r);
1567 colorStr += gDigitsSep; colorStr += QString::number(g);
1568 colorStr += gDigitsSep; colorStr += QString::number(b);
1569 param = occParam + "Color";
1570 ip->setParameter(entry, param, colorStr.toLatin1().data());
1572 param = occParam + "Opacity";
1573 ip->setParameter(entry, param, QString::number(aGeomActor->GetOpacity()).toLatin1().data());
1575 int nbUIso(0), nbVIso(0);
1576 aGeomActor->GetNbIsos(nbUIso,nbVIso);
1577 QString isosStr = QString::number(nbUIso);
1578 isosStr += gDigitsSep;
1579 isosStr += QString::number(nbVIso);
1580 param = occParam + "Isos";
1581 ip->setParameter(entry, param, isosStr.toLatin1().data());
1582 } // if (io->hasEntry())
1583 } // GEOM_Actor && hasIO
1585 } // while.. actors traversal
1589 } // if (SVTK view model)
1590 else if (vType == SOCC_Viewer::Type()) // processing OCC viewers
1592 QVector<SUIT_ViewWindow*> views = vman->getViews();
1593 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
1595 SOCC_ViewWindow* occView = dynamic_cast<SOCC_ViewWindow*>(views[i]);
1598 //Handle(AIS_InteractiveContext) ic =
1599 // ((OCCViewer_Viewer*)(occView->getViewManager()->getViewModel()))->getAISContext();
1600 OCCViewer_Viewer* viewModel = (OCCViewer_Viewer*)(vman->getViewModel());
1601 //OCCViewer_Viewer* viewModel = ((OCCViewer_ViewManager*)vman)->getOCCViewer();
1602 Handle(AIS_InteractiveContext) ic = viewModel->getAISContext();
1604 AIS_ListOfInteractive aList;
1605 ic->DisplayedObjects(aList);
1607 AIS_ListIteratorOfListOfInteractive ite (aList);
1608 for (; ite.More(); ite.Next())
1610 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
1612 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
1615 Handle(SALOME_InteractiveObject) io =
1616 Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
1619 // entry is "encoded": it does NOT contain component adress,
1620 // since it is a subject to change on next component loading
1621 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
1623 std::string param, occParam = vType.toLatin1().data();
1624 occParam += gSeparator;
1625 occParam += QString::number(occViewers).toLatin1().data();
1626 occParam += gSeparator;
1629 param = occParam + "Visibility";
1630 ip->setParameter(entry, param, "On");
1633 param = occParam + "DisplayMode";
1634 int dm = aSh->DisplayMode();
1635 ip->setParameter(entry, param, QString::number(dm).toLatin1().data());
1638 // is a property of GEOM_Object, it is stored by GEOM engine
1641 param = occParam + "Transparency";
1642 ip->setParameter(entry, param, QString::number(aSh->Transparency()).toLatin1().data());
1645 Handle(AIS_Drawer) aDrawer = aSh->Attributes();
1646 int nbUIso = aDrawer->UIsoAspect()->Number();
1647 int nbVIso = aDrawer->VIsoAspect()->Number();
1648 QString isosStr = QString::number(nbUIso);
1649 isosStr += gDigitsSep;
1650 isosStr += QString::number(nbVIso);
1651 param = occParam + "Isos";
1652 ip->setParameter(entry, param, isosStr.toLatin1().data());
1653 } // if (io->hasEntry())
1655 } // if (GEOM_AISShape)
1656 } // for (AIS_ListOfInteractive)
1660 } // if (SOCC view model)
1663 // unknown viewer type
1665 } // for (viewManagers)
1669 * \brief Restore visual parameters
1671 * This method is called after the study document is opened.
1672 * Restore visual parameters from AttributeParameter attribue(s)
1674 void GeometryGUI::restoreVisualParameters (int savePoint)
1676 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1677 if (!appStudy || !appStudy->studyDS())
1679 _PTR(Study) studyDS = appStudy->studyDS();
1681 // componentName is used for encoding of entries when storing them in IParameters
1682 std::string componentName = myComponentGeom->ComponentDataType();
1683 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1684 //if (!aSComponent) return;
1687 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1688 componentName.c_str(),
1690 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1692 std::vector<std::string> entries = ip->getEntries();
1694 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
1696 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1697 QString entry (ip->decodeEntry(*entIt).c_str());
1699 // Check that the entry corresponds to a real object in the Study
1700 // as the object may be deleted or modified after the visual state is saved.
1701 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1702 if (!so) continue; //Skip the not existent entry
1704 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1705 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1707 std::vector<std::string>::iterator namesIt = paramNames.begin();
1708 std::vector<std::string>::iterator valuesIt = paramValues.begin();
1710 // actors are stored in a map after displaying of them for
1711 // quicker access in the future: map < viewID to actor >
1712 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
1713 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
1715 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
1717 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
1718 // '_' is used as separator and should not be used in viewer type or parameter names.
1719 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
1720 if (lst.size() != 3)
1723 QString viewerTypStr = lst[0];
1724 QString viewIndexStr = lst[1];
1725 QString paramNameStr = lst[2];
1728 int viewIndex = viewIndexStr.toUInt(&ok);
1729 if (!ok) // bad conversion of view index to integer
1733 if (viewerTypStr == SVTK_Viewer::Type())
1735 GEOM_Actor* vActor = 0;
1736 if (vtkActors.IsBound(viewIndex))
1737 vActor = vtkActors.Find(viewIndex);
1739 if (paramNameStr == "Visibility")
1741 if (!vActor && displayer())
1743 QList<SUIT_ViewManager*> lst;
1744 getApp()->viewManagers(viewerTypStr, lst);
1746 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
1747 if (viewIndex >= 0 && viewIndex < lst.count()) {
1748 SUIT_ViewManager* vman = lst.at(viewIndex);
1749 SUIT_ViewModel* vmodel = vman->getViewModel();
1750 // SVTK view model can be casted to SALOME_View
1751 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
1753 // store displayed actor in a temporary map for quicker
1754 // access later when restoring other parameters
1755 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
1756 vtkRenderer* Renderer = vtkView->getRenderer();
1757 vtkActorCollection* theActors = Renderer->GetActors();
1758 theActors->InitTraversal();
1759 bool isFound = false;
1760 vtkActor *ac = theActors->GetNextActor();
1761 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
1762 if (ac->IsA("GEOM_Actor")) {
1763 GEOM_Actor* aGeomAc = GEOM_Actor::SafeDownCast(ac);
1764 if (aGeomAc->hasIO()) {
1765 Handle(SALOME_InteractiveObject) io =
1766 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
1767 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
1769 vtkActors.Bind(viewIndex, aGeomAc);
1776 } // if (paramNameStr == "Visibility")
1779 // the rest properties "work" with GEOM_Actor
1782 QString val ((*valuesIt).c_str());
1784 if (paramNameStr == "DisplayMode") {
1785 vActor->setDisplayMode(val.toInt());
1787 else if (paramNameStr == "Color") {
1788 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
1789 if (colors.count() == 3)
1790 vActor->SetColor(colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat());
1792 else if (paramNameStr == "Opacity") {
1793 vActor->SetOpacity(val.toFloat());
1795 else if (paramNameStr == "Isos") {
1796 QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
1797 if (isos.count() == 2) {
1798 int aIsos[2] = {isos[0].toInt(), isos[1].toInt()};
1799 vActor->SetNbIsos(aIsos);
1803 } // other parameters than Visibility
1805 else if (viewerTypStr == SOCC_Viewer::Type())
1807 //Handle(AIS_InteractiveObject) occActor;
1808 Handle(GEOM_AISShape) occActor;
1809 if (occActors.IsBound(viewIndex))
1810 occActor = occActors.Find(viewIndex);
1812 // ViewModel and InteractiveContext
1813 SOCC_Viewer* occVModel = 0;
1814 Handle(AIS_InteractiveContext) ic;
1816 QList<SUIT_ViewManager*> lst;
1817 getApp()->viewManagers(viewerTypStr, lst);
1819 // SOCC ViewManager always has 1 ViewWindow, so view index is index of view manager
1820 if (viewIndex >= 0 && viewIndex < lst.count()) {
1821 SUIT_ViewManager* vman = lst.at(viewIndex);
1822 SUIT_ViewModel* vmodel = vman->getViewModel();
1823 occVModel = dynamic_cast<SOCC_Viewer*>(vmodel);
1825 ic = occVModel->getAISContext();
1831 if (paramNameStr == "Visibility")
1833 if (occActor.IsNull() && displayer())
1835 displayer()->Display(entry, true, occVModel);
1837 // store displayed actor in a temporary map for quicker
1838 // access later when restoring other parameters
1839 AIS_ListOfInteractive aList;
1840 ic->DisplayedObjects(aList);
1841 bool isFound = false;
1842 AIS_ListIteratorOfListOfInteractive ite (aList);
1843 for (; ite.More() && !isFound; ite.Next()) {
1844 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
1845 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
1847 Handle(SALOME_InteractiveObject) io =
1848 Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
1849 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
1851 occActors.Bind(viewIndex, aSh);
1857 } // if (paramNameStr == "Visibility")
1860 // the rest properties "work" with GEOM_AISShape
1861 if (!occActor.IsNull())
1863 QString val ((*valuesIt).c_str());
1865 if (paramNameStr == "DisplayMode") {
1866 ic->SetDisplayMode(occActor, AIS_DisplayMode(val.toInt()), false);
1867 //ic->Redisplay(occActor, Standard_False, Standard_True);
1869 // Color is restored by the GEOM engine
1870 else if (paramNameStr == "Transparency") {
1871 ic->SetTransparency(occActor, val.toFloat(), false);
1872 ic->Redisplay(occActor, Standard_False, Standard_True);
1874 else if (paramNameStr == "Isos") {
1875 QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
1876 if (isos.count() == 2) {
1877 Handle(AIS_Drawer) aDrawer = occActor->Attributes();
1878 int nbUIso = isos[0].toInt();
1879 int nbVIso = isos[1].toInt();
1880 Handle(Prs3d_IsoAspect) uIsoAspect = aDrawer->UIsoAspect();
1881 Handle(Prs3d_IsoAspect) vIsoAspect = aDrawer->VIsoAspect();
1882 uIsoAspect->SetNumber(nbUIso);
1883 vIsoAspect->SetNumber(nbVIso);
1884 aDrawer->SetUIsoAspect(uIsoAspect);
1885 aDrawer->SetVIsoAspect(vIsoAspect);
1886 ic->SetLocalAttributes(occActor, aDrawer);
1887 ic->Redisplay(occActor);
1891 } // other parameters than Visibility
1895 // unknown viewer type
1897 } // for names/parameters iterator
1898 } // for entries iterator
1900 // update all VTK and OCC views
1901 QList<SUIT_ViewManager*> lst;
1902 getApp()->viewManagers(lst);
1903 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
1904 SUIT_ViewModel* vmodel = (*it)->getViewModel();
1907 if (vmodel->getType() == SVTK_Viewer::Type()) {
1908 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
1909 vtkView->getRenderer()->ResetCameraClippingRange();
1912 else if (vmodel->getType() == SOCC_Viewer::Type()) {
1913 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
1914 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
1921 void GeometryGUI::onViewAboutToShow()
1923 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
1924 QAction* a = action( GEOMOp::OpSwitchVectors );
1926 a->setEnabled(true);
1927 bool vmode = window->getCustomData("VectorsMode").toBool();
1928 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
1930 a->setText ( tr("MEN_VECTOR_MODE_ON") );
1931 a->setEnabled(false);