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 ) :
37 QFrame* aFrame = new QFrame( this );
38 QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
40 QFrame* aCoordFrame = new QFrame( aFrame );
41 QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
43 QLabel* aLbl = new QLabel(tr("NAME"), this);
44 myName = new QLineEdit(this);
45 aCoordLayout->addWidget(aLbl, 0, 0);
46 aCoordLayout->addWidget(myName, 0 , 1);
48 aLbl = new QLabel(tr("LINE_TYPE"));
49 myLineType = new QComboBox(this);
51 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
52 QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
53 QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
55 // QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE"));
56 // QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE"));
57 myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE"));
58 myLineType->addItem(aSplinePixmap, tr("SPLINE_TYPE"));
59 myLineType->setCurrentIndex(0);
60 aCoordLayout->addWidget(aLbl, 1, 0);
61 aCoordLayout->addWidget(myLineType, 1 , 1);
63 aLbl = new QLabel(tr("LINE_CLOSED"));
64 myIsClosed = new QCheckBox(this);
65 aCoordLayout->addWidget(aLbl, 2, 0);
66 aCoordLayout->addWidget(myIsClosed, 2, 1);
67 if ( !enableClosed ) {
72 myBtnFrame = new QFrame( aFrame );
73 QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
75 myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame );
76 myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame );
78 connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
79 connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelSection() ) );
81 aBtnsLayout->addWidget( myAddBtn );
82 aBtnsLayout->addStretch( 1 );
83 aBtnsLayout->addWidget( myCancelBtn );
85 aLayout->addWidget( aCoordFrame, 0 );
86 aLayout->addWidget( myBtnFrame, 1 );
89 void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::SectionType theType )
91 myName->setText(theName);
92 myIsClosed->setChecked(isClosed);
93 if( theType == CurveCreator::Polyline )
94 myLineType->setCurrentIndex(0);
96 myLineType->setCurrentIndex(1);
99 void CurveCreator_NewSectionDlg::clear()
102 myIsClosed->setChecked(true);
103 myLineType->setCurrentIndex(0);
106 void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
110 myAddBtn->setText(tr("OK"));
111 myAddBtn->disconnect( SIGNAL( clicked() ) );
112 connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifySection() ) );
115 myAddBtn->setText(tr("ADD_BTN"));
116 myAddBtn->disconnect( SIGNAL( clicked() ) );
117 connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
122 QString CurveCreator_NewSectionDlg::getName() const
124 return myName->text();
127 bool CurveCreator_NewSectionDlg::isClosed() const
129 return myIsClosed->isChecked();
132 CurveCreator::SectionType CurveCreator_NewSectionDlg::getSectionType() const
134 if( myLineType->currentIndex() == 0 )
135 return CurveCreator::Polyline;
137 return CurveCreator::Spline;
140 void CurveCreator_NewSectionDlg::updateTitle()
144 aTitle = tr("ADD_NEW_SECTION");
146 aTitle = QString(tr("SET_SECTION_PARAMETERS"));
147 setWindowTitle(aTitle);
150 void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )
152 myName->setText(theName);