2016-03-15 17:26:56 +05:00
|
|
|
// Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
2013-10-30 22:50:50 +06:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
2015-02-10 14:25:19 +05:00
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
2013-10-30 22:50:50 +06:00
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "CurveCreator_NewSectionDlg.h"
|
2014-09-08 18:07:16 +06:00
|
|
|
//#include "CurveCreator_Curve.hxx"
|
2013-10-30 22:50:50 +06:00
|
|
|
|
|
|
|
#include <SUIT_Session.h>
|
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
|
2014-09-08 18:07:16 +06:00
|
|
|
CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent, bool enableClosed ) :
|
|
|
|
QWidget(parent), myIsEnableClosed( enableClosed )
|
2013-10-30 22:50:50 +06:00
|
|
|
{
|
2014-09-08 18:07:16 +06:00
|
|
|
QVBoxLayout* aMainLayout = new QVBoxLayout( this );
|
|
|
|
aMainLayout->setMargin( 0 );
|
|
|
|
|
2013-10-30 22:50:50 +06:00
|
|
|
QFrame* aFrame = new QFrame( this );
|
2014-09-08 18:07:16 +06:00
|
|
|
aMainLayout->addWidget( aFrame );
|
|
|
|
|
2013-10-30 22:50:50 +06:00
|
|
|
QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
|
2014-09-08 18:07:16 +06:00
|
|
|
aLayout->setMargin( 0 );
|
2013-10-30 22:50:50 +06:00
|
|
|
|
|
|
|
QFrame* aCoordFrame = new QFrame( aFrame );
|
|
|
|
QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
|
|
|
|
|
2014-09-08 18:07:16 +06:00
|
|
|
QLabel* aLbl = new QLabel(tr("SECTION_NAME"), this);
|
2013-10-30 22:50:50 +06:00
|
|
|
myName = new QLineEdit(this);
|
|
|
|
aCoordLayout->addWidget(aLbl, 0, 0);
|
|
|
|
aCoordLayout->addWidget(myName, 0 , 1);
|
|
|
|
|
2014-09-08 18:07:16 +06:00
|
|
|
aLbl = new QLabel(tr("SECTION_LINE_TYPE"));
|
2013-10-30 22:50:50 +06:00
|
|
|
myLineType = new QComboBox(this);
|
|
|
|
|
|
|
|
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
|
|
|
QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
|
|
|
QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
|
|
|
|
|
|
|
// QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE"));
|
|
|
|
// QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE"));
|
2014-09-08 18:07:16 +06:00
|
|
|
myLineType->addItem(aPolylinePixmap, tr("SECTION_POLYLINE_TYPE"));
|
|
|
|
myLineType->addItem(aSplinePixmap, tr("SECTION_SPLINE_TYPE"));
|
2013-10-30 22:50:50 +06:00
|
|
|
myLineType->setCurrentIndex(0);
|
|
|
|
aCoordLayout->addWidget(aLbl, 1, 0);
|
|
|
|
aCoordLayout->addWidget(myLineType, 1 , 1);
|
|
|
|
|
2014-09-08 18:07:16 +06:00
|
|
|
aLbl = new QLabel(tr("SECTION_LINE_CLOSED"));
|
2013-10-30 22:50:50 +06:00
|
|
|
myIsClosed = new QCheckBox(this);
|
|
|
|
aCoordLayout->addWidget(aLbl, 2, 0);
|
|
|
|
aCoordLayout->addWidget(myIsClosed, 2, 1);
|
2014-09-08 18:07:16 +06:00
|
|
|
if ( !myIsEnableClosed ) {
|
|
|
|
aLbl->hide();
|
|
|
|
myIsClosed->hide();
|
|
|
|
}
|
2013-10-30 22:50:50 +06:00
|
|
|
|
|
|
|
myBtnFrame = new QFrame( aFrame );
|
|
|
|
QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
|
|
|
|
|
2014-09-08 18:07:16 +06:00
|
|
|
myAddBtn = new QPushButton( tr( "SECTION_ADD_BTN" ), myBtnFrame );
|
|
|
|
myCancelBtn = new QPushButton( tr( "SECTION_CANCEL_BTN" ), myBtnFrame );
|
2013-10-30 22:50:50 +06:00
|
|
|
|
|
|
|
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
|
|
|
|
connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelSection() ) );
|
|
|
|
|
|
|
|
aBtnsLayout->addWidget( myAddBtn );
|
|
|
|
aBtnsLayout->addStretch( 1 );
|
|
|
|
aBtnsLayout->addWidget( myCancelBtn );
|
|
|
|
|
|
|
|
aLayout->addWidget( aCoordFrame, 0 );
|
|
|
|
aLayout->addWidget( myBtnFrame, 1 );
|
|
|
|
}
|
|
|
|
|
2014-09-08 18:07:16 +06:00
|
|
|
void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::SectionType theType )
|
2013-10-30 22:50:50 +06:00
|
|
|
{
|
|
|
|
myName->setText(theName);
|
|
|
|
myIsClosed->setChecked(isClosed);
|
|
|
|
if( theType == CurveCreator::Polyline )
|
|
|
|
myLineType->setCurrentIndex(0);
|
|
|
|
else
|
|
|
|
myLineType->setCurrentIndex(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CurveCreator_NewSectionDlg::clear()
|
|
|
|
{
|
|
|
|
myName->setText("");
|
|
|
|
myIsClosed->setChecked(true);
|
|
|
|
myLineType->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
|
|
|
|
{
|
|
|
|
myIsEdit = isEdit;
|
|
|
|
if( myIsEdit ){
|
2014-09-08 18:07:16 +06:00
|
|
|
myAddBtn->setText(tr("SECTION_OK_BTN"));
|
2013-10-30 22:50:50 +06:00
|
|
|
myAddBtn->disconnect( SIGNAL( clicked() ) );
|
|
|
|
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifySection() ) );
|
|
|
|
}
|
|
|
|
else{
|
2014-09-08 18:07:16 +06:00
|
|
|
myAddBtn->setText(tr("SECTION_ADD_BTN"));
|
2013-10-30 22:50:50 +06:00
|
|
|
myAddBtn->disconnect( SIGNAL( clicked() ) );
|
|
|
|
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
|
|
|
|
}
|
|
|
|
updateTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CurveCreator_NewSectionDlg::getName() const
|
|
|
|
{
|
|
|
|
return myName->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CurveCreator_NewSectionDlg::isClosed() const
|
|
|
|
{
|
|
|
|
return myIsClosed->isChecked();
|
|
|
|
}
|
|
|
|
|
2014-09-08 18:07:16 +06:00
|
|
|
CurveCreator::SectionType CurveCreator_NewSectionDlg::getSectionType() const
|
2013-10-30 22:50:50 +06:00
|
|
|
{
|
|
|
|
if( myLineType->currentIndex() == 0 )
|
|
|
|
return CurveCreator::Polyline;
|
|
|
|
else
|
2014-09-08 18:07:16 +06:00
|
|
|
return CurveCreator::Spline;
|
2013-10-30 22:50:50 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CurveCreator_NewSectionDlg::updateTitle()
|
|
|
|
{
|
|
|
|
QString aTitle;
|
|
|
|
if( !myIsEdit )
|
|
|
|
aTitle = tr("ADD_NEW_SECTION");
|
|
|
|
else
|
|
|
|
aTitle = QString(tr("SET_SECTION_PARAMETERS"));
|
|
|
|
setWindowTitle(aTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )
|
|
|
|
{
|
|
|
|
myName->setText(theName);
|
|
|
|
}
|