资源简介

从数据采集板上接收数据帧,进行判断,然后接收,并且显示在表格上,以及显示在坐标轴上。同时支持通过串口下传数据。备注:由于是按照具体的数据帧设计的,不同数据帧测试时候会不准确,得作出相应的修改。

资源截图

代码片段和文件信息

//*************************** coordinate.cpp *********************
#include “mainwindow.h“
#include “ui_mainwindow.h“
#include 
#include 
#include 


// radarWidget中画图
bool MainWindow::eventFilter(Qobject *obj QEvent *e)
{
    if(obj == ui->radarWidget)
    {
        if(e->type() == QEvent::Paint)
        {
            draw();
            qDebug()<<“Workinggggggggggggggggggggggggggg................................“;
            return true;
        }
        else
        {
            qDebug()<<“Waiting“;
        }
    }
    return QMainWindow::eventFilter(obj e);
}

void MainWindow::draw()
{
    extern float floatData[20][2];      // 声明下在mainwindow.cpp里面定义的全局变量
    extern int dcFlag;                   // dcFlag = 1 时候相当不断刷新, 等于0时候相当于关闭,进行清屏操作,留背景
    extern int ti;
    QPainter painter(ui->radarWidget);
    QPixmap pix;
    pix.load(“:/coordinate05-18.png“);
    painter.drawPixmap(0 0 400 440 pix);

    painter.setBrush(Qt::red);              //先设定好画笔颜色
    painter.translate(194 432);        // 变换坐标原点

    float radian = 0.140;               //设定弧度,让其按照指定的角度偏移


//    dcFlag = 1;


    qDebug()<    if(dcFlag == 1)
    {
        int x = 0;
        // 2012-05-18,考虑角度偏移的坐标确定,改小号图像
        for(int j = 0; j < ti; j++)         // ti为全局变量  不能实时传送,只能当ti等于最后的数的时候才传过来??
        {
            x = int(floatData[j][0] / 10);
            switch(x)
            {
            case 0:
                if(floatData[j][1] == 0)
                {
                    painter.drawEllipse(0 -(floatData[j][0] * 4.5) 10 10);               // 0m - 10m内0度偏角
                }

                else if(floatData[j][1] == 4)
                {
                    painter.drawEllipse((floatData[j][0] * 4.5) * qSin(radian)
                                        -((floatData[j][0] * 4.5) * qCos(radian)) 10 10);    // 4度偏角
                }

                qDebug()<<(floatData[j][0] * 4.5)<<(floatData[j][0] * 4.5) * qSin(radian)
                       <<((floatData[j][0] * 4.5) * qCos(radian));
                break;
            case 1:
                if(floatData[j][1] == 0)
                    painter.drawEllipse(0 -(45 + (floatData[j][0] - 10) * 4.4) 10 10);   // 10m - 20m内
                else if(floatData[j][1] == 4)
                    painter.drawEllipse((45 + (floatData[j][0] - 10) * 4.4) * qSin(radian)
                                        -((45 + (floatData[j][0] - 10) * 4.4) * qCos(radian)) 10 10);   // 10m - 20m内
                break;
            case 2:
                if(floatData[j][1] == 0)
                    painter.drawEllipse(0 -(89 + (floatData[j][0] - 20) * 4.2) 10 10);  // 20m - 30m内
                else if(floatData[j][1] == 4)
                    painter.drawEllipse((89 + (floatData[j][0] - 20) * 4.2) * qSin(radian)
                                        -(89 + (floatData[j][0] - 20) * 4.2) * qCo

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       8604  2012-06-26 13:27  Qt_Interface_poll_Windows_V7\coordinate.cpp

     文件      67083  2012-05-19 22:56  Qt_Interface_poll_Windows_V7\coordinate05-18.png

     文件        819  2012-06-26 13:19  Qt_Interface_poll_Windows_V7\main.cpp

     文件       8821  2012-06-26 13:27  Qt_Interface_poll_Windows_V7\mainwindow.cpp

     文件       1304  2012-06-26 12:20  Qt_Interface_poll_Windows_V7\mainwindow.h

     文件       9085  2012-06-26 12:11  Qt_Interface_poll_Windows_V7\mainwindow.ui

     文件      38286  2012-05-11 22:39  Qt_Interface_poll_Windows_V7\posix_qextserialport.cpp

     文件       1934  2012-05-11 22:39  Qt_Interface_poll_Windows_V7\posix_qextserialport.h

     文件       6528  2012-05-11 22:39  Qt_Interface_poll_Windows_V7\qextserialbase.cpp

     文件       6974  2012-05-11 22:39  Qt_Interface_poll_Windows_V7\qextserialbase.h

     文件       3260  2012-05-11 22:39  Qt_Interface_poll_Windows_V7\qextserialport.cpp

     文件        867  2012-05-11 22:39  Qt_Interface_poll_Windows_V7\qextserialport.h

     文件         98  2012-06-26 11:50  Qt_Interface_poll_Windows_V7\Qt_Interface_poll.qrc

     文件        478  2012-06-26 12:10  Qt_Interface_poll_Windows_V7\Qt_Interface_poll_Windows_V7.pro

     文件      14603  2012-06-26 13:27  Qt_Interface_poll_Windows_V7\Qt_Interface_poll_Windows_V7.pro.user

     文件      34893  2012-05-11 22:39  Qt_Interface_poll_Windows_V7\win_qextserialport.cpp

     文件       4476  2012-05-11 22:39  Qt_Interface_poll_Windows_V7\win_qextserialport.h

     目录          0  2012-06-26 12:15  Qt_Interface_poll_Windows_V7

----------- ---------  ---------- -----  ----

               208113                    18


评论

共有 条评论