Salome HOME
Unicode support: correct handling of unicode on GUI level
[modules/gui.git] / src / SPlot2d / SPlot2d_ViewModel.cxx
index a9b214e590a8c97512937076265831cb2415df78..0d8250f24822a3322f53d1bee0caac6b8a493205 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #include <qwt_plot_curve.h>
 #include <stdlib.h>
 
-//ASL: Temporary commented in order to avoir dependency on SALOMEDS
-
-//#include "SALOMEDSClient.hxx"
-//#include "SALOMEDS_StudyManager.hxx"
-
-// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
-// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from
-// SALOMEDS::StudyManager - no linkage with SalomeApp.  
-
-/*static _PTR(Study) getStudyDS()
-{
-  SALOMEDSClient_Study* aStudy = NULL;
-  _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
-
-  // get id of SUIT_Study, if it's a SalomeApp_Study, it will return
-  //    id of its underlying SALOMEDS::Study
-  SUIT_Application* app = SUIT_Session::session()->activeApplication();
-  if ( !app )  return _PTR(Study)(aStudy);
-  SUIT_Study* stud = app->activeStudy();
-  if ( !stud ) return _PTR(Study)(aStudy);
-  const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
-  // get SALOMEDS_Study with this id from StudyMgr
-  return aMgr->GetStudyByID( id );
-} */               
-
 /*!
   Constructor
 */
@@ -110,7 +85,7 @@ void SPlot2d_Viewer::rename( const Handle(SALOME_InteractiveObject)& IObject,
     }
 
     if( aCurve && aCurve->hasTableIO() && aCurve->getTableIO()->isSame( IObject ) )
-      aCurve->getTableIO()->setName( newName.toLatin1() );
+      aCurve->getTableIO()->setName( newName.toUtf8() );
   }
   aViewFrame->updateTitles();
 }
@@ -407,17 +382,31 @@ void SPlot2d_Viewer::onClicked( const QVariant& itemInfo, int index )
 
   QwtPlotItem* plotItem = aViewFrame->getPlot()->infoToItem( itemInfo );
 
-  bool isAnalytical = false;
+  bool isCurveSelected = false;
+  CurveDict aCurves = aViewFrame->getCurves();
+  for( CurveDict::Iterator it = aCurves.begin(); it != aCurves.end(); ++it )
+  {
+    if(plotItem == it.key()) {
+      isCurveSelected = true;
+      it.value()->setSelected(true);
+    } else {
+      it.value()->setSelected(false);
+    }
+  }
+
   AnalyticalCurveList curves = aViewFrame->getAnalyticalCurves();
    foreach ( Plot2d_AnalyticalCurve* curve, curves ) {
           if(plotItem == curve->plotItem()) {
-                 isAnalytical = true;
+          isCurveSelected = true;
                  curve->setSelected(true);
           } else {
                  curve->setSelected(false);
           }
    }
-  if(isAnalytical) {
+  if(isCurveSelected) {
+    for( CurveDict::Iterator it = aCurves.begin(); it != aCurves.end(); ++it )
+      aViewFrame->updateCurve( it.value() );
+
        myDeselectAnalytical = false;
        emit clearSelected();
        aViewFrame->updateAnalyticalCurves();
@@ -426,7 +415,6 @@ void SPlot2d_Viewer::onClicked( const QVariant& itemInfo, int index )
   }
 
   Plot2d_Object* anObject = aViewFrame->getPlotObject(plotItem);
-  
   if(anObject) {
     
     // Highlight object in Object Browser