Salome HOME
Using stl container instead of Qt.
authornds <nds@opencascade.com>
Wed, 20 Nov 2013 11:48:06 +0000 (11:48 +0000)
committernds <nds@opencascade.com>
Wed, 20 Nov 2013 11:48:06 +0000 (11:48 +0000)
src/HYDROCurveCreator/CurveCreator_Widget.cxx
src/HYDROCurveCreator/CurveCreator_Widget.h

index fed3c5013b2fb983f1a251199b4b914ebb6567a9..f55d43d4eb32a881c14cb3f66b40b20bff7d532b 100644 (file)
@@ -1141,7 +1141,6 @@ void CurveCreator_Widget::updateLocalPointView()
   bool isBlocked = myLocalPointView->blockSignals(true);
   gp_Pnt aPnt;
   myLocalPointView->setRowCount( 0 );
-  int anInitialCount = myLocalPointView->rowCount();
   for ( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() ) {
     TopoDS_Vertex aVertex;
     TopoDS_Shape aShape = aContext->SelectedShape();
@@ -1176,9 +1175,6 @@ void CurveCreator_Widget::updateLocalPointView()
       addLocalPointToTable( aPnt.X(), aPnt.Y() );
     }
   }
-  int aFinalCount = myLocalPointView->rowCount();
-  if ( anInitialCount == aFinalCount )
-    int aValue = 9;
   myLocalPointView->blockSignals(isBlocked);
 }
 
@@ -1247,9 +1243,9 @@ void CurveCreator_Widget::addLocalPointToTable( const double theX, const double
     aCurrentY = myLocalPointView->item( i, 3 )->data( Qt::UserRole ).toDouble();
     if ( fabs( aCurrentX - theX ) < LOCAL_SELECTION_TOLERANCE &&
          fabs( aCurrentY - theY ) < LOCAL_SELECTION_TOLERANCE ) {
-      aPoint = qMakePair( getSectionId( i ), getPointId( i ) );
-      if ( !aSkipList.contains( aPoint ) )
-        aSkipList.append( aPoint );
+           aPoint = std::make_pair<int, int>( getSectionId( i ), getPointId( i ) );
+      if ( !contains( aSkipList, aPoint ) )
+        aSkipList.push_back( aPoint );
     }
   }
   if ( aSkipList.size() == aPoints.size() )
@@ -1259,7 +1255,7 @@ void CurveCreator_Widget::addLocalPointToTable( const double theX, const double
   SectionToPointList::const_iterator anIt = aPoints.begin(), aLast = aPoints.end();
   for ( ; anIt != aLast; anIt++ ) {
     aPoint = *anIt;
-    if ( aSkipList.contains( aPoint ) )
+    if ( contains( aSkipList, aPoint ) )
       continue;
 
     myLocalPointView->setRowCount( aRowId+1 );
@@ -1317,7 +1313,7 @@ void CurveCreator_Widget::getSelectedPonts( CurveCreator_Widget::SectionToPointL
 {
   thePoints.clear();
   for ( int i = 0, aNb = myLocalPointView->rowCount(); i < aNb; i++ )
-    thePoints.append( qMakePair( getSectionId( i ), getPointId( i ) ) );
+    thePoints.push_back( std::make_pair( getSectionId( i ), getPointId( i ) ) );
 }
 
 void CurveCreator_Widget::setSelectedPonts( const CurveCreator_Widget::SectionToPointList& thePoints )
@@ -1357,7 +1353,7 @@ void CurveCreator_Widget::setSelectedPonts( const CurveCreator_Widget::SectionTo
     SectionToPoint aPoint;
     for ( ; anIt != aLast; anIt++ ) {
       aPoint = *anIt;
-      if ( thePoints.contains( aPoint ) )
+      if ( contains( thePoints, aPoint ) )
         aListToSelect.Append( anAIS );
     }
   }
@@ -1432,9 +1428,9 @@ void CurveCreator_Widget::findSectionsToPoints( const double theX, const double
     aPointId = findLocalPointIndex( i, theX, theY );
     if ( aPointId < 0 )
       continue;
-    SectionToPoint aPoint = qMakePair( i, aPointId );
-    if ( !thePoints.contains( aPoint ) )
-     thePoints.append( aPoint );
+    SectionToPoint aPoint = std::make_pair( i, aPointId );
+    if ( !contains( thePoints, aPoint ) )
+      thePoints.push_back( aPoint );
   }
 }
 
@@ -1598,3 +1594,20 @@ 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
+ * \param theValue a value
+ */
+bool CurveCreator_Widget::contains( const CurveCreator_Widget::SectionToPointList& theList,
+                                    const CurveCreator_Widget::SectionToPoint& theValue ) const
+{
+  bool isFound = false;
+
+  SectionToPointList::const_iterator anIt = theList.begin(), aLast = theList.end();
+  for ( ; anIt != aLast && !isFound; anIt++ )
+    isFound = anIt->first == theValue.first && anIt->second == theValue.second;
+
+  return isFound;
+}
index d0559c50b67cc7bc586b97a7e93f585cab502b47..03cfd0948a1ff4c188eab8a1b95b5a038ce82d3e 100644 (file)
@@ -130,8 +130,8 @@ protected:
     DetectionMode
   };
 
-  typedef QPair< int, int > SectionToPoint;
-  typedef QList< SectionToPoint > SectionToPointList;
+  typedef std::pair< int, int > SectionToPoint;
+  typedef std::deque< SectionToPoint > SectionToPointList;
 
 private:
   QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
@@ -178,6 +178,8 @@ private:
   int getSectionId( const int theRowId ) const;
   int getPointId( const int theRowId ) const;
 
+  bool contains( const SectionToPointList& theList, const SectionToPoint& theValue ) const;
+
 private:
   QMap<ActionId, QAction*>    myActionMap;
   CurveCreator_ICurve*         myCurve;