return mySections.at(theISection)->myIsClosed;
}
+std::string CurveCreator_Curve::getSectionName(const int theISection) const
+{
+ return mySections.at(theISection)->myName;
+}
+
//=======================================================================
// function: setType
// purpose:
// purpose:
//=======================================================================
void CurveCreator_Curve::addSection
- (const CurveCreator::Type theType,
+ (const std::string& theName,
+ const CurveCreator::Type theType,
const bool theIsClosed,
const CurveCreator::Coordinates &thePoints)
{
CurveCreator_Section *aSection = new CurveCreator_Section;
+ std::string aName = theName;
+ if( aName.empty() ){
+ aName = getUnicSectionName();
+ }
+ aSection->myName = aName;
aSection->myType = theType;
aSection->myIsClosed = theIsClosed;
aSection->myPoints = thePoints;
}
}
+void CurveCreator_Curve::movePoint(const int theISection, const int theIPointFrom, const int theNewIndex)
+{
+ CurveCreator::Coordinates aCoords = getCoordinates(theISection, theIPointFrom );
+ insertPoints(aCoords, theISection, theNewIndex+1);
+ int aRemPntIndx = theIPointFrom;
+ if( theNewIndex < theIPointFrom )
+ aRemPntIndx++;
+ removePoints(theISection, aRemPntIndx, 1 );
+}
+
//=======================================================================
// function: removePoints
// purpose:
}
}
+/** Set name of the specified section.
+ */
+void CurveCreator_Curve::setName( const std::string& theName, const int theISection )
+{
+ if( ( theISection >= 0 ) && ( theISection < mySections.size() )){
+ mySections.at(theISection)->myName = theName;
+ }
+}
+
//=======================================================================
// function: moveSection
// purpose:
{
return theIPnt*myDimension;
}
+
+//=======================================================================
+// function: getUnicSectionName
+// purpose: return unic section name
+//=======================================================================
+std::string CurveCreator_Curve::getUnicSectionName()
+{
+ for( int i = 0 ; i < 1000000 ; i++ ){
+ char aBuffer[255];
+ sprintf( aBuffer, "Section_%d", i+1 );
+ std::string aName(aBuffer);
+ int j;
+ for( j = 0 ; j < mySections.size() ; j++ ){
+ if( mySections[j]->myName == aName )
+ break;
+ }
+ if( j == mySections.size() )
+ return aName;
+ }
+ return "";
+}
//! Get \93closed\94 flag of the specified section
bool isClosed(const int theISection) const;
+ //! Returns specifyed section name
+ std::string getSectionName(const int theISection) const;
+
+ /**
+ * Return unic section name
+ */
+ std::string getUnicSectionName();
protected:
/** Set type of the specified section (or all sections
(const CurveCreator::Coordinates &thePoints, const int theISection = -1);
//! Add a new section.
- void addSection (const CurveCreator::Type theType,
+ void addSection (const std::string &theName, const CurveCreator::Type theType,
const bool theIsClosed,
const CurveCreator::Coordinates &thePoints);
const int theIPnt,
const int theNbPoints = -1);
+ /** Move specified point within section to new position
+ */
+ void movePoint(const int theISection,
+ const int theIPointFrom,
+ const int theNewIndex);
+
//! Remove all sections.
void clear();
*/
void setClosed(const bool theIsClosed, const int theISection = -1);
+ /** Set name of the specified section.
+ */
+ void setName( const std::string& theName, const int theISection );
+
/** Move specified \a theISection to the specified position
* in the sections list.
*/
// purpose:
//=======================================================================
void CurveCreator_CurveEditor::addSection
- (const CurveCreator::Type theType,
+ (const std::string& theName, const CurveCreator::Type theType,
const bool theIsClosed,
const CurveCreator::Coordinates &thePoints)
{
}
// Update the curve.
- myPCurve->addSection(theType, theIsClosed, thePoints);
+ myPCurve->addSection(theName, theType, theIsClosed, thePoints);
}
}
}
}
+//=======================================================================
+// function: movePoints
+// purpose:
+//=======================================================================
+void CurveCreator_CurveEditor::movePoint(const int theISection,
+ const int theOrigIPnt,
+ const int theNewIPnt )
+{
+ myPCurve->movePoint(theISection, theOrigIPnt, theNewIPnt);
+}
+
//=======================================================================
// function: removePoints
// purpose:
}
}
+//=======================================================================
+// function: setName
+// purpose:
+//=======================================================================
+void CurveCreator_CurveEditor::setName(const std::string& theName,
+ const int theISection)
+{
+ myPCurve->setName( theName, theISection );
+}
+
//=======================================================================
// function: moveSection
// purpose:
*/
void setType(const CurveCreator::Type theType, const int theISection = -1);
+ /** Set section closed (or all sections
+ * if \a theISection is -1).
+ */
+ void setClosed(const bool theIsClosed, const int theISection);
+
+ /** Set section name (if theISection is invalid it is ignored).
+ */
+ void setName(const std::string& theName, const int theISection);
+
/** Add points to the specified section (or last section
* if \a theISection is -1).
*/
const int theISection = -1);
//! Add a new section.
- void addSection(const CurveCreator::Type theType,
+ void addSection(const std::string &theName, const CurveCreator::Type theType,
const bool theIsClosed,
const CurveCreator::Coordinates &thePoints);
const int theIPnt,
const int theNbPoints = -1);
+ /** Mobe point in \a theISection from given position \a theOrigIPnt
+ * to new position \a theNewIPnt.
+ */
+ void movePoint(const int theISection,
+ const int theOrigIPnt,
+ const int theNewIPnt );
+
//! Remove all sections.
void clear();
const int theISection,
const int theIPnt);
- /** Set \93closed\94 flag of the specified section (all sections if
- * \a theISection is -1).
- */
- void setClosed(const bool theIsClosed, const int theISection = -1);
-
/** Move specified \a theISection to the specified position
* in the sections list.
*/
+++ /dev/null
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_EditPntDlg.cxx
-// Created: Tue Jul 16 10:58:31 2013
-// Author: Sergey KHROMOV
-//
-
-
-#include <CurveCreator_EditPntDlg.h>
-#include <CurveCreator_PointItem.h>
-#include <QGroupBox>
-#include <QVBoxLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <QSpinBox>
-#include <QListWidget>
-
-
-//=======================================================================
-// function: Constructor
-// purpose:
-//=======================================================================
-CurveCreator_EditPntDlg::CurveCreator_EditPntDlg
- (QWidget* parent,
- const CurveCreator::Dimension theDimension)
- : QDialog (parent),
- myDimension (theDimension),
- myXSpn (NULL),
- myYSpn (NULL),
- myZSpn (NULL),
- myOkBtn (NULL),
- myCancelBtn (NULL)
-{
- setWindowTitle(tr("CC_EDIT_POINT_TITLE"));
-
- // Set Add/modify point group
- QGroupBox *aModifPntGrp =
- new QGroupBox(tr("CC_EDIT_POINT_MODIFY"));
- QGridLayout *aModifPntLO = new QGridLayout(aModifPntGrp);
- QLabel *aXLbl =
- new QLabel(tr("CC_EDIT_POINT_X"), aModifPntGrp);
- QLabel *aYLbl =
- new QLabel(tr("CC_EDIT_POINT_Y"), aModifPntGrp);
-
- aXLbl->setAlignment(Qt::AlignRight);
- aYLbl->setAlignment(Qt::AlignRight);
- myXSpn = new QDoubleSpinBox(aModifPntGrp);
- myYSpn = new QDoubleSpinBox(aModifPntGrp);
- aModifPntLO->setMargin(9);
- aModifPntLO->setSpacing(6);
- aModifPntLO->addWidget(aXLbl, 0, 0);
- aModifPntLO->addWidget(aYLbl, 1, 0);
- aModifPntLO->addWidget(myXSpn, 0, 1);
- aModifPntLO->addWidget(myYSpn, 1, 1);
-
- if (myDimension == CurveCreator::Dim3d) {
- QLabel *aZLbl = new QLabel(tr("CC_EDIT_POINT_Z"), aModifPntGrp);
-
- aZLbl->setAlignment(Qt::AlignRight);
- myZSpn = new QDoubleSpinBox(aModifPntGrp);
- aModifPntLO->addWidget(aZLbl, 2, 0);
- aModifPntLO->addWidget(myZSpn, 2, 1);
- }
-
- // Set OK/Cancel buttons group
- QGroupBox *anOkCancelGrp = new QGroupBox;
- QGridLayout *anOkCancelLO = new QGridLayout(anOkCancelGrp);
-
- myOkBtn = new QPushButton(tr("GEOM_BUT_OK"), anOkCancelGrp);
- myCancelBtn = new QPushButton(tr("GEOM_BUT_CANCEL"), anOkCancelGrp);
- anOkCancelLO->setMargin(9);
- anOkCancelLO->setSpacing(6);
- anOkCancelLO->addWidget(myOkBtn, 0, 0);
- anOkCancelLO->addWidget(myCancelBtn, 0, 1);
-
- // Set main group
- QGroupBox *aMainGrp = new QGroupBox;
- QVBoxLayout *aMainLO = new QVBoxLayout(aMainGrp);
-
- aMainLO->addWidget(aModifPntGrp);
- aMainLO->addWidget(anOkCancelGrp);
-
- setLayout(aMainLO);
-
- init();
-}
-
-//=======================================================================
-// function: Destructor
-// purpose:
-//=======================================================================
-CurveCreator_EditPntDlg::~CurveCreator_EditPntDlg()
-{
-}
-
-//=======================================================================
-// function: setPoint
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntDlg::setPoint
- (const CurveCreator::Coordinates &thePoint)
-{
- myPoint = thePoint;
-
- if (myPoint.size() == myDimension) {
- myXSpn->setValue(myPoint[0]);
- myYSpn->setValue(myPoint[1]);
-
- if (myDimension == CurveCreator::Dim3d) {
- myZSpn->setValue(myPoint[2]);
- }
- }
-}
-
-//=======================================================================
-// function: getPoint
-// purpose:
-//=======================================================================
-const CurveCreator::Coordinates &CurveCreator_EditPntDlg::getPoint() const
-{
- return myPoint;
-}
-
-//=======================================================================
-// function: init
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntDlg::init()
-{
- // Init spin boxes.
- initSpinBox(myXSpn);
- initSpinBox(myYSpn);
-
- if (myDimension == CurveCreator::Dim3d) {
- initSpinBox(myZSpn);
- }
-
- // Init buttons.
- myOkBtn->setDefault(true);
-
- connect(myOkBtn, SIGNAL(clicked()), this, SLOT(accept()));
- connect(myCancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
-
- setTabOrder();
-}
-
-//=======================================================================
-// function: initSpinBox
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntDlg::initSpinBox(QDoubleSpinBox *theSpinBox)
-{
- const double aCoordMin = -1.e+15;
- const double aCoordMax = 1.e+15;
- const double aStep = 10;
- const int aPrecision = 6;
-
- theSpinBox->setDecimals( qAbs( aPrecision ) );
- theSpinBox->setRange(aCoordMin, aCoordMax);
- theSpinBox->setSingleStep(aStep);
- theSpinBox->setValue(0.);
-}
-
-//=======================================================================
-// function: setTabOrder
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntDlg::setTabOrder()
-{
- QWidget::setTabOrder(myXSpn, myYSpn);
-
- if (myDimension == CurveCreator::Dim3d) {
- QWidget::setTabOrder(myYSpn, myZSpn);
- QWidget::setTabOrder(myZSpn, myOkBtn);
- } else {
- QWidget::setTabOrder(myYSpn, myOkBtn);
- }
-
- QWidget::setTabOrder(myOkBtn, myCancelBtn);
-}
-
-//=======================================================================
-// function: accept
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntDlg::accept()
-{
- // Copy point
- myPoint.clear();
- myPoint.push_back(myXSpn->value());
- myPoint.push_back(myYSpn->value());
-
- if (myDimension == CurveCreator::Dim3d) {
- myPoint.push_back(myZSpn->value());
- }
-
- QDialog::accept();
-}
+++ /dev/null
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_EditPntDlg.h
-// Created: Tue Jul 16 10:58:22 2013
-// Author: Sergey KHROMOV
-//
-
-#ifndef _CurveCreator_EditPntDlg_HeaderFile
-#define _CurveCreator_EditPntDlg_HeaderFile
-
-
-#include <QDialog>
-#include <CurveCreator.hxx>
-
-class QListWidget;
-class QDoubleSpinBox;
-class QPushButton;
-
-
-class CurveCreator_EditPntDlg : public QDialog
-{
- Q_OBJECT
-
-public:
-
- CurveCreator_EditPntDlg(QWidget* parent,
- const CurveCreator::Dimension theDimension);
-
- ~CurveCreator_EditPntDlg();
-
- void setPoint(const CurveCreator::Coordinates &thePoint);
-
- const CurveCreator::Coordinates &getPoint() const;
-
-private:
-
- void init();
-
- void initSpinBox(QDoubleSpinBox *theSpinBox);
-
- void setTabOrder();
-
-private slots:
-
- void accept();
-
-protected:
-
- CurveCreator::Dimension myDimension;
- CurveCreator::Coordinates myPoint;
- QDoubleSpinBox *myXSpn;
- QDoubleSpinBox *myYSpn;
- QDoubleSpinBox *myZSpn;
- QPushButton *myOkBtn;
- QPushButton *myCancelBtn;
-
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_EditPntsDlg.cxx
-// Created: Fri Jul 05 16:29:53 2013
-// Author: Sergey KHROMOV
-//
-
-
-#include <CurveCreator_EditPntsDlg.h>
-#include <CurveCreator_PointItem.h>
-#include <QGroupBox>
-#include <QVBoxLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <QSpinBox>
-#include <QListWidget>
-
-
-//=======================================================================
-// function: Constructor
-// purpose:
-//=======================================================================
-CurveCreator_EditPntsDlg::CurveCreator_EditPntsDlg
- (QWidget* parent, const CurveCreator::Dimension theDimension)
- : QDialog (parent),
- myDimension (theDimension),
- myPntsList (NULL),
- myXSpn (NULL),
- myYSpn (NULL),
- myZSpn (NULL),
- myAddBtn (NULL),
- myModifBtn (NULL),
- myRmBtn (NULL),
- myClearBtn (NULL),
- myPntUpBtn (NULL),
- myPntDownBtn (NULL),
- myOkBtn (NULL),
- myCancelBtn (NULL)
-{
- setWindowTitle(tr("CC_EDIT_POINTS_TITLE"));
-
- // Set Add/modify point group
- QGroupBox *aModifPntGrp =
- new QGroupBox(tr("CC_EDIT_POINTS_ADD_MODIFY"));
- QGridLayout *aModifPntLO = new QGridLayout(aModifPntGrp);
- QLabel *aXLbl =
- new QLabel(tr("CC_EDIT_POINTS_X"), aModifPntGrp);
- QLabel *aYLbl =
- new QLabel(tr("CC_EDIT_POINTS_Y"), aModifPntGrp);
-
- aXLbl->setAlignment(Qt::AlignRight);
- aYLbl->setAlignment(Qt::AlignRight);
- myXSpn = new QDoubleSpinBox(aModifPntGrp);
- myYSpn = new QDoubleSpinBox(aModifPntGrp);
- myAddBtn = new QPushButton(tr("CC_EDIT_POINTS_ADD"), aModifPntGrp);
- myModifBtn = new QPushButton(tr("CC_EDIT_POINTS_MODIFY"), aModifPntGrp);
- myRmBtn = new QPushButton(tr("CC_EDIT_POINTS_REMOVE"), aModifPntGrp);
- aModifPntLO->setMargin(9);
- aModifPntLO->setSpacing(6);
- aModifPntLO->addWidget(aXLbl, 0, 0);
- aModifPntLO->addWidget(aYLbl, 1, 0);
- aModifPntLO->addWidget(myXSpn, 0, 1);
- aModifPntLO->addWidget(myYSpn, 1, 1);
- aModifPntLO->addWidget(myAddBtn, 0, 2);
- aModifPntLO->addWidget(myModifBtn, 1, 2);
- aModifPntLO->addWidget(myRmBtn, 2, 2);
-
- if (myDimension == CurveCreator::Dim3d) {
- QLabel *aZLbl = new QLabel(tr("CC_EDIT_POINTS_Z"), aModifPntGrp);
-
- aZLbl->setAlignment(Qt::AlignRight);
- myZSpn = new QDoubleSpinBox(aModifPntGrp);
- aModifPntLO->addWidget(aZLbl, 2, 0);
- aModifPntLO->addWidget(myZSpn, 2, 1);
- }
-
- // Set Buttons group
- QGroupBox *aPntsGrp = new QGroupBox();
- QGridLayout *aPntsLO = new QGridLayout(aPntsGrp);
-
- myClearBtn = new QPushButton(tr("CC_EDIT_POINTS_CLEAR"), aModifPntGrp);
- myPntUpBtn = new QPushButton(tr("CC_EDIT_POINTS_UP"), aPntsGrp);
- myPntDownBtn = new QPushButton(tr("CC_EDIT_POINTS_DOWN"), aPntsGrp);
- myPntsList = new QListWidget(aPntsGrp);
- aPntsLO->setMargin(9);
- aPntsLO->setSpacing(6);
- aPntsLO->addWidget(myClearBtn, 0, 0);
- aPntsLO->addWidget(myPntUpBtn, 2, 4);
- aPntsLO->addWidget(myPntDownBtn, 3, 4);
- aPntsLO->addWidget(myPntsList, 1, 0, 4, 4);
-
- // Set OK/Cancel buttons group
- QGroupBox *anOkCancelGrp = new QGroupBox();
- QGridLayout *anOkCancelLO = new QGridLayout(anOkCancelGrp);
-
- myOkBtn = new QPushButton(tr("GEOM_BUT_OK"), anOkCancelGrp);
- myCancelBtn = new QPushButton(tr("GEOM_BUT_CANCEL"), anOkCancelGrp);
- anOkCancelLO->setMargin(9);
- anOkCancelLO->setSpacing(6);
- anOkCancelLO->addWidget(myOkBtn, 0, 3);
- anOkCancelLO->addWidget(myCancelBtn, 0, 4);
-
- // Set main group
- QGroupBox *aMainGrp = new QGroupBox;
- QVBoxLayout *aMainLO = new QVBoxLayout(aMainGrp);
-
- aMainLO->addWidget(aModifPntGrp);
- aMainLO->addWidget(aPntsGrp);
- aMainLO->addWidget(anOkCancelGrp);
-
- setLayout(aMainLO);
-
- init();
-}
-
-//=======================================================================
-// function: Destructor
-// purpose:
-//=======================================================================
-CurveCreator_EditPntsDlg::~CurveCreator_EditPntsDlg()
-{
-}
-
-//=======================================================================
-// function: setPoints
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::setPoints
- (const CurveCreator::Coordinates &thePoints)
-{
- myPoints = thePoints;
- updateEditList();
-}
-
-//=======================================================================
-// function: getPoints
-// purpose:
-//=======================================================================
-const CurveCreator::Coordinates &CurveCreator_EditPntsDlg::getPoints() const
-{
- return myPoints;
-}
-
-//=======================================================================
-// function: init
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::init()
-{
- // Init spin boxes.
- initSpinBox(myXSpn);
- initSpinBox(myYSpn);
-
- if (myDimension == CurveCreator::Dim3d) {
- initSpinBox(myZSpn);
- }
-
- // Init buttons.
- myModifBtn->setEnabled(false);
- myRmBtn->setEnabled(false);
- myClearBtn->setEnabled(false);
- myPntUpBtn->setEnabled(false);
- myPntDownBtn->setEnabled(false);
- myOkBtn->setDefault(true);
-
- connect(myAddBtn, SIGNAL(clicked()), this, SLOT(appendPoint()));
- connect(myModifBtn, SIGNAL(clicked()), this, SLOT(modifyPoint()));
- connect(myRmBtn, SIGNAL(clicked()), this, SLOT(removePoint()));
- connect(myClearBtn, SIGNAL(clicked()), this, SLOT(clear()));
- connect(myPntUpBtn, SIGNAL(clicked()), this, SLOT(upPoint()));
- connect(myPntDownBtn, SIGNAL(clicked()), this, SLOT(downPoint()));
- connect(myOkBtn, SIGNAL(clicked()), this, SLOT(accept()));
- connect(myCancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
-
- // Init list widget.
- myPntsList->clear();
- myPntsList->setSelectionMode(QAbstractItemView::ExtendedSelection);
- myPntsList->setDragEnabled(true);
- myPntsList->setDragDropMode(QAbstractItemView::InternalMove);
- myPntsList->viewport()->setAcceptDrops(true);
-
- connect(myPntsList, SIGNAL(itemSelectionChanged()),
- this, SLOT(changeSelection()));
- connect(this, SIGNAL(numberOfItemsChanged(int)),
- this, SLOT(onNumberOfItemsChanged(int)));
-
- // Set tab order.
- setTabOrder();
-}
-
-//=======================================================================
-// function: initSpinBox
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::initSpinBox(QDoubleSpinBox *theSpinBox)
-{
- const double aCoordMin = -1.e+15;
- const double aCoordMax = 1.e+15;
- const double aStep = 10;
- const int aPrecision = 6;
-
- theSpinBox->setDecimals( qAbs( aPrecision ) );
- theSpinBox->setRange(aCoordMin, aCoordMax);
- theSpinBox->setSingleStep(aStep);
- theSpinBox->setValue(0.0);
-}
-
-//=======================================================================
-// function: updateEditList
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::updateEditList()
-{
- myPntsList->clear();
-
- const int aNbCoords = myPoints.size();
-
- if (aNbCoords % myDimension == 0) {
- int i = 0;
-
- while (i < aNbCoords) {
- const CurveCreator::TypeCoord aX = myPoints[i++];
- const CurveCreator::TypeCoord aY = myPoints[i++];
-
- if (myDimension == CurveCreator::Dim3d) {
- const CurveCreator::TypeCoord aZ = myPoints[i++];
-
- new CurveCreator_PointItem(aX, aY, aZ, myPntsList);
- } else {
- new CurveCreator_PointItem(aX, aY, myPntsList);
- }
- }
- }
-
- emit numberOfItemsChanged(myPntsList->count());
-}
-
-//=======================================================================
-// function: movePoints
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::movePoints(const int theShift)
-{
- // Sort list items in ascending or descending order depending on
- // the sign of theShift.
- QList<QListWidgetItem *> aListItems = myPntsList->selectedItems();
-
- if (!aListItems.empty() && theShift != 0) {
- QMap<int, QListWidgetItem *> aMapItems;
-
- foreach(QListWidgetItem *anItem, aListItems) {
- int aRow = myPntsList->row(anItem);
-
- if (theShift > 0) {
- aRow = -aRow;
- }
-
- aMapItems.insert(aRow, anItem);
- }
-
- // Compute new rows
- QList<int> aListRows = aMapItems.keys();
- QList<int> aListNewRows;
- int i;
- const int aSize = aListRows.size();
-
-
- if (theShift < 0) {
- // Check each row to be positive.
- int aMinIndex = 0;
-
- for (i = 0; i < aSize; i++) {
- int aRow = aListRows[i] + theShift;
-
- if (aRow < aMinIndex) {
- aRow = aMinIndex++;
- }
-
- aListNewRows.append(aRow);
- }
- } else {
- // Check each row to be not greater then a myPntsList's size.
- int aMaxIndex = myPntsList->count() - 1;
-
- for (i = 0; i < aSize; i++) {
- int aRow = -aListRows[i] + theShift;
-
- if (aRow > aMaxIndex) {
- aRow = aMaxIndex--;
- }
-
- aListRows[i] = -aListRows[i];
- aListNewRows.append(aRow);
- }
- }
-
- // Move each item to another position.
- for (i = 0; i < aSize; i++) {
- if (aListRows[i] != aListNewRows[i]) {
- QListWidgetItem *anItem = myPntsList->takeItem(aListRows[i]);
-
- myPntsList->insertItem(aListNewRows[i], anItem);
- }
- }
-
- // Select added items.
- foreach (int anIndex, aListNewRows) {
- myPntsList->item(anIndex)->setSelected(true);
- }
- }
-}
-
-//=======================================================================
-// function: setTabOrder
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::setTabOrder()
-{
- QWidget::setTabOrder(myXSpn, myYSpn);
-
- if (myDimension == CurveCreator::Dim3d) {
- QWidget::setTabOrder(myYSpn, myZSpn);
- QWidget::setTabOrder(myZSpn, myAddBtn);
- } else {
- QWidget::setTabOrder(myYSpn, myAddBtn);
- }
-
- QWidget::setTabOrder(myAddBtn, myModifBtn);
- QWidget::setTabOrder(myModifBtn, myRmBtn);
- QWidget::setTabOrder(myRmBtn, myClearBtn);
- QWidget::setTabOrder(myClearBtn, myPntsList);
- QWidget::setTabOrder(myPntsList, myPntUpBtn);
- QWidget::setTabOrder(myPntUpBtn, myPntDownBtn);
- QWidget::setTabOrder(myPntDownBtn, myOkBtn);
- QWidget::setTabOrder(myOkBtn, myCancelBtn);
-}
-
-//=======================================================================
-// function: appendPoint
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::appendPoint()
-{
- if (myDimension == CurveCreator::Dim3d) {
- new CurveCreator_PointItem(myXSpn->value(), myYSpn->value(),
- myZSpn->value(), myPntsList);
- } else {
- new CurveCreator_PointItem(myXSpn->value(), myYSpn->value(), myPntsList);
- }
-
- emit numberOfItemsChanged(myPntsList->count());
-}
-
-//=======================================================================
-// function: modifyPoint
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::modifyPoint()
-{
- QList<QListWidgetItem *> aListItems = myPntsList->selectedItems();
-
- if (aListItems.size() == 1) {
- CurveCreator_PointItem *aPntItem =
- (CurveCreator_PointItem *)aListItems.first();
-
- if (myDimension == CurveCreator::Dim3d) {
- aPntItem->setCoord(myXSpn->value(), myYSpn->value(), myZSpn->value());
- } else {
- aPntItem->setCoord(myXSpn->value(), myYSpn->value());
- }
- }
-}
-
-//=======================================================================
-// function: removePoint
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::removePoint()
-{
- QList<QListWidgetItem *> aListItems = myPntsList->selectedItems();
- int aRow = -1;
-
- foreach(QListWidgetItem *anItem, aListItems) {
- if (aRow < 0) {
- aRow = myPntsList->row(anItem);
- }
-
- delete anItem;
- }
-
- if (aRow >= 0) {
- emit numberOfItemsChanged(myPntsList->count());
- }
-
- // Set the new selection.
- if (aRow >= myPntsList->count()) {
- aRow = myPntsList->count() - 1;
- }
-
- if (aRow >= 0) {
- myPntsList->item(aRow)->setSelected(true);
- }
-}
-
-//=======================================================================
-// function: upPoint
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::upPoint()
-{
- movePoints(-1);
-}
-
-//=======================================================================
-// function: downPoint
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::downPoint()
-{
- movePoints(1);
-}
-
-//=======================================================================
-// function: changeSelection
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::changeSelection()
-{
- // Update modify button and spin boxes.
- QList<QListWidgetItem *> aListItems = myPntsList->selectedItems();
- const int aNbItems = aListItems.size();
-
- if (aNbItems == 1) {
- const CurveCreator_PointItem *aPntItem =
- (const CurveCreator_PointItem *)aListItems.first();
-
- myModifBtn->setEnabled(true);
- myXSpn->setValue(aPntItem->getX());
- myYSpn->setValue(aPntItem->getY());
-
- if (myDimension == CurveCreator::Dim3d) {
- myZSpn->setValue(aPntItem->getZ());
- }
- } else if (myModifBtn->isEnabled()) {
- myModifBtn->setEnabled(false);
- myXSpn->setValue(0.0);
- myYSpn->setValue(0.0);
-
- if (myDimension == CurveCreator::Dim3d) {
- myZSpn->setValue(0.0);
- }
- }
-
- // Set enabled remove, up and down points.
- bool isEnabled = (aNbItems > 0);
-
- myRmBtn->setEnabled(isEnabled);
- isEnabled &= (aNbItems < myPntsList->count());
- myPntUpBtn->setEnabled(isEnabled);
- myPntDownBtn->setEnabled(isEnabled);
-}
-
-//=======================================================================
-// function: accept
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::accept()
-{
- // Copy points
- myPoints.clear();
-
- const int aNbPoints = myPntsList->count();
- int i;
-
- for (i = 0; i < aNbPoints; i++) {
- const CurveCreator_PointItem *aPntItem =
- (const CurveCreator_PointItem *)myPntsList->item(i);
-
- myPoints.push_back(aPntItem->getX());
- myPoints.push_back(aPntItem->getY());
-
- if (myDimension == CurveCreator::Dim3d) {
- myPoints.push_back(aPntItem->getZ());
- }
- }
-
- QDialog::accept();
-}
-
-//=======================================================================
-// function: clear
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::clear()
-{
- bool isEmpty = (myPntsList->count() == 0);
-
- myPntsList->clear();
-
- if (!isEmpty) {
- emit onNumberOfItemsChanged(0);
- }
-}
-
-//=======================================================================
-// function: onNumberOfItemsChanged
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsDlg::onNumberOfItemsChanged(int theNewValue)
-{
- myClearBtn->setEnabled(theNewValue > 0);
-
- // Update Up and down buttons
- QList<QListWidgetItem *> aListItems = myPntsList->selectedItems();
- const int aNbItems = aListItems.size();
- const bool isEnabled = (aNbItems > 0 && aNbItems < theNewValue);
-
- myPntUpBtn->setEnabled(isEnabled);
- myPntDownBtn->setEnabled(isEnabled);
-}
+++ /dev/null
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_EditPntsDlg.h
-// Created: Fri Jul 05 16:29:48 2013
-// Author: Sergey KHROMOV
-//
-
-#ifndef _CurveCreator_EditPntsDlg_HeaderFile
-#define _CurveCreator_EditPntsDlg_HeaderFile
-
-
-#include <QDialog>
-#include <CurveCreator.hxx>
-
-class QListWidget;
-class QDoubleSpinBox;
-class QPushButton;
-
-
-class CurveCreator_EditPntsDlg : public QDialog
-{
- Q_OBJECT
-
-public:
-
- CurveCreator_EditPntsDlg(QWidget* parent,
- const CurveCreator::Dimension theDimension);
-
- ~CurveCreator_EditPntsDlg();
-
- void setPoints(const CurveCreator::Coordinates &thePoints);
-
- const CurveCreator::Coordinates &getPoints() const;
-
-private:
-
- void init();
-
- void initSpinBox(QDoubleSpinBox *theSpinBox);
-
- void updateEditList();
-
- void movePoints(const int theShift);
-
- void setTabOrder();
-
-private slots:
-
- void appendPoint();
-
- void modifyPoint();
-
- void removePoint();
-
- void upPoint();
-
- void downPoint();
-
- void changeSelection();
-
- void accept();
-
- void clear();
-
- void onNumberOfItemsChanged(int theNewValue);
-
-signals:
-
- void numberOfItemsChanged(int theNewValue);
-
-protected:
-
- CurveCreator::Dimension myDimension;
- CurveCreator::Coordinates myPoints;
- QListWidget *myPntsList;
- QDoubleSpinBox *myXSpn;
- QDoubleSpinBox *myYSpn;
- QDoubleSpinBox *myZSpn;
- QPushButton *myAddBtn;
- QPushButton *myModifBtn;
- QPushButton *myRmBtn;
- QPushButton *myClearBtn;
- QPushButton *myPntUpBtn;
- QPushButton *myPntDownBtn;
- QPushButton *myOkBtn;
- QPushButton *myCancelBtn;
-
-};
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_EditPntsWidget.cxx
-// Created: Fri Jul 05 16:30:11 2013
-// Author: Sergey KHROMOV
-//
-
-
-#include <CurveCreator_EditPntsWidget.h>
-#include <CurveCreator_EditPntsDlg.h>
-#include <CurveCreator_PointItem.h>
-#include <QGroupBox>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QLineEdit>
-#include <QListWidget>
-#include <QPushButton>
-
-
-//=======================================================================
-// function: Constructor
-// purpose:
-//=======================================================================
-CurveCreator_EditPntsWidget::CurveCreator_EditPntsWidget
- (QWidget* parent,
- const bool IsSection,
- const CurveCreator::Dimension theDimension)
- : QWidget (parent),
- myDimension (theDimension),
- myPntsEdit (NULL),
- myPntsBtn (NULL),
- myPntsEditDlg (NULL),
- myPntsList (NULL)
-{
- QGroupBox *aMainGrp = new QGroupBox;
- QHBoxLayout *aMainLO = new QHBoxLayout(aMainGrp);
-
- myPntsEdit = new QLineEdit(aMainGrp);
- myPntsBtn = new QPushButton
- (IsSection? tr("CC_SECTION_POINTS_EDIT") : tr("CC_POINTS_EDIT"), aMainGrp);
- aMainLO->addWidget(myPntsEdit);
- aMainLO->addWidget(myPntsBtn);
-
- setLayout(aMainLO);
-
- init();
-}
-
-//=======================================================================
-// function: Destructor
-// purpose:
-//=======================================================================
-CurveCreator_EditPntsWidget::~CurveCreator_EditPntsWidget()
-{
-}
-
-//=======================================================================
-// function: setPoints
-// purpose:
-//=======================================================================
-void CurveCreator_EditPntsWidget::setPoints
- (const CurveCreator::Coordinates &thePoints)
-{
- myPoints = thePoints;
- updateEditLine();
-}
-
-//=======================================================================
-// function: getPoints
-// purpose:
-//=======================================================================
-const CurveCreator::Coordinates &CurveCreator_EditPntsWidget::getPoints() const
-{
- return myPoints;
-}
-
-//=======================================================================
-// function : setPointsList
-// purpose :
-//=======================================================================
-void CurveCreator_EditPntsWidget::setPointsList(QListWidget *thePntsList)
-{
- myPntsList = thePntsList;
-}
-
-//=======================================================================
-// function : clear
-// purpose :
-//=======================================================================
-void CurveCreator_EditPntsWidget::clear()
-{
- myPoints.clear();
- myPntsEdit->setText("");
-}
-
-//=======================================================================
-// function : getPointsEdit
-// purpose :
-//=======================================================================
-QLineEdit *CurveCreator_EditPntsWidget::getPointsEdit() const
-{
- return myPntsEdit;
-}
-
-//=======================================================================
-// function : getPointsButton
-// purpose :
-//=======================================================================
-QPushButton *CurveCreator_EditPntsWidget::getPointsButton() const
-{
- return myPntsBtn;
-}
-
-//=======================================================================
-// function : init
-// purpose :
-//=======================================================================
-void CurveCreator_EditPntsWidget::init()
-{
- connect(myPntsBtn, SIGNAL(clicked()), this, SLOT(editPoints()));
-
- myPntsEdit->setReadOnly(true);
- updateEditLine();
-
- // Set tab order.
- QWidget::setTabOrder(myPntsEdit, myPntsBtn);
-}
-
-//=======================================================================
-// function : editPoints
-// purpose :
-//=======================================================================
-void CurveCreator_EditPntsWidget::editPoints()
-{
- if (myPntsEditDlg == NULL) {
- // Create the dialog.
- myPntsEditDlg = new CurveCreator_EditPntsDlg(this, myDimension);
- }
-
- // Set points to dialog.
- setPointsToDialog();
-
- const int aResult = myPntsEditDlg->exec();
-
- if (aResult == QDialog::Accepted) {
- // Update the list of points and myPntsEdit.
- const CurveCreator::Coordinates &aNewPoints = myPntsEditDlg->getPoints();
-
- myPoints.clear();
- myPoints.insert(myPoints.end(), aNewPoints.begin(), aNewPoints.end());
- updateEditLine();
- }
-}
-
-//=======================================================================
-// function : updateEditLine
-// purpose :
-//=======================================================================
-void CurveCreator_EditPntsWidget::updateEditLine()
-{
- const int aNbPnts = myPoints.size();
-
- if ( aNbPnts == 0 ) {
- myPntsEdit->setText("");
- } else if ( aNbPnts == myDimension ) {
- // One point.
- QString aText;
-
- if (myDimension == CurveCreator::Dim3d) {
- aText = CurveCreator_PointItem::getText
- (myPoints[0], myPoints[1], myPoints[2]);
- } else {
- aText = CurveCreator_PointItem::getText(myPoints[0], myPoints[1]);
- }
-
- myPntsEdit->setText(aText);
- } else if ( aNbPnts > 0 ) {
- myPntsEdit->setText(tr("CC_POINTS_NUMBER").arg(aNbPnts/myDimension));
- }
-}
-
-//=======================================================================
-// function : setPointsToDialog
-// purpose :
-//=======================================================================
-void CurveCreator_EditPntsWidget::setPointsToDialog()
-{
- bool isPntsFromWidget = false;
-
- if (myPntsList != NULL) {
- QList<QListWidgetItem *> aListItems = myPntsList->selectedItems();
-
- if (aListItems.size() > 0) {
- CurveCreator::Coordinates aPoints;
-
- foreach (QListWidgetItem *anItem, aListItems) {
- const CurveCreator_PointItem *aPntItem =
- (const CurveCreator_PointItem *)anItem;
-
- aPoints.push_back(aPntItem->getX());
- aPoints.push_back(aPntItem->getY());
-
- if (myDimension == CurveCreator::Dim3d) {
- aPoints.push_back(aPntItem->getZ());
- }
- }
-
- myPntsEditDlg->setPoints(aPoints);
- isPntsFromWidget = true;
- }
- }
-
- if (!isPntsFromWidget) {
- myPntsEditDlg->setPoints(myPoints);
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_EditPntsWidget.h
-// Created: Fri Jul 05 16:30:17 2013
-// Author: Sergey KHROMOV
-//
-
-#ifndef _CurveCreator_EditPntsWidget_HeaderFile
-#define _CurveCreator_EditPntsWidget_HeaderFile
-
-
-#include <QWidget>
-#include <CurveCreator.hxx>
-
-class QLineEdit;
-class QPushButton;
-class QListWidget;
-class CurveCreator_EditPntsDlg;
-
-
-class CurveCreator_EditPntsWidget : public QWidget
-{
- Q_OBJECT
-
-public:
-
- CurveCreator_EditPntsWidget(QWidget* parent,
- const bool IsSection,
- const CurveCreator::Dimension theDimension);
-
- ~CurveCreator_EditPntsWidget();
-
- void setPoints(const CurveCreator::Coordinates &thePoints);
-
- const CurveCreator::Coordinates &getPoints() const;
-
- void setPointsList(QListWidget *thePntsList);
-
- void clear();
-
- QLineEdit *getPointsEdit() const;
-
- QPushButton *getPointsButton() const;
-
-private slots:
-
- void editPoints();
-
-private:
-
- void init();
-
- void updateEditLine();
-
- void setPointsToDialog();
-
-protected:
-
- CurveCreator::Coordinates myPoints;
- CurveCreator::Dimension myDimension;
- QPushButton *myPntsBtn;
- QLineEdit *myPntsEdit;
- CurveCreator_EditPntsDlg *myPntsEditDlg;
- QListWidget *myPntsList;
-
-};
-
-#endif
-
--- /dev/null
+#include "CurveCreator_NewPointDlg.h"\r
+#include <QGridLayout>\r
+#include <QVBoxLayout>\r
+#include <QLabel>\r
+#include <QDoubleSpinBox>\r
+#include <QDialogButtonBox>\r
+#include <QDoubleValidator>\r
+#include <QRegExpValidator>\r
+#include <QAbstractButton>\r
+#include <QPushButton>\r
+#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
+{\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
+}\r
+\r
+void CurveCreator_NewPointDlg::setSectionName( const QString& theName )\r
+{\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
+}\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
+ }\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
+}\r
+\r
+void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )\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
+}\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
+}\r
+\r
+//=======================================================================\r
+// function: initSpinBox\r
+// purpose:\r
+//=======================================================================\r
+void CurveCreator_NewPointDlg::initSpinBox(QDoubleSpinBox *theSpinBox)\r
+{\r
+ const double aCoordMin = -1.e+15;\r
+ const double aCoordMax = 1.e+15;\r
+ const double aStep = 10;\r
+ const int aPrecision = 6;\r
+\r
+ theSpinBox->setDecimals( qAbs( aPrecision ) );\r
+ theSpinBox->setRange(aCoordMin, aCoordMax);\r
+ theSpinBox->setSingleStep(aStep);\r
+ theSpinBox->setValue(0.0);\r
+}\r
--- /dev/null
+#ifndef CURVECREATOR_NEWPOINTDLG_H\r
+#define CURVECREATOR_NEWPOINTDLG_H\r
+\r
+#include "CurveCreator.hxx"\r
+\r
+#include <QDialog>\r
+\r
+class QDoubleSpinBox;\r
+class QDialogButtonBox;\r
+class QAbstractButton;\r
+class QPushButton;\r
+\r
+class CurveCreator_NewPointDlg : public QDialog\r
+{\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
+signals:\r
+ void addPoint();\r
+public slots:\r
+protected slots:\r
+ void onBtnClicked(QAbstractButton* theBtn );\r
+protected:\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
+};\r
+\r
+#endif // CURVECREATOR_NEWPOINTDLG_H\r
--- /dev/null
+#include "CurveCreator_NewSectionDlg.h"\r
+\r
+#include "CurveCreator_Curve.hxx"\r
+\r
+#include <SUIT_Session.h>\r
+#include <SUIT_ResourceMgr.h>\r
+\r
+#include <QGridLayout>\r
+#include <QLabel>\r
+#include <QLineEdit>\r
+#include <QComboBox>\r
+#include <QCheckBox>\r
+#include <QDialogButtonBox>\r
+#include <QPushButton>\r
+\r
+CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *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
+}\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
+}\r
+\r
+void CurveCreator_NewSectionDlg::clear()\r
+{\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
+}\r
+\r
+QString CurveCreator_NewSectionDlg::getName() const\r
+{\r
+ return myName->text();\r
+}\r
+\r
+bool CurveCreator_NewSectionDlg::isClosed() const\r
+{\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
+}\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
+}\r
+\r
+void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )\r
+{\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
+}\r
--- /dev/null
+#ifndef CURVECREATOR_NEWSECTION_H\r
+#define CURVECREATOR_NEWSECTION_H\r
+\r
+#include "CurveCreator.hxx"\r
+\r
+#include <QDialog>\r
+\r
+class CurveCreator_Curve;\r
+\r
+class QLineEdit;\r
+class QComboBox;\r
+class QCheckBox;\r
+class QPushButton;\r
+class QAbstractButton;\r
+class QDialogButtonBox;\r
+\r
+class CurveCreator_NewSectionDlg : public QDialog\r
+{\r
+ Q_OBJECT\r
+public:\r
+ explicit CurveCreator_NewSectionDlg(QWidget *parent = 0);\r
+\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
+\r
+signals:\r
+ void addSection();\r
+public slots:\r
+protected slots:\r
+ void onBtnClicked(QAbstractButton* theBtn );\r
+protected:\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
+};\r
+\r
+#endif // CURVECREATOR_NEWSECTION_H\r
#include <CurveCreator_Operation.hxx>
#include <CurveCreator_Curve.hxx>
+#include <string>
#include <stdlib.h>
CurveCreator::Coordinates aCoords;
getCoords(&pInt[2], aCoords);
- theCurve->addSection(aType, (pInt[1] != 0), aCoords);
+ theCurve->addSection(std::string(""), aType, (pInt[1] != 0), aCoords);
}
break;
case CurveCreator_Operation::RemoveSection:
MoveSection, //!< Method CurveCreator_Curve::moveSection
Join, //!< Method CurveCreator_Curve::join
AddSection, //!< Method CurveCreator_Curve::addSection
- RemoveSection //!< Method CurveCreator_Curve::removeSection
+ RemoveSection, //!< Method CurveCreator_Curve::removeSection
+ RenameCurve //!< Method CurveCreator_Curve::renameCurve
};
/**
+++ /dev/null
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_PointItem.cxx
-// Created: Wed Jul 10 12:17:47 2013
-// Author: Sergey KHROMOV
-//
-
-
-#include <CurveCreator_PointItem.h>
-#include <QVariant>
-
-
-//=======================================================================
-// function: Constructor
-// purpose:
-//=======================================================================
-CurveCreator_PointItem::CurveCreator_PointItem
- (const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY,
- QListWidget *theParent)
- : QListWidgetItem(theParent, ITEM_TYPE_XY)
-{
- setCoord(theX, theY);
-}
-
-//=======================================================================
-// function: Constructor
-// purpose:
-//=======================================================================
-CurveCreator_PointItem::CurveCreator_PointItem
- (const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY,
- const CurveCreator::TypeCoord theZ,
- QListWidget *theParent)
- : QListWidgetItem(theParent, ITEM_TYPE_XYZ)
-{
- setCoord(theX, theY, theZ);
-}
-
-//=======================================================================
-// function: Destructor
-// purpose:
-//=======================================================================
-CurveCreator_PointItem::~CurveCreator_PointItem()
-{
-}
-
-//=======================================================================
-// function: getText
-// purpose:
-//=======================================================================
-QString CurveCreator_PointItem::getText(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY)
-{
- return QObject::tr("CC_PNT_ITEM_X_Y").arg(theX).arg(theY);
-}
-
-//=======================================================================
-// function: getText
-// purpose:
-//=======================================================================
-QString CurveCreator_PointItem::getText(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY,
- const CurveCreator::TypeCoord theZ)
-{
- return QObject::tr("CC_PNT_ITEM_X_Y_Z").arg(theX).arg(theY).arg(theZ);
-}
-
-//=======================================================================
-// function: setCoord
-// purpose:
-//=======================================================================
-void CurveCreator_PointItem::setCoord(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY)
-{
- if (!is3d()) {
- setData(ROLE_X, theX);
- setData(ROLE_Y, theY);
- setText(getText(theX, theY));
- }
-}
-
-//=======================================================================
-// function: setCoord
-// purpose:
-//=======================================================================
-void CurveCreator_PointItem::setCoord(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY,
- const CurveCreator::TypeCoord theZ)
-{
- if (is3d()) {
- setData(ROLE_X, theX);
- setData(ROLE_Y, theY);
- setData(ROLE_Z, theZ);
- setText(getText(theX, theY, theZ));
- }
-}
-
-//=======================================================================
-// function: getX
-// purpose:
-//=======================================================================
-CurveCreator::TypeCoord CurveCreator_PointItem::getX() const
-{
- return data(ROLE_X).value<CurveCreator::TypeCoord>();
-}
-
-//=======================================================================
-// function: getY
-// purpose:
-//=======================================================================
-CurveCreator::TypeCoord CurveCreator_PointItem::getY() const
-{
- return data(ROLE_Y).value<CurveCreator::TypeCoord>();
-}
-
-//=======================================================================
-// function: getZ
-// purpose:
-//=======================================================================
-CurveCreator::TypeCoord CurveCreator_PointItem::getZ() const
-{
- return (is3d() ? data(ROLE_Z).value<CurveCreator::TypeCoord>() : 0.);
-}
-
-//=======================================================================
-// function: is3d
-// purpose:
-//=======================================================================
-bool CurveCreator_PointItem::is3d() const
-{
- return (type() == ITEM_TYPE_XYZ);
-}
+++ /dev/null
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_PointItem.h
-// Created: Wed Jul 10 12:17:40 2013
-// Author: Sergey KHROMOV
-//
-
-
-#ifndef _CurveCreator_PointItem_HeaderFile
-#define _CurveCreator_PointItem_HeaderFile
-
-
-#include <QListWidgetItem>
-#include <CurveCreator.hxx>
-
-
-#define ITEM_TYPE_XY QListWidgetItem::UserType + 1
-#define ITEM_TYPE_XYZ QListWidgetItem::UserType + 2
-#define ROLE_X Qt::UserRole + 1
-#define ROLE_Y Qt::UserRole + 2
-#define ROLE_Z Qt::UserRole + 3
-
-/**
- * This class represents a list widget item to facilitate storage
- * of 2d or 3d points in a list widget. The type of a stored point
- * (2d or 3d) is determined by a constructor chosen to create an object.
- */
-class CurveCreator_PointItem : public QListWidgetItem
-{
-
-public:
-
- /**
- * Constructor. Initializes the object with 2d point.
- */
- CurveCreator_PointItem(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY,
- QListWidget * theParent = 0);
-
- /**
- * Constructor. Initializes the object with 3d point.
- */
- CurveCreator_PointItem(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY,
- const CurveCreator::TypeCoord theZ,
- QListWidget * theParent = 0);
-
- /**
- * Destructor
- */
- ~CurveCreator_PointItem();
-
- /**
- * This static method is used to construct the text to be displayed by this
- * item for 2d point.
- */
- static QString getText(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY);
-
- /**
- * This static method is used to construct the text to be displayed by this
- * item for 3d point.
- */
- static QString getText(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY,
- const CurveCreator::TypeCoord theZ);
-
- /**
- * This method sets the coordinates for 2d point. If the object has type
- * 3d point this method does nothing.
- */
- void setCoord(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY);
-
- /**
- * This method sets the coordinates for 3d point. If the object has type
- * 2d point this method does nothing.
- */
- void setCoord(const CurveCreator::TypeCoord theX,
- const CurveCreator::TypeCoord theY,
- const CurveCreator::TypeCoord theZ);
-
- /**
- * Query the X coordinate of the point.
- */
- CurveCreator::TypeCoord getX() const;
-
- /**
- * Query the Y coordinate of the point.
- */
- CurveCreator::TypeCoord getY() const;
-
- /**
- * Query the Z coordinate of the point. Return 0 for the type 2d point.
- */
- CurveCreator::TypeCoord getZ() const;
-
- /**
- * Returns true if the type of the stored point is 3d; false otherwise.
- */
- bool is3d() const;
-
-};
-
-#endif
#include <CurveCreator.hxx>
+#include <string>
//! Structure to store sections representing the CurveCreator_Curve object
struct CurveCreator_Section
{
//! Constructor. Initializes object with default values.
- CurveCreator_Section() : myType(CurveCreator::Polyline), myIsClosed(false)
+ CurveCreator_Section() : myName("Section"),myType(CurveCreator::Polyline), myIsClosed(false)
{ }
+ std::string myName; //!< section name
CurveCreator::Coordinates myPoints; //!< points coordinates
CurveCreator::Type myType; //!< type of the section
bool myIsClosed; //!< closed or not
--- /dev/null
+#include "CurveCreator_TreeView.h"\r
+\r
+#include "CurveCreator_Curve.hxx"\r
+\r
+#include <SUIT_Session.h>\r
+#include <SUIT_ResourceMgr.h>\r
+\r
+#include <QHeaderView>\r
+#include <QtAlgorithms>\r
+\r
+#define ID_SECTION -1\r
+\r
+CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent ) :\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
+\r
+ QPixmap aPolylineIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));\r
+ if( !aPolylineIcon.isNull() )\r
+ myCachedIcons[ICON_POLYLINE] = aPolylineIcon;\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
+\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
+\r
+ QPixmap aPointIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POINT")));\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
+}\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
+ }\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
+ }\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 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
+}\r
+\r
+QModelIndex CurveCreator_TreeViewModel::parent(const QModelIndex & theIndex) const\r
+{\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
+}\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
+ }\r
+ return aRowCnt;\r
+}\r
+\r
+QModelIndex CurveCreator_TreeViewModel::sectionIndex( int theSection ) const\r
+{\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
+}\r
+\r
+bool CurveCreator_TreeViewModel::isSection( const QModelIndex& theIndx ) const\r
+{\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
+}\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
+}\r
+\r
+/*****************************************************************************************/\r
+CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *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
+}\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
+ 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
+}\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
+}\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
+ }\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
+}\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
+}\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
+ }\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
+}\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
+}\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
+}\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
+}\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
+}\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
+ }\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
+ }\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
+}\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
+}\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
+ }\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
+}\r
--- /dev/null
+#ifndef CURVECREATOR_TREEVIEW_H\r
+#define CURVECREATOR_TREEVIEW_H\r
+\r
+#include <QTreeView>\r
+#include <QAbstractItemModel>\r
+\r
+class CurveCreator_Curve;\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
+\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
+private:\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
+};\r
+\r
+class CurveCreator_TreeView : public QTreeView\r
+{\r
+ Q_OBJECT\r
+public:\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
+\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 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 setSelectedSections( const QList<int>& theList );\r
+ void setSelectedPoints( const QList< QPair<int, int> >& thePointsList );\r
+\r
+signals:\r
+ void selectionChanged();\r
+ void sectionEntered(int);\r
+ void pointEntered(int,int);\r
+public slots:\r
+protected slots:\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
+};\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
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_Widget.cxx
-// Created: Mon Jul 01 12:49:31 2013
-// Author: Sergey KHROMOV
-//
-
-
-#include <CurveCreator_Widget.h>
-#include <CurveCreator_EditPntsWidget.h>
-#include <CurveCreator_UndoOptsDlg.h>
-#include <CurveCreator_EditPntDlg.h>
-#include <CurveCreator_PointItem.h>
-#include <QPushButton>
-#include <QButtonGroup>
-#include <QHBoxLayout>
-#include <QListWidget>
-#include <QGroupBox>
-#include <QLabel>
-#include <QLineEdit>
-#include <QRadioButton>
-#include <QComboBox>
-#include <QCheckBox>
-
-#define SECTION_ADD 0
-#define SECTION_MODIFY 1
-#define POLYLINE_INDEX 0
-#define BSPLINE_INDEX 1
-#define UNDO_REDO_DISABLED 0
-#define UNDO_REDO_UNLIMITED -1
-
-//=======================================================================
-// function: Constructor
-// purpose:
-//=======================================================================
-CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
- CurveCreator_Curve *theCurve,
- Qt::WindowFlags fl)
- : QWidget (parent, fl),
- myEditor (theCurve),
- myDimension (theCurve == NULL ?
- CurveCreator::Dim2d : theCurve->getDimension()),
- myEnabledUndoLbl (NULL),
- myBufSizeUndoLbl (NULL),
- myUndoBtn (NULL),
- myRedoBtn (NULL),
- myUndoOptsBtn (NULL),
- myUndoOptsDlg (NULL),
- myAddSecGrp (NULL),
- mySecBtnGrp (NULL),
- mySecTypeCmbBox (NULL),
- mySecCloseChkBox (NULL),
- mySecAddModifBtn (NULL),
- mySecRmBtn (NULL),
- mySecJoinBtn (NULL),
- mySecJoinAllBtn (NULL),
- mySecClearBtn (NULL),
- mySecUpBtn (NULL),
- mySecDownBtn (NULL),
- mySecList (NULL),
- myEditSecPnts (NULL),
- myPntsGrp (NULL),
- myPntsList (NULL),
- myPntEditDlg (NULL),
- myEditPnts (NULL),
- myAddPntsBtn (NULL),
- myInsertPntsBtn (NULL),
- myRmPntsBtn (NULL)
-{
- setWindowTitle(tr("CC_TITLE"));
-
- // Set undo/redo options group
- QGroupBox *anUndoOptsGrp = new QGroupBox(tr("CC_UNDO_REDO_OPTIONS"));
- QGridLayout *anUndoOptsLO = new QGridLayout(anUndoOptsGrp);
-
- myEnabledUndoLbl = new QLabel(tr("CC_UNDO_REDO_ENABLED"), anUndoOptsGrp);
- myBufSizeUndoLbl = new QLabel(tr("CC_UNDO_REDO_BUFFER_SIZE"), anUndoOptsGrp);
- myUndoOptsBtn = new QPushButton(tr("CC_UNDO_REDO_MODIFY"), anUndoOptsGrp);
- anUndoOptsLO->setMargin(9);
- anUndoOptsLO->setSpacing(6);
- anUndoOptsLO->addWidget(myEnabledUndoLbl, 0, 0);
- anUndoOptsLO->addWidget(myBufSizeUndoLbl, 1, 0);
- anUndoOptsLO->addWidget(myUndoOptsBtn, 0, 1, 2, 1);
-
- // Set undo/redo group
- QGroupBox *anUndoRedoGrp = new QGroupBox(tr("CC_UNDO_REDO_TITLE"));
- QHBoxLayout *anUndoRedoLO = new QHBoxLayout(anUndoRedoGrp);
-
- myUndoBtn = new QPushButton(tr("CC_UNDO"), anUndoRedoGrp);
- myRedoBtn = new QPushButton(tr("CC_REDO"), anUndoRedoGrp);
- anUndoRedoLO->setMargin(9);
- anUndoRedoLO->setSpacing(6);
- anUndoRedoLO->addWidget(myUndoBtn, 0, Qt::AlignRight);
- anUndoRedoLO->addWidget(myRedoBtn, 0, Qt::AlignLeft);
- anUndoRedoLO->addWidget(anUndoOptsGrp, 0, Qt::AlignRight);
-
- // Set section add/modification group.
- myAddSecGrp = new QGroupBox(tr("CC_SECTION_ADD_TITLE"));
-
- QGridLayout *anAddSecLO = new QGridLayout(myAddSecGrp);
- QLabel *aSectTypeLbl =
- new QLabel(tr("CC_SECTION_TYPE"), myAddSecGrp);
- QLabel *aSecPntsLbl =
- new QLabel(tr("CC_SECTION_POINTS_ADD_LBL"), myAddSecGrp);
-
- mySecCloseChkBox = new QCheckBox(tr("CC_SECTION_CLOSED"), myAddSecGrp);
- mySecTypeCmbBox = new QComboBox(myAddSecGrp);
- mySecAddModifBtn = new QPushButton(tr("CC_SECTION_NEW"), myAddSecGrp);
- myEditSecPnts = new CurveCreator_EditPntsWidget
- (myAddSecGrp, true, myDimension);
- anAddSecLO->setMargin(9);
- anAddSecLO->setSpacing(6);
- anAddSecLO->addWidget(mySecCloseChkBox, 0, 0);
- anAddSecLO->addWidget(aSectTypeLbl, 1, 0);
- anAddSecLO->addWidget(mySecTypeCmbBox, 1, 1);
- anAddSecLO->addWidget(aSecPntsLbl, 2, 0);
- anAddSecLO->addWidget(myEditSecPnts, 2, 1);
- anAddSecLO->addWidget(mySecAddModifBtn, 1, 3);
-
- // Set section group
- QGroupBox *aSecGrp = new QGroupBox(tr("CC_SECTION_TITLE"));
- QGridLayout *aSecLO = new QGridLayout(aSecGrp);
- QRadioButton *anAddSecRdBtn =
- new QRadioButton(tr("CC_SECTION_ADD_TITLE"), aSecGrp);
- QRadioButton *aModifSecRdBtn =
- new QRadioButton(tr("CC_SECTION_MODIFY_TITLE"), aSecGrp);
-
- mySecRmBtn = new QPushButton(tr("CC_SECTION_REMOVE"), aSecGrp);
- mySecJoinBtn = new QPushButton(tr("CC_SECTION_JOIN"), aSecGrp);
- mySecJoinAllBtn = new QPushButton(tr("CC_SECTION_JOIN_ALL"), aSecGrp);
- mySecClearBtn = new QPushButton(tr("CC_SECTION_CLEAR"), aSecGrp);
- mySecUpBtn = new QPushButton(tr("CC_SECTION_UP"), aSecGrp);
- mySecDownBtn = new QPushButton(tr("CC_SECTION_DOWN"), aSecGrp);
- mySecBtnGrp = new QButtonGroup(aSecGrp);
- mySecList = new QListWidget(aSecGrp);
- aSecLO->setMargin(9);
- aSecLO->setSpacing(6);
- aSecLO->addWidget(anAddSecRdBtn, 0, 0);
- aSecLO->addWidget(aModifSecRdBtn, 0, 1);
- aSecLO->addWidget(myAddSecGrp, 1, 0, 1, 5);
- aSecLO->addWidget(mySecRmBtn, 2, 0);
- aSecLO->addWidget(mySecJoinBtn, 2, 1);
- aSecLO->addWidget(mySecJoinAllBtn, 2, 2);
- aSecLO->addWidget(mySecClearBtn, 2, 3);
- aSecLO->addWidget(mySecUpBtn, 4, 4);
- aSecLO->addWidget(mySecDownBtn, 5, 4);
- aSecLO->addWidget(mySecList, 3, 0, 4, 4);
- mySecBtnGrp->addButton(anAddSecRdBtn, SECTION_ADD);
- mySecBtnGrp->addButton(aModifSecRdBtn, SECTION_MODIFY);
-
- // Set point add/modification group.
- QGroupBox *anAddPntsGrp = new QGroupBox(tr("CC_POINTS_ADD_TITLE"));
-
- QGridLayout *anAddPntsLO = new QGridLayout(anAddPntsGrp);
- QLabel *aPntsLbl =
- new QLabel(tr("CC_POINTS_ADD_LBL"), anAddPntsGrp);
-
- myEditPnts = new CurveCreator_EditPntsWidget
- (anAddPntsGrp, false, myDimension);
- myAddPntsBtn = new QPushButton(tr("CC_POINTS_ADD"), anAddPntsGrp);
- myInsertPntsBtn = new QPushButton(tr("CC_POINTS_INSERT"), anAddPntsGrp);
- anAddPntsLO->setMargin(9);
- anAddPntsLO->setSpacing(6);
- anAddPntsLO->addWidget(aPntsLbl, 0, 0);
- anAddPntsLO->addWidget(myEditPnts, 0, 1);
- anAddPntsLO->addWidget(myAddPntsBtn, 0, 4);
- anAddPntsLO->addWidget(myInsertPntsBtn, 1, 4);
-
- // Set Points group
- myPntsGrp = new QGroupBox(tr("CC_POINTS_TITLE"));
-
- QGridLayout *aPntsLO = new QGridLayout(myPntsGrp);
-
- myPntsList = new QListWidget(myPntsGrp);
- myRmPntsBtn = new QPushButton(tr("CC_POINTS_REMOVE"), myPntsGrp);
- aPntsLO->setMargin(9);
- aPntsLO->setSpacing(6);
- aPntsLO->addWidget(anAddPntsGrp, 0, 0, 1, 4);
- aPntsLO->addWidget(myRmPntsBtn, 1, 0);
- aPntsLO->addWidget(myPntsList, 2, 0, 4, 4);
-
- // Set main group
- QGroupBox *aMainGrp = new QGroupBox(tr("CC_TITLE"));
- QGridLayout *aMainLO = new QGridLayout(aMainGrp);
-
- aMainLO->setMargin(9);
- aMainLO->setSpacing(6);
- aMainLO->addWidget(anUndoRedoGrp, 0, 0, 1, 2);
- aMainLO->addWidget(aSecGrp, 1, 0);
- aMainLO->addWidget(myPntsGrp, 1, 1);
-
- setLayout(aMainLO);
-
- init();
-}
-
-//=======================================================================
-// function: init
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::init()
-{
- // Initialize Undo/Redo group.
- QString anUnlim = tr("CC_UNDO_REDO_UNLIMITED");
-
- myEnabledUndoLbl->setText(tr("CC_UNDO_REDO_ENABLED"));
- myBufSizeUndoLbl->setText(tr("CC_UNDO_REDO_BUFFER_SIZE").arg(anUnlim));
- connect(myUndoOptsBtn, SIGNAL(clicked()), this, SLOT(undoOptionsChanged()));
- connect(myUndoBtn, SIGNAL(clicked()), this, SLOT(undo()));
- connect(myRedoBtn, SIGNAL(clicked()), this, SLOT(redo()));
- updateUndoRedoButtons();
-
- // Initialize sections group.
- mySecBtnGrp->setExclusive(true);
- mySecBtnGrp->button(SECTION_ADD)->setChecked(true);
- connect(mySecBtnGrp, SIGNAL(buttonClicked(int)),
- this, SLOT(addModifChanged(int)));
-
- // Init section buttons.
- mySecAddModifBtn->setEnabled(true);
- mySecRmBtn->setEnabled(false);
- mySecJoinBtn->setEnabled(false);
- mySecJoinAllBtn->setEnabled(false);
- mySecClearBtn->setEnabled(false);
- mySecUpBtn->setEnabled(false);
- mySecDownBtn->setEnabled(false);
-
- connect(mySecAddModifBtn, SIGNAL(clicked()),this, SLOT(sectionAddOrModify()));
- connect(mySecRmBtn, SIGNAL(clicked()),this, SLOT(sectionRemove()));
- connect(mySecJoinBtn, SIGNAL(clicked()),this, SLOT(sectionJoin()));
- connect(mySecJoinAllBtn, SIGNAL(clicked()),this, SLOT(sectionJoinAll()));
- connect(mySecClearBtn, SIGNAL(clicked()),this, SLOT(sectionClear()));
- connect(mySecUpBtn, SIGNAL(clicked()),this, SLOT(sectionUp()));
- connect(mySecDownBtn, SIGNAL(clicked()),this, SLOT(sectionDown()));
-
- // Init section input fields.
- mySecCloseChkBox->setChecked(false);
- mySecTypeCmbBox->addItem(tr("CC_SECTION_TYPE_POLYLINE"));
- mySecTypeCmbBox->addItem(tr("CC_SECTION_TYPE_BSPLINE"));
- mySecTypeCmbBox->setCurrentIndex(POLYLINE_INDEX);
- myEditSecPnts->clear();
-
- // Init sections list widget.
- mySecList->setSelectionMode(QAbstractItemView::ExtendedSelection);
-
- connect(this, SIGNAL(numberOfItemsChanged(QListWidget *)),
- this, SLOT(onNumberOfItemsChanged(QListWidget *)));
- initSections();
- connect(mySecList, SIGNAL(itemSelectionChanged()),
- this, SLOT(changeSecSelection()));
-
- // Init points list widget.
- myPntsGrp->setEnabled(false);
- myPntsList->clear();
- myPntsList->setSelectionMode(QAbstractItemView::ExtendedSelection);
-
- connect(myPntsList, SIGNAL(itemSelectionChanged()),
- this, SLOT(changePntsSelection()));
- connect(myPntsList, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
- this, SLOT(editPnt(QListWidgetItem *)));
-
- // Init points buttons.
- connect(myAddPntsBtn, SIGNAL(clicked()),this, SLOT(pntsAdd()));
- connect(myInsertPntsBtn, SIGNAL(clicked()),this, SLOT(pntsInsert()));
- connect(myRmPntsBtn, SIGNAL(clicked()),this, SLOT(pntsRemove()));
-
- // Init edit points widgets.
- myEditSecPnts->setPointsList(myPntsList);
- myEditPnts->setPointsList(myPntsList);
-
- // Set tab order
- setTabOrder();
-}
-
-//=======================================================================
-// function: initSections
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::initSections()
-{
- CurveCreator_Curve *aCurve = myEditor.getCurve();
-
- const int aNbSections = aCurve->getNbSections();
- int i;
-
- mySecList->clear();
-
- for (i = 0; i < aNbSections; i++) {
- addSectionItem(aCurve->getType(i), aCurve->isClosed(i));
- }
-
- emit numberOfItemsChanged(mySecList);
-}
-
-//=======================================================================
-// function: addSectionItem
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::addSectionItem(const CurveCreator::Type theType,
- const bool isClosed)
-{
- const int aRow = mySecList->count();
-
- new QListWidgetItem(mySecList);
- updateSectionItem(aRow, theType, isClosed);
- emit numberOfItemsChanged(mySecList);
-}
-
-//=======================================================================
-// function: updateSectionItem
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::updateSectionItem(const int theRow,
- const CurveCreator::Type theType,
- const bool isClosed)
-{
- QListWidgetItem *anItem = mySecList->item(theRow);
- QString aStrType;
-
- if (theType == CurveCreator::Polyline) {
- aStrType = tr("CC_SECTION_ITEM_POLYLINE");
- } else {
- aStrType = tr("CC_SECTION_ITEM_BSPLINE");
- }
-
- const QString aTrCode =
- (isClosed ? "CC_SECTION_ITEM_CLOSED" : "CC_SECTION_ITEM");
-
- anItem->setText(tr(aTrCode.toLatin1().constData()).arg(aStrType));
-}
-
-//=======================================================================
-// function: sectionMove
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::sectionMove(const int theShift)
-{
- // Sort list items in ascending or descending order depending on
- // the sign of theShift.
- QList<QListWidgetItem *> aListItems = mySecList->selectedItems();
-
- if (!aListItems.empty() && theShift != 0) {
- QMap<int, QListWidgetItem *> aMapItems;
-
- foreach(QListWidgetItem *anItem, aListItems) {
- int aRow = mySecList->row(anItem);
-
- if (theShift > 0) {
- aRow = -aRow;
- }
-
- aMapItems.insert(aRow, anItem);
- }
-
- // Compute new rows
- QList<int> aListRows = aMapItems.keys();
- QList<int> aListNewRows;
- int i;
- const int aSize = aListRows.size();
-
-
- if (theShift < 0) {
- // Check each row to be positive.
- int aMinIndex = 0;
-
- for (i = 0; i < aSize; i++) {
- int aRow = aListRows[i] + theShift;
-
- if (aRow < aMinIndex) {
- aRow = aMinIndex++;
- }
-
- aListNewRows.append(aRow);
- }
- } else {
- // Check each row to be not greater then a mySecList's size.
- int aMaxIndex = mySecList->count() - 1;
-
- for (i = 0; i < aSize; i++) {
- int aRow = -aListRows[i] + theShift;
-
- if (aRow > aMaxIndex) {
- aRow = aMaxIndex--;
- }
-
- aListRows[i] = -aListRows[i];
- aListNewRows.append(aRow);
- }
- }
-
- // Move each item to another position.
- for (i = 0; i < aSize; i++) {
- if (aListRows[i] != aListNewRows[i]) {
- QListWidgetItem *anItem = mySecList->takeItem(aListRows[i]);
-
- // Move section.
- mySecList->insertItem(aListNewRows[i], anItem);
- myEditor.moveSection(aListRows[i], aListNewRows[i]);
- }
- }
-
- // Select added items.
- foreach (int anIndex, aListNewRows) {
- mySecList->item(anIndex)->setSelected(true);
- }
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
-}
-
-//=======================================================================
-// function: initPoints
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::initPoints(const int theSectionIndex)
-{
- // Clear the points list
- const int aNbPnts = myPntsList->count();
-
- myPntsList->clear();
-
- if (theSectionIndex < 0) {
- if (aNbPnts > 0) {
- emit numberOfItemsChanged(myPntsList);
- }
- } else {
- // Fill the points list with the points of the section.
- const CurveCreator::Coordinates &aPoints =
- myEditor.getCurve()->getPoints(theSectionIndex);
- const int aNbCoords = aPoints.size();
-
- if (aNbCoords % myDimension == 0) {
- int i = 0;
-
- while (i < aNbCoords) {
- const CurveCreator::TypeCoord aX = aPoints[i++];
- const CurveCreator::TypeCoord aY = aPoints[i++];
-
- if (myDimension == CurveCreator::Dim3d) {
- const CurveCreator::TypeCoord aZ = aPoints[i++];
-
- new CurveCreator_PointItem(aX, aY, aZ, myPntsList);
- } else {
- new CurveCreator_PointItem(aX, aY, myPntsList);
- }
- }
- }
-
- if (aNbPnts != aNbCoords/myDimension) {
- emit numberOfItemsChanged(myPntsList);
- }
- }
-}
-
-//=======================================================================
-// function: getCurrentSectionIndex
-// purpose:
-//=======================================================================
-int CurveCreator_Widget::getCurrentSectionIndex()
-{
- int anIndex = -1;
- QList<QListWidgetItem *> aListSec = mySecList->selectedItems();
-
- if (aListSec.size() == 1) {
- anIndex = mySecList->row(aListSec.first());
- }
-
- return anIndex;
-}
-
-//=======================================================================
-// function: updateUndoRedo
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::updateUndoRedo()
-{
- // Update undo/redo buttons.
- updateUndoRedoButtons();
-
- // Update sections.
- CurveCreator_Curve *aCurve = myEditor.getCurve();
- const bool isKeepSelection = (mySecList->count() == aCurve->getNbSections());
- QList<int> aSelectedRows;
- QList<QListWidgetItem *> aListItems = mySecList->selectedItems();
-
- if (isKeepSelection) {
- foreach (QListWidgetItem *anItem, aListItems) {
- aSelectedRows.append(mySecList->row(anItem));
- }
- }
-
- initSections();
-
- // Set selection.
- if (isKeepSelection) {
- foreach (int aRow, aSelectedRows) {
- mySecList->item(aRow)->setSelected(true);
- }
- }
-
- changeSecSelection();
-}
-
-//=======================================================================
-// function: updateUndoRedoButtons
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::updateUndoRedoButtons()
-{
- // Update undo/redo buttons.
- const int anUndoDepth = myEditor.getUndoDepth();
-
- if (anUndoDepth == UNDO_REDO_DISABLED) {
- myUndoBtn->setEnabled(false);
- myRedoBtn->setEnabled(false);
- } else {
- myUndoBtn->setEnabled(myEditor.getNbUndo() > 0);
- myRedoBtn->setEnabled(myEditor.getNbRedo() > 0);
- }
-}
-
-
-//=======================================================================
-// function: setTabOrder
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::setTabOrder()
-{
- QWidget::setTabOrder(myUndoBtn, myRedoBtn);
- QWidget::setTabOrder(myRedoBtn, myUndoOptsBtn);
- QWidget::setTabOrder(myUndoOptsBtn, mySecBtnGrp->button(SECTION_ADD));
- QWidget::setTabOrder(mySecBtnGrp->button(SECTION_ADD),
- mySecBtnGrp->button(SECTION_MODIFY));
- QWidget::setTabOrder(mySecBtnGrp->button(SECTION_MODIFY), mySecCloseChkBox);
- QWidget::setTabOrder(mySecCloseChkBox, mySecTypeCmbBox);
- QWidget::setTabOrder(mySecTypeCmbBox, myEditSecPnts->getPointsEdit());
- QWidget::setTabOrder(myEditSecPnts->getPointsEdit(),
- myEditSecPnts->getPointsButton());
- QWidget::setTabOrder(myEditSecPnts->getPointsButton(), mySecAddModifBtn);
- QWidget::setTabOrder(mySecAddModifBtn, mySecRmBtn);
- QWidget::setTabOrder(mySecRmBtn, mySecJoinBtn);
- QWidget::setTabOrder(mySecJoinBtn, mySecJoinAllBtn);
- QWidget::setTabOrder(mySecJoinAllBtn, mySecClearBtn);
- QWidget::setTabOrder(mySecClearBtn, mySecList);
- QWidget::setTabOrder(mySecList, mySecUpBtn);
- QWidget::setTabOrder(mySecUpBtn, mySecDownBtn);
- QWidget::setTabOrder(mySecDownBtn, myEditPnts->getPointsEdit());
- QWidget::setTabOrder(myEditPnts->getPointsEdit(),
- myEditPnts->getPointsButton());
- QWidget::setTabOrder(myEditPnts->getPointsButton(), myAddPntsBtn);
- QWidget::setTabOrder(myAddPntsBtn, myInsertPntsBtn);
- QWidget::setTabOrder(myInsertPntsBtn, myRmPntsBtn);
- QWidget::setTabOrder(myRmPntsBtn, myPntsList);
-}
-
-//=======================================================================
-// function: undoOptionsChanged
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::undoOptionsChanged()
-{
- if (myUndoOptsDlg == NULL) {
- // Create the dialog.
- myUndoOptsDlg = new CurveCreator_UndoOptsDlg(this);
- }
-
- // set undo depth.
- myUndoOptsDlg->setUndoDepth(myEditor.getUndoDepth());
-
- const int aResult = myUndoOptsDlg->exec();
-
- if (aResult == QDialog::Accepted) {
- // Get undo depth.
- const int anUndoDepth = myUndoOptsDlg->getUndoDepth();
- const bool isEnabled = myUndoOptsDlg->isEnabled();
-
- myEditor.setUndoDepth(anUndoDepth);
-
- // Update options labels.
- myBufSizeUndoLbl->setVisible(isEnabled);
-
- if (isEnabled) {
- QString aSize;
-
- if (myUndoOptsDlg->isUnlimited()) {
- aSize = tr("CC_UNDO_REDO_UNLIMITED");
- } else {
- aSize = QString::number(anUndoDepth);
- }
-
- myEnabledUndoLbl->setText(tr("CC_UNDO_REDO_ENABLED"));
- myBufSizeUndoLbl->setText(tr("CC_UNDO_REDO_BUFFER_SIZE").arg(aSize));
- } else {
- myEnabledUndoLbl->setText(tr("CC_UNDO_REDO_DISABLED"));
- }
- }
-
- // Update Undo Redo buttons.
- updateUndoRedoButtons();
-}
-
-//=======================================================================
-// function: sectionAddOrModify
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::sectionAddOrModify()
-{
- const bool isClosed = mySecCloseChkBox->isChecked();
- CurveCreator::Type aType;
-
- if (mySecTypeCmbBox->currentIndex() == POLYLINE_INDEX) {
- aType = CurveCreator::Polyline;
- } else {
- aType = CurveCreator::BSpline;
- }
-
- if (mySecBtnGrp->checkedId() == SECTION_MODIFY) {
- // Modify section mode.
- QList<QListWidgetItem *> aListItems = mySecList->selectedItems();
-
- if (aListItems.size() == 1) {
- const int aRow = mySecList->row(aListItems.first());
- bool isModified = false;
- CurveCreator_Curve *aCurve = myEditor.getCurve();
-
-
- if (aCurve->getType(aRow) != aType) {
- // Set type.
- isModified = true;
- myEditor.setType(aType, aRow);
- }
-
- if (aCurve->isClosed(aRow) != isClosed) {
- // Set closed flag.
- isModified = true;
- myEditor.setClosed(isClosed, aRow);
- }
-
- if (isModified) {
- updateSectionItem(aRow, aType, isClosed);
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
- }
- } else {
- // Add section mode. Add section.
- myEditor.addSection(aType, isClosed, myEditSecPnts->getPoints());
- addSectionItem(aType, isClosed);
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
-}
-
-//=======================================================================
-// function: secButtonClicked
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::addModifChanged(int theId)
-{
- if (theId == SECTION_ADD) {
- // Add section
- myAddSecGrp->setTitle(tr("CC_SECTION_ADD_TITLE"));
- mySecAddModifBtn->setText(tr("CC_SECTION_NEW"));
- myEditSecPnts->setEnabled(true);
- mySecAddModifBtn->setEnabled(true);
- } else {
- // Modify section
- myAddSecGrp->setTitle(tr("CC_SECTION_MODIFICATION_TITLE"));
- mySecAddModifBtn->setText(tr("CC_SECTION_MODIFY"));
- myEditSecPnts->setEnabled(false);
- changeSecSelection();
- }
-}
-
-//=======================================================================
-// function: changeSecSelection
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::changeSecSelection()
-{
- // Update modify button and section data.
- QList<QListWidgetItem *> aListItems = mySecList->selectedItems();
- const int aNbItems = aListItems.size();
-
- if (mySecBtnGrp->checkedId() == SECTION_MODIFY) {
- // Modify section mode.
- if (aNbItems == 1) {
- // Initialize type and closed flags.
- CurveCreator_Curve *aCurve = myEditor.getCurve();
- const int anIndex = mySecList->row(aListItems.first());
-
- mySecAddModifBtn->setEnabled(true);
- mySecCloseChkBox->setChecked(aCurve->isClosed(anIndex));
-
- if (aCurve->getType(anIndex) == CurveCreator::Polyline) {
- mySecTypeCmbBox->setCurrentIndex(POLYLINE_INDEX);
- } else {
- mySecTypeCmbBox->setCurrentIndex(BSPLINE_INDEX);
- }
- } else if (mySecAddModifBtn->isEnabled()) {
- mySecAddModifBtn->setEnabled(false);
- }
- } else {
- // Add section mode.
- mySecAddModifBtn->setEnabled(true);
- }
-
- // Set enabled remove, up and down points.
- bool isEnabled = (aNbItems > 0);
- const int aCount = mySecList->count();
-
- mySecRmBtn->setEnabled(isEnabled);
- isEnabled &= (aNbItems < aCount);
- mySecUpBtn->setEnabled(isEnabled);
- mySecDownBtn->setEnabled(isEnabled);
- mySecJoinBtn->setEnabled(aNbItems == 2);
-
- // Init points.
- myPntsGrp->setEnabled(aNbItems == 1);
-
- if (aNbItems == 1) {
- const int aSecIndex = mySecList->row(aListItems.first());
-
- initPoints(aSecIndex);
- } else {
- initPoints(-1);
- }
-}
-
-//=======================================================================
-// function: sectionRemove
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::sectionRemove()
-{
- QList<QListWidgetItem *> aListItems = mySecList->selectedItems();
-
- if (!aListItems.empty()) {
- QList<int> aListRows;
-
- // Get items rows.
- foreach(QListWidgetItem *anItem, aListItems) {
- aListRows.append(mySecList->row(anItem));
- }
-
- // Delete items.
- foreach(QListWidgetItem *anItem, aListItems) {
- delete anItem;
- }
-
- qSort(aListRows);
-
- // Delete points from curve.
- const int aNbPnts = aListRows.size();
- int i;
-
- for (i = aNbPnts - 1; i >= 0; i--) {
- myEditor.removeSection(aListRows[i]);
- }
-
- // Set the new selection.
- int aRow = aListRows[0];
-
- if (aListRows[0] >= mySecList->count()) {
- aRow = mySecList->count() - 1;
- }
-
- if (aRow >= 0) {
- mySecList->item(aRow)->setSelected(true);
- }
-
- emit numberOfItemsChanged(mySecList);
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
-}
-
-//=======================================================================
-// function: sectionJoin
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::sectionJoin()
-{
- QList<QListWidgetItem *> aListItems = mySecList->selectedItems();
-
- if (aListItems.size() == 2) {
- int aRowTo = mySecList->row(aListItems.first());
- int aRowFrom = mySecList->row(aListItems.last());
-
- if (aRowTo > aRowFrom) {
- // Swap rows.
- int aTmp = aRowTo;
-
- aRowTo = aRowFrom;
- aRowFrom = aTmp;
- }
-
- // Join two sections.
- myEditor.join(aRowTo, aRowFrom);
- delete mySecList->takeItem(aRowFrom);
- emit numberOfItemsChanged(mySecList);
- // Select the joined item.
- mySecList->item(aRowTo)->setSelected(true);
- changeSecSelection();
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
-}
-
-//=======================================================================
-// function: sectionJoinAll
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::sectionJoinAll()
-{
- const int aNbItems = mySecList->count();
-
- if (aNbItems > 1) {
- // Join two sections.
- myEditor.join();
-
- // Update mySecList.
- for (int i = 1; i < aNbItems; i++) {
- delete mySecList->takeItem(1);
- }
-
- emit numberOfItemsChanged(mySecList);
- // Select the joined item.
- mySecList->item(0)->setSelected(true);
- changeSecSelection();
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
-}
-
-//=======================================================================
-// function: sectionClear
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::sectionClear()
-{
- bool isEmpty = (mySecList->count() == 0);
-
- if (!isEmpty) {
- mySecList->clear();
- myEditor.clear();
- emit numberOfItemsChanged(mySecList);
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
-}
-
-//=======================================================================
-// function: sectionUp
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::sectionUp()
-{
- sectionMove(-1);
-}
-
-//=======================================================================
-// function: sectionDown
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::sectionDown()
-{
- sectionMove(1);
-}
-
-//=======================================================================
-// function: onNumberOfItemsChanged
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::onNumberOfItemsChanged(QListWidget *theListWidget)
-{
- if (theListWidget == mySecList) {
- // List of sections is modified.
- mySecJoinAllBtn->setEnabled(mySecList->count() > 1);
- mySecClearBtn->setEnabled(mySecList->count() > 0);
- } else {
- // List of points is modified.
- QList<QListWidgetItem *> aListItems = myPntsList->selectedItems();
- const int aNbItems = aListItems.size();
-
- myRmPntsBtn->setEnabled(aNbItems > 0);
- }
-}
-
-//=======================================================================
-// function: changePntsSelection
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::changePntsSelection()
-{
- // Update modify buttons and section data.
- QList<QListWidgetItem *> aListItems = myPntsList->selectedItems();
- const int aNbItems = aListItems.size();
- const int aCount = myPntsList->count();
-
- myRmPntsBtn->setEnabled(aNbItems > 0);
- myInsertPntsBtn->setEnabled(aCount == 0 || aNbItems == 1);
-}
-
-//=======================================================================
-// function: editPnt
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::editPnt(QListWidgetItem *theItem)
-{
- if (theItem != NULL) {
- if (myPntEditDlg == NULL) {
- // Create the dialog.
- myPntEditDlg = new CurveCreator_EditPntDlg(this, myDimension);
- }
-
- // Get coordinates.
- CurveCreator_PointItem *aPntItem = (CurveCreator_PointItem *)theItem;
- CurveCreator::Coordinates aPoint;
-
- aPoint.push_back(aPntItem->getX());
- aPoint.push_back(aPntItem->getY());
-
- if (myDimension == CurveCreator::Dim3d) {
- aPoint.push_back(aPntItem->getZ());
- }
-
- myPntEditDlg->setPoint(aPoint);
-
- const int aResult = myPntEditDlg->exec();
-
- if (aResult == QDialog::Accepted) {
- // Get the section index.
- const int aSectionIndex = getCurrentSectionIndex();
-
- if (aSectionIndex >= 0) {
- // Update the point.
- const CurveCreator::Coordinates &aNewPoint = myPntEditDlg->getPoint();
-
- if (myDimension == CurveCreator::Dim3d) {
- aPntItem->setCoord(aNewPoint[0], aNewPoint[1], aNewPoint[2]);
- } else {
- aPntItem->setCoord(aNewPoint[0], aNewPoint[1]);
- }
-
- // Update curve
- const int aPntIndex = myPntsList->row(theItem);
-
- myEditor.setCoordinates(aNewPoint, aSectionIndex, aPntIndex);
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
- }
- }
-}
-
-//=======================================================================
-// function: pntsAdd
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::pntsAdd()
-{
- const CurveCreator::Coordinates &aNewPoints = myEditPnts->getPoints();
- const int aNbCoords = aNewPoints.size();
-
- if (aNbCoords > 0 && aNbCoords % myDimension == 0) {
- // Get the section index.
- const int aSectionIndex = getCurrentSectionIndex();
-
- if (aSectionIndex >= 0) {
- // Update list.
- int i = 0;
-
- while (i < aNbCoords) {
- const CurveCreator::TypeCoord aX = aNewPoints[i++];
- const CurveCreator::TypeCoord aY = aNewPoints[i++];
-
- if (myDimension == CurveCreator::Dim3d) {
- const CurveCreator::TypeCoord aZ = aNewPoints[i++];
-
- new CurveCreator_PointItem(aX, aY, aZ, myPntsList);
- } else {
- new CurveCreator_PointItem(aX, aY, myPntsList);
- }
- }
-
- // Update curve
- myEditor.addPoints(aNewPoints, aSectionIndex);
- emit numberOfItemsChanged(myPntsList);
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
- }
-}
-
-//=======================================================================
-// function: pntsInsert
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::pntsInsert()
-{
- const CurveCreator::Coordinates &aNewPoints = myEditPnts->getPoints();
- const int aNbCoords = aNewPoints.size();
-
- if (aNbCoords > 0 && aNbCoords % myDimension == 0) {
- // Get the section index.
- const int aSectionIndex = getCurrentSectionIndex();
-
- if (aSectionIndex >= 0) {
- // Get the selected point index.
- int aPntIndex = -1;
- QList<QListWidgetItem *> aListPnts = myPntsList->selectedItems();
-
- if (aListPnts.size() == 1) {
- aPntIndex = myPntsList->row(aListPnts.first());
- }
-
- // Update list.
- int i = 0;
- int aRow = aPntIndex;
-
- while (i < aNbCoords) {
- const CurveCreator::TypeCoord aX = aNewPoints[i++];
- const CurveCreator::TypeCoord aY = aNewPoints[i++];
- CurveCreator_PointItem *aNewItem = NULL;
-
- if (myDimension == CurveCreator::Dim3d) {
- const CurveCreator::TypeCoord aZ = aNewPoints[i++];
-
- aNewItem = new CurveCreator_PointItem(aX, aY, aZ);
- } else {
- aNewItem = new CurveCreator_PointItem(aX, aY);
- }
-
-
- if (aPntIndex < 0) {
- // Append point.
- myPntsList->addItem(aNewItem);
- } else {
- // Insert point.
- myPntsList->insertItem(aRow++, aNewItem);
- }
- }
-
- // Update curve
- myEditor.insertPoints(aNewPoints, aSectionIndex, aPntIndex);
- emit numberOfItemsChanged(myPntsList);
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
- }
-}
-
-//=======================================================================
-// function: pntsRemove
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::pntsRemove()
-{
- QList<QListWidgetItem *> aListItems = myPntsList->selectedItems();
- const int aSectionIndex = getCurrentSectionIndex();
-
- if (aSectionIndex >= 0 && aListItems.size() > 0) {
- QList<int> aListRows;
-
- // Get items rows.
- foreach(QListWidgetItem *anItem, aListItems) {
- aListRows.append(myPntsList->row(anItem));
- }
-
- // Delete items.
- foreach(QListWidgetItem *anItem, aListItems) {
- delete anItem;
- }
-
- qSort(aListRows);
-
- // Delete points from curve.
- const int aNbPnts = aListRows.size();
- int aNbPntsRm = 1;
- int aCurRow = aListRows.last();
- int i;
-
- for (i = aNbPnts - 2; i >= 0; i--) {
- if (aListRows[i] == aCurRow - 1) {
- // This is the previous index.
- aCurRow--;
- aNbPntsRm++;
- } else {
- // This is not the previous index. Remove the current chain of points.
- myEditor.removePoints(aSectionIndex, aCurRow, aNbPntsRm);
- aCurRow = aListRows[i];
- aNbPntsRm = 1;
- }
- }
-
- // Remove last points.
- myEditor.removePoints(aSectionIndex, aCurRow, aNbPntsRm);
-
- emit numberOfItemsChanged(myPntsList);
-
- // Set the new selection.
- int aRow = aListRows.first();
-
- if (aRow >= myPntsList->count()) {
- aRow = myPntsList->count() - 1;
- }
-
- if (aRow >= 0) {
- myPntsList->item(aRow)->setSelected(true);
- }
-
- // Update undo/redo buttons.
- updateUndoRedoButtons();
- }
-}
-
-//=======================================================================
-// function: undo
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::undo()
-{
- if (myEditor.getNbUndo() > 0) {
- // Perform undo
- myEditor.undo();
-
- // Reinitialize required widgets.
- updateUndoRedo();
- }
-}
-
-//=======================================================================
-// function: redo
-// purpose:
-//=======================================================================
-void CurveCreator_Widget::redo()
-{
- if (myEditor.getNbRedo() > 0) {
- // Perform undo
- myEditor.redo();
-
- // Reinitialize required widgets.
- updateUndoRedo();
- }
-}
+#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_Curve.hxx"\r
+#include "CurveCreator_CurveEditor.hxx"\r
+\r
+#include <SUIT_Session.h>\r
+#include <SUIT_ResourceMgr.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
+#include <QPixmap>\r
+\r
+CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,\r
+ CurveCreator_Curve *theCurve,\r
+ Qt::WindowFlags fl ) :\r
+ QWidget(parent), myNewPointEditor(NULL)\r
+{\r
+ myCurve = theCurve; \r
+ myEdit = new CurveCreator_CurveEditor( myCurve );\r
+\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
+\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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );\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, \r
+ const QPixmap& theImage, const QString& theToolTip, \r
+ 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
+}\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
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File: CurveCreator_Widget.h
-// Created: Mon Jul 01 12:49:21 2013
-// Author: Sergey KHROMOV
-//
-
-#ifndef _CurveCreator_Widget_HeaderFile
-#define _CurveCreator_Widget_HeaderFile
-
-
-#include <QWidget>
-#include <CurveCreator_CurveEditor.hxx>
-
-class CurveCreator_Curve;
-class QGroupBox;
-class QButtonGroup;
-class QComboBox;
-class QCheckBox;
-class QPushButton;
-class QLabel;
-class QListWidget;
-class QListWidgetItem;
-class CurveCreator_EditPntsWidget;
-class CurveCreator_EditPntDlg;
-class CurveCreator_UndoOptsDlg;
-
-
-class CurveCreator_Widget : public QWidget
-{
- Q_OBJECT
-
-public:
-
- CurveCreator_Widget(QWidget* parent,
- CurveCreator_Curve *theCurve,
- Qt::WindowFlags fl = 0);
-
-private:
-
- void init();
-
- void initSections();
-
- void addSectionItem(const CurveCreator::Type theType, const bool isClosed);
-
- void updateSectionItem(const int theRow, const CurveCreator::Type theType,
- const bool isClosed);
-
- void sectionMove(const int theShift);
-
- void initPoints(const int theSectionIndex);
-
- int getCurrentSectionIndex();
-
- void updateUndoRedo();
-
- void updateUndoRedoButtons();
-
- void setTabOrder();
-
-private slots:
-
- void undoOptionsChanged();
-
- void sectionAddOrModify();
-
- void addModifChanged(int theId);
-
- void changeSecSelection();
-
- void sectionRemove();
-
- void sectionJoin();
-
- void sectionJoinAll();
-
- void sectionClear();
-
- void sectionUp();
-
- void sectionDown();
-
- void onNumberOfItemsChanged(QListWidget *theListWidget);
-
- void changePntsSelection();
-
- void editPnt(QListWidgetItem *theItem);
-
- void pntsAdd();
-
- void pntsInsert();
-
- void pntsRemove();
-
- void undo();
-
- void redo();
-
-signals:
-
- void numberOfItemsChanged(QListWidget *theListWidget);
-
-protected:
-
- CurveCreator_CurveEditor myEditor;
- CurveCreator::Dimension myDimension;
- // Undo/redo widgets
- QLabel *myEnabledUndoLbl;
- QLabel *myBufSizeUndoLbl;
- QPushButton *myUndoBtn;
- QPushButton *myRedoBtn;
- QPushButton *myUndoOptsBtn;
- CurveCreator_UndoOptsDlg *myUndoOptsDlg;
- // Sections widgets
- QGroupBox *myAddSecGrp;
- QButtonGroup *mySecBtnGrp;
- QComboBox *mySecTypeCmbBox;
- QCheckBox *mySecCloseChkBox;
- QPushButton *mySecAddModifBtn;
- QPushButton *mySecRmBtn;
- QPushButton *mySecJoinBtn;
- QPushButton *mySecJoinAllBtn;
- QPushButton *mySecClearBtn;
- QPushButton *mySecUpBtn;
- QPushButton *mySecDownBtn;
- QListWidget *mySecList;
- CurveCreator_EditPntsWidget *myEditSecPnts;
- // Points widgets
- QGroupBox *myPntsGrp;
- QListWidget *myPntsList;
- CurveCreator_EditPntDlg *myPntEditDlg;
- CurveCreator_EditPntsWidget *myEditPnts;
- QPushButton *myAddPntsBtn;
- QPushButton *myInsertPntsBtn;
- QPushButton *myRmPntsBtn;
-
-};
-
-#endif
+#ifndef CURVECREATOR_WIDGET_H\r
+#define CURVECREATOR_WIDGET_H\r
+\r
+#include "CurveCreator_Curve.hxx"\r
+\r
+#include <QWidget>\r
+\r
+#include <QMap>\r
+\r
+class QAction;\r
+class QPixmap;\r
+class CurveCreator_CurveEditor;\r
+class CurveCreator_TreeView;\r
+class CurveCreator_NewPointDlg;\r
+class CurveCreator_NewSectionDlg;\r
+\r
+class CurveCreator_Widget : public QWidget\r
+{\r
+ Q_OBJECT\r
+public:\r
+ explicit CurveCreator_Widget( QWidget* parent,\r
+ CurveCreator_Curve *theCurve,\r
+ Qt::WindowFlags fl=0 );\r
+ \r
+signals:\r
+ \r
+public slots:\r
+\r
+protected slots:\r
+ void onNewPoint();\r
+ void onNewSection();\r
+ void onSelectionChanged();\r
+ void onAddNewPoint();\r
+ void onAddNewSection();\r
+ void onEditSection( int theSection );\r
+ void onEditPoint( int theSection, int thePoint );\r
+ void onJoin();\r
+ void onRemove();\r
+ void onMoveUp();\r
+ void onMoveDown();\r
+ void onClearAll();\r
+ void onJoinAll();\r
+ void onInsertSectionBefore();\r
+ void onInsertSectionAfter();\r
+ void onSetSpline();\r
+ void onSetPolyline();\r
+ void onCloseSections();\r
+ void onUncloseSections();\r
+ void onInsertPointBefore();\r
+ void onInsertPointAfter();\r
+ void onUndoSettings();\r
+ void onContextMenu(QPoint thePoint);\r
+protected:\r
+ enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, NEW_POINT_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID,\r
+ JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID,\r
+ INSERT_POINT_BEFORE_ID, INSERT_POINT_AFTER_ID, CLOSE_SECTIONS_ID, UNCLOSE_SECTIONS_ID,\r
+ SET_SECTIONS_POLYLINE_ID, SET_SECTIONS_SPLINE_ID, CLEAR_ALL_ID, SEPARATOR_ID };\r
+private:\r
+ QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,\r
+ const QString& theToolTip, const QKeySequence& theShortcut );\r
+ QAction* getAction(ActionId theId);\r
+private:\r
+ QMap<ActionId, QAction*> myActionMap;\r
+ CurveCreator_Curve* myCurve;\r
+ CurveCreator_CurveEditor* myEdit;\r
+ CurveCreator_TreeView* mySectionView;\r
+ CurveCreator_NewPointDlg* myNewPointEditor;\r
+ CurveCreator_NewSectionDlg* myNewSectionEditor;\r
+ int mySection;\r
+ int myPointNum;\r
+};\r
+\r
+#endif // CURVECREATOR_WIDGET_H\r
# Compilation options for GUI mode
if GEOM_ENABLE_GUI
dist_libCurveCreator_la_SOURCES += \
- CurveCreator_PointItem.h \
- CurveCreator_UndoOptsDlg.h \
- CurveCreator_EditPntDlg.h \
- CurveCreator_EditPntsDlg.h \
- CurveCreator_EditPntsWidget.h \
- CurveCreator_Widget.h \
- CurveCreator_PointItem.cxx \
- CurveCreator_UndoOptsDlg.cxx \
- CurveCreator_EditPntDlg.cxx \
- CurveCreator_EditPntsDlg.cxx \
- CurveCreator_EditPntsWidget.cxx \
+ CurveCreator_NewPointDlg.h \
+ CurveCreator_NewSection.h \
+ CurveCreator_TreeView.h \
+ CurveCreator_Widget.h \
+ CurveCreator_NewPointDlg.cxx \
+ CurveCreator_NewSectionDlg.cxx \
+ CurveCreator_TreeView.cxx \
CurveCreator_Widget.cxx
salomeinclude_HEADERS += \
- CurveCreator_PointItem.h \
- CurveCreator_UndoOptsDlg.h \
- CurveCreator_EditPntDlg.h \
- CurveCreator_EditPntsDlg.h \
- CurveCreator_EditPntsWidget.h \
+ CurveCreator_NewPointDlg.h \
+ CurveCreator_NewSectionDlg.h \
+ CurveCreator_TreeView.h \
CurveCreator_Widget.h
MOC_FILES = \
- CurveCreator_UndoOptsDlg_moc.cxx \
- CurveCreator_EditPntDlg_moc.cxx \
- CurveCreator_EditPntsDlg_moc.cxx \
- CurveCreator_EditPntsWidget_moc.cxx \
+ CurveCreator_NewPointDlg_moc.cxx \
+ CurveCreator_NewSectionDlg_moc.cxx \
+ CurveCreator_TreeView_moc.cxx \
CurveCreator_Widget_moc.cxx
nodist_libCurveCreator_la_SOURCES = $(MOC_FILES)
libCurveCreator_la_CPPFLAGS = \
$(QT_INCLUDES) \
$(CAS_CPPFLAGS) \
- $(KERNEL_CXXFLAGS)
+ $(KERNEL_CXXFLAGS) \
+ $(GUI_CXXFLAGS)
libCurveCreator_la_LDFLAGS = \
$(KERNEL_LDFLAGS) \