Salome HOME
refs #1331: profiles points sorting
authorasl <asl@opencascade.com>
Thu, 28 Sep 2017 07:26:37 +0000 (10:26 +0300)
committerasl <asl@opencascade.com>
Thu, 28 Sep 2017 07:26:37 +0000 (10:26 +0300)
src/CurveCreator/CurveCreator_TableView.cxx
src/CurveCreator/CurveCreator_TableView.h
src/CurveCreator/CurveCreator_Widget.h

index 6cd0b35ae4d2a4f331ccef53b748b9cc87b52f7c..a6d819dcd78830415b57251a2e85853b2e76a527 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "CurveCreator_TableView.h"
 #include "CurveCreator_UtilsICurve.hxx"
+#include "CurveCreator_Widget.h"
 
 #include <gp_Pnt.hxx>
 
@@ -98,9 +99,10 @@ void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor,
 
 
 CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve,
-                                                QWidget* theParent,
+                                                CurveCreator_Widget* theParent,
                                                 const QStringList& theCoordTitles )
-  : QTableWidget( theParent ), myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder )
+  : QTableWidget( theParent ), myWidget( theParent ),
+    myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder )
 {
   setItemDelegate( new CurveCreator_TableItemDelegate( this ) );
   setVisible( false );
@@ -209,5 +211,15 @@ void CurveCreator_TableView::OnHeaderClick( int theLogicalId )
       myCurrentSortOrder = Qt::AscendingOrder;
 
   sortByColumn( theLogicalId, myCurrentSortOrder );
+
+  CurveCreator_ICurve::SectionToPointList selected;
+  for( int r=0, n=rowCount(); r<n; r++ )
+  {
+    int section = item( r, 0 )->data( Qt::UserRole ).toInt();
+    int point = item( r, 1 )->data( Qt::UserRole ).toInt();
+    selected.push_back( CurveCreator_ICurve::SectionToPoint( section, point ) );
+  }
+  myWidget->setSelectedPoints( selected );
+
   myCurrentSortId = theLogicalId;
 }
index 67d813c173058dd003cfba3d9fca99821c31ef2d..c293e834416ec5ac4a01e124af2504ffcbd8b483 100644 (file)
@@ -25,6 +25,8 @@
 #include <QItemDelegate>
 #include <QTableWidget>
 
+class CurveCreator_Widget;
+
 class CurveCreator_TableItemDelegate : public QItemDelegate
 {
 public:
@@ -44,7 +46,7 @@ class CurveCreator_TableView : public QTableWidget
   Q_OBJECT
 
 public:
-  CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent = 0,
+  CurveCreator_TableView( CurveCreator_ICurve* theCurve, CurveCreator_Widget* theParent,
                           const QStringList& theCoordTitles = QStringList() );
   ~CurveCreator_TableView() {};
 
@@ -67,6 +69,7 @@ private slots:
   void OnHeaderClick( int );
 
 private:
+  CurveCreator_Widget* myWidget;
   CurveCreator_ICurve* myCurve;
 
   int           myCurrentSortId;
index da38404a6127ef3be372d8b2a4ee21137524db91..bcde2f6d6159afb418e7de3b225413270693a207 100644 (file)
@@ -95,6 +95,9 @@ public:
 
   void SetViewer2DMode(const bool To2D);
 
+  void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
+                               CurveCreator_ICurve::SectionToPointList() );
+
 signals:
   void selectionChanged();
   void subOperationStarted( QWidget*, bool );
@@ -185,8 +188,6 @@ private:
   void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
 
   void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints );
-  void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
-                               CurveCreator_ICurve::SectionToPointList() );
 
   void stopActionMode();