#include <qstring.h>
#include <qpainter.h>
#include <qwt_plot.h>
-#include <qwt_interval_data.h>
#include <qwt_painter.h>
#include <qwt_scale_map.h>
#include <qwt_legend.h>
#include <qwt_legend_item.h>
#include <qwt_symbol.h>
#include <qwt_plot_dict.h>
+#include <QPixmap>
/**
/**
* Sets data to object
*/
-void Plot2d_HistogramQwtItem::setData( const QwtIntervalData& theData )
+void Plot2d_HistogramQwtItem::setData( const QwtIntervalSeriesData& theData )
{
- m_pData->data = theData;
+ m_pData->data = theData.samples();
itemChanged();
}
/**
* Returns data from object
*/
-const QwtIntervalData &Plot2d_HistogramQwtItem::data() const
+const QwtIntervalSeriesData &Plot2d_HistogramQwtItem::data() const
{
- return m_pData->data;
+ return QwtIntervalSeriesData( m_pData->data );
}
/**
*/
QwtDoubleRect Plot2d_HistogramQwtItem::boundingRect() const
{
- QwtDoubleRect aRect = m_pData->data.boundingRect();
+ QwtIntervalSeriesData iData( m_pData->data );
+ //QwtDoubleRect aRect = m_pData->data.boundingRect();
+ QwtDoubleRect aRect = iData.boundingRect();
if ( !aRect.isValid() )
return aRect;
void Plot2d_HistogramQwtItem::draw( QPainter *thePainter,
const QwtScaleMap& theXMap,
const QwtScaleMap& theYMap,
- const QRect& ) const
+ const QRectF& ) const
{
- const QwtIntervalData &iData = m_pData->data;
thePainter->setPen( QPen( m_pData->color ) );
- const int x0 = theXMap.transform( baseline() );
- const int y0 = theYMap.transform( baseline() );
-
+ const double x0 = theXMap.transform( baseline() );
+ const double y0 = theYMap.transform( baseline() );
+ const QVector<QwtIntervalSample>& iData = m_pData->data;
for ( int i = 0; i < (int)iData.size(); i++ ) {
+
if ( m_pData->attributes & Plot2d_HistogramQwtItem::Xfy ) {
- const int x2 = theXMap.transform( iData.value( i ) );
+ const double x2 = theXMap.transform( iData.at(i).value );
if ( x2 == x0 )
continue;
- int y1 = theYMap.transform( iData.interval( i ).minValue() );
- int y2 = theYMap.transform( iData.interval( i ).maxValue() );
+ double y1 = theYMap.transform( iData.at(i).interval.minValue() );
+ double y2 = theYMap.transform( iData.at(i).interval.maxValue() );
if ( y1 > y2 )
qSwap( y1, y2 );
if ( i < (int)iData.size() - 2 ) {
- const int yy1 = theYMap.transform( iData.interval(i+1).minValue() );
- const int yy2 = theYMap.transform( iData.interval(i+1).maxValue() );
+ const double yy1 = theYMap.transform( iData.at( i+1 ).interval.minValue() );
+ const double yy2 = theYMap.transform( iData.at( i+1 ). interval.maxValue() );
if ( y2 == qwtMin( yy1, yy2 ) ) {
- const int xx2 = theXMap.transform( iData.interval(i+1).minValue() );
+ const double xx2 = theXMap.transform( iData.at( i+1 ).interval.minValue() );
if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) ||
( xx2 > x0 && x2 > x0 ) ) ) {
// One pixel distance between neighboured bars
drawBar( thePainter, Qt::Horizontal, QRect( x0, y1, x2 - x0, y2 - y1 ) );
}
else {
- const int y2 = theYMap.transform( iData.value( i ) );
+ const double y2 = theYMap.transform( iData.at(i).value );
if ( y2 == y0 )
continue;
- int x1 = theXMap.transform( iData.interval( i ).minValue() );
- int x2 = theXMap.transform( iData.interval( i ).maxValue() );
+ double x1 = theXMap.transform( iData.at( i ).interval.minValue() );
+ double x2 = theXMap.transform( iData.at( i ).interval.maxValue() );
if ( x1 > x2 )
qSwap( x1, x2 );
if ( i < (int)iData.size() - 2 ) {
- const int xx1 = theXMap.transform( iData.interval(i+1).minValue() );
- const int xx2 = theXMap.transform( iData.interval(i+1).maxValue() );
+ const double xx1 = theXMap.transform( iData.at( i+1 ).interval.minValue() );
+ const double xx2 = theXMap.transform( iData.at( i+1 ).interval.maxValue() );
if ( x2 == qwtMin( xx1, xx2 ) ) {
- const int yy2 = theYMap.transform( iData.value(i+1) );
+ const double yy2 = theYMap.transform( iData.at( i+1 ).value );
if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) ||
( yy2 > y0 && y2 > y0 ) ) ) {
// One pixel distance between neighboured bars
int aSize = aFMetrics.height();
QwtSymbol aSymbol( QwtSymbol::Rect, QBrush( color() ),
QPen( color() ), QSize( aSize, aSize ) );
- anItem->setSymbol( aSymbol );
- anItem->setIdentifierMode( theLegend->identifierMode()
- | QwtLegendItem::ShowSymbol );
+ //anItem->setSymbol( aSymbol );
+ //anItem->setIdentifierMode( theLegend->identifierMode()
+ // | QwtLegendItem::ShowSymbol );
+ QPixmap aPixMap( 8, 8);
+ aPixMap.fill( color() );
+ anItem->setIdentifier( aPixMap );
anItem->update();
}
Plot2d_HistogramItem* anItem = (Plot2d_HistogramItem*)this;
anItem->m_BarItems.clear();
- const QwtIntervalData &iData = m_pData->data;
thePainter->setPen( QPen( m_pData->color ) );
- const int x0 = theXMap.transform( baseline() );
- const int y0 = theYMap.transform( baseline() );
-
+ const double x0 = theXMap.transform( baseline() );
+ const double y0 = theYMap.transform( baseline() );
+ const QVector<QwtIntervalSample>& iData = m_pData->data;
for ( int i = 0; i < (int)iData.size(); i++ ) {
if ( m_pData->attributes & Plot2d_HistogramItem::Xfy ) {
- const int x2 = theXMap.transform( iData.value( i ) );
+ const double x2 = theXMap.transform( iData.at(i).value );
if ( x2 == x0 )
continue;
- int y1 = theYMap.transform( iData.interval( i ).minValue() );
- int y2 = theYMap.transform( iData.interval( i ).maxValue() );
+ double y1 = theYMap.transform( iData.at(i).interval.minValue() );
+ double y2 = theYMap.transform( iData.at(i).interval.maxValue() );
if ( y1 > y2 )
qSwap( y1, y2 );
if ( i < (int)iData.size() - 2 ) {
- const int yy1 = theYMap.transform( iData.interval(i+1).minValue() );
- const int yy2 = theYMap.transform( iData.interval(i+1).maxValue() );
+ const double yy1 = theYMap.transform( iData.at( i+1 ).interval.minValue() );
+ const double yy2 = theYMap.transform( iData.at( i+1 ).interval.maxValue() );
if ( y2 == qwtMin( yy1, yy2 ) ) {
- const int xx2 = theXMap.transform( iData.interval(i+1).minValue() );
+ const double xx2 = theXMap.transform( iData.at( i+1 ).interval.minValue() );
if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) ||
( xx2 > x0 && x2 > x0 ) ) ) {
// One pixel distance between neighboured bars
anItem->m_BarItems.append( aRect );
}
else {
- const int y2 = theYMap.transform( iData.value( i ) );
+ const double y2 = theYMap.transform( iData.at( i ).value );
if ( y2 == y0 )
continue;
- int x1 = theXMap.transform( iData.interval( i ).minValue() );
- int x2 = theXMap.transform( iData.interval( i ).maxValue() );
+ double x1 = theXMap.transform( iData.at( i ).interval.minValue() );
+ double x2 = theXMap.transform( iData.at( i ).interval.maxValue() );
if ( x1 > x2 )
qSwap( x1, x2 );
if ( i < (int)iData.size() - 2 ) {
- const int xx1 = theXMap.transform( iData.interval(i+1).minValue() );
- const int xx2 = theXMap.transform( iData.interval(i+1).maxValue() );
+ const double xx1 = theXMap.transform( iData.at( i+1 ).interval.minValue() );
+ const double xx2 = theXMap.transform( iData.at( i+1 ).interval.maxValue() );
if ( x2 == qwtMin( xx1, xx2 ) ) {
- const int yy2 = theYMap.transform( iData.value(i+1) );
+ const double yy2 = theYMap.transform(iData.at( i+1 ).value );
if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) ||
( yy2 > y0 && y2 > y0 ) ) ) {
// One pixel distance between neighboured bars
#include <qwt_scale_engine.h>
#include <qwt_plot_zoomer.h>
#include <qwt_curve_fitter.h>
+#include <qwt_compat.h>
+#include <qwt_plot_renderer.h>
#include <iostream>
#include <stdlib.h>
const int zoomBtn = Qt::ControlModifier | Qt::LeftButton;
const int panBtn = Qt::ControlModifier | Qt::MidButton;
const int fitBtn = Qt::ControlModifier | Qt::RightButton;
-
- switch (btn)
- {
- case zoomBtn:
+
+ if( btn == zoomBtn)
{
QPixmap zoomPixmap (imageZoomCursor);
QCursor zoomCursor (zoomPixmap);
myPlot->canvas()->setCursor( zoomCursor );
return ZoomId;
}
- case panBtn:
+ else if( btn == panBtn )
+ {
myPlot->canvas()->setCursor( QCursor( Qt::SizeAllCursor ) );
return PanId;
- case fitBtn:
+ }
+ else if(btn == fitBtn)
+ {
myPlot->canvas()->setCursor( QCursor( Qt::PointingHandCursor ) );
return FitAreaId;
- default :
+ }
+ else
return NoOpId;
- }
+
}
/*!
QwtPlotCurve* crv = it.key();
if ( crv )
{
- QwtSymbol aSymbol = crv->symbol();
- aSymbol.setSize( myMarkerSize, myMarkerSize );
- crv->setSymbol( aSymbol );
+ const QwtSymbol* aSymbol = crv->symbol();
+ QwtSymbol* aSymbolNew = new QwtSymbol( aSymbol->style(), aSymbol->brush(), aSymbol->pen(), aSymbol->size() );
+ aSymbolNew->setSize( myMarkerSize, myMarkerSize );
+ crv->setSymbol( aSymbolNew );
}
}
if ( update )
myIsPolished( false )
{
myPlotZoomer = new Plot2d_QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas() );
- myPlotZoomer->setSelectionFlags( QwtPicker::DragSelection | QwtPicker::CornerToCorner );
+ //myPlotZoomer->setSelectionFlags( QwtPicker::DragSelection | QwtPicker::CornerToCorner );
myPlotZoomer->setTrackerMode( QwtPicker::AlwaysOff );
myPlotZoomer->setRubberBand( QwtPicker::RectRubberBand );
myPlotZoomer->setRubberBandPen( QColor( Qt::green ) );
if( pd )
{
- myPlot->print( *pd );
+ QwtPlotRenderer aRend;
+ aRend.renderTo( myPlot, *pd );
res = true;
delete pd;
}
/**
* Print Plot2d window
*/
-void Plot2d_ViewFrame::printPlot( QPainter* p, const QRect& rect,
- const QwtPlotPrintFilter& filter ) const
+void Plot2d_ViewFrame::printPlot( QPainter* p, const QRectF& rect) const
{
- myPlot->print( p, rect, filter );
+ QwtPlotRenderer aRend;
+ aRend.render( myPlot, p, rect );
}
/*!