Changeset bd5e45b in mmcs for mainwindow.C


Ignore:
Timestamp:
Aug 10, 2015, 11:33:27 AM (9 years ago)
Author:
rboet <rboet@…>
Branches:
master, matrices
Children:
740d6bf
Parents:
8ad4484
Message:

Traducción de los botones de diálogo, primer prototipo de matriz La

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mainwindow.C

    r9dd61b1 rbd5e45b  
    22#include "accountwidget.H"
    33#include "stackvariablesexogenas.h"
     4#include "formexportmatrix.h"
    45#include <QDebug>
     6
     7#define ARMA_DONT_PRINT_ERRORS
    58#include <armadillo>
     9
    610
    711using namespace arma;
     
    1418            this, SLOT(slotFormLoadMatrixAccepted(QString,int,char)));
    1519}
     20
    1621void MainWindow::slotExportMatrix()
    1722{
    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
    20104}
    21105void MainWindow::closeEvent(QCloseEvent * event)
    22106{
    23     if(QMessageBox::question(this, "Warning", "Are you sure?",
    24                              QMessageBox::Yes | QMessageBox::No) ==
    25        QMessageBox::No)
     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)
    26110    {
    27111        event->ignore();
     
    135219{
    136220    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
    137228    initGUI();
    138229
     
    285376    /*****      Se llena la tabla vacia con los valores de la tabla principal ****/
    286377
    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)
    288379
    289380    /*      Se agrega la columna y fila (0,0) y se insertan los titulos de las cuentas      */
     
    318409    for(int i=0;i<count-1;i++)
    319410    {
    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
    321413        for(int j=0;j<count-1;j++)
    322414        {
    323415            if(i!=0 && j!=0)
    324416            {
    325                 double valor=tw->item(j,i)->text().toDouble();
     417                QString value = Separador(tw->item(i,j),true);
     418                double valor=value.toDouble();
    326419                if(total==0)//Se comprueba en caso de que el total sea zero
    327420                {
     
    332425                    valor/=total;//Se divide el valor de la celda entre el total correspondiente
    333426                }
    334                 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',4));
     427                QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',2));
    335428                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);
    337432            }
    338433            /****           En este else se llenan las celdas con fila y columna 0, es decir las que tienen nombre *****/
     
    367462void MainWindow::slotDeshacerExogena()
    368463{
    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)
    374469    {
    375470        int cantidad=stackVE->comboAccount->count();
     
    457552                if(i!=0 && j!=0)
    458553                {
    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);
    461559                    ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable);
    462560                    tablaEE->setItem(i,j,ValoraInsertar);
     
    555653                if(i!=0 && j!=0)
    556654                {
    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);
    559660                    ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable);
    560661                    tablaEE->setItem(i,j,ValoraInsertar);
     
    614715    setAccountTitle(tablaPPAL);
    615716}
     717
    616718/***        Slot para calcular el coeficiente tecnico horizontal de la matriz endogena/exogena      ***/
    617719void MainWindow::slotAn()
     
    620722    tabWidget->addTab(new QWidget,"An");
    621723    QTableWidget *tw = findChild<QTableWidget *>("MatrizEndogenaEndogena");
     724    QTableWidget *to = findChild<QTableWidget *>("TablaExogenaEndogena");
    622725    QTableWidget *tablaAn = new QTableWidget;
     726    tablaAn->setObjectName("MatrizAn");
    623727    int count=tw->rowCount();
    624728    CrearTablaVacia(count,tablaAn);//Se crea una tabla vacia
     
    627731    /*****      Se llena la tabla vacia con los valores de la tabla principal ****/
    628732
    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    }
    630747
    631748    int indice=ObtenerIndice("An");//Se obtiene el indice de la pestaña
     
    642759void MainWindow::slotLa()
    643760{
    644     QTableWidget *tw = findChild<QTableWidget *>("MatrizEndogenaEndogena");
     761    QTableWidget *tw = findChild<QTableWidget *>("MatrizAn");
    645762    double matrizIdentidad[200][200];
    646763    double matrizResta[200][200];
     
    779896    actionLoadMatrix.setDisabled(true);
    780897
     898    actionExportMatrix.setEnabled(true);
     899
    781900    /****          Se conectan las acciones para coeficientes tecnicos horizontales y verticales      ****/
    782901    connect(&actionCH, SIGNAL(triggered()), this,SLOT(slotCoeficienteHorizontal()));
     
    788907void MainWindow::AgregarCuenta()
    789908{
    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)
    795914    {
    796915        QTableWidget *tw = findChild<QTableWidget *>("TablaPrincipal");//Se busca la tabla que se creo
     
    880999void MainWindow::FinalizarCuentas()
    8811000{
    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)
    8861006    {
    8871007        bool Centinela=ComprobarCuentas();//Se llama a la funcion que comprueba si todos los campos de las cuentas estan llenos
     
    9551075        for(int j=inicio;j<filas;j++)
    9561076        {
    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();
    9591081            SumaFila+=thisFila;
    9601082            SumaColumna+=thisColumna;
    9611083        }
    9621084        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);
    9641088        Valor1->setFlags(Valor1->flags() ^ Qt::ItemIsEditable);
    9651089        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);
    9671093        Valor2->setFlags(Valor2->flags() ^ Qt::ItemIsEditable);
    9681094        tableWidget->setItem(filas,i,Valor1);//Inserta en Filas
     
    9741100void MainWindow::RestaurarCeldas()//Slot que permite restaurar el titulo de las cuentas en las celdas
    9751101{
    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)
    9801107    {
    9811108        QTableWidget *tw = findChild<QTableWidget *>("TablaPrincipal");
     
    9871114void MainWindow::ModificarCuenta()//Slot que permite habilitar la edicion de una cuenta una vez agregada
    9881115{
    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)
    9931121    {
    9941122        StackWidget *sw = findChild<StackWidget *>();//Se buscan las cuentas creadas
     
    10151143        int row = 0;
    10161144        QString lineHead = file.readLine();
    1017         std::vector<std::string> rowVH =
     1145        const std::vector<std::string> rowVH =
    10181146                csv_read_row(lineHead.toStdString(), csvSeparator);
     1147
    10191148
    10201149        matrixSize = rowVH.size();
     
    10471176
    10481177            }*/
     1178
    10491179            std::vector<std::string> rowV =
    10501180                    csv_read_row(line.toStdString(), csvSeparator);
    1051 
    10521181            for(int column=0, leng=rowV.size();
    10531182            column < leng and column<matrixSize; column++) {
    10541183
    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
    10561191
    10571192                QTableWidgetItem *newItem = new QTableWidgetItem(
     
    11211256
    11221257    int precision = 2;
     1258    bool controlador = false;
     1259    if(d<0)
     1260    {
     1261        controlador = true;
     1262        d *=-1;
     1263    }
     1264
    11231265
    11241266    QString stringNumber = QString::number(d, 'f', precision);
     
    11291271            stringNumber.insert(i, '*');
    11301272        }
     1273    }
     1274    if(controlador)
     1275    {
     1276        double var = stringNumber.toDouble();
     1277        var *=-1;
     1278        stringNumber = QString::number(var, 'f', precision);
    11311279    }
    11321280    stringNumber.replace(".", ",");
     
    12281376       }
    12291377    }
     1378    return 0;
    12301379}
    12311380
     
    12811430    tw->setItem(0,1,CuentaEndogenafila);
    12821431    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    }
    12841441    CuentaEndogenaColumna->setFlags(CuentaEndogenaColumna->flags() ^ Qt::ItemIsEditable);
    12851442    tw->setItem(1,0,CuentaEndogenaColumna);
    12861443    tw->setSpan(1,0,inicioExogena-1,1);
    1287     if(condicion)
     1444    if(condicion)//Si tiene cuentas exogenas
    12881445    {
    12891446        /*      Titulos para las Cuentas exogenas   */
     
    13141471}
    13151472
    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 ****/
     1473void MainWindow::CalcularAn(QTableWidget *tw,QTableWidget *nuevaTabla,QTableWidget *tablaOriginal,int count,bool endogena)//Funcion para calcular el Coeficiente Tecnico Horizontal (An)
     1474{
    13251475    for(int i=0;i<count-1;i++)
    13261476    {
    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        }
    13281490        for(int j=0;j<count-1;j++)
    13291491        {
    13301492            if(i!=0 && j!=0)
    13311493            {
    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
    13331498                if(total==0)//Se comprueba en caso de que el total sea zero
    13341499                {
     
    13381503                {
    13391504                    valor/=total;//Se divide el valor de la celda entre el total correspondiente
     1505
    13401506                }
    1341                 QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',4));
     1507                QTableWidgetItem *ValoraInsertar = new QTableWidgetItem(QString::number(valor,'f',2));
    13421508                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);
    13441512            }
    13451513            /****           En este else se llenan las celdas con fila y columna 0, es decir las que tienen nombre *****/
     
    13541522
    13551523    }
    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         else
    1366         {
    1367            //setEndogenaExogenaCell(nuevaTabla,count,0,count,false);
    1368            setEndogenaExogenaCell(tw,count,0,false);
    1369         }
    1370     }
    13711524}
    13721525
     
    13791532            if(i!=0 && j!=0)
    13801533            {
    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);
    13831539                ValoraInsertar->setFlags(ValoraInsertar->flags() ^ Qt::ItemIsEditable);
    13841540                nuevaTabla->setItem(i,j,ValoraInsertar);
     
    13991555{
    14001556    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++)
    14041560        {
    14051561            if(i!=0 && j!=0)
     
    14411597        for(int j=0;j<cantidad-1;j++)
    14421598        {
     1599            //qDebug()<<MatrizEndogenaEndogena[i][j]<<" "<<identidad[i][j];
    14431600            resta[i][j] = identidad[i][j]-MatrizEndogenaEndogena[i][j];
    14441601            //qDebug()<<"A"<<resta[i][j];
     
    14481605         }
    14491606    }
    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;
    14511634    A << 1 << 2.2222 << 3 << 4 << endr
    14521635     << 2 << 1 << 5 << 6 << endr
    14531636     << 3 << 5 << 1 << 7 <<endr
    1454      << 4 << 6 << 7 << 1<<endr;*/
     1637     << 4 << 6 << 7 << 1<<endr;
    14551638    //qDebug()<<"here"<<A.at(0,8);
    14561639    //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++)
    14641648        {
    14651649            qDebug()<<"inversa"<<inverse.at(i,j);
     
    14681652    }*/
    14691653
    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())
    14721659    {
    14731660        qDebug()<<"-inf";
     
    14801667    {
    14811668        qDebug()<< "nan";
    1482     }
    1483 
     1669    }*/
    14841670
    14851671
     
    15221708}
    15231709
     1710/*                  Funcion para agregar/quitar columnas y filas                    */
    15241711void MainWindow::insertremoveRowCol(QTableWidget *tw, int rowcol, bool opcion)
    15251712{
     
    15351722    }
    15361723}
     1724
     1725/*                      Funcion para agregar/quitar el separador de miles y la coma en las tablas           */
     1726QString 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
     1742void MainWindow::slotCloseExport()
     1743{
     1744    formExportMatriz->ExportLine->setText("");
     1745    formExportMatriz->close();
     1746}
     1747
     1748void 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
     1770void 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.