Salome HOME
lots 3,8 - corrections
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 54d2a851049d52a4fdabb436b279281abcaf460e..f9bdea57ac2d9310178b7d135e9bb59d22673a77 100644 (file)
@@ -397,6 +397,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsObjectCanBeColored = false;
   bool isRoot = false;
   bool isStreamHasBottom = false;
+  bool anIsBCPolygon = false;
 
   SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
   SUIT_DataOwnerPtrList anOwners;
@@ -511,6 +512,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsStricklerTable = true;
       else if( anObjectKind == KIND_LAND_COVER_MAP )
         anIsLandCoverMap = true;
+      else if (anObjectKind == KIND_BC_POLYGON)
+        anIsBCPolygon = true;
       else if( anObjectKind == KIND_STREAM )
       {
         anIsStream = true;
@@ -589,6 +592,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       case KIND_VISUAL_STATE:
         theMenu->addAction( action( SaveVisualStateId ) );
         break;
+      case KIND_BC_POLYGON:
+        theMenu->addAction( action( ImportBCPolygonId ) );
+        break;
       }
       theMenu->addSeparator();
     }
@@ -752,6 +758,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       }
       else if (anIsZone)
         theMenu->addAction( action( ZoneSetColorId ) );
+      else if (anIsBCPolygon)
+        theMenu->addAction( action( SetBoundaryTypePolygonId ) );
 
       if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
       {
@@ -801,7 +809,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       anIsImmersibleZone || anIsZone || anIsRegion ||
       anIsBathymetry || anIsObstacle || anIsStream ||
       anIsChannel || anIsDigue || anIsDummyObject3D ||
-      anIsValidProfile || anIsGroup || anIsLandCoverMap )
+      anIsValidProfile || anIsGroup || anIsLandCoverMap ||
+      anIsBCPolygon)
     {
       if( anIsHiddenInSelection )
         theMenu->addAction( action( ShowId ) );
@@ -1992,6 +2001,67 @@ void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn
   update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
 }
 
+bool HYDROGUI_Module::isDraggable( const SUIT_DataObject* what ) const
+{
+  return true;
+}
+
+bool HYDROGUI_Module::isDropAccepted( const SUIT_DataObject* where ) const
+{
+
+  return true;
+}
+
+void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
+                                   const int row, Qt::DropAction action )
+{
+  if ( action != Qt::CopyAction && action != Qt::MoveAction )
+    return; 
+
+  if (row == -1)
+    return;
+
+  if (where->level() < 2 )
+    return;  
+
+  DataObjectList::ConstIterator it = what.constBegin();
+  for (;it != what.constEnd();++it) 
+  {
+    if ((*it)->parent() != where)
+      return;
+  }
+
+  it = what.constBegin();
+
+  int i=0;
+  for (;it != what.constEnd();++it) 
+  {
+    SUIT_DataObject* objWhat = *it;
+
+    DataObjectList objInSect = where->children();
+
+    //std::list<SUIT_DataObject*> t1 = where->children().toStdList(); //debug
+    int ind = objInSect.indexOf(objWhat);
+    if (ind != -1)
+    {
+      HYDROGUI_DataModel* aModel = getDataModel();
+      int pos = -1;
+      if (ind >= row)
+      {
+        pos = row + i;
+        i++;
+      }
+      else
+        pos = row - 1;
+      where->moveChildPos(objWhat, pos);
+      //std::list<SUIT_DataObject*> t2 = where->children().toStdList(); //debug
+    }  
+  }
+
+  getApp()->updateObjectBrowser(true);
+  
+}
+
 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
 {
   Handle(HYDROData_StricklerTable) aTable;