#include "SahuWaveScene.h"
#include <QGraphicsItem>
#include <stdlib.h>
#include <qstring.h>
#include <string.h>
#include <QTextCodec>
#include <QMutexLocker>
SahuWaveScene::SahuWaveScene(QObject *parent) :
QGraphicsScene(parent) {
this->setBackgroundBrush(Qt::black);
//setDefaultScaleLinePen();
//setDefaultWaveDataPen();
//setDefaultScope();
}
SahuWaveScene::SahuWaveScene(qreal width, qreal height, QObject * parent) :
QGraphicsScene(0, 0, width, height, parent) {
this->setBackgroundBrush(Qt::black);
//setDefaultScaleLinePen();
//setDefaultWaveDataPen();
//setDefaultScope();
}
/** 设置默认的刻度线画笔 *//*
void SahuWaveScene::setDefaultScaleLinePen() {
m_scaleLinePen.setColor(Qt::green);
m_scaleLinePen.setStyle(Qt::DashLine);
m_scaleLinePen.setWidthF(1);
}*/
/** 设置默认波形画笔 *//*
void SahuWaveScene::setDefaultWaveDataPen() {
m_waveDataPen.setColor(Qt::red);
m_waveDataPen.setStyle(Qt::SolidLine);
m_waveDataPen.setWidthF(1);
}*/
/** 设置默认显示范围和比例 *//*
void SahuWaveScene::setDefaultScope() {
QRectF rectf = this->sceneRect();
setScope(rectf.width(), rectf.height());
}*/
/** 设置刻度线画笔 *//*
void SahuWaveScene::setScaleLinePen(QPen pen) {
m_scaleLinePen = pen;
}*/
/** 设置波形画笔 *//*
void SahuWaveScene::setWaveDataPen(QPen pen) {
m_waveDataPen = pen;
}*/
/** 设置显示范围 *//*
void SahuWaveScene::setScope(qreal scopeX, qreal scopeY) {
QRectF rectf = this->sceneRect();
m_scopeX = scopeX;
m_scopeY = scopeY;
m_scaleX = rectf.width() / m_scopeX;
m_scaleY = rectf.height() / m_scopeY;
}*/
/** 画刻度线,默认为横向两格,纵向两格*//*
void SahuWaveScene::createScale() {
createScale(2, 2);
}*/
/** 画刻度线,并指定横向和纵向的栅格数 *//*
void SahuWaveScene::createScale(int num_x, int num_y) {
m_numScaleX = num_x;
m_numScaleY = num_y;
QRectF rectf = this->sceneRect();
//绘制刻度线的边框
QPointF p1;
QPointF p2;
//绘制横向刻度线
for (int i = 1; i < num_x; i++) {
p1.setX(rectf.x());
p1.setY(rectf.height() / num_x * i);
p2.setX(rectf.width());
p2.setY(rectf.height() / num_x * i);
m_scaleLinesList.push_back((QGraphicsItem*) this->addLine(
QLineF(p1, p2), m_scaleLinePen));
}
//绘制纵向刻度线
for (int i = 1; i < num_y; i++) {
p1.setX(rectf.width() / num_y * i);
p1.setY(rectf.y());
p2.setX(rectf.width() / num_y * i);
p2.setY(rectf.height());
m_scaleLinesList.push_back((QGraphicsItem*) this->addLine(
QLineF(p1, p2), m_scaleLinePen));
}
}
*/
/** 移除全部的刻度线 */
/*
void SahuWaveScene::removeScale() {
if (m_scaleLinesList.isEmpty())
return;
foreach(QGraphicsItem *item, m_scaleLinesList)
{
this->removeItem(item);
}
m_scaleLinesList.clear();
}
*/
评论4
最新资源