| 
									
										
										
										
											2025-04-27 10:05:00 +08:00
										 |  |  | #include "pointname.h"
 | 
					
						
							|  |  |  | #include "ui_pointname.h"
 | 
					
						
							|  |  |  | #include "config_mgr.h"
 | 
					
						
							|  |  |  | #include "vibrationdata.h"
 | 
					
						
							| 
									
										
										
										
											2025-07-10 15:23:58 +08:00
										 |  |  | #include "tachometer_data.h"
 | 
					
						
							| 
									
										
										
										
											2025-08-15 14:40:25 +08:00
										 |  |  | #include "keyphase_data.h"
 | 
					
						
							| 
									
										
										
										
											2025-04-27 10:05:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | PointName::PointName(int slot_no_,int cardtype,QWidget *parent) : | 
					
						
							|  |  |  |     QWidget(parent), | 
					
						
							|  |  |  |     ui(new Ui::PointName) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->setupUi(this); | 
					
						
							|  |  |  |     slot_no = slot_no_; | 
					
						
							|  |  |  |     car_type = static_cast<CardType>(cardtype); | 
					
						
							|  |  |  |     ui->label_slot->setText(QString::number(slot_no)); | 
					
						
							|  |  |  |     Init(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PointName::~PointName() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PointName::Init() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); | 
					
						
							|  |  |  |     if (base_ptr == nullptr) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-07-10 15:23:58 +08:00
										 |  |  |     if(base_ptr->card_type_ == kCardVibSingle){ | 
					
						
							|  |  |  |         std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr); | 
					
						
							| 
									
										
										
										
											2025-04-27 10:05:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-10 15:23:58 +08:00
										 |  |  |         ui->lineEdit_pointname_1->setText(vib_data->base_config_[0].point_name); | 
					
						
							|  |  |  |         ui->lineEdit_pointname_2->setText(vib_data->base_config_[1].point_name); | 
					
						
							|  |  |  |         ui->lineEdit_pointname_3->setText(vib_data->base_config_[2].point_name); | 
					
						
							|  |  |  |         ui->lineEdit_pointname_4->setText(vib_data->base_config_[3].point_name); | 
					
						
							|  |  |  |     }else if(base_ptr->card_type_ == kCardSpeedSingle){ | 
					
						
							|  |  |  |         std::shared_ptr<TachometerData> tac_data = std::dynamic_pointer_cast<TachometerData>(base_ptr); | 
					
						
							|  |  |  |         ui->lineEdit_pointname_1->setText(tac_data->variables_[0].point_name); | 
					
						
							|  |  |  |         ui->lineEdit_pointname_2->setText(tac_data->variables_[1].point_name); | 
					
						
							|  |  |  |         ui->lineEdit_pointname_3->setText(tac_data->variables_[2].point_name); | 
					
						
							|  |  |  |         ui->lineEdit_pointname_4->setText(tac_data->variables_[3].point_name); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-04-27 10:05:00 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PointName::on_pushButton_cancel_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     this->close(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void PointName::on_pushButton_confirm_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); | 
					
						
							|  |  |  |     if (base_ptr == nullptr) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-07-10 15:23:58 +08:00
										 |  |  |     if(base_ptr->card_type_ == kCardVibSingle){ | 
					
						
							|  |  |  |         std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr); | 
					
						
							|  |  |  |         vib_data->base_config_[0].point_name = ui->lineEdit_pointname_1->text(); | 
					
						
							|  |  |  |         vib_data->base_config_[1].point_name = ui->lineEdit_pointname_2->text(); | 
					
						
							|  |  |  |         vib_data->base_config_[2].point_name = ui->lineEdit_pointname_3->text(); | 
					
						
							|  |  |  |         vib_data->base_config_[3].point_name = ui->lineEdit_pointname_4->text(); | 
					
						
							|  |  |  |     }else if(base_ptr->card_type_ == kCardSpeedSingle){ | 
					
						
							|  |  |  |         std::shared_ptr<TachometerData> tac_data = std::dynamic_pointer_cast<TachometerData>(base_ptr); | 
					
						
							|  |  |  |         tac_data->variables_[0].point_name = ui->lineEdit_pointname_1->text(); | 
					
						
							|  |  |  |         tac_data->variables_[1].point_name = ui->lineEdit_pointname_2->text(); | 
					
						
							|  |  |  |         tac_data->variables_[2].point_name = ui->lineEdit_pointname_3->text(); | 
					
						
							|  |  |  |         tac_data->variables_[3].point_name = ui->lineEdit_pointname_4->text(); | 
					
						
							| 
									
										
										
										
											2025-08-15 14:40:25 +08:00
										 |  |  |     }else if(base_ptr->card_type_ == kCardKeyphaseSingle){ | 
					
						
							|  |  |  |         std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr); | 
					
						
							|  |  |  |         keyphase_data->variables_[0].point_name = ui->lineEdit_pointname_1->text(); | 
					
						
							|  |  |  |         keyphase_data->variables_[1].point_name = ui->lineEdit_pointname_2->text(); | 
					
						
							|  |  |  |         keyphase_data->variables_[2].point_name = ui->lineEdit_pointname_3->text(); | 
					
						
							|  |  |  |         keyphase_data->variables_[3].point_name = ui->lineEdit_pointname_4->text(); | 
					
						
							| 
									
										
										
										
											2025-07-10 15:23:58 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-04-27 10:05:00 +08:00
										 |  |  |     this->close(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |