1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : GeometryGUI.cxx
25 // Author : Lucien PIGNOLONI
29 #include "GeometryGUI.h"
30 #include "GEOMGUI_OCCSelector.h"
31 #include "GEOMGUI_Selection.h"
32 #include "GEOM_Displayer.h"
34 #include <SUIT_Desktop.h>
35 #include <SUIT_MessageBox.h>
36 #include <SUIT_ResourceMgr.h>
37 #include <SUIT_Session.h>
38 #include <SUIT_ViewManager.h>
40 #include <QtxActionMenuMgr.h>
41 #include <QtxPopupMgr.h>
42 #include <CAM_Module.h>
44 #include <OCCViewer_ViewWindow.h>
45 #include <OCCViewer_ViewPort3d.h>
46 #include <OCCViewer_ViewModel.h>
47 #include <OCCViewer_ViewManager.h>
49 #include <SVTK_ViewWindow.h>
50 #include <SVTK_RenderWindowInteractor.h>
51 #include <SVTK_InteractorStyle.h>
52 #include <SVTK_ViewModel.h>
54 #include <SalomeApp_Application.h>
55 #include <LightApp_SelectionMgr.h>
56 #include <LightApp_VTKSelector.h>
57 #include <SalomeApp_Study.h>
58 #include <LightApp_Preferences.h>
59 #include <SALOME_LifeCycleCORBA.hxx>
60 #include <SALOME_ListIO.hxx>
68 #include <Prs3d_Drawer.hxx>
69 #include <Prs3d_IsoAspect.hxx>
70 #include <Aspect_TypeOfMarker.hxx>
71 #include <OSD_SharedLibrary.hxx>
73 #include <utilities.h>
75 #include <vtkCamera.h>
76 #include <vtkRenderer.h>
81 Standard_EXPORT CAM_Module* createModule() {
82 return new GeometryGUI();
88 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
90 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
92 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
93 if (CORBA::is_nil(myComponentGeom))
95 return GeometryGUI::myComponentGeom;
98 bool GeometryGUI::InitGeomGen()
101 if( CORBA::is_nil( myComponentGeom ) ) return false;
105 //=======================================================================
106 // function : ClientSObjectToObject
108 //=======================================================================
109 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
111 _PTR(GenericAttribute) anAttr;
112 CORBA::Object_var anObj;
114 std::string aValue = theSObject->GetIOR();
115 if (strcmp(aValue.c_str(), "") != 0) {
116 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
117 anObj = anORB->string_to_object(aValue.c_str());
120 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
122 return anObj._retn();
125 //=======================================================================
126 // function : ClientStudyToStudy
128 //=======================================================================
129 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
131 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
132 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
133 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
134 int aStudyID = theStudy->StudyId();
135 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
136 return aDSStudy._retn();
139 //=======================================================================
140 // function : GeometryGUI::GeometryGUI()
141 // purpose : Constructor
142 //=======================================================================
143 GeometryGUI::GeometryGUI() :
144 SalomeApp_Module( "GEOM" )
146 if ( CORBA::is_nil( myComponentGeom ) )
148 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
149 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "GEOM" );
150 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
154 myActiveDialogBox = 0;
157 gp_Pnt origin = gp_Pnt(0., 0., 0.);
158 gp_Dir direction = gp_Dir(0., 0., 1.);
159 myWorkingPlane = gp_Ax3(origin, direction);
162 myLocalSelectionMode = GEOM_ALLOBJECTS;
165 //=======================================================================
166 // function : GeometryGUI::~GeometryGUI()
167 // purpose : Destructor
168 //=======================================================================
169 GeometryGUI::~GeometryGUI()
171 while (!myOCCSelectors.isEmpty())
172 delete myOCCSelectors.takeFirst();
174 while (!myVTKSelectors.isEmpty())
175 delete myVTKSelectors.takeFirst();
178 //=======================================================================
179 // function : GeometryGUI::getLibrary()
180 // purpose : get or load GUI library by name [ internal ]
181 //=======================================================================
182 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
183 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
185 if ( !myGUIMap.contains( libraryName ) ) {
186 // try to load library if it is not loaded yet
189 libs = getenv( "LD_LIBRARY_PATH" );
190 if( !libs.isEmpty() ) {
191 QStringList dirList = libs.split( ":", QString::SkipEmptyParts ); // skip empty entries
193 libs = getenv( "PATH" );
194 if( !libs.isEmpty() ) {
195 QStringList dirList = libs.split( ";", QString::SkipEmptyParts ); // skip empty entries
197 for( int i = dirList.count()-1; i >= 0; i-- ) {
198 QString dir = dirList[ i ];
199 QFileInfo fi( Qtx::addSlash( dirList[ i ] ) + libraryName );
201 OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().data() );
202 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
204 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
205 continue; // continue search further
207 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
208 if ( osdF != NULL ) {
209 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
210 GEOMGUI* libGUI = (*func)(this);
212 myGUIMap[ libraryName ] = libGUI;
213 break; // found and loaded!
220 if ( myGUIMap.contains( libraryName ) )
221 // library is successfully loaded
222 return myGUIMap[ libraryName ];
226 //=======================================================================
227 // function : GeometryGUI::ActiveWorkingPlane()
228 // purpose : Activate Working Plane View
229 //=======================================================================
230 void GeometryGUI::ActiveWorkingPlane()
232 gp_Dir DZ = myWorkingPlane.Direction();
233 gp_Dir DY = myWorkingPlane.YDirection();
235 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
236 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
237 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
240 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
242 Handle(V3d_View) view3d = vw->getViewPort()->getView();
244 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
245 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
251 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
253 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
255 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
256 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
257 camera->SetFocalPoint(0,0,0);
264 //=======================================================================
265 // function : GeometryGUI::SetActiveDialogBox()
266 // purpose : Set active dialog box
267 //=======================================================================
268 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
270 myActiveDialogBox = (QDialog*)aDlg;
273 //=======================================================================
274 // function : GeometryGUI::EmitSignalDeactivateDialog()
275 // purpose : Emit a signal to deactivate the active dialog Box
276 //=======================================================================
277 void GeometryGUI::EmitSignalDeactivateDialog()
279 emit SignalDeactivateActiveDialog();
282 //=======================================================================
283 // function : GeometryGUI::EmitSignalCloseAllDialogs()
284 // purpose : Emit a signal to close all non modal dialogs box
285 //=======================================================================
286 void GeometryGUI::EmitSignalCloseAllDialogs()
288 emit SignalCloseAllDialogs();
291 //=======================================================================
292 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
293 // purpose : Emit a signal to inform that default real spin box step has
295 //=======================================================================
296 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
298 emit SignalDefaultStepValueChanged(newVal);
301 //=======================================================================
302 // function : GeometryGUI::OnGUIEvent()
303 // purpose : common slot for all menu/toolbar actions
304 //=======================================================================
305 void GeometryGUI::OnGUIEvent()
307 const QObject* obj = sender();
308 if ( !obj || !obj->inherits( "QAction" ) )
310 int id = actionId((QAction*)obj);
315 //=======================================================================
316 // function : GeometryGUI::OnGUIEvent()
317 // purpose : manage all events on GUI [static]
318 //=======================================================================
319 void GeometryGUI::OnGUIEvent( int id )
321 SUIT_Application* anApp = application();
323 SUIT_Desktop* desk = anApp->desktop();
325 // check type of the active viewframe
326 SUIT_ViewWindow* window = desk->activeWindow();
327 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
328 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
329 // if current viewframe is not of OCC and not of VTK type - return immediately
330 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
331 bool NotViewerDependentCommand = ( id == 901 || id == 216 || id == 213 );
332 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommand )
335 // fix for IPAL9103, point 2
336 if ( CORBA::is_nil( GetGeomGen() ) ) {
337 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
341 GEOMGUI* library = 0;
342 // try to get-or-load corresponding GUI library
343 if( id == 111 || // MENU FILE - IMPORT BREP
344 id == 112 || // MENU FILE - IMPORT IGES
345 id == 113 || // MENU FILE - IMPORT STEP
346 id == 121 || // MENU FILE - EXPORT BREP
347 id == 122 || // MENU FILE - EXPORT IGES
348 id == 123 || // MENU FILE - EXPORT STEP
349 id == 2171 || // POPUP VIEWER - SELECT ONLY - VERTEX
350 id == 2172 || // POPUP VIEWER - SELECT ONLY - EDGE
351 id == 2173 || // POPUP VIEWER - SELECT ONLY - WIRE
352 id == 2174 || // POPUP VIEWER - SELECT ONLY - FACE
353 id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL
354 id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID
355 id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND
356 id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL
357 id == 31 || // MENU EDIT - COPY
358 id == 33 || // MENU EDIT - DELETE
359 id == 411 || // MENU SETTINGS - ADD IN STUDY
360 id == 412 || // MENU SETTINGS - SHADING COLOR
361 id == 413 || // MENU SETTINGS - ISOS
362 id == 414 || // MENU SETTINGS - STEP VALUE FOR SPIN BOXES
363 id == 5103 || // MENU TOOLS - CHECK GEOMETRY
364 id == 8032 || // POPUP VIEWER - COLOR
365 id == 8033 || // POPUP VIEWER - TRANSPARENCY
366 id == 8034 || // POPUP VIEWER - ISOS
367 id == 804 || // POPUP VIEWER - ADD IN STUDY
368 id == 901 || // OBJECT BROWSER - RENAME
369 id == 9024 ) { // OBJECT BROWSER - OPEN
370 //cout << "id " << id << " received" << endl;
372 library = getLibrary( "libGEOMToolsGUI.so" );
374 library = getLibrary( "GEOMToolsGUI.dll" );
377 else if( id == 211 || // MENU VIEW - WIREFRAME/SHADING
378 id == 212 || // MENU VIEW - DISPLAY ALL
379 id == 213 || // MENU VIEW - DISPLAY ONLY
380 id == 214 || // MENU VIEW - ERASE ALL
381 id == 215 || // MENU VIEW - ERASE
382 id == 216 || // MENU VIEW - DISPLAY
383 id == 80311 || // POPUP VIEWER - WIREFRAME
384 id == 80312 ) { // POPUP VIEWER - SHADING
386 library = getLibrary( "libDisplayGUI.so" );
388 library = getLibrary( "DisplayGUI.dll" );
391 else if( id == 4011 || // MENU BASIC - POINT
392 id == 4012 || // MENU BASIC - LINE
393 id == 4013 || // MENU BASIC - CIRCLE
394 id == 4014 || // MENU BASIC - ELLIPSE
395 id == 4015 || // MENU BASIC - ARC
396 id == 4016 || // MENU BASIC - VECTOR
397 id == 4017 || // MENU BASIC - PLANE
398 id == 4018 || // MENU BASIC - WPLANE
399 id == 4019 || // MENU BASIC - CURVE
400 id == 4020 ) { // MENU BASIC - REPAIR
402 library = getLibrary( "libBasicGUI.so" );
404 library = getLibrary( "BasicGUI.dll" );
407 else if( id == 4021 || // MENU PRIMITIVE - BOX
408 id == 4022 || // MENU PRIMITIVE - CYLINDER
409 id == 4023 || // MENU PRIMITIVE - SPHERE
410 id == 4024 || // MENU PRIMITIVE - TORUS
411 id == 4025 ) { // MENU PRIMITIVE - CONE
413 library = getLibrary( "libPrimitiveGUI.so" );
415 library = getLibrary( "PrimitiveGUI.dll" );
418 else if( id == 4031 || // MENU GENERATION - PRISM
419 id == 4032 || // MENU GENERATION - REVOLUTION
420 id == 4033 || // MENU GENERATION - FILLING
421 id == 4034 ) { // MENU GENERATION - PIPE
423 library = getLibrary( "libGenerationGUI.so" );
425 library = getLibrary( "GenerationGUI.dll" );
428 else if( id == 404 || // MENU ENTITY - SKETCHER
429 id == 407 ) { // MENU ENTITY - EXPLODE
431 library = getLibrary( "libEntityGUI.so" );
433 library = getLibrary( "EntityGUI.dll" );
436 else if( id == 4081 || // MENU BUILD - EDGE
437 id == 4082 || // MENU BUILD - WIRE
438 id == 4083 || // MENU BUILD - FACE
439 id == 4084 || // MENU BUILD - SHELL
440 id == 4085 || // MENU BUILD - SOLID
441 id == 4086 ) { // MENU BUILD - COMPUND
443 library = getLibrary( "libBuildGUI.so" );
445 library = getLibrary( "BuildGUI.dll" );
448 else if( id == 5011 || // MENU BOOLEAN - FUSE
449 id == 5012 || // MENU BOOLEAN - COMMON
450 id == 5013 || // MENU BOOLEAN - CUT
451 id == 5014 ) { // MENU BOOLEAN - SECTION
453 library = getLibrary( "libBooleanGUI.so" );
455 library = getLibrary( "BooleanGUI.dll" );
458 else if( id == 5021 || // MENU TRANSFORMATION - TRANSLATION
459 id == 5022 || // MENU TRANSFORMATION - ROTATION
460 id == 5023 || // MENU TRANSFORMATION - LOCATION
461 id == 5024 || // MENU TRANSFORMATION - MIRROR
462 id == 5025 || // MENU TRANSFORMATION - SCALE
463 id == 5026 || // MENU TRANSFORMATION - OFFSET
464 id == 5027 || // MENU TRANSFORMATION - MULTI-TRANSLATION
465 id == 5028 ) { // MENU TRANSFORMATION - MULTI-ROTATION
467 library = getLibrary( "libTransformationGUI.so" );
469 library = getLibrary( "TransformationGUI.dll" );
472 else if( id == 503 || // MENU OPERATION - PARTITION
473 id == 504 || // MENU OPERATION - ARCHIMEDE
474 id == 505 || // MENU OPERATION - FILLET
475 id == 506 || // MENU OPERATION - CHAMFER
476 id == 507 ) { // MENU OPERATION - CLIPPING RANGE
478 library = getLibrary( "libOperationGUI.so" );
480 library = getLibrary( "OperationGUI.dll" );
483 else if( id == 601 || // MENU REPAIR - SEWING
484 id == 603 || // MENU REPAIR - SUPPRESS FACES
485 id == 604 || // MENU REPAIR - SUPPRESS HOLE
486 id == 605 || // MENU REPAIR - SHAPE PROCESSING
487 id == 606 || // MENU REPAIR - CLOSE CONTOUR
488 id == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES
489 id == 608 || // MENU REPAIR - ADD POINT ON EDGE
490 id == 609 || // MENU REPAIR - FREE BOUNDARIES
491 id == 610 || // MENU REPAIR - FREE FACES
492 id == 611 || // MENU REPAIR - CHANGE ORIENTATION
493 id == 602 ) { // MENU REPAIR - GLUE FACES
495 library = getLibrary( "libRepairGUI.so" );
497 library = getLibrary( "RepairGUI.dll" );
500 else if( id == 701 || // MENU MEASURE - PROPERTIES
501 id == 702 || // MENU MEASURE - CDG
502 id == 703 || // MENU MEASURE - INERTIA
503 id == 7041 || // MENU MEASURE - BOUNDING BOX
504 id == 7042 || // MENU MEASURE - MIN DISTANCE
505 id == 705 || // MENU MEASURE - TOLERANCE
506 id == 706 || // MENU MEASURE - WHATIS
507 id == 707 || // MENU MEASURE - CHECK
508 id == 7072 || // MENU MEASURE - CHECK COMPOUND OF BLOCKS
509 id == 708 ) { // MENU MEASURE - POINT COORDINATES
511 library = getLibrary( "libMeasureGUI.so" );
513 library = getLibrary( "MeasureGUI.dll" );
516 else if( id == 800 || // MENU GROUP - CREATE
517 id == 8001 || // POPUP MENU - CREATE GROUP
518 id == 801 ) { // MENU GROUP - EDIT
520 library = getLibrary( "libGroupGUI.so" );
522 library = getLibrary( "GroupGUI.dll" );
525 else if( id == 9999 || // MENU BLOCKS - HEXAHEDRAL SOLID
526 id == 9998 || // MENU BLOCKS - MULTI-TRANSFORMATION
527 id == 9997 || // MENU BLOCKS - QUADRANGLE FACE
528 id == 99991 || // MENU BLOCKS - PROPAGATE
529 id == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS
531 library = getLibrary( "libBlocksGUI.so" );
533 library = getLibrary( "BlocksGUI.dll" );
537 // call method of corresponding GUI library
539 library->OnGUIEvent( id, desk );
541 SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
545 //=================================================================================
546 // function : GeometryGUI::OnKeyPress()
547 // purpose : Called when any key is pressed by user [static]
548 //=================================================================================
549 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* win, QKeyEvent* pe )
553 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
554 SUIT_Application* anApp = application();
556 bOk = bOk && it.value()->OnKeyPress( pe, anApp->desktop(), win );
562 //=================================================================================
563 // function : GeometryGUI::OnMouseMove()
564 // purpose : Manages mouse move events [static]
565 //=================================================================================
566 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* win, QMouseEvent* pe )
570 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
571 SUIT_Application* anApp = application();
573 bOk = bOk && it.value()->OnMouseMove( pe, anApp->desktop(), win );
579 //=================================================================================
580 // function : GeometryGUI::0nMousePress()
581 // purpose : Manage mouse press events [static]
582 //=================================================================================
583 void GeometryGUI::OnMousePress( SUIT_ViewWindow* win, QMouseEvent* pe )
586 // OnMousePress() should return false if this event should be processed further
587 // (see OCCViewer_Viewer3d::onMousePress() for explanation)
588 bool processed = false;
589 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
590 SUIT_Application* anApp = application();
592 processed = processed || it.value()->OnMousePress( pe, anApp->desktop(), win );
598 static void UpdateVtkSelection()
600 QPtrList<SUIT_ViewWindow> winList = application()->desktop()->windows();
601 SUIT_ViewWindow* win = 0;
602 for ( win = winList.first(); win; win = winList.next() ) {
603 if ( win->getViewManager()->getTypeView() == VIEW_VTK ) {
604 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
606 SVTK_RenderWindowInteractor* anInteractor = vw->getRWInteractor();
607 anInteractor->SetSelectionProp();
608 anInteractor->SetSelectionTolerance();
609 SVTK_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
611 aStyle->setPreselectionProp();
618 //=================================================================================
619 // function : GeometryGUI::SetSettings()
620 // purpose : Called when GEOM module is activated [static]
621 //=================================================================================
622 bool GeometryGUI::SetSettings()
624 QMenuBar* Mb = parent->getMainMenuBar();
625 SUIT_Study* ActiveStudy = application()->activeStudy();
627 // Wireframe or Shading
629 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
630 bool ViewOCC = ( window && window->getViewManager()->getType() == VIEW_OCC );
631 bool ViewVTK = ( window && window->getViewManager()->getType() == VIEW_VTK );
633 OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( window->getViewManager() );
635 Handle(AIS_InteractiveContext) ic = vm->getOCCViewer()->getAISContext();
636 DisplayMode = ic->DisplayMode();
639 else if ( ViewVTK ) {
640 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
642 SVTK_RenderWindowInteractor* myRenderInter = vw->getRWInteractor();
643 DisplayMode = myRenderInter->GetDisplayMode();
647 if( DisplayMode == 1 )
649 Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) );
651 Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) );
654 // Add in Study - !!!ALWAYS TRUE!!! /////// VSR : TO BE REMOVED
655 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
656 int Settings_AddInStudy;
657 // if(!AddInStudy.isEmpty())
658 // Settings_AddInStudy = AddInStudy.toInt();
661 Settings_AddInStudy = 1;
662 Mb->setItemChecked(411, Settings_AddInStudy);
665 QString S = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
667 QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", "100");
670 int count = ActiveStudy->getStudyFramesCount();
671 for(int i = 0; i < count; i++) {
672 if(ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC) {
673 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
674 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
676 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
677 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
679 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
681 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
687 // PAL5356: update VTK selection
688 ::UpdateVtkSelection();
691 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
692 bOk = bOk && it.data()->SetSettings( parent );
694 // MZN: Enable/disable "Clipping range" menu item(from GEOM_CLIPPING variable)
695 if (getenv( "GEOM_CLIPPING" ) == NULL)
697 QMenuItem* mi = Mb->findItem(50);
698 if (mi && mi->popup())
699 mi->popup()->removeItem(507);
706 //=======================================================================
707 // function : createGeomAction
709 //=======================================================================
710 void GeometryGUI::createGeomAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
713 QWidget* parent = application()->desktop();
714 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
716 if ( icon_id.length() )
717 pix = resMgr->loadPixmap( "GEOM", tr( icon_id.toStdString().c_str() ) );
719 pix = resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+po_id).toStdString().c_str() ), false );
723 QString tooltip = tr( (QString( "TOP_" )+po_id).toStdString().c_str() ),
724 menu = tr( (QString( "MEN_" )+po_id).toStdString().c_str() ),
725 status_bar = tr( (QString( "STB_" )+po_id).toStdString().c_str() );
727 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
732 //=======================================================================
733 // function : GeometryGUI::initialize()
734 // purpose : Called when GEOM module is created
735 //=======================================================================
736 void GeometryGUI::initialize( CAM_Application* app )
738 SalomeApp_Module::initialize( app );
740 // ----- create actions --------------
742 createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) );
743 createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) );
745 createGeomAction( 33, "DELETE" );
747 createGeomAction( 4011, "POINT" );
748 createGeomAction( 4012, "LINE" );
749 createGeomAction( 4013, "CIRCLE" );
750 createGeomAction( 4014, "ELLIPSE" );
751 createGeomAction( 4015, "ARC" );
752 createGeomAction( 4019, "CURVE" );
753 createGeomAction( 4016, "VECTOR" );
754 createGeomAction( 4017, "PLANE" );
755 createGeomAction( 4018, "WORK_PLANE" );
756 createGeomAction( 4020, "LOCAL_CS" );
758 createGeomAction( 4021, "BOX" );
759 createGeomAction( 4022, "CYLINDER" );
760 createGeomAction( 4023, "SPHERE" );
761 createGeomAction( 4024, "TORUS" );
762 createGeomAction( 4025, "CONE" );
764 createGeomAction( 4031, "EXTRUSION" );
765 createGeomAction( 4032, "REVOLUTION" );
766 createGeomAction( 4033, "FILLING" );
767 createGeomAction( 4034, "PIPE" );
769 createGeomAction( 800, "GROUP_CREATE" );
770 createGeomAction( 801, "GROUP_EDIT" );
772 createGeomAction( 9997, "Q_FACE" );
773 createGeomAction( 9999, "HEX_SOLID" );
775 createGeomAction( 404, "SKETCH" );
776 createGeomAction( 407, "EXPLODE" );
778 createGeomAction( 4081, "EDGE" );
779 createGeomAction( 4082, "WIRE" );
780 createGeomAction( 4083, "FACE" );
781 createGeomAction( 4084, "SHELL" );
782 createGeomAction( 4085, "SOLID" );
783 createGeomAction( 4086, "COMPOUND" );
785 createGeomAction( 5011, "FUSE" );
786 createGeomAction( 5012, "COMMON" );
787 createGeomAction( 5013, "CUT" );
788 createGeomAction( 5014, "SECTION" );
790 createGeomAction( 5021, "TRANSLATION" );
791 createGeomAction( 5022, "ROTATION" );
792 createGeomAction( 5023, "MODIFY_LOCATION" );
793 createGeomAction( 5024, "MIRROR" );
794 createGeomAction( 5025, "SCALE" );
795 createGeomAction( 5026, "OFFSET" );
796 createGeomAction( 5027, "MUL_TRANSLATION" );
797 createGeomAction( 5028, "MUL_ROTATION" );
799 createGeomAction( 503, "PARTITION" );
800 createGeomAction( 504, "ARCHIMEDE" );
801 createGeomAction( 505, "FILLET" );
802 createGeomAction( 506, "CHAMFER" );
803 //createGeomAction( 507, "CLIPPING" );
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" );
821 createGeomAction( 708, "POINT_COORDS" );
822 createGeomAction( 701, "BASIC_PROPS" );
823 createGeomAction( 702, "MASS_CENTER" );
824 createGeomAction( 703, "INERTIA" );
825 createGeomAction( 7041, "BND_BOX" );
826 createGeomAction( 7042, "MIN_DIST" );
828 createGeomAction( 705, "TOLERANCE" );
829 createGeomAction( 706, "WHAT_IS" );
830 createGeomAction( 707, "CHECK" );
831 createGeomAction( 7072, "CHECK_COMPOUND" );
833 createGeomAction( 5103, "CHECK_GEOMETRY" );
835 createGeomAction( 412, "SHADING_COLOR" );
836 createGeomAction( 413, "ISOS" );
837 createGeomAction( 414, "STEP_VALUE" );
839 createGeomAction( 211, "SHADING" );
840 createGeomAction( 212, "DISPLAY_ALL" );
841 createGeomAction( 214, "ERASE_ALL" );
842 createGeomAction( 216, "DISPLAY" );
843 createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true );
844 createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true );
845 createGeomAction( 2173, "WIRE_SEL_ONLY", "", 0, true );
846 createGeomAction( 2174, "FACE_SEL_ONLY", "", 0, true );
847 createGeomAction( 2175, "SHELL_SEL_ONLY", "", 0, true );
848 createGeomAction( 2176, "SOLID_SEL_ONLY", "", 0, true );
849 createGeomAction( 2177, "COMPOUND_SEL_ONLY", "", 0, true );
850 createGeomAction( 2178, "ALL_SEL_ONLY", "", 0, true );
851 createGeomAction( 213, "DISPLAY_ONLY" );
852 createGeomAction( 215, "ERASE" );
854 createGeomAction( 901, "POP_RENAME" );
855 createGeomAction( 80311, "POP_WIREFRAME", "", 0, true );
856 createGeomAction( 80312, "POP_SHADING", "", 0, true );
857 createGeomAction( 8032, "POP_COLOR" );
858 createGeomAction( 8033, "POP_TRANSPARENCY" );
859 createGeomAction( 8034, "POP_ISOS" );
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 );
972 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
973 createMenu( 708, measurId, -1 );
974 createMenu( 701, measurId, -1 );
975 createMenu( separator(), measurId, -1 );
976 createMenu( 702, measurId, -1 );
977 createMenu( 703, measurId, -1 );
978 createMenu( separator(), measurId, -1 );
980 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
981 createMenu( 7041, dimId, -1 );
982 createMenu( 7042, dimId, -1 );
983 createMenu( separator(), measurId, -1 );
985 createMenu( 705, measurId, -1 );
986 createMenu( separator(), measurId, -1 );
987 createMenu( 706, measurId, -1 );
988 createMenu( 707, measurId, -1 );
989 createMenu( 7072, measurId, -1 );
991 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
992 createMenu( separator(), toolsId, -1 );
993 createMenu( 5103, toolsId, -1 );
995 //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 );
996 //createMenu( separator(), prefId, -1 );
997 //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 );
998 //createMenu( 412, geomId, -1 );
999 //createMenu( 413, geomId, -1 );
1000 //createMenu( 414, geomId, -1 );
1001 //createMenu( separator(), prefId, -1 );
1003 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1004 createMenu( separator(), viewId, -1 );
1006 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1007 createMenu( 211, dispmodeId, -1 );
1009 createMenu( separator(), viewId, -1 );
1010 createMenu( 212, viewId, -1 );
1011 createMenu( 214, viewId, -1 );
1012 createMenu( separator(), viewId, -1 );
1016 because of these items are accessible through object browser and viewers
1017 we have removed they from main menu
1019 createMenu( 216, viewId, -1 );
1020 createMenu( 213, viewId, -1 );
1021 createMenu( 215, viewId, -1 );
1024 // ---- create toolbars --------------------------
1026 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1027 createTool( 4011, basicTbId );
1028 createTool( 4012, basicTbId );
1029 createTool( 4013, basicTbId );
1030 createTool( 4014, basicTbId );
1031 createTool( 4015, basicTbId );
1032 createTool( 4019, basicTbId );
1033 createTool( 4016, basicTbId );
1034 createTool( 4017, basicTbId );
1035 createTool( 4018, basicTbId );
1036 createTool( 4020, basicTbId );
1038 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1039 createTool( 4021, primTbId );
1040 createTool( 4022, primTbId );
1041 createTool( 4023, primTbId );
1042 createTool( 4024, primTbId );
1043 createTool( 4025, primTbId );
1045 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1046 createTool( 5011, boolTbId );
1047 createTool( 5012, boolTbId );
1048 createTool( 5013, boolTbId );
1049 createTool( 5014, boolTbId );
1051 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1052 createTool( 4031, genTbId );
1053 createTool( 4032, genTbId );
1054 createTool( 4033, genTbId );
1055 createTool( 4034, genTbId );
1057 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1058 createTool( 5021, transTbId );
1059 createTool( 5022, transTbId );
1060 createTool( 5023, transTbId );
1061 createTool( 5024, transTbId );
1062 createTool( 5025, transTbId );
1063 createTool( 5026, transTbId );
1064 createTool( separator(), transTbId );
1065 createTool( 5027, transTbId );
1066 createTool( 5028, transTbId );
1068 // ---- create popup menus --------------------------
1070 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1071 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1073 QtxPopupMgr* mgr = popupMgr();
1074 mgr->insert( action( 901 ), -1, -1 ); // rename
1075 mgr->setRule( action( 901 ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
1076 mgr->insert( action( 8001 ), -1, -1 ); // create group
1077 mgr->setRule( action( 8001 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1078 mgr->insert( action( 801 ), -1, -1 ); // edit group
1079 mgr->setRule( action( 801 ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1080 mgr->insert( separator(), -1, -1 ); // -----------
1081 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1082 mgr->insert( action( 80311 ), dispmodeId, -1 ); // wireframe
1083 mgr->setRule( action( 80311 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1084 mgr->setRule( action( 80311 ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1085 mgr->insert( action( 80312 ), dispmodeId, -1 ); // shading
1086 mgr->setRule( action( 80312 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1087 mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1088 mgr->insert( separator(), -1, -1 ); // -----------
1089 mgr->insert( action( 8032 ), -1, -1 ); // color
1090 mgr->setRule( action( 8032 ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1091 mgr->insert( action( 8033 ), -1, -1 ); // transparency
1092 mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1093 mgr->insert( action( 8034 ), -1, -1 ); // isos
1094 mgr->setRule( action( 8034 ), QString("client='OCCViewer' and selcount>0 and isVisible"), QtxPopupMgr::VisibleRule );
1095 mgr->insert( separator(), -1, -1 ); // -----------
1098 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1099 onlyComponent = "((type='Component') and selcount=1)",
1100 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1101 types = "'Shape' 'Group'";
1103 mgr->insert( action( 216 ), -1, -1 ); // display
1104 mgr->setRule( action( 216 ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1106 mgr->insert( action( 215 ), -1, -1 ); // erase
1107 mgr->setRule( action( 215 ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1109 mgr->insert( action( 214 ), -1, -1 ); // erase All
1110 mgr->setRule( action( 214 ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1112 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1114 int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1115 mgr->insert( action(2171), selectolnyId, -1); //Vertex
1116 mgr->setRule(action(2171), selectOnly, QtxPopupMgr::VisibleRule);
1117 mgr->setRule(action(2171), selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1118 mgr->insert( action(2172), selectolnyId, -1); //Edge
1119 mgr->setRule(action(2172), selectOnly, QtxPopupMgr::VisibleRule);
1120 mgr->setRule(action(2172), selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1121 mgr->insert( action(2173), selectolnyId, -1); //Wire
1122 mgr->setRule(action(2173), selectOnly, QtxPopupMgr::VisibleRule);
1123 mgr->setRule(action(2173), selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1124 mgr->insert( action(2174), selectolnyId, -1); //Face
1125 mgr->setRule(action(2174), selectOnly, QtxPopupMgr::VisibleRule);
1126 mgr->setRule(action(2174), selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1127 mgr->insert( action(2175), selectolnyId, -1); //Shell
1128 mgr->setRule(action(2175), selectOnly, QtxPopupMgr::VisibleRule);
1129 mgr->setRule(action(2175), selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1130 mgr->insert( action(2176), selectolnyId, -1); //Solid
1131 mgr->setRule(action(2176), selectOnly, QtxPopupMgr::VisibleRule);
1132 mgr->setRule(action(2176), selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1133 mgr->insert( action(2177), selectolnyId, -1); //Compound
1134 mgr->setRule(action(2177), selectOnly, QtxPopupMgr::VisibleRule);
1135 mgr->setRule(action(2177), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1136 mgr->insert( separator(), selectolnyId, -1);
1137 mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter
1138 mgr->setRule(action(2178), selectOnly, QtxPopupMgr::VisibleRule);
1139 mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1141 mgr->insert( action( 213 ), -1, -1 ); // display only
1142 mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1143 mgr->insert( separator(), -1, -1 );
1145 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1148 //=======================================================================
1149 // function : GeometryGUI::activateModule()
1150 // purpose : Called when GEOM module is activated
1151 //=======================================================================
1152 bool GeometryGUI::activateModule( SUIT_Study* study )
1154 if ( CORBA::is_nil( myComponentGeom ) )
1157 bool res = SalomeApp_Module::activateModule( study );
1162 setMenuShown( true );
1163 setToolShown( true );
1165 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1166 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1168 // Reset actions accelerator keys
1169 //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import
1170 //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export
1171 action(111)->setEnabled(true); // Import
1172 action(121)->setEnabled(true); // Export
1174 GUIMap::Iterator it;
1175 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1176 it.value()->activate( application()->desktop() );
1178 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1179 SUIT_ViewManager* vm;
1180 ViewManagerList OCCViewManagers, VTKViewManagers;
1182 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1183 QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1184 while ( itOCC.hasNext() && (vm = itOCC.next()) )
1185 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1187 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1188 QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1189 while ( itVTK.hasNext() && (vm = itVTK.next()) )
1190 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1192 // disable OCC selectors
1193 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1194 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1195 while ( itOCCSel.hasNext() )
1196 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1197 sr->setEnabled(true);
1199 // disable VTK selectors
1200 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1201 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1202 while ( itVTKSel.hasNext() )
1203 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1204 sr->setEnabled(true);
1210 //=======================================================================
1211 // function : GeometryGUI::deactivateModule()
1212 // purpose : Called when GEOM module is deactivated
1213 //=======================================================================
1214 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1216 setMenuShown( false );
1217 setToolShown( false );
1219 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1220 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1222 EmitSignalCloseAllDialogs();
1224 GUIMap::Iterator it;
1225 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1226 it.value()->deactivate();
1228 // Unset actions accelerator keys
1229 //action(111)->setAccel(QKeySequence()); // Import
1230 //action(121)->setAccel(QKeySequence()); // Export
1231 action(111)->setEnabled(false); // Import
1232 action(121)->setEnabled(false); // Export
1234 myOCCSelectors.clear();
1235 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1237 myVTKSelectors.clear();
1238 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1240 return SalomeApp_Module::deactivateModule( study );
1243 //=======================================================================
1244 // function : GeometryGUI::BuildPresentation()
1246 //=======================================================================
1247 void GeometryGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& io, SUIT_ViewWindow* win )
1249 //GEOM_Displayer().Display( io, false, win );
1252 //=======================================================================
1253 // function : onWindowActivated()
1254 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1255 //=======================================================================
1256 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1261 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1262 // const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1264 // disable non-OCC viewframe menu commands
1265 // action( 404 )->setEnabled( ViewOCC ); // SKETCHER
1266 action( 603 )->setEnabled( ViewOCC ); // SuppressFace
1267 action( 604 )->setEnabled( ViewOCC ); // SuppressHole
1268 action( 606 )->setEnabled( ViewOCC ); // CloseContour
1269 action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires
1270 action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
1271 // action( 609 )->setEnabled( ViewOCC ); // Free boundaries
1272 action( 413 )->setEnabled( ViewOCC ); // Isos Settings
1274 action( 800 )->setEnabled( ViewOCC ); // Create Group
1275 action( 801 )->setEnabled( ViewOCC ); // Edit Group
1277 action( 9998 )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1280 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1282 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1283 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1286 void GeometryGUI::viewManagers( QStringList& lst ) const
1288 lst.append( OCCViewer_Viewer::Type() );
1291 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1293 if ( vm->getType() == OCCViewer_Viewer::Type() )
1295 qDebug( "connect" );
1296 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1297 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1298 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1299 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1300 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1301 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1304 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1305 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1307 // disable OCC selectors
1308 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1309 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1310 while ( itOCCSel.hasNext() )
1311 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1312 sr->setEnabled(true);
1314 else if ( vm->getType() == SVTK_Viewer::Type() )
1316 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1317 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1319 // disable VTK selectors
1320 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1321 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1322 while ( itVTKSel.hasNext() )
1323 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1324 sr->setEnabled(true);
1328 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1330 SUIT_ViewModel* viewer = vm->getViewModel();
1331 if ( vm->getType() == OCCViewer_Viewer::Type() )
1333 QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1334 while ( itOCCSel.hasNext() )
1335 if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1336 if ( sr->viewer() == viewer )
1338 delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1342 if ( vm->getType() == SVTK_Viewer::Type() )
1344 QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1345 while ( itVTKSel.hasNext() )
1346 if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1347 if ( sr->viewer() == viewer )
1349 delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1355 QString GeometryGUI::engineIOR() const
1357 QString anIOR = QString::null;
1358 if ( !CORBA::is_nil( GetGeomGen() ) )
1360 CORBA::String_var objStr = getApp()->orb()->object_to_string( GetGeomGen() );
1361 anIOR = QString( objStr.in() );
1362 // free( objStr ); ASV : 26.07.06 : commented out because it raises exception and blocks application
1367 LightApp_Selection* GeometryGUI::createSelection( const QString& client, LightApp_SelectionMgr* mgr ) const
1369 return new GEOMGUI_Selection( client, mgr );
1372 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1374 SalomeApp_Module::contextMenuPopup( client, menu, title );
1376 getApp()->selectionMgr()->selectedObjects( lst );
1377 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
1378 Handle(SALOME_InteractiveObject) io = lst.First();
1379 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1380 _PTR(Study) study = appStudy->studyDS();
1381 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
1383 title = QString( obj->GetName().c_str() );
1387 void GeometryGUI::createPreferences()
1389 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1391 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1392 setPreferenceProperty( genGroup, "columns", 1 );
1394 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1395 LightApp_Preferences::Selector, "Geometry", "display_mode" );
1397 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1398 LightApp_Preferences::Color, "Geometry", "shading_color" );
1400 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1401 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1403 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1404 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1406 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1407 LightApp_Preferences::Color, "Geometry", "line_color" );
1409 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1410 LightApp_Preferences::Color, "Geometry", "point_color" );
1412 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1413 LightApp_Preferences::Color, "Geometry", "isos_color" );
1415 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1416 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1418 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1420 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1421 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1423 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1424 LightApp_Preferences::DblSpin, "Geometry", "marker_scale" );
1426 // Set property for default display mode
1427 QStringList aModesList;
1428 aModesList.append( tr("MEN_WIREFRAME") );
1429 aModesList.append( tr("MEN_SHADING") );
1431 QList<QVariant> anIndexesList;
1432 anIndexesList.append(0);
1433 anIndexesList.append(1);
1435 setPreferenceProperty( dispmode, "strings", aModesList );
1436 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1438 // Set property for step value for spinboxes
1439 setPreferenceProperty( step, "min", 0.001 );
1440 setPreferenceProperty( step, "max", 10000 );
1441 setPreferenceProperty( step, "precision", 3 );
1443 // Set property for type of vertex marker
1444 QStringList aTypeOfMarkerList;
1445 QList<QVariant> anTypeOfMarkerIndexesList;
1447 aTypeOfMarkerList.append( tr("TOM_PLUS") );
1448 anTypeOfMarkerIndexesList.append(Aspect_TOM_PLUS);
1450 aTypeOfMarkerList.append( tr("TOM_POINT") );
1451 anTypeOfMarkerIndexesList.append(Aspect_TOM_POINT);
1453 aTypeOfMarkerList.append( tr("TOM_STAR") );
1454 anTypeOfMarkerIndexesList.append(Aspect_TOM_STAR);
1456 aTypeOfMarkerList.append( tr("TOM_O") );
1457 anTypeOfMarkerIndexesList.append(Aspect_TOM_O);
1459 aTypeOfMarkerList.append( tr("TOM_X") );
1460 anTypeOfMarkerIndexesList.append(Aspect_TOM_X);
1462 aTypeOfMarkerList.append( tr("TOM_O_POINT") );
1463 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_POINT);
1465 aTypeOfMarkerList.append( tr("TOM_O_PLUS") );
1466 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_PLUS);
1468 aTypeOfMarkerList.append( tr("TOM_O_STAR") );
1469 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_STAR);
1471 aTypeOfMarkerList.append( tr("TOM_O_X") );
1472 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_X);
1475 setPreferenceProperty( typeOfMarker, "strings", aTypeOfMarkerList );
1476 setPreferenceProperty( typeOfMarker, "indexes", anTypeOfMarkerIndexesList );
1478 // Set property for Vertex Marker scale
1479 setPreferenceProperty( markerScale, "min", 1. );
1480 setPreferenceProperty( markerScale, "max", 7. );
1481 setPreferenceProperty( markerScale, "precision", 0.01 );
1482 setPreferenceProperty( markerScale, "step", 0.5 );
1486 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1488 if (section == "Geometry") {
1489 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1490 if (param == QString("SettingsGeomStep")) {
1491 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1492 EmitSignalDefaultStepValueChanged(spin_step);
1497 LightApp_Displayer* GeometryGUI::displayer()
1500 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1504 void GeometryGUI::setLocalSelectionMode(const int mode)
1506 myLocalSelectionMode = mode;
1508 int GeometryGUI::getLocalSelectionMode() const
1510 return myLocalSelectionMode;