1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_CalculationDlg.h"
25 #include "HYDROGUI_ObjSelector.h"
26 #include "HYDROGUI_Tool.h"
27 #include "HYDROGUI_DataBrowser.h"
28 #include "HYDROGUI_DataModel.h"
29 #include "HYDROGUI_Module.h"
30 #include "HYDROGUI_DataObject.h"
32 #include <HYDROData_Document.h>
33 #include <HYDROData_Entity.h>
34 #include <HYDROData_Object.h>
36 #include <CAM_Application.h>
37 #include <LightApp_DataObject.h>
39 #include <SUIT_FileDlg.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SUIT_Session.h>
42 #include <SUIT_Study.h>
48 #include <QListWidget>
50 #include <QPushButton>
51 #include <QToolButton>
52 #include <QWizardPage>
55 HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle )
56 : HYDROGUI_Wizard( theModule, theTitle )
58 QWizard* aWizard = wizard();
59 aWizard->addPage( createObjectsPage() );
60 aWizard->addPage( createZonesPage() );
64 HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
68 void HYDROGUI_CalculationDlg::reset()
70 myObjectName->clear();
71 myGeomObjects->clear();
74 QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
75 QWizardPage* aPage = new QWizardPage( wizard() );
76 QFrame* aFrame = new QFrame( aPage );
78 // myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ), aFrame );
80 // myObjectName = new QLineEdit( myObjectNameGroup );
81 myObjectName = new QLineEdit( aPage );
83 //QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
84 //aNameLayout->setMargin( 5 );
85 //aNameLayout->setSpacing( 5 );
86 //aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
87 //aNameLayout->addWidget( myObjectName );
90 //QFrame* anObjectsFrame = new QFrame( aFrame );
92 //myGeomObjects = new QListWidget( anObjectsFrame );
93 myGeomObjects = new QListWidget( aPage );
94 myGeomObjects->setSelectionMode( QListWidget::SingleSelection );
95 myGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
96 myGeomObjects->setViewMode( QListWidget::ListMode );
98 QFrame* aBtnsFrame = new QFrame( aPage );
99 QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
100 aBtnsLayout->setMargin( 5 );
101 aBtnsLayout->setSpacing( 5 );
102 aBtnsFrame->setLayout( aBtnsLayout );
103 QPushButton* anAddBtn = new QPushButton( tr("ADD"), aBtnsFrame );
104 QPushButton* aRemoveBtn = new QPushButton( tr("REMOVE"), aBtnsFrame );
105 aBtnsLayout->addWidget( anAddBtn );
106 aBtnsLayout->addWidget( aRemoveBtn );
107 aBtnsLayout->addStretch( 1 );
109 QLabel* aNameLabel = new QLabel( tr( "NAME" ), aPage );
110 QLabel* anObjectsLabel = new QLabel( tr( "CALCULATION_REFERENCE_OBJECTS" ), aPage );
112 QGridLayout* aZonesLayout = new QGridLayout( aPage );
113 aZonesLayout->setMargin( 5 );
114 aZonesLayout->setSpacing( 5 );
115 aZonesLayout->setVerticalSpacing( 10 );
116 aZonesLayout->addWidget( aNameLabel, 0, 0, Qt::AlignHCenter );
117 aZonesLayout->addWidget( myObjectName, 0, 1 );
118 aZonesLayout->addWidget( anObjectsLabel, 1, 0, Qt::AlignHCenter );
119 aZonesLayout->addWidget( myGeomObjects, 1, 1, 2, 1 );
120 aZonesLayout->addWidget( aBtnsFrame, 2, 0, Qt::AlignHCenter );
122 //QBoxLayout* aMainLayout = new QVBoxLayout( aFrame );
123 //aMainLayout->setMargin( 0 );
124 //aMainLayout->setSpacing( 5 );
125 //aMainLayout->addWidget( myObjectNameGroup );
126 //aMainLayout->addWidget( anObjectsFrame );
127 //aMainLayout->addStretch();
129 //aPage->setLayout( aMainLayout );
130 aPage->setLayout( aZonesLayout );
135 QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
136 QWizardPage* aPage = new QWizardPage( wizard() );
137 QFrame* aFrame = new QFrame( aPage );
139 QGridLayout* aLayout = new QGridLayout( aPage );
140 //Handle(HYDROData_Entity) anEntity = module()->getDataModel()->getDocument()->CreateObject( KIND_CALCULATION );
142 myBrowser = new HYDROGUI_DataBrowser( module(), 0/*module()->application()->activeStudy()->root()*/, aPage );
143 myBrowser->setAutoOpenLevel( 3 );
144 aLayout->setMargin( 5 );
145 aLayout->setSpacing( 5 );
147 aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
149 QLabel* aBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
150 myBathymetryChoice = new QComboBox( aFrame );
151 myBathymetryChoice->addItem( tr( "ZMIN" ) );
152 myBathymetryChoice->addItem( tr( "ZMAX" ) );
154 aLayout->addWidget( aBatimetryLabel, 1, 0 );
155 aLayout->addWidget( myBathymetryChoice, 1, 1 );
157 aPage->setLayout( aLayout );
162 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
164 myObjectName->setText( theName );
167 QString HYDROGUI_CalculationDlg::getObjectName() const
169 return myObjectName->text();
172 void HYDROGUI_CalculationDlg::setGeomObjects( const QStringList& theObjects )
176 void HYDROGUI_CalculationDlg::setSelectedGeomObjects( const QStringList& theObjects )
178 myGeomObjects->clear();
180 for ( int i = 0, n = theObjects.length(); i < n; ++i )
182 QString anObjName = theObjects.at( i );
184 QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myGeomObjects );
185 aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
189 QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
191 QStringList aResList;
193 for ( int i = 0, n = myGeomObjects->count(); i < n; ++i )
195 QListWidgetItem* aListItem = myGeomObjects->item( i );
199 QString aSelObjName = aListItem->text();
200 aResList.append( aSelObjName );
206 void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculation) theCase )
208 myEditedObject = theCase;
210 Handle(HYDROData_Object) anEntity = Handle(HYDROData_Object)::DownCast(
211 module()->getDataModel()->getDocument()->CreateObject( KIND_IMMERSIBLE_ZONE ) );
212 myEditedObject->AddGeometryObject( anEntity );
215 HYDROGUI_DataObject* anobj = new HYDROGUI_DataObject( 0, NULL, "" );
216 myBrowser->setRoot(anobj);
218 LightApp_DataObject* aCaseItem = module()->getDataModel()->createObject( anobj,
219 myEditedObject, "", true );
221 myBrowser->updateTree();
222 myBrowser->openLevels();