00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00158
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
00231 system("Xvfb :5.0 -ac -fbdir /tmp -screen 0 800x600x8 &");
00232 system("xmodmap -display :5.0 /usr/X11R6/lib/X11/xmodmap.std");
00233
00234
00235 command = "acroread -display :5.0 -geometry 800x600+0+0 -tempFile +useFrontEndProgram " + m_pdfname + " &";
00236 system(command.toAscii().constData());
00237
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
00251
00252 }
00253
00254 macro.open(QIODevice::WriteOnly);
00255 m_output.setDevice(¯o);
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
00267
00268 macro.open(QIODevice::WriteOnly);
00269 m_output.setDevice(¯o);
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
00286
00287 macro.open(QIODevice::WriteOnly);
00288 m_output.setDevice(¯o);
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
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
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334