From 77e1b353e142e3646176c9927dab1d2e44467b89 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 19 Jun 2007 05:46:00 +0000 Subject: [PATCH] Porting to qwt-5.0.1 and qt-4.2.3 products. --- src/Plot2d/Plot2d_Curve.cxx | 11 ----------- src/Plot2d/Plot2d_Prs.cxx | 10 +++++----- src/Plot2d/Plot2d_Prs.h | 1 + src/Plot2d/Plot2d_ToolTip.cxx | 14 ++++---------- src/Plot2d/Plot2d_ViewFrame.h | 23 +++++++++-------------- 5 files changed, 19 insertions(+), 40 deletions(-) diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index 41668a1f6..95bee5dc3 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -185,17 +185,6 @@ void Plot2d_Curve::deletePoint(int thePos) { if ( thePos >= 0 && thePos < myPoints.count() ) myPoints.removeAt( thePos ); - /* - QList::iterator aIt; - int aCurrent = 0; - for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { - if (thePos == aCurrent) { - myPoints.remove(aIt); - return; - } - aCurrent++; - } - */ } /*! diff --git a/src/Plot2d/Plot2d_Prs.cxx b/src/Plot2d/Plot2d_Prs.cxx index fe91c3da2..8c9d24109 100755 --- a/src/Plot2d/Plot2d_Prs.cxx +++ b/src/Plot2d/Plot2d_Prs.cxx @@ -33,18 +33,16 @@ Default constructor */ Plot2d_Prs::Plot2d_Prs( bool theDelete ) -: mySecondY( false) +: mySecondY( false), myIsAutoDel( theDelete ) { - setAutoDel(theDelete); } /*! Standard constructor */ Plot2d_Prs::Plot2d_Prs( const Plot2d_Curve* obj, bool theDelete ) -: mySecondY( false) +: mySecondY( false), myIsAutoDel( theDelete ) { - setAutoDel(theDelete); AddObject( obj ); } @@ -53,6 +51,8 @@ Plot2d_Prs::Plot2d_Prs( const Plot2d_Curve* obj, bool theDelete ) */ Plot2d_Prs::~Plot2d_Prs() { + if ( myIsAutoDel ) + qDeleteAll( myCurves ); } /*! @@ -95,5 +95,5 @@ bool Plot2d_Prs::isSecondY() const */ void Plot2d_Prs::setAutoDel(bool theDel) { - //myCurves.setAutoDelete(theDel); + myIsAutoDel = theDel; } diff --git a/src/Plot2d/Plot2d_Prs.h b/src/Plot2d/Plot2d_Prs.h index 2f98aadeb..a4fba43b0 100755 --- a/src/Plot2d/Plot2d_Prs.h +++ b/src/Plot2d/Plot2d_Prs.h @@ -41,6 +41,7 @@ public: protected: curveList myCurves; bool mySecondY; + bool myIsAutoDel; }; #endif diff --git a/src/Plot2d/Plot2d_ToolTip.cxx b/src/Plot2d/Plot2d_ToolTip.cxx index 12e85eeea..2afbd2370 100644 --- a/src/Plot2d/Plot2d_ToolTip.cxx +++ b/src/Plot2d/Plot2d_ToolTip.cxx @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -47,15 +48,8 @@ Plot2d_ToolTip::~Plot2d_ToolTip() void Plot2d_ToolTip::onToolTip( QPoint p, QString& str, QFont& f, QRect& txtRect, QRect& rect ) { - int pInd;//, dist; + int pInd; double dist; - //double x, y; - //curInd = myPlot->closestCurve( p.x(), p.y(), dist, x, y, pInd ); - - //if( dist>maxDist ) - // return; - - //Plot2d_Curve* c = myFrame->getCurves().find( curInd ); Plot2d_Curve* c = myPlot->getClosestCurve( p, dist, pInd ); if( dist>maxDist || !c ) @@ -89,8 +83,8 @@ bool Plot2d_ToolTip::eventFilter( QObject* o, QEvent* e ) bool res = QtxToolTip::eventFilter( o, e ); if( e && e->type() == QEvent::MouseMove ) { - ///QMouseEvent* me = ( QMouseEvent* )e; - ///if( me->state()==0 ) + QMouseEvent* me = ( QMouseEvent* )e; + if( me->modifiers()==0 ) return true; } return res; diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index f98cce1c8..ba9f2e5f8 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -30,6 +30,7 @@ class Plot2d_Prs; class QCustomEvent; class QwtPlotCurve; class QwtPlotGrid; +class QwtPlotZoomer; typedef QMultiHash CurveDict; @@ -59,6 +60,8 @@ public: void Erase( const Plot2d_Prs*, const bool = false ); Plot2d_Prs* CreatePrs( const char* entry = 0 ); + virtual bool eventFilter(QObject* watched, QEvent* e); + /* operations */ void updateTitles(); void setTitle( const QString& title ); @@ -68,8 +71,7 @@ public: void eraseCurve( Plot2d_Curve* curve, bool update = false ); void eraseCurves( const curveList& curves, bool update = false ); int getCurves( curveList& clist ); - const CurveDict& getCurves();/// { return myPlot->getCurves(); } - //int hasCurve( Plot2d_Curve* curve ); + const CurveDict& getCurves(); bool isVisible( Plot2d_Curve* curve ); void updateCurve( Plot2d_Curve* curve, bool update = false ); void updateLegend( const Plot2d_Prs* prs ); @@ -137,6 +139,7 @@ protected: virtual void wheelEvent( QWheelEvent* ); QwtPlotCurve* getPlotCurve( Plot2d_Curve* curve ); bool hasPlotCurve( Plot2d_Curve* curve ); + void setCurveType( QwtPlotCurve* curve, int curveType ); public slots: void onViewPan(); @@ -157,10 +160,8 @@ public slots: protected: virtual void customEvent( QEvent* ); - -protected slots: void plotMousePressed( const QMouseEvent& ); - void plotMouseMoved( const QMouseEvent& ); + bool plotMouseMoved( const QMouseEvent& ); void plotMouseReleased( const QMouseEvent& ); signals: @@ -173,7 +174,6 @@ protected: Plot2d_Plot2d* myPlot; int myOperation; QPoint myPnt; - //CurveDict myCurves; int myCurveType; bool myShowLegend; @@ -211,31 +211,26 @@ public: virtual QSize sizeHint() const; virtual QSizePolicy sizePolicy() const; virtual QSize minimumSizeHint() const; + void defaultPicker(); + void setPickerMousePattern( int button, int state = Qt::NoButton ); bool polished() const { return myIsPolished; } QwtPlotGrid* grid() { return myGrid; }; CurveDict& getCurves() { return myCurves; } Plot2d_Curve* getClosestCurve( QPoint p, double& distance, int& index ); -signals: - void plotMouseMoved( const QMouseEvent& ); - void plotMousePressed( const QMouseEvent& ); - void plotMouseReleased( const QMouseEvent& ); - public slots: virtual void polish(); protected: bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine ); - virtual void mousePressEvent( QMouseEvent* event ); - virtual void mouseMoveEvent( QMouseEvent* event ); - virtual void mouseReleaseEvent( QMouseEvent* event ); protected: CurveDict myCurves; QwtPlotGrid* myGrid; QList myColors; bool myIsPolished; + QwtPlotZoomer* myPlotZoomer; }; #endif -- 2.39.2