#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 <HYDROData_Object.h>
#include <CAM_Application.h>
#include <LightApp_DataObject.h>
+#include <SUIT_DataObject.h>
#include <SUIT_FileDlg.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
QWizard* aWizard = wizard();
aWizard->addPage( createObjectsPage() );
aWizard->addPage( createZonesPage() );
+ connect( aWizard->button( QWizard::NextButton ), SIGNAL( clicked() ), SIGNAL( splitZones() ) );
aWizard->show();
}
QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
QWizardPage* aPage = new QWizardPage( wizard() );
QFrame* aFrame = new QFrame( aPage );
- // Calculation name
-// myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ), aFrame );
-// myObjectName = new QLineEdit( myObjectNameGroup );
+ // Calculation name
myObjectName = new QLineEdit( aPage );
myValidator = new HYDROGUI_NameValidator(module(), myObjectName);
myObjectName->setValidator( myValidator );
connect( myValidator, SIGNAL( emptyName() ), this, SLOT( onEmptyName() ) );
connect( myValidator, SIGNAL( alreadyExists( QString ) ), this, SLOT( onAlreadyExists( QString ) ) );
- //QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
- //aNameLayout->setMargin( 5 );
- //aNameLayout->setSpacing( 5 );
- //aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
- //aNameLayout->addWidget( myObjectName );
-
- // Calculation zones
- //QFrame* anObjectsFrame = new QFrame( aFrame );
-
- //myGeomObjects = new QListWidget( anObjectsFrame );
myGeomObjects = new QListWidget( aPage );
myGeomObjects->setSelectionMode( QListWidget::SingleSelection );
myGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
myGeomObjects->setViewMode( QListWidget::ListMode );
+ myGeomObjects->setSortingEnabled( true );
QFrame* aBtnsFrame = new QFrame( aPage );
QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
QFrame* aFrame = new QFrame( aPage );
QGridLayout* aLayout = new QGridLayout( aPage );
- //Handle(HYDROData_Entity) anEntity = module()->getDataModel()->getDocument()->CreateObject( KIND_CALCULATION );
- myBrowser = new HYDROGUI_DataBrowser( module(), 0/*module()->application()->activeStudy()->root()*/, aPage );
+ myBrowser = new HYDROGUI_DataBrowser( module(), 0, aPage );
myBrowser->setAutoOpenLevel( 3 );
aLayout->setMargin( 5 );
aLayout->setSpacing( 5 );
aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
- QLabel* aBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
+ myBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
myBathymetryChoice = new QComboBox( aFrame );
- myBathymetryChoice->addItem( tr( "ZMIN" ) );
- myBathymetryChoice->addItem( tr( "ZMAX" ) );
- aLayout->addWidget( aBatimetryLabel, 1, 0 );
+ myBathymetryChoice->setVisible( false );
+ myBatimetryLabel->setVisible( false );
+
+ aLayout->addWidget( myBatimetryLabel, 1, 0 );
aLayout->addWidget( myBathymetryChoice, 1, 1 );
aPage->setLayout( aLayout );
+ 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
+ emit createRegion( aZonesList );
+ }
+ else
+ {
+ HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
+ if ( aRegion )
+ {
+ emit moveZones( theTargetParent, aZonesList );
+ }
+ }
+ }
+}
+
+void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
+{
+ int aType = myBathymetryChoice->itemData( theIndex ).toInt();
+ QString aText = myBathymetryChoice->itemText( theIndex );
+ emit setMergeType( aType, aText );
+}
+
+void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject )
+{
+ bool doShow = false;
+ HYDROGUI_Zone* aZone = dynamic_cast<HYDROGUI_Zone*>( theObject );
+ if ( aZone )
+ {
+ doShow = aZone->isMergingNeed();
+ }
+
+ if ( doShow )
+ {
+ // Fill the merge type combo box
+ bool prevBlock = myBathymetryChoice->blockSignals( true );
+ myCurrentZone = aZone;
+ myBathymetryChoice->clear();
+ myBathymetryChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN );
+ myBathymetryChoice->addItem( tr("MERGE_ZMIN"), HYDROData_Zone::Merge_ZMIN );
+ myBathymetryChoice->addItem( tr("MERGE_ZMAX"), HYDROData_Zone::Merge_ZMAX );
+ QStringList aList = aZone->getBathymetries();
+ for ( int i = 0; i < aList.length(); i++ )
+ {
+ myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
+ }
+ // Select the current choice if any
+ int aCurIndex = 0;
+ switch ( aZone->getMergeType() )
+ {
+ case HYDROData_Zone::Merge_ZMIN:
+ aCurIndex = 1;
+ break;
+ case HYDROData_Zone::Merge_ZMAX:
+ aCurIndex = 2;
+ break;
+ case HYDROData_Zone::Merge_Object:
+ aCurIndex = 3 + aList.indexOf( aZone->text( HYDROGUI_DataObject::BathymetryId ) );
+ break;
+ default:
+ aCurIndex = 0; // Select unknown by default
+ }
+ myBathymetryChoice->setCurrentIndex( aCurIndex );
+ myBathymetryChoice->blockSignals( prevBlock );
+ }
+
+ myBathymetryChoice->setVisible( doShow );
+ myBatimetryLabel->setVisible( doShow );
+}
+
void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
{
myObjectName->setText( theName );
HYDROGUI_DataObject* anobj = new HYDROGUI_DataObject( 0, NULL, "" );
myBrowser->setRoot(anobj);
- LightApp_DataObject* aCaseItem = module()->getDataModel()->createObject( anobj,
- myEditedObject, "", true );
+ module()->getDataModel()->buildCaseTree( anobj, myEditedObject );
myBrowser->updateTree();
myBrowser->openLevels();
+ myBrowser->adjustColumnsWidth();
+}
+
+HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
+{
+ return myCurrentZone;
}
+
+void HYDROGUI_CalculationDlg::refreshZonesBrowser()
+{
+ myBrowser->updateTree();
+}
\ No newline at end of file