Salome HOME
debug abort on stream linear interpolation when bathy displayed and modified
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportPolylineDlg.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_ImportPolylineDlg.h"
20 #include <QVBoxLayout>
21 #include <QPushButton>
22 #include <QLabel>
23
24 HYDROGUI_ImportPolylineDlg::HYDROGUI_ImportPolylineDlg( QWidget* theParent, 
25   const NCollection_Sequence<Handle(HYDROData_Entity)>& PolyEnts )
26   : QDialog( theParent )
27 {
28   QVBoxLayout* aMainLayout = new QVBoxLayout( this );
29   aMainLayout->setMargin(5);
30   aMainLayout->setSpacing(5);
31
32   QLabel* gLabel = new QLabel();
33   gLabel->setText(tr("POLYLINES_3D_IN_FILES"));
34
35   myPolylineTable = new QTableWidget(PolyEnts.Size(), 2);
36
37   myPolyEnts = PolyEnts;
38
39   QStringList header;
40   header << tr("POLYLINE_NAME") << tr("FULL_IMPORT");
41   myPolylineTable->setHorizontalHeaderLabels(header);
42   myPolylineTable->setShowGrid(true);
43
44   for (int i = 1; i <= myPolyEnts.Size(); i++)
45   {
46     QTableWidgetItem* item = new QTableWidgetItem(myPolyEnts(i)->GetName());
47     item->setFlags(item->flags() ^ Qt::ItemIsEditable);
48     myPolylineTable->setItem(i-1, 0, item);
49
50     QTableWidgetItem* itemCheckbox = new QTableWidgetItem("");
51     itemCheckbox->setFlags(itemCheckbox->flags() ^ Qt::ItemIsEditable);
52     itemCheckbox->setCheckState(Qt::Unchecked);
53     myPolylineTable->setItem(i-1, 1, itemCheckbox);
54   }
55
56   aMainLayout->addWidget(gLabel);
57   aMainLayout->addWidget(myPolylineTable);
58
59   QPushButton* CheckAllButton = new QPushButton( tr("CHECK_ALL"), this );
60   QPushButton* UncheckAllButton = new QPushButton( tr("UNCHECK_ALL"), this );
61
62   QPushButton* anOkButton = new QPushButton( tr("OK"), this );
63   anOkButton->setDefault( true ); 
64
65   aMainLayout->addWidget( CheckAllButton );
66   aMainLayout->addWidget( UncheckAllButton );
67   aMainLayout->addWidget( anOkButton );
68
69   connect( anOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
70   connect( CheckAllButton, SIGNAL( clicked() ), this, SLOT( onCheckAll() ) );
71   connect( UncheckAllButton, SIGNAL( clicked() ), this, SLOT( onUncheckAll() ) );
72
73   setLayout(aMainLayout);
74 }
75
76 HYDROGUI_ImportPolylineDlg::~HYDROGUI_ImportPolylineDlg()
77 {
78 }
79
80 void HYDROGUI_ImportPolylineDlg::onCheckAll()
81 {
82   for (int i = 1; i <= myPolyEnts.Size(); i++)
83   {
84     QTableWidgetItem* itemCheckbox = myPolylineTable->item(i-1, 1);
85     itemCheckbox->setCheckState(Qt::Checked);
86   }
87 }
88
89 void HYDROGUI_ImportPolylineDlg::onUncheckAll()
90 {
91   for (int i = 1; i <= myPolyEnts.Size(); i++)
92   {
93     QTableWidgetItem* itemCheckbox = myPolylineTable->item(i-1, 1);
94     itemCheckbox->setCheckState(Qt::Unchecked);
95   }
96 }
97
98 NCollection_Sequence<Handle(HYDROData_Entity)> HYDROGUI_ImportPolylineDlg::GetCheckedPolylines() const
99 {
100   NCollection_Sequence<Handle(HYDROData_Entity)> checkedPolys;
101   for (int i = 1; i <= myPolyEnts.Size(); i++)
102   {
103     QTableWidgetItem* itemCheckbox = myPolylineTable->item(i-1, 1);
104     if (itemCheckbox->checkState() == Qt::CheckState::Checked)
105       checkedPolys.Append(myPolyEnts(i));
106   }
107   return checkedPolys;
108 }
109
110
111
112