资源简介

添加OBJ文件至Qml,通过qwt创建操控界面,通过Qt创建虚拟摇杆,采用qml与c++交互,实时控制直升机运动。

资源截图

代码片段和文件信息

#include “control.h“
#include “ui_control.h“
#include 
#include 

Control::Control(QWidget *parent) :
    QDialog(parent)
    ui(new Ui::Control)
{
    helicopter=new Helicopter(this);
    ui->setupUi(this);
    QwtLinearColorMap *DirectionThermo_1map = new QwtLinearColorMap();
    DirectionThermo_1map->setColorInterval( Qt::blue Qt::red );
    ui->Thermo_3->setColorMap( DirectionThermo_1map );
    ui->Thermo->setOriginMode( QwtThermo::OriginCustom );
    ui->Thermo->setOrigin( 0.0 );
    ui->Thermo_2->setOriginMode( QwtThermo::OriginCustom );
    ui->Thermo_2->setOrigin( 0.0 );

    connect(ui->verticalSliderSIGNAL(valueChanged(int))thisSLOT(SetThrottle()));
}

Control::~Control()
{
    delete ui;
}

//===================================鼠标移动信息获取,虚拟手柄===================================
void Control::mouseMoveEvent(QMouseEvent *event)
{
    Mouse_Pos = event->pos();
    Dis = sqrt(double(pow(Mouse_Pos.x() -1092) + pow(Mouse_Pos.y() -1092)));
    Button_Pos = ui->label->pos();
    MouseX=Button_Pos.x()-80;
    MouseY=Button_Pos.y()-80;
    if(Dis<=100){
        ui->label->move(Mouse_Pos.x()-29Mouse_Pos.y()-29);       
    }else if(Dis<=150){
        Ratio=100/Dis;
        ui->label->move((Mouse_Pos.x()-109)*Ratio+80(Mouse_Pos.y()-109)*Ratio+80);
    }
    ui->Thermo->setValue(-MouseY);
    ui->Thermo_2->setValue(MouseX);
    emit helicopter->receiveRotation(MouseXMouseY);

}

void Control::mouseReleaseEvent(QMouseEvent *event)
{
    ui->label->move(8080);
    Button_Pos = ui->label->pos();
    MouseX=MouseY=0;
    ui->Thermo->setValue(MouseY);
    ui->Thermo_2->setValue(MouseX);
    emit helicopter->receiveRotation(MouseXMouseY);
}
//==========================================================================================


void Control::SetThrottle()
{
    Throttle=ui->verticalSlider->value();
    ui->Thermo_3->setValue(Throttle);
    emit helicopter->receiveThrottle(Throttle);
}

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

     文件       4513  2017-10-24 14:43  feiji\airscrew.obj

     文件       3389  2017-10-25 08:55  feiji\Airscrew.qml

     文件       1111  2017-10-24 15:53  feiji\airscrewf.obj

     文件        105  2017-10-24 17:07  feiji\airscrewf.obj.mtl

     文件       3072  2017-10-25 09:09  feiji\Airscrewf.qml

     文件       1109  2017-10-24 17:07  feiji\airscrewg.obj

     文件      72715  2017-10-19 14:43  feiji\axis.obj

     文件       2850  2017-10-24 12:02  feiji\BasicCamera.qml

     文件       2046  2017-10-26 12:04  feiji\control.cpp

     文件        727  2017-10-26 11:50  feiji\control.h

     文件       4992  2017-10-26 11:27  feiji\control.ui

     文件        266  2017-10-19 16:07  feiji\deployment.pri

     文件        772  2017-10-25 09:27  feiji\Empennage.qml

     文件       1146  2017-10-26 11:29  feiji\feiji.pro

     文件      23945  2017-10-26 13:51  feiji\feiji.pro.user

     文件        598  2017-10-26 13:24  feiji\helicopter.cpp

     文件        484  2017-10-26 13:09  feiji\helicopter.h

     文件     159800  2017-10-25 09:17  feiji\helicopter.obj

     文件        105  2017-10-25 09:17  feiji\helicopter.obj.mtl

     文件       1350  2017-10-25 09:29  feiji\Helicopter.qml

     文件        700  2017-10-25 19:54  feiji\main.cpp

     文件       6477  2017-10-26 13:20  feiji\main.qml

     文件       3113  2017-10-19 16:25  feiji\Qhow.qml

     文件        861  2017-10-25 09:01  feiji\qml.qrc

     文件       3146  2017-10-24 11:44  feiji\robustwireframe.frag

     文件       4465  2017-10-24 11:44  feiji\robustwireframe.geom

     文件        437  2017-10-24 11:44  feiji\robustwireframe.vert

     文件       4425  2017-10-25 19:36  feiji\Show.qml

     文件    1764501  2016-06-13 01:44  feiji\toyplane.obj

     文件       3071  2017-10-25 08:53  feiji\TrefoilKnot.qml

............此处省略12个文件信息

评论

共有 条评论