Salome HOME
Path to resource files corrected as in LINUX platform.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationDlg.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_CalculationDlg.h"
24
25 #include "HYDROGUI_ObjSelector.h"
26 #include "HYDROGUI_Tool.h"
27
28 #include <SUIT_FileDlg.h>
29 #include <SUIT_ResourceMgr.h>
30 #include <SUIT_Session.h>
31
32 #include <QGroupBox>
33 #include <QLabel>
34 #include <QLayout>
35 #include <QLineEdit>
36 #include <QListWidget>
37 #include <QPicture>
38 #include <QPushButton>
39 #include <QToolButton>
40
41 HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle )
42 : HYDROGUI_InputPanel( theModule, theTitle )
43 {
44   // Calculation name
45   myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ), mainFrame() );
46
47   myObjectName = new QLineEdit( myObjectNameGroup );
48
49   QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
50   aNameLayout->setMargin( 5 );
51   aNameLayout->setSpacing( 5 );
52   aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
53   aNameLayout->addWidget( myObjectName );
54
55   // Calculation zones
56   QFrame* anObjectsFrame = new QFrame( mainFrame() );
57
58   myGeomObjects = new QListWidget( anObjectsFrame );
59   myGeomObjects->setSelectionMode( QListWidget::SingleSelection );
60   myGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
61   myGeomObjects->setViewMode( QListWidget::ListMode );
62
63   QGridLayout* aZonesLayout = new QGridLayout( anObjectsFrame );
64   aZonesLayout->setMargin( 5 );
65   aZonesLayout->setSpacing( 5 );
66   aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_REFERENCE_OBJECTS" ), myGeomObjects ), 0, 0 );
67   aZonesLayout->addWidget( myGeomObjects, 0, 1 );
68
69   // Common
70   addWidget( myObjectNameGroup );
71   addWidget( anObjectsFrame );
72   addStretch();
73 }
74
75 HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
76 {
77 }
78
79 void HYDROGUI_CalculationDlg::reset()
80 {
81   myObjectName->clear();
82
83   myGeomObjects->clear();
84 }
85
86 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
87 {
88   myObjectName->setText( theName );
89 }
90
91 QString HYDROGUI_CalculationDlg::getObjectName() const
92 {
93   return myObjectName->text();
94 }
95
96 void HYDROGUI_CalculationDlg::setGeomObjects( const QStringList& theObjects )
97 {
98 }
99
100 void HYDROGUI_CalculationDlg::setSelectedGeomObjects( const QStringList& theObjects )
101 {
102   myGeomObjects->clear();
103
104   for ( int i = 0, n = theObjects.length(); i < n; ++i )
105   {
106     QString anObjName = theObjects.at( i );
107
108     QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myGeomObjects );
109     aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
110   }
111 }
112
113 QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
114 {
115   QStringList aResList;
116
117   for ( int i = 0, n = myGeomObjects->count(); i < n; ++i )
118   {
119     QListWidgetItem* aListItem = myGeomObjects->item( i );
120     if ( !aListItem )
121       continue;
122
123     QString aSelObjName = aListItem->text();
124     aResList.append( aSelObjName );
125   }
126
127   return aResList;
128 }
129
130