-
Notifications
You must be signed in to change notification settings - Fork 0
/
rbevaluation.cpp
1437 lines (1296 loc) · 63.6 KB
/
rbevaluation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "rbevaluation.h"
#include "ui_rbevaluation.h"
//查bug用
#include<QDebug>
using namespace std;
////Sta部分
//定义几个全局变量,方便参数传值
int z;
double D,dm,alpha0,fi,fe,Fr,Fa,M;
//定义结果变量
double stadeltar,stadeltaa,statheta;
QVector<double> vecsalphatocharts(100);
QVector<double> vecsqtocharts(100);
////SimuDyn部分
int zsd,numberssd,ORsd;
double Dsd,dmsd,alpha0sd,fisd,fesd,Frsd,Fasd,Msd,vsd,Esd,osd,o1sd,o2sd,nisd,rhosd,errosd;
double sd_p0;
////Dyn部分
int z_dyn;
double D_dyn,dm_dyn,alpha0_dyn,fi_dyn,fe_dyn,Cp_dyn,Cg_dyn;
double E_dyn,v_dyn,rho_dyn,Ec_dyn,vc_dyn,rhoc_dyn;
double ni_dyn,Fa_dyn,Fr_dyn,My_dyn,Mz_dyn,OR_dyn;
double T0_dyn,n0_dyn,alpha_dyn,beta_dyn,K_dyn;
double h0_dyn,kt_dyn,Ferr_dyn,uerr_dyn,T_dyn;
RBEvaluation::RBEvaluation(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::RBEvaluation)
, m_sta_simudyn_status(0) //初始化
, m_mode(0) //模式选择默认为0
{
ui->setupUi(this);
////初始最大化显示
setWindowState(Qt::WindowMaximized);
//设置为不可缩小,否则图片可能会显示错误
//setFixedSize(this->width(),this->height());
//setWindowFlags(windowFlags()&~Qt::WindowMaximizeButtonHint); //这个是把缩小按钮标志为假
////工具栏设置
//toolbar宽度设置
ui->toolBar->setMinimumHeight(50);
//分配空间
m_opennew_sta = new QToolButton(this);
m_opennew_simudyn = new QToolButton(this);
m_opennew_dyn = new QToolButton(this);
m_run = new QToolButton(this);
m_toolbar_hboxlayout = new QWidget(this);
m_hboxlayout = new QHBoxLayout(m_toolbar_hboxlayout); //hbox写在里面
m_toolbar_h_spacer = new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Expanding);
m_rollingbearing_mode = new QToolButton(this);
m_taperedrollerbearing_mode = new QToolButton(this);
m_cylindricalrollerbearing_mode = new QToolButton(this);
//ICON设置
m_opennew_sta->setFixedSize(50,50);
//m_opennew_sta->setIconSize(QSize(100,100));
m_opennew_sta->setIcon(QIcon("sta.png")); //
m_opennew_simudyn->setFixedSize(50,50);
m_opennew_simudyn->setIcon(QIcon("simudyn.png"));
m_opennew_dyn->setFixedSize(50,50); //
m_opennew_dyn->setIcon(QIcon("dyn.png"));
m_run->setFixedSize(50,50); //
m_run->setIcon(QIcon("run.png"));
m_rollingbearing_mode->setFixedSize(50,50); //
m_rollingbearing_mode->setIcon(QIcon("rb.png"));
m_taperedrollerbearing_mode->setFixedSize(50,50); //
m_taperedrollerbearing_mode->setIcon(QIcon("tb.png"));
m_cylindricalrollerbearing_mode->setFixedSize(50,50); //
m_cylindricalrollerbearing_mode->setIcon(QIcon("cb.png"));
//加入显示
//从左往右加
ui->toolBar->addWidget(m_opennew_sta);
ui->toolBar->addWidget(m_opennew_simudyn);
ui->toolBar->addWidget(m_opennew_dyn);
ui->toolBar->addSeparator(); //加分割杠
ui->toolBar->addWidget(m_run);
ui->toolBar->addSeparator();
//从右往左加,只需中间添加一个弹簧
m_hboxlayout->addItem(m_toolbar_h_spacer);
ui->toolBar->addWidget(m_toolbar_hboxlayout);
ui->toolBar->addSeparator();
ui->toolBar->addWidget(m_rollingbearing_mode);
ui->toolBar->addWidget(m_taperedrollerbearing_mode);
ui->toolBar->addWidget(m_cylindricalrollerbearing_mode);
//设置tooltip
m_opennew_sta->setToolTip("新建静力学计算");
m_opennew_simudyn->setToolTip("新建拟动力学计算");
m_opennew_dyn->setToolTip("新建动力学计算");
m_run->setToolTip("运行");
m_rollingbearing_mode->setToolTip("滚动球轴承分析");
m_taperedrollerbearing_mode->setToolTip("圆锥滚子轴承分析");
m_cylindricalrollerbearing_mode->setToolTip("圆柱滚子轴承分析");
//设置点击功能
connect(m_opennew_sta,&QPushButton::clicked,this,&RBEvaluation::on_actionstainput_triggered); //显示静力学input
connect(m_opennew_simudyn,&QPushButton::clicked,this,&RBEvaluation::on_actionsdinput_triggered); //显示拟动力学input
connect(m_opennew_dyn,&QPushButton::clicked,this,&RBEvaluation::on_actiondyninput_triggered);
connect(m_run,&QPushButton::clicked,
[=]()
{
switch (m_sta_simudyn_status)
{
case 1: on_actionstarun_triggered();break;
case 2: on_actionsdrun_triggered();break;
case 3:break;
default:break;
}
}
);
connect(m_rollingbearing_mode,&QPushButton::clicked,
[=]()
{
m_mode = 1; //mode标志位置一表示滚动球轴承在使用
//pixmap设置,并且自适应图片
QPixmap *pixmap = new QPixmap("rbpixmap.png");
pixmap->scaled(ui->labelpixmap->size(), Qt::KeepAspectRatio);
ui->labelpixmap->setScaledContents(true);
ui->labelpixmap->setPixmap(*pixmap);
}
);
connect(m_taperedrollerbearing_mode,&QPushButton::clicked,
[=]()
{
m_mode = 2;//mode标志位置2表示圆锥滚子轴承在使用
//pixmap设置,并且自适应图片
QPixmap *pixmap = new QPixmap("tbpixmap.png");
pixmap->scaled(ui->labelpixmap->size(), Qt::KeepAspectRatio);
ui->labelpixmap->setScaledContents(true);
ui->labelpixmap->setPixmap(*pixmap);
}
);
connect(m_cylindricalrollerbearing_mode,&QPushButton::clicked,
[=]()
{
m_mode = 3;//mode标志位置3表示圆柱滚子轴承在使用
//pixmap设置,并且自适应图片
QPixmap *pixmap = new QPixmap("cbpixmap.png");
pixmap->scaled(ui->labelpixmap->size(), Qt::KeepAspectRatio);
ui->labelpixmap->setScaledContents(true);
ui->labelpixmap->setPixmap(*pixmap);
}
);
//分配子窗口空间
staoutput = new Sta_Output();
stacharts = new Sta_Charts();
simudyncharts = new SimuDyn_Charts();
simudynoutput = new SimuDyn_Output();
cloudtest = new CloudTest();
indiaopengl = new IndiaOpenGL();
SD_3D_Input = new SimuDyn_ThreeD_Input();
////线程
//给线程动态分配空间,但是不能指定父对象
m_stathread = new StaThread;
m_simudynthread = new SimuDynThread;
//创建子线程
threadsta = new QThread(this);
threadsd = new QThread(this);
//把自定义的线程加入到子线程中
m_stathread->moveToThread(threadsta);
m_simudynthread->moveToThread(threadsd);
////Sta部分
//建立连接,一点下按钮就收集读取的数据,由于该成员变量不是指针,所以需要取一下地址
connect(&stainput,&Sta_Input::stainput,this,&RBEvaluation::stadealinput);
//建立连接,一点下按钮就开始计算
connect(this,&RBEvaluation::startthreadsta,m_stathread,&StaThread::sta);
//建立连接,接收函数
connect(m_stathread,&StaThread::stasendback,this,&RBEvaluation::stadealresult);
//建立连接,参数传到output窗口
connect(this,&RBEvaluation::statooutput,staoutput,&Sta_Output::stadealoutput);
//建立连接,参数传到charts窗口
connect(this,&RBEvaluation::statocharts,stacharts,&Sta_Charts::stadealcharts);
//建立连接,如果sta计算完成,则停止线程
connect(m_stathread,&StaThread::staprogress,this,&RBEvaluation::dealdestroyed);
////SD部分
//建立连接,一点下按钮就收集读取的数据,由于该成员变量不是指针,所以需要取一下地址
connect(&simudyninput,&SimuDyn_Input::sdinput,this,&RBEvaluation::sddealinput);
//建立连接,一点下按钮就开始计算
connect(this,&RBEvaluation::startthreadsd,m_simudynthread,&SimuDynThread::dyn);
//建立连接,接收误差参数类进行主窗口绘图
//connect(m_simudynthread,&SimuDynThread::sdthreadtodiagro,this,&RBEvaluation::sddealerro);
//建立连接,接收函数准备分发进行绘图等等工作
connect(m_simudynthread,&SimuDynThread::sdthreadtomain,this,&RBEvaluation::sddealresult);
//建立连接,参数传到output窗口
connect(this,&RBEvaluation::sdtooutput,simudynoutput,&SimuDyn_Output::sddealoutput);
//建立连接,参数传到charts窗口
connect(this,&RBEvaluation::sdtocharts,simudyncharts,&SimuDyn_Charts::sddealcharts);
//建立连接,如果simudyn超出极限次数,则停止线程
connect(m_simudynthread,&SimuDynThread::sdthreadnotwork,this,&RBEvaluation::dealdestroyed);
//建立连接,如果simudyn计算结束,则停止线程,否则会无法使用destroy窗口信号
connect(m_simudynthread,&SimuDynThread::sdthreadisallover,this,&RBEvaluation::dealdestroyed);
//建立连接,simudyn计算被中断
connect(m_simudynthread,&SimuDynThread::stopdynthread,
[=]()
{
if(threadsd->isRunning()==false)
{
return;
}
threadsd->quit();
threadsd->wait();
}
);
////DYN部分
//建立与数据输入窗口的联系,输入数据
connect(&dyninput,&Dyn_Input::dyninput,this,&RBEvaluation::dyndealinput);
////3D部分
connect(this,&RBEvaluation::MainWindowToThreeD,indiaopengl,&IndiaOpenGL::dealtopview);
//建立与三维输入界面的连接,输入最大赫兹压力
connect(this,&RBEvaluation::MainWindowToThreeDInput,SD_3D_Input,&SimuDyn_ThreeD_Input::dealMainWindowToThreeDInput);
//建立与三维输入界面的连接,输入读取文件的名称
connect(this,&RBEvaluation::FilenameToThreeD,indiaopengl,&IndiaOpenGL::dealSentFilename);
//建立与云图的连接,输入读取文件的名称
connect(this,&RBEvaluation::FilenameToCloud,cloudtest,&CloudTest::dealCloudSentFilename);
////公共部分
//与自己建立连接,当关闭窗口的时候,也可以终止线程,两个都关
connect(this,&RBEvaluation::destroyed,this,&RBEvaluation::dealdestroyed);
//建立关闭主界面工作区tab连接
connect(ui->tabWidgetworkingarea,&QTabWidget::tabCloseRequested,this,&RBEvaluation::TabClose);
//设计逻辑结构,使得初始化的时候一些按键无法被按下
ui->actionstarun->setEnabled(false);
ui->actionstaoutput->setEnabled(false);
ui->actionstachart->setEnabled(false);
ui->actionsdrun->setEnabled(false);
ui->actionsdoutput->setEnabled(false);
ui->actionsdchart->setEnabled(false);
//ui->action3D->setEnabled(false);
//ui->actionsta->setEnabled(false);
//ui->actionsimudyn->setEnabled(false);
ui->actionstaalpha->setEnabled(false);
ui->actionstaq->setEnabled(false);
ui->actionalphai->setEnabled(false);
ui->actionalphae->setEnabled(false);
ui->actionlamda->setEnabled(false);
ui->actionu->setEnabled(false);
ui->actionQi->setEnabled(false);
ui->actionQe->setEnabled(false);
ui->actionFc->setEnabled(false);
ui->actionMg->setEnabled(false);
ui->actionwb->setEnabled(false);
ui->actionwc->setEnabled(false);
ui->actionSRi->setEnabled(false);
ui->actionSRe->setEnabled(false);
//标志为初始化
flag_stacharts = false; //标志当前没有标签页
flag_staoutput = false;
flag_simudynoutput = false;
flag_simudyncharts = false;
}
RBEvaluation::~RBEvaluation()
{
delete ui;
}
////Sta部分
//按下新建按钮便打开静力学输入参数Form
void RBEvaluation::on_actionstainput_triggered()
{
if(m_mode == 1) //如果选定了rb模式1
{
stainput.show();
//让窗口显示在屏幕中央
stainput.move ((QApplication::desktop()->width() - stainput.width())/2,(QApplication::desktop()->height() - stainput.height())/2);
}
}
//槽函数进行数据传递,从input传到这里
void RBEvaluation::stadealinput(int sz, double sD, double sdm, double salpha0, double sfi, double sfe, double sFr, double sFa, double sM)
{
z=sz;
D=sD;
dm=sdm;
alpha0=salpha0;
fi=sfi;
fe=sfe;
Fr=sFr;
Fa=sFa;
M=sM;
//将sta计算设置为true
ui->actionstarun->setEnabled(true);
//那边点了应用,这边就开始画TreeWidget
ui->treeWidget->clear(); //清空以前的东西
ui->treeWidget->setColumnCount(1); //设置列数
//设置str编码类型
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));
ui->treeWidget->setHeaderLabel(tr("静力学计算输入参数")); //设置标题
QList<QTreeWidgetItem *> items;
//创建两个节点
QTreeWidgetItem *father_Item_1 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("工况条件")));
QTreeWidgetItem *father_Item_2 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("结构参数")));
items.append(father_Item_1);
items.append(father_Item_2);
//添加顶层节点
ui->treeWidget->insertTopLevelItems(0,items);
//添加子节点_1
QTreeWidgetItem *Child_Item_Fr = new QTreeWidgetItem(father_Item_1,QStringList(QString("径向载荷(Fr)")));
QTreeWidgetItem *Child_Item_Fa = new QTreeWidgetItem(father_Item_1,QStringList(QString("轴向载荷(Fa)")));
QTreeWidgetItem *Child_Item_M = new QTreeWidgetItem(father_Item_1,QStringList(QString("力矩(M)")));
father_Item_1->addChild(Child_Item_Fr);
father_Item_1->addChild(Child_Item_Fa);
father_Item_1->addChild(Child_Item_M);
//添加子节点_2
QTreeWidgetItem *Child_Item_Z = new QTreeWidgetItem(father_Item_2,QStringList(QString("钢球个数(Z)")));
QTreeWidgetItem *Child_Item_D = new QTreeWidgetItem(father_Item_2,QStringList(QString("钢球直径(D)")));
QTreeWidgetItem *Child_Item_dm = new QTreeWidgetItem(father_Item_2,QStringList(QString("内圈直径(dm)")));
QTreeWidgetItem *Child_Item_alpha0 = new QTreeWidgetItem(father_Item_2,QStringList(QString("初始接触角")));
QTreeWidgetItem *Child_Item_fi = new QTreeWidgetItem(father_Item_2,QStringList(QString("内圈沟渠率半径系数")));
QTreeWidgetItem *Child_Item_fe = new QTreeWidgetItem(father_Item_2,QStringList(QString("外圈沟渠率半径系数")));
father_Item_2->addChild(Child_Item_Z);
father_Item_2->addChild(Child_Item_D);
father_Item_2->addChild(Child_Item_dm);
father_Item_2->addChild(Child_Item_alpha0);
father_Item_2->addChild(Child_Item_fi);
father_Item_2->addChild(Child_Item_fe);
ui->treeWidget->expandAll();
m_sta_simudyn_status = 1; //置一表示当前是静力学分析
//pixmap设置,并且自适应图片
//ui->labelpixmap->setPixmap(QPixmap("simupixmap.png"));
//QPixmap *pixmap = new QPixmap("rb/pixmap.png");
//pixmap->scaled(ui->labelpixmap->size(), Qt::KeepAspectRatio);
//ui->labelpixmap->setScaledContents(true);
//ui->labelpixmap->setPixmap(*pixmap);
}
//按下静力学运行按钮进行计算,把数据从这里传到thread
void RBEvaluation::on_actionstarun_triggered()
{
//判断一下,不再运行的时候才启动
if(threadsta->isRunning()==true)
{
return;
}
//启动线程,但是没有启动线程处理函数
threadsta->start();
//发送信号告诉线程该启动了
emit startthreadsta(z,D,dm,alpha0,fi,fe,Fr,Fa,M);
}
//槽函数把算好的值都放回来
void RBEvaluation::stadealresult(double deltar, double deltaa, double theta, QVector<double> vecsalpha, QVector<double> vecsq)
{
stadeltar=deltar;
stadeltaa=deltaa;
statheta=theta;
static int i;
for(i=0;i<z;i++)
{
vecsalphatocharts[i]=vecsalpha[i];
vecsqtocharts[i]=vecsq[i];
}
//关闭sta线程
if(threadsta->isRunning()==false)
{
return;
}
threadsta->quit();
threadsta->wait();
//计算完成,可显示查看结果,图表,查看txt按钮
ui->actionstaoutput->setEnabled(true);
ui->actionstachart->setEnabled(true);
//ui->actionsta->setEnabled(true);
}
//按下显示结果按钮便打开静力学计算结果
void RBEvaluation::on_actionstaoutput_triggered()
{
if(flag_staoutput == false) //如果没被按下
{
//标志为设置
flag_staoutput = true;
//发送数据信号
emit statooutput(D,dm,alpha0,fi,fe,Fr,Fa,M,stadeltaa,stadeltar,statheta,z,vecsalphatocharts,vecsqtocharts);
//如果不存在该标签页,则创建一个新的标签页
m_tabstaoutputdyn = new QWidget();
int currentindex = ui->tabWidgetworkingarea->addTab(m_tabstaoutputdyn,"静力学计算结果");
ui->tabWidgetworkingarea->setCurrentIndex(currentindex);
ui->tabWidgetworkingarea->setTabsClosable(true); //设置为可关闭的
//将图表写进来
staoutput->setParent(m_tabstaoutputdyn);
//stacharts->move ((QApplication::desktop()->width() - stacharts->width())/2,(QApplication::desktop()->height() - stacharts->height())/2);//让窗口显示在屏幕中央
//获取长和宽
qreal tabstaoutputdyn_width,tabstaoutputdyn_height;
tabstaoutputdyn_width = ui->tabWidgetworkingarea->geometry().width();
tabstaoutputdyn_height = ui->tabWidgetworkingarea->geometry().height();
//resize安排窗口,使得其能自适应填满
qreal heightratio;
heightratio = 0.95;
staoutput->resize(tabstaoutputdyn_width,tabstaoutputdyn_height*heightratio);
//显示在左上角
staoutput->move(0,0);
staoutput->show();
}
//如果存在,则发出警告
else if(flag_staoutput == true)
{
SetMessageBoxSize msgBox; //自己写了一个类,可以设置size的继承于QMessageBox的类
msgBox.AutosetSize(300,100);
msgBox.setIcon(QMessageBox::Warning); //设置类型
msgBox.setWindowTitle("警告");
msgBox.setText("静力学计算结果结果已存在");
//msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
}
//让窗口显示在屏幕中央
//staoutput.move ((QApplication::desktop()->width() - staoutput.width())/2,(QApplication::desktop()->height() - staoutput.height())/2);
}
//按下图表按钮便打开静力学图表
void RBEvaluation::on_actionstachart_triggered()
{
if(flag_stacharts == false) //如果没被按下
{
//标志为设置
flag_stacharts = true;
//发送数据信号
emit statocharts(z,vecsalphatocharts,vecsqtocharts);
//如果不存在该标签页,则创建一个新的标签页
m_tabstachartsdyn = new QWidget();
int currentindex = ui->tabWidgetworkingarea->addTab(m_tabstachartsdyn,"静力学图表");
ui->tabWidgetworkingarea->setCurrentIndex(currentindex);
ui->tabWidgetworkingarea->setTabsClosable(true); //设置为可关闭的
//将图表写进来
stacharts->setParent(m_tabstachartsdyn);
//stacharts->move ((QApplication::desktop()->width() - stacharts->width())/2,(QApplication::desktop()->height() - stacharts->height())/2);//让窗口显示在屏幕中央
//获取长和宽
qreal tabstachartsdyn_width,tabstachartsdyn_height;
tabstachartsdyn_width = ui->tabWidgetworkingarea->geometry().width();
tabstachartsdyn_height = ui->tabWidgetworkingarea->geometry().height();
//resize安排窗口,使得其能自适应填满
qreal heightratio;
heightratio = 0.95;
stacharts->resize(tabstachartsdyn_width,tabstachartsdyn_height*heightratio);
//显示在左上角
stacharts->move(0,0);
stacharts->show();
}
//如果存在,则发出警告
else if(flag_stacharts == true)
{
SetMessageBoxSize msgBox; //自己写了一个类,可以设置size的继承于QMessageBox的类
msgBox.AutosetSize(300,100);
msgBox.setIcon(QMessageBox::Warning); //设置类型
msgBox.setWindowTitle("警告");
msgBox.setText("静力学图表结果已存在");
//msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
}
}
////SimuDyn部分
//按下新建按钮便打开拟动力学输入参数Form
void RBEvaluation::on_actionsdinput_triggered()
{
if(m_mode == 1)
{
simudyninput.show();
//让窗口显示在屏幕中央
simudyninput.move ((QApplication::desktop()->width() - simudyninput.width())/2,(QApplication::desktop()->height() - simudyninput.height())/2);
}
}
//槽函数进行数据传递,从input传到这里
void RBEvaluation::sddealinput(double E, double v, double rho, double alpha0, double D, double di, double fe, double fi, int Z, double Fr, double Fa, double M, double ni, double omiga, double omiga1, double omiga2, int OR, double erro, int numbers)
{
Esd=E;
vsd=v;
rhosd=rho;
alpha0sd=alpha0;
Dsd=D;
dmsd=di;
fesd=fe;
fisd=fi;
zsd=Z;
Fasd=Fa;
Frsd=Fr;
Msd=M;
nisd=ni;
ORsd=OR;
osd=omiga;
o1sd=omiga1;
o2sd=omiga2;
errosd=erro;
numberssd=numbers;
//让用户可以开始点计算按钮
ui->actionsdrun->setEnabled(true);
//那边点了应用,这边就ka开始画TreeWidget
ui->treeWidget->clear(); //清空以前的东西
ui->treeWidget->setColumnCount(1); //设置列数
//设置str编码类型
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));
ui->treeWidget->setHeaderLabel(tr("拟动力学计算输入参数")); //设置标题
QList<QTreeWidgetItem *> items;
//创建两个节点
QTreeWidgetItem *father_Item_1 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("工况条件")));
QTreeWidgetItem *father_Item_2 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("结构参数")));
QTreeWidgetItem *father_Item_3 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("材料参数")));
QTreeWidgetItem *father_Item_4 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("引导方式")));
QTreeWidgetItem *father_Item_5 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("润滑剂/摩擦相关参数")));
QTreeWidgetItem *father_Item_6 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("数值计算相关参数")));
items.append(father_Item_1);
items.append(father_Item_2);
items.append(father_Item_3);
items.append(father_Item_4);
items.append(father_Item_5);
items.append(father_Item_6);
//添加顶层节点
ui->treeWidget->insertTopLevelItems(0,items);
//添加子节点_1
QTreeWidgetItem *Child_Item_Fr = new QTreeWidgetItem(father_Item_1,QStringList(QString("径向载荷(Fr)")));
QTreeWidgetItem *Child_Item_Fa = new QTreeWidgetItem(father_Item_1,QStringList(QString("轴向载荷(Fa)")));
QTreeWidgetItem *Child_Item_M = new QTreeWidgetItem(father_Item_1,QStringList(QString("力矩(M)")));
QTreeWidgetItem *Child_Item_ni = new QTreeWidgetItem(father_Item_1,QStringList(QString("内圈转速(ni)")));
father_Item_1->addChild(Child_Item_Fr);
father_Item_1->addChild(Child_Item_Fa);
father_Item_1->addChild(Child_Item_M);
father_Item_1->addChild(Child_Item_ni);
//添加子节点_2
QTreeWidgetItem *Child_Item_Z = new QTreeWidgetItem(father_Item_2,QStringList(QString("钢球个数(Z)")));
QTreeWidgetItem *Child_Item_D = new QTreeWidgetItem(father_Item_2,QStringList(QString("钢球直径(D)")));
QTreeWidgetItem *Child_Item_dm = new QTreeWidgetItem(father_Item_2,QStringList(QString("内圈直径(dm)")));
QTreeWidgetItem *Child_Item_alpha0 = new QTreeWidgetItem(father_Item_2,QStringList(QString("初始接触角")));
QTreeWidgetItem *Child_Item_fi = new QTreeWidgetItem(father_Item_2,QStringList(QString("内圈沟渠率半径系数")));
QTreeWidgetItem *Child_Item_fe = new QTreeWidgetItem(father_Item_2,QStringList(QString("外圈沟渠率半径系数")));
father_Item_2->addChild(Child_Item_Z);
father_Item_2->addChild(Child_Item_D);
father_Item_2->addChild(Child_Item_dm);
father_Item_2->addChild(Child_Item_alpha0);
father_Item_2->addChild(Child_Item_fi);
father_Item_2->addChild(Child_Item_fe);
//添加子节点_3
QTreeWidgetItem *Child_Item_rho = new QTreeWidgetItem(father_Item_3,QStringList(QString("钢球材料密度")));
QTreeWidgetItem *Child_Item_E = new QTreeWidgetItem(father_Item_3,QStringList(QString("弹性模量")));
QTreeWidgetItem *Child_Item_v = new QTreeWidgetItem(father_Item_3,QStringList(QString("泊松比")));
father_Item_3->addChild(Child_Item_rho);
father_Item_3->addChild(Child_Item_E);
father_Item_3->addChild(Child_Item_v);
//添加子节点_4
QTreeWidgetItem *Child_Item_OR = new QTreeWidgetItem(father_Item_4,QStringList(QString("引导方式")));
father_Item_4->addChild(Child_Item_OR);
//添加子节点_5
QTreeWidgetItem *Child_Item_episilo = new QTreeWidgetItem(father_Item_5,QStringList(QString("润滑油黏度(η)")));
QTreeWidgetItem *Child_Item_rr = new QTreeWidgetItem(father_Item_5,QStringList(QString("润滑油密度(ρ)")));
QTreeWidgetItem *Child_Item_alpha = new QTreeWidgetItem(father_Item_5,QStringList(QString("润滑油黏压系数(α)")));
QTreeWidgetItem *Child_Item_beita = new QTreeWidgetItem(father_Item_5,QStringList(QString("润滑油黏温(β)")));
QTreeWidgetItem *Child_Item_mu = new QTreeWidgetItem(father_Item_5,QStringList(QString("摩擦系数(μ)")));
father_Item_5->addChild(Child_Item_episilo);
father_Item_5->addChild(Child_Item_rr);
father_Item_5->addChild(Child_Item_alpha);
father_Item_5->addChild(Child_Item_beita);
father_Item_5->addChild(Child_Item_mu);
//添加子节点_6
QTreeWidgetItem *Child_Item_omigaD = new QTreeWidgetItem(father_Item_6,QStringList(QString("位移修正系数(ωD)")));
QTreeWidgetItem *Child_Item_omigaRr = new QTreeWidgetItem(father_Item_6,QStringList(QString("姿态角修正系数(ωγ)")));
QTreeWidgetItem *Child_Item_erro = new QTreeWidgetItem(father_Item_6,QStringList(QString("规定迭代误差")));
QTreeWidgetItem *Child_Item_numbers = new QTreeWidgetItem(father_Item_6,QStringList(QString("极限迭代次数")));
father_Item_6->addChild(Child_Item_omigaD);
father_Item_6->addChild(Child_Item_omigaRr);
father_Item_6->addChild(Child_Item_erro);
father_Item_6->addChild(Child_Item_numbers);
ui->treeWidget->expandAll();
m_sta_simudyn_status = 2; //置二表示当前是拟动力学分析
//pixmap设置,并且自适应图片
//ui->labelpixmap->setPixmap(QPixmap("simupixmap.png"));
//QPixmap *pixmap = new QPixmap("rbpixmap.png");
//pixmap->scaled(ui->labelpixmap->size(), Qt::KeepAspectRatio);
//ui->labelpixmap->setScaledContents(true);
//ui->labelpixmap->setPixmap(*pixmap);
}
//按下拟动力学运行按钮进行计算
void RBEvaluation::on_actionsdrun_triggered()
{
//判断一下,不再运行的时候才启动
if(threadsd->isRunning()==true)
{
return;
}
//启动线程,但是没有启动线程处理函数
threadsd->start();
//发送信号告诉线程该启动了
emit startthreadsd(Esd,vsd,rhosd,alpha0sd,Dsd,dmsd,fesd,fisd,zsd,Frsd,Fasd,Msd,nisd,osd,o1sd,o2sd,ORsd,errosd,numberssd);
}
//收集数据进行处理,准备发放,可以直接在这里把数据就传给各个窗口
void RBEvaluation::sddealresult(double Dthetat, double Ddeltaat, double Ddeltart, QVector<double> vecsdlamdat, QVector<double> vecsdalphaet, QVector<double> vecsdalphait, QVector<double> vecsdut, QVector<double> vecsdQet, QVector<double> vecsdQit, QVector<double> vecsdFct, QVector<double> vecsdMgt, QVector<double> vecsdwbt, QVector<double> vecsdwct, QVector<double> vecsdSRet, QVector<double> vecsdSRit ,double P0)
{
//给output窗口发送数据
emit sdtooutput(Esd,vsd,rhosd,alpha0sd,Dsd,dmsd,fesd,fisd,Frsd,Fasd,Msd,nisd,osd,o1sd,o2sd,ORsd,errosd,numberssd,zsd,Dthetat,Ddeltaat,Ddeltart, vecsdlamdat,vecsdalphaet,vecsdalphait,vecsdut,vecsdQet,vecsdQit,vecsdFct,vecsdMgt,vecsdwbt,vecsdwct,vecsdSRet,vecsdSRit);
//给charts窗口发送数据
emit sdtocharts(zsd,vecsdlamdat,vecsdalphaet,vecsdalphait,vecsdut,vecsdQet,vecsdQit,vecsdFct,vecsdMgt,vecsdwbt,vecsdwct,vecsdSRet,vecsdSRit);
//与三维图交互
sd_p0 = P0;
//给输入界面传入数据
emit MainWindowToThreeDInput(sd_p0);
//关闭sd线程
if(threadsd->isRunning()==false)
{
return;
}
threadsd->quit();
threadsd->wait();
//计算结束 使得可以查看结果
ui->actionsdoutput->setEnabled(true);
ui->actionsdchart->setEnabled(true);
//ui->actionsimudyn->setEnabled(true);
}
//按下图表按钮便打开拟动力学图表
void RBEvaluation::on_actionsdchart_triggered()
{
if(flag_simudyncharts == false) //如果没被按下
{
//标志为设置
flag_simudyncharts = true;
//如果不存在该标签页,则创建一个新的标签页
m_tabsimudynchartsdyn = new QWidget();
int currentindex = ui->tabWidgetworkingarea->addTab(m_tabsimudynchartsdyn,"拟动力学图表");
ui->tabWidgetworkingarea->setCurrentIndex(currentindex);
ui->tabWidgetworkingarea->setTabsClosable(true); //设置为可关闭的
//将图表写进来
simudyncharts->setParent(m_tabsimudynchartsdyn);
//stacharts->move ((QApplication::desktop()->width() - stacharts->width())/2,(QApplication::desktop()->height() - stacharts->height())/2);//让窗口显示在屏幕中央
//获取长和宽
qreal tabsimudynchartsdyn_width,tabsimudynchartsdyn_height;
tabsimudynchartsdyn_width = ui->tabWidgetworkingarea->geometry().width();
tabsimudynchartsdyn_height = ui->tabWidgetworkingarea->geometry().height();
//resize安排窗口,使得其能自适应填满
qreal heightratio;
heightratio = 0.95;
simudyncharts->resize(tabsimudynchartsdyn_width,tabsimudynchartsdyn_height*heightratio);
//显示在左上角
simudyncharts->move(0,0);
simudyncharts->show();
}
//如果存在,则发出警告
else if(flag_simudyncharts == true)
{
SetMessageBoxSize msgBox; //自己写了一个类,可以设置size的继承于QMessageBox的类
msgBox.AutosetSize(300,100);
msgBox.setIcon(QMessageBox::Warning); //设置类型
msgBox.setWindowTitle("警告");
msgBox.setText("拟动力学图表结果已存在");
//msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
}
//让窗口显示在屏幕中央
//simudyncharts->move ((QApplication::desktop()->width() - simudyncharts->width())/2,(QApplication::desktop()->height() - simudyncharts->height())/2);
}
//按下显示结果按钮便打开拟动力学计算结果
void RBEvaluation::on_actionsdoutput_triggered()
{
if(flag_simudynoutput == false) //如果没被按下
{
//标志为设置
flag_simudynoutput = true;
//如果不存在该标签页,则创建一个新的标签页
m_tabsimudynoutptudyn = new QWidget();
int currentindex = ui->tabWidgetworkingarea->addTab(m_tabsimudynoutptudyn,"拟动力学计算结果");
ui->tabWidgetworkingarea->setCurrentIndex(currentindex);
ui->tabWidgetworkingarea->setTabsClosable(true); //设置为可关闭的
//将图表写进来
simudynoutput->setParent(m_tabsimudynoutptudyn);
//stacharts->move ((QApplication::desktop()->width() - stacharts->width())/2,(QApplication::desktop()->height() - stacharts->height())/2);//让窗口显示在屏幕中央
//获取长和宽
qreal tabsimudynoutputdyn_width,tabsimudynoutputdyn_height;
tabsimudynoutputdyn_width = ui->tabWidgetworkingarea->geometry().width();
tabsimudynoutputdyn_height = ui->tabWidgetworkingarea->geometry().height();
//resize安排窗口,使得其能自适应填满
qreal heightratio;
heightratio = 0.95;
simudynoutput->resize(tabsimudynoutputdyn_width,tabsimudynoutputdyn_height*heightratio);
//显示在左上角
simudynoutput->move(0,0);
simudynoutput->show();
}
//如果存在,则发出警告
else if(flag_simudynoutput == true)
{
SetMessageBoxSize msgBox; //自己写了一个类,可以设置size的继承于QMessageBox的类
msgBox.AutosetSize(300,100);
msgBox.setIcon(QMessageBox::Warning); //设置类型
msgBox.setWindowTitle("警告");
msgBox.setText("拟动力学计算结果已存在");
//msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
}
//让窗口显示在屏幕中央
//simudynoutput.move ((QApplication::desktop()->width() - simudynoutput.width())/2,(QApplication::desktop()->height() - simudynoutput.height())/2);
}
////Dyn部分
//打开输入界面
void RBEvaluation::on_actiondyninput_triggered()
{
if(m_mode == 1)
{
dyninput.show();
//让窗口显示在屏幕中央
dyninput.move ((QApplication::desktop()->width() - dyninput.width())/2,(QApplication::desktop()->height() - dyninput.height())/2);
}
}
//接收到来自input的存好的数据
void RBEvaluation::dyndealinput(int zdyn, double Ddyn, double dmdyn, double alpha0dyn, double fidyn, double fedyn, double Cpdyn, double Cgdyn, double Edyn, double vdyn, double rhodyn, double Ecdyn, double vcdyn, double rhocdyn, double nidyn, double Fadyn, double Frdyn, double Mydyn, double Mzdy, double ORdyn, double T0dyn, double n0dyn, double alphadyn, double betadyn, double Kdyn,double h0dyn,double ktdyn,double Ferrdyn,double uerrdyn,double Tdyn)
{
//数据存入主界面
z_dyn = zdyn;
D_dyn = Ddyn,dm_dyn = dmdyn,alpha0_dyn=alpha0dyn,fi_dyn=fidyn,fe_dyn=fedyn,Cp_dyn=Cpdyn,Cg_dyn=Cgdyn;
E_dyn=Edyn,v_dyn=vdyn,rho_dyn=rhodyn,Ec_dyn=Ecdyn,vc_dyn=vcdyn,rhoc_dyn=rhocdyn;
ni_dyn=nidyn,Fa_dyn=Fadyn,Fr_dyn=Frdyn,My_dyn=Mydyn,Mz_dyn=Mzdy,OR_dyn=ORdyn;
T0_dyn=T0dyn,n0_dyn=n0dyn,alpha_dyn=alphadyn,beta_dyn=betadyn,K_dyn=Kdyn;
h0_dyn=h0dyn,kt_dyn=ktdyn,Ferr_dyn=Ferrdyn,uerr_dyn=uerrdyn,T_dyn=Tdyn;
//TreeWidget
//那边点了应用,这边就ka开始画TreeWidget
ui->treeWidget->clear(); //清空以前的东西
ui->treeWidget->setColumnCount(1); //设置列数
//设置str编码类型
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));
ui->treeWidget->setHeaderLabel(tr("动力学计算输入参数")); //设置标题
QList<QTreeWidgetItem *> items;
//创建两个节点
QTreeWidgetItem *father_Item_1 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("工况条件")));
QTreeWidgetItem *father_Item_2 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("结构参数")));
QTreeWidgetItem *father_Item_3 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("材料参数")));
QTreeWidgetItem *father_Item_4 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("润滑剂/摩擦相关参数")));
QTreeWidgetItem *father_Item_5 = new QTreeWidgetItem(ui->treeWidget,QStringList(QString("数值计算相关参数")));
items.append(father_Item_1);
items.append(father_Item_2);
items.append(father_Item_3);
items.append(father_Item_4);
items.append(father_Item_5);
//添加顶层节点
ui->treeWidget->insertTopLevelItems(0,items);
//添加子节点_1
QTreeWidgetItem *Child_Item_Fr = new QTreeWidgetItem(father_Item_1,QStringList(QString("径向载荷(Fr)")));
QTreeWidgetItem *Child_Item_Fa = new QTreeWidgetItem(father_Item_1,QStringList(QString("轴向载荷(Fa)")));
QTreeWidgetItem *Child_Item_My = new QTreeWidgetItem(father_Item_1,QStringList(QString("力矩载荷(My)")));
QTreeWidgetItem *Child_Item_Mz = new QTreeWidgetItem(father_Item_1,QStringList(QString("力矩载荷(Mz)")));
QTreeWidgetItem *Child_Item_ni = new QTreeWidgetItem(father_Item_1,QStringList(QString("轴承转速(ni)")));
QTreeWidgetItem *Child_Item_OR = new QTreeWidgetItem(father_Item_1,QStringList(QString("保持架引导方式(OR)")));
father_Item_1->addChild(Child_Item_ni);
father_Item_1->addChild(Child_Item_Fa);
father_Item_1->addChild(Child_Item_Fr);
father_Item_1->addChild(Child_Item_My);
father_Item_1->addChild(Child_Item_Mz);
father_Item_1->addChild(Child_Item_OR);
//添加子节点_2
QTreeWidgetItem *Child_Item_Z = new QTreeWidgetItem(father_Item_2,QStringList(QString("钢球个数(Z)")));
QTreeWidgetItem *Child_Item_D = new QTreeWidgetItem(father_Item_2,QStringList(QString("钢球直径(D)")));
QTreeWidgetItem *Child_Item_dm = new QTreeWidgetItem(father_Item_2,QStringList(QString("内圈直径(dm)")));
QTreeWidgetItem *Child_Item_alpha0 = new QTreeWidgetItem(father_Item_2,QStringList(QString("初始接触角")));
QTreeWidgetItem *Child_Item_fi = new QTreeWidgetItem(father_Item_2,QStringList(QString("内圈沟渠率半径系数")));
QTreeWidgetItem *Child_Item_fe = new QTreeWidgetItem(father_Item_2,QStringList(QString("外圈沟渠率半径系数")));
QTreeWidgetItem *Child_Item_Cp = new QTreeWidgetItem(father_Item_2,QStringList(QString("保持架兜孔间隙")));
QTreeWidgetItem *Child_Item_Cg = new QTreeWidgetItem(father_Item_2,QStringList(QString("保持架引导间隙")));
father_Item_2->addChild(Child_Item_Z);
father_Item_2->addChild(Child_Item_D);
father_Item_2->addChild(Child_Item_dm);
father_Item_2->addChild(Child_Item_alpha0);
father_Item_2->addChild(Child_Item_fi);
father_Item_2->addChild(Child_Item_fe);
father_Item_2->addChild(Child_Item_Cp);
father_Item_2->addChild(Child_Item_Cg);
//添加子节点_3
//QTreeWidgetItem *Child_Item_rb = new QTreeWidgetItem(father_Item_3,QStringList(QString("滚动体/内外圆")));
//QTreeWidgetItem *Child_Item_holder = new QTreeWidgetItem(father_Item_3,QStringList(QString("保持架")));
QTreeWidgetItem *Child_Item_rho = new QTreeWidgetItem(father_Item_3,QStringList(QString("滚动体材料密度")));
QTreeWidgetItem *Child_Item_E = new QTreeWidgetItem(father_Item_3,QStringList(QString("滚动体弹性模量")));
QTreeWidgetItem *Child_Item_v = new QTreeWidgetItem(father_Item_3,QStringList(QString("滚动体泊松比")));
QTreeWidgetItem *Child_Item_rhoc = new QTreeWidgetItem(father_Item_3,QStringList(QString("保持架材料密度")));
QTreeWidgetItem *Child_Item_Ec = new QTreeWidgetItem(father_Item_3,QStringList(QString("保持架弹性模量")));
QTreeWidgetItem *Child_Item_vc = new QTreeWidgetItem(father_Item_3,QStringList(QString("保持架泊松比")));
//father_Item_3->addChild(Child_Item_rb);
father_Item_3->addChild(Child_Item_E);
father_Item_3->addChild(Child_Item_v);
father_Item_3->addChild(Child_Item_rho);
//father_Item_3->addChild(Child_Item_holder);
father_Item_3->addChild(Child_Item_Ec);
father_Item_3->addChild(Child_Item_vc);
father_Item_3->addChild(Child_Item_rhoc);
//添加子节点_4
QTreeWidgetItem *Child_Item_T0 = new QTreeWidgetItem(father_Item_4,QStringList(QString("环境温度(T0)")));
QTreeWidgetItem *Child_Item_n0 = new QTreeWidgetItem(father_Item_4,QStringList(QString("润滑油粘度(η0)")));
QTreeWidgetItem *Child_Item_alpha = new QTreeWidgetItem(father_Item_4,QStringList(QString("润滑油黏压系数(α)")));
QTreeWidgetItem *Child_Item_beta = new QTreeWidgetItem(father_Item_4,QStringList(QString("润滑油黏温系数(β)")));
QTreeWidgetItem *Child_Item_K = new QTreeWidgetItem(father_Item_4,QStringList(QString("润滑油热传导系数(K)")));
father_Item_4->addChild(Child_Item_T0);
father_Item_4->addChild(Child_Item_n0);
father_Item_4->addChild(Child_Item_alpha);
father_Item_4->addChild(Child_Item_beta);
father_Item_4->addChild(Child_Item_K);
//添加子节点_5
QTreeWidgetItem *Child_Item_h0 = new QTreeWidgetItem(father_Item_5,QStringList(QString("初始步长(h0)")));
QTreeWidgetItem *Child_Item_kt = new QTreeWidgetItem(father_Item_5,QStringList(QString("步长修正系数(kt)")));
QTreeWidgetItem *Child_Item_Ferr = new QTreeWidgetItem(father_Item_5,QStringList(QString("力残差(Ferr)")));
QTreeWidgetItem *Child_Item_Uerr = new QTreeWidgetItem(father_Item_5,QStringList(QString("位移残差(Uerr)")));
QTreeWidgetItem *Child_Item_T = new QTreeWidgetItem(father_Item_5,QStringList(QString("动力学分析时间(T)")));
father_Item_5->addChild(Child_Item_h0);
father_Item_5->addChild(Child_Item_kt);
father_Item_5->addChild(Child_Item_Ferr);
father_Item_5->addChild(Child_Item_Uerr);
father_Item_5->addChild(Child_Item_T);
ui->treeWidget->expandAll();
m_sta_simudyn_status = 3; //置3表示当前是动力学分析
}
////公共部分
//关闭窗口终止线程
void RBEvaluation::dealdestroyed()
{
//if(threadsta->isRunning()==false)
//{
// return;
//}
//threadsta->quit();
//threadsta->wait();
if(threadsd->isRunning()==false)
{
return;
}
threadsd->quit();
threadsd->wait();
}
//接收来自欢迎界面的信号
void RBEvaluation::dealWelcometoMain(int mode_rb)
{
//this->show();
m_mode = mode_rb;
QString str_pixmap;
switch(m_mode)
{
case 1:str_pixmap ="rbpixmap.png" ;break;
case 2:str_pixmap ="tbpixmap.png" ;break;
case 3:str_pixmap ="cbpixmap.png" ;break;
default:break;
}
QPixmap *pixmap = new QPixmap(str_pixmap);
pixmap->scaled(ui->labelpixmap->size(), Qt::KeepAspectRatio);
ui->labelpixmap->setScaledContents(true);
ui->labelpixmap->setPixmap(*pixmap);
}
//测试打开QFileDialog,负责查看角接触球轴承计算数据
void RBEvaluation::on_actionstadata_1_triggered()
{
QString dataopenfile_name = QFileDialog::getOpenFileName(this,"数据文件",".","文本文档(*.txt);;WORD文档(*.doc *.docx);;EXCEL文档(*.xls *.xlsx *.csv);;ALL(*.*)");
if(!dataopenfile_name.isEmpty())
{
//读取qstring最后四位或者五位
//判断打开的对象是不是txt文件,调用notepad打开
if(dataopenfile_name.right(4) == ".txt")
{
//QProcess *txtprocess = new QProcess();
//QString notepadpath = "notepad.exe " + dataopenfile_name; //草了我太牛逼了,试了一下 + 就成功了
//txtprocess->start(notepadpath);
//这个直接调用windows启动更加方便
QDesktopServices::openUrl(QUrl::fromLocalFile(dataopenfile_name));
}
//判断打开的对象是不是xls,调用.excel打开
else if(dataopenfile_name.right(4) == ".xls" || dataopenfile_name.right(5) ==".xlsx"|| dataopenfile_name.right(4) ==".csv")
{
QDesktopServices::openUrl(QUrl::fromLocalFile(dataopenfile_name));
}
//判断格式,调用word打开word文档
else if(dataopenfile_name.right(4) == ".doc" || dataopenfile_name.right(5) ==".docx")
{
QDesktopServices::openUrl(QUrl::fromLocalFile(dataopenfile_name));
}
}
}
//打开图表图片文档
void RBEvaluation::on_actioncharts_triggered()
{
QString chartsopenfile_name = QFileDialog::getOpenFileName(this,"图表图片",".","图片(*.png *.jpg)");
QDesktopServices::openUrl(QUrl::fromLocalFile(chartsopenfile_name));
}
//专业画表头
void RBEvaluation::creattablewidgetheaders(QString title,double data,QString unit)
{
//QTableWidget 表格创建
//设置为不可编辑状态
ui->tableWidgetmainwindow->setEditTriggers(QAbstractItemView::NoEditTriggers);
//规范行列数
ui->tableWidgetmainwindow->setColumnCount(3);
ui->tableWidgetmainwindow->setRowCount(1); //暂时只显示一行
//设置可见情况
ui->tableWidgetmainwindow->verticalHeader()->setVisible(false);
ui->tableWidgetmainwindow->horizontalHeader()->setVisible(true);
//第一个表头
QTableWidgetItem *item0 = new QTableWidgetItem();
item0->setText("变量名称(常用符号)");
item0->setTextAlignment(Qt::AlignRight |Qt::AlignVCenter);
ui->tableWidgetmainwindow->setHorizontalHeaderItem(0,item0);
//第二个水平表头
QTableWidgetItem *item1 = new QTableWidgetItem();
item1->setText("值");
item1->setTextAlignment(Qt::AlignRight |Qt::AlignVCenter);
ui->tableWidgetmainwindow->setHorizontalHeaderItem(1,item1);
//第三个水平表头
QTableWidgetItem *item2 = new QTableWidgetItem();
item2->setText("单位");
item2->setTextAlignment(Qt::AlignLeft |Qt::AlignVCenter);
ui->tableWidgetmainwindow->setHorizontalHeaderItem(2,item2);
//列宽设置
ui->tableWidgetmainwindow->setColumnWidth(0,200);
ui->tableWidgetmainwindow->setColumnWidth(1,100);
ui->tableWidgetmainwindow->setColumnWidth(2,100);
//第一列