HYDROGUI_PrsPolylineDriver.h
HYDROGUI_PrsZone.h
HYDROGUI_PrsZoneDriver.h
+ HYDROGUI_Region.h
HYDROGUI_Shape.h
HYDROGUI_ShowHideOp.h
HYDROGUI_Tool.h
HYDROGUI_PrsPolylineDriver.cxx
HYDROGUI_PrsZone.cxx
HYDROGUI_PrsZoneDriver.cxx
+ HYDROGUI_Region.cxx
HYDROGUI_Shape.cxx
HYDROGUI_ShowHideOp.cxx
HYDROGUI_Tool.cxx
#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>
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();
myEditedObject, "", true );
myBrowser->updateTree();
myBrowser->openLevels();
+ myBrowser->adjustColumnsWidth();
}
HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
* 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();
#include <SUIT_DataObject.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_SelectionMgr.h>
+#include <SUIT_DataObjectIterator.h>
#define VISIBILITY_COLUMN_WIDTH 25
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
/*
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;
+}
#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
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;
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_Zone.h"
+#include "HYDROGUI_Region.h"
#include <HYDROData_Bathymetry.h>
#include <HYDROData_CalculationCase.h>
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 )
{
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 )
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 )
Handle(HYDROData_Zone) aRegionZone =
Handle(HYDROData_Zone)::DownCast( anIter.Value() );
if( !aRegionZone.IsNull() && !aRegionZone->IsRemoved() )
- createObject( aGuiObj, aRegionZone, "", true );
+ createZone( aGuiObj, aRegionZone, "", true );
}
}
}
#include <HYDROData_Document.h>
#include <HYDROData_Entity.h>
+#include <HYDROData_Zone.h>
+#include <HYDROData_Region.h>
#include <QMap>
#include <LightApp_DataModel.h>
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
--- /dev/null
+// 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
+ ;
+ }
+}
--- /dev/null
+// 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
/**
* 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.