#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 )
+{
+ QWizard* aWizard = wizard();
+ aWizard->addPage( createObjectsPage() );
+ aWizard->addPage( createZonesPage() );
+ aWizard->show();
+}
+
+HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
+{
+}
+
+void HYDROGUI_CalculationDlg::reset()
{
+ myObjectName->clear();
+ myGeomObjects->clear();
+}
+
+QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
+ QWizardPage* aPage = new QWizardPage( wizard() );
+ QFrame* aFrame = new QFrame( aPage );
// Calculation name
- myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ), mainFrame() );
+// myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ), aFrame );
+
+// myObjectName = new QLineEdit( myObjectNameGroup );
+ myObjectName = new QLineEdit( aPage );
+ myValidator = new HYDROGUI_NameValidator(module(), myObjectName);
+ myObjectName->setValidator( myValidator );
- myObjectName = new QLineEdit( myObjectNameGroup );
+ 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 );
+ //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( mainFrame() );
+ //QFrame* anObjectsFrame = new QFrame( aFrame );
- myGeomObjects = new QListWidget( anObjectsFrame );
+ //myGeomObjects = new QListWidget( anObjectsFrame );
+ myGeomObjects = new QListWidget( aPage );
myGeomObjects->setSelectionMode( QListWidget::SingleSelection );
myGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
myGeomObjects->setViewMode( QListWidget::ListMode );
- QGridLayout* aZonesLayout = new QGridLayout( anObjectsFrame );
+ 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->addWidget( new QLabel( tr( "CALCULATION_REFERENCE_OBJECTS" ), myGeomObjects ), 0, 0 );
- aZonesLayout->addWidget( myGeomObjects, 0, 1 );
-
- // Common
- addWidget( myObjectNameGroup );
- addWidget( anObjectsFrame );
- addStretch();
+ 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;
}
-HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
+void HYDROGUI_CalculationDlg::onEmptyName()
{
+ QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
+ QString aMessage = QObject::tr( "INCORRECT_OBJECT_NAME" );
+ SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
}
-void HYDROGUI_CalculationDlg::reset()
+void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
{
- myObjectName->clear();
+ 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 );
+}
- myGeomObjects->clear();
+QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
+ QWizardPage* aPage = new QWizardPage( wizard() );
+ 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->setAutoOpenLevel( 3 );
+ aLayout->setMargin( 5 );
+ aLayout->setSpacing( 5 );
+
+ aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
+
+ QLabel* aBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
+ myBathymetryChoice = new QComboBox( aFrame );
+ myBathymetryChoice->addItem( tr( "ZMIN" ) );
+ myBathymetryChoice->addItem( tr( "ZMAX" ) );
+
+ aLayout->addWidget( aBatimetryLabel, 1, 0 );
+ aLayout->addWidget( myBathymetryChoice, 1, 1 );
+
+ aPage->setLayout( aLayout );
+
+ return aPage;
}
void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
return aResList;
}
+void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase )
+{
+ myEditedObject = theCase;
+ myValidator->setEditedObject( theCase );
+
+ HYDROGUI_DataObject* anobj = new HYDROGUI_DataObject( 0, NULL, "" );
+ myBrowser->setRoot(anobj);
+ LightApp_DataObject* aCaseItem = module()->getDataModel()->createObject( anobj,
+ myEditedObject, "", true );
+ myBrowser->updateTree();
+ myBrowser->openLevels();
+}