]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
OCC functionality moving out from the widget
authornds <nds@opencascade.com>
Wed, 4 Dec 2013 03:47:13 +0000 (03:47 +0000)
committernds <nds@opencascade.com>
Wed, 4 Dec 2013 03:47:13 +0000 (03:47 +0000)
src/HYDROCurveCreator/CurveCreator_Curve.cxx
src/HYDROCurveCreator/CurveCreator_TableView.cxx
src/HYDROCurveCreator/CurveCreator_TableView.h
src/HYDROCurveCreator/CurveCreator_Utils.cxx
src/HYDROCurveCreator/CurveCreator_Utils.h
src/HYDROCurveCreator/CurveCreator_UtilsICurve.cxx
src/HYDROCurveCreator/CurveCreator_UtilsICurve.hxx
src/HYDROCurveCreator/CurveCreator_Widget.cxx
src/HYDROCurveCreator/CurveCreator_Widget.h

index 129520136437240ed6e21fce61cf9ae439a34aad..26268884a478d27e839db990be5dc490a85dab1f 100644 (file)
@@ -1015,6 +1015,8 @@ CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection )
 std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructWire() const
 {
   std::vector<Handle_AIS_InteractiveObject> aCurveRepresentation;
+
+#ifndef ONE_SHAPE
   std::vector<Handle_AIS_InteractiveObject> aSectionObjects;
   for( int iSection = 0 ; iSection < getNbSections() ; iSection++ ){
     aSectionObjects = constructSection( iSection );
@@ -1022,6 +1024,14 @@ std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructWire() co
       aCurveRepresentation.push_back( aSectionObjects.at(iObject) );
     }
   }
+#else
+  TopoDS_Shape aShape;
+  CurveCreator_Utils::constructShape( this, aShape );
+
+  AIS_Shape* anAISShape = new AIS_Shape( aShape );
+  //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
+  aCurveRepresentation.push_back( anAISShape );
+#endif
   return aCurveRepresentation;
 }
 
index 994992214e6e689a78bc1d074ad11a864e9862fd..52a8f4923b2accc3fea52552ad13370cf0cb0007 100644 (file)
@@ -18,6 +18,7 @@
 //
 
 #include "CurveCreator_TableView.h"
+#include "CurveCreator_UtilsICurve.hxx"
 
 #include <QTableWidget>
 #include <QTableWidgetItem>
 const double DBL_MINIMUM = -10000000.;
 const double DBL_MAXIMUM = 10000000.;
 
+const int SECTION_NAME_COLUMN_WIDTH = 75;
+const int POINT_INDEX_COLUMN_WIDTH = 40;
+
+const double LOCAL_SELECTION_TOLERANCE = 0.0001;
+
 CurveCreator_TableItemDelegate::CurveCreator_TableItemDelegate( QObject* theParent )
 : QItemDelegate( theParent )
 {
@@ -92,3 +98,91 @@ void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor,
     QItemDelegate::setModelData( theEditor, theModel, theIndex );
 }
 
+CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent )
+: QTableWidget( theParent ), myCurve( theCurve )
+{
+  setItemDelegate( new CurveCreator_TableItemDelegate( this ) );
+  setVisible( false );
+  setColumnCount( 4 );
+  setColumnWidth( 0, SECTION_NAME_COLUMN_WIDTH );
+  setColumnWidth( 1, POINT_INDEX_COLUMN_WIDTH );
+  QStringList aLabels;
+  //aLabels << tr( "SECTION_LABEL" ) << tr( "IDENTIFIER_LABEL" ) << tr( "X_POSITION_LBL" ) << tr( "Y_POSITION_LBL" );
+  aLabels << tr( "Section" ) << "Index" << tr( "X" ) << tr( "Y" );
+  setHorizontalHeaderLabels( aLabels );
+}
+
+void CurveCreator_TableView::setCurve( CurveCreator_ICurve* theCurve )
+{
+  myCurve = theCurve;
+}
+
+void CurveCreator_TableView::addLocalPointToTable( const double theX, const double theY )
+{
+  CurveCreator_ICurve::SectionToPointList aPoints;
+  CurveCreator_UtilsICurve::findSectionsToPoints( myCurve, theX, theY, aPoints );
+
+  CurveCreator_ICurve::SectionToPointList aSkipList;
+  // table could not contain two equal value rows
+  int aRowId = rowCount();
+  double aCurrentX, aCurrentY;
+  int aSectionId, aPointId;
+  CurveCreator_ICurve::SectionToPoint aPoint;
+  for ( int i = 0; i < aRowId; i++ ) {
+    aCurrentX = item( i, 2 )->data( Qt::UserRole ).toDouble();
+    aCurrentY = item( i, 3 )->data( Qt::UserRole ).toDouble();
+    if ( fabs( aCurrentX - theX ) < LOCAL_SELECTION_TOLERANCE &&
+         fabs( aCurrentY - theY ) < LOCAL_SELECTION_TOLERANCE ) {
+      aPoint = std::make_pair<int, int>( getSectionId( i ), getPointId( i ) );
+      if ( !CurveCreator_UtilsICurve::contains( aSkipList, aPoint ) )
+        aSkipList.push_back( aPoint );
+    }
+  }
+  if ( aSkipList.size() == aPoints.size() )
+    return;
+
+  QTableWidgetItem* anItem;
+  CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(),
+                                                          aLast = aPoints.end();
+  for ( ; anIt != aLast; anIt++ ) {
+    aPoint = *anIt;
+    if ( CurveCreator_UtilsICurve::contains( aSkipList, aPoint ) )
+      continue;
+
+    setRowCount( aRowId+1 );
+    aSectionId = aPoint.first;
+    aPointId = aPoint.second;
+
+    anItem = new QTableWidgetItem( myCurve->getSectionName( aSectionId ).c_str() );
+    anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
+    anItem->setData( Qt::UserRole, aSectionId );
+    setItem( aRowId, 0, anItem );
+
+    anItem = new QTableWidgetItem( QString::number( aPointId + 1 ) );
+    anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
+    anItem->setData( Qt::UserRole, aPointId );
+    setItem( aRowId, 1, anItem );
+
+    anItem = new QTableWidgetItem( QString::number( theX ) );
+    anItem->setData( Qt::UserRole, theX );
+    setItem( aRowId, 2, anItem );
+
+    anItem = new QTableWidgetItem( QString::number( theY ) );
+    anItem->setData( Qt::UserRole, theY );
+    setItem( aRowId, 3, anItem );
+  }
+}
+
+int CurveCreator_TableView::getSectionId( const int theRowId ) const
+{
+  return item( theRowId, 0 )->data( Qt::UserRole ).toInt();
+}
+
+/**
+ * Returns a point index from the table
+ * \param theRowId a table row
+ */
+int CurveCreator_TableView::getPointId( const int theRowId ) const
+{
+  return item( theRowId, 1 )->data( Qt::UserRole ).toInt();
+}
index a1e185ae3e7e0ad4464e48e7d99a5d3ff8c91e06..ffbd3da7fd92602a0bdb11da5b5cbc8a2b0a10c2 100644 (file)
 #ifndef CURVECREATOR_TABLEVIEW_H
 #define CURVECREATOR_TABLEVIEW_H
 
+#include "CurveCreator_ICurve.hxx"
+
 #include <QItemDelegate>
+#include <QTableWidget>
 
 class CurveCreator_TableItemDelegate : public QItemDelegate
 {
@@ -36,4 +39,30 @@ public:
                                  const QModelIndex& theIndex ) const;
 };
 
+class CurveCreator_TableView : public QTableWidget
+{
+public:
+  CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent = 0 );
+  ~CurveCreator_TableView() {};
+
+  void setCurve( CurveCreator_ICurve* theCurve );
+
+  void addLocalPointToTable( const double theX, const double theY );
+
+  /**
+   * Returns a section index from the table
+   * \param theRowId a table row
+   */
+  int getSectionId( const int theRowId ) const;
+  /**
+   * Returns a point index from the table
+   * \param theRowId a table row
+   */
+  int getPointId( const int theRowId ) const;
+
+private:
+  CurveCreator_ICurve* myCurve;
+
+};
+
 #endif // CURVECREATOR_TABLEVIEW_H
index f4e49253ac69e7ff38c073248b656cbf1622a1b5..0007e660c82fe01417f2f1d0b6de90c17e45b040 100644 (file)
@@ -213,6 +213,76 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
   }
 }
 
+void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
+                                         TopoDS_Shape& theShape )
+{
+  BRep_Builder aBuilder;
+  TopoDS_Compound aComp;
+  aBuilder.MakeCompound( aComp );
+  for( int iSection = 0 ; iSection < theCurve->getNbSections() ; iSection++ )
+  {
+    int theISection = iSection;
+
+    CurveCreator::SectionType aSectType = theCurve->getSectionType( theISection );
+    int aPointSize = theCurve->getNbPoints( theISection );
+    bool aSectIsClosed = theCurve->isClosed( theISection );
+    bool isPolyline = aSectType == CurveCreator::Polyline;
+    int iPoint = 0;
+    gp_Pnt aPrevPoint, aPoint;
+    if ( aPointSize == 1 ) {
+      CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
+      TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
+      aBuilder.Add( aComp, aVertex );
+    }
+    else if ( aPointSize > 1 ) {
+      Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aPointSize);
+      int aHIndex = 1;
+
+      TopoDS_Edge aPointEdge;
+      TopoDS_Vertex aVertex;
+      CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
+      aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
+      aBuilder.Add( aComp, aVertex );
+      aHCurvePoints->SetValue(aHIndex++, aPoint);
+      aPrevPoint = aPoint;
+      iPoint++;
+      for( ; iPoint < aPointSize; iPoint++ ) {
+        CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
+        aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
+        aBuilder.Add( aComp, aVertex );
+        aHCurvePoints->SetValue(aHIndex++, aPoint);
+        if ( isPolyline ) {
+          aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge();
+          aBuilder.Add( aComp, aPointEdge );
+        }
+        aPrevPoint = aPoint;
+      }
+      if( aSectIsClosed && ( aPointSize > 2 ) ) {
+        CurveCreator_UtilsICurve::getPoint( theCurve, theISection, 0, aPoint );
+        aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
+        aBuilder.Add( aComp, aVertex );
+        if ( isPolyline ) {
+          aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge();
+          aBuilder.Add( aComp, aPointEdge );
+        }
+      }
+      if( !isPolyline ) {
+        // compute BSpline
+        Handle(Geom_BSplineCurve) aBSplineCurve;
+        GeomAPI_Interpolate aGBC(aHCurvePoints, aSectIsClosed, gp::Resolution());
+        aGBC.Perform();
+        if ( aGBC.IsDone() )
+          aBSplineCurve = aGBC.Curve();
+        TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSplineCurve ).Edge();
+        TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
+        aBuilder.Add( aComp, aWire );
+      }
+    }
+  }
+  theShape = aComp;
+}
+
+
 std::list<float> CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext )
 {
   std::list<float> aSelectedPoints;
index cc0817fac079fd3dedb8a27672254e9b97ede8d5..b81f4cf2bb9ff3ff96fc91d32162bdc0cf7cea0e 100644 (file)
@@ -62,7 +62,7 @@ public:
                                                          Handle(V3d_View) theView );
 
   /**
-   * Generates shape on the curve
+   * Generates shape on the curve with a fixed section index
    * \param theCurve a curve object, that contains data
    * \param theISection a curve section index
    * \param theShape a generated shape
@@ -72,6 +72,14 @@ public:
                                                   TopoDS_Shape& theShape,
                                                   std::vector<Handle_AIS_InteractiveObject>& theAdditional );
 
+  /**
+   * Generates shape on the curve
+   * \param theCurve a curve object, that contains data
+   * \param theShape a generated shape
+   */
+  CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
+                                                  TopoDS_Shape& theShape );
+
   /**
    * Find selected points in the context
    * \param theContext the viewer context
index 979a246d9aa1a6d91a75a0bf301c5532a362ad7d..d8b5d2ded840c5b2d22643040b3f651e08333681 100644 (file)
@@ -94,11 +94,23 @@ void CurveCreator_UtilsICurve::getPoint( const CurveCreator_ICurve* theCurve, co
   thePoint = gp_Pnt( anX, anY, aZ);
 }
 
-/**
- * Returns whethe the container has the value
- * \param theList a container of values
- * \param theValue a value
- */
+std::string CurveCreator_UtilsICurve::getUniqSectionName( CurveCreator_ICurve* theCurve )
+{
+  for( int i = 0 ; i < 1000000 ; i++ ){
+    char aBuffer[255];
+    sprintf( aBuffer, "Section_%d", i+1 );
+    std::string aName(aBuffer);
+    int j;
+    for( j = 0 ; j < theCurve->getNbSections() ; j++ ){
+      if( theCurve->getSectionName(j) == aName )
+        break;
+    }
+    if( j == theCurve->getNbSections() )
+      return aName;
+  }
+  return "";
+}
+
 bool CurveCreator_UtilsICurve::contains( const CurveCreator_ICurve::SectionToPointList& theList,
                                          const CurveCreator_ICurve::SectionToPoint& theValue )
 {
index c749e47b6d615c48dcae9def23847ef9fc0482b3..9681552e663fae1dffef0dcff369b0e627c747e0 100644 (file)
@@ -48,6 +48,13 @@ public:
   CURVECREATOR_EXPORT static void getPoint( const CurveCreator_ICurve* theCurve, const int theISection,
                                             const int theIPoint, gp_Pnt& thePoint );
 
+  /*!
+   * Returns a unique section name
+   * \param theCurve a curve interface
+   */
+  CURVECREATOR_EXPORT static std::string getUniqSectionName(
+                                            CurveCreator_ICurve* theCurve );
+
   /**
    * Returns whethe the container has the value
    * \param theList a container of values
index 96a838c6d9352e69580ca41ce4e9cdbeb61711d9..719a58a7274e519524af45f511c931d909a86030 100644 (file)
 #include <QTableWidget>
 
 const double LOCAL_SELECTION_TOLERANCE = 0.0001;
-const int SECTION_NAME_COLUMN_WIDTH = 75;
-const int POINT_INDEX_COLUMN_WIDTH = 40;
-
-const int SCENE_PIXEL_TOLERANCE = 10;
 
 CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
                                          CurveCreator_ICurve *theCurve,
@@ -98,16 +94,7 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
   connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) );
   connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) );
 
-  myLocalPointView = new QTableWidget();
-  myLocalPointView->setItemDelegate( new CurveCreator_TableItemDelegate( myLocalPointView ) );
-  myLocalPointView->setVisible( false );
-  myLocalPointView->setColumnCount( 4 );
-  myLocalPointView->setColumnWidth( 0, SECTION_NAME_COLUMN_WIDTH );
-  myLocalPointView->setColumnWidth( 1, POINT_INDEX_COLUMN_WIDTH );
-  QStringList aLabels;
-  //aLabels << tr( "SECTION_LABEL" ) << tr( "IDENTIFIER_LABEL" ) << tr( "X_POSITION_LBL" ) << tr( "Y_POSITION_LBL" );
-  aLabels << tr( "Section" ) << "Index" << tr( "X" ) << tr( "Y" );
-  myLocalPointView->setHorizontalHeaderLabels( aLabels );
+  myLocalPointView = new CurveCreator_TableView( myCurve, this );
   connect( myLocalPointView, SIGNAL( cellChanged( int, int ) ),
            this, SLOT( onCellChanged( int, int ) ) );
 
@@ -218,7 +205,9 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
 //    aLay->addLayout(aNameLayout);
   aLay->addWidget(aSectionGroup);
   setLayout(aLay);
-  onSelectionChanged();
+
+  updateActionsStates();
+  updateUndoRedo();
 }
 
 /**
@@ -333,36 +322,23 @@ void CurveCreator_Widget::reset()
 {
 }
 
-//=======================================================================
-// function: getUniqSectionName
-// purpose: return unique section name
-//=======================================================================
-std::string CurveCreator_Widget::getUniqSectionName( CurveCreator_ICurve* theCurve ) const
-{
-  for( int i = 0 ; i < 1000000 ; i++ ){
-      char aBuffer[255];
-      sprintf( aBuffer, "Section_%d", i+1 );
-      std::string aName(aBuffer);
-      int j;
-      for( j = 0 ; j < theCurve->getNbSections() ; j++ ){
-        if( theCurve->getSectionName(j) == aName )
-            break;
-      }
-      if( j == theCurve->getNbSections() )
-          return aName;
-  }
-  return "";
-}
-
 void CurveCreator_Widget::setCurve( CurveCreator_ICurve* theCurve )
 {
   myCurve = theCurve;
-  mySectionView->setCurve(myCurve);
-  onSelectionChanged();
+  mySectionView->setCurve( myCurve );
+  myLocalPointView->setCurve( myCurve );
+  updateActionsStates();
   updateUndoRedo();
 }
 
 void CurveCreator_Widget::onSelectionChanged()
+{
+  updateActionsStates();
+  updateUndoRedo();
+  emit selectionChanged();
+}
+
+void CurveCreator_Widget::updateActionsStates()
 {
   QList<ActionId> anEnabledAct;
   if( myCurve ){
@@ -459,8 +435,6 @@ void CurveCreator_Widget::onSelectionChanged()
       }
     }
   }
-  updateUndoRedo();
-  emit selectionChanged();
 }
 
 void CurveCreator_Widget::onAdditionMode(bool checked)
@@ -526,7 +500,8 @@ void CurveCreator_Widget::onModeChanged(bool checked)
         break;
     }
   }
-  onSelectionChanged();
+  updateActionsStates();
+  updateUndoRedo();
   setLocalPointContext( aMode == ModificationMode, true );
 }
 
@@ -544,7 +519,7 @@ void CurveCreator_Widget::onAddNewPoint(const CurveCreator::Coordinates& theCoor
   int aSection = aSections[0];
   myCurve->addPoints(theCoords, aSection); // add to the end of section
   mySectionView->pointsAdded( aSection, myCurve->getNbPoints( aSection ) );
-  onSelectionChanged();
+  updateActionsStates();
   updateUndoRedo();
 }
 
@@ -554,7 +529,7 @@ void CurveCreator_Widget::onNewSection()
     return;
   myNewSectionEditor->clear();
   myNewSectionEditor->setEditMode(false);
-  QString aSectName = QString( getUniqSectionName(myCurve).c_str() );
+  QString aSectName = QString( CurveCreator_UtilsICurve::getUniqSectionName( myCurve ).c_str() );
   myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );
   emit subOperationStarted( myNewSectionEditor );
 }
@@ -563,12 +538,13 @@ void CurveCreator_Widget::onAddNewSection()
 {
   if( !myCurve )
     return;
-  myCurve->addSection( myNewSectionEditor->getName().toStdString(), myNewSectionEditor->getSectionType(),
-                      myNewSectionEditor->isClosed() );
+  myCurve->addSection( myNewSectionEditor->getName().toStdString(),
+                       myNewSectionEditor->getSectionType(),
+                       myNewSectionEditor->isClosed() );
   mySectionView->sectionAdded( -1 ); // add a new section to the end of list
-  QString aNewName = QString(getUniqSectionName(myCurve).c_str());
+  QString aNewName = QString( CurveCreator_UtilsICurve::getUniqSectionName( myCurve ).c_str() );
   myNewSectionEditor->setSectionName(aNewName);
-  onSelectionChanged();
+  updateActionsStates();
   updateUndoRedo();
   onCancelSection();
 }
@@ -720,7 +696,7 @@ void CurveCreator_Widget::onClearAll()
     return;
   myCurve->clear();
   mySectionView->reset();
-  onSelectionChanged();
+  updateActionsStates();
   updateUndoRedo();
 }
 
@@ -730,7 +706,7 @@ void CurveCreator_Widget::onJoinAll()
     return;
   myCurve->join();
   mySectionView->reset();
-  onSelectionChanged();
+  updateActionsStates();
   updateUndoRedo();
 }
 
@@ -1059,8 +1035,8 @@ void CurveCreator_Widget::onMouseMove( QMouseEvent* theEvent )
 
 void CurveCreator_Widget::onCellChanged( int theRow, int theColumn )
 {
-  int aCurrSect = getSectionId( theRow );
-  int aPntIndex = getPointId( theRow );
+  int aCurrSect = myLocalPointView->getSectionId( theRow );
+  int aPntIndex = myLocalPointView->getPointId( theRow );
 
   if ( aPntIndex < 0 )
     return;
@@ -1251,7 +1227,7 @@ void CurveCreator_Widget::updateLocalPointView()
     float anY = *anIt;
     anIt++;
     float aZ = *anIt;
-    addLocalPointToTable( aX, anY );
+    myLocalPointView->addLocalPointToTable( aX, anY );
   }
   myLocalPointView->blockSignals(isBlocked);
 }
@@ -1266,62 +1242,6 @@ void CurveCreator_Widget::setLocalPointContext( const bool theOpen, const bool i
     updateLocalPointView();
 }
 
-void CurveCreator_Widget::addLocalPointToTable( const double theX, const double theY )
-{
-  CurveCreator_ICurve::SectionToPointList aPoints;
-  findSectionsToPoints( theX, theY, aPoints );
-
-  CurveCreator_ICurve::SectionToPointList aSkipList;
-  // table could not contain two equal value rows
-  int aRowId = myLocalPointView->rowCount();
-  double aCurrentX, aCurrentY;
-  int aSectionId, aPointId;
-  CurveCreator_ICurve::SectionToPoint aPoint;
-  for ( int i = 0; i < aRowId; i++ ) {
-    aCurrentX = myLocalPointView->item( i, 2 )->data( Qt::UserRole ).toDouble();
-    aCurrentY = myLocalPointView->item( i, 3 )->data( Qt::UserRole ).toDouble();
-    if ( fabs( aCurrentX - theX ) < LOCAL_SELECTION_TOLERANCE &&
-         fabs( aCurrentY - theY ) < LOCAL_SELECTION_TOLERANCE ) {
-           aPoint = std::make_pair<int, int>( getSectionId( i ), getPointId( i ) );
-      if ( !contains( aSkipList, aPoint ) )
-        aSkipList.push_back( aPoint );
-    }
-  }
-  if ( aSkipList.size() == aPoints.size() )
-    return;
-
-  QTableWidgetItem* anItem;
-  CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(),
-                                                          aLast = aPoints.end();
-  for ( ; anIt != aLast; anIt++ ) {
-    aPoint = *anIt;
-    if ( contains( aSkipList, aPoint ) )
-      continue;
-
-    myLocalPointView->setRowCount( aRowId+1 );
-    aSectionId = aPoint.first;
-    aPointId = aPoint.second;
-
-    anItem = new QTableWidgetItem( myCurve->getSectionName( aSectionId ).c_str() );
-    anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
-    anItem->setData( Qt::UserRole, aSectionId );
-    myLocalPointView->setItem( aRowId, 0, anItem );
-
-    anItem = new QTableWidgetItem( QString::number( aPointId + 1 ) );
-    anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
-    anItem->setData( Qt::UserRole, aPointId );
-    myLocalPointView->setItem( aRowId, 1, anItem );
-
-    anItem = new QTableWidgetItem( QString::number( theX ) );
-    anItem->setData( Qt::UserRole, theX );
-    myLocalPointView->setItem( aRowId, 2, anItem );
-
-    anItem = new QTableWidgetItem( QString::number( theY ) );
-    anItem->setData( Qt::UserRole, theY );
-    myLocalPointView->setItem( aRowId, 3, anItem );
-  }
-}
-
 /**
  * Set drag operation started. Save the position and a list of dragged points
  * \param theState the drag operation state: started/finished
@@ -1351,7 +1271,8 @@ void CurveCreator_Widget::getSelectedPonts( CurveCreator_ICurve::SectionToPointL
 {
   thePoints.clear();
   for ( int i = 0, aNb = myLocalPointView->rowCount(); i < aNb; i++ )
-    thePoints.push_back( std::make_pair( getSectionId( i ), getPointId( i ) ) );
+    thePoints.push_back( std::make_pair( myLocalPointView->getSectionId( i ),
+                                         myLocalPointView->getPointId( i ) ) );
 }
 
 
@@ -1359,22 +1280,15 @@ bool CurveCreator_Widget::isIntersectVertexToPoint( const TopoDS_Vertex& theVert
                                const CurveCreator_ICurve::SectionToPoint& theSToPoint )
 {
   bool isIntersect = false;
-
   if ( theVertex.IsNull() )
     return isIntersect;
 
-  gp_Pnt aPnt = BRep_Tool::Pnt( theVertex );
-
-  CurveCreator_ICurve::SectionToPointList aPoints;
-  findSectionsToPoints( aPnt.X(), aPnt.Y(), aPoints );
-
-  CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(),
-                                                          aLast = aPoints.end();
-  CurveCreator_ICurve::SectionToPoint aPoint;
-  for ( ; anIt != aLast && !isIntersect; anIt++ ) {
-    aPoint = *anIt;
-    isIntersect = aPoint.first == theSToPoint.first && aPoint.second == theSToPoint.second;
-  }
+  gp_Pnt aSPoint;
+  CurveCreator_UtilsICurve::getPoint( myCurve, theSToPoint.first, theSToPoint.second,
+                                      aSPoint );
+  gp_Pnt aVertexPoint = BRep_Tool::Pnt( theVertex );
+  isIntersect = fabs( aVertexPoint.X() - aSPoint.X() ) < LOCAL_SELECTION_TOLERANCE &&
+                fabs( aVertexPoint.Y() - aSPoint.Y() ) < LOCAL_SELECTION_TOLERANCE;
 
   return isIntersect;
 }
@@ -1400,7 +1314,6 @@ void CurveCreator_Widget::setSelectedPonts( const CurveCreator_ICurve::SectionTo
   bool isSelectedVertex = false;
   for( ; anIt != aLast; anIt++ ) {
     aSToPoint = *anIt;
-
     for ( AIS_ListIteratorOfListOfInteractive it( aDisplayedList ); it.More(); it.Next() )
     {
       Handle(AIS_InteractiveObject) anAIS = it.Value();
@@ -1491,24 +1404,6 @@ void CurveCreator_Widget::convert( const CurveCreator_ICurve::SectionToPointList
   return CurveCreator_UtilsICurve::convert( thePoints, theConvPoints );
 }
 
-/**
- * Returns a section index from the table
- * \param theRowId a table row
- */
-int CurveCreator_Widget::getSectionId( const int theRowId ) const
-{
-  return myLocalPointView->item( theRowId, 0 )->data( Qt::UserRole ).toInt();
-}
-
-/**
- * Returns a point index from the table
- * \param theRowId a table row
- */
-int CurveCreator_Widget::getPointId( const int theRowId ) const
-{
-  return myLocalPointView->item( theRowId, 1 )->data( Qt::UserRole ).toInt();
-}
-
 /**
  * Returns whethe the container has the value
  * \param theList a container of values
index 6f073f165f7696cc88b320f642f8dc03d0ff868d..fcb6cc34cd7bf8cfa6dd13b49ee591a0775bd899 100644 (file)
@@ -43,7 +43,7 @@ class AIS_ListOfInteractive;
 
 class QAction;
 class QPixmap;
-class QTableWidget;
+class CurveCreator_TableView;
 class CurveCreator_TreeView;
 class CurveCreator_NewPointDlg;
 class CurveCreator_NewSectionDlg;
@@ -65,10 +65,6 @@ public:
   void setObjectsSelected(const AIS_ListOfInteractive& theList);
 
   void reset();
-
-  //! Return unique section name
-  std::string getUniqSectionName(CurveCreator_ICurve* theCurve) const;
-
   void setCurve( CurveCreator_ICurve* theCurve );
 
   QList<int> getSelectedSections();
@@ -155,7 +151,8 @@ private:
   QAction* getAction(ActionId theId);
   ActionMode getActionMode() const;
 
-  void     updateUndoRedo();
+  void updateActionsStates();
+  void updateUndoRedo();
 
   void removeSection();
   void removePoint();
@@ -164,7 +161,6 @@ private:
   void moveSelectedPoints( const int theXPosition, const int theYPosition );
   void updateLocalPointView();
   void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
-  void addLocalPointToTable( const double theX, const double theY );
 
   void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
 
@@ -186,18 +182,14 @@ private:
   void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
                 QMap<int, QList<int> >& theConvPoints );
 
-  // local point view table methods
-  int getSectionId( const int theRowId ) const;
-  int getPointId( const int theRowId ) const;
-
   bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
                  const CurveCreator_ICurve::SectionToPoint& theValue ) const;
 
 private:
   QMap<ActionId, QAction*>    myActionMap;
-  CurveCreator_ICurve*         myCurve;
+  CurveCreator_ICurve*        myCurve;
   CurveCreator_TreeView*      mySectionView;
-  QTableWidget*               myLocalPointView;
+  CurveCreator_TableView*     myLocalPointView;
   CurveCreator_NewSectionDlg* myNewSectionEditor;
   OCCViewer_Viewer*           myOCCViewer;
   int                         mySection;