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 //=======================================================================
155 // function : GeometryGUI::GeometryGUI()
156 // purpose : Constructor
157 //=======================================================================
158 GeometryGUI::GeometryGUI() :
159 SalomeApp_Module( "GEOM" ),
160 LightApp_Module( "GEOM" )
162 if ( CORBA::is_nil( myComponentGeom ) )
164 Engines::Component_var comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
165 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
168 myActiveDialogBox = 0;
170 gp_Pnt origin = gp_Pnt(0., 0., 0.);
171 gp_Dir direction = gp_Dir(0., 0., 1.);
172 myWorkingPlane = gp_Ax3(origin, direction);
175 myLocalSelectionMode = GEOM_ALLOBJECTS;
178 //=======================================================================
179 // function : GeometryGUI::~GeometryGUI()
180 // purpose : Destructor
181 //=======================================================================
182 GeometryGUI::~GeometryGUI()
184 while (!myOCCSelectors.isEmpty())
185 delete myOCCSelectors.takeFirst();
187 while (!myVTKSelectors.isEmpty())
188 delete myVTKSelectors.takeFirst();
190 qDeleteAll(myGUIMap);
193 //=======================================================================
194 // function : GeometryGUI::getLibrary()
195 // purpose : get or load GUI library by name [ internal ]
196 //=======================================================================
197 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
198 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
200 if ( !myGUIMap.contains( libraryName ) ) {
201 // try to load library if it is not loaded yet
203 QString dirs = getenv( "LD_LIBRARY_PATH" );
206 QString dirs = getenv( "PATH" );
209 if ( !dirs.isEmpty() ) {
210 QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
211 QListIterator<QString> it( dirList ); it.toBack();
212 while ( it.hasPrevious() ) {
213 QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
215 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
216 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
218 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
219 continue; // continue search further
221 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
222 if ( osdF != NULL ) {
223 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
224 GEOMGUI* libGUI = (*func)( this );
226 myGUIMap[ libraryName ] = libGUI;
227 break; // found and loaded!
234 return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
237 //=======================================================================
238 // function : GeometryGUI::ActiveWorkingPlane()
239 // purpose : Activate Working Plane View
240 //=======================================================================
241 void GeometryGUI::ActiveWorkingPlane()
243 gp_Dir DZ = myWorkingPlane.Direction();
244 gp_Dir DY = myWorkingPlane.YDirection();
246 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
247 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
248 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
251 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
253 Handle(V3d_View) view3d = vw->getViewPort()->getView();
255 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
256 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
262 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
264 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
266 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
267 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
268 camera->SetFocalPoint(0,0,0);
275 //=======================================================================
276 // function : GeometryGUI::SetActiveDialogBox()
277 // purpose : Set active dialog box
278 //=======================================================================
279 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
281 myActiveDialogBox = (QDialog*)aDlg;
284 //=======================================================================
285 // function : GeometryGUI::EmitSignalDeactivateDialog()
286 // purpose : Emit a signal to deactivate the active dialog Box
287 //=======================================================================
288 void GeometryGUI::EmitSignalDeactivateDialog()
290 emit SignalDeactivateActiveDialog();
293 //=======================================================================
294 // function : GeometryGUI::EmitSignalCloseAllDialogs()
295 // purpose : Emit a signal to close all non modal dialogs box
296 //=======================================================================
297 void GeometryGUI::EmitSignalCloseAllDialogs()
299 emit SignalCloseAllDialogs();
302 //=======================================================================
303 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
304 // purpose : Emit a signal to inform that default real spin box step has
306 //=======================================================================
307 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
309 emit SignalDefaultStepValueChanged(newVal);
312 //=======================================================================
313 // function : GeometryGUI::OnGUIEvent()
314 // purpose : common slot for all menu/toolbar actions
315 //=======================================================================
316 void GeometryGUI::OnGUIEvent()
318 const QObject* obj = sender();
319 if ( !obj || !obj->inherits( "QAction" ) )
321 int id = actionId((QAction*)obj);
326 //=======================================================================
327 // function : GeometryGUI::OnGUIEvent()
328 // purpose : manage all events on GUI [static]
329 //=======================================================================
330 void GeometryGUI::OnGUIEvent( int id )
332 SUIT_Application* anApp = application();
334 SUIT_Desktop* desk = anApp->desktop();
336 // check type of the active viewframe
337 SUIT_ViewWindow* window = desk->activeWindow();
338 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
339 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
340 // if current viewframe is not of OCC and not of VTK type - return immediately
341 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
342 QList<int> NotViewerDependentCommands;
343 NotViewerDependentCommands << GEOMOp::OpRename
346 << GEOMOp::OpShowOnly
347 << GEOMOp::OpShowChildren
348 << GEOMOp::OpHideChildren
349 << GEOMOp::OpPointMarker;
350 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
353 // fix for IPAL9103, point 2
354 if ( CORBA::is_nil( GetGeomGen() ) ) {
355 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
360 // find corresponding GUI library
362 case GEOMOp::OpOriginAndVectors: // MENU BASIC - ORIGIN AND BASE VECTORS
363 createOriginAndBaseVectors(); // internal operation
365 case GEOMOp::OpImport: // MENU FILE - IMPORT
366 case GEOMOp::OpExport: // MENU FILE - EXPORT
367 case GEOMOp::OpSelectVertex: // POPUP MENU - SELECT ONLY - VERTEX
368 case GEOMOp::OpSelectEdge: // POPUP MENU - SELECT ONLY - EDGE
369 case GEOMOp::OpSelectWire: // POPUP MENU - SELECT ONLY - WIRE
370 case GEOMOp::OpSelectFace: // POPUP MENU - SELECT ONLY - FACE
371 case GEOMOp::OpSelectShell: // POPUP MENU - SELECT ONLY - SHELL
372 case GEOMOp::OpSelectSolid: // POPUP MENU - SELECT ONLY - SOLID
373 case GEOMOp::OpSelectCompound: // POPUP MENU - SELECT ONLY - COMPOUND
374 case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL
375 case GEOMOp::OpDelete: // MENU EDIT - DELETE
376 case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
377 case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
378 case GEOMOp::OpColor: // POPUP MENU - COLOR
379 case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
380 case GEOMOp::OpIsos: // POPUP MENU - ISOS
381 case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
382 case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
383 case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
384 case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN
385 case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
386 case GEOMOp::OpRename: // POPUP MENU - RENAME
387 libName = "GEOMToolsGUI";
389 case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
390 case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
391 case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
392 case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
393 case GEOMOp::OpHide: // MENU VIEW - ERASE
394 case GEOMOp::OpShow: // MENU VIEW - DISPLAY
395 case GEOMOp::OpSwitchVectors: // MENU VIEW - VECTOR MODE
396 case GEOMOp::OpWireframe: // POPUP MENU - WIREFRAME
397 case GEOMOp::OpShading: // POPUP MENU - SHADING
398 case GEOMOp::OpVectors: // POPUP MENU - VECTORS
399 libName = "DisplayGUI";
401 case GEOMOp::OpPoint: // MENU BASIC - POINT
402 case GEOMOp::OpLine: // MENU BASIC - LINE
403 case GEOMOp::OpCircle: // MENU BASIC - CIRCLE
404 case GEOMOp::OpEllipse: // MENU BASIC - ELLIPSE
405 case GEOMOp::OpArc: // MENU BASIC - ARC
406 case GEOMOp::OpVector: // MENU BASIC - VECTOR
407 case GEOMOp::OpPlane: // MENU BASIC - PLANE
408 case GEOMOp::OpCurve: // MENU BASIC - CURVE
409 case GEOMOp::OpLCS: // MENU BASIC - LOCAL COORDINATE SYSTEM
410 libName = "BasicGUI";
412 case GEOMOp::OpBox: // MENU PRIMITIVE - BOX
413 case GEOMOp::OpCylinder: // MENU PRIMITIVE - CYLINDER
414 case GEOMOp::OpSphere: // MENU PRIMITIVE - SPHERE
415 case GEOMOp::OpTorus: // MENU PRIMITIVE - TORUS
416 case GEOMOp::OpCone: // MENU PRIMITIVE - CONE
417 case GEOMOp::OpRectangle: // MENU PRIMITIVE - FACE
418 case GEOMOp::OpDisk: // MENU PRIMITIVE - DISK
419 libName = "PrimitiveGUI";
421 case GEOMOp::OpPrism: // MENU GENERATION - PRISM
422 case GEOMOp::OpRevolution: // MENU GENERATION - REVOLUTION
423 case GEOMOp::OpFilling: // MENU GENERATION - FILLING
424 case GEOMOp::OpPipe: // MENU GENERATION - PIPE
425 libName = "GenerationGUI";
427 case GEOMOp::Op2dSketcher: // MENU ENTITY - SKETCHER
428 case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
429 case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
430 libName = "EntityGUI";
432 case GEOMOp::OpEdge: // MENU BUILD - EDGE
433 case GEOMOp::OpWire: // MENU BUILD - WIRE
434 case GEOMOp::OpFace: // MENU BUILD - FACE
435 case GEOMOp::OpShell: // MENU BUILD - SHELL
436 case GEOMOp::OpSolid: // MENU BUILD - SOLID
437 case GEOMOp::OpCompound: // MENU BUILD - COMPUND
438 libName = "BuildGUI";
440 case GEOMOp::OpFuse: // MENU BOOLEAN - FUSE
441 case GEOMOp::OpCommon: // MENU BOOLEAN - COMMON
442 case GEOMOp::OpCut: // MENU BOOLEAN - CUT
443 case GEOMOp::OpSection: // MENU BOOLEAN - SECTION
444 libName = "BooleanGUI";
446 case GEOMOp::OpTranslate: // MENU TRANSFORMATION - TRANSLATION
447 case GEOMOp::OpRotate: // MENU TRANSFORMATION - ROTATION
448 case GEOMOp::OpChangeLoc: // MENU TRANSFORMATION - LOCATION
449 case GEOMOp::OpMirror: // MENU TRANSFORMATION - MIRROR
450 case GEOMOp::OpScale: // MENU TRANSFORMATION - SCALE
451 case GEOMOp::OpOffset: // MENU TRANSFORMATION - OFFSET
452 case GEOMOp::OpMultiTranslate: // MENU TRANSFORMATION - MULTI-TRANSLATION
453 case GEOMOp::OpMultiRotate: // MENU TRANSFORMATION - MULTI-ROTATION
454 case GEOMOp::OpReimport: // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
455 libName = "TransformationGUI";
457 case GEOMOp::OpPartition: // MENU OPERATION - PARTITION
458 case GEOMOp::OpArchimede: // MENU OPERATION - ARCHIMEDE
459 case GEOMOp::OpFillet3d: // MENU OPERATION - FILLET
460 case GEOMOp::OpChamfer: // MENU OPERATION - CHAMFER
461 case GEOMOp::OpClipping: // MENU OPERATION - CLIPPING RANGE
462 case GEOMOp::OpShapesOnShape: // MENU OPERATION - GET SHAPES ON SHAPE
463 case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
464 case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
465 libName = "OperationGUI";
467 case GEOMOp::OpSewing: // MENU REPAIR - SEWING
468 case GEOMOp::OpSuppressFaces: // MENU REPAIR - SUPPRESS FACES
469 case GEOMOp::OpSuppressHoles: // MENU REPAIR - SUPPRESS HOLE
470 case GEOMOp::OpShapeProcess: // MENU REPAIR - SHAPE PROCESSING
471 case GEOMOp::OpCloseContour: // MENU REPAIR - CLOSE CONTOUR
472 case GEOMOp::OpRemoveIntWires: // MENU REPAIR - REMOVE INTERNAL WIRES
473 case GEOMOp::OpAddPointOnEdge: // MENU REPAIR - ADD POINT ON EDGE
474 case GEOMOp::OpFreeBoundaries: // MENU MEASURE - FREE BOUNDARIES
475 case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
476 case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
477 case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
478 case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
479 case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
480 libName = "RepairGUI";
482 case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
483 case GEOMOp::OpCenterMass: // MENU MEASURE - CDG
484 case GEOMOp::OpInertia: // MENU MEASURE - INERTIA
485 case GEOMOp::OpNormale: // MENU MEASURE - NORMALE
486 case GEOMOp::OpBoundingBox: // MENU MEASURE - BOUNDING BOX
487 case GEOMOp::OpMinDistance: // MENU MEASURE - MIN DISTANCE
488 case GEOMOp::OpAngle: // MENU MEASURE - ANGLE
489 case GEOMOp::OpTolerance: // MENU MEASURE - TOLERANCE
490 case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
491 case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
492 case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
493 case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
494 libName = "MeasureGUI";
496 case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
497 case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
498 case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
499 libName = "GroupGUI";
501 case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
502 case GEOMOp::OpMultiTransform: // MENU BLOCKS - MULTI-TRANSFORMATION
503 case GEOMOp::OpQuadFace: // MENU BLOCKS - QUADRANGLE FACE
504 case GEOMOp::OpPropagate: // MENU BLOCKS - PROPAGATE
505 case GEOMOp::OpExplodeBlock: // MENU BLOCKS - EXPLODE ON BLOCKS
506 libName = "BlocksGUI";
508 case GEOMOp::OpAdvancedNoOp: // NO OPERATION (advanced operations base)
509 case GEOMOp::OpPipeTShape: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
510 // case GEOMOp::OpPipeTShapeGroups: // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
511 //@@ 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 @@//
512 libName = "AdvancedGUI";
518 GEOMGUI* library = 0;
519 if ( !libName.isEmpty() ) {
521 libName = QString( "lib" ) + libName + ".so";
523 libName = libName + ".dll";
525 library = getLibrary( libName );
528 // call method of corresponding GUI library
530 library->OnGUIEvent( id, desk );
532 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
535 //=================================================================================
536 // function : GeometryGUI::OnKeyPress()
537 // purpose : Called when any key is pressed by user [static]
538 //=================================================================================
539 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
541 if ( !application() )
543 foreach ( GEOMGUI* lib, myGUIMap )
544 lib->OnKeyPress( e, application()->desktop(), w );
547 //=================================================================================
548 // function : GeometryGUI::OnMouseMove()
549 // purpose : Manages mouse move events [static]
550 //=================================================================================
551 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
553 if ( !application() )
555 foreach ( GEOMGUI* lib, myGUIMap )
556 lib->OnMouseMove( e, application()->desktop(), w );
559 //=================================================================================
560 // function : GeometryGUI::OnMousePress()
561 // purpose : Manage mouse press events [static]
562 //=================================================================================
563 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
565 if ( !application() )
567 foreach ( GEOMGUI* lib, myGUIMap )
568 lib->OnMousePress( e, application()->desktop(), w );
571 //=======================================================================
572 // function : createGeomAction
574 //=======================================================================
575 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel, const int accel, const bool toggle )
577 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
578 QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
579 : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
581 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
583 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
584 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
586 application()->desktop(),
588 this, SLOT( OnGUIEvent() ) );
591 //=======================================================================
592 // function : createGeomAction
594 //=======================================================================
595 void GeometryGUI::createOriginAndBaseVectors()
597 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
599 _PTR(Study) studyDS = appStudy->studyDS();
600 if( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
601 GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
602 if( !aBasicOperations->_is_nil() ) {
603 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
604 double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
605 GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
606 GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
607 GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
608 GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
610 SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
611 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
612 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
613 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
614 GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
616 getApp()->updateObjectBrowser( false );
622 //=======================================================================
623 // function : GeometryGUI::initialize()
624 // purpose : Called when GEOM module is created
625 //=======================================================================
626 void GeometryGUI::initialize( CAM_Application* app )
628 SalomeApp_Module::initialize( app );
630 // ----- create actions --------------
632 createGeomAction( GEOMOp::OpImport, "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
633 createGeomAction( GEOMOp::OpExport, "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
635 createGeomAction( GEOMOp::OpDelete, "DELETE", "", Qt::Key_Delete );
637 createGeomAction( GEOMOp::OpPoint, "POINT" );
638 createGeomAction( GEOMOp::OpLine, "LINE" );
639 createGeomAction( GEOMOp::OpCircle, "CIRCLE" );
640 createGeomAction( GEOMOp::OpEllipse, "ELLIPSE" );
641 createGeomAction( GEOMOp::OpArc, "ARC" );
642 createGeomAction( GEOMOp::OpCurve, "CURVE" );
643 createGeomAction( GEOMOp::OpVector, "VECTOR" );
644 createGeomAction( GEOMOp::OpPlane, "PLANE" );
645 createGeomAction( GEOMOp::OpLCS, "LOCAL_CS" );
646 createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
648 createGeomAction( GEOMOp::OpBox, "BOX" );
649 createGeomAction( GEOMOp::OpCylinder, "CYLINDER" );
650 createGeomAction( GEOMOp::OpSphere, "SPHERE" );
651 createGeomAction( GEOMOp::OpTorus, "TORUS" );
652 createGeomAction( GEOMOp::OpCone, "CONE" );
653 createGeomAction( GEOMOp::OpRectangle, "RECTANGLE" );
654 createGeomAction( GEOMOp::OpDisk, "DISK" );
656 createGeomAction( GEOMOp::OpPrism, "EXTRUSION" );
657 createGeomAction( GEOMOp::OpRevolution, "REVOLUTION" );
658 createGeomAction( GEOMOp::OpFilling, "FILLING" );
659 createGeomAction( GEOMOp::OpPipe, "PIPE" );
661 createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
662 createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
664 createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
666 createGeomAction( GEOMOp::OpQuadFace, "Q_FACE" );
667 createGeomAction( GEOMOp::OpHexaSolid, "HEX_SOLID" );
669 createGeomAction( GEOMOp::Op2dSketcher, "SKETCH" );
670 createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
671 createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
673 createGeomAction( GEOMOp::OpEdge, "EDGE" );
674 createGeomAction( GEOMOp::OpWire, "WIRE" );
675 createGeomAction( GEOMOp::OpFace, "FACE" );
676 createGeomAction( GEOMOp::OpShell, "SHELL" );
677 createGeomAction( GEOMOp::OpSolid, "SOLID" );
678 createGeomAction( GEOMOp::OpCompound, "COMPOUND" );
680 createGeomAction( GEOMOp::OpFuse, "FUSE" );
681 createGeomAction( GEOMOp::OpCommon, "COMMON" );
682 createGeomAction( GEOMOp::OpCut, "CUT" );
683 createGeomAction( GEOMOp::OpSection, "SECTION" );
685 createGeomAction( GEOMOp::OpTranslate, "TRANSLATION" );
686 createGeomAction( GEOMOp::OpRotate, "ROTATION" );
687 createGeomAction( GEOMOp::OpChangeLoc, "MODIFY_LOCATION" );
688 createGeomAction( GEOMOp::OpMirror, "MIRROR" );
689 createGeomAction( GEOMOp::OpScale, "SCALE" );
690 createGeomAction( GEOMOp::OpOffset, "OFFSET" );
691 createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
692 createGeomAction( GEOMOp::OpMultiRotate, "MUL_ROTATION" );
694 createGeomAction( GEOMOp::OpPartition, "PARTITION" );
695 createGeomAction( GEOMOp::OpArchimede, "ARCHIMEDE" );
696 createGeomAction( GEOMOp::OpFillet3d, "FILLET" );
697 createGeomAction( GEOMOp::OpChamfer, "CHAMFER" );
698 //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
699 createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPES" );
700 createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
701 createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
703 createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
704 createGeomAction( GEOMOp::OpExplodeBlock, "EXPLODE_BLOCKS" );
705 createGeomAction( GEOMOp::OpPropagate, "PROPAGATE" );
707 createGeomAction( GEOMOp::OpSewing, "SEWING" );
708 createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
709 createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
710 createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
711 createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
712 createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
713 createGeomAction( GEOMOp::OpCloseContour, "CLOSE_CONTOUR" );
714 createGeomAction( GEOMOp::OpRemoveIntWires, "SUPPRESS_INT_WIRES" );
715 createGeomAction( GEOMOp::OpAddPointOnEdge, "POINT_ON_EDGE" );
716 createGeomAction( GEOMOp::OpFreeBoundaries, "CHECK_FREE_BNDS" );
717 createGeomAction( GEOMOp::OpFreeFaces, "CHECK_FREE_FACES" );
718 createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
719 createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
721 createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
722 createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
723 createGeomAction( GEOMOp::OpCenterMass, "MASS_CENTER" );
724 createGeomAction( GEOMOp::OpInertia, "INERTIA" );
725 createGeomAction( GEOMOp::OpNormale, "NORMALE" );
726 createGeomAction( GEOMOp::OpBoundingBox, "BND_BOX" );
727 createGeomAction( GEOMOp::OpMinDistance, "MIN_DIST" );
728 createGeomAction( GEOMOp::OpAngle, "MEASURE_ANGLE" );
730 createGeomAction( GEOMOp::OpTolerance, "TOLERANCE" );
731 createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
732 createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
733 createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
735 #ifdef _DEBUG_ // PAL16821
736 createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" );
739 createGeomAction( GEOMOp::OpDisplayMode, "SHADING" );
740 createGeomAction( GEOMOp::OpShowAll, "DISPLAY_ALL" );
741 createGeomAction( GEOMOp::OpHideAll, "ERASE_ALL" );
742 createGeomAction( GEOMOp::OpShow, "DISPLAY" );
743 createGeomAction( GEOMOp::OpSwitchVectors, "VECTOR_MODE");
744 createGeomAction( GEOMOp::OpSelectVertex, "VERTEX_SEL_ONLY" ,"", 0, true );
745 createGeomAction( GEOMOp::OpSelectEdge, "EDGE_SEL_ONLY", "", 0, true );
746 createGeomAction( GEOMOp::OpSelectWire, "WIRE_SEL_ONLY", "", 0, true );
747 createGeomAction( GEOMOp::OpSelectFace, "FACE_SEL_ONLY", "", 0, true );
748 createGeomAction( GEOMOp::OpSelectShell, "SHELL_SEL_ONLY", "", 0, true );
749 createGeomAction( GEOMOp::OpSelectSolid, "SOLID_SEL_ONLY", "", 0, true );
750 createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
751 createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
752 createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
753 createGeomAction( GEOMOp::OpHide, "ERASE" );
755 createGeomAction( GEOMOp::OpRename, "POP_RENAME", "", Qt::Key_F2 );
756 createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
757 createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
758 createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
759 createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
760 createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
761 createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
762 createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
763 createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
764 createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
765 createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
766 createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" );
767 createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" );
768 createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
770 createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
771 // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
772 //@@ 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 @@//
774 // ---- create menus --------------------------
776 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
777 createMenu( separator(), fileId, 10 );
778 createMenu( GEOMOp::OpImport, fileId, 10 );
779 createMenu( GEOMOp::OpExport, fileId, 10 );
780 createMenu( separator(), fileId, -1 );
782 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
783 createMenu( GEOMOp::OpDelete, editId, -1 );
785 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
787 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
788 createMenu( GEOMOp::OpPoint, basicId, -1 );
789 createMenu( GEOMOp::OpLine, basicId, -1 );
790 createMenu( GEOMOp::OpCircle, basicId, -1 );
791 createMenu( GEOMOp::OpEllipse, basicId, -1 );
792 createMenu( GEOMOp::OpArc, basicId, -1 );
793 createMenu( GEOMOp::OpCurve, basicId, -1 );
794 createMenu( separator(), basicId, -1 );
795 createMenu( GEOMOp::OpVector, basicId, -1 );
796 createMenu( GEOMOp::OpPlane, basicId, -1 );
797 createMenu( GEOMOp::OpLCS, basicId, -1 );
798 createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
800 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
801 createMenu( GEOMOp::OpBox, primId, -1 );
802 createMenu( GEOMOp::OpCylinder, primId, -1 );
803 createMenu( GEOMOp::OpSphere, primId, -1 );
804 createMenu( GEOMOp::OpTorus, primId, -1 );
805 createMenu( GEOMOp::OpCone, primId, -1 );
806 createMenu( GEOMOp::OpRectangle, primId, -1 );
807 createMenu( GEOMOp::OpDisk, primId, -1 );
809 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
810 createMenu( GEOMOp::OpPrism, genId, -1 );
811 createMenu( GEOMOp::OpRevolution, genId, -1 );
812 createMenu( GEOMOp::OpFilling, genId, -1 );
813 createMenu( GEOMOp::OpPipe, genId, -1 );
815 int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
816 createMenu( GEOMOp::OpPipeTShape, advId, -1 );
817 // createMenu( GEOMOp::OpPipeTShapeGroups, advId, -1 );
818 //@@ 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 @@//
820 createMenu( separator(), newEntId, -1 );
822 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
823 createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
824 createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
826 createMenu( separator(), newEntId, -1 );
828 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
829 createMenu( GEOMOp::OpQuadFace, blocksId, -1 );
830 createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
832 createMenu( separator(), newEntId, -1 );
834 createMenu( GEOMOp::Op2dSketcher, newEntId, -1 );
835 createMenu( GEOMOp::Op3dSketcher, newEntId, -1 );
837 createMenu( separator(), newEntId, -1 );
839 createMenu( GEOMOp::OpExplode, newEntId, -1 );
841 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
842 createMenu( GEOMOp::OpEdge, buildId, -1 );
843 createMenu( GEOMOp::OpWire, buildId, -1 );
844 createMenu( GEOMOp::OpFace, buildId, -1 );
845 createMenu( GEOMOp::OpShell, buildId, -1 );
846 createMenu( GEOMOp::OpSolid, buildId, -1 );
847 createMenu( GEOMOp::OpCompound, buildId, -1 );
849 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
851 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
852 createMenu( GEOMOp::OpFuse, boolId, -1 );
853 createMenu( GEOMOp::OpCommon, boolId, -1 );
854 createMenu( GEOMOp::OpCut, boolId, -1 );
855 createMenu( GEOMOp::OpSection, boolId, -1 );
857 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
858 createMenu( GEOMOp::OpTranslate, transId, -1 );
859 createMenu( GEOMOp::OpRotate, transId, -1 );
860 createMenu( GEOMOp::OpChangeLoc, transId, -1 );
861 createMenu( GEOMOp::OpMirror, transId, -1 );
862 createMenu( GEOMOp::OpScale, transId, -1 );
863 createMenu( GEOMOp::OpOffset, transId, -1 );
864 createMenu( separator(), transId, -1 );
865 createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
866 createMenu( GEOMOp::OpMultiRotate, transId, -1 );
868 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
869 createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
870 createMenu( GEOMOp::OpExplodeBlock, blockId, -1 );
871 createMenu( GEOMOp::OpPropagate, blockId, -1 );
873 createMenu( separator(), operId, -1 );
875 createMenu( GEOMOp::OpPartition, operId, -1 );
876 createMenu( GEOMOp::OpArchimede, operId, -1 );
877 createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
879 createMenu( separator(), operId, -1 );
881 createMenu( GEOMOp::OpFillet1d, operId, -1 );
882 createMenu( GEOMOp::OpFillet2d, operId, -1 );
883 createMenu( GEOMOp::OpFillet3d, operId, -1 );
884 createMenu( GEOMOp::OpChamfer, operId, -1 );
885 //createMenu( GEOMOp::OpClipping, operId, -1 );
887 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
888 createMenu( GEOMOp::OpShapeProcess, repairId, -1 );
889 createMenu( GEOMOp::OpSuppressFaces, repairId, -1 );
890 createMenu( GEOMOp::OpCloseContour, repairId, -1 );
891 createMenu( GEOMOp::OpRemoveIntWires, repairId, -1 );
892 createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
893 createMenu( GEOMOp::OpSewing, repairId, -1 );
894 createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
895 createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
896 createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
897 //createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
898 //createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
899 createMenu( GEOMOp::OpOrientation, repairId, -1 );
900 createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
902 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
903 createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
904 createMenu( GEOMOp::OpProperties, measurId, -1 );
905 createMenu( separator(), measurId, -1 );
906 createMenu( GEOMOp::OpCenterMass, measurId, -1 );
907 createMenu( GEOMOp::OpInertia, measurId, -1 );
908 createMenu( GEOMOp::OpNormale, measurId, -1 );
909 createMenu( separator(), measurId, -1 );
910 createMenu( GEOMOp::OpFreeBoundaries, measurId, -1 );
911 createMenu( GEOMOp::OpFreeFaces, measurId, -1 );
912 createMenu( separator(), measurId, -1 );
914 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
915 createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
916 createMenu( GEOMOp::OpMinDistance, dimId, -1 );
917 createMenu( GEOMOp::OpAngle, dimId, -1 );
919 createMenu( separator(), measurId, -1 );
920 createMenu( GEOMOp::OpTolerance, measurId, -1 );
921 createMenu( separator(), measurId, -1 );
922 createMenu( GEOMOp::OpWhatIs, measurId, -1 );
923 createMenu( GEOMOp::OpCheckShape, measurId, -1 );
924 createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
926 #ifdef _DEBUG_ // PAL16821
927 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
928 createMenu( separator(), toolsId, -1 );
929 createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
932 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
933 createMenu( separator(), viewId, -1 );
935 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
936 createMenu( GEOMOp::OpDisplayMode, dispmodeId, -1 );
937 createMenu( separator(), dispmodeId, -1 );
938 createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
940 createMenu( separator(), viewId, -1 );
941 createMenu( GEOMOp::OpShowAll, viewId, -1 );
942 createMenu( GEOMOp::OpHideAll, viewId, -1 );
943 createMenu( separator(), viewId, -1 );
947 because of these items are accessible through object browser and viewers
948 we have removed they from main menu
950 createMenu( GEOMOp::OpShow, viewId, -1 );
951 createMenu( GEOMOp::OpShowOnly, viewId, -1 );
952 createMenu( GEOMOp::OpHide, viewId, -1 );
955 // ---- create toolbars --------------------------
957 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
958 createTool( GEOMOp::OpPoint, basicTbId );
959 createTool( GEOMOp::OpLine, basicTbId );
960 createTool( GEOMOp::OpCircle, basicTbId );
961 createTool( GEOMOp::OpEllipse, basicTbId );
962 createTool( GEOMOp::OpArc, basicTbId );
963 createTool( GEOMOp::OpCurve, basicTbId );
964 createTool( GEOMOp::OpVector, basicTbId );
965 createTool( GEOMOp::OpPlane, basicTbId );
966 createTool( GEOMOp::OpLCS, basicTbId );
967 createTool( GEOMOp::OpOriginAndVectors, basicTbId );
969 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
970 createTool( GEOMOp::OpBox, primTbId );
971 createTool( GEOMOp::OpCylinder, primTbId );
972 createTool( GEOMOp::OpSphere, primTbId );
973 createTool( GEOMOp::OpTorus, primTbId );
974 createTool( GEOMOp::OpCone, primTbId );
975 createTool( GEOMOp::OpRectangle, primTbId );
976 createTool( GEOMOp::OpDisk, primTbId );
978 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
979 createTool( GEOMOp::OpFuse, boolTbId );
980 createTool( GEOMOp::OpCommon, boolTbId );
981 createTool( GEOMOp::OpCut, boolTbId );
982 createTool( GEOMOp::OpSection, boolTbId );
984 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
985 createTool( GEOMOp::OpPrism, genTbId );
986 createTool( GEOMOp::OpRevolution, genTbId );
987 createTool( GEOMOp::OpFilling, genTbId );
988 createTool( GEOMOp::OpPipe, genTbId );
990 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
991 createTool( GEOMOp::OpTranslate, transTbId );
992 createTool( GEOMOp::OpRotate, transTbId );
993 createTool( GEOMOp::OpChangeLoc, transTbId );
994 createTool( GEOMOp::OpMirror, transTbId );
995 createTool( GEOMOp::OpScale, transTbId );
996 createTool( GEOMOp::OpOffset, transTbId );
997 createTool( separator(), transTbId );
998 createTool( GEOMOp::OpMultiTranslate, transTbId );
999 createTool( GEOMOp::OpMultiRotate, transTbId );
1001 int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1002 createTool( GEOMOp::Op2dSketcher, operTbId );
1003 createTool( GEOMOp::Op3dSketcher, operTbId );
1004 createTool( separator(), operTbId );
1005 createTool( GEOMOp::OpExplode, operTbId );
1006 createTool( separator(), operTbId );
1007 createTool( GEOMOp::OpPartition, operTbId );
1008 createTool( GEOMOp::OpArchimede, operTbId );
1009 createTool( GEOMOp::OpShapesOnShape, operTbId );
1010 createTool( separator(), operTbId );
1011 createTool( GEOMOp::OpFillet1d, operTbId );
1012 createTool( GEOMOp::OpFillet2d, operTbId );
1013 createTool( GEOMOp::OpFillet3d, operTbId );
1014 createTool( GEOMOp::OpChamfer, operTbId );
1016 int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1017 createTool( GEOMOp::OpEdge, buildTbId );
1018 createTool( GEOMOp::OpWire, buildTbId );
1019 createTool( GEOMOp::OpFace, buildTbId );
1020 createTool( GEOMOp::OpShell, buildTbId );
1021 createTool( GEOMOp::OpSolid, buildTbId );
1022 createTool( GEOMOp::OpCompound, buildTbId );
1024 int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1025 createTool( GEOMOp::OpPointCoordinates, measureTbId );
1026 createTool( GEOMOp::OpProperties, measureTbId );
1027 createTool( GEOMOp::OpCenterMass, measureTbId );
1028 createTool( GEOMOp::OpInertia, measureTbId );
1029 createTool( GEOMOp::OpNormale, measureTbId );
1030 createTool( separator(), measureTbId );
1031 createTool( GEOMOp::OpBoundingBox, measureTbId );
1032 createTool( GEOMOp::OpMinDistance, measureTbId );
1033 createTool( GEOMOp::OpAngle, measureTbId );
1034 createTool( GEOMOp::OpTolerance , measureTbId );
1035 createTool( separator(), measureTbId );
1036 createTool( GEOMOp::OpFreeBoundaries, measureTbId );
1037 createTool( GEOMOp::OpFreeFaces, measureTbId );
1038 createTool( separator(), measureTbId );
1039 createTool( GEOMOp::OpWhatIs, measureTbId );
1040 createTool( GEOMOp::OpCheckShape, measureTbId );
1041 createTool( GEOMOp::OpCheckCompound, measureTbId );
1043 int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1044 createTool( GEOMOp::OpPipeTShape, advancedTbId );
1045 //@@ 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 @@//
1047 // ---- create popup menus --------------------------
1049 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1050 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1052 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1053 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1055 QString autoColorPrefix =
1056 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1058 QtxPopupMgr* mgr = popupMgr();
1059 mgr->insert( action( GEOMOp::OpRename ), -1, -1 ); // rename
1060 mgr->setRule( action( GEOMOp::OpRename ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
1061 mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
1062 mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1063 mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1064 mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1065 mgr->insert( action( GEOMOp::OpShowChildren ), -1, -1 ); // show children
1066 mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
1067 mgr->insert( action( GEOMOp::OpHideChildren ), -1, -1 ); // hide children
1068 mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
1069 mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
1070 mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1071 mgr->insert( separator(), -1, -1 ); // -----------
1072 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1073 mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1074 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1075 mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1076 mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1077 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1078 mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1079 mgr->insert( separator(), dispmodeId, -1 );
1080 mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1081 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1082 mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1083 mgr->insert( separator(), -1, -1 ); // -----------
1084 mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
1085 mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1086 mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
1087 mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1088 mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
1089 mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1090 mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
1091 mgr->setRule( action( GEOMOp::OpDeflection ), "selcount>0 and isVisible and client='OCCViewer'", QtxPopupMgr::VisibleRule );
1092 mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1093 //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1094 mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM::VERTEX), QtxPopupMgr::VisibleRule );
1095 mgr->insert( separator(), -1, -1 ); // -----------
1096 mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1097 mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1098 mgr->insert( action( GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1099 mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1100 mgr->insert( separator(), -1, -1 ); // -----------
1102 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1103 onlyComponent = "((type='Component') and selcount=1)",
1104 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1105 types = "'Shape' 'Group'";
1107 mgr->insert( action( GEOMOp::OpShow ), -1, -1 ); // display
1108 mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1110 mgr->insert( action( GEOMOp::OpHide ), -1, -1 ); // erase
1111 mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1113 mgr->insert( action( GEOMOp::OpHideAll ), -1, -1 ); // erase All
1114 mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1116 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1118 int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1119 mgr->insert( action(GEOMOp::OpSelectVertex), selectonlyId, -1); //Vertex
1120 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly, QtxPopupMgr::VisibleRule);
1121 mgr->setRule(action(GEOMOp::OpSelectVertex), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1122 mgr->insert( action(GEOMOp::OpSelectEdge), selectonlyId, -1); //Edge
1123 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly, QtxPopupMgr::VisibleRule);
1124 mgr->setRule(action(GEOMOp::OpSelectEdge), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1125 mgr->insert( action(GEOMOp::OpSelectWire), selectonlyId, -1); //Wire
1126 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly, QtxPopupMgr::VisibleRule);
1127 mgr->setRule(action(GEOMOp::OpSelectWire), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1128 mgr->insert( action(GEOMOp::OpSelectFace), selectonlyId, -1); //Face
1129 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly, QtxPopupMgr::VisibleRule);
1130 mgr->setRule(action(GEOMOp::OpSelectFace), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1131 mgr->insert( action(GEOMOp::OpSelectShell), selectonlyId, -1); //Shell
1132 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly, QtxPopupMgr::VisibleRule);
1133 mgr->setRule(action(GEOMOp::OpSelectShell), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1134 mgr->insert( action(GEOMOp::OpSelectSolid), selectonlyId, -1); //Solid
1135 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly, QtxPopupMgr::VisibleRule);
1136 mgr->setRule(action(GEOMOp::OpSelectSolid), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1137 mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1); //Compound
1138 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1139 mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1140 mgr->insert( separator(), selectonlyId, -1);
1141 mgr->insert( action(GEOMOp::OpSelectAll), selectonlyId, -1); //Clear selection filter
1142 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly, QtxPopupMgr::VisibleRule);
1143 mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1144 mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1145 mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1146 mgr->insert( separator(), -1, -1 );
1148 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1151 //=======================================================================
1152 // function : GeometryGUI::activateModule()
1153 // purpose : Called when GEOM module is activated
1154 //=======================================================================
1155 bool GeometryGUI::activateModule( SUIT_Study* study )
1157 if ( CORBA::is_nil( myComponentGeom ) )
1160 bool res = SalomeApp_Module::activateModule( study );
1165 setMenuShown( true );
1166 setToolShown( true );
1168 // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1169 PyGILState_STATE gstate = PyGILState_Ensure();
1170 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
1171 if(pluginsmanager==NULL)
1175 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"geom","New Entity","Other");
1180 PyGILState_Release(gstate);
1181 // end of GEOM plugins loading
1183 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1184 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1186 // Reset actions accelerator keys
1187 action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1188 action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1189 action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1190 action(GEOMOp::OpRename)->setEnabled( true ); // Rename: Key_F2
1192 GUIMap::Iterator it;
1193 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1194 it.value()->activate( application()->desktop() );
1196 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1198 SUIT_ViewManager* vm;
1199 ViewManagerList OCCViewManagers, VTKViewManagers;
1201 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1202 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1203 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1204 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1206 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1207 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1208 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1209 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1212 SALOME_ListIO selected;
1213 sm->selectedObjects( selected );
1214 sm->clearSelected();
1216 // disable OCC selectors
1217 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1218 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1219 while ( itOCCSel.hasNext() )
1220 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1221 sr->setEnabled(true);
1223 // disable VTK selectors
1224 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1225 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1226 while ( itVTKSel.hasNext() )
1227 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1228 sr->setEnabled(true);
1230 sm->setSelectedObjects( selected, true ); //NPAL 19674
1232 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1234 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1236 // 0020836 (Basic vectors and origin)
1237 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1238 if( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1239 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1241 _PTR(Study) studyDS = appStudy->studyDS();
1243 _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1244 if( !aSComponent ) // create objects automatically only if there is no GEOM component
1245 createOriginAndBaseVectors();
1254 //=======================================================================
1255 // function : GeometryGUI::deactivateModule()
1256 // purpose : Called when GEOM module is deactivated
1257 //=======================================================================
1258 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1260 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1262 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1264 setMenuShown( false );
1265 setToolShown( false );
1267 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1268 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1270 EmitSignalCloseAllDialogs();
1272 GUIMap::Iterator it;
1273 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1274 it.value()->deactivate();
1276 // Unset actions accelerator keys
1277 action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1278 action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1279 action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1280 action(GEOMOp::OpRename)->setEnabled( false ); // Rename: Key_F2
1282 qDeleteAll(myOCCSelectors);
1283 myOCCSelectors.clear();
1284 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1286 qDeleteAll(myVTKSelectors);
1287 myVTKSelectors.clear();
1288 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1290 return SalomeApp_Module::deactivateModule( study );
1293 //=======================================================================
1294 // function : onWindowActivated()
1295 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1296 //=======================================================================
1297 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1302 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1303 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1305 // disable non-OCC viewframe menu commands
1306 // action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1307 action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1308 action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1309 action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1310 action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1311 action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1312 // action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1314 action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1315 action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1317 action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1320 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1322 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1323 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1326 void GeometryGUI::viewManagers( QStringList& lst ) const
1328 lst.append( OCCViewer_Viewer::Type() );
1331 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1333 if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1335 qDebug( "connect" );
1336 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1337 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1338 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1339 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1340 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1341 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1343 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1344 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1346 // disable OCC selectors
1347 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1348 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1349 while ( itOCCSel.hasNext() )
1350 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1351 sr->setEnabled(true);
1353 else if ( vm->getType() == SVTK_Viewer::Type() )
1355 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1356 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1358 // disable VTK selectors
1359 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1360 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1361 while ( itVTKSel.hasNext() )
1362 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1363 sr->setEnabled(true);
1367 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1369 SUIT_ViewModel* viewer = vm->getViewModel();
1370 if ( vm->getType() == OCCViewer_Viewer::Type() )
1372 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1373 while ( itOCCSel.hasNext() )
1374 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1375 if ( sr->viewer() == viewer )
1377 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1381 if ( vm->getType() == SVTK_Viewer::Type() )
1383 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1384 while ( itVTKSel.hasNext() )
1385 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1386 if ( sr->viewer() == viewer )
1388 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1394 QString GeometryGUI::engineIOR() const
1396 if ( !CORBA::is_nil( GetGeomGen() ) )
1397 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1401 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture( SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight )
1403 theWidth = theHeight = 0;
1404 Handle(Graphic3d_HArray1OfBytes) aTexture;
1406 TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1407 aTexture = aTextureMap[ theId ];
1408 if ( aTexture.IsNull() ) {
1409 GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1410 if ( !aInsOp->_is_nil() ) {
1411 CORBA::Long aWidth, aHeight;
1412 SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1413 if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1415 theHeight = aHeight;
1416 aTexture = new Graphic3d_HArray1OfBytes( 1, aStream->length() );
1417 for ( int i = 0; i < aStream->length(); i++ )
1418 aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1419 aTextureMap[ theId ] = aTexture;
1427 LightApp_Selection* GeometryGUI::createSelection() const
1429 return new GEOMGUI_Selection();
1432 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1434 SalomeApp_Module::contextMenuPopup(client, menu, title);
1437 getApp()->selectionMgr()->selectedObjects(lst);
1438 if (lst.Extent() < 1)
1441 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1442 _PTR(Study) study = appStudy->studyDS();
1444 bool isImported = true;
1445 SALOME_ListIteratorOfListIO anIt (lst);
1446 for (; anIt.More() && isImported; anIt.Next()) {
1447 Handle(SALOME_InteractiveObject) io = anIt.Value();
1448 _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1450 if (lst.Extent() == 1) {
1451 // Set context menu title
1452 if (client == "OCCViewer" || client == "VTKViewer")
1453 title = QString(aSObj->GetName().c_str());
1456 CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1457 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1458 if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1466 menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
1470 void GeometryGUI::createPreferences()
1472 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1474 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1475 setPreferenceProperty( genGroup, "columns", 2 );
1477 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1478 LightApp_Preferences::Selector,
1479 "Geometry", "display_mode" );
1481 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1482 LightApp_Preferences::Color, "Geometry", "shading_color" );
1484 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1485 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1487 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1488 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1490 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1491 LightApp_Preferences::Color, "Geometry", "line_color" );
1493 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1494 LightApp_Preferences::Color, "Geometry", "point_color" );
1496 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1497 LightApp_Preferences::Color, "Geometry", "isos_color" );
1499 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1500 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1502 int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1503 LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1505 // Quantities with individual precision settings
1506 int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1507 setPreferenceProperty( precGroup, "columns", 2 );
1509 const int nbQuantities = 8;
1510 int prec[nbQuantities], ii = 0;
1511 prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1512 LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1513 prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1514 LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1515 prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1516 LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1517 prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1518 LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1519 prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1520 LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1521 prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1522 LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1523 prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1524 LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1525 prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1526 LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1528 // Set property for precision value for spinboxes
1529 for ( ii = 0; ii < nbQuantities; ii++ ){
1530 setPreferenceProperty( prec[ii], "min", -14 );
1531 setPreferenceProperty( prec[ii], "max", 14 );
1532 setPreferenceProperty( prec[ii], "precision", 2 );
1535 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1536 setPreferenceProperty( VertexGroup, "columns", 2 );
1538 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1539 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1541 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1542 LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1544 // Set property for default display mode
1545 QStringList aModesList;
1546 aModesList.append( tr("MEN_WIREFRAME") );
1547 aModesList.append( tr("MEN_SHADING") );
1549 QList<QVariant> anIndexesList;
1550 anIndexesList.append(0);
1551 anIndexesList.append(1);
1553 setPreferenceProperty( dispmode, "strings", aModesList );
1554 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1556 // Set property for step value for spinboxes
1557 setPreferenceProperty( step, "min", 1 );
1558 setPreferenceProperty( step, "max", 10000 );
1559 setPreferenceProperty( step, "precision", 3 );
1561 // Set property for deflection value for spinboxes
1562 setPreferenceProperty( defl, "min", DEFLECTION_MIN );
1563 setPreferenceProperty( defl, "max", 1.0 );
1564 setPreferenceProperty( defl, "step", 1.0e-04 );
1565 setPreferenceProperty( defl, "precision", 6 );
1567 // Set property vertex marker type
1568 QList<QVariant> aMarkerTypeIndicesList;
1569 QList<QVariant> aMarkerTypeIconsList;
1571 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1572 for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1573 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1574 QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1575 aMarkerTypeIndicesList << (i-1);
1576 aMarkerTypeIconsList << pixmap;
1579 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1580 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
1582 // Set property for vertex marker scale
1583 QList<QVariant> aMarkerScaleIndicesList;
1584 QStringList aMarkerScaleValuesList;
1586 for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
1587 aMarkerScaleIndicesList << iii;
1588 aMarkerScaleValuesList << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
1591 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1592 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1594 int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
1595 setPreferenceProperty( originGroup, "columns", 2 );
1597 int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
1598 LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
1599 setPreferenceProperty( baseVectorsLength, "min", 0.01 );
1600 setPreferenceProperty( baseVectorsLength, "max", 1000 );
1602 addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
1603 LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
1607 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1609 if (section == "Geometry") {
1610 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1611 if (param == QString("SettingsGeomStep")) {
1612 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1613 EmitSignalDefaultStepValueChanged(spin_step);
1618 LightApp_Displayer* GeometryGUI::displayer()
1621 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1625 void GeometryGUI::setLocalSelectionMode(const int mode)
1627 myLocalSelectionMode = mode;
1629 int GeometryGUI::getLocalSelectionMode() const
1631 return myLocalSelectionMode;
1634 const char gSeparator = '_'; // character used to separate parameter names
1635 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1638 * \brief Store visual parameters
1640 * This method is called just before the study document is saved.
1641 * Store visual parameters in AttributeParameter attribue(s)
1643 void GeometryGUI::storeVisualParameters (int savePoint)
1645 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1646 if (!appStudy || !appStudy->studyDS())
1648 _PTR(Study) studyDS = appStudy->studyDS();
1650 // componentName is used for encoding of entries when storing them in IParameters
1651 std::string componentName = myComponentGeom->ComponentDataType();
1652 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1653 //if (!aSComponent) return;
1656 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1657 componentName.c_str(),
1659 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1661 // viewers counters are used for storing view_numbers in IParameters
1662 int vtkViewers(0), occViewers(0);
1664 QList<SUIT_ViewManager*> lst;
1665 QList<SUIT_ViewManager*>::Iterator it;
1667 // main cycle to store parameters of displayed objects
1669 vtkViewers = occViewers = 0;
1670 getApp()->viewManagers(lst);
1671 for (it = lst.begin(); it != lst.end(); it++)
1673 SUIT_ViewManager* vman = *it;
1674 QString vType = vman->getType();
1676 // saving VTK actors properties
1677 if (vType == SVTK_Viewer::Type())
1679 QVector<SUIT_ViewWindow*> views = vman->getViews();
1680 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
1682 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
1684 vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
1685 allActors->InitTraversal();
1686 while (vtkActor* actor = allActors->GetNextActor())
1688 if (actor->GetVisibility()) // store only visible actors
1690 GEOM_Actor* aGeomActor = 0;
1691 if (actor->IsA("GEOM_Actor"))
1692 aGeomActor = GEOM_Actor::SafeDownCast(actor);
1693 if (aGeomActor && aGeomActor->hasIO())
1695 Handle(SALOME_InteractiveObject) io = aGeomActor->getIO();
1698 // entry is "encoded" = it does NOT contain component adress, since it is a
1699 // subject to change on next component loading
1700 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
1702 std::string param, occParam = vType.toLatin1().data();
1703 occParam += gSeparator;
1704 occParam += QString::number(vtkViewers).toLatin1().data();
1705 occParam += gSeparator;
1707 param = occParam + "Visibility";
1708 ip->setParameter(entry, param, "On");
1710 param = occParam + "DisplayMode";
1711 ip->setParameter(entry, param, QString::number
1712 (aGeomActor->getDisplayMode()).toLatin1().data());
1714 vtkFloatingPointType r, g, b;
1715 aGeomActor->GetColor(r, g, b);
1716 QString colorStr = QString::number(r);
1717 colorStr += gDigitsSep; colorStr += QString::number(g);
1718 colorStr += gDigitsSep; colorStr += QString::number(b);
1719 param = occParam + "Color";
1720 ip->setParameter(entry, param, colorStr.toLatin1().data());
1722 param = occParam + "Opacity";
1723 ip->setParameter(entry, param, QString::number(aGeomActor->GetOpacity()).toLatin1().data());
1725 int nbUIso(0), nbVIso(0);
1726 aGeomActor->GetNbIsos(nbUIso,nbVIso);
1727 QString isosStr = QString::number(nbUIso);
1728 isosStr += gDigitsSep;
1729 isosStr += QString::number(nbVIso);
1730 param = occParam + "Isos";
1731 ip->setParameter(entry, param, isosStr.toLatin1().data());
1732 } // if (io->hasEntry())
1733 } // GEOM_Actor && hasIO
1735 } // while.. actors traversal
1739 } // if (SVTK view model)
1740 else if (vType == SOCC_Viewer::Type()) // processing OCC viewers
1742 QVector<SUIT_ViewWindow*> views = vman->getViews();
1743 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
1745 SOCC_ViewWindow* occView = dynamic_cast<SOCC_ViewWindow*>(views[i]);
1748 //Handle(AIS_InteractiveContext) ic =
1749 // ((OCCViewer_Viewer*)(occView->getViewManager()->getViewModel()))->getAISContext();
1750 OCCViewer_Viewer* viewModel = (OCCViewer_Viewer*)(vman->getViewModel());
1751 //OCCViewer_Viewer* viewModel = ((OCCViewer_ViewManager*)vman)->getOCCViewer();
1752 Handle(AIS_InteractiveContext) ic = viewModel->getAISContext();
1754 AIS_ListOfInteractive aList;
1755 ic->DisplayedObjects(aList);
1757 AIS_ListIteratorOfListOfInteractive ite (aList);
1758 for (; ite.More(); ite.Next())
1760 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
1762 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
1765 Handle(SALOME_InteractiveObject) io =
1766 Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
1769 // entry is "encoded": it does NOT contain component adress,
1770 // since it is a subject to change on next component loading
1771 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
1773 std::string param, occParam = vType.toLatin1().data();
1774 occParam += gSeparator;
1775 occParam += QString::number(occViewers).toLatin1().data();
1776 occParam += gSeparator;
1779 param = occParam + "Visibility";
1780 ip->setParameter(entry, param, "On");
1783 param = occParam + "DisplayMode";
1784 int dm = aSh->DisplayMode();
1785 ip->setParameter(entry, param, QString::number(dm).toLatin1().data());
1788 // is a property of GEOM_Object, it is stored by GEOM engine
1791 param = occParam + "Transparency";
1792 ip->setParameter(entry, param, QString::number(aSh->Transparency()).toLatin1().data());
1795 Handle(AIS_Drawer) aDrawer = aSh->Attributes();
1796 int nbUIso = aDrawer->UIsoAspect()->Number();
1797 int nbVIso = aDrawer->VIsoAspect()->Number();
1798 QString isosStr = QString::number(nbUIso);
1799 isosStr += gDigitsSep;
1800 isosStr += QString::number(nbVIso);
1801 param = occParam + "Isos";
1802 ip->setParameter(entry, param, isosStr.toLatin1().data());
1803 } // if (io->hasEntry())
1805 } // if (GEOM_AISShape)
1806 } // for (AIS_ListOfInteractive)
1810 } // if (SOCC view model)
1813 // unknown viewer type
1815 } // for (viewManagers)
1819 * \brief Restore visual parameters
1821 * This method is called after the study document is opened.
1822 * Restore visual parameters from AttributeParameter attribue(s)
1824 void GeometryGUI::restoreVisualParameters (int savePoint)
1826 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1827 if (!appStudy || !appStudy->studyDS())
1829 _PTR(Study) studyDS = appStudy->studyDS();
1831 // componentName is used for encoding of entries when storing them in IParameters
1832 std::string componentName = myComponentGeom->ComponentDataType();
1833 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1834 //if (!aSComponent) return;
1837 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1838 componentName.c_str(),
1840 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1842 std::vector<std::string> entries = ip->getEntries();
1844 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
1846 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1847 QString entry (ip->decodeEntry(*entIt).c_str());
1849 // Check that the entry corresponds to a real object in the Study
1850 // as the object may be deleted or modified after the visual state is saved.
1851 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1852 if (!so) continue; //Skip the not existent entry
1854 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1855 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1857 std::vector<std::string>::iterator namesIt = paramNames.begin();
1858 std::vector<std::string>::iterator valuesIt = paramValues.begin();
1860 // actors are stored in a map after displaying of them for
1861 // quicker access in the future: map < viewID to actor >
1862 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
1863 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
1865 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
1867 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
1868 // '_' is used as separator and should not be used in viewer type or parameter names.
1869 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
1870 if (lst.size() != 3)
1873 QString viewerTypStr = lst[0];
1874 QString viewIndexStr = lst[1];
1875 QString paramNameStr = lst[2];
1878 int viewIndex = viewIndexStr.toUInt(&ok);
1879 if (!ok) // bad conversion of view index to integer
1883 if (viewerTypStr == SVTK_Viewer::Type())
1885 GEOM_Actor* vActor = 0;
1886 if (vtkActors.IsBound(viewIndex))
1887 vActor = vtkActors.Find(viewIndex);
1889 if (paramNameStr == "Visibility")
1891 if (!vActor && displayer())
1893 QList<SUIT_ViewManager*> lst;
1894 getApp()->viewManagers(viewerTypStr, lst);
1896 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
1897 if (viewIndex >= 0 && viewIndex < lst.count()) {
1898 SUIT_ViewManager* vman = lst.at(viewIndex);
1899 SUIT_ViewModel* vmodel = vman->getViewModel();
1900 // SVTK view model can be casted to SALOME_View
1901 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
1903 // store displayed actor in a temporary map for quicker
1904 // access later when restoring other parameters
1905 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
1906 vtkRenderer* Renderer = vtkView->getRenderer();
1907 vtkActorCollection* theActors = Renderer->GetActors();
1908 theActors->InitTraversal();
1909 bool isFound = false;
1910 vtkActor *ac = theActors->GetNextActor();
1911 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
1912 if (ac->IsA("GEOM_Actor")) {
1913 GEOM_Actor* aGeomAc = GEOM_Actor::SafeDownCast(ac);
1914 if (aGeomAc->hasIO()) {
1915 Handle(SALOME_InteractiveObject) io =
1916 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
1917 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
1919 vtkActors.Bind(viewIndex, aGeomAc);
1926 } // if (paramNameStr == "Visibility")
1929 // the rest properties "work" with GEOM_Actor
1932 QString val ((*valuesIt).c_str());
1934 if (paramNameStr == "DisplayMode") {
1935 vActor->setDisplayMode(val.toInt());
1937 else if (paramNameStr == "Color") {
1938 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
1939 if (colors.count() == 3)
1940 vActor->SetColor(colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat());
1942 else if (paramNameStr == "Opacity") {
1943 vActor->SetOpacity(val.toFloat());
1945 else if (paramNameStr == "Isos") {
1946 QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
1947 if (isos.count() == 2) {
1948 int aIsos[2] = {isos[0].toInt(), isos[1].toInt()};
1949 vActor->SetNbIsos(aIsos);
1953 } // other parameters than Visibility
1955 else if (viewerTypStr == SOCC_Viewer::Type())
1957 //Handle(AIS_InteractiveObject) occActor;
1958 Handle(GEOM_AISShape) occActor;
1959 if (occActors.IsBound(viewIndex))
1960 occActor = occActors.Find(viewIndex);
1962 // ViewModel and InteractiveContext
1963 SOCC_Viewer* occVModel = 0;
1964 Handle(AIS_InteractiveContext) ic;
1966 QList<SUIT_ViewManager*> lst;
1967 getApp()->viewManagers(viewerTypStr, lst);
1969 // SOCC ViewManager always has 1 ViewWindow, so view index is index of view manager
1970 if (viewIndex >= 0 && viewIndex < lst.count()) {
1971 SUIT_ViewManager* vman = lst.at(viewIndex);
1972 SUIT_ViewModel* vmodel = vman->getViewModel();
1973 occVModel = dynamic_cast<SOCC_Viewer*>(vmodel);
1975 ic = occVModel->getAISContext();
1981 if (paramNameStr == "Visibility")
1983 if (occActor.IsNull() && displayer())
1985 displayer()->Display(entry, true, occVModel);
1987 // store displayed actor in a temporary map for quicker
1988 // access later when restoring other parameters
1989 AIS_ListOfInteractive aList;
1990 ic->DisplayedObjects(aList);
1991 bool isFound = false;
1992 AIS_ListIteratorOfListOfInteractive ite (aList);
1993 for (; ite.More() && !isFound; ite.Next()) {
1994 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
1995 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
1997 Handle(SALOME_InteractiveObject) io =
1998 Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
1999 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
2001 occActors.Bind(viewIndex, aSh);
2007 } // if (paramNameStr == "Visibility")
2010 // the rest properties "work" with GEOM_AISShape
2011 if (!occActor.IsNull())
2013 QString val ((*valuesIt).c_str());
2015 if (paramNameStr == "DisplayMode") {
2016 ic->SetDisplayMode(occActor, AIS_DisplayMode(val.toInt()), false);
2017 //ic->Redisplay(occActor, Standard_False, Standard_True);
2019 // Color is restored by the GEOM engine
2020 else if (paramNameStr == "Transparency") {
2021 ic->SetTransparency(occActor, val.toFloat(), false);
2022 ic->Redisplay(occActor, Standard_False, Standard_True);
2024 else if (paramNameStr == "Isos") {
2025 QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
2026 if (isos.count() == 2) {
2027 Handle(AIS_Drawer) aDrawer = occActor->Attributes();
2028 int nbUIso = isos[0].toInt();
2029 int nbVIso = isos[1].toInt();
2030 Handle(Prs3d_IsoAspect) uIsoAspect = aDrawer->UIsoAspect();
2031 Handle(Prs3d_IsoAspect) vIsoAspect = aDrawer->VIsoAspect();
2032 uIsoAspect->SetNumber(nbUIso);
2033 vIsoAspect->SetNumber(nbVIso);
2034 aDrawer->SetUIsoAspect(uIsoAspect);
2035 aDrawer->SetVIsoAspect(vIsoAspect);
2036 ic->SetLocalAttributes(occActor, aDrawer);
2037 ic->Redisplay(occActor);
2041 } // other parameters than Visibility
2045 // unknown viewer type
2047 } // for names/parameters iterator
2048 } // for entries iterator
2050 // update all VTK and OCC views
2051 QList<SUIT_ViewManager*> lst;
2052 getApp()->viewManagers(lst);
2053 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
2054 SUIT_ViewModel* vmodel = (*it)->getViewModel();
2057 if (vmodel->getType() == SVTK_Viewer::Type()) {
2058 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
2059 vtkView->getRenderer()->ResetCameraClippingRange();
2062 else if (vmodel->getType() == SOCC_Viewer::Type()) {
2063 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
2064 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
2071 void GeometryGUI::onViewAboutToShow()
2073 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
2074 QAction* a = action( GEOMOp::OpSwitchVectors );
2076 a->setEnabled(true);
2077 bool vmode = window->getCustomData("VectorsMode").toBool();
2078 a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
2080 a->setText ( tr("MEN_VECTOR_MODE_ON") );
2081 a->setEnabled(false);