From: rnv Date: Thu, 20 Jan 2011 15:25:02 +0000 (+0000) Subject: Implementation of the Point 2 of the 20948: EDF 1468 SMESH: Histogram of the quality... X-Git-Tag: V6_3_0a1~86 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3f00bce0cdd99a54030db9be790d7d96f01a1de7;p=modules%2Fgui.git Implementation of the Point 2 of the 20948: EDF 1468 SMESH: Histogram of the quality controls. --- diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 489fff70b..85d7801b4 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -644,12 +644,13 @@ void Plot2d_ViewFrame::displayObject( Plot2d_Object* object, bool update ) if ( myYMode && object->getMinY() <= 0. ) setVerScaleMode( 0, false ); + if ( object->isAutoAssign() ) + object->autoFill( myPlot ); + if ( hasPlotObject( object ) ) { updateObject( object, update ); } else { - if ( object->isAutoAssign() ) - object->autoFill( myPlot ); QwtPlotItem* anItem = object->createPlotItem(); anItem->attach( myPlot ); myObjects.insert( anItem, object ); @@ -2386,6 +2387,22 @@ void Plot2d_ViewFrame::customEvent( QEvent* ce ) fitAll(); } + +/*! + * Return Plot2d_Object by the QwtPlotItem + * +*/ +Plot2d_Object* Plot2d_ViewFrame::getPlotObject( QwtPlotItem* plotItem ) const { + + ObjectDict::const_iterator it = myObjects.begin(); + for( ; it != myObjects.end(); ++it ) { + if ( it.key() == plotItem ) { + return it.value(); + } + } + return 0; +} + Plot2d_ScaleDraw::Plot2d_ScaleDraw( char f, int prec ) : QwtScaleDraw(), myFormat(f), @@ -2420,3 +2437,5 @@ QwtText Plot2d_ScaleDraw::label( double value ) const return QwtScaleDraw::label( value ); } + + diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index e18069c0f..b99915639 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -156,6 +156,8 @@ public: QwtPlotCanvas* getPlotCanvas() const; Plot2d_Curve* getClosestCurve( QPoint, double&, int& ) const; + + Plot2d_Object* getPlotObject( QwtPlotItem* ) const; protected: int testOperation( const QMouseEvent& ); @@ -169,6 +171,10 @@ protected: QwtPlotItem* getPlotObject( Plot2d_Object* ) const; bool hasPlotObject( Plot2d_Object* ) const; + + + + public slots: void onViewPan(); void onViewZoom(); diff --git a/src/SPlot2d/SPlot2d_ViewModel.cxx b/src/SPlot2d/SPlot2d_ViewModel.cxx index 37ca42aa1..05a83d2b9 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.cxx +++ b/src/SPlot2d/SPlot2d_ViewModel.cxx @@ -29,6 +29,7 @@ #include "SPlot2d_ViewWindow.h" #include "SPlot2d_Prs.h" +#include "SPlot2d_Histogram.h" #include "SUIT_Session.h" #include "SUIT_Application.h" #include "SUIT_ViewManager.h" @@ -391,19 +392,22 @@ void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem ) Plot2d_ViewFrame* aViewFrame = getActiveViewFrame(); if(aViewFrame == NULL) return; - CurveDict aCurves = aViewFrame->getCurves(); - SPlot2d_Curve* aSCurve; - CurveDict::Iterator it = aCurves.begin(); - for( ; it != aCurves.end(); ++it ) - { - if ( it.key() == plotItem ) { - aSCurve = dynamic_cast( it.value() ); - break; + + Plot2d_Object* anObject = aViewFrame->getPlotObject(plotItem); + + if(anObject) { + + // Highlight object in Object Browser + QString anEntry; + if(SPlot2d_Curve* aSCurve = dynamic_cast(anObject)) { + if(aSCurve->hasIO()) + anEntry = aSCurve->getIO()->getEntry(); + } else if( SPlot2d_Histogram* aSHisto = dynamic_cast(anObject)) { + if(aSHisto->hasIO()) + anEntry = aSHisto->getIO()->getEntry(); } - } - // Highlight curve in Object Browser - if(aSCurve && aSCurve->hasIO()) { - QString anEntry = aSCurve->getIO()->getEntry(); - emit legendSelected( anEntry ); + + if(!anEntry.isEmpty()) + emit legendSelected( anEntry ); } }