Vincent Rabeux avatar Vincent Rabeux committed 580c2bf Merge

Merged.

Comments (0)

Files changed (10)

Import scripts/convert.py

 import os, sys, getopt
 import Image
 import argparse
+from xml.dom.minidom import parse
 
 ###############################################################################
 # Font importer
                     if bwPix[y, x] == 0:            # if mask is black
                         outPix[y, x] = gPix[y, x];  # use grey level image
 
-            # setup name
+            # setup character name
+            xmlFile = coloFile = bwFile.rstrip('_bw.bmp')
+            xmlFile += '.xml'
+            xmlDom = parse(xmlFile);
+            charName = xmlDom.getElementsByTagName('Transcription')[0].getAttribute('Unicode')
+            charName = charName.replace('M+', 'U+')
+            
+            print charName
+            
             outFile = unicode(bwFile, 'utf8')
-            letter = outFile[0]
-            version = outFile[1]
-            outFileCustom = unicode(outRep + fontName +'_'+ letter +'_'+ version + ".bmp")
+            split = outFile.split('_')
+            mo = re.match(r'.*(\d+)$', split[0])
+            
+            if mo != None : 
+                version = mo.group(1)
+                outFileCustom = unicode(outRep + fontName +'_'+ charName +'_'+ version + ".bmp")
 
-            print outFileCustom
+                #print outFileCustom
 
-            outIm.save(outFileCustom, "BMP")
+                outIm.save(outFileCustom, "BMP")
 
-            print 'done'
+                print 'done'
     return "well done"
 
 

documentImageCreator/src/framework/DocumentCreator/iomanager/parametricdocumentloader.cpp

 #include <QTextStream>
 #include <QString>
 #include <QFile>
+#include <iostream>
+#include <QDebug>
 
 namespace IOManager
 {
         _y(_margin),
         _w(_pageWidth-100),
         _h(_pageHeight-100),
-        _styleName("default")
+        _fontname("")
 
     {
         _reader = new CmdLineParser(_input);
     //protected:
     DocStyle * ParametricDocumentLoader::buildStyle ()
     {
-        DocStyle * s = new DocStyle(_styleName);
-        s->setFontName( _reader->value("font") );
+        _fontname = _reader->value("font");
+
+        if(_fontname.isEmpty() ) {
+            qDebug() << "bad font name";
+            return NULL;
+        }
+
+        DocStyle * s = new DocStyle(_fontname);
+        s->setFontName(_fontname);
         return s;
     }
 
     Page * ParametricDocumentLoader::buildPage ()
     {
+        QString bg = _reader->value("bg");
+        QString filename = _reader->value("inputfile");
+
+        if(bg.isEmpty() ) {
+            qDebug() << "bad background name";
+            return NULL;
+        }
+
+        if(filename.isEmpty() ) {
+            qDebug() << "bad file name";
+            return NULL;
+        }
+
         Page * p = new Page(_output);
-        p->setBackgroundFileName( _reader->value("bg") );
+        p->setBackgroundFileName(bg);
 
         //load texte file
-        loadTextFile(_reader->value("inputfile"), p);
+        loadTextFile(filename, p);
 
         return p;
     }
         while(!in.atEnd())
         {
             QString line = in.readLine();
+            //std::cout << line.toStdString() << std::endl;
 
             if(line.isEmpty() && ! paragraph.isEmpty()) {
                 _paragraphs << paragraph;
                 paragraph.clear();
             } else {
-                paragraph << line.toLocal8Bit(); // convert to locale multi-byte string
+                paragraph << line.toLocal8Bit() << " "; // convert to locale multi-byte string
             }
         }
         _paragraphs << paragraph;
     DocString * ParametricDocumentLoader::buildString (QString str)
     {
         // TODO : default style
-        DocStyle* style = _output->getStyle(_styleName);
+        DocStyle* style = _output->getStyle(_fontname);
         DocString* s = new DocString(style ,_output);
         foreach (const QChar c, str) {
             s->add( buildCharacter(c) );
     DocCharacter * ParametricDocumentLoader::buildCharacter (){}
     DocCharacter * ParametricDocumentLoader::buildCharacter (const QChar ch)
     {
-        QAtomicInt id = 1;
+        QAtomicInt id = -1;
         QString display = ch;
-
         DocCharacter * c = new DocCharacter(display, id, _output);
 
         return c;

documentImageCreator/src/framework/DocumentCreator/iomanager/parametricdocumentloader.h

             //Attributes
             CmdLineParser * _reader;
             QList<QStringList> _paragraphs;
-            QString _styleName;
+            QString _fontname;
             QAtomicInt _pageWidth;
             QAtomicInt _pageHeight;
             QAtomicInt _margin;

documentImageCreator/src/framework/DocumentCreator/models/character.cpp

     /* Getters */
     CharacterData* Character::getRandomCharacterData() const
     {
-		if (this->_dataMap.values().isEmpty())
+        if (this->_dataMap.values().isEmpty())
             return NULL;
 
-		qsrand(QDateTime::currentDateTime ().toTime_t ());
-		QAtomicInt randomIndex=qrand() % _dataMap.keys().length();
-		       
+        int r = qrand();
+        QAtomicInt randomIndex = r % _dataMap.keys().length();
+
 		return this->_dataMap.values().at(randomIndex);
     }
+
     CharacterData* Character::getCharacterData(QAtomicInt id) const
     {
         if (this->_dataMap.contains(id))

documentImageCreator/src/framework/DocumentCreator/models/doc/doccharacter.h

 
 		void setX(QAtomicInt x) { _rect.setX(x); }
 		void setY(QAtomicInt y) { _rect.setY(y); }
+        void setId(QAtomicInt id) { _id = id; }
 		void setWidth(QAtomicInt width) { _rect.setWidth(width); }
 		void setHeight(QAtomicInt height) { _rect.setHeight(height); }
 

documentImageCreator/src/gui/AncientDocumentEditor/CMakeLists.txt

 " COMPONENT Runtime)
 
 ## On install les fichiers de conf dans le bundle :
+MESSAGE(${Lipsum4Qt_LIBRARIES})
+MESSAGE(${NAME}.app/Contents/Frameworks)
 
-
-install (DIRECTORY ${Lipsum4Qt_LIBRARIES} DESTINATION ${NAME}.app/Contents/Frameworks)
+install (FILES ${Lipsum4Qt_LIBRARIES} DESTINATION ${NAME}.app/Contents/Frameworks)
 
 #--------------------------------------------------------------------------------
 # On copie le qt_menu.nib de QT dans le bundle courant

documentImageCreator/src/gui/AncientDocumentEditor/src/Document/graphicstextblockitem.cpp

 #include "graphicstextblockitem.h"
 #include "graphicspageitem.h"
 #include <DocumentCreator/context.h>
+#include <iostream>
+
 using namespace Context;
 
 #include "documentcontroller.h"
     Character * character = font->getCharacter( c->getDisplay() );
     if(character == NULL)
         return;
+
+    if(c->getId() == -1)
+        c->setId( character->getRandomCharacterData()->getId() );
+
     CharacterData* data = character->getCharacterData(c->getId());
     if(data == NULL)
         return ;

documentImageCreator/src/gui/AncientDocumentEditor/src/ancientdocumenteditor.cpp

 #include <QXmlSchema>
 #include <QXmlSchemaValidator>
 #include <QApplication>
+#include <QDebug>
 
 #include "Utils/messagehandler.h"
 #include "Degradations/BleedThrough.hpp"
 AncientDocumentEditor::AncientDocumentEditor()
 {
     hide();
+    qsrand(QDateTime::currentDateTime ().toTime_t ());
     _docController = NULL;
     _fontController = NULL;
     _keyboardController = NULL;
 
     setCentralWidget(central);
     setUnifiedTitleAndToolBarOnMac(true);
-    //showMaximized();
 
     setWindowIcon(QIcon(":/appicon"));
 
         CmdLineParser parser(cmdline);
 
         QString rep = parser.value("inputrep");
+        QString filename = parser.value("inputfile");
         QStringList filters;
         filters<<"*.txt";
 
         }
 
         // if working on a single file
-        else generateDocument(cmdline);
+        else if (!filename.isEmpty())
+            generateDocument(cmdline);
+
+        else
+            qDebug() << "error in file/repertory argument";
     }
 
     exit(0);

documentImageCreator/src/gui/AncientDocumentEditor/src/main.cpp

 
 #include "Document/lipsum.h"
 
+/**
+  * AncientDocumentEditor has two modes :
+  *
+  * 1) standard : run in GUI mode, let user import font, write texte, export, etc
+  * 2) command line mode : generate an image from a specific texte file
+  *     args are :
+  *     --font="fontname" : select a specific font for rendering
+  *     --bg="backgound.jpg" : select a specific background image for rendering
+  *     --inputfile="input.txt" : set an input file to read an render
+  *     --inputrep="directoryName" : set an input directory, will scan all textes files and render them
+  **/
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);

libs/Lipsum4Qt/CMakeLists.txt

 
 
 
-#INSTALL(FILES ${Lipsum4Qt_headers} DESTINATION include/${LIB_NAME})
+INSTALL(FILES ${Lipsum4Qt_headers} DESTINATION include/${LIB_NAME})
 
 
 INSTALL(TARGETS ${LIB_NAME}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.