mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-27 13:10:34 +05:00
CurveCreator was updated
This commit is contained in:
parent
9b88d11eb3
commit
2c4464497c
@ -33,6 +33,8 @@
|
|||||||
#include <CurveCreator_Macro.hxx>
|
#include <CurveCreator_Macro.hxx>
|
||||||
#include <CurveCreator_Operation.hxx>
|
#include <CurveCreator_Operation.hxx>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
class CurveCreator_Section;
|
class CurveCreator_Section;
|
||||||
|
|
||||||
|
|
||||||
@ -40,7 +42,7 @@ class CurveCreator_Section;
|
|||||||
* The CurveCreator_Curve object is represented as one or more sets of
|
* The CurveCreator_Curve object is represented as one or more sets of
|
||||||
* connected points; thus CurveCreator_Curve object can contain several
|
* connected points; thus CurveCreator_Curve object can contain several
|
||||||
* not connected curves (polylines or b-splines), each such curve has two
|
* not connected curves (polylines or b-splines), each such curve has two
|
||||||
* only ends – start and end points – in other words non-manifold curves
|
* only ends <EFBFBD> start and end points <EFBFBD> in other words non-manifold curves
|
||||||
* are not supported.
|
* are not supported.
|
||||||
*/
|
*/
|
||||||
class CURVECREATOR_EXPORT CurveCreator_Curve
|
class CURVECREATOR_EXPORT CurveCreator_Curve
|
||||||
@ -83,7 +85,7 @@ public:
|
|||||||
//! Get type of the specified section
|
//! Get type of the specified section
|
||||||
CurveCreator::Type getType(const int theISection) const;
|
CurveCreator::Type getType(const int theISection) const;
|
||||||
|
|
||||||
//! Get “closed” flag of the specified section
|
//! Get <EFBFBD>closed<EFBFBD> flag of the specified section
|
||||||
bool isClosed(const int theISection) const;
|
bool isClosed(const int theISection) const;
|
||||||
|
|
||||||
//! Returns specifyed section name
|
//! Returns specifyed section name
|
||||||
@ -144,7 +146,7 @@ protected:
|
|||||||
const int theISection,
|
const int theISection,
|
||||||
const int theIPnt);
|
const int theIPnt);
|
||||||
|
|
||||||
/** Set “closed” flag of the specified section (all sections if
|
/** Set <EFBFBD>closed<EFBFBD> flag of the specified section (all sections if
|
||||||
* \a theISection is -1).
|
* \a theISection is -1).
|
||||||
*/
|
*/
|
||||||
void setClosed(const bool theIsClosed, const int theISection = -1);
|
void setClosed(const bool theIsClosed, const int theISection = -1);
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
//! Undo previous operation
|
//! Undo previous operation
|
||||||
void undo();
|
void undo();
|
||||||
|
|
||||||
//! Redo last previously “undoed” operation
|
//! Redo last previously <EFBFBD>undoed<EFBFBD> operation
|
||||||
void redo();
|
void redo();
|
||||||
|
|
||||||
//! Get number of available undo operations
|
//! Get number of available undo operations
|
||||||
|
@ -11,122 +11,136 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
|
||||||
CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) :
|
CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) :
|
||||||
QDialog(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false)
|
QDialog(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false)
|
||||||
{
|
{
|
||||||
QGridLayout* aCoordLay = new QGridLayout();
|
QGridLayout* aCoordLay = new QGridLayout();
|
||||||
|
|
||||||
QString aTitle = QString(tr("ADD_NEW_POINT"));
|
QString aTitle = QString(tr("ADD_NEW_POINT"));
|
||||||
setWindowTitle(aTitle);
|
setWindowTitle(aTitle);
|
||||||
|
|
||||||
QLabel* aLbl = new QLabel( tr("X_COORD"), this);
|
QLabel* aLbl = new QLabel( tr("X_COORD"), this);
|
||||||
myX = new QDoubleSpinBox(this);
|
myX = new QDoubleSpinBox(this);
|
||||||
aCoordLay->addWidget(aLbl, 0, 0);
|
aCoordLay->addWidget(aLbl, 0, 0);
|
||||||
aCoordLay->addWidget(myX, 0, 1 );
|
aCoordLay->addWidget(myX, 0, 1 );
|
||||||
|
|
||||||
aLbl = new QLabel( tr("Y_COORD"), this);
|
aLbl = new QLabel( tr("Y_COORD"), this);
|
||||||
myY = new QDoubleSpinBox(this);
|
myY = new QDoubleSpinBox(this);
|
||||||
aCoordLay->addWidget(aLbl, 1, 0 );
|
aCoordLay->addWidget(aLbl, 1, 0 );
|
||||||
aCoordLay->addWidget(myY, 1, 1 );
|
aCoordLay->addWidget(myY, 1, 1 );
|
||||||
|
|
||||||
if( theDim == CurveCreator::Dim3d ){
|
myZLabel = new QLabel( tr("Z_COORD"), this);
|
||||||
aLbl = new QLabel( tr("Z_COORD"), this);
|
myZ = new QDoubleSpinBox(this);
|
||||||
myZ = new QDoubleSpinBox(this);
|
aCoordLay->addWidget(myZLabel, 2,0 );
|
||||||
aCoordLay->addWidget(aLbl, 2,0 );
|
aCoordLay->addWidget(myZ, 2,1 );
|
||||||
aCoordLay->addWidget(myZ, 2,1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
myBtnBox = new QDialogButtonBox(this);
|
if( theDim != CurveCreator::Dim3d ){
|
||||||
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
|
myZ->hide();
|
||||||
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
|
myZLabel->hide();
|
||||||
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
|
}
|
||||||
|
|
||||||
connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
|
myBtnBox = new QDialogButtonBox(this);
|
||||||
connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
|
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
|
||||||
connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
|
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
|
||||||
QVBoxLayout* aMainLay = new QVBoxLayout();
|
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
|
||||||
aMainLay->addLayout(aCoordLay);
|
|
||||||
aMainLay->addWidget(myBtnBox);
|
connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
setLayout(aMainLay);
|
connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
clear();
|
connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
|
||||||
updateTitle();
|
QVBoxLayout* aMainLay = new QVBoxLayout();
|
||||||
|
aMainLay->addLayout(aCoordLay);
|
||||||
|
aMainLay->addWidget(myBtnBox);
|
||||||
|
setLayout(aMainLay);
|
||||||
|
clear();
|
||||||
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewPointDlg::setSectionName( const QString& theName )
|
void CurveCreator_NewPointDlg::setSectionName( const QString& theName )
|
||||||
{
|
{
|
||||||
mySectionName = theName;
|
mySectionName = theName;
|
||||||
updateTitle();
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewPointDlg::setEditMode( bool isEdit )
|
void CurveCreator_NewPointDlg::setEditMode( bool isEdit )
|
||||||
{
|
{
|
||||||
myIsEdit = isEdit;
|
myIsEdit = isEdit;
|
||||||
if( myIsEdit ){
|
if( myIsEdit ){
|
||||||
myContBtn->hide();
|
myContBtn->hide();
|
||||||
myAddBtn->setText(tr("OK"));
|
myAddBtn->setText(tr("OK"));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
myContBtn->show();
|
myContBtn->show();
|
||||||
myAddBtn->setText(tr("ADD_BTN"));
|
myAddBtn->setText(tr("ADD_BTN"));
|
||||||
}
|
}
|
||||||
updateTitle();
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewPointDlg::updateTitle()
|
void CurveCreator_NewPointDlg::updateTitle()
|
||||||
{
|
{
|
||||||
QString aTitle;
|
QString aTitle;
|
||||||
if( !myIsEdit ){
|
if( !myIsEdit ){
|
||||||
if( mySectionName.isEmpty() ){
|
if( mySectionName.isEmpty() ){
|
||||||
aTitle = tr("ADD_NEW_POINT");
|
aTitle = tr("ADD_NEW_POINT");
|
||||||
}
|
|
||||||
else{
|
|
||||||
aTitle = QString(tr("ADD_NEW_POINT_TO_%1")).arg(mySectionName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
aTitle = tr("SET_POINT_COORDINATES");
|
aTitle = QString(tr("ADD_NEW_POINT_TO_%1")).arg(mySectionName);
|
||||||
}
|
}
|
||||||
setWindowTitle(aTitle);
|
}
|
||||||
|
else{
|
||||||
|
aTitle = tr("SET_POINT_COORDINATES");
|
||||||
|
}
|
||||||
|
setWindowTitle(aTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const
|
CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const
|
||||||
{
|
{
|
||||||
CurveCreator::Coordinates aCoords;
|
CurveCreator::Coordinates aCoords;
|
||||||
double anX = myX->value();
|
double anX = myX->value();
|
||||||
aCoords.push_back(anX);
|
aCoords.push_back(anX);
|
||||||
double anY = myY->value();
|
double anY = myY->value();
|
||||||
aCoords.push_back(anY);
|
aCoords.push_back(anY);
|
||||||
if( myZ ){
|
if( myZ->isVisible() ){
|
||||||
double aZ = myZ->value();
|
double aZ = myZ->value();
|
||||||
aCoords.push_back(aZ);
|
aCoords.push_back(aZ);
|
||||||
}
|
}
|
||||||
return aCoords;
|
return aCoords;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )
|
void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )
|
||||||
{
|
{
|
||||||
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
|
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
|
||||||
emit addPoint();
|
emit addPoint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewPointDlg::clear()
|
void CurveCreator_NewPointDlg::clear()
|
||||||
{
|
{
|
||||||
initSpinBox(myX);
|
initSpinBox(myX);
|
||||||
initSpinBox(myY);
|
initSpinBox(myY);
|
||||||
if( myZ )
|
initSpinBox(myZ);
|
||||||
initSpinBox(myZ);
|
}
|
||||||
|
|
||||||
|
void CurveCreator_NewPointDlg::setDimension(CurveCreator::Dimension theDim)
|
||||||
|
{
|
||||||
|
if( theDim == CurveCreator::Dim2d ){
|
||||||
|
myZ->hide();
|
||||||
|
myZLabel->hide();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
myZ->show();
|
||||||
|
myZLabel->show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewPointDlg::setCoordinates( const CurveCreator::Coordinates& theCoords )
|
void CurveCreator_NewPointDlg::setCoordinates( const CurveCreator::Coordinates& theCoords )
|
||||||
{
|
{
|
||||||
double anX = theCoords[0];
|
double anX = theCoords[0];
|
||||||
myX->setValue(anX);
|
myX->setValue(anX);
|
||||||
double anY = theCoords[1];
|
double anY = theCoords[1];
|
||||||
myY->setValue(anY);
|
myY->setValue(anY);
|
||||||
if( myZ && ( theCoords.size() == 3)){
|
if( theCoords.size() == 3 ){
|
||||||
double aZ = theCoords[2];
|
double aZ = theCoords[2];
|
||||||
myZ->setValue(aZ);
|
myZ->setValue(aZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -9,35 +9,38 @@ class QDoubleSpinBox;
|
|||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QAbstractButton;
|
class QAbstractButton;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
class CurveCreator_NewPointDlg : public QDialog
|
class CurveCreator_NewPointDlg : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent = 0);
|
explicit CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent = 0);
|
||||||
CurveCreator::Coordinates getCoordinates() const;
|
CurveCreator::Coordinates getCoordinates() const;
|
||||||
void clear();
|
void clear();
|
||||||
void setSectionName( const QString& theName );
|
void setSectionName( const QString& theName );
|
||||||
void setEditMode( bool isEdit );
|
void setEditMode( bool isEdit );
|
||||||
void setCoordinates( const CurveCreator::Coordinates& theCoords );
|
void setCoordinates( const CurveCreator::Coordinates& theCoords );
|
||||||
|
void setDimension(CurveCreator::Dimension theDim);
|
||||||
signals:
|
signals:
|
||||||
void addPoint();
|
void addPoint();
|
||||||
public slots:
|
public slots:
|
||||||
protected slots:
|
protected slots:
|
||||||
void onBtnClicked(QAbstractButton* theBtn );
|
void onBtnClicked(QAbstractButton* theBtn );
|
||||||
protected:
|
protected:
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
void initSpinBox(QDoubleSpinBox *theSpinBox);
|
void initSpinBox(QDoubleSpinBox *theSpinBox);
|
||||||
private:
|
private:
|
||||||
QDialogButtonBox* myBtnBox;
|
QDialogButtonBox* myBtnBox;
|
||||||
CurveCreator::Dimension myDim;
|
CurveCreator::Dimension myDim;
|
||||||
QDoubleSpinBox* myX;
|
QDoubleSpinBox* myX;
|
||||||
QDoubleSpinBox* myY;
|
QDoubleSpinBox* myY;
|
||||||
QDoubleSpinBox* myZ;
|
QDoubleSpinBox* myZ;
|
||||||
QPushButton* myContBtn;
|
QLabel* myZLabel;
|
||||||
QPushButton* myAddBtn;
|
QPushButton* myContBtn;
|
||||||
bool myIsEdit;
|
QPushButton* myAddBtn;
|
||||||
QString mySectionName;
|
bool myIsEdit;
|
||||||
|
QString mySectionName;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CURVECREATOR_NEWPOINTDLG_H
|
#endif // CURVECREATOR_NEWPOINTDLG_H
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "CurveCreator_NewSectionDlg.h"
|
#include "CurveCreator_NewSectionDlg.h"
|
||||||
|
|
||||||
#include "CurveCreator_Curve.hxx"
|
#include "CurveCreator_Curve.hxx"
|
||||||
|
|
||||||
#include <SUIT_Session.h>
|
#include <SUIT_Session.h>
|
||||||
@ -14,110 +13,117 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
|
CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
|
||||||
QDialog(parent)
|
QDialog(parent)
|
||||||
{
|
{
|
||||||
std::string aNameStr;
|
std::string aNameStr;
|
||||||
QGridLayout* aLay = new QGridLayout();
|
QGridLayout* aLay = new QGridLayout();
|
||||||
QLabel* aLbl = new QLabel(tr("NAME"), this);
|
QLabel* aLbl = new QLabel(tr("NAME"), this);
|
||||||
myName = new QLineEdit(this);
|
myName = new QLineEdit(this);
|
||||||
aLay->addWidget(aLbl, 0, 0);
|
aLay->addWidget(aLbl, 0, 0);
|
||||||
aLay->addWidget(myName, 0 , 1);
|
aLay->addWidget(myName, 0 , 1);
|
||||||
|
|
||||||
aLbl = new QLabel(tr("LINE_TYPE"));
|
aLbl = new QLabel(tr("LINE_TYPE"));
|
||||||
myLineType = new QComboBox(this);
|
myLineType = new QComboBox(this);
|
||||||
QPixmap aPolylineImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
|
||||||
myLineType->addItem(aPolylineImage, tr("POLYLINE_TYPE"));
|
|
||||||
QPixmap aSplineImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
|
||||||
myLineType->addItem(aSplineImage,tr("SPLINE_TYPE"));
|
|
||||||
myLineType->setCurrentIndex(0);
|
|
||||||
aLay->addWidget(aLbl, 1, 0);
|
|
||||||
aLay->addWidget(myLineType, 1 , 1);
|
|
||||||
|
|
||||||
aLbl = new QLabel(tr("LINE_CLOSED"));
|
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||||
myIsClosed = new QCheckBox(this);
|
QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
||||||
aLay->addWidget(aLbl, 2, 0);
|
QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
||||||
aLay->addWidget(myIsClosed, 2, 1);
|
|
||||||
|
|
||||||
myBtnBox = new QDialogButtonBox(this);
|
// QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE"));
|
||||||
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
|
// QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE"));
|
||||||
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
|
myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE"));
|
||||||
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
|
myLineType->addItem(aSplinePixmap, tr("SPLINE_TYPE"));
|
||||||
|
myLineType->setCurrentIndex(0);
|
||||||
|
aLay->addWidget(aLbl, 1, 0);
|
||||||
|
aLay->addWidget(myLineType, 1 , 1);
|
||||||
|
|
||||||
connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
|
aLbl = new QLabel(tr("LINE_CLOSED"));
|
||||||
connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
|
myIsClosed = new QCheckBox(this);
|
||||||
connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
|
aLay->addWidget(aLbl, 2, 0);
|
||||||
|
aLay->addWidget(myIsClosed, 2, 1);
|
||||||
|
|
||||||
QVBoxLayout* aMainLay = new QVBoxLayout();
|
myBtnBox = new QDialogButtonBox(this);
|
||||||
aMainLay->addLayout(aLay);
|
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
|
||||||
aMainLay->addWidget(myBtnBox);
|
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
|
||||||
setLayout(aMainLay);
|
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
|
||||||
|
|
||||||
|
connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
|
connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
|
||||||
|
|
||||||
|
QVBoxLayout* aMainLay = new QVBoxLayout();
|
||||||
|
aMainLay->addLayout(aLay);
|
||||||
|
aMainLay->addWidget(myBtnBox);
|
||||||
|
setLayout(aMainLay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType )
|
void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType )
|
||||||
{
|
{
|
||||||
myName->setText(theName);
|
myName->setText(theName);
|
||||||
myIsClosed->setChecked(isClosed);
|
myIsClosed->setChecked(isClosed);
|
||||||
if( theType == CurveCreator::Polyline )
|
if( theType == CurveCreator::Polyline )
|
||||||
myLineType->setCurrentIndex(0);
|
myLineType->setCurrentIndex(0);
|
||||||
|
else
|
||||||
|
myLineType->setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewSectionDlg::clear()
|
void CurveCreator_NewSectionDlg::clear()
|
||||||
{
|
{
|
||||||
myName->setText("");
|
myName->setText("");
|
||||||
myIsClosed->setChecked(true);
|
myIsClosed->setChecked(true);
|
||||||
myLineType->setCurrentIndex(0);
|
myLineType->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
|
void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
|
||||||
{
|
{
|
||||||
myIsEdit = isEdit;
|
myIsEdit = isEdit;
|
||||||
if( myIsEdit ){
|
if( myIsEdit ){
|
||||||
myContBtn->hide();
|
myContBtn->hide();
|
||||||
myAddBtn->setText(tr("OK"));
|
myAddBtn->setText(tr("OK"));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
myContBtn->show();
|
myContBtn->show();
|
||||||
myAddBtn->setText(tr("ADD_BTN"));
|
myAddBtn->setText(tr("ADD_BTN"));
|
||||||
}
|
}
|
||||||
updateTitle();
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CurveCreator_NewSectionDlg::getName() const
|
QString CurveCreator_NewSectionDlg::getName() const
|
||||||
{
|
{
|
||||||
return myName->text();
|
return myName->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CurveCreator_NewSectionDlg::isClosed() const
|
bool CurveCreator_NewSectionDlg::isClosed() const
|
||||||
{
|
{
|
||||||
return myIsClosed->isChecked();
|
return myIsClosed->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
CurveCreator::Type CurveCreator_NewSectionDlg::getSectionType() const
|
CurveCreator::Type CurveCreator_NewSectionDlg::getSectionType() const
|
||||||
{
|
{
|
||||||
if( myLineType->currentIndex() == 0 )
|
if( myLineType->currentIndex() == 0 )
|
||||||
return CurveCreator::Polyline;
|
return CurveCreator::Polyline;
|
||||||
else
|
else
|
||||||
return CurveCreator::BSpline;
|
return CurveCreator::BSpline;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewSectionDlg::updateTitle()
|
void CurveCreator_NewSectionDlg::updateTitle()
|
||||||
{
|
{
|
||||||
QString aTitle;
|
QString aTitle;
|
||||||
if( !myIsEdit )
|
if( !myIsEdit )
|
||||||
aTitle = tr("ADD_NEW_SECTION");
|
aTitle = tr("ADD_NEW_SECTION");
|
||||||
else
|
else
|
||||||
aTitle = QString(tr("SET_SECTION_PARAMETERS"));
|
aTitle = QString(tr("SET_SECTION_PARAMETERS"));
|
||||||
setWindowTitle(aTitle);
|
setWindowTitle(aTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )
|
void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )
|
||||||
{
|
{
|
||||||
myName->setText(theName);
|
myName->setText(theName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_NewSectionDlg::onBtnClicked(QAbstractButton* theBtn )
|
void CurveCreator_NewSectionDlg::onBtnClicked(QAbstractButton* theBtn )
|
||||||
{
|
{
|
||||||
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
|
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
|
||||||
emit addSection();
|
emit addSection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,34 +16,34 @@ class QDialogButtonBox;
|
|||||||
|
|
||||||
class CurveCreator_NewSectionDlg : public QDialog
|
class CurveCreator_NewSectionDlg : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CurveCreator_NewSectionDlg(QWidget *parent = 0);
|
explicit CurveCreator_NewSectionDlg(QWidget *parent = 0);
|
||||||
|
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
bool isClosed() const;
|
bool isClosed() const;
|
||||||
CurveCreator::Type getSectionType() const;
|
CurveCreator::Type getSectionType() const;
|
||||||
|
|
||||||
void setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType );
|
void setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType );
|
||||||
void setSectionName(const QString& theName );
|
void setSectionName(const QString& theName );
|
||||||
void clear();
|
void clear();
|
||||||
void setEditMode( bool isEdit );
|
void setEditMode( bool isEdit );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void addSection();
|
void addSection();
|
||||||
public slots:
|
public slots:
|
||||||
protected slots:
|
protected slots:
|
||||||
void onBtnClicked(QAbstractButton* theBtn );
|
void onBtnClicked(QAbstractButton* theBtn );
|
||||||
protected:
|
protected:
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
private:
|
private:
|
||||||
QLineEdit* myName;
|
QLineEdit* myName;
|
||||||
QComboBox* myLineType;
|
QComboBox* myLineType;
|
||||||
QCheckBox* myIsClosed;
|
QCheckBox* myIsClosed;
|
||||||
bool myIsEdit;
|
bool myIsEdit;
|
||||||
QPushButton* myContBtn;
|
QPushButton* myContBtn;
|
||||||
QPushButton* myAddBtn;
|
QPushButton* myAddBtn;
|
||||||
QDialogButtonBox* myBtnBox;
|
QDialogButtonBox* myBtnBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CURVECREATOR_NEWSECTION_H
|
#endif // CURVECREATOR_NEWSECTION_H
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "CurveCreator_TreeView.h"
|
#include "CurveCreator_TreeView.h"
|
||||||
|
|
||||||
#include "CurveCreator_Curve.hxx"
|
#include "CurveCreator_Curve.hxx"
|
||||||
|
|
||||||
#include <SUIT_Session.h>
|
#include <SUIT_Session.h>
|
||||||
@ -11,412 +10,442 @@
|
|||||||
#define ID_SECTION -1
|
#define ID_SECTION -1
|
||||||
|
|
||||||
CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent ) :
|
CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent ) :
|
||||||
QAbstractItemModel(parent), myCurve(theCurve)
|
QAbstractItemModel(parent), myCurve(theCurve)
|
||||||
{
|
{
|
||||||
QPixmap aSplineIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||||
if( !aSplineIcon.isNull() )
|
QPixmap aSplineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
||||||
myCachedIcons[ICON_SPLINE] = aSplineIcon;
|
QPixmap aPolylineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
||||||
|
QPixmap aClosedSplineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_CLOSED_SPLINE")));
|
||||||
|
QPixmap aClosedPolylineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_CLOSED_POLYLINE")));
|
||||||
|
QPixmap aPointIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POINT")));
|
||||||
|
|
||||||
QPixmap aPolylineIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
/* QPixmap aSplineIcon(tr(":images/ICON_SPLINE"));
|
||||||
if( !aPolylineIcon.isNull() )
|
QPixmap aPolylineIcon(tr(":images/ICON_POLYLINE"));
|
||||||
myCachedIcons[ICON_POLYLINE] = aPolylineIcon;
|
QPixmap aClosedPolylineIcon(tr(":images/ICON_CLOSED_POLYLINE"));
|
||||||
|
QPixmap aClosedSplineIcon(tr(":images/ICON_CLOSED_SPLINE"));
|
||||||
|
QPixmap aPointIcon(tr(":images/ICON_POINT")); */
|
||||||
|
|
||||||
QPixmap aClosedPolylineIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_CLOSED_POLYLINE")));
|
if( !aSplineIcon.isNull() )
|
||||||
if( !aPolylineIcon.isNull() )
|
myCachedIcons[ICON_SPLINE] = aSplineIcon;
|
||||||
myCachedIcons[ICON_CLOSED_POLYLINE] = aClosedPolylineIcon;
|
|
||||||
|
|
||||||
QPixmap aClosedSplineIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_CLOSED_SPLINE")));
|
if( !aPolylineIcon.isNull() )
|
||||||
if( !aPolylineIcon.isNull() )
|
myCachedIcons[ICON_POLYLINE] = aPolylineIcon;
|
||||||
myCachedIcons[ICON_CLOSED_SPLINE] = aClosedSplineIcon;
|
|
||||||
|
|
||||||
QPixmap aPointIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POINT")));
|
if( !aPolylineIcon.isNull() )
|
||||||
if( !aPointIcon.isNull() )
|
myCachedIcons[ICON_CLOSED_POLYLINE] = aClosedPolylineIcon;
|
||||||
myCachedIcons[ICON_POINT] = aPointIcon;
|
|
||||||
|
if( !aPolylineIcon.isNull() )
|
||||||
|
myCachedIcons[ICON_CLOSED_SPLINE] = aClosedSplineIcon;
|
||||||
|
|
||||||
|
if( !aPointIcon.isNull() )
|
||||||
|
myCachedIcons[ICON_POINT] = aPointIcon;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CurveCreator_TreeViewModel::columnCount(const QModelIndex & parent ) const
|
int CurveCreator_TreeViewModel::columnCount(const QModelIndex & parent ) const
|
||||||
{
|
{
|
||||||
if( parent.internalId() == ID_SECTION )
|
if( parent.internalId() == ID_SECTION )
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant CurveCreator_TreeViewModel::data(const QModelIndex & index, int role ) const
|
QVariant CurveCreator_TreeViewModel::data(const QModelIndex & index, int role ) const
|
||||||
{
|
{
|
||||||
int aRow = index.row();
|
int aRow = index.row();
|
||||||
int aColumn = index.column();
|
int aColumn = index.column();
|
||||||
if( myCurve ){
|
if( myCurve ){
|
||||||
if( index.internalId() == ID_SECTION ){
|
if( index.internalId() == ID_SECTION ){
|
||||||
if( role == Qt::DisplayRole ){
|
if( role == Qt::DisplayRole ){
|
||||||
if( aColumn == 0 )
|
if( aColumn == 0 )
|
||||||
return QString::fromStdString(myCurve->getSectionName(aRow));
|
return QString::fromStdString(myCurve->getSectionName(aRow));
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
else if( role == Qt::DecorationRole ){
|
||||||
|
if( aColumn == 0 ){
|
||||||
|
CurveCreator::Type aSectionType = myCurve->getType(aRow);
|
||||||
|
if( aSectionType == CurveCreator::Polyline ){
|
||||||
|
if( myCurve->isClosed(aRow) ){
|
||||||
|
return myCachedIcons[ICON_CLOSED_POLYLINE];
|
||||||
}
|
}
|
||||||
else if( role == Qt::DecorationRole ){
|
else{
|
||||||
if( aColumn == 0 ){
|
return myCachedIcons[ICON_POLYLINE];
|
||||||
CurveCreator::Type aSectionType = myCurve->getType(aRow);
|
|
||||||
if( aSectionType == CurveCreator::Polyline ){
|
|
||||||
if( myCurve->isClosed(aRow) ){
|
|
||||||
return myCachedIcons[ICON_CLOSED_POLYLINE];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return myCachedIcons[ICON_POLYLINE];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if( myCurve->isClosed(aRow) ){
|
|
||||||
return myCachedIcons[ICON_CLOSED_SPLINE];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return myCachedIcons[ICON_SPLINE];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if( role == Qt::DisplayRole ){
|
|
||||||
if( aColumn == 1 )
|
|
||||||
return QVariant();
|
|
||||||
// return "Point";
|
|
||||||
else if( aColumn == 0 ){
|
|
||||||
CurveCreator::Coordinates aCoords = myCurve->getCoordinates(index.internalId(),index.row() );
|
|
||||||
QString anOut;
|
|
||||||
if( myCurve->getDimension() == CurveCreator::Dim2d ){
|
|
||||||
anOut = QString(tr("X=%1, Y=%2")).arg(aCoords[0]).arg(aCoords[1]);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
anOut = QString(tr("X=%1, Y=%2, Z=%3")).arg(aCoords[0]).arg(aCoords[1]).arg(aCoords[2]);
|
|
||||||
}
|
|
||||||
return anOut;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( role == Qt::DecorationRole ){
|
|
||||||
if( aColumn == 0 ){
|
|
||||||
return myCachedIcons[ICON_POINT];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if( myCurve->isClosed(aRow) ){
|
||||||
|
return myCachedIcons[ICON_CLOSED_SPLINE];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return myCachedIcons[ICON_SPLINE];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return QVariant();
|
else{
|
||||||
|
if( role == Qt::DisplayRole ){
|
||||||
|
if( aColumn == 1 )
|
||||||
|
return QVariant();
|
||||||
|
// return "Point";
|
||||||
|
else if( aColumn == 0 ){
|
||||||
|
CurveCreator::Coordinates aCoords = myCurve->getCoordinates(index.internalId(),index.row() );
|
||||||
|
QString anOut;
|
||||||
|
if( myCurve->getDimension() == CurveCreator::Dim2d ){
|
||||||
|
anOut = QString(tr("X=%1, Y=%2")).arg(aCoords[0]).arg(aCoords[1]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
anOut = QString(tr("X=%1, Y=%2, Z=%3")).arg(aCoords[0]).arg(aCoords[1]).arg(aCoords[2]);
|
||||||
|
}
|
||||||
|
return anOut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( role == Qt::DecorationRole ){
|
||||||
|
if( aColumn == 0 ){
|
||||||
|
return myCachedIcons[ICON_POINT];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex CurveCreator_TreeViewModel::index(int row, int column, const QModelIndex & parent ) const
|
QModelIndex CurveCreator_TreeViewModel::index(int row, int column, const QModelIndex & parent ) const
|
||||||
{
|
{
|
||||||
if( parent.isValid() ){
|
if( parent.isValid() ){
|
||||||
return createIndex(row, column, parent.row() );
|
return createIndex(row, column, parent.row() );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
QModelIndex aParent = createIndex(row, column, ID_SECTION );
|
QModelIndex aParent = createIndex(row, column, ID_SECTION );
|
||||||
return aParent;
|
return aParent;
|
||||||
}
|
}
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex CurveCreator_TreeViewModel::parent(const QModelIndex & theIndex) const
|
QModelIndex CurveCreator_TreeViewModel::parent(const QModelIndex & theIndex) const
|
||||||
{
|
{
|
||||||
if( !theIndex.isValid() )
|
if( !theIndex.isValid() )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
if( theIndex.internalId() == ID_SECTION ){
|
if( theIndex.internalId() == ID_SECTION ){
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
return createIndex( theIndex.internalId(), 0, ID_SECTION );
|
return createIndex( theIndex.internalId(), 0, ID_SECTION );
|
||||||
}
|
}
|
||||||
|
|
||||||
int CurveCreator_TreeViewModel::rowCount(const QModelIndex & parent ) const
|
int CurveCreator_TreeViewModel::rowCount(const QModelIndex & parent ) const
|
||||||
{
|
{
|
||||||
int aRowCnt = 0;
|
int aRowCnt = 0;
|
||||||
if( myCurve != NULL ){
|
if( myCurve != NULL ){
|
||||||
if( !parent.isValid() ){
|
if( !parent.isValid() ){
|
||||||
//Points level
|
//Points level
|
||||||
aRowCnt = myCurve->getNbSections();
|
aRowCnt = myCurve->getNbSections();
|
||||||
}
|
|
||||||
else{
|
|
||||||
//Section level
|
|
||||||
if( parent.internalId() == ID_SECTION ){
|
|
||||||
aRowCnt = myCurve->getNbPoints(parent.row());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return aRowCnt;
|
else{
|
||||||
|
//Section level
|
||||||
|
if( parent.internalId() == ID_SECTION ){
|
||||||
|
aRowCnt = myCurve->getNbPoints(parent.row());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aRowCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex CurveCreator_TreeViewModel::sectionIndex( int theSection ) const
|
QModelIndex CurveCreator_TreeViewModel::sectionIndex( int theSection ) const
|
||||||
{
|
{
|
||||||
return createIndex( theSection, 0, ID_SECTION );
|
return createIndex( theSection, 0, ID_SECTION );
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex CurveCreator_TreeViewModel::pointIndex( int theSection, int thePoint ) const
|
QModelIndex CurveCreator_TreeViewModel::pointIndex( int theSection, int thePoint ) const
|
||||||
{
|
{
|
||||||
return createIndex( thePoint, 0, theSection );
|
return createIndex( thePoint, 0, theSection );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CurveCreator_TreeViewModel::isSection( const QModelIndex& theIndx ) const
|
bool CurveCreator_TreeViewModel::isSection( const QModelIndex& theIndx ) const
|
||||||
{
|
{
|
||||||
if( theIndx.internalId() == ID_SECTION )
|
if( theIndx.internalId() == ID_SECTION )
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CurveCreator_TreeViewModel::getSection( const QModelIndex& theIndx ) const
|
int CurveCreator_TreeViewModel::getSection( const QModelIndex& theIndx ) const
|
||||||
{
|
{
|
||||||
if( theIndx.internalId() == ID_SECTION )
|
if( theIndx.internalId() == ID_SECTION )
|
||||||
return theIndx.row();
|
return theIndx.row();
|
||||||
return theIndx.internalId();
|
return theIndx.internalId();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CurveCreator_TreeViewModel::getPoint( const QModelIndex& theIndx ) const
|
int CurveCreator_TreeViewModel::getPoint( const QModelIndex& theIndx ) const
|
||||||
{
|
{
|
||||||
if( theIndx.internalId() == ID_SECTION )
|
if( theIndx.internalId() == ID_SECTION )
|
||||||
return -1;
|
return -1;
|
||||||
return theIndx.row();
|
return theIndx.row();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurveCreator_TreeViewModel::setCurve( CurveCreator_Curve* theCurve )
|
||||||
|
{
|
||||||
|
myCurve = theCurve;
|
||||||
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent) :
|
CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent) :
|
||||||
QTreeView(parent)
|
QTreeView(parent)
|
||||||
{
|
{
|
||||||
header()->hide();
|
header()->hide();
|
||||||
setUniformRowHeights(true);
|
setUniformRowHeights(true);
|
||||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||||
CurveCreator_TreeViewModel* aModel = new CurveCreator_TreeViewModel(theCurve, this);
|
CurveCreator_TreeViewModel* aModel = new CurveCreator_TreeViewModel(theCurve, this);
|
||||||
setModel(aModel);
|
setModel(aModel);
|
||||||
setSelectionBehavior(SelectRows);
|
setSelectionBehavior(SelectRows);
|
||||||
setSelectionMode(ExtendedSelection);
|
setSelectionMode(ExtendedSelection);
|
||||||
setExpandsOnDoubleClick(false);
|
setExpandsOnDoubleClick(false);
|
||||||
connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||||
this, SIGNAL(selectionChanged()) );
|
this, SIGNAL(selectionChanged()) );
|
||||||
connect( this, SIGNAL(activated(QModelIndex)), this, SLOT(onActivated(QModelIndex)));
|
connect( this, SIGNAL(activated(QModelIndex)), this, SLOT(onActivated(QModelIndex)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> CurveCreator_TreeView::getSelectedSections() const
|
QList<int> CurveCreator_TreeView::getSelectedSections() const
|
||||||
{
|
{
|
||||||
QList<int> aSect;
|
QList<int> aSect;
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( !aModel )
|
if( !aModel )
|
||||||
return aSect;
|
|
||||||
QModelIndexList anIndxs = selectionModel()->selectedIndexes();
|
|
||||||
for( int i = 0 ; i < anIndxs.size() ; i++ ){
|
|
||||||
if( aModel->isSection(anIndxs[i]) ){
|
|
||||||
aSect << aModel->getSection( anIndxs[i] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qSort(aSect.begin(), aSect.end());
|
|
||||||
return aSect;
|
return aSect;
|
||||||
|
QModelIndexList anIndxs = selectionModel()->selectedIndexes();
|
||||||
|
for( int i = 0 ; i < anIndxs.size() ; i++ ){
|
||||||
|
if( aModel->isSection(anIndxs[i]) ){
|
||||||
|
aSect << aModel->getSection( anIndxs[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qSort(aSect.begin(), aSect.end());
|
||||||
|
return aSect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePointsCnt )
|
void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePointsCnt )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
QModelIndex aSectIndx = aModel->sectionIndex( theSection );
|
QModelIndex aSectIndx = aModel->sectionIndex( theSection );
|
||||||
rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
|
rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::pointDataChanged( int theSection, int thePoint )
|
void CurveCreator_TreeView::pointDataChanged( int theSection, int thePoint )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
QModelIndex aPointIndx = aModel->pointIndex( theSection, thePoint );
|
QModelIndex aPointIndx = aModel->pointIndex( theSection, thePoint );
|
||||||
dataChanged( aPointIndx, aPointIndx );
|
dataChanged( aPointIndx, aPointIndx );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::pointsRemoved( int theSection, int thePoint, int thePointsCnt )
|
void CurveCreator_TreeView::pointsRemoved( int theSection, int thePoint, int thePointsCnt )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
QModelIndex aSectIndx = aModel->sectionIndex( theSection );
|
for( int i = 0 ; i < thePointsCnt ; i++ ){
|
||||||
rowsRemoved(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
|
QModelIndex aSectIndx = aModel->pointIndex(theSection, thePoint + i);
|
||||||
|
selectionModel()->select(aSectIndx,QItemSelectionModel::Deselect);
|
||||||
}
|
}
|
||||||
|
QModelIndex aSectIndx = aModel->sectionIndex( theSection );
|
||||||
|
rowsRemoved(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::sectionAdded( int theSection )
|
void CurveCreator_TreeView::sectionAdded( int theSection )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
rowsInserted(QModelIndex(), theSection, theSection );
|
rowsInserted(QModelIndex(), theSection, theSection );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::sectionChanged( int theSection, int aSectCnt )
|
void CurveCreator_TreeView::sectionChanged( int theSection, int aSectCnt )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
QModelIndex aFirstSectIndx = aModel->sectionIndex( theSection );
|
QModelIndex aFirstSectIndx = aModel->sectionIndex( theSection );
|
||||||
QModelIndex aLastSectIndx = aModel->sectionIndex( theSection + aSectCnt - 1);
|
QModelIndex aLastSectIndx = aModel->sectionIndex( theSection + aSectCnt - 1);
|
||||||
dataChanged( aFirstSectIndx, aLastSectIndx );
|
dataChanged( aFirstSectIndx, aLastSectIndx );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::sectionsRemoved( int theSection, int theSectionCnt )
|
void CurveCreator_TreeView::sectionsRemoved( int theSection, int theSectionCnt )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
this->rowsRemoved( QModelIndex(), theSection, theSection+theSectionCnt-1 );
|
for( int i = 0 ; i < theSectionCnt ; i++ ){
|
||||||
|
QModelIndex aSectIndx = aModel->sectionIndex(theSection + i);
|
||||||
|
this->selectionModel()->select(aSectIndx,QItemSelectionModel::Deselect);
|
||||||
}
|
}
|
||||||
|
rowsRemoved( QModelIndex(), theSection, theSection+theSectionCnt-1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent )
|
void CurveCreator_TreeView::setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent )
|
||||||
{
|
{
|
||||||
setExpanded( theIndx, isExpanded );
|
setExpanded( theIndx, isExpanded );
|
||||||
QItemSelectionModel::SelectionFlags aFlag = QItemSelectionModel::Select;
|
QItemSelectionModel::SelectionFlags aFlag = QItemSelectionModel::Select;
|
||||||
if( !isSelected ){
|
if( !isSelected ){
|
||||||
aFlag = QItemSelectionModel::Deselect;
|
aFlag = QItemSelectionModel::Deselect;
|
||||||
}
|
}
|
||||||
selectionModel()->select( theIndx, aFlag );
|
selectionModel()->select( theIndx, aFlag );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::getIndexInfo( const QModelIndex& theIndx, bool& isExpand, bool& isSelected, bool& isCurrent )
|
void CurveCreator_TreeView::getIndexInfo( const QModelIndex& theIndx, bool& isExpand, bool& isSelected, bool& isCurrent )
|
||||||
{
|
{
|
||||||
isExpand = isExpanded(theIndx);
|
isExpand = isExpanded(theIndx);
|
||||||
isSelected = selectionModel()->isSelected(theIndx);
|
isSelected = selectionModel()->isSelected(theIndx);
|
||||||
isCurrent = (theIndx == selectionModel()->currentIndex());
|
isCurrent = (theIndx == selectionModel()->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond )
|
void CurveCreator_TreeView::swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond )
|
||||||
{
|
{
|
||||||
bool isFirstSelected;
|
bool isFirstSelected;
|
||||||
bool isFirstExpanded;
|
bool isFirstExpanded;
|
||||||
bool isFirstCurrent;
|
bool isFirstCurrent;
|
||||||
getIndexInfo( theFirst, isFirstExpanded, isFirstSelected, isFirstCurrent );
|
getIndexInfo( theFirst, isFirstExpanded, isFirstSelected, isFirstCurrent );
|
||||||
|
|
||||||
bool isSecondSelected;
|
bool isSecondSelected;
|
||||||
bool isSecondExpanded;
|
bool isSecondExpanded;
|
||||||
bool isSecondCurrent;
|
bool isSecondCurrent;
|
||||||
getIndexInfo( theSecond, isSecondExpanded, isSecondSelected, isSecondCurrent );
|
getIndexInfo( theSecond, isSecondExpanded, isSecondSelected, isSecondCurrent );
|
||||||
|
|
||||||
setIndexState( theFirst, isSecondExpanded, isSecondSelected, isSecondCurrent );
|
setIndexState( theFirst, isSecondExpanded, isSecondSelected, isSecondCurrent );
|
||||||
setIndexState( theSecond, isFirstExpanded, isFirstSelected, isFirstCurrent );
|
setIndexState( theSecond, isFirstExpanded, isFirstSelected, isFirstCurrent );
|
||||||
dataChanged(theFirst,theFirst);
|
dataChanged(theFirst,theFirst);
|
||||||
dataChanged(theSecond,theSecond);
|
dataChanged(theSecond,theSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::sectionsSwapped( int theSection, int theOffset )
|
void CurveCreator_TreeView::sectionsSwapped( int theSection, int theOffset )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
QModelIndex aFirstIndex = aModel->sectionIndex( theSection );
|
QModelIndex aFirstIndex = aModel->sectionIndex( theSection );
|
||||||
QModelIndex aSecondIndex = aModel->sectionIndex( theSection + theOffset );
|
QModelIndex aSecondIndex = aModel->sectionIndex( theSection + theOffset );
|
||||||
swapIndexes( aFirstIndex, aSecondIndex );
|
swapIndexes( aFirstIndex, aSecondIndex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::pointsSwapped( int theSection, int thePointNum, int theOffset )
|
void CurveCreator_TreeView::pointsSwapped( int theSection, int thePointNum, int theOffset )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
QModelIndex aFirstIndex = aModel->pointIndex( theSection, thePointNum );
|
QModelIndex aFirstIndex = aModel->pointIndex( theSection, thePointNum );
|
||||||
QModelIndex aSecondIndex = aModel->pointIndex( theSection, thePointNum + theOffset );
|
QModelIndex aSecondIndex = aModel->pointIndex( theSection, thePointNum + theOffset );
|
||||||
swapIndexes( aFirstIndex, aSecondIndex );
|
swapIndexes( aFirstIndex, aSecondIndex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::setSelectedSections( const QList<int>& theList )
|
void CurveCreator_TreeView::setSelectedSections( const QList<int>& theList )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
selectionModel()->clearSelection();
|
selectionModel()->clearSelection();
|
||||||
for( int i = 0 ; i < theList.size() ; i++ ){
|
for( int i = 0 ; i < theList.size() ; i++ ){
|
||||||
QModelIndex aSectIndx = aModel->sectionIndex(theList[i]);
|
QModelIndex aSectIndx = aModel->sectionIndex(theList[i]);
|
||||||
selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
|
selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::setSelectedPoints( const QList< QPair<int, int> >& thePointsList )
|
void CurveCreator_TreeView::setSelectedPoints( const QList< QPair<int, int> >& thePointsList )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( aModel ){
|
if( aModel ){
|
||||||
selectionModel()->clearSelection();
|
selectionModel()->clearSelection();
|
||||||
for( int i = 0 ; i < thePointsList.size() ; i++ ){
|
for( int i = 0 ; i < thePointsList.size() ; i++ ){
|
||||||
QModelIndex aSectIndx = aModel->pointIndex( thePointsList[i].first, thePointsList[i].second );
|
QModelIndex aSectIndx = aModel->pointIndex( thePointsList[i].first, thePointsList[i].second );
|
||||||
selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
|
selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pointLessThan(const QPair<int,int> &s1, const QPair<int,int> &s2)
|
bool pointLessThan(const QPair<int,int> &s1, const QPair<int,int> &s2)
|
||||||
{
|
{
|
||||||
if( s1.first < s2.first )
|
if( s1.first < s2.first )
|
||||||
return true;
|
return true;
|
||||||
if( s1.first > s2.first )
|
if( s1.first > s2.first )
|
||||||
return false;
|
return false;
|
||||||
return s1.second < s2.second;
|
return s1.second < s2.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList< QPair< int, int > > CurveCreator_TreeView::getSelectedPoints() const
|
QList< QPair< int, int > > CurveCreator_TreeView::getSelectedPoints() const
|
||||||
{
|
{
|
||||||
QList< QPair< int, int > > aPoints;
|
QList< QPair< int, int > > aPoints;
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( !aModel )
|
if( !aModel )
|
||||||
return aPoints;
|
return aPoints;
|
||||||
QModelIndexList anIndxs = selectionModel()->selectedIndexes();
|
QModelIndexList anIndxs = selectionModel()->selectedIndexes();
|
||||||
for( int i = 0 ; i < anIndxs.size() ; i++ ){
|
for( int i = 0 ; i < anIndxs.size() ; i++ ){
|
||||||
if( !aModel->isSection( anIndxs[i] ) ){
|
if( !aModel->isSection( anIndxs[i] ) ){
|
||||||
int aSect = aModel->getSection(anIndxs[i]);
|
int aSect = aModel->getSection(anIndxs[i]);
|
||||||
int aPointNum = aModel->getPoint(anIndxs[i]);
|
int aPointNum = aModel->getPoint(anIndxs[i]);
|
||||||
QPair< int, int > aPoint = QPair<int,int>( aSect, aPointNum );
|
QPair< int, int > aPoint = QPair<int,int>( aSect, aPointNum );
|
||||||
aPoints.push_back( aPoint );
|
aPoints.push_back( aPoint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qSort( aPoints.begin(), aPoints.end(), pointLessThan );
|
qSort( aPoints.begin(), aPoints.end(), pointLessThan );
|
||||||
return aPoints;
|
return aPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurveCreator_TreeView::SelectionType CurveCreator_TreeView::getSelectionType() const
|
CurveCreator_TreeView::SelectionType CurveCreator_TreeView::getSelectionType() const
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( !aModel )
|
if( !aModel )
|
||||||
return ST_NOSEL;
|
|
||||||
bool isPointSel = false;
|
|
||||||
bool isSectSel = false;
|
|
||||||
bool isOneSection = true;
|
|
||||||
int aSectNum = -1;
|
|
||||||
QModelIndexList aLst = selectionModel()->selectedIndexes();
|
|
||||||
for( int i = 0 ; i < aLst.size() ; i++ ){
|
|
||||||
if( aModel->isSection( aLst[i] ) ){
|
|
||||||
isSectSel = true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
isPointSel = true;
|
|
||||||
if( aSectNum == -1 ){
|
|
||||||
aSectNum = aModel->getSection(aLst[i]);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if( aSectNum != aModel->getSection( aLst[i] ) ){
|
|
||||||
isOneSection = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( isSectSel && !isPointSel )
|
|
||||||
return ST_SECTIONS;
|
|
||||||
if( isPointSel && !isSectSel ){
|
|
||||||
if( isOneSection ){
|
|
||||||
return ST_POINTS_ONE_SECTION;
|
|
||||||
}
|
|
||||||
return ST_POINTS;
|
|
||||||
}
|
|
||||||
if( isPointSel && isSectSel )
|
|
||||||
return ST_MIXED;
|
|
||||||
return ST_NOSEL;
|
return ST_NOSEL;
|
||||||
|
bool isPointSel = false;
|
||||||
|
bool isSectSel = false;
|
||||||
|
bool isOneSection = true;
|
||||||
|
int aSectNum = -1;
|
||||||
|
QModelIndexList aLst = selectionModel()->selectedIndexes();
|
||||||
|
for( int i = 0 ; i < aLst.size() ; i++ ){
|
||||||
|
if( aModel->isSection( aLst[i] ) ){
|
||||||
|
isSectSel = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
isPointSel = true;
|
||||||
|
if( aSectNum == -1 ){
|
||||||
|
aSectNum = aModel->getSection(aLst[i]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if( aSectNum != aModel->getSection( aLst[i] ) ){
|
||||||
|
isOneSection = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( isSectSel && !isPointSel )
|
||||||
|
return ST_SECTIONS;
|
||||||
|
if( isPointSel && !isSectSel ){
|
||||||
|
if( isOneSection ){
|
||||||
|
return ST_POINTS_ONE_SECTION;
|
||||||
|
}
|
||||||
|
return ST_POINTS;
|
||||||
|
}
|
||||||
|
if( isPointSel && isSectSel )
|
||||||
|
return ST_MIXED;
|
||||||
|
return ST_NOSEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_TreeView::onActivated( QModelIndex theIndx )
|
void CurveCreator_TreeView::onActivated( QModelIndex theIndx )
|
||||||
{
|
{
|
||||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
if( !aModel )
|
if( !aModel )
|
||||||
return;
|
return;
|
||||||
int aSect = aModel->getSection(theIndx);
|
int aSect = aModel->getSection(theIndx);
|
||||||
if( aModel->isSection(theIndx) ){
|
if( aModel->isSection(theIndx) ){
|
||||||
emit sectionEntered( aSect );
|
emit sectionEntered( aSect );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int aPointNum = aModel->getPoint( theIndx );
|
int aPointNum = aModel->getPoint( theIndx );
|
||||||
emit pointEntered( aSect, aPointNum );
|
emit pointEntered( aSect, aPointNum );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurveCreator_TreeView::setCurve( CurveCreator_Curve* theCurve )
|
||||||
|
{
|
||||||
|
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||||
|
if( aModel )
|
||||||
|
aModel->setCurve(theCurve);
|
||||||
|
reset();
|
||||||
}
|
}
|
||||||
|
@ -9,63 +9,67 @@ class CurveCreator_Curve;
|
|||||||
class CurveCreator_TreeViewModel : public QAbstractItemModel
|
class CurveCreator_TreeViewModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent );
|
CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent );
|
||||||
virtual int columnCount(const QModelIndex & parent = QModelIndex()) const;
|
virtual int columnCount(const QModelIndex & parent = QModelIndex()) const;
|
||||||
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||||||
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||||
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
||||||
virtual QModelIndex parent(const QModelIndex & theIndex) const;
|
virtual QModelIndex parent(const QModelIndex & theIndex) const;
|
||||||
|
|
||||||
QModelIndex sectionIndex( int theSection ) const;
|
QModelIndex sectionIndex( int theSection ) const;
|
||||||
QModelIndex pointIndex( int theSection, int thePoint ) const;
|
QModelIndex pointIndex( int theSection, int thePoint ) const;
|
||||||
|
|
||||||
|
bool isSection( const QModelIndex& theIndx ) const;
|
||||||
|
int getSection( const QModelIndex& theIndx ) const;
|
||||||
|
int getPoint( const QModelIndex& theIndx ) const;
|
||||||
|
|
||||||
|
void setCurve( CurveCreator_Curve* theCurve );
|
||||||
|
|
||||||
bool isSection( const QModelIndex& theIndx ) const;
|
|
||||||
int getSection( const QModelIndex& theIndx ) const;
|
|
||||||
int getPoint( const QModelIndex& theIndx ) const;
|
|
||||||
private:
|
private:
|
||||||
enum IconType{ ICON_POLYLINE, ICON_SPLINE, ICON_CLOSED_SPLINE, ICON_CLOSED_POLYLINE, ICON_POINT };
|
enum IconType{ ICON_POLYLINE, ICON_SPLINE, ICON_CLOSED_SPLINE, ICON_CLOSED_POLYLINE, ICON_POINT };
|
||||||
private:
|
private:
|
||||||
CurveCreator_Curve* myCurve;
|
CurveCreator_Curve* myCurve;
|
||||||
QMap<IconType, QPixmap> myCachedIcons;
|
QMap<IconType, QPixmap> myCachedIcons;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CurveCreator_TreeView : public QTreeView
|
class CurveCreator_TreeView : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum SelectionType{ ST_NOSEL, ST_POINTS, ST_POINTS_ONE_SECTION, ST_SECTIONS, ST_MIXED };
|
enum SelectionType{ ST_NOSEL, ST_POINTS, ST_POINTS_ONE_SECTION, ST_SECTIONS, ST_MIXED };
|
||||||
public:
|
public:
|
||||||
explicit CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent = 0);
|
explicit CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent = 0);
|
||||||
SelectionType getSelectionType() const;
|
SelectionType getSelectionType() const;
|
||||||
QList<int> getSelectedSections() const;
|
QList<int> getSelectedSections() const;
|
||||||
QList< QPair< int, int > > getSelectedPoints() const;
|
QList< QPair< int, int > > getSelectedPoints() const;
|
||||||
|
|
||||||
void pointsAdded( int theSection, int thePoint, int thePointsCnt=1 );
|
void pointsAdded( int theSection, int thePoint, int thePointsCnt=1 );
|
||||||
void pointDataChanged( int theSection, int thePoint );
|
void pointDataChanged( int theSection, int thePoint );
|
||||||
void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 );
|
void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 );
|
||||||
void pointsSwapped( int theSection, int thePointNum, int theOffset );
|
void pointsSwapped( int theSection, int thePointNum, int theOffset );
|
||||||
|
|
||||||
void sectionAdded( int theSection );
|
void sectionAdded( int theSection );
|
||||||
void sectionChanged(int theSection , int aSectCnt = 1);
|
void sectionChanged(int theSection , int aSectCnt = 1);
|
||||||
void sectionsRemoved( int theSection, int theSectionCnt=1 );
|
void sectionsRemoved( int theSection, int theSectionCnt=1 );
|
||||||
void sectionsSwapped( int theSection, int theOffset );
|
void sectionsSwapped( int theSection, int theOffset );
|
||||||
|
|
||||||
void setSelectedSections( const QList<int>& theList );
|
void setSelectedSections( const QList<int>& theList );
|
||||||
void setSelectedPoints( const QList< QPair<int, int> >& thePointsList );
|
void setSelectedPoints( const QList< QPair<int, int> >& thePointsList );
|
||||||
|
|
||||||
|
void setCurve( CurveCreator_Curve* theCurve );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
void sectionEntered(int);
|
void sectionEntered(int);
|
||||||
void pointEntered(int,int);
|
void pointEntered(int,int);
|
||||||
public slots:
|
public slots:
|
||||||
protected slots:
|
protected slots:
|
||||||
void onActivated( QModelIndex theIndx );
|
void onActivated( QModelIndex theIndx );
|
||||||
protected:
|
protected:
|
||||||
void setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
|
void setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
|
||||||
void swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond );
|
void swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond );
|
||||||
void getIndexInfo( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
|
void getIndexInfo( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
|
||||||
private:
|
|
||||||
CurveCreator_Curve* myCurve;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CURVECREATOR_TREEVIEW_H
|
#endif // CURVECREATOR_TREEVIEW_H
|
||||||
|
@ -1,547 +0,0 @@
|
|||||||
#include "CurveCreator_Widget.h"
|
|
||||||
#include "CurveCreator_TreeView.h"
|
|
||||||
#include "QVBoxLayout"
|
|
||||||
#include "CurveCreator_Curve.hxx"
|
|
||||||
#include "CurveCreator_CurveEditor.hxx"
|
|
||||||
#include "CurveCreator.hxx"
|
|
||||||
#include "CurveCreator_NewPointDlg.h"
|
|
||||||
#include "CurveCreator_NewSectionDlg.h"
|
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QGroupBox>
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QToolBar>
|
|
||||||
#include <QAction>
|
|
||||||
#include <QMenu>
|
|
||||||
|
|
||||||
CurveCreator_Widget::CurveCreator_Widget(QWidget *parent) :
|
|
||||||
QWidget(parent), myNewPointEditor(NULL)
|
|
||||||
{
|
|
||||||
//TODO remove it for debug only
|
|
||||||
myCurve = new CurveCreator_Curve(CurveCreator::Dim2d);
|
|
||||||
myEdit = new CurveCreator_CurveEditor( myCurve );
|
|
||||||
CurveCreator::Coordinates aCoords;
|
|
||||||
|
|
||||||
aCoords.push_back(10);
|
|
||||||
aCoords.push_back(20);
|
|
||||||
aCoords.push_back(1);
|
|
||||||
aCoords.push_back(2);
|
|
||||||
|
|
||||||
myEdit->addSection("",CurveCreator::BSpline, true, aCoords );
|
|
||||||
|
|
||||||
aCoords.clear();
|
|
||||||
aCoords.push_back(11);
|
|
||||||
aCoords.push_back(21);
|
|
||||||
aCoords.push_back(111);
|
|
||||||
aCoords.push_back(211);
|
|
||||||
aCoords.push_back(101);
|
|
||||||
aCoords.push_back(201);
|
|
||||||
aCoords.push_back(13);
|
|
||||||
aCoords.push_back(25);
|
|
||||||
myEdit->addSection("",CurveCreator::Polyline, false, aCoords );
|
|
||||||
|
|
||||||
aCoords.clear();
|
|
||||||
for( int i = 0 ; i < 1000000 ; i++ ){
|
|
||||||
double anX = ((double)i)/10000.;
|
|
||||||
double anY = ((double)i)/10000. + 3.4;
|
|
||||||
aCoords.push_back(anX);
|
|
||||||
aCoords.push_back(anY);
|
|
||||||
}
|
|
||||||
myEdit->addSection("",CurveCreator::Polyline, true, aCoords );
|
|
||||||
|
|
||||||
//TODO end debug
|
|
||||||
myNewPointEditor = new CurveCreator_NewPointDlg(myCurve->getDimension(), this);
|
|
||||||
connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()));
|
|
||||||
|
|
||||||
myNewSectionEditor = new CurveCreator_NewSectionDlg(this);
|
|
||||||
connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()));
|
|
||||||
|
|
||||||
QHBoxLayout* aNameLayout = new QHBoxLayout();
|
|
||||||
QLabel* aNameLabel = new QLabel(tr("CURVE_NAME_TLT"), this);
|
|
||||||
aNameLayout->addWidget(aNameLabel);
|
|
||||||
QLineEdit* aNameEdit = new QLineEdit(this);
|
|
||||||
aNameLayout->addWidget(aNameEdit);
|
|
||||||
|
|
||||||
QGroupBox* aSectionGroup = new QGroupBox(tr("SECTION_GROUP_TLT"),this);
|
|
||||||
|
|
||||||
mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup);
|
|
||||||
connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) );
|
|
||||||
connect( mySectionView, SIGNAL(pointEntered(int,int)), this, SLOT(onEditPoint(int,int)) );
|
|
||||||
connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) );
|
|
||||||
connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) );
|
|
||||||
QToolBar* aTB = new QToolBar(tr("TOOL_BAR_TLT"), aSectionGroup);
|
|
||||||
// QToolButton* anUndoBtn = new QToolButton(aTB);
|
|
||||||
QAction* anAct = createAction( UNDO_ID, tr("UNDO"), tr(":images/ICON_UNDO"), tr("UNDO_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Z) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
|
|
||||||
anAct = createAction( REDO_ID, tr("REDO"), tr(":images/ICON_REDO"), tr("REDO_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Y) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
|
|
||||||
aTB->addSeparator();
|
|
||||||
|
|
||||||
anAct = createAction( NEW_SECTION_ID, tr("ICON_NEW_SECTION"), tr(":images/ICON_NEW_SECTION"), tr("NEW_SECTION_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_N) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
|
|
||||||
anAct = createAction( INSERT_SECTION_BEFORE_ID, tr("INSERT_SECTION_BEFORE"), tr(":images/ICON_INSERT_SECTION_BEFORE"), tr("INSERT_SECTION_BEFORE_TLT"),
|
|
||||||
QKeySequence(Qt::ControlModifier | Qt::Key_Insert ) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionBefore()) );
|
|
||||||
|
|
||||||
anAct = createAction( INSERT_SECTION_AFTER_ID, tr("INSERT_SECTION_AFTER"), tr(":images/ICON_INSERT_SECTION_AFTER"), tr("INSERT_SECTION_AFTER_TLT"),
|
|
||||||
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Insert ) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionAfter()) );
|
|
||||||
|
|
||||||
anAct = createAction( NEW_POINT_ID, tr("ICON_NEW_POINT"), tr(":images/ICON_NEW_POINT"), tr("NEW_POINT_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_P) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onNewPoint()) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
aTB->addSeparator();
|
|
||||||
|
|
||||||
anAct = createAction( INSERT_POINT_BEFORE_ID, tr("INSERT_POINT_BEFORE"), tr(":images/ICON_POINT_BEFORE"), tr("INSERT_POINT_BEFORE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_B) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointBefore()) );
|
|
||||||
|
|
||||||
anAct = createAction( INSERT_POINT_AFTER_ID, tr("INSERT_POINT_AFTER"), tr(":images/ICON_POINT_AFTER"), tr("INSERT_POINT_AFTER_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_M) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointAfter()) );
|
|
||||||
|
|
||||||
anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), tr(":images/ICON_CLOSE_SECTIONS"), tr("CLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_W) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) );
|
|
||||||
|
|
||||||
anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), tr(":images/ICON_UNCLOSE_SECTIONS"), tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) );
|
|
||||||
|
|
||||||
anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"), tr(":images/ICON_POLYLINE"), tr("SET_POLYLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_E) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) );
|
|
||||||
|
|
||||||
anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), tr(":images/ICON_SPLINE"), tr("SET_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
|
|
||||||
|
|
||||||
anAct = createAction( REMOVE_ID, tr("ICON_REMOVE"), tr(":images/ICON_REMOVE"), tr("REMOVE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );
|
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
aTB->addSeparator();
|
|
||||||
|
|
||||||
anAct = createAction( JOIN_ID, tr("ICON_JOIN"), tr(":images/ICON_JOIN"), tr("JOIN_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
|
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
aTB->addSeparator();
|
|
||||||
|
|
||||||
anAct = createAction( UP_ID, tr("ICON_STEP_UP"), tr(":images/ICON_STEP_UP"), tr("STEP_UP_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Up ) );
|
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveUp()) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
|
|
||||||
anAct = createAction( DOWN_ID, tr("ICON_STEP_DOWN"), tr(":images/ICON_STEP_DOWN"), tr("STEP_DOWN"), QKeySequence(Qt::ControlModifier|Qt::Key_Down ) );
|
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveDown()) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
|
|
||||||
anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), tr(":images/ICON_CLEAR_ALL"), tr("CLEAR_ALL_TLT"), QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
|
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
|
|
||||||
anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), tr(":images/ICON_JOIN_ALL"), tr("JOIN_ALL_TLT"), QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
|
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
|
|
||||||
aTB->addAction(anAct);
|
|
||||||
|
|
||||||
QVBoxLayout* aSectLayout = new QVBoxLayout();
|
|
||||||
aSectLayout->addWidget(aTB);
|
|
||||||
aSectLayout->addWidget(mySectionView);
|
|
||||||
aSectionGroup->setLayout(aSectLayout);
|
|
||||||
QVBoxLayout* aLay = new QVBoxLayout();
|
|
||||||
aLay->addLayout(aNameLayout);
|
|
||||||
aLay->addWidget(aSectionGroup);
|
|
||||||
setLayout(aLay);
|
|
||||||
onSelectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onSelectionChanged()
|
|
||||||
{
|
|
||||||
QList<ActionId> anEnabledAct;
|
|
||||||
anEnabledAct << NEW_SECTION_ID;
|
|
||||||
int aSectCnt = myCurve->getNbPoints();
|
|
||||||
if( aSectCnt > 0 )
|
|
||||||
anEnabledAct << CLEAR_ALL_ID;
|
|
||||||
if( aSectCnt > 1 )
|
|
||||||
anEnabledAct << JOIN_ALL_ID;
|
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
|
||||||
QList< QPair< int, int > > aSelPoints = mySectionView->getSelectedPoints();
|
|
||||||
CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType();
|
|
||||||
switch( aSelType ){
|
|
||||||
case CurveCreator_TreeView::ST_NOSEL:{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CurveCreator_TreeView::ST_SECTIONS:{
|
|
||||||
if( aSelSections.size() > 1 ){
|
|
||||||
anEnabledAct << JOIN_ID;
|
|
||||||
}
|
|
||||||
if( aSelSections[0] > 0 ){
|
|
||||||
anEnabledAct << UP_ID;
|
|
||||||
}
|
|
||||||
if( aSelSections.size() == 1 ){
|
|
||||||
anEnabledAct << NEW_POINT_ID << INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID;
|
|
||||||
}
|
|
||||||
if( aSelSections[ aSelSections.size() - 1 ] < ( myCurve->getNbSections() - 1 ) ){
|
|
||||||
anEnabledAct << DOWN_ID;
|
|
||||||
}
|
|
||||||
anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CurveCreator_TreeView::ST_POINTS_ONE_SECTION:{
|
|
||||||
if( aSelPoints[0].second > 0 ){
|
|
||||||
anEnabledAct << UP_ID;
|
|
||||||
}
|
|
||||||
int aLastIndex = aSelPoints.size()-1;
|
|
||||||
int aSect = aSelPoints[0].first;
|
|
||||||
if( aSelPoints[aLastIndex].second < (myCurve->getNbPoints(aSect) - 1)){
|
|
||||||
anEnabledAct << DOWN_ID;
|
|
||||||
}
|
|
||||||
if( aSelPoints.size() == 1){
|
|
||||||
anEnabledAct << INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int aSelObjsCnt = aSelPoints.size() + aSelSections.size();
|
|
||||||
if( aSelObjsCnt > 0 ){
|
|
||||||
anEnabledAct << REMOVE_ID;
|
|
||||||
}
|
|
||||||
if( myCurve->getNbSections() > 0 ){
|
|
||||||
anEnabledAct << REMOVE_ALL_ID;
|
|
||||||
}
|
|
||||||
if( myCurve->getNbSections() > 1 ){
|
|
||||||
anEnabledAct << JOIN_ALL_ID;
|
|
||||||
}
|
|
||||||
QList<ActionId> anIds = myActionMap.keys();
|
|
||||||
for( int i = 0 ; i < anIds.size() ; i++ ){
|
|
||||||
if( myActionMap.contains(anIds[i]) ){
|
|
||||||
if( anEnabledAct.contains(anIds[i]) ){
|
|
||||||
myActionMap[anIds[i]]->setEnabled(true);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
myActionMap[anIds[i]]->setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onNewPoint()
|
|
||||||
{
|
|
||||||
mySection= -1;
|
|
||||||
myPointNum = -1;
|
|
||||||
QList<int> aSelSection = mySectionView->getSelectedSections();
|
|
||||||
if( aSelSection.size() > 0 ){
|
|
||||||
mySection = aSelSection[0];
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
|
|
||||||
if( aSelPoints.size() > 0 ){
|
|
||||||
mySection = aSelPoints[0].first;
|
|
||||||
myPointNum = aSelPoints[0].second + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString aSectName;
|
|
||||||
if( mySection < 0 ){
|
|
||||||
mySection = myCurve->getNbSections() - 1;
|
|
||||||
}
|
|
||||||
aSectName = QString::fromStdString( myCurve->getSectionName(mySection));
|
|
||||||
if( myPointNum < 0 ){
|
|
||||||
myPointNum = myCurve->getNbPoints(mySection);
|
|
||||||
}
|
|
||||||
myNewPointEditor->clear();
|
|
||||||
myNewPointEditor->setEditMode(false);
|
|
||||||
myNewPointEditor->setSectionName(aSectName);
|
|
||||||
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
|
||||||
onAddNewPoint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onAddNewPoint()
|
|
||||||
{
|
|
||||||
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
|
|
||||||
myEdit->insertPoints(aCoords, mySection, myPointNum );
|
|
||||||
mySectionView->pointsAdded( mySection, myPointNum );
|
|
||||||
myNewPointEditor->clear();
|
|
||||||
myPointNum++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onNewSection()
|
|
||||||
{
|
|
||||||
myNewSectionEditor->clear();
|
|
||||||
myNewSectionEditor->setEditMode(false);
|
|
||||||
QString aSectName = QString( myCurve->getUnicSectionName().c_str() );
|
|
||||||
myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );
|
|
||||||
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
|
||||||
onAddNewSection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onAddNewSection()
|
|
||||||
{
|
|
||||||
CurveCreator::Coordinates aCoords;
|
|
||||||
myEdit->addSection( myNewSectionEditor->getName().toStdString(), myNewSectionEditor->getSectionType(),
|
|
||||||
myNewSectionEditor->isClosed(), aCoords );
|
|
||||||
mySectionView->sectionAdded( mySection );
|
|
||||||
QString aNewName = QString(myCurve->getUnicSectionName().c_str());
|
|
||||||
myNewSectionEditor->setSectionName(aNewName);
|
|
||||||
mySection++;
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theName, const QString& theImageName,
|
|
||||||
const QString& theToolTip, const QKeySequence& theShortcut )
|
|
||||||
{
|
|
||||||
QAction* anAct = new QAction(theName,this);
|
|
||||||
QIcon anIcon(theImageName);
|
|
||||||
if( !anIcon.isNull() ){
|
|
||||||
anAct->setIcon(anIcon);
|
|
||||||
}
|
|
||||||
anAct->setShortcut(theShortcut);
|
|
||||||
anAct->setToolTip(theToolTip);
|
|
||||||
myActionMap[theId] = anAct;
|
|
||||||
return anAct;
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction* CurveCreator_Widget::getAction(ActionId theId)
|
|
||||||
{
|
|
||||||
if( myActionMap.contains(theId) )
|
|
||||||
return myActionMap[theId];
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onEditSection( int theSection )
|
|
||||||
{
|
|
||||||
mySection = theSection;
|
|
||||||
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
|
||||||
bool isClosed = myCurve->isClosed(theSection);
|
|
||||||
CurveCreator::Type aType = myCurve->getType(theSection);
|
|
||||||
myNewSectionEditor->setEditMode(true);
|
|
||||||
myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType );
|
|
||||||
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
|
||||||
QString aName = myNewSectionEditor->getName();
|
|
||||||
bool isClosed = myNewSectionEditor->isClosed();
|
|
||||||
CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
|
|
||||||
myEdit->setClosed( isClosed, mySection );
|
|
||||||
myEdit->setName( aName.toStdString(), mySection );
|
|
||||||
myEdit->setType( aSectType, mySection );
|
|
||||||
mySectionView->sectionChanged(mySection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onEditPoint( int theSection, int thePoint )
|
|
||||||
{
|
|
||||||
if( !myNewPointEditor ){
|
|
||||||
}
|
|
||||||
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
|
||||||
myNewPointEditor->setEditMode(true);
|
|
||||||
myNewPointEditor->setSectionName(aSectName);
|
|
||||||
CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint);
|
|
||||||
myNewPointEditor->setCoordinates(aCoords);
|
|
||||||
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
|
||||||
aCoords = myNewPointEditor->getCoordinates();
|
|
||||||
myEdit->setCoordinates(aCoords, theSection, thePoint);
|
|
||||||
mySectionView->pointDataChanged(theSection, thePoint );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onJoin()
|
|
||||||
{
|
|
||||||
QList<int> aSections = mySectionView->getSelectedSections();
|
|
||||||
if( aSections.size() == 0 ){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int aMainSect = aSections[0];
|
|
||||||
int aMainSectSize = myCurve->getNbPoints(aMainSect);
|
|
||||||
for( int i = 1 ; i < aSections.size() ; i++ ){
|
|
||||||
int aSectNum = aSections[i] - (i-1);
|
|
||||||
myEdit->join( aMainSect, aSectNum );
|
|
||||||
mySectionView->sectionsRemoved( aSectNum );
|
|
||||||
}
|
|
||||||
int aNewSectSize = myCurve->getNbPoints(aMainSect);
|
|
||||||
if( aNewSectSize != aMainSectSize )
|
|
||||||
mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onRemove()
|
|
||||||
{
|
|
||||||
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
|
|
||||||
int aCurrSect=-1;
|
|
||||||
int aRemoveCnt = 0;
|
|
||||||
for( int i = 0 ; i < aSelPoints.size() ; i++ ){
|
|
||||||
if( aCurrSect != aSelPoints[i].first ){
|
|
||||||
aRemoveCnt = 0;
|
|
||||||
aCurrSect = aSelPoints[i].first;
|
|
||||||
}
|
|
||||||
int aPntIndx = aSelPoints[i].second - aRemoveCnt;
|
|
||||||
myEdit->removePoints(aCurrSect,aPntIndx, 1);
|
|
||||||
mySectionView->pointsRemoved( aCurrSect, aPntIndx );
|
|
||||||
aRemoveCnt++;
|
|
||||||
}
|
|
||||||
QList<int> aSections = mySectionView->getSelectedSections();
|
|
||||||
for( int i = 0 ; i < aSections.size() ; i++ ){
|
|
||||||
int aSectNum = aSections[i] - (i);
|
|
||||||
myEdit->removeSection( aSectNum );
|
|
||||||
mySectionView->sectionsRemoved( aSectNum );
|
|
||||||
}
|
|
||||||
mySectionView->clearSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onMoveUp()
|
|
||||||
{
|
|
||||||
if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){
|
|
||||||
//Move sections
|
|
||||||
QList<int> aSections = mySectionView->getSelectedSections();
|
|
||||||
for( int i = 0 ; i < aSections.size() ; i++ ){
|
|
||||||
int anIndx = aSections[i];
|
|
||||||
myEdit->moveSection( anIndx, anIndx-1);
|
|
||||||
mySectionView->sectionsSwapped( anIndx, -1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
//Move points
|
|
||||||
QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();
|
|
||||||
for( int i = 0 ; i < aPoints.size() ; i++ ){
|
|
||||||
int aSection = aPoints[i].first;
|
|
||||||
int aPoint = aPoints[i].second;
|
|
||||||
myEdit->movePoint(aSection, aPoint, aPoint-2);
|
|
||||||
mySectionView->pointsSwapped( aSection, aPoint, -1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onMoveDown()
|
|
||||||
{
|
|
||||||
if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){
|
|
||||||
//Move sections
|
|
||||||
QList<int> aSections = mySectionView->getSelectedSections();
|
|
||||||
for( int i = aSections.size()-1 ; i >=0 ; i-- ){
|
|
||||||
int anIndx = aSections[i];
|
|
||||||
myEdit->moveSection( anIndx, anIndx+1);
|
|
||||||
mySectionView->sectionsSwapped( anIndx, 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
//Move points
|
|
||||||
QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();
|
|
||||||
for( int i = aPoints.size() - 1; i >= 0 ; i-- ){
|
|
||||||
int aSection = aPoints[i].first;
|
|
||||||
int aPoint = aPoints[i].second;
|
|
||||||
myEdit->movePoint(aSection, aPoint, aPoint+1);
|
|
||||||
mySectionView->pointsSwapped( aSection, aPoint, 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onClearAll()
|
|
||||||
{
|
|
||||||
myEdit->clear();
|
|
||||||
mySectionView->reset();
|
|
||||||
onSelectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onJoinAll()
|
|
||||||
{
|
|
||||||
myEdit->join();
|
|
||||||
mySectionView->reset();
|
|
||||||
onSelectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onInsertSectionBefore()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onInsertSectionAfter()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onInsertPointBefore()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onInsertPointAfter()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onUndoSettings()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onSetSpline()
|
|
||||||
{
|
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
|
||||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
|
||||||
myEdit->setType(CurveCreator::BSpline, aSelSections[i]);
|
|
||||||
mySectionView->sectionChanged(aSelSections[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onSetPolyline()
|
|
||||||
{
|
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
|
||||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
|
||||||
myEdit->setType(CurveCreator::Polyline, aSelSections[i]);
|
|
||||||
mySectionView->sectionChanged(aSelSections[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onCloseSections()
|
|
||||||
{
|
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
|
||||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
|
||||||
myEdit->setClosed(true, aSelSections[i]);
|
|
||||||
mySectionView->sectionChanged(aSelSections[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onUncloseSections()
|
|
||||||
{
|
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
|
||||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
|
||||||
myEdit->setClosed(false, aSelSections[i]);
|
|
||||||
mySectionView->sectionChanged(aSelSections[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveCreator_Widget::onContextMenu( QPoint thePoint )
|
|
||||||
{
|
|
||||||
QList<ActionId> aContextActions;
|
|
||||||
aContextActions << CLEAR_ALL_ID << JOIN_ALL_ID << SEPARATOR_ID <<
|
|
||||||
INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID << SEPARATOR_ID <<
|
|
||||||
CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID <<
|
|
||||||
SET_SECTIONS_SPLINE_ID << SEPARATOR_ID <<
|
|
||||||
INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
|
|
||||||
QPoint aGlPoint = mySectionView->mapToGlobal(thePoint);
|
|
||||||
bool isVis = false;
|
|
||||||
QList<ActionId> aResAct;
|
|
||||||
for( int i = 0 ; i < aContextActions.size() ; i++ ){
|
|
||||||
if( aContextActions[i] != SEPARATOR_ID ){
|
|
||||||
if( myActionMap.contains(aContextActions[i]) ){
|
|
||||||
QAction* anAct = myActionMap[aContextActions[i]];
|
|
||||||
if( anAct->isEnabled() ){
|
|
||||||
aResAct << aContextActions[i];
|
|
||||||
isVis = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
aResAct << SEPARATOR_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( !isVis )
|
|
||||||
return;
|
|
||||||
|
|
||||||
QMenu* aMenu = new QMenu(this);
|
|
||||||
for( int i = 0 ; i < aResAct.size() ; i++ ){
|
|
||||||
if( aResAct[i] == SEPARATOR_ID ){
|
|
||||||
aMenu->addSeparator();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
QAction* anAct = myActionMap[aResAct[i]];
|
|
||||||
aMenu->insertAction(NULL, anAct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aMenu->exec(aGlPoint);
|
|
||||||
}
|
|
@ -1,11 +1,11 @@
|
|||||||
#include "CurveCreator_NewPointDlg.h"
|
|
||||||
#include "CurveCreator_NewSectionDlg.h"
|
|
||||||
#include "CurveCreator_TreeView.h"
|
|
||||||
#include "CurveCreator_Widget.h"
|
#include "CurveCreator_Widget.h"
|
||||||
|
#include "CurveCreator_TreeView.h"
|
||||||
#include "CurveCreator.hxx"
|
#include "QVBoxLayout"
|
||||||
#include "CurveCreator_Curve.hxx"
|
#include "CurveCreator_Curve.hxx"
|
||||||
#include "CurveCreator_CurveEditor.hxx"
|
#include "CurveCreator_CurveEditor.hxx"
|
||||||
|
#include "CurveCreator.hxx"
|
||||||
|
#include "CurveCreator_NewPointDlg.h"
|
||||||
|
#include "CurveCreator_NewSectionDlg.h"
|
||||||
|
|
||||||
#include <SUIT_Session.h>
|
#include <SUIT_Session.h>
|
||||||
#include <SUIT_ResourceMgr.h>
|
#include <SUIT_ResourceMgr.h>
|
||||||
@ -19,29 +19,25 @@
|
|||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QPixmap>
|
|
||||||
|
|
||||||
CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
||||||
CurveCreator_Curve *theCurve,
|
CurveCreator_Curve *theCurve,
|
||||||
Qt::WindowFlags fl ) :
|
Qt::WindowFlags fl) :
|
||||||
QWidget(parent), myNewPointEditor(NULL)
|
QWidget(parent), myNewPointEditor(NULL), myNewSectionEditor(NULL), myEdit(NULL), myCurve(theCurve)
|
||||||
{
|
{
|
||||||
myCurve = theCurve;
|
if( myCurve )
|
||||||
myEdit = new CurveCreator_CurveEditor( myCurve );
|
myEdit = new CurveCreator_CurveEditor( myCurve );
|
||||||
|
|
||||||
myNewPointEditor = new CurveCreator_NewPointDlg(myCurve->getDimension(), this);
|
CurveCreator::Dimension aDim = CurveCreator::Dim3d;
|
||||||
|
if( myCurve )
|
||||||
|
aDim = myCurve->getDimension();
|
||||||
|
myNewPointEditor = new CurveCreator_NewPointDlg(aDim, this);
|
||||||
connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()));
|
connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()));
|
||||||
|
|
||||||
myNewSectionEditor = new CurveCreator_NewSectionDlg(this);
|
myNewSectionEditor = new CurveCreator_NewSectionDlg(this);
|
||||||
connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()));
|
connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()));
|
||||||
|
|
||||||
/* QHBoxLayout* aNameLayout = new QHBoxLayout();
|
QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),this);
|
||||||
QLabel* aNameLabel = new QLabel(tr("CURVE_NAME_TLT"), this);
|
|
||||||
aNameLayout->addWidget(aNameLabel);
|
|
||||||
QLineEdit* aNameEdit = new QLineEdit(this);
|
|
||||||
aNameLayout->addWidget(aNameEdit); */
|
|
||||||
|
|
||||||
QGroupBox* aSectionGroup = new QGroupBox(tr("SECTION_GROUP_TLT"),this);
|
|
||||||
|
|
||||||
mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup);
|
mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup);
|
||||||
connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) );
|
connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) );
|
||||||
@ -51,81 +47,113 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
|||||||
QToolBar* aTB = new QToolBar(tr("TOOL_BAR_TLT"), aSectionGroup);
|
QToolBar* aTB = new QToolBar(tr("TOOL_BAR_TLT"), aSectionGroup);
|
||||||
// QToolButton* anUndoBtn = new QToolButton(aTB);
|
// QToolButton* anUndoBtn = new QToolButton(aTB);
|
||||||
|
|
||||||
QPixmap anUndoImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_UNDO")));
|
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||||
QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoImage, tr("UNDO_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Z) );
|
QPixmap anUndoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_UNDO")));
|
||||||
|
QPixmap aRedoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_REDO")));
|
||||||
|
QPixmap aNewSectionPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_SECTION")));
|
||||||
|
QPixmap aNewPointPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_POINT")));
|
||||||
|
QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
||||||
|
QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
||||||
|
QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE")));
|
||||||
|
QPixmap aJoinPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_JOIN")));
|
||||||
|
QPixmap aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP")));
|
||||||
|
QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN")));
|
||||||
|
|
||||||
|
/* QPixmap anUndoPixmap = QPixmap(tr(":images/ICON_UNDO"));
|
||||||
|
QPixmap aRedoPixmap = QPixmap(tr(":images/ICON_REDO"));
|
||||||
|
QPixmap aNewSectionPixmap = QPixmap(tr(":images/ICON_NEW_SECTION"));
|
||||||
|
QPixmap aNewPointPixmap = QPixmap(tr(":images/ICON_NEW_POINT"));
|
||||||
|
QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE"));
|
||||||
|
QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE"));
|
||||||
|
QPixmap aRemovePixmap = QPixmap(tr(":images/ICON_REMOVE"));
|
||||||
|
QPixmap aJoinPixmap = QPixmap(tr(":images/ICON_JOIN"));
|
||||||
|
QPixmap aStepUpPixmap = QPixmap(tr(":images/ICON_STEP_UP"));
|
||||||
|
QPixmap aStepDownPixmap = QPixmap(tr(":images/ICON_STEP_DOWN"));*/
|
||||||
|
|
||||||
|
QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"),
|
||||||
|
QKeySequence(Qt::ControlModifier|Qt::Key_Z) );
|
||||||
aTB->addAction(anAct);
|
aTB->addAction(anAct);
|
||||||
|
|
||||||
QPixmap aRedoImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_REDO")));
|
anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"),
|
||||||
anAct = createAction( REDO_ID, tr("REDO"), aRedoImage, tr("REDO_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Y) );
|
QKeySequence(Qt::ControlModifier|Qt::Key_Y) );
|
||||||
aTB->addAction(anAct);
|
aTB->addAction(anAct);
|
||||||
|
|
||||||
aTB->addSeparator();
|
aTB->addSeparator();
|
||||||
|
|
||||||
QPixmap aNewSectImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_NEW_SECTION")));
|
anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectionPixmap, tr("NEW_SECTION_TLT"),
|
||||||
anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectImage, tr("NEW_SECTION_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_N) );
|
QKeySequence(Qt::ControlModifier|Qt::Key_N) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) );
|
||||||
aTB->addAction(anAct);
|
aTB->addAction(anAct);
|
||||||
|
|
||||||
anAct = createAction( INSERT_SECTION_BEFORE_ID, tr("INSERT_SECTION_BEFORE"), QPixmap(), tr("INSERT_SECTION_BEFORE_TLT"),
|
anAct = createAction( INSERT_SECTION_BEFORE_ID, tr("INSERT_SECTION_BEFORE"), QPixmap(),
|
||||||
|
tr("INSERT_SECTION_BEFORE_TLT"),
|
||||||
QKeySequence(Qt::ControlModifier | Qt::Key_Insert ) );
|
QKeySequence(Qt::ControlModifier | Qt::Key_Insert ) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionBefore()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionBefore()) );
|
||||||
|
|
||||||
anAct = createAction( INSERT_SECTION_AFTER_ID, tr("INSERT_SECTION_AFTER"), QPixmap(), tr("INSERT_SECTION_AFTER_TLT"),
|
anAct = createAction( INSERT_SECTION_AFTER_ID, tr("INSERT_SECTION_AFTER"), QPixmap(),
|
||||||
|
tr("INSERT_SECTION_AFTER_TLT"),
|
||||||
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Insert ) );
|
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Insert ) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionAfter()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionAfter()) );
|
||||||
|
|
||||||
QPixmap aNewPointImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_NEW_POINT")));
|
anAct = createAction( NEW_POINT_ID, tr("NEW_POINT"), aNewPointPixmap, tr("NEW_POINT_TLT"),
|
||||||
anAct = createAction( NEW_POINT_ID, tr("NEW_POINT"), aNewPointImage, tr("NEW_POINT_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_P) );
|
QKeySequence(Qt::ControlModifier|Qt::Key_P) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onNewPoint()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onNewPoint()) );
|
||||||
aTB->addAction(anAct);
|
aTB->addAction(anAct);
|
||||||
aTB->addSeparator();
|
aTB->addSeparator();
|
||||||
|
|
||||||
anAct = createAction( INSERT_POINT_BEFORE_ID, tr("INSERT_POINT_BEFORE"), QPixmap(), tr("INSERT_POINT_BEFORE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_B) );
|
anAct = createAction( INSERT_POINT_BEFORE_ID, tr("INSERT_POINT_BEFORE"), QPixmap(),
|
||||||
|
tr("INSERT_POINT_BEFORE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_B) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointBefore()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointBefore()) );
|
||||||
|
|
||||||
anAct = createAction( INSERT_POINT_AFTER_ID, tr("INSERT_POINT_AFTER"), QPixmap(), tr("INSERT_POINT_AFTER_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_M) );
|
anAct = createAction( INSERT_POINT_AFTER_ID, tr("INSERT_POINT_AFTER"), QPixmap(),
|
||||||
|
tr("INSERT_POINT_AFTER_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_M) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointAfter()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointAfter()) );
|
||||||
|
|
||||||
anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_W) );
|
anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"),
|
||||||
|
QKeySequence(Qt::ControlModifier|Qt::Key_W) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) );
|
||||||
|
|
||||||
anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), QPixmap(), tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) );
|
anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), QPixmap(),
|
||||||
|
tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) );
|
||||||
|
|
||||||
QPixmap aPolylineImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"),
|
||||||
anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"), aPolylineImage, tr("SET_POLYLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_E) );
|
aPolylinePixmap, tr("SET_POLYLINE_TLT"),
|
||||||
|
QKeySequence(Qt::ControlModifier|Qt::Key_E) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) );
|
||||||
|
|
||||||
QPixmap aSplineImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), aSplinePixmap,
|
||||||
anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), aSplineImage, tr("SET_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
|
tr("SET_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
|
||||||
|
|
||||||
QPixmap aRemoveImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_DELETE")));
|
anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"),
|
||||||
anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemoveImage, tr("REMOVE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );
|
QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
|
||||||
aTB->addAction(anAct);
|
aTB->addAction(anAct);
|
||||||
aTB->addSeparator();
|
aTB->addSeparator();
|
||||||
|
|
||||||
QPixmap aJoinImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_JOIN")));
|
anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"),
|
||||||
anAct = createAction( JOIN_ID, tr("JOIN"), aJoinImage, tr("JOIN_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
|
QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
|
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
|
||||||
aTB->addAction(anAct);
|
aTB->addAction(anAct);
|
||||||
aTB->addSeparator();
|
aTB->addSeparator();
|
||||||
|
|
||||||
QPixmap aStepUpImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP")));
|
anAct = createAction( UP_ID, tr("STEP_UP"), aStepUpPixmap, tr("STEP_UP_TLT"),
|
||||||
anAct = createAction( UP_ID, tr("STEP_UP"), aStepUpImage, tr("STEP_UP_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Up ) );
|
QKeySequence(Qt::ControlModifier|Qt::Key_Up ) );
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveUp()) );
|
connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveUp()) );
|
||||||
aTB->addAction(anAct);
|
aTB->addAction(anAct);
|
||||||
|
|
||||||
QPixmap aStepDownImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN")));
|
anAct = createAction( DOWN_ID, tr("STEP_DOWN"), aStepDownPixmap, tr("STEP_DOWN"),
|
||||||
anAct = createAction( DOWN_ID, tr("STEP_DOWN"), aStepDownImage, tr("STEP_DOWN_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Down ) );
|
QKeySequence(Qt::ControlModifier|Qt::Key_Down ) );
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveDown()) );
|
connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveDown()) );
|
||||||
aTB->addAction(anAct);
|
aTB->addAction(anAct);
|
||||||
|
|
||||||
anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"), QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
|
anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"),
|
||||||
|
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
|
connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
|
||||||
|
|
||||||
anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"), QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
|
anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"),
|
||||||
|
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
|
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
|
||||||
|
|
||||||
QVBoxLayout* aSectLayout = new QVBoxLayout();
|
QVBoxLayout* aSectLayout = new QVBoxLayout();
|
||||||
@ -139,294 +167,337 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
|||||||
onSelectionChanged();
|
onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CurveCreator_Widget::setCurve( CurveCreator_Curve* theCurve )
|
||||||
|
{
|
||||||
|
if( myEdit != NULL ){
|
||||||
|
delete myEdit;
|
||||||
|
myEdit = NULL;
|
||||||
|
}
|
||||||
|
myCurve = theCurve;
|
||||||
|
mySectionView->setCurve(myCurve);
|
||||||
|
if( myCurve != NULL ){
|
||||||
|
myEdit = new CurveCreator_CurveEditor(myCurve);
|
||||||
|
}
|
||||||
|
onSelectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onSelectionChanged()
|
void CurveCreator_Widget::onSelectionChanged()
|
||||||
{
|
{
|
||||||
QList<ActionId> anEnabledAct;
|
QList<ActionId> anEnabledAct;
|
||||||
|
if( myCurve ){
|
||||||
anEnabledAct << NEW_SECTION_ID;
|
anEnabledAct << NEW_SECTION_ID;
|
||||||
int aSectCnt = myCurve->getNbPoints();
|
int aSectCnt = myCurve->getNbPoints();
|
||||||
if( aSectCnt > 0 )
|
if( aSectCnt > 0 )
|
||||||
anEnabledAct << CLEAR_ALL_ID;
|
anEnabledAct << CLEAR_ALL_ID;
|
||||||
if( aSectCnt > 1 )
|
if( aSectCnt > 1 )
|
||||||
anEnabledAct << JOIN_ALL_ID;
|
anEnabledAct << JOIN_ALL_ID;
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||||
QList< QPair< int, int > > aSelPoints = mySectionView->getSelectedPoints();
|
QList< QPair< int, int > > aSelPoints = mySectionView->getSelectedPoints();
|
||||||
CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType();
|
CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType();
|
||||||
switch( aSelType ){
|
switch( aSelType ){
|
||||||
case CurveCreator_TreeView::ST_NOSEL:{
|
case CurveCreator_TreeView::ST_NOSEL:{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CurveCreator_TreeView::ST_SECTIONS:{
|
case CurveCreator_TreeView::ST_SECTIONS:{
|
||||||
if( aSelSections.size() > 1 ){
|
if( aSelSections.size() > 1 ){
|
||||||
anEnabledAct << JOIN_ID;
|
anEnabledAct << JOIN_ID;
|
||||||
}
|
}
|
||||||
if( aSelSections[0] > 0 ){
|
if( aSelSections[0] > 0 ){
|
||||||
anEnabledAct << UP_ID;
|
anEnabledAct << UP_ID;
|
||||||
}
|
}
|
||||||
if( aSelSections.size() == 1 ){
|
if( aSelSections.size() == 1 ){
|
||||||
anEnabledAct << NEW_POINT_ID << INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID;
|
anEnabledAct << NEW_POINT_ID << INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID;
|
||||||
}
|
}
|
||||||
if( aSelSections[ aSelSections.size() - 1 ] < ( myCurve->getNbSections() - 1 ) ){
|
if( aSelSections[ aSelSections.size() - 1 ] < ( myCurve->getNbSections() - 1 ) ){
|
||||||
anEnabledAct << DOWN_ID;
|
anEnabledAct << DOWN_ID;
|
||||||
}
|
}
|
||||||
anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
|
anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CurveCreator_TreeView::ST_POINTS_ONE_SECTION:{
|
case CurveCreator_TreeView::ST_POINTS_ONE_SECTION:{
|
||||||
if( aSelPoints[0].second > 0 ){
|
if( aSelPoints[0].second > 0 ){
|
||||||
anEnabledAct << UP_ID;
|
anEnabledAct << UP_ID;
|
||||||
}
|
}
|
||||||
int aLastIndex = aSelPoints.size()-1;
|
int aLastIndex = aSelPoints.size()-1;
|
||||||
int aSect = aSelPoints[0].first;
|
int aSect = aSelPoints[0].first;
|
||||||
if( aSelPoints[aLastIndex].second < (myCurve->getNbPoints(aSect) - 1)){
|
if( aSelPoints[aLastIndex].second < (myCurve->getNbPoints(aSect) - 1)){
|
||||||
anEnabledAct << DOWN_ID;
|
anEnabledAct << DOWN_ID;
|
||||||
}
|
}
|
||||||
if( aSelPoints.size() == 1){
|
if( aSelPoints.size() == 1){
|
||||||
anEnabledAct << INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
|
anEnabledAct << INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int aSelObjsCnt = aSelPoints.size() + aSelSections.size();
|
int aSelObjsCnt = aSelPoints.size() + aSelSections.size();
|
||||||
if( aSelObjsCnt > 0 ){
|
if( aSelObjsCnt > 0 ){
|
||||||
anEnabledAct << REMOVE_ID;
|
anEnabledAct << REMOVE_ID;
|
||||||
}
|
}
|
||||||
if( myCurve->getNbSections() > 0 ){
|
if( (myCurve->getNbSections() + myCurve->getNbPoints()) > 0 ){
|
||||||
anEnabledAct << REMOVE_ALL_ID;
|
anEnabledAct << REMOVE_ALL_ID;
|
||||||
}
|
}
|
||||||
if( myCurve->getNbSections() > 1 ){
|
if( myCurve->getNbSections() > 1 ){
|
||||||
anEnabledAct << JOIN_ALL_ID;
|
anEnabledAct << JOIN_ALL_ID;
|
||||||
}
|
}
|
||||||
QList<ActionId> anIds = myActionMap.keys();
|
}
|
||||||
for( int i = 0 ; i < anIds.size() ; i++ ){
|
QList<ActionId> anIds = myActionMap.keys();
|
||||||
if( myActionMap.contains(anIds[i]) ){
|
for( int i = 0 ; i < anIds.size() ; i++ ){
|
||||||
if( anEnabledAct.contains(anIds[i]) ){
|
if( myActionMap.contains(anIds[i]) ){
|
||||||
myActionMap[anIds[i]]->setEnabled(true);
|
if( anEnabledAct.contains(anIds[i]) ){
|
||||||
}
|
myActionMap[anIds[i]]->setEnabled(true);
|
||||||
else{
|
}
|
||||||
myActionMap[anIds[i]]->setEnabled(false);
|
else{
|
||||||
}
|
myActionMap[anIds[i]]->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onNewPoint()
|
void CurveCreator_Widget::onNewPoint()
|
||||||
{
|
{
|
||||||
mySection= -1;
|
if( !myEdit )
|
||||||
myPointNum = -1;
|
return;
|
||||||
QList<int> aSelSection = mySectionView->getSelectedSections();
|
mySection= -1;
|
||||||
if( aSelSection.size() > 0 ){
|
myPointNum = -1;
|
||||||
mySection = aSelSection[0];
|
QList<int> aSelSection = mySectionView->getSelectedSections();
|
||||||
}
|
if( aSelSection.size() > 0 ){
|
||||||
else{
|
mySection = aSelSection[0];
|
||||||
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
|
}
|
||||||
if( aSelPoints.size() > 0 ){
|
else{
|
||||||
mySection = aSelPoints[0].first;
|
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
|
||||||
myPointNum = aSelPoints[0].second + 1;
|
if( aSelPoints.size() > 0 ){
|
||||||
}
|
mySection = aSelPoints[0].first;
|
||||||
}
|
myPointNum = aSelPoints[0].second + 1;
|
||||||
QString aSectName;
|
|
||||||
if( mySection < 0 ){
|
|
||||||
mySection = myCurve->getNbSections() - 1;
|
|
||||||
}
|
|
||||||
aSectName = QString::fromStdString( myCurve->getSectionName(mySection));
|
|
||||||
if( myPointNum < 0 ){
|
|
||||||
myPointNum = myCurve->getNbPoints(mySection);
|
|
||||||
}
|
|
||||||
myNewPointEditor->clear();
|
|
||||||
myNewPointEditor->setEditMode(false);
|
|
||||||
myNewPointEditor->setSectionName(aSectName);
|
|
||||||
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
|
||||||
onAddNewPoint();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
QString aSectName;
|
||||||
|
if( mySection < 0 ){
|
||||||
|
mySection = myCurve->getNbSections() - 1;
|
||||||
|
}
|
||||||
|
aSectName = QString::fromStdString( myCurve->getSectionName(mySection));
|
||||||
|
if( myPointNum < 0 ){
|
||||||
|
myPointNum = myCurve->getNbPoints(mySection);
|
||||||
|
}
|
||||||
|
myNewPointEditor->clear();
|
||||||
|
myNewPointEditor->setEditMode(false);
|
||||||
|
myNewPointEditor->setSectionName(aSectName);
|
||||||
|
myNewPointEditor->setDimension(myCurve->getDimension());
|
||||||
|
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
||||||
|
onAddNewPoint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onAddNewPoint()
|
void CurveCreator_Widget::onAddNewPoint()
|
||||||
{
|
{
|
||||||
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
|
if( !myEdit )
|
||||||
myEdit->insertPoints(aCoords, mySection, myPointNum );
|
return;
|
||||||
mySectionView->pointsAdded( mySection, myPointNum );
|
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
|
||||||
myNewPointEditor->clear();
|
myEdit->insertPoints(aCoords, mySection, myPointNum );
|
||||||
myPointNum++;
|
mySectionView->pointsAdded( mySection, myPointNum );
|
||||||
|
myNewPointEditor->clear();
|
||||||
|
myPointNum++;
|
||||||
|
onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onNewSection()
|
void CurveCreator_Widget::onNewSection()
|
||||||
{
|
{
|
||||||
myNewSectionEditor->clear();
|
if( !myEdit )
|
||||||
myNewSectionEditor->setEditMode(false);
|
return;
|
||||||
QString aSectName = QString( myCurve->getUnicSectionName().c_str() );
|
myNewSectionEditor->clear();
|
||||||
myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );
|
myNewSectionEditor->setEditMode(false);
|
||||||
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
QString aSectName = QString( myCurve->getUnicSectionName().c_str() );
|
||||||
onAddNewSection();
|
myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );
|
||||||
}
|
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
||||||
|
onAddNewSection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onAddNewSection()
|
void CurveCreator_Widget::onAddNewSection()
|
||||||
{
|
{
|
||||||
CurveCreator::Coordinates aCoords;
|
if( !myEdit )
|
||||||
myEdit->addSection( myNewSectionEditor->getName().toStdString(), myNewSectionEditor->getSectionType(),
|
return;
|
||||||
myNewSectionEditor->isClosed(), aCoords );
|
CurveCreator::Coordinates aCoords;
|
||||||
mySectionView->sectionAdded( mySection );
|
myEdit->addSection( myNewSectionEditor->getName().toStdString(), myNewSectionEditor->getSectionType(),
|
||||||
QString aNewName = QString(myCurve->getUnicSectionName().c_str());
|
myNewSectionEditor->isClosed(), aCoords );
|
||||||
myNewSectionEditor->setSectionName(aNewName);
|
mySectionView->sectionAdded( mySection );
|
||||||
mySection++;
|
QString aNewName = QString(myCurve->getUnicSectionName().c_str());
|
||||||
|
myNewSectionEditor->setSectionName(aNewName);
|
||||||
|
mySection++;
|
||||||
|
onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theName,
|
QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
|
||||||
const QPixmap& theImage, const QString& theToolTip,
|
const QString& theToolTip, const QKeySequence& theShortcut )
|
||||||
const QKeySequence& theShortcut )
|
|
||||||
{
|
{
|
||||||
QAction* anAct = new QAction(theName,this);
|
QAction* anAct = new QAction(theName,this);
|
||||||
if( !theImage.isNull() ){
|
if( !theImage.isNull() ){
|
||||||
anAct->setIcon(theImage);
|
anAct->setIcon(theImage);
|
||||||
}
|
}
|
||||||
anAct->setShortcut(theShortcut);
|
anAct->setShortcut(theShortcut);
|
||||||
anAct->setToolTip(theToolTip);
|
anAct->setToolTip(theToolTip);
|
||||||
myActionMap[theId] = anAct;
|
myActionMap[theId] = anAct;
|
||||||
return anAct;
|
return anAct;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* CurveCreator_Widget::getAction(ActionId theId)
|
QAction* CurveCreator_Widget::getAction(ActionId theId)
|
||||||
{
|
{
|
||||||
if( myActionMap.contains(theId) )
|
if( myActionMap.contains(theId) )
|
||||||
return myActionMap[theId];
|
return myActionMap[theId];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onEditSection( int theSection )
|
void CurveCreator_Widget::onEditSection( int theSection )
|
||||||
{
|
{
|
||||||
mySection = theSection;
|
if( !myEdit )
|
||||||
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
return;
|
||||||
bool isClosed = myCurve->isClosed(theSection);
|
mySection = theSection;
|
||||||
CurveCreator::Type aType = myCurve->getType(theSection);
|
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
||||||
myNewSectionEditor->setEditMode(true);
|
bool isClosed = myCurve->isClosed(theSection);
|
||||||
myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType );
|
CurveCreator::Type aType = myCurve->getType(theSection);
|
||||||
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
myNewSectionEditor->setEditMode(true);
|
||||||
QString aName = myNewSectionEditor->getName();
|
myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType );
|
||||||
bool isClosed = myNewSectionEditor->isClosed();
|
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
||||||
CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
|
QString aName = myNewSectionEditor->getName();
|
||||||
myEdit->setClosed( isClosed, mySection );
|
bool isClosed = myNewSectionEditor->isClosed();
|
||||||
myEdit->setName( aName.toStdString(), mySection );
|
CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
|
||||||
myEdit->setType( aSectType, mySection );
|
myEdit->setClosed( isClosed, mySection );
|
||||||
mySectionView->sectionChanged(mySection);
|
myEdit->setName( aName.toStdString(), mySection );
|
||||||
}
|
myEdit->setType( aSectType, mySection );
|
||||||
|
mySectionView->sectionChanged(mySection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onEditPoint( int theSection, int thePoint )
|
void CurveCreator_Widget::onEditPoint( int theSection, int thePoint )
|
||||||
{
|
{
|
||||||
if( !myNewPointEditor ){
|
if( !myNewPointEditor )
|
||||||
}
|
return;
|
||||||
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
if( !myEdit )
|
||||||
myNewPointEditor->setEditMode(true);
|
return;
|
||||||
myNewPointEditor->setSectionName(aSectName);
|
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
||||||
CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint);
|
myNewPointEditor->setEditMode(true);
|
||||||
myNewPointEditor->setCoordinates(aCoords);
|
myNewPointEditor->setSectionName(aSectName);
|
||||||
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
myNewPointEditor->setDimension( myCurve->getDimension() );
|
||||||
aCoords = myNewPointEditor->getCoordinates();
|
CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint);
|
||||||
myEdit->setCoordinates(aCoords, theSection, thePoint);
|
myNewPointEditor->setCoordinates(aCoords);
|
||||||
mySectionView->pointDataChanged(theSection, thePoint );
|
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
||||||
}
|
aCoords = myNewPointEditor->getCoordinates();
|
||||||
|
myEdit->setCoordinates(aCoords, theSection, thePoint);
|
||||||
|
mySectionView->pointDataChanged(theSection, thePoint );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onJoin()
|
void CurveCreator_Widget::onJoin()
|
||||||
{
|
{
|
||||||
QList<int> aSections = mySectionView->getSelectedSections();
|
if( !myEdit )
|
||||||
if( aSections.size() == 0 ){
|
return;
|
||||||
return;
|
QList<int> aSections = mySectionView->getSelectedSections();
|
||||||
}
|
if( aSections.size() == 0 ){
|
||||||
int aMainSect = aSections[0];
|
return;
|
||||||
int aMainSectSize = myCurve->getNbPoints(aMainSect);
|
}
|
||||||
for( int i = 1 ; i < aSections.size() ; i++ ){
|
int aMainSect = aSections[0];
|
||||||
int aSectNum = aSections[i] - (i-1);
|
int aMainSectSize = myCurve->getNbPoints(aMainSect);
|
||||||
myEdit->join( aMainSect, aSectNum );
|
for( int i = 1 ; i < aSections.size() ; i++ ){
|
||||||
mySectionView->sectionsRemoved( aSectNum );
|
int aSectNum = aSections[i] - (i-1);
|
||||||
}
|
myEdit->join( aMainSect, aSectNum );
|
||||||
int aNewSectSize = myCurve->getNbPoints(aMainSect);
|
mySectionView->sectionsRemoved( aSectNum );
|
||||||
if( aNewSectSize != aMainSectSize )
|
}
|
||||||
mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );
|
int aNewSectSize = myCurve->getNbPoints(aMainSect);
|
||||||
|
if( aNewSectSize != aMainSectSize )
|
||||||
|
mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onRemove()
|
void CurveCreator_Widget::onRemove()
|
||||||
{
|
{
|
||||||
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
|
if( !myEdit )
|
||||||
int aCurrSect=-1;
|
return;
|
||||||
int aRemoveCnt = 0;
|
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
|
||||||
for( int i = 0 ; i < aSelPoints.size() ; i++ ){
|
int aCurrSect=-1;
|
||||||
if( aCurrSect != aSelPoints[i].first ){
|
int aRemoveCnt = 0;
|
||||||
aRemoveCnt = 0;
|
for( int i = 0 ; i < aSelPoints.size() ; i++ ){
|
||||||
aCurrSect = aSelPoints[i].first;
|
if( aCurrSect != aSelPoints[i].first ){
|
||||||
}
|
aRemoveCnt = 0;
|
||||||
int aPntIndx = aSelPoints[i].second - aRemoveCnt;
|
aCurrSect = aSelPoints[i].first;
|
||||||
myEdit->removePoints(aCurrSect,aPntIndx, 1);
|
|
||||||
mySectionView->pointsRemoved( aCurrSect, aPntIndx );
|
|
||||||
aRemoveCnt++;
|
|
||||||
}
|
}
|
||||||
QList<int> aSections = mySectionView->getSelectedSections();
|
int aPntIndx = aSelPoints[i].second - aRemoveCnt;
|
||||||
for( int i = 0 ; i < aSections.size() ; i++ ){
|
myEdit->removePoints(aCurrSect,aPntIndx, 1);
|
||||||
int aSectNum = aSections[i] - (i);
|
mySectionView->pointsRemoved( aCurrSect, aPntIndx );
|
||||||
myEdit->removeSection( aSectNum );
|
aRemoveCnt++;
|
||||||
mySectionView->sectionsRemoved( aSectNum );
|
}
|
||||||
}
|
QList<int> aSections = mySectionView->getSelectedSections();
|
||||||
mySectionView->clearSelection();
|
for( int i = 0 ; i < aSections.size() ; i++ ){
|
||||||
|
int aSectNum = aSections[i] - (i);
|
||||||
|
myEdit->removeSection( aSectNum );
|
||||||
|
mySectionView->sectionsRemoved( aSectNum );
|
||||||
|
}
|
||||||
|
mySectionView->clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onMoveUp()
|
void CurveCreator_Widget::onMoveUp()
|
||||||
{
|
{
|
||||||
if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){
|
if( !myEdit )
|
||||||
//Move sections
|
return;
|
||||||
QList<int> aSections = mySectionView->getSelectedSections();
|
if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){
|
||||||
for( int i = 0 ; i < aSections.size() ; i++ ){
|
//Move sections
|
||||||
int anIndx = aSections[i];
|
QList<int> aSections = mySectionView->getSelectedSections();
|
||||||
myEdit->moveSection( anIndx, anIndx-1);
|
for( int i = 0 ; i < aSections.size() ; i++ ){
|
||||||
mySectionView->sectionsSwapped( anIndx, -1 );
|
int anIndx = aSections[i];
|
||||||
}
|
myEdit->moveSection( anIndx, anIndx-1);
|
||||||
|
mySectionView->sectionsSwapped( anIndx, -1 );
|
||||||
}
|
}
|
||||||
else{
|
}
|
||||||
//Move points
|
else{
|
||||||
QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();
|
//Move points
|
||||||
for( int i = 0 ; i < aPoints.size() ; i++ ){
|
QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();
|
||||||
int aSection = aPoints[i].first;
|
for( int i = 0 ; i < aPoints.size() ; i++ ){
|
||||||
int aPoint = aPoints[i].second;
|
int aSection = aPoints[i].first;
|
||||||
myEdit->movePoint(aSection, aPoint, aPoint-2);
|
int aPoint = aPoints[i].second;
|
||||||
mySectionView->pointsSwapped( aSection, aPoint, -1 );
|
myEdit->movePoint(aSection, aPoint, aPoint-2);
|
||||||
}
|
mySectionView->pointsSwapped( aSection, aPoint, -1 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onMoveDown()
|
void CurveCreator_Widget::onMoveDown()
|
||||||
{
|
{
|
||||||
if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){
|
if( !myEdit )
|
||||||
//Move sections
|
return;
|
||||||
QList<int> aSections = mySectionView->getSelectedSections();
|
if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){
|
||||||
for( int i = aSections.size()-1 ; i >=0 ; i-- ){
|
//Move sections
|
||||||
int anIndx = aSections[i];
|
QList<int> aSections = mySectionView->getSelectedSections();
|
||||||
myEdit->moveSection( anIndx, anIndx+1);
|
for( int i = aSections.size()-1 ; i >=0 ; i-- ){
|
||||||
mySectionView->sectionsSwapped( anIndx, 1 );
|
int anIndx = aSections[i];
|
||||||
}
|
myEdit->moveSection( anIndx, anIndx+1);
|
||||||
|
mySectionView->sectionsSwapped( anIndx, 1 );
|
||||||
}
|
}
|
||||||
else{
|
}
|
||||||
//Move points
|
else{
|
||||||
QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();
|
//Move points
|
||||||
for( int i = aPoints.size() - 1; i >= 0 ; i-- ){
|
QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();
|
||||||
int aSection = aPoints[i].first;
|
for( int i = aPoints.size() - 1; i >= 0 ; i-- ){
|
||||||
int aPoint = aPoints[i].second;
|
int aSection = aPoints[i].first;
|
||||||
myEdit->movePoint(aSection, aPoint, aPoint+1);
|
int aPoint = aPoints[i].second;
|
||||||
mySectionView->pointsSwapped( aSection, aPoint, 1 );
|
myEdit->movePoint(aSection, aPoint, aPoint+1);
|
||||||
}
|
mySectionView->pointsSwapped( aSection, aPoint, 1 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onClearAll()
|
void CurveCreator_Widget::onClearAll()
|
||||||
{
|
{
|
||||||
myEdit->clear();
|
if( !myEdit )
|
||||||
mySectionView->reset();
|
return;
|
||||||
onSelectionChanged();
|
myEdit->clear();
|
||||||
|
mySectionView->reset();
|
||||||
|
onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onJoinAll()
|
void CurveCreator_Widget::onJoinAll()
|
||||||
{
|
{
|
||||||
myEdit->join();
|
if( !myEdit )
|
||||||
mySectionView->reset();
|
return;
|
||||||
onSelectionChanged();
|
myEdit->join();
|
||||||
|
mySectionView->reset();
|
||||||
|
onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onInsertSectionBefore()
|
void CurveCreator_Widget::onInsertSectionBefore()
|
||||||
@ -456,77 +527,85 @@ void CurveCreator_Widget::onUndoSettings()
|
|||||||
|
|
||||||
void CurveCreator_Widget::onSetSpline()
|
void CurveCreator_Widget::onSetSpline()
|
||||||
{
|
{
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
if( !myEdit )
|
||||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
return;
|
||||||
myEdit->setType(CurveCreator::BSpline, aSelSections[i]);
|
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||||
mySectionView->sectionChanged(aSelSections[i]);
|
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
||||||
}
|
myEdit->setType(CurveCreator::BSpline, aSelSections[i]);
|
||||||
|
mySectionView->sectionChanged(aSelSections[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onSetPolyline()
|
void CurveCreator_Widget::onSetPolyline()
|
||||||
{
|
{
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
if( !myEdit )
|
||||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
return;
|
||||||
myEdit->setType(CurveCreator::Polyline, aSelSections[i]);
|
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||||
mySectionView->sectionChanged(aSelSections[i]);
|
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
||||||
}
|
myEdit->setType(CurveCreator::Polyline, aSelSections[i]);
|
||||||
|
mySectionView->sectionChanged(aSelSections[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onCloseSections()
|
void CurveCreator_Widget::onCloseSections()
|
||||||
{
|
{
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
if( !myEdit )
|
||||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
return;
|
||||||
myEdit->setClosed(true, aSelSections[i]);
|
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||||
mySectionView->sectionChanged(aSelSections[i]);
|
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
||||||
}
|
myEdit->setClosed(true, aSelSections[i]);
|
||||||
|
mySectionView->sectionChanged(aSelSections[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onUncloseSections()
|
void CurveCreator_Widget::onUncloseSections()
|
||||||
{
|
{
|
||||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
if( !myEdit )
|
||||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
return;
|
||||||
myEdit->setClosed(false, aSelSections[i]);
|
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||||
mySectionView->sectionChanged(aSelSections[i]);
|
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
||||||
}
|
myEdit->setClosed(false, aSelSections[i]);
|
||||||
|
mySectionView->sectionChanged(aSelSections[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveCreator_Widget::onContextMenu( QPoint thePoint )
|
void CurveCreator_Widget::onContextMenu( QPoint thePoint )
|
||||||
{
|
{
|
||||||
QList<ActionId> aContextActions;
|
QList<ActionId> aContextActions;
|
||||||
aContextActions << CLEAR_ALL_ID << JOIN_ALL_ID << SEPARATOR_ID <<
|
aContextActions << CLEAR_ALL_ID << JOIN_ALL_ID << SEPARATOR_ID <<
|
||||||
INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID << SEPARATOR_ID <<
|
INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID << SEPARATOR_ID <<
|
||||||
CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID <<
|
CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID <<
|
||||||
SET_SECTIONS_SPLINE_ID << SEPARATOR_ID <<
|
SET_SECTIONS_SPLINE_ID << SEPARATOR_ID <<
|
||||||
INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
|
INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
|
||||||
QPoint aGlPoint = mySectionView->mapToGlobal(thePoint);
|
QPoint aGlPoint = mySectionView->mapToGlobal(thePoint);
|
||||||
bool isVis = false;
|
bool isVis = false;
|
||||||
QList<ActionId> aResAct;
|
QList<ActionId> aResAct;
|
||||||
for( int i = 0 ; i < aContextActions.size() ; i++ ){
|
for( int i = 0 ; i < aContextActions.size() ; i++ ){
|
||||||
if( aContextActions[i] != SEPARATOR_ID ){
|
if( aContextActions[i] != SEPARATOR_ID ){
|
||||||
if( myActionMap.contains(aContextActions[i]) ){
|
if( myActionMap.contains(aContextActions[i]) ){
|
||||||
QAction* anAct = myActionMap[aContextActions[i]];
|
QAction* anAct = myActionMap[aContextActions[i]];
|
||||||
if( anAct->isEnabled() ){
|
if( anAct->isEnabled() ){
|
||||||
aResAct << aContextActions[i];
|
aResAct << aContextActions[i];
|
||||||
isVis = true;
|
isVis = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
aResAct << SEPARATOR_ID;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( !isVis )
|
else{
|
||||||
return;
|
aResAct << SEPARATOR_ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !isVis )
|
||||||
|
return;
|
||||||
|
|
||||||
QMenu* aMenu = new QMenu(this);
|
QMenu* aMenu = new QMenu(this);
|
||||||
for( int i = 0 ; i < aResAct.size() ; i++ ){
|
for( int i = 0 ; i < aResAct.size() ; i++ ){
|
||||||
if( aResAct[i] == SEPARATOR_ID ){
|
if( aResAct[i] == SEPARATOR_ID ){
|
||||||
aMenu->addSeparator();
|
aMenu->addSeparator();
|
||||||
}
|
|
||||||
else{
|
|
||||||
QAction* anAct = myActionMap[aResAct[i]];
|
|
||||||
aMenu->insertAction(NULL, anAct);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
aMenu->exec(aGlPoint);
|
else{
|
||||||
|
QAction* anAct = myActionMap[aResAct[i]];
|
||||||
|
aMenu->insertAction(NULL, anAct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aMenu->exec(aGlPoint);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,9 @@ public:
|
|||||||
explicit CurveCreator_Widget( QWidget* parent,
|
explicit CurveCreator_Widget( QWidget* parent,
|
||||||
CurveCreator_Curve *theCurve,
|
CurveCreator_Curve *theCurve,
|
||||||
Qt::WindowFlags fl=0 );
|
Qt::WindowFlags fl=0 );
|
||||||
|
|
||||||
|
void setCurve( CurveCreator_Curve* theCurve );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
Reference in New Issue
Block a user