Changeset b23848e in mmcs for mainwindow.C
- Timestamp:
- Sep 14, 2016, 11:22:49 AM (8 years ago)
- Branches:
- master
- Children:
- b0c244f
- Parents:
- dfabbb4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mainwindow.C
rdfabbb4 rb23848e 878 878 void MainWindow::abrirManual() 879 879 { 880 //QDesktopServices::openUrl(QUrl("/usr/share/mmcs/Usuario/Entrada.html",QUrl::TolerantMode)); 881 // generate some data: 882 /*QCustomPlot *customPlot = new QCustomPlot; 883 QVector<double> x(101), y(101); // initialize with entries 0..100 884 for (int i=0; i<10; ++i) 885 { 886 x[i] = i/5.0 - 1; // x goes from -1 to 1 887 y[i] = x[i]*x[i]; // let's plot a quadratic function 888 } 889 // create graph and assign data to it: 890 customPlot->addGraph(); 891 customPlot->graph(0)->setData(x, y); 892 //customPlot->graph(0)->setLineStyle(QCPGraph::lsNone); 893 customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCross, 4)); 894 // give the axes some labels: 895 customPlot->xAxis->setLabel("-y"); 896 customPlot->yAxis->setLabel("-x"); 897 customPlot->xAxis2->setLabel("y"); 898 customPlot->yAxis2->setLabel("x"); 899 // set axes ranges, so we see all data: 900 customPlot->xAxis->setRange(-5, 5); 901 customPlot->yAxis->setRange(-5, 5); 902 customPlot->xAxis2->setRange(-5, 5); 903 customPlot->yAxis2->setRange(-5, 5); 904 customPlot->xAxis2->setVisible(true); 905 customPlot->yAxis2->setVisible(true); 906 customPlot->replot(); 907 FormExportMatrix *form = new FormExportMatrix(this); 908 QHBoxLayout *layoutHorizontal = new QHBoxLayout; 909 layoutHorizontal->addWidget(customPlot); 910 form->setLayout(layoutHorizontal); 911 form->show();*/ 880 QDesktopServices::openUrl(QUrl("/usr/share/mmcs/Usuario/Entrada.html",QUrl::TolerantMode)); 912 881 } 913 882 … … 2870 2839 QPushButton * buttonAgregar = new QPushButton; 2871 2840 buttonAgregar->setObjectName("AgregarEncadenamiento");//Se le asigna nombre al objeto 2872 buttonAgregar->setText("A gregar");2841 buttonAgregar->setText("A&gregar"); 2873 2842 buttonAgregar->setFixedWidth(130); 2874 2843 buttonAgregar->setStyleSheet("background-color: #358ccb; color: #fff;" … … 2877 2846 QPushButton * buttonCancelar = new QPushButton; 2878 2847 buttonCancelar->setObjectName("CancelarEncadenamiento");//Se le asigna nombre al objeto 2879 buttonCancelar->setText(" Cancelar");2848 buttonCancelar->setText("&Cancelar"); 2880 2849 buttonCancelar->setFixedWidth(130); 2881 2850 buttonCancelar->setStyleSheet("background-color: #358ccb; color: #fff;" … … 2884 2853 QPushButton * buttonVer = new QPushButton; 2885 2854 buttonVer->setObjectName("VerEncadenamiento");//Se le asigna nombre al objeto 2886 buttonVer->setText("V er");2855 buttonVer->setText("V&er"); 2887 2856 buttonVer->setFixedWidth(130); 2888 2857 buttonVer->setStyleSheet("background-color: #358ccb; color: #fff;" … … 3030 2999 "font-weight: bold; height: 30px; border: none;" 3031 3000 "border-radius: 5px; margin-top: 40px;"); 3001 //Se genera el boton de gráfico 3002 QPushButton * buttonGraphic = new QPushButton; 3003 buttonGraphic->setText("&Gráfico"); 3004 buttonGraphic->setObjectName("ReportButton"); 3005 buttonGraphic->setFixedWidth(100); 3006 buttonGraphic->setStyleSheet("background-color: #358ccb; color: #fff;" 3007 "font-weight: bold; height: 30px; border: none;" 3008 "border-radius: 5px; margin-top: 40px;"); 3032 3009 3033 3010 //Se genera la caja de grupo que contendrá el botón … … 3042 3019 QHBoxLayout * layoutButtons = new QHBoxLayout; 3043 3020 layoutButtons->addWidget(buttonReport); 3021 layoutButtons->addWidget(buttonGraphic); 3044 3022 groupBoxAccount->setLayout(layoutButtons); 3045 3023 //Se conecta el boton de reporte 3046 3024 connect(buttonReport,SIGNAL(clicked()),this,SLOT(slotEncadenamientoReport())); 3025 connect(buttonGraphic,SIGNAL(clicked()),this,SLOT(slotEncadenamientoGraphic())); 3047 3026 3048 3027 layoutLateralWidget->addWidget(groupBoxAccount); … … 3084 3063 "font-weight: bold; height: 30px; border: none;" 3085 3064 "border-radius: 5px; margin-top: 40px;"); 3065 //Se genera el boton de gráfico 3066 QPushButton * buttonGraphic = new QPushButton; 3067 buttonGraphic->setText("&Gráfico"); 3068 buttonGraphic->setObjectName("ReportButton"); 3069 buttonGraphic->setFixedWidth(100); 3070 buttonGraphic->setStyleSheet("background-color: #358ccb; color: #fff;" 3071 "font-weight: bold; height: 30px; border: none;" 3072 "border-radius: 5px; margin-top: 40px;"); 3086 3073 3087 3074 //Se genera la caja de grupo que contendrá el botón … … 3096 3083 QHBoxLayout * layoutButtons = new QHBoxLayout; 3097 3084 layoutButtons->addWidget(buttonReport); 3085 layoutButtons->addWidget(buttonGraphic); 3098 3086 groupBoxAccount->setLayout(layoutButtons); 3099 3087 //Se conecta el boton de reporte 3100 3088 connect(buttonReport,SIGNAL(clicked()),this,SLOT(slotEncadenamientoReport())); 3089 connect(buttonGraphic,SIGNAL(clicked()),this,SLOT(slotEncadenamientoGraphic())); 3101 3090 3102 3091 layoutLateralWidget->addWidget(groupBoxAccount); … … 3140 3129 crearTablaVaciaEncadenamiento(elementos,enTable,7); 3141 3130 int columna=0; 3142 qDebug()<< diccCuentasEncadenamientos;3143 3131 foreach(int key,diccCuentasEncadenamientos.keys()) 3144 3132 { … … 3527 3515 3528 3516 /** 3529 @brief Función que permite agregar la primera celda en los clasificadores3530 @date 10/09/20153531 @author Rodrigo Boet3532 @param <tw> Recibe el widget de la tabla de clasificadores3533 */3534 void MainWindow::agregarPrimeraCelda(QTableWidget *tw)3535 {3536 tw->insertRow(0);3537 //Se colocan no editables la celda 0 y 13538 noEditColZero(tw);3539 QTableWidgetItem *one = new QTableWidgetItem;3540 one->setFlags(one->flags() ^ Qt::ItemIsEditable);3541 tw->setItem(0,1,one);3542 for(int i=0;i<3;i++)3543 {3544 QTableWidgetItem *cAn = new QTableWidgetItem("Clasificador por An");3545 cAn->setTextAlignment(Qt::AlignCenter);3546 cAn->setFlags(cAn->flags() ^ Qt::ItemIsEditable);3547 CellStyleExEn(cAn);3548 tw->setItem(0,i+2,cAn);3549 QTableWidgetItem *cMa = new QTableWidgetItem("Clasificador por Ma");3550 cMa->setTextAlignment(Qt::AlignCenter);3551 cMa->setFlags(cMa->flags() ^ Qt::ItemIsEditable);3552 CellStyleExEn(cMa);3553 tw->setItem(0,5+i,cMa);3554 }3555 tw->setSpan(0,2,1,3);3556 tw->setSpan(0,5,1,3);3557 }3558 3559 /**3560 3517 @brief Función que permite abir el formulario de creación del reporte de los encadenamientos 3561 3518 @date 31/08/2015 … … 3565 3522 { 3566 3523 FormExportReport *formularioReporte = new FormExportReport(this); 3567 connect(formularioReporte,SIGNAL(formAccepted(QString)),this,SLOT(slotGenerarEncadenamientoReport(QString))); 3524 connect(formularioReporte,SIGNAL(formAccepted(QString,bool)),this,SLOT(slotGenerarEncadenamientoReport(QString,bool))); 3525 formularioReporte->show(); 3526 } 3527 3528 /** 3529 @brief Función que permite abir el formulario de creación de gráficos de los encadenamientos 3530 @date 14/09/2016 3531 @author Rodrigo Boet 3532 */ 3533 void MainWindow::slotEncadenamientoGraphic() 3534 { 3535 FormExportReport *formularioReporte = new FormExportReport(this); 3536 formularioReporte->setWindowTitle("Exportar Gráfico"); 3537 formularioReporte->ui->label->setText("Guardar Gráifco"); 3538 formularioReporte->ui->label_3->setText("Seleccione la ruta para guardar el gráfico"); 3539 disconnect(formularioReporte->ui->ButtonCargar,SIGNAL(clicked()),formularioReporte,SLOT(slotLoad())); 3540 disconnect(formularioReporte->ui->ButtonGenerar,SIGNAL(clicked()),formularioReporte,SLOT(slotClicked())); 3541 connect(formularioReporte->ui->ButtonCargar,SIGNAL(clicked()),formularioReporte,SLOT(slotLoadGraphic())); 3542 connect(formularioReporte->ui->ButtonGenerar,SIGNAL(clicked()),formularioReporte,SLOT(slotClickedGraphic())); 3543 connect(formularioReporte,SIGNAL(formAccepted(QString,bool)),this,SLOT(slotGenerarEncadenamientoReport(QString,bool))); 3568 3544 formularioReporte->show(); 3569 3545 } … … 3573 3549 @date 31/08/2015 3574 3550 @author Rodrigo Boet 3575 */ 3576 void MainWindow::slotGenerarEncadenamientoReport(QString filename) 3551 @param <filename> Recibe el nombre del archivo 3552 @param <report> recibe un booleano (true si es reporte, falso en caso contrario) 3553 */ 3554 void MainWindow::slotGenerarEncadenamientoReport(QString filename, bool report) 3577 3555 { 3578 3556 int indice = tabWidget->currentIndex(); … … 3581 3559 int row = tw->rowCount(); 3582 3560 int col = tw->columnCount(); 3561 QVector<double> x, y; 3583 3562 QStringList myHtml; 3584 3563 myHtml.append("<table>"); … … 3589 3568 { 3590 3569 QString item = tw->item(i,j)->text(); 3591 myHtml.append("<td>"+item+"</td>"); 3570 //Comprende las filas superiores 3571 if(i==0 and j>1) 3572 { 3573 myHtml.append("<td align='center' style='font-weight:bold;background-color:LightGrey;'>"+item+"</td>"); 3574 } 3575 //Comprende las cuentas en la parte izquierda 3576 else if((i>0 and i<row-1) and j==0) 3577 { 3578 myHtml.append("<td style='background-color:steelblue;color:white'>"+item+"</td>"); 3579 } 3580 //Comprende las subcuentas en la parte izquierda 3581 else if((i>0 and i<row-1)and j==1) 3582 { 3583 myHtml.append("<td align='center' style='background-color:LightGrey'>"+item+"</td>"); 3584 } 3585 //Comprende la última fila 3586 else if(i==row-1) 3587 { 3588 myHtml.append("<td align='center' style='font-weight:bold'>"+item+"</td>"); 3589 } 3590 //Comprende el resto de los elementos 3591 else 3592 { 3593 myHtml.append("<td align='center'>"+item+"</td>"); 3594 } 3595 if((i>0 and i<row-1) and (j>3 and j<col-1)) 3596 { 3597 QString titem = Separador(tw->item(i,j),true); 3598 double valor = titem.toDouble(); 3599 if(j==4) 3600 { 3601 x.append(valor); 3602 } 3603 else 3604 { 3605 y.append(valor); 3606 } 3607 } 3592 3608 } 3593 3609 myHtml.append("</tr>"); 3594 3610 } 3595 3611 myHtml.append("</table>"); 3612 //Máximos y Mínimos 3613 double max = 3; 3614 double min = -1; 3615 //Gráfico 3596 3616 QCustomPlot *customPlot = new QCustomPlot; 3597 QVector<double> x(101), y(101); // initialize with entries 0..1003598 for (int i=0; i<10; ++i)3599 {3600 x[i] = i/5.0 - 1; // x goes from -1 to 13601 y[i] = x[i]*x[i]; // let's plot a quadratic function3602 }3603 3617 // create graph and assign data to it: 3604 3618 customPlot->addGraph(); 3605 3619 customPlot->graph(0)->setData(x, y); 3606 //customPlot->graph(0)->setLineStyle(QCPGraph::lsNone);3620 customPlot->graph(0)->setLineStyle(QCPGraph::lsNone); 3607 3621 customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCross, 4)); 3622 // set title of plot: 3623 customPlot->plotLayout()->insertRow(0); 3624 customPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(customPlot, "Clasificación de Cuentas")); 3608 3625 // give the axes some labels: 3609 3626 customPlot->xAxis->setLabel("-y"); 3627 customPlot->xAxis->setTickStep(1); 3628 customPlot->xAxis->setAutoTickStep(false); 3629 customPlot->xAxis->setSubTickCount(5); 3610 3630 customPlot->yAxis->setLabel("-x"); 3631 customPlot->yAxis->setAutoTickStep(false); 3632 customPlot->yAxis->setTickStep(1); 3633 customPlot->yAxis->setSubTickCount(5); 3611 3634 customPlot->xAxis2->setLabel("y"); 3635 customPlot->xAxis2->setAutoTickStep(false); 3636 customPlot->xAxis2->setTickStep(1); 3637 customPlot->xAxis2->setSubTickCount(5); 3612 3638 customPlot->yAxis2->setLabel("x"); 3639 customPlot->yAxis2->setAutoTickStep(false); 3640 customPlot->yAxis2->setTickStep(1); 3641 customPlot->yAxis2->setSubTickCount(5); 3613 3642 // set axes ranges, so we see all data: 3614 customPlot->xAxis->setRange( -5, 5);3615 customPlot->yAxis->setRange( -5, 5);3616 customPlot->xAxis2->setRange( -5, 5);3617 customPlot->yAxis2->setRange( -5, 5);3643 customPlot->xAxis->setRange(min, max); 3644 customPlot->yAxis->setRange(min, max); 3645 customPlot->xAxis2->setRange(min, max); 3646 customPlot->yAxis2->setRange(min, max); 3618 3647 customPlot->xAxis2->setVisible(true); 3619 3648 customPlot->yAxis2->setVisible(true); 3649 // flecha 3650 QCPItemStraightLine *newY = new QCPItemStraightLine(customPlot); 3651 customPlot->addItem(newY); 3652 newY->point1->setCoords(1,3); 3653 QCPItemStraightLine *newX = new QCPItemStraightLine(customPlot); 3654 customPlot->addItem(newX); 3655 newX->point1->setCoords(3,1); 3656 //Se crean los labels 3657 QCPItemText *claveText = new QCPItemText(customPlot); 3658 customPlot->addItem(claveText); 3659 claveText->position->setCoords(max-0.5, max-0.5); 3660 claveText->setPositionAlignment(Qt::AlignBottom|Qt::AlignHCenter); 3661 claveText->setPen(QPen(Qt::black)); 3662 claveText->setText("Clave"); 3663 claveText->setFont(QFont(font().family(), 10)); 3664 QCPItemText *baseText = new QCPItemText(customPlot); 3665 customPlot->addItem(baseText); 3666 baseText->position->setCoords(min+0.5, max-0.5); 3667 baseText->setPositionAlignment(Qt::AlignBottom|Qt::AlignHCenter); 3668 baseText->setPen(QPen(Qt::black)); 3669 baseText->setText("Base"); 3670 baseText->setFont(QFont(font().family(), 10)); 3671 QCPItemText *indepentientesText = new QCPItemText(customPlot); 3672 customPlot->addItem(indepentientesText); 3673 indepentientesText->position->setCoords(min+0.8, min+0.5); 3674 indepentientesText->setPositionAlignment(Qt::AlignBottom|Qt::AlignHCenter); 3675 indepentientesText->setPen(QPen(Qt::black)); 3676 indepentientesText->setText("Independiente"); 3677 indepentientesText->setFont(QFont(font().family(), 10)); 3678 QCPItemText *fuertearrastreText = new QCPItemText(customPlot); 3679 customPlot->addItem(fuertearrastreText); 3680 fuertearrastreText->position->setCoords(max-0.8, min+0.5); 3681 fuertearrastreText->setPositionAlignment(Qt::AlignBottom|Qt::AlignHCenter); 3682 fuertearrastreText->setPen(QPen(Qt::black)); 3683 fuertearrastreText->setText("Impulsor"); 3684 fuertearrastreText->setFont(QFont(font().family(), 10)); 3685 //Se generan los cambios en el grafico 3620 3686 customPlot->replot(); 3621 3687 3622 QTextDocument report; 3623 report.setHtml(myHtml.join("")); 3624 QTextCursor cursor(&report); 3625 QPixmap pm = customPlot->toPixmap(); 3626 QImage img = pm.toImage(); 3627 cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); 3628 cursor.insertImage(img); 3629 QPrinter printer( QPrinter::HighResolution ); 3630 printer.setOutputFileName(filename); 3631 printer.setOutputFormat(QPrinter::PdfFormat); 3632 report.print(&printer); 3688 QString reportText; 3689 //Se evalua si es un reporte 3690 if(report){ 3691 QTextDocument report; 3692 report.setHtml(myHtml.join("")); 3693 QTextCursor cursor(&report); 3694 QPixmap pm = customPlot->toPixmap(); 3695 QImage img = pm.toImage(); 3696 cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); 3697 cursor.insertImage(img); 3698 QPrinter printer( QPrinter::HighResolution ); 3699 printer.setOutputFileName(filename); 3700 printer.setOutputFormat(QPrinter::PdfFormat); 3701 report.print(&printer); 3702 reportText = "Se generó con éxito el reporte\n en "+filename; 3703 } 3704 else 3705 { 3706 customPlot->savePng(filename); 3707 reportText = "Se generó con éxito el gráfico en "+filename; 3708 } 3709 //Mensaje de confimación 3710 QMessageBox::information(this,"Reporte",reportText); 3633 3711 3634 3712 /*QPainter painter( &printer );
Note: See TracChangeset
for help on using the changeset viewer.