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 <LightApp_DataObject.h>
51 #include <SalomeApp_Study.h>
52 #include <LightApp_Preferences.h>
53 #include <SALOME_LifeCycleCORBA.hxx>
54 #include <SALOME_ListIO.hxx>
55 #include <SALOME_ListIteratorOfListIO.hxx>
63 #include <Prs3d_Drawer.hxx>
64 #include <Prs3d_IsoAspect.hxx>
65 #include <Aspect_TypeOfMarker.hxx>
66 #include <OSD_SharedLibrary.hxx>
68 #include <utilities.h>
70 #include <vtkCamera.h>
71 #include <vtkRenderer.h>
76 Standard_EXPORT CAM_Module* createModule() {
77 return new GeometryGUI();
83 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
85 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
87 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
88 if (CORBA::is_nil(myComponentGeom))
90 return GeometryGUI::myComponentGeom;
93 bool GeometryGUI::InitGeomGen()
96 if( CORBA::is_nil( myComponentGeom ) ) return false;
100 //=======================================================================
101 // function : ClientSObjectToObject
103 //=======================================================================
104 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
106 _PTR(GenericAttribute) anAttr;
107 CORBA::Object_var anObj;
109 std::string aValue = theSObject->GetIOR();
110 if (strcmp(aValue.c_str(), "") != 0) {
111 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
112 anObj = anORB->string_to_object(aValue.c_str());
115 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
117 return anObj._retn();
120 //=======================================================================
121 // function : ClientStudyToStudy
123 //=======================================================================
124 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
126 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
127 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
128 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
129 int aStudyID = theStudy->StudyId();
130 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
131 return aDSStudy._retn();
134 //=======================================================================
135 // function : GeometryGUI::GeometryGUI()
136 // purpose : Constructor
137 //=======================================================================
138 GeometryGUI::GeometryGUI() :
139 SalomeApp_Module( "GEOM" )
141 if ( CORBA::is_nil( myComponentGeom ) )
143 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
144 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "GEOM" );
145 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
149 myActiveDialogBox = 0;
152 gp_Pnt origin = gp_Pnt(0., 0., 0.);
153 gp_Dir direction = gp_Dir(0., 0., 1.);
154 myWorkingPlane = gp_Ax3(origin, direction);
157 myLocalSelectionMode = GEOM_ALLOBJECTS;
160 //=======================================================================
161 // function : GeometryGUI::~GeometryGUI()
162 // purpose : Destructor
163 //=======================================================================
164 GeometryGUI::~GeometryGUI()
166 while (!myOCCSelectors.isEmpty())
167 delete myOCCSelectors.takeFirst();
169 while (!myVTKSelectors.isEmpty())
170 delete myVTKSelectors.takeFirst();
173 //=======================================================================
174 // function : GeometryGUI::getLibrary()
175 // purpose : get or load GUI library by name [ internal ]
176 //=======================================================================
177 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
178 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
180 if ( !myGUIMap.contains( libraryName ) ) {
181 // try to load library if it is not loaded yet
184 libs = getenv( "LD_LIBRARY_PATH" );
185 if( !libs.isEmpty() ) {
186 QStringList dirList = libs.split( ":", QString::SkipEmptyParts ); // skip empty entries
188 libs = getenv( "PATH" );
189 if( !libs.isEmpty() ) {
190 QStringList dirList = libs.split( ";", QString::SkipEmptyParts ); // skip empty entries
192 for( int i = dirList.count()-1; i >= 0; i-- ) {
193 QString dir = dirList[ i ];
194 QFileInfo fi( Qtx::addSlash( dirList[ i ] ) + libraryName );
196 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().data() );
197 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
199 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
200 continue; // continue search further
202 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
203 if ( osdF != NULL ) {
204 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
205 GEOMGUI* libGUI = (*func)(this);
207 myGUIMap[ libraryName ] = libGUI;
208 break; // found and loaded!
215 if ( myGUIMap.contains( libraryName ) )
216 // library is successfully loaded
217 return myGUIMap[ libraryName ];
221 //=======================================================================
222 // function : GeometryGUI::ActiveWorkingPlane()
223 // purpose : Activate Working Plane View
224 //=======================================================================
225 void GeometryGUI::ActiveWorkingPlane()
227 gp_Dir DZ = myWorkingPlane.Direction();
228 gp_Dir DY = myWorkingPlane.YDirection();
230 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
231 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
232 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
235 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
237 Handle(V3d_View) view3d = vw->getViewPort()->getView();
239 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
240 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
246 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
248 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
250 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
251 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
252 camera->SetFocalPoint(0,0,0);
259 //=======================================================================
260 // function : GeometryGUI::SetActiveDialogBox()
261 // purpose : Set active dialog box
262 //=======================================================================
263 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
265 myActiveDialogBox = (QDialog*)aDlg;
268 //=======================================================================
269 // function : GeometryGUI::EmitSignalDeactivateDialog()
270 // purpose : Emit a signal to deactivate the active dialog Box
271 //=======================================================================
272 void GeometryGUI::EmitSignalDeactivateDialog()
274 emit SignalDeactivateActiveDialog();
277 //=======================================================================
278 // function : GeometryGUI::EmitSignalCloseAllDialogs()
279 // purpose : Emit a signal to close all non modal dialogs box
280 //=======================================================================
281 void GeometryGUI::EmitSignalCloseAllDialogs()
283 emit SignalCloseAllDialogs();
286 //=======================================================================
287 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
288 // purpose : Emit a signal to inform that default real spin box step has
290 //=======================================================================
291 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
293 emit SignalDefaultStepValueChanged(newVal);
296 //=======================================================================
297 // function : GeometryGUI::OnGUIEvent()
298 // purpose : common slot for all menu/toolbar actions
299 //=======================================================================
300 void GeometryGUI::OnGUIEvent()
302 const QObject* obj = sender();
303 if ( !obj || !obj->inherits( "QAction" ) )
305 int id = actionId((QAction*)obj);
310 //=======================================================================
311 // function : GeometryGUI::OnGUIEvent()
312 // purpose : manage all events on GUI [static]
313 //=======================================================================
314 void GeometryGUI::OnGUIEvent( int id )
316 SUIT_Application* anApp = application();
318 SUIT_Desktop* desk = anApp->desktop();
320 // check type of the active viewframe
321 SUIT_ViewWindow* window = desk->activeWindow();
322 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
323 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
324 // if current viewframe is not of OCC and not of VTK type - return immediately
325 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
326 bool NotViewerDependentCommand = ( id == 901 || id == 216 || id == 213 );
327 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommand )
330 // fix for IPAL9103, point 2
331 if ( CORBA::is_nil( GetGeomGen() ) ) {
332 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
336 GEOMGUI* library = 0;
337 // try to get-or-load corresponding GUI library
338 if( id == 111 || // MENU FILE - IMPORT BREP
339 id == 112 || // MENU FILE - IMPORT IGES
340 id == 113 || // MENU FILE - IMPORT STEP
341 id == 121 || // MENU FILE - EXPORT BREP
342 id == 122 || // MENU FILE - EXPORT IGES
343 id == 123 || // MENU FILE - EXPORT STEP
344 id == 2171 || // POPUP VIEWER - SELECT ONLY - VERTEX
345 id == 2172 || // POPUP VIEWER - SELECT ONLY - EDGE
346 id == 2173 || // POPUP VIEWER - SELECT ONLY - WIRE
347 id == 2174 || // POPUP VIEWER - SELECT ONLY - FACE
348 id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL
349 id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID
350 id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND
351 id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL
352 id == 31 || // MENU EDIT - COPY
353 id == 33 || // MENU EDIT - DELETE
354 id == 411 || // MENU SETTINGS - ADD IN STUDY
355 id == 412 || // MENU SETTINGS - SHADING COLOR
356 id == 5103 || // MENU TOOLS - CHECK GEOMETRY
357 id == 8032 || // POPUP VIEWER - COLOR
358 id == 8033 || // POPUP VIEWER - TRANSPARENCY
359 id == 8034 || // POPUP VIEWER - ISOS
360 id == 8035 || // POPUP VIEWER - AUTO COLOR
361 id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR
362 id == 804 || // POPUP VIEWER - ADD IN STUDY
363 id == 901 || // OBJECT BROWSER - RENAME
364 id == 9024 ) { // OBJECT BROWSER - OPEN
365 //cout << "id " << id << " received" << endl;
367 library = getLibrary( "libGEOMToolsGUI.so" );
369 library = getLibrary( "GEOMToolsGUI.dll" );
372 else if( id == 211 || // MENU VIEW - WIREFRAME/SHADING
373 id == 212 || // MENU VIEW - DISPLAY ALL
374 id == 213 || // MENU VIEW - DISPLAY ONLY
375 id == 214 || // MENU VIEW - ERASE ALL
376 id == 215 || // MENU VIEW - ERASE
377 id == 216 || // MENU VIEW - DISPLAY
378 id == 80311 || // POPUP VIEWER - WIREFRAME
379 id == 80312 ) { // POPUP VIEWER - SHADING
381 library = getLibrary( "libDisplayGUI.so" );
383 library = getLibrary( "DisplayGUI.dll" );
386 else if( id == 4011 || // MENU BASIC - POINT
387 id == 4012 || // MENU BASIC - LINE
388 id == 4013 || // MENU BASIC - CIRCLE
389 id == 4014 || // MENU BASIC - ELLIPSE
390 id == 4015 || // MENU BASIC - ARC
391 id == 4016 || // MENU BASIC - VECTOR
392 id == 4017 || // MENU BASIC - PLANE
393 id == 4018 || // MENU BASIC - WPLANE
394 id == 4019 || // MENU BASIC - CURVE
395 id == 4020 ) { // MENU BASIC - REPAIR
397 library = getLibrary( "libBasicGUI.so" );
399 library = getLibrary( "BasicGUI.dll" );
402 else if( id == 4021 || // MENU PRIMITIVE - BOX
403 id == 4022 || // MENU PRIMITIVE - CYLINDER
404 id == 4023 || // MENU PRIMITIVE - SPHERE
405 id == 4024 || // MENU PRIMITIVE - TORUS
406 id == 4025 ) { // MENU PRIMITIVE - CONE
408 library = getLibrary( "libPrimitiveGUI.so" );
410 library = getLibrary( "PrimitiveGUI.dll" );
413 else if( id == 4031 || // MENU GENERATION - PRISM
414 id == 4032 || // MENU GENERATION - REVOLUTION
415 id == 4033 || // MENU GENERATION - FILLING
416 id == 4034 ) { // MENU GENERATION - PIPE
418 library = getLibrary( "libGenerationGUI.so" );
420 library = getLibrary( "GenerationGUI.dll" );
423 else if( id == 404 || // MENU ENTITY - SKETCHER
424 id == 407 ) { // MENU ENTITY - EXPLODE
426 library = getLibrary( "libEntityGUI.so" );
428 library = getLibrary( "EntityGUI.dll" );
431 else if( id == 4081 || // MENU BUILD - EDGE
432 id == 4082 || // MENU BUILD - WIRE
433 id == 4083 || // MENU BUILD - FACE
434 id == 4084 || // MENU BUILD - SHELL
435 id == 4085 || // MENU BUILD - SOLID
436 id == 4086 ) { // MENU BUILD - COMPUND
438 library = getLibrary( "libBuildGUI.so" );
440 library = getLibrary( "BuildGUI.dll" );
443 else if( id == 5011 || // MENU BOOLEAN - FUSE
444 id == 5012 || // MENU BOOLEAN - COMMON
445 id == 5013 || // MENU BOOLEAN - CUT
446 id == 5014 ) { // MENU BOOLEAN - SECTION
448 library = getLibrary( "libBooleanGUI.so" );
450 library = getLibrary( "BooleanGUI.dll" );
453 else if( id == 5021 || // MENU TRANSFORMATION - TRANSLATION
454 id == 5022 || // MENU TRANSFORMATION - ROTATION
455 id == 5023 || // MENU TRANSFORMATION - LOCATION
456 id == 5024 || // MENU TRANSFORMATION - MIRROR
457 id == 5025 || // MENU TRANSFORMATION - SCALE
458 id == 5026 || // MENU TRANSFORMATION - OFFSET
459 id == 5027 || // MENU TRANSFORMATION - MULTI-TRANSLATION
460 id == 5028 ) { // MENU TRANSFORMATION - MULTI-ROTATION
462 library = getLibrary( "libTransformationGUI.so" );
464 library = getLibrary( "TransformationGUI.dll" );
467 else if( id == 503 || // MENU OPERATION - PARTITION
468 id == 504 || // MENU OPERATION - ARCHIMEDE
469 id == 505 || // MENU OPERATION - FILLET
470 id == 506 || // MENU OPERATION - CHAMFER
471 id == 507 || // MENU OPERATION - CLIPPING RANGE
472 id == 508 ) { // MENU OPERATION - GET SHAPES ON SHAPE
474 library = getLibrary( "libOperationGUI.so" );
476 library = getLibrary( "OperationGUI.dll" );
479 else if( id == 601 || // MENU REPAIR - SEWING
480 id == 603 || // MENU REPAIR - SUPPRESS FACES
481 id == 604 || // MENU REPAIR - SUPPRESS HOLE
482 id == 605 || // MENU REPAIR - SHAPE PROCESSING
483 id == 606 || // MENU REPAIR - CLOSE CONTOUR
484 id == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES
485 id == 608 || // MENU REPAIR - ADD POINT ON EDGE
486 id == 609 || // MENU MEASURE - FREE BOUNDARIES
487 id == 610 || // MENU MEASURE - FREE FACES
488 id == 611 || // MENU REPAIR - CHANGE ORIENTATION
489 id == 602 || // MENU REPAIR - GLUE FACES
490 id == 612 ) { // MENU REPAIR - REMOVE EXTRA EDGES
492 library = getLibrary( "libRepairGUI.so" );
494 library = getLibrary( "RepairGUI.dll" );
497 else if( id == 701 || // MENU MEASURE - PROPERTIES
498 id == 702 || // MENU MEASURE - CDG
499 id == 703 || // MENU MEASURE - INERTIA
500 id == 704 || // MENU MEASURE - NORMALE
501 id == 7041 || // MENU MEASURE - BOUNDING BOX
502 id == 7042 || // MENU MEASURE - MIN DISTANCE
503 id == 7043 || // MENU MEASURE - ANGLE
504 id == 705 || // MENU MEASURE - TOLERANCE
505 id == 706 || // MENU MEASURE - WHATIS
506 id == 707 || // MENU MEASURE - CHECK
507 id == 7072 || // MENU MEASURE - CHECK COMPOUND OF BLOCKS
508 id == 708 ) { // MENU MEASURE - POINT COORDINATES
510 library = getLibrary( "libMeasureGUI.so" );
512 library = getLibrary( "MeasureGUI.dll" );
515 else if( id == 800 || // MENU GROUP - CREATE
516 id == 8001 || // POPUP MENU - CREATE GROUP
517 id == 801 ) { // MENU GROUP - EDIT
519 library = getLibrary( "libGroupGUI.so" );
521 library = getLibrary( "GroupGUI.dll" );
524 else if( id == 9999 || // MENU BLOCKS - HEXAHEDRAL SOLID
525 id == 9998 || // MENU BLOCKS - MULTI-TRANSFORMATION
526 id == 9997 || // MENU BLOCKS - QUADRANGLE FACE
527 id == 99991 || // MENU BLOCKS - PROPAGATE
528 id == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS
530 library = getLibrary( "libBlocksGUI.so" );
532 library = getLibrary( "BlocksGUI.dll" );
536 // call method of corresponding GUI library
538 library->OnGUIEvent( id, desk );
540 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
544 //=================================================================================
545 // function : GeometryGUI::OnKeyPress()
546 // purpose : Called when any key is pressed by user [static]
547 //=================================================================================
548 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* win, QKeyEvent* pe )
552 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
553 SUIT_Application* anApp = application();
555 bOk = bOk && it.value()->OnKeyPress( pe, anApp->desktop(), win );
561 //=================================================================================
562 // function : GeometryGUI::OnMouseMove()
563 // purpose : Manages mouse move events [static]
564 //=================================================================================
565 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* win, QMouseEvent* pe )
569 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
570 SUIT_Application* anApp = application();
572 bOk = bOk && it.value()->OnMouseMove( pe, anApp->desktop(), win );
578 //=================================================================================
579 // function : GeometryGUI::0nMousePress()
580 // purpose : Manage mouse press events [static]
581 //=================================================================================
582 void GeometryGUI::OnMousePress( SUIT_ViewWindow* win, QMouseEvent* pe )
585 // OnMousePress() should return false if this event should be processed further
586 // (see OCCViewer_Viewer3d::onMousePress() for explanation)
587 bool processed = false;
588 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
589 SUIT_Application* anApp = application();
591 processed = processed || it.value()->OnMousePress( pe, anApp->desktop(), win );
597 static void UpdateVtkSelection()
599 QPtrList<SUIT_ViewWindow> winList = application()->desktop()->windows();
600 SUIT_ViewWindow* win = 0;
601 for ( win = winList.first(); win; win = winList.next() ) {
602 if ( win->getViewManager()->getTypeView() == VIEW_VTK ) {
603 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
605 SVTK_RenderWindowInteractor* anInteractor = vw->getRWInteractor();
606 anInteractor->SetSelectionProp();
607 anInteractor->SetSelectionTolerance();
608 SVTK_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
610 aStyle->setPreselectionProp();
617 //=================================================================================
618 // function : GeometryGUI::SetSettings()
619 // purpose : Called when GEOM module is activated [static]
620 //=================================================================================
621 bool GeometryGUI::SetSettings()
623 QMenuBar* Mb = parent->getMainMenuBar();
624 SUIT_Study* ActiveStudy = application()->activeStudy();
626 // Wireframe or Shading
628 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
629 bool ViewOCC = ( window && window->getViewManager()->getType() == VIEW_OCC );
630 bool ViewVTK = ( window && window->getViewManager()->getType() == VIEW_VTK );
632 OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( window->getViewManager() );
634 Handle(AIS_InteractiveContext) ic = vm->getOCCViewer()->getAISContext();
635 DisplayMode = ic->DisplayMode();
638 else if ( ViewVTK ) {
639 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
641 SVTK_RenderWindowInteractor* myRenderInter = vw->getRWInteractor();
642 DisplayMode = myRenderInter->GetDisplayMode();
646 if( DisplayMode == 1 )
648 Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) );
650 Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) );
653 // Add in Study - !!!ALWAYS TRUE!!! /////// VSR : TO BE REMOVED
654 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
655 int Settings_AddInStudy;
656 // if(!AddInStudy.isEmpty())
657 // Settings_AddInStudy = AddInStudy.toInt();
660 Settings_AddInStudy = 1;
661 Mb->setItemChecked(411, Settings_AddInStudy);
664 QString S = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
666 QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", "100");
669 int count = ActiveStudy->getStudyFramesCount();
670 for(int i = 0; i < count; i++) {
671 if(ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC) {
672 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
673 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
675 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
676 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
678 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
680 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
686 // PAL5356: update VTK selection
687 ::UpdateVtkSelection();
690 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
691 bOk = bOk && it.data()->SetSettings( parent );
693 // MZN: Enable/disable "Clipping range" menu item(from GEOM_CLIPPING variable)
694 if (getenv( "GEOM_CLIPPING" ) == NULL)
696 QMenuItem* mi = Mb->findItem(50);
697 if (mi && mi->popup())
698 mi->popup()->removeItem(507);
705 //=======================================================================
706 // function : createGeomAction
708 //=======================================================================
709 void GeometryGUI::createGeomAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
712 QWidget* parent = application()->desktop();
713 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
715 if ( icon_id.length() )
716 pix = resMgr->loadPixmap( "GEOM", tr( icon_id.toLatin1().constData() ) );
718 pix = resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+po_id).toLatin1().constData() ), false );
722 QString tooltip = tr( (QString( "TOP_" )+po_id).toLatin1().constData() ),
723 menu = tr( (QString( "MEN_" )+po_id).toLatin1().constData() ),
724 status_bar = tr( (QString( "STB_" )+po_id).toLatin1().constData() );
726 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
731 //=======================================================================
732 // function : GeometryGUI::initialize()
733 // purpose : Called when GEOM module is created
734 //=======================================================================
735 void GeometryGUI::initialize( CAM_Application* app )
737 SalomeApp_Module::initialize( app );
739 // ----- create actions --------------
741 createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) );
742 createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) );
744 createGeomAction( 33, "DELETE", "", Qt::Key_Delete );
746 createGeomAction( 4011, "POINT" );
747 createGeomAction( 4012, "LINE" );
748 createGeomAction( 4013, "CIRCLE" );
749 createGeomAction( 4014, "ELLIPSE" );
750 createGeomAction( 4015, "ARC" );
751 createGeomAction( 4019, "CURVE" );
752 createGeomAction( 4016, "VECTOR" );
753 createGeomAction( 4017, "PLANE" );
754 createGeomAction( 4018, "WORK_PLANE" );
755 createGeomAction( 4020, "LOCAL_CS" );
757 createGeomAction( 4021, "BOX" );
758 createGeomAction( 4022, "CYLINDER" );
759 createGeomAction( 4023, "SPHERE" );
760 createGeomAction( 4024, "TORUS" );
761 createGeomAction( 4025, "CONE" );
763 createGeomAction( 4031, "EXTRUSION" );
764 createGeomAction( 4032, "REVOLUTION" );
765 createGeomAction( 4033, "FILLING" );
766 createGeomAction( 4034, "PIPE" );
768 createGeomAction( 800, "GROUP_CREATE" );
769 createGeomAction( 801, "GROUP_EDIT" );
771 createGeomAction( 9997, "Q_FACE" );
772 createGeomAction( 9999, "HEX_SOLID" );
774 createGeomAction( 404, "SKETCH" );
775 createGeomAction( 407, "EXPLODE" );
777 createGeomAction( 4081, "EDGE" );
778 createGeomAction( 4082, "WIRE" );
779 createGeomAction( 4083, "FACE" );
780 createGeomAction( 4084, "SHELL" );
781 createGeomAction( 4085, "SOLID" );
782 createGeomAction( 4086, "COMPOUND" );
784 createGeomAction( 5011, "FUSE" );
785 createGeomAction( 5012, "COMMON" );
786 createGeomAction( 5013, "CUT" );
787 createGeomAction( 5014, "SECTION" );
789 createGeomAction( 5021, "TRANSLATION" );
790 createGeomAction( 5022, "ROTATION" );
791 createGeomAction( 5023, "MODIFY_LOCATION" );
792 createGeomAction( 5024, "MIRROR" );
793 createGeomAction( 5025, "SCALE" );
794 createGeomAction( 5026, "OFFSET" );
795 createGeomAction( 5027, "MUL_TRANSLATION" );
796 createGeomAction( 5028, "MUL_ROTATION" );
798 createGeomAction( 503, "PARTITION" );
799 createGeomAction( 504, "ARCHIMEDE" );
800 createGeomAction( 505, "FILLET" );
801 createGeomAction( 506, "CHAMFER" );
802 //createGeomAction( 507, "CLIPPING" );
803 createGeomAction( 508, "GET_SHAPES_ON_SHAPES" );
805 createGeomAction( 9998, "MUL_TRANSFORM" );
806 createGeomAction( 9995, "EXPLODE_BLOCKS" );
807 createGeomAction( 99991, "PROPAGATE" );
809 createGeomAction( 601, "SEWING" );
810 createGeomAction( 602, "GLUE_FACES" );
811 createGeomAction( 603, "SUPPRESS_FACES" );
812 createGeomAction( 604, "SUPPERSS_HOLES" );
813 createGeomAction( 605, "SHAPE_PROCESS" );
814 createGeomAction( 606, "CLOSE_CONTOUR" );
815 createGeomAction( 607, "SUPPRESS_INT_WIRES" );
816 createGeomAction( 608, "POINT_ON_EDGE" );
817 createGeomAction( 609, "CHECK_FREE_BNDS" );
818 createGeomAction( 610, "CHECK_FREE_FACES" );
819 createGeomAction( 611, "CHANGE_ORIENTATION" );
820 createGeomAction( 612, "REMOVE_EXTRA_EDGES" );
822 createGeomAction( 708, "POINT_COORDS" );
823 createGeomAction( 701, "BASIC_PROPS" );
824 createGeomAction( 702, "MASS_CENTER" );
825 createGeomAction( 703, "INERTIA" );
826 createGeomAction( 704, "NORMALE" );
827 createGeomAction( 7041, "BND_BOX" );
828 createGeomAction( 7042, "MIN_DIST" );
829 createGeomAction( 7043, "MEASURE_ANGLE" );
831 createGeomAction( 705, "TOLERANCE" );
832 createGeomAction( 706, "WHAT_IS" );
833 createGeomAction( 707, "CHECK" );
834 createGeomAction( 7072, "CHECK_COMPOUND" );
836 #ifdef _DEBUG_ // PAL16821
837 createGeomAction( 5103, "CHECK_GEOMETRY" );
839 createGeomAction( 412, "SHADING_COLOR" );
841 createGeomAction( 211, "SHADING" );
842 createGeomAction( 212, "DISPLAY_ALL" );
843 createGeomAction( 214, "ERASE_ALL" );
844 createGeomAction( 216, "DISPLAY" );
845 createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true );
846 createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true );
847 createGeomAction( 2173, "WIRE_SEL_ONLY", "", 0, true );
848 createGeomAction( 2174, "FACE_SEL_ONLY", "", 0, true );
849 createGeomAction( 2175, "SHELL_SEL_ONLY", "", 0, true );
850 createGeomAction( 2176, "SOLID_SEL_ONLY", "", 0, true );
851 createGeomAction( 2177, "COMPOUND_SEL_ONLY", "", 0, true );
852 createGeomAction( 2178, "ALL_SEL_ONLY", "", 0, true );
853 createGeomAction( 213, "DISPLAY_ONLY" );
854 createGeomAction( 215, "ERASE" );
856 createGeomAction( 901, "POP_RENAME", "", Qt::Key_F2 );
857 createGeomAction( 80311, "POP_WIREFRAME", "", 0, true );
858 createGeomAction( 80312, "POP_SHADING", "", 0, true );
859 createGeomAction( 8032, "POP_COLOR" );
860 createGeomAction( 8033, "POP_TRANSPARENCY" );
861 createGeomAction( 8034, "POP_ISOS" );
862 createGeomAction( 8035, "POP_AUTO_COLOR" );
863 createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" );
864 createGeomAction( 8001, "POP_CREATE_GROUP" );
866 // make wireframe-shading items to be exclusive (only one at a time is selected)
867 //QActionGroup* dispModeGr = new QActionGroup( this, "", true );
868 //dispModeGr->add( action( 80311 ) );
869 //dispModeGr->add( action( 80312 ) );
870 // ---- create menu --------------------------
872 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
873 createMenu( separator(), fileId, 10 );
874 createMenu( 111, fileId, 10 );
875 createMenu( 121, fileId, 10 );
876 createMenu( separator(), fileId, -1 );
878 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
879 createMenu( 33, editId, -1 );
881 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
883 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
884 createMenu( 4011, basicId, -1 );
885 createMenu( 4012, basicId, -1 );
886 createMenu( 4013, basicId, -1 );
887 createMenu( 4014, basicId, -1 );
888 createMenu( 4015, basicId, -1 );
889 createMenu( 4019, basicId, -1 );
890 createMenu( separator(), basicId, -1 );
891 createMenu( 4016, basicId, -1 );
892 createMenu( 4017, basicId, -1 );
893 createMenu( 4018, basicId, -1 );
894 createMenu( 4020, basicId, -1 );
896 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
897 createMenu( 4021, primId, -1 );
898 createMenu( 4022, primId, -1 );
899 createMenu( 4023, primId, -1 );
900 createMenu( 4024, primId, -1 );
901 createMenu( 4025, primId, -1 );
903 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
904 createMenu( 4031, genId, -1 );
905 createMenu( 4032, genId, -1 );
906 createMenu( 4033, genId, -1 );
907 createMenu( 4034, genId, -1 );
908 createMenu( separator(), newEntId, -1 );
910 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
911 createMenu( 800, groupId, -1 );
912 createMenu( 801, groupId, -1 );
913 createMenu( separator(), newEntId, -1 );
915 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
916 createMenu( 9997, blocksId, -1 );
917 createMenu( 9999, blocksId, -1 );
919 createMenu( separator(), newEntId, -1 );
920 createMenu( 404, newEntId, -1 );
921 createMenu( separator(), newEntId, -1 );
922 createMenu( 407, newEntId, -1 );
924 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
925 createMenu( 4081, buildId, -1 );
926 createMenu( 4082, buildId, -1 );
927 createMenu( 4083, buildId, -1 );
928 createMenu( 4084, buildId, -1 );
929 createMenu( 4085, buildId, -1 );
930 createMenu( 4086, buildId, -1 );
932 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
934 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
935 createMenu( 5011, boolId, -1 );
936 createMenu( 5012, boolId, -1 );
937 createMenu( 5013, boolId, -1 );
938 createMenu( 5014, boolId, -1 );
940 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
941 createMenu( 5021, transId, -1 );
942 createMenu( 5022, transId, -1 );
943 createMenu( 5023, transId, -1 );
944 createMenu( 5024, transId, -1 );
945 createMenu( 5025, transId, -1 );
946 createMenu( 5026, transId, -1 );
947 createMenu( separator(), transId, -1 );
948 createMenu( 5027, transId, -1 );
949 createMenu( 5028, transId, -1 );
951 createMenu( 503, operId, -1 );
952 createMenu( 504, operId, -1 );
953 createMenu( 508, operId, -1 );
954 createMenu( separator(), operId, -1 );
955 createMenu( 505, transId, -1 );
956 createMenu( 506, transId, -1 );
957 //createMenu( 507, transId, -1 );
959 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
960 createMenu( 9998, blockId, -1 );
961 createMenu( 9995, blockId, -1 );
962 createMenu( 99991, blockId, -1 );
964 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
965 createMenu( 605, repairId, -1 );
966 createMenu( 603, repairId, -1 );
967 createMenu( 606, repairId, -1 );
968 createMenu( 607, repairId, -1 );
969 createMenu( 604, repairId, -1 );
970 createMenu( 601, repairId, -1 );
971 createMenu( 602, repairId, -1 );
972 createMenu( 608, repairId, -1 );
973 //createMenu( 609, repairId, -1 );
974 //createMenu( 610, repairId, -1 );
975 createMenu( 611, repairId, -1 );
976 createMenu( 612, repairId, -1 );
978 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
979 createMenu( 708, measurId, -1 );
980 createMenu( 701, measurId, -1 );
981 createMenu( separator(), measurId, -1 );
982 createMenu( 702, measurId, -1 );
983 createMenu( 703, measurId, -1 );
984 createMenu( 704, measurId, -1 );
985 // NPAL16572: move "Check free boundaries" and "Check free faces" from "Repair" to "Measure"
986 createMenu( separator(), measurId, -1 );
987 createMenu( 609, measurId, -1 );
988 createMenu( 610, measurId, -1 );
990 createMenu( separator(), measurId, -1 );
992 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
993 createMenu( 7041, dimId, -1 );
994 createMenu( 7042, dimId, -1 );
995 createMenu( 7043, dimId, -1 );
996 createMenu( separator(), measurId, -1 );
998 createMenu( 705, measurId, -1 );
999 createMenu( separator(), measurId, -1 );
1000 createMenu( 706, measurId, -1 );
1001 createMenu( 707, measurId, -1 );
1002 createMenu( 7072, measurId, -1 );
1004 #ifdef _DEBUG_ // PAL16821
1005 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1006 createMenu( separator(), toolsId, -1 );
1007 createMenu( 5103, toolsId, -1 );
1009 //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 );
1010 //createMenu( separator(), prefId, -1 );
1011 //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 );
1012 //createMenu( 412, geomId, -1 );
1013 //createMenu( separator(), prefId, -1 );
1015 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1016 createMenu( separator(), viewId, -1 );
1018 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1019 createMenu( 211, dispmodeId, -1 );
1021 createMenu( separator(), viewId, -1 );
1022 createMenu( 212, viewId, -1 );
1023 createMenu( 214, viewId, -1 );
1024 createMenu( separator(), viewId, -1 );
1028 because of these items are accessible through object browser and viewers
1029 we have removed they from main menu
1031 createMenu( 216, viewId, -1 );
1032 createMenu( 213, viewId, -1 );
1033 createMenu( 215, viewId, -1 );
1036 // ---- create toolbars --------------------------
1038 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1039 createTool( 4011, basicTbId );
1040 createTool( 4012, basicTbId );
1041 createTool( 4013, basicTbId );
1042 createTool( 4014, basicTbId );
1043 createTool( 4015, basicTbId );
1044 createTool( 4019, basicTbId );
1045 createTool( 4016, basicTbId );
1046 createTool( 4017, basicTbId );
1047 createTool( 4018, basicTbId );
1048 createTool( 4020, basicTbId );
1050 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1051 createTool( 4021, primTbId );
1052 createTool( 4022, primTbId );
1053 createTool( 4023, primTbId );
1054 createTool( 4024, primTbId );
1055 createTool( 4025, primTbId );
1057 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1058 createTool( 5011, boolTbId );
1059 createTool( 5012, boolTbId );
1060 createTool( 5013, boolTbId );
1061 createTool( 5014, boolTbId );
1063 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1064 createTool( 4031, genTbId );
1065 createTool( 4032, genTbId );
1066 createTool( 4033, genTbId );
1067 createTool( 4034, genTbId );
1069 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1070 createTool( 5021, transTbId );
1071 createTool( 5022, transTbId );
1072 createTool( 5023, transTbId );
1073 createTool( 5024, transTbId );
1074 createTool( 5025, transTbId );
1075 createTool( 5026, transTbId );
1076 createTool( separator(), transTbId );
1077 createTool( 5027, transTbId );
1078 createTool( 5028, transTbId );
1080 // ---- create popup menus --------------------------
1082 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1083 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1085 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1086 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1088 QString autoColorPrefix =
1089 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1091 QtxPopupMgr* mgr = popupMgr();
1092 mgr->insert( action( 901 ), -1, -1 ); // rename
1093 mgr->setRule( action( 901 ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
1094 mgr->insert( action( 33 ), -1, -1 ); // delete
1095 mgr->setRule( action( 33 ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1096 mgr->insert( action( 8001 ), -1, -1 ); // create group
1097 mgr->setRule( action( 8001 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1098 mgr->insert( action( 801 ), -1, -1 ); // edit group
1099 mgr->setRule( action( 801 ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1100 mgr->insert( separator(), -1, -1 ); // -----------
1101 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1102 mgr->insert( action( 80311 ), dispmodeId, -1 ); // wireframe
1103 mgr->setRule( action( 80311 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1104 mgr->setRule( action( 80311 ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1105 mgr->insert( action( 80312 ), dispmodeId, -1 ); // shading
1106 mgr->setRule( action( 80312 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1107 mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1108 mgr->insert( separator(), -1, -1 ); // -----------
1109 mgr->insert( action( 8032 ), -1, -1 ); // color
1110 mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1111 mgr->insert( action( 8033 ), -1, -1 ); // transparency
1112 mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1113 mgr->insert( action( 8034 ), -1, -1 ); // isos
1114 mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1115 mgr->insert( separator(), -1, -1 ); // -----------
1116 mgr->insert( action( 8035 ), -1, -1 ); // auto color
1117 mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1118 mgr->insert( action( 8036 ), -1, -1 ); // disable auto color
1119 mgr->setRule( action( 8036 ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1120 mgr->insert( separator(), -1, -1 ); // -----------
1123 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1124 onlyComponent = "((type='Component') and selcount=1)",
1125 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1126 types = "'Shape' 'Group'";
1128 mgr->insert( action( 216 ), -1, -1 ); // display
1129 mgr->setRule( action( 216 ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1131 mgr->insert( action( 215 ), -1, -1 ); // erase
1132 mgr->setRule( action( 215 ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1134 mgr->insert( action( 214 ), -1, -1 ); // erase All
1135 mgr->setRule( action( 214 ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1137 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1139 int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1140 mgr->insert( action(2171), selectolnyId, -1); //Vertex
1141 mgr->setRule(action(2171), selectOnly, QtxPopupMgr::VisibleRule);
1142 mgr->setRule(action(2171), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1143 mgr->insert( action(2172), selectolnyId, -1); //Edge
1144 mgr->setRule(action(2172), selectOnly, QtxPopupMgr::VisibleRule);
1145 mgr->setRule(action(2172), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1146 mgr->insert( action(2173), selectolnyId, -1); //Wire
1147 mgr->setRule(action(2173), selectOnly, QtxPopupMgr::VisibleRule);
1148 mgr->setRule(action(2173), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1149 mgr->insert( action(2174), selectolnyId, -1); //Face
1150 mgr->setRule(action(2174), selectOnly, QtxPopupMgr::VisibleRule);
1151 mgr->setRule(action(2174), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1152 mgr->insert( action(2175), selectolnyId, -1); //Shell
1153 mgr->setRule(action(2175), selectOnly, QtxPopupMgr::VisibleRule);
1154 mgr->setRule(action(2175), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1155 mgr->insert( action(2176), selectolnyId, -1); //Solid
1156 mgr->setRule(action(2176), selectOnly, QtxPopupMgr::VisibleRule);
1157 mgr->setRule(action(2176), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1158 mgr->insert( action(2177), selectolnyId, -1); //Compound
1159 mgr->setRule(action(2177), selectOnly, QtxPopupMgr::VisibleRule);
1160 mgr->setRule(action(2177), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1161 mgr->insert( separator(), selectolnyId, -1);
1162 mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter
1163 mgr->setRule(action(2178), selectOnly, QtxPopupMgr::VisibleRule);
1164 mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1165 mgr->insert( action( 213 ), -1, -1 ); // display only
1166 mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1167 mgr->insert( separator(), -1, -1 );
1169 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1172 //=======================================================================
1173 // function : GeometryGUI::activateModule()
1174 // purpose : Called when GEOM module is activated
1175 //=======================================================================
1176 bool GeometryGUI::activateModule( SUIT_Study* study )
1178 if ( CORBA::is_nil( myComponentGeom ) )
1181 bool res = SalomeApp_Module::activateModule( study );
1186 setMenuShown( true );
1187 setToolShown( true );
1189 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1190 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1192 // Reset actions accelerator keys
1193 //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import
1194 //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export
1195 action(111)->setEnabled( true ); // Import: CTRL + Key_I
1196 action(121)->setEnabled( true ); // Export: CTRL + Key_E
1197 action( 33)->setEnabled( true ); // Delete: Key_Delete
1198 action(901)->setEnabled( true ); // Rename: Key_F2
1200 GUIMap::Iterator it;
1201 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1202 it.value()->activate( application()->desktop() );
1204 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1206 SUIT_ViewManager* vm;
1207 ViewManagerList OCCViewManagers, VTKViewManagers;
1209 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1210 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1211 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1212 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1214 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1215 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1216 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1217 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1220 SALOME_ListIO selected;
1221 sm->selectedObjects( selected );
1222 sm->clearSelected();
1224 // disable OCC selectors
1225 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1226 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1227 while ( itOCCSel.hasNext() )
1228 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1229 sr->setEnabled(true);
1231 // disable VTK selectors
1232 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1233 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1234 while ( itVTKSel.hasNext() )
1235 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1236 sr->setEnabled(true);
1238 sm->setSelectedObjects( selected, true ); //NPAL 19674
1244 //=======================================================================
1245 // function : GeometryGUI::deactivateModule()
1246 // purpose : Called when GEOM module is deactivated
1247 //=======================================================================
1248 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1250 setMenuShown( false );
1251 setToolShown( false );
1253 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1254 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1256 EmitSignalCloseAllDialogs();
1258 GUIMap::Iterator it;
1259 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1260 it.value()->deactivate();
1262 // Unset actions accelerator keys
1263 //action(111)->setAccel(QKeySequence()); // Import
1264 //action(121)->setAccel(QKeySequence()); // Export
1265 action(111)->setEnabled( false ); // Import: CTRL + Key_I
1266 action(121)->setEnabled( false ); // Export: CTRL + Key_E
1267 action( 33)->setEnabled( false ); // Delete: Key_Delete
1268 action(901)->setEnabled( false ); // Rename: Key_F2
1270 qDeleteAll(myOCCSelectors);
1271 myOCCSelectors.clear();
1272 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1274 qDeleteAll(myVTKSelectors);
1275 myVTKSelectors.clear();
1276 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1278 return SalomeApp_Module::deactivateModule( study );
1281 //=======================================================================
1282 // function : GeometryGUI::BuildPresentation()
1284 //=======================================================================
1285 void GeometryGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& io, SUIT_ViewWindow* win )
1287 //GEOM_Displayer().Display( io, false, win );
1290 //=======================================================================
1291 // function : onWindowActivated()
1292 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1293 //=======================================================================
1294 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1299 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1300 const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1302 // disable non-OCC viewframe menu commands
1303 // action( 404 )->setEnabled( ViewOCC ); // SKETCHER
1304 action( 603 )->setEnabled( ViewOCC ); // SuppressFace
1305 action( 604 )->setEnabled( ViewOCC ); // SuppressHole
1306 action( 606 )->setEnabled( ViewOCC ); // CloseContour
1307 action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires
1308 action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
1309 // action( 609 )->setEnabled( ViewOCC ); // Free boundaries
1311 action( 800 )->setEnabled( ViewOCC ); // Create Group
1312 action( 801 )->setEnabled( ViewOCC ); // Edit Group
1314 action( 9998 )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1317 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1319 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1320 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1323 void GeometryGUI::viewManagers( QStringList& lst ) const
1325 lst.append( OCCViewer_Viewer::Type() );
1328 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1330 if ( vm->getType() == OCCViewer_Viewer::Type() )
1332 qDebug( "connect" );
1333 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1334 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1335 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1336 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1337 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1338 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1341 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1342 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1344 // disable OCC selectors
1345 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1346 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1347 while ( itOCCSel.hasNext() )
1348 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1349 sr->setEnabled(true);
1351 else if ( vm->getType() == SVTK_Viewer::Type() )
1353 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1354 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1356 // disable VTK selectors
1357 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1358 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1359 while ( itVTKSel.hasNext() )
1360 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1361 sr->setEnabled(true);
1365 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1367 SUIT_ViewModel* viewer = vm->getViewModel();
1368 if ( vm->getType() == OCCViewer_Viewer::Type() )
1370 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1371 while ( itOCCSel.hasNext() )
1372 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1373 if ( sr->viewer() == viewer )
1375 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1379 if ( vm->getType() == SVTK_Viewer::Type() )
1381 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1382 while ( itVTKSel.hasNext() )
1383 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1384 if ( sr->viewer() == viewer )
1386 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1392 QString GeometryGUI::engineIOR() const
1394 if ( !CORBA::is_nil( GetGeomGen() ) )
1395 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1399 LightApp_Selection* GeometryGUI::createSelection() const
1401 return new GEOMGUI_Selection();
1404 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1406 SalomeApp_Module::contextMenuPopup( client, menu, title );
1408 getApp()->selectionMgr()->selectedObjects( lst );
1409 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
1410 Handle(SALOME_InteractiveObject) io = lst.First();
1411 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1412 _PTR(Study) study = appStudy->studyDS();
1413 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
1415 title = QString( obj->GetName().c_str() );
1419 void GeometryGUI::createPreferences()
1421 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1423 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1424 setPreferenceProperty( genGroup, "columns", 2 );
1426 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1427 LightApp_Preferences::Selector,
1428 "Geometry", "display_mode" );
1430 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1431 LightApp_Preferences::Color, "Geometry", "shading_color" );
1433 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1434 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1436 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1437 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1439 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1440 LightApp_Preferences::Color, "Geometry", "line_color" );
1442 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1443 LightApp_Preferences::Color, "Geometry", "point_color" );
1445 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1446 LightApp_Preferences::Color, "Geometry", "isos_color" );
1448 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1449 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1451 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1452 setPreferenceProperty( VertexGroup, "columns", 2 );
1454 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1455 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1457 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1458 LightApp_Preferences::DblSpin, "Geometry", "marker_scale" );
1460 // Set property for default display mode
1461 QStringList aModesList;
1462 aModesList.append( tr("MEN_WIREFRAME") );
1463 aModesList.append( tr("MEN_SHADING") );
1465 QList<QVariant> anIndexesList;
1466 anIndexesList.append(0);
1467 anIndexesList.append(1);
1469 setPreferenceProperty( dispmode, "strings", aModesList );
1470 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1472 // Set property for step value for spinboxes
1473 setPreferenceProperty( step, "min", 1 );
1474 setPreferenceProperty( step, "max", 10000 );
1475 setPreferenceProperty( step, "precision", 3 );
1477 // Set property for type of vertex marker
1478 QStringList aTypeOfMarkerList;
1479 QList<QVariant> anTypeOfMarkerIndexesList;
1481 aTypeOfMarkerList.append( tr("TOM_PLUS") );
1482 anTypeOfMarkerIndexesList.append(Aspect_TOM_PLUS);
1484 aTypeOfMarkerList.append( tr("TOM_POINT") );
1485 anTypeOfMarkerIndexesList.append(Aspect_TOM_POINT);
1487 aTypeOfMarkerList.append( tr("TOM_STAR") );
1488 anTypeOfMarkerIndexesList.append(Aspect_TOM_STAR);
1490 aTypeOfMarkerList.append( tr("TOM_O") );
1491 anTypeOfMarkerIndexesList.append(Aspect_TOM_O);
1493 aTypeOfMarkerList.append( tr("TOM_X") );
1494 anTypeOfMarkerIndexesList.append(Aspect_TOM_X);
1496 aTypeOfMarkerList.append( tr("TOM_O_POINT") );
1497 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_POINT);
1499 aTypeOfMarkerList.append( tr("TOM_O_PLUS") );
1500 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_PLUS);
1502 aTypeOfMarkerList.append( tr("TOM_O_STAR") );
1503 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_STAR);
1505 aTypeOfMarkerList.append( tr("TOM_O_X") );
1506 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_X);
1509 setPreferenceProperty( typeOfMarker, "strings", aTypeOfMarkerList );
1510 setPreferenceProperty( typeOfMarker, "indexes", anTypeOfMarkerIndexesList );
1512 // Set property for Vertex Marker scale
1513 setPreferenceProperty( markerScale, "min", 1. );
1514 setPreferenceProperty( markerScale, "max", 7. );
1515 setPreferenceProperty( markerScale, "precision", 0.01 );
1516 setPreferenceProperty( markerScale, "step", 0.5 );
1520 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1522 if (section == "Geometry") {
1523 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1524 if (param == QString("SettingsGeomStep")) {
1525 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1526 EmitSignalDefaultStepValueChanged(spin_step);
1531 LightApp_Displayer* GeometryGUI::displayer()
1534 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1538 void GeometryGUI::setLocalSelectionMode(const int mode)
1540 myLocalSelectionMode = mode;
1542 int GeometryGUI::getLocalSelectionMode() const
1544 return myLocalSelectionMode;