📄 radafdtdgui.ui.h
字号:
}void MainWindowForm::addRcvItem(){ if (m_addRcvForm != NULL) { delete m_addRcvForm; m_addRcvForm = NULL; } m_addRcvForm = new AddRcvForm(this); connect(m_addRcvForm,SIGNAL(NewRcvItem(QString,int,int,int,int,int,int,int,int)), this,SLOT(takeNewRcvParamsSlot(QString,int,int,int,int,int,int,int,int))); connect(m_addRcvForm,SIGNAL(Cancel()),this,SLOT(AddRcvCancelSlot())); m_addRcvForm->show();}void MainWindowForm::editRcvItem(){ }void MainWindowForm::deleteRcvItem(){ if (rcvTable->numRows() == 0) // There are no receivers return; QValueList<rcv_t>::iterator it = m_rcv.at(m_currentTableItem); // Erase the receiver from the list m_rcv.remove(it); // Remove it from the table as well rcvTable->removeRow(m_currentTableItem); m_rcv_changed = true; m_not_saved = true;}void MainWindowForm::takeNewRcvParamsSlot( QString name, int x0, int y0, int z0, int x1, int y1, int z1, int comp, int skip ){ rcv_t rcv; rcv.name = name; rcv.x0 = x0; rcv.y0 = y0; rcv.z0 = z0; rcv.x1 = x1; rcv.y1 = y1; rcv.z1 = z1; rcv.component = comp; rcv.skip = skip; m_rcv.push_back(rcv); // Add it to the table rcvTable->setNumRows(rcvTable->numRows()+1); // Add row int row_num = rcvTable->numRows()-1; // last raw // Write to the last new raw rcvTable->setText(row_num,0,name); QString s; s.sprintf("(%d,%d,%d)",x0,y0,z0); rcvTable->setText(row_num,1,s); s.sprintf("(%d,%d,%d)",x1,y1,z1); rcvTable->setText(row_num,2,s); s.sprintf("%d",skip); rcvTable->setText(row_num,3,s); s = (comp == 0) ? "H-total" : (comp == 1) ? "Hx" : (comp == 2) ? "Hy" : (comp == 3) ? "Hz" : (comp == 4) ? "Ex" : (comp == 5) ? "Ey" : (comp == 6) ? "Ez" : "E-total"; rcvTable->setText(row_num,4,s); rcvTable->adjustRow(row_num); m_rcv_changed = true; m_not_saved = true;}void MainWindowForm::AddRcvCancelSlot(){ delete m_addRcvForm; m_addRcvForm = NULL; }void MainWindowForm::handleObjectTableClickSlot( int row, int, int button, const QPoint & ){ m_currentTableItem = row; if (button == 1) { // Left click } else if (button == 2) { // Right click if (m_popup != NULL) { delete m_popup; m_popup = NULL; } m_popup = new QPopupMenu(this,"Message Operations"); m_popup->insertItem("&Edit", this, SLOT(editObjectItem())); m_popup->insertItem("&Delete", this, SLOT(deleteObjectItem())); m_popup->exec(QCursor::pos()); } }void MainWindowForm::editObjectItem(){ }void MainWindowForm::deleteObjectItem(){ if (objectTable->numRows() == 0) // There are no objects return; QValueList<object_t>::iterator it = m_object.at(m_currentTableItem); // Erase the receiver from the list m_object.remove(it); // Remove it from the table as well objectTable->removeRow(m_currentTableItem); m_geometry_changed = true; m_not_saved = true;}static void ReadLine(FILE *file, char s[]){ fscanf (file, "%[^\n]\n", s);}static void ReadNextLine (FILE *file, char s[]) { // Read next line, which is not a comment, i.e. there is no '#' at the beginning s[0] = '#'; while ((s[0] == '#') && (!feof(file))) fscanf (file, "%[^\n]\n", s);} void MainWindowForm::readSimCfg( QString fileName ){ FILE *fp; fp = fopen(fileName.ascii(),"r"); if (fp == NULL) { QMessageBox::information( this, "radarFDTD GUI", "File Cannot be read.\n" "Access Denied !"); return; } m_file_name = fileName; char s[1000]; // Read Version line ReadNextLine(fp,s); // Memory limit ReadNextLine(fp,s); maxMemory->setText(QString(s)); // PML conductivity ReadNextLine(fp,s); pmlMaxCond->setText(QString(s)); // PML Stretching ReadNextLine(fp,s); pmlStretching->setText(QString(s)); // PML Seepness ReadNextLine(fp,s); pmlSteepness->setText(QString(s)); // Simulation length ReadNextLine(fp,s); simulationLength->setText(QString(s)); // Size of simulation space ReadNextLine(fp,s); int lx,ly,lz; sscanf(s,"%d %d %d",&lx,&ly,&lz); Lx->setText(QString::number(lx)); Ly->setText(QString::number(ly)); Lz->setText(QString::number(lz)); m_space_size_x = lx; m_space_size_y = ly; m_space_size_z = lz; oglViewer->takeGeometry(m_object,m_space_size_x,m_space_size_y, m_space_size_z); // Cell Sizes ReadNextLine(fp,s); float dx,dy,dz; sscanf(s,"%f %f %f",&dx,&dy,&dz); DX->setText(QString::number(dx)); DY->setText(QString::number(dy)); DZ->setText(QString::number(dz)); m_cell_size_x = dx; m_cell_size_y = dy; m_cell_size_z = dz; // Step size ReadNextLine(fp,s); timeStep->setText(QString(s)); // DATA STORAGE I - rcv dump skip ReadNextLine(fp,s); rcvSkipLineEdit->setText(QString(s)); // DATA STORAGE II - snap shot ReadNextLine(fp,s); int skp,p,pos,comp; sscanf(s,"%d %d %d %d",&skp,&p,&pos,&comp); snapShotSkipLineEdit->setText(QString::number(skp)); snapShotPlaneComboBox->setCurrentItem(p-1); snapShotHeightLineEdit->setText(QString::number(pos)); snapShotComponentComboBox->setCurrentItem(comp); // Number of PML layers ReadNextLine(fp,s); pmlNofLayers->setText(QString(s)); // Number of Materials ReadNextLine(fp,s); int nofMaterials; material_t mat; mat.name = ""; sscanf(s,"%d",&nofMaterials); for (int i=0; i<nofMaterials; i++) { ReadLine(fp,s); QString ll(s); if (ll.left(7) == "##MAT##") { // gui format QStringList l = QStringList::split(" ",ll); if (l.size() < 5) { fprintf(stderr,"Bad cfg file format [material]\n"); } // In case when the material name not a single word mat.name = l[1]; // The last 3 numbers are the color RGBs for (int kk=2; kk<((int)l.size()-3); kk++) { mat.name = mat.name + " " + l[kk]; } mat.viewColor.setRgb(l[l.size()-3].toInt(),l[l.size()-2].toInt(),l[l.size()-1].toInt()); ReadNextLine(fp,s); } else { mat.name = "-"; // Set a random color mat.viewColor.setRgb(100+rand()%156,100+rand()%156,100+rand()%156); if (ll[0] == '#') ReadNextLine(fp,s); } sscanf(s,"%f %f",&(mat.eps),&(mat.sigma)); m_material.push_back(mat); // Add materials to their table materialTable->setNumRows(materialTable->numRows()+1); // Add row int row_num = materialTable->numRows()-1; // last raw // Write to the last new raw materialTable->setText(row_num,0,mat.name); materialTable->setText(row_num,1,QString::number(mat.eps)); materialTable->setText(row_num,2,QString::number(mat.sigma)); QRect rect = materialTable->cellRect(row_num,3); QPixmap pix(rect.width(),rect.height()); pix.fill(mat.viewColor); materialTable->setPixmap(row_num,3,pix); materialTable->adjustRow(row_num); QHeader *headers = materialTable->verticalHeader(); headers->setLabel(headers->count()-1,QString::number(m_material.size()-1)); } oglViewer->updateMaterialColorTable(m_material); // Material Objects ReadNextLine(fp,s); int nofBoxes; sscanf(s,"%d",&nofBoxes); int nofReadBoxes = 0; object_t obj; // Clear the object table in case when we read a file // after we add objects before int nR = objectTable->numRows(); for (int i=0; i<nR; i++) objectTable->removeRow(objectTable->numRows()-1); m_object.clear(); m_geometry_changed = true; while (nofReadBoxes < nofBoxes) { // Read remark with object information // Available only if saved by the GUI application ReadLine(fp,s); QString name,type; int nBox; QString ll(s); //printf("Line: %s\n",ll.ascii()); if (ll.left(7) != "##OBJ##") { // non gui format for (int i=0; i<nofBoxes; i++) { ReadNextLine(fp,s); } break; // Get out of here } else { //printf("Next object\n"); // The format: "##OBJ## %d %s %s\n" QStringList l = QStringList::split(" ",ll); nBox = l[1].toInt(); //printf("nBox: %d\n",nBox); obj.type = l[l.size()-1]; obj.name = (l[2] != "-") ? l[2] : ""; // In case when object name is not a single word for (int kk=3; kk<((int)l.size()-1); kk++) { obj.name = obj.name + " " + l[kk]; } obj.boxes.clear(); box_t bx; for (int i=0; i<nBox; i++) { ReadNextLine(fp,s); sscanf(s,"%d %d %d %d %d %d %d", &bx.x0,&bx.y0,&bx.z0,&bx.x1,&bx.y1,&bx.z1,&bx.material_indx); obj.boxes.push_back(bx); nofReadBoxes++; } m_object.push_back(obj); // Add it to the objects table objectTable->setNumRows(objectTable->numRows()+1); // Add row int row_num = objectTable->numRows()-1; // last raw // Write to the last new raw objectTable->setText(row_num,0,obj.name); objectTable->setText(row_num,1,obj.type); objectTable->setText(row_num,2,QString::number(bx.material_indx)); objectTable->adjustRow(row_num); } } // Force sending the new geometry to the viewer oglViewer->takeGeometry(m_object,m_space_size_x,m_space_size_y, m_space_size_z); // Transmitter boxes ReadNextLine(fp,s); sscanf(s,"%d",&nofBoxes); xmt_t xmt; xmt.name = ""; nR = xmtTable->numRows(); for (int i=0; i<nR; i++) xmtTable->removeRow(xmtTable->numRows()-1); m_xmt.clear(); for (int i=0; i<nofBoxes; i++) { ReadNextLine(fp,s); sscanf(s,"%d %d %d %d %d %d %d",&xmt.x0,&xmt.y0,&xmt.z0,&xmt.x1,&xmt.y1,&xmt.z1,&xmt.skip); m_xmt.push_back(xmt); // Add it to the table xmtTable->setNumRows(xmtTable->numRows()+1); // Add row int row_num = xmtTable->numRows()-1; // last raw // Write to the last new raw xmtTable->setText(row_num,0,xmt.name); QString ss; ss.sprintf("(%d,%d,%d)",xmt.x0,xmt.y0,xmt.z0); xmtTable->setText(row_num,1,ss); ss.sprintf("(%d,%d,%d)",xmt.x1,xmt.y1,xmt.z1); xmtTable->setText(row_num,2,ss); ss.sprintf("%d",xmt.skip); xmtTable->setText(row_num,3,ss); xmtTable->adjustRow(row_num); } // Transmision mode ReadNextLine(fp,s); sscanf(s,"%d %f %f %f %f %d",&m_xmt_mode,&m_xmt_amp,&m_xmt_p1,&m_xmt_p2,&m_xmt_p3,&m_xmt_component); xmtModeCombo->setCurrentItem(m_xmt_mode); xmtPolCombo->setCurrentItem(m_xmt_component); oglViewer->takeXMTs(m_xmt,m_xmt_component); // Number of receivers ReadNextLine(fp,s); int nofRcv; sscanf(s,"%d",&nofRcv); rcv_t rcv; rcv.name = ""; nR = rcvTable->numRows(); for (int i=0; i<nR; i++) rcvTable->removeRow(rcvTable->numRows()-1); m_rcv.clear(); for (int i=0; i<nofRcv; i++) { ReadNextLine(fp,s); sscanf(s,"%d %d %d %d %d %d %d %d", &rcv.x0,&rcv.y0,&rcv.z0,&rcv.x1,&rcv.y1,&rcv.z1,&rcv.component,&rcv.skip); m_rcv.push_back(rcv); // Add it to the table rcvTable->setNumRows(rcvTable->numRows()+1); // Add row int row_num = rcvTable->numRows()-1; // last raw // Write to the last new raw rcvTable->setText(row_num,0,rcv.name); QString ss; ss.sprintf("(%d,%d,%d)",rcv.x0,rcv.y0,rcv.z0); rcvTable->setText(row_num,1,ss); ss.sprintf("(%d,%d,%d)",rcv.x1,rcv.y1,rcv.z1); rcvTable->setText(row_num,2,ss); ss.sprintf("%d",rcv.skip); rcvTable->setText(row_num,3,ss); ss = (rcv.component == 0) ? "H-total" : (rcv.component == 1) ? "Hx" : (rcv.component == 2) ? "Hy" : (rcv.component == 3) ? "Hz" : (rcv.component == 4) ? "Ex" : (rcv.component == 5) ? "Ey" : (rcv.component == 6) ? "Ez" : "E-total"; rcvTable->setText(row_num,4,ss); rcvTable->adjustRow(row_num); } oglViewer->takeRCVs(m_rcv); oglViewer->refresh(); fclose(fp); // Change window caption to the read file name QString caption = "radarFDTD GUI [ " + m_file_name + " ]"; this->setCaption(caption);}void MainWindowForm::handleTabChange(){ if (tabWidget->currentPageIndex() == 3) { if (m_geometry_changed) { oglViewer->takeGeometry(m_object,m_space_size_x,m_space_size_y, m_space_size_z); m_geometry_changed = false; } if (m_xmt_changed) { oglViewer->takeXMTs(m_xmt,m_xmt_component); m_xmt_changed = false; } if (m_rcv_changed) { oglViewer->takeRCVs(m_rcv); m_rcv_changed = false; } oglViewer->refresh(); }}void MainWindowForm::xmtPolComboChanged( int ){ m_xmt_changed = true; m_xmt_component = (xmtPolCombo->currentText() == "X") ? 0 : ((xmtPolCombo->currentText() == "Y") ? 1 : 2);}void MainWindowForm::dataChangedSlot(){ updateData(); m_not_saved = true;}void MainWindowForm::handleMaterialTableClick( int row, int, int button, const QPoint & ){ m_currentTableItem = row; if (button == 1) { // Left click } else if (button == 2) { // Right click if (m_popup != NULL) { delete m_popup; m_popup = NULL; } m_popup = new QPopupMenu(this,"Message Operations"); m_popup->insertItem("&Add", this, SLOT(addMeterialSlot())); m_popup->insertItem("&Delete", this, SLOT(deleteMaterialSlot())); m_popup->exec(QCursor::pos()); }}void MainWindowForm::deleteMaterialSlot(){ if (materialTable->numRows() == 0) // There are no transmitters return; if ((m_currentTableItem == 0)||(m_currentTableItem == 1)) { QMessageBox::information( this, "radarFDTD GUI", "Removing basic materials is \n" "strictly forbidden !"); return; } // Check if material is in use for (int i=0; i<objectTable->numRows(); i++) { if (objectTable->text(i,2).toInt() == m_currentTableItem) { QMessageBox::information( this, "radarFDTD GUI", "This material is in use,\n" "Remove all objects of this meterial\n" "and then you will be able to remove it !"); return; } } QValueList<material_t>::iterator it = m_material.at(m_currentTableItem); // Erase the transmitter from the list m_material.remove(it); // REmove it from the table as well materialTable->removeRow(m_currentTableItem); oglViewer->updateMaterialColorTable(m_material); QHeader *headers = materialTable->verticalHeader(); for (int i=m_currentTableItem; i<materialTable->numRows(); i++) headers->setLabel(i,QString::number(i)); // Update all object to the change in the material indices for (unsigned int i=0; i<m_object.size(); i++) { if (m_object[i].boxes[0].material_indx > m_currentTableItem) { for (unsigned int j=0; j<m_object[i].boxes.size(); j++) { m_object[i].boxes[j].material_indx--; } } } for (int i=0; i<objectTable->numRows(); i++) { objectTable->setText(i,0,m_object[i].name); objectTable->setText(i,1,m_object[i].type); objectTable->setText(i,2,QString::number(m_object[i].boxes[0].material_indx)); } m_xmt_changed = true; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -