/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
// vim: expandtab
#include <qscrollbar.h>
#include "qwt_text.h"
#include "qwt_text_label.h"
#include "qwt_plot_canvas.h"
#include "qwt_scale_widget.h"
#include "qwt_legend.h"
#include "qwt_plot_layout.h"
class QwtPlotLayout::LayoutData
{
public:
void init(const QwtPlot *, const QRect &rect);
struct t_legendData
{
int frameWidth;
int vScrollBarWidth;
int hScrollBarHeight;
QSize hint;
} legend;
struct t_titleData
{
QwtText text;
int frameWidth;
} title;
struct t_scaleData
{
bool isEnabled;
const QwtScaleWidget *scaleWidget;
QFont scaleFont;
int start;
int end;
int baseLineOffset;
int tickOffset;
int dimWithoutTitle;
} scale[QwtPlot::axisCnt];
struct t_canvasData
{
int frameWidth;
} canvas;
};
/*
Extract all layout relevant data from the plot components
*/
void QwtPlotLayout::LayoutData::init(const QwtPlot *plot, const QRect &rect)
{
// legend
if ( plot->plotLayout()->legendPosition() != QwtPlot::ExternalLegend
&& plot->legend() )
{
legend.frameWidth = plot->legend()->frameWidth();
legend.vScrollBarWidth =
plot->legend()->verticalScrollBar()->sizeHint().width();
legend.hScrollBarHeight =
plot->legend()->horizontalScrollBar()->sizeHint().height();
const QSize hint = plot->legend()->sizeHint();
int w = qwtMin(hint.width(), rect.width());
int h = plot->legend()->heightForWidth(w);
if ( h == 0 )
h = hint.height();
if ( h > rect.height() )
w += legend.vScrollBarWidth;
legend.hint = QSize(w, h);
}
// title
title.frameWidth = 0;
title.text = QwtText();
if (plot->titleLabel() )
{
const QwtTextLabel *label = plot->titleLabel();
title.text = label->text();
if ( !(title.text.testPaintAttribute(QwtText::PaintUsingTextFont)) )
title.text.setFont(label->font());
title.frameWidth = plot->titleLabel()->frameWidth();
}
// scales
for (int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
if ( plot->axisEnabled(axis) )
{
const QwtScaleWidget *scaleWidget = plot->axisWidget(axis);
scale[axis].isEnabled = true;
scale[axis].scaleWidget = scaleWidget;
scale[axis].scaleFont = scaleWidget->font();
scale[axis].start = scaleWidget->startBorderDist();
scale[axis].end = scaleWidget->endBorderDist();
scale[axis].baseLineOffset = scaleWidget->margin();
scale[axis].tickOffset = scaleWidget->margin();
if ( scaleWidget->scaleDraw()->hasComponent(
QwtAbstractScaleDraw::Ticks) )
{
scale[axis].tickOffset +=
(int)scaleWidget->scaleDraw()->majTickLength();
}
scale[axis].dimWithoutTitle = scaleWidget->dimForLength(
QWIDGETSIZE_MAX, scale[axis].scaleFont);
if ( !scaleWidget->title().isEmpty() )
{
scale[axis].dimWithoutTitle -=
scaleWidget->titleHeightForWidth(QWIDGETSIZE_MAX);
}
}
else
{
scale[axis].isEnabled = false;
scale[axis].start = 0;
scale[axis].end = 0;
scale[axis].baseLineOffset = 0;
scale[axis].tickOffset = 0;
scale[axis].dimWithoutTitle = 0;
}
}
// canvas
canvas.frameWidth = plot->canvas()->frameWidth();
}
class QwtPlotLayout::PrivateData
{
public:
PrivateData():
margin(0),
spacing(5),
alignCanvasToScales(false)
{
}
QRect titleRect;
QRect legendRect;
QRect scaleRect[QwtPlot::axisCnt];
QRect canvasRect;
QwtPlotLayout::LayoutData layoutData;
QwtPlot::LegendPosition legendPos;
double legendRatio;
unsigned int margin;
unsigned int spacing;
unsigned int canvasMargin[QwtPlot::axisCnt];
bool alignCanvasToScales;
};
/*!
\brief Constructor
*/
QwtPlotLayout::QwtPlotLayout()
{
d_data = new PrivateData;
setLegendPosition(QwtPlot::BottomLegend);
setCanvasMargin(4);
invalidate();
}
//! Destructor
QwtPlotLayout::~QwtPlotLayout()
{
delete d_data;
}
/*!
Change the margin of the plot. The margin is the space
around all components.
\param margin new margin
\sa margin(), setSpacing(),
QwtPlot::setMargin()
*/
void QwtPlotLayout::setMargin(int margin)
{
if ( margin < 0 )
margin = 0;
d_data->margin = margin;
}
/*!
\return margin
\sa setMargin(), spacing(), QwtPlot::margin()
*/
int QwtPlotLayout::margin() const
{
return d_data->margin;
}
/*!
Change a margin of the canvas. The margin is the space
above/below the scale ticks. A negative margin will
be set to -1, excluding the borders of the scales.
\param margin New margin
\param axis One of QwtPlot::Axis. Specifies where the position of the margin.
-1 means margin at all borders.
\sa canvasMargin()
\warning The margin will have no effect when alignCanvasToScales is true
*/
void QwtPlotLayout::setCanvasMargin(int margin, int axis)
{
if ( margin < -1 )
margin = -1;
if ( axis == -1 )
{
for (axis = 0; axis < QwtPlot::axisCnt; axis++)
d_data->canvasMargin[axis] = margin;
}
else if ( axis >= 0 || axis < QwtPlot::axisCnt )
d_data->canvasMargin[axis] = margin;
}
/*!
\return Margin around the scale tick borders
\sa setCanvasMargin()
*/
int QwtPlotLayout::canvasMargin(int axis) const
{
if ( axis < 0 || axis >= QwtPlot::axisCnt )
return 0;
return d_data->canvasMargin[axis];
}
/*!
Change the align-canvas-to-axis-scales setting. The canvas may:
- extend beyond the axis scale ends to maximize its size,
- align with the axis scale ends to control its size.
\param alignCanvasToScales New align-canvas-to-axis-scales setting
\sa setCanvasMargin()
\note In this context the term 'scale' means the backbone of a scale.
\warning In case of alignCanvasToScales == true canvasMargin will have
no effect
*/
void QwtPlotLayout::setAlignCanvasToScales(bool alignCanvasToScales)
{
d_data->alignCanvasToScales = alignCanvasToScales;
}
/*!
Return the align-canvas-to-axis-scales setting. The canvas may:
- extend beyond the axis scale ends to maximize its size
- align with the axis scale ends to control its size.
\return align-canvas-to-axis-scales setting
\sa setAlignCanvasToScales, setCanvasMargin()
\note In this context the term 'scale' means the backbone of a scale.
*/
bool QwtPlotLayout::alignCanvasToScales() const
{
return d_data->alignCanvasToScales;
}
/*!
Change the spacing of the plot. The spacing is the distance
between the plot components.
\param spacing new spacing
\sa setMargin(), spacing()
*/
void QwtPlotLayout::setSpacing(int spacing)
{
d_data->spacing = qwtMax(0, spacing);
}
/*!
\return spacing
\sa margin(), setSpacing()
*/
int QwtPlotLayout::spacing() const
{
return d_data->spacing;
}
/*!
\brief Specify the position of the legend
\param pos The legend's position.
\param ratio Ratio between legend and the bounding rect
of title, canvas and axes. The legend will be shrinked
if it would need more space than the given ratio.
The ratio is limited to ]0.0 ..
没有合适的资源?快使用搜索试试~ 我知道了~
qwt 5.1.1 qt 曲线显示
共1190个文件
html:339个
png:188个
md5:155个
4星 · 超过85%的资源 需积分: 10 89 下载量 190 浏览量
2009-12-02
14:49:32
上传
评论 1
收藏 2.37MB RAR 举报
温馨提示
qt的开源类,用于显示各种二维曲线,各个接口封装的很好,使用简单。很好很强大。
资源推荐
资源详情
资源评论
收起资源包目录
qwt 5.1.1 qt 曲线显示 (1190个子文件)
QwtPlot.3 42KB
QwtPicker.3 32KB
QwtPlotCurve.3 29KB
qwtlicense.3 27KB
QwtDial.3 23KB
QwtPlotItem.3 18KB
QwtScaleDraw.3 18KB
QwtText.3 17KB
QwtAbstractSlider.3 16KB
QwtPlotZoomer.3 16KB
QwtScaleWidget.3 16KB
QwtPlotSpectrogram.3 15KB
QwtThermo.3 15KB
QwtSlider.3 14KB
QwtAbstractScaleDraw.3 13KB
QwtPlotLayout.3 13KB
QwtPlotPicker.3 13KB
QwtDoubleRange.3 12KB
QwtLegendItem.3 12KB
QwtDoubleInterval.3 11KB
QwtCounter.3 11KB
QwtPlotScaleItem.3 11KB
QwtPainter.3 11KB
QwtMagnifier.3 11KB
QwtEventPattern.3 10KB
QwtScaleEngine.3 10KB
QwtDynGridLayout.3 9KB
QwtPanner.3 9KB
QwtWheel.3 9KB
QwtAbstractScale.3 9KB
QwtPlotGrid.3 9KB
QwtPlotMarker.3 8KB
QwtLegend.3 8KB
QwtRoundScaleDraw.3 8KB
QwtKnob.3 7KB
QwtPlotRasterItem.3 7KB
QwtPlotCanvas.3 7KB
QwtSymbol.3 7KB
QwtLinearColorMap.3 7KB
QwtScaleMap.3 7KB
QwtTextLabel.3 6KB
QwtScaleDiv.3 6KB
QwtAnalogClock.3 6KB
QwtCompass.3 6KB
QwtPlotPrintFilter.3 6KB
QwtCompassMagnetNeedle.3 5KB
QwtColorMap.3 5KB
QwtPlotSvgItem.3 5KB
QwtTextEngine.3 5KB
QwtSpline.3 5KB
qwtinstall.3 5KB
QwtRasterData.3 5KB
QwtArrowButton.3 4KB
QwtSimpleCompassRose.3 4KB
QwtMathMLTextEngine.3 4KB
QwtLog10ScaleEngine.3 4KB
QwtCompassWindArrow.3 4KB
QwtPlotPanner.3 4KB
QwtDialSimpleNeedle.3 4KB
QwtPlotMagnifier.3 4KB
QwtPlainTextEngine.3 4KB
QwtLinearScaleEngine.3 4KB
QwtArrayData.3 4KB
QwtCPointerData.3 4KB
QwtData.3 4KB
QwtRichTextEngine.3 4KB
QwtDialNeedle.3 3KB
QwtPlotDict.3 3KB
QwtAlphaColorMap.3 3KB
QwtMetricsMap.3 3KB
QwtPickerMachine.3 3KB
QwtScaleArithmetic.3 3KB
QwtScaleTransformation.3 3KB
QwtPolygonFData.3 3KB
QwtDialScaleDraw.3 2KB
QwtPickerClickRectMachine.3 1KB
QwtPickerPolygonMachine.3 1KB
QwtPickerDragRectMachine.3 1KB
qwt_double_rect.h.3 1KB
QwtCompassRose.3 1KB
QwtPickerDragPointMachine.3 1KB
QwtPickerClickPointMachine.3 1KB
QwtSplineCurveFitter.3 1KB
QwtRect.3 1KB
QwtCurveFitter.3 998B
QwtIntervalData.3 918B
qwt_plot_dict.h.3 845B
QwtClipper.3 744B
QwtLegendItemManager.3 676B
QwtEventPattern_MousePattern.3 630B
QwtEventPattern_KeyPattern.3 606B
deprecated.3 498B
todo.3 220B
controlscreenshots.3 202B
spectrogramscreenshots.3 185B
curvescreenshots.3 160B
histogramscreenshots.3 150B
scatterscreenshots.3 149B
CHANGES 14KB
COPYING 27KB
共 1190 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
lg8307
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页