Commit 6ee8d7bc authored by antoine's avatar antoine

Merge branch 'master' of gitlab.constantvzw.org:osp/workshop.metahoguet

parents 2a2b85ce e3b6dd3c
for (( ; ; )); for (( ; ; ));
do do
mkdir -p svg eps mkdir -p svg eps
rm -f svg/*.svg
rm -f eps/*.eps
echo 'prologues := 3; outputtemplate := "%c.eps";' > eps/metahoguet.eps.mp echo 'prologues := 3; outputtemplate := "%c.eps";' > eps/metahoguet.eps.mp
echo 'outputtemplate := "%c.svg";' > svg/metahoguet.svg.mp echo 'outputtemplate := "%c.svg";' > svg/metahoguet.svg.mp
curl http://osp.constantvzw.org:9999/p/metahoguet/export/txt | tee -a eps/metahoguet.eps.mp >> svg/metahoguet.svg.mp curl http://osp.constantvzw.org:9999/p/metahoguet/export/txt | tee -a eps/metahoguet.eps.mp >> svg/metahoguet.svg.mp
cd svg cd svg
mpost -interaction=batchmode -s 'outputformat="svg"' metahoguet.svg.mp mpost -interaction=batchmode -s 'outputformat="svg"' metahoguet.svg.mp
cd .. cd ..
cd eps cd eps
mpost -interaction=batchmode -s 'outputformat="eps"' eps/metahoguet.eps.mp mpost -interaction=batchmode -s 'outputformat="eps"' eps/metahoguet.eps.mp
cd .. cd ..
sleep 3 sleep 2
done done
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>- </title> <title>- </title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
img { img {
height: 200px;; height: 200px;;
width: auto; width: auto;
overflow: visible; overflow: visible;
} }
footer{ footer{
bottom: 0px; bottom: 0px;
...@@ -37,81 +37,85 @@ ...@@ -37,81 +37,85 @@
color: grey; color: grey;
} }
</style> </style>
</head> </head>
<body> <body>
<footer> <footer>
<button onclick="Zoom('up')">+</button> <button onclick="Zoom('up')">+</button>
<button onclick="Zoom('down')">-</button> <button onclick="Zoom('down')">-</button>
<button onclick="Compare()">Compare</button> <button onclick="Compare()">Compare</button>
<span id="type"></span> <span id="type"></span>
</footer> </footer>
<script> <script>
var elt = []; var elt = [];
function splitHash(){ function splitHash(){
var startImg = window.location.hash; var startImg = window.location.hash;
startImg = startImg.substring(2); startImg = startImg.substring(2);
elt = startImg.split("-"); elt = startImg.split("-");
} }
splitHash();
if(elt.length > 0){
for(i=0; i < elt.length; i++){
console.log(elt[i]);
$( "body" ).append('<img id="letter_'+i+'" title="cliquez pour imprimer" src="svg/'+elt[i]+'.svg" />');
}
}
function Zoom(valZ){
var imgH = $('img').height();
if(valZ == 'up'){
imgH = imgH + 50;
}else if (valZ == 'down'){
imgW = imgW - 50;
}
$('img').css("height", imgW);
}
function Compare(){ splitHash();
$('img').toggleClass('compare');
}
function testing () { if(elt.length > 0){
$("body").keydown( function( event ) { for(i=0; i < elt.length; i++){
if (event.key == "Backspace" ) { console.log(elt[i]);
var startImg = window.location.hash; $( "body" ).append('<img id="letter_'+i+'" title="cliquez pour imprimer" src="svg/'+elt[i]+'.svg?'+ (new Date()).getTime() + '" />');
var newUrl = startImg.lastIndexOf('-'); }
window.location.hash = startImg.substring(0, newUrl); }
$('img').last().remove();
} function Zoom(valZ){
}) var imgH = $('img').height();
$( "body" ).keypress(function(event) { if(valZ == 'up'){
var savehash = window.location.hash; imgH = imgH + 50;
savehash = savehash.substring(1); }else if (valZ == 'down'){
$( "body" ).append('<img src="svg/'+event.keyCode+'.svg" />'); imgW = imgW - 50;
console.log(event.keyCode); }
savehash += '-'+event.keyCode; $('img').css("height", imgH);
window.location.hash = savehash; }
Zoom();
});
} function Compare(){
$("body").on("click", "img", function(){ $('img').toggleClass('compare');
var result = window.confirm('voulez-vous imprimer ce glyph ?'); }
if(result){ function testing () {
var path = $(this).attr('src').replace(/svg/g, 'eps'); $("body").keydown( function( event ) {
if (event.key == "Backspace" ) {
var startImg = window.location.hash;
var newUrl = startImg.lastIndexOf('-');
window.location.hash = startImg.substring(0, newUrl);
$('img').last().remove();
}
})
$.get('/api/ploteps/', { epsfile : path }); $( "body" ).keypress(function(event) {
} var savehash = window.location.hash;
}); savehash = savehash.substring(1);
setTimeout(function(){ $( "body" ).append('<img src="svg/'+event.keyCode+'.svg?'+ (new Date()).getTime() + '" />');
window.location.reload(1); console.log(event.keyCode);
}, 5000); savehash += '-'+event.keyCode;
window.location.hash = savehash;
testing(); Zoom();
});
</script> }
</body>
</html> $("body").on("click", "img", function(){
var result = window.confirm('voulez-vous imprimer ce glyph ?');
if(result){
var path = $(this).attr('src').split('?')[0].replace(/svg/g, 'eps');
$.get('/api/ploteps/', { epsfile : path });
}
});
setInterval(function(){
stamp = (new Date).getTime();
$("img").each(function () {
var src = $(this).attr('src').split('?')[0];
$(this).attr('src', src + '?' + stamp);
});
}, 7000);
testing();
</script>
</body>
</html>
...@@ -10,51 +10,81 @@ from plottertools.textbox import Textbox ...@@ -10,51 +10,81 @@ from plottertools.textbox import Textbox
from chiplotle.geometry.core.coordinate import Coordinate from chiplotle.geometry.core.coordinate import Coordinate
from settings import db from settings import db
import os.path import os.path
import shutil
from flask import Flask, Response, app, request, render_template from flask import Flask, Response, app, request, render_template
marginleft = 30 # margin left in mm marginleft = 30 # margin left in mm
marginbottom = (297 / 3) # margin bottom in mm marginbottom = (271.75 / 3) # margin bottom in mm
page = { page = {
'left': marginleft * -40, 'left': int(marginleft * -40),
'right': (210 - marginleft) * 40, 'right': int((190 - marginleft) * 40),
'bottom': marginbottom * -40, 'bottom': int(marginbottom * -40),
'top': (297 - marginbottom) * 40 'top': int((271.75 - marginbottom) * 40)
} }
pen = 1 pen = 1
speed = 10 speed = 10
force = 1 force = 1
font=Font(path='fonts/converted/futural.fnt', resolution=1, scale=3) font=Font(path='fonts/converted/futural.fnt', resolution=1, scale=4.5)
app = Flask(__name__) app = Flask(__name__)
@app.route("/api/ploteps/") @app.route("/api/ploteps/")
def ploteps(): def ploteps():
epsfile = request.args.get('epsfile') epsfile = request.args.get('epsfile')
hpglfile = './{}.hpgl'.format(os.path.splitext(epsfile)[0]) charnum = os.path.splitext(os.path.basename(epsfile))[0]
svgfile = './svg/{}.svg'.format(charnum)
hpglfile = './hpgl/{}.hpgl'.format(charnum)
shutil.copy(svgfile, './svg/snaps/{}-{}.svg'.format(charnum, int(time.time())))
# converting eps to hpgl # converting eps to hpgl
subprocess.call([ subprocess.call([
'./eps2hpgl.sh', 'pstoedit',
'./{0}'.format(epsfile) '-f',
'plot-hpgl',
epsfile,
hpglfile
]) ])
handle = open(hpglfile) handle = open(hpglfile)
shape = ''.join(handle.readlines()).replace('\n', '') dirtyhpgl = ''.join(handle.readlines()).replace('\n', '')
cleanhpglchunks = []
pen = 1
pencount = 4
penmap = {}
for chunk in dirtyhpgl.split(';'):
if chunk[0:2] in ['PA', 'PR', 'PU', 'PD']:
cleanhpglchunks.append(chunk)
elif chunk[0:2] == 'SP':
sourcepen = int(chunk[2])
if not sourcepen in penmap:
pen += 1
if pen > pencount:
pen = 1
penmap[sourcepen] = pen
cleanhpglchunks.append('SP{}'.format(penmap[sourcepen]))
cleanhpgl = ';'.join(cleanhpglchunks)
textbox = Textbox( textbox = Textbox(
font=font, font=font,
width = 50 * 40, width = 75 * 40,
position = Coordinate(page['right'] - (55 * 40), page['bottom'] + (12 * 40)), position = Coordinate(page['right'] - (80 * 40), page['bottom'] + (12 * 40)),
align = Textbox.alignLeft, align = Textbox.alignLeft,
lineHeight=1.40 lineHeight=1.40
) )
textbox.insertText('{0} \n{1} \n\ntype.code, Maison du Livre, Bruxelles'.format(hpglfile, datetime.now().strftime("%d-%m-%Y %H:%M"))) textbox.insertText('{0} \n{1} \n\ntype.code, Maison du Livre, Bruxelles'.format(hpglfile, datetime.now().strftime("%d-%m-%Y %H:%M")))
hpgl = 'SC{0},{1},{2},{3};SP{4};FS{5};VS{6};PU;{7};PU;'.format(page['left'], page['right'], page['bottom'], page['top'], pen, force, speed, shape) hpgl = 'IN;RO90;IP0,0,7600,10870;SC{0},{1},{2},{3};FS{5};SP{4};VS{6};PU;{7};PU;'.format(page['left'], page['right'], page['bottom'], page['top'], pen, force, speed, cleanhpgl)
# hpgl += box((page['left'] + 200, page['bottom'] + 200), 200 * 40, 287 * 40) # hpgl += box((page['left'] + 200, page['bottom'] + 200), 200 * 40, 287 * 40)
hpgl += textbox.hpgl() hpgl += textbox.hpgl()
......
../pad/hpgl
\ No newline at end of file
...@@ -25,7 +25,7 @@ while True: ...@@ -25,7 +25,7 @@ while True:
if plot: if plot:
try: try:
plotter.write(str(plot['hpgl'].decode('utf-8'))) plotter.write('IN;{};PG;'.format(str(plot['hpgl'].decode('utf-8'))))
plotter._serial_port.flush() plotter._serial_port.flush()
......
../pad/svg/
\ No newline at end of file
% To run the API % To run the API
screen -S api screen -S api
cd /home/pi/Documents/osp.work.metahoguet/plotter cd /home/pi/Documents/osp.workshop.metahoguet/plotter
. /home/pi/venvs/metahoguet/bin/activate . /home/pi/venvs/metahoguet/bin/activate
python wsgi.py gunicorn --bind 0.0.0.0:5555 --workers 3 wsgi:app
sudo service nginx reload
% !!! ctr+a d % !!! ctr+a d
% To run the plotter % To run the plotter
screen -S plotter screen -S plotter
cd /home/pi/Documents/osp.work.metahoguet/plotter cd /home/pi/Documents/osp.workshop.metahoguet/plotter
. /home/pi/venvs/metahoguet/bin/activate . /home/pi/venvs/metahoguet/bin/activate
python runner.py python runner.py
...@@ -20,7 +21,7 @@ python runner.py ...@@ -20,7 +21,7 @@ python runner.py
% To run the mpost downloaded % To run the mpost downloaded
screen -S mpost screen -S mpost
cd /home/pi/Documents/osp.work.metahoguet/pad cd /home/pi/Documents/osp.workshop.metahoguet/pad
bash exportMeta.sh bash exportMeta.sh
% !!! ctr+a d % !!! ctr+a d
...@@ -34,6 +35,6 @@ screen -r plotter ...@@ -34,6 +35,6 @@ screen -r plotter
python runner.py python runner.py
% !!! ctr+a d % !!! ctr+a d
screen -S mpost screen -r mpost
bash exportMeta.sh bash exportMeta.sh
% !!! ctr+a d % !!! ctr+a d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment