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 "GEOMGUI_OCCSelector.h"
28 #include "GEOMGUI_Selection.h"
29 #include "GEOM_Displayer.h"
30 #include "GEOM_AISShape.hxx"
32 #include "GEOM_Actor.h"
34 #include <SUIT_Desktop.h>
35 #include <SUIT_MessageBox.h>
36 #include <SUIT_ResourceMgr.h>
37 #include <SUIT_Session.h>
38 #include <SUIT_ViewManager.h>
40 #include <OCCViewer_ViewWindow.h>
41 #include <OCCViewer_ViewPort3d.h>
42 #include <OCCViewer_ViewModel.h>
43 #include <OCCViewer_ViewManager.h>
45 #include <SOCC_ViewModel.h>
46 #include <SOCC_ViewWindow.h>
48 #include <SVTK_ViewWindow.h>
49 #include <SVTK_RenderWindowInteractor.h>
50 #include <SVTK_InteractorStyle.h>
51 #include <SVTK_ViewModel.h>
53 #include <SalomeApp_Application.h>
54 #include <SalomeApp_Study.h>
56 #include <LightApp_SelectionMgr.h>
57 #include <LightApp_VTKSelector.h>
58 #include <LightApp_DataObject.h>
59 #include <LightApp_Preferences.h>
61 #include <SALOME_LifeCycleCORBA.hxx>
62 #include <SALOME_ListIO.hxx>
63 #include <SALOME_ListIteratorOfListIO.hxx>
65 #include <SALOMEDSClient_ClientFactory.hxx>
66 #include <SALOMEDSClient_IParameters.hxx>
75 #include <AIS_Drawer.hxx>
76 #include <AIS_ListOfInteractive.hxx>
77 #include <AIS_ListIteratorOfListOfInteractive.hxx>
78 #include <Prs3d_Drawer.hxx>
79 #include <Prs3d_IsoAspect.hxx>
80 #include <Aspect_TypeOfMarker.hxx>
81 #include <OSD_SharedLibrary.hxx>
82 #include <NCollection_DataMap.hxx>
84 #include <utilities.h>
86 #include <vtkCamera.h>
87 #include <vtkRenderer.h>
89 #include "GEOMImpl_Types.hxx"
94 Standard_EXPORT CAM_Module* createModule() {
95 return new GeometryGUI();
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 );
167 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
204 libs = getenv( "LD_LIBRARY_PATH" );
205 if( !libs.isEmpty() ) {
206 QStringList dirList = libs.split( ":", QString::SkipEmptyParts ); // skip empty entries
208 libs = getenv( "PATH" );
209 if( !libs.isEmpty() ) {
210 QStringList dirList = libs.split( ";", QString::SkipEmptyParts ); // skip empty entries
212 for( int i = dirList.count()-1; i >= 0; i-- ) {
213 QString dir = dirList[ i ];
214 QFileInfo fi( Qtx::addSlash( dirList[ i ] ) + libraryName );
216 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().data() );
217 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
219 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
220 continue; // continue search further
222 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
223 if ( osdF != NULL ) {
224 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
225 GEOMGUI* libGUI = (*func)(this);
227 myGUIMap[ libraryName ] = libGUI;
228 break; // found and loaded!
235 if ( myGUIMap.contains( libraryName ) )
236 // library is successfully loaded
237 return myGUIMap[ libraryName ];
241 //=======================================================================
242 // function : GeometryGUI::ActiveWorkingPlane()
243 // purpose : Activate Working Plane View
244 //=======================================================================
245 void GeometryGUI::ActiveWorkingPlane()
247 gp_Dir DZ = myWorkingPlane.Direction();
248 gp_Dir DY = myWorkingPlane.YDirection();
250 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
251 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
252 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
255 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
257 Handle(V3d_View) view3d = vw->getViewPort()->getView();
259 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
260 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
266 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
268 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
270 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
271 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
272 camera->SetFocalPoint(0,0,0);
279 //=======================================================================
280 // function : GeometryGUI::SetActiveDialogBox()
281 // purpose : Set active dialog box
282 //=======================================================================
283 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
285 myActiveDialogBox = (QDialog*)aDlg;
288 //=======================================================================
289 // function : GeometryGUI::EmitSignalDeactivateDialog()
290 // purpose : Emit a signal to deactivate the active dialog Box
291 //=======================================================================
292 void GeometryGUI::EmitSignalDeactivateDialog()
294 emit SignalDeactivateActiveDialog();
297 //=======================================================================
298 // function : GeometryGUI::EmitSignalCloseAllDialogs()
299 // purpose : Emit a signal to close all non modal dialogs box
300 //=======================================================================
301 void GeometryGUI::EmitSignalCloseAllDialogs()
303 emit SignalCloseAllDialogs();
306 //=======================================================================
307 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
308 // purpose : Emit a signal to inform that default real spin box step has
310 //=======================================================================
311 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
313 emit SignalDefaultStepValueChanged(newVal);
316 //=======================================================================
317 // function : GeometryGUI::OnGUIEvent()
318 // purpose : common slot for all menu/toolbar actions
319 //=======================================================================
320 void GeometryGUI::OnGUIEvent()
322 const QObject* obj = sender();
323 if ( !obj || !obj->inherits( "QAction" ) )
325 int id = actionId((QAction*)obj);
330 //=======================================================================
331 // function : GeometryGUI::OnGUIEvent()
332 // purpose : manage all events on GUI [static]
333 //=======================================================================
334 void GeometryGUI::OnGUIEvent( int id )
336 SUIT_Application* anApp = application();
338 SUIT_Desktop* desk = anApp->desktop();
340 // check type of the active viewframe
341 SUIT_ViewWindow* window = desk->activeWindow();
342 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
343 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
344 // if current viewframe is not of OCC and not of VTK type - return immediately
345 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
346 bool NotViewerDependentCommand = ( id == 901 || id == 216 || id == 213 );
347 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommand )
350 // fix for IPAL9103, point 2
351 if ( CORBA::is_nil( GetGeomGen() ) ) {
352 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
356 GEOMGUI* library = 0;
357 // try to get-or-load corresponding GUI library
358 if( id == 111 || // MENU FILE - IMPORT BREP
359 id == 112 || // MENU FILE - IMPORT IGES
360 id == 113 || // MENU FILE - IMPORT STEP
361 id == 121 || // MENU FILE - EXPORT BREP
362 id == 122 || // MENU FILE - EXPORT IGES
363 id == 123 || // MENU FILE - EXPORT STEP
364 id == 2171 || // POPUP VIEWER - SELECT ONLY - VERTEX
365 id == 2172 || // POPUP VIEWER - SELECT ONLY - EDGE
366 id == 2173 || // POPUP VIEWER - SELECT ONLY - WIRE
367 id == 2174 || // POPUP VIEWER - SELECT ONLY - FACE
368 id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL
369 id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID
370 id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND
371 id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL
372 id == 31 || // MENU EDIT - COPY
373 id == 33 || // MENU EDIT - DELETE
374 id == 411 || // MENU SETTINGS - ADD IN STUDY
375 id == 412 || // MENU SETTINGS - SHADING COLOR
376 id == 5103 || // MENU TOOLS - CHECK GEOMETRY
377 id == 8032 || // POPUP VIEWER - COLOR
378 id == 8033 || // POPUP VIEWER - TRANSPARENCY
379 id == 8034 || // POPUP VIEWER - ISOS
380 id == 8035 || // POPUP VIEWER - AUTO COLOR
381 id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR
382 id == 8037 || // POPUP VIEWER - SHOW CHILDREN
383 id == 8038 || // POPUP VIEWER - HIDE CHILDREN
384 id == 804 || // POPUP VIEWER - ADD IN STUDY
385 id == 901 || // OBJECT BROWSER - RENAME
386 id == 9024 ) { // OBJECT BROWSER - OPEN
387 //cout << "id " << id << " received" << endl;
389 library = getLibrary( "libGEOMToolsGUI.so" );
391 library = getLibrary( "GEOMToolsGUI.dll" );
394 else if( id == 211 || // MENU VIEW - WIREFRAME/SHADING
395 id == 212 || // MENU VIEW - DISPLAY ALL
396 id == 213 || // MENU VIEW - DISPLAY ONLY
397 id == 214 || // MENU VIEW - ERASE ALL
398 id == 215 || // MENU VIEW - ERASE
399 id == 216 || // MENU VIEW - DISPLAY
400 id == 218 || // MENU VIEW - VECTOR MODE
401 id == 80311 || // POPUP VIEWER - WIREFRAME
402 id == 80312 || // POPUP VIEWER - SHADING
403 id == 80313 ) { // POPUP VIEWER - VECTORS
405 library = getLibrary( "libDisplayGUI.so" );
407 library = getLibrary( "DisplayGUI.dll" );
410 else if( id == 4011 || // MENU BASIC - POINT
411 id == 4012 || // MENU BASIC - LINE
412 id == 4013 || // MENU BASIC - CIRCLE
413 id == 4014 || // MENU BASIC - ELLIPSE
414 id == 4015 || // MENU BASIC - ARC
415 id == 4016 || // MENU BASIC - VECTOR
416 id == 4017 || // MENU BASIC - PLANE
417 // id == 4018 || // MENU BASIC - WPLANE // DEPRECATED
418 id == 4019 || // MENU BASIC - CURVE
419 id == 4020 ) { // MENU BASIC - REPAIR
421 library = getLibrary( "libBasicGUI.so" );
423 library = getLibrary( "BasicGUI.dll" );
426 else if( id == 4021 || // MENU PRIMITIVE - BOX
427 id == 4022 || // MENU PRIMITIVE - CYLINDER
428 id == 4023 || // MENU PRIMITIVE - SPHERE
429 id == 4024 || // MENU PRIMITIVE - TORUS
430 id == 4025 || // MENU PRIMITIVE - CONE
431 id == 4026 || // MENU PRIMITIVE - FACE
432 id == 4027 ) { // MENU PRIMITIVE - DISK
434 library = getLibrary( "libPrimitiveGUI.so" );
436 library = getLibrary( "PrimitiveGUI.dll" );
439 else if( id == 4031 || // MENU GENERATION - PRISM
440 id == 4032 || // MENU GENERATION - REVOLUTION
441 id == 4033 || // MENU GENERATION - FILLING
442 id == 4034 ) { // MENU GENERATION - PIPE
444 library = getLibrary( "libGenerationGUI.so" );
446 library = getLibrary( "GenerationGUI.dll" );
449 else if( id == 404 || // MENU ENTITY - SKETCHER
450 id == 405 || // MENU ENTITY - 3D SKETCHER
451 id == 407 ) { // MENU ENTITY - EXPLODE
453 library = getLibrary( "libEntityGUI.so" );
455 library = getLibrary( "EntityGUI.dll" );
458 else if( id == 4081 || // MENU BUILD - EDGE
459 id == 4082 || // MENU BUILD - WIRE
460 id == 4083 || // MENU BUILD - FACE
461 id == 4084 || // MENU BUILD - SHELL
462 id == 4085 || // MENU BUILD - SOLID
463 id == 4086 ) { // MENU BUILD - COMPUND
465 library = getLibrary( "libBuildGUI.so" );
467 library = getLibrary( "BuildGUI.dll" );
470 else if( id == 5011 || // MENU BOOLEAN - FUSE
471 id == 5012 || // MENU BOOLEAN - COMMON
472 id == 5013 || // MENU BOOLEAN - CUT
473 id == 5014 ) { // MENU BOOLEAN - SECTION
475 library = getLibrary( "libBooleanGUI.so" );
477 library = getLibrary( "BooleanGUI.dll" );
480 else if( id == 5021 || // MENU TRANSFORMATION - TRANSLATION
481 id == 5022 || // MENU TRANSFORMATION - ROTATION
482 id == 5023 || // MENU TRANSFORMATION - LOCATION
483 id == 5024 || // MENU TRANSFORMATION - MIRROR
484 id == 5025 || // MENU TRANSFORMATION - SCALE
485 id == 5026 || // MENU TRANSFORMATION - OFFSET
486 id == 5027 || // MENU TRANSFORMATION - MULTI-TRANSLATION
487 id == 5028 || // MENU TRANSFORMATION - MULTI-ROTATION
488 id == 5029 ) { // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
490 library = getLibrary( "libTransformationGUI.so" );
492 library = getLibrary( "TransformationGUI.dll" );
495 else if( id == 503 || // MENU OPERATION - PARTITION
496 id == 504 || // MENU OPERATION - ARCHIMEDE
497 id == 505 || // MENU OPERATION - FILLET
498 id == 506 || // MENU OPERATION - CHAMFER
499 id == 507 || // MENU OPERATION - CLIPPING RANGE
500 id == 508 || // MENU OPERATION - GET SHAPES ON SHAPE
501 id == 509 || // MENU OPERATION - FILLET 2D
502 id == 510 ) { // MENU OPERATION - FILLET 1D
504 library = getLibrary( "libOperationGUI.so" );
506 library = getLibrary( "OperationGUI.dll" );
509 else if( id == 601 || // MENU REPAIR - SEWING
510 id == 603 || // MENU REPAIR - SUPPRESS FACES
511 id == 604 || // MENU REPAIR - SUPPRESS HOLE
512 id == 605 || // MENU REPAIR - SHAPE PROCESSING
513 id == 606 || // MENU REPAIR - CLOSE CONTOUR
514 id == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES
515 id == 608 || // MENU REPAIR - ADD POINT ON EDGE
516 id == 609 || // MENU MEASURE - FREE BOUNDARIES
517 id == 610 || // MENU MEASURE - FREE FACES
518 id == 611 || // MENU REPAIR - CHANGE ORIENTATION
519 id == 602 || // MENU REPAIR - GLUE FACES
520 id == 612 ) { // MENU REPAIR - REMOVE EXTRA EDGES
522 library = getLibrary( "libRepairGUI.so" );
524 library = getLibrary( "RepairGUI.dll" );
527 else if( id == 701 || // MENU MEASURE - PROPERTIES
528 id == 702 || // MENU MEASURE - CDG
529 id == 703 || // MENU MEASURE - INERTIA
530 id == 704 || // MENU MEASURE - NORMALE
531 id == 7041 || // MENU MEASURE - BOUNDING BOX
532 id == 7042 || // MENU MEASURE - MIN DISTANCE
533 id == 7043 || // MENU MEASURE - ANGLE
534 id == 705 || // MENU MEASURE - TOLERANCE
535 id == 706 || // MENU MEASURE - WHATIS
536 id == 707 || // MENU MEASURE - CHECK
537 id == 7072 || // MENU MEASURE - CHECK COMPOUND OF BLOCKS
538 id == 708 ) { // MENU MEASURE - POINT COORDINATES
540 library = getLibrary( "libMeasureGUI.so" );
542 library = getLibrary( "MeasureGUI.dll" );
545 else if( id == 800 || // MENU GROUP - CREATE
546 id == 8001 || // POPUP MENU - CREATE GROUP
547 id == 801 ) { // MENU GROUP - EDIT
549 library = getLibrary( "libGroupGUI.so" );
551 library = getLibrary( "GroupGUI.dll" );
554 else if( id == 9999 || // MENU BLOCKS - HEXAHEDRAL SOLID
555 id == 9998 || // MENU BLOCKS - MULTI-TRANSFORMATION
556 id == 9997 || // MENU BLOCKS - QUADRANGLE FACE
557 id == 99991 || // MENU BLOCKS - PROPAGATE
558 id == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS
560 library = getLibrary( "libBlocksGUI.so" );
562 library = getLibrary( "BlocksGUI.dll" );
566 // call method of corresponding GUI library
568 library->OnGUIEvent( id, desk );
570 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
574 //=================================================================================
575 // function : GeometryGUI::OnKeyPress()
576 // purpose : Called when any key is pressed by user [static]
577 //=================================================================================
578 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* win, QKeyEvent* pe )
582 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
583 SUIT_Application* anApp = application();
585 bOk = bOk && it.value()->OnKeyPress( pe, anApp->desktop(), win );
591 //=================================================================================
592 // function : GeometryGUI::OnMouseMove()
593 // purpose : Manages mouse move events [static]
594 //=================================================================================
595 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* win, QMouseEvent* pe )
599 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
600 SUIT_Application* anApp = application();
602 bOk = bOk && it.value()->OnMouseMove( pe, anApp->desktop(), win );
608 //=================================================================================
609 // function : GeometryGUI::0nMousePress()
610 // purpose : Manage mouse press events [static]
611 //=================================================================================
612 void GeometryGUI::OnMousePress( SUIT_ViewWindow* win, QMouseEvent* pe )
615 // OnMousePress() should return false if this event should be processed further
616 // (see OCCViewer_Viewer3d::onMousePress() for explanation)
617 bool processed = false;
618 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
619 SUIT_Application* anApp = application();
621 processed = processed || it.value()->OnMousePress( pe, anApp->desktop(), win );
627 static void UpdateVtkSelection()
629 QPtrList<SUIT_ViewWindow> winList = application()->desktop()->windows();
630 SUIT_ViewWindow* win = 0;
631 for ( win = winList.first(); win; win = winList.next() ) {
632 if ( win->getViewManager()->getTypeView() == VIEW_VTK ) {
633 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
635 SVTK_RenderWindowInteractor* anInteractor = vw->getRWInteractor();
636 anInteractor->SetSelectionProp();
637 anInteractor->SetSelectionTolerance();
638 SVTK_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
640 aStyle->setPreselectionProp();
647 //=================================================================================
648 // function : GeometryGUI::SetSettings()
649 // purpose : Called when GEOM module is activated [static]
650 //=================================================================================
651 bool GeometryGUI::SetSettings()
653 QMenuBar* Mb = parent->getMainMenuBar();
654 SUIT_Study* ActiveStudy = application()->activeStudy();
656 // Wireframe or Shading
658 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
659 bool ViewOCC = ( window && window->getViewManager()->getType() == VIEW_OCC );
660 bool ViewVTK = ( window && window->getViewManager()->getType() == VIEW_VTK );
662 OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( window->getViewManager() );
664 Handle(AIS_InteractiveContext) ic = vm->getOCCViewer()->getAISContext();
665 DisplayMode = ic->DisplayMode();
668 else if ( ViewVTK ) {
669 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
671 SVTK_RenderWindowInteractor* myRenderInter = vw->getRWInteractor();
672 DisplayMode = myRenderInter->GetDisplayMode();
676 if( DisplayMode == 1 )
678 Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) );
680 Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) );
683 // Add in Study - !!!ALWAYS TRUE!!! /////// VSR : TO BE REMOVED
684 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
685 int Settings_AddInStudy;
686 // if(!AddInStudy.isEmpty())
687 // Settings_AddInStudy = AddInStudy.toInt();
690 Settings_AddInStudy = 1;
691 Mb->setItemChecked(411, Settings_AddInStudy);
694 QString S = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
696 QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", "100");
699 int count = ActiveStudy->getStudyFramesCount();
700 for(int i = 0; i < count; i++) {
701 if(ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC) {
702 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
703 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
705 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
706 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
708 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
710 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
716 // PAL5356: update VTK selection
717 ::UpdateVtkSelection();
720 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
721 bOk = bOk && it.data()->SetSettings( parent );
723 // MZN: Enable/disable "Clipping range" menu item(from GEOM_CLIPPING variable)
724 if (getenv( "GEOM_CLIPPING" ) == NULL)
726 QMenuItem* mi = Mb->findItem(50);
727 if (mi && mi->popup())
728 mi->popup()->removeItem(507);
735 //=======================================================================
736 // function : createGeomAction
738 //=======================================================================
739 void GeometryGUI::createGeomAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
742 QWidget* parent = application()->desktop();
743 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
745 if ( icon_id.length() )
746 pix = resMgr->loadPixmap( "GEOM", tr( icon_id.toLatin1().constData() ) );
748 pix = resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+po_id).toLatin1().constData() ), false );
752 QString tooltip = tr( (QString( "TOP_" )+po_id).toLatin1().constData() ),
753 menu = tr( (QString( "MEN_" )+po_id).toLatin1().constData() ),
754 status_bar = tr( (QString( "STB_" )+po_id).toLatin1().constData() );
756 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
761 //=======================================================================
762 // function : GeometryGUI::initialize()
763 // purpose : Called when GEOM module is created
764 //=======================================================================
765 void GeometryGUI::initialize( CAM_Application* app )
767 SalomeApp_Module::initialize( app );
769 // ----- create actions --------------
771 createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) );
772 createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) );
774 createGeomAction( 33, "DELETE", "", Qt::Key_Delete );
776 createGeomAction( 4011, "POINT" );
777 createGeomAction( 4012, "LINE" );
778 createGeomAction( 4013, "CIRCLE" );
779 createGeomAction( 4014, "ELLIPSE" );
780 createGeomAction( 4015, "ARC" );
781 createGeomAction( 4019, "CURVE" );
782 createGeomAction( 4016, "VECTOR" );
783 createGeomAction( 4017, "PLANE" );
784 // createGeomAction( 4018, "WORK_PLANE" ); DEPRECATED
785 createGeomAction( 4020, "LOCAL_CS" );
787 createGeomAction( 4021, "BOX" );
788 createGeomAction( 4022, "CYLINDER" );
789 createGeomAction( 4023, "SPHERE" );
790 createGeomAction( 4024, "TORUS" );
791 createGeomAction( 4025, "CONE" );
792 createGeomAction( 4026, "FACE" );
793 createGeomAction( 4027, "DISK" );
795 createGeomAction( 4031, "EXTRUSION" );
796 createGeomAction( 4032, "REVOLUTION" );
797 createGeomAction( 4033, "FILLING" );
798 createGeomAction( 4034, "PIPE" );
800 createGeomAction( 800, "GROUP_CREATE" );
801 createGeomAction( 801, "GROUP_EDIT" );
803 createGeomAction( 5029, "RELOAD_IMPORTED" );
805 createGeomAction( 9997, "Q_FACE" );
806 createGeomAction( 9999, "HEX_SOLID" );
808 createGeomAction( 404, "SKETCH" );
809 createGeomAction( 405, "3DSKETCH" );
810 createGeomAction( 407, "EXPLODE" );
812 createGeomAction( 4081, "EDGE" );
813 createGeomAction( 4082, "WIRE" );
814 createGeomAction( 4083, "FACE" );
815 createGeomAction( 4084, "SHELL" );
816 createGeomAction( 4085, "SOLID" );
817 createGeomAction( 4086, "COMPOUND" );
819 createGeomAction( 5011, "FUSE" );
820 createGeomAction( 5012, "COMMON" );
821 createGeomAction( 5013, "CUT" );
822 createGeomAction( 5014, "SECTION" );
824 createGeomAction( 5021, "TRANSLATION" );
825 createGeomAction( 5022, "ROTATION" );
826 createGeomAction( 5023, "MODIFY_LOCATION" );
827 createGeomAction( 5024, "MIRROR" );
828 createGeomAction( 5025, "SCALE" );
829 createGeomAction( 5026, "OFFSET" );
830 createGeomAction( 5027, "MUL_TRANSLATION" );
831 createGeomAction( 5028, "MUL_ROTATION" );
833 createGeomAction( 503, "PARTITION" );
834 createGeomAction( 504, "ARCHIMEDE" );
835 createGeomAction( 505, "FILLET" );
836 createGeomAction( 506, "CHAMFER" );
837 //createGeomAction( 507, "CLIPPING" );
838 createGeomAction( 508, "GET_SHAPES_ON_SHAPES" );
839 createGeomAction( 510, "FILLET_1D" );
840 createGeomAction( 509, "FILLET_2D" );
842 createGeomAction( 9998, "MUL_TRANSFORM" );
843 createGeomAction( 9995, "EXPLODE_BLOCKS" );
844 createGeomAction( 99991, "PROPAGATE" );
846 createGeomAction( 601, "SEWING" );
847 createGeomAction( 602, "GLUE_FACES" );
848 createGeomAction( 603, "SUPPRESS_FACES" );
849 createGeomAction( 604, "SUPPERSS_HOLES" );
850 createGeomAction( 605, "SHAPE_PROCESS" );
851 createGeomAction( 606, "CLOSE_CONTOUR" );
852 createGeomAction( 607, "SUPPRESS_INT_WIRES" );
853 createGeomAction( 608, "POINT_ON_EDGE" );
854 createGeomAction( 609, "CHECK_FREE_BNDS" );
855 createGeomAction( 610, "CHECK_FREE_FACES" );
856 createGeomAction( 611, "CHANGE_ORIENTATION" );
857 createGeomAction( 612, "REMOVE_EXTRA_EDGES" );
859 createGeomAction( 708, "POINT_COORDS" );
860 createGeomAction( 701, "BASIC_PROPS" );
861 createGeomAction( 702, "MASS_CENTER" );
862 createGeomAction( 703, "INERTIA" );
863 createGeomAction( 704, "NORMALE" );
864 createGeomAction( 7041, "BND_BOX" );
865 createGeomAction( 7042, "MIN_DIST" );
866 createGeomAction( 7043, "MEASURE_ANGLE" );
868 createGeomAction( 705, "TOLERANCE" );
869 createGeomAction( 706, "WHAT_IS" );
870 createGeomAction( 707, "CHECK" );
871 createGeomAction( 7072, "CHECK_COMPOUND" );
873 #ifdef _DEBUG_ // PAL16821
874 createGeomAction( 5103, "CHECK_GEOMETRY" );
876 createGeomAction( 412, "SHADING_COLOR" );
878 createGeomAction( 211, "SHADING" );
879 createGeomAction( 212, "DISPLAY_ALL" );
880 createGeomAction( 214, "ERASE_ALL" );
881 createGeomAction( 216, "DISPLAY" );
882 createGeomAction( 218, "VECTOR_MODE");
883 createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true );
884 createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true );
885 createGeomAction( 2173, "WIRE_SEL_ONLY", "", 0, true );
886 createGeomAction( 2174, "FACE_SEL_ONLY", "", 0, true );
887 createGeomAction( 2175, "SHELL_SEL_ONLY", "", 0, true );
888 createGeomAction( 2176, "SOLID_SEL_ONLY", "", 0, true );
889 createGeomAction( 2177, "COMPOUND_SEL_ONLY", "", 0, true );
890 createGeomAction( 2178, "ALL_SEL_ONLY", "", 0, true );
891 createGeomAction( 213, "DISPLAY_ONLY" );
892 createGeomAction( 215, "ERASE" );
894 createGeomAction( 901, "POP_RENAME", "", Qt::Key_F2 );
895 createGeomAction( 80311, "POP_WIREFRAME", "", 0, true );
896 createGeomAction( 80312, "POP_SHADING", "", 0, true );
897 createGeomAction( 80313, "POP_VECTORS", "", 0, true );
898 createGeomAction( 8032, "POP_COLOR" );
899 createGeomAction( 8033, "POP_TRANSPARENCY" );
900 createGeomAction( 8034, "POP_ISOS" );
901 createGeomAction( 8035, "POP_AUTO_COLOR" );
902 createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" );
903 createGeomAction( 8001, "POP_CREATE_GROUP" );
904 createGeomAction( 8037, "POP_SHOW_CHILDREN" );
905 createGeomAction( 8038, "POP_HIDE_CHILDREN" );
907 // make wireframe-shading items to be exclusive (only one at a time is selected)
908 //QActionGroup* dispModeGr = new QActionGroup( this, "", true );
909 //dispModeGr->add( action( 80311 ) );
910 //dispModeGr->add( action( 80312 ) );
911 // ---- create menu --------------------------
913 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
914 createMenu( separator(), fileId, 10 );
915 createMenu( 111, fileId, 10 );
916 createMenu( 121, fileId, 10 );
917 createMenu( separator(), fileId, -1 );
919 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
920 createMenu( 33, editId, -1 );
922 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
924 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
925 createMenu( 4011, basicId, -1 );
926 createMenu( 4012, basicId, -1 );
927 createMenu( 4013, basicId, -1 );
928 createMenu( 4014, basicId, -1 );
929 createMenu( 4015, basicId, -1 );
930 createMenu( 4019, basicId, -1 );
931 createMenu( separator(), basicId, -1 );
932 createMenu( 4016, basicId, -1 );
933 createMenu( 4017, basicId, -1 );
934 // createMenu( 4018, basicId, -1 ); DEPRECATED
935 createMenu( 4020, basicId, -1 );
937 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
938 createMenu( 4021, primId, -1 );
939 createMenu( 4022, primId, -1 );
940 createMenu( 4023, primId, -1 );
941 createMenu( 4024, primId, -1 );
942 createMenu( 4025, primId, -1 );
943 createMenu( 4026, primId, -1 );
944 createMenu( 4027, primId, -1 );
946 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
947 createMenu( 4031, genId, -1 );
948 createMenu( 4032, genId, -1 );
949 createMenu( 4033, genId, -1 );
950 createMenu( 4034, genId, -1 );
951 createMenu( separator(), newEntId, -1 );
953 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
954 createMenu( 800, groupId, -1 );
955 createMenu( 801, groupId, -1 );
956 createMenu( separator(), newEntId, -1 );
958 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
959 createMenu( 9997, blocksId, -1 );
960 createMenu( 9999, blocksId, -1 );
962 createMenu( separator(), newEntId, -1 );
963 createMenu( 404, newEntId, -1 );
964 createMenu( 405, newEntId, -1 );
965 createMenu( separator(), newEntId, -1 );
966 createMenu( 407, newEntId, -1 );
968 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
969 createMenu( 4081, buildId, -1 );
970 createMenu( 4082, buildId, -1 );
971 createMenu( 4083, buildId, -1 );
972 createMenu( 4084, buildId, -1 );
973 createMenu( 4085, buildId, -1 );
974 createMenu( 4086, buildId, -1 );
976 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
978 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
979 createMenu( 5011, boolId, -1 );
980 createMenu( 5012, boolId, -1 );
981 createMenu( 5013, boolId, -1 );
982 createMenu( 5014, boolId, -1 );
984 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
985 createMenu( 5021, transId, -1 );
986 createMenu( 5022, transId, -1 );
987 createMenu( 5023, transId, -1 );
988 createMenu( 5024, transId, -1 );
989 createMenu( 5025, transId, -1 );
990 createMenu( 5026, transId, -1 );
991 createMenu( separator(), transId, -1 );
992 createMenu( 5027, transId, -1 );
993 createMenu( 5028, transId, -1 );
995 createMenu( 503, operId, -1 );
996 createMenu( 504, operId, -1 );
997 createMenu( 508, operId, -1 );
998 createMenu( separator(), operId, -1 );
999 createMenu( 510, transId, -1 );
1000 createMenu( 509, transId, -1 );
1001 createMenu( 505, transId, -1 );
1002 createMenu( 506, transId, -1 );
1003 //createMenu( 507, transId, -1 );
1005 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1006 createMenu( 9998, blockId, -1 );
1007 createMenu( 9995, blockId, -1 );
1008 createMenu( 99991, blockId, -1 );
1010 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1011 createMenu( 605, repairId, -1 );
1012 createMenu( 603, repairId, -1 );
1013 createMenu( 606, repairId, -1 );
1014 createMenu( 607, repairId, -1 );
1015 createMenu( 604, repairId, -1 );
1016 createMenu( 601, repairId, -1 );
1017 createMenu( 602, repairId, -1 );
1018 createMenu( 608, repairId, -1 );
1019 //createMenu( 609, repairId, -1 );
1020 //createMenu( 610, repairId, -1 );
1021 createMenu( 611, repairId, -1 );
1022 createMenu( 612, repairId, -1 );
1024 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1025 createMenu( 708, measurId, -1 );
1026 createMenu( 701, measurId, -1 );
1027 createMenu( separator(), measurId, -1 );
1028 createMenu( 702, measurId, -1 );
1029 createMenu( 703, measurId, -1 );
1030 createMenu( 704, measurId, -1 );
1031 // NPAL16572: move "Check free boundaries" and "Check free faces" from "Repair" to "Measure"
1032 createMenu( separator(), measurId, -1 );
1033 createMenu( 609, measurId, -1 );
1034 createMenu( 610, measurId, -1 );
1036 createMenu( separator(), measurId, -1 );
1038 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1039 createMenu( 7041, dimId, -1 );
1040 createMenu( 7042, dimId, -1 );
1041 createMenu( 7043, dimId, -1 );
1042 createMenu( separator(), measurId, -1 );
1044 createMenu( 705, measurId, -1 );
1045 createMenu( separator(), measurId, -1 );
1046 createMenu( 706, measurId, -1 );
1047 createMenu( 707, measurId, -1 );
1048 createMenu( 7072, measurId, -1 );
1050 #ifdef _DEBUG_ // PAL16821
1051 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1052 createMenu( separator(), toolsId, -1 );
1053 createMenu( 5103, toolsId, -1 );
1055 //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 );
1056 //createMenu( separator(), prefId, -1 );
1057 //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 );
1058 //createMenu( 412, geomId, -1 );
1059 //createMenu( separator(), prefId, -1 );
1061 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1062 createMenu( separator(), viewId, -1 );
1064 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1065 createMenu( 211, dispmodeId, -1 );
1066 createMenu( separator(), dispmodeId, -1 );
1067 createMenu( 218, dispmodeId, -1 );
1069 createMenu( separator(), viewId, -1 );
1070 createMenu( 212, viewId, -1 );
1071 createMenu( 214, viewId, -1 );
1072 createMenu( separator(), viewId, -1 );
1076 because of these items are accessible through object browser and viewers
1077 we have removed they from main menu
1079 createMenu( 216, viewId, -1 );
1080 createMenu( 213, viewId, -1 );
1081 createMenu( 215, viewId, -1 );
1084 // ---- create toolbars --------------------------
1086 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1087 createTool( 4011, basicTbId );
1088 createTool( 4012, basicTbId );
1089 createTool( 4013, basicTbId );
1090 createTool( 4014, basicTbId );
1091 createTool( 4015, basicTbId );
1092 createTool( 4019, basicTbId );
1093 createTool( 4016, basicTbId );
1094 createTool( 4017, basicTbId );
1095 // createTool( 4018, basicTbId ); DEPRECATED
1096 createTool( 4020, basicTbId );
1098 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1099 createTool( 4021, primTbId );
1100 createTool( 4022, primTbId );
1101 createTool( 4023, primTbId );
1102 createTool( 4024, primTbId );
1103 createTool( 4025, primTbId );
1104 createTool( 4026, primTbId );
1105 createTool( 4027, primTbId );
1107 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1108 createTool( 5011, boolTbId );
1109 createTool( 5012, boolTbId );
1110 createTool( 5013, boolTbId );
1111 createTool( 5014, boolTbId );
1113 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1114 createTool( 4031, genTbId );
1115 createTool( 4032, genTbId );
1116 createTool( 4033, genTbId );
1117 createTool( 4034, genTbId );
1119 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1120 createTool( 5021, transTbId );
1121 createTool( 5022, transTbId );
1122 createTool( 5023, transTbId );
1123 createTool( 5024, transTbId );
1124 createTool( 5025, transTbId );
1125 createTool( 5026, transTbId );
1126 createTool( separator(), transTbId );
1127 createTool( 5027, transTbId );
1128 createTool( 5028, transTbId );
1130 // ---- create popup menus --------------------------
1132 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1133 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1135 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1136 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1138 QString autoColorPrefix =
1139 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1141 QtxPopupMgr* mgr = popupMgr();
1142 mgr->insert( action( 901 ), -1, -1 ); // rename
1143 mgr->setRule( action( 901 ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
1144 mgr->insert( action( 33 ), -1, -1 ); // delete
1145 mgr->setRule( action( 33 ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1146 mgr->insert( action( 8001 ), -1, -1 ); // create group
1147 mgr->setRule( action( 8001 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1148 mgr->insert( action( 8037 ), -1, -1 ); // show children
1149 mgr->setRule( action( 8037 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
1150 mgr->insert( action( 8038 ), -1, -1 ); // hide children
1151 mgr->setRule( action( 8038 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
1152 mgr->insert( action( 801 ), -1, -1 ); // edit group
1153 mgr->setRule( action( 801 ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1154 mgr->insert( separator(), -1, -1 ); // -----------
1155 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1156 mgr->insert( action( 80311 ), dispmodeId, -1 ); // wireframe
1157 mgr->setRule( action( 80311 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1158 mgr->setRule( action( 80311 ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1159 mgr->insert( action( 80312 ), dispmodeId, -1 ); // shading
1160 mgr->setRule( action( 80312 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1161 mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1162 mgr->insert( separator(), dispmodeId, -1 );
1163 mgr->insert( action( 80313 ), dispmodeId, -1 ); // vectors
1164 mgr->setRule( action( 80313 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1165 mgr->setRule( action( 80313 ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1166 mgr->insert( separator(), -1, -1 ); // -----------
1167 mgr->insert( action( 8032 ), -1, -1 ); // color
1168 mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1169 mgr->insert( action( 8033 ), -1, -1 ); // transparency
1170 mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1171 mgr->insert( action( 8034 ), -1, -1 ); // isos
1172 mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1173 mgr->insert( separator(), -1, -1 ); // -----------
1174 mgr->insert( action( 8035 ), -1, -1 ); // auto color
1175 mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1176 mgr->insert( action( 8036 ), -1, -1 ); // disable auto color
1177 mgr->setRule( action( 8036 ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1178 mgr->insert( separator(), -1, -1 ); // -----------
1181 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1182 onlyComponent = "((type='Component') and selcount=1)",
1183 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1184 types = "'Shape' 'Group'";
1186 mgr->insert( action( 216 ), -1, -1 ); // display
1187 mgr->setRule( action( 216 ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1189 mgr->insert( action( 215 ), -1, -1 ); // erase
1190 mgr->setRule( action( 215 ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1192 mgr->insert( action( 214 ), -1, -1 ); // erase All
1193 mgr->setRule( action( 214 ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1195 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1197 int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1198 mgr->insert( action(2171), selectolnyId, -1); //Vertex
1199 mgr->setRule(action(2171), selectOnly, QtxPopupMgr::VisibleRule);
1200 mgr->setRule(action(2171), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1201 mgr->insert( action(2172), selectolnyId, -1); //Edge
1202 mgr->setRule(action(2172), selectOnly, QtxPopupMgr::VisibleRule);
1203 mgr->setRule(action(2172), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1204 mgr->insert( action(2173), selectolnyId, -1); //Wire
1205 mgr->setRule(action(2173), selectOnly, QtxPopupMgr::VisibleRule);
1206 mgr->setRule(action(2173), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1207 mgr->insert( action(2174), selectolnyId, -1); //Face
1208 mgr->setRule(action(2174), selectOnly, QtxPopupMgr::VisibleRule);
1209 mgr->setRule(action(2174), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1210 mgr->insert( action(2175), selectolnyId, -1); //Shell
1211 mgr->setRule(action(2175), selectOnly, QtxPopupMgr::VisibleRule);
1212 mgr->setRule(action(2175), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1213 mgr->insert( action(2176), selectolnyId, -1); //Solid
1214 mgr->setRule(action(2176), selectOnly, QtxPopupMgr::VisibleRule);
1215 mgr->setRule(action(2176), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1216 mgr->insert( action(2177), selectolnyId, -1); //Compound
1217 mgr->setRule(action(2177), selectOnly, QtxPopupMgr::VisibleRule);
1218 mgr->setRule(action(2177), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1219 mgr->insert( separator(), selectolnyId, -1);
1220 mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter
1221 mgr->setRule(action(2178), selectOnly, QtxPopupMgr::VisibleRule);
1222 mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1223 mgr->insert( action( 213 ), -1, -1 ); // display only
1224 mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1225 mgr->insert( separator(), -1, -1 );
1227 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1230 //=======================================================================
1231 // function : GeometryGUI::activateModule()
1232 // purpose : Called when GEOM module is activated
1233 //=======================================================================
1234 bool GeometryGUI::activateModule( SUIT_Study* study )
1236 if ( CORBA::is_nil( myComponentGeom ) )
1239 bool res = SalomeApp_Module::activateModule( study );
1244 setMenuShown( true );
1245 setToolShown( true );
1247 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1248 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1250 // Reset actions accelerator keys
1251 //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import
1252 //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export
1253 action(111)->setEnabled( true ); // Import: CTRL + Key_I
1254 action(121)->setEnabled( true ); // Export: CTRL + Key_E
1255 action( 33)->setEnabled( true ); // Delete: Key_Delete
1256 action(901)->setEnabled( true ); // Rename: Key_F2
1258 GUIMap::Iterator it;
1259 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1260 it.value()->activate( application()->desktop() );
1262 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1264 SUIT_ViewManager* vm;
1265 ViewManagerList OCCViewManagers, VTKViewManagers;
1267 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1268 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1269 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1270 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1272 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1273 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1274 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1275 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1278 SALOME_ListIO selected;
1279 sm->selectedObjects( selected );
1280 sm->clearSelected();
1282 // disable OCC selectors
1283 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1284 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1285 while ( itOCCSel.hasNext() )
1286 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1287 sr->setEnabled(true);
1289 // disable VTK selectors
1290 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1291 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1292 while ( itVTKSel.hasNext() )
1293 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1294 sr->setEnabled(true);
1296 sm->setSelectedObjects( selected, true ); //NPAL 19674
1298 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1300 connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1306 //=======================================================================
1307 // function : GeometryGUI::deactivateModule()
1308 // purpose : Called when GEOM module is deactivated
1309 //=======================================================================
1310 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1312 QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1314 disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1316 setMenuShown( false );
1317 setToolShown( false );
1319 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1320 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1322 EmitSignalCloseAllDialogs();
1324 GUIMap::Iterator it;
1325 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1326 it.value()->deactivate();
1328 // Unset actions accelerator keys
1329 //action(111)->setAccel(QKeySequence()); // Import
1330 //action(121)->setAccel(QKeySequence()); // Export
1331 action(111)->setEnabled( false ); // Import: CTRL + Key_I
1332 action(121)->setEnabled( false ); // Export: CTRL + Key_E
1333 action( 33)->setEnabled( false ); // Delete: Key_Delete
1334 action(901)->setEnabled( false ); // Rename: Key_F2
1336 qDeleteAll(myOCCSelectors);
1337 myOCCSelectors.clear();
1338 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1340 qDeleteAll(myVTKSelectors);
1341 myVTKSelectors.clear();
1342 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1344 return SalomeApp_Module::deactivateModule( study );
1347 //=======================================================================
1348 // function : GeometryGUI::BuildPresentation()
1350 //=======================================================================
1351 void GeometryGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& io, SUIT_ViewWindow* win )
1353 //GEOM_Displayer().Display( io, false, win );
1356 //=======================================================================
1357 // function : onWindowActivated()
1358 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1359 //=======================================================================
1360 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1365 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1366 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1368 // disable non-OCC viewframe menu commands
1369 // action( 404 )->setEnabled( ViewOCC ); // SKETCHER
1370 action( 603 )->setEnabled( ViewOCC ); // SuppressFace
1371 action( 604 )->setEnabled( ViewOCC ); // SuppressHole
1372 action( 606 )->setEnabled( ViewOCC ); // CloseContour
1373 action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires
1374 action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
1375 // action( 609 )->setEnabled( ViewOCC ); // Free boundaries
1377 action( 800 )->setEnabled( ViewOCC ); // Create Group
1378 action( 801 )->setEnabled( ViewOCC ); // Edit Group
1380 action( 9998 )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1383 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1385 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1386 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1389 void GeometryGUI::viewManagers( QStringList& lst ) const
1391 lst.append( OCCViewer_Viewer::Type() );
1394 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1396 if ( vm->getType() == OCCViewer_Viewer::Type() )
1398 qDebug( "connect" );
1399 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1400 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1401 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1402 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1403 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1404 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1407 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1408 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1410 // disable OCC selectors
1411 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1412 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1413 while ( itOCCSel.hasNext() )
1414 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1415 sr->setEnabled(true);
1417 else if ( vm->getType() == SVTK_Viewer::Type() )
1419 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1420 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1422 // disable VTK selectors
1423 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1424 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1425 while ( itVTKSel.hasNext() )
1426 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1427 sr->setEnabled(true);
1431 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1433 SUIT_ViewModel* viewer = vm->getViewModel();
1434 if ( vm->getType() == OCCViewer_Viewer::Type() )
1436 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1437 while ( itOCCSel.hasNext() )
1438 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1439 if ( sr->viewer() == viewer )
1441 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1445 if ( vm->getType() == SVTK_Viewer::Type() )
1447 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1448 while ( itVTKSel.hasNext() )
1449 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1450 if ( sr->viewer() == viewer )
1452 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1458 QString GeometryGUI::engineIOR() const
1460 if ( !CORBA::is_nil( GetGeomGen() ) )
1461 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1465 LightApp_Selection* GeometryGUI::createSelection() const
1467 return new GEOMGUI_Selection();
1470 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1472 SalomeApp_Module::contextMenuPopup(client, menu, title);
1475 getApp()->selectionMgr()->selectedObjects(lst);
1476 if (lst.Extent() < 1)
1479 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1480 _PTR(Study) study = appStudy->studyDS();
1482 bool isImported = true;
1483 SALOME_ListIteratorOfListIO anIt (lst);
1484 for (; anIt.More() && isImported; anIt.Next()) {
1485 Handle(SALOME_InteractiveObject) io = anIt.Value();
1486 _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1488 if (lst.Extent() == 1) {
1489 // Set context menu title
1490 if (client == "OCCViewer" || client == "VTKViewer")
1491 title = QString(aSObj->GetName().c_str());
1494 CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1495 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1496 if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1502 menu->addAction(action(5029)); // Reload imported shape
1506 void GeometryGUI::createPreferences()
1508 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1510 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1511 setPreferenceProperty( genGroup, "columns", 2 );
1513 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1514 LightApp_Preferences::Selector,
1515 "Geometry", "display_mode" );
1517 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1518 LightApp_Preferences::Color, "Geometry", "shading_color" );
1520 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1521 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1523 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1524 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1526 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1527 LightApp_Preferences::Color, "Geometry", "line_color" );
1529 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1530 LightApp_Preferences::Color, "Geometry", "point_color" );
1532 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1533 LightApp_Preferences::Color, "Geometry", "isos_color" );
1535 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1536 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1538 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1539 setPreferenceProperty( VertexGroup, "columns", 2 );
1541 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1542 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1544 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1545 LightApp_Preferences::DblSpin, "Geometry", "marker_scale" );
1547 // Set property for default display mode
1548 QStringList aModesList;
1549 aModesList.append( tr("MEN_WIREFRAME") );
1550 aModesList.append( tr("MEN_SHADING") );
1552 QList<QVariant> anIndexesList;
1553 anIndexesList.append(0);
1554 anIndexesList.append(1);
1556 setPreferenceProperty( dispmode, "strings", aModesList );
1557 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1559 // Set property for step value for spinboxes
1560 setPreferenceProperty( step, "min", 1 );
1561 setPreferenceProperty( step, "max", 10000 );
1562 setPreferenceProperty( step, "precision", 3 );
1564 // Set property for type of vertex marker
1565 QStringList aTypeOfMarkerList;
1566 QList<QVariant> anTypeOfMarkerIndexesList;
1568 aTypeOfMarkerList.append( tr("TOM_PLUS") );
1569 anTypeOfMarkerIndexesList.append(Aspect_TOM_PLUS);
1571 aTypeOfMarkerList.append( tr("TOM_POINT") );
1572 anTypeOfMarkerIndexesList.append(Aspect_TOM_POINT);
1574 aTypeOfMarkerList.append( tr("TOM_STAR") );
1575 anTypeOfMarkerIndexesList.append(Aspect_TOM_STAR);
1577 aTypeOfMarkerList.append( tr("TOM_O") );
1578 anTypeOfMarkerIndexesList.append(Aspect_TOM_O);
1580 aTypeOfMarkerList.append( tr("TOM_X") );
1581 anTypeOfMarkerIndexesList.append(Aspect_TOM_X);
1583 aTypeOfMarkerList.append( tr("TOM_O_POINT") );
1584 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_POINT);
1586 aTypeOfMarkerList.append( tr("TOM_O_PLUS") );
1587 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_PLUS);
1589 aTypeOfMarkerList.append( tr("TOM_O_STAR") );
1590 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_STAR);
1592 aTypeOfMarkerList.append( tr("TOM_O_X") );
1593 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_X);
1596 setPreferenceProperty( typeOfMarker, "strings", aTypeOfMarkerList );
1597 setPreferenceProperty( typeOfMarker, "indexes", anTypeOfMarkerIndexesList );
1599 // Set property for Vertex Marker scale
1600 setPreferenceProperty( markerScale, "min", 1. );
1601 setPreferenceProperty( markerScale, "max", 7. );
1602 setPreferenceProperty( markerScale, "precision", 0.01 );
1603 setPreferenceProperty( markerScale, "step", 0.5 );
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( 218 );
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);