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