1 // Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "CurveCreator_NewSectionDlg.h"
21 //#include "CurveCreator_Curve.hxx"
23 #include <SUIT_Session.h>
24 #include <SUIT_ResourceMgr.h>
26 #include <QGridLayout>
31 #include <QDialogButtonBox>
32 #include <QPushButton>
34 CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent, bool enableClosed ) :
35 QWidget(parent), myIsEnableClosed( enableClosed )
37 QVBoxLayout* aMainLayout = new QVBoxLayout( this );
38 aMainLayout->setMargin( 0 );
40 QFrame* aFrame = new QFrame( this );
41 aMainLayout->addWidget( aFrame );
43 QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
44 aLayout->setMargin( 0 );
46 QFrame* aCoordFrame = new QFrame( aFrame );
47 QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
49 QLabel* aLbl = new QLabel(tr("NAME"), this);
50 myName = new QLineEdit(this);
51 aCoordLayout->addWidget(aLbl, 0, 0);
52 aCoordLayout->addWidget(myName, 0 , 1);
54 aLbl = new QLabel(tr("LINE_TYPE"));
55 myLineType = new QComboBox(this);
57 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
58 QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
59 QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
61 // QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE"));
62 // QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE"));
63 myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE"));
64 myLineType->addItem(aSplinePixmap, tr("SPLINE_TYPE"));
65 myLineType->setCurrentIndex(0);
66 aCoordLayout->addWidget(aLbl, 1, 0);
67 aCoordLayout->addWidget(myLineType, 1 , 1);
69 aLbl = new QLabel(tr("LINE_CLOSED"));
70 myIsClosed = new QCheckBox(this);
71 aCoordLayout->addWidget(aLbl, 2, 0);
72 aCoordLayout->addWidget(myIsClosed, 2, 1);
73 if ( !myIsEnableClosed ) {
78 myBtnFrame = new QFrame( aFrame );
79 QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
81 myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame );
82 myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame );
84 connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
85 connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelSection() ) );
87 aBtnsLayout->addWidget( myAddBtn );
88 aBtnsLayout->addStretch( 1 );
89 aBtnsLayout->addWidget( myCancelBtn );
91 aLayout->addWidget( aCoordFrame, 0 );
92 aLayout->addWidget( myBtnFrame, 1 );
95 void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::SectionType theType )
97 myName->setText(theName);
98 myIsClosed->setChecked(isClosed);
99 if( theType == CurveCreator::Polyline )
100 myLineType->setCurrentIndex(0);
102 myLineType->setCurrentIndex(1);
105 void CurveCreator_NewSectionDlg::clear()
108 myIsClosed->setChecked(true);
109 myLineType->setCurrentIndex(0);
112 void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
116 myAddBtn->setText(tr("OK"));
117 myAddBtn->disconnect( SIGNAL( clicked() ) );
118 connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifySection() ) );
121 myAddBtn->setText(tr("ADD_BTN"));
122 myAddBtn->disconnect( SIGNAL( clicked() ) );
123 connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
128 QString CurveCreator_NewSectionDlg::getName() const
130 return myName->text();
133 bool CurveCreator_NewSectionDlg::isClosed() const
135 return myIsClosed->isChecked();
138 CurveCreator::SectionType CurveCreator_NewSectionDlg::getSectionType() const
140 if( myLineType->currentIndex() == 0 )
141 return CurveCreator::Polyline;
143 return CurveCreator::Spline;
146 void CurveCreator_NewSectionDlg::updateTitle()
150 aTitle = tr("ADD_NEW_SECTION");
152 aTitle = QString(tr("SET_SECTION_PARAMETERS"));
153 setWindowTitle(aTitle);
156 void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )
158 myName->setText(theName);