mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-14 08:51:34 +05:00
CurveCreator was updated
This commit is contained in:
parent
31f45c228c
commit
9b88d11eb3
@ -143,6 +143,11 @@ bool CurveCreator_Curve::isClosed(const int theISection) const
|
||||
return mySections.at(theISection)->myIsClosed;
|
||||
}
|
||||
|
||||
std::string CurveCreator_Curve::getSectionName(const int theISection) const
|
||||
{
|
||||
return mySections.at(theISection)->myName;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setType
|
||||
// purpose:
|
||||
@ -181,12 +186,18 @@ void CurveCreator_Curve::addPoints
|
||||
// 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;
|
||||
@ -231,6 +242,16 @@ void CurveCreator_Curve::insertPoints
|
||||
}
|
||||
}
|
||||
|
||||
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:
|
||||
@ -304,6 +325,15 @@ void CurveCreator_Curve::setClosed(const bool theIsClosed,
|
||||
}
|
||||
}
|
||||
|
||||
/** 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:
|
||||
@ -376,3 +406,24 @@ int CurveCreator_Curve::toICoord(const int theIPnt) const
|
||||
{
|
||||
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 "";
|
||||
}
|
||||
|
@ -86,6 +86,13 @@ public:
|
||||
//! Get “closed” 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
|
||||
@ -100,7 +107,7 @@ protected:
|
||||
(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);
|
||||
|
||||
@ -123,6 +130,12 @@ protected:
|
||||
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();
|
||||
|
||||
@ -136,6 +149,10 @@ protected:
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -229,7 +229,7 @@ void CurveCreator_CurveEditor::addPoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::addSection
|
||||
(const CurveCreator::Type theType,
|
||||
(const std::string& theName, const CurveCreator::Type theType,
|
||||
const bool theIsClosed,
|
||||
const CurveCreator::Coordinates &thePoints)
|
||||
{
|
||||
@ -241,7 +241,7 @@ void CurveCreator_CurveEditor::addSection
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->addSection(theType, theIsClosed, thePoints);
|
||||
myPCurve->addSection(theName, theType, theIsClosed, thePoints);
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,6 +284,17 @@ void CurveCreator_CurveEditor::insertPoints
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: movePoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::movePoint(const int theISection,
|
||||
const int theOrigIPnt,
|
||||
const int theNewIPnt )
|
||||
{
|
||||
myPCurve->movePoint(theISection, theOrigIPnt, theNewIPnt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: removePoints
|
||||
// purpose:
|
||||
@ -362,6 +373,16 @@ void CurveCreator_CurveEditor::setClosed(const bool theIsClosed,
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setName
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::setName(const std::string& theName,
|
||||
const int theISection)
|
||||
{
|
||||
myPCurve->setName( theName, theISection );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: moveSection
|
||||
// purpose:
|
||||
|
@ -81,6 +81,15 @@ public:
|
||||
*/
|
||||
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).
|
||||
*/
|
||||
@ -88,7 +97,7 @@ public:
|
||||
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);
|
||||
|
||||
@ -111,6 +120,13 @@ public:
|
||||
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();
|
||||
|
||||
@ -119,11 +135,6 @@ public:
|
||||
const int theISection,
|
||||
const int theIPnt);
|
||||
|
||||
/** Set “closed” 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.
|
||||
*/
|
||||
|
@ -1,218 +0,0 @@
|
||||
// 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();
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
// 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
|
@ -1,540 +0,0 @@
|
||||
// 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);
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
// 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
|
@ -1,236 +0,0 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
// 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
|
||||
|
147
src/CurveCreator/CurveCreator_NewPointDlg.cxx
Executable file
147
src/CurveCreator/CurveCreator_NewPointDlg.cxx
Executable file
@ -0,0 +1,147 @@
|
||||
#include "CurveCreator_NewPointDlg.h"
|
||||
#include <QGridLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDoubleValidator>
|
||||
#include <QRegExpValidator>
|
||||
#include <QAbstractButton>
|
||||
#include <QPushButton>
|
||||
#include <QLocale>
|
||||
|
||||
CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) :
|
||||
QDialog(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false)
|
||||
{
|
||||
QGridLayout* aCoordLay = new QGridLayout();
|
||||
|
||||
QString aTitle = QString(tr("ADD_NEW_POINT"));
|
||||
setWindowTitle(aTitle);
|
||||
|
||||
QLabel* aLbl = new QLabel( tr("X_COORD"), this);
|
||||
myX = new QDoubleSpinBox(this);
|
||||
aCoordLay->addWidget(aLbl, 0, 0);
|
||||
aCoordLay->addWidget(myX, 0, 1 );
|
||||
|
||||
aLbl = new QLabel( tr("Y_COORD"), this);
|
||||
myY = new QDoubleSpinBox(this);
|
||||
aCoordLay->addWidget(aLbl, 1, 0 );
|
||||
aCoordLay->addWidget(myY, 1, 1 );
|
||||
|
||||
if( theDim == CurveCreator::Dim3d ){
|
||||
aLbl = new QLabel( tr("Z_COORD"), this);
|
||||
myZ = new QDoubleSpinBox(this);
|
||||
aCoordLay->addWidget(aLbl, 2,0 );
|
||||
aCoordLay->addWidget(myZ, 2,1 );
|
||||
}
|
||||
|
||||
myBtnBox = new QDialogButtonBox(this);
|
||||
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
|
||||
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
|
||||
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
|
||||
|
||||
connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
|
||||
QVBoxLayout* aMainLay = new QVBoxLayout();
|
||||
aMainLay->addLayout(aCoordLay);
|
||||
aMainLay->addWidget(myBtnBox);
|
||||
setLayout(aMainLay);
|
||||
clear();
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::setSectionName( const QString& theName )
|
||||
{
|
||||
mySectionName = theName;
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::setEditMode( bool isEdit )
|
||||
{
|
||||
myIsEdit = isEdit;
|
||||
if( myIsEdit ){
|
||||
myContBtn->hide();
|
||||
myAddBtn->setText(tr("OK"));
|
||||
}
|
||||
else{
|
||||
myContBtn->show();
|
||||
myAddBtn->setText(tr("ADD_BTN"));
|
||||
}
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::updateTitle()
|
||||
{
|
||||
QString aTitle;
|
||||
if( !myIsEdit ){
|
||||
if( mySectionName.isEmpty() ){
|
||||
aTitle = tr("ADD_NEW_POINT");
|
||||
}
|
||||
else{
|
||||
aTitle = QString(tr("ADD_NEW_POINT_TO_%1")).arg(mySectionName);
|
||||
}
|
||||
}
|
||||
else{
|
||||
aTitle = tr("SET_POINT_COORDINATES");
|
||||
}
|
||||
setWindowTitle(aTitle);
|
||||
}
|
||||
|
||||
CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const
|
||||
{
|
||||
CurveCreator::Coordinates aCoords;
|
||||
double anX = myX->value();
|
||||
aCoords.push_back(anX);
|
||||
double anY = myY->value();
|
||||
aCoords.push_back(anY);
|
||||
if( myZ ){
|
||||
double aZ = myZ->value();
|
||||
aCoords.push_back(aZ);
|
||||
}
|
||||
return aCoords;
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )
|
||||
{
|
||||
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
|
||||
emit addPoint();
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::clear()
|
||||
{
|
||||
initSpinBox(myX);
|
||||
initSpinBox(myY);
|
||||
if( myZ )
|
||||
initSpinBox(myZ);
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::setCoordinates( const CurveCreator::Coordinates& theCoords )
|
||||
{
|
||||
double anX = theCoords[0];
|
||||
myX->setValue(anX);
|
||||
double anY = theCoords[1];
|
||||
myY->setValue(anY);
|
||||
if( myZ && ( theCoords.size() == 3)){
|
||||
double aZ = theCoords[2];
|
||||
myZ->setValue(aZ);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: initSpinBox
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_NewPointDlg::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);
|
||||
}
|
43
src/CurveCreator/CurveCreator_NewPointDlg.h
Executable file
43
src/CurveCreator/CurveCreator_NewPointDlg.h
Executable file
@ -0,0 +1,43 @@
|
||||
#ifndef CURVECREATOR_NEWPOINTDLG_H
|
||||
#define CURVECREATOR_NEWPOINTDLG_H
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
class QDialogButtonBox;
|
||||
class QAbstractButton;
|
||||
class QPushButton;
|
||||
|
||||
class CurveCreator_NewPointDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent = 0);
|
||||
CurveCreator::Coordinates getCoordinates() const;
|
||||
void clear();
|
||||
void setSectionName( const QString& theName );
|
||||
void setEditMode( bool isEdit );
|
||||
void setCoordinates( const CurveCreator::Coordinates& theCoords );
|
||||
signals:
|
||||
void addPoint();
|
||||
public slots:
|
||||
protected slots:
|
||||
void onBtnClicked(QAbstractButton* theBtn );
|
||||
protected:
|
||||
void updateTitle();
|
||||
void initSpinBox(QDoubleSpinBox *theSpinBox);
|
||||
private:
|
||||
QDialogButtonBox* myBtnBox;
|
||||
CurveCreator::Dimension myDim;
|
||||
QDoubleSpinBox* myX;
|
||||
QDoubleSpinBox* myY;
|
||||
QDoubleSpinBox* myZ;
|
||||
QPushButton* myContBtn;
|
||||
QPushButton* myAddBtn;
|
||||
bool myIsEdit;
|
||||
QString mySectionName;
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_NEWPOINTDLG_H
|
123
src/CurveCreator/CurveCreator_NewSectionDlg.cxx
Executable file
123
src/CurveCreator/CurveCreator_NewSectionDlg.cxx
Executable file
@ -0,0 +1,123 @@
|
||||
#include "CurveCreator_NewSectionDlg.h"
|
||||
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
|
||||
QDialog(parent)
|
||||
{
|
||||
std::string aNameStr;
|
||||
QGridLayout* aLay = new QGridLayout();
|
||||
QLabel* aLbl = new QLabel(tr("NAME"), this);
|
||||
myName = new QLineEdit(this);
|
||||
aLay->addWidget(aLbl, 0, 0);
|
||||
aLay->addWidget(myName, 0 , 1);
|
||||
|
||||
aLbl = new QLabel(tr("LINE_TYPE"));
|
||||
myLineType = new QComboBox(this);
|
||||
QPixmap aPolylineImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
||||
myLineType->addItem(aPolylineImage, tr("POLYLINE_TYPE"));
|
||||
QPixmap aSplineImage(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
||||
myLineType->addItem(aSplineImage,tr("SPLINE_TYPE"));
|
||||
myLineType->setCurrentIndex(0);
|
||||
aLay->addWidget(aLbl, 1, 0);
|
||||
aLay->addWidget(myLineType, 1 , 1);
|
||||
|
||||
aLbl = new QLabel(tr("LINE_CLOSED"));
|
||||
myIsClosed = new QCheckBox(this);
|
||||
aLay->addWidget(aLbl, 2, 0);
|
||||
aLay->addWidget(myIsClosed, 2, 1);
|
||||
|
||||
myBtnBox = new QDialogButtonBox(this);
|
||||
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
|
||||
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
|
||||
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
|
||||
|
||||
connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
|
||||
|
||||
QVBoxLayout* aMainLay = new QVBoxLayout();
|
||||
aMainLay->addLayout(aLay);
|
||||
aMainLay->addWidget(myBtnBox);
|
||||
setLayout(aMainLay);
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType )
|
||||
{
|
||||
myName->setText(theName);
|
||||
myIsClosed->setChecked(isClosed);
|
||||
if( theType == CurveCreator::Polyline )
|
||||
myLineType->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::clear()
|
||||
{
|
||||
myName->setText("");
|
||||
myIsClosed->setChecked(true);
|
||||
myLineType->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
|
||||
{
|
||||
myIsEdit = isEdit;
|
||||
if( myIsEdit ){
|
||||
myContBtn->hide();
|
||||
myAddBtn->setText(tr("OK"));
|
||||
}
|
||||
else{
|
||||
myContBtn->show();
|
||||
myAddBtn->setText(tr("ADD_BTN"));
|
||||
}
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
QString CurveCreator_NewSectionDlg::getName() const
|
||||
{
|
||||
return myName->text();
|
||||
}
|
||||
|
||||
bool CurveCreator_NewSectionDlg::isClosed() const
|
||||
{
|
||||
return myIsClosed->isChecked();
|
||||
}
|
||||
|
||||
CurveCreator::Type CurveCreator_NewSectionDlg::getSectionType() const
|
||||
{
|
||||
if( myLineType->currentIndex() == 0 )
|
||||
return CurveCreator::Polyline;
|
||||
else
|
||||
return CurveCreator::BSpline;
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::updateTitle()
|
||||
{
|
||||
QString aTitle;
|
||||
if( !myIsEdit )
|
||||
aTitle = tr("ADD_NEW_SECTION");
|
||||
else
|
||||
aTitle = QString(tr("SET_SECTION_PARAMETERS"));
|
||||
setWindowTitle(aTitle);
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )
|
||||
{
|
||||
myName->setText(theName);
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::onBtnClicked(QAbstractButton* theBtn )
|
||||
{
|
||||
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
|
||||
emit addSection();
|
||||
}
|
||||
}
|
49
src/CurveCreator/CurveCreator_NewSectionDlg.h
Executable file
49
src/CurveCreator/CurveCreator_NewSectionDlg.h
Executable file
@ -0,0 +1,49 @@
|
||||
#ifndef CURVECREATOR_NEWSECTION_H
|
||||
#define CURVECREATOR_NEWSECTION_H
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class CurveCreator_Curve;
|
||||
|
||||
class QLineEdit;
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
class QPushButton;
|
||||
class QAbstractButton;
|
||||
class QDialogButtonBox;
|
||||
|
||||
class CurveCreator_NewSectionDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CurveCreator_NewSectionDlg(QWidget *parent = 0);
|
||||
|
||||
QString getName() const;
|
||||
bool isClosed() const;
|
||||
CurveCreator::Type getSectionType() const;
|
||||
|
||||
void setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType );
|
||||
void setSectionName(const QString& theName );
|
||||
void clear();
|
||||
void setEditMode( bool isEdit );
|
||||
|
||||
signals:
|
||||
void addSection();
|
||||
public slots:
|
||||
protected slots:
|
||||
void onBtnClicked(QAbstractButton* theBtn );
|
||||
protected:
|
||||
void updateTitle();
|
||||
private:
|
||||
QLineEdit* myName;
|
||||
QComboBox* myLineType;
|
||||
QCheckBox* myIsClosed;
|
||||
bool myIsEdit;
|
||||
QPushButton* myContBtn;
|
||||
QPushButton* myAddBtn;
|
||||
QDialogButtonBox* myBtnBox;
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_NEWSECTION_H
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <CurveCreator_Operation.hxx>
|
||||
#include <CurveCreator_Curve.hxx>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@ -273,7 +274,7 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
|
||||
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:
|
||||
|
@ -59,7 +59,8 @@ public:
|
||||
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
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,153 +0,0 @@
|
||||
// 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);
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
// 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
|
@ -31,14 +31,16 @@
|
||||
|
||||
#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
|
||||
|
422
src/CurveCreator/CurveCreator_TreeView.cxx
Executable file
422
src/CurveCreator/CurveCreator_TreeView.cxx
Executable file
@ -0,0 +1,422 @@
|
||||
#include "CurveCreator_TreeView.h"
|
||||
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QtAlgorithms>
|
||||
|
||||
#define ID_SECTION -1
|
||||
|
||||
CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent ) :
|
||||
QAbstractItemModel(parent), myCurve(theCurve)
|
||||
{
|
||||
QPixmap aSplineIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
||||
if( !aSplineIcon.isNull() )
|
||||
myCachedIcons[ICON_SPLINE] = aSplineIcon;
|
||||
|
||||
QPixmap aPolylineIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
|
||||
if( !aPolylineIcon.isNull() )
|
||||
myCachedIcons[ICON_POLYLINE] = aPolylineIcon;
|
||||
|
||||
QPixmap aClosedPolylineIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_CLOSED_POLYLINE")));
|
||||
if( !aPolylineIcon.isNull() )
|
||||
myCachedIcons[ICON_CLOSED_POLYLINE] = aClosedPolylineIcon;
|
||||
|
||||
QPixmap aClosedSplineIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_CLOSED_SPLINE")));
|
||||
if( !aPolylineIcon.isNull() )
|
||||
myCachedIcons[ICON_CLOSED_SPLINE] = aClosedSplineIcon;
|
||||
|
||||
QPixmap aPointIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_CC_POINT")));
|
||||
if( !aPointIcon.isNull() )
|
||||
myCachedIcons[ICON_POINT] = aPointIcon;
|
||||
|
||||
}
|
||||
|
||||
int CurveCreator_TreeViewModel::columnCount(const QModelIndex & parent ) const
|
||||
{
|
||||
if( parent.internalId() == ID_SECTION )
|
||||
return 1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
QVariant CurveCreator_TreeViewModel::data(const QModelIndex & index, int role ) const
|
||||
{
|
||||
int aRow = index.row();
|
||||
int aColumn = index.column();
|
||||
if( myCurve ){
|
||||
if( index.internalId() == ID_SECTION ){
|
||||
if( role == Qt::DisplayRole ){
|
||||
if( aColumn == 0 )
|
||||
return QString::fromStdString(myCurve->getSectionName(aRow));
|
||||
return QVariant();
|
||||
}
|
||||
else if( role == Qt::DecorationRole ){
|
||||
if( aColumn == 0 ){
|
||||
CurveCreator::Type aSectionType = myCurve->getType(aRow);
|
||||
if( aSectionType == CurveCreator::Polyline ){
|
||||
if( myCurve->isClosed(aRow) ){
|
||||
return myCachedIcons[ICON_CLOSED_POLYLINE];
|
||||
}
|
||||
else{
|
||||
return myCachedIcons[ICON_POLYLINE];
|
||||
}
|
||||
}
|
||||
else{
|
||||
if( myCurve->isClosed(aRow) ){
|
||||
return myCachedIcons[ICON_CLOSED_SPLINE];
|
||||
}
|
||||
else{
|
||||
return myCachedIcons[ICON_SPLINE];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if( role == Qt::DisplayRole ){
|
||||
if( aColumn == 1 )
|
||||
return QVariant();
|
||||
// return "Point";
|
||||
else if( aColumn == 0 ){
|
||||
CurveCreator::Coordinates aCoords = myCurve->getCoordinates(index.internalId(),index.row() );
|
||||
QString anOut;
|
||||
if( myCurve->getDimension() == CurveCreator::Dim2d ){
|
||||
anOut = QString(tr("X=%1, Y=%2")).arg(aCoords[0]).arg(aCoords[1]);
|
||||
}
|
||||
else{
|
||||
anOut = QString(tr("X=%1, Y=%2, Z=%3")).arg(aCoords[0]).arg(aCoords[1]).arg(aCoords[2]);
|
||||
}
|
||||
return anOut;
|
||||
}
|
||||
}
|
||||
else if( role == Qt::DecorationRole ){
|
||||
if( aColumn == 0 ){
|
||||
return myCachedIcons[ICON_POINT];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QModelIndex CurveCreator_TreeViewModel::index(int row, int column, const QModelIndex & parent ) const
|
||||
{
|
||||
if( parent.isValid() ){
|
||||
return createIndex(row, column, parent.row() );
|
||||
}
|
||||
else{
|
||||
QModelIndex aParent = createIndex(row, column, ID_SECTION );
|
||||
return aParent;
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex CurveCreator_TreeViewModel::parent(const QModelIndex & theIndex) const
|
||||
{
|
||||
if( !theIndex.isValid() )
|
||||
return QModelIndex();
|
||||
|
||||
if( theIndex.internalId() == ID_SECTION ){
|
||||
return QModelIndex();
|
||||
}
|
||||
return createIndex( theIndex.internalId(), 0, ID_SECTION );
|
||||
}
|
||||
|
||||
int CurveCreator_TreeViewModel::rowCount(const QModelIndex & parent ) const
|
||||
{
|
||||
int aRowCnt = 0;
|
||||
if( myCurve != NULL ){
|
||||
if( !parent.isValid() ){
|
||||
//Points level
|
||||
aRowCnt = myCurve->getNbSections();
|
||||
}
|
||||
else{
|
||||
//Section level
|
||||
if( parent.internalId() == ID_SECTION ){
|
||||
aRowCnt = myCurve->getNbPoints(parent.row());
|
||||
}
|
||||
}
|
||||
}
|
||||
return aRowCnt;
|
||||
}
|
||||
|
||||
QModelIndex CurveCreator_TreeViewModel::sectionIndex( int theSection ) const
|
||||
{
|
||||
return createIndex( theSection, 0, ID_SECTION );
|
||||
}
|
||||
|
||||
QModelIndex CurveCreator_TreeViewModel::pointIndex( int theSection, int thePoint ) const
|
||||
{
|
||||
return createIndex( thePoint, 0, theSection );
|
||||
}
|
||||
|
||||
bool CurveCreator_TreeViewModel::isSection( const QModelIndex& theIndx ) const
|
||||
{
|
||||
if( theIndx.internalId() == ID_SECTION )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int CurveCreator_TreeViewModel::getSection( const QModelIndex& theIndx ) const
|
||||
{
|
||||
if( theIndx.internalId() == ID_SECTION )
|
||||
return theIndx.row();
|
||||
return theIndx.internalId();
|
||||
}
|
||||
|
||||
int CurveCreator_TreeViewModel::getPoint( const QModelIndex& theIndx ) const
|
||||
{
|
||||
if( theIndx.internalId() == ID_SECTION )
|
||||
return -1;
|
||||
return theIndx.row();
|
||||
}
|
||||
|
||||
/*****************************************************************************************/
|
||||
CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent) :
|
||||
QTreeView(parent)
|
||||
{
|
||||
header()->hide();
|
||||
setUniformRowHeights(true);
|
||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
CurveCreator_TreeViewModel* aModel = new CurveCreator_TreeViewModel(theCurve, this);
|
||||
setModel(aModel);
|
||||
setSelectionBehavior(SelectRows);
|
||||
setSelectionMode(ExtendedSelection);
|
||||
setExpandsOnDoubleClick(false);
|
||||
connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||
this, SIGNAL(selectionChanged()) );
|
||||
connect( this, SIGNAL(activated(QModelIndex)), this, SLOT(onActivated(QModelIndex)));
|
||||
}
|
||||
|
||||
QList<int> CurveCreator_TreeView::getSelectedSections() const
|
||||
{
|
||||
QList<int> aSect;
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( !aModel )
|
||||
return aSect;
|
||||
QModelIndexList anIndxs = selectionModel()->selectedIndexes();
|
||||
for( int i = 0 ; i < anIndxs.size() ; i++ ){
|
||||
if( aModel->isSection(anIndxs[i]) ){
|
||||
aSect << aModel->getSection( anIndxs[i] );
|
||||
}
|
||||
}
|
||||
qSort(aSect.begin(), aSect.end());
|
||||
return aSect;
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePointsCnt )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
QModelIndex aSectIndx = aModel->sectionIndex( theSection );
|
||||
rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::pointDataChanged( int theSection, int thePoint )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
QModelIndex aPointIndx = aModel->pointIndex( theSection, thePoint );
|
||||
dataChanged( aPointIndx, aPointIndx );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::pointsRemoved( int theSection, int thePoint, int thePointsCnt )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
QModelIndex aSectIndx = aModel->sectionIndex( theSection );
|
||||
rowsRemoved(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::sectionAdded( int theSection )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
rowsInserted(QModelIndex(), theSection, theSection );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::sectionChanged( int theSection, int aSectCnt )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
QModelIndex aFirstSectIndx = aModel->sectionIndex( theSection );
|
||||
QModelIndex aLastSectIndx = aModel->sectionIndex( theSection + aSectCnt - 1);
|
||||
dataChanged( aFirstSectIndx, aLastSectIndx );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::sectionsRemoved( int theSection, int theSectionCnt )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
this->rowsRemoved( QModelIndex(), theSection, theSection+theSectionCnt-1 );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent )
|
||||
{
|
||||
setExpanded( theIndx, isExpanded );
|
||||
QItemSelectionModel::SelectionFlags aFlag = QItemSelectionModel::Select;
|
||||
if( !isSelected ){
|
||||
aFlag = QItemSelectionModel::Deselect;
|
||||
}
|
||||
selectionModel()->select( theIndx, aFlag );
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::getIndexInfo( const QModelIndex& theIndx, bool& isExpand, bool& isSelected, bool& isCurrent )
|
||||
{
|
||||
isExpand = isExpanded(theIndx);
|
||||
isSelected = selectionModel()->isSelected(theIndx);
|
||||
isCurrent = (theIndx == selectionModel()->currentIndex());
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond )
|
||||
{
|
||||
bool isFirstSelected;
|
||||
bool isFirstExpanded;
|
||||
bool isFirstCurrent;
|
||||
getIndexInfo( theFirst, isFirstExpanded, isFirstSelected, isFirstCurrent );
|
||||
|
||||
bool isSecondSelected;
|
||||
bool isSecondExpanded;
|
||||
bool isSecondCurrent;
|
||||
getIndexInfo( theSecond, isSecondExpanded, isSecondSelected, isSecondCurrent );
|
||||
|
||||
setIndexState( theFirst, isSecondExpanded, isSecondSelected, isSecondCurrent );
|
||||
setIndexState( theSecond, isFirstExpanded, isFirstSelected, isFirstCurrent );
|
||||
dataChanged(theFirst,theFirst);
|
||||
dataChanged(theSecond,theSecond);
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::sectionsSwapped( int theSection, int theOffset )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
QModelIndex aFirstIndex = aModel->sectionIndex( theSection );
|
||||
QModelIndex aSecondIndex = aModel->sectionIndex( theSection + theOffset );
|
||||
swapIndexes( aFirstIndex, aSecondIndex );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::pointsSwapped( int theSection, int thePointNum, int theOffset )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
QModelIndex aFirstIndex = aModel->pointIndex( theSection, thePointNum );
|
||||
QModelIndex aSecondIndex = aModel->pointIndex( theSection, thePointNum + theOffset );
|
||||
swapIndexes( aFirstIndex, aSecondIndex );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::setSelectedSections( const QList<int>& theList )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
selectionModel()->clearSelection();
|
||||
for( int i = 0 ; i < theList.size() ; i++ ){
|
||||
QModelIndex aSectIndx = aModel->sectionIndex(theList[i]);
|
||||
selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::setSelectedPoints( const QList< QPair<int, int> >& thePointsList )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
selectionModel()->clearSelection();
|
||||
for( int i = 0 ; i < thePointsList.size() ; i++ ){
|
||||
QModelIndex aSectIndx = aModel->pointIndex( thePointsList[i].first, thePointsList[i].second );
|
||||
selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool pointLessThan(const QPair<int,int> &s1, const QPair<int,int> &s2)
|
||||
{
|
||||
if( s1.first < s2.first )
|
||||
return true;
|
||||
if( s1.first > s2.first )
|
||||
return false;
|
||||
return s1.second < s2.second;
|
||||
}
|
||||
|
||||
QList< QPair< int, int > > CurveCreator_TreeView::getSelectedPoints() const
|
||||
{
|
||||
QList< QPair< int, int > > aPoints;
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( !aModel )
|
||||
return aPoints;
|
||||
QModelIndexList anIndxs = selectionModel()->selectedIndexes();
|
||||
for( int i = 0 ; i < anIndxs.size() ; i++ ){
|
||||
if( !aModel->isSection( anIndxs[i] ) ){
|
||||
int aSect = aModel->getSection(anIndxs[i]);
|
||||
int aPointNum = aModel->getPoint(anIndxs[i]);
|
||||
QPair< int, int > aPoint = QPair<int,int>( aSect, aPointNum );
|
||||
aPoints.push_back( aPoint );
|
||||
}
|
||||
}
|
||||
qSort( aPoints.begin(), aPoints.end(), pointLessThan );
|
||||
return aPoints;
|
||||
}
|
||||
|
||||
CurveCreator_TreeView::SelectionType CurveCreator_TreeView::getSelectionType() const
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( !aModel )
|
||||
return ST_NOSEL;
|
||||
bool isPointSel = false;
|
||||
bool isSectSel = false;
|
||||
bool isOneSection = true;
|
||||
int aSectNum = -1;
|
||||
QModelIndexList aLst = selectionModel()->selectedIndexes();
|
||||
for( int i = 0 ; i < aLst.size() ; i++ ){
|
||||
if( aModel->isSection( aLst[i] ) ){
|
||||
isSectSel = true;
|
||||
}
|
||||
else{
|
||||
isPointSel = true;
|
||||
if( aSectNum == -1 ){
|
||||
aSectNum = aModel->getSection(aLst[i]);
|
||||
}
|
||||
else{
|
||||
if( aSectNum != aModel->getSection( aLst[i] ) ){
|
||||
isOneSection = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( isSectSel && !isPointSel )
|
||||
return ST_SECTIONS;
|
||||
if( isPointSel && !isSectSel ){
|
||||
if( isOneSection ){
|
||||
return ST_POINTS_ONE_SECTION;
|
||||
}
|
||||
return ST_POINTS;
|
||||
}
|
||||
if( isPointSel && isSectSel )
|
||||
return ST_MIXED;
|
||||
return ST_NOSEL;
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::onActivated( QModelIndex theIndx )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( !aModel )
|
||||
return;
|
||||
int aSect = aModel->getSection(theIndx);
|
||||
if( aModel->isSection(theIndx) ){
|
||||
emit sectionEntered( aSect );
|
||||
return;
|
||||
}
|
||||
int aPointNum = aModel->getPoint( theIndx );
|
||||
emit pointEntered( aSect, aPointNum );
|
||||
}
|
71
src/CurveCreator/CurveCreator_TreeView.h
Executable file
71
src/CurveCreator/CurveCreator_TreeView.h
Executable file
@ -0,0 +1,71 @@
|
||||
#ifndef CURVECREATOR_TREEVIEW_H
|
||||
#define CURVECREATOR_TREEVIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
class CurveCreator_Curve;
|
||||
|
||||
class CurveCreator_TreeViewModel : public QAbstractItemModel
|
||||
{
|
||||
public:
|
||||
CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent );
|
||||
virtual int columnCount(const QModelIndex & parent = QModelIndex()) const;
|
||||
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||||
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
||||
virtual QModelIndex parent(const QModelIndex & theIndex) const;
|
||||
|
||||
QModelIndex sectionIndex( int theSection ) const;
|
||||
QModelIndex pointIndex( int theSection, int thePoint ) const;
|
||||
|
||||
bool isSection( const QModelIndex& theIndx ) const;
|
||||
int getSection( const QModelIndex& theIndx ) const;
|
||||
int getPoint( const QModelIndex& theIndx ) const;
|
||||
private:
|
||||
enum IconType{ ICON_POLYLINE, ICON_SPLINE, ICON_CLOSED_SPLINE, ICON_CLOSED_POLYLINE, ICON_POINT };
|
||||
private:
|
||||
CurveCreator_Curve* myCurve;
|
||||
QMap<IconType, QPixmap> myCachedIcons;
|
||||
};
|
||||
|
||||
class CurveCreator_TreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum SelectionType{ ST_NOSEL, ST_POINTS, ST_POINTS_ONE_SECTION, ST_SECTIONS, ST_MIXED };
|
||||
public:
|
||||
explicit CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent = 0);
|
||||
SelectionType getSelectionType() const;
|
||||
QList<int> getSelectedSections() const;
|
||||
QList< QPair< int, int > > getSelectedPoints() const;
|
||||
|
||||
void pointsAdded( int theSection, int thePoint, int thePointsCnt=1 );
|
||||
void pointDataChanged( int theSection, int thePoint );
|
||||
void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 );
|
||||
void pointsSwapped( int theSection, int thePointNum, int theOffset );
|
||||
|
||||
void sectionAdded( int theSection );
|
||||
void sectionChanged(int theSection , int aSectCnt = 1);
|
||||
void sectionsRemoved( int theSection, int theSectionCnt=1 );
|
||||
void sectionsSwapped( int theSection, int theOffset );
|
||||
|
||||
void setSelectedSections( const QList<int>& theList );
|
||||
void setSelectedPoints( const QList< QPair<int, int> >& thePointsList );
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
void sectionEntered(int);
|
||||
void pointEntered(int,int);
|
||||
public slots:
|
||||
protected slots:
|
||||
void onActivated( QModelIndex theIndx );
|
||||
protected:
|
||||
void setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
|
||||
void swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond );
|
||||
void getIndexInfo( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
|
||||
private:
|
||||
CurveCreator_Curve* myCurve;
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_TREEVIEW_H
|
547
src/CurveCreator/CurveCreator_Widget.cpp
Executable file
547
src/CurveCreator/CurveCreator_Widget.cpp
Executable file
@ -0,0 +1,547 @@
|
||||
#include "CurveCreator_Widget.h"
|
||||
#include "CurveCreator_TreeView.h"
|
||||
#include "QVBoxLayout"
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
#include "CurveCreator_CurveEditor.hxx"
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_NewPointDlg.h"
|
||||
#include "CurveCreator_NewSectionDlg.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QGroupBox>
|
||||
#include <QToolButton>
|
||||
#include <QToolBar>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
CurveCreator_Widget::CurveCreator_Widget(QWidget *parent) :
|
||||
QWidget(parent), myNewPointEditor(NULL)
|
||||
{
|
||||
//TODO remove it for debug only
|
||||
myCurve = new CurveCreator_Curve(CurveCreator::Dim2d);
|
||||
myEdit = new CurveCreator_CurveEditor( myCurve );
|
||||
CurveCreator::Coordinates aCoords;
|
||||
|
||||
aCoords.push_back(10);
|
||||
aCoords.push_back(20);
|
||||
aCoords.push_back(1);
|
||||
aCoords.push_back(2);
|
||||
|
||||
myEdit->addSection("",CurveCreator::BSpline, true, aCoords );
|
||||
|
||||
aCoords.clear();
|
||||
aCoords.push_back(11);
|
||||
aCoords.push_back(21);
|
||||
aCoords.push_back(111);
|
||||
aCoords.push_back(211);
|
||||
aCoords.push_back(101);
|
||||
aCoords.push_back(201);
|
||||
aCoords.push_back(13);
|
||||
aCoords.push_back(25);
|
||||
myEdit->addSection("",CurveCreator::Polyline, false, aCoords );
|
||||
|
||||
aCoords.clear();
|
||||
for( int i = 0 ; i < 1000000 ; i++ ){
|
||||
double anX = ((double)i)/10000.;
|
||||
double anY = ((double)i)/10000. + 3.4;
|
||||
aCoords.push_back(anX);
|
||||
aCoords.push_back(anY);
|
||||
}
|
||||
myEdit->addSection("",CurveCreator::Polyline, true, aCoords );
|
||||
|
||||
//TODO end debug
|
||||
myNewPointEditor = new CurveCreator_NewPointDlg(myCurve->getDimension(), this);
|
||||
connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()));
|
||||
|
||||
myNewSectionEditor = new CurveCreator_NewSectionDlg(this);
|
||||
connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()));
|
||||
|
||||
QHBoxLayout* aNameLayout = new QHBoxLayout();
|
||||
QLabel* aNameLabel = new QLabel(tr("CURVE_NAME_TLT"), this);
|
||||
aNameLayout->addWidget(aNameLabel);
|
||||
QLineEdit* aNameEdit = new QLineEdit(this);
|
||||
aNameLayout->addWidget(aNameEdit);
|
||||
|
||||
QGroupBox* aSectionGroup = new QGroupBox(tr("SECTION_GROUP_TLT"),this);
|
||||
|
||||
mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup);
|
||||
connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) );
|
||||
connect( mySectionView, SIGNAL(pointEntered(int,int)), this, SLOT(onEditPoint(int,int)) );
|
||||
connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) );
|
||||
connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) );
|
||||
QToolBar* aTB = new QToolBar(tr("TOOL_BAR_TLT"), aSectionGroup);
|
||||
// QToolButton* anUndoBtn = new QToolButton(aTB);
|
||||
QAction* anAct = createAction( UNDO_ID, tr("UNDO"), tr(":images/ICON_UNDO"), tr("UNDO_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Z) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( REDO_ID, tr("REDO"), tr(":images/ICON_REDO"), tr("REDO_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Y) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
aTB->addSeparator();
|
||||
|
||||
anAct = createAction( NEW_SECTION_ID, tr("ICON_NEW_SECTION"), tr(":images/ICON_NEW_SECTION"), tr("NEW_SECTION_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_N) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( INSERT_SECTION_BEFORE_ID, tr("INSERT_SECTION_BEFORE"), tr(":images/ICON_INSERT_SECTION_BEFORE"), tr("INSERT_SECTION_BEFORE_TLT"),
|
||||
QKeySequence(Qt::ControlModifier | Qt::Key_Insert ) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionBefore()) );
|
||||
|
||||
anAct = createAction( INSERT_SECTION_AFTER_ID, tr("INSERT_SECTION_AFTER"), tr(":images/ICON_INSERT_SECTION_AFTER"), tr("INSERT_SECTION_AFTER_TLT"),
|
||||
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Insert ) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionAfter()) );
|
||||
|
||||
anAct = createAction( NEW_POINT_ID, tr("ICON_NEW_POINT"), tr(":images/ICON_NEW_POINT"), tr("NEW_POINT_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_P) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onNewPoint()) );
|
||||
aTB->addAction(anAct);
|
||||
aTB->addSeparator();
|
||||
|
||||
anAct = createAction( INSERT_POINT_BEFORE_ID, tr("INSERT_POINT_BEFORE"), tr(":images/ICON_POINT_BEFORE"), tr("INSERT_POINT_BEFORE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_B) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointBefore()) );
|
||||
|
||||
anAct = createAction( INSERT_POINT_AFTER_ID, tr("INSERT_POINT_AFTER"), tr(":images/ICON_POINT_AFTER"), tr("INSERT_POINT_AFTER_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_M) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointAfter()) );
|
||||
|
||||
anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), tr(":images/ICON_CLOSE_SECTIONS"), tr("CLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_W) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) );
|
||||
|
||||
anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), tr(":images/ICON_UNCLOSE_SECTIONS"), tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) );
|
||||
|
||||
anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"), tr(":images/ICON_POLYLINE"), tr("SET_POLYLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_E) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) );
|
||||
|
||||
anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), tr(":images/ICON_SPLINE"), tr("SET_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
|
||||
|
||||
anAct = createAction( REMOVE_ID, tr("ICON_REMOVE"), tr(":images/ICON_REMOVE"), tr("REMOVE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
|
||||
aTB->addAction(anAct);
|
||||
aTB->addSeparator();
|
||||
|
||||
anAct = createAction( JOIN_ID, tr("ICON_JOIN"), tr(":images/ICON_JOIN"), tr("JOIN_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
|
||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
|
||||
aTB->addAction(anAct);
|
||||
aTB->addSeparator();
|
||||
|
||||
anAct = createAction( UP_ID, tr("ICON_STEP_UP"), tr(":images/ICON_STEP_UP"), tr("STEP_UP_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Up ) );
|
||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveUp()) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( DOWN_ID, tr("ICON_STEP_DOWN"), tr(":images/ICON_STEP_DOWN"), tr("STEP_DOWN"), QKeySequence(Qt::ControlModifier|Qt::Key_Down ) );
|
||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveDown()) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), tr(":images/ICON_CLEAR_ALL"), tr("CLEAR_ALL_TLT"), QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
|
||||
connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), tr(":images/ICON_JOIN_ALL"), tr("JOIN_ALL_TLT"), QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
|
||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
QVBoxLayout* aSectLayout = new QVBoxLayout();
|
||||
aSectLayout->addWidget(aTB);
|
||||
aSectLayout->addWidget(mySectionView);
|
||||
aSectionGroup->setLayout(aSectLayout);
|
||||
QVBoxLayout* aLay = new QVBoxLayout();
|
||||
aLay->addLayout(aNameLayout);
|
||||
aLay->addWidget(aSectionGroup);
|
||||
setLayout(aLay);
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onSelectionChanged()
|
||||
{
|
||||
QList<ActionId> anEnabledAct;
|
||||
anEnabledAct << NEW_SECTION_ID;
|
||||
int aSectCnt = myCurve->getNbPoints();
|
||||
if( aSectCnt > 0 )
|
||||
anEnabledAct << CLEAR_ALL_ID;
|
||||
if( aSectCnt > 1 )
|
||||
anEnabledAct << JOIN_ALL_ID;
|
||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||
QList< QPair< int, int > > aSelPoints = mySectionView->getSelectedPoints();
|
||||
CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType();
|
||||
switch( aSelType ){
|
||||
case CurveCreator_TreeView::ST_NOSEL:{
|
||||
break;
|
||||
}
|
||||
case CurveCreator_TreeView::ST_SECTIONS:{
|
||||
if( aSelSections.size() > 1 ){
|
||||
anEnabledAct << JOIN_ID;
|
||||
}
|
||||
if( aSelSections[0] > 0 ){
|
||||
anEnabledAct << UP_ID;
|
||||
}
|
||||
if( aSelSections.size() == 1 ){
|
||||
anEnabledAct << NEW_POINT_ID << INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID;
|
||||
}
|
||||
if( aSelSections[ aSelSections.size() - 1 ] < ( myCurve->getNbSections() - 1 ) ){
|
||||
anEnabledAct << DOWN_ID;
|
||||
}
|
||||
anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
|
||||
break;
|
||||
}
|
||||
case CurveCreator_TreeView::ST_POINTS_ONE_SECTION:{
|
||||
if( aSelPoints[0].second > 0 ){
|
||||
anEnabledAct << UP_ID;
|
||||
}
|
||||
int aLastIndex = aSelPoints.size()-1;
|
||||
int aSect = aSelPoints[0].first;
|
||||
if( aSelPoints[aLastIndex].second < (myCurve->getNbPoints(aSect) - 1)){
|
||||
anEnabledAct << DOWN_ID;
|
||||
}
|
||||
if( aSelPoints.size() == 1){
|
||||
anEnabledAct << INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
int aSelObjsCnt = aSelPoints.size() + aSelSections.size();
|
||||
if( aSelObjsCnt > 0 ){
|
||||
anEnabledAct << REMOVE_ID;
|
||||
}
|
||||
if( myCurve->getNbSections() > 0 ){
|
||||
anEnabledAct << REMOVE_ALL_ID;
|
||||
}
|
||||
if( myCurve->getNbSections() > 1 ){
|
||||
anEnabledAct << JOIN_ALL_ID;
|
||||
}
|
||||
QList<ActionId> anIds = myActionMap.keys();
|
||||
for( int i = 0 ; i < anIds.size() ; i++ ){
|
||||
if( myActionMap.contains(anIds[i]) ){
|
||||
if( anEnabledAct.contains(anIds[i]) ){
|
||||
myActionMap[anIds[i]]->setEnabled(true);
|
||||
}
|
||||
else{
|
||||
myActionMap[anIds[i]]->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onNewPoint()
|
||||
{
|
||||
mySection= -1;
|
||||
myPointNum = -1;
|
||||
QList<int> aSelSection = mySectionView->getSelectedSections();
|
||||
if( aSelSection.size() > 0 ){
|
||||
mySection = aSelSection[0];
|
||||
}
|
||||
else{
|
||||
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
|
||||
if( aSelPoints.size() > 0 ){
|
||||
mySection = aSelPoints[0].first;
|
||||
myPointNum = aSelPoints[0].second + 1;
|
||||
}
|
||||
}
|
||||
QString aSectName;
|
||||
if( mySection < 0 ){
|
||||
mySection = myCurve->getNbSections() - 1;
|
||||
}
|
||||
aSectName = QString::fromStdString( myCurve->getSectionName(mySection));
|
||||
if( myPointNum < 0 ){
|
||||
myPointNum = myCurve->getNbPoints(mySection);
|
||||
}
|
||||
myNewPointEditor->clear();
|
||||
myNewPointEditor->setEditMode(false);
|
||||
myNewPointEditor->setSectionName(aSectName);
|
||||
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
||||
onAddNewPoint();
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onAddNewPoint()
|
||||
{
|
||||
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
|
||||
myEdit->insertPoints(aCoords, mySection, myPointNum );
|
||||
mySectionView->pointsAdded( mySection, myPointNum );
|
||||
myNewPointEditor->clear();
|
||||
myPointNum++;
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onNewSection()
|
||||
{
|
||||
myNewSectionEditor->clear();
|
||||
myNewSectionEditor->setEditMode(false);
|
||||
QString aSectName = QString( myCurve->getUnicSectionName().c_str() );
|
||||
myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );
|
||||
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
||||
onAddNewSection();
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onAddNewSection()
|
||||
{
|
||||
CurveCreator::Coordinates aCoords;
|
||||
myEdit->addSection( myNewSectionEditor->getName().toStdString(), myNewSectionEditor->getSectionType(),
|
||||
myNewSectionEditor->isClosed(), aCoords );
|
||||
mySectionView->sectionAdded( mySection );
|
||||
QString aNewName = QString(myCurve->getUnicSectionName().c_str());
|
||||
myNewSectionEditor->setSectionName(aNewName);
|
||||
mySection++;
|
||||
}
|
||||
|
||||
QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theName, const QString& theImageName,
|
||||
const QString& theToolTip, const QKeySequence& theShortcut )
|
||||
{
|
||||
QAction* anAct = new QAction(theName,this);
|
||||
QIcon anIcon(theImageName);
|
||||
if( !anIcon.isNull() ){
|
||||
anAct->setIcon(anIcon);
|
||||
}
|
||||
anAct->setShortcut(theShortcut);
|
||||
anAct->setToolTip(theToolTip);
|
||||
myActionMap[theId] = anAct;
|
||||
return anAct;
|
||||
}
|
||||
|
||||
QAction* CurveCreator_Widget::getAction(ActionId theId)
|
||||
{
|
||||
if( myActionMap.contains(theId) )
|
||||
return myActionMap[theId];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onEditSection( int theSection )
|
||||
{
|
||||
mySection = theSection;
|
||||
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
||||
bool isClosed = myCurve->isClosed(theSection);
|
||||
CurveCreator::Type aType = myCurve->getType(theSection);
|
||||
myNewSectionEditor->setEditMode(true);
|
||||
myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType );
|
||||
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
||||
QString aName = myNewSectionEditor->getName();
|
||||
bool isClosed = myNewSectionEditor->isClosed();
|
||||
CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
|
||||
myEdit->setClosed( isClosed, mySection );
|
||||
myEdit->setName( aName.toStdString(), mySection );
|
||||
myEdit->setType( aSectType, mySection );
|
||||
mySectionView->sectionChanged(mySection);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onEditPoint( int theSection, int thePoint )
|
||||
{
|
||||
if( !myNewPointEditor ){
|
||||
}
|
||||
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
||||
myNewPointEditor->setEditMode(true);
|
||||
myNewPointEditor->setSectionName(aSectName);
|
||||
CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint);
|
||||
myNewPointEditor->setCoordinates(aCoords);
|
||||
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
||||
aCoords = myNewPointEditor->getCoordinates();
|
||||
myEdit->setCoordinates(aCoords, theSection, thePoint);
|
||||
mySectionView->pointDataChanged(theSection, thePoint );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onJoin()
|
||||
{
|
||||
QList<int> aSections = mySectionView->getSelectedSections();
|
||||
if( aSections.size() == 0 ){
|
||||
return;
|
||||
}
|
||||
int aMainSect = aSections[0];
|
||||
int aMainSectSize = myCurve->getNbPoints(aMainSect);
|
||||
for( int i = 1 ; i < aSections.size() ; i++ ){
|
||||
int aSectNum = aSections[i] - (i-1);
|
||||
myEdit->join( aMainSect, aSectNum );
|
||||
mySectionView->sectionsRemoved( aSectNum );
|
||||
}
|
||||
int aNewSectSize = myCurve->getNbPoints(aMainSect);
|
||||
if( aNewSectSize != aMainSectSize )
|
||||
mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onRemove()
|
||||
{
|
||||
QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
|
||||
int aCurrSect=-1;
|
||||
int aRemoveCnt = 0;
|
||||
for( int i = 0 ; i < aSelPoints.size() ; i++ ){
|
||||
if( aCurrSect != aSelPoints[i].first ){
|
||||
aRemoveCnt = 0;
|
||||
aCurrSect = aSelPoints[i].first;
|
||||
}
|
||||
int aPntIndx = aSelPoints[i].second - aRemoveCnt;
|
||||
myEdit->removePoints(aCurrSect,aPntIndx, 1);
|
||||
mySectionView->pointsRemoved( aCurrSect, aPntIndx );
|
||||
aRemoveCnt++;
|
||||
}
|
||||
QList<int> aSections = mySectionView->getSelectedSections();
|
||||
for( int i = 0 ; i < aSections.size() ; i++ ){
|
||||
int aSectNum = aSections[i] - (i);
|
||||
myEdit->removeSection( aSectNum );
|
||||
mySectionView->sectionsRemoved( aSectNum );
|
||||
}
|
||||
mySectionView->clearSelection();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onMoveUp()
|
||||
{
|
||||
if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){
|
||||
//Move sections
|
||||
QList<int> aSections = mySectionView->getSelectedSections();
|
||||
for( int i = 0 ; i < aSections.size() ; i++ ){
|
||||
int anIndx = aSections[i];
|
||||
myEdit->moveSection( anIndx, anIndx-1);
|
||||
mySectionView->sectionsSwapped( anIndx, -1 );
|
||||
}
|
||||
}
|
||||
else{
|
||||
//Move points
|
||||
QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();
|
||||
for( int i = 0 ; i < aPoints.size() ; i++ ){
|
||||
int aSection = aPoints[i].first;
|
||||
int aPoint = aPoints[i].second;
|
||||
myEdit->movePoint(aSection, aPoint, aPoint-2);
|
||||
mySectionView->pointsSwapped( aSection, aPoint, -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onMoveDown()
|
||||
{
|
||||
if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){
|
||||
//Move sections
|
||||
QList<int> aSections = mySectionView->getSelectedSections();
|
||||
for( int i = aSections.size()-1 ; i >=0 ; i-- ){
|
||||
int anIndx = aSections[i];
|
||||
myEdit->moveSection( anIndx, anIndx+1);
|
||||
mySectionView->sectionsSwapped( anIndx, 1 );
|
||||
}
|
||||
}
|
||||
else{
|
||||
//Move points
|
||||
QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();
|
||||
for( int i = aPoints.size() - 1; i >= 0 ; i-- ){
|
||||
int aSection = aPoints[i].first;
|
||||
int aPoint = aPoints[i].second;
|
||||
myEdit->movePoint(aSection, aPoint, aPoint+1);
|
||||
mySectionView->pointsSwapped( aSection, aPoint, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onClearAll()
|
||||
{
|
||||
myEdit->clear();
|
||||
mySectionView->reset();
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onJoinAll()
|
||||
{
|
||||
myEdit->join();
|
||||
mySectionView->reset();
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onInsertSectionBefore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onInsertSectionAfter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onInsertPointBefore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onInsertPointAfter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onUndoSettings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onSetSpline()
|
||||
{
|
||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
||||
myEdit->setType(CurveCreator::BSpline, aSelSections[i]);
|
||||
mySectionView->sectionChanged(aSelSections[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onSetPolyline()
|
||||
{
|
||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
||||
myEdit->setType(CurveCreator::Polyline, aSelSections[i]);
|
||||
mySectionView->sectionChanged(aSelSections[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onCloseSections()
|
||||
{
|
||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
||||
myEdit->setClosed(true, aSelSections[i]);
|
||||
mySectionView->sectionChanged(aSelSections[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onUncloseSections()
|
||||
{
|
||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||
for( int i = 0 ; i < aSelSections.size() ; i++ ){
|
||||
myEdit->setClosed(false, aSelSections[i]);
|
||||
mySectionView->sectionChanged(aSelSections[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onContextMenu( QPoint thePoint )
|
||||
{
|
||||
QList<ActionId> aContextActions;
|
||||
aContextActions << CLEAR_ALL_ID << JOIN_ALL_ID << SEPARATOR_ID <<
|
||||
INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID << SEPARATOR_ID <<
|
||||
CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID <<
|
||||
SET_SECTIONS_SPLINE_ID << SEPARATOR_ID <<
|
||||
INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
|
||||
QPoint aGlPoint = mySectionView->mapToGlobal(thePoint);
|
||||
bool isVis = false;
|
||||
QList<ActionId> aResAct;
|
||||
for( int i = 0 ; i < aContextActions.size() ; i++ ){
|
||||
if( aContextActions[i] != SEPARATOR_ID ){
|
||||
if( myActionMap.contains(aContextActions[i]) ){
|
||||
QAction* anAct = myActionMap[aContextActions[i]];
|
||||
if( anAct->isEnabled() ){
|
||||
aResAct << aContextActions[i];
|
||||
isVis = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
aResAct << SEPARATOR_ID;
|
||||
}
|
||||
}
|
||||
if( !isVis )
|
||||
return;
|
||||
|
||||
QMenu* aMenu = new QMenu(this);
|
||||
for( int i = 0 ; i < aResAct.size() ; i++ ){
|
||||
if( aResAct[i] == SEPARATOR_ID ){
|
||||
aMenu->addSeparator();
|
||||
}
|
||||
else{
|
||||
QAction* anAct = myActionMap[aResAct[i]];
|
||||
aMenu->insertAction(NULL, anAct);
|
||||
}
|
||||
}
|
||||
aMenu->exec(aGlPoint);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,160 +1,73 @@
|
||||
// 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
|
||||
#define CURVECREATOR_WIDGET_H
|
||||
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <QMap>
|
||||
|
||||
class QAction;
|
||||
class QPixmap;
|
||||
class CurveCreator_CurveEditor;
|
||||
class CurveCreator_TreeView;
|
||||
class CurveCreator_NewPointDlg;
|
||||
class CurveCreator_NewSectionDlg;
|
||||
|
||||
class CurveCreator_Widget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CurveCreator_Widget( QWidget* parent,
|
||||
CurveCreator_Curve *theCurve,
|
||||
Qt::WindowFlags fl=0 );
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
protected slots:
|
||||
void onNewPoint();
|
||||
void onNewSection();
|
||||
void onSelectionChanged();
|
||||
void onAddNewPoint();
|
||||
void onAddNewSection();
|
||||
void onEditSection( int theSection );
|
||||
void onEditPoint( int theSection, int thePoint );
|
||||
void onJoin();
|
||||
void onRemove();
|
||||
void onMoveUp();
|
||||
void onMoveDown();
|
||||
void onClearAll();
|
||||
void onJoinAll();
|
||||
void onInsertSectionBefore();
|
||||
void onInsertSectionAfter();
|
||||
void onSetSpline();
|
||||
void onSetPolyline();
|
||||
void onCloseSections();
|
||||
void onUncloseSections();
|
||||
void onInsertPointBefore();
|
||||
void onInsertPointAfter();
|
||||
void onUndoSettings();
|
||||
void onContextMenu(QPoint thePoint);
|
||||
protected:
|
||||
enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, NEW_POINT_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID,
|
||||
JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID,
|
||||
INSERT_POINT_BEFORE_ID, INSERT_POINT_AFTER_ID, CLOSE_SECTIONS_ID, UNCLOSE_SECTIONS_ID,
|
||||
SET_SECTIONS_POLYLINE_ID, SET_SECTIONS_SPLINE_ID, CLEAR_ALL_ID, SEPARATOR_ID };
|
||||
private:
|
||||
QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
|
||||
const QString& theToolTip, const QKeySequence& theShortcut );
|
||||
QAction* getAction(ActionId theId);
|
||||
private:
|
||||
QMap<ActionId, QAction*> myActionMap;
|
||||
CurveCreator_Curve* myCurve;
|
||||
CurveCreator_CurveEditor* myEdit;
|
||||
CurveCreator_TreeView* mySectionView;
|
||||
CurveCreator_NewPointDlg* myNewPointEditor;
|
||||
CurveCreator_NewSectionDlg* myNewSectionEditor;
|
||||
int mySection;
|
||||
int myPointNum;
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_WIDGET_H
|
||||
|
@ -54,32 +54,25 @@ salomeinclude_HEADERS = \
|
||||
# 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)
|
||||
@ -90,7 +83,8 @@ endif
|
||||
libCurveCreator_la_CPPFLAGS = \
|
||||
$(QT_INCLUDES) \
|
||||
$(CAS_CPPFLAGS) \
|
||||
$(KERNEL_CXXFLAGS)
|
||||
$(KERNEL_CXXFLAGS) \
|
||||
$(GUI_CXXFLAGS)
|
||||
|
||||
libCurveCreator_la_LDFLAGS = \
|
||||
$(KERNEL_LDFLAGS) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user