代码拉取完成,页面将自动刷新
同步操作将从 rbc/Qt_painter 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "gan.h"
#include <QTimer>
#include <cmath>
using namespace std;
Gan::~Gan()
{
}
Gan::Gan(double a,double b, double c,double d,Ui::painter* ui_ptr)
{
this->ui = ui_ptr;
this->LengthGan1 =a;
this->LengthGan2 =b;
this->LengthGan3 =c;
this->LengthGan4 =d;
this->ui->OutputText->append("检查机构参数合法性及类型");
return;
}
void Gan::Judge()
{
if (this->Min_Max_Bar_sum > this->Other_Bar_sum)
{
this->ui->OutputText->append("四杆机构类型:双摇杆机构");
this->ui->MechanisimType->setText(QString("双摇杆机构"));
return;
}
else
{
if (this->Min_Bar_Num == 3)
{
this->ui->OutputText->append("四杆机构类型:双曲柄机构");
this->ui->MechanisimType->setText(QString("双曲柄机构"));
return;
}
else if (this->Min_Bar_Num == 1 || this->Min_Bar_Num == 2)
{
this->ui->OutputText->append("四杆机构类型:曲柄摇杆机构");
this->ui->MechanisimType->setText(QString("曲柄摇杆机构"));
return;
}
else if (this->Min_Bar_Num == 0)
{
this->ui->OutputText->append("四杆机构类型:双摇杆机构");
this->ui->MechanisimType->setText(QString("双摇杆机构"));
return;
}
}
}
bool Gan::CheckInput()
{
for (int i = 0; i < 4; i++)
{
if (this->Bar[i] <= 0)
{
this->ui->OutputText->append("输入错误:输入的杆存在小于或等于零的杆");
this->isInputLeagal = false;
return false;
}
else
{
this->isInputLeagal = true;
}
}
return true;
}
void Gan::MaxBar(float *Bar)
{
float tmp = Bar[0];
//求出最长的杆的长度以及其所处的位置
for (int i = 1; i <= 3; i++)
{
if (tmp < Bar[i])
{
tmp = Bar[i];
this->Max_Bar_Num = i;
}
}
this->Max_Bar_length = tmp;
}
void Gan::OtherBarSum()
{
this->Min_Max_Bar_sum = this->Max_Bar_length + this->Min_Bar_Length;//其它两杆的长度和
this->Other_Bar_sum = 0;
int flag = 1;
for (int i = 0; i < 4; i++)
{
if (i == this->Max_Bar_Num || i == this->Min_Bar_Num)
{
continue;
}
else
{
this->Other_Bar_num[flag] = i;
this->Other_Bar_sum += this->Bar[i];
}
}
}
void Gan::MinBar(float *Bar)
{
float tmp = Bar[0];
//求出最短的杆的长度以及其所处的位置
for (int i = 1; i <= 3; i++)
{
if (tmp > Bar[i])
{
tmp = Bar[i];
this->Min_Bar_Num = i;
}
}
this->Min_Bar_Length = tmp;
}
void Gan::Check()
{
// cout << "ab为连架杆,bc为连杆,cd也为连架杆,ad为机架。" << endl;
// cout << "请依次输入ab、bc、cd、ad各杆长长度:" << endl;
// cin >> Bar[0] >> Bar[1] >> Bar[2] >> Bar[3];
this->Bar[0] = this->LengthGan1;
this->Bar[1] = this->LengthGan2;
this->Bar[2] = this->LengthGan3;
this->Bar[3] = this->LengthGan4;
if (CheckInput())
{
this->MinBar(Bar);
this->MaxBar(Bar);
this->OtherBarSum();
if(this->Min_Bar_Length+this->Max_Bar_length > this->Other_Bar_sum)
{
this->isInputLeagal = false;
this->ui->OutputText->append("输入参数杆长条件不满足要求!");
}
this->Judge();
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。