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
24 // File : GeometryGUI.cxx
25 // Author : Lucien PIGNOLONI
29 #include "GeometryGUI.h"
30 #include "GEOMGUI_OCCSelector.h"
31 #include "GEOMGUI_Selection.h"
32 #include "GEOM_Displayer.h"
34 #include <SUIT_MessageBox.h>
35 #include <SUIT_ResourceMgr.h>
36 #include <SUIT_Session.h>
37 #include <SUIT_ViewManager.h>
39 #include <OCCViewer_ViewWindow.h>
40 #include <OCCViewer_ViewPort3d.h>
41 #include <OCCViewer_ViewModel.h>
42 #include <OCCViewer_ViewManager.h>
44 #include <SVTK_ViewWindow.h>
45 #include <SVTK_RenderWindowInteractor.h>
46 #include <SVTK_InteractorStyle.h>
47 #include <SVTK_ViewModel.h>
48 #include <SVTK_ViewManager.h>
50 #include <SalomeApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
52 #include <LightApp_VTKSelector.h>
53 #include <LightApp_DataObject.h>
54 #include <SalomeApp_Study.h>
55 #include <LightApp_Preferences.h>
56 #include <SALOME_LifeCycleCORBA.hxx>
57 #include <SALOME_ListIO.hxx>
58 #include <SALOME_ListIteratorOfListIO.hxx>
61 #include <qfileinfo.h>
64 #include <Prs3d_Drawer.hxx>
65 #include <Prs3d_IsoAspect.hxx>
66 #include <Aspect_TypeOfMarker.hxx>
67 #include <OSD_SharedLibrary.hxx>
69 #include <utilities.h>
71 #include <vtkCamera.h>
72 #include <vtkRenderer.h>
74 #include "GEOMImpl_Types.hxx"
77 Standard_EXPORT CAM_Module* createModule() {
78 return new GeometryGUI();
84 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
86 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
88 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
89 if (CORBA::is_nil(myComponentGeom))
91 return GeometryGUI::myComponentGeom;
94 bool GeometryGUI::InitGeomGen()
97 if( CORBA::is_nil( myComponentGeom ) ) return false;
101 //=======================================================================
102 // function : ClientSObjectToObject
104 //=======================================================================
105 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
107 _PTR(GenericAttribute) anAttr;
108 CORBA::Object_var anObj;
110 std::string aValue = theSObject->GetIOR();
111 if (strcmp(aValue.c_str(), "") != 0) {
112 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
113 anObj = anORB->string_to_object(aValue.c_str());
116 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
118 return anObj._retn();
121 //=======================================================================
122 // function : ClientStudyToStudy
124 //=======================================================================
125 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
127 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
128 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
129 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
130 int aStudyID = theStudy->StudyId();
131 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
132 return aDSStudy._retn();
135 //=================================================================================
136 // class : CustomItem
137 // purpose : Set Font to a text.
138 //=================================================================================
139 class CustomItem : public QCustomMenuItem
142 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
145 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
148 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
149 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
150 p->setFont( myFont );
151 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
157 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
160 bool fullSpan() const
170 //=======================================================================
171 // function : GeometryGUI::GeometryGUI()
172 // purpose : Constructor
173 //=======================================================================
174 GeometryGUI::GeometryGUI() :
175 SalomeApp_Module( "GEOM" )
177 if ( CORBA::is_nil( myComponentGeom ) )
179 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
180 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "GEOM" );
181 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
185 myActiveDialogBox = 0;
188 gp_Pnt origin = gp_Pnt(0., 0., 0.);
189 gp_Dir direction = gp_Dir(0., 0., 1.);
190 myWorkingPlane = gp_Ax3(origin, direction);
192 myOCCSelectors.setAutoDelete( true );
193 myVTKSelectors.setAutoDelete( true );
196 myLocalSelectionMode = GEOM_ALLOBJECTS;
199 //=======================================================================
200 // function : GeometryGUI::~GeometryGUI()
201 // purpose : Destructor
202 //=======================================================================
203 GeometryGUI::~GeometryGUI()
207 //=======================================================================
208 // function : GeometryGUI::getLibrary()
209 // purpose : get or load GUI library by name [ internal ]
210 //=======================================================================
211 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
212 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
214 if ( !myGUIMap.contains( libraryName ) ) {
215 // try to load library if it is not loaded yet
218 if ( (libs = getenv( "LD_LIBRARY_PATH" )) ) {
219 QStringList dirList = QStringList::split( ":", libs, false ); // skip empty entries
221 if ( (libs = getenv( "PATH" )) ) {
222 QStringList dirList = QStringList::split( ";", libs, false ); // skip empty entries
224 for( int i = dirList.count()-1; i >= 0; i-- ) {
225 QString dir = dirList[ i ];
226 QFileInfo fi( Qtx::addSlash( dirList[ i ] ) + libraryName );
228 OSD_SharedLibrary aSharedLibrary( (char*)fi.fileName().latin1() );
229 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
231 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
232 continue; // continue search further
234 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
235 if ( osdF != NULL ) {
236 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
237 GEOMGUI* libGUI = (*func)(this);
239 myGUIMap[ libraryName ] = libGUI;
240 break; // found and loaded!
247 if ( myGUIMap.contains( libraryName ) )
248 // library is successfully loaded
249 return myGUIMap[ libraryName ];
253 //=======================================================================
254 // function : GeometryGUI::ActiveWorkingPlane()
255 // purpose : Activate Working Plane View
256 //=======================================================================
257 void GeometryGUI::ActiveWorkingPlane()
259 gp_Dir DZ = myWorkingPlane.Direction();
260 gp_Dir DY = myWorkingPlane.YDirection();
262 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
263 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
264 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
267 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
269 Handle(V3d_View) view3d = vw->getViewPort()->getView();
271 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
272 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
278 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
280 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
282 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
283 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
284 camera->SetFocalPoint(0,0,0);
291 //=======================================================================
292 // function : GeometryGUI::SetActiveDialogBox()
293 // purpose : Set active dialog box
294 //=======================================================================
295 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
297 myActiveDialogBox = (QDialog*)aDlg;
300 //=======================================================================
301 // function : GeometryGUI::EmitSignalDeactivateDialog()
302 // purpose : Emit a signal to deactivate the active dialog Box
303 //=======================================================================
304 void GeometryGUI::EmitSignalDeactivateDialog()
306 emit SignalDeactivateActiveDialog();
309 //=======================================================================
310 // function : GeometryGUI::EmitSignalCloseAllDialogs()
311 // purpose : Emit a signal to close all non modal dialogs box
312 //=======================================================================
313 void GeometryGUI::EmitSignalCloseAllDialogs()
315 emit SignalCloseAllDialogs();
318 //=======================================================================
319 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
320 // purpose : Emit a signal to inform that default real spin box step has
322 //=======================================================================
323 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
325 emit SignalDefaultStepValueChanged(newVal);
328 //=======================================================================
329 // function : GeometryGUI::OnGUIEvent()
330 // purpose : common slot for all menu/toolbar actions
331 //=======================================================================
332 void GeometryGUI::OnGUIEvent()
334 const QObject* obj = sender();
335 if ( !obj || !obj->inherits( "QAction" ) )
337 int id = actionId((QAction*)obj);
342 //=======================================================================
343 // function : GeometryGUI::OnGUIEvent()
344 // purpose : manage all events on GUI [static]
345 //=======================================================================
346 void GeometryGUI::OnGUIEvent( int id )
348 SUIT_Application* anApp = application();
350 SUIT_Desktop* desk = anApp->desktop();
352 // check type of the active viewframe
353 SUIT_ViewWindow* window = desk->activeWindow();
354 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
355 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
356 // if current viewframe is not of OCC and not of VTK type - return immediately
357 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
358 bool NotViewerDependentCommand = ( id == 901 || id == 216 || id == 213 );
359 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommand )
362 // fix for IPAL9103, point 2
363 if ( CORBA::is_nil( GetGeomGen() ) ) {
364 SUIT_MessageBox::error1( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
368 GEOMGUI* library = 0;
369 // try to get-or-load corresponding GUI library
370 if( id == 111 || // MENU FILE - IMPORT BREP
371 id == 112 || // MENU FILE - IMPORT IGES
372 id == 113 || // MENU FILE - IMPORT STEP
373 id == 121 || // MENU FILE - EXPORT BREP
374 id == 122 || // MENU FILE - EXPORT IGES
375 id == 123 || // MENU FILE - EXPORT STEP
376 id == 2171 || // POPUP VIEWER - SELECT ONLY - VERTEX
377 id == 2172 || // POPUP VIEWER - SELECT ONLY - EDGE
378 id == 2173 || // POPUP VIEWER - SELECT ONLY - WIRE
379 id == 2174 || // POPUP VIEWER - SELECT ONLY - FACE
380 id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL
381 id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID
382 id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND
383 id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL
384 id == 31 || // MENU EDIT - COPY
385 id == 33 || // MENU EDIT - DELETE
386 id == 411 || // MENU SETTINGS - ADD IN STUDY
387 id == 412 || // MENU SETTINGS - SHADING COLOR
388 id == 5103 || // MENU TOOLS - CHECK GEOMETRY
389 id == 8032 || // POPUP VIEWER - COLOR
390 id == 8033 || // POPUP VIEWER - TRANSPARENCY
391 id == 8034 || // POPUP VIEWER - ISOS
392 id == 8035 || // POPUP VIEWER - AUTO COLOR
393 id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR
394 id == 804 || // POPUP VIEWER - ADD IN STUDY
395 id == 901 || // OBJECT BROWSER - RENAME
396 id == 9024 ) { // OBJECT BROWSER - OPEN
397 //cout << "id " << id << " received" << endl;
399 library = getLibrary( "libGEOMToolsGUI.so" );
401 library = getLibrary( "GEOMToolsGUI.dll" );
404 else if( id == 211 || // MENU VIEW - WIREFRAME/SHADING
405 id == 212 || // MENU VIEW - DISPLAY ALL
406 id == 213 || // MENU VIEW - DISPLAY ONLY
407 id == 214 || // MENU VIEW - ERASE ALL
408 id == 215 || // MENU VIEW - ERASE
409 id == 216 || // MENU VIEW - DISPLAY
410 id == 80311 || // POPUP VIEWER - WIREFRAME
411 id == 80312 ) { // POPUP VIEWER - SHADING
413 library = getLibrary( "libDisplayGUI.so" );
415 library = getLibrary( "DisplayGUI.dll" );
418 else if( id == 4011 || // MENU BASIC - POINT
419 id == 4012 || // MENU BASIC - LINE
420 id == 4013 || // MENU BASIC - CIRCLE
421 id == 4014 || // MENU BASIC - ELLIPSE
422 id == 4015 || // MENU BASIC - ARC
423 id == 4016 || // MENU BASIC - VECTOR
424 id == 4017 || // MENU BASIC - PLANE
425 id == 4018 || // MENU BASIC - WPLANE
426 id == 4019 || // MENU BASIC - CURVE
427 id == 4020 ) { // MENU BASIC - REPAIR
429 library = getLibrary( "libBasicGUI.so" );
431 library = getLibrary( "BasicGUI.dll" );
434 else if( id == 4021 || // MENU PRIMITIVE - BOX
435 id == 4022 || // MENU PRIMITIVE - CYLINDER
436 id == 4023 || // MENU PRIMITIVE - SPHERE
437 id == 4024 || // MENU PRIMITIVE - TORUS
438 id == 4025 ) { // MENU PRIMITIVE - CONE
440 library = getLibrary( "libPrimitiveGUI.so" );
442 library = getLibrary( "PrimitiveGUI.dll" );
445 else if( id == 4031 || // MENU GENERATION - PRISM
446 id == 4032 || // MENU GENERATION - REVOLUTION
447 id == 4033 || // MENU GENERATION - FILLING
448 id == 4034 ) { // MENU GENERATION - PIPE
450 library = getLibrary( "libGenerationGUI.so" );
452 library = getLibrary( "GenerationGUI.dll" );
455 else if( id == 404 || // MENU ENTITY - SKETCHER
456 id == 407 ) { // MENU ENTITY - EXPLODE
458 library = getLibrary( "libEntityGUI.so" );
460 library = getLibrary( "EntityGUI.dll" );
463 else if( id == 4081 || // MENU BUILD - EDGE
464 id == 4082 || // MENU BUILD - WIRE
465 id == 4083 || // MENU BUILD - FACE
466 id == 4084 || // MENU BUILD - SHELL
467 id == 4085 || // MENU BUILD - SOLID
468 id == 4086 ) { // MENU BUILD - COMPUND
470 library = getLibrary( "libBuildGUI.so" );
472 library = getLibrary( "BuildGUI.dll" );
475 else if( id == 5011 || // MENU BOOLEAN - FUSE
476 id == 5012 || // MENU BOOLEAN - COMMON
477 id == 5013 || // MENU BOOLEAN - CUT
478 id == 5014 ) { // MENU BOOLEAN - SECTION
480 library = getLibrary( "libBooleanGUI.so" );
482 library = getLibrary( "BooleanGUI.dll" );
485 else if( id == 5021 || // MENU TRANSFORMATION - TRANSLATION
486 id == 5022 || // MENU TRANSFORMATION - ROTATION
487 id == 5023 || // MENU TRANSFORMATION - LOCATION
488 id == 5024 || // MENU TRANSFORMATION - MIRROR
489 id == 5025 || // MENU TRANSFORMATION - SCALE
490 id == 5026 || // MENU TRANSFORMATION - OFFSET
491 id == 5027 || // MENU TRANSFORMATION - MULTI-TRANSLATION
492 id == 5028 || // MENU TRANSFORMATION - MULTI-ROTATION
493 id == 5029 ) { // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
495 library = getLibrary( "libTransformationGUI.so" );
497 library = getLibrary( "TransformationGUI.dll" );
500 else if( id == 503 || // MENU OPERATION - PARTITION
501 id == 504 || // MENU OPERATION - ARCHIMEDE
502 id == 505 || // MENU OPERATION - FILLET
503 id == 506 || // MENU OPERATION - CHAMFER
504 id == 507 || // MENU OPERATION - CLIPPING RANGE
505 id == 508 ) { // MENU OPERATION - GET SHAPES ON SHAPE
507 library = getLibrary( "libOperationGUI.so" );
509 library = getLibrary( "OperationGUI.dll" );
512 else if( id == 601 || // MENU REPAIR - SEWING
513 id == 603 || // MENU REPAIR - SUPPRESS FACES
514 id == 604 || // MENU REPAIR - SUPPRESS HOLE
515 id == 605 || // MENU REPAIR - SHAPE PROCESSING
516 id == 606 || // MENU REPAIR - CLOSE CONTOUR
517 id == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES
518 id == 608 || // MENU REPAIR - ADD POINT ON EDGE
519 id == 609 || // MENU MEASURE - FREE BOUNDARIES
520 id == 610 || // MENU MEASURE - FREE FACES
521 id == 611 || // MENU REPAIR - CHANGE ORIENTATION
522 id == 602 || // MENU REPAIR - GLUE FACES
523 id == 612 ) { // MENU REPAIR - REMOVE EXTRA EDGES
525 library = getLibrary( "libRepairGUI.so" );
527 library = getLibrary( "RepairGUI.dll" );
530 else if( id == 701 || // MENU MEASURE - PROPERTIES
531 id == 702 || // MENU MEASURE - CDG
532 id == 703 || // MENU MEASURE - INERTIA
533 id == 704 || // MENU MEASURE - NORMALE
534 id == 7041 || // MENU MEASURE - BOUNDING BOX
535 id == 7042 || // MENU MEASURE - MIN DISTANCE
536 id == 7043 || // MENU MEASURE - ANGLE
537 id == 705 || // MENU MEASURE - TOLERANCE
538 id == 706 || // MENU MEASURE - WHATIS
539 id == 707 || // MENU MEASURE - CHECK
540 id == 7072 || // MENU MEASURE - CHECK COMPOUND OF BLOCKS
541 id == 708 ) { // MENU MEASURE - POINT COORDINATES
543 library = getLibrary( "libMeasureGUI.so" );
545 library = getLibrary( "MeasureGUI.dll" );
548 else if( id == 800 || // MENU GROUP - CREATE
549 id == 8001 || // POPUP MENU - CREATE GROUP
550 id == 801 ) { // MENU GROUP - EDIT
552 library = getLibrary( "libGroupGUI.so" );
554 library = getLibrary( "GroupGUI.dll" );
557 else if( id == 9999 || // MENU BLOCKS - HEXAHEDRAL SOLID
558 id == 9998 || // MENU BLOCKS - MULTI-TRANSFORMATION
559 id == 9997 || // MENU BLOCKS - QUADRANGLE FACE
560 id == 99991 || // MENU BLOCKS - PROPAGATE
561 id == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS
563 library = getLibrary( "libBlocksGUI.so" );
565 library = getLibrary( "BlocksGUI.dll" );
569 // call method of corresponding GUI library
571 library->OnGUIEvent( id, desk );
573 SUIT_MessageBox::error1( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
577 //=================================================================================
578 // function : GeometryGUI::OnKeyPress()
579 // purpose : Called when any key is pressed by user [static]
580 //=================================================================================
581 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* win, QKeyEvent* pe )
585 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
586 SUIT_Application* anApp = application();
588 bOk = bOk && it.data()->OnKeyPress( pe, anApp->desktop(), win );
594 //=================================================================================
595 // function : GeometryGUI::OnMouseMove()
596 // purpose : Manages mouse move events [static]
597 //=================================================================================
598 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* win, QMouseEvent* pe )
602 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
603 SUIT_Application* anApp = application();
605 bOk = bOk && it.data()->OnMouseMove( pe, anApp->desktop(), win );
611 //=================================================================================
612 // function : GeometryGUI::0nMousePress()
613 // purpose : Manage mouse press events [static]
614 //=================================================================================
615 void GeometryGUI::OnMousePress( SUIT_ViewWindow* win, QMouseEvent* pe )
618 // OnMousePress() should return false if this event should be processed further
619 // (see OCCViewer_Viewer3d::onMousePress() for explanation)
620 bool processed = false;
621 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
622 SUIT_Application* anApp = application();
624 processed = processed || it.data()->OnMousePress( pe, anApp->desktop(), win );
630 static void UpdateVtkSelection()
632 QPtrList<SUIT_ViewWindow> winList = application()->desktop()->windows();
633 SUIT_ViewWindow* win = 0;
634 for ( win = winList.first(); win; win = winList.next() ) {
635 if ( win->getViewManager()->getTypeView() == VIEW_VTK ) {
636 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
638 SVTK_RenderWindowInteractor* anInteractor = vw->getRWInteractor();
639 anInteractor->SetSelectionProp();
640 anInteractor->SetSelectionTolerance();
641 SVTK_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
643 aStyle->setPreselectionProp();
650 //=================================================================================
651 // function : GeometryGUI::SetSettings()
652 // purpose : Called when GEOM module is activated [static]
653 //=================================================================================
654 bool GeometryGUI::SetSettings()
656 QMenuBar* Mb = parent->getMainMenuBar();
657 SUIT_Study* ActiveStudy = application()->activeStudy();
659 // Wireframe or Shading
661 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
662 bool ViewOCC = ( window && window->getViewManager()->getType() == VIEW_OCC );
663 bool ViewVTK = ( window && window->getViewManager()->getType() == VIEW_VTK );
665 OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( window->getViewManager() );
667 Handle(AIS_InteractiveContext) ic = vm->getOCCViewer()->getAISContext();
668 DisplayMode = ic->DisplayMode();
671 else if ( ViewVTK ) {
672 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
674 SVTK_RenderWindowInteractor* myRenderInter = vw->getRWInteractor();
675 DisplayMode = myRenderInter->GetDisplayMode();
679 if( DisplayMode == 1 )
681 Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) );
683 Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) );
686 // Add in Study - !!!ALWAYS TRUE!!! /////// VSR : TO BE REMOVED
687 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
688 int Settings_AddInStudy;
689 // if(!AddInStudy.isEmpty())
690 // Settings_AddInStudy = AddInStudy.toInt();
693 Settings_AddInStudy = 1;
694 Mb->setItemChecked(411, Settings_AddInStudy);
697 QString S = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
699 QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", "100");
702 int count = ActiveStudy->getStudyFramesCount();
703 for(int i = 0; i < count; i++) {
704 if(ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC) {
705 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
706 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
708 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
709 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
711 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
713 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
719 // PAL5356: update VTK selection
720 ::UpdateVtkSelection();
723 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
724 bOk = bOk && it.data()->SetSettings( parent );
726 // MZN: Enable/disable "Clipping range" menu item(from GEOM_CLIPPING variable)
727 if (getenv( "GEOM_CLIPPING" ) == NULL)
729 QMenuItem* mi = Mb->findItem(50);
730 if (mi && mi->popup())
731 mi->popup()->removeItem(507);
738 //=======================================================================
739 // function : createGeomAction
741 //=======================================================================
742 void GeometryGUI::createGeomAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
745 QWidget* parent = application()->desktop();
746 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
748 if ( icon_id.length() )
749 pix = resMgr->loadPixmap( "GEOM", tr( icon_id ) );
751 pix = resMgr->loadPixmap( "GEOM", tr( QString( "ICO_" )+po_id ), false );
753 icon = QIconSet( pix );
755 QString tooltip = tr( QString( "TOP_" )+po_id ),
756 menu = tr( QString( "MEN_" )+po_id ),
757 status_bar = tr( QString( "STB_" )+po_id );
759 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
764 //=======================================================================
765 // function : GeometryGUI::initialize()
766 // purpose : Called when GEOM module is created
767 //=======================================================================
768 void GeometryGUI::initialize( CAM_Application* app )
770 SalomeApp_Module::initialize( app );
772 // ----- create actions --------------
774 createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) );
775 createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) );
777 createGeomAction( 33, "DELETE", "", Key_Delete );
779 createGeomAction( 4011, "POINT" );
780 createGeomAction( 4012, "LINE" );
781 createGeomAction( 4013, "CIRCLE" );
782 createGeomAction( 4014, "ELLIPSE" );
783 createGeomAction( 4015, "ARC" );
784 createGeomAction( 4019, "CURVE" );
785 createGeomAction( 4016, "VECTOR" );
786 createGeomAction( 4017, "PLANE" );
787 createGeomAction( 4018, "WORK_PLANE" );
788 createGeomAction( 4020, "LOCAL_CS" );
790 createGeomAction( 4021, "BOX" );
791 createGeomAction( 4022, "CYLINDER" );
792 createGeomAction( 4023, "SPHERE" );
793 createGeomAction( 4024, "TORUS" );
794 createGeomAction( 4025, "CONE" );
796 createGeomAction( 4031, "EXTRUSION" );
797 createGeomAction( 4032, "REVOLUTION" );
798 createGeomAction( 4033, "FILLING" );
799 createGeomAction( 4034, "PIPE" );
801 createGeomAction( 800, "GROUP_CREATE" );
802 createGeomAction( 801, "GROUP_EDIT" );
804 createGeomAction( 9997, "Q_FACE" );
805 createGeomAction( 9999, "HEX_SOLID" );
807 createGeomAction( 404, "SKETCH" );
808 createGeomAction( 407, "EXPLODE" );
810 createGeomAction( 4081, "EDGE" );
811 createGeomAction( 4082, "WIRE" );
812 createGeomAction( 4083, "FACE" );
813 createGeomAction( 4084, "SHELL" );
814 createGeomAction( 4085, "SOLID" );
815 createGeomAction( 4086, "COMPOUND" );
817 createGeomAction( 5011, "FUSE" );
818 createGeomAction( 5012, "COMMON" );
819 createGeomAction( 5013, "CUT" );
820 createGeomAction( 5014, "SECTION" );
822 createGeomAction( 5021, "TRANSLATION" );
823 createGeomAction( 5022, "ROTATION" );
824 createGeomAction( 5023, "MODIFY_LOCATION" );
825 createGeomAction( 5024, "MIRROR" );
826 createGeomAction( 5025, "SCALE" );
827 createGeomAction( 5026, "OFFSET" );
828 createGeomAction( 5027, "MUL_TRANSLATION" );
829 createGeomAction( 5028, "MUL_ROTATION" );
830 createGeomAction( 5029, "RELOAD_IMPORTED" );
832 createGeomAction( 503, "PARTITION" );
833 createGeomAction( 504, "ARCHIMEDE" );
834 createGeomAction( 505, "FILLET" );
835 createGeomAction( 506, "CHAMFER" );
836 //createGeomAction( 507, "CLIPPING" );
837 createGeomAction( 508, "GET_SHAPES_ON_SHAPES" );
839 createGeomAction( 9998, "MUL_TRANSFORM" );
840 createGeomAction( 9995, "EXPLODE_BLOCKS" );
841 createGeomAction( 99991, "PROPAGATE" );
843 createGeomAction( 601, "SEWING" );
844 createGeomAction( 602, "GLUE_FACES" );
845 createGeomAction( 603, "SUPPRESS_FACES" );
846 createGeomAction( 604, "SUPPERSS_HOLES" );
847 createGeomAction( 605, "SHAPE_PROCESS" );
848 createGeomAction( 606, "CLOSE_CONTOUR" );
849 createGeomAction( 607, "SUPPRESS_INT_WIRES" );
850 createGeomAction( 608, "POINT_ON_EDGE" );
851 createGeomAction( 609, "CHECK_FREE_BNDS" );
852 createGeomAction( 610, "CHECK_FREE_FACES" );
853 createGeomAction( 611, "CHANGE_ORIENTATION" );
854 createGeomAction( 612, "REMOVE_EXTRA_EDGES" );
856 createGeomAction( 708, "POINT_COORDS" );
857 createGeomAction( 701, "BASIC_PROPS" );
858 createGeomAction( 702, "MASS_CENTER" );
859 createGeomAction( 703, "INERTIA" );
860 createGeomAction( 704, "NORMALE" );
861 createGeomAction( 7041, "BND_BOX" );
862 createGeomAction( 7042, "MIN_DIST" );
863 createGeomAction( 7043, "MEASURE_ANGLE" );
865 createGeomAction( 705, "TOLERANCE" );
866 createGeomAction( 706, "WHAT_IS" );
867 createGeomAction( 707, "CHECK" );
868 createGeomAction( 7072, "CHECK_COMPOUND" );
870 #ifdef _DEBUG_ // PAL16821
871 createGeomAction( 5103, "CHECK_GEOMETRY" );
873 createGeomAction( 412, "SHADING_COLOR" );
875 createGeomAction( 211, "SHADING" );
876 createGeomAction( 212, "DISPLAY_ALL" );
877 createGeomAction( 214, "ERASE_ALL" );
878 createGeomAction( 216, "DISPLAY" );
879 createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true );
880 createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true );
881 createGeomAction( 2173, "WIRE_SEL_ONLY", "", 0, true );
882 createGeomAction( 2174, "FACE_SEL_ONLY", "", 0, true );
883 createGeomAction( 2175, "SHELL_SEL_ONLY", "", 0, true );
884 createGeomAction( 2176, "SOLID_SEL_ONLY", "", 0, true );
885 createGeomAction( 2177, "COMPOUND_SEL_ONLY", "", 0, true );
886 createGeomAction( 2178, "ALL_SEL_ONLY", "", 0, true );
887 createGeomAction( 213, "DISPLAY_ONLY" );
888 createGeomAction( 215, "ERASE" );
890 createGeomAction( 901, "POP_RENAME", "", Key_F2 );
891 createGeomAction( 80311, "POP_WIREFRAME", "", 0, true );
892 createGeomAction( 80312, "POP_SHADING", "", 0, true );
893 createGeomAction( 8032, "POP_COLOR" );
894 createGeomAction( 8033, "POP_TRANSPARENCY" );
895 createGeomAction( 8034, "POP_ISOS" );
896 createGeomAction( 8035, "POP_AUTO_COLOR" );
897 createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" );
898 createGeomAction( 8001, "POP_CREATE_GROUP" );
900 // make wireframe-shading items to be exclusive (only one at a time is selected)
901 //QActionGroup* dispModeGr = new QActionGroup( this, "", true );
902 //dispModeGr->add( action( 80311 ) );
903 //dispModeGr->add( action( 80312 ) );
904 // ---- create menu --------------------------
906 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
907 createMenu( separator(), fileId, 10 );
908 createMenu( 111, fileId, 10 );
909 createMenu( 121, fileId, 10 );
910 createMenu( separator(), fileId, -1 );
912 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
913 createMenu( 33, editId, -1 );
915 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
917 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
918 createMenu( 4011, basicId, -1 );
919 createMenu( 4012, basicId, -1 );
920 createMenu( 4013, basicId, -1 );
921 createMenu( 4014, basicId, -1 );
922 createMenu( 4015, basicId, -1 );
923 createMenu( 4019, basicId, -1 );
924 createMenu( separator(), basicId, -1 );
925 createMenu( 4016, basicId, -1 );
926 createMenu( 4017, basicId, -1 );
927 createMenu( 4018, basicId, -1 );
928 createMenu( 4020, basicId, -1 );
930 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
931 createMenu( 4021, primId, -1 );
932 createMenu( 4022, primId, -1 );
933 createMenu( 4023, primId, -1 );
934 createMenu( 4024, primId, -1 );
935 createMenu( 4025, primId, -1 );
937 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
938 createMenu( 4031, genId, -1 );
939 createMenu( 4032, genId, -1 );
940 createMenu( 4033, genId, -1 );
941 createMenu( 4034, genId, -1 );
942 createMenu( separator(), newEntId, -1 );
944 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
945 createMenu( 800, groupId, -1 );
946 createMenu( 801, groupId, -1 );
947 createMenu( separator(), newEntId, -1 );
949 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
950 createMenu( 9997, blocksId, -1 );
951 createMenu( 9999, blocksId, -1 );
953 createMenu( separator(), newEntId, -1 );
954 createMenu( 404, newEntId, -1 );
955 createMenu( separator(), newEntId, -1 );
956 createMenu( 407, newEntId, -1 );
958 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
959 createMenu( 4081, buildId, -1 );
960 createMenu( 4082, buildId, -1 );
961 createMenu( 4083, buildId, -1 );
962 createMenu( 4084, buildId, -1 );
963 createMenu( 4085, buildId, -1 );
964 createMenu( 4086, buildId, -1 );
966 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
968 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
969 createMenu( 5011, boolId, -1 );
970 createMenu( 5012, boolId, -1 );
971 createMenu( 5013, boolId, -1 );
972 createMenu( 5014, boolId, -1 );
974 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
975 createMenu( 5021, transId, -1 );
976 createMenu( 5022, transId, -1 );
977 createMenu( 5023, transId, -1 );
978 createMenu( 5024, transId, -1 );
979 createMenu( 5025, transId, -1 );
980 createMenu( 5026, transId, -1 );
981 createMenu( separator(), transId, -1 );
982 createMenu( 5027, transId, -1 );
983 createMenu( 5028, transId, -1 );
985 createMenu( 503, operId, -1 );
986 createMenu( 504, operId, -1 );
987 createMenu( 508, operId, -1 );
988 createMenu( separator(), operId, -1 );
989 createMenu( 505, transId, -1 );
990 createMenu( 506, transId, -1 );
991 //createMenu( 507, transId, -1 );
993 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
994 createMenu( 9998, blockId, -1 );
995 createMenu( 9995, blockId, -1 );
996 createMenu( 99991, blockId, -1 );
998 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
999 createMenu( 605, repairId, -1 );
1000 createMenu( 603, repairId, -1 );
1001 createMenu( 606, repairId, -1 );
1002 createMenu( 607, repairId, -1 );
1003 createMenu( 604, repairId, -1 );
1004 createMenu( 601, repairId, -1 );
1005 createMenu( 602, repairId, -1 );
1006 createMenu( 608, repairId, -1 );
1007 //createMenu( 609, repairId, -1 );
1008 //createMenu( 610, repairId, -1 );
1009 createMenu( 611, repairId, -1 );
1010 createMenu( 612, repairId, -1 );
1012 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1013 createMenu( 708, measurId, -1 );
1014 createMenu( 701, measurId, -1 );
1015 createMenu( separator(), measurId, -1 );
1016 createMenu( 702, measurId, -1 );
1017 createMenu( 703, measurId, -1 );
1018 createMenu( 704, measurId, -1 );
1019 // NPAL16572: move "Check free boundaries" and "Check free faces" from "Repair" to "Measure"
1020 createMenu( separator(), measurId, -1 );
1021 createMenu( 609, measurId, -1 );
1022 createMenu( 610, measurId, -1 );
1024 createMenu( separator(), measurId, -1 );
1026 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1027 createMenu( 7041, dimId, -1 );
1028 createMenu( 7042, dimId, -1 );
1029 createMenu( 7043, dimId, -1 );
1030 createMenu( separator(), measurId, -1 );
1032 createMenu( 705, measurId, -1 );
1033 createMenu( separator(), measurId, -1 );
1034 createMenu( 706, measurId, -1 );
1035 createMenu( 707, measurId, -1 );
1036 createMenu( 7072, measurId, -1 );
1038 #ifdef _DEBUG_ // PAL16821
1039 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1040 createMenu( separator(), toolsId, -1 );
1041 createMenu( 5103, toolsId, -1 );
1043 //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 );
1044 //createMenu( separator(), prefId, -1 );
1045 //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 );
1046 //createMenu( 412, geomId, -1 );
1047 //createMenu( separator(), prefId, -1 );
1049 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1050 createMenu( separator(), viewId, -1 );
1052 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1053 createMenu( 211, dispmodeId, -1 );
1055 createMenu( separator(), viewId, -1 );
1056 createMenu( 212, viewId, -1 );
1057 createMenu( 214, viewId, -1 );
1058 createMenu( separator(), viewId, -1 );
1062 because of these items are accessible through object browser and viewers
1063 we have removed they from main menu
1065 createMenu( 216, viewId, -1 );
1066 createMenu( 213, viewId, -1 );
1067 createMenu( 215, viewId, -1 );
1070 // ---- create toolbars --------------------------
1072 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1073 createTool( 4011, basicTbId );
1074 createTool( 4012, basicTbId );
1075 createTool( 4013, basicTbId );
1076 createTool( 4014, basicTbId );
1077 createTool( 4015, basicTbId );
1078 createTool( 4019, basicTbId );
1079 createTool( 4016, basicTbId );
1080 createTool( 4017, basicTbId );
1081 createTool( 4018, basicTbId );
1082 createTool( 4020, basicTbId );
1084 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1085 createTool( 4021, primTbId );
1086 createTool( 4022, primTbId );
1087 createTool( 4023, primTbId );
1088 createTool( 4024, primTbId );
1089 createTool( 4025, primTbId );
1091 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1092 createTool( 5011, boolTbId );
1093 createTool( 5012, boolTbId );
1094 createTool( 5013, boolTbId );
1095 createTool( 5014, boolTbId );
1097 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1098 createTool( 4031, genTbId );
1099 createTool( 4032, genTbId );
1100 createTool( 4033, genTbId );
1101 createTool( 4034, genTbId );
1103 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1104 createTool( 5021, transTbId );
1105 createTool( 5022, transTbId );
1106 createTool( 5023, transTbId );
1107 createTool( 5024, transTbId );
1108 createTool( 5025, transTbId );
1109 createTool( 5026, transTbId );
1110 createTool( separator(), transTbId );
1111 createTool( 5027, transTbId );
1112 createTool( 5028, transTbId );
1114 // ---- create popup menus --------------------------
1116 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1117 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1119 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1120 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1122 QString autoColorPrefix =
1123 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1125 QtxPopupMgr* mgr = popupMgr();
1126 mgr->insert( action( 901 ), -1, -1 ); // rename
1127 mgr->setRule( action( 901 ), "$type in {'Shape' 'Group'} and selcount=1", true );
1128 mgr->insert( action( 33 ), -1, -1 ); // delete
1129 mgr->setRule( action( 33 ), "$type in {'Shape' 'Group'} and selcount>0", true );
1130 mgr->insert( action( 8001 ), -1, -1 ); // create group
1131 mgr->setRule( action( 8001 ), "client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true", true );
1132 mgr->insert( action( 801 ), -1, -1 ); // edit group
1133 mgr->setRule( action( 801 ), "client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true", true );
1134 mgr->insert( separator(), -1, -1 ); // -----------
1135 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1136 mgr->insert( action( 80311 ), dispmodeId, -1 ); // wireframe
1137 mgr->setRule( action( 80311 ), clientOCCorVTK_AndSomeVisible, true );
1138 mgr->setRule( action( 80311 ), clientOCCorVTK + " and displaymode='Wireframe'", false );
1139 mgr->insert( action( 80312 ), dispmodeId, -1 ); // shading
1140 mgr->setRule( action( 80312 ), clientOCCorVTK_AndSomeVisible, true );
1141 mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", false );
1142 mgr->insert( separator(), -1, -1 ); // -----------
1143 mgr->insert( action( 8032 ), -1, -1 ); // color
1144 mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", true );
1145 mgr->insert( action( 8033 ), -1, -1 ); // transparency
1146 mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, true );
1147 mgr->insert( action( 8034 ), -1, -1 ); // isos
1148 mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", true );
1149 mgr->insert( separator(), -1, -1 ); // -----------
1150 mgr->insert( action( 8035 ), -1, -1 ); // auto color
1151 mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", true );
1152 mgr->insert( action( 8036 ), -1, -1 ); // disable auto color
1153 mgr->setRule( action( 8036 ), autoColorPrefix + " and isAutoColor=true", true );
1154 mgr->insert( separator(), -1, -1 ); // -----------
1157 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1158 onlyComponent = "((type='Component') and selcount=1)",
1159 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1160 types = "'Shape' 'Group'";
1162 mgr->insert( action( 216 ), -1, -1 ); // display
1163 mgr->setRule( action( 216 ), rule.arg( types ).arg( "not isVisible" ), true );
1165 mgr->insert( action( 215 ), -1, -1 ); // erase
1166 mgr->setRule( action( 215 ), rule.arg( types ).arg( "isVisible" ), true );
1168 mgr->insert( action( 214 ), -1, -1 ); // erase All
1169 mgr->setRule( action( 214 ), clientOCCorVTK, true );
1171 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1173 int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1174 mgr->insert( action(2171), selectolnyId, -1); //Vertex
1175 mgr->setRule(action(2171), selectOnly, true);
1176 mgr->setRule(action(2171), selectOnly + " and selectionmode='VERTEX'", false);
1177 mgr->insert( action(2172), selectolnyId, -1); //Edge
1178 mgr->setRule(action(2172), selectOnly, true);
1179 mgr->setRule(action(2172), selectOnly + " and selectionmode='EDGE'", false);
1180 mgr->insert( action(2173), selectolnyId, -1); //Wire
1181 mgr->setRule(action(2173), selectOnly, true);
1182 mgr->setRule(action(2173), selectOnly + " and selectionmode='WIRE'", false);
1183 mgr->insert( action(2174), selectolnyId, -1); //Face
1184 mgr->setRule(action(2174), selectOnly, true);
1185 mgr->setRule(action(2174), selectOnly + " and selectionmode='FACE'", false);
1186 mgr->insert( action(2175), selectolnyId, -1); //Shell
1187 mgr->setRule(action(2175), selectOnly, true);
1188 mgr->setRule(action(2175), selectOnly + " and selectionmode='SHELL'", false);
1189 mgr->insert( action(2176), selectolnyId, -1); //Solid
1190 mgr->setRule(action(2176), selectOnly, true);
1191 mgr->setRule(action(2176), selectOnly + " and selectionmode='SOLID'", false);
1192 mgr->insert( action(2177), selectolnyId, -1); //Compound
1193 mgr->setRule(action(2177), selectOnly, true);
1194 mgr->setRule(action(2177), selectOnly + " and selectionmode='COMPOUND'", false);
1195 mgr->insert( separator(), selectolnyId, -1);
1196 mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter
1197 mgr->setRule(action(2178), selectOnly, true);
1198 mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", false);
1200 mgr->insert( action( 213 ), -1, -1 ); // display only
1201 mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), true );
1202 mgr->insert( separator(), -1, -1 );
1204 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1207 //=======================================================================
1208 // function : GeometryGUI::activateModule()
1209 // purpose : Called when GEOM module is activated
1210 //=======================================================================
1211 bool GeometryGUI::activateModule( SUIT_Study* study )
1213 if ( CORBA::is_nil( myComponentGeom ) )
1216 bool res = SalomeApp_Module::activateModule( study );
1221 setMenuShown( true );
1222 setToolShown( true );
1224 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1225 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1227 // Reset actions accelerator keys
1228 //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import
1229 //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export
1230 action(111)->setEnabled(true); // Import: CTRL + Key_I
1231 action(121)->setEnabled(true); // Export: CTRL + Key_E
1232 action( 33)->setEnabled(true); // Delete: Key_Delete
1233 action(901)->setEnabled(true); // Rename: Key_F2
1235 GUIMap::Iterator it;
1236 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1237 it.data()->activate( application()->desktop() );
1239 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1241 SUIT_ViewManager* vm;
1242 ViewManagerList OCCViewManagers, VTKViewManagers;
1243 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1244 for ( vm = OCCViewManagers.first(); vm; vm = OCCViewManagers.next() )
1245 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1246 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1247 for ( vm = VTKViewManagers.first(); vm; vm = VTKViewManagers.next() )
1248 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1251 SALOME_ListIO selected;
1252 sm->selectedObjects( selected );
1253 sm->clearSelected();
1255 // disable OCC selectors
1256 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1257 for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() )
1258 sr->setEnabled(true);
1260 // disable VTK selectors
1261 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1262 for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() )
1263 sr->setEnabled(true);
1265 sm->setSelectedObjects( selected, true ); //NPAL 19674
1271 //=======================================================================
1272 // function : GeometryGUI::deactivateModule()
1273 // purpose : Called when GEOM module is deactivated
1274 //=======================================================================
1275 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1277 setMenuShown( false );
1278 setToolShown( false );
1280 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1281 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1283 EmitSignalCloseAllDialogs();
1285 GUIMap::Iterator it;
1286 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1287 it.data()->deactivate();
1289 // Unset actions accelerator keys
1290 //action(111)->setAccel(QKeySequence()); // Import
1291 //action(121)->setAccel(QKeySequence()); // Export
1292 action(111)->setEnabled(false); // Import: CTRL + Key_I
1293 action(121)->setEnabled(false); // Export: CTRL + Key_E
1294 action( 33)->setEnabled(false); // Delete: Key_Delete
1295 action(901)->setEnabled(false); // Rename: Key_F2
1297 myOCCSelectors.clear();
1298 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1300 myVTKSelectors.clear();
1301 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1303 return SalomeApp_Module::deactivateModule( study );
1306 //=================================================================================
1307 // function : GeometryGUI::DefinePopup()
1308 // purpose : Called from desktop to define popup menu [static]
1309 //=================================================================================
1311 void GeometryGUI::DefinePopup(QString& theContext, QString& theParent, QString& theObject)
1313 QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
1314 SALOME_Selection* Sel = SALOME_Selection::Selection(ActiveStudy->getSelection());
1319 if ( theParent == "Viewer" ) {
1320 if ( Sel->IObjectCount() == 0 )
1321 theContext = "NothingSelected";
1324 if ( Sel->IObjectCount() == 1 ) {
1325 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
1326 if( IO->hasEntry() ) {
1327 SALOMEDS::SObject_var sobj = ActiveStudy->getStudyDocument()->FindObjectID( IO->getEntry() );
1328 if ( !sobj->_is_nil() ) {
1329 SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
1330 if ( !strcmp(scomp->GetID(), IO->getEntry() ) ) {
1331 // component is selected
1332 theObject = "Component";
1335 GEOM::GEOM_Object_var aGObj = GEOM::GEOM_Object::_narrow( sobj->GetObject() );
1336 if ( !CORBA::is_nil( aGObj ) ) {
1337 switch( aGObj->GetType() ) {
1339 theObject = "Group";
1342 theObject = "Shape";
1352 //=================================================================================
1353 // function : GeometryGUI::CustomPopup()
1354 // purpose : Called from desktop to create popup menu [static]
1355 //=================================================================================
1356 bool GeometryGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
1357 const QString& theParent, const QString& theObject)
1359 GeometryGUI* geomGUI = GetGeomGUI();
1361 // Deactivate any non modal dialog box to get the neutral point
1362 geomGUI->EmitSignalDeactivateDialog();
1363 QAD_Study* anActiveStudy = parent->getActiveStudy();
1364 QAD_StudyFrame* aStudyFrame = anActiveStudy->getActiveStudyFrame();
1365 QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
1366 SALOME_Selection* Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
1367 QString parentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
1368 bool isOCCViewer = aViewFrame->getTypeView() == VIEW_OCC;
1369 bool isVTKViewer = aViewFrame->getTypeView() == VIEW_VTK;
1370 int aDisplayMode = 0;
1373 if ( aViewFrame->getTypeView() == VIEW_OCC )
1374 aDisplayMode = ((OCCViewer_ViewFrame*)aViewFrame)->getViewer()->getAISContext()->DisplayMode();
1375 else if ( aViewFrame->getTypeView() == VIEW_VTK )
1376 aDisplayMode = (dynamic_cast<SVTK_ViewFrame*>( aViewFrame )->getRWInteractor()->GetDisplayMode();
1378 int nbSel = Sel->IObjectCount();
1381 ////// NOTHING SELECTED
1384 else if ( nbSel == 1 ) {
1385 ////// SINGLE OBJECT SELECTION
1386 if ( parentComponent != parent->getActiveComponent() ) {
1387 ////// selected object does not belong to GEOM module:
1388 // remove all commands except Display/Erase...
1390 int id = popup->idAt( 0 );
1391 if ( id <= QAD_TopLabel_Popup_ID )
1392 popup->removeItemAt( 0 );
1398 ////// selected object belong to the GEOM module
1399 // get interactive object
1400 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1401 objectName = IObject->getName();
1402 // if object has entry get SObject
1403 SALOMEDS::SObject_var SO;
1404 if ( IObject->hasEntry() )
1405 SO = anActiveStudy->getStudyDocument()->FindObjectID( IObject->getEntry() );
1407 if ( theObject == "Component" ) {
1408 ////// menu for component
1409 if ( !isOCCViewer && !isVTKViewer ) {
1410 popup->removeItem( QAD_DisplayOnly_Popup_ID );
1411 popup->removeItem( QAD_Display_Popup_ID );
1412 popup->removeItem( QAD_Erase_Popup_ID );
1416 ////// not component (should be shape)
1417 if ( IObject->hasEntry() ) /////// VSR : TO BE REMOVED
1418 popup->removeItem( 804 ); // "Add in Study"
1420 // Here could be analysis of the geom shape's type
1423 SALOMEDS::GenericAttribute_var aTmpAttr;
1424 if( SO->_is_nil() || SO->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR") )
1425 popup->removeItem( 9024 ); // "Open" /////// VSR : TO BE REMOVED
1427 if ( !isOCCViewer && theParent == "ObjectBrowser" ) {
1428 if ( theObject == "Shape" )
1429 popup->removeItem( 800 ); // Create Group
1430 else if ( theObject == "Group" )
1431 popup->removeItem( 801 ); // Edit Group
1434 if ( isOCCViewer || isVTKViewer ) {
1435 ////// current viewer is OCC or VTK
1436 SALOME_Prs* prs = aViewFrame->CreatePrs( IObject->getEntry() );
1437 if ( aViewFrame->isVisible( IObject ) ) {
1438 ////// object is already displayed in the viewer
1439 popup->removeItem( QAD_Display_Popup_ID );
1440 if ( isOCCViewer ) {
1441 ////// OCC viewer only
1442 OCCViewer_Prs* occPrs = dynamic_cast<OCCViewer_Prs*>( prs );
1443 if ( occPrs && !occPrs->IsNull() ) {
1444 AIS_ListOfInteractive ioList;
1445 occPrs->GetObjects( ioList );
1446 QMenuItem* mi = popup->findItem( 803 );
1447 if ( mi && mi->popup() ) {
1448 if ( ioList.First()->DisplayMode() == 0 )
1449 mi->popup()->setItemChecked( 80311, true ); // "Wireframe"
1450 else if ( ioList.First()->DisplayMode() == 1 )
1451 mi->popup()->setItemChecked( 80312, true ); // "Shading"
1452 else if ( ioList.First()->DisplayMode() < 0 )
1453 mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading"
1458 ////// VTK viewer only
1459 //popup->removeItem( 8034 ); // "Isos"
1460 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1461 if ( vtkPrs && !vtkPrs->IsNull() ) {
1462 vtkActorCollection* actorList = vtkPrs->GetObjects();
1463 actorList->InitTraversal();
1464 SALOME_Actor* ac = SALOME_Actor::SafeDownCast( actorList->GetNextActor() );
1465 QMenuItem* mi = popup->findItem( 803 );
1466 if ( ac && mi && mi->popup() ) {
1467 if ( ac->getDisplayMode() == 0 )
1468 mi->popup()->setItemChecked( 80311, true ); // "Wireframe"
1469 else if ( ac->getDisplayMode() == 1 )
1470 mi->popup()->setItemChecked( 80312, true ); // "Shading"
1472 mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading"
1478 ////// object is not yet displayed in the viewer
1479 popup->removeItem( 803 ); // "Display Mode"
1480 popup->removeItem( 8032 ); // "Color"
1481 popup->removeItem( 8033 ); // "Transparency"
1482 popup->removeItem( 8034 ); // "Isos"
1483 popup->removeItem( QAD_Erase_Popup_ID );
1488 ////// other viewer type (neither OCC nor VTK)
1489 popup->removeItem( 803 ); // "Display Mode"
1490 popup->removeItem( 8032 ); // "Color"
1491 popup->removeItem( 8033 ); // "Transparency"
1492 popup->removeItem( 8034 ); // "Isos"
1493 popup->removeItem( QAD_Display_Popup_ID );
1494 popup->removeItem( QAD_DisplayOnly_Popup_ID );
1495 popup->removeItem( QAD_Erase_Popup_ID );
1501 ////// MULTIPLE SELECTION
1502 if ( parentComponent != parent->getActiveComponent() ) {
1503 ////// not GEOM module objects or objects belong to different modules
1504 // remove all commands except Display/Erase...
1506 int id = popup->idAt( 0 );
1507 if ( id <= QAD_TopLabel_Popup_ID )
1508 popup->removeItemAt( 0 );
1512 if ( parentComponent.isNull() ) {
1513 ////// objects belong to different modules
1514 popup->removeItem(QAD_Display_Popup_ID);
1515 popup->removeItem(QAD_DisplayOnly_Popup_ID);
1516 popup->removeItem(QAD_Erase_Popup_ID);
1519 objectName = tr( "GEOM_MEN_POPUP_NAME" ).arg( nbSel );
1523 ////// all selected objects belong to GEOM module
1524 popup->removeItem( 901 ); // "Rename"
1526 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1527 bool isComponent = false;
1528 bool needOpen = false;
1529 bool needDisplay = false;
1530 bool needErase = false;
1531 int needToPublish = 0;
1533 for( ;It.More();It.Next() ) {
1534 Handle(SALOME_InteractiveObject) anIObject = It.Value();
1536 if ( aViewFrame->isVisible( anIObject ) )
1541 if( anIObject->hasEntry() ) {
1542 needToPublish = -1; /////// VSR : TO BE REMOVED
1543 SALOMEDS::SObject_var obj = anActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
1544 SALOMEDS::GenericAttribute_var aTmpAttr;
1545 if ( !obj->_is_nil() && !obj->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR" ) )
1546 needOpen = true; /////// VSR : TO BE REMOVED
1547 if ( !obj->_is_nil() && QString( obj->GetID() ) == QString( obj->GetFatherComponent()->GetID() ) )
1551 if ( needToPublish != -1 ) needToPublish = 1;
1554 if( needOpen || ( !isOCCViewer && !isVTKViewer ) ) {
1555 ////// Data is not loaded yet or current viewer is neither OCC nor VTK
1556 popup->removeItem( 803 ); // "Display Mode"
1557 popup->removeItem( 8032 ); // "Color"
1558 popup->removeItem( 8033 ); // "Transparency"
1559 popup->removeItem( 8034 ); // "Isos"
1560 popup->removeItem( 804 ); // "Add in Study"
1561 popup->removeItem( QAD_DisplayOnly_Popup_ID );
1562 popup->removeItem( QAD_Display_Popup_ID );
1563 popup->removeItem( QAD_Erase_Popup_ID );
1566 popup->removeItem( 9024 ); // "Open"
1567 if ( needToPublish <= 0 )
1568 popup->removeItem( 804 ); // "Add in Study"
1571 popup->removeItem( 803 ); // "Display Mode"
1572 popup->removeItem( 8032 ); // "Color"
1573 popup->removeItem( 8033 ); // "Transparency"
1574 popup->removeItem( 8034 ); // "Isos"
1575 popup->removeItem( QAD_DisplayOnly_Popup_ID );
1579 popup->removeItem( QAD_Display_Popup_ID );
1581 popup->removeItem( QAD_Erase_Popup_ID );
1582 if ( !isOCCViewer && !isVTKViewer)
1583 popup->removeItem( 8034 ); // "Isos"
1588 // check popup for unnecessary separators
1589 QAD_Tools::checkPopup( popup );
1590 // find popup menu's TopLabel item (with title)
1591 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
1592 if ( topItem >= 0 ) {
1593 // remove popup menu's title item
1594 popup->removeItem( QAD_TopLabel_Popup_ID );
1595 if ( theParent == "Viewer" && !objectName.isEmpty() && popup->count() > 0 ) {
1596 // set bold font for popup menu's title
1597 QFont f = popup->font(); f.setBold( TRUE );
1598 popup->removeItem( QAD_TopLabel_Popup_ID );
1599 popup->insertItem( new CustomItem( objectName, f ), QAD_TopLabel_Popup_ID, topItem );
1608 //=======================================================================
1609 // function : GeometryGUI::BuildPresentation()
1611 //=======================================================================
1612 void GeometryGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& io, SUIT_ViewWindow* win )
1614 //GEOM_Displayer().Display( io, false, win );
1617 //=======================================================================
1618 // function : onWindowActivated()
1619 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1620 //=======================================================================
1621 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1626 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1627 const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1629 // disable non-OCC viewframe menu commands
1630 // action( 404 )->setEnabled( ViewOCC ); // SKETCHER
1631 action( 603 )->setEnabled( ViewOCC ); // SuppressFace
1632 action( 604 )->setEnabled( ViewOCC ); // SuppressHole
1633 action( 606 )->setEnabled( ViewOCC ); // CloseContour
1634 action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires
1635 action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
1636 // action( 609 )->setEnabled( ViewOCC ); // Free boundaries
1638 action( 800 )->setEnabled( ViewOCC ); // Create Group
1639 action( 801 )->setEnabled( ViewOCC ); // Edit Group
1641 action( 9998 )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1644 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1646 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
1647 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
1650 void GeometryGUI::viewManagers( QStringList& lst ) const
1652 lst.append( OCCViewer_Viewer::Type() );
1655 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1657 if ( vm->getType() == OCCViewer_Viewer::Type() )
1659 qDebug( "connect" );
1660 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1661 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1662 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1663 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1664 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1665 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1668 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1669 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1671 // disable OCC selectors
1672 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1673 for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() )
1674 sr->setEnabled(true);
1676 else if ( vm->getType() == SVTK_Viewer::Type() )
1678 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1679 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1681 // disable VTK selectors
1682 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1683 for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() )
1684 sr->setEnabled(true);
1688 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1690 SUIT_ViewModel* viewer = vm->getViewModel();
1691 if ( vm->getType() == OCCViewer_Viewer::Type() )
1693 for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() )
1694 if ( sr->viewer() == viewer )
1696 myOCCSelectors.remove( sr );
1700 if ( vm->getType() == SVTK_Viewer::Type() )
1702 for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() )
1703 if ( sr->viewer() == viewer )
1705 myVTKSelectors.remove( sr );
1711 QString GeometryGUI::engineIOR() const
1713 if ( !CORBA::is_nil( GetGeomGen() ) )
1714 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1715 return QString( "" );
1718 LightApp_Selection* GeometryGUI::createSelection() const
1720 return new GEOMGUI_Selection();
1723 void GeometryGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
1725 SalomeApp_Module::contextMenuPopup( client, menu, title );
1727 getApp()->selectionMgr()->selectedObjects( lst );
1729 if (lst.Extent() == 1) {
1730 Handle(SALOME_InteractiveObject) io = lst.First();
1731 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1732 _PTR(Study) study = appStudy->studyDS();
1733 _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1735 // Set context menu title
1736 if (client == "OCCViewer" || client == "VTKViewer")
1737 title = QString(aSObj->GetName().c_str());
1739 // Reload imported shape
1740 CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1741 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1742 if (!CORBA::is_nil(aGeomObj) && aGeomObj->GetType() == GEOM_IMPORT)
1743 action(5029)->addTo(menu);
1748 void GeometryGUI::createPreferences()
1750 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1752 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1753 setPreferenceProperty( genGroup, "columns", 1 );
1755 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1756 LightApp_Preferences::Selector, "Geometry", "display_mode" );
1758 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1759 LightApp_Preferences::Color, "Geometry", "shading_color" );
1761 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1762 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1764 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1765 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1767 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1768 LightApp_Preferences::Color, "Geometry", "line_color" );
1770 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1771 LightApp_Preferences::Color, "Geometry", "point_color" );
1773 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1774 LightApp_Preferences::Color, "Geometry", "isos_color" );
1776 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1777 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1779 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1781 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1782 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1784 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1785 LightApp_Preferences::DblSpin, "Geometry", "marker_scale" );
1787 // Set property for default display mode
1788 QStringList aModesList;
1789 aModesList.append( tr("MEN_WIREFRAME") );
1790 aModesList.append( tr("MEN_SHADING") );
1792 QValueList<QVariant> anIndexesList;
1793 anIndexesList.append(0);
1794 anIndexesList.append(1);
1796 setPreferenceProperty( dispmode, "strings", aModesList );
1797 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1799 // Set property for step value for spinboxes
1800 setPreferenceProperty( step, "min", 0.001 );
1801 setPreferenceProperty( step, "max", 10000 );
1802 setPreferenceProperty( step, "precision", 3 );
1804 // Set property for type of vertex marker
1805 QStringList aTypeOfMarkerList;
1806 QValueList<QVariant> anTypeOfMarkerIndexesList;
1808 aTypeOfMarkerList.append( tr("TOM_PLUS") );
1809 anTypeOfMarkerIndexesList.append(Aspect_TOM_PLUS);
1811 aTypeOfMarkerList.append( tr("TOM_POINT") );
1812 anTypeOfMarkerIndexesList.append(Aspect_TOM_POINT);
1814 aTypeOfMarkerList.append( tr("TOM_STAR") );
1815 anTypeOfMarkerIndexesList.append(Aspect_TOM_STAR);
1817 aTypeOfMarkerList.append( tr("TOM_O") );
1818 anTypeOfMarkerIndexesList.append(Aspect_TOM_O);
1820 aTypeOfMarkerList.append( tr("TOM_X") );
1821 anTypeOfMarkerIndexesList.append(Aspect_TOM_X);
1823 aTypeOfMarkerList.append( tr("TOM_O_POINT") );
1824 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_POINT);
1826 aTypeOfMarkerList.append( tr("TOM_O_PLUS") );
1827 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_PLUS);
1829 aTypeOfMarkerList.append( tr("TOM_O_STAR") );
1830 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_STAR);
1832 aTypeOfMarkerList.append( tr("TOM_O_X") );
1833 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_X);
1836 setPreferenceProperty( typeOfMarker, "strings", aTypeOfMarkerList );
1837 setPreferenceProperty( typeOfMarker, "indexes", anTypeOfMarkerIndexesList );
1839 // Set property for Vertex Marker scale
1840 setPreferenceProperty( markerScale, "min", 1. );
1841 setPreferenceProperty( markerScale, "max", 7. );
1842 setPreferenceProperty( markerScale, "precision", 0.01 );
1843 setPreferenceProperty( markerScale, "step", 0.5 );
1847 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1849 if (section == "Geometry") {
1850 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1851 if (param == QString("SettingsGeomStep")) {
1852 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1853 EmitSignalDefaultStepValueChanged(spin_step);
1858 LightApp_Displayer* GeometryGUI::displayer()
1861 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1865 void GeometryGUI::setLocalSelectionMode(const int mode)
1867 myLocalSelectionMode = mode;
1869 int GeometryGUI::getLocalSelectionMode() const
1871 return myLocalSelectionMode;