QWT3D根据高程值加载模型

根据高程值来加载三维模型


#include <QApplication>
#include <qwt3d_surfaceplot.h>

#include <QFile>
#include <QTextStream>
#include <QVector>
#include <QDateTime>
#include <QDir>
using namespace Qwt3D;

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
	//高程值来源  高程值渠道很多种 只要获取即可
	/*************************************************/
	QVector<double>dobvec;   //高程值数据容器

	//txt文件中存放   顺序是从(0,0)开始 纵向读取每一个点的高程值 
	/*
	{	(0,2) (1,2) (2,2)
		(0,1) (1,1) (2,1)
		(0,0) (1,0) (2,0)
	}
	即 (0,0)(0,1)(0,2)(1,0)。。。每个点的高程值
	*/
    QFile dir("C:/Users/216/Desktop/QWT3Dlib和运用/QWT3DTest/heightdata.txt");
    dir.open(QIODevice::ReadOnly|QIODevice::Text);
    dir.seek(0);
    QTextStream s(&dir);
    int cout = 0;

    while(1)                         //获得每一个点的高程值
    {
        if(cout == 30*30)
            break;
        QString str = s.readLine();
        cout++;

        dobvec.push_back(str.toDouble());
    }
    dir.close();
	/*************************************************/

	//建立模型
	/*************************************************/
    SurfacePlot Surfac;

    int x = 30, y = 30 ;  //x轴和y轴长度

    double** data  = new double* [x] ;   //创建矩阵
    for ( int i = 0; i < x; ++i)
        data[i]  = new double [y];

    int i = 0;
    for(int k = 0; k < x; k++)     
    {
        for(int l = 0; l < y; l++)
        {
            data[k][l] = dobvec[i];  //根据坐标x与y来对应每一个点的高程值
            i++;
        }
    }

    Surfac.loadFromData(data, x, y, 0, x, 0, y);   //加载高程值

    for ( int i = 0; i < x; i++)   //删除矩阵
        delete [] data[i];
    delete [] data;
/*************************************************/
   // Qwt3D::RGBA h{0,255,0};
   // Surfac.setTitleColor(h);

/********  基操 **********/
    Surfac.setRotation(30,0,15);
    Surfac.setScale(1,1,1); //x y z 缩放
    Surfac.setShift(0,0,0);
   // Surfac.setZoom(0.9);

    Surfac.updateData();
    Surfac.updateGL();
    Surfac.show();
/******** **********/

    return a.exec();
}

源码下载地址 https://download.csdn.net/download/ztq_12345/11856291
如需要其他需求请到 http://qwtplot3d.sourceforge.net/web/navigation/api_frame.html
官网查找文档

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值