]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
*** empty log message ***
authorakl <akl@opencascade.com>
Mon, 28 Oct 2013 06:50:13 +0000 (06:50 +0000)
committerakl <akl@opencascade.com>
Mon, 28 Oct 2013 06:50:13 +0000 (06:50 +0000)
src/CurveCreator/CurveCreator_ICurve.cxx
src/CurveCreator/CurveCreator_TreeView.cxx
src/CurveCreator/CurveCreator_TreeView.h
src/CurveCreator/CurveCreator_Widget.cxx

index 1cf2869d8eb39fe91ba93d2a4771f9171653da96..a52e34001e4601c17ee869e461cc352b88123fa5 100644 (file)
@@ -216,7 +216,8 @@ void CurveCreator_ICurve::removeSection(const int theISection)
     delete *anIterRm;
     mySections.erase(anIterRm);
   }
-   myListener->sectionRemoved(theISection);
+  if( myListener )
+    myListener->sectionRemoved(theISection);
 }
 
 //=======================================================================
@@ -268,7 +269,8 @@ void CurveCreator_ICurve::removePoints(const int theISection,
     aSection->myPoints.end() : anIterBegin + toICoord(theNbPoints));
 
   aSection->myPoints.erase(anIterBegin, anIterEnd);
-  myListener->pointRemoved(theISection, theIPnt, theNbPoints );
+  if( myListener )
+    myListener->pointRemoved(theISection, theIPnt, theNbPoints );
 }
 
 //=======================================================================
index d7b49f9c79d0d3536c6c6fb3cafa50555a2f89bd..18704810c1777980e07cdae10d824d34cd6f9b1d 100755 (executable)
@@ -160,6 +160,11 @@ QModelIndex CurveCreator_TreeViewModel::sectionIndex( int theSection ) const
   return createIndex( theSection, 0, ID_SECTION );
 }
 
+QModelIndex CurveCreator_TreeViewModel::nbPointsIndex( int theSection ) const
+{
+  return createIndex( theSection, 1, ID_SECTION );
+}
+
 QModelIndex CurveCreator_TreeViewModel::pointIndex( int theSection, int thePoint ) const
 {
   return createIndex( thePoint, 0, theSection );
@@ -203,9 +208,10 @@ CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWid
   CurveCreator_TreeViewModel* aModel = new CurveCreator_TreeViewModel(theCurve, this);
   setModel(aModel);
   setSelectionBehavior(SelectRows);
-  setSelectionMode(ExtendedSelection);
+  setSelectionMode(SingleSelection);
   setRootIsDecorated(false);
   setItemsExpandable(false);
+  setAllColumnsShowFocus(true);
   connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SIGNAL(selectionChanged()) );
   connect( this, SIGNAL(activated(QModelIndex)), this, SLOT(onActivated(QModelIndex)));
@@ -235,6 +241,7 @@ void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePo
     QModelIndex aSectIndx = aModel->sectionIndex( theSection );
     rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
 //    expand( aSectIndx );
+    update( aModel->nbPointsIndex( theSection ) );
   }
 }
 
index aab39b6af26daf9026a406636846e895d7da19d8..57dce8652b7d6815f8ad911764f414a33f0b8d5d 100755 (executable)
@@ -18,6 +18,7 @@ public:
 //  virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole);
 
   QModelIndex sectionIndex( int theSection ) const;
+  QModelIndex nbPointsIndex( int theSection ) const;
   QModelIndex pointIndex( int theSection, int thePoint ) const;
 
   bool    isSection( const QModelIndex& theIndx ) const;
index 32950c1206e0a4827309386b9c73d97f6e033d5c..f5399e414c681505e8e855443439706831a4bb7a 100644 (file)
@@ -226,11 +226,6 @@ 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();
@@ -239,22 +234,40 @@ void CurveCreator_Widget::onSelectionChanged()
       break;
     }
     case CurveCreator_TreeView::ST_SECTIONS:{
-      if( aSelSections.size() > 1 ){
-        anEnabledAct << JOIN_ID;
-      }
-      if( aSelSections[0] > 0 ){
+      /*if( aSelSections[0] > 0 ){
         anEnabledAct << UP_ID;
-      }
+      }*/
       if( aSelSections.size() == 1 ){
         anEnabledAct << CREATION_MODE_ID << EDITION_MODE_ID << DETECTION_MODE_ID;
       }
-      if( aSelSections[ aSelSections.size() - 1 ] < ( myCurve->getNbSections() - 1 ) ){
-        anEnabledAct << DOWN_ID;
+      if (myActionMap[CREATION_MODE_ID]->isChecked()) {
+        mySection = -1;
+        myPointNum = -1;
+        QList<int> aSelSection = mySectionView->getSelectedSections();
+        if( aSelSection.size() > 0 ){
+          mySection = aSelSection[0];
+          myPointNum = myCurve->getNbPoints(mySection);
+        }
+      } else if (myActionMap[EDITION_MODE_ID]->isChecked()) {
+        anEnabledAct << REMOVE_ID;
+        anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
+        int aSectCnt = myCurve->getNbSections();
+        if( aSectCnt > 0 )
+          anEnabledAct << CLEAR_ALL_ID;
+        if( aSectCnt > 1 )
+          anEnabledAct << JOIN_ALL_ID;
+        if( aSelSections.size() > 1 ){
+          anEnabledAct << JOIN_ID;
+        }
+      } else if (myActionMap[DETECTION_MODE_ID]->isChecked()) {
+      } else { //no active mode
       }
-      anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
+      /*if( aSelSections[ aSelSections.size() - 1 ] < ( myCurve->getNbSections() - 1 ) ){
+        anEnabledAct << DOWN_ID;
+      }*/
       break;
     }
-    case CurveCreator_TreeView::ST_POINTS_ONE_SECTION:{
+    /*case CurveCreator_TreeView::ST_POINTS_ONE_SECTION:{
       if( aSelPoints[0].second > 0 ){
         anEnabledAct << UP_ID;
       }
@@ -267,15 +280,17 @@ void CurveCreator_Widget::onSelectionChanged()
         anEnabledAct << INSERT_POINT_BEFORE_ID << INSERT_POINT_AFTER_ID;
       }
       break;
+    }*/
+
     }
-    }
-    int aSelObjsCnt = aSelPoints.size() + aSelSections.size();
+    
+    /*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;
     }
@@ -356,29 +371,30 @@ void CurveCreator_Widget::onDetectPoints(bool checked)
 
 void CurveCreator_Widget::onModeChanged(bool checked)
 {
-  if (!checked)
-    return;
-  QAction* anAction = (QAction*)sender();
-  switch(myActionMap.key(anAction)) {
-    case CREATION_MODE_ID:
-      if (myActionMap[EDITION_MODE_ID]->isChecked())
-        myActionMap[EDITION_MODE_ID]->trigger();
-      else if (myActionMap[DETECTION_MODE_ID]->isChecked())
-        myActionMap[DETECTION_MODE_ID]->trigger();
-      break;
-    case EDITION_MODE_ID:
-      if (myActionMap[CREATION_MODE_ID]->isChecked())
-        myActionMap[CREATION_MODE_ID]->trigger();
-      else if (myActionMap[DETECTION_MODE_ID]->isChecked())
-        myActionMap[DETECTION_MODE_ID]->trigger();
-      break;
-    case DETECTION_MODE_ID:
-      if (myActionMap[CREATION_MODE_ID]->isChecked())
-        myActionMap[CREATION_MODE_ID]->trigger();
-      else if (myActionMap[EDITION_MODE_ID]->isChecked())
-        myActionMap[EDITION_MODE_ID]->trigger();
-      break;
+  if (checked) {
+    QAction* anAction = (QAction*)sender();
+    switch(myActionMap.key(anAction)) {
+      case CREATION_MODE_ID:
+        if (myActionMap[EDITION_MODE_ID]->isChecked())
+          myActionMap[EDITION_MODE_ID]->trigger();
+        else if (myActionMap[DETECTION_MODE_ID]->isChecked())
+          myActionMap[DETECTION_MODE_ID]->trigger();
+        break;
+      case EDITION_MODE_ID:
+        if (myActionMap[CREATION_MODE_ID]->isChecked())
+          myActionMap[CREATION_MODE_ID]->trigger();
+        else if (myActionMap[DETECTION_MODE_ID]->isChecked())
+          myActionMap[DETECTION_MODE_ID]->trigger();
+        break;
+      case DETECTION_MODE_ID:
+        if (myActionMap[CREATION_MODE_ID]->isChecked())
+          myActionMap[CREATION_MODE_ID]->trigger();
+        else if (myActionMap[EDITION_MODE_ID]->isChecked())
+          myActionMap[EDITION_MODE_ID]->trigger();
+        break;
+    }
   }
+  onSelectionChanged();
 }
 
 void CurveCreator_Widget::onAddNewPoint()
@@ -387,8 +403,8 @@ void CurveCreator_Widget::onAddNewPoint()
     return;
   CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
   myEdit->insertPoints(aCoords, mySection, myPointNum );
-//  mySectionView->pointsAdded( mySection, myPointNum );
-//  myNewPointEditor->clear();
+  mySectionView->pointsAdded( mySection, myPointNum );
+  myNewPointEditor->clear();
   myPointNum++;
   onSelectionChanged();
   updateUndoRedo();