]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix for imp 0020845: EDF 1376 GUI : More shortcuts.
authormzn <mzn@opencascade.com>
Mon, 30 Aug 2010 10:44:22 +0000 (10:44 +0000)
committermzn <mzn@opencascade.com>
Mon, 30 Aug 2010 10:44:22 +0000 (10:44 +0000)
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI.h
src/GEOMGUI/GeometryGUI_Operations.h
src/GEOMToolsGUI/GEOMToolsGUI.cxx
src/GEOMToolsGUI/GEOMToolsGUI.h
src/GEOMToolsGUI/GEOMToolsGUI_1.cxx

index 44d9898fd995093d86595c34710ccc0e8efa45e6..d3aa9a3aca063028a42b881bcb55e8ccaeb85e05 100644 (file)
@@ -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 @@//
 
index 69cd94753c1dd1a0f5f6c9fdab04eba24f7a4e70..23aabc8c6eb840390f52afe1f220d7453ea4f287 100644 (file)
@@ -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,
index c027220c936dcfec888a1ff08cd25f7322f43266..064d04fe0f1febe5c683ca129296996e5c8cdd53 100644 (file)
@@ -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
index a01872173af59d92675500d2c7cc63d7c9f84694..3d183d97602db3d7443623ad294c3298dc72d2eb 100644 (file)
@@ -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;
index ab7d404f38599f22cdb8f69172fb98116ebc67fe..09cdbd4e8e9e282aba8365f82f9415027ff625bb 100644 (file)
@@ -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),
index fb05288a1731b37ca9414ed4a949b4ec401e901c..ae395b43a69b6a82f7d0a362cd53bc68393ca613 100644 (file)
@@ -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<SVTK_ViewWindow*>( 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<OCCViewer_Viewer*>( 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
 }