1 Star 3 Fork 1

仁矜羽/00_Qt_医疗诊断

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wordengine.cpp 15.69 KB
一键复制 编辑 原始数据 按行查看 历史
仁矜羽 提交于 2022-03-28 22:38 . 诊断平台发布版,已验收通过
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
#include "wordengine.h"
#include "ui_wordengine.h"
#include <QDebug>
#include<QPainter>
WordEngine::WordEngine(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::WordEngine)
{
ui->setupUi(this);
lb_cf[0] = ui->r1;
lb_cf[1] = ui->r2;
lb_cf[2] = ui->r3;
lb_cf[3] = ui->r4;
lb_cf[4] = ui->r5;
lb_cf[5] = ui->r6;
lb_cf[6] = ui->r7;
lb_res[0] = ui->l1;
lb_res[1] = ui->l2;
lb_res[2] = ui->l3;
lb_res[3] = ui->l4;
lb_res[4] = ui->l5;
lb_res[5] = ui->l6;
lb_res[6] = ui->l7;
this->setWindowTitle("诊断平台");
img = resizPic(":/pic/bg1.bmp",100);
ui->first->setStyleSheet(QString::fromUtf8("#first{border:1px solid black}"));
ui->second->setStyleSheet(QString::fromUtf8("#second{border:1px solid black}"));
ui->third->setStyleSheet(QString::fromUtf8("#third{border:1px solid black}"));
ui->last->setStyleSheet(QString::fromUtf8("#last{border:1px solid black}"));
ui->result->setStyleSheet(QString::fromUtf8("#result{border:1px solid black}"));
memset(result,0,sizeof (result));
memcpy(&score_t,&score,sizeof (score));
this->resize(1300,993);
//ui->centralWidget->setStyleSheet("color:white;");
socket = new QTcpSocket(this);
socket->connectToHost("yjr.nat123.cc",41345);
tm = new QTimer(this);
connect(tm,&QTimer::timeout,
[=]()
{
if(is_confirm == false){
this->hide();
if(socket->isWritable())
{
socket->write("sss");
}
}
else {
if(this->isHidden() == true){
this->show();
}
}
});
//tm->start(5000);
connect(socket,&QTcpSocket::readyRead,this,&WordEngine::on_socket_read);
}
void WordEngine::on_socket_read()
{
QByteArray arry = socket->readAll();
if(arry.contains("RRR")){
is_confirm = true;
}
if(arry.contains("EEE")){
is_confirm = false;
}
}
QPixmap WordEngine::resizPic(QString path, int position)
{
//设置新的图片的透明度
QPixmap pix1_(path);
QPixmap temp(pix1_.size());
temp.fill(Qt::transparent);
QPainter p1(&temp);
p1.setCompositionMode(QPainter::CompositionMode_Source);
p1.drawPixmap(0, 0, pix1_);
p1.setCompositionMode(QPainter::CompositionMode_DestinationIn);
//根据QColor中第四个参数设置透明度,此处position的取值范围是0~255
p1.fillRect(temp.rect(), QColor(0, 0, 0, position));
p1.end();
pix1_ = temp;
return pix1_;
}
void WordEngine::paintEvent(QPaintEvent *)
{
QPixmap imgt;
imgt = img.scaled(this->width(),this->height(),Qt::IgnoreAspectRatio);
QPainter p(this);
p.drawPixmap(0,0,imgt);
}
void WordEngine::update_sta(int item, int index, int sta)
{
item--;
index--;
/* 设置对应位标记 */
score_t[item][index].set = sta;
/* 特殊处理 */
if(sta == 0){
if(item == 2){ /* 痛有定处”即可得分,不用管有没有选“胃痛拒按 */
if( index == 0){
if(ui->a_1_4->isChecked() == true || ui->d_1_2->isChecked() == true){
score_t[2][0].set = 1;
}
}
else if (index == 2) { /* “舌质淡暗或暗红”或“瘀点瘀斑”满足其一即可得分 */
if(ui->c_1_4->isChecked() == true || ui->c_2_2->isChecked() == true){
score_t[2][2].set = 1;
}
}
else {
/* do nothing */
}
}
else if ((item == 3) && (index == 0)) { /* “胀痛“或”胀满”满足其一即可得分 */
if(ui->a_1_1->isChecked() == true || ui->a_2_4->isChecked() == true){
score_t[3][0].set = 1;
}
}
else if ((item == 6) && (index == 1)) { /* “口苦“或”口臭”满足其一即可得分 */
if(ui->a_4_4->isChecked() == true || ui->a_4_5->isChecked() == true){
score_t[6][1].set = 1;
}
}
else {
/* do nothing */
}
}
else {
if ((item == 6) && (index == 4)){ /* 需满足“黄苔“+(”厚苔“或”腻苔”)才可得分 */
if((ui->c_4_2->isChecked() == false )\
|| ((ui->c_5_1->isChecked() == false) && (ui->c_5_2->isChecked() == false))){
score_t[6][4].set = 0;
}
}
}
memset(result,0,sizeof (result));
/* 计算各病症得分 */
for (uint8_t i=0;i<7;i++) {
for (uint8_t j=0;j<config[i].num; j++) {
if(score_t[i][j].set){
result[i] += score_t[i][j].score;
// qDebug()<<"i:"<<i<<"j:"<<j;
// qDebug()<<"stat:"<<score_t[i][j].set<<"ret:"<<result[0];
}
}
color_t[i] = (result[i]>=config[i].confirm_score)?"color:red;":"color:black;";
lb_res[i]->setStyleSheet(color_t[i]);
lb_res[i]->setText(QString("%1").arg(result[i]));
if(color_t[i].contains("red")){
lb_cf[i]->setText("确诊");
}
else {
if(result[i]>=mul_t[i].dec){
int ret = (double)(result[i]-mul_t[i].min)*mul_t[i].num*100;
QString tes = QString("%1.%2%").arg(ret/100).arg(ret%100);
lb_cf[i]->setText(tes);
}
else {
lb_cf[i]->setText("---");;
}
}
}
ui->l1->setStyleSheet(color_t[0]);
ui->l2->setStyleSheet(color_t[1]);
ui->l3->setStyleSheet(color_t[2]);
ui->l4->setStyleSheet(color_t[3]);
ui->l5->setStyleSheet(color_t[4]);
ui->l6->setStyleSheet(color_t[5]);
ui->l7->setStyleSheet(color_t[6]);
ui->l1->setText(QString("%1").arg(result[0]));
ui->l2->setText(QString("%1").arg(result[1]));
ui->l3->setText(QString("%1").arg(result[2]));
ui->l4->setText(QString("%1").arg(result[3]));
ui->l5->setText(QString("%1").arg(result[4]));
ui->l6->setText(QString("%1").arg(result[5]));
ui->l7->setText(QString("%1").arg(result[6]));
}
WordEngine::~WordEngine()
{
delete ui;
}
void WordEngine::on_a_1_x_clicked()
{
ui->a_1_t->clear();
ui->a_1_1->setCheckState(Qt::CheckState::Unchecked);
ui->a_1_2->setCheckState(Qt::CheckState::Unchecked);
ui->a_1_3->setCheckState(Qt::CheckState::Unchecked);
ui->a_1_4->setCheckState(Qt::CheckState::Unchecked);
ui->a_1_5->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_a_1_1_stateChanged(int arg1)
{
//qDebug()<<arg1;
if(ui->a_1_x->isChecked() == true){
//ui->a_1_x->setCheckState(Qt::CheckState::Unchecked);
}
update_sta(4,1, arg1);
}
void WordEngine::on_a_1_2_stateChanged(int arg1)
{
if(ui->a_1_x->isChecked() == true){
//ui->a_1_x->setCheckState(Qt::CheckState::Unchecked);
}
update_sta(5,1, arg1);
update_sta(6,1, arg1);
}
void WordEngine::on_a_1_3_stateChanged(int arg1)
{
update_sta(1,1, arg1);
update_sta(2,1, arg1);
}
void WordEngine::on_a_1_4_stateChanged(int arg1)
{
update_sta(3,1, arg1);
}
void WordEngine::on_a_1_5_stateChanged(int arg1)
{
}
void WordEngine::on_a_2_x_clicked()
{
ui->a_2_t->clear();
ui->a_2_1->setCheckState(Qt::CheckState::Unchecked);
ui->a_2_2->setCheckState(Qt::CheckState::Unchecked);
ui->a_2_3->setCheckState(Qt::CheckState::Unchecked);
ui->a_2_4->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_a_2_1_stateChanged(int arg1)
{
update_sta(4,1, arg1);
update_sta(1,2, arg1);
}
void WordEngine::on_a_2_2_stateChanged(int arg1)
{
update_sta(7,1, arg1);
}
void WordEngine::on_a_2_3_stateChanged(int arg1)
{
update_sta(5,2, arg1);
update_sta(6,2, arg1);
}
void WordEngine::on_a_3_x_clicked()
{
ui->a_3_t->clear();
ui->a_3_1->setCheckState(Qt::CheckState::Unchecked);
ui->a_3_2->setCheckState(Qt::CheckState::Unchecked);
ui->a_3_3->setCheckState(Qt::CheckState::Unchecked);
ui->a_3_4->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_a_3_1_stateChanged(int arg1)
{
update_sta(4,2, arg1);
}
void WordEngine::on_a_3_2_stateChanged(int arg1)
{
update_sta(5,4, arg1);
}
void WordEngine::on_a_3_3_stateChanged(int arg1)
{
update_sta(2,2, arg1);
}
void WordEngine::on_a_4_x_clicked()
{
ui->a_4_t->clear();
ui->a_4_1->setCheckState(Qt::CheckState::Unchecked);
ui->a_4_2->setCheckState(Qt::CheckState::Unchecked);
ui->a_4_3->setCheckState(Qt::CheckState::Unchecked);
ui->a_4_4->setCheckState(Qt::CheckState::Unchecked);
ui->a_4_5->setCheckState(Qt::CheckState::Unchecked);
ui->a_4_6->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_a_4_1_stateChanged(int arg1)
{
update_sta(1,3, arg1);
}
void WordEngine::on_a_4_2_stateChanged(int arg1)
{
update_sta(6,3, arg1);
}
void WordEngine::on_a_4_3_stateChanged(int arg1)
{
update_sta(6,4, arg1);
}
void WordEngine::on_a_4_4_stateChanged(int arg1)
{
update_sta(5,3, arg1);
update_sta(7,2, arg1);
}
void WordEngine::on_a_4_5_stateChanged(int arg1)
{
update_sta(7,2, arg1);
}
void WordEngine::on_b_1_x_clicked()
{
ui->b_1_t->clear();
ui->b_1_1->setCheckState(Qt::CheckState::Unchecked);
ui->b_1_2->setCheckState(Qt::CheckState::Unchecked);
ui->b_1_3->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_b_2_x_clicked()
{
ui->b_2_t->clear();
ui->b_2_1->setCheckState(Qt::CheckState::Unchecked);
ui->b_2_2->setCheckState(Qt::CheckState::Unchecked);
ui->b_2_3->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_b_3_x_clicked()
{
ui->b_3_t->clear();
ui->b_3_1->setCheckState(Qt::CheckState::Unchecked);
ui->b_3_2->setCheckState(Qt::CheckState::Unchecked);
ui->b_3_3->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_b_4_x_clicked()
{
ui->b_4_t->clear();
ui->b_4_1->setCheckState(Qt::CheckState::Unchecked);
ui->b_4_2->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_b_1_1_stateChanged(int arg1)
{
update_sta(4,4, arg1);
}
void WordEngine::on_b_1_2_stateChanged(int arg1)
{
update_sta(2,4, arg1);
}
void WordEngine::on_b_2_1_stateChanged(int arg1)
{
update_sta(5,5, arg1);
}
void WordEngine::on_b_2_2_stateChanged(int arg1)
{
update_sta(4,5, arg1);
}
void WordEngine::on_b_3_1_stateChanged(int arg1)
{
update_sta(1,4, arg1);
}
void WordEngine::on_b_3_2_stateChanged(int arg1)
{
update_sta(1,5, arg1);
}
void WordEngine::on_b_4_1_stateChanged(int arg1)
{
update_sta(3,2, arg1);
}
void WordEngine::on_c_1_1_stateChanged(int arg1)
{
}
void WordEngine::on_c_1_2_stateChanged(int arg1)
{
update_sta(2,7, arg1);
update_sta(1,7, arg1);
}
void WordEngine::on_c_1_3_stateChanged(int arg1)
{
update_sta(7,5, arg1);
update_sta(6,6, arg1);
update_sta(5,6, arg1);
}
void WordEngine::on_c_1_4_stateChanged(int arg1)
{
update_sta(3,3, arg1);
}
void WordEngine::on_c_2_1_stateChanged(int arg1)
{
update_sta(6,8, arg1);
}
void WordEngine::on_c_2_2_stateChanged(int arg1)
{
update_sta(3,3, arg1);
}
void WordEngine::on_c_2_3_stateChanged(int arg1)
{
update_sta(3,4, arg1);
}
void WordEngine::on_c_3_x_clicked()
{
// ui->c_3_1->setCheckState(Qt::CheckState::Unchecked);
// ui->c_3_2->setCheckState(Qt::CheckState::Unchecked);
// ui->c_3_3->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_c_3_1_stateChanged(int arg1)
{
update_sta(1,8, arg1);
}
void WordEngine::on_c_3_2_stateChanged(int arg1)
{
update_sta(6,7, arg1);
}
void WordEngine::on_c_4_2_stateChanged(int arg1)
{
update_sta(5,7, arg1);
update_sta(7,5, arg1);
}
void WordEngine::on_c_5_1_stateChanged(int arg1)
{
update_sta(7,5, arg1);
}
void WordEngine::on_c_5_2_stateChanged(int arg1)
{
update_sta(7,5, arg1);
}
void WordEngine::on_c_5_4_stateChanged(int arg1)
{
update_sta(6,9, arg1);
}
void WordEngine::on_e_1_1_stateChanged(int arg1)
{
update_sta(4,6, arg1);
}
void WordEngine::on_e_1_2_stateChanged(int arg1)
{
update_sta(6,10, arg1);
}
void WordEngine::on_e_1_3_stateChanged(int arg1)
{
update_sta(7,6, arg1);
}
void WordEngine::on_e_1_4_stateChanged(int arg1)
{
update_sta(2,8, arg1);
update_sta(1,9, arg1);
}
void WordEngine::on_e_1_5_stateChanged(int arg1)
{
update_sta(3,5, arg1);
}
void WordEngine::on_d_1_x_clicked()
{
}
void WordEngine::on_d_1_1_stateChanged(int arg1)
{
update_sta(2,5, arg1);
}
void WordEngine::on_d_1_2_stateChanged(int arg1)
{
update_sta(3,1, arg1);
}
void WordEngine::on_d_1_3_stateChanged(int arg1)
{
update_sta(1,6, arg1);
}
void WordEngine::on_d_1_4_stateChanged(int arg1)
{
update_sta(4,4, arg1);
}
void WordEngine::on_d_1_5_stateChanged(int arg1)
{
update_sta(2,6, arg1);
}
void WordEngine::on_bt_clear_clicked()
{
/* 清除A组 */
ui->a_1_x->click();
ui->a_1_x->click();
ui->a_2_x->click();
ui->a_3_x->click();
ui->a_4_x->click();
ui->a_5_x->click();
/* 清除B组 */
ui->b_1_x->click();
ui->b_2_x->click();
ui->b_3_x->click();
ui->b_4_x->click();
/* 清除C_3组 */
ui->c_3_x->setCheckState(Qt::CheckState::Checked);
/* 清除C组 */
ui->c_1_1->setCheckState(Qt::CheckState::Unchecked);
ui->c_1_2->setCheckState(Qt::CheckState::Unchecked);
ui->c_1_3->setCheckState(Qt::CheckState::Unchecked);
ui->c_1_4->setCheckState(Qt::CheckState::Unchecked);
ui->c_1_5->setCheckState(Qt::CheckState::Unchecked);
ui->c_1_t->clear();
ui->c_2_1->setCheckState(Qt::CheckState::Unchecked);
ui->c_2_2->setCheckState(Qt::CheckState::Unchecked);
ui->c_2_3->setCheckState(Qt::CheckState::Unchecked);
ui->c_2_4->setCheckState(Qt::CheckState::Unchecked);
ui->c_2_t->clear();
ui->c_4_1->setCheckState(Qt::CheckState::Unchecked);
ui->c_4_2->setCheckState(Qt::CheckState::Unchecked);
ui->c_4_3->setCheckState(Qt::CheckState::Unchecked);
ui->c_4_t->clear();
ui->c_5_1->setCheckState(Qt::CheckState::Unchecked);
ui->c_5_2->setCheckState(Qt::CheckState::Unchecked);
ui->c_5_3->setCheckState(Qt::CheckState::Unchecked);
ui->c_5_4->setCheckState(Qt::CheckState::Unchecked);
ui->c_5_5->setCheckState(Qt::CheckState::Unchecked);
ui->c_5_t->clear();
/* 清除D组 */
ui->d_1_1->setCheckState(Qt::CheckState::Unchecked);
ui->d_1_2->setCheckState(Qt::CheckState::Unchecked);
ui->d_1_3->setCheckState(Qt::CheckState::Unchecked);
ui->d_1_4->setCheckState(Qt::CheckState::Unchecked);
ui->d_1_5->setCheckState(Qt::CheckState::Unchecked);
ui->d_1_x->setCheckState(Qt::CheckState::Unchecked);
ui->d_1_t->clear();
/* 清除E组 */
ui->e_1_1->setCheckState(Qt::CheckState::Unchecked);
ui->e_1_2->setCheckState(Qt::CheckState::Unchecked);
ui->e_1_3->setCheckState(Qt::CheckState::Unchecked);
ui->e_1_4->setCheckState(Qt::CheckState::Unchecked);
ui->e_1_5->setCheckState(Qt::CheckState::Unchecked);
ui->e_1_6->setCheckState(Qt::CheckState::Unchecked);
ui->e_1_t->clear();
}
void WordEngine::on_c_3_x_stateChanged(int arg1)
{
if(arg1){
ui->c_3_1->setCheckState(Qt::CheckState::Unchecked);
ui->c_3_2->setCheckState(Qt::CheckState::Unchecked);
ui->c_3_3->setCheckState(Qt::CheckState::Unchecked);
ui->c_3_x->setCheckState(Qt::CheckState::Unchecked);
ui->c_3_t->clear();
}
}
void WordEngine::on_c_4_1_stateChanged(int arg1)
{
}
void WordEngine::on_a_5_x_clicked()
{
ui->a_5_t->clear();
ui->a_5_1->setCheckState(Qt::CheckState::Unchecked);
ui->a_5_2->setCheckState(Qt::CheckState::Unchecked);
ui->a_5_3->setCheckState(Qt::CheckState::Unchecked);
ui->a_5_4->setCheckState(Qt::CheckState::Unchecked);
}
void WordEngine::on_a_5_1_stateChanged(int arg1)
{
update_sta(6,5, arg1);
}
void WordEngine::on_a_5_2_stateChanged(int arg1)
{
update_sta(7,3, arg1);
}
void WordEngine::on_a_5_3_stateChanged(int arg1)
{
update_sta(2,3, arg1);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yjr_ty/qt-medical-diagnosis.git
git@gitee.com:yjr_ty/qt-medical-diagnosis.git
yjr_ty
qt-medical-diagnosis
00_Qt_医疗诊断
master

搜索帮助