]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
1) CurveCreator_NewSection.h is replaced with CurveCreator_NewSectionDlg.h in Makefile.am
authorouv <ouv@opencascade.com>
Wed, 21 Aug 2013 07:55:34 +0000 (07:55 +0000)
committerouv <ouv@opencascade.com>
Wed, 21 Aug 2013 07:55:34 +0000 (07:55 +0000)
2) Some files are converted to UNIX format
3) CURVECREATOR_EXPORT macro is added to definiton of CurveCreator_Widget class (required for compilation on Windows)

src/CurveCreator/CurveCreator_NewPointDlg.cxx
src/CurveCreator/CurveCreator_NewPointDlg.h
src/CurveCreator/CurveCreator_NewSectionDlg.cxx
src/CurveCreator/CurveCreator_NewSectionDlg.h
src/CurveCreator/CurveCreator_TreeView.cxx
src/CurveCreator/CurveCreator_TreeView.h
src/CurveCreator/CurveCreator_Widget.cxx
src/CurveCreator/CurveCreator_Widget.h
src/CurveCreator/Makefile.am

index 82af1fa674833316481af7225b35b968aa85e34c..eddf2822566798b69f8b7a8f6d90b69d6a9394e6 100755 (executable)
-#include "CurveCreator_NewPointDlg.h"\r
-#include <QGridLayout>\r
-#include <QVBoxLayout>\r
-#include <QLabel>\r
-#include <QDoubleSpinBox>\r
-#include <QDialogButtonBox>\r
-#include <QDoubleValidator>\r
-#include <QRegExpValidator>\r
-#include <QAbstractButton>\r
-#include <QPushButton>\r
-#include <QLocale>\r
-\r
-CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) :\r
-  QDialog(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false)\r
-{\r
-  QGridLayout* aCoordLay = new QGridLayout();\r
-\r
-  QString aTitle = QString(tr("ADD_NEW_POINT"));\r
-  setWindowTitle(aTitle);\r
-\r
-  QLabel* aLbl = new QLabel( tr("X_COORD"), this);\r
-  myX = new QDoubleSpinBox(this);\r
-  aCoordLay->addWidget(aLbl, 0, 0);\r
-  aCoordLay->addWidget(myX, 0, 1 );\r
-\r
-  aLbl = new QLabel( tr("Y_COORD"), this);\r
-  myY = new QDoubleSpinBox(this);\r
-  aCoordLay->addWidget(aLbl, 1, 0 );\r
-  aCoordLay->addWidget(myY, 1, 1 );\r
-\r
-  myZLabel = new QLabel( tr("Z_COORD"), this);\r
-  myZ = new QDoubleSpinBox(this);\r
-  aCoordLay->addWidget(myZLabel, 2,0 );\r
-  aCoordLay->addWidget(myZ, 2,1 );\r
-\r
-  if( theDim != CurveCreator::Dim3d ){\r
-    myZ->hide();\r
-    myZLabel->hide();\r
-  }\r
-\r
-  myBtnBox = new QDialogButtonBox(this);\r
-  myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );\r
-  myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );\r
-  myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );\r
-\r
-  connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));\r
-  connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));\r
-  connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));\r
-  QVBoxLayout* aMainLay = new QVBoxLayout();\r
-  aMainLay->addLayout(aCoordLay);\r
-  aMainLay->addWidget(myBtnBox);\r
-  setLayout(aMainLay);\r
-  clear();\r
-  updateTitle();\r
-}\r
-\r
-void CurveCreator_NewPointDlg::setSectionName( const QString& theName )\r
-{\r
-  mySectionName = theName;\r
-  updateTitle();\r
-}\r
-\r
-void CurveCreator_NewPointDlg::setEditMode( bool isEdit )\r
-{\r
-  myIsEdit = isEdit;\r
-  if( myIsEdit ){\r
-    myContBtn->hide();\r
-    myAddBtn->setText(tr("OK"));\r
-  }\r
-  else{\r
-    myContBtn->show();\r
-    myAddBtn->setText(tr("ADD_BTN"));\r
-  }\r
-  updateTitle();\r
-}\r
-\r
-void CurveCreator_NewPointDlg::updateTitle()\r
-{\r
-  QString aTitle;\r
-  if( !myIsEdit ){\r
-    if( mySectionName.isEmpty() ){\r
-      aTitle = tr("ADD_NEW_POINT");\r
-    }\r
-    else{\r
-      aTitle = QString(tr("ADD_NEW_POINT_TO_%1")).arg(mySectionName);\r
-    }\r
-  }\r
-  else{\r
-    aTitle = tr("SET_POINT_COORDINATES");\r
-  }\r
-  setWindowTitle(aTitle);\r
-}\r
-\r
-CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const\r
-{\r
-  CurveCreator::Coordinates aCoords;\r
-  double anX = myX->value();\r
-  aCoords.push_back(anX);\r
-  double anY = myY->value();\r
-  aCoords.push_back(anY);\r
-  if( myZ->isVisible() ){\r
-    double aZ = myZ->value();\r
-    aCoords.push_back(aZ);\r
-  }\r
-  return aCoords;\r
-}\r
-\r
-void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )\r
-{\r
-  if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){\r
-    emit addPoint();\r
-  }\r
-}\r
-\r
-void CurveCreator_NewPointDlg::clear()\r
-{\r
-  initSpinBox(myX);\r
-  initSpinBox(myY);\r
-  initSpinBox(myZ);\r
-}\r
-\r
-void CurveCreator_NewPointDlg::setDimension(CurveCreator::Dimension theDim)\r
-{\r
-  if( theDim == CurveCreator::Dim2d ){\r
-    myZ->hide();\r
-    myZLabel->hide();\r
-  }\r
-  else{\r
-    myZ->show();\r
-    myZLabel->show();\r
-  }\r
-}\r
-\r
-void CurveCreator_NewPointDlg::setCoordinates( const CurveCreator::Coordinates& theCoords )\r
-{\r
-  double anX = theCoords[0];\r
-  myX->setValue(anX);\r
-  double anY = theCoords[1];\r
-  myY->setValue(anY);\r
-  if( theCoords.size() == 3 ){\r
-    double aZ = theCoords[2];\r
-    myZ->setValue(aZ);\r
-  }\r
-}\r
-\r
-//=======================================================================\r
-// function: initSpinBox\r
-// purpose:\r
-//=======================================================================\r
-void CurveCreator_NewPointDlg::initSpinBox(QDoubleSpinBox *theSpinBox)\r
-{\r
-  const double aCoordMin  = -1.e+15;\r
-  const double aCoordMax  = 1.e+15;\r
-  const double aStep      = 10;\r
-  const int    aPrecision = 6;\r
-\r
-  theSpinBox->setDecimals( qAbs( aPrecision ) );\r
-  theSpinBox->setRange(aCoordMin, aCoordMax);\r
-  theSpinBox->setSingleStep(aStep);\r
-  theSpinBox->setValue(0.0);\r
-}\r
+#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 );
+
+  myZLabel = new QLabel( tr("Z_COORD"), this);
+  myZ = new QDoubleSpinBox(this);
+  aCoordLay->addWidget(myZLabel, 2,0 );
+  aCoordLay->addWidget(myZ, 2,1 );
+
+  if( theDim != CurveCreator::Dim3d ){
+    myZ->hide();
+    myZLabel->hide();
+  }
+
+  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->isVisible() ){
+    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);
+  initSpinBox(myZ);
+}
+
+void CurveCreator_NewPointDlg::setDimension(CurveCreator::Dimension theDim)
+{
+  if( theDim == CurveCreator::Dim2d ){
+    myZ->hide();
+    myZLabel->hide();
+  }
+  else{
+    myZ->show();
+    myZLabel->show();
+  }
+}
+
+void CurveCreator_NewPointDlg::setCoordinates( const CurveCreator::Coordinates& theCoords )
+{
+  double anX = theCoords[0];
+  myX->setValue(anX);
+  double anY = theCoords[1];
+  myY->setValue(anY);
+  if( 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);
+}
index 883297e5c1e9962498b202265bd5538631f01a13..71dc2e81918dafeebf37d54acc2ebf656d2abc19 100755 (executable)
@@ -1,46 +1,46 @@
-#ifndef CURVECREATOR_NEWPOINTDLG_H\r
-#define CURVECREATOR_NEWPOINTDLG_H\r
-\r
-#include "CurveCreator.hxx"\r
-\r
-#include <QDialog>\r
-\r
-class QDoubleSpinBox;\r
-class QDialogButtonBox;\r
-class QAbstractButton;\r
-class QPushButton;\r
-class QLabel;\r
-\r
-class CurveCreator_NewPointDlg : public QDialog\r
-{\r
-  Q_OBJECT\r
-public:\r
-  explicit CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent = 0);\r
-  CurveCreator::Coordinates getCoordinates() const;\r
-  void clear();\r
-  void setSectionName( const QString& theName );\r
-  void setEditMode( bool isEdit );\r
-  void setCoordinates( const CurveCreator::Coordinates& theCoords );\r
-  void setDimension(CurveCreator::Dimension theDim);\r
-signals:\r
-  void addPoint();\r
-public slots:\r
-protected slots:\r
-  void onBtnClicked(QAbstractButton* theBtn );\r
-protected:\r
-  void updateTitle();\r
-  void initSpinBox(QDoubleSpinBox *theSpinBox);\r
-private:\r
-  QDialogButtonBox*       myBtnBox;\r
-  CurveCreator::Dimension myDim;\r
-  QDoubleSpinBox*         myX;\r
-  QDoubleSpinBox*         myY;\r
-  QDoubleSpinBox*         myZ;\r
-  QLabel*                 myZLabel;\r
-  QPushButton*            myContBtn;\r
-  QPushButton*            myAddBtn;\r
-  bool                    myIsEdit;\r
-  QString                 mySectionName;\r
-};\r
-\r
-#endif // CURVECREATOR_NEWPOINTDLG_H\r
+#ifndef CURVECREATOR_NEWPOINTDLG_H
+#define CURVECREATOR_NEWPOINTDLG_H
+
+#include "CurveCreator.hxx"
+
+#include <QDialog>
+
+class QDoubleSpinBox;
+class QDialogButtonBox;
+class QAbstractButton;
+class QPushButton;
+class QLabel;
+
+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 );
+  void setDimension(CurveCreator::Dimension theDim);
+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;
+  QLabel*                 myZLabel;
+  QPushButton*            myContBtn;
+  QPushButton*            myAddBtn;
+  bool                    myIsEdit;
+  QString                 mySectionName;
+};
+
+#endif // CURVECREATOR_NEWPOINTDLG_H
index 59a1465eee9a69113e215573aa1880ac188a067b..497bef2a61d63681b0ab44c38a8a3767ecc8297c 100755 (executable)
-#include "CurveCreator_NewSectionDlg.h"\r
-#include "CurveCreator_Curve.hxx"\r
-\r
-#include <SUIT_Session.h>\r
-#include <SUIT_ResourceMgr.h>\r
-\r
-#include <QGridLayout>\r
-#include <QLabel>\r
-#include <QLineEdit>\r
-#include <QComboBox>\r
-#include <QCheckBox>\r
-#include <QDialogButtonBox>\r
-#include <QPushButton>\r
-\r
-CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :\r
-  QDialog(parent)\r
-{\r
-  std::string aNameStr;\r
-  QGridLayout* aLay = new QGridLayout();\r
-  QLabel* aLbl = new QLabel(tr("NAME"), this);\r
-  myName = new QLineEdit(this);\r
-  aLay->addWidget(aLbl, 0, 0);\r
-  aLay->addWidget(myName, 0 , 1);\r
-\r
-  aLbl = new QLabel(tr("LINE_TYPE"));\r
-  myLineType = new QComboBox(this);\r
-\r
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();\r
-  QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));\r
-  QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));\r
-\r
-//  QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE"));\r
-//  QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE"));\r
-  myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE"));\r
-  myLineType->addItem(aSplinePixmap, tr("SPLINE_TYPE"));\r
-  myLineType->setCurrentIndex(0);\r
-  aLay->addWidget(aLbl, 1, 0);\r
-  aLay->addWidget(myLineType, 1 , 1);\r
-\r
-  aLbl = new QLabel(tr("LINE_CLOSED"));\r
-  myIsClosed = new QCheckBox(this);\r
-  aLay->addWidget(aLbl, 2, 0);\r
-  aLay->addWidget(myIsClosed, 2, 1);\r
-\r
-  myBtnBox = new QDialogButtonBox(this);\r
-  myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );\r
-  myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );\r
-  myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );\r
-\r
-  connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));\r
-  connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));\r
-  connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));\r
-\r
-  QVBoxLayout* aMainLay = new QVBoxLayout();\r
-  aMainLay->addLayout(aLay);\r
-  aMainLay->addWidget(myBtnBox);\r
-  setLayout(aMainLay);\r
-}\r
-\r
-void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType )\r
-{\r
-  myName->setText(theName);\r
-  myIsClosed->setChecked(isClosed);\r
-  if( theType == CurveCreator::Polyline )\r
-    myLineType->setCurrentIndex(0);\r
-  else\r
-    myLineType->setCurrentIndex(1);\r
-}\r
-\r
-void CurveCreator_NewSectionDlg::clear()\r
-{\r
-  myName->setText("");\r
-  myIsClosed->setChecked(true);\r
-  myLineType->setCurrentIndex(0);\r
-}\r
-\r
-void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )\r
-{\r
-  myIsEdit = isEdit;\r
-  if( myIsEdit ){\r
-    myContBtn->hide();\r
-    myAddBtn->setText(tr("OK"));\r
-  }\r
-  else{\r
-    myContBtn->show();\r
-    myAddBtn->setText(tr("ADD_BTN"));\r
-  }\r
-  updateTitle();\r
-}\r
-\r
-QString CurveCreator_NewSectionDlg::getName() const\r
-{\r
-  return myName->text();\r
-}\r
-\r
-bool CurveCreator_NewSectionDlg::isClosed() const\r
-{\r
-  return myIsClosed->isChecked();\r
-}\r
-\r
-CurveCreator::Type CurveCreator_NewSectionDlg::getSectionType() const\r
-{\r
-  if( myLineType->currentIndex() == 0 )\r
-    return CurveCreator::Polyline;\r
-  else\r
-    return CurveCreator::BSpline;\r
-}\r
-\r
-void CurveCreator_NewSectionDlg::updateTitle()\r
-{\r
-  QString aTitle;\r
-  if( !myIsEdit )\r
-    aTitle = tr("ADD_NEW_SECTION");\r
-  else\r
-    aTitle = QString(tr("SET_SECTION_PARAMETERS"));\r
-  setWindowTitle(aTitle);\r
-}\r
-\r
-void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )\r
-{\r
-  myName->setText(theName);\r
-}\r
-\r
-void CurveCreator_NewSectionDlg::onBtnClicked(QAbstractButton* theBtn )\r
-{\r
-  if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){\r
-    emit addSection();\r
-  }\r
-}\r
+#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);
+
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
+  QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
+
+//  QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE"));
+//  QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE"));
+  myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE"));
+  myLineType->addItem(aSplinePixmap, 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);
+  else
+    myLineType->setCurrentIndex(1);
+}
+
+void CurveCreator_NewSectionDlg::clear()
+{
+  myName->setText("");
+  myIsClosed->setChecked(true);
+  myLineType->setCurrentIndex(0);
+}
+
+void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
+{
+  myIsEdit = isEdit;
+  if( myIsEdit ){
+    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();
+  }
+}
index cc590ed2dc7a4c3e044499c7d7953e2203ff4990..d7568fb27270cf81af6ce6d98d675b28481fcafb 100755 (executable)
@@ -1,49 +1,49 @@
-#ifndef CURVECREATOR_NEWSECTION_H\r
-#define CURVECREATOR_NEWSECTION_H\r
-\r
-#include "CurveCreator.hxx"\r
-\r
-#include <QDialog>\r
-\r
-class CurveCreator_Curve;\r
-\r
-class QLineEdit;\r
-class QComboBox;\r
-class QCheckBox;\r
-class QPushButton;\r
-class QAbstractButton;\r
-class QDialogButtonBox;\r
-\r
-class CurveCreator_NewSectionDlg : public QDialog\r
-{\r
-  Q_OBJECT\r
-public:\r
-  explicit CurveCreator_NewSectionDlg(QWidget *parent = 0);\r
-\r
-  QString getName() const;\r
-  bool    isClosed() const;\r
-  CurveCreator::Type getSectionType() const;\r
-\r
-  void    setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType );\r
-  void    setSectionName(const QString& theName );\r
-  void    clear();\r
-  void    setEditMode( bool isEdit );\r
-\r
-signals:\r
-  void    addSection();\r
-public slots:\r
-protected slots:\r
-  void onBtnClicked(QAbstractButton* theBtn );\r
-protected:\r
-  void    updateTitle();\r
-private:\r
-  QLineEdit*          myName;\r
-  QComboBox*          myLineType;\r
-  QCheckBox*          myIsClosed;\r
-  bool                myIsEdit;\r
-  QPushButton*        myContBtn;\r
-  QPushButton*        myAddBtn;\r
-  QDialogButtonBox*   myBtnBox;\r
-};\r
-\r
-#endif // CURVECREATOR_NEWSECTION_H\r
+#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
index c7ff6f929a4d68d9cd476c77fcaccc4f4e4e78fa..a6eaaaa0496d6197c238ad77e32b2590b86f129a 100755 (executable)
-#include "CurveCreator_TreeView.h"\r
-#include "CurveCreator_Curve.hxx"\r
-\r
-#include <SUIT_Session.h>\r
-#include <SUIT_ResourceMgr.h>\r
-\r
-#include <QHeaderView>\r
-#include <QtAlgorithms>\r
-\r
-#define ID_SECTION -1\r
-\r
-CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent ) :\r
-  QAbstractItemModel(parent), myCurve(theCurve)\r
-{\r
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();\r
-  QPixmap aSplineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));\r
-  QPixmap aPolylineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));\r
-  QPixmap aClosedSplineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_CLOSED_SPLINE")));\r
-  QPixmap aClosedPolylineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_CLOSED_POLYLINE")));\r
-  QPixmap aPointIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POINT")));\r
-\r
-/*  QPixmap aSplineIcon(tr(":images/ICON_SPLINE"));\r
-  QPixmap aPolylineIcon(tr(":images/ICON_POLYLINE"));\r
-  QPixmap aClosedPolylineIcon(tr(":images/ICON_CLOSED_POLYLINE"));\r
-  QPixmap aClosedSplineIcon(tr(":images/ICON_CLOSED_SPLINE"));\r
-  QPixmap aPointIcon(tr(":images/ICON_POINT")); */\r
-\r
-  if( !aSplineIcon.isNull() )\r
-    myCachedIcons[ICON_SPLINE] = aSplineIcon;\r
-\r
-  if( !aPolylineIcon.isNull() )\r
-    myCachedIcons[ICON_POLYLINE] = aPolylineIcon;\r
-\r
-  if( !aPolylineIcon.isNull() )\r
-    myCachedIcons[ICON_CLOSED_POLYLINE] = aClosedPolylineIcon;\r
-\r
-  if( !aPolylineIcon.isNull() )\r
-    myCachedIcons[ICON_CLOSED_SPLINE] = aClosedSplineIcon;\r
-\r
-  if( !aPointIcon.isNull() )\r
-    myCachedIcons[ICON_POINT] = aPointIcon;\r
-\r
-}\r
-\r
-int    CurveCreator_TreeViewModel::columnCount(const QModelIndex & parent ) const\r
-{\r
-  if( parent.internalId() == ID_SECTION )\r
-    return 1;\r
-  else\r
-    return 1;\r
-}\r
-\r
-QVariant       CurveCreator_TreeViewModel::data(const QModelIndex & index, int role ) const\r
-{\r
-  int aRow = index.row();\r
-  int aColumn = index.column();\r
-  if( myCurve ){\r
-    if( index.internalId() == ID_SECTION ){\r
-      if( role == Qt::DisplayRole ){\r
-        if( aColumn == 0 )\r
-          return QString::fromStdString(myCurve->getSectionName(aRow));\r
-        return QVariant();\r
-      }\r
-      else if( role == Qt::DecorationRole ){\r
-        if( aColumn == 0 ){\r
-          CurveCreator::Type aSectionType = myCurve->getType(aRow);\r
-          if( aSectionType == CurveCreator::Polyline ){\r
-            if( myCurve->isClosed(aRow) ){\r
-              return myCachedIcons[ICON_CLOSED_POLYLINE];\r
-            }\r
-            else{\r
-              return myCachedIcons[ICON_POLYLINE];\r
-            }\r
-          }\r
-          else{\r
-            if( myCurve->isClosed(aRow) ){\r
-              return myCachedIcons[ICON_CLOSED_SPLINE];\r
-            }\r
-            else{\r
-              return myCachedIcons[ICON_SPLINE];\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-    else{\r
-      if( role == Qt::DisplayRole ){\r
-        if( aColumn == 1 )\r
-          return QVariant();\r
-        //                    return "Point";\r
-        else if( aColumn == 0 ){\r
-          CurveCreator::Coordinates aCoords = myCurve->getCoordinates(index.internalId(),index.row() );\r
-          QString anOut;\r
-          if( myCurve->getDimension() == CurveCreator::Dim2d ){\r
-            anOut = QString(tr("X=%1, Y=%2")).arg(aCoords[0]).arg(aCoords[1]);\r
-          }\r
-          else{\r
-            anOut = QString(tr("X=%1, Y=%2, Z=%3")).arg(aCoords[0]).arg(aCoords[1]).arg(aCoords[2]);\r
-          }\r
-          return anOut;\r
-        }\r
-      }\r
-      else if( role == Qt::DecorationRole ){\r
-        if( aColumn == 0 ){\r
-          return myCachedIcons[ICON_POINT];\r
-        }\r
-      }\r
-    }\r
-  }\r
-  return QVariant();\r
-}\r
-\r
-QModelIndex    CurveCreator_TreeViewModel::index(int row, int column, const QModelIndex & parent ) const\r
-{\r
-  if( parent.isValid() ){\r
-    return createIndex(row, column, parent.row() );\r
-  }\r
-  else{\r
-    QModelIndex aParent = createIndex(row, column, ID_SECTION );\r
-    return aParent;\r
-  }\r
-  return QModelIndex();\r
-}\r
-\r
-QModelIndex    CurveCreator_TreeViewModel::parent(const QModelIndex & theIndex) const\r
-{\r
-  if( !theIndex.isValid() )\r
-    return QModelIndex();\r
-\r
-  if( theIndex.internalId() == ID_SECTION ){\r
-    return QModelIndex();\r
-  }\r
-  return createIndex( theIndex.internalId(), 0, ID_SECTION  );\r
-}\r
-\r
-int    CurveCreator_TreeViewModel::rowCount(const QModelIndex & parent ) const\r
-{\r
-  int aRowCnt = 0;\r
-  if( myCurve != NULL ){\r
-    if( !parent.isValid() ){\r
-      //Points level\r
-      aRowCnt =  myCurve->getNbSections();\r
-    }\r
-    else{\r
-      //Section level\r
-      if( parent.internalId() == ID_SECTION ){\r
-        aRowCnt = myCurve->getNbPoints(parent.row());\r
-      }\r
-    }\r
-  }\r
-  return aRowCnt;\r
-}\r
-\r
-QModelIndex CurveCreator_TreeViewModel::sectionIndex( int theSection ) const\r
-{\r
-  return createIndex( theSection, 0, ID_SECTION );\r
-}\r
-\r
-QModelIndex CurveCreator_TreeViewModel::pointIndex( int theSection, int thePoint ) const\r
-{\r
-  return createIndex( thePoint, 0, theSection );\r
-}\r
-\r
-bool CurveCreator_TreeViewModel::isSection( const QModelIndex& theIndx ) const\r
-{\r
-  if( theIndx.internalId() == ID_SECTION )\r
-    return true;\r
-  return false;\r
-}\r
-\r
-int CurveCreator_TreeViewModel::getSection( const QModelIndex& theIndx ) const\r
-{\r
-  if( theIndx.internalId() == ID_SECTION )\r
-    return theIndx.row();\r
-  return theIndx.internalId();\r
-}\r
-\r
-int CurveCreator_TreeViewModel::getPoint( const QModelIndex& theIndx ) const\r
-{\r
-  if( theIndx.internalId() == ID_SECTION )\r
-    return -1;\r
-  return theIndx.row();\r
-}\r
-\r
-void CurveCreator_TreeViewModel::setCurve( CurveCreator_Curve* theCurve )\r
-{\r
-  myCurve = theCurve;\r
-  reset();\r
-}\r
-\r
-/*****************************************************************************************/\r
-CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent) :\r
-  QTreeView(parent)\r
-{\r
-  header()->hide();\r
-  setUniformRowHeights(true);\r
-  setContextMenuPolicy( Qt::CustomContextMenu );\r
-  CurveCreator_TreeViewModel* aModel = new CurveCreator_TreeViewModel(theCurve, this);\r
-  setModel(aModel);\r
-  setSelectionBehavior(SelectRows);\r
-  setSelectionMode(ExtendedSelection);\r
-  setExpandsOnDoubleClick(false);\r
-  connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),\r
-           this, SIGNAL(selectionChanged()) );\r
-  connect( this, SIGNAL(activated(QModelIndex)), this, SLOT(onActivated(QModelIndex)));\r
-}\r
-\r
-QList<int> CurveCreator_TreeView::getSelectedSections() const\r
-{\r
-  QList<int> aSect;\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( !aModel )\r
-    return aSect;\r
-  QModelIndexList anIndxs = selectionModel()->selectedIndexes();\r
-  for( int i = 0 ; i < anIndxs.size() ; i++ ){\r
-    if( aModel->isSection(anIndxs[i]) ){\r
-      aSect << aModel->getSection( anIndxs[i] );\r
-    }\r
-  }\r
-  qSort(aSect.begin(), aSect.end());\r
-  return aSect;\r
-}\r
-\r
-void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePointsCnt )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    QModelIndex aSectIndx = aModel->sectionIndex( theSection );\r
-    rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );\r
-  }\r
-}\r
-\r
-void CurveCreator_TreeView::pointDataChanged( int theSection, int thePoint )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    QModelIndex aPointIndx = aModel->pointIndex( theSection, thePoint );\r
-    dataChanged( aPointIndx, aPointIndx );\r
-  }\r
-}\r
-\r
-void CurveCreator_TreeView::pointsRemoved( int theSection, int thePoint, int thePointsCnt )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    for( int i = 0 ; i < thePointsCnt ; i++ ){\r
-      QModelIndex aSectIndx = aModel->pointIndex(theSection, thePoint + i);\r
-      selectionModel()->select(aSectIndx,QItemSelectionModel::Deselect);\r
-    }\r
-    QModelIndex aSectIndx = aModel->sectionIndex( theSection );\r
-    rowsRemoved(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );\r
-  }\r
-}\r
-\r
-void CurveCreator_TreeView::sectionAdded( int theSection )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    rowsInserted(QModelIndex(), theSection, theSection );\r
-  }\r
-}\r
-\r
-void CurveCreator_TreeView::sectionChanged( int theSection, int aSectCnt )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    QModelIndex aFirstSectIndx = aModel->sectionIndex( theSection );\r
-    QModelIndex aLastSectIndx = aModel->sectionIndex( theSection + aSectCnt - 1);\r
-    dataChanged( aFirstSectIndx, aLastSectIndx );\r
-  }\r
-}\r
-\r
-void CurveCreator_TreeView::sectionsRemoved( int theSection, int theSectionCnt )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    for( int i = 0 ; i < theSectionCnt ; i++ ){\r
-      QModelIndex aSectIndx = aModel->sectionIndex(theSection + i);\r
-      this->selectionModel()->select(aSectIndx,QItemSelectionModel::Deselect);\r
-    }\r
-    rowsRemoved( QModelIndex(), theSection, theSection+theSectionCnt-1 );\r
-  }\r
-}\r
-\r
-void CurveCreator_TreeView::setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent )\r
-{\r
-  setExpanded( theIndx, isExpanded );\r
-  QItemSelectionModel::SelectionFlags aFlag = QItemSelectionModel::Select;\r
-  if( !isSelected ){\r
-    aFlag = QItemSelectionModel::Deselect;\r
-  }\r
-  selectionModel()->select( theIndx, aFlag );\r
-}\r
-\r
-void CurveCreator_TreeView::getIndexInfo( const QModelIndex& theIndx, bool& isExpand, bool& isSelected, bool& isCurrent )\r
-{\r
-  isExpand = isExpanded(theIndx);\r
-  isSelected = selectionModel()->isSelected(theIndx);\r
-  isCurrent = (theIndx == selectionModel()->currentIndex());\r
-}\r
-\r
-void CurveCreator_TreeView::swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond )\r
-{\r
-  bool isFirstSelected;\r
-  bool isFirstExpanded;\r
-  bool isFirstCurrent;\r
-  getIndexInfo( theFirst, isFirstExpanded, isFirstSelected, isFirstCurrent );\r
-\r
-  bool isSecondSelected;\r
-  bool isSecondExpanded;\r
-  bool isSecondCurrent;\r
-  getIndexInfo( theSecond, isSecondExpanded, isSecondSelected, isSecondCurrent );\r
-\r
-  setIndexState( theFirst, isSecondExpanded, isSecondSelected, isSecondCurrent );\r
-  setIndexState( theSecond, isFirstExpanded, isFirstSelected, isFirstCurrent );\r
-  dataChanged(theFirst,theFirst);\r
-  dataChanged(theSecond,theSecond);\r
-}\r
-\r
-void CurveCreator_TreeView::sectionsSwapped( int theSection, int theOffset )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    QModelIndex aFirstIndex = aModel->sectionIndex( theSection );\r
-    QModelIndex aSecondIndex = aModel->sectionIndex( theSection + theOffset );\r
-    swapIndexes( aFirstIndex, aSecondIndex );\r
-  }\r
-}\r
-\r
-void CurveCreator_TreeView::pointsSwapped( int theSection, int thePointNum, int theOffset )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    QModelIndex aFirstIndex = aModel->pointIndex( theSection, thePointNum );\r
-    QModelIndex aSecondIndex = aModel->pointIndex( theSection, thePointNum + theOffset );\r
-    swapIndexes( aFirstIndex, aSecondIndex );\r
-  }\r
-}\r
-\r
-void CurveCreator_TreeView::setSelectedSections( const QList<int>& theList )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    selectionModel()->clearSelection();\r
-    for( int i = 0 ; i < theList.size() ; i++ ){\r
-      QModelIndex aSectIndx = aModel->sectionIndex(theList[i]);\r
-      selectionModel()->select(aSectIndx, QItemSelectionModel::Select );\r
-    }\r
-  }\r
-}\r
-\r
-void CurveCreator_TreeView::setSelectedPoints( const QList< QPair<int, int> >& thePointsList )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel ){\r
-    selectionModel()->clearSelection();\r
-    for( int i = 0 ; i < thePointsList.size() ; i++ ){\r
-      QModelIndex aSectIndx = aModel->pointIndex( thePointsList[i].first, thePointsList[i].second );\r
-      selectionModel()->select(aSectIndx, QItemSelectionModel::Select );\r
-    }\r
-  }\r
-}\r
-\r
-bool pointLessThan(const QPair<int,int> &s1, const QPair<int,int> &s2)\r
-{\r
-  if( s1.first < s2.first )\r
-    return true;\r
-  if( s1.first > s2.first )\r
-    return false;\r
-  return s1.second < s2.second;\r
-}\r
-\r
-QList< QPair< int, int > > CurveCreator_TreeView::getSelectedPoints() const\r
-{\r
-  QList< QPair< int, int > > aPoints;\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( !aModel )\r
-    return aPoints;\r
-  QModelIndexList anIndxs = selectionModel()->selectedIndexes();\r
-  for( int i = 0 ; i < anIndxs.size() ; i++ ){\r
-    if( !aModel->isSection( anIndxs[i] ) ){\r
-      int aSect = aModel->getSection(anIndxs[i]);\r
-      int aPointNum = aModel->getPoint(anIndxs[i]);\r
-      QPair< int, int > aPoint = QPair<int,int>( aSect, aPointNum );\r
-      aPoints.push_back( aPoint );\r
-    }\r
-  }\r
-  qSort( aPoints.begin(), aPoints.end(), pointLessThan );\r
-  return aPoints;\r
-}\r
-\r
-CurveCreator_TreeView::SelectionType CurveCreator_TreeView::getSelectionType() const\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( !aModel )\r
-    return ST_NOSEL;\r
-  bool isPointSel = false;\r
-  bool isSectSel = false;\r
-  bool isOneSection = true;\r
-  int aSectNum = -1;\r
-  QModelIndexList aLst = selectionModel()->selectedIndexes();\r
-  for( int i = 0 ; i < aLst.size() ; i++ ){\r
-    if( aModel->isSection( aLst[i] ) ){\r
-      isSectSel = true;\r
-    }\r
-    else{\r
-      isPointSel = true;\r
-      if( aSectNum == -1 ){\r
-        aSectNum = aModel->getSection(aLst[i]);\r
-      }\r
-      else{\r
-        if( aSectNum != aModel->getSection( aLst[i] ) ){\r
-          isOneSection = false;\r
-        }\r
-      }\r
-    }\r
-  }\r
-  if( isSectSel && !isPointSel )\r
-    return ST_SECTIONS;\r
-  if( isPointSel && !isSectSel ){\r
-    if( isOneSection ){\r
-      return ST_POINTS_ONE_SECTION;\r
-    }\r
-    return ST_POINTS;\r
-  }\r
-  if( isPointSel && isSectSel )\r
-    return ST_MIXED;\r
-  return ST_NOSEL;\r
-}\r
-\r
-void CurveCreator_TreeView::onActivated( QModelIndex theIndx )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( !aModel )\r
-    return;\r
-  int aSect = aModel->getSection(theIndx);\r
-  if( aModel->isSection(theIndx) ){\r
-    emit sectionEntered( aSect );\r
-    return;\r
-  }\r
-  int aPointNum = aModel->getPoint( theIndx );\r
-  emit pointEntered( aSect, aPointNum );\r
-}\r
-\r
-void CurveCreator_TreeView::setCurve( CurveCreator_Curve* theCurve )\r
-{\r
-  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());\r
-  if( aModel )\r
-    aModel->setCurve(theCurve);\r
-  reset();\r
-}\r
+#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)
+{
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  QPixmap aSplineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
+  QPixmap aPolylineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
+  QPixmap aClosedSplineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_CLOSED_SPLINE")));
+  QPixmap aClosedPolylineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_CLOSED_POLYLINE")));
+  QPixmap aPointIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POINT")));
+
+/*  QPixmap aSplineIcon(tr(":images/ICON_SPLINE"));
+  QPixmap aPolylineIcon(tr(":images/ICON_POLYLINE"));
+  QPixmap aClosedPolylineIcon(tr(":images/ICON_CLOSED_POLYLINE"));
+  QPixmap aClosedSplineIcon(tr(":images/ICON_CLOSED_SPLINE"));
+  QPixmap aPointIcon(tr(":images/ICON_POINT")); */
+
+  if( !aSplineIcon.isNull() )
+    myCachedIcons[ICON_SPLINE] = aSplineIcon;
+
+  if( !aPolylineIcon.isNull() )
+    myCachedIcons[ICON_POLYLINE] = aPolylineIcon;
+
+  if( !aPolylineIcon.isNull() )
+    myCachedIcons[ICON_CLOSED_POLYLINE] = aClosedPolylineIcon;
+
+  if( !aPolylineIcon.isNull() )
+    myCachedIcons[ICON_CLOSED_SPLINE] = aClosedSplineIcon;
+
+  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();
+}
+
+void CurveCreator_TreeViewModel::setCurve( CurveCreator_Curve* theCurve )
+{
+  myCurve = theCurve;
+  reset();
+}
+
+/*****************************************************************************************/
+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 ){
+    for( int i = 0 ; i < thePointsCnt ; i++ ){
+      QModelIndex aSectIndx = aModel->pointIndex(theSection, thePoint + i);
+      selectionModel()->select(aSectIndx,QItemSelectionModel::Deselect);
+    }
+    QModelIndex aSectIndx = aModel->sectionIndex( theSection );
+    rowsRemoved(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
+  }
+}
+
+void CurveCreator_TreeView::sectionAdded( int theSection )
+{
+  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 ){
+    for( int i = 0 ; i < theSectionCnt ; i++ ){
+      QModelIndex aSectIndx = aModel->sectionIndex(theSection + i);
+      this->selectionModel()->select(aSectIndx,QItemSelectionModel::Deselect);
+    }
+    rowsRemoved( QModelIndex(), theSection, theSection+theSectionCnt-1 );
+  }
+}
+
+void CurveCreator_TreeView::setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent )
+{
+  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 );
+}
+
+void CurveCreator_TreeView::setCurve( CurveCreator_Curve* theCurve )
+{
+  CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
+  if( aModel )
+    aModel->setCurve(theCurve);
+  reset();
+}
index 85fe54cf0b396ef65b6c1153a56d19bde1e9e363..19067ec852734097ca3c71468602c72b0a7fefa2 100755 (executable)
@@ -1,75 +1,75 @@
-#ifndef CURVECREATOR_TREEVIEW_H\r
-#define CURVECREATOR_TREEVIEW_H\r
-\r
-#include <QTreeView>\r
-#include <QAbstractItemModel>\r
-\r
-class CurveCreator_Curve;\r
-\r
-class CurveCreator_TreeViewModel : public QAbstractItemModel\r
-{\r
-public:\r
-  CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent );\r
-  virtual int  columnCount(const QModelIndex & parent = QModelIndex()) const;\r
-  virtual int  rowCount(const QModelIndex & parent = QModelIndex()) const;\r
-  virtual QVariant     data(const QModelIndex & index, int role = Qt::DisplayRole) const;\r
-  virtual QModelIndex  index(int row, int column, const QModelIndex & parent = QModelIndex()) const;\r
-  virtual QModelIndex  parent(const QModelIndex & theIndex) const;\r
-\r
-  QModelIndex sectionIndex( int theSection ) const;\r
-  QModelIndex pointIndex( int theSection, int thePoint ) const;\r
-\r
-  bool    isSection( const QModelIndex& theIndx ) const;\r
-  int     getSection( const QModelIndex& theIndx ) const;\r
-  int     getPoint( const QModelIndex& theIndx ) const;\r
-\r
-  void    setCurve( CurveCreator_Curve* theCurve );\r
-\r
-private:\r
-  enum IconType{ ICON_POLYLINE, ICON_SPLINE, ICON_CLOSED_SPLINE, ICON_CLOSED_POLYLINE, ICON_POINT };\r
-private:\r
-  CurveCreator_Curve*          myCurve;\r
-  QMap<IconType, QPixmap>      myCachedIcons;\r
-};\r
-\r
-class CurveCreator_TreeView : public QTreeView\r
-{\r
-  Q_OBJECT\r
-public:\r
-  enum SelectionType{ ST_NOSEL, ST_POINTS, ST_POINTS_ONE_SECTION, ST_SECTIONS, ST_MIXED };\r
-public:\r
-  explicit CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent = 0);\r
-  SelectionType getSelectionType() const;\r
-  QList<int> getSelectedSections() const;\r
-  QList< QPair< int, int > > getSelectedPoints() const;\r
-\r
-  void    pointsAdded( int theSection, int thePoint, int thePointsCnt=1 );\r
-  void    pointDataChanged( int theSection, int thePoint );\r
-  void    pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 );\r
-  void    pointsSwapped( int theSection, int thePointNum, int theOffset );\r
-\r
-  void    sectionAdded( int theSection );\r
-  void    sectionChanged(int theSection , int aSectCnt = 1);\r
-  void    sectionsRemoved( int theSection, int theSectionCnt=1 );\r
-  void    sectionsSwapped( int theSection, int theOffset );\r
-\r
-  void    setSelectedSections( const QList<int>& theList );\r
-  void    setSelectedPoints( const QList< QPair<int, int> >& thePointsList );\r
-\r
-  void    setCurve( CurveCreator_Curve* theCurve );\r
-\r
-signals:\r
-  void    selectionChanged();\r
-  void    sectionEntered(int);\r
-  void    pointEntered(int,int);\r
-public slots:\r
-protected slots:\r
-  void onActivated( QModelIndex theIndx );\r
-protected:\r
-  void setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );\r
-  void swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond );\r
-  void getIndexInfo( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );\r
-\r
-};\r
-\r
-#endif // CURVECREATOR_TREEVIEW_H\r
+#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;
+
+  void    setCurve( CurveCreator_Curve* theCurve );
+
+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 );
+
+  void    setCurve( CurveCreator_Curve* theCurve );
+
+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 );
+
+};
+
+#endif // CURVECREATOR_TREEVIEW_H
index e05d2ed725c69551ed61072dc45da897709813bf..9ab5db74a9ec0f1e8e2752993ffe2f604693dd51 100644 (file)
-#include "CurveCreator_Widget.h"\r
-#include "CurveCreator_TreeView.h"\r
-#include "QVBoxLayout"\r
-#include "CurveCreator_Curve.hxx"\r
-#include "CurveCreator_CurveEditor.hxx"\r
-#include "CurveCreator.hxx"\r
-#include "CurveCreator_NewPointDlg.h"\r
-#include "CurveCreator_NewSectionDlg.h"\r
-\r
-#include <SUIT_Session.h>\r
-#include <SUIT_ResourceMgr.h>\r
-\r
-#include <QHBoxLayout>\r
-#include <QVBoxLayout>\r
-#include <QLabel>\r
-#include <QLineEdit>\r
-#include <QGroupBox>\r
-#include <QToolButton>\r
-#include <QToolBar>\r
-#include <QAction>\r
-#include <QMenu>\r
-\r
-CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,\r
-                                         CurveCreator_Curve *theCurve,\r
-                                         Qt::WindowFlags fl) :\r
-    QWidget(parent), myNewPointEditor(NULL), myNewSectionEditor(NULL), myEdit(NULL), myCurve(theCurve)\r
-{\r
-    if( myCurve )\r
-        myEdit = new CurveCreator_CurveEditor( myCurve );\r
-\r
-    CurveCreator::Dimension aDim = CurveCreator::Dim3d;\r
-    if( myCurve )\r
-        aDim = myCurve->getDimension();\r
-    myNewPointEditor = new CurveCreator_NewPointDlg(aDim, this);\r
-    connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()));\r
-\r
-    myNewSectionEditor = new CurveCreator_NewSectionDlg(this);\r
-    connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()));\r
-\r
-    QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),this);\r
-\r
-    mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup);\r
-    connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) );\r
-    connect( mySectionView, SIGNAL(pointEntered(int,int)), this, SLOT(onEditPoint(int,int)) );\r
-    connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) );\r
-    connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) );\r
-    QToolBar* aTB = new QToolBar(tr("TOOL_BAR_TLT"), aSectionGroup);\r
-//    QToolButton* anUndoBtn = new QToolButton(aTB);\r
-\r
-    SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();\r
-    QPixmap anUndoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_UNDO")));\r
-    QPixmap aRedoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_REDO")));\r
-    QPixmap aNewSectionPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_SECTION")));\r
-    QPixmap aNewPointPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_POINT")));\r
-    QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));\r
-    QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));\r
-    QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE")));\r
-    QPixmap aJoinPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_JOIN")));\r
-    QPixmap aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP")));\r
-    QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN")));\r
-\r
-/*    QPixmap anUndoPixmap = QPixmap(tr(":images/ICON_UNDO"));\r
-    QPixmap aRedoPixmap = QPixmap(tr(":images/ICON_REDO"));\r
-    QPixmap aNewSectionPixmap = QPixmap(tr(":images/ICON_NEW_SECTION"));\r
-    QPixmap aNewPointPixmap = QPixmap(tr(":images/ICON_NEW_POINT"));\r
-    QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE"));\r
-    QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE"));\r
-    QPixmap aRemovePixmap = QPixmap(tr(":images/ICON_REMOVE"));\r
-    QPixmap aJoinPixmap = QPixmap(tr(":images/ICON_JOIN"));\r
-    QPixmap aStepUpPixmap = QPixmap(tr(":images/ICON_STEP_UP"));\r
-    QPixmap aStepDownPixmap = QPixmap(tr(":images/ICON_STEP_DOWN"));*/\r
-\r
-    QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"), \r
-                                   QKeySequence(Qt::ControlModifier|Qt::Key_Z) );\r
-    aTB->addAction(anAct);\r
-\r
-    anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"), \r
-                          QKeySequence(Qt::ControlModifier|Qt::Key_Y) );\r
-    aTB->addAction(anAct);\r
-\r
-    aTB->addSeparator();\r
-\r
-    anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectionPixmap, tr("NEW_SECTION_TLT"), \r
-                          QKeySequence(Qt::ControlModifier|Qt::Key_N) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) );\r
-    aTB->addAction(anAct);\r
-\r
-    anAct = createAction( INSERT_SECTION_BEFORE_ID, tr("INSERT_SECTION_BEFORE"), QPixmap(), \r
-                          tr("INSERT_SECTION_BEFORE_TLT"),\r
-                          QKeySequence(Qt::ControlModifier | Qt::Key_Insert ) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionBefore()) );\r
-\r
-    anAct = createAction( INSERT_SECTION_AFTER_ID, tr("INSERT_SECTION_AFTER"), QPixmap(), \r
-                          tr("INSERT_SECTION_AFTER_TLT"),\r
-                          QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Insert ) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionAfter()) );\r
-\r
-    anAct = createAction( NEW_POINT_ID, tr("NEW_POINT"), aNewPointPixmap, tr("NEW_POINT_TLT"), \r
-                          QKeySequence(Qt::ControlModifier|Qt::Key_P) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onNewPoint()) );\r
-    aTB->addAction(anAct);\r
-    aTB->addSeparator();\r
-\r
-    anAct = createAction( INSERT_POINT_BEFORE_ID, tr("INSERT_POINT_BEFORE"), QPixmap(), \r
-                          tr("INSERT_POINT_BEFORE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_B) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointBefore()) );\r
-\r
-    anAct = createAction( INSERT_POINT_AFTER_ID, tr("INSERT_POINT_AFTER"), QPixmap(), \r
-                           tr("INSERT_POINT_AFTER_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_M) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertPointAfter()) );\r
-                                 \r
-    anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"), \r
-                          QKeySequence(Qt::ControlModifier|Qt::Key_W) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) );\r
-\r
-    anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), QPixmap(), \r
-                          tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) );\r
-\r
-    anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"), \r
-                          aPolylinePixmap, tr("SET_POLYLINE_TLT"), \r
-                          QKeySequence(Qt::ControlModifier|Qt::Key_E) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) );\r
-\r
-    anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), aSplinePixmap, \r
-                          tr("SET_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );\r
-\r
-    anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"), \r
-                          QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );\r
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );\r
-    aTB->addAction(anAct);\r
-    aTB->addSeparator();\r
-\r
-    anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"), \r
-                          QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );\r
-    connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );\r
-    aTB->addAction(anAct);\r
-    aTB->addSeparator();\r
-\r
-    anAct = createAction( UP_ID, tr("STEP_UP"), aStepUpPixmap, tr("STEP_UP_TLT"), \r
-                          QKeySequence(Qt::ControlModifier|Qt::Key_Up ) );\r
-    connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveUp()) );\r
-    aTB->addAction(anAct);\r
-\r
-    anAct = createAction( DOWN_ID, tr("STEP_DOWN"), aStepDownPixmap, tr("STEP_DOWN"), \r
-                          QKeySequence(Qt::ControlModifier|Qt::Key_Down ) );\r
-    connect( anAct, SIGNAL(triggered()), this, SLOT(onMoveDown()) );\r
-    aTB->addAction(anAct);\r
-\r
-    anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"), \r
-                          QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );\r
-    connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );\r
-\r
-    anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"), \r
-                          QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );\r
-    connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );\r
-\r
-    QVBoxLayout* aSectLayout = new QVBoxLayout();\r
-    aSectLayout->addWidget(aTB);\r
-    aSectLayout->addWidget(mySectionView);\r
-    aSectionGroup->setLayout(aSectLayout);\r
-    QVBoxLayout* aLay = new QVBoxLayout();\r
-//    aLay->addLayout(aNameLayout);\r
-    aLay->addWidget(aSectionGroup);\r
-    setLayout(aLay);\r
-    onSelectionChanged();\r
-}\r
-\r
-void CurveCreator_Widget::setCurve( CurveCreator_Curve* theCurve )\r
-{\r
-  if( myEdit != NULL ){\r
-    delete myEdit;\r
-    myEdit = NULL;\r
-  }\r
-  myCurve = theCurve;\r
-  mySectionView->setCurve(myCurve);\r
-  if( myCurve != NULL ){\r
-    myEdit = new CurveCreator_CurveEditor(myCurve);\r
-  }\r
-  onSelectionChanged();\r
-}\r
-\r
-void CurveCreator_Widget::onSelectionChanged()\r
-{\r
-  QList<ActionId> anEnabledAct;\r
-  if( myCurve ){\r
-    anEnabledAct << NEW_SECTION_ID;\r
-    int aSectCnt = myCurve->getNbPoints();\r
-    if( aSectCnt > 0 )\r
-      anEnabledAct << CLEAR_ALL_ID;\r
-    if( aSectCnt > 1 )\r
-      anEnabledAct << JOIN_ALL_ID;\r
-    QList<int> aSelSections = mySectionView->getSelectedSections();\r
-    QList< QPair< int, int > > aSelPoints = mySectionView->getSelectedPoints();\r
-    CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType();\r
-    switch( aSelType ){\r
-    case CurveCreator_TreeView::ST_NOSEL:{\r
-      break;\r
-    }\r
-    case CurveCreator_TreeView::ST_SECTIONS:{\r
-      if( aSelSections.size() > 1 ){\r
-        anEnabledAct << JOIN_ID;\r
-      }\r
-      if( aSelSections[0] > 0 ){\r
-        anEnabledAct << UP_ID;\r
-      }\r
-      if( aSelSections.size() == 1 ){\r
-        anEnabledAct << NEW_POINT_ID << INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID;\r
-      }\r
-      if( aSelSections[ aSelSections.size() - 1 ] < ( myCurve->getNbSections() - 1 ) ){\r
-        anEnabledAct << DOWN_ID;\r
-      }\r
-      anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;\r
-      break;\r
-    }\r
-    case CurveCreator_TreeView::ST_POINTS_ONE_SECTION:{\r
-      if( aSelPoints[0].second > 0 ){\r
-        anEnabledAct << UP_ID;\r
-      }\r
-      int aLastIndex = aSelPoints.size()-1;\r
-      int aSect = aSelPoints[0].first;\r
-      if( aSelPoints[aLastIndex].second < (myCurve->getNbPoints(aSect) - 1)){\r
-        anEnabledAct << DOWN_ID;\r
-      }\r
-      if( aSelPoints.size() == 1){\r
-        anEnabledAct << INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;\r
-      }\r
-      break;\r
-    }\r
-    }\r
-    int aSelObjsCnt = aSelPoints.size() + aSelSections.size();\r
-    if( aSelObjsCnt > 0 ){\r
-      anEnabledAct << REMOVE_ID;\r
-    }\r
-    if( (myCurve->getNbSections() + myCurve->getNbPoints()) > 0 ){\r
-      anEnabledAct << REMOVE_ALL_ID;\r
-    }\r
-    if( myCurve->getNbSections() > 1 ){\r
-      anEnabledAct << JOIN_ALL_ID;\r
-    }\r
-  }\r
-  QList<ActionId> anIds = myActionMap.keys();\r
-  for( int i = 0 ; i < anIds.size() ; i++ ){\r
-    if( myActionMap.contains(anIds[i]) ){\r
-      if( anEnabledAct.contains(anIds[i]) ){\r
-        myActionMap[anIds[i]]->setEnabled(true);\r
-      }\r
-      else{\r
-        myActionMap[anIds[i]]->setEnabled(false);\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onNewPoint()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  mySection= -1;\r
-  myPointNum = -1;\r
-  QList<int> aSelSection = mySectionView->getSelectedSections();\r
-  if( aSelSection.size() > 0 ){\r
-    mySection = aSelSection[0];\r
-  }\r
-  else{\r
-    QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();\r
-    if( aSelPoints.size() > 0 ){\r
-      mySection = aSelPoints[0].first;\r
-      myPointNum = aSelPoints[0].second + 1;\r
-    }\r
-  }\r
-  QString aSectName;\r
-  if( mySection < 0 ){\r
-    mySection = myCurve->getNbSections() - 1;\r
-  }\r
-  aSectName = QString::fromStdString( myCurve->getSectionName(mySection));\r
-  if( myPointNum < 0 ){\r
-    myPointNum = myCurve->getNbPoints(mySection);\r
-  }\r
-  myNewPointEditor->clear();\r
-  myNewPointEditor->setEditMode(false);\r
-  myNewPointEditor->setSectionName(aSectName);\r
-  myNewPointEditor->setDimension(myCurve->getDimension());\r
-  if( myNewPointEditor->exec() == QDialog::Accepted ){\r
-    onAddNewPoint();\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onAddNewPoint()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();\r
-  myEdit->insertPoints(aCoords, mySection, myPointNum );\r
-  mySectionView->pointsAdded( mySection, myPointNum );\r
-  myNewPointEditor->clear();\r
-  myPointNum++;\r
-  onSelectionChanged();\r
-}\r
-\r
-void CurveCreator_Widget::onNewSection()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  myNewSectionEditor->clear();\r
-  myNewSectionEditor->setEditMode(false);\r
-  QString aSectName = QString( myCurve->getUnicSectionName().c_str() );\r
-  myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );\r
-  if( myNewSectionEditor->exec() == QDialog::Accepted ){\r
-    onAddNewSection();\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onAddNewSection()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  CurveCreator::Coordinates aCoords;\r
-  myEdit->addSection( myNewSectionEditor->getName().toStdString(), myNewSectionEditor->getSectionType(),\r
-                      myNewSectionEditor->isClosed(), aCoords  );\r
-  mySectionView->sectionAdded( mySection );\r
-  QString aNewName = QString(myCurve->getUnicSectionName().c_str());\r
-  myNewSectionEditor->setSectionName(aNewName);\r
-  mySection++;\r
-  onSelectionChanged();\r
-}\r
-\r
-QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theName, const QPixmap& theImage,\r
-                                            const QString& theToolTip, const QKeySequence& theShortcut )\r
-{\r
-  QAction* anAct = new QAction(theName,this);\r
-  if( !theImage.isNull() ){\r
-    anAct->setIcon(theImage);\r
-  }\r
-  anAct->setShortcut(theShortcut);\r
-  anAct->setToolTip(theToolTip);\r
-  myActionMap[theId] = anAct;\r
-  return anAct;\r
-}\r
-\r
-QAction* CurveCreator_Widget::getAction(ActionId theId)\r
-{\r
-  if( myActionMap.contains(theId) )\r
-    return myActionMap[theId];\r
-  return NULL;\r
-}\r
-\r
-void CurveCreator_Widget::onEditSection( int theSection )\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  mySection = theSection;\r
-  QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));\r
-  bool isClosed = myCurve->isClosed(theSection);\r
-  CurveCreator::Type aType = myCurve->getType(theSection);\r
-  myNewSectionEditor->setEditMode(true);\r
-  myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType );\r
-  if( myNewSectionEditor->exec() == QDialog::Accepted ){\r
-    QString aName = myNewSectionEditor->getName();\r
-    bool    isClosed = myNewSectionEditor->isClosed();\r
-    CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();\r
-    myEdit->setClosed( isClosed, mySection );\r
-    myEdit->setName( aName.toStdString(), mySection );\r
-    myEdit->setType( aSectType, mySection );\r
-    mySectionView->sectionChanged(mySection);\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onEditPoint( int theSection, int thePoint )\r
-{\r
-  if( !myNewPointEditor )\r
-    return;\r
-  if( !myEdit )\r
-    return;\r
-  QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));\r
-  myNewPointEditor->setEditMode(true);\r
-  myNewPointEditor->setSectionName(aSectName);\r
-  myNewPointEditor->setDimension( myCurve->getDimension() );\r
-  CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint);\r
-  myNewPointEditor->setCoordinates(aCoords);\r
-  if( myNewPointEditor->exec() == QDialog::Accepted ){\r
-    aCoords = myNewPointEditor->getCoordinates();\r
-    myEdit->setCoordinates(aCoords, theSection, thePoint);\r
-    mySectionView->pointDataChanged(theSection, thePoint );\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onJoin()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  QList<int> aSections = mySectionView->getSelectedSections();\r
-  if( aSections.size() == 0 ){\r
-    return;\r
-  }\r
-  int aMainSect = aSections[0];\r
-  int aMainSectSize = myCurve->getNbPoints(aMainSect);\r
-  for( int i = 1 ; i < aSections.size() ; i++ ){\r
-    int aSectNum = aSections[i] - (i-1);\r
-    myEdit->join( aMainSect, aSectNum );\r
-    mySectionView->sectionsRemoved( aSectNum );\r
-  }\r
-  int aNewSectSize = myCurve->getNbPoints(aMainSect);\r
-  if( aNewSectSize != aMainSectSize )\r
-    mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );\r
-}\r
-\r
-void CurveCreator_Widget::onRemove()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();\r
-  int aCurrSect=-1;\r
-  int aRemoveCnt = 0;\r
-  for( int i = 0 ; i < aSelPoints.size() ; i++ ){\r
-    if( aCurrSect != aSelPoints[i].first ){\r
-      aRemoveCnt = 0;\r
-      aCurrSect = aSelPoints[i].first;\r
-    }\r
-    int aPntIndx = aSelPoints[i].second - aRemoveCnt;\r
-    myEdit->removePoints(aCurrSect,aPntIndx, 1);\r
-    mySectionView->pointsRemoved( aCurrSect, aPntIndx );\r
-    aRemoveCnt++;\r
-  }\r
-  QList<int> aSections = mySectionView->getSelectedSections();\r
-  for( int i = 0 ; i < aSections.size() ; i++ ){\r
-    int aSectNum = aSections[i] - (i);\r
-    myEdit->removeSection( aSectNum );\r
-    mySectionView->sectionsRemoved( aSectNum );\r
-  }\r
-  mySectionView->clearSelection();\r
-}\r
-\r
-void CurveCreator_Widget::onMoveUp()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){\r
-    //Move sections\r
-    QList<int> aSections = mySectionView->getSelectedSections();\r
-    for( int i = 0 ; i < aSections.size() ; i++ ){\r
-      int anIndx = aSections[i];\r
-      myEdit->moveSection( anIndx, anIndx-1);\r
-      mySectionView->sectionsSwapped( anIndx, -1 );\r
-    }\r
-  }\r
-  else{\r
-    //Move points\r
-    QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();\r
-    for( int i = 0 ; i < aPoints.size() ; i++ ){\r
-      int aSection = aPoints[i].first;\r
-      int aPoint = aPoints[i].second;\r
-      myEdit->movePoint(aSection, aPoint, aPoint-2);\r
-      mySectionView->pointsSwapped( aSection, aPoint, -1 );\r
-    }\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onMoveDown()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  if( mySectionView->getSelectionType() == CurveCreator_TreeView::ST_SECTIONS ){\r
-    //Move sections\r
-    QList<int> aSections = mySectionView->getSelectedSections();\r
-    for( int i = aSections.size()-1 ; i >=0 ; i-- ){\r
-      int anIndx = aSections[i];\r
-      myEdit->moveSection( anIndx, anIndx+1);\r
-      mySectionView->sectionsSwapped( anIndx, 1 );\r
-    }\r
-  }\r
-  else{\r
-    //Move points\r
-    QList< QPair<int,int> > aPoints = mySectionView->getSelectedPoints();\r
-    for( int i = aPoints.size() - 1; i >= 0 ; i--  ){\r
-      int aSection = aPoints[i].first;\r
-      int aPoint = aPoints[i].second;\r
-      myEdit->movePoint(aSection, aPoint, aPoint+1);\r
-      mySectionView->pointsSwapped( aSection, aPoint, 1 );\r
-    }\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onClearAll()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  myEdit->clear();\r
-  mySectionView->reset();\r
-  onSelectionChanged();\r
-}\r
-\r
-void CurveCreator_Widget::onJoinAll()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  myEdit->join();\r
-  mySectionView->reset();\r
-  onSelectionChanged();\r
-}\r
-\r
-void CurveCreator_Widget::onInsertSectionBefore()\r
-{\r
-\r
-}\r
-\r
-void CurveCreator_Widget::onInsertSectionAfter()\r
-{\r
-\r
-}\r
-\r
-void CurveCreator_Widget::onInsertPointBefore()\r
-{\r
-\r
-}\r
-\r
-void CurveCreator_Widget::onInsertPointAfter()\r
-{\r
-\r
-}\r
-\r
-void CurveCreator_Widget::onUndoSettings()\r
-{\r
-\r
-}\r
-\r
-void CurveCreator_Widget::onSetSpline()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  QList<int> aSelSections = mySectionView->getSelectedSections();\r
-  for( int i = 0 ; i < aSelSections.size() ; i++ ){\r
-    myEdit->setType(CurveCreator::BSpline, aSelSections[i]);\r
-    mySectionView->sectionChanged(aSelSections[i]);\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onSetPolyline()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  QList<int> aSelSections = mySectionView->getSelectedSections();\r
-  for( int i = 0 ; i < aSelSections.size() ; i++ ){\r
-    myEdit->setType(CurveCreator::Polyline, aSelSections[i]);\r
-    mySectionView->sectionChanged(aSelSections[i]);\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onCloseSections()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  QList<int> aSelSections = mySectionView->getSelectedSections();\r
-  for( int i = 0 ; i < aSelSections.size() ; i++ ){\r
-    myEdit->setClosed(true, aSelSections[i]);\r
-    mySectionView->sectionChanged(aSelSections[i]);\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onUncloseSections()\r
-{\r
-  if( !myEdit )\r
-    return;\r
-  QList<int> aSelSections = mySectionView->getSelectedSections();\r
-  for( int i = 0 ; i < aSelSections.size() ; i++ ){\r
-    myEdit->setClosed(false, aSelSections[i]);\r
-    mySectionView->sectionChanged(aSelSections[i]);\r
-  }\r
-}\r
-\r
-void CurveCreator_Widget::onContextMenu( QPoint thePoint )\r
-{\r
-  QList<ActionId> aContextActions;\r
-  aContextActions << CLEAR_ALL_ID << JOIN_ALL_ID << SEPARATOR_ID <<\r
-                     INSERT_SECTION_BEFORE_ID << INSERT_SECTION_AFTER_ID << SEPARATOR_ID <<\r
-                     CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID <<\r
-                     SET_SECTIONS_SPLINE_ID << SEPARATOR_ID <<\r
-                     INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;\r
-  QPoint aGlPoint = mySectionView->mapToGlobal(thePoint);\r
-  bool isVis = false;\r
-  QList<ActionId> aResAct;\r
-  for( int i = 0 ; i < aContextActions.size() ; i++ ){\r
-    if( aContextActions[i] != SEPARATOR_ID ){\r
-      if( myActionMap.contains(aContextActions[i]) ){\r
-        QAction* anAct = myActionMap[aContextActions[i]];\r
-        if( anAct->isEnabled() ){\r
-          aResAct << aContextActions[i];\r
-          isVis = true;\r
-        }\r
-      }\r
-    }\r
-    else{\r
-      aResAct << SEPARATOR_ID;\r
-    }\r
-  }\r
-  if( !isVis )\r
-    return;\r
-\r
-  QMenu* aMenu = new QMenu(this);\r
-  for( int i = 0 ; i < aResAct.size() ; i++ ){\r
-    if( aResAct[i] == SEPARATOR_ID ){\r
-      aMenu->addSeparator();\r
-    }\r
-    else{\r
-      QAction* anAct = myActionMap[aResAct[i]];\r
-      aMenu->insertAction(NULL, anAct);\r
-    }\r
-  }\r
-  aMenu->exec(aGlPoint);\r
-}\r
+#include "CurveCreator_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 <SUIT_Session.h>
+#include <SUIT_ResourceMgr.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,
+                                         CurveCreator_Curve *theCurve,
+                                         Qt::WindowFlags fl) :
+    QWidget(parent), myNewPointEditor(NULL), myNewSectionEditor(NULL), myEdit(NULL), myCurve(theCurve)
+{
+    if( myCurve )
+        myEdit = new CurveCreator_CurveEditor( myCurve );
+
+    CurveCreator::Dimension aDim = CurveCreator::Dim3d;
+    if( myCurve )
+        aDim = myCurve->getDimension();
+    myNewPointEditor = new CurveCreator_NewPointDlg(aDim, this);
+    connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()));
+
+    myNewSectionEditor = new CurveCreator_NewSectionDlg(this);
+    connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()));
+
+    QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),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);
+
+    SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+    QPixmap anUndoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_UNDO")));
+    QPixmap aRedoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_REDO")));
+    QPixmap aNewSectionPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_SECTION")));
+    QPixmap aNewPointPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_POINT")));
+    QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
+    QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
+    QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE")));
+    QPixmap aJoinPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_JOIN")));
+    QPixmap aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP")));
+    QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN")));
+
+/*    QPixmap anUndoPixmap = QPixmap(tr(":images/ICON_UNDO"));
+    QPixmap aRedoPixmap = QPixmap(tr(":images/ICON_REDO"));
+    QPixmap aNewSectionPixmap = QPixmap(tr(":images/ICON_NEW_SECTION"));
+    QPixmap aNewPointPixmap = QPixmap(tr(":images/ICON_NEW_POINT"));
+    QPixmap aPolylinePixmap = QPixmap(tr(":images/ICON_POLYLINE"));
+    QPixmap aSplinePixmap = QPixmap(tr(":images/ICON_SPLINE"));
+    QPixmap aRemovePixmap = QPixmap(tr(":images/ICON_REMOVE"));
+    QPixmap aJoinPixmap = QPixmap(tr(":images/ICON_JOIN"));
+    QPixmap aStepUpPixmap = QPixmap(tr(":images/ICON_STEP_UP"));
+    QPixmap aStepDownPixmap = QPixmap(tr(":images/ICON_STEP_DOWN"));*/
+
+    QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"), 
+                                   QKeySequence(Qt::ControlModifier|Qt::Key_Z) );
+    aTB->addAction(anAct);
+
+    anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"), 
+                          QKeySequence(Qt::ControlModifier|Qt::Key_Y) );
+    aTB->addAction(anAct);
+
+    aTB->addSeparator();
+
+    anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectionPixmap, 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"), QPixmap(), 
+                          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"), QPixmap(), 
+                          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("NEW_POINT"), aNewPointPixmap, 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"), QPixmap(), 
+                          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"), QPixmap(), 
+                           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"), QPixmap(), 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"), QPixmap(), 
+                          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"), 
+                          aPolylinePixmap, 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"), aSplinePixmap, 
+                          tr("SET_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
+    connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
+
+    anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, 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("JOIN"), aJoinPixmap, 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("STEP_UP"), aStepUpPixmap, 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("STEP_DOWN"), aStepDownPixmap, 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"), QPixmap(), tr("CLEAR_ALL_TLT"), 
+                          QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
+    connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
+
+    anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"), 
+                          QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
+    connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
+
+    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::setCurve( CurveCreator_Curve* theCurve )
+{
+  if( myEdit != NULL ){
+    delete myEdit;
+    myEdit = NULL;
+  }
+  myCurve = theCurve;
+  mySectionView->setCurve(myCurve);
+  if( myCurve != NULL ){
+    myEdit = new CurveCreator_CurveEditor(myCurve);
+  }
+  onSelectionChanged();
+}
+
+void CurveCreator_Widget::onSelectionChanged()
+{
+  QList<ActionId> anEnabledAct;
+  if( myCurve ){
+    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() + myCurve->getNbPoints()) > 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()
+{
+  if( !myEdit )
+    return;
+  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);
+  myNewPointEditor->setDimension(myCurve->getDimension());
+  if( myNewPointEditor->exec() == QDialog::Accepted ){
+    onAddNewPoint();
+  }
+}
+
+void CurveCreator_Widget::onAddNewPoint()
+{
+  if( !myEdit )
+    return;
+  CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
+  myEdit->insertPoints(aCoords, mySection, myPointNum );
+  mySectionView->pointsAdded( mySection, myPointNum );
+  myNewPointEditor->clear();
+  myPointNum++;
+  onSelectionChanged();
+}
+
+void CurveCreator_Widget::onNewSection()
+{
+  if( !myEdit )
+    return;
+  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()
+{
+  if( !myEdit )
+    return;
+  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++;
+  onSelectionChanged();
+}
+
+QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
+                                            const QString& theToolTip, const QKeySequence& theShortcut )
+{
+  QAction* anAct = new QAction(theName,this);
+  if( !theImage.isNull() ){
+    anAct->setIcon(theImage);
+  }
+  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 )
+{
+  if( !myEdit )
+    return;
+  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 )
+    return;
+  if( !myEdit )
+    return;
+  QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
+  myNewPointEditor->setEditMode(true);
+  myNewPointEditor->setSectionName(aSectName);
+  myNewPointEditor->setDimension( myCurve->getDimension() );
+  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()
+{
+  if( !myEdit )
+    return;
+  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()
+{
+  if( !myEdit )
+    return;
+  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( !myEdit )
+    return;
+  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( !myEdit )
+    return;
+  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()
+{
+  if( !myEdit )
+    return;
+  myEdit->clear();
+  mySectionView->reset();
+  onSelectionChanged();
+}
+
+void CurveCreator_Widget::onJoinAll()
+{
+  if( !myEdit )
+    return;
+  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()
+{
+  if( !myEdit )
+    return;
+  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()
+{
+  if( !myEdit )
+    return;
+  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()
+{
+  if( !myEdit )
+    return;
+  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()
+{
+  if( !myEdit )
+    return;
+  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);
+}
index 5a3c55dcd01b9dff478d9fa68c4590cf040a33d4..88f4a7aa6ee201302c7a9117eb67ecd295231f1c 100644 (file)
@@ -1,75 +1,75 @@
-#ifndef CURVECREATOR_WIDGET_H\r
-#define CURVECREATOR_WIDGET_H\r
-\r
-#include "CurveCreator_Curve.hxx"\r
-\r
-#include <QWidget>\r
-\r
-#include <QMap>\r
-\r
-class QAction;\r
-class QPixmap;\r
-class CurveCreator_CurveEditor;\r
-class CurveCreator_TreeView;\r
-class CurveCreator_NewPointDlg;\r
-class CurveCreator_NewSectionDlg;\r
-\r
-class CurveCreator_Widget : public QWidget\r
-{\r
-    Q_OBJECT\r
-public:\r
-    explicit CurveCreator_Widget( QWidget* parent,\r
-                      CurveCreator_Curve *theCurve,\r
-                      Qt::WindowFlags fl=0 );\r
-\r
-    void setCurve( CurveCreator_Curve* theCurve );\r
-\r
-signals:\r
-    \r
-public slots:\r
-\r
-protected slots:\r
-    void     onNewPoint();\r
-    void     onNewSection();\r
-    void     onSelectionChanged();\r
-    void     onAddNewPoint();\r
-    void     onAddNewSection();\r
-    void     onEditSection( int theSection );\r
-    void     onEditPoint( int theSection, int thePoint );\r
-    void     onJoin();\r
-    void     onRemove();\r
-    void     onMoveUp();\r
-    void     onMoveDown();\r
-    void     onClearAll();\r
-    void     onJoinAll();\r
-    void     onInsertSectionBefore();\r
-    void     onInsertSectionAfter();\r
-    void     onSetSpline();\r
-    void     onSetPolyline();\r
-    void     onCloseSections();\r
-    void     onUncloseSections();\r
-    void     onInsertPointBefore();\r
-    void     onInsertPointAfter();\r
-    void     onUndoSettings();\r
-    void     onContextMenu(QPoint thePoint);\r
-protected:\r
-    enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, NEW_POINT_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID,\r
-                   JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID,\r
-                   INSERT_POINT_BEFORE_ID, INSERT_POINT_AFTER_ID, CLOSE_SECTIONS_ID, UNCLOSE_SECTIONS_ID,\r
-                   SET_SECTIONS_POLYLINE_ID, SET_SECTIONS_SPLINE_ID, CLEAR_ALL_ID, SEPARATOR_ID };\r
-private:\r
-    QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,\r
-                           const QString& theToolTip, const QKeySequence& theShortcut );\r
-    QAction* getAction(ActionId theId);\r
-private:\r
-    QMap<ActionId, QAction*>    myActionMap;\r
-    CurveCreator_Curve*         myCurve;\r
-    CurveCreator_CurveEditor*   myEdit;\r
-    CurveCreator_TreeView*      mySectionView;\r
-    CurveCreator_NewPointDlg*   myNewPointEditor;\r
-    CurveCreator_NewSectionDlg* myNewSectionEditor;\r
-    int                         mySection;\r
-    int                         myPointNum;\r
-};\r
-\r
-#endif // CURVECREATOR_WIDGET_H\r
+#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_EXPORT CurveCreator_Widget : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit CurveCreator_Widget( QWidget* parent,
+                      CurveCreator_Curve *theCurve,
+                      Qt::WindowFlags fl=0 );
+
+    void setCurve( CurveCreator_Curve* theCurve );
+
+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
index 6372a395e2d429e1739587e5c948b8e71f629c42..8bd4a36892f1084ccb8c3917bb47e42b6bd3c486 100644 (file)
@@ -55,7 +55,7 @@ salomeinclude_HEADERS =       \
 if GEOM_ENABLE_GUI
   dist_libCurveCreator_la_SOURCES +=  \
         CurveCreator_NewPointDlg.h \
-        CurveCreator_NewSection.h \
+        CurveCreator_NewSectionDlg.h \
         CurveCreator_TreeView.h \
         CurveCreator_Widget.h     \
         CurveCreator_NewPointDlg.cxx \
@@ -87,5 +87,7 @@ libCurveCreator_la_CPPFLAGS = \
        $(GUI_CXXFLAGS)
 
 libCurveCreator_la_LDFLAGS  =                  \
-       $(KERNEL_LDFLAGS)       \
-       $(CAS_KERNEL)
+       $(QT_MT_LIBS) \
+       $(CAS_KERNEL) \
+       $(KERNEL_LDFLAGS) \
+       $(GUI_LDFLAGS) -lqtx -lsuit