+/*!
+ create SPlot2d_ViewWindow
+*/
+SUIT_ViewWindow* SPlot2d_Viewer::createView( SUIT_Desktop* theDesktop )
+{
+ SPlot2d_ViewWindow* aPlot2dView = new SPlot2d_ViewWindow(theDesktop, this);
+ aPlot2dView->initLayout();
+ if (getPrs())
+ aPlot2dView->getViewFrame()->Display(getPrs());
+ return aPlot2dView;
+}
+
+/*!
+ SLOT: called when action "Legend Clicked" is activated.
+ override "onLegendClicked" method from Plot2d_ViewModel.
+*/
+void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+{
+ Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
+ if(aViewFrame == NULL) return;
+
+ bool isAnalytical = false;
+ AnalyticalCurveList curves = aViewFrame->getAnalyticalCurves();
+ foreach ( Plot2d_AnalyticalCurve* curve, curves ) {
+ if(plotItem == curve->plotItem()) {
+ isAnalytical = true;
+ curve->setSelected(true);
+ } else {
+ curve->setSelected(false);
+ }
+ }
+ if(isAnalytical) {
+ myDeselectAnalytical = false;
+ emit clearSelected();
+ aViewFrame->updateAnalyticalCurves();
+ myDeselectAnalytical = true;
+ return;
+ }
+
+ Plot2d_Object* anObject = aViewFrame->getPlotObject(plotItem);
+
+ if(anObject) {
+
+ // Highlight object in Object Browser
+ QString anEntry;
+ if(SPlot2d_Curve* aSCurve = dynamic_cast<SPlot2d_Curve*>(anObject)) {
+ if(aSCurve->hasIO())
+ anEntry = aSCurve->getIO()->getEntry();
+ } else if( SPlot2d_Histogram* aSHisto = dynamic_cast<SPlot2d_Histogram*>(anObject)) {
+ if(aSHisto->hasIO())
+ anEntry = aSHisto->getIO()->getEntry();
+ }
+
+ if(!anEntry.isEmpty())
+ emit legendSelected( anEntry );
+ }
+}
+
+/*!
+
+*/
+void SPlot2d_Viewer::setObjectsSelected( SALOME_ListIO& theList ) {
+ Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
+ if(aViewFrame) {
+
+ objectList allObjects;
+ aViewFrame->getObjects( allObjects );
+
+ bool isSelected = false;
+ SPlot2d_Histogram* h = 0;
+ SPlot2d_Curve* c =0;
+
+ foreach ( Plot2d_Object* o, allObjects ) {
+ isSelected = false;
+
+ Handle(SALOME_InteractiveObject) io;
+ if( (h = dynamic_cast<SPlot2d_Histogram*>(o)) && h->hasIO() ) {
+ io = h->getIO();
+ } else if((c = dynamic_cast<SPlot2d_Curve*>(o)) && c->hasIO()) {
+ io = c->getIO();
+ } else {
+ continue;
+ }
+
+ SALOME_ListIteratorOfListIO anIter( theList );
+
+ for( ; anIter.More(); anIter.Next() ) {
+ if ( anIter.Value()->hasEntry() ) {
+ if( io->isSame(anIter.Value()) ) {
+ isSelected = o->isSelected();
+ if( !isSelected ) {
+ o->setSelected(true);
+ aViewFrame->updateObject(o);
+ theList.Remove(anIter);
+ isSelected = true;
+ break;
+ } else
+ break;
+ }
+ }
+ }
+ if( !isSelected && o->isSelected() != false ) {
+ o->setSelected(false);
+ aViewFrame->updateObject(o);
+ }
+ }
+ if( myDeselectAnalytical ) {
+ aViewFrame->deselectAnalyticalCurves();
+ aViewFrame->updateAnalyticalCurves();
+ }
+ aViewFrame->Repaint();
+ }
+}