1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : GeometryGUI.cxx
25 // Author : Lucien PIGNOLONI
29 #include "GeometryGUI.h"
30 #include "GEOMGUI_OCCSelector.h"
31 #include "GEOMGUI_Selection.h"
32 #include "GEOM_Displayer.h"
34 #include <SUIT_MessageBox.h>
35 #include <SUIT_ResourceMgr.h>
36 #include <SUIT_Session.h>
37 #include <SUIT_ViewManager.h>
39 #include <OCCViewer_ViewWindow.h>
40 #include <OCCViewer_ViewPort3d.h>
41 #include <OCCViewer_ViewModel.h>
42 #include <OCCViewer_ViewManager.h>
44 #include <SVTK_ViewWindow.h>
45 #include <SVTK_RenderWindowInteractor.h>
46 #include <SVTK_InteractorStyle.h>
47 #include <SVTK_ViewModel.h>
48 #include <SVTK_ViewManager.h>
50 #include <SalomeApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
52 #include <LightApp_VTKSelector.h>
53 #include <SalomeApp_Study.h>
54 #include <LightApp_Preferences.h>
55 #include <SALOME_LifeCycleCORBA.hxx>
56 #include <SALOME_ListIO.hxx>
57 #include <SALOME_ListIteratorOfListIO.hxx>
60 #include <qfileinfo.h>
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>
75 Standard_EXPORT CAM_Module* createModule() {
76 return new GeometryGUI();
82 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
84 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
86 // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
87 if (CORBA::is_nil(myComponentGeom))
89 return GeometryGUI::myComponentGeom;
92 bool GeometryGUI::InitGeomGen()
95 if( CORBA::is_nil( myComponentGeom ) ) return false;
99 //=======================================================================
100 // function : ClientSObjectToObject
102 //=======================================================================
103 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
105 _PTR(GenericAttribute) anAttr;
106 CORBA::Object_var anObj;
108 std::string aValue = theSObject->GetIOR();
109 if (strcmp(aValue.c_str(), "") != 0) {
110 CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
111 anObj = anORB->string_to_object(aValue.c_str());
114 INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
116 return anObj._retn();
119 //=======================================================================
120 // function : ClientStudyToStudy
122 //=======================================================================
123 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
125 SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
126 CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
127 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
128 int aStudyID = theStudy->StudyId();
129 SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
130 return aDSStudy._retn();
133 //=================================================================================
134 // class : CustomItem
135 // purpose : Set Font to a text.
136 //=================================================================================
137 class CustomItem : public QCustomMenuItem
140 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
143 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
146 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
147 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
148 p->setFont( myFont );
149 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
155 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
158 bool fullSpan() const
168 //=======================================================================
169 // function : GeometryGUI::GeometryGUI()
170 // purpose : Constructor
171 //=======================================================================
172 GeometryGUI::GeometryGUI() :
173 SalomeApp_Module( "GEOM" )
175 if ( CORBA::is_nil( myComponentGeom ) )
177 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
178 Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "GEOM" );
179 myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
183 myActiveDialogBox = 0;
186 gp_Pnt origin = gp_Pnt(0., 0., 0.);
187 gp_Dir direction = gp_Dir(0., 0., 1.);
188 myWorkingPlane = gp_Ax3(origin, direction);
190 myOCCSelectors.setAutoDelete( true );
191 myVTKSelectors.setAutoDelete( true );
194 myLocalSelectionMode = GEOM_ALLOBJECTS;
197 //=======================================================================
198 // function : GeometryGUI::~GeometryGUI()
199 // purpose : Destructor
200 //=======================================================================
201 GeometryGUI::~GeometryGUI()
205 //=======================================================================
206 // function : GeometryGUI::getLibrary()
207 // purpose : get or load GUI library by name [ internal ]
208 //=======================================================================
209 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
210 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
212 if ( !myGUIMap.contains( libraryName ) ) {
213 // try to load library if it is not loaded yet
216 if ( (libs = getenv( "LD_LIBRARY_PATH" )) ) {
217 QStringList dirList = QStringList::split( ":", libs, false ); // skip empty entries
219 if ( (libs = getenv( "PATH" )) ) {
220 QStringList dirList = QStringList::split( ";", libs, false ); // skip empty entries
222 for( int i = dirList.count()-1; i >= 0; i-- ) {
223 QString dir = dirList[ i ];
224 QFileInfo fi( Qtx::addSlash( dirList[ i ] ) + libraryName );
226 OSD_SharedLibrary aSharedLibrary( (char*)fi.fileName().latin1() );
227 bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
229 MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
230 continue; // continue search further
232 OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
233 if ( osdF != NULL ) {
234 LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
235 GEOMGUI* libGUI = (*func)(this);
237 myGUIMap[ libraryName ] = libGUI;
238 break; // found and loaded!
245 if ( myGUIMap.contains( libraryName ) )
246 // library is successfully loaded
247 return myGUIMap[ libraryName ];
251 //=======================================================================
252 // function : GeometryGUI::ActiveWorkingPlane()
253 // purpose : Activate Working Plane View
254 //=======================================================================
255 void GeometryGUI::ActiveWorkingPlane()
257 gp_Dir DZ = myWorkingPlane.Direction();
258 gp_Dir DY = myWorkingPlane.YDirection();
260 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
261 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
262 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
265 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
267 Handle(V3d_View) view3d = vw->getViewPort()->getView();
269 view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
270 view3d->SetUp(DY.X(), DY.Y(), DY.Z());
276 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
278 vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
280 camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
281 camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
282 camera->SetFocalPoint(0,0,0);
289 //=======================================================================
290 // function : GeometryGUI::SetActiveDialogBox()
291 // purpose : Set active dialog box
292 //=======================================================================
293 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
295 myActiveDialogBox = (QDialog*)aDlg;
298 //=======================================================================
299 // function : GeometryGUI::EmitSignalDeactivateDialog()
300 // purpose : Emit a signal to deactivate the active dialog Box
301 //=======================================================================
302 void GeometryGUI::EmitSignalDeactivateDialog()
304 emit SignalDeactivateActiveDialog();
307 //=======================================================================
308 // function : GeometryGUI::EmitSignalCloseAllDialogs()
309 // purpose : Emit a signal to close all non modal dialogs box
310 //=======================================================================
311 void GeometryGUI::EmitSignalCloseAllDialogs()
313 emit SignalCloseAllDialogs();
316 //=======================================================================
317 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
318 // purpose : Emit a signal to inform that default real spin box step has
320 //=======================================================================
321 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
323 emit SignalDefaultStepValueChanged(newVal);
326 //=======================================================================
327 // function : GeometryGUI::OnGUIEvent()
328 // purpose : common slot for all menu/toolbar actions
329 //=======================================================================
330 void GeometryGUI::OnGUIEvent()
332 const QObject* obj = sender();
333 if ( !obj || !obj->inherits( "QAction" ) )
335 int id = actionId((QAction*)obj);
340 //=======================================================================
341 // function : GeometryGUI::OnGUIEvent()
342 // purpose : manage all events on GUI [static]
343 //=======================================================================
344 void GeometryGUI::OnGUIEvent( int id )
346 SUIT_Application* anApp = application();
348 SUIT_Desktop* desk = anApp->desktop();
350 // check type of the active viewframe
351 SUIT_ViewWindow* window = desk->activeWindow();
352 bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
353 bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
354 // if current viewframe is not of OCC and not of VTK type - return immediately
355 // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
356 bool NotViewerDependentCommand = ( id == 901 || id == 216 || id == 213 );
357 if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommand )
360 // fix for IPAL9103, point 2
361 if ( CORBA::is_nil( GetGeomGen() ) ) {
362 SUIT_MessageBox::error1( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
366 GEOMGUI* library = 0;
367 // try to get-or-load corresponding GUI library
368 if( id == 111 || // MENU FILE - IMPORT BREP
369 id == 112 || // MENU FILE - IMPORT IGES
370 id == 113 || // MENU FILE - IMPORT STEP
371 id == 121 || // MENU FILE - EXPORT BREP
372 id == 122 || // MENU FILE - EXPORT IGES
373 id == 123 || // MENU FILE - EXPORT STEP
374 id == 2171 || // POPUP VIEWER - SELECT ONLY - VERTEX
375 id == 2172 || // POPUP VIEWER - SELECT ONLY - EDGE
376 id == 2173 || // POPUP VIEWER - SELECT ONLY - WIRE
377 id == 2174 || // POPUP VIEWER - SELECT ONLY - FACE
378 id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL
379 id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID
380 id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND
381 id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL
382 id == 31 || // MENU EDIT - COPY
383 id == 33 || // MENU EDIT - DELETE
384 id == 411 || // MENU SETTINGS - ADD IN STUDY
385 id == 412 || // MENU SETTINGS - SHADING COLOR
386 id == 413 || // MENU SETTINGS - ISOS
387 id == 414 || // MENU SETTINGS - STEP VALUE FOR SPIN BOXES
388 id == 5103 || // MENU TOOLS - CHECK GEOMETRY
389 id == 8032 || // POPUP VIEWER - COLOR
390 id == 8033 || // POPUP VIEWER - TRANSPARENCY
391 id == 8034 || // POPUP VIEWER - ISOS
392 id == 8035 || // POPUP VIEWER - AUTO COLOR
393 id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR
394 id == 804 || // POPUP VIEWER - ADD IN STUDY
395 id == 901 || // OBJECT BROWSER - RENAME
396 id == 9024 ) { // OBJECT BROWSER - OPEN
397 //cout << "id " << id << " received" << endl;
399 library = getLibrary( "libGEOMToolsGUI.so" );
401 library = getLibrary( "GEOMToolsGUI.dll" );
404 else if( id == 211 || // MENU VIEW - WIREFRAME/SHADING
405 id == 212 || // MENU VIEW - DISPLAY ALL
406 id == 213 || // MENU VIEW - DISPLAY ONLY
407 id == 214 || // MENU VIEW - ERASE ALL
408 id == 215 || // MENU VIEW - ERASE
409 id == 216 || // MENU VIEW - DISPLAY
410 id == 80311 || // POPUP VIEWER - WIREFRAME
411 id == 80312 ) { // POPUP VIEWER - SHADING
413 library = getLibrary( "libDisplayGUI.so" );
415 library = getLibrary( "DisplayGUI.dll" );
418 else if( id == 4011 || // MENU BASIC - POINT
419 id == 4012 || // MENU BASIC - LINE
420 id == 4013 || // MENU BASIC - CIRCLE
421 id == 4014 || // MENU BASIC - ELLIPSE
422 id == 4015 || // MENU BASIC - ARC
423 id == 4016 || // MENU BASIC - VECTOR
424 id == 4017 || // MENU BASIC - PLANE
425 id == 4018 || // MENU BASIC - WPLANE
426 id == 4019 || // MENU BASIC - CURVE
427 id == 4020 ) { // MENU BASIC - REPAIR
429 library = getLibrary( "libBasicGUI.so" );
431 library = getLibrary( "BasicGUI.dll" );
434 else if( id == 4021 || // MENU PRIMITIVE - BOX
435 id == 4022 || // MENU PRIMITIVE - CYLINDER
436 id == 4023 || // MENU PRIMITIVE - SPHERE
437 id == 4024 || // MENU PRIMITIVE - TORUS
438 id == 4025 ) { // MENU PRIMITIVE - CONE
440 library = getLibrary( "libPrimitiveGUI.so" );
442 library = getLibrary( "PrimitiveGUI.dll" );
445 else if( id == 4031 || // MENU GENERATION - PRISM
446 id == 4032 || // MENU GENERATION - REVOLUTION
447 id == 4033 || // MENU GENERATION - FILLING
448 id == 4034 ) { // MENU GENERATION - PIPE
450 library = getLibrary( "libGenerationGUI.so" );
452 library = getLibrary( "GenerationGUI.dll" );
455 else if( id == 404 || // MENU ENTITY - SKETCHER
456 id == 407 ) { // MENU ENTITY - EXPLODE
458 library = getLibrary( "libEntityGUI.so" );
460 library = getLibrary( "EntityGUI.dll" );
463 else if( id == 4081 || // MENU BUILD - EDGE
464 id == 4082 || // MENU BUILD - WIRE
465 id == 4083 || // MENU BUILD - FACE
466 id == 4084 || // MENU BUILD - SHELL
467 id == 4085 || // MENU BUILD - SOLID
468 id == 4086 ) { // MENU BUILD - COMPUND
470 library = getLibrary( "libBuildGUI.so" );
472 library = getLibrary( "BuildGUI.dll" );
475 else if( id == 5011 || // MENU BOOLEAN - FUSE
476 id == 5012 || // MENU BOOLEAN - COMMON
477 id == 5013 || // MENU BOOLEAN - CUT
478 id == 5014 ) { // MENU BOOLEAN - SECTION
480 library = getLibrary( "libBooleanGUI.so" );
482 library = getLibrary( "BooleanGUI.dll" );
485 else if( id == 5021 || // MENU TRANSFORMATION - TRANSLATION
486 id == 5022 || // MENU TRANSFORMATION - ROTATION
487 id == 5023 || // MENU TRANSFORMATION - LOCATION
488 id == 5024 || // MENU TRANSFORMATION - MIRROR
489 id == 5025 || // MENU TRANSFORMATION - SCALE
490 id == 5026 || // MENU TRANSFORMATION - OFFSET
491 id == 5027 || // MENU TRANSFORMATION - MULTI-TRANSLATION
492 id == 5028 ) { // MENU TRANSFORMATION - MULTI-ROTATION
494 library = getLibrary( "libTransformationGUI.so" );
496 library = getLibrary( "TransformationGUI.dll" );
499 else if( id == 503 || // MENU OPERATION - PARTITION
500 id == 504 || // MENU OPERATION - ARCHIMEDE
501 id == 505 || // MENU OPERATION - FILLET
502 id == 506 || // MENU OPERATION - CHAMFER
503 id == 507 || // MENU OPERATION - CLIPPING RANGE
504 id == 508 ) { // MENU OPERATION - GET SHAPES ON SHAPE
506 library = getLibrary( "libOperationGUI.so" );
508 library = getLibrary( "OperationGUI.dll" );
511 else if( id == 601 || // MENU REPAIR - SEWING
512 id == 603 || // MENU REPAIR - SUPPRESS FACES
513 id == 604 || // MENU REPAIR - SUPPRESS HOLE
514 id == 605 || // MENU REPAIR - SHAPE PROCESSING
515 id == 606 || // MENU REPAIR - CLOSE CONTOUR
516 id == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES
517 id == 608 || // MENU REPAIR - ADD POINT ON EDGE
518 id == 609 || // MENU MEASURE - FREE BOUNDARIES
519 id == 610 || // MENU MEASURE - FREE FACES
520 id == 611 || // MENU REPAIR - CHANGE ORIENTATION
521 id == 602 || // MENU REPAIR - GLUE FACES
522 id == 612 ) { // MENU REPAIR - REMOVE EXTRA EDGES
524 library = getLibrary( "libRepairGUI.so" );
526 library = getLibrary( "RepairGUI.dll" );
529 else if( id == 701 || // MENU MEASURE - PROPERTIES
530 id == 702 || // MENU MEASURE - CDG
531 id == 703 || // MENU MEASURE - INERTIA
532 id == 704 || // MENU MEASURE - NORMALE
533 id == 7041 || // MENU MEASURE - BOUNDING BOX
534 id == 7042 || // MENU MEASURE - MIN DISTANCE
535 id == 7043 || // MENU MEASURE - ANGLE
536 id == 705 || // MENU MEASURE - TOLERANCE
537 id == 706 || // MENU MEASURE - WHATIS
538 id == 707 || // MENU MEASURE - CHECK
539 id == 7072 || // MENU MEASURE - CHECK COMPOUND OF BLOCKS
540 id == 708 ) { // MENU MEASURE - POINT COORDINATES
542 library = getLibrary( "libMeasureGUI.so" );
544 library = getLibrary( "MeasureGUI.dll" );
547 else if( id == 800 || // MENU GROUP - CREATE
548 id == 8001 || // POPUP MENU - CREATE GROUP
549 id == 801 ) { // MENU GROUP - EDIT
551 library = getLibrary( "libGroupGUI.so" );
553 library = getLibrary( "GroupGUI.dll" );
556 else if( id == 9999 || // MENU BLOCKS - HEXAHEDRAL SOLID
557 id == 9998 || // MENU BLOCKS - MULTI-TRANSFORMATION
558 id == 9997 || // MENU BLOCKS - QUADRANGLE FACE
559 id == 99991 || // MENU BLOCKS - PROPAGATE
560 id == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS
562 library = getLibrary( "libBlocksGUI.so" );
564 library = getLibrary( "BlocksGUI.dll" );
568 // call method of corresponding GUI library
570 library->OnGUIEvent( id, desk );
572 SUIT_MessageBox::error1( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
576 //=================================================================================
577 // function : GeometryGUI::OnKeyPress()
578 // purpose : Called when any key is pressed by user [static]
579 //=================================================================================
580 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* win, QKeyEvent* pe )
584 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
585 SUIT_Application* anApp = application();
587 bOk = bOk && it.data()->OnKeyPress( pe, anApp->desktop(), win );
593 //=================================================================================
594 // function : GeometryGUI::OnMouseMove()
595 // purpose : Manages mouse move events [static]
596 //=================================================================================
597 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* win, QMouseEvent* pe )
601 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
602 SUIT_Application* anApp = application();
604 bOk = bOk && it.data()->OnMouseMove( pe, anApp->desktop(), win );
610 //=================================================================================
611 // function : GeometryGUI::0nMousePress()
612 // purpose : Manage mouse press events [static]
613 //=================================================================================
614 void GeometryGUI::OnMousePress( SUIT_ViewWindow* win, QMouseEvent* pe )
617 // OnMousePress() should return false if this event should be processed further
618 // (see OCCViewer_Viewer3d::onMousePress() for explanation)
619 bool processed = false;
620 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
621 SUIT_Application* anApp = application();
623 processed = processed || it.data()->OnMousePress( pe, anApp->desktop(), win );
629 static void UpdateVtkSelection()
631 QPtrList<SUIT_ViewWindow> winList = application()->desktop()->windows();
632 SUIT_ViewWindow* win = 0;
633 for ( win = winList.first(); win; win = winList.next() ) {
634 if ( win->getViewManager()->getTypeView() == VIEW_VTK ) {
635 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
637 SVTK_RenderWindowInteractor* anInteractor = vw->getRWInteractor();
638 anInteractor->SetSelectionProp();
639 anInteractor->SetSelectionTolerance();
640 SVTK_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
642 aStyle->setPreselectionProp();
649 //=================================================================================
650 // function : GeometryGUI::SetSettings()
651 // purpose : Called when GEOM module is activated [static]
652 //=================================================================================
653 bool GeometryGUI::SetSettings()
655 QMenuBar* Mb = parent->getMainMenuBar();
656 SUIT_Study* ActiveStudy = application()->activeStudy();
658 // Wireframe or Shading
660 SUIT_ViewWindow* window = application()->desktop()->activeWindow();
661 bool ViewOCC = ( window && window->getViewManager()->getType() == VIEW_OCC );
662 bool ViewVTK = ( window && window->getViewManager()->getType() == VIEW_VTK );
664 OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( window->getViewManager() );
666 Handle(AIS_InteractiveContext) ic = vm->getOCCViewer()->getAISContext();
667 DisplayMode = ic->DisplayMode();
670 else if ( ViewVTK ) {
671 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
673 SVTK_RenderWindowInteractor* myRenderInter = vw->getRWInteractor();
674 DisplayMode = myRenderInter->GetDisplayMode();
678 if( DisplayMode == 1 )
680 Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) );
682 Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) );
685 // Add in Study - !!!ALWAYS TRUE!!! /////// VSR : TO BE REMOVED
686 QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
687 int Settings_AddInStudy;
688 // if(!AddInStudy.isEmpty())
689 // Settings_AddInStudy = AddInStudy.toInt();
692 Settings_AddInStudy = 1;
693 Mb->setItemChecked(411, Settings_AddInStudy);
696 QString S = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
698 QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", "100");
701 int count = ActiveStudy->getStudyFramesCount();
702 for(int i = 0; i < count; i++) {
703 if(ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC) {
704 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
705 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
707 QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
708 QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
710 ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
712 ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
718 // PAL5356: update VTK selection
719 ::UpdateVtkSelection();
722 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
723 bOk = bOk && it.data()->SetSettings( parent );
725 // MZN: Enable/disable "Clipping range" menu item(from GEOM_CLIPPING variable)
726 if (getenv( "GEOM_CLIPPING" ) == NULL)
728 QMenuItem* mi = Mb->findItem(50);
729 if (mi && mi->popup())
730 mi->popup()->removeItem(507);
737 //=======================================================================
738 // function : createGeomAction
740 //=======================================================================
741 void GeometryGUI::createGeomAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
744 QWidget* parent = application()->desktop();
745 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
747 if ( icon_id.length() )
748 pix = resMgr->loadPixmap( "GEOM", tr( icon_id ) );
750 pix = resMgr->loadPixmap( "GEOM", tr( QString( "ICO_" )+po_id ), false );
752 icon = QIconSet( pix );
754 QString tooltip = tr( QString( "TOP_" )+po_id ),
755 menu = tr( QString( "MEN_" )+po_id ),
756 status_bar = tr( QString( "STB_" )+po_id );
758 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
763 //=======================================================================
764 // function : GeometryGUI::initialize()
765 // purpose : Called when GEOM module is created
766 //=======================================================================
767 void GeometryGUI::initialize( CAM_Application* app )
769 SalomeApp_Module::initialize( app );
771 // ----- create actions --------------
773 createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) );
774 createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) );
776 createGeomAction( 33, "DELETE", "", Key_Delete );
778 createGeomAction( 4011, "POINT" );
779 createGeomAction( 4012, "LINE" );
780 createGeomAction( 4013, "CIRCLE" );
781 createGeomAction( 4014, "ELLIPSE" );
782 createGeomAction( 4015, "ARC" );
783 createGeomAction( 4019, "CURVE" );
784 createGeomAction( 4016, "VECTOR" );
785 createGeomAction( 4017, "PLANE" );
786 createGeomAction( 4018, "WORK_PLANE" );
787 createGeomAction( 4020, "LOCAL_CS" );
789 createGeomAction( 4021, "BOX" );
790 createGeomAction( 4022, "CYLINDER" );
791 createGeomAction( 4023, "SPHERE" );
792 createGeomAction( 4024, "TORUS" );
793 createGeomAction( 4025, "CONE" );
795 createGeomAction( 4031, "EXTRUSION" );
796 createGeomAction( 4032, "REVOLUTION" );
797 createGeomAction( 4033, "FILLING" );
798 createGeomAction( 4034, "PIPE" );
800 createGeomAction( 800, "GROUP_CREATE" );
801 createGeomAction( 801, "GROUP_EDIT" );
803 createGeomAction( 9997, "Q_FACE" );
804 createGeomAction( 9999, "HEX_SOLID" );
806 createGeomAction( 404, "SKETCH" );
807 createGeomAction( 407, "EXPLODE" );
809 createGeomAction( 4081, "EDGE" );
810 createGeomAction( 4082, "WIRE" );
811 createGeomAction( 4083, "FACE" );
812 createGeomAction( 4084, "SHELL" );
813 createGeomAction( 4085, "SOLID" );
814 createGeomAction( 4086, "COMPOUND" );
816 createGeomAction( 5011, "FUSE" );
817 createGeomAction( 5012, "COMMON" );
818 createGeomAction( 5013, "CUT" );
819 createGeomAction( 5014, "SECTION" );
821 createGeomAction( 5021, "TRANSLATION" );
822 createGeomAction( 5022, "ROTATION" );
823 createGeomAction( 5023, "MODIFY_LOCATION" );
824 createGeomAction( 5024, "MIRROR" );
825 createGeomAction( 5025, "SCALE" );
826 createGeomAction( 5026, "OFFSET" );
827 createGeomAction( 5027, "MUL_TRANSLATION" );
828 createGeomAction( 5028, "MUL_ROTATION" );
830 createGeomAction( 503, "PARTITION" );
831 createGeomAction( 504, "ARCHIMEDE" );
832 createGeomAction( 505, "FILLET" );
833 createGeomAction( 506, "CHAMFER" );
834 //createGeomAction( 507, "CLIPPING" );
835 createGeomAction( 508, "GET_SHAPES_ON_SHAPES" );
837 createGeomAction( 9998, "MUL_TRANSFORM" );
838 createGeomAction( 9995, "EXPLODE_BLOCKS" );
839 createGeomAction( 99991, "PROPAGATE" );
841 createGeomAction( 601, "SEWING" );
842 createGeomAction( 602, "GLUE_FACES" );
843 createGeomAction( 603, "SUPPRESS_FACES" );
844 createGeomAction( 604, "SUPPERSS_HOLES" );
845 createGeomAction( 605, "SHAPE_PROCESS" );
846 createGeomAction( 606, "CLOSE_CONTOUR" );
847 createGeomAction( 607, "SUPPRESS_INT_WIRES" );
848 createGeomAction( 608, "POINT_ON_EDGE" );
849 createGeomAction( 609, "CHECK_FREE_BNDS" );
850 createGeomAction( 610, "CHECK_FREE_FACES" );
851 createGeomAction( 611, "CHANGE_ORIENTATION" );
852 createGeomAction( 612, "REMOVE_EXTRA_EDGES" );
854 createGeomAction( 708, "POINT_COORDS" );
855 createGeomAction( 701, "BASIC_PROPS" );
856 createGeomAction( 702, "MASS_CENTER" );
857 createGeomAction( 703, "INERTIA" );
858 createGeomAction( 704, "NORMALE" );
859 createGeomAction( 7041, "BND_BOX" );
860 createGeomAction( 7042, "MIN_DIST" );
861 createGeomAction( 7043, "MEASURE_ANGLE" );
863 createGeomAction( 705, "TOLERANCE" );
864 createGeomAction( 706, "WHAT_IS" );
865 createGeomAction( 707, "CHECK" );
866 createGeomAction( 7072, "CHECK_COMPOUND" );
868 #ifdef _DEBUG_ // PAL16821
869 createGeomAction( 5103, "CHECK_GEOMETRY" );
871 createGeomAction( 412, "SHADING_COLOR" );
872 createGeomAction( 413, "ISOS" );
873 createGeomAction( 414, "STEP_VALUE" );
875 createGeomAction( 211, "SHADING" );
876 createGeomAction( 212, "DISPLAY_ALL" );
877 createGeomAction( 214, "ERASE_ALL" );
878 createGeomAction( 216, "DISPLAY" );
879 createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true );
880 createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true );
881 createGeomAction( 2173, "WIRE_SEL_ONLY", "", 0, true );
882 createGeomAction( 2174, "FACE_SEL_ONLY", "", 0, true );
883 createGeomAction( 2175, "SHELL_SEL_ONLY", "", 0, true );
884 createGeomAction( 2176, "SOLID_SEL_ONLY", "", 0, true );
885 createGeomAction( 2177, "COMPOUND_SEL_ONLY", "", 0, true );
886 createGeomAction( 2178, "ALL_SEL_ONLY", "", 0, true );
887 createGeomAction( 213, "DISPLAY_ONLY" );
888 createGeomAction( 215, "ERASE" );
890 createGeomAction( 901, "POP_RENAME", "", Key_F2 );
891 createGeomAction( 80311, "POP_WIREFRAME", "", 0, true );
892 createGeomAction( 80312, "POP_SHADING", "", 0, true );
893 createGeomAction( 8032, "POP_COLOR" );
894 createGeomAction( 8033, "POP_TRANSPARENCY" );
895 createGeomAction( 8034, "POP_ISOS" );
896 createGeomAction( 8035, "POP_AUTO_COLOR" );
897 createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" );
898 createGeomAction( 8001, "POP_CREATE_GROUP" );
900 // make wireframe-shading items to be exclusive (only one at a time is selected)
901 //QActionGroup* dispModeGr = new QActionGroup( this, "", true );
902 //dispModeGr->add( action( 80311 ) );
903 //dispModeGr->add( action( 80312 ) );
904 // ---- create menu --------------------------
906 int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
907 createMenu( separator(), fileId, 10 );
908 createMenu( 111, fileId, 10 );
909 createMenu( 121, fileId, 10 );
910 createMenu( separator(), fileId, -1 );
912 int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
913 createMenu( 33, editId, -1 );
915 int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
917 int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
918 createMenu( 4011, basicId, -1 );
919 createMenu( 4012, basicId, -1 );
920 createMenu( 4013, basicId, -1 );
921 createMenu( 4014, basicId, -1 );
922 createMenu( 4015, basicId, -1 );
923 createMenu( 4019, basicId, -1 );
924 createMenu( separator(), basicId, -1 );
925 createMenu( 4016, basicId, -1 );
926 createMenu( 4017, basicId, -1 );
927 createMenu( 4018, basicId, -1 );
928 createMenu( 4020, basicId, -1 );
930 int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
931 createMenu( 4021, primId, -1 );
932 createMenu( 4022, primId, -1 );
933 createMenu( 4023, primId, -1 );
934 createMenu( 4024, primId, -1 );
935 createMenu( 4025, primId, -1 );
937 int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
938 createMenu( 4031, genId, -1 );
939 createMenu( 4032, genId, -1 );
940 createMenu( 4033, genId, -1 );
941 createMenu( 4034, genId, -1 );
942 createMenu( separator(), newEntId, -1 );
944 int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
945 createMenu( 800, groupId, -1 );
946 createMenu( 801, groupId, -1 );
947 createMenu( separator(), newEntId, -1 );
949 int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
950 createMenu( 9997, blocksId, -1 );
951 createMenu( 9999, blocksId, -1 );
953 createMenu( separator(), newEntId, -1 );
954 createMenu( 404, newEntId, -1 );
955 createMenu( separator(), newEntId, -1 );
956 createMenu( 407, newEntId, -1 );
958 int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
959 createMenu( 4081, buildId, -1 );
960 createMenu( 4082, buildId, -1 );
961 createMenu( 4083, buildId, -1 );
962 createMenu( 4084, buildId, -1 );
963 createMenu( 4085, buildId, -1 );
964 createMenu( 4086, buildId, -1 );
966 int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
968 int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
969 createMenu( 5011, boolId, -1 );
970 createMenu( 5012, boolId, -1 );
971 createMenu( 5013, boolId, -1 );
972 createMenu( 5014, boolId, -1 );
974 int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
975 createMenu( 5021, transId, -1 );
976 createMenu( 5022, transId, -1 );
977 createMenu( 5023, transId, -1 );
978 createMenu( 5024, transId, -1 );
979 createMenu( 5025, transId, -1 );
980 createMenu( 5026, transId, -1 );
981 createMenu( separator(), transId, -1 );
982 createMenu( 5027, transId, -1 );
983 createMenu( 5028, transId, -1 );
985 createMenu( 503, operId, -1 );
986 createMenu( 504, operId, -1 );
987 createMenu( 508, operId, -1 );
988 createMenu( separator(), operId, -1 );
989 createMenu( 505, transId, -1 );
990 createMenu( 506, transId, -1 );
991 //createMenu( 507, transId, -1 );
993 int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
994 createMenu( 9998, blockId, -1 );
995 createMenu( 9995, blockId, -1 );
996 createMenu( 99991, blockId, -1 );
998 int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
999 createMenu( 605, repairId, -1 );
1000 createMenu( 603, repairId, -1 );
1001 createMenu( 606, repairId, -1 );
1002 createMenu( 607, repairId, -1 );
1003 createMenu( 604, repairId, -1 );
1004 createMenu( 601, repairId, -1 );
1005 createMenu( 602, repairId, -1 );
1006 createMenu( 608, repairId, -1 );
1007 //createMenu( 609, repairId, -1 );
1008 //createMenu( 610, repairId, -1 );
1009 createMenu( 611, repairId, -1 );
1010 createMenu( 612, repairId, -1 );
1012 int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1013 createMenu( 708, measurId, -1 );
1014 createMenu( 701, measurId, -1 );
1015 createMenu( separator(), measurId, -1 );
1016 createMenu( 702, measurId, -1 );
1017 createMenu( 703, measurId, -1 );
1018 createMenu( 704, measurId, -1 );
1019 // NPAL16572: move "Check free boundaries" and "Check free faces" from "Repair" to "Measure"
1020 createMenu( separator(), measurId, -1 );
1021 createMenu( 609, measurId, -1 );
1022 createMenu( 610, measurId, -1 );
1024 createMenu( separator(), measurId, -1 );
1026 int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1027 createMenu( 7041, dimId, -1 );
1028 createMenu( 7042, dimId, -1 );
1029 createMenu( 7043, dimId, -1 );
1030 createMenu( separator(), measurId, -1 );
1032 createMenu( 705, measurId, -1 );
1033 createMenu( separator(), measurId, -1 );
1034 createMenu( 706, measurId, -1 );
1035 createMenu( 707, measurId, -1 );
1036 createMenu( 7072, measurId, -1 );
1038 #ifdef _DEBUG_ // PAL16821
1039 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1040 createMenu( separator(), toolsId, -1 );
1041 createMenu( 5103, toolsId, -1 );
1043 //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 );
1044 //createMenu( separator(), prefId, -1 );
1045 //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 );
1046 //createMenu( 412, geomId, -1 );
1047 //createMenu( 413, geomId, -1 );
1048 //createMenu( 414, geomId, -1 );
1049 //createMenu( separator(), prefId, -1 );
1051 int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1052 createMenu( separator(), viewId, -1 );
1054 int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1055 createMenu( 211, dispmodeId, -1 );
1057 createMenu( separator(), viewId, -1 );
1058 createMenu( 212, viewId, -1 );
1059 createMenu( 214, viewId, -1 );
1060 createMenu( separator(), viewId, -1 );
1064 because of these items are accessible through object browser and viewers
1065 we have removed they from main menu
1067 createMenu( 216, viewId, -1 );
1068 createMenu( 213, viewId, -1 );
1069 createMenu( 215, viewId, -1 );
1072 // ---- create toolbars --------------------------
1074 int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1075 createTool( 4011, basicTbId );
1076 createTool( 4012, basicTbId );
1077 createTool( 4013, basicTbId );
1078 createTool( 4014, basicTbId );
1079 createTool( 4015, basicTbId );
1080 createTool( 4019, basicTbId );
1081 createTool( 4016, basicTbId );
1082 createTool( 4017, basicTbId );
1083 createTool( 4018, basicTbId );
1084 createTool( 4020, basicTbId );
1086 int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1087 createTool( 4021, primTbId );
1088 createTool( 4022, primTbId );
1089 createTool( 4023, primTbId );
1090 createTool( 4024, primTbId );
1091 createTool( 4025, primTbId );
1093 int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1094 createTool( 5011, boolTbId );
1095 createTool( 5012, boolTbId );
1096 createTool( 5013, boolTbId );
1097 createTool( 5014, boolTbId );
1099 int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1100 createTool( 4031, genTbId );
1101 createTool( 4032, genTbId );
1102 createTool( 4033, genTbId );
1103 createTool( 4034, genTbId );
1105 int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1106 createTool( 5021, transTbId );
1107 createTool( 5022, transTbId );
1108 createTool( 5023, transTbId );
1109 createTool( 5024, transTbId );
1110 createTool( 5025, transTbId );
1111 createTool( 5026, transTbId );
1112 createTool( separator(), transTbId );
1113 createTool( 5027, transTbId );
1114 createTool( 5028, transTbId );
1116 // ---- create popup menus --------------------------
1118 QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1119 QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1121 QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1122 QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1124 QString autoColorPrefix =
1125 "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1127 QtxPopupMgr* mgr = popupMgr();
1128 mgr->insert( action( 901 ), -1, -1 ); // rename
1129 mgr->setRule( action( 901 ), "$type in {'Shape' 'Group'} and selcount=1", true );
1130 mgr->insert( action( 33 ), -1, -1 ); // delete
1131 mgr->setRule( action( 33 ), "$type in {'Shape' 'Group'} and selcount>0", true );
1132 mgr->insert( action( 8001 ), -1, -1 ); // create group
1133 mgr->setRule( action( 8001 ), "client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true", true );
1134 mgr->insert( action( 801 ), -1, -1 ); // edit group
1135 mgr->setRule( action( 801 ), "client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true", true );
1136 mgr->insert( separator(), -1, -1 ); // -----------
1137 dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1138 mgr->insert( action( 80311 ), dispmodeId, -1 ); // wireframe
1139 mgr->setRule( action( 80311 ), clientOCCorVTK_AndSomeVisible, true );
1140 mgr->setRule( action( 80311 ), clientOCCorVTK + " and displaymode='Wireframe'", false );
1141 mgr->insert( action( 80312 ), dispmodeId, -1 ); // shading
1142 mgr->setRule( action( 80312 ), clientOCCorVTK_AndSomeVisible, true );
1143 mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", false );
1144 mgr->insert( separator(), -1, -1 ); // -----------
1145 mgr->insert( action( 8032 ), -1, -1 ); // color
1146 mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", true );
1147 mgr->insert( action( 8033 ), -1, -1 ); // transparency
1148 mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, true );
1149 mgr->insert( action( 8034 ), -1, -1 ); // isos
1150 mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", true );
1151 mgr->insert( separator(), -1, -1 ); // -----------
1152 mgr->insert( action( 8035 ), -1, -1 ); // auto color
1153 mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", true );
1154 mgr->insert( action( 8036 ), -1, -1 ); // disable auto color
1155 mgr->setRule( action( 8036 ), autoColorPrefix + " and isAutoColor=true", true );
1156 mgr->insert( separator(), -1, -1 ); // -----------
1159 QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1160 onlyComponent = "((type='Component') and selcount=1)",
1161 rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1162 types = "'Shape' 'Group'";
1164 mgr->insert( action( 216 ), -1, -1 ); // display
1165 mgr->setRule( action( 216 ), rule.arg( types ).arg( "not isVisible" ), true );
1167 mgr->insert( action( 215 ), -1, -1 ); // erase
1168 mgr->setRule( action( 215 ), rule.arg( types ).arg( "isVisible" ), true );
1170 mgr->insert( action( 214 ), -1, -1 ); // erase All
1171 mgr->setRule( action( 214 ), clientOCCorVTK, true );
1173 QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1175 int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu
1176 mgr->insert( action(2171), selectolnyId, -1); //Vertex
1177 mgr->setRule(action(2171), selectOnly, true);
1178 mgr->setRule(action(2171), selectOnly + " and selectionmode='VERTEX'", false);
1179 mgr->insert( action(2172), selectolnyId, -1); //Edge
1180 mgr->setRule(action(2172), selectOnly, true);
1181 mgr->setRule(action(2172), selectOnly + " and selectionmode='EDGE'", false);
1182 mgr->insert( action(2173), selectolnyId, -1); //Wire
1183 mgr->setRule(action(2173), selectOnly, true);
1184 mgr->setRule(action(2173), selectOnly + " and selectionmode='WIRE'", false);
1185 mgr->insert( action(2174), selectolnyId, -1); //Face
1186 mgr->setRule(action(2174), selectOnly, true);
1187 mgr->setRule(action(2174), selectOnly + " and selectionmode='FACE'", false);
1188 mgr->insert( action(2175), selectolnyId, -1); //Shell
1189 mgr->setRule(action(2175), selectOnly, true);
1190 mgr->setRule(action(2175), selectOnly + " and selectionmode='SHELL'", false);
1191 mgr->insert( action(2176), selectolnyId, -1); //Solid
1192 mgr->setRule(action(2176), selectOnly, true);
1193 mgr->setRule(action(2176), selectOnly + " and selectionmode='SOLID'", false);
1194 mgr->insert( action(2177), selectolnyId, -1); //Compound
1195 mgr->setRule(action(2177), selectOnly, true);
1196 mgr->setRule(action(2177), selectOnly + " and selectionmode='COMPOUND'", false);
1197 mgr->insert( separator(), selectolnyId, -1);
1198 mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter
1199 mgr->setRule(action(2178), selectOnly, true);
1200 mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", false);
1202 mgr->insert( action( 213 ), -1, -1 ); // display only
1203 mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), true );
1204 mgr->insert( separator(), -1, -1 );
1206 mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1209 //=======================================================================
1210 // function : GeometryGUI::activateModule()
1211 // purpose : Called when GEOM module is activated
1212 //=======================================================================
1213 bool GeometryGUI::activateModule( SUIT_Study* study )
1215 if ( CORBA::is_nil( myComponentGeom ) )
1218 bool res = SalomeApp_Module::activateModule( study );
1223 setMenuShown( true );
1224 setToolShown( true );
1226 connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1227 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1229 // Reset actions accelerator keys
1230 //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import
1231 //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export
1232 action(111)->setEnabled(true); // Import
1233 action(121)->setEnabled(true); // Export
1235 GUIMap::Iterator it;
1236 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1237 it.data()->activate( application()->desktop() );
1239 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1240 SUIT_ViewManager* vm;
1241 ViewManagerList OCCViewManagers, VTKViewManagers;
1242 application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1243 for ( vm = OCCViewManagers.first(); vm; vm = OCCViewManagers.next() )
1244 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1245 application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1246 for ( vm = VTKViewManagers.first(); vm; vm = VTKViewManagers.next() )
1247 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1249 // disable OCC selectors
1250 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1251 for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() )
1252 sr->setEnabled(true);
1254 // disable VTK selectors
1255 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1256 for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() )
1257 sr->setEnabled(true);
1263 //=======================================================================
1264 // function : GeometryGUI::deactivateModule()
1265 // purpose : Called when GEOM module is deactivated
1266 //=======================================================================
1267 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1269 setMenuShown( false );
1270 setToolShown( false );
1272 disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1273 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1275 EmitSignalCloseAllDialogs();
1277 GUIMap::Iterator it;
1278 for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1279 it.data()->deactivate();
1281 // Unset actions accelerator keys
1282 //action(111)->setAccel(QKeySequence()); // Import
1283 //action(121)->setAccel(QKeySequence()); // Export
1284 action(111)->setEnabled(false); // Import
1285 action(121)->setEnabled(false); // Export
1287 myOCCSelectors.clear();
1288 getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1290 myVTKSelectors.clear();
1291 getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1293 return SalomeApp_Module::deactivateModule( study );
1296 //=================================================================================
1297 // function : GeometryGUI::DefinePopup()
1298 // purpose : Called from desktop to define popup menu [static]
1299 //=================================================================================
1301 void GeometryGUI::DefinePopup(QString& theContext, QString& theParent, QString& theObject)
1303 QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
1304 SALOME_Selection* Sel = SALOME_Selection::Selection(ActiveStudy->getSelection());
1309 if ( theParent == "Viewer" ) {
1310 if ( Sel->IObjectCount() == 0 )
1311 theContext = "NothingSelected";
1314 if ( Sel->IObjectCount() == 1 ) {
1315 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
1316 if( IO->hasEntry() ) {
1317 SALOMEDS::SObject_var sobj = ActiveStudy->getStudyDocument()->FindObjectID( IO->getEntry() );
1318 if ( !sobj->_is_nil() ) {
1319 SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
1320 if ( !strcmp(scomp->GetID(), IO->getEntry() ) ) {
1321 // component is selected
1322 theObject = "Component";
1325 GEOM::GEOM_Object_var aGObj = GEOM::GEOM_Object::_narrow( sobj->GetObject() );
1326 if ( !CORBA::is_nil( aGObj ) ) {
1327 switch( aGObj->GetType() ) {
1329 theObject = "Group";
1332 theObject = "Shape";
1342 //=================================================================================
1343 // function : GeometryGUI::CustomPopup()
1344 // purpose : Called from desktop to create popup menu [static]
1345 //=================================================================================
1346 bool GeometryGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
1347 const QString& theParent, const QString& theObject)
1349 GeometryGUI* geomGUI = GetGeomGUI();
1351 // Deactivate any non modal dialog box to get the neutral point
1352 geomGUI->EmitSignalDeactivateDialog();
1353 QAD_Study* anActiveStudy = parent->getActiveStudy();
1354 QAD_StudyFrame* aStudyFrame = anActiveStudy->getActiveStudyFrame();
1355 QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
1356 SALOME_Selection* Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
1357 QString parentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
1358 bool isOCCViewer = aViewFrame->getTypeView() == VIEW_OCC;
1359 bool isVTKViewer = aViewFrame->getTypeView() == VIEW_VTK;
1360 int aDisplayMode = 0;
1363 if ( aViewFrame->getTypeView() == VIEW_OCC )
1364 aDisplayMode = ((OCCViewer_ViewFrame*)aViewFrame)->getViewer()->getAISContext()->DisplayMode();
1365 else if ( aViewFrame->getTypeView() == VIEW_VTK )
1366 aDisplayMode = (dynamic_cast<SVTK_ViewFrame*>( aViewFrame )->getRWInteractor()->GetDisplayMode();
1368 int nbSel = Sel->IObjectCount();
1371 ////// NOTHING SELECTED
1374 else if ( nbSel == 1 ) {
1375 ////// SINGLE OBJECT SELECTION
1376 if ( parentComponent != parent->getActiveComponent() ) {
1377 ////// selected object does not belong to GEOM module:
1378 // remove all commands except Display/Erase...
1380 int id = popup->idAt( 0 );
1381 if ( id <= QAD_TopLabel_Popup_ID )
1382 popup->removeItemAt( 0 );
1388 ////// selected object belong to the GEOM module
1389 // get interactive object
1390 Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1391 objectName = IObject->getName();
1392 // if object has entry get SObject
1393 SALOMEDS::SObject_var SO;
1394 if ( IObject->hasEntry() )
1395 SO = anActiveStudy->getStudyDocument()->FindObjectID( IObject->getEntry() );
1397 if ( theObject == "Component" ) {
1398 ////// menu for component
1399 if ( !isOCCViewer && !isVTKViewer ) {
1400 popup->removeItem( QAD_DisplayOnly_Popup_ID );
1401 popup->removeItem( QAD_Display_Popup_ID );
1402 popup->removeItem( QAD_Erase_Popup_ID );
1406 ////// not component (should be shape)
1407 if ( IObject->hasEntry() ) /////// VSR : TO BE REMOVED
1408 popup->removeItem( 804 ); // "Add in Study"
1410 // Here could be analysis of the geom shape's type
1413 SALOMEDS::GenericAttribute_var aTmpAttr;
1414 if( SO->_is_nil() || SO->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR") )
1415 popup->removeItem( 9024 ); // "Open" /////// VSR : TO BE REMOVED
1417 if ( !isOCCViewer && theParent == "ObjectBrowser" ) {
1418 if ( theObject == "Shape" )
1419 popup->removeItem( 800 ); // Create Group
1420 else if ( theObject == "Group" )
1421 popup->removeItem( 801 ); // Edit Group
1424 if ( isOCCViewer || isVTKViewer ) {
1425 ////// current viewer is OCC or VTK
1426 SALOME_Prs* prs = aViewFrame->CreatePrs( IObject->getEntry() );
1427 if ( aViewFrame->isVisible( IObject ) ) {
1428 ////// object is already displayed in the viewer
1429 popup->removeItem( QAD_Display_Popup_ID );
1430 if ( isOCCViewer ) {
1431 ////// OCC viewer only
1432 OCCViewer_Prs* occPrs = dynamic_cast<OCCViewer_Prs*>( prs );
1433 if ( occPrs && !occPrs->IsNull() ) {
1434 AIS_ListOfInteractive ioList;
1435 occPrs->GetObjects( ioList );
1436 QMenuItem* mi = popup->findItem( 803 );
1437 if ( mi && mi->popup() ) {
1438 if ( ioList.First()->DisplayMode() == 0 )
1439 mi->popup()->setItemChecked( 80311, true ); // "Wireframe"
1440 else if ( ioList.First()->DisplayMode() == 1 )
1441 mi->popup()->setItemChecked( 80312, true ); // "Shading"
1442 else if ( ioList.First()->DisplayMode() < 0 )
1443 mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading"
1448 ////// VTK viewer only
1449 //popup->removeItem( 8034 ); // "Isos"
1450 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1451 if ( vtkPrs && !vtkPrs->IsNull() ) {
1452 vtkActorCollection* actorList = vtkPrs->GetObjects();
1453 actorList->InitTraversal();
1454 SALOME_Actor* ac = SALOME_Actor::SafeDownCast( actorList->GetNextActor() );
1455 QMenuItem* mi = popup->findItem( 803 );
1456 if ( ac && mi && mi->popup() ) {
1457 if ( ac->getDisplayMode() == 0 )
1458 mi->popup()->setItemChecked( 80311, true ); // "Wireframe"
1459 else if ( ac->getDisplayMode() == 1 )
1460 mi->popup()->setItemChecked( 80312, true ); // "Shading"
1462 mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading"
1468 ////// object is not yet displayed in the viewer
1469 popup->removeItem( 803 ); // "Display Mode"
1470 popup->removeItem( 8032 ); // "Color"
1471 popup->removeItem( 8033 ); // "Transparency"
1472 popup->removeItem( 8034 ); // "Isos"
1473 popup->removeItem( QAD_Erase_Popup_ID );
1478 ////// other viewer type (neither OCC nor VTK)
1479 popup->removeItem( 803 ); // "Display Mode"
1480 popup->removeItem( 8032 ); // "Color"
1481 popup->removeItem( 8033 ); // "Transparency"
1482 popup->removeItem( 8034 ); // "Isos"
1483 popup->removeItem( QAD_Display_Popup_ID );
1484 popup->removeItem( QAD_DisplayOnly_Popup_ID );
1485 popup->removeItem( QAD_Erase_Popup_ID );
1491 ////// MULTIPLE SELECTION
1492 if ( parentComponent != parent->getActiveComponent() ) {
1493 ////// not GEOM module objects or objects belong to different modules
1494 // remove all commands except Display/Erase...
1496 int id = popup->idAt( 0 );
1497 if ( id <= QAD_TopLabel_Popup_ID )
1498 popup->removeItemAt( 0 );
1502 if ( parentComponent.isNull() ) {
1503 ////// objects belong to different modules
1504 popup->removeItem(QAD_Display_Popup_ID);
1505 popup->removeItem(QAD_DisplayOnly_Popup_ID);
1506 popup->removeItem(QAD_Erase_Popup_ID);
1509 objectName = tr( "GEOM_MEN_POPUP_NAME" ).arg( nbSel );
1513 ////// all selected objects belong to GEOM module
1514 popup->removeItem( 901 ); // "Rename"
1516 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1517 bool isComponent = false;
1518 bool needOpen = false;
1519 bool needDisplay = false;
1520 bool needErase = false;
1521 int needToPublish = 0;
1523 for( ;It.More();It.Next() ) {
1524 Handle(SALOME_InteractiveObject) anIObject = It.Value();
1526 if ( aViewFrame->isVisible( anIObject ) )
1531 if( anIObject->hasEntry() ) {
1532 needToPublish = -1; /////// VSR : TO BE REMOVED
1533 SALOMEDS::SObject_var obj = anActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
1534 SALOMEDS::GenericAttribute_var aTmpAttr;
1535 if ( !obj->_is_nil() && !obj->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR" ) )
1536 needOpen = true; /////// VSR : TO BE REMOVED
1537 if ( !obj->_is_nil() && QString( obj->GetID() ) == QString( obj->GetFatherComponent()->GetID() ) )
1541 if ( needToPublish != -1 ) needToPublish = 1;
1544 if( needOpen || ( !isOCCViewer && !isVTKViewer ) ) {
1545 ////// Data is not loaded yet or current viewer is neither OCC nor VTK
1546 popup->removeItem( 803 ); // "Display Mode"
1547 popup->removeItem( 8032 ); // "Color"
1548 popup->removeItem( 8033 ); // "Transparency"
1549 popup->removeItem( 8034 ); // "Isos"
1550 popup->removeItem( 804 ); // "Add in Study"
1551 popup->removeItem( QAD_DisplayOnly_Popup_ID );
1552 popup->removeItem( QAD_Display_Popup_ID );
1553 popup->removeItem( QAD_Erase_Popup_ID );
1556 popup->removeItem( 9024 ); // "Open"
1557 if ( needToPublish <= 0 )
1558 popup->removeItem( 804 ); // "Add in Study"
1561 popup->removeItem( 803 ); // "Display Mode"
1562 popup->removeItem( 8032 ); // "Color"
1563 popup->removeItem( 8033 ); // "Transparency"
1564 popup->removeItem( 8034 ); // "Isos"
1565 popup->removeItem( QAD_DisplayOnly_Popup_ID );
1569 popup->removeItem( QAD_Display_Popup_ID );
1571 popup->removeItem( QAD_Erase_Popup_ID );
1572 if ( !isOCCViewer && !isVTKViewer)
1573 popup->removeItem( 8034 ); // "Isos"
1578 // check popup for unnecessary separators
1579 QAD_Tools::checkPopup( popup );
1580 // find popup menu's TopLabel item (with title)
1581 int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
1582 if ( topItem >= 0 ) {
1583 // remove popup menu's title item
1584 popup->removeItem( QAD_TopLabel_Popup_ID );
1585 if ( theParent == "Viewer" && !objectName.isEmpty() && popup->count() > 0 ) {
1586 // set bold font for popup menu's title
1587 QFont f = popup->font(); f.setBold( TRUE );
1588 popup->removeItem( QAD_TopLabel_Popup_ID );
1589 popup->insertItem( new CustomItem( objectName, f ), QAD_TopLabel_Popup_ID, topItem );
1598 //=======================================================================
1599 // function : GeometryGUI::BuildPresentation()
1601 //=======================================================================
1602 void GeometryGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& io, SUIT_ViewWindow* win )
1604 //GEOM_Displayer().Display( io, false, win );
1607 //=======================================================================
1608 // function : onWindowActivated()
1609 // purpose : update menu items' status - disable non-OCC-viewer-compatible actions
1610 //=======================================================================
1611 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1616 const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1617 const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1619 // disable non-OCC viewframe menu commands
1620 // action( 404 )->setEnabled( ViewOCC ); // SKETCHER
1621 action( 603 )->setEnabled( ViewOCC ); // SuppressFace
1622 action( 604 )->setEnabled( ViewOCC ); // SuppressHole
1623 action( 606 )->setEnabled( ViewOCC ); // CloseContour
1624 action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires
1625 action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
1626 // action( 609 )->setEnabled( ViewOCC ); // Free boundaries
1627 action( 413 )->setEnabled( ViewOCC ); // Isos Settings
1628 action( 413 )->setEnabled( ViewVTK ); // Isos Settings
1630 action( 800 )->setEnabled( ViewOCC ); // Create Group
1631 action( 801 )->setEnabled( ViewOCC ); // Edit Group
1633 action( 9998 )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1636 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1638 mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
1639 mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
1642 void GeometryGUI::viewManagers( QStringList& lst ) const
1644 lst.append( OCCViewer_Viewer::Type() );
1647 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1649 if ( vm->getType() == OCCViewer_Viewer::Type() )
1651 qDebug( "connect" );
1652 connect( vm, SIGNAL( keyPress ( SUIT_ViewWindow*, QKeyEvent* ) ),
1653 this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1654 connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1655 this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1656 connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1657 this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1660 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1661 myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1663 // disable OCC selectors
1664 getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1665 for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() )
1666 sr->setEnabled(true);
1668 else if ( vm->getType() == SVTK_Viewer::Type() )
1670 LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1671 myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1673 // disable VTK selectors
1674 getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1675 for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() )
1676 sr->setEnabled(true);
1680 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1682 SUIT_ViewModel* viewer = vm->getViewModel();
1683 if ( vm->getType() == OCCViewer_Viewer::Type() )
1685 for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() )
1686 if ( sr->viewer() == viewer )
1688 myOCCSelectors.remove( sr );
1692 if ( vm->getType() == SVTK_Viewer::Type() )
1694 for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() )
1695 if ( sr->viewer() == viewer )
1697 myVTKSelectors.remove( sr );
1703 QString GeometryGUI::engineIOR() const
1705 if ( !CORBA::is_nil( GetGeomGen() ) )
1706 return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1707 return QString( "" );
1710 LightApp_Selection* GeometryGUI::createSelection() const
1712 return new GEOMGUI_Selection();
1715 void GeometryGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
1717 SalomeApp_Module::contextMenuPopup( client, menu, title );
1719 getApp()->selectionMgr()->selectedObjects( lst );
1720 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
1721 Handle(SALOME_InteractiveObject) io = lst.First();
1722 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1723 _PTR(Study) study = appStudy->studyDS();
1724 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
1726 title = QString( obj->GetName().c_str() );
1730 void GeometryGUI::createPreferences()
1732 int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1734 int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1735 setPreferenceProperty( genGroup, "columns", 1 );
1737 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1738 LightApp_Preferences::Selector, "Geometry", "display_mode" );
1740 addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1741 LightApp_Preferences::Color, "Geometry", "shading_color" );
1743 addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1744 LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1746 addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1747 LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1749 addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1750 LightApp_Preferences::Color, "Geometry", "line_color" );
1752 addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1753 LightApp_Preferences::Color, "Geometry", "point_color" );
1755 addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1756 LightApp_Preferences::Color, "Geometry", "isos_color" );
1758 int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1759 LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1761 int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1763 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1764 LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1766 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1767 LightApp_Preferences::DblSpin, "Geometry", "marker_scale" );
1769 // Set property for default display mode
1770 QStringList aModesList;
1771 aModesList.append( tr("MEN_WIREFRAME") );
1772 aModesList.append( tr("MEN_SHADING") );
1774 QValueList<QVariant> anIndexesList;
1775 anIndexesList.append(0);
1776 anIndexesList.append(1);
1778 setPreferenceProperty( dispmode, "strings", aModesList );
1779 setPreferenceProperty( dispmode, "indexes", anIndexesList );
1781 // Set property for step value for spinboxes
1782 setPreferenceProperty( step, "min", 0.001 );
1783 setPreferenceProperty( step, "max", 10000 );
1784 setPreferenceProperty( step, "precision", 3 );
1786 // Set property for type of vertex marker
1787 QStringList aTypeOfMarkerList;
1788 QValueList<QVariant> anTypeOfMarkerIndexesList;
1790 aTypeOfMarkerList.append( tr("TOM_PLUS") );
1791 anTypeOfMarkerIndexesList.append(Aspect_TOM_PLUS);
1793 aTypeOfMarkerList.append( tr("TOM_POINT") );
1794 anTypeOfMarkerIndexesList.append(Aspect_TOM_POINT);
1796 aTypeOfMarkerList.append( tr("TOM_STAR") );
1797 anTypeOfMarkerIndexesList.append(Aspect_TOM_STAR);
1799 aTypeOfMarkerList.append( tr("TOM_O") );
1800 anTypeOfMarkerIndexesList.append(Aspect_TOM_O);
1802 aTypeOfMarkerList.append( tr("TOM_X") );
1803 anTypeOfMarkerIndexesList.append(Aspect_TOM_X);
1805 aTypeOfMarkerList.append( tr("TOM_O_POINT") );
1806 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_POINT);
1808 aTypeOfMarkerList.append( tr("TOM_O_PLUS") );
1809 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_PLUS);
1811 aTypeOfMarkerList.append( tr("TOM_O_STAR") );
1812 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_STAR);
1814 aTypeOfMarkerList.append( tr("TOM_O_X") );
1815 anTypeOfMarkerIndexesList.append(Aspect_TOM_O_X);
1818 setPreferenceProperty( typeOfMarker, "strings", aTypeOfMarkerList );
1819 setPreferenceProperty( typeOfMarker, "indexes", anTypeOfMarkerIndexesList );
1821 // Set property for Vertex Marker scale
1822 setPreferenceProperty( markerScale, "min", 1. );
1823 setPreferenceProperty( markerScale, "max", 7. );
1824 setPreferenceProperty( markerScale, "precision", 0.01 );
1825 setPreferenceProperty( markerScale, "step", 0.5 );
1829 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1831 if (section == "Geometry") {
1832 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1833 if (param == QString("SettingsGeomStep")) {
1834 double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1835 EmitSignalDefaultStepValueChanged(spin_step);
1840 LightApp_Displayer* GeometryGUI::displayer()
1843 myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1847 void GeometryGUI::setLocalSelectionMode(const int mode)
1849 myLocalSelectionMode = mode;
1851 int GeometryGUI::getLocalSelectionMode() const
1853 return myLocalSelectionMode;