-// 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
// 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
#include "Plot2d.h"
#include "Plot2d_Curve.h"
+#ifndef NO_ANALYTICAL_CURVES
#include "Plot2d_AnalyticalCurve.h"
+#endif
#include "Plot2d_NormalizeAlgorithm.h"
#include <QWidget>
#include <qwt_scale_draw.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_picker.h>
+#include <qwt_plot_canvas.h>
+#include <qwt_legend.h>
#include <iostream>
#include <ostream>
typedef QMultiHash<QwtPlotCurve*, Plot2d_Curve*> CurveDict;
typedef QMultiHash<QwtPlotItem*, Plot2d_Object*> 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:
Plot2d_ViewFrame( QWidget*, const QString& = "" );
virtual ~Plot2d_ViewFrame();
+ void Init();
+ void SetPreference();
+
enum ObjectType { MainTitle, XTitle, YTitle, Y2Title, XAxis, YAxis, Y2Axis };
QWidget* getViewWidget();
virtual bool eventFilter( QObject*, QEvent* );
/* operations */
- void updateTitles();
+ void updateTitles( const bool = true );
void setTitle( const QString& );
QString getTitle() const;
QVector< QVector<QwtPlotCurve *> > displayPlot2dCurveList( const QList< QList<Plot2d_Curve*> >& sysCoCurveList,
bool displayLegend,
const QList< QList<bool> >& sides);
-
+
QVector< QVector<QwtPlotCurve *> > displayPlot2dCurveList( const QList<Plot2d_Curve*>& curveList,
int groupsize,
bool displayLegend,
const QList< bool >& sides);
-
+
Plot2d_Curve* createPlot2dCurve( QString & title,
QString & unit,
QList<double> & xList,
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* );
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 );
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;
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& );
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;
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;
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();
void vpNormRModeChanged();
void vpCurveChanged();
void contextMenuRequested( QContextMenuEvent* );
- void legendClicked( QwtPlotItem* );
+ void clicked (const QVariant&, int );
protected:
Plot2d_Plot2d* myPlot;
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;
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<QwtPlotItem*> myQwtPlotCurveList;
-
+
// List of intermittent segments to connect curves
QList<QwtPlotCurve*> myIntermittentSegmentList;
- // List of markers associated with curves points
- QList<QwtPlotMarker*> myMarkerList;
-
// List of curves Plot2d_Curve
QList<Plot2d_Curve*> 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<QwtPlotMarker*> 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();
const QList< QPair< QString, QMap<double,QString> > > & devicesPosLabelTicks);
void createSeparationLine( double Xpos);
-
-
-public slots:
- virtual void polish();
-
-protected slots:
- void onScaleDivChanged();
protected:
QwtPlotGrid* myGrid;
QList<QColor> myColors;
- bool myIsPolished;
QwtPlotZoomer* myPlotZoomer;
Plot2d_AxisScaleDraw* myScaleDraw;
// The point picker associated with the graphic view
private:
// List of verticals segments between two curves
QList<QwtPlotMarker*> 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;
virtual QwtText label(double value) const;
void setLabelTick(double value, QString label, bool isDevice = false);
-
+
void setTicks(const QList<double> 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:
QMap<double, QString> myLabelX; // position, label
//
QList<double> myTicks; // positions
-
+
// Systems names to display under X axis
QMap<double, QString> myLabelDevice;
-
+
Plot2d_Plot2d* myPlot; // Drawing zone QwtPlot
double myLowerBound;
{
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<QwtPlotMarker*> pMarkers; // points markers
QMap<QwtPlotMarker*, QwtText> pMarkersToolTip; // associations (marker,tooltip)
protected:
- virtual QwtText trackerText( const QwtDoublePoint & pos ) const;
+ virtual QwtText trackerText( const QPoint & pos ) const;
};