提交 9bc5e589 编写于 作者: G--H's avatar G--H

调整文档

上级 5a24752b
......@@ -15,8 +15,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
model-qt/QQuickPaintedItem/ChartView/EVChartView.cpp \
model-qt/QQuickPaintedItem/Dashboard/Dashboard.cpp
model-qt/QQuickPaintedItem/ChartView/ZSChartView.cpp \
model-qt/QQuickPaintedItem/Dashboard/ZSDashboard.cpp
RESOURCES += qml.qrc
......@@ -33,9 +33,9 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
model-qt/QQuickPaintedItem/ChartView/EVChartView.h \
model-qt/QQuickPaintedItem/ChartView/PropertyHelper.h \
model-qt/QQuickPaintedItem/Dashboard/Dashboard.h
model-qt/QQuickPaintedItem/ChartView/ZSChartView.h \
model-qt/QQuickPaintedItem/ChartView/ZSPropertyHelper.h \
model-qt/QQuickPaintedItem/Dashboard/ZSDashboard.h
......
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "model-qt/QQuickPaintedItem/ChartView/EVChartView.h"
#include "model-qt/QQuickPaintedItem/Dashboard/Dashboard.h"
#include "model-qt/QQuickPaintedItem/ChartView/ZSChartView.h"
#include "model-qt/QQuickPaintedItem/Dashboard/ZSDashboard.h"
//注册到qml中使用
void initRegester()
{
qmlRegisterType<Dashboard>("Zs.model", 1, 0, "Dashboard");
qmlRegisterType<EVChartView>("Zs.model", 1, 0, "EVChartView");
qmlRegisterType<ZSDashboard>("Zs.model", 1, 0, "ZSDashboard");
qmlRegisterType<ZSChartView>("Zs.model", 1, 0, "ZSChartView");
}
int main(int argc, char *argv[])
......
#include "EVChartView.h"
#include "ZSChartView.h"
#include <QFontMetrics>
#include <QTime>
EVChartView::EVChartView(QQuickItem *parent):
ZSChartView::ZSChartView(QQuickItem *parent):
QQuickPaintedItem(parent),_painter(nullptr)
{
setRenderTarget(QQuickPaintedItem::FramebufferObject);
......@@ -11,11 +11,11 @@ EVChartView::EVChartView(QQuickItem *parent):
setFlag(ItemAcceptsInputMethod, true);
}
EVChartView::~EVChartView()
ZSChartView::~ZSChartView()
{
}
void EVChartView::setLine(QStringList list)
void ZSChartView::setLine(QStringList list)
{
//选择时间后 读取数据库后传入
if(list.size()<0) return;
......@@ -59,14 +59,14 @@ void EVChartView::setLine(QStringList list)
update();
}
void EVChartView::clearLine()
void ZSChartView::clearLine()
{
_vLine.clear();
_vSeeAreaLine.clear();
update();
}
void EVChartView::startTest()
void ZSChartView::startTest()
{
m_xMin = 0;
m_xMax = 1000;
......@@ -84,7 +84,7 @@ void EVChartView::startTest()
setLine(list);
}
void EVChartView::paint(QPainter *painter)
void ZSChartView::paint(QPainter *painter)
{
_painter = painter;
setFont();
......@@ -104,27 +104,27 @@ void EVChartView::paint(QPainter *painter)
_painter->setClipRect(_chartFrame);
}
void EVChartView::hoverEnterEvent(QHoverEvent *)
void ZSChartView::hoverEnterEvent(QHoverEvent *)
{
}
void EVChartView::hoverLeaveEvent(QHoverEvent *)
void ZSChartView::hoverLeaveEvent(QHoverEvent *)
{
}
void EVChartView::hoverMoveEvent(QHoverEvent *)
void ZSChartView::hoverMoveEvent(QHoverEvent *)
{
}
void EVChartView::wheelEvent(QWheelEvent *)
void ZSChartView::wheelEvent(QWheelEvent *)
{
}
void EVChartView::drawHeader()
void ZSChartView::drawHeader()
{
if(m_headerHeight>0 &&!m_headerTxt.isEmpty()){
int widthOfTitle =_painter->fontMetrics().horizontalAdvance(m_headerTxt);//.width(m_headerTxt);//字符串显示的像素大小
......@@ -137,7 +137,7 @@ void EVChartView::drawHeader()
}
}
void EVChartView::drawFrame()
void ZSChartView::drawFrame()
{
QVector<QLine> vLine;
//top
......@@ -153,7 +153,7 @@ void EVChartView::drawFrame()
_painter->drawLines(vLine);
}
void EVChartView::drawHorizontalLine()
void ZSChartView::drawHorizontalLine()
{
_yTickCountTmp = m_vTickCount;
QStringList list = stepZoom(_yMinTmp,_yMaxTmp);
......@@ -169,7 +169,7 @@ void EVChartView::drawHorizontalLine()
_painter->drawLines(vLine);
}
void EVChartView::drawLeftTickLabel()
void ZSChartView::drawLeftTickLabel()
{
_yTickCountTmp =m_vTickCount;
QStringList list = stepZoom(_yMinTmp,_yMaxTmp);
......@@ -191,7 +191,7 @@ void EVChartView::drawLeftTickLabel()
}
}
void EVChartView::drawBottomTitle()
void ZSChartView::drawBottomTitle()
{
//算出xlabel的位置
_yTickCountTmp =m_hTickCount;
......@@ -213,7 +213,7 @@ void EVChartView::drawBottomTitle()
}
}
void EVChartView::drawLeftLabel()
void ZSChartView::drawLeftLabel()
{
_painter->translate(m_leftDisplayWidth/2-4,_height/2);
_painter->rotate(270);// 旋转
......@@ -229,7 +229,7 @@ void EVChartView::drawLeftLabel()
setFont();
}
void EVChartView::drawVlines()
void ZSChartView::drawVlines()
{
if(_vLine.size()>0){
_painter->setPen("blue");
......@@ -245,12 +245,12 @@ void EVChartView::drawVlines()
}
}
QStringList EVChartView::getCurrentFrame(const QString &strframeValue)
QStringList ZSChartView::getCurrentFrame(const QString &strframeValue)
{
return strframeValue.split("&");
}
void EVChartView::pointScale(const QPoint &point)
void ZSChartView::pointScale(const QPoint &point)
{
double xMinTmp =_xMinTmp,xMaxTmp =_xMaxTmp,yMaxTmp =_yMaxTmp,yMinTmp =_yMinTmp;
double xWidth =(_width-m_leftDisplayWidth-m_rightDisplayWidth);
......@@ -269,11 +269,11 @@ void EVChartView::pointScale(const QPoint &point)
double xRightWidth = xCurrentScaleWidth*((double)1-xRate);
double yTopHeight = yCurrentScaleHeight*yRate;
double yBottomHeight = yCurrentScaleHeight*((double)1-yRate);
//宽坐标 0-24000
//宽坐标
double xPointLen =_xMaxTmp-_xMinTmp; double yPointLen =_yMaxTmp-_yMinTmp;
_xMinTmp = (_xMinTmp+ (xLeftWidth-x)*(xPointLen/xCurrentScaleWidth));
_xMaxTmp = _xMaxTmp-(xRightWidth-(xWidth-x))*(xPointLen/xCurrentScaleWidth);
//高坐标 -8-8
//高坐标
// _yMaxTmp = m_yMax- (yTopHeight-y)*(yPointLen/yCurrentScaleHeight);
// _yMinTmp = m_yMin+(yBottomHeight-(yHeight-y))*(yPointLen/yCurrentScaleHeight);
_yMaxTmp =_yMaxTmp -(yTopHeight-y)*(yPointLen/yCurrentScaleHeight);
......@@ -292,7 +292,7 @@ void EVChartView::pointScale(const QPoint &point)
}
void EVChartView::pointNarrow(const QPoint &point)
void ZSChartView::pointNarrow(const QPoint &point)
{
//缩小后刻度
qDebug()<<"缩小前 xMin:"<<_xMinTmp<<" 缩小前 xMax:"<<_xMaxTmp;
......@@ -328,7 +328,7 @@ void EVChartView::pointNarrow(const QPoint &point)
_isScale=true;
}
void EVChartView::getSeeAreaLine()
void ZSChartView::getSeeAreaLine()
{
//获取可视区域
_vSeeAreaLine.clear();
......@@ -373,21 +373,21 @@ void EVChartView::getSeeAreaLine()
}
}
double EVChartView::initDouble(double &bRate)
double ZSChartView::initDouble(double &bRate)
{
QString num=QString::number(bRate,'f',8);
//取到不为0的开始 补齐为5 假如为0.0004 则补齐为 0.0005 每次加
return 0.0;
}
double EVChartView::getYScaleValue()
double ZSChartView::getYScaleValue()
{
_yScaleCount++;
if(_yScaleCount<=0) return 1;
return _yScale;
}
double EVChartView::getXScaleValue()
double ZSChartView::getXScaleValue()
{
_xScaleCount++;
if(_xScaleCount<=0) return 1;
......@@ -395,7 +395,7 @@ double EVChartView::getXScaleValue()
return _xScale;
}
void EVChartView::setFont()
void ZSChartView::setFont()
{
QFont font;
font.setPointSize(10);
......@@ -405,7 +405,7 @@ void EVChartView::setFont()
_painter->setRenderHint(QPainter::Antialiasing);
}
QString EVChartView::removeZero(double data)
QString ZSChartView::removeZero(double data)
{
QString label;
QRegExp reg;
......@@ -415,7 +415,7 @@ QString EVChartView::removeZero(double data)
return "";
}
bool EVChartView::isXaxisInt()
bool ZSChartView::isXaxisInt()
{
double xLen = ((double)_xMaxTmp- (double)_xMinTmp)/m_hTickCount;
if(isInt(xLen)){
......@@ -436,7 +436,7 @@ bool EVChartView::isXaxisInt()
return true;
}
bool EVChartView::isInt(const double &dData)
bool ZSChartView::isInt(const double &dData)
{
int nData = (int)dData;
if(nData==dData){
......@@ -446,7 +446,7 @@ bool EVChartView::isInt(const double &dData)
}
}
QStringList EVChartView::stepZoom(double &min, double &max)
QStringList ZSChartView::stepZoom(double &min, double &max)
{
//最小步径
QStringList list;
......
#ifndef EVChartView_H
#define EVChartView_H
#ifndef ZSChartView_H
#define ZSChartView_H
#include <QObject>
#include <QQuickPaintedItem>
#include "PropertyHelper.h"
#include "ZSPropertyHelper.h"
#include <QPainter>
#include <QList>
#include <QMutex>
class EVChartView : public QQuickPaintedItem
class ZSChartView : public QQuickPaintedItem
{
Q_OBJECT
public:
EVChartView(QQuickItem *parent = 0);
~EVChartView();
ZSChartView(QQuickItem *parent = 0);
~ZSChartView();
AUTO_PROPERTY(int,vTickCount,5)
AUTO_PROPERTY(int,hTickCount,5)
......@@ -33,9 +32,7 @@ public:
Q_INVOKABLE void setLine(QStringList list);
Q_INVOKABLE void clearLine();
Q_INVOKABLE void startTest(); //测试数据 支持百万级瞬绘
protected:
void paint(QPainter *painter) override;
protected:
......@@ -71,8 +68,6 @@ private:
double getYScaleValue(); //获取y放大倍数
double getXScaleValue(); //获取x放大倍数
void setFont();
//一格小于100操作
private:
QString removeZero(double data);
bool isXaxisInt();
......@@ -105,7 +100,6 @@ private:
bool _isScale = false;
int _yTickCountTmp =0;
int _xTickCountTmp =0;
};
#endif // EVChartView_H
#endif // ZSChartView_H
#include "Dashboard.h"
#include "ZSDashboard.h"
#include <qmath.h>
......@@ -12,24 +12,24 @@ const int shortstep = maxv/longstep; //短刻度步长
const double startDraw = -135.0; //绘制起始角度
const double stopDraw = 270.0; //绘制结束角度
Dashboard::Dashboard(QQuickItem *parent):
ZSDashboard::ZSDashboard(QQuickItem *parent):
QQuickPaintedItem(parent)
{
Values = 0;
}
Dashboard::~Dashboard()
ZSDashboard::~ZSDashboard()
{
}
void Dashboard::setValues(unsigned int &iValues)
void ZSDashboard::setValues(unsigned int &iValues)
{
Values = iValues;
update();
}
void Dashboard::paint(QPainter *painter)
void ZSDashboard::paint(QPainter *painter)
{
painter->setRenderHint(QPainter::Antialiasing);
QPoint center(width()/2,height()/2);
......
#ifndef DASHBOARD_H
#define DASHBOARD_H
#ifndef ZSDashboard_H
#define ZSDashboard_H
#include <QQuickPaintedItem>
#include <QQuickItem>
#include <QPainter>
class Dashboard : public QQuickPaintedItem
class ZSDashboard : public QQuickPaintedItem
{
Q_OBJECT
public:
Dashboard(QQuickItem *parent = nullptr);
~Dashboard();
ZSDashboard(QQuickItem *parent = nullptr);
~ZSDashboard();
public:
void setValues(unsigned int& iValues);
Q_INVOKABLE void setValues(unsigned int& iValues);
protected:
void paint(QPainter *painter);
......@@ -21,4 +21,4 @@ private:
qreal Values;
};
#endif // DASHBOARD_H
#endif // ZSDashboard_H
<RCC>
<qresource prefix="/">
<file>qml/main.qml</file>
<file>qml/ModelComponent.qml</file>
<file>qml/model-qml/graphical/GraphicalControl.qml</file>
<file>qml/ZSModelComponent.qml</file>
<file>qml/model-qml/graphical/ZSGraphicalControl.qml</file>
</qresource>
</RCC>
......@@ -16,7 +16,7 @@ Rectangle {
if(index == 0)
{
modelLoader.source ="qrc:/qml/model-qml/graphical/GraphicalControl.qml"
modelLoader.source ="qrc:/qml/model-qml/graphical/ZSGraphicalControl.qml"
}
else if(index == 1)
{
......@@ -28,6 +28,6 @@ Rectangle {
id:modelLoader
width: parent.width
height:parent.height
source:"qrc:/qml/model-qml/graphical/GraphicalControl.qml"
source:"qrc:/qml/model-qml/graphical/ZSGraphicalControl.qml"
}
}
......@@ -38,7 +38,7 @@ Window {
}
}
ModelComponent{
ZSModelComponent{
id:modelComponent
width: parent.width-listView.width
height: parent.height
......
......@@ -58,11 +58,11 @@ Rectangle{
width: parent.width
height: parent.height-100
currentIndex:listView.currentIndex
Dashboard{
ZSDashboard{
width:parent.width
height: parent.height
}
EVChartView{
ZSChartView{
id:sddddd
width:parent.width
height: parent.height-200
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册