From abe63c42525c9299302649cdb5dcff4f83368c26 Mon Sep 17 00:00:00 2001 From: rkv Date: Tue, 29 Oct 2013 10:57:10 +0000 Subject: [PATCH] Calculation Case Creation dialog is refactored. It is now a two-page wizard. --- src/HYDROGUI/CMakeLists.txt | 4 + src/HYDROGUI/HYDROGUI_CalculationDlg.cxx | 145 ++++++++++++++++++---- src/HYDROGUI/HYDROGUI_CalculationDlg.h | 17 ++- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 6 + src/HYDROGUI/HYDROGUI_DataBrowser.cxx | 90 ++++++++++++++ src/HYDROGUI/HYDROGUI_DataBrowser.h | 47 +++++++ src/HYDROGUI/HYDROGUI_DataModel.h | 2 +- src/HYDROGUI/HYDROGUI_DataObject.cxx | 52 ++++++++ src/HYDROGUI/HYDROGUI_DataObject.h | 17 +++ src/HYDROGUI/HYDROGUI_InputPanel.cxx | 70 ++++++----- src/HYDROGUI/HYDROGUI_InputPanel.h | 4 +- src/HYDROGUI/HYDROGUI_Operation.cxx | 12 ++ src/HYDROGUI/HYDROGUI_Operation.h | 1 + src/HYDROGUI/HYDROGUI_Wizard.cxx | 57 +++++++++ src/HYDROGUI/HYDROGUI_Wizard.h | 49 ++++++++ src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 24 ++++ 16 files changed, 536 insertions(+), 61 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_DataBrowser.cxx create mode 100644 src/HYDROGUI/HYDROGUI_DataBrowser.h create mode 100644 src/HYDROGUI/HYDROGUI_Wizard.cxx create mode 100644 src/HYDROGUI/HYDROGUI_Wizard.h diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index d121c61b..2e227bad 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -8,6 +8,7 @@ set(PROJECT_HEADERS HYDROGUI_CalculationOp.h HYDROGUI_ColorWidget.h HYDROGUI_CopyPasteOp.h + HYDROGUI_DataBrowser.h HYDROGUI_DataModel.h HYDROGUI_DataObject.h HYDROGUI_DeleteOp.h @@ -47,6 +48,7 @@ set(PROJECT_HEADERS HYDROGUI_UpdateFlags.h HYDROGUI_UpdateImageOp.h HYDROGUI_VisualStateOp.h + HYDROGUI_Wizard.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -57,6 +59,7 @@ set(PROJECT_SOURCES HYDROGUI_CalculationOp.cxx HYDROGUI_ColorWidget.cxx HYDROGUI_CopyPasteOp.cxx + HYDROGUI_DataBrowser.cxx HYDROGUI_DataModel.cxx HYDROGUI_DataObject.cxx HYDROGUI_DeleteOp.cxx @@ -95,6 +98,7 @@ set(PROJECT_SOURCES HYDROGUI_TwoImagesOp.cxx HYDROGUI_UpdateImageOp.cxx HYDROGUI_VisualStateOp.cxx + HYDROGUI_Wizard.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 1fc70566..f2f4b79e 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -24,10 +24,22 @@ #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 +#include +#include + +#include +#include #include #include #include +#include #include #include @@ -37,50 +49,114 @@ #include #include #include +#include +#include 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( myObjectNameGroup ); + myObjectName = new QLineEdit( aPage ); - 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() -{ -} +QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() { + QWizardPage* aPage = new QWizardPage( wizard() ); + QFrame* aFrame = new QFrame( aPage ); -void HYDROGUI_CalculationDlg::reset() -{ - myObjectName->clear(); + 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 ); - myGeomObjects->clear(); + 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 ) @@ -127,4 +203,21 @@ QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const return aResList; } - +void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculation) theCase ) +{ + myEditedObject = theCase; + /////////////////// + Handle(HYDROData_Object) anEntity = Handle(HYDROData_Object)::DownCast( + module()->getDataModel()->getDocument()->CreateObject( KIND_IMMERSIBLE_ZONE ) ); + myEditedObject->AddGeometryObject( anEntity ); + //////////////// + + HYDROGUI_DataObject* anobj = new HYDROGUI_DataObject( 0, NULL, "" ); + myBrowser->setRoot(anobj); + + LightApp_DataObject* aCaseItem = module()->getDataModel()->createObject( anobj, + myEditedObject, "", true ); + + myBrowser->updateTree(); + myBrowser->openLevels(); +} diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 8ab1c410..0d46504f 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -23,14 +23,17 @@ #ifndef HYDROGUI_CALCULATIONDLG_H #define HYDROGUI_CALCULATIONDLG_H -#include "HYDROGUI_InputPanel.h" +#include "HYDROGUI_Wizard.h" +#include class HYDROGUI_ObjSelector; class QGroupBox; class QLineEdit; class QListWidget; +class QComboBox; +class HYDROGUI_DataBrowser; -class HYDROGUI_CalculationDlg : public HYDROGUI_InputPanel +class HYDROGUI_CalculationDlg : public HYDROGUI_Wizard { Q_OBJECT @@ -43,15 +46,25 @@ public: void setObjectName( const QString& theName ); QString getObjectName() const; + void setEditedObject( const Handle(HYDROData_Calculation) theCase ); + void setGeomObjects( const QStringList& theObjects ); void setSelectedGeomObjects( const QStringList& theObjects ); QStringList getSelectedGeomObjects() const; private: + + QWizardPage* createObjectsPage(); + QWizardPage* createZonesPage(); + QGroupBox* myObjectNameGroup; QLineEdit* myObjectName; QListWidget* myGeomObjects; + + HYDROGUI_DataBrowser* myBrowser; + Handle(HYDROData_Calculation) myEditedObject; + QComboBox* myBathymetryChoice; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 4ab01f72..aab45580 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -96,8 +96,14 @@ void HYDROGUI_CalculationOp::startOperation() } } } + else + { + myEditedObject = + Handle(HYDROData_Calculation)::DownCast( doc()->CreateObject( KIND_CALCULATION ) ); + } aPanel->setObjectName( anObjectName ); + aPanel->setEditedObject( myEditedObject ); aPanel->setSelectedGeomObjects( aSelectedObjects ); createPreview(); diff --git a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx new file mode 100644 index 00000000..b6cdedb2 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx @@ -0,0 +1,90 @@ +// 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_DataBrowser.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_DataObject.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define VISIBILITY_COLUMN_WIDTH 25 + +HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_DataObject* theRoot, QWidget* theParent ) +: SUIT_DataBrowser( theRoot, theParent ), myModule( theModule ) +{ + SUIT_ResourceMgr* resMgr = theModule->getApp()->resourceMgr(); + + setSortMenuEnabled( true ); + setAutoUpdate( true ); + + if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) ) + searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) ); + + setWindowTitle( tr( "OBJECT_BROWSER" ) ); + connect( this, SIGNAL( requestUpdate() ), theModule->getApp(), SLOT( onRefresh() ) ); + + QString RefObjCol = tr( "REF_OBJECT_COLUMN" ); + QString BathymetryCol = tr( "BATHYMETRY_COLUMN" ); + SUIT_AbstractModel* treeModel = dynamic_cast( model() ); + treeModel->setSearcher( theModule->getApp() ); + 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(treeModel); + //RKV: if ( proxyModel ) { + //RKV: connect( proxyModel, SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ), + //RKV: theModule->getApp(), SLOT( onDropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ) ); + //RKV: } + + // temporary commented + /* + OB_ListView* ob_list = dynamic_cast( const_cast( listView() ) ); + if( ob_list ) + ob_list->setColumnMaxWidth( 0, theModule->getApp()->desktop()->width()/4 ); + + setFilter( new LightApp_OBFilter( theModule->getApp()->selectionMgr() ) ); + */ + + // Create OBSelector + new LightApp_OBSelector( this, theModule->getApp()->selectionMgr() ); + + 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); + //RKV: connectPopupRequest( theModule->getApp(), SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); +} + +HYDROGUI_DataBrowser::~HYDROGUI_DataBrowser() +{ +} diff --git a/src/HYDROGUI/HYDROGUI_DataBrowser.h b/src/HYDROGUI/HYDROGUI_DataBrowser.h new file mode 100644 index 00000000..3c3e3201 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DataBrowser.h @@ -0,0 +1,47 @@ +// 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_DATABROWSER_H +#define HYDROGUI_DATABROWSER_H + +#include + +class HYDROGUI_Module; + +/**\class HYDROGUI_DataBrowser + *\brief The data model browser widget implementation + */ +class HYDROGUI_DataBrowser : public SUIT_DataBrowser +{ + Q_OBJECT + +public: + HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_DataObject*, QWidget* = 0 ); + ~HYDROGUI_DataBrowser(); + + HYDROGUI_Module* module() const; + +private: + HYDROGUI_Module* myModule; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_DataModel.h b/src/HYDROGUI/HYDROGUI_DataModel.h index 1a3b12da..97379263 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.h +++ b/src/HYDROGUI/HYDROGUI_DataModel.h @@ -222,7 +222,6 @@ public: */ static QString partitionName( const ObjectKind theObjectKind ); -protected: /** * Returns the document for the current study */ @@ -239,6 +238,7 @@ protected: const QString& theParentEntry = QString(), const bool theIsBuildTree = true ); +protected: /** * Creates the GUI data object without corresponding model object: just by name * \param theParent a created object will be appended as a child of this object diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index 0b293cd2..83be9e8f 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -23,6 +23,8 @@ #include "HYDROGUI_DataObject.h" #include +#include +#include #include @@ -72,6 +74,56 @@ QFont HYDROGUI_DataObject::font( const int theId ) const return aFont; } +QString HYDROGUI_DataObject::text( const int theColumnId ) const +{ + QString aRes; + if( !myData.IsNull() ) + { + if ( theColumnId == RefObjectId || theColumnId == BathymetryId ) + { + Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( myData ); + if ( !aZone.IsNull() ) + { + HYDROData_SequenceOfObjects::Iterator anIter( aZone->GetGeometryObjects() ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Object) aRefGeomObj = + Handle(HYDROData_Object)::DownCast( anIter.Value() ); + if ( !aRefGeomObj.IsNull() ) + { + switch ( theColumnId ) + { + case RefObjectId: + aRes += aRefGeomObj->GetName() + ", "; + break; + case BathymetryId: + //TODO: Get bathymetry name + //aRes += aRefGeomObj-> + ; + } + } + } + } + if ( aRes.length() > 1 ) + { + aRes.remove( aRes.length() - 2, 2 ); + } + } + else + { + aRes = LightApp_DataObject::text( theColumnId ); + } + } + return aRes; +} + +QColor HYDROGUI_DataObject::color( const ColorRole theColorRole, const int theColumnId ) const +{ + //TODO: Implement red color for bathymetry conflicts in case creation dialog + return LightApp_DataObject::color( theColorRole, theColumnId ); +} + + QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& theObject, const bool theWithPrefix ) { diff --git a/src/HYDROGUI/HYDROGUI_DataObject.h b/src/HYDROGUI/HYDROGUI_DataObject.h index e8814367..6ea1038d 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.h +++ b/src/HYDROGUI/HYDROGUI_DataObject.h @@ -30,6 +30,7 @@ #include #include #include +#include /** * \class HYDROGUI_DataObject @@ -43,6 +44,12 @@ class HYDROGUI_DataObject : public LightApp_DataObject { public: + //! Column id + enum { + RefObjectId = RefEntryId + 1, //!< Ref.Object column + BathymetryId //!< Bathymetry column + }; + /** * Constructor. * \param theParent parent data object @@ -94,6 +101,16 @@ public: static QString dataObjectEntry( const Handle(HYDROData_Entity)& theObject, const bool theWithPrefix = true ); + /** + * Returns the text for the specified column. + */ + virtual QString text( const int = NameId ) const; + + /** + * Returns the color for the specified column. + */ + virtual QColor color( const ColorRole, const int = NameId ) const; + protected: Handle(HYDROData_Entity) myData; ///< object from data model QString myParentEntry; diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index 5b9fa21d..23a9c06e 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -29,7 +29,7 @@ #include #include -HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle ) +HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout ) : QDockWidget( theModule->application()->desktop() ), myModule( theModule ) { @@ -37,36 +37,39 @@ HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QStr setWindowTitle( theTitle ); setAllowedAreas( Qt::RightDockWidgetArea ); - QFrame* aFrame = new QFrame( this ); - setWidget( aFrame ); - QVBoxLayout* aLayout = new QVBoxLayout( aFrame ); - - myMainFrame = new QFrame( aFrame ); - QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame ); - aMainLayout->setMargin( 0 ); - aMainLayout->setSpacing( 5 ); - - myBtnFrame = new QFrame( aFrame ); - - aLayout->addWidget( myMainFrame, 1 ); - aLayout->addWidget( myBtnFrame, 0 ); - - QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame ); - aBtnsLayout->setMargin( 5 ); - aBtnsLayout->setSpacing( 5 ); - - myApply = new QPushButton( tr( "APPLY" ), myBtnFrame ); - myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame ); - myHelp = new QPushButton( tr( "HELP" ), myBtnFrame ); - - aBtnsLayout->addWidget( myApply, 0 ); - aBtnsLayout->addWidget( myCancel, 0 ); - aBtnsLayout->addStretch( 1 ); - aBtnsLayout->addWidget( myHelp, 0 ); - - connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) ); - connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) ); - connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); + if ( doInitLayout ) { + + QFrame* aFrame = new QFrame( this ); + setWidget( aFrame ); + QVBoxLayout* aLayout = new QVBoxLayout( aFrame ); + + myMainFrame = new QFrame( aFrame ); + QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame ); + aMainLayout->setMargin( 0 ); + aMainLayout->setSpacing( 5 ); + + aLayout->addWidget( myMainFrame, 1 ); + + myBtnFrame = new QFrame( aFrame ); + aLayout->addWidget( myBtnFrame, 0 ); + + QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame ); + aBtnsLayout->setMargin( 5 ); + aBtnsLayout->setSpacing( 5 ); + + myApply = new QPushButton( tr( "APPLY" ), myBtnFrame ); + myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame ); + myHelp = new QPushButton( tr( "HELP" ), myBtnFrame ); + + aBtnsLayout->addWidget( myApply, 0 ); + aBtnsLayout->addWidget( myCancel, 0 ); + aBtnsLayout->addStretch( 1 ); + aBtnsLayout->addWidget( myHelp, 0 ); + + connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) ); + connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) ); + connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); + } } HYDROGUI_InputPanel::~HYDROGUI_InputPanel() @@ -92,6 +95,11 @@ void HYDROGUI_InputPanel::onHelp() { } +void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event ) +{ + emit panelCancel(); +} + void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch ) { QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index 9d16ad0f..81a6e5de 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -28,6 +28,7 @@ class QFrame; class QPushButton; class QLayout; +class QCloseEvent; class HYDROGUI_Module; @@ -39,7 +40,7 @@ class HYDROGUI_InputPanel : public QDockWidget Q_OBJECT public: - HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle ); + HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout = true ); virtual ~HYDROGUI_InputPanel(); void addWidget( QWidget* theWidget, int theStretch = 0 ); @@ -59,6 +60,7 @@ protected slots: protected: QFrame* mainFrame() const; + virtual void closeEvent ( QCloseEvent * event ); private: HYDROGUI_Module* myModule; diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index d3d15202..52fbcd17 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -103,6 +103,18 @@ void HYDROGUI_Operation::commitOperation() closeInputPanel(); } +void HYDROGUI_Operation::setDialogActive( const bool active ) +{ + LightApp_Operation::setDialogActive( active ); + if( myPanel ) + { + if( active ) + { + myPanel->show(); + } + } +} + HYDROGUI_InputPanel* HYDROGUI_Operation::createInputPanel() const { return NULL; diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 70b1ccd0..5bce481f 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -50,6 +50,7 @@ protected: virtual void startOperation(); virtual void abortOperation(); virtual void commitOperation(); + virtual void setDialogActive( const bool ); virtual HYDROGUI_InputPanel* createInputPanel() const; virtual void closeInputPanel(); diff --git a/src/HYDROGUI/HYDROGUI_Wizard.cxx b/src/HYDROGUI/HYDROGUI_Wizard.cxx new file mode 100644 index 00000000..34c6a04a --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Wizard.cxx @@ -0,0 +1,57 @@ +// 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_Wizard.h" +#include "HYDROGUI_Module.h" +#include +#include +#include +#include +#include + +HYDROGUI_Wizard::HYDROGUI_Wizard( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle, false ) +{ + + myWizard = new QWizard( theModule->application()->desktop() ); + myWizard->setOption( QWizard::HaveHelpButton ); + setWidget( myWizard ); + + connect( myWizard, SIGNAL( accepted() ), this, SLOT( onApply() ) ); + connect( myWizard, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); + connect( myWizard, SIGNAL( helpRequested() ), this, SLOT( onHelp() ) ); +} + +HYDROGUI_Wizard::~HYDROGUI_Wizard() +{ +} + +QWizard* HYDROGUI_Wizard::wizard() const +{ + return myWizard; +} + +void HYDROGUI_Wizard::show() +{ + HYDROGUI_InputPanel::show(); + myWizard->show(); +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_Wizard.h b/src/HYDROGUI/HYDROGUI_Wizard.h new file mode 100644 index 00000000..0349029b --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_Wizard.h @@ -0,0 +1,49 @@ +// 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_WIZARD_H +#define HYDROGUI_WIZARD_H + +#include "HYDROGUI_InputPanel.h" +#include + +/**\class HYDROGUI_Wizard + *\brief The base class representing base wizard for HYDROGUI module + */ +class HYDROGUI_Wizard : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_Wizard( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_Wizard(); + + void show(); + +protected: + QWizard* wizard() const; + +private: + QWizard* myWizard; +}; + +#endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index ae546f69..c7c7a8b2 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -76,6 +76,18 @@ does not exist or you have not enough permissions to open it. NAME Name + + BATHYMETRY + Bathymetry + + + ADD + Add + + + REMOVE + Remove + @@ -94,6 +106,18 @@ does not exist or you have not enough permissions to open it. + + HYDROGUI_DataBrowser + + REF_OBJECT_COLUMN + Ref.Object + + + BATHYMETRY_COLUMN + Bathymetry + + + HYDROGUI_CopyPasteOp -- 2.39.2