Salome HOME
refs #514: add 'Cursor for specific operations' section into preferences of HYDRO...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index d08d53b5aaa3f980bf9f84d5def5df83aec0635d..a9690cdb396f1195c7c6646afcf839c207c3f82a 100644 (file)
 #include "HYDROGUI_ImportGeomObjectOp.h"
 #include "HYDROGUI_ShowHideOp.h"
 
+#include <HYDROData_Tool.h>
 #include <HYDROData_Image.h>
+#include <HYDROData_Stream.h>
 #include <HYDROData_Profile.h>
 #include <HYDROData_Lambert93.h>
-#include <HYDROData_Tool.h>
+#include <HYDROData_Polyline3D.h>
 
 #include <HYDROData_OperationsFactory.h>
 
@@ -81,6 +83,7 @@
 #include <SUIT_Study.h>
 #include <SUIT_ViewManager.h>
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
 
 #include <SVTK_ViewManager.h>
 #include <SVTK_ViewModel.h>
@@ -339,6 +342,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsGroup = false;
   bool anIsObjectCanBeColored = false;
   bool isRoot = false;
+  bool isStreamHasBottom = false;
 
   SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
   SUIT_DataOwnerPtrList anOwners;
@@ -450,7 +454,13 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       else if( anObjectKind == KIND_OBSTACLE )
         anIsObstacle = true;
       else if( anObjectKind == KIND_STREAM )
+      {
         anIsStream = true;
+        Handle(HYDROData_Stream) aStream = 
+          Handle(HYDROData_Stream)::DownCast( anObject );
+        if ( !aStream.IsNull() )
+            isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
+      }
       else if( anObjectKind == KIND_CHANNEL )
         anIsChannel = true;
       else if( anObjectKind == KIND_DIGUE )
@@ -599,6 +609,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       else if( anIsStream )
       {
         theMenu->addAction( action( EditStreamId ) );
+        if ( action( RiverBottomContextId ) )
+        {
+            theMenu->addAction( action( RiverBottomContextId ) );
+            action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
+        }
+        theMenu->addAction( action( ProfileInterpolateId ) );
         theMenu->addSeparator();
       }
       else if( anIsChannel )
@@ -691,6 +707,30 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addAction( action( EditLocalCSId ) );
 }
 
+void HYDROGUI_Module::createPreferences()
+{
+  int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
+  int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
+
+  int typeOfCursor = addPreference( tr( "PREF_TYPE_OF_CURSOR" ), CursorGroup,
+                                    LightApp_Preferences::Selector, "preferences", "type_of_cursor" );
+
+  // Set property cursor type
+  QList<QVariant> aCursorTypeIndicesList;
+  QList<QVariant> aCursorTypeIconsList;
+
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  for ( int i = CT_ArrowCursor; i < CT_User; i++ ) {
+    QString icoFile = QString( "ICON_CURSOR_%1" ).arg( i+1 );
+    QPixmap pixmap = resMgr->loadPixmap( "HYDRO", tr( qPrintable( icoFile ) ) );
+    aCursorTypeIndicesList << i;
+    aCursorTypeIconsList << pixmap;
+  }
+
+  setPreferenceProperty( typeOfCursor, "indexes", aCursorTypeIndicesList );
+  setPreferenceProperty( typeOfCursor, "icons",   aCursorTypeIconsList );
+}
+
 void HYDROGUI_Module::update( const int flags )
 {
   if( !isUpdateEnabled() )