1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SelectField.h"
22 #include <qgroupbox.h>
25 #include <qlistview.h>
29 SelectField::SelectField(FilterGUI* theModule,const QString& file,
31 bool modal, WFlags fl)
32 : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
33 myFilterGUI( theModule ),
43 QListViewItem *element;
45 cout << "File: " << _file << endl;
47 _med = new ::MED(MED_DRIVER,_file);
48 deque<string> meshesNames = _med->getMeshNames();
49 int numberOfMeshes = meshesNames.size();
51 deque<string> fieldsNames = _med->getFieldNames();
52 int numberOfFields = fieldsNames.size();
54 QGridLayout* _lay = new QGridLayout( this, 1, 1 );
56 QGroupBox* _GroupC1 = new QGroupBox( this, "GroupC1" );
57 _lay->addWidget( _GroupC1,0,0 );
59 MESSAGE(basename(_file));
60 QString qs(tr("FILTER_FILE"));
61 qs.append(basename(_file));
62 _GroupC1->setTitle(qs);
63 _GroupC1->setColumnLayout(0, Qt::Vertical );
64 _GroupC1->layout()->setSpacing( 0 );
65 _GroupC1->layout()->setMargin( 0 );
66 _myGroupLayout = new QGridLayout( _GroupC1->layout() );
67 _myGroupLayout->setAlignment( Qt::AlignTop );
68 _myGroupLayout->setSpacing( 6 );
69 _myGroupLayout->setMargin( 11 );
70 _myGroupLayout->setColStretch( 0, 0 );
71 _myGroupLayout->setColStretch( 1, 1 );
75 // 0) tree to visualize meshes and fields
76 _myList = new QListView( _GroupC1, "List of fields" );
77 _myList->setMinimumSize( 400, 400 );
78 _myList->setMaximumSize( 400, 400 );
79 _myList->setRootIsDecorated(true);
80 _myList->addColumn(tr("FILTER_NAME"));
81 _myList->addColumn(tr("FILTER_TYPE"));
83 for(int i=0;i<numberOfMeshes;i++){
84 element = new QListViewItem( _myList, meshesNames[i], tr("FILTER_MESH") );
85 element->setExpandable(true);
86 _myList->setOpen(element,true);
88 for (int j=0; j<numberOfFields; j++){
89 deque<DT_IT_> myIteration = _med->getFieldIteration (fieldsNames[j]);
90 string meshName = _med->getField(fieldsNames[j],myIteration[0].dt,myIteration[0].it)->getSupport()->getMesh()->getName();
91 if( strcmp(meshName.c_str(),meshesNames[i].c_str()) == 0)
92 new QListViewItem( element, fieldsNames[j], tr("FILTER_FIELD") );
95 element->setSelectable(false);
96 _myGroupLayout->addWidget( _myList, row, 0 );
100 // 1) label for time steps
101 _myLab = new QLabel(tr("FILTER_SEL_TS"),_GroupC1);
103 _myGroupLayout->addWidget( _myLab, row, 0 );
106 // 2) slider to visualize time steps
107 _mySlider = new QSlider(_GroupC1);
108 _mySlider->setOrientation(Qt::Horizontal);
109 _mySlider->setTickmarks(QSlider::Below);
110 _myGroupLayout->addWidget( _mySlider, row, 0 );
115 connect( _myList, SIGNAL(clicked(QListViewItem *)), this, SLOT(fieldSelected(QListViewItem *)));
116 connect( _mySlider, SIGNAL(sliderReleased()), this, SLOT(tsSelected()));
118 this->show(); /* displays Dialog */
121 SelectField::~SelectField()
123 // no need to delete child widgets, Qt does it all for us
124 cout << "SelectField: destructor called" << endl;
128 void SelectField::fieldSelected(QListViewItem *lvi)
131 if( strcmp(lvi->text(1),"Field") == 0){
132 _field = lvi->text(0);
133 _mesh = lvi->parent()->text(0);
134 deque<DT_IT_> myIteration = _med->getFieldIteration (lvi->text(0));
135 int numberOfIteration = myIteration.size();
136 if( numberOfIteration > 1 ){
137 _mySlider->setRange(myIteration[0].dt,
138 myIteration[numberOfIteration-1].dt);
151 void SelectField::tsSelected()
153 _ts = _mySlider->value();
154 MESSAGE("File " << _file );
155 MESSAGE("Mesh " << _mesh );
156 MESSAGE("Field " << _field );
157 MESSAGE("Time step " << _ts );