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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_ImportPolylineDlg.h"
20 #include <QVBoxLayout>
21 #include <QPushButton>
24 HYDROGUI_ImportPolylineDlg::HYDROGUI_ImportPolylineDlg( QWidget* theParent,
25 const NCollection_Sequence<Handle(HYDROData_Entity)>& PolyEnts )
26 : QDialog( theParent )
28 QVBoxLayout* aMainLayout = new QVBoxLayout( this );
29 aMainLayout->setMargin(5);
30 aMainLayout->setSpacing(5);
32 QLabel* gLabel = new QLabel();
33 gLabel->setText(tr("POLYLINES_3D_IN_FILES"));
35 myPolylineTable = new QTableWidget(PolyEnts.Size(), 2);
37 myPolyEnts = PolyEnts;
40 header << tr("POLYLINE_NAME") << tr("FULL_IMPORT");
41 myPolylineTable->setHorizontalHeaderLabels(header);
42 myPolylineTable->setShowGrid(true);
44 for (int i = 1; i <= myPolyEnts.Size(); i++)
46 QTableWidgetItem* item = new QTableWidgetItem(myPolyEnts(i)->GetName());
47 item->setFlags(item->flags() ^ Qt::ItemIsEditable);
48 myPolylineTable->setItem(i-1, 0, item);
50 QTableWidgetItem* itemCheckbox = new QTableWidgetItem("");
51 itemCheckbox->setFlags(itemCheckbox->flags() ^ Qt::ItemIsEditable);
52 itemCheckbox->setCheckState(Qt::Unchecked);
53 myPolylineTable->setItem(i-1, 1, itemCheckbox);
56 aMainLayout->addWidget(gLabel);
57 aMainLayout->addWidget(myPolylineTable);
59 QPushButton* CheckAllButton = new QPushButton( tr("CHECK_ALL"), this );
60 QPushButton* UncheckAllButton = new QPushButton( tr("UNCHECK_ALL"), this );
62 QPushButton* anOkButton = new QPushButton( tr("OK"), this );
63 anOkButton->setDefault( true );
65 aMainLayout->addWidget( CheckAllButton );
66 aMainLayout->addWidget( UncheckAllButton );
67 aMainLayout->addWidget( anOkButton );
69 connect( anOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
70 connect( CheckAllButton, SIGNAL( clicked() ), this, SLOT( onCheckAll() ) );
71 connect( UncheckAllButton, SIGNAL( clicked() ), this, SLOT( onUncheckAll() ) );
73 setLayout(aMainLayout);
76 HYDROGUI_ImportPolylineDlg::~HYDROGUI_ImportPolylineDlg()
80 void HYDROGUI_ImportPolylineDlg::onCheckAll()
82 for (int i = 1; i <= myPolyEnts.Size(); i++)
84 QTableWidgetItem* itemCheckbox = myPolylineTable->item(i-1, 1);
85 itemCheckbox->setCheckState(Qt::Checked);
89 void HYDROGUI_ImportPolylineDlg::onUncheckAll()
91 for (int i = 1; i <= myPolyEnts.Size(); i++)
93 QTableWidgetItem* itemCheckbox = myPolylineTable->item(i-1, 1);
94 itemCheckbox->setCheckState(Qt::Unchecked);
98 NCollection_Sequence<Handle(HYDROData_Entity)> HYDROGUI_ImportPolylineDlg::GetCheckedPolylines() const
100 NCollection_Sequence<Handle(HYDROData_Entity)> checkedPolys;
101 for (int i = 1; i <= myPolyEnts.Size(); i++)
103 QTableWidgetItem* itemCheckbox = myPolylineTable->item(i-1, 1);
104 if (itemCheckbox->checkState() == Qt::CheckState::Checked)
105 checkedPolys.Append(myPolyEnts(i));