#include "HYDROGUI_ObjSelector.h"
#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_DataBrowser.h"
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_DataObject.h"
+#include "HYDROGUI_NameValidator.h"
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Entity.h>
+#include <HYDROData_Object.h>
+
+#include <CAM_Application.h>
+#include <LightApp_DataObject.h>
#include <SUIT_FileDlg.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_Study.h>
+
+#include <LightApp_Application.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
#include <QGroupBox>
#include <QLabel>
#include <QPicture>
#include <QPushButton>
#include <QToolButton>
+#include <QWizardPage>
+#include <QComboBox>
HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
+: HYDROGUI_Wizard( theModule, theTitle )
{
- // Calculation name
- myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ), mainFrame() );
-
- myObjectName = new QLineEdit( myObjectNameGroup );
-
- QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
- aNameLayout->setMargin( 5 );
- aNameLayout->setSpacing( 5 );
- aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
- aNameLayout->addWidget( myObjectName );
-
-
- // Calculation boundary line
- QGroupBox* aBndGroup = new QGroupBox( tr( "CALCULATION_BOUNDARY" ), mainFrame() );
-
- myBndPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINE, aBndGroup );
-
- QBoxLayout* aBndLayout = new QHBoxLayout( aBndGroup );
- aBndLayout->setMargin( 5 );
- aBndLayout->setSpacing( 5 );
- aBndLayout->addWidget( new QLabel( tr( "BOUNDARY_POLYLINE" ), aBndGroup ) );
- aBndLayout->addWidget( myBndPolyline );
-
-
- // Calculation zones
- QGroupBox* aZonesGroup = new QGroupBox( tr( "CALCULATION_ZONES" ), mainFrame() );
-
- myZones = new QListWidget( aZonesGroup );
- myZones->setSelectionMode( QListWidget::SingleSelection );
- myZones->setEditTriggers( QListWidget::NoEditTriggers );
- myZones->setViewMode( QListWidget::ListMode );
-
- myRegions = new QListWidget( aZonesGroup );
- myRegions->setSelectionMode( QListWidget::SingleSelection );
- myRegions->setEditTriggers( QListWidget::NoEditTriggers );
- myRegions->setViewMode( QListWidget::ListMode );
-
- mySplittedZonesPrefix = new QLineEdit( aZonesGroup );
-
- QPushButton* aSplitBtn = new QPushButton( tr( "SPLIT_REFERENCE_ZONES" ), aZonesGroup );
-
- QGridLayout* aZonesLayout = new QGridLayout( aZonesGroup );
- aZonesLayout->setMargin( 5 );
- aZonesLayout->setSpacing( 5 );
- aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_REFERENCE_ZONES" ), aZonesGroup ), 0, 0, 1, 2 );
- aZonesLayout->addWidget( myZones, 1, 0, 1, 2 );
- aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_REGIONS" ), aZonesGroup ), 2, 0, 1, 2 );
- aZonesLayout->addWidget( myRegions, 3, 0, 1, 2 );
- aZonesLayout->addWidget( new QLabel( tr( "PREFIX_REGIONS" ), aZonesGroup ), 4, 0 );
- aZonesLayout->addWidget( mySplittedZonesPrefix, 4, 1 );
- aZonesLayout->addWidget( aSplitBtn, 5, 0, 1, 2 );
-
- // Common
- addWidget( myObjectNameGroup );
- addWidget( aBndGroup );
- addWidget( aZonesGroup );
- addStretch();
-
-
- // Connect signals and slots
- connect( aSplitBtn, SIGNAL( clicked( bool ) ), this, SIGNAL( SplitZones() ) );
+ QWizard* aWizard = wizard();
+ aWizard->addPage( createObjectsPage() );
+ aWizard->addPage( createZonesPage() );
+ aWizard->show();
}
HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
void HYDROGUI_CalculationDlg::reset()
{
myObjectName->clear();
+ myGeomObjects->clear();
+}
- myBndPolyline->Clear();
+QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
+ QWizardPage* aPage = new QWizardPage( wizard() );
+ QFrame* aFrame = new QFrame( aPage );
+ // Calculation name
+// myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ), aFrame );
- myZones->clear();
- myRegions->clear();
+// myObjectName = new QLineEdit( myObjectNameGroup );
+ myObjectName = new QLineEdit( aPage );
+ myValidator = new HYDROGUI_NameValidator(module(), myObjectName);
+ myObjectName->setValidator( myValidator );
- setSplitZonesPrefix( tr( "DEFAULT_PREFIX_REGIONS" ) );
-}
+ connect( myValidator, SIGNAL( emptyName() ), this, SLOT( onEmptyName() ) );
+ connect( myValidator, SIGNAL( alreadyExists( QString ) ), this, SLOT( onAlreadyExists( QString ) ) );
-void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
-{
- myObjectName->setText( theName );
-}
+ //QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
+ //aNameLayout->setMargin( 5 );
+ //aNameLayout->setSpacing( 5 );
+ //aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
+ //aNameLayout->addWidget( myObjectName );
-QString HYDROGUI_CalculationDlg::getObjectName() const
-{
- return myObjectName->text();
+ // 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 );
+
+ QFrame* aBtnsFrame = new QFrame( aPage );
+ QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
+ aBtnsLayout->setMargin( 5 );
+ aBtnsLayout->setSpacing( 5 );
+ aBtnsFrame->setLayout( aBtnsLayout );
+ QPushButton* anAddBtn = new QPushButton( tr("ADD"), aBtnsFrame );
+ QPushButton* aRemoveBtn = new QPushButton( tr("REMOVE"), aBtnsFrame );
+ aBtnsLayout->addWidget( anAddBtn );
+ aBtnsLayout->addWidget( aRemoveBtn );
+ aBtnsLayout->addStretch( 1 );
+
+ QLabel* aNameLabel = new QLabel( tr( "NAME" ), aPage );
+ QLabel* anObjectsLabel = new QLabel( tr( "CALCULATION_REFERENCE_OBJECTS" ), aPage );
+
+ QGridLayout* aZonesLayout = new QGridLayout( aPage );
+ aZonesLayout->setMargin( 5 );
+ aZonesLayout->setSpacing( 5 );
+ aZonesLayout->setVerticalSpacing( 10 );
+ aZonesLayout->addWidget( aNameLabel, 0, 0, Qt::AlignHCenter );
+ aZonesLayout->addWidget( myObjectName, 0, 1 );
+ aZonesLayout->addWidget( anObjectsLabel, 1, 0, Qt::AlignHCenter );
+ aZonesLayout->addWidget( myGeomObjects, 1, 1, 2, 1 );
+ aZonesLayout->addWidget( aBtnsFrame, 2, 0, Qt::AlignHCenter );
+
+ //QBoxLayout* aMainLayout = new QVBoxLayout( aFrame );
+ //aMainLayout->setMargin( 0 );
+ //aMainLayout->setSpacing( 5 );
+ //aMainLayout->addWidget( myObjectNameGroup );
+ //aMainLayout->addWidget( anObjectsFrame );
+ //aMainLayout->addStretch();
+
+ //aPage->setLayout( aMainLayout );
+ aPage->setLayout( aZonesLayout );
+
+ return aPage;
}
-void HYDROGUI_CalculationDlg::setPolylineName( const QString& theName )
+void HYDROGUI_CalculationDlg::onEmptyName()
{
- myBndPolyline->SetName( theName );
+ QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
+ QString aMessage = QObject::tr( "INCORRECT_OBJECT_NAME" );
+ SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
}
-QString HYDROGUI_CalculationDlg::getPolylineName() const
+void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
{
- return myBndPolyline->GetName();
+ QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
+ QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
+ SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
}
-void HYDROGUI_CalculationDlg::setZones( const QStringList& theZones )
-{
- myZones->clear();
+QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
+ QWizardPage* aPage = new QWizardPage( wizard() );
+ QFrame* aFrame = new QFrame( aPage );
- for ( int i = 0, n = theZones.length(); i < n; ++i )
- {
- QString aZoneName = theZones.at( i );
+ 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->setAutoOpenLevel( 3 );
+ aLayout->setMargin( 5 );
+ aLayout->setSpacing( 5 );
- QListWidgetItem* aListItem = new QListWidgetItem( aZoneName, myZones );
- aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable );
- aListItem->setCheckState( Qt::Unchecked );
- }
-}
+ aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
-void HYDROGUI_CalculationDlg::setSelectedZones( const QStringList& theZones )
-{
- for ( int i = 0, n = theZones.length(); i < n; ++i )
- {
- QString aZoneName = theZones.at( i );
+ QLabel* aBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
+ myBathymetryChoice = new QComboBox( aFrame );
+ myBathymetryChoice->addItem( tr( "ZMIN" ) );
+ myBathymetryChoice->addItem( tr( "ZMAX" ) );
- QList<QListWidgetItem *> anItems =
- myZones->findItems( aZoneName, Qt::MatchFixedString | Qt::MatchCaseSensitive );
- if ( anItems.isEmpty() )
- continue;
+ aLayout->addWidget( aBatimetryLabel, 1, 0 );
+ aLayout->addWidget( myBathymetryChoice, 1, 1 );
- QListWidgetItem* aListItem = anItems.first();
- if ( !aListItem )
- continue;
+ aPage->setLayout( aLayout );
- aListItem->setCheckState( Qt::Checked );
- }
+ return aPage;
}
-QStringList HYDROGUI_CalculationDlg::getSelectedZones() const
+void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
{
- QStringList aResList;
-
- for ( int i = 0, n = myZones->count(); i < n; ++i )
- {
- QListWidgetItem* aListItem = myZones->item( i );
- if ( !aListItem || aListItem->checkState() != Qt::Checked )
- continue;
+ myObjectName->setText( theName );
+}
- QString aSelZoneName = aListItem->text();
- aResList.append( aSelZoneName );
- }
+QString HYDROGUI_CalculationDlg::getObjectName() const
+{
+ return myObjectName->text();
+}
- return aResList;
+void HYDROGUI_CalculationDlg::setGeomObjects( const QStringList& theObjects )
+{
}
-void HYDROGUI_CalculationDlg::setRegions( const QStringList& theRegions )
+void HYDROGUI_CalculationDlg::setSelectedGeomObjects( const QStringList& theObjects )
{
- myRegions->clear();
+ myGeomObjects->clear();
- for ( int i = 0, n = theRegions.length(); i < n; ++i )
+ for ( int i = 0, n = theObjects.length(); i < n; ++i )
{
- QString aRegionName = theRegions.at( i );
+ QString anObjName = theObjects.at( i );
- QListWidgetItem* aListItem = new QListWidgetItem( aRegionName, myRegions );
+ QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myGeomObjects );
aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
}
}
-QStringList HYDROGUI_CalculationDlg::getRegions() const
+QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
{
QStringList aResList;
- for ( int i = 0, n = myRegions->count(); i < n; ++i )
+ for ( int i = 0, n = myGeomObjects->count(); i < n; ++i )
{
- QListWidgetItem* aListItem = myRegions->item( i );
+ QListWidgetItem* aListItem = myGeomObjects->item( i );
if ( !aListItem )
continue;
- QString aRegionName = aListItem->text();
- aResList.append( aRegionName );
+ QString aSelObjName = aListItem->text();
+ aResList.append( aSelObjName );
}
return aResList;
}
-void HYDROGUI_CalculationDlg::setSplitZonesPrefix( const QString& theName )
+void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase )
{
- mySplittedZonesPrefix->setText( theName );
-}
+ myEditedObject = theCase;
+ myValidator->setEditedObject( theCase );
-QString HYDROGUI_CalculationDlg::getSplitZonesPrefix() const
-{
- QString aPrefix = mySplittedZonesPrefix->text();
- if ( aPrefix.isEmpty() )
- aPrefix = tr( "DEFAULT_PREFIX_REGIONS" );
- return aPrefix;
-}
+ HYDROGUI_DataObject* anobj = new HYDROGUI_DataObject( 0, NULL, "" );
+ myBrowser->setRoot(anobj);
+ LightApp_DataObject* aCaseItem = module()->getDataModel()->createObject( anobj,
+ myEditedObject, "", true );
+ myBrowser->updateTree();
+ myBrowser->openLevels();
+}