Salome HOME
refs #1813 ... lot 14 combined commit : parts : 1 - 16
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_SetBoundaryTypePolygonDlg.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_SetBoundaryTypePolygonDlg.h"
20 #include <QVBoxLayout>
21 #include <QPushButton>
22 #include <QFrame>
23 #include <QLabel>
24 #include <QFrame>
25 #include <SUIT_ResourceMgr.h>
26 #include <SUIT_Session.h>
27 #include <QListWidgetItem>
28
29 HYDROGUI_SetBoundaryTypePolygonDlg::HYDROGUI_SetBoundaryTypePolygonDlg( QWidget* theParent, int theType )
30   : QDialog( theParent )
31 {
32   QVBoxLayout* aMainLayout = new QVBoxLayout( this );
33   aMainLayout->setMargin( 5 );
34   aMainLayout->setSpacing( 5 );
35
36   QFrame* aBTFrame = new QFrame( this );
37   QLabel* aBoundaryLabel = new QLabel( tr( "BOUNDARY_TYPE" ), aBTFrame );
38   myBTBox = new QComboBox( aBTFrame );
39   myBTBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
40
41   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
42   QStringList Types;
43   Types << QObject::tr( QString("HYDRO_BC_POLYGON_TYPE1_ICO").toLatin1()) <<
44     QObject::tr( QString("HYDRO_BC_POLYGON_TYPE2_ICO").toLatin1()) <<
45     QObject::tr( QString("HYDRO_BC_POLYGON_TYPE3_ICO").toLatin1());
46
47   myBTBox->addItem(QIcon( aResMgr->loadPixmap( "HYDRO", Types[0])), tr( "CUT_TOOL" ));
48   myBTBox->addItem(QIcon( aResMgr->loadPixmap( "HYDRO", Types[1])), tr( "INCLUDE_TOOL" ));
49   myBTBox->addItem(QIcon( aResMgr->loadPixmap( "HYDRO", Types[2])), tr( "SELECTION_TOOL" ));
50
51   if (theType != 1 && theType != 2 && theType != 3)
52     theType = -1;
53   myBTBox->setCurrentIndex(theType - 1);
54
55   QBoxLayout* aColorLayout = new QHBoxLayout( aBTFrame );
56   aColorLayout->setMargin( 10 );
57   aColorLayout->setSpacing( 5 );
58   aColorLayout->addWidget( aBoundaryLabel );
59   aColorLayout->addWidget( myBTBox );
60
61   aMainLayout->addWidget( aBTFrame );
62
63   // Buttons
64   QPushButton* anOkButton = new QPushButton( tr( "OK" ), this );
65   anOkButton->setDefault( true ); 
66   QPushButton* aCancelButton = new QPushButton( tr( "CANCEL" ), this );
67   aCancelButton->setAutoDefault( true );
68
69   QHBoxLayout* aButtonsLayout = new QHBoxLayout;
70   aButtonsLayout->setMargin( 5 );
71   aButtonsLayout->setSpacing( 5 );
72   aButtonsLayout->addWidget( anOkButton );
73   aButtonsLayout->addStretch();
74   aButtonsLayout->addWidget( aCancelButton );
75
76   aMainLayout->addStretch();
77   aMainLayout->addLayout( aButtonsLayout );
78
79   setLayout( aMainLayout );  
80
81   connect( anOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
82   connect( aCancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
83 }
84
85 int HYDROGUI_SetBoundaryTypePolygonDlg::GetCurrentType()
86 {
87   return myBTBox->currentIndex();
88 }
89
90 HYDROGUI_SetBoundaryTypePolygonDlg::~HYDROGUI_SetBoundaryTypePolygonDlg()
91 {
92 }
93
94