1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 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 // File : GeometryGUI.cxx
23 // 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>
74 #include <AIS_Drawer.hxx>
75 #include <AIS_ListOfInteractive.hxx>
76 #include <AIS_ListIteratorOfListOfInteractive.hxx>
77 #include <Prs3d_Drawer.hxx>
78 #include <Prs3d_IsoAspect.hxx>
79 #include <Aspect_TypeOfMarker.hxx>
80 #include <OSD_SharedLibrary.hxx>
81 #include <NCollection_DataMap.hxx>
83 #include <utilities.h>
85 #include <vtkCamera.h>
86 #include <vtkRenderer.h>
91 Standard_EXPORT CAM_Module* createModule() {
92 return new GeometryGUI();
98 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
100 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
102 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
103 if (CORBA::is_nil(myComponentGeom))
105 return GeometryGUI::myComponentGeom;
108 bool GeometryGUI::InitGeomGen()
111 if( CORBA::is_nil( myComponentGeom ) ) return false;
115 //=======================================================================
116 // function : ClientSObjectToObject
118 //=======================================================================
119 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
121 _PTR(GenericAttribute) anAttr;
122 CORBA::Object_var anObj;
124 std::string aValue = theSObject->GetIOR();
125 if (strcmp(aValue.c_str(), "") != 0) {
126 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
127 anObj = anORB->string_to_object(aValue.c_str());
130 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
132 return anObj._retn();
135 //=======================================================================
136 // function : ClientStudyToStudy
138 //=======================================================================
139 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
141 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
142 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
143 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
144 int aStudyID = theStudy->StudyId();
145 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
146 return aDSStudy._retn();
149 //=======================================================================
150 // function : GeometryGUI::GeometryGUI()
151 // purpose : Constructor
152 //=======================================================================
153 GeometryGUI::GeometryGUI() :
154 SalomeApp_Module( "GEOM" )
156 if ( CORBA::is_nil( myComponentGeom ) )
158 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
159 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "GEOM" );
160 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
164 myActiveDialogBox = 0;
167 gp_Pnt origin = gp_Pnt(0., 0., 0.);
168 gp_Dir direction = gp_Dir(0., 0., 1.);
169 myWorkingPlane = gp_Ax3(origin, direction);
172 myLocalSelectionMode = GEOM_ALLOBJECTS;
175 //=======================================================================
176 // function : GeometryGUI::~GeometryGUI()
177 // purpose : Destructor
178 //=======================================================================
179 GeometryGUI::~GeometryGUI()
181 while (!myOCCSelectors.isEmpty())
182 delete myOCCSelectors.takeFirst();
184 while (!myVTKSelectors.isEmpty())
185 delete myVTKSelectors.takeFirst();
188 //=======================================================================
189 // function : GeometryGUI::getLibrary()
190 // purpose : get or load GUI library by name [ internal ]
191 //=======================================================================
192 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
193 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
195 if ( !myGUIMap.contains( libraryName ) ) {
196 // try to load library if it is not loaded yet
199 libs = getenv( "LD_LIBRARY_PATH" );
200 if( !libs.isEmpty() ) {
201 QStringList dirList = libs.split( ":", QString::SkipEmptyParts ); // skip empty entries
203 libs = getenv( "PATH" );
204 if( !libs.isEmpty() ) {
205 QStringList dirList = libs.split( ";", QString::SkipEmptyParts ); // skip empty entries
207 for( int i = dirList.count()-1; i >= 0; i-- ) {
208 QString dir = dirList[ i ];
209 QFileInfo fi( Qtx::addSlash( dirList[ i ] ) + libraryName );
211 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().data() );
212 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
214 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
215 continue; // continue search further
217 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
218 if ( osdF != NULL ) {
219 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
220 GEOMGUI* libGUI = (*func)(this);
222 myGUIMap[ libraryName ] = libGUI;
223 break; // found and loaded!
230 if ( myGUIMap.contains( libraryName ) )
231 // library is successfully loaded
232 return myGUIMap[ libraryName ];
236 //=======================================================================
237 // function : GeometryGUI::ActiveWorkingPlane()
238 // purpose : Activate Working Plane View
239 //=======================================================================
240 void GeometryGUI::ActiveWorkingPlane()
242 gp_Dir DZ = myWorkingPlane.Direction();
243 gp_Dir DY = myWorkingPlane.YDirection();
245 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
246 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
247 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
250 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
252 Handle(V3d_View) view3d = vw->getViewPort()->getView();
254 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
255 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
261 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
263 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
265 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
266 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
267 camera->SetFocalPoint(0,0,0);
274 //=======================================================================
275 // function : GeometryGUI::SetActiveDialogBox()
276 // purpose : Set active dialog box
277 //=======================================================================
278 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
280 myActiveDialogBox = (QDialog*)aDlg;
283 //=======================================================================
284 // function : GeometryGUI::EmitSignalDeactivateDialog()
285 // purpose : Emit a signal to deactivate the active dialog Box
286 //=======================================================================
287 void GeometryGUI::EmitSignalDeactivateDialog()
289 emit SignalDeactivateActiveDialog();
292 //=======================================================================
293 // function : GeometryGUI::EmitSignalCloseAllDialogs()
294 // purpose : Emit a signal to close all non modal dialogs box
295 //=======================================================================
296 void GeometryGUI::EmitSignalCloseAllDialogs()
298 emit SignalCloseAllDialogs();
301 //=======================================================================
302 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
303 // purpose : Emit a signal to inform that default real spin box step has
305 //=======================================================================
306 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
308 emit SignalDefaultStepValueChanged(newVal);
311 //=======================================================================
312 // function : GeometryGUI::OnGUIEvent()
313 // purpose : common slot for all menu/toolbar actions
314 //=======================================================================
315 void GeometryGUI::OnGUIEvent()
317 const QObject* obj = sender();
318 if ( !obj || !obj->inherits( "QAction" ) )
320 int id = actionId((QAction*)obj);
325 //=======================================================================
326 // function : GeometryGUI::OnGUIEvent()
327 // purpose : manage all events on GUI [static]
328 //=======================================================================
329 void GeometryGUI::OnGUIEvent( int id )
331 SUIT_Application* anApp = application();
333 SUIT_Desktop* desk = anApp->desktop();
335 // check type of the active viewframe
336 SUIT_ViewWindow* window = desk->activeWindow();
337 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
338 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
339 // if current viewframe is not of OCC and not of VTK type - return immediately
340 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
341 bool NotViewerDependentCommand = ( id == 901 || id == 216 || id == 213 );
342 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommand )
345 // fix for IPAL9103, point 2
346 if ( CORBA::is_nil( GetGeomGen() ) ) {
347 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
351 GEOMGUI* library = 0;
352 // try to get-or-load corresponding GUI library
353 if( id == 111 || // MENU FILE - IMPORT BREP
354 id == 112 || // MENU FILE - IMPORT IGES
355 id == 113 || // MENU FILE - IMPORT STEP
356 id == 121 || // MENU FILE - EXPORT BREP
357 id == 122 || // MENU FILE - EXPORT IGES
358 id == 123 || // MENU FILE - EXPORT STEP
359 id == 2171 || // POPUP VIEWER - SELECT ONLY - VERTEX
360 id == 2172 || // POPUP VIEWER - SELECT ONLY - EDGE
361 id == 2173 || // POPUP VIEWER - SELECT ONLY - WIRE
362 id == 2174 || // POPUP VIEWER - SELECT ONLY - FACE
363 id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL
364 id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID
365 id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND
366 id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL
367 id == 31 || // MENU EDIT - COPY
368 id == 33 || // MENU EDIT - DELETE
369 id == 411 || // MENU SETTINGS - ADD IN STUDY
370 id == 412 || // MENU SETTINGS - SHADING COLOR
371 id == 5103 || // MENU TOOLS - CHECK GEOMETRY
372 id == 8032 || // POPUP VIEWER - COLOR
373 id == 8033 || // POPUP VIEWER - TRANSPARENCY
374 id == 8034 || // POPUP VIEWER - ISOS
375 id == 8035 || // POPUP VIEWER - AUTO COLOR
376 id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR
377 id == 804 || // POPUP VIEWER - ADD IN STUDY
378 id == 901 || // OBJECT BROWSER - RENAME
379 id == 9024 ) { // OBJECT BROWSER - OPEN
380 //cout << "id " << id << " received" << endl;
382 library = getLibrary( "libGEOMToolsGUI.so" );
384 library = getLibrary( "GEOMToolsGUI.dll" );
387 else if( id == 211 || // MENU VIEW - WIREFRAME/SHADING
388 id == 212 || // MENU VIEW - DISPLAY ALL
389 id == 213 || // MENU VIEW - DISPLAY ONLY
390 id == 214 || // MENU VIEW - ERASE ALL
391 id == 215 || // MENU VIEW - ERASE
392 id == 216 || // MENU VIEW - DISPLAY
393 id == 80311 || // POPUP VIEWER - WIREFRAME
394 id == 80312 ) { // POPUP VIEWER - SHADING
396 library = getLibrary( "libDisplayGUI.so" );
398 library = getLibrary( "DisplayGUI.dll" );
401 else if( id == 4011 || // MENU BASIC - POINT
402 id == 4012 || // MENU BASIC - LINE
403 id == 4013 || // MENU BASIC - CIRCLE
404 id == 4014 || // MENU BASIC - ELLIPSE
405 id == 4015 || // MENU BASIC - ARC
406 id == 4016 || // MENU BASIC - VECTOR
407 id == 4017 || // MENU BASIC - PLANE
408 id == 4018 || // MENU BASIC - WPLANE
409 id == 4019 || // MENU BASIC - CURVE
410 id == 4020 ) { // MENU BASIC - REPAIR
412 library = getLibrary( "libBasicGUI.so" );
414 library = getLibrary( "BasicGUI.dll" );
417 else if( id == 4021 || // MENU PRIMITIVE - BOX
418 id == 4022 || // MENU PRIMITIVE - CYLINDER
419 id == 4023 || // MENU PRIMITIVE - SPHERE
420 id == 4024 || // MENU PRIMITIVE - TORUS
421 id == 4025 || // MENU PRIMITIVE - CONE
422 id == 4026 || // MENU PRIMITIVE - FACE
423 id == 4027 ) { // MENU PRIMITIVE - DISK
425 library = getLibrary( "libPrimitiveGUI.so" );
427 library = getLibrary( "PrimitiveGUI.dll" );
430 else if( id == 4031 || // MENU GENERATION - PRISM
431 id == 4032 || // MENU GENERATION - REVOLUTION
432 id == 4033 || // MENU GENERATION - FILLING
433 id == 4034 ) { // MENU GENERATION - PIPE
435 library = getLibrary( "libGenerationGUI.so" );
437 library = getLibrary( "GenerationGUI.dll" );
440 else if( id == 404 || // MENU ENTITY - SKETCHER
441 id == 407 ) { // MENU ENTITY - EXPLODE
443 library = getLibrary( "libEntityGUI.so" );
445 library = getLibrary( "EntityGUI.dll" );
448 else if( id == 4081 || // MENU BUILD - EDGE
449 id == 4082 || // MENU BUILD - WIRE
450 id == 4083 || // MENU BUILD - FACE
451 id == 4084 || // MENU BUILD - SHELL
452 id == 4085 || // MENU BUILD - SOLID
453 id == 4086 ) { // MENU BUILD - COMPUND
455 library = getLibrary( "libBuildGUI.so" );
457 library = getLibrary( "BuildGUI.dll" );
460 else if( id == 5011 || // MENU BOOLEAN - FUSE
461 id == 5012 || // MENU BOOLEAN - COMMON
462 id == 5013 || // MENU BOOLEAN - CUT
463 id == 5014 ) { // MENU BOOLEAN - SECTION
465 library = getLibrary( "libBooleanGUI.so" );
467 library = getLibrary( "BooleanGUI.dll" );
470 else if( id == 5021 || // MENU TRANSFORMATION - TRANSLATION
471 id == 5022 || // MENU TRANSFORMATION - ROTATION
472 id == 5023 || // MENU TRANSFORMATION - LOCATION
473 id == 5024 || // MENU TRANSFORMATION - MIRROR
474 id == 5025 || // MENU TRANSFORMATION - SCALE
475 id == 5026 || // MENU TRANSFORMATION - OFFSET
476 id == 5027 || // MENU TRANSFORMATION - MULTI-TRANSLATION
477 id == 5028 ) { // MENU TRANSFORMATION - MULTI-ROTATION
479 library = getLibrary( "libTransformationGUI.so" );
481 library = getLibrary( "TransformationGUI.dll" );
484 else if( id == 503 || // MENU OPERATION - PARTITION
485 id == 504 || // MENU OPERATION - ARCHIMEDE
486 id == 505 || // MENU OPERATION - FILLET
487 id == 506 || // MENU OPERATION - CHAMFER
488 id == 507 || // MENU OPERATION - CLIPPING RANGE
489 id == 508 ) { // MENU OPERATION - GET SHAPES ON SHAPE
491 library = getLibrary( "libOperationGUI.so" );
493 library = getLibrary( "OperationGUI.dll" );
496 else if( id == 601 || // MENU REPAIR - SEWING
497 id == 603 || // MENU REPAIR - SUPPRESS FACES
498 id == 604 || // MENU REPAIR - SUPPRESS HOLE
499 id == 605 || // MENU REPAIR - SHAPE PROCESSING
500 id == 606 || // MENU REPAIR - CLOSE CONTOUR
501 id == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES
502 id == 608 || // MENU REPAIR - ADD POINT ON EDGE
503 id == 609 || // MENU MEASURE - FREE BOUNDARIES
504 id == 610 || // MENU MEASURE - FREE FACES
505 id == 611 || // MENU REPAIR - CHANGE ORIENTATION
506 id == 602 || // MENU REPAIR - GLUE FACES
507 id == 612 ) { // MENU REPAIR - REMOVE EXTRA EDGES
509 library = getLibrary( "libRepairGUI.so" );
511 library = getLibrary( "RepairGUI.dll" );
514 else if( id == 701 || // MENU MEASURE - PROPERTIES
515 id == 702 || // MENU MEASURE - CDG
516 id == 703 || // MENU MEASURE - INERTIA
517 id == 704 || // MENU MEASURE - NORMALE
518 id == 7041 || // MENU MEASURE - BOUNDING BOX
519 id == 7042 || // MENU MEASURE - MIN DISTANCE
520 id == 7043 || // MENU MEASURE - ANGLE
521 id == 705 || // MENU MEASURE - TOLERANCE
522 id == 706 || // MENU MEASURE - WHATIS
523 id == 707 || // MENU MEASURE - CHECK
524 id == 7072 || // MENU MEASURE - CHECK COMPOUND OF BLOCKS
525 id == 708 ) { // MENU MEASURE - POINT COORDINATES
527 library = getLibrary( "libMeasureGUI.so" );
529 library = getLibrary( "MeasureGUI.dll" );
532 else if( id == 800 || // MENU GROUP - CREATE
533 id == 8001 || // POPUP MENU - CREATE GROUP
534 id == 801 ) { // MENU GROUP - EDIT
536 library = getLibrary( "libGroupGUI.so" );
538 library = getLibrary( "GroupGUI.dll" );
541 else if( id == 9999 || // MENU BLOCKS - HEXAHEDRAL SOLID
542 id == 9998 || // MENU BLOCKS - MULTI-TRANSFORMATION
543 id == 9997 || // MENU BLOCKS - QUADRANGLE FACE
544 id == 99991 || // MENU BLOCKS - PROPAGATE
545 id == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS
547 library = getLibrary( "libBlocksGUI.so" );
549 library = getLibrary( "BlocksGUI.dll" );
553 // call method of corresponding GUI library
555 library->OnGUIEvent( id, desk );
557 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
561 //=================================================================================
562 // function : GeometryGUI::OnKeyPress()
563 // purpose : Called when any key is pressed by user [static]
564 //=================================================================================
565 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* win, QKeyEvent* pe )
569 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
570 SUIT_Application* anApp = application();
572 bOk = bOk && it.value()->OnKeyPress( pe, anApp->desktop(), win );
578 //=================================================================================
579 // function : GeometryGUI::OnMouseMove()
580 // purpose : Manages mouse move events [static]
581 //=================================================================================
582 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* win, QMouseEvent* pe )
586 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
587 SUIT_Application* anApp = application();
589 bOk = bOk && it.value()->OnMouseMove( pe, anApp->desktop(), win );
595 //=================================================================================
596 // function : GeometryGUI::0nMousePress()
597 // purpose : Manage mouse press events [static]
598 //=================================================================================
599 void GeometryGUI::OnMousePress( SUIT_ViewWindow* win, QMouseEvent* pe )
602 // OnMousePress() should return false if this event should be processed further
603 // (see OCCViewer_Viewer3d::onMousePress() for explanation)
604 bool processed = false;
605 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
606 SUIT_Application* anApp = application();
608 processed = processed || it.value()->OnMousePress( pe, anApp->desktop(), win );
614 static void UpdateVtkSelection()
616 QPtrList<SUIT_ViewWindow> winList = application()->desktop()->windows();
617 SUIT_ViewWindow* win = 0;
618 for ( win = winList.first(); win; win = winList.next() ) {
619 if ( win->getViewManager()->getTypeView() == VIEW_VTK ) {
620 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
622 SVTK_RenderWindowInteractor* anInteractor = vw->getRWInteractor();
623 anInteractor->SetSelectionProp();
624 anInteractor->SetSelectionTolerance();
625 SVTK_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
627 aStyle->setPreselectionProp();
634 //=================================================================================
635 // function : GeometryGUI::SetSettings()
636 // purpose : Called when GEOM module is activated [static]
637 //=================================================================================
638 bool GeometryGUI::SetSettings()
640 QMenuBar* Mb = parent->getMainMenuBar();
641 SUIT_Study* ActiveStudy = application()->activeStudy();
643 // Wireframe or Shading
645 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
646 bool ViewOCC = ( window && window->getViewManager()->getType() == VIEW_OCC );
647 bool ViewVTK = ( window && window->getViewManager()->getType() == VIEW_VTK );
649 OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( window->getViewManager() );
651 Handle(AIS_InteractiveContext) ic = vm->getOCCViewer()->getAISContext();
652 DisplayMode = ic->DisplayMode();
655 else if ( ViewVTK ) {
656 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
658 SVTK_RenderWindowInteractor* myRenderInter = vw->getRWInteractor();
659 DisplayMode = myRenderInter->GetDisplayMode();
663 if( DisplayMode == 1 )
665 Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) );
667 Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) );
670 // Add in Study - !!!ALWAYS TRUE!!! /////// VSR : TO BE REMOVED
671 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
672 int Settings_AddInStudy;
673 // if(!AddInStudy.isEmpty())
674 // Settings_AddInStudy = AddInStudy.toInt();
677 Settings_AddInStudy = 1;
678 Mb->setItemChecked(411, Settings_AddInStudy);
681 QString S = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
683 QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", "100");
686 int count = ActiveStudy->getStudyFramesCount();
687 for(int i = 0; i < count; i++) {
688 if(ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC) {
689 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
690 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
692 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
693 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
695 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
697 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
703 // PAL5356: update VTK selection
704 ::UpdateVtkSelection();
707 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
708 bOk = bOk && it.data()->SetSettings( parent );
710 // MZN: Enable/disable "Clipping range" menu item(from GEOM_CLIPPING variable)
711 if (getenv( "GEOM_CLIPPING" ) == NULL)
713 QMenuItem* mi = Mb->findItem(50);
714 if (mi && mi->popup())
715 mi->popup()->removeItem(507);
722 //=======================================================================
723 // function : createGeomAction
725 //=======================================================================
726 void GeometryGUI::createGeomAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
729 QWidget* parent = application()->desktop();
730 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
732 if ( icon_id.length() )
733 pix = resMgr->loadPixmap( "GEOM", tr( icon_id.toLatin1().constData() ) );
735 pix = resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+po_id).toLatin1().constData() ), false );
739 QString tooltip = tr( (QString( "TOP_" )+po_id).toLatin1().constData() ),
740 menu = tr( (QString( "MEN_" )+po_id).toLatin1().constData() ),
741 status_bar = tr( (QString( "STB_" )+po_id).toLatin1().constData() );
743 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
748 //=======================================================================
749 // function : GeometryGUI::initialize()
750 // purpose : Called when GEOM module is created
751 //=======================================================================
752 void GeometryGUI::initialize( CAM_Application* app )
754 SalomeApp_Module::initialize( app );
756 // ----- create actions --------------
758 createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) );
759 createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) );
761 createGeomAction( 33, "DELETE", "", Qt::Key_Delete );
763 createGeomAction( 4011, "POINT" );
764 createGeomAction( 4012, "LINE" );
765 createGeomAction( 4013, "CIRCLE" );
766 createGeomAction( 4014, "ELLIPSE" );
767 createGeomAction( 4015, "ARC" );
768 createGeomAction( 4019, "CURVE" );
769 createGeomAction( 4016, "VECTOR" );
770 createGeomAction( 4017, "PLANE" );
771 createGeomAction( 4018, "WORK_PLANE" );
772 createGeomAction( 4020, "LOCAL_CS" );
774 createGeomAction( 4021, "BOX" );
775 createGeomAction( 4022, "CYLINDER" );
776 createGeomAction( 4023, "SPHERE" );
777 createGeomAction( 4024, "TORUS" );
778 createGeomAction( 4025, "CONE" );
779 createGeomAction( 4026, "FACE" );
780 createGeomAction( 4027, "DISK" );
782 createGeomAction( 4031, "EXTRUSION" );
783 createGeomAction( 4032, "REVOLUTION" );
784 createGeomAction( 4033, "FILLING" );
785 createGeomAction( 4034, "PIPE" );
787 createGeomAction( 800, "GROUP_CREATE" );
788 createGeomAction( 801, "GROUP_EDIT" );
790 createGeomAction( 9997, "Q_FACE" );
791 createGeomAction( 9999, "HEX_SOLID" );
793 createGeomAction( 404, "SKETCH" );
794 createGeomAction( 407, "EXPLODE" );
796 createGeomAction( 4081, "EDGE" );
797 createGeomAction( 4082, "WIRE" );
798 createGeomAction( 4083, "FACE" );
799 createGeomAction( 4084, "SHELL" );
800 createGeomAction( 4085, "SOLID" );
801 createGeomAction( 4086, "COMPOUND" );
803 createGeomAction( 5011, "FUSE" );
804 createGeomAction( 5012, "COMMON" );
805 createGeomAction( 5013, "CUT" );
806 createGeomAction( 5014, "SECTION" );
808 createGeomAction( 5021, "TRANSLATION" );
809 createGeomAction( 5022, "ROTATION" );
810 createGeomAction( 5023, "MODIFY_LOCATION" );
811 createGeomAction( 5024, "MIRROR" );
812 createGeomAction( 5025, "SCALE" );
813 createGeomAction( 5026, "OFFSET" );
814 createGeomAction( 5027, "MUL_TRANSLATION" );
815 createGeomAction( 5028, "MUL_ROTATION" );
817 createGeomAction( 503, "PARTITION" );
818 createGeomAction( 504, "ARCHIMEDE" );
819 createGeomAction( 505, "FILLET" );
820 createGeomAction( 506, "CHAMFER" );
821 //createGeomAction( 507, "CLIPPING" );
822 createGeomAction( 508, "GET_SHAPES_ON_SHAPES" );
824 createGeomAction( 9998, "MUL_TRANSFORM" );
825 createGeomAction( 9995, "EXPLODE_BLOCKS" );
826 createGeomAction( 99991, "PROPAGATE" );
828 createGeomAction( 601, "SEWING" );
829 createGeomAction( 602, "GLUE_FACES" );
830 createGeomAction( 603, "SUPPRESS_FACES" );
831 createGeomAction( 604, "SUPPERSS_HOLES" );
832 createGeomAction( 605, "SHAPE_PROCESS" );
833 createGeomAction( 606, "CLOSE_CONTOUR" );
834 createGeomAction( 607, "SUPPRESS_INT_WIRES" );
835 createGeomAction( 608, "POINT_ON_EDGE" );
836 createGeomAction( 609, "CHECK_FREE_BNDS" );
837 createGeomAction( 610, "CHECK_FREE_FACES" );
838 createGeomAction( 611, "CHANGE_ORIENTATION" );
839 createGeomAction( 612, "REMOVE_EXTRA_EDGES" );
841 createGeomAction( 708, "POINT_COORDS" );
842 createGeomAction( 701, "BASIC_PROPS" );
843 createGeomAction( 702, "MASS_CENTER" );
844 createGeomAction( 703, "INERTIA" );
845 createGeomAction( 704, "NORMALE" );
846 createGeomAction( 7041, "BND_BOX" );
847 createGeomAction( 7042, "MIN_DIST" );
848 createGeomAction( 7043, "MEASURE_ANGLE" );
850 createGeomAction( 705, "TOLERANCE" );
851 createGeomAction( 706, "WHAT_IS" );
852 createGeomAction( 707, "CHECK" );
853 createGeomAction( 7072, "CHECK_COMPOUND" );
855 #ifdef _DEBUG_ // PAL16821
856 createGeomAction( 5103, "CHECK_GEOMETRY" );
858 createGeomAction( 412, "SHADING_COLOR" );
860 createGeomAction( 211, "SHADING" );
861 createGeomAction( 212, "DISPLAY_ALL" );
862 createGeomAction( 214, "ERASE_ALL" );
863 createGeomAction( 216, "DISPLAY" );
864 createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true );
865 createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true );
866 createGeomAction( 2173, "WIRE_SEL_ONLY", "", 0, true );
867 createGeomAction( 2174, "FACE_SEL_ONLY", "", 0, true );
868 createGeomAction( 2175, "SHELL_SEL_ONLY", "", 0, true );
869 createGeomAction( 2176, "SOLID_SEL_ONLY", "", 0, true );
870 createGeomAction( 2177, "COMPOUND_SEL_ONLY", "", 0, true );
871 createGeomAction( 2178, "ALL_SEL_ONLY", "", 0, true );
872 createGeomAction( 213, "DISPLAY_ONLY" );
873 createGeomAction( 215, "ERASE" );
875 createGeomAction( 901, "POP_RENAME", "", Qt::Key_F2 );
876 createGeomAction( 80311, "POP_WIREFRAME", "", 0, true );
877 createGeomAction( 80312, "POP_SHADING", "", 0, true );
878 createGeomAction( 8032, "POP_COLOR" );
879 createGeomAction( 8033, "POP_TRANSPARENCY" );
880 createGeomAction( 8034, "POP_ISOS" );
881 createGeomAction( 8035, "POP_AUTO_COLOR" );
882 createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" );
883 createGeomAction( 8001, "POP_CREATE_GROUP" );
885 // make wireframe-shading items to be exclusive (only one at a time is selected)
886 //QActionGroup* dispModeGr = new QActionGroup( this, "", true );
887 //dispModeGr->add( action( 80311 ) );
888 //dispModeGr->add( action( 80312 ) );
889 // ---- create menu --------------------------
891 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
892 createMenu( separator(), fileId, 10 );
893 createMenu( 111, fileId, 10 );
894 createMenu( 121, fileId, 10 );
895 createMenu( separator(), fileId, -1 );
897 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
898 createMenu( 33, editId, -1 );
900 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
902 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
903 createMenu( 4011, basicId, -1 );
904 createMenu( 4012, basicId, -1 );
905 createMenu( 4013, basicId, -1 );
906 createMenu( 4014, basicId, -1 );
907 createMenu( 4015, basicId, -1 );
908 createMenu( 4019, basicId, -1 );
909 createMenu( separator(), basicId, -1 );
910 createMenu( 4016, basicId, -1 );
911 createMenu( 4017, basicId, -1 );
912 createMenu( 4018, basicId, -1 );
913 createMenu( 4020, basicId, -1 );
915 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
916 createMenu( 4021, primId, -1 );
917 createMenu( 4022, primId, -1 );
918 createMenu( 4023, primId, -1 );
919 createMenu( 4024, primId, -1 );
920 createMenu( 4025, primId, -1 );
921 createMenu( 4026, primId, -1 );
922 createMenu( 4027, primId, -1 );
924 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
925 createMenu( 4031, genId, -1 );
926 createMenu( 4032, genId, -1 );
927 createMenu( 4033, genId, -1 );
928 createMenu( 4034, genId, -1 );
929 createMenu( separator(), newEntId, -1 );
931 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
932 createMenu( 800, groupId, -1 );
933 createMenu( 801, groupId, -1 );
934 createMenu( separator(), newEntId, -1 );
936 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
937 createMenu( 9997, blocksId, -1 );
938 createMenu( 9999, blocksId, -1 );
940 createMenu( separator(), newEntId, -1 );
941 createMenu( 404, newEntId, -1 );
942 createMenu( separator(), newEntId, -1 );
943 createMenu( 407, newEntId, -1 );
945 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
946 createMenu( 4081, buildId, -1 );
947 createMenu( 4082, buildId, -1 );
948 createMenu( 4083, buildId, -1 );
949 createMenu( 4084, buildId, -1 );
950 createMenu( 4085, buildId, -1 );
951 createMenu( 4086, buildId, -1 );
953 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
955 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
956 createMenu( 5011, boolId, -1 );
957 createMenu( 5012, boolId, -1 );
958 createMenu( 5013, boolId, -1 );
959 createMenu( 5014, boolId, -1 );
961 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
962 createMenu( 5021, transId, -1 );
963 createMenu( 5022, transId, -1 );
964 createMenu( 5023, transId, -1 );
965 createMenu( 5024, transId, -1 );
966 createMenu( 5025, transId, -1 );
967 createMenu( 5026, transId, -1 );
968 createMenu( separator(), transId, -1 );
969 createMenu( 5027, transId, -1 );
970 createMenu( 5028, transId, -1 );
972 createMenu( 503, operId, -1 );
973 createMenu( 504, operId, -1 );
974 createMenu( 508, operId, -1 );
975 createMenu( separator(), operId, -1 );
976 createMenu( 505, transId, -1 );
977 createMenu( 506, transId, -1 );
978 //createMenu( 507, transId, -1 );
980 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
981 createMenu( 9998, blockId, -1 );
982 createMenu( 9995, blockId, -1 );
983 createMenu( 99991, blockId, -1 );
985 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
986 createMenu( 605, repairId, -1 );
987 createMenu( 603, repairId, -1 );
988 createMenu( 606, repairId, -1 );
989 createMenu( 607, repairId, -1 );
990 createMenu( 604, repairId, -1 );
991 createMenu( 601, repairId, -1 );
992 createMenu( 602, repairId, -1 );
993 createMenu( 608, repairId, -1 );
994 //createMenu( 609, repairId, -1 );
995 //createMenu( 610, repairId, -1 );
996 createMenu( 611, repairId, -1 );
997 createMenu( 612, repairId, -1 );
999 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1000 createMenu( 708, measurId, -1 );
1001 createMenu( 701, measurId, -1 );
1002 createMenu( separator(), measurId, -1 );
1003 createMenu( 702, measurId, -1 );
1004 createMenu( 703, measurId, -1 );
1005 createMenu( 704, measurId, -1 );
1006 // NPAL16572: move "Check free boundaries" and "Check free faces" from "Repair" to "Measure"
1007 createMenu( separator(), measurId, -1 );
1008 createMenu( 609, measurId, -1 );
1009 createMenu( 610, measurId, -1 );
1011 createMenu( separator(), measurId, -1 );
1013 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1014 createMenu( 7041, dimId, -1 );
1015 createMenu( 7042, dimId, -1 );
1016 createMenu( 7043, dimId, -1 );
1017 createMenu( separator(), measurId, -1 );
1019 createMenu( 705, measurId, -1 );
1020 createMenu( separator(), measurId, -1 );
1021 createMenu( 706, measurId, -1 );
1022 createMenu( 707, measurId, -1 );
1023 createMenu( 7072, measurId, -1 );
1025 #ifdef _DEBUG_ // PAL16821
1026 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1027 createMenu( separator(), toolsId, -1 );
1028 createMenu( 5103, toolsId, -1 );
1030 //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 );
1031 //createMenu( separator(), prefId, -1 );
1032 //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 );
1033 //createMenu( 412, geomId, -1 );
1034 //createMenu( separator(), prefId, -1 );
1036 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1037 createMenu( separator(), viewId, -1 );
1039 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1040 createMenu( 211, dispmodeId, -1 );
1042 createMenu( separator(), viewId, -1 );
1043 createMenu( 212, viewId, -1 );
1044 createMenu( 214, viewId, -1 );
1045 createMenu( separator(), viewId, -1 );
1049 because of these items are accessible through object browser and viewers
1050 we have removed they from main menu
1052 createMenu( 216, viewId, -1 );
1053 createMenu( 213, viewId, -1 );
1054 createMenu( 215, viewId, -1 );
1057 // ---- create toolbars --------------------------
1059 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1060 createTool( 4011, basicTbId );
1061 createTool( 4012, basicTbId );
1062 createTool( 4013, basicTbId );
1063 createTool( 4014, basicTbId );
1064 createTool( 4015, basicTbId );
1065 createTool( 4019, basicTbId );
1066 createTool( 4016, basicTbId );
1067 createTool( 4017, basicTbId );
1068 createTool( 4018, basicTbId );
1069 createTool( 4020, basicTbId );
1071 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1072 createTool( 4021, primTbId );
1073 createTool( 4022, primTbId );
1074 createTool( 4023, primTbId );
1075 createTool( 4024, primTbId );
1076 createTool( 4025, primTbId );
1077 createTool( 4026, primTbId );
1078 createTool( 4027, primTbId );
1080 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1081 createTool( 5011, boolTbId );
1082 createTool( 5012, boolTbId );
1083 createTool( 5013, boolTbId );
1084 createTool( 5014, boolTbId );
1086 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1087 createTool( 4031, genTbId );
1088 createTool( 4032, genTbId );
1089 createTool( 4033, genTbId );
1090 createTool( 4034, genTbId );
1092 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1093 createTool( 5021, transTbId );
1094 createTool( 5022, transTbId );
1095 createTool( 5023, transTbId );
1096 createTool( 5024, transTbId );
1097 createTool( 5025, transTbId );
1098 createTool( 5026, transTbId );
1099 createTool( separator(), transTbId );
1100 createTool( 5027, transTbId );
1101 createTool( 5028, transTbId );
1103 // ---- create popup menus --------------------------
1105 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1106 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1108 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1109 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1111 QString autoColorPrefix =
1112 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1114 QtxPopupMgr* mgr = popupMgr();
1115 mgr->insert( action( 901 ), -1, -1 ); // rename
1116 mgr->setRule( action( 901 ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
1117 mgr->insert( action( 33 ), -1, -1 ); // delete
1118 mgr->setRule( action( 33 ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1119 mgr->insert( action( 8001 ), -1, -1 ); // create group
1120 mgr->setRule( action( 8001 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1121 mgr->insert( action( 801 ), -1, -1 ); // edit group
1122 mgr->setRule( action( 801 ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1123 mgr->insert( separator(), -1, -1 ); // -----------
1124 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1125 mgr->insert( action( 80311 ), dispmodeId, -1 ); // wireframe
1126 mgr->setRule( action( 80311 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1127 mgr->setRule( action( 80311 ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1128 mgr->insert( action( 80312 ), dispmodeId, -1 ); // shading
1129 mgr->setRule( action( 80312 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1130 mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1131 mgr->insert( separator(), -1, -1 ); // -----------
1132 mgr->insert( action( 8032 ), -1, -1 ); // color
1133 mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1134 mgr->insert( action( 8033 ), -1, -1 ); // transparency
1135 mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1136 mgr->insert( action( 8034 ), -1, -1 ); // isos
1137 mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1138 mgr->insert( separator(), -1, -1 ); // -----------
1139 mgr->insert( action( 8035 ), -1, -1 ); // auto color
1140 mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1141 mgr->insert( action( 8036 ), -1, -1 ); // disable auto color
1142 mgr->setRule( action( 8036 ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1143 mgr->insert( separator(), -1, -1 ); // -----------
1146 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1147 onlyComponent = "((type='Component') and selcount=1)",
1148 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1149 types = "'Shape' 'Group'";
1151 mgr->insert( action( 216 ), -1, -1 ); // display
1152 mgr->setRule( action( 216 ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1154 mgr->insert( action( 215 ), -1, -1 ); // erase
1155 mgr->setRule( action( 215 ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1157 mgr->insert( action( 214 ), -1, -1 ); // erase All
1158 mgr->setRule( action( 214 ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1160 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1162 int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1163 mgr->insert( action(2171), selectolnyId, -1); //Vertex
1164 mgr->setRule(action(2171), selectOnly, QtxPopupMgr::VisibleRule);
1165 mgr->setRule(action(2171), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1166 mgr->insert( action(2172), selectolnyId, -1); //Edge
1167 mgr->setRule(action(2172), selectOnly, QtxPopupMgr::VisibleRule);
1168 mgr->setRule(action(2172), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1169 mgr->insert( action(2173), selectolnyId, -1); //Wire
1170 mgr->setRule(action(2173), selectOnly, QtxPopupMgr::VisibleRule);
1171 mgr->setRule(action(2173), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1172 mgr->insert( action(2174), selectolnyId, -1); //Face
1173 mgr->setRule(action(2174), selectOnly, QtxPopupMgr::VisibleRule);
1174 mgr->setRule(action(2174), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1175 mgr->insert( action(2175), selectolnyId, -1); //Shell
1176 mgr->setRule(action(2175), selectOnly, QtxPopupMgr::VisibleRule);
1177 mgr->setRule(action(2175), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1178 mgr->insert( action(2176), selectolnyId, -1); //Solid
1179 mgr->setRule(action(2176), selectOnly, QtxPopupMgr::VisibleRule);
1180 mgr->setRule(action(2176), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1181 mgr->insert( action(2177), selectolnyId, -1); //Compound
1182 mgr->setRule(action(2177), selectOnly, QtxPopupMgr::VisibleRule);
1183 mgr->setRule(action(2177), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1184 mgr->insert( separator(), selectolnyId, -1);
1185 mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter
1186 mgr->setRule(action(2178), selectOnly, QtxPopupMgr::VisibleRule);
1187 mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1188 mgr->insert( action( 213 ), -1, -1 ); // display only
1189 mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1190 mgr->insert( separator(), -1, -1 );
1192 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1195 //=======================================================================
1196 // function : GeometryGUI::activateModule()
1197 // purpose : Called when GEOM module is activated
1198 //=======================================================================
1199 bool GeometryGUI::activateModule( SUIT_Study* study )
1201 if ( CORBA::is_nil( myComponentGeom ) )
1204 bool res = SalomeApp_Module::activateModule( study );
1209 setMenuShown( true );
1210 setToolShown( true );
1212 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1213 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1215 // Reset actions accelerator keys
1216 //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import
1217 //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export
1218 action(111)->setEnabled( true ); // Import: CTRL + Key_I
1219 action(121)->setEnabled( true ); // Export: CTRL + Key_E
1220 action( 33)->setEnabled( true ); // Delete: Key_Delete
1221 action(901)->setEnabled( true ); // Rename: Key_F2
1223 GUIMap::Iterator it;
1224 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1225 it.value()->activate( application()->desktop() );
1227 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1229 SUIT_ViewManager* vm;
1230 ViewManagerList OCCViewManagers, VTKViewManagers;
1232 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1233 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1234 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1235 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1237 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1238 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1239 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1240 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1243 SALOME_ListIO selected;
1244 sm->selectedObjects( selected );
1245 sm->clearSelected();
1247 // disable OCC selectors
1248 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1249 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1250 while ( itOCCSel.hasNext() )
1251 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1252 sr->setEnabled(true);
1254 // disable VTK selectors
1255 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1256 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1257 while ( itVTKSel.hasNext() )
1258 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1259 sr->setEnabled(true);
1261 sm->setSelectedObjects( selected, true ); //NPAL 19674
1267 //=======================================================================
1268 // function : GeometryGUI::deactivateModule()
1269 // purpose : Called when GEOM module is deactivated
1270 //=======================================================================
1271 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1273 setMenuShown( false );
1274 setToolShown( false );
1276 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1277 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1279 EmitSignalCloseAllDialogs();
1281 GUIMap::Iterator it;
1282 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1283 it.value()->deactivate();
1285 // Unset actions accelerator keys
1286 //action(111)->setAccel(QKeySequence()); // Import
1287 //action(121)->setAccel(QKeySequence()); // Export
1288 action(111)->setEnabled( false ); // Import: CTRL + Key_I
1289 action(121)->setEnabled( false ); // Export: CTRL + Key_E
1290 action( 33)->setEnabled( false ); // Delete: Key_Delete
1291 action(901)->setEnabled( false ); // Rename: Key_F2
1293 qDeleteAll(myOCCSelectors);
1294 myOCCSelectors.clear();
1295 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1297 qDeleteAll(myVTKSelectors);
1298 myVTKSelectors.clear();
1299 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1301 return SalomeApp_Module::deactivateModule( study );
1304 //=======================================================================
1305 // function : GeometryGUI::BuildPresentation()
1307 //=======================================================================
1308 void GeometryGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& io, SUIT_ViewWindow* win )
1310 //GEOM_Displayer().Display( io, false, win );
1313 //=======================================================================
1314 // function : onWindowActivated()
1315 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1316 //=======================================================================
1317 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1322 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1323 //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1325 // disable non-OCC viewframe menu commands
1326 // action( 404 )->setEnabled( ViewOCC ); // SKETCHER
1327 action( 603 )->setEnabled( ViewOCC ); // SuppressFace
1328 action( 604 )->setEnabled( ViewOCC ); // SuppressHole
1329 action( 606 )->setEnabled( ViewOCC ); // CloseContour
1330 action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires
1331 action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
1332 // action( 609 )->setEnabled( ViewOCC ); // Free boundaries
1334 action( 800 )->setEnabled( ViewOCC ); // Create Group
1335 action( 801 )->setEnabled( ViewOCC ); // Edit Group
1337 action( 9998 )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1340 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1342 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1343 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1346 void GeometryGUI::viewManagers( QStringList& lst ) const
1348 lst.append( OCCViewer_Viewer::Type() );
1351 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1353 if ( vm->getType() == OCCViewer_Viewer::Type() )
1355 qDebug( "connect" );
1356 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1357 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1358 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1359 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1360 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1361 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1364 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1365 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1367 // disable OCC selectors
1368 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1369 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1370 while ( itOCCSel.hasNext() )
1371 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1372 sr->setEnabled(true);
1374 else if ( vm->getType() == SVTK_Viewer::Type() )
1376 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1377 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1379 // disable VTK selectors
1380 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1381 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1382 while ( itVTKSel.hasNext() )
1383 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1384 sr->setEnabled(true);
1388 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1390 SUIT_ViewModel* viewer = vm->getViewModel();
1391 if ( vm->getType() == OCCViewer_Viewer::Type() )
1393 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1394 while ( itOCCSel.hasNext() )
1395 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1396 if ( sr->viewer() == viewer )
1398 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1402 if ( vm->getType() == SVTK_Viewer::Type() )
1404 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1405 while ( itVTKSel.hasNext() )
1406 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1407 if ( sr->viewer() == viewer )
1409 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1415 QString GeometryGUI::engineIOR() const
1417 if ( !CORBA::is_nil( GetGeomGen() ) )
1418 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1422 LightApp_Selection* GeometryGUI::createSelection() const
1424 return new GEOMGUI_Selection();
1427 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1429 SalomeApp_Module::contextMenuPopup( client, menu, title );
1431 getApp()->selectionMgr()->selectedObjects( lst );
1432 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
1433 Handle(SALOME_InteractiveObject) io = lst.First();
1434 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1435 _PTR(Study) study = appStudy->studyDS();
1436 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
1438 title = QString( obj->GetName().c_str() );
1442 void GeometryGUI::createPreferences()
1444 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1446 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1447 setPreferenceProperty( genGroup, "columns", 2 );
1449 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1450 LightApp_Preferences::Selector,
1451 "Geometry", "display_mode" );
1453 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1454 LightApp_Preferences::Color, "Geometry", "shading_color" );
1456 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1457 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1459 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1460 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1462 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1463 LightApp_Preferences::Color, "Geometry", "line_color" );
1465 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1466 LightApp_Preferences::Color, "Geometry", "point_color" );
1468 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1469 LightApp_Preferences::Color, "Geometry", "isos_color" );
1471 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1472 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1474 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1475 setPreferenceProperty( VertexGroup, "columns", 2 );
1477 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1478 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1480 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1481 LightApp_Preferences::DblSpin, "Geometry", "marker_scale" );
1483 // Set property for default display mode
1484 QStringList aModesList;
1485 aModesList.append( tr("MEN_WIREFRAME") );
1486 aModesList.append( tr("MEN_SHADING") );
1488 QList<QVariant> anIndexesList;
1489 anIndexesList.append(0);
1490 anIndexesList.append(1);
1492 setPreferenceProperty( dispmode, "strings", aModesList );
1493 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1495 // Set property for step value for spinboxes
1496 setPreferenceProperty( step, "min", 1 );
1497 setPreferenceProperty( step, "max", 10000 );
1498 setPreferenceProperty( step, "precision", 3 );
1500 // Set property for type of vertex marker
1501 QStringList aTypeOfMarkerList;
1502 QList<QVariant> anTypeOfMarkerIndexesList;
1504 aTypeOfMarkerList.append( tr("TOM_PLUS") );
1505 anTypeOfMarkerIndexesList.append(Aspect_TOM_PLUS);
1507 aTypeOfMarkerList.append( tr("TOM_POINT") );
1508 anTypeOfMarkerIndexesList.append(Aspect_TOM_POINT);
1510 aTypeOfMarkerList.append( tr("TOM_STAR") );
1511 anTypeOfMarkerIndexesList.append(Aspect_TOM_STAR);
1513 aTypeOfMarkerList.append( tr("TOM_O") );
1514 anTypeOfMarkerIndexesList.append(Aspect_TOM_O);
1516 aTypeOfMarkerList.append( tr("TOM_X") );
1517 anTypeOfMarkerIndexesList.append(Aspect_TOM_X);
1519 aTypeOfMarkerList.append( tr("TOM_O_POINT") );
1520 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_POINT);
1522 aTypeOfMarkerList.append( tr("TOM_O_PLUS") );
1523 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_PLUS);
1525 aTypeOfMarkerList.append( tr("TOM_O_STAR") );
1526 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_STAR);
1528 aTypeOfMarkerList.append( tr("TOM_O_X") );
1529 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_X);
1532 setPreferenceProperty( typeOfMarker, "strings", aTypeOfMarkerList );
1533 setPreferenceProperty( typeOfMarker, "indexes", anTypeOfMarkerIndexesList );
1535 // Set property for Vertex Marker scale
1536 setPreferenceProperty( markerScale, "min", 1. );
1537 setPreferenceProperty( markerScale, "max", 7. );
1538 setPreferenceProperty( markerScale, "precision", 0.01 );
1539 setPreferenceProperty( markerScale, "step", 0.5 );
1543 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1545 if (section == "Geometry") {
1546 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1547 if (param == QString("SettingsGeomStep")) {
1548 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1549 EmitSignalDefaultStepValueChanged(spin_step);
1554 LightApp_Displayer* GeometryGUI::displayer()
1557 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1561 void GeometryGUI::setLocalSelectionMode(const int mode)
1563 myLocalSelectionMode = mode;
1565 int GeometryGUI::getLocalSelectionMode() const
1567 return myLocalSelectionMode;
1570 const char gSeparator = '_'; // character used to separate parameter names
1571 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1574 * \brief Store visual parameters
1576 * This method is called just before the study document is saved.
1577 * Store visual parameters in AttributeParameter attribue(s)
1579 void GeometryGUI::storeVisualParameters (int savePoint)
1581 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1582 if (!appStudy || !appStudy->studyDS())
1584 _PTR(Study) studyDS = appStudy->studyDS();
1586 // componentName is used for encoding of entries when storing them in IParameters
1587 std::string componentName = myComponentGeom->ComponentDataType();
1588 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1589 //if (!aSComponent) return;
1592 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1593 componentName.c_str(),
1595 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1597 // viewers counters are used for storing view_numbers in IParameters
1598 int vtkViewers(0), occViewers(0);
1600 QList<SUIT_ViewManager*> lst;
1601 QList<SUIT_ViewManager*>::Iterator it;
1603 // main cycle to store parameters of displayed objects
1605 vtkViewers = occViewers = 0;
1606 getApp()->viewManagers(lst);
1607 for (it = lst.begin(); it != lst.end(); it++)
1609 SUIT_ViewManager* vman = *it;
1610 QString vType = vman->getType();
1612 // saving VTK actors properties
1613 if (vType == SVTK_Viewer::Type())
1615 QVector<SUIT_ViewWindow*> views = vman->getViews();
1616 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
1618 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
1620 vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
1621 allActors->InitTraversal();
1622 while (vtkActor* actor = allActors->GetNextActor())
1624 if (actor->GetVisibility()) // store only visible actors
1626 GEOM_Actor* aGeomActor = 0;
1627 if (actor->IsA("GEOM_Actor"))
1628 aGeomActor = GEOM_Actor::SafeDownCast(actor);
1629 if (aGeomActor && aGeomActor->hasIO())
1631 Handle(SALOME_InteractiveObject) io = aGeomActor->getIO();
1634 // entry is "encoded" = it does NOT contain component adress, since it is a
1635 // subject to change on next component loading
1636 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
1638 std::string param, occParam = vType.toLatin1().data();
1639 occParam += gSeparator;
1640 occParam += QString::number(vtkViewers).toLatin1().data();
1641 occParam += gSeparator;
1643 param = occParam + "Visibility";
1644 ip->setParameter(entry, param, "On");
1646 param = occParam + "DisplayMode";
1647 ip->setParameter(entry, param, QString::number
1648 (aGeomActor->getDisplayMode()).toLatin1().data());
1650 vtkFloatingPointType r, g, b;
1651 aGeomActor->GetColor(r, g, b);
1652 QString colorStr = QString::number(r);
1653 colorStr += gDigitsSep; colorStr += QString::number(g);
1654 colorStr += gDigitsSep; colorStr += QString::number(b);
1655 param = occParam + "Color";
1656 ip->setParameter(entry, param, colorStr.toLatin1().data());
1658 param = occParam + "Opacity";
1659 ip->setParameter(entry, param, QString::number(aGeomActor->GetOpacity()).toLatin1().data());
1661 int nbUIso(0), nbVIso(0);
1662 aGeomActor->GetNbIsos(nbUIso,nbVIso);
1663 QString isosStr = QString::number(nbUIso);
1664 isosStr += gDigitsSep;
1665 isosStr += QString::number(nbVIso);
1666 param = occParam + "Isos";
1667 ip->setParameter(entry, param, isosStr.toLatin1().data());
1668 } // if (io->hasEntry())
1669 } // GEOM_Actor && hasIO
1671 } // while.. actors traversal
1675 } // if (SVTK view model)
1676 else if (vType == SOCC_Viewer::Type()) // processing OCC viewers
1678 QVector<SUIT_ViewWindow*> views = vman->getViews();
1679 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
1681 SOCC_ViewWindow* occView = dynamic_cast<SOCC_ViewWindow*>(views[i]);
1684 //Handle(AIS_InteractiveContext) ic =
1685 // ((OCCViewer_Viewer*)(occView->getViewManager()->getViewModel()))->getAISContext();
1686 OCCViewer_Viewer* viewModel = (OCCViewer_Viewer*)(vman->getViewModel());
1687 //OCCViewer_Viewer* viewModel = ((OCCViewer_ViewManager*)vman)->getOCCViewer();
1688 Handle(AIS_InteractiveContext) ic = viewModel->getAISContext();
1690 AIS_ListOfInteractive aList;
1691 ic->DisplayedObjects(aList);
1693 AIS_ListIteratorOfListOfInteractive ite (aList);
1694 for (; ite.More(); ite.Next())
1696 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
1698 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
1701 Handle(SALOME_InteractiveObject) io =
1702 Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
1705 // entry is "encoded": it does NOT contain component adress,
1706 // since it is a subject to change on next component loading
1707 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
1709 std::string param, occParam = vType.toLatin1().data();
1710 occParam += gSeparator;
1711 occParam += QString::number(occViewers).toLatin1().data();
1712 occParam += gSeparator;
1715 param = occParam + "Visibility";
1716 ip->setParameter(entry, param, "On");
1719 param = occParam + "DisplayMode";
1720 int dm = aSh->DisplayMode();
1721 ip->setParameter(entry, param, QString::number(dm).toLatin1().data());
1724 // is a property of GEOM_Object, it is stored by GEOM engine
1727 param = occParam + "Transparency";
1728 ip->setParameter(entry, param, QString::number(aSh->Transparency()).toLatin1().data());
1731 Handle(AIS_Drawer) aDrawer = aSh->Attributes();
1732 int nbUIso = aDrawer->UIsoAspect()->Number();
1733 int nbVIso = aDrawer->VIsoAspect()->Number();
1734 QString isosStr = QString::number(nbUIso);
1735 isosStr += gDigitsSep;
1736 isosStr += QString::number(nbVIso);
1737 param = occParam + "Isos";
1738 ip->setParameter(entry, param, isosStr.toLatin1().data());
1739 } // if (io->hasEntry())
1741 } // if (GEOM_AISShape)
1742 } // for (AIS_ListOfInteractive)
1746 } // if (SOCC view model)
1749 // unknown viewer type
1751 } // for (viewManagers)
1755 * \brief Restore visual parameters
1757 * This method is called after the study document is opened.
1758 * Restore visual parameters from AttributeParameter attribue(s)
1760 void GeometryGUI::restoreVisualParameters (int savePoint)
1762 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1763 if (!appStudy || !appStudy->studyDS())
1765 _PTR(Study) studyDS = appStudy->studyDS();
1767 // componentName is used for encoding of entries when storing them in IParameters
1768 std::string componentName = myComponentGeom->ComponentDataType();
1769 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1770 //if (!aSComponent) return;
1773 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1774 componentName.c_str(),
1776 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1778 std::vector<std::string> entries = ip->getEntries();
1780 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
1782 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1783 QString entry (ip->decodeEntry(*entIt).c_str());
1785 // Check that the entry corresponds to a real object in the Study
1786 // as the object may be deleted or modified after the visual state is saved.
1787 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1788 if (!so) continue; //Skip the not existent entry
1790 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1791 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1793 std::vector<std::string>::iterator namesIt = paramNames.begin();
1794 std::vector<std::string>::iterator valuesIt = paramValues.begin();
1796 // actors are stored in a map after displaying of them for
1797 // quicker access in the future: map < viewID to actor >
1798 NCollection_DataMap<int, GEOM_Actor* > vtkActors;
1799 NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
1801 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
1803 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
1804 // '_' is used as separator and should not be used in viewer type or parameter names.
1805 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
1806 if (lst.size() != 3)
1809 QString viewerTypStr = lst[0];
1810 QString viewIndexStr = lst[1];
1811 QString paramNameStr = lst[2];
1814 int viewIndex = viewIndexStr.toUInt(&ok);
1815 if (!ok) // bad conversion of view index to integer
1819 if (viewerTypStr == SVTK_Viewer::Type())
1821 GEOM_Actor* vActor = 0;
1822 if (vtkActors.IsBound(viewIndex))
1823 vActor = vtkActors.Find(viewIndex);
1825 if (paramNameStr == "Visibility")
1827 if (!vActor && displayer())
1829 QList<SUIT_ViewManager*> lst;
1830 getApp()->viewManagers(viewerTypStr, lst);
1832 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
1833 if (viewIndex >= 0 && viewIndex < lst.count()) {
1834 SUIT_ViewManager* vman = lst.at(viewIndex);
1835 SUIT_ViewModel* vmodel = vman->getViewModel();
1836 // SVTK view model can be casted to SALOME_View
1837 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
1839 // store displayed actor in a temporary map for quicker
1840 // access later when restoring other parameters
1841 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
1842 vtkRenderer* Renderer = vtkView->getRenderer();
1843 vtkActorCollection* theActors = Renderer->GetActors();
1844 theActors->InitTraversal();
1845 bool isFound = false;
1846 vtkActor *ac = theActors->GetNextActor();
1847 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
1848 if (ac->IsA("GEOM_Actor")) {
1849 GEOM_Actor* aGeomAc = GEOM_Actor::SafeDownCast(ac);
1850 if (aGeomAc->hasIO()) {
1851 Handle(SALOME_InteractiveObject) io =
1852 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
1853 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
1855 vtkActors.Bind(viewIndex, aGeomAc);
1862 } // if (paramNameStr == "Visibility")
1865 // the rest properties "work" with GEOM_Actor
1868 QString val ((*valuesIt).c_str());
1870 if (paramNameStr == "DisplayMode") {
1871 vActor->setDisplayMode(val.toInt());
1873 else if (paramNameStr == "Color") {
1874 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
1875 if (colors.count() == 3)
1876 vActor->SetColor(colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat());
1878 else if (paramNameStr == "Opacity") {
1879 vActor->SetOpacity(val.toFloat());
1881 else if (paramNameStr == "Isos") {
1882 QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
1883 if (isos.count() == 2) {
1884 int aIsos[2] = {isos[0].toInt(), isos[1].toInt()};
1885 vActor->SetNbIsos(aIsos);
1889 } // other parameters than Visibility
1891 else if (viewerTypStr == SOCC_Viewer::Type())
1893 //Handle(AIS_InteractiveObject) occActor;
1894 Handle(GEOM_AISShape) occActor;
1895 if (occActors.IsBound(viewIndex))
1896 occActor = occActors.Find(viewIndex);
1898 // ViewModel and InteractiveContext
1899 SOCC_Viewer* occVModel = 0;
1900 Handle(AIS_InteractiveContext) ic;
1902 QList<SUIT_ViewManager*> lst;
1903 getApp()->viewManagers(viewerTypStr, lst);
1905 // SOCC ViewManager always has 1 ViewWindow, so view index is index of view manager
1906 if (viewIndex >= 0 && viewIndex < lst.count()) {
1907 SUIT_ViewManager* vman = lst.at(viewIndex);
1908 SUIT_ViewModel* vmodel = vman->getViewModel();
1909 occVModel = dynamic_cast<SOCC_Viewer*>(vmodel);
1911 ic = occVModel->getAISContext();
1917 if (paramNameStr == "Visibility")
1919 if (occActor.IsNull() && displayer())
1921 displayer()->Display(entry, true, occVModel);
1923 // store displayed actor in a temporary map for quicker
1924 // access later when restoring other parameters
1925 AIS_ListOfInteractive aList;
1926 ic->DisplayedObjects(aList);
1927 bool isFound = false;
1928 AIS_ListIteratorOfListOfInteractive ite (aList);
1929 for (; ite.More() && !isFound; ite.Next()) {
1930 if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
1931 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
1933 Handle(SALOME_InteractiveObject) io =
1934 Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
1935 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
1937 occActors.Bind(viewIndex, aSh);
1943 } // if (paramNameStr == "Visibility")
1946 // the rest properties "work" with GEOM_AISShape
1947 if (!occActor.IsNull())
1949 QString val ((*valuesIt).c_str());
1951 if (paramNameStr == "DisplayMode") {
1952 ic->SetDisplayMode(occActor, AIS_DisplayMode(val.toInt()), false);
1953 //ic->Redisplay(occActor, Standard_False, Standard_True);
1955 // Color is restored by the GEOM engine
1956 else if (paramNameStr == "Transparency") {
1957 ic->SetTransparency(occActor, val.toFloat(), false);
1958 ic->Redisplay(occActor, Standard_False, Standard_True);
1960 else if (paramNameStr == "Isos") {
1961 QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
1962 if (isos.count() == 2) {
1963 Handle(AIS_Drawer) aDrawer = occActor->Attributes();
1964 int nbUIso = isos[0].toInt();
1965 int nbVIso = isos[1].toInt();
1966 Handle(Prs3d_IsoAspect) uIsoAspect = aDrawer->UIsoAspect();
1967 Handle(Prs3d_IsoAspect) vIsoAspect = aDrawer->VIsoAspect();
1968 uIsoAspect->SetNumber(nbUIso);
1969 vIsoAspect->SetNumber(nbVIso);
1970 aDrawer->SetUIsoAspect(uIsoAspect);
1971 aDrawer->SetVIsoAspect(vIsoAspect);
1972 ic->SetLocalAttributes(occActor, aDrawer);
1973 ic->Redisplay(occActor);
1977 } // other parameters than Visibility
1981 // unknown viewer type
1983 } // for names/parameters iterator
1984 } // for entries iterator
1986 // update all VTK and OCC views
1987 QList<SUIT_ViewManager*> lst;
1988 getApp()->viewManagers(lst);
1989 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
1990 SUIT_ViewModel* vmodel = (*it)->getViewModel();
1993 if (vmodel->getType() == SVTK_Viewer::Type()) {
1994 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
1995 vtkView->getRenderer()->ResetCameraClippingRange();
1998 else if (vmodel->getType() == SOCC_Viewer::Type()) {
1999 //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
2000 SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);