From: mzn Date: Mon, 30 Aug 2010 10:44:22 +0000 (+0000) Subject: Fix for imp 0020845: EDF 1376 GUI : More shortcuts. X-Git-Tag: end_translate_resources_09Jul10~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=35a3b96395e0a2a5711c2951bebf1be06738a254;p=modules%2Fgeom.git Fix for imp 0020845: EDF 1376 GUI : More shortcuts. --- diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 44d9898fd..d3aa9a3ac 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -377,7 +377,11 @@ void GeometryGUI::OnGUIEvent( int id ) case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT case GEOMOp::OpColor: // POPUP MENU - COLOR case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY + case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY + case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY case GEOMOp::OpIsos: // POPUP MENU - ISOS + case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS + case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN @@ -572,7 +576,8 @@ void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e ) // function : createGeomAction // purpose : //======================================================================= -void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel, const int accel, const bool toggle ) +void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel, + const int accel, const bool toggle, const QString& shortcutAction ) { SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false ) @@ -585,11 +590,12 @@ void GeometryGUI::createGeomAction( const int id, const QString& label, const QS accel, application()->desktop(), toggle, - this, SLOT( OnGUIEvent() ) ); + this, SLOT( OnGUIEvent() ), + shortcutAction ); } //======================================================================= -// function : createGeomAction +// function : createOriginAndBaseVectors // purpose : //======================================================================= void GeometryGUI::createOriginAndBaseVectors() @@ -768,6 +774,19 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" ); createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" ); + + // Create actions for increase/decrease transparency shortcuts + createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false, + "Geometry:Increase transparency"); + createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false, + "Geometry:Decrease transparency"); + + // Create actions for increase/decrease number of isolines + createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false, + "Geometry:Increase number of isolines"); + createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false, + "Geometry:Decrease number of isolines"); + // createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 69cd94753..23aabc8c6 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -147,7 +147,8 @@ private: GEOMGUI* getLibrary( const QString& libraryName ); void createGeomAction( const int id, const QString& po_id, const QString& icon_id = QString(""), - const int key = 0, const bool toggle = false ); + const int key = 0, const bool toggle = false, + const QString& shortcutAction = QString() ); void createPopupItem( const int, const QString& clients, const QString& types, const bool isSingle = false, const int isVisible = -1, const bool isExpandAll = false, const bool isOCC = false, diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index c027220c9..064d04fe0 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -40,10 +40,14 @@ namespace GEOMOp { OpDeflection = 1200, // POPUP MENU - DEFLECTION COEFFICIENT OpColor = 1201, // POPUP MENU - COLOR OpTransparency = 1202, // POPUP MENU - TRANSPARENCY - OpIsos = 1203, // POPUP MENU - ISOS - OpAutoColor = 1204, // POPUP MENU - AUTO COLOR - OpNoAutoColor = 1205, // POPUP MENU - DISABLE AUTO COLOR - OpPointMarker = 1206, // POPUP MENU - POINT MARKER + OpIncrTransparency = 1203, // SHORTCUT - INCREASE TRANSPARENCY + OpDecrTransparency = 1204, // SHORTCUT - DECREASE TRANSPARENCY + OpIsos = 1205, // POPUP MENU - ISOS + OpIncrNbIsos = 1206, // SHORTCUT - INCREASE NB ISOS + OpDecrNbIsos = 1207, // SHORTCUT - DECREASE NB ISOS + OpAutoColor = 1208, // POPUP MENU - AUTO COLOR + OpNoAutoColor = 1209, // POPUP MENU - DISABLE AUTO COLOR + OpPointMarker = 1210, // POPUP MENU - POINT MARKER OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN OpRename = 1252, // POPUP MENU - RENAME diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index a01872173..3d183d976 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -334,9 +334,21 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) case GEOMOp::OpTransparency: // POPUP - TRANSPARENCY OnTransparency(); break; + case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY + OnChangeTransparency( true ); + break; + case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY + OnChangeTransparency( false ); + break; case GEOMOp::OpIsos: // POPUP - ISOS OnNbIsos(); break; + case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOLINES + OnNbIsos( INCR ); + break; + case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOLINES + OnNbIsos( DECR ); + break; case GEOMOp::OpAutoColor: // POPUP - AUTO COLOR OnAutoColor(); break; diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index ab7d404f3..09cdbd4e8 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI.h @@ -52,6 +52,8 @@ public: bool OnGUIEvent( int, SUIT_Desktop* ); virtual void deactivate(); + enum ActionType { SHOWDLG, INCR, DECR }; + private: // Import and export topology methods bool Import(); @@ -67,12 +69,15 @@ private: void OnDisableAutoColor(); void OnColor(); void OnTransparency(); - void OnNbIsos(); + void OnNbIsos( ActionType actionType = SHOWDLG ); void OnDeflection(); void OnSelectOnly(int mode); void OnShowHideChildren( bool ); void OnPointMarker(); + // Shortcut commands + void OnChangeTransparency( bool ); + // Recursive deletion of object with children void removeObjectWithChildren( _PTR(SObject), _PTR(Study), diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index fb05288a1..ae395b43a 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -399,7 +399,86 @@ void GEOMToolsGUI::OnTransparency() dlg.exec(); } -void GEOMToolsGUI::OnNbIsos() +void GEOMToolsGUI::OnChangeTransparency( bool increase ) +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) + return; + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) + return; + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) + return; + + Handle(SALOME_InteractiveObject) FirstIOS = selected.First(); + if ( FirstIOS.IsNull() ) + return; + + // Delta + float delta = 0.01; + if ( !increase ) + delta *= -1; + + SUIT_ViewWindow* window = app->desktop()->activeWindow(); + bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); + bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); + + if ( isVTK ) { + SVTK_ViewWindow* vtkVW = dynamic_cast( window ); + if ( !vtkVW ) + return; + SVTK_View* aView = vtkVW->getView(); + + float transp = aView->GetTransparency(FirstIOS); + + // Compute new transparency value + transp = transp + delta; + if ( transp < 0 ) + transp = 0; + else if ( transp > 1 ) + transp = 1; + + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + aView->SetTransparency( It.Value(), transp ); + } + aView->Repaint(); + } // if ( isVTK ) + + else if ( isOCC ) { + GEOMBase* gb = new GEOMBase(); + Standard_Boolean found; + Handle(GEOM_AISShape) aisShape; + + aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, found ); + if( !found ) + return; + float transp = aisShape->Transparency(); + + // Compute new transparency value + transp = transp + delta; + if ( transp < 0 ) + transp = 0; + else if ( transp > 1 ) + transp = 1; + + OCCViewer_Viewer* vm = dynamic_cast( window->getViewManager()->getViewModel() ); + if ( !vm ) + return; + Handle(AIS_InteractiveContext) ic = vm->getAISContext(); + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), found ); + if ( found ) { + ic->SetTransparency( aisShape, transp, false ); + ic->Redisplay( aisShape, Standard_False, Standard_True ); + } + } // for... + ic->UpdateCurrentViewer(); + } // if ( isOCC ) +} + +void GEOMToolsGUI::OnNbIsos( ActionType actionType ) { SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); @@ -419,27 +498,44 @@ void GEOMToolsGUI::OnNbIsos() int UIso = CurDrawer->UIsoAspect()->Number(); int VIso = CurDrawer->VIsoAspect()->Number(); - GEOMToolsGUI_NbIsosDlg * NbIsosDlg = - new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); + int newNbUIso = -1; + int newNbVIso = -1; - NbIsosDlg->setU( UIso ); - NbIsosDlg->setV( VIso ); + if ( actionType == SHOWDLG ) { + GEOMToolsGUI_NbIsosDlg * NbIsosDlg = + new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); - if ( NbIsosDlg->exec() ) { - SUIT_OverrideCursor(); - for(; ic->MoreCurrent(); ic->NextCurrent()) { - CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); - Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); + NbIsosDlg->setU( UIso ); + NbIsosDlg->setV( VIso ); - int nbUIso = NbIsosDlg->getU(); - int nbVIso = NbIsosDlg->getV(); - - CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) ); - CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) ); + if ( NbIsosDlg->exec() ) { + SUIT_OverrideCursor(); + + newNbUIso = NbIsosDlg->getU(); + newNbVIso = NbIsosDlg->getV(); + } + } + else if ( actionType == INCR || actionType == DECR ) { + int delta = 1; + if (actionType == DECR) + delta = -1; + + newNbUIso = UIso + delta; + newNbVIso = VIso + delta; + + if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 ) + return; + } - ic->SetLocalAttributes(CurObject, CurDrawer); - ic->Redisplay(CurObject); - } + for(; ic->MoreCurrent(); ic->NextCurrent()) { + CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); + Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); + + CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbUIso) ); + CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbVIso) ); + + ic->SetLocalAttributes(CurObject, CurDrawer); + ic->Redisplay(CurObject); } } } @@ -492,27 +588,45 @@ void GEOMToolsGUI::OnNbIsos() anActor->GetNbIsos(UIso,VIso); else return; + + int newNbUIso = -1; + int newNbVIso = -1; - GEOMToolsGUI_NbIsosDlg* NbIsosDlg = - new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); + if ( actionType == SHOWDLG ) { + GEOMToolsGUI_NbIsosDlg* NbIsosDlg = + new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); - NbIsosDlg->setU( UIso ); - NbIsosDlg->setV( VIso ); + NbIsosDlg->setU( UIso ); + NbIsosDlg->setV( VIso ); - if ( NbIsosDlg->exec() ) { - SUIT_OverrideCursor(); + if ( NbIsosDlg->exec() ) { + SUIT_OverrideCursor(); - while( anAct!=NULL ) { - if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){ - // There are no casting to needed actor. - UIso = NbIsosDlg->getU(); - VIso = NbIsosDlg->getV(); - int aIsos[2]={UIso,VIso}; - anActor->SetNbIsos(aIsos); - } - anAct = aCollection->GetNextActor(); + newNbUIso = NbIsosDlg->getU(); + newNbVIso = NbIsosDlg->getV(); + } + } + else if ( actionType == INCR || actionType == DECR ) { + int delta = 1; + if (actionType == DECR) + delta = -1; + + newNbUIso = UIso + delta; + newNbVIso = VIso + delta; + + if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 ) + return; + } + + while( anAct!=NULL ) { + if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){ + // There are no casting to needed actor. + int aIsos[2]={newNbUIso,newNbVIso}; + anActor->SetNbIsos(aIsos); } + anAct = aCollection->GetNextActor(); } + view->Repaint(); } // end vtkviewer }