]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
- Stub for drag and drop in the Calculation Case wizard is implemented (zones moving...
authorrkv <rkv@opencascade.com>
Fri, 1 Nov 2013 11:36:00 +0000 (11:36 +0000)
committerrkv <rkv@opencascade.com>
Fri, 1 Nov 2013 11:36:00 +0000 (11:36 +0000)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_DataBrowser.cxx
src/HYDROGUI/HYDROGUI_DataBrowser.h
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DataModel.h
src/HYDROGUI/HYDROGUI_Region.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Region.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Zone.h

index 32e007dd0079519f39655cb289b53b026ef36e8f..dc39fbe20052e3a8748234c3333f6b86a2bc84bd 100644 (file)
@@ -41,6 +41,7 @@ set(PROJECT_HEADERS
     HYDROGUI_PrsPolylineDriver.h
     HYDROGUI_PrsZone.h
     HYDROGUI_PrsZoneDriver.h
+    HYDROGUI_Region.h
     HYDROGUI_Shape.h
     HYDROGUI_ShowHideOp.h
     HYDROGUI_Tool.h
@@ -94,6 +95,7 @@ set(PROJECT_SOURCES
     HYDROGUI_PrsPolylineDriver.cxx
     HYDROGUI_PrsZone.cxx
     HYDROGUI_PrsZoneDriver.cxx
+    HYDROGUI_Region.cxx
     HYDROGUI_Shape.cxx
     HYDROGUI_ShowHideOp.cxx
     HYDROGUI_Tool.cxx
index e395d6d611b515e5ac19cab26bec1227b9abf103..c06ab638b0f0e2d3ff6480d2c4a556c44be64ae7 100644 (file)
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_DataObject.h"
 #include "HYDROGUI_NameValidator.h"
+#include "HYDROGUI_Region.h"
+#include "HYDROGUI_Zone.h"
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Entity.h>
-#include <HYDROGUI_Zone.h>
 
 #include <CAM_Application.h>
 #include <LightApp_DataObject.h>
@@ -168,10 +169,46 @@ QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
 
   connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
   connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) );
+  connect( myBrowser, 
+      SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
+      SLOT( onZonesDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
 
   return aPage;
 }
 
+void HYDROGUI_CalculationDlg::onZonesDropped( const QList<SUIT_DataObject*>& theList, 
+    SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
+{
+  QList<SUIT_DataObject*> aZonesList;
+  HYDROGUI_Zone* aZone;
+  // Get a list of dropped zones
+  for ( int i = 0; i < theList.length(); i++ )
+  {
+    aZone = dynamic_cast<HYDROGUI_Zone*>( theList.at( i ) );
+    if ( aZone )
+    {
+      aZonesList.append( aZone );
+    }
+  }
+  if ( aZonesList.length() > 0 )
+  {
+    // Get the target region
+    HYDROGUI_NamedObject* aRegionsRoot = dynamic_cast<HYDROGUI_NamedObject*>(theTargetParent);
+    if ( aRegionsRoot )
+    {
+      // Create a new region
+    }
+    else
+    {
+      HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
+      if ( aRegion )
+      {
+        aRegion->addZones( );
+      }
+    }
+  }
+}
+
 void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
 {
   int aType = myBathymetryChoice->itemData( theIndex ).toInt();
@@ -276,6 +313,7 @@ void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculatio
                                      myEditedObject, "", true );
   myBrowser->updateTree();
   myBrowser->openLevels();
+  myBrowser->adjustColumnsWidth();
 }
 
 HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
index 7db16048eb6500257d880786dccde4177144971c..e2791f2140a016fff88809ed9c9138cd7f81add0 100644 (file)
@@ -70,6 +70,11 @@ public slots:
    * Process merge type selection: set the selected bathymetry merge type for the currently selected zone.
    */
   void                       onMergeTypeSelected( int theIndex );
+  /**
+   * Process zones moving. Create a new region with dropped zones or add to existing one.
+   */
+  void                       onZonesDropped( const QList<SUIT_DataObject*>& theList, 
+    SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction );
 
 signals:
   void                       addObjects();
index b6cdedb224516b134715593cbfc522844e113e1a..f4cc73c2b0ad64f157d411c65e972e741280dd89 100644 (file)
@@ -33,6 +33,7 @@
 #include <SUIT_DataObject.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_SelectionMgr.h>
+#include <SUIT_DataObjectIterator.h>
         
 #define VISIBILITY_COLUMN_WIDTH 25
 
@@ -50,22 +51,26 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat
   setWindowTitle( tr( "OBJECT_BROWSER" ) );
   connect( this, SIGNAL( requestUpdate() ), theModule->getApp(), SLOT( onRefresh() ) );
 
+  QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
   QString RefObjCol = tr( "REF_OBJECT_COLUMN" );
   QString BathymetryCol = tr( "BATHYMETRY_COLUMN" );
   SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( model() );
-  treeModel->setSearcher( theModule->getApp() );
+  //RKV: treeModel->setSearcher( theModule->getApp() );
+  treeModel->setSearcher( this ); //RKV
+  treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
+  treeModel->setAppropriate( EntryCol, Qtx::Toggled );
   treeModel->registerColumn( 0, RefObjCol, HYDROGUI_DataObject::RefObjectId );
   treeModel->setAppropriate( RefObjCol, Qtx::Toggled );
   treeModel->registerColumn( 0, BathymetryCol, HYDROGUI_DataObject::BathymetryId );
   treeModel->setAppropriate( BathymetryCol, Qtx::Toggled );
 
   // Mantis issue 0020136: Drag&Drop in OB
-  //RKV: TODO: Uncomment for drag and drop
-  //RKV: SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
-  //RKV: if ( proxyModel ) {
-  //RKV:   connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
-  //RKV:            theModule->getApp(), SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
-  //RKV: }
+  SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
+  if ( proxyModel ) {
+    connect( proxyModel, 
+      SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
+      SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
+  }
 
   // temporary commented
   /*
@@ -82,9 +87,22 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat
   treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
   treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
   treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
+  treeView()->hideColumn( SUIT_DataObject::VisibilityId );
+  treeView()->hideColumn( LightApp_DataObject::EntryId );
   //RKV: connectPopupRequest( theModule->getApp(), SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
 }
 
 HYDROGUI_DataBrowser::~HYDROGUI_DataBrowser()
 {
 }
+
+SUIT_DataObject* HYDROGUI_DataBrowser::findObject( const QString& theEntry ) const
+{
+  LightApp_DataObject* aCurObj;
+  for ( SUIT_DataObjectIterator it( root(), SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
+    aCurObj = dynamic_cast<LightApp_DataObject*>( it.current() );
+    if ( aCurObj && aCurObj->entry() == theEntry )
+      return aCurObj;
+  }
+  return NULL;
+}
index 3c3e3201ac4dc9d10ea64ab19afd219998569f46..2d79a829e88bd54db392f79a4876b9ae1d448825 100644 (file)
 #define HYDROGUI_DATABROWSER_H
 
 #include <SUIT_DataBrowser.h>
+#include <SUIT_TreeModel.h>
 
 class HYDROGUI_Module;
 
 /**\class HYDROGUI_DataBrowser
  *\brief The data model browser widget implementation
  */
-class HYDROGUI_DataBrowser : public SUIT_DataBrowser
+class HYDROGUI_DataBrowser : public SUIT_DataBrowser, public SUIT_DataSearcher
 {
   Q_OBJECT
 
@@ -38,7 +39,18 @@ public:
   HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_DataObject*, QWidget* = 0 );
   ~HYDROGUI_DataBrowser();
 
-  HYDROGUI_Module* module() const;
+  HYDROGUI_Module*         module() const;
+
+  /*!
+    Find a data object by the specified entry.
+    \param theEntry - Entry of the object.
+    \return data object.
+  */
+  virtual SUIT_DataObject* findObject( const QString& ) const override;
+
+signals:
+  void             dropped( const QList<SUIT_DataObject*>& theList, 
+    SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction );
 
 private:
   HYDROGUI_Module* myModule;
index 6ea2d54aeab8160a183de0f6eccdffaf4a790359..dbe6cead511cd96d7b0dbd2f36861e88313a27c6 100644 (file)
@@ -26,6 +26,7 @@
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_Tool.h"
 #include "HYDROGUI_Zone.h"
+#include "HYDROGUI_Region.h"
 
 #include <HYDROData_Bathymetry.h>
 #include <HYDROData_CalculationCase.h>
@@ -528,17 +529,7 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*
                                                        const QString&           theParentEntry,
                                                        const bool               theIsBuildTree )
 {
-  HYDROGUI_DataObject* aResObj;
-  Handle(HYDROData_Zone) aRegionZone =
-    Handle(HYDROData_Zone)::DownCast( theModelObject );
-  if( !aRegionZone.IsNull() )
-  {
-    aResObj = new HYDROGUI_Zone( theParent, aRegionZone, theParentEntry );
-  }
-  else
-  {
-    aResObj = new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
-  }
+  HYDROGUI_DataObject* aResObj = new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
   
   if ( theIsBuildTree )
   {
@@ -548,6 +539,34 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*
   return aResObj;
 }
 
+LightApp_DataObject* HYDROGUI_DataModel::buildObject( SUIT_DataObject*     theParent,
+                                                      HYDROGUI_DataObject* theObject,
+                                                      const QString&       theParentEntry,
+                                                      const bool           theIsBuildTree )
+{
+  if ( theIsBuildTree )
+  {
+    buildObjectTree( theParent, theObject, theParentEntry );
+  }
+  return theObject;
+}
+
+LightApp_DataObject* HYDROGUI_DataModel::createZone( SUIT_DataObject*       theParent,
+                                                     Handle(HYDROData_Zone) theModelObject,
+                                                     const QString&         theParentEntry,
+                                                     const bool             theIsBuildTree )
+{
+  return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
+}
+
+LightApp_DataObject* HYDROGUI_DataModel::createRegion( SUIT_DataObject*         theParent,
+                                                       Handle(HYDROData_Region) theModelObject,
+                                                       const QString&           theParentEntry,
+                                                       const bool               theIsBuildTree )
+{
+  return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
+}
+
 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
                                                        const QString&   theName,
                                                        const QString&   theParentEntry )
@@ -614,7 +633,7 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
       Handle(HYDROData_Region) aCaseRegion =
         Handle(HYDROData_Region)::DownCast( anIter.Value() );
       if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
-        createObject( aCaseRegionsSect, aCaseRegion, "", true );
+        createRegion( aCaseRegionsSect, aCaseRegion, "", true );
     }
   }
   else if ( anObjectKind == KIND_REGION )
@@ -629,7 +648,7 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
       Handle(HYDROData_Zone) aRegionZone =
         Handle(HYDROData_Zone)::DownCast( anIter.Value() );
       if( !aRegionZone.IsNull() && !aRegionZone->IsRemoved() )
-        createObject( aGuiObj, aRegionZone, "", true );
+        createZone( aGuiObj, aRegionZone, "", true );
     }
   }
 }
index 97379263a0a804c9d55cf05775f3b09551e93dff..bfc590e71b4a2d43df8b0b6ed87028ef311dbb51 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Entity.h>
+#include <HYDROData_Zone.h>
+#include <HYDROData_Region.h>
 
 #include <QMap>
 #include <LightApp_DataModel.h>
@@ -249,6 +251,28 @@ protected:
                                      const QString&   theName,
                                      const QString&   theParentEntry = QString() );
 
+  /**
+   * Build object tree if the flag theIsBuildTree is true. 
+   * This is a conditional wrapper for buildObjectTree method.
+   * \param theParent a created object will be appended as a child of this object
+   * \param theObject the GUI object
+   * \param theParentEntry the entry of parent object
+   * \param theIsBuildTree if true then build the subtree of the GUI object
+   */
+  LightApp_DataObject* buildObject( SUIT_DataObject*     theParent,
+                                    HYDROGUI_DataObject* theObject,
+                                    const QString&       theParentEntry,
+                                    const bool           theIsBuildTree );
+
+  LightApp_DataObject* createZone( SUIT_DataObject*       theParent,
+                                   Handle(HYDROData_Zone) theModelObject,
+                                   const QString&         theParentEntry,
+                                   const bool             theIsBuildTree );
+
+  LightApp_DataObject* createRegion( SUIT_DataObject*         theParent,
+                                     Handle(HYDROData_Region) theModelObject,
+                                     const QString&           theParentEntry,
+                                     const bool               theIsBuildTree );
   /**
    * Build tree of model object.
    * \param theParent a created object will be appended as a child of this object
diff --git a/src/HYDROGUI/HYDROGUI_Region.cxx b/src/HYDROGUI/HYDROGUI_Region.cxx
new file mode 100644 (file)
index 0000000..1572290
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_Region.h"
+
+#include "HYDROGUI_Zone.h"
+
+#include <HYDROData_Region.h>
+#include <HYDROData_Zone.h>
+#include <HYDROData_Object.h>
+
+#include <SUIT_DataObject.h>
+
+HYDROGUI_Region::HYDROGUI_Region( SUIT_DataObject* theParent, 
+                                  Handle(HYDROData_Region) theData,
+                                  const QString& theParentEntry )
+: HYDROGUI_DataObject( theParent, theData, theParentEntry ), CAM_DataObject( theParent )
+{
+}
+
+void HYDROGUI_Region::addZones( )
+{
+  Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast( modelObject() );
+  if ( !aRegion.IsNull() )
+  {
+    // TODO: Add zones
+    ;
+  }
+}
diff --git a/src/HYDROGUI/HYDROGUI_Region.h b/src/HYDROGUI/HYDROGUI_Region.h
new file mode 100644 (file)
index 0000000..c5b3ac7
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_REGION_H
+#define HYDROGUI_REGION_H
+
+#include "HYDROGUI_DataObject.h"
+
+#include <HYDROData_Region.h>
+
+#include <QString>
+#include <QColor>
+
+/**
+ * \class HYDROGUI_Region
+ * \brief Browser item presenting a zone, used for object browser tree creation.
+ *
+ * This is an Object Browser item that contains reference to a zone data structure 
+ * element inside.
+ */
+class HYDROGUI_Region : public HYDROGUI_DataObject
+{
+public:
+  /**
+   * Constructor.
+   * \param theParent parent data object
+   * \param theData reference to the corresponding object from data structure
+   * \param theParentEntry entry of the parent data object (for reference objects)
+   */
+  HYDROGUI_Region( SUIT_DataObject* theParent,
+                   Handle(HYDROData_Region) theData,
+                   const QString& theParentEntry );
+
+  bool isDropAccepted() const override { return true; }
+
+  /**
+   * Add zones to the region. 
+   */
+  void addZones();
+};
+#endif
index 2b1f08fdd04b1563e2c2265b9b44a6754276be1e..4dca40d27ad013e3688e77c4101a0e7cc9323145 100644 (file)
@@ -58,7 +58,12 @@ public:
   /**
    * Returns the color for the specified column.
    */
-  QColor      color( const ColorRole, const int = NameId ) const override;
+  QColor      color( const ColorRole theColorRole, const int theColumnId = NameId ) const override;
+
+  /**
+   * Return true because zones are draggable.
+   */
+  bool        isDraggable() const override { return true; }
 
   /**
    * Returns true if it is a zone which needs merge of bathymetries.