modelosps.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Josep Burcion                                   *
00003  *   josep@burcion.com                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include <stdio.h>
00022 #include <fstream>
00023 #include <iostream>
00024 
00025 #include <QString>
00026 #include <QComboBox>
00027 #include <QRadioButton>
00028 #include <QLineEdit>
00029 #include <QCustomEvent>
00030 #include <QTextStream>
00031 #include <QMessageBox>
00032 #include <QObject>
00033 
00034 #include "modelosps.h"
00035 #include "configuracion.h"
00036 #include "postgresiface2.h"
00037 
00038 
00040 
00042 Modgenps::Modgenps() {
00043     _depura("Modgenps::Modgenps", 0);
00044     _depura("END Modgenps::Modgenps", 0);
00045 }
00046 
00047 
00049 
00051 Modgenps::~Modgenps() {
00052     _depura("Modgenps::~Modgenps", 0);
00053     _depura("Modgenps::~Modgenps", 0);
00054 }
00055 
00056 
00058 
00063 void Modgenps::formatdigits(QString *cad1, QString *cad2, float x) {
00064     _depura("Modgenps::formatdigits", 0);
00065     QString tempstr;
00067     tempstr.sprintf("%.2f", x);
00068     *cad2 = tempstr.section('.', 1, 1);
00069     *cad1 = tempstr.section('.', 0, 0);
00071     cad1->append(',');
00072     _depura("END Modgenps::formatdigits", 0);
00073 }
00074 
00075 
00077 
00082 void Modgenps::escrizq(QString cad, int x, int y) {
00083     _depura("Modgenps::escrizq", 0);
00086     m_output << "("<< cad<< ") " << x << " "<< y << " " << cad.length() << " escrizq\n";
00087     _depura("END Modgenps::escrizq", 0);
00088 }
00089 
00090 
00092 
00097 void Modgenps::escrizq(float valor, int x, int y) {
00098     _depura("Modgenps::escrizq", 0);
00099     QString tempstr;
00100     tempstr.sprintf("%g", valor);
00101     escrizq(tempstr, x, y);
00102     _depura("END Modgenps::escrizq", 0);
00103 }
00104 
00105 
00108 
00111 void Modgenps::escrder(QString cad,int x,int y) {
00112     _depura("Modgenps::escrder", 0);
00115     m_output << "("<< cad<< ") " << x << " " << y << " "<< cad.length() << " escrder\n";
00116     _depura("END Modgenps::escrder", 0);
00117 }
00118 
00119 
00121 
00126 void Modgenps::escrder(float valor, int x, int y) {
00127     _depura("Modgenps::escrder", 0);
00128     QString tempstr;
00129     tempstr.sprintf("%g", valor);
00130     escrder(tempstr, x, y);
00131     _depura("END Modgenps::escrder", 0);
00132 }
00133 
00134 
00136 
00140 void Modgenps::escrizqder(QString cad1, QString cad2, int x, int y) {
00141     _depura("Modgenps::escrizqder", 0);
00142     escrizq(cad1, x, y);
00143     escrder(cad2, x, y);
00144     _depura("END Modgenps::escrizqder", 0);
00145 }
00146 
00147 
00149 
00153 void Modgenps::escrizqder(float valor, int x, int y) {
00154     _depura("Modgenps::escrizqder", 0);
00155     QString cad1, cad2;
00156     formatdigits(&cad1, &cad2, valor);
00157 //    cout << "Si le digo" << valor << " me sale:\n";
00158 //    cout << "OJO!!!:"<< cad1.toAscii().constData() << " ," << cad2.toAscii().constData() <<"\n";
00159     escrizq(cad1, x, y);
00160     escrder(cad2, x, y);
00161     _depura("END Modgenps::escrizqder", 0);
00162 }
00163 
00164 
00166 
00171 void Modgenps::marca_casilla(QString marca, int x, int y) {
00172     _depura("Modgenps::marca_casilla", 0);
00173     escrder(marca, x - 2, y);
00174     _depura("END Modgenps::marca_casilla", 0);
00175 }
00176 
00177 
00179 
00181 void Modgenps::marcadeagua_borrador() {
00182     _depura("Modgenps::marcadeagua_borrador", 0);
00183     m_output << "gsave\n";
00184     m_output << "1 setgray\n";
00185     m_output << "newpath\n";
00186     m_output << "360 685 moveto\n";
00187     m_output << "567 685 lineto\n";
00188     m_output << "567 630 lineto\n";
00189     m_output << "360 630 lineto\n";
00190     m_output << "closepath\n";
00191     m_output << "fill\n";
00192     m_output << ".7 setgray\n";
00193     m_output << "/Helvetica-Bold findfont\n";
00194     m_output << "100 scalefont\n";
00195     m_output << "setfont\n";
00196     m_output << "147 107 moveto\n";
00197     m_output << "45 rotate\n";
00198     m_output << "(BORRADOR) true charpath\n";
00199     m_output << "stroke\n";
00200     m_output << "grestore\n";
00201     _depura("END Modgenps::marcadeagua_borrador", 0);
00202 }
00203 
00204 
00206 
00211 Genps_thread::Genps_thread(QString pdfnamepar, QString tempnamepar, QProgressDialog *dialpar) {
00212     _depura("Genps_thread::Genps_thread", 0);
00213     m_pdfname = pdfnamepar;
00214     m_tempname = tempnamepar;
00215     m_progressdia = dialpar;
00216     _depura("END Genps_thread::Genps_thread", 0);
00217 }
00218 
00219 
00221 
00223 void Genps_thread::run() {
00224     _depura("Genps_thread::run", 0);
00225     QTextStream m_output;
00226     QString command;
00228     command = "rm -f " + m_tempname;
00229     system(command.toAscii().constData());
00230 //    cout << "Llamando a XVfb...\n";
00231     system("Xvfb :5.0 -ac -fbdir /tmp -screen 0 800x600x8 &");
00232     system("xmodmap -display :5.0 /usr/X11R6/lib/X11/xmodmap.std");
00233 //    cout << "XVfb iniciado...\n";
00234 //    cout << "Iniciando acrobat reader...\n";
00235     command = "acroread -display :5.0 -geometry 800x600+0+0 -tempFile +useFrontEndProgram " + m_pdfname + " &";
00236     system(command.toAscii().constData());
00237 //    cout << "Acrobat reader iniciado...\n";
00238 
00239     QString macrofilename = QString(getenv("HOME")) + "/.bulmages/macrotmp";
00240     QFile macro(macrofilename);
00241 
00246 
00248     for (int i = 1; i < 11; i++) {
00249         sleep(1);
00250         //QCoreApplication::postEvent(m_progressdia, new QCustomEvent(sleep10));
00251 //        cout << i << "\n";
00252     } // end for
00253 
00254     macro.open(QIODevice::WriteOnly);
00255     m_output.setDevice(&macro);
00256     m_output << "MotionNotify 400 300\n";
00257     m_output << "KeyStrPress Control_L\n";
00258     m_output << "KeyStrPress p\n";
00259     m_output << "KeyStrRelease p\n";
00260     m_output << "KeyStrRelease Control_L\n";
00261     macro.close();
00262     command = "xmacroplay :5.0 < " + macrofilename;
00263     system(command.toAscii().constData());
00264 
00265     sleep(1);
00266     //QCoreApplication::postEvent(m_progressdia, new QCustomEvent(sleep3));
00267 
00268     macro.open(QIODevice::WriteOnly);
00269     m_output.setDevice(&macro);
00270     m_output << "KeyStrPress Tab\n";
00271     m_output << "KeyStrRelease Tab\n";
00272     m_output << "KeyStrPress Down\n";
00273     m_output << "KeyStrRelease Down\n";
00274     m_output << "KeyStrPress space\n";
00275     m_output << "KeyStrRelease space\n";
00277     m_output << "String "<< m_tempname+"\n";
00278     m_output << "KeyStrPress Return\n";
00279     m_output << "KeyStrRelease Return\n";
00280     macro.close();
00281     command = "xmacroplay :5.0 < " + macrofilename;
00282     system(command.toAscii().constData());
00283 
00284     sleep(3);
00285     //QCoreApplication::postEvent(m_progressdia, new QCustomEvent(sleep3));
00286 
00287     macro.open(QIODevice::WriteOnly);
00288     m_output.setDevice(&macro);
00289     m_output << "KeyStrPress Control_L\n";
00290     m_output << "KeyStrPress q\n";
00291     m_output << "KeyStrRelease q\n";
00292     m_output << "KeyStrRelease Control_L\n";
00293     macro.close();
00294     command = "xmacroplay :5.0 < " + macrofilename;
00295     system(command.toAscii().constData());
00296 
00298     command = "kill $(ps aux|grep 'Xvfb :5.0'|grep -v grep|awk '{print $2}')";
00299     system(command.toAscii().constData());
00300 //    cout << "Se acabo!!\n";
00301     _depura("END Genps_thread::run", 0);
00302 }
00303 
00304 
00306 
00314 Psprogressdialog::Psprogressdialog(QString etiqueta, QString btcancelar, int minimo, int maximo, QWidget *widget, Qt::WFlags bandera)
00315         : QProgressDialog(etiqueta, btcancelar, minimo, maximo, widget, bandera) {
00316     _depura("Psprogressdialog::Psprogressdialog", 0);
00317     _depura("END Psprogressdialog::Psprogressdialog", 0);
00318 }
00319 
00320 /*
00321 void Psprogressdialog::customEvent(QCustomEvent *event) {
00322     if ((int)event->type() == sleep10) {
00323         this->setValue(value() + 5);
00324     } // end if
00325     if ((int)event->type() == sleep3) {
00326         this->setValue(value() + 25);
00327     } // end if
00328     if (value() > 98) {
00329         setValue(100);
00330     } // end if
00331 }
00332 
00333 */
00334 

Generated on Sat Dec 15 00:01:04 2007 for BulmaGes by  doxygen 1.5.1