Changeset bd5e45b in mmcs for mainwindow.C
- Timestamp:
- Aug 10, 2015, 11:33:27 AM (9 years ago)
- Branches:
- master, matrices
- Children:
- 740d6bf
- Parents:
- 8ad4484
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mainwindow.C
r9dd61b1 rbd5e45b 2 2 #include "accountwidget.H" 3 3 #include "stackvariablesexogenas.h" 4 #include "formexportmatrix.h" 4 5 #include <QDebug> 6 7 #define ARMA_DONT_PRINT_ERRORS 5 8 #include <armadillo> 9 6 10 7 11 using namespace arma; … … 14 18 this, SLOT(slotFormLoadMatrixAccepted(QString,int,char))); 15 19 } 20 16 21 void MainWindow::slotExportMatrix() 17 22 { 18 QMessageBox::warning(this,"Warning", "Opcion en desarrollo", 19 QMessageBox::Ok); 23 24 if(opcionExportarMatriz == 0) 25 { 26 formExportMatriz = new FormExportMatrix(this); 27 QHBoxLayout * layoutLateralWidget = new QHBoxLayout; 28 QVBoxLayout * layoutCentralWidget = new QVBoxLayout; 29 30 QLabel *label = new QLabel; 31 label->setText("Seleccione una de las matrices"); 32 label->setStyleSheet("font-size:14;font-weight:bold;"); 33 layoutLateralWidget->addWidget(label); 34 35 formExportMatriz->Exportcb = new QComboBox; 36 formExportMatriz->Exportcb->setFixedWidth(150); 37 QVBoxLayout *cbLayout = new QVBoxLayout; 38 cbLayout->addWidget(formExportMatriz->Exportcb); 39 QWidget *cbWidget = new QWidget; 40 cbWidget->setLayout(cbLayout); 41 42 QStringList list; 43 list << "valor1" << "valor2" << "valor3"; 44 formExportMatriz->Exportcb->addItems(list); 45 46 layoutLateralWidget->addWidget(cbWidget); 47 48 QLabel *label2 = new QLabel; 49 label2->setText("Archivo"); 50 formExportMatriz->ExportLine = new QLineEdit; 51 //line->setObjectName("lineaCarga"); 52 formExportMatriz->ExportLine->setReadOnly(true); 53 formExportMatriz->ExportLine->setFixedWidth(450); 54 55 QPushButton * buttonExplorar = new QPushButton; 56 buttonExplorar->setObjectName("Exportar-Explorar"); 57 buttonExplorar->setFlat(true); 58 buttonExplorar->setIcon(QIcon("./img/folder_blue.png")); 59 60 QHBoxLayout *layoutMiddle = new QHBoxLayout; 61 layoutMiddle->addWidget(label2); 62 layoutMiddle->addWidget(formExportMatriz->ExportLine); 63 layoutMiddle->addWidget(buttonExplorar); 64 QWidget *middle = new QWidget; 65 middle->setLayout(layoutMiddle); 66 67 68 /*** Se crean y personalizan los bottones para agregar, finalizar, deshacer y cancelar ***/ 69 QPushButton * buttonExportar = new QPushButton; 70 buttonExportar->setObjectName("ExportarMatriz");//Se le asigna nombre al objeto 71 buttonExportar->setText("Exportar"); 72 buttonExportar->setFixedWidth(130); 73 74 QPushButton * buttonCancelar = new QPushButton; 75 buttonCancelar->setObjectName("CancelarMatriz");//Se le asigna nombre al objeto 76 buttonCancelar->setText("Cancelar"); 77 buttonCancelar->setFixedWidth(130); 78 79 connect(buttonCancelar,SIGNAL(clicked()),this,SLOT(slotCloseExport())); 80 connect(buttonExportar,SIGNAL(clicked()),this,SLOT(slotSaveExport())); 81 connect(buttonExplorar,SIGNAL(clicked()),this,SLOT(slotSearchExport())); 82 83 QHBoxLayout * layoutsButtons = new QHBoxLayout; 84 layoutsButtons->addWidget(buttonExportar); 85 layoutsButtons->addWidget(buttonCancelar); 86 QWidget *buttonWidget = new QWidget; 87 buttonWidget->setLayout(layoutsButtons); 88 89 QWidget *widget = new QWidget; 90 widget->setLayout(layoutLateralWidget); 91 layoutCentralWidget->addWidget(widget); 92 layoutCentralWidget->addWidget(middle); 93 layoutCentralWidget->addWidget(buttonWidget); 94 formExportMatriz->setLayout(layoutCentralWidget); 95 formExportMatriz->show(); 96 opcionExportarMatriz = 1; 97 98 } 99 else 100 { 101 formExportMatriz->show(); 102 } 103 20 104 } 21 105 void MainWindow::closeEvent(QCloseEvent * event) 22 106 { 23 if(QMessageBox::question(this, "Warning", "Are you sure?",24 QMessageBox::Yes | QMessageBox::No) ==25 107 QMessageBox msBox(QMessageBox::Question,"Alerta","¿Desea Salir?", QMessageBox::Yes | QMessageBox::No,this); 108 msBox.setButtonText(QMessageBox::Yes,"Si"); 109 if(msBox.exec()==QMessageBox::No) 26 110 { 27 111 event->ignore(); … … 135 219 { 136 220 tabWidget = new QTabWidget; 221 222 /* Opcion de la cuenta exogena, 0 para decir que nos se selecciono ninguna, 1 que se seleccionaron algunas 223 y 2 para decir que se seleccionaron todas*/ 224 opcionCuentaExogena = 0; 225 opcionVentanaExogena = 0; 226 opcionExportarMatriz = 0; 227 137 228 initGUI(); 138 229 … … 285 376 /***** Se llena la tabla vacia con los valores de la tabla principal ****/ 286 377 287 CalcularAn(tw,CT_HorizontalTW, count,false);//Funcion para calcular el Coeficiente Tecnico Horizontal (An)378 CalcularAn(tw,CT_HorizontalTW,new QTableWidget,count,false);//Funcion para calcular el Coeficiente Tecnico Horizontal (An) 288 379 289 380 /* Se agrega la columna y fila (0,0) y se insertan los titulos de las cuentas */ … … 318 409 for(int i=0;i<count-1;i++) 319 410 { 320 double total=tw->item(count-1,i)->text().toDouble();//Se obtiene el total de esa columna 411 QString STotal = Separador(tw->item(i,count-1),true); 412 double total=STotal.toDouble();//Se obtiene el total de esa columna 321 413 for(int j=0;j<count-1;j++) 322 414 { 323 415 if(i!=0 && j!=0) 324 416 { 325 double valor=tw->item(j,i)->text().toDouble(); 417 QString value = Separador(tw->item(i,j),true); 418 double valor=value.toDouble(); 326 419 if(total==0)//Se comprueba en caso de que el total sea zero 327 420 { … … 332 425 valor/=total;//Se divide el valor de la celda entre el total correspondiente 333 426 } 334 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f', 4));427 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',2)); 335 428 ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable); 336 CT_VerticalTW->setItem(j,i,ValoraInsertar); 429 value = Separador(ValoraInsertar,false); 430 ValoraInsertar->setText(value); 431 CT_VerticalTW->setItem(i,j,ValoraInsertar); 337 432 } 338 433 /**** En este else se llenan las celdas con fila y columna 0, es decir las que tienen nombre *****/ … … 367 462 void MainWindow::slotDeshacerExogena() 368 463 { 369 QMessageBox ::StandardButton respuesta;370 respuesta=QMessageBox::question(this,"Deshacer","¿Desea deshacer todos los cambios?",371 QMessageBox::Yes|QMessageBox::Default, QMessageBox::No);372 373 if( respuesta==QMessageBox::Yes)464 QMessageBox msBox(QMessageBox::Question,"Deshacer","¿Desea deshacer todos los cambios?", 465 QMessageBox::Yes | QMessageBox::No,this); 466 msBox.setButtonText(QMessageBox::Yes,"Si"); 467 msBox.setDefaultButton(QMessageBox::Yes); 468 if(msBox.exec()==QMessageBox::Yes) 374 469 { 375 470 int cantidad=stackVE->comboAccount->count(); … … 457 552 if(i!=0 && j!=0) 458 553 { 459 double valor=tablaPPAL->item(i,j)->text().toDouble(); 460 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',4)); 554 QString value = Separador(tablaPPAL->item(i,j),true); 555 double valor=value.toDouble(); 556 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',2)); 557 value = Separador(ValoraInsertar,false); 558 ValoraInsertar->setText(value); 461 559 ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable); 462 560 tablaEE->setItem(i,j,ValoraInsertar); … … 555 653 if(i!=0 && j!=0) 556 654 { 557 double valor=tablaPPAL->item(i,j)->text().toDouble(); 558 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',4)); 655 QString value = Separador(tablaPPAL->item(i,j),true); 656 double valor=value.toDouble(); 657 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',2)); 658 value = Separador(ValoraInsertar,false); 659 ValoraInsertar->setText(value); 559 660 ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable); 560 661 tablaEE->setItem(i,j,ValoraInsertar); … … 614 715 setAccountTitle(tablaPPAL); 615 716 } 717 616 718 /*** Slot para calcular el coeficiente tecnico horizontal de la matriz endogena/exogena ***/ 617 719 void MainWindow::slotAn() … … 620 722 tabWidget->addTab(new QWidget,"An"); 621 723 QTableWidget *tw = findChild<QTableWidget *>("MatrizEndogenaEndogena"); 724 QTableWidget *to = findChild<QTableWidget *>("TablaExogenaEndogena"); 622 725 QTableWidget *tablaAn = new QTableWidget; 726 tablaAn->setObjectName("MatrizAn"); 623 727 int count=tw->rowCount(); 624 728 CrearTablaVacia(count,tablaAn);//Se crea una tabla vacia … … 627 731 /***** Se llena la tabla vacia con los valores de la tabla principal ****/ 628 732 629 CalcularAn(tw,tablaAn,count,false);//Funcion para calcular el Coeficiente Tecnico Horizontal (An) 733 insertremoveRowCol(to,0, false); 734 CalcularAn(tw,tablaAn,to,count,true);//Funcion para calcular el Coeficiente Tecnico Horizontal (An) 735 /*** Procedimiento para obtener la matriz con los totales originales para luegos ser usados en An ***/ 736 int elementos = contarElementosMap(); 737 count=to->rowCount()-1; 738 if(opcionCuentaExogena==1) 739 { 740 int inicioExogena=count-elementos; 741 setEndogenaExogenaCell(to,inicioExogena+1,elementos,true); 742 } 743 else 744 { 745 setEndogenaExogenaCell(to,count,0,false); 746 } 630 747 631 748 int indice=ObtenerIndice("An");//Se obtiene el indice de la pestaña … … 642 759 void MainWindow::slotLa() 643 760 { 644 QTableWidget *tw = findChild<QTableWidget *>("Matriz EndogenaEndogena");761 QTableWidget *tw = findChild<QTableWidget *>("MatrizAn"); 645 762 double matrizIdentidad[200][200]; 646 763 double matrizResta[200][200]; … … 779 896 actionLoadMatrix.setDisabled(true); 780 897 898 actionExportMatrix.setEnabled(true); 899 781 900 /**** Se conectan las acciones para coeficientes tecnicos horizontales y verticales ****/ 782 901 connect(&actionCH, SIGNAL(triggered()), this,SLOT(slotCoeficienteHorizontal())); … … 788 907 void MainWindow::AgregarCuenta() 789 908 { 790 QMessageBox ::StandardButton respuesta;791 respuesta=QMessageBox::question(this,"Agregar cuenta","¿Está seguro que agregar la cuenta?",792 QMessageBox::Yes|QMessageBox::Default, QMessageBox::No);793 794 if( respuesta==QMessageBox::Yes)909 QMessageBox msBox(QMessageBox::Question,"Agregar cuenta","¿Está seguro que agregar la cuenta?", 910 QMessageBox::Yes | QMessageBox::No,this); 911 msBox.setButtonText(QMessageBox::Yes,"Si"); 912 msBox.setDefaultButton(QMessageBox::Yes); 913 if(msBox.exec()==QMessageBox::Yes) 795 914 { 796 915 QTableWidget *tw = findChild<QTableWidget *>("TablaPrincipal");//Se busca la tabla que se creo … … 880 999 void MainWindow::FinalizarCuentas() 881 1000 { 882 QMessageBox::StandardButton respuesta; 883 respuesta=QMessageBox::question(this,"Finalizar Carga","¿Está seguro que desea finalizar?", 884 QMessageBox::Yes|QMessageBox::Default, QMessageBox::No); 885 if(respuesta==QMessageBox::Yes) 1001 QMessageBox msBox(QMessageBox::Question,"Finalizar Carga","¿Está seguro que desea finalizar?", 1002 QMessageBox::Yes | QMessageBox::No,this); 1003 msBox.setButtonText(QMessageBox::Yes,"Si"); 1004 msBox.setDefaultButton(QMessageBox::Yes); 1005 if(msBox.exec()==QMessageBox::Yes) 886 1006 { 887 1007 bool Centinela=ComprobarCuentas();//Se llama a la funcion que comprueba si todos los campos de las cuentas estan llenos … … 955 1075 for(int j=inicio;j<filas;j++) 956 1076 { 957 double thisFila=tableWidget->item(j,i)->text().toDouble(); 958 double thisColumna=tableWidget->item(i,j)->text().toDouble(); 1077 QString fila=Separador(tableWidget->item(j,i),true); 1078 double thisFila=fila.toDouble(); 1079 QString columna=Separador(tableWidget->item(i,j),true); 1080 double thisColumna=columna.toDouble(); 959 1081 SumaFila+=thisFila; 960 1082 SumaColumna+=thisColumna; 961 1083 } 962 1084 QTableWidgetItem *Valor1 = new QTableWidgetItem; 963 Valor1->setText(QString::number(SumaFila)); 1085 Valor1->setText(QString::number(SumaFila,'f',2)); 1086 QString value1 = Separador(Valor1,false); 1087 Valor1->setText(value1); 964 1088 Valor1->setFlags(Valor1->flags() ^ Qt::ItemIsEditable); 965 1089 QTableWidgetItem *Valor2 = new QTableWidgetItem; 966 Valor2->setText(QString::number(SumaColumna)); 1090 Valor2->setText(QString::number(SumaColumna,'f',2)); 1091 QString value2 = Separador(Valor2,false); 1092 Valor2->setText(value2); 967 1093 Valor2->setFlags(Valor2->flags() ^ Qt::ItemIsEditable); 968 1094 tableWidget->setItem(filas,i,Valor1);//Inserta en Filas … … 974 1100 void MainWindow::RestaurarCeldas()//Slot que permite restaurar el titulo de las cuentas en las celdas 975 1101 { 976 QMessageBox::StandardButton respuesta; 977 respuesta=QMessageBox::question(this,"Restaurar Celdas","¿Desea Restaurar el titulo de todas las celdas?", 978 QMessageBox::Yes|QMessageBox::Default, QMessageBox::No); 979 if(respuesta==QMessageBox::Yes) 1102 QMessageBox msBox(QMessageBox::Question,"Restaurar Celdas","¿Desea Restaurar el titulo de todas las celdas?", 1103 QMessageBox::Yes | QMessageBox::No,this); 1104 msBox.setButtonText(QMessageBox::Yes,"Si"); 1105 msBox.setDefaultButton(QMessageBox::Yes); 1106 if(msBox.exec()==QMessageBox::Yes) 980 1107 { 981 1108 QTableWidget *tw = findChild<QTableWidget *>("TablaPrincipal"); … … 987 1114 void MainWindow::ModificarCuenta()//Slot que permite habilitar la edicion de una cuenta una vez agregada 988 1115 { 989 QMessageBox::StandardButton respuesta; 990 respuesta=QMessageBox::question(this,"Modificar Cuenta","¿Desea Modificar la Cuenta Actual?", 991 QMessageBox::Yes|QMessageBox::Default, QMessageBox::No); 992 if(respuesta==QMessageBox::Yes) 1116 QMessageBox msBox(QMessageBox::Question,"Modificar Cuenta","¿Desea Modificar la Cuenta Actual?", 1117 QMessageBox::Yes | QMessageBox::No,this); 1118 msBox.setButtonText(QMessageBox::Yes,"Si"); 1119 msBox.setDefaultButton(QMessageBox::Yes); 1120 if(msBox.exec()==QMessageBox::Yes) 993 1121 { 994 1122 StackWidget *sw = findChild<StackWidget *>();//Se buscan las cuentas creadas … … 1015 1143 int row = 0; 1016 1144 QString lineHead = file.readLine(); 1017 std::vector<std::string> rowVH =1145 const std::vector<std::string> rowVH = 1018 1146 csv_read_row(lineHead.toStdString(), csvSeparator); 1147 1019 1148 1020 1149 matrixSize = rowVH.size(); … … 1047 1176 1048 1177 }*/ 1178 1049 1179 std::vector<std::string> rowV = 1050 1180 csv_read_row(line.toStdString(), csvSeparator); 1051 1052 1181 for(int column=0, leng=rowV.size(); 1053 1182 column < leng and column<matrixSize; column++) { 1054 1183 1055 double value = (double)atof(rowV[column].c_str()); 1184 //double value = (double)atof(rowV[column].c_str()); 1185 1186 /* Aqui se incorporan los valores luego de la coma(,) */ 1187 QString rowVal = QString::fromUtf8(rowV[column].c_str()); 1188 double value = rowVal.toDouble(); 1189 1190 1056 1191 1057 1192 QTableWidgetItem *newItem = new QTableWidgetItem( … … 1121 1256 1122 1257 int precision = 2; 1258 bool controlador = false; 1259 if(d<0) 1260 { 1261 controlador = true; 1262 d *=-1; 1263 } 1264 1123 1265 1124 1266 QString stringNumber = QString::number(d, 'f', precision); … … 1129 1271 stringNumber.insert(i, '*'); 1130 1272 } 1273 } 1274 if(controlador) 1275 { 1276 double var = stringNumber.toDouble(); 1277 var *=-1; 1278 stringNumber = QString::number(var, 'f', precision); 1131 1279 } 1132 1280 stringNumber.replace(".", ","); … … 1228 1376 } 1229 1377 } 1378 return 0; 1230 1379 } 1231 1380 … … 1281 1430 tw->setItem(0,1,CuentaEndogenafila); 1282 1431 tw->setSpan(0,1,1,inicioExogena-1); 1283 QTableWidgetItem *CuentaEndogenaColumna = new QTableWidgetItem("C\nu\ne\nn\nt\na\ns\n\nE\nn\nd\no\ng\ne\nn\na\ns"); 1432 QTableWidgetItem *CuentaEndogenaColumna = new QTableWidgetItem; 1433 if(elementos<12) 1434 { 1435 CuentaEndogenaColumna->setText("Cuentas \nExogenas"); 1436 } 1437 else 1438 { 1439 CuentaEndogenaColumna->setText("C\nu\ne\nn\nt\na\ns\n\nE\nn\nd\no\ng\ne\nn\na\ns"); 1440 } 1284 1441 CuentaEndogenaColumna->setFlags(CuentaEndogenaColumna->flags() ^ Qt::ItemIsEditable); 1285 1442 tw->setItem(1,0,CuentaEndogenaColumna); 1286 1443 tw->setSpan(1,0,inicioExogena-1,1); 1287 if(condicion) 1444 if(condicion)//Si tiene cuentas exogenas 1288 1445 { 1289 1446 /* Titulos para las Cuentas exogenas */ … … 1314 1471 } 1315 1472 1316 void MainWindow::CalcularAn(QTableWidget *tw,QTableWidget *nuevaTabla,int count,bool exogena)//Funcion para calcular el Coeficiente Tecnico Horizontal (An) 1317 { 1318 if(exogena) 1319 { 1320 tw->removeRow(0); 1321 tw->removeColumn(0); 1322 count=tw->rowCount(); 1323 } 1324 /***** Se llena la tabla vacia con los valores de la tabla principal ****/ 1473 void MainWindow::CalcularAn(QTableWidget *tw,QTableWidget *nuevaTabla,QTableWidget *tablaOriginal,int count,bool endogena)//Funcion para calcular el Coeficiente Tecnico Horizontal (An) 1474 { 1325 1475 for(int i=0;i<count-1;i++) 1326 1476 { 1327 double total=tw->item(i,count-1)->text().toDouble();//Se obtiene el total de esa columna 1477 double total; 1478 if(endogena) 1479 { 1480 QString value = Separador(tablaOriginal->item(count,i),true); 1481 value = QString::number(value.toDouble(),'f',2); 1482 total=value.toDouble(); 1483 } 1484 else 1485 { 1486 QString value = Separador(tw->item(count-1,i),true); 1487 value = QString::number(value.toDouble(),'f',2); 1488 total=value.toDouble(); 1489 } 1328 1490 for(int j=0;j<count-1;j++) 1329 1491 { 1330 1492 if(i!=0 && j!=0) 1331 1493 { 1332 double valor=tw->item(i,j)->text().toDouble(); 1494 QString values = Separador(tw->item(j,i),true); 1495 values = QString::number(values.toDouble(),'f',2); 1496 double valor=values.toDouble(); 1497 1333 1498 if(total==0)//Se comprueba en caso de que el total sea zero 1334 1499 { … … 1338 1503 { 1339 1504 valor/=total;//Se divide el valor de la celda entre el total correspondiente 1505 1340 1506 } 1341 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f', 4));1507 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',2)); 1342 1508 ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable); 1343 nuevaTabla->setItem(i,j,ValoraInsertar); 1509 QString value = Separador(ValoraInsertar,false); 1510 ValoraInsertar->setText(value); 1511 nuevaTabla->setItem(j,i,ValoraInsertar); 1344 1512 } 1345 1513 /**** En este else se llenan las celdas con fila y columna 0, es decir las que tienen nombre *****/ … … 1354 1522 1355 1523 } 1356 if(exogena)1357 {1358 if(opcionCuentaExogena==1)1359 {1360 int elementos = contarElementosMap();1361 int inicioExogena=count-elementos;1362 //setEndogenaExogenaCell(nuevaTabla,inicioExogena,elementos,count-1,true);1363 setEndogenaExogenaCell(tw,inicioExogena,elementos,true);1364 }1365 else1366 {1367 //setEndogenaExogenaCell(nuevaTabla,count,0,count,false);1368 setEndogenaExogenaCell(tw,count,0,false);1369 }1370 }1371 1524 } 1372 1525 … … 1379 1532 if(i!=0 && j!=0) 1380 1533 { 1381 double valor=tw->item(i,j)->text().toDouble(); 1382 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',4)); 1534 QString value = Separador(tw->item(i,j),true); 1535 double valor= value.toDouble(); 1536 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',2)); 1537 value = Separador(ValoraInsertar,false); 1538 ValoraInsertar->setText(value); 1383 1539 ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable); 1384 1540 nuevaTabla->setItem(i,j,ValoraInsertar); … … 1399 1555 { 1400 1556 int cantidad=tw->rowCount(); 1401 for(int i=0;i<cantidad -1;i++)1402 { 1403 for(int j=0;j<cantidad -1;j++)1557 for(int i=0;i<cantidad;i++) 1558 { 1559 for(int j=0;j<cantidad;j++) 1404 1560 { 1405 1561 if(i!=0 && j!=0) … … 1441 1597 for(int j=0;j<cantidad-1;j++) 1442 1598 { 1599 //qDebug()<<MatrizEndogenaEndogena[i][j]<<" "<<identidad[i][j]; 1443 1600 resta[i][j] = identidad[i][j]-MatrizEndogenaEndogena[i][j]; 1444 1601 //qDebug()<<"A"<<resta[i][j]; … … 1448 1605 } 1449 1606 } 1450 /* mat A; 1607 1608 mat inverse = inv(A); 1609 1610 QTableWidget *tablaLa = new QTableWidget; 1611 tablaLa->setObjectName("MatrizLa"); 1612 CrearTablaVacia(cantidad,tablaLa); 1613 for(int i=0;i<cantidad-1;i++) 1614 { 1615 for(int j=0;j<cantidad-1;j++) 1616 { 1617 double value = inverse.at(i,j); 1618 qDebug()<<"double "<<value; 1619 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(value,'f',2)); 1620 ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable); 1621 tablaLa->setItem(i,j,ValoraInsertar); 1622 1623 } 1624 } 1625 tabWidget->addTab(new QWidget,"La"); 1626 int indice=ObtenerIndice("La");//Se obtiene el indice de la pestaña 1627 QHBoxLayout * layoutCentralWidget = new QHBoxLayout; 1628 layoutCentralWidget->addWidget(tablaLa); 1629 QWidget *widget = tabWidget->widget(indice); 1630 widget->setLayout(layoutCentralWidget);//Se añade el widget y layout a la pestaña creada 1631 1632 1633 /*mat A; 1451 1634 A << 1 << 2.2222 << 3 << 4 << endr 1452 1635 << 2 << 1 << 5 << 6 << endr 1453 1636 << 3 << 5 << 1 << 7 <<endr 1454 << 4 << 6 << 7 << 1<<endr; */1637 << 4 << 6 << 7 << 1<<endr; 1455 1638 //qDebug()<<"here"<<A.at(0,8); 1456 1639 //qDebug()<<"resta"<<resta[0][8]; 1457 double determinant = det(A); 1458 qDebug() << isnan(determinant); 1459 /* 1460 mat inverse = inv(A); 1461 for(int i=0;i<4-1;i++) 1462 { 1463 for(int j=0;j<4-1;j++) 1640 1641 double determinant = det(A);*/ 1642 //qDebug() << isnan(determinant); 1643 1644 /*mat inverse = inv(A); 1645 for(int i=0;i<4;i++) 1646 { 1647 for(int j=0;j<4;j++) 1464 1648 { 1465 1649 qDebug()<<"inversa"<<inverse.at(i,j); … … 1468 1652 }*/ 1469 1653 1470 qDebug()<<"determinant"<<determinant; 1471 if(determinant < -std::numeric_limits<qreal>::max()) 1654 1655 1656 1657 //qDebug()<<"determinant"<<determinant; 1658 /*if(determinant < -std::numeric_limits<qreal>::max()) 1472 1659 { 1473 1660 qDebug()<<"-inf"; … … 1480 1667 { 1481 1668 qDebug()<< "nan"; 1482 } 1483 1669 }*/ 1484 1670 1485 1671 … … 1522 1708 } 1523 1709 1710 /* Funcion para agregar/quitar columnas y filas */ 1524 1711 void MainWindow::insertremoveRowCol(QTableWidget *tw, int rowcol, bool opcion) 1525 1712 { … … 1535 1722 } 1536 1723 } 1724 1725 /* Funcion para agregar/quitar el separador de miles y la coma en las tablas */ 1726 QString MainWindow::Separador(QTableWidgetItem *ti,bool quitar) 1727 { 1728 QString value=ti->text(); 1729 if(quitar) 1730 { 1731 value.remove(QChar('.')); 1732 value.replace(",","."); 1733 } 1734 else 1735 { 1736 double val =value.toDouble(); 1737 value = numberFormat(val); 1738 } 1739 return value; 1740 } 1741 1742 void MainWindow::slotCloseExport() 1743 { 1744 formExportMatriz->ExportLine->setText(""); 1745 formExportMatriz->close(); 1746 } 1747 1748 void MainWindow::slotSaveExport() 1749 { 1750 1751 if(formExportMatriz->ExportLine->text().isEmpty()) 1752 { 1753 QMessageBox::critical(this,"Nombre del Archivo","Debe Colocar un nombre"); 1754 } 1755 else 1756 { 1757 QString filename = formExportMatriz->ExportLine->text(); 1758 QFile archivo(filename); 1759 archivo.open(QFile::WriteOnly | QFile::Text); 1760 QTextStream out(&archivo); 1761 out << "hola " << "que hace" << "? \n"; 1762 out << "otra linea de prueba"; 1763 archivo.flush(); 1764 archivo.close(); 1765 formExportMatriz->ExportLine->setText(""); 1766 formExportMatriz->close(); 1767 } 1768 } 1769 1770 void MainWindow::slotSearchExport() 1771 { 1772 QString format = ".txt"; 1773 1774 QString filename = QFileDialog::getSaveFileName(this, 1775 "Elija el nombre", QDir::homePath(),"*.txt"); 1776 1777 filename +=format; 1778 1779 formExportMatriz->Exportcb->addItem(filename); 1780 1781 formExportMatriz->ExportLine->setText(filename); 1782 qDebug()<< formExportMatriz->ExportLine->text(); 1783 1784 }
Note: See TracChangeset
for help on using the changeset viewer.