X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPlot2d%2FPlot2d_ViewFrame.h;h=dadf7cb6c634420db76f75d8c121b7043675b5aa;hb=5204b0c67ebf51714353b53f585ff7aafe70af30;hp=0455f1c850c45d7b550bad82d61687f2425bed6b;hpb=5ab4e9f868874916c91b51f12aa8beacf09f4125;p=modules%2Fgui.git diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 0455f1c85..dadf7cb6c 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 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 @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +25,9 @@ #include "Plot2d.h" #include "Plot2d_Curve.h" +#ifndef NO_ANALYTICAL_CURVES #include "Plot2d_AnalyticalCurve.h" +#endif #include "Plot2d_NormalizeAlgorithm.h" #include @@ -37,6 +39,8 @@ #include #include #include +#include +#include #include #include @@ -56,11 +60,14 @@ class Plot2d_QwtPlotPicker; typedef QMultiHash CurveDict; typedef QMultiHash ObjectDict; -class PLOT2D_EXPORT Plot2d_ViewFrame : public QWidget, public Plot2d_CurveContainer -{ +class PLOT2D_EXPORT Plot2d_ViewFrame : public QWidget +#ifndef NO_ANALYTICAL_CURVES + , public Plot2d_CurveContainer +#endif +{ Q_OBJECT - - enum { NoOpId, FitAreaId, ZoomId, PanId, GlPanId, DumpId, + + enum { NoOpId, FitAreaId, ZoomId, PanId, GlPanId, DumpId, ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId, LegendId, CurvePointsId, CurveLinesId, CurveSplinesId }; public: @@ -68,6 +75,9 @@ public: Plot2d_ViewFrame( QWidget*, const QString& = "" ); virtual ~Plot2d_ViewFrame(); + void Init(); + void SetPreference(); + enum ObjectType { MainTitle, XTitle, YTitle, Y2Title, XAxis, YAxis, Y2Axis }; QWidget* getViewWidget(); @@ -84,19 +94,19 @@ public: virtual bool eventFilter( QObject*, QEvent* ); /* operations */ - void updateTitles(); + void updateTitles( const bool = true ); void setTitle( const QString& ); QString getTitle() const; QVector< QVector > displayPlot2dCurveList( const QList< QList >& sysCoCurveList, bool displayLegend, const QList< QList >& sides); - + QVector< QVector > displayPlot2dCurveList( const QList& curveList, int groupsize, bool displayLegend, const QList< bool >& sides); - + Plot2d_Curve* createPlot2dCurve( QString & title, QString & unit, QList & xList, @@ -147,25 +157,28 @@ public: void fitData( const int, const double, const double, const double, const double, const double = 0, const double = 0 ); - + void getFitRanges( double&, double&, double&, double&, double&, double&); - + void getFitRangeByCurves( double&, double&, double&, double&, double&, double& ); void getFitRangeByMarkers(double&, double&, double&, double&, double&, double& ); +#ifndef NO_ANALYTICAL_CURVES void addAnalyticalCurve( Plot2d_AnalyticalCurve* ); void removeAnalyticalCurve( Plot2d_AnalyticalCurve* ); void updateAnalyticalCurve( Plot2d_AnalyticalCurve*, bool = false ); void updateAnalyticalCurves(); - void deselectAnalyticalCurves(); - void deselectObjects(); + void deselectAnalyticalCurves(); AnalyticalCurveList getAnalyticalCurves() const; Plot2d_AnalyticalCurve* getAnalyticalCurve(QwtPlotItem *); +#endif + + void deselectObjects(); /* view parameters */ void copyPreferences( Plot2d_ViewFrame* ); @@ -176,14 +189,20 @@ public: void showLegend( bool, bool = true ); void setLegendPos( int ); int getLegendPos() const; + void setLegendSymbolType( int ); + int getLegendSymbolType() const; void setLegendFont( const QFont& ); QFont getLegendFont() const; void setLegendFontColor( const QColor& ); QColor getLegendFontColor() const; + void setSelectedLegendFontColor( const QColor& ); + QColor getSelectedLegendFontColor() const; void setMarkerSize( const int, bool = true ); int getMarkerSize() const; - void setBackgroundColor( const QColor& ); + virtual void setBackgroundColor( const QColor& ); QColor backgroundColor() const; + virtual void setSelectionColor( const QColor& ); + QColor selectionColor() const; void setXGrid( bool, const int, bool, const int, bool = true ); void setYGrid( bool, const int, bool, const int, bool, const int, bool, const int, bool = true ); @@ -214,7 +233,7 @@ public: bool isLegendShow() const; - // Protection against QwtCurve::drawLines() bug in Qwt 0.4.x: + // Protection against QwtCurve::drawLines() bug in Qwt 0.4.x: // it crashes if switched to X/Y logarithmic mode, when one or more points have // non-positive X/Y coordinate bool isXLogEnabled() const; @@ -222,8 +241,7 @@ public: void setEnableAxis( QwtPlot::Axis, bool ); virtual bool print( const QString&, const QString& ) const; - void printPlot( QPainter*, const QRect&, - const QwtPlotPrintFilter& = QwtPlotPrintFilter() ) const; + void printPlot( QPainter*, const QRectF& ) const; QString getVisualParameters(); void setVisualParameters( const QString& ); @@ -233,7 +251,7 @@ public: QwtPlotCanvas* getPlotCanvas() const; Plot2d_Curve* getClosestCurve( QPoint, double&, int& ) const; - + Plot2d_Object* getPlotObject( QwtPlotItem* ) const; QwtPlotItem* getPlotObject( Plot2d_Object* ) const; QwtPlotCurve* getPlotCurve( Plot2d_Curve* ) const; @@ -242,8 +260,8 @@ public: void updatePlotItem(Plot2d_Object*, QwtPlotItem*); protected: int testOperation( const QMouseEvent& ); - void readPreferences(); - void writePreferences(); + virtual void readPreferences(); + virtual void writePreferences(); QString getInfo( const QPoint& ); virtual void wheelEvent( QWheelEvent* ); bool hasPlotCurve( Plot2d_Curve* ) const; @@ -252,18 +270,16 @@ protected: QString getXmlVisualParameters(); bool setXmlVisualParameters(const QString&); - - - - public slots: - void onViewPan(); + void onViewPan(); void onViewZoom(); void onViewFitAll(); void onViewFitArea(); - void onViewGlobalPan(); + void onViewGlobalPan(); void onSettings(); +#ifndef NO_ANALYTICAL_CURVES void onAnalyticalCurve(); +#endif void onFitData(); void onChangeBackground(); void onPanLeft(); @@ -286,7 +302,7 @@ signals: void vpNormRModeChanged(); void vpCurveChanged(); void contextMenuRequested( QContextMenuEvent* ); - void legendClicked( QwtPlotItem* ); + void clicked (const QVariant&, int ); protected: Plot2d_Plot2d* myPlot; @@ -296,10 +312,13 @@ protected: int myCurveType; bool myShowLegend; int myLegendPos; + int myLegendSymbolType; QFont myLegendFont; QColor myLegendColor; + QColor mySelectedLegendFontColor; int myMarkerSize; QColor myBackground; + QColor mySelectionColor; QString myTitle, myXTitle, myYTitle, myY2Title; bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled, myY2TitleEnabled; bool myXGridMajorEnabled, myYGridMajorEnabled, myY2GridMajorEnabled; @@ -311,14 +330,16 @@ protected: double myXDistance, myYDistance, myYDistance2; bool mySecondY; ObjectDict myObjects; +#ifndef NO_ANALYTICAL_CURVES AnalyticalCurveList myAnalyticalCurves; +#endif Plot2d_NormalizeAlgorithm* myLNormAlgo; Plot2d_NormalizeAlgorithm* myRNormAlgo; bool myIsDefTitle; private: // List of QwtPlotCurve curves to draw (created by Plot2d_Curve::createPlotItem() ) QList myQwtPlotCurveList; - + // List of intermittent segments to connect curves QList myIntermittentSegmentList; @@ -326,38 +347,39 @@ protected: QList myPlot2dCurveList; }; -class Plot2d_Plot2d : public QwtPlot +class Plot2d_Plot2d : public QwtPlot { Q_OBJECT public: Plot2d_Plot2d( QWidget* ); virtual ~Plot2d_Plot2d(); - void setLogScale( int, bool ); + void setLogScale( int, bool ); - void replot(); - QwtLegend* getLegend(); - QSize sizeHint() const; - QSize minimumSizeHint() const; - void defaultPicker(); - void setPickerMousePattern( int, int = Qt::NoButton ); - void setPicker( Plot2d_QwtPlotPicker *picker); + void replot(); + QwtAbstractLegend* getLegend(); + QSize sizeHint() const; + QSize minimumSizeHint() const; + void defaultPicker(); + void setPickerMousePattern( int, int = Qt::NoButton ); + void setPicker( Plot2d_QwtPlotPicker *picker); Plot2d_QwtPlotPicker* getPicker() { return myPicker; } Plot2d_AxisScaleDraw* getScaleDraw() { return myScaleDraw; } QList getSeparationLineList() { return mySeparationLineList; } void clearSeparationLineList(); - QwtPlotMarker *createMarkerAndTooltip( QwtSymbol symbol, - double X, - double Y, - QString & tooltip, - Plot2d_QwtPlotPicker *picker); + void setLegendSymbolType( const int ); + int getLegendSymbolType(); + QwtPlotMarker *createMarkerAndTooltip( QwtSymbol* symbol, + double X, + double Y, + QString & tooltip, + Plot2d_QwtPlotPicker *picker); - bool polished() const; QwtPlotGrid* grid() const; QwtPlotZoomer* zoomer() const; virtual void updateYAxisIdentifiers(); - + // Methods to deal with axes ticks void createAxisScaleDraw(); @@ -369,18 +391,10 @@ public: const QList< QPair< QString, QMap > > & devicesPosLabelTicks); void createSeparationLine( double Xpos); - - -public slots: - virtual void polish(); - -protected slots: - void onScaleDivChanged(); protected: QwtPlotGrid* myGrid; QList myColors; - bool myIsPolished; QwtPlotZoomer* myPlotZoomer; Plot2d_AxisScaleDraw* myScaleDraw; // The point picker associated with the graphic view @@ -388,13 +402,13 @@ protected: private: // List of verticals segments between two curves QList mySeparationLineList; + int myLegendSymbolType; }; class Plot2d_ScaleDraw: public QwtScaleDraw { public: Plot2d_ScaleDraw( char f = 'g', int prec = 6 ); - Plot2d_ScaleDraw( const QwtScaleDraw& scaleDraw, char f = 'g', int prec = 6 ); virtual QwtText label( double value ) const; @@ -433,17 +447,19 @@ public: virtual QwtText label(double value) const; void setLabelTick(double value, QString label, bool isDevice = false); - + void setTicks(const QList aTicks); void setInterval(double lowerBound, double upperBound); void applyTicks(); + double extent( const QFont &font ) const; + protected: void drawLabel( QPainter* painter, double value) const; - + void drawTick( QPainter* painter, double value, int len) const; private: @@ -454,10 +470,10 @@ private: QMap myLabelX; // position, label // QList myTicks; // positions - + // Systems names to display under X axis QMap myLabelDevice; - + Plot2d_Plot2d* myPlot; // Drawing zone QwtPlot double myLowerBound; @@ -473,26 +489,25 @@ class Plot2d_QwtPlotPicker : public QwtPlotPicker { public: static const double BOUND_HV_SIZE; - + Plot2d_QwtPlotPicker( int xAxis, int yAxis, - int selectionFlags, RubberBand rubberBand, DisplayMode trackerMode, QwtPlotCanvas *canvas); - + Plot2d_QwtPlotPicker( int xAxis, int yAxis, QwtPlotCanvas *canvas); - + virtual ~Plot2d_QwtPlotPicker(); - + QList pMarkers; // points markers QMap pMarkersToolTip; // associations (marker,tooltip) protected: - virtual QwtText trackerText( const QwtDoublePoint & pos ) const; + virtual QwtText trackerText( const QPoint & pos ) const; };