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"
31 #include <SUIT_Desktop.h>
32 #include <SUIT_MessageBox.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SUIT_Session.h>
35 #include <SUIT_ViewManager.h>
37 #include <OCCViewer_ViewWindow.h>
38 #include <OCCViewer_ViewPort3d.h>
39 #include <OCCViewer_ViewModel.h>
40 #include <OCCViewer_ViewManager.h>
42 #include <SVTK_ViewWindow.h>
43 #include <SVTK_RenderWindowInteractor.h>
44 #include <SVTK_InteractorStyle.h>
45 #include <SVTK_ViewModel.h>
47 #include <SalomeApp_Application.h>
48 #include <LightApp_SelectionMgr.h>
49 #include <LightApp_VTKSelector.h>
50 #include <SalomeApp_Study.h>
51 #include <LightApp_Preferences.h>
52 #include <SALOME_LifeCycleCORBA.hxx>
53 #include <SALOME_ListIO.hxx>
61 #include <Prs3d_Drawer.hxx>
62 #include <Prs3d_IsoAspect.hxx>
63 #include <Aspect_TypeOfMarker.hxx>
64 #include <OSD_SharedLibrary.hxx>
66 #include <utilities.h>
68 #include <vtkCamera.h>
69 #include <vtkRenderer.h>
74 Standard_EXPORT CAM_Module* createModule() {
75 return new GeometryGUI();
81 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
83 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
85 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
86 if (CORBA::is_nil(myComponentGeom))
88 return GeometryGUI::myComponentGeom;
91 bool GeometryGUI::InitGeomGen()
94 if( CORBA::is_nil( myComponentGeom ) ) return false;
98 //=======================================================================
99 // function : ClientSObjectToObject
101 //=======================================================================
102 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
104 _PTR(GenericAttribute) anAttr;
105 CORBA::Object_var anObj;
107 std::string aValue = theSObject->GetIOR();
108 if (strcmp(aValue.c_str(), "") != 0) {
109 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
110 anObj = anORB->string_to_object(aValue.c_str());
113 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
115 return anObj._retn();
118 //=======================================================================
119 // function : ClientStudyToStudy
121 //=======================================================================
122 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
124 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
125 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
126 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
127 int aStudyID = theStudy->StudyId();
128 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
129 return aDSStudy._retn();
132 //=======================================================================
133 // function : GeometryGUI::GeometryGUI()
134 // purpose : Constructor
135 //=======================================================================
136 GeometryGUI::GeometryGUI() :
137 SalomeApp_Module( "GEOM" )
139 if ( CORBA::is_nil( myComponentGeom ) )
141 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
142 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "GEOM" );
143 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
147 myActiveDialogBox = 0;
150 gp_Pnt origin = gp_Pnt(0., 0., 0.);
151 gp_Dir direction = gp_Dir(0., 0., 1.);
152 myWorkingPlane = gp_Ax3(origin, direction);
155 myLocalSelectionMode = GEOM_ALLOBJECTS;
158 //=======================================================================
159 // function : GeometryGUI::~GeometryGUI()
160 // purpose : Destructor
161 //=======================================================================
162 GeometryGUI::~GeometryGUI()
164 while (!myOCCSelectors.isEmpty())
165 delete myOCCSelectors.takeFirst();
167 while (!myVTKSelectors.isEmpty())
168 delete myVTKSelectors.takeFirst();
171 //=======================================================================
172 // function : GeometryGUI::getLibrary()
173 // purpose : get or load GUI library by name [ internal ]
174 //=======================================================================
175 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
176 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
178 if ( !myGUIMap.contains( libraryName ) ) {
179 // try to load library if it is not loaded yet
182 libs = getenv( "LD_LIBRARY_PATH" );
183 if( !libs.isEmpty() ) {
184 QStringList dirList = libs.split( ":", QString::SkipEmptyParts ); // skip empty entries
186 libs = getenv( "PATH" );
187 if( !libs.isEmpty() ) {
188 QStringList dirList = libs.split( ";", QString::SkipEmptyParts ); // skip empty entries
190 for( int i = dirList.count()-1; i >= 0; i-- ) {
191 QString dir = dirList[ i ];
192 QFileInfo fi( Qtx::addSlash( dirList[ i ] ) + libraryName );
194 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().data() );
195 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
197 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
198 continue; // continue search further
200 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
201 if ( osdF != NULL ) {
202 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
203 GEOMGUI* libGUI = (*func)(this);
205 myGUIMap[ libraryName ] = libGUI;
206 break; // found and loaded!
213 if ( myGUIMap.contains( libraryName ) )
214 // library is successfully loaded
215 return myGUIMap[ libraryName ];
219 //=======================================================================
220 // function : GeometryGUI::ActiveWorkingPlane()
221 // purpose : Activate Working Plane View
222 //=======================================================================
223 void GeometryGUI::ActiveWorkingPlane()
225 gp_Dir DZ = myWorkingPlane.Direction();
226 gp_Dir DY = myWorkingPlane.YDirection();
228 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
229 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
230 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
233 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
235 Handle(V3d_View) view3d = vw->getViewPort()->getView();
237 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
238 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
244 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
246 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
248 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
249 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
250 camera->SetFocalPoint(0,0,0);
257 //=======================================================================
258 // function : GeometryGUI::SetActiveDialogBox()
259 // purpose : Set active dialog box
260 //=======================================================================
261 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
263 myActiveDialogBox = (QDialog*)aDlg;
266 //=======================================================================
267 // function : GeometryGUI::EmitSignalDeactivateDialog()
268 // purpose : Emit a signal to deactivate the active dialog Box
269 //=======================================================================
270 void GeometryGUI::EmitSignalDeactivateDialog()
272 emit SignalDeactivateActiveDialog();
275 //=======================================================================
276 // function : GeometryGUI::EmitSignalCloseAllDialogs()
277 // purpose : Emit a signal to close all non modal dialogs box
278 //=======================================================================
279 void GeometryGUI::EmitSignalCloseAllDialogs()
281 emit SignalCloseAllDialogs();
284 //=======================================================================
285 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
286 // purpose : Emit a signal to inform that default real spin box step has
288 //=======================================================================
289 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
291 emit SignalDefaultStepValueChanged(newVal);
294 //=======================================================================
295 // function : GeometryGUI::OnGUIEvent()
296 // purpose : common slot for all menu/toolbar actions
297 //=======================================================================
298 void GeometryGUI::OnGUIEvent()
300 const QObject* obj = sender();
301 if ( !obj || !obj->inherits( "QAction" ) )
303 int id = actionId((QAction*)obj);
308 //=======================================================================
309 // function : GeometryGUI::OnGUIEvent()
310 // purpose : manage all events on GUI [static]
311 //=======================================================================
312 void GeometryGUI::OnGUIEvent( int id )
314 SUIT_Application* anApp = application();
316 SUIT_Desktop* desk = anApp->desktop();
318 // check type of the active viewframe
319 SUIT_ViewWindow* window = desk->activeWindow();
320 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
321 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
322 // if current viewframe is not of OCC and not of VTK type - return immediately
323 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
324 bool NotViewerDependentCommand = ( id == 901 || id == 216 || id == 213 );
325 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommand )
328 // fix for IPAL9103, point 2
329 if ( CORBA::is_nil( GetGeomGen() ) ) {
330 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
334 GEOMGUI* library = 0;
335 // try to get-or-load corresponding GUI library
336 if( id == 111 || // MENU FILE - IMPORT BREP
337 id == 112 || // MENU FILE - IMPORT IGES
338 id == 113 || // MENU FILE - IMPORT STEP
339 id == 121 || // MENU FILE - EXPORT BREP
340 id == 122 || // MENU FILE - EXPORT IGES
341 id == 123 || // MENU FILE - EXPORT STEP
342 id == 2171 || // POPUP VIEWER - SELECT ONLY - VERTEX
343 id == 2172 || // POPUP VIEWER - SELECT ONLY - EDGE
344 id == 2173 || // POPUP VIEWER - SELECT ONLY - WIRE
345 id == 2174 || // POPUP VIEWER - SELECT ONLY - FACE
346 id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL
347 id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID
348 id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND
349 id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL
350 id == 31 || // MENU EDIT - COPY
351 id == 33 || // MENU EDIT - DELETE
352 id == 411 || // MENU SETTINGS - ADD IN STUDY
353 id == 412 || // MENU SETTINGS - SHADING COLOR
354 id == 5103 || // MENU TOOLS - CHECK GEOMETRY
355 id == 8032 || // POPUP VIEWER - COLOR
356 id == 8033 || // POPUP VIEWER - TRANSPARENCY
357 id == 8034 || // POPUP VIEWER - ISOS
358 id == 8035 || // POPUP VIEWER - AUTO COLOR
359 id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR
360 id == 804 || // POPUP VIEWER - ADD IN STUDY
361 id == 901 || // OBJECT BROWSER - RENAME
362 id == 9024 ) { // OBJECT BROWSER - OPEN
363 //cout << "id " << id << " received" << endl;
365 library = getLibrary( "libGEOMToolsGUI.so" );
367 library = getLibrary( "GEOMToolsGUI.dll" );
370 else if( id == 211 || // MENU VIEW - WIREFRAME/SHADING
371 id == 212 || // MENU VIEW - DISPLAY ALL
372 id == 213 || // MENU VIEW - DISPLAY ONLY
373 id == 214 || // MENU VIEW - ERASE ALL
374 id == 215 || // MENU VIEW - ERASE
375 id == 216 || // MENU VIEW - DISPLAY
376 id == 80311 || // POPUP VIEWER - WIREFRAME
377 id == 80312 ) { // POPUP VIEWER - SHADING
379 library = getLibrary( "libDisplayGUI.so" );
381 library = getLibrary( "DisplayGUI.dll" );
384 else if( id == 4011 || // MENU BASIC - POINT
385 id == 4012 || // MENU BASIC - LINE
386 id == 4013 || // MENU BASIC - CIRCLE
387 id == 4014 || // MENU BASIC - ELLIPSE
388 id == 4015 || // MENU BASIC - ARC
389 id == 4016 || // MENU BASIC - VECTOR
390 id == 4017 || // MENU BASIC - PLANE
391 id == 4018 || // MENU BASIC - WPLANE
392 id == 4019 || // MENU BASIC - CURVE
393 id == 4020 ) { // MENU BASIC - REPAIR
395 library = getLibrary( "libBasicGUI.so" );
397 library = getLibrary( "BasicGUI.dll" );
400 else if( id == 4021 || // MENU PRIMITIVE - BOX
401 id == 4022 || // MENU PRIMITIVE - CYLINDER
402 id == 4023 || // MENU PRIMITIVE - SPHERE
403 id == 4024 || // MENU PRIMITIVE - TORUS
404 id == 4025 ) { // MENU PRIMITIVE - CONE
406 library = getLibrary( "libPrimitiveGUI.so" );
408 library = getLibrary( "PrimitiveGUI.dll" );
411 else if( id == 4031 || // MENU GENERATION - PRISM
412 id == 4032 || // MENU GENERATION - REVOLUTION
413 id == 4033 || // MENU GENERATION - FILLING
414 id == 4034 ) { // MENU GENERATION - PIPE
416 library = getLibrary( "libGenerationGUI.so" );
418 library = getLibrary( "GenerationGUI.dll" );
421 else if( id == 404 || // MENU ENTITY - SKETCHER
422 id == 407 ) { // MENU ENTITY - EXPLODE
424 library = getLibrary( "libEntityGUI.so" );
426 library = getLibrary( "EntityGUI.dll" );
429 else if( id == 4081 || // MENU BUILD - EDGE
430 id == 4082 || // MENU BUILD - WIRE
431 id == 4083 || // MENU BUILD - FACE
432 id == 4084 || // MENU BUILD - SHELL
433 id == 4085 || // MENU BUILD - SOLID
434 id == 4086 ) { // MENU BUILD - COMPUND
436 library = getLibrary( "libBuildGUI.so" );
438 library = getLibrary( "BuildGUI.dll" );
441 else if( id == 5011 || // MENU BOOLEAN - FUSE
442 id == 5012 || // MENU BOOLEAN - COMMON
443 id == 5013 || // MENU BOOLEAN - CUT
444 id == 5014 ) { // MENU BOOLEAN - SECTION
446 library = getLibrary( "libBooleanGUI.so" );
448 library = getLibrary( "BooleanGUI.dll" );
451 else if( id == 5021 || // MENU TRANSFORMATION - TRANSLATION
452 id == 5022 || // MENU TRANSFORMATION - ROTATION
453 id == 5023 || // MENU TRANSFORMATION - LOCATION
454 id == 5024 || // MENU TRANSFORMATION - MIRROR
455 id == 5025 || // MENU TRANSFORMATION - SCALE
456 id == 5026 || // MENU TRANSFORMATION - OFFSET
457 id == 5027 || // MENU TRANSFORMATION - MULTI-TRANSLATION
458 id == 5028 ) { // MENU TRANSFORMATION - MULTI-ROTATION
460 library = getLibrary( "libTransformationGUI.so" );
462 library = getLibrary( "TransformationGUI.dll" );
465 else if( id == 503 || // MENU OPERATION - PARTITION
466 id == 504 || // MENU OPERATION - ARCHIMEDE
467 id == 505 || // MENU OPERATION - FILLET
468 id == 506 || // MENU OPERATION - CHAMFER
469 id == 507 ) { // MENU OPERATION - CLIPPING RANGE
471 library = getLibrary( "libOperationGUI.so" );
473 library = getLibrary( "OperationGUI.dll" );
476 else if( id == 601 || // MENU REPAIR - SEWING
477 id == 603 || // MENU REPAIR - SUPPRESS FACES
478 id == 604 || // MENU REPAIR - SUPPRESS HOLE
479 id == 605 || // MENU REPAIR - SHAPE PROCESSING
480 id == 606 || // MENU REPAIR - CLOSE CONTOUR
481 id == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES
482 id == 608 || // MENU REPAIR - ADD POINT ON EDGE
483 id == 609 || // MENU MEASURE - FREE BOUNDARIES
484 id == 610 || // MENU MEASURE - FREE FACES
485 id == 611 || // MENU REPAIR - CHANGE ORIENTATION
486 id == 602 || // MENU REPAIR - GLUE FACES
487 id == 612 ) { // MENU REPAIR - REMOVE EXTRA EDGES
489 library = getLibrary( "libRepairGUI.so" );
491 library = getLibrary( "RepairGUI.dll" );
494 else if( id == 701 || // MENU MEASURE - PROPERTIES
495 id == 702 || // MENU MEASURE - CDG
496 id == 703 || // MENU MEASURE - INERTIA
497 id == 704 || // MENU MEASURE - NORMALE
498 id == 7041 || // MENU MEASURE - BOUNDING BOX
499 id == 7042 || // MENU MEASURE - MIN DISTANCE
500 id == 7043 || // MENU MEASURE - ANGLE
501 id == 705 || // MENU MEASURE - TOLERANCE
502 id == 706 || // MENU MEASURE - WHATIS
503 id == 707 || // MENU MEASURE - CHECK
504 id == 7072 || // MENU MEASURE - CHECK COMPOUND OF BLOCKS
505 id == 708 ) { // MENU MEASURE - POINT COORDINATES
507 library = getLibrary( "libMeasureGUI.so" );
509 library = getLibrary( "MeasureGUI.dll" );
512 else if( id == 800 || // MENU GROUP - CREATE
513 id == 8001 || // POPUP MENU - CREATE GROUP
514 id == 801 ) { // MENU GROUP - EDIT
516 library = getLibrary( "libGroupGUI.so" );
518 library = getLibrary( "GroupGUI.dll" );
521 else if( id == 9999 || // MENU BLOCKS - HEXAHEDRAL SOLID
522 id == 9998 || // MENU BLOCKS - MULTI-TRANSFORMATION
523 id == 9997 || // MENU BLOCKS - QUADRANGLE FACE
524 id == 99991 || // MENU BLOCKS - PROPAGATE
525 id == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS
527 library = getLibrary( "libBlocksGUI.so" );
529 library = getLibrary( "BlocksGUI.dll" );
533 // call method of corresponding GUI library
535 library->OnGUIEvent( id, desk );
537 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
541 //=================================================================================
542 // function : GeometryGUI::OnKeyPress()
543 // purpose : Called when any key is pressed by user [static]
544 //=================================================================================
545 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* win, QKeyEvent* pe )
549 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
550 SUIT_Application* anApp = application();
552 bOk = bOk && it.value()->OnKeyPress( pe, anApp->desktop(), win );
558 //=================================================================================
559 // function : GeometryGUI::OnMouseMove()
560 // purpose : Manages mouse move events [static]
561 //=================================================================================
562 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* win, QMouseEvent* pe )
566 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
567 SUIT_Application* anApp = application();
569 bOk = bOk && it.value()->OnMouseMove( pe, anApp->desktop(), win );
575 //=================================================================================
576 // function : GeometryGUI::0nMousePress()
577 // purpose : Manage mouse press events [static]
578 //=================================================================================
579 void GeometryGUI::OnMousePress( SUIT_ViewWindow* win, QMouseEvent* pe )
582 // OnMousePress() should return false if this event should be processed further
583 // (see OCCViewer_Viewer3d::onMousePress() for explanation)
584 bool processed = false;
585 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
586 SUIT_Application* anApp = application();
588 processed = processed || it.value()->OnMousePress( pe, anApp->desktop(), win );
594 static void UpdateVtkSelection()
596 QPtrList<SUIT_ViewWindow> winList = application()->desktop()->windows();
597 SUIT_ViewWindow* win = 0;
598 for ( win = winList.first(); win; win = winList.next() ) {
599 if ( win->getViewManager()->getTypeView() == VIEW_VTK ) {
600 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
602 SVTK_RenderWindowInteractor* anInteractor = vw->getRWInteractor();
603 anInteractor->SetSelectionProp();
604 anInteractor->SetSelectionTolerance();
605 SVTK_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
607 aStyle->setPreselectionProp();
614 //=================================================================================
615 // function : GeometryGUI::SetSettings()
616 // purpose : Called when GEOM module is activated [static]
617 //=================================================================================
618 bool GeometryGUI::SetSettings()
620 QMenuBar* Mb = parent->getMainMenuBar();
621 SUIT_Study* ActiveStudy = application()->activeStudy();
623 // Wireframe or Shading
625 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
626 bool ViewOCC = ( window && window->getViewManager()->getType() == VIEW_OCC );
627 bool ViewVTK = ( window && window->getViewManager()->getType() == VIEW_VTK );
629 OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( window->getViewManager() );
631 Handle(AIS_InteractiveContext) ic = vm->getOCCViewer()->getAISContext();
632 DisplayMode = ic->DisplayMode();
635 else if ( ViewVTK ) {
636 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
638 SVTK_RenderWindowInteractor* myRenderInter = vw->getRWInteractor();
639 DisplayMode = myRenderInter->GetDisplayMode();
643 if( DisplayMode == 1 )
645 Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) );
647 Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) );
650 // Add in Study - !!!ALWAYS TRUE!!! /////// VSR : TO BE REMOVED
651 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
652 int Settings_AddInStudy;
653 // if(!AddInStudy.isEmpty())
654 // Settings_AddInStudy = AddInStudy.toInt();
657 Settings_AddInStudy = 1;
658 Mb->setItemChecked(411, Settings_AddInStudy);
661 QString S = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
663 QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", "100");
666 int count = ActiveStudy->getStudyFramesCount();
667 for(int i = 0; i < count; i++) {
668 if(ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC) {
669 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
670 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
672 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
673 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
675 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
677 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
683 // PAL5356: update VTK selection
684 ::UpdateVtkSelection();
687 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
688 bOk = bOk && it.data()->SetSettings( parent );
690 // MZN: Enable/disable "Clipping range" menu item(from GEOM_CLIPPING variable)
691 if (getenv( "GEOM_CLIPPING" ) == NULL)
693 QMenuItem* mi = Mb->findItem(50);
694 if (mi && mi->popup())
695 mi->popup()->removeItem(507);
702 //=======================================================================
703 // function : createGeomAction
705 //=======================================================================
706 void GeometryGUI::createGeomAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
709 QWidget* parent = application()->desktop();
710 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
712 if ( icon_id.length() )
713 pix = resMgr->loadPixmap( "GEOM", tr( icon_id.toLatin1().constData() ) );
715 pix = resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+po_id).toLatin1().constData() ), false );
719 QString tooltip = tr( (QString( "TOP_" )+po_id).toLatin1().constData() ),
720 menu = tr( (QString( "MEN_" )+po_id).toLatin1().constData() ),
721 status_bar = tr( (QString( "STB_" )+po_id).toLatin1().constData() );
723 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
728 //=======================================================================
729 // function : GeometryGUI::initialize()
730 // purpose : Called when GEOM module is created
731 //=======================================================================
732 void GeometryGUI::initialize( CAM_Application* app )
734 SalomeApp_Module::initialize( app );
736 // ----- create actions --------------
738 createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) );
739 createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) );
741 createGeomAction( 33, "DELETE", "", Qt::Key_Delete );
743 createGeomAction( 4011, "POINT" );
744 createGeomAction( 4012, "LINE" );
745 createGeomAction( 4013, "CIRCLE" );
746 createGeomAction( 4014, "ELLIPSE" );
747 createGeomAction( 4015, "ARC" );
748 createGeomAction( 4019, "CURVE" );
749 createGeomAction( 4016, "VECTOR" );
750 createGeomAction( 4017, "PLANE" );
751 createGeomAction( 4018, "WORK_PLANE" );
752 createGeomAction( 4020, "LOCAL_CS" );
754 createGeomAction( 4021, "BOX" );
755 createGeomAction( 4022, "CYLINDER" );
756 createGeomAction( 4023, "SPHERE" );
757 createGeomAction( 4024, "TORUS" );
758 createGeomAction( 4025, "CONE" );
760 createGeomAction( 4031, "EXTRUSION" );
761 createGeomAction( 4032, "REVOLUTION" );
762 createGeomAction( 4033, "FILLING" );
763 createGeomAction( 4034, "PIPE" );
765 createGeomAction( 800, "GROUP_CREATE" );
766 createGeomAction( 801, "GROUP_EDIT" );
768 createGeomAction( 9997, "Q_FACE" );
769 createGeomAction( 9999, "HEX_SOLID" );
771 createGeomAction( 404, "SKETCH" );
772 createGeomAction( 407, "EXPLODE" );
774 createGeomAction( 4081, "EDGE" );
775 createGeomAction( 4082, "WIRE" );
776 createGeomAction( 4083, "FACE" );
777 createGeomAction( 4084, "SHELL" );
778 createGeomAction( 4085, "SOLID" );
779 createGeomAction( 4086, "COMPOUND" );
781 createGeomAction( 5011, "FUSE" );
782 createGeomAction( 5012, "COMMON" );
783 createGeomAction( 5013, "CUT" );
784 createGeomAction( 5014, "SECTION" );
786 createGeomAction( 5021, "TRANSLATION" );
787 createGeomAction( 5022, "ROTATION" );
788 createGeomAction( 5023, "MODIFY_LOCATION" );
789 createGeomAction( 5024, "MIRROR" );
790 createGeomAction( 5025, "SCALE" );
791 createGeomAction( 5026, "OFFSET" );
792 createGeomAction( 5027, "MUL_TRANSLATION" );
793 createGeomAction( 5028, "MUL_ROTATION" );
795 createGeomAction( 503, "PARTITION" );
796 createGeomAction( 504, "ARCHIMEDE" );
797 createGeomAction( 505, "FILLET" );
798 createGeomAction( 506, "CHAMFER" );
799 //createGeomAction( 507, "CLIPPING" );
801 createGeomAction( 9998, "MUL_TRANSFORM" );
802 createGeomAction( 9995, "EXPLODE_BLOCKS" );
803 createGeomAction( 99991, "PROPAGATE" );
805 createGeomAction( 601, "SEWING" );
806 createGeomAction( 602, "GLUE_FACES" );
807 createGeomAction( 603, "SUPPRESS_FACES" );
808 createGeomAction( 604, "SUPPERSS_HOLES" );
809 createGeomAction( 605, "SHAPE_PROCESS" );
810 createGeomAction( 606, "CLOSE_CONTOUR" );
811 createGeomAction( 607, "SUPPRESS_INT_WIRES" );
812 createGeomAction( 608, "POINT_ON_EDGE" );
813 createGeomAction( 609, "CHECK_FREE_BNDS" );
814 createGeomAction( 610, "CHECK_FREE_FACES" );
815 createGeomAction( 611, "CHANGE_ORIENTATION" );
816 createGeomAction( 612, "REMOVE_EXTRA_EDGES" );
818 createGeomAction( 708, "POINT_COORDS" );
819 createGeomAction( 701, "BASIC_PROPS" );
820 createGeomAction( 702, "MASS_CENTER" );
821 createGeomAction( 703, "INERTIA" );
822 createGeomAction( 704, "NORMALE" );
823 createGeomAction( 7041, "BND_BOX" );
824 createGeomAction( 7042, "MIN_DIST" );
825 createGeomAction( 7043, "MEASURE_ANGLE" );
827 createGeomAction( 705, "TOLERANCE" );
828 createGeomAction( 706, "WHAT_IS" );
829 createGeomAction( 707, "CHECK" );
830 createGeomAction( 7072, "CHECK_COMPOUND" );
832 #ifdef _DEBUG_ // PAL16821
833 createGeomAction( 5103, "CHECK_GEOMETRY" );
835 createGeomAction( 412, "SHADING_COLOR" );
837 createGeomAction( 211, "SHADING" );
838 createGeomAction( 212, "DISPLAY_ALL" );
839 createGeomAction( 214, "ERASE_ALL" );
840 createGeomAction( 216, "DISPLAY" );
841 createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true );
842 createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true );
843 createGeomAction( 2173, "WIRE_SEL_ONLY", "", 0, true );
844 createGeomAction( 2174, "FACE_SEL_ONLY", "", 0, true );
845 createGeomAction( 2175, "SHELL_SEL_ONLY", "", 0, true );
846 createGeomAction( 2176, "SOLID_SEL_ONLY", "", 0, true );
847 createGeomAction( 2177, "COMPOUND_SEL_ONLY", "", 0, true );
848 createGeomAction( 2178, "ALL_SEL_ONLY", "", 0, true );
849 createGeomAction( 213, "DISPLAY_ONLY" );
850 createGeomAction( 215, "ERASE" );
852 createGeomAction( 901, "POP_RENAME", "", Qt::Key_F2 );
853 createGeomAction( 80311, "POP_WIREFRAME", "", 0, true );
854 createGeomAction( 80312, "POP_SHADING", "", 0, true );
855 createGeomAction( 8032, "POP_COLOR" );
856 createGeomAction( 8033, "POP_TRANSPARENCY" );
857 createGeomAction( 8034, "POP_ISOS" );
858 createGeomAction( 8035, "POP_AUTO_COLOR" );
859 createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" );
860 createGeomAction( 8001, "POP_CREATE_GROUP" );
862 // make wireframe-shading items to be exclusive (only one at a time is selected)
863 //QActionGroup* dispModeGr = new QActionGroup( this, "", true );
864 //dispModeGr->add( action( 80311 ) );
865 //dispModeGr->add( action( 80312 ) );
866 // ---- create menu --------------------------
868 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
869 createMenu( separator(), fileId, 10 );
870 createMenu( 111, fileId, 10 );
871 createMenu( 121, fileId, 10 );
872 createMenu( separator(), fileId, -1 );
874 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
875 createMenu( 33, editId, -1 );
877 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
879 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
880 createMenu( 4011, basicId, -1 );
881 createMenu( 4012, basicId, -1 );
882 createMenu( 4013, basicId, -1 );
883 createMenu( 4014, basicId, -1 );
884 createMenu( 4015, basicId, -1 );
885 createMenu( 4019, basicId, -1 );
886 createMenu( separator(), basicId, -1 );
887 createMenu( 4016, basicId, -1 );
888 createMenu( 4017, basicId, -1 );
889 createMenu( 4018, basicId, -1 );
890 createMenu( 4020, basicId, -1 );
892 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
893 createMenu( 4021, primId, -1 );
894 createMenu( 4022, primId, -1 );
895 createMenu( 4023, primId, -1 );
896 createMenu( 4024, primId, -1 );
897 createMenu( 4025, primId, -1 );
899 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
900 createMenu( 4031, genId, -1 );
901 createMenu( 4032, genId, -1 );
902 createMenu( 4033, genId, -1 );
903 createMenu( 4034, genId, -1 );
904 createMenu( separator(), newEntId, -1 );
906 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
907 createMenu( 800, groupId, -1 );
908 createMenu( 801, groupId, -1 );
909 createMenu( separator(), newEntId, -1 );
911 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
912 createMenu( 9997, blocksId, -1 );
913 createMenu( 9999, blocksId, -1 );
915 createMenu( separator(), newEntId, -1 );
916 createMenu( 404, newEntId, -1 );
917 createMenu( separator(), newEntId, -1 );
918 createMenu( 407, newEntId, -1 );
920 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
921 createMenu( 4081, buildId, -1 );
922 createMenu( 4082, buildId, -1 );
923 createMenu( 4083, buildId, -1 );
924 createMenu( 4084, buildId, -1 );
925 createMenu( 4085, buildId, -1 );
926 createMenu( 4086, buildId, -1 );
928 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
930 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
931 createMenu( 5011, boolId, -1 );
932 createMenu( 5012, boolId, -1 );
933 createMenu( 5013, boolId, -1 );
934 createMenu( 5014, boolId, -1 );
936 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
937 createMenu( 5021, transId, -1 );
938 createMenu( 5022, transId, -1 );
939 createMenu( 5023, transId, -1 );
940 createMenu( 5024, transId, -1 );
941 createMenu( 5025, transId, -1 );
942 createMenu( 5026, transId, -1 );
943 createMenu( separator(), transId, -1 );
944 createMenu( 5027, transId, -1 );
945 createMenu( 5028, transId, -1 );
947 createMenu( 503, operId, -1 );
948 createMenu( 504, operId, -1 );
949 createMenu( separator(), operId, -1 );
950 createMenu( 505, transId, -1 );
951 createMenu( 506, transId, -1 );
952 //createMenu( 507, transId, -1 );
954 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
955 createMenu( 9998, blockId, -1 );
956 createMenu( 9995, blockId, -1 );
957 createMenu( 99991, blockId, -1 );
959 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
960 createMenu( 605, repairId, -1 );
961 createMenu( 603, repairId, -1 );
962 createMenu( 606, repairId, -1 );
963 createMenu( 607, repairId, -1 );
964 createMenu( 604, repairId, -1 );
965 createMenu( 601, repairId, -1 );
966 createMenu( 602, repairId, -1 );
967 createMenu( 608, repairId, -1 );
968 //createMenu( 609, repairId, -1 );
969 //createMenu( 610, repairId, -1 );
970 createMenu( 611, repairId, -1 );
971 createMenu( 612, repairId, -1 );
973 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
974 createMenu( 708, measurId, -1 );
975 createMenu( 701, measurId, -1 );
976 createMenu( separator(), measurId, -1 );
977 createMenu( 702, measurId, -1 );
978 createMenu( 703, measurId, -1 );
979 createMenu( 704, measurId, -1 );
980 // NPAL16572: move "Check free boundaries" and "Check free faces" from "Repair" to "Measure"
981 createMenu( separator(), measurId, -1 );
982 createMenu( 609, measurId, -1 );
983 createMenu( 610, measurId, -1 );
985 createMenu( separator(), measurId, -1 );
987 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
988 createMenu( 7041, dimId, -1 );
989 createMenu( 7042, dimId, -1 );
990 createMenu( 7043, dimId, -1 );
991 createMenu( separator(), measurId, -1 );
993 createMenu( 705, measurId, -1 );
994 createMenu( separator(), measurId, -1 );
995 createMenu( 706, measurId, -1 );
996 createMenu( 707, measurId, -1 );
997 createMenu( 7072, measurId, -1 );
999 #ifdef _DEBUG_ // PAL16821
1000 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1001 createMenu( separator(), toolsId, -1 );
1002 createMenu( 5103, toolsId, -1 );
1004 //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 );
1005 //createMenu( separator(), prefId, -1 );
1006 //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 );
1007 //createMenu( 412, geomId, -1 );
1008 //createMenu( separator(), prefId, -1 );
1010 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1011 createMenu( separator(), viewId, -1 );
1013 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1014 createMenu( 211, dispmodeId, -1 );
1016 createMenu( separator(), viewId, -1 );
1017 createMenu( 212, viewId, -1 );
1018 createMenu( 214, viewId, -1 );
1019 createMenu( separator(), viewId, -1 );
1023 because of these items are accessible through object browser and viewers
1024 we have removed they from main menu
1026 createMenu( 216, viewId, -1 );
1027 createMenu( 213, viewId, -1 );
1028 createMenu( 215, viewId, -1 );
1031 // ---- create toolbars --------------------------
1033 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1034 createTool( 4011, basicTbId );
1035 createTool( 4012, basicTbId );
1036 createTool( 4013, basicTbId );
1037 createTool( 4014, basicTbId );
1038 createTool( 4015, basicTbId );
1039 createTool( 4019, basicTbId );
1040 createTool( 4016, basicTbId );
1041 createTool( 4017, basicTbId );
1042 createTool( 4018, basicTbId );
1043 createTool( 4020, basicTbId );
1045 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1046 createTool( 4021, primTbId );
1047 createTool( 4022, primTbId );
1048 createTool( 4023, primTbId );
1049 createTool( 4024, primTbId );
1050 createTool( 4025, primTbId );
1052 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1053 createTool( 5011, boolTbId );
1054 createTool( 5012, boolTbId );
1055 createTool( 5013, boolTbId );
1056 createTool( 5014, boolTbId );
1058 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1059 createTool( 4031, genTbId );
1060 createTool( 4032, genTbId );
1061 createTool( 4033, genTbId );
1062 createTool( 4034, genTbId );
1064 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1065 createTool( 5021, transTbId );
1066 createTool( 5022, transTbId );
1067 createTool( 5023, transTbId );
1068 createTool( 5024, transTbId );
1069 createTool( 5025, transTbId );
1070 createTool( 5026, transTbId );
1071 createTool( separator(), transTbId );
1072 createTool( 5027, transTbId );
1073 createTool( 5028, transTbId );
1075 // ---- create popup menus --------------------------
1077 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1078 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1080 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1081 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1083 QString autoColorPrefix =
1084 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1086 QtxPopupMgr* mgr = popupMgr();
1087 mgr->insert( action( 901 ), -1, -1 ); // rename
1088 mgr->setRule( action( 901 ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
1089 mgr->insert( action( 33 ), -1, -1 ); // delete
1090 mgr->setRule( action( 33 ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1091 mgr->insert( action( 8001 ), -1, -1 ); // create group
1092 mgr->setRule( action( 8001 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1093 mgr->insert( action( 801 ), -1, -1 ); // edit group
1094 mgr->setRule( action( 801 ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1095 mgr->insert( separator(), -1, -1 ); // -----------
1096 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1097 mgr->insert( action( 80311 ), dispmodeId, -1 ); // wireframe
1098 mgr->setRule( action( 80311 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1099 mgr->setRule( action( 80311 ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1100 mgr->insert( action( 80312 ), dispmodeId, -1 ); // shading
1101 mgr->setRule( action( 80312 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1102 mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1103 mgr->insert( separator(), -1, -1 ); // -----------
1104 mgr->insert( action( 8032 ), -1, -1 ); // color
1105 mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1106 mgr->insert( action( 8033 ), -1, -1 ); // transparency
1107 mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1108 mgr->insert( action( 8034 ), -1, -1 ); // isos
1109 mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1110 mgr->insert( separator(), -1, -1 ); // -----------
1111 mgr->insert( action( 8035 ), -1, -1 ); // auto color
1112 mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1113 mgr->insert( action( 8036 ), -1, -1 ); // disable auto color
1114 mgr->setRule( action( 8036 ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1115 mgr->insert( separator(), -1, -1 ); // -----------
1118 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1119 onlyComponent = "((type='Component') and selcount=1)",
1120 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1121 types = "'Shape' 'Group'";
1123 mgr->insert( action( 216 ), -1, -1 ); // display
1124 mgr->setRule( action( 216 ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1126 mgr->insert( action( 215 ), -1, -1 ); // erase
1127 mgr->setRule( action( 215 ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1129 mgr->insert( action( 214 ), -1, -1 ); // erase All
1130 mgr->setRule( action( 214 ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1132 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1134 int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1135 mgr->insert( action(2171), selectolnyId, -1); //Vertex
1136 mgr->setRule(action(2171), selectOnly, QtxPopupMgr::VisibleRule);
1137 mgr->setRule(action(2171), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1138 mgr->insert( action(2172), selectolnyId, -1); //Edge
1139 mgr->setRule(action(2172), selectOnly, QtxPopupMgr::VisibleRule);
1140 mgr->setRule(action(2172), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1141 mgr->insert( action(2173), selectolnyId, -1); //Wire
1142 mgr->setRule(action(2173), selectOnly, QtxPopupMgr::VisibleRule);
1143 mgr->setRule(action(2173), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1144 mgr->insert( action(2174), selectolnyId, -1); //Face
1145 mgr->setRule(action(2174), selectOnly, QtxPopupMgr::VisibleRule);
1146 mgr->setRule(action(2174), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1147 mgr->insert( action(2175), selectolnyId, -1); //Shell
1148 mgr->setRule(action(2175), selectOnly, QtxPopupMgr::VisibleRule);
1149 mgr->setRule(action(2175), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1150 mgr->insert( action(2176), selectolnyId, -1); //Solid
1151 mgr->setRule(action(2176), selectOnly, QtxPopupMgr::VisibleRule);
1152 mgr->setRule(action(2176), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1153 mgr->insert( action(2177), selectolnyId, -1); //Compound
1154 mgr->setRule(action(2177), selectOnly, QtxPopupMgr::VisibleRule);
1155 mgr->setRule(action(2177), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1156 mgr->insert( separator(), selectolnyId, -1);
1157 mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter
1158 mgr->setRule(action(2178), selectOnly, QtxPopupMgr::VisibleRule);
1159 mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1160 mgr->insert( action( 213 ), -1, -1 ); // display only
1161 mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1162 mgr->insert( separator(), -1, -1 );
1164 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1167 //=======================================================================
1168 // function : GeometryGUI::activateModule()
1169 // purpose : Called when GEOM module is activated
1170 //=======================================================================
1171 bool GeometryGUI::activateModule( SUIT_Study* study )
1173 if ( CORBA::is_nil( myComponentGeom ) )
1176 bool res = SalomeApp_Module::activateModule( study );
1181 setMenuShown( true );
1182 setToolShown( true );
1184 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1185 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1187 // Reset actions accelerator keys
1188 //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import
1189 //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export
1190 action(111)->setEnabled(true); // Import
1191 action(121)->setEnabled(true); // Export
1193 GUIMap::Iterator it;
1194 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1195 it.value()->activate( application()->desktop() );
1197 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1198 SUIT_ViewManager* vm;
1199 ViewManagerList OCCViewManagers, VTKViewManagers;
1201 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1202 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1203 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1204 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1206 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1207 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1208 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1209 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1211 // disable OCC selectors
1212 //getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1213 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1214 while ( itOCCSel.hasNext() )
1215 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1216 sr->setEnabled(true);
1218 // disable VTK selectors
1219 //getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1220 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1221 while ( itVTKSel.hasNext() )
1222 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1223 sr->setEnabled(true);
1229 //=======================================================================
1230 // function : GeometryGUI::deactivateModule()
1231 // purpose : Called when GEOM module is deactivated
1232 //=======================================================================
1233 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1235 setMenuShown( false );
1236 setToolShown( false );
1238 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1239 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1241 EmitSignalCloseAllDialogs();
1243 GUIMap::Iterator it;
1244 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1245 it.value()->deactivate();
1247 // Unset actions accelerator keys
1248 //action(111)->setAccel(QKeySequence()); // Import
1249 //action(121)->setAccel(QKeySequence()); // Export
1250 action(111)->setEnabled(false); // Import
1251 action(121)->setEnabled(false); // Export
1253 myOCCSelectors.clear();
1254 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1256 myVTKSelectors.clear();
1257 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1259 return SalomeApp_Module::deactivateModule( study );
1262 //=======================================================================
1263 // function : GeometryGUI::BuildPresentation()
1265 //=======================================================================
1266 void GeometryGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& io, SUIT_ViewWindow* win )
1268 //GEOM_Displayer().Display( io, false, win );
1271 //=======================================================================
1272 // function : onWindowActivated()
1273 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1274 //=======================================================================
1275 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1280 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1281 const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1283 // disable non-OCC viewframe menu commands
1284 // action( 404 )->setEnabled( ViewOCC ); // SKETCHER
1285 action( 603 )->setEnabled( ViewOCC ); // SuppressFace
1286 action( 604 )->setEnabled( ViewOCC ); // SuppressHole
1287 action( 606 )->setEnabled( ViewOCC ); // CloseContour
1288 action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires
1289 action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
1290 // action( 609 )->setEnabled( ViewOCC ); // Free boundaries
1291 // action( 413 )->setEnabled( ViewOCC || ViewVTK ); // Isos Settings
1293 action( 800 )->setEnabled( ViewOCC ); // Create Group
1294 action( 801 )->setEnabled( ViewOCC ); // Edit Group
1296 action( 9998 )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1299 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1301 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1302 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1305 void GeometryGUI::viewManagers( QStringList& lst ) const
1307 lst.append( OCCViewer_Viewer::Type() );
1310 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1312 if ( vm->getType() == OCCViewer_Viewer::Type() )
1314 qDebug( "connect" );
1315 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1316 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1317 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1318 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1319 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1320 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1323 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1324 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1326 // disable OCC selectors
1327 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1328 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1329 while ( itOCCSel.hasNext() )
1330 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1331 sr->setEnabled(true);
1333 else if ( vm->getType() == SVTK_Viewer::Type() )
1335 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1336 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1338 // disable VTK selectors
1339 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1340 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1341 while ( itVTKSel.hasNext() )
1342 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1343 sr->setEnabled(true);
1347 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1349 SUIT_ViewModel* viewer = vm->getViewModel();
1350 if ( vm->getType() == OCCViewer_Viewer::Type() )
1352 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1353 while ( itOCCSel.hasNext() )
1354 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1355 if ( sr->viewer() == viewer )
1357 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1361 if ( vm->getType() == SVTK_Viewer::Type() )
1363 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1364 while ( itVTKSel.hasNext() )
1365 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1366 if ( sr->viewer() == viewer )
1368 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1374 QString GeometryGUI::engineIOR() const
1376 if ( !CORBA::is_nil( GetGeomGen() ) )
1377 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1381 LightApp_Selection* GeometryGUI::createSelection() const
1383 return new GEOMGUI_Selection();
1386 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1388 SalomeApp_Module::contextMenuPopup( client, menu, title );
1390 getApp()->selectionMgr()->selectedObjects( lst );
1391 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
1392 Handle(SALOME_InteractiveObject) io = lst.First();
1393 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1394 _PTR(Study) study = appStudy->studyDS();
1395 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
1397 title = QString( obj->GetName().c_str() );
1401 void GeometryGUI::createPreferences()
1403 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1405 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1406 setPreferenceProperty( genGroup, "columns", 1 );
1408 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1409 LightApp_Preferences::Selector,
1410 "Geometry", "display_mode" );
1412 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1413 LightApp_Preferences::Color, "Geometry", "shading_color" );
1415 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1416 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1418 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1419 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1421 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1422 LightApp_Preferences::Color, "Geometry", "line_color" );
1424 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1425 LightApp_Preferences::Color, "Geometry", "point_color" );
1427 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1428 LightApp_Preferences::Color, "Geometry", "isos_color" );
1430 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1431 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1433 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1435 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1436 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1438 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1439 LightApp_Preferences::DblSpin, "Geometry", "marker_scale" );
1441 // Set property for default display mode
1442 QStringList aModesList;
1443 aModesList.append( tr("MEN_WIREFRAME") );
1444 aModesList.append( tr("MEN_SHADING") );
1446 QList<QVariant> anIndexesList;
1447 anIndexesList.append(0);
1448 anIndexesList.append(1);
1450 setPreferenceProperty( dispmode, "strings", aModesList );
1451 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1453 // Set property for step value for spinboxes
1454 setPreferenceProperty( step, "min", 0.001 );
1455 setPreferenceProperty( step, "max", 10000 );
1456 setPreferenceProperty( step, "precision", 3 );
1458 // Set property for type of vertex marker
1459 QStringList aTypeOfMarkerList;
1460 QList<QVariant> anTypeOfMarkerIndexesList;
1462 aTypeOfMarkerList.append( tr("TOM_PLUS") );
1463 anTypeOfMarkerIndexesList.append(Aspect_TOM_PLUS);
1465 aTypeOfMarkerList.append( tr("TOM_POINT") );
1466 anTypeOfMarkerIndexesList.append(Aspect_TOM_POINT);
1468 aTypeOfMarkerList.append( tr("TOM_STAR") );
1469 anTypeOfMarkerIndexesList.append(Aspect_TOM_STAR);
1471 aTypeOfMarkerList.append( tr("TOM_O") );
1472 anTypeOfMarkerIndexesList.append(Aspect_TOM_O);
1474 aTypeOfMarkerList.append( tr("TOM_X") );
1475 anTypeOfMarkerIndexesList.append(Aspect_TOM_X);
1477 aTypeOfMarkerList.append( tr("TOM_O_POINT") );
1478 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_POINT);
1480 aTypeOfMarkerList.append( tr("TOM_O_PLUS") );
1481 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_PLUS);
1483 aTypeOfMarkerList.append( tr("TOM_O_STAR") );
1484 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_STAR);
1486 aTypeOfMarkerList.append( tr("TOM_O_X") );
1487 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_X);
1490 setPreferenceProperty( typeOfMarker, "strings", aTypeOfMarkerList );
1491 setPreferenceProperty( typeOfMarker, "indexes", anTypeOfMarkerIndexesList );
1493 // Set property for Vertex Marker scale
1494 setPreferenceProperty( markerScale, "min", 1. );
1495 setPreferenceProperty( markerScale, "max", 7. );
1496 setPreferenceProperty( markerScale, "precision", 0.01 );
1497 setPreferenceProperty( markerScale, "step", 0.5 );
1501 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1503 if (section == "Geometry") {
1504 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1505 if (param == QString("SettingsGeomStep")) {
1506 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1507 EmitSignalDefaultStepValueChanged(spin_step);
1512 LightApp_Displayer* GeometryGUI::displayer()
1515 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1519 void GeometryGUI::setLocalSelectionMode(const int mode)
1521 myLocalSelectionMode = mode;
1523 int GeometryGUI::getLocalSelectionMode() const
1525 return myLocalSelectionMode;