📄 radafdtdgui.ui.h
字号:
/****************************************************************************** ui.h extension file, included from the uic-generated form implementation.**** If you wish to add, delete or rename functions or slots use** Qt Designer which will update this file, preserving your code. Create an** init() function in place of a constructor, and a destroy() function in** place of a destructor.*****************************************************************************/#define SQR(x) ((x)*(x))void MainWindowForm::fileNew(){ }void MainWindowForm::fileOpen(){ if (m_not_saved) { int ans = QMessageBox::warning( this, "radarFDTD GUI", "Current information is not saved.\n" "Exit without save will cause loss of information !\n" "Are tou sure ?\n\n", "Cancel", "Open", 0, 0, 1 ); if (ans == 0) return; } m_file_name = QFileDialog::getOpenFileName(QString::null, "radarFDTD Config (*.cfg)", this,"open file dialog" "Choose a file" ); if (m_file_name == "") return; // Clear containers m_rcv.clear(); m_xmt.clear(); m_object.clear(); m_material.clear(); // Clear tables for (int i=0; i<rcvTable->numRows(); i++) rcvTable->removeRow(i); for (int i=0; i<xmtTable->numRows(); i++) xmtTable->removeRow(i); for (int i=0; i<objectTable->numRows(); i++) objectTable->removeRow(i); for (int i=2; i<materialTable->numRows(); i++) materialTable->removeRow(i); // Add back the default materials material_t mt; QColor color(0,0,0); mt.name = "Air"; mt.viewColor = color; mt.eps = 1.0; mt.sigma = 0.0; m_material.push_back(mt); materialTable->setText(0,0,"Air"); materialTable->setText(0,1,"1.0"); materialTable->setText(0,2,"0.0"); color.setRgb(255,0,0); mt.name = "Perfect Conductor"; mt.viewColor = color; mt.eps = 1.0; mt.sigma = 1.0e33; m_material.push_back(mt); materialTable->setText(1,0,"Perfect Conductor"); materialTable->setText(1,1,"1.0"); materialTable->setText(1,2,"Inifinity"); // Read the data from file readSimCfg(m_file_name); m_not_saved = false; m_geometry_changed = true; m_xmt_changed = true; m_rcv_changed = true;}void MainWindowForm::fileSave(){ if (m_file_name == "") { fileSaveAs(); } else { writeSimCfg(m_file_name); m_not_saved = false; }}void MainWindowForm::fileSaveAs(){ m_file_name = QFileDialog::getSaveFileName(QString::null, "radarFDTD Config (*.cfg)", this,"open file dialog" "Choose a file" ); if (m_file_name == "") return; writeSimCfg(m_file_name); QString caption = "radarFDTD GUI [ " + m_file_name + " ]"; this->setCaption(caption); m_not_saved = false;}void MainWindowForm::filePrint(){ }void MainWindowForm::fileExit(){ if (m_not_saved) { int ans = QMessageBox::warning( this, "radarFDTD GUI", "Current information is not saved.\n" "Exit without save will cause loss of information !\n" "Are tou sure ?\n\n", "Cancel", "Exit", 0, 0, 1 ); if (ans == 0) return; } qApp->quit();}void MainWindowForm::editUndo(){ }void MainWindowForm::editRedo(){ }void MainWindowForm::editCut(){ }void MainWindowForm::editCopy(){ }void MainWindowForm::editPaste(){ }void MainWindowForm::editFind(){ }void MainWindowForm::helpIndex(){ }void MainWindowForm::helpContents(){ }//// Implement base class virtual function.// Prevent destructive window closing when data// isn't saved.//void MainWindowForm::closeEvent( QCloseEvent * ce ){ if (m_not_saved) { int ans = QMessageBox::warning( this, "radarFDTD GUI", "Current information is not saved.\n" "Exit without save will cause loss of information !\n" "Are tou sure ?\n\n", "Cancel", "Exit", 0, 0, 1 ); if (ans == 0) return; } ce->accept();}void MainWindowForm::helpAbout(){ QMessageBox::about( this, "About radarFDTD GUI", "Version: 0.9\n" "Copyright (C) 2004 to Ron Daisy.\n" "All Rights reserved.\n\n" "For bugs, comments, and suggestions,\n" "contact: rdaisy@netvision.net.il.\n"); }void MainWindowForm::addObjectSlot(){ QString objectType = objectTypeComboBox->currentText(); if (objectType == "Box") { if (m_addBoxForm == NULL) { delete m_addBoxForm; m_addBoxForm = NULL; } m_addBoxForm = new AddBoxForm(this); connect(this,SIGNAL(sendMaxMaterialIndx(int)), m_addBoxForm,SLOT(takeMaxMaterialIndx(int))); connect(m_addBoxForm,SIGNAL(NewItem(QString,int,int,int,int,int,int,int)), this,SLOT(takeNewBoxItem(QString,int,int,int,int,int,int,int))); connect(m_addBoxForm,SIGNAL(Cancel()), this,SLOT(addBoxItemCancel())); emit sendMaxMaterialIndx((int)m_material.size()); m_addBoxForm->show(); } else if (objectType == "Cylinder") { if (m_addCylinderForm == NULL) { delete m_addCylinderForm; m_addCylinderForm = NULL; } m_addCylinderForm = new AddCylinderForm(this); connect(this,SIGNAL(sendMaxMaterialIndx(int)), m_addCylinderForm,SLOT(takeMaxMaterialIndx(int))); connect(m_addCylinderForm, SIGNAL(NewItem(QString,int,int,int,int,float,float,float,float)), this,SLOT(takeNewCylinderItem(QString,int,int,int,int,float,float,float,float))); connect(m_addCylinderForm,SIGNAL(Cancel()), this,SLOT(addCylinderItemCancel())); emit sendMaxMaterialIndx((int)m_material.size()); m_addCylinderForm->show(); } else if (objectType == "Sphere") { if (m_addSphereForm == NULL) { delete m_addSphereForm; m_addSphereForm = NULL; } m_addSphereForm = new AddSphereForm(this); connect(this,SIGNAL(sendMaxMaterialIndx(int)), m_addSphereForm,SLOT(takeMaxMaterialIndx(int))); connect(m_addSphereForm,SIGNAL(NewItem(QString,int,int,int,int,float)), this,SLOT(takeNewSphereItem(QString,int,int,int,int,float))); connect(m_addSphereForm,SIGNAL(Cancel()), this,SLOT(addSphereItemCancel())); emit sendMaxMaterialIndx((int)m_material.size()); m_addSphereForm->show(); } else { fprintf(stderr,"Internal Error !! Bad Object type !!\n"); }}void MainWindowForm::addMeterialSlot(){ if (m_addMaterialForm == NULL) { delete m_addMaterialForm; m_addMaterialForm = NULL; } m_addMaterialForm = new AddMaterialForm(this); connect(m_addMaterialForm,SIGNAL(NewMaterial(QString,float,float,QColor)), this,SLOT(takeNewMaterial(QString,float,float,QColor))); connect(m_addMaterialForm,SIGNAL(Cancel()),this,SLOT(addMaterialCancel())); m_addMaterialForm->show();}void MainWindowForm::xmtModeConfigSlot(){ QString mode = xmtModeCombo->currentText(); if (mode == "Sine") { if (m_sineModeConfigForm != NULL) { delete m_sineModeConfigForm; m_sineModeConfigForm = NULL; } m_sineModeConfigForm = new sineModeConfigForm(this); connect(m_sineModeConfigForm,SIGNAL(NewModeParams(float,float,float)), this,SLOT(takeNewSineModeParamsSlot(float,float,float))); connect(m_sineModeConfigForm,SIGNAL(Cancel()),this,SLOT(SineModeCfgCancelSlot())); m_sineModeConfigForm->show(); } else if (mode == "Sine square") { if (m_sineSquareModeConfigForm != NULL) { delete m_sineSquareModeConfigForm; m_sineSquareModeConfigForm = NULL; } m_sineSquareModeConfigForm = new SineSquareModeConfigForm(this); connect(m_sineSquareModeConfigForm,SIGNAL(NewModeParams(float,float,float,int)), this,SLOT(takeNewSineSquareModeParamsSlot(float,float,float,int))); connect(m_sineSquareModeConfigForm,SIGNAL(Cancel()),this,SLOT(SineSquareModeCfgCancelSlot())); m_sineSquareModeConfigForm->show(); } else if (mode == "Gaussian pulse") { if (m_gaussianPulseConfigForm != NULL) { delete m_gaussianPulseConfigForm; m_gaussianPulseConfigForm = NULL; } m_gaussianPulseConfigForm = new GaussianPulseConfigForm(this); connect(m_gaussianPulseConfigForm,SIGNAL(NewModeParams(float,float,float)), this,SLOT(takeNewGaussianPulseModeParamsSlot(float,float,float))); connect(m_gaussianPulseConfigForm,SIGNAL(Cancel()),this,SLOT(GaussianPulseModeCfgCancelSlot())); m_gaussianPulseConfigForm->show(); } else if (mode == "RT Radar pulse") { if (m_radarPulseConfigForm != NULL) { delete m_radarPulseConfigForm; m_radarPulseConfigForm = NULL; } m_radarPulseConfigForm = new RadarPulseConfigForm(this); connect(m_radarPulseConfigForm,SIGNAL(NewModeParams(float,float,int,float)), this,SLOT(takeNewRadarPulseModeParamsSlot(float,float,int,float))); connect(m_radarPulseConfigForm,SIGNAL(Cancel()),this,SLOT(RadarPulseModeCfgCancelSlot())); m_radarPulseConfigForm->show(); } else { fprintf(stderr,"Internal Error - Bad XMT mode !\n"); }}void MainWindowForm::init(){ QString s; m_sim_length = 30e-9; s.sprintf("%10.2e",m_sim_length); simulationLength->setText(s); m_time_step = 20.0e-12; s.sprintf("%10.2e",m_time_step); timeStep->setText(s); m_max_memory = 400000000; s.sprintf("%ld",m_max_memory); maxMemory->setText(s); m_pml_nof_layers = 8; s.sprintf("%d",m_pml_nof_layers); pmlNofLayers->setText(s); m_pml_max_cond = 0.025; s.sprintf("%f",m_pml_max_cond); pmlMaxCond->setText(s); m_pml_max_stretching = 4.0; s.sprintf("%f",m_pml_max_stretching); pmlStretching->setText(s); m_pml_steepness = 2.0; s.sprintf("%f",m_pml_steepness); pmlSteepness->setText(s); m_space_size_x = 50; s.sprintf("%d",m_space_size_x); Lx->setText(s); m_space_size_y = 50; s.sprintf("%d",m_space_size_y); Ly->setText(s); m_space_size_z = 50; s.sprintf("%d",m_space_size_z); Lz->setText(s); m_cell_size_x = 0.02; s.sprintf("%f",m_cell_size_x); DX->setText(s); m_cell_size_y = 0.02; s.sprintf("%f",m_cell_size_y); DY->setText(s); m_cell_size_z = 0.02; s.sprintf("%f",m_cell_size_z); DZ->setText(s); m_rcv_skip = 1; s.sprintf("%d",m_rcv_skip); rcvSkipLineEdit->setText(s); m_snap_shot_skip = 20; s.sprintf("%d",m_snap_shot_skip); snapShotSkipLineEdit->setText(s); m_snap_shot_plan = 1; snapShotPlaneComboBox->setCurrentItem(0); m_snap_shot_height = 20; s.sprintf("%d",m_snap_shot_height); snapShotHeightLineEdit->setText(s); m_snap_shot_component = 7; snapShotComponentComboBox->setCurrentItem(m_snap_shot_component); material_t mt; QColor color(0,0,0); mt.name = "Air"; mt.viewColor = color; mt.eps = 1.0; mt.sigma = 0.0; m_material.push_back(mt); materialTable->setText(0,0,"Air"); materialTable->setText(0,1,"1.0"); materialTable->setText(0,2,"0.0"); QRect rect = materialTable->cellRect(0,3); QPixmap p1(rect.width(),rect.height()); p1.fill(color); materialTable->setPixmap(0,3,p1); color.setRgb(255,0,0); mt.name = "Perfect Conductor"; mt.viewColor = color; mt.eps = 1.0; mt.sigma = 1.0e33; m_material.push_back(mt); materialTable->setText(1,0,"Perfect Conductor"); materialTable->setText(1,1,"1.0"); materialTable->setText(1,2,"Inifinity"); rect = materialTable->cellRect(1,3); QPixmap p2(rect.width(),rect.height()); p2.fill(color); materialTable->setPixmap(1,3,p2); oglViewer->updateMaterialColorTable(m_material); objectTable->setColumnWidth(1,70); m_xmt_mode = 0; m_xmt_amp = 1000.0; m_xmt_p1 = 1.0e-9; m_xmt_p2 = 100.0e6; m_xmt_p3 = 3.0; m_xmt_component = 0; m_addBoxForm = NULL; m_addMaterialForm = NULL; m_sineModeConfigForm = NULL; m_sineSquareModeConfigForm = NULL; m_gaussianPulseConfigForm = NULL; m_radarPulseConfigForm = NULL; m_addSphereForm = NULL; m_addCylinderForm = NULL; m_addXmtForm = NULL; m_addRcvForm = NULL; m_popup = NULL; m_file_name = ""; m_not_saved = false; m_geometry_changed = false; m_xmt_changed = false; m_rcv_changed = false; oglViewer->takeGeometry(m_object,m_space_size_x,m_space_size_y, m_space_size_z); oglViewer->refresh();}void MainWindowForm::writeSimCfg( QString & fileName ){ FILE *fp; fp = fopen(fileName.ascii(),"w"); if (fp == NULL) { return; } // Before writing take the current information from the GUI updateData(); fprintf(fp,"# CFG file generated by radarFDTDGUI\n"); QDate date(QDate::currentDate()); fprintf(fp,"# Date: %s\n",date.toString().ascii()); fprintf(fp,"# version\n"); fprintf(fp,"3\n"); fprintf(fp,"# maximum nuber of bytes the program may allocate\n"); fprintf(fp,"%ld\n",m_max_memory); fprintf(fp,"# maximum pml conductivity here [S/m]\n"); fprintf(fp,"%e\n",m_pml_max_cond); fprintf(fp,"# maximum pml-stretching here [1]\n"); fprintf(fp,"%e\n",m_pml_max_stretching); fprintf(fp,"# PML steepness\n"); fprintf(fp,"%e\n",m_pml_steepness); fprintf(fp,"# Length of Simulation [s]\n"); fprintf(fp,"%e\n",m_sim_length); fprintf(fp,"# Size of simulation space\n"); fprintf(fp,"%d %d %d\n",m_space_size_x,m_space_size_y,m_space_size_z); fprintf(fp,"# Real size of a Box [m] (x,y,z)\n"); fprintf(fp,"%e %e %e\n",m_cell_size_x,m_cell_size_y,m_cell_size_z); fprintf(fp,"# Simulation time step size\n"); fprintf(fp,"%e\n",m_time_step); fprintf(fp,"# Receiver data should be stored every x steps..\n"); fprintf(fp,"%d\n",m_rcv_skip); fprintf(fp,"# Snapshot\n"); fprintf(fp,"%d %d %d %d\n", m_snap_shot_skip,m_snap_shot_plan, m_snap_shot_height,m_snap_shot_component); fprintf(fp,"# Number of PML layers\n"); fprintf(fp,"%d\n",m_pml_nof_layers); fprintf(fp,"# Number of materials (over the Vaccum and perfect conductor)\n"); fprintf(fp,"%d\n",m_material.size()-2); for (unsigned int i=2; i<m_material.size(); i++) { fprintf(fp,"##MAT## %s %d %d %d\n", m_material[i].name.ascii(), m_material[i].viewColor.red(), m_material[i].viewColor.green(), m_material[i].viewColor.blue()); fprintf(fp,"%e %g\n",m_material[i].eps,m_material[i].sigma); } fprintf(fp,"# Number of material boxes\n"); int nof_boxes=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -