Merge branch 'dev/objeto_preview' into 'main'

Dev/objeto preview

See merge request jjimenez/safekat!97
This commit is contained in:
Ignacio Martinez Navajas
2023-12-27 09:43:19 +00:00
3 changed files with 190 additions and 319 deletions

View File

@ -189,6 +189,7 @@ return [
'previewGramaje' => 'Gramaje',
'previewMano' => 'Mano',
'previewLibro' => 'Libro',
'previewForma' => 'Forma',
'previewFormas' => 'Formas',
'previewLomo' => 'Lomo',
'previewSolapas' => 'Solapas',

View File

@ -118,7 +118,6 @@
<div class="col-3">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div class="row g-3 mb-3">
<div class="col-12">
<a id="pv_bn_pg" href="#" sk-url="<?= site_url('configuracion/papelesgenericos/edit/'); ?>" target="_blank">
@ -169,8 +168,11 @@
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewLibro") ?></dt>
<dd id="pv_bn_libro" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewForma") ?></dt>
<dd id="pv_bn_forma" class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewFormas") ?></dt>
<dd id="pv_bn_formas" class="col-6 text-left">TBD</dd>
<dd id="pv_bn_nFormas" class="col-6 text-left">TBD</dd>
</dl>
</div>
</div>
@ -178,7 +180,7 @@
<div class="col-9">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewPapelGenerico") ?></h6>
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div id="shape-container">
<div id="pv_bn_shape" class="draw-shapes"></div>
@ -194,7 +196,6 @@
<div class="col-3">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div class="row g-3 mb-3">
<div class="col-12">
<a id="pv_bnhq_pg" href="#" sk-url="<?= site_url('configuracion/papelesgenericos/edit/'); ?>" target="_blank">
@ -245,8 +246,11 @@
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewLibro") ?></dt>
<dd id="pv_bnhq_libro" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewForma") ?></dt>
<dd id="pv_bnhq_forma" class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewFormas") ?></dt>
<dd id="pv_bnhq_formas" class="col-6 text-left">TBD</dd>
<dd id="pv_bnhq_nFormas" class="col-6 text-left">TBD</dd>
</dl>
</div>
</div>
@ -254,7 +258,7 @@
<div class="col-9">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewPapelGenerico") ?></h6>
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div id="shape-container">
<div id="pv_bnhq_shape" class="draw-shapes"></div>
@ -270,7 +274,6 @@
<div class="col-3">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div class="row g-3 mb-3">
<div class="col-12">
<a id="pv_color_pg" href="#" sk-url="<?= site_url('configuracion/papelesgenericos/edit/'); ?>" target="_blank">
@ -321,8 +324,11 @@
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewLibro") ?></dt>
<dd id="pv_color_libro" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewForma") ?></dt>
<dd id="pv_color_forma" class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewFormas") ?></dt>
<dd id="pv_color_formas" class="col-6 text-left">TBD</dd>
<dd id="pv_color_nFormas" class="col-6 text-left">TBD</dd>
</dl>
</div>
</div>
@ -330,7 +336,7 @@
<div class="col-9">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewPapelGenerico") ?></h6>
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div id="shape-container">
<div id="pv_color_shape" class="draw-shapes"></div>
@ -346,8 +352,7 @@
<div class="col-3">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div class="row g-3 mb-3">
<div class="row g-3 mb-3">
<div class="col-12">
<a id="pv_colorhq_pg" href="#" sk-url="<?= site_url('configuracion/papelesgenericos/edit/'); ?>" target="_blank">
<div class="d-grid">
@ -397,8 +402,11 @@
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewLibro") ?></dt>
<dd id="pv_colorhq_libro" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewForma") ?></dt>
<dd id="pv_colorhq_forma" class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewFormas") ?></dt>
<dd id="pv_colorhq_formas" class="col-6 text-left">TBD</dd>
<dd id="pv_colorhq_nFormas" class="col-6 text-left">TBD</dd>
</dl>
</div>
</div>
@ -406,7 +414,7 @@
<div class="col-9">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewPapelGenerico") ?></h6>
<h6><?= lang("Presupuestos.previewMaquinaPlana") ?></h6>
<div id="shape-container">
<div id="pv_colorhq_shape" class="draw-shapes"></div>
@ -422,7 +430,6 @@
<div class="col-3">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
<div class="row g-3 mb-3">
<div class="col-12">
<a id="pv_rot_bn_pg" href="#" sk-url="<?= site_url('configuracion/papelesgenericos/edit/'); ?>" target="_blank">
@ -473,8 +480,9 @@
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewLibro") ?></dt>
<dd id="pv_rot_bn_libro" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewFormas") ?></dt>
<dd id="pv_rot_bn_formas" class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewForma") ?></dt>
<dd id="pv_rot_bn_forma" class="col-6 text-left">TBD</dd>
</dl>
</div>
</div>
@ -482,7 +490,7 @@
<div class="col-9">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewPapelGenerico") ?></h6>
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
<div id="shape-container">
<div id="pv_rot_bn_shape" class="draw-rot-shapes"></div>
@ -498,7 +506,6 @@
<div class="col-3">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
<div class="row g-3 mb-3">
<div class="col-12">
<a id="pv_rot_color_pg" href="#" sk-url="<?= site_url('configuracion/papelesgenericos/edit/'); ?>" target="_blank">
@ -550,8 +557,9 @@
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewLibro") ?></dt>
<dd id="pv_rot_color_libro" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewFormas") ?></dt>
<dd id="pv_rot_color_formas" class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewForma") ?></dt>
<dd id="pv_rot_color_forma" class="col-6 text-left">TBD</dd>
</dl>
</div>
</div>
@ -559,7 +567,7 @@
<div class="col-9">
<div class="p-4 mb-3 pb-3">
<!-- Configuraciones -->
<h6><?= lang("Presupuestos.previewPapelGenerico") ?></h6>
<h6><?= lang("Presupuestos.previewMaquinaRotativa") ?></h6>
<div id="shape-container">
<div id="pv_rot_color_shape" class="draw-rot-shapes"></div>
@ -616,6 +624,9 @@
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewMano") ?></dt>
<dd id="pv_cubierta_mano" class="col-sm-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold pv-solapas"><?= lang("Presupuestos.previewSolapas") ?></dt>
<dd id="pv_cubierta_solapas" class="col-sm-6 text-left pv-solapas">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewMaquina") ?></dt>
<dd id="pv_cubierta_maquina" class="col-6 text-left">TBDxTBD</dd>
@ -625,8 +636,11 @@
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewLibro") ?></dt>
<dd id="pv_cubierta_libro" class="col-6 text-left">TBDxTBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewForma") ?></dt>
<dd id="pv_cubierta_forma" class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewFormas") ?></dt>
<dd id="pv_cubierta_formas" class="col-6 text-left">TBD</dd>
<dd id="pv_cubierta_nFormas" class="col-6 text-left">TBD</dd>
</dl>
</div>
</div>
@ -691,8 +705,8 @@
<dt class="col-6 fw-semibold"><?= lang("Presupuestos.previewLomo") ?></dt>
<dd id='pv_ec_lomo' class="col-6 text-left">TBD</dd>
<dt class="col-6 fw-semibold pv-ec-solapas"><?= lang("Presupuestos.previewSolapas") ?></dt>
<dd id='pv_ec_solapas' class="col-6 text-left pv-ec-solapas">TBD</dd>
<dt class="col-6 fw-semibold pv-solapas"><?= lang("Presupuestos.previewSolapas") ?></dt>
<dd id='pv_ec_solapas' class="col-6 text-left pv-solapas">TBD</dd>
</dl>
</div>
</div>
@ -729,164 +743,51 @@ getVisibleTabs();
$('#tab-pv-bn').on( "click", function() {
let scV = 4;
let scH = 2;
cubiertaObjeto = {
idIndex: 'bn',
anchoMaquina: 487,
altoMaquina: 330,
anchoImpresion: 475,
altoImpresion: 310,
anchoLibro: 170/scH,
altoLibro: 240/scV,
solapas:45,
lomo:25,
formas: scH * scV,
formasH: scH,
formasV: scV
};
getObjetoLP('bn');
previewInteriorPlana(cubiertaObjeto);
previewInteriorPlana('bn');
} );
$('#tab-pv-bnhq').on( "click", function() {
let scV = 4;
let scH = 2;
cubiertaObjeto = {
idIndex: 'bnhq',
anchoMaquina: 487,
altoMaquina: 330,
anchoImpresion: 475,
altoImpresion: 310,
anchoLibro: 170/scH,
altoLibro: 240/scV,
solapas:45,
lomo:25,
formas: scH * scV,
formasH: scH,
formasV: scV
};
getObjetoLP('bnhq');
previewInteriorPlana(cubiertaObjeto);
previewInteriorPlana('bnhq');
} );
$('#tab-pv-color').on( "click", function() {
let scV = 2;
let scH = 2;
cubiertaObjeto = {
idIndex: 'color',
anchoMaquina: 487,
altoMaquina: 330,
anchoImpresion: 475,
altoImpresion: 310,
anchoLibro: 170/scH,
altoLibro: 240/scV,
solapas:45,
lomo:25,
formas: scH * scV,
formasH: scH,
formasV: scV
};
getObjetoLP('color');
previewInteriorPlana(cubiertaObjeto);
previewInteriorPlana('color');
} );
$('#tab-pv-colorhq').on( "click", function() {
let scV = 4;
let scH = 2;
cubiertaObjeto = {
idIndex: 'colorhq',
anchoMaquina: 487,
altoMaquina: 330,
anchoImpresion: 475,
altoImpresion: 310,
anchoLibro: 170/scH,
altoLibro: 240/scV,
solapas:45,
lomo:25,
formas: scH * scV,
formasH: scH,
formasV: scV
};
getObjetoLP('colorhq');
previewInteriorPlana(cubiertaObjeto);
previewInteriorPlana('colorhq');
} );
$('#tab-pv-rot-bn').on( "click", function() {
let scV = 3;
let scH = 1;
cubiertaObjeto = {
idIndex: 'rot_bn',
anchoMaquina: 520,
altoMaquina: 800,
anchoImpresion: 515,
altoImpresion: 800,
altoClick: 305,
anchoLibro: 170,
altoLibro: 240,
solapas:45,
lomo:25,
formas: scH * scV,
formasH: scH,
formasV: scV
};
getObjetoLP('rot_bn');
previewRotativa(cubiertaObjeto);
previewRotativa('rot_bn');
} );
$('#tab-pv-rot-color').on( "click", function() {
getObjetoLP('rot_color');
previewRotativa('rot_color');
} );
$('#tab-pv-cubierta').on( "click", function() {
getObjetoLP('cubierta');
cubiertaObjeto = {
idIndex: 'bn',
anchoMaquina: 487,
altoMaquina: 330,
anchoImpresion: 475,
altoImpresion: 310,
anchoLibro: 170,
altoLibro: 240,
solapas:45,
lomo:25,
formas: 1,
formasH: 1,
formasV: 1
};
previewConfiguracionCubierta(cubiertaObjeto);
previewInteriorPlana('cubierta');
} );
$('#tab-pv-esquema-cubierta').on( "click", function() {
getObjetoEC();
previewEsquemaCubierta(objEC);
previewEsquemaCubierta('ec');
} );

View File

@ -1,8 +1,8 @@
// Global parameters
var _isCosido = true;
var _offsetSolapas = 2; // millimeters
var objEC;
var pvObj;
var styles = {
@ -15,34 +15,33 @@ var sangradoValor = parseFloat(5); // mm
var offsetSolapaValor = parseFloat(3); // mm
function previewInteriorPlana(cubiertaObj) {
function previewInteriorPlana(lpTagName) {
// Local parameters
let margenTop = 3;
let guardaV = 0;
guardaH = 0;
let styleText = {size: 12, family: 'Public Sans'};
// Get the preview Object parameters
getObjetoLP(lpTagName);
// Calculos
// Configuracion de las guardas
// Guarda vertical
if (cubiertaObj.formasV > 1) {
//guardaV = (cubiertaObj.altoImpresion - (2 * margenTop) - (cubiertaObj.altoLibro * cubiertaObj.formasV)) / (cubiertaObj.formasV - 1);
if (pvObj.nFormasV > 1) {
guardaV = 3;
}
// Guarda horizontal
if (cubiertaObj.formasH > 1) {
if (pvObj.nFormasH > 1) {
guardaH = 3;
}
// Constantes relativas al libro
let LVo = cubiertaObj.altoLibro / 2;
let LHo = cubiertaObj.anchoLibro / 2;
// Constantes relativas a las dimnesiones de la forma
let LVo = pvObj.altoForma / 2;
let LHo = pvObj.anchoForma / 2;
// Clear the canvas element
$('#pv_' + cubiertaObj.idIndex + '_shape').empty();
$('#pv_' + pvObj.idIndex + '_shape').empty();
// Get the element for placing the graphical elements
var divPlana = document.getElementById('pv_' + cubiertaObj.idIndex + '_shape');
var divPlana = document.getElementById('pv_' + pvObj.idIndex + '_shape');
var _pvPlana = new Two({fitted: true}).appendTo(divPlana);
// Calculate the center of the canvas element
var origenPlana = new Two.Vector(_pvPlana.width / 2, _pvPlana.height / 2);
@ -50,8 +49,8 @@ function previewInteriorPlana(cubiertaObj) {
var areaMaquinaPlana = _pvPlana.makeRectangle(
origenPlana.x,
origenPlana.y,
cubiertaObj.anchoMaquina,
cubiertaObj.altoMaquina);
pvObj.anchoMaquina,
pvObj.altoMaquina);
areaMaquinaPlana.stroke = 'black';
areaMaquinaPlana.fill = '#E69F6E';
areaMaquinaPlana.linewidth = 1;
@ -59,85 +58,76 @@ function previewInteriorPlana(cubiertaObj) {
var areaImpresionPlana = _pvPlana.makeRectangle(
origenPlana.x,
origenPlana.y,
cubiertaObj.anchoImpresion,
cubiertaObj.altoImpresion);
pvObj.anchoImpresion,
pvObj.altoImpresion);
areaImpresionPlana.stroke = 'red';
areaImpresionPlana.fill = '#FCEAF1';
areaImpresionPlana.linewidth = 1;
var formas = [];
for (let iV = 0; iV < cubiertaObj.formasV; iV++) {
for (let iV = 0; iV < pvObj.nFormasV; iV++) {
for (let iH = 0; iH < cubiertaObj.formasH; iH++) {
for (let iH = 0; iH < pvObj.nFormasH; iH++) {
let _offsetX = ((((pvObj.nFormasH - 1) - 2 * iH) * LHo) + (((pvObj.nFormasH - 1) / 2 - iH) * guardaH));
let _offsetY = ((((pvObj.nFormasV - 1) - 2 * iV) * LVo) + (((pvObj.nFormasV - 1) / 2 - iV) * guardaV));
formas[iV + iH] = _pvPlana.makeRectangle(
origenPlana.x + ((((cubiertaObj.formasH - 1) - 2 * iH) * LHo) + (((cubiertaObj.formasH - 1) / 2 - iH) * guardaH)),
origenPlana.y + ((((cubiertaObj.formasV - 1) - 2 * iV) * LVo) + (((cubiertaObj.formasV - 1) / 2 - iV) * guardaV)),
cubiertaObj.anchoLibro,
cubiertaObj.altoLibro);
origenPlana.x + _offsetX,
origenPlana.y + _offsetY,
pvObj.anchoForma,
pvObj.altoForma);
formas[iV + iH].stroke = 'grey';
formas[iV + iH].fill = '#F4F8F2';
formas[iV + iH].linewidth = 1;
// Texts
_pvPlana.makeText(pvObj.altoForma, (origenPlana.x + _offsetX) + (pvObj.anchoForma / 2 - 25), (origenPlana.y + _offsetY), styleText);
_pvPlana.makeText(pvObj.anchoForma, (origenPlana.x + _offsetX), (origenPlana.y + _offsetY) + (pvObj.altoForma / 2 - 15), styleText);
}
}
// Texts
//_pvPlana.makeText(cubiertaObj.altoLibro, origenPlana.x + (fullBookWith / 2 - 25), origenPlana.y, styles);
//_pvPlana.makeText(fullBookWith, origenPlana.x, origenPlana.y + (cubiertaObj.altoLibro / 2 - 15), styles);
_pvPlana.update();
/*
var arrowX = twoMaquina.makeArrow(origin.x -200, origin.y, origin.x+200, origin.y, 0);
arrowX.stroke = 'green';
arrowX.dashes = [5, 5];
arrowX.linewidth = 1;
var arrowY = twoMaquina.makeArrow(origin.x, origin.y-200, origin.x, origin.y+200, 0);
arrowY.stroke = 'pink';
arrowY.dashes = [5, 5];
arrowY.linewidth = 2;*/
}
function previewRotativa(cubiertaObj) {
function previewRotativa(lpTagName) {
// Local parameters
let styleText = {size: 12, family: 'Public Sans'};
let margenTop = 3;
let guardaV = 0;
guardaH = 0;
// Get the preview Object parameters
getObjetoLP(lpTagName);
// Calculos
// Configuracion de las guardas
// Guarda vertical
if (cubiertaObj.formasV > 1) {
//guardaV = (cubiertaObj.altoImpresion - (2 * margenTop) - (cubiertaObj.altoLibro * cubiertaObj.formasV)) / (cubiertaObj.formasV - 1);
if (pvObj.nFormasV > 1) {
guardaV = 3;
}
// Guarda horizontal
if (cubiertaObj.formasH > 1) {
if (pvObj.nFormasH > 1) {
guardaH = 3;
}
// Constantes relativas al libro
let LVo = cubiertaObj.altoLibro / 2;
let LHo = cubiertaObj.anchoLibro / 2;
let LVo = pvObj.altoForma / 2;
let LHo = pvObj.anchoForma / 2;
// offset Y
let nTopForms = (cubiertaObj.altoImpresion / 2.0 - margenTop) / (LVo + guardaV);
let nTopForms = (pvObj.altoImpresion / 2.0 - margenTop) / (LVo + guardaV);
let yOffset = LVo * getDecimalPart(nTopForms);
console.log(yOffset);
//console.log(yOffset);
// Clear the canvas element
$('#pv_' + cubiertaObj.idIndex + '_shape').empty();
$('#pv_' + pvObj.idIndex + '_shape').empty();
// Get the element for placing the graphical elements
var divRotativa = document.getElementById('pv_' + cubiertaObj.idIndex + '_shape');
var divRotativa = document.getElementById('pv_' + pvObj.idIndex + '_shape');
var _pvRotativa = new Two({fitted: true}).appendTo(divRotativa);
// Calculate the center of the canvas element
var origenRotativa = new Two.Vector(_pvRotativa.width / 2, _pvRotativa.height / 2);
@ -145,8 +135,8 @@ function previewRotativa(cubiertaObj) {
var areaMaquinaRotativa = _pvRotativa.makeRectangle(
origenRotativa.x,
origenRotativa.y,
cubiertaObj.anchoMaquina,
cubiertaObj.altoMaquina);
pvObj.anchoMaquina,
pvObj.altoMaquina);
areaMaquinaRotativa.stroke = 'black';
areaMaquinaRotativa.fill = '#E69F6E';
areaMaquinaRotativa.linewidth = 1;
@ -154,36 +144,43 @@ function previewRotativa(cubiertaObj) {
var areaImpresionRotativa = _pvRotativa.makeRectangle(
origenRotativa.x,
origenRotativa.y,
cubiertaObj.anchoImpresion,
cubiertaObj.altoImpresion);
pvObj.anchoImpresion,
pvObj.altoImpresion);
areaImpresionRotativa.stroke = 'red';
areaImpresionRotativa.fill = '#FCEAF1';
areaImpresionRotativa.linewidth = 1;
var areaClickRotativa = _pvRotativa.makeRectangle(
origenRotativa.x,
origenRotativa.y - (cubiertaObj.altoImpresion / 2 - cubiertaObj.altoClick/2),
cubiertaObj.anchoImpresion - 10,
cubiertaObj.altoClick);
origenRotativa.y - (pvObj.altoImpresion / 2 - pvObj.altoClick / 2),
pvObj.anchoImpresion - 10,
pvObj.altoClick);
areaClickRotativa.stroke = 'blue';
//areaClickRotativa.fill = '#FCEAF1';
areaClickRotativa.linewidth = 2;
var formas = [];
for (let iV = 0; iV < cubiertaObj.formasV; iV++) {
for (let iV = 0; iV < pvObj.nFormasV; iV++) {
for (let iH = 0; iH < cubiertaObj.formasH; iH++) {
for (let iH = 0; iH < pvObj.nFormasH; iH++) {
let _offsetX = ((((pvObj.nFormasH - 1) - 2 * iH) * LHo) + (((pvObj.nFormasH - 1) / 2 - iH) * guardaH));
let _offsetY = ((((pvObj.nFormasV - 1) - 2 * iV) * LVo) + (((pvObj.nFormasV - 1) / 2 - iV) * guardaV));
formas[iV + iH] = _pvRotativa.makeRectangle(
origenRotativa.x + ((((cubiertaObj.formasH - 1) - 2 * iH) * LHo) + (((cubiertaObj.formasH - 1) / 2 - iH) * guardaH)),
(origenRotativa.y - yOffset) + ((((cubiertaObj.formasV - 1) - 2 * iV) * LVo) + (((cubiertaObj.formasV - 1) / 2 - iV) * guardaV)),
2 * cubiertaObj.anchoLibro, // Open book is 2x
cubiertaObj.altoLibro);
origenRotativa.x + _offsetX,
(origenRotativa.y - yOffset) + _offsetY,
pvObj.anchoForma,
pvObj.altoForma);
formas[iV + iH].stroke = 'grey';
formas[iV + iH].fill = '#F4F8F2';
formas[iV + iH].linewidth = 1;
// Texts
_pvRotativa.makeText(pvObj.altoForma, (origenRotativa.x + _offsetX) + (pvObj.anchoForma / 2 - 25), ((origenRotativa.y - yOffset) + _offsetY), styleText);
_pvRotativa.makeText(pvObj.anchoForma, (origenRotativa.x + _offsetX), ((origenRotativa.y - yOffset) + _offsetY) + (pvObj.altoForma / 2 - 15), styleText);
}
}
@ -195,19 +192,6 @@ function previewRotativa(cubiertaObj) {
_pvRotativa.update();
/*
var arrowX = twoMaquina.makeArrow(origin.x -200, origin.y, origin.x+200, origin.y, 0);
arrowX.stroke = 'green';
arrowX.dashes = [5, 5];
arrowX.linewidth = 1;
var arrowY = twoMaquina.makeArrow(origin.x, origin.y-200, origin.x, origin.y+200, 0);
arrowY.stroke = 'pink';
arrowY.dashes = [5, 5];
arrowY.linewidth = 2;*/
}
function getDecimalPart(floatNumber) {
@ -216,66 +200,18 @@ function getDecimalPart(floatNumber) {
return float_part;
}
function previewConfiguracionCubierta(cubiertaObj) {
// Local parameters
let fullBookWith = ((2 * cubiertaObj.anchoLibro) + (2 * (cubiertaObj.solapas + _offsetSolapas)) + cubiertaObj.lomo);
// Clear the canvas element
$('#pv_cubierta_shape').empty();
// Get the element for placing the graphical elements
var divCubierta = document.getElementById('pv_cubierta_shape');
var _previewConfiguracionCubierta = new Two({fitted: true}).appendTo(divCubierta);
// Calculate the center of the canvas element
var origenCubierta = new Two.Vector(_previewConfiguracionCubierta.width / 2, _previewConfiguracionCubierta.height / 2);
var areaMaquinaCubierta = _previewConfiguracionCubierta.makeRectangle(
origenCubierta.x,
origenCubierta.y,
cubiertaObj.anchoMaquina,
cubiertaObj.altoMaquina);
areaMaquinaCubierta.stroke = 'black';
areaMaquinaCubierta.linewidth = 1;
var areaImpresionCubierta = _previewConfiguracionCubierta.makeRectangle(
origenCubierta.x,
origenCubierta.y,
cubiertaObj.anchoImpresion,
cubiertaObj.altoImpresion);
areaImpresionCubierta.stroke = 'red';
areaImpresionCubierta.linewidth = 1;
var formaCubierta = _previewConfiguracionCubierta.makeRectangle(
origenCubierta.x,
origenCubierta.y,
fullBookWith,
cubiertaObj.altoLibro);
formaCubierta.stroke = 'grey';
formaCubierta.fill = '#F4F8F2';
formaCubierta.linewidth = 1;
// Texts
_previewConfiguracionCubierta.makeText(cubiertaObj.altoLibro, origenCubierta.x + (fullBookWith / 2 - 25), origenCubierta.y, styles);
_previewConfiguracionCubierta.makeText(fullBookWith, origenCubierta.x, origenCubierta.y + (cubiertaObj.altoLibro / 2 - 15), styles);
_previewConfiguracionCubierta.update();
// Update preview info fields
$('#pv_ec_libro').text(cubiertaObj.anchoLibro + "X" + cubiertaObj.altoLibro);
$('#pv_ec_lomo').text(cubiertaObj.lomo);
$('#pv_ec_solapas').text(cubiertaObj.solapas);
}
function previewEsquemaCubierta(objEC) {
function previewEsquemaCubierta(lpTagName) {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
let styleCotas = {size: 12, family: 'Public Sans'};
// Get the preview Object parameters
getObjetoLP(lpTagName);
// Definicion de los parametros del Esquema de Cubierta (EC)
if (objEC.anchoSolapa == 0) {
if (pvObj.anchoSolapa == 0) {
anchoSangrado = 600; // px
altoSangrado = (anchoSangrado * 0.647 > 350) ? anchoSangrado * 0.647 : 350; // px
altoLibro = altoSangrado * 0.97;
@ -313,7 +249,7 @@ function previewEsquemaCubierta(objEC) {
sangrado.fill = '#FCEAF1';
sangrado.linewidth = 1;
if (objEC.anchoSolapa != 0) {
if (pvObj.anchoSolapa != 0) {
var solapas = previewEC.makeRectangle(
origenEC.x,
origenEC.y,
@ -343,8 +279,8 @@ function previewEsquemaCubierta(objEC) {
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
// Textos Cotas Solapas
previewEC.makeText(objEC.anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(objEC.anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
}
@ -416,11 +352,11 @@ function previewEsquemaCubierta(objEC) {
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(objEC.lomoLibro + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(objEC.anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(objEC.anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(objEC.altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * objEC.anchoLibro) + (2 * (objEC.anchoSolapa + offsetSolapaValor)) + objEC.lomoLibro + (2 * sangradoValor) + " mm",
previewEC.makeText(pvObj.lomoLibro + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.anchoLibro + offsetSolapaValor + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(pvObj.altoLibro + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + offsetSolapaValor)) + pvObj.lomoLibro + (2 * sangradoValor) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
@ -429,58 +365,91 @@ function previewEsquemaCubierta(objEC) {
}
function getObjetoEC() {
function getLomoLibro() {
let _anchoLomo = 0;
$("#tableLineasPresupuesto tbody tr:visible td input[id*='_lomo']").each(function () {
_anchoLomo += parseFloat($(this).val());
});
objEC = {
altoLibro: getDimensionLibro().alto,
anchoLibro: getDimensionLibro().ancho,
anchoSolapa: parseFloat($('#solapas_ancho').val()),
lomoLibro: parseFloat(_anchoLomo.toFixed(2))
};
// Update preview info fields
$('#pv_ec_pg').attr("href", $('#pv_ec_pg').attr('sk-url') + $('#lp_cubierta_papel').val());
$('#pv_ec_pi').attr("href", $('#pv_ec_pi').attr('sk-url') + $('#lp_cubierta_papelImpresion').val());
$('#pv_ec_mi').attr("href", $('#pv_ec_mi').attr('sk-url') + $('#lp_cubierta_maquina').val());
$('#pv_ec_libro').text(objEC.anchoLibro + "X" + objEC.altoLibro);
$('#pv_ec_lomo').text(objEC.lomoLibro);
$('#pv_ec_solapas').text(objEC.anchoSolapa);
(objEC.anchoSolapa != 0) ? $('.pv-ec-solapas').show() : $('.pv-ec-solapas').hide();
return parseFloat(_anchoLomo.toFixed(2));
}
function getObjetoLP(lpName) {
objEC = {
altoLibro: getDimensionLibro().alto,
anchoLibro: getDimensionLibro().ancho,
altoMaquina: $('#lp_' + lpName + '_maquina_alto').val(),
anchoMaquina: $('#lp_' + lpName + '_maquina_ancho').val(),
altoImpresion: $('#lp_' + lpName + '_maquina_impresion_alto').val(),
anchoImpresion: $('#lp_' + lpName + '_maquina_impresion_ancho').val(),
pvObj = {
idIndex: lpName,
gramajeLibro: parseFloat($('#lp_' + lpName + '_gramaje').val()),
manoLP: parseFloat($('#lp_' + lpName + '_lomo').val()),
lomoLibro: getLomoLibro(),
anchoSolapa: parseFloat($('#solapas_ancho').val()),
nFormas: $('#lp_' + lpName + '_formas').val(),
//lomoLibro:parseFloat(_anchoLomo.toFixed(2))
nFormas: parseInt($('#lp_' + lpName + '_formas').val()),
nFormasH: parseInt($('#lp_' + lpName + '_formas_h').val()),
nFormasV: parseInt($('#lp_' + lpName + '_formas_v').val()),
orientacionFormas: $('#lp_' + lpName + '_formas_orientacion').val(),
altoMaquina: parseFloat($('#lp_' + lpName + '_maquina_alto').val()),
anchoMaquina: parseFloat($('#lp_' + lpName + '_maquina_ancho').val()),
altoImpresion: parseFloat($('#lp_' + lpName + '_maquina_impresion_alto').val()),
anchoImpresion: parseFloat($('#lp_' + lpName + '_maquina_impresion_ancho').val()),
altoLibro: getDimensionLibro().alto,
anchoLibro: getDimensionLibro().ancho
};
// Printing shape definition
pvObj.anchoForma = (_isCosido) ? 2 * pvObj.anchoLibro : pvObj.anchoLibro;
pvObj.altoForma = pvObj.altoLibro;
// Conditional assignements depending on rotation of the printing shape
if (pvObj.orientacionFormas == 'v') {
let auxReg = pvObj.altoForma;
pvObj.altoForma = pvObj.anchoForma;
pvObj.anchoForma = auxReg;
}
// Update preview info fields
let pvName = '#pv_' + lpName;
$(pvName + '_pg').attr("href", $(pvName + '_pg').attr('sk-url') + $('#lp_' + lpName + '_papel').val());
$(pvName + '_pi').attr("href", $(pvName + '_pi').attr('sk-url') + $('#lp_' + lpName + '_papelImpresion').val());
$(pvName + '_mi').attr("href", $(pvName + '_mi').attr('sk-url') + $('#lp_' + lpName + '_maquina').val());
$(pvName + '_gramaje').text(parseFloat($('#lp_' + lpName + '_gramaje').val()));
$(pvName + '_mano').text(parseFloat($('#lp_' + lpName + '_lomo').val()));
$(pvName + '_maquina').text(objEC.anchoMaquina + "x" + objEC.altoMaquina);
$(pvName + '_maquina_impresion').text(objEC.anchoImpresion + "x" + objEC.altoImpresion);
$(pvName + '_libro').text(objEC.anchoLibro + "x" + objEC.altoLibro);
$(pvName + '_formas').text(objEC.nFormas);
$(pvName + '_gramaje').text(pvObj.gramajeLibro);
$(pvName + '_mano').text(pvObj.manoLP);
$(pvName + '_solapas').text(pvObj.anchoSolapa);
$(pvName + '_maquina').text(pvObj.anchoMaquina + "x" + pvObj.altoMaquina);
$(pvName + '_maquina_impresion').text(pvObj.anchoImpresion + "x" + pvObj.altoImpresion);
$(pvName + '_libro').text(pvObj.anchoLibro + "x" + pvObj.altoLibro);
$(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma);
$(pvName + '_nFormas').text(pvObj.nFormas);
(pvObj.anchoSolapa != 0) ? $('.pv-solapas').show() : $('.pv-solapas').hide();
// Custom overwrites
switch (pvObj.idIndex) {
case 'cubierta':
pvObj.anchoForma = ((2 * pvObj.anchoLibro) + (2 * (pvObj.anchoSolapa + _offsetSolapas)) + pvObj.lomoLibro);
$(pvName + '_forma').text(pvObj.anchoForma + "x" + pvObj.altoForma);
break;
case 'ec':
$(pvName + '_pg').attr("href", $(pvName + '_pg').attr('sk-url') + $('#lp_cubierta_papel').val());
$(pvName + '_pi').attr("href", $(pvName + '_pi').attr('sk-url') + $('#lp_cubierta_papelImpresion').val());
$(pvName + '_mi').attr("href", $(pvName + '_mi').attr('sk-url') + $('#lp_cubierta_maquina').val());
$('#pv_ec_lomo').text(pvObj.lomoLibro);
break;
case 'rot_bn':
case 'rot_color':
pvObj.anchoMaquina = 520;
pvObj.altoMaquina= 800;
pvObj.anchoImpresion= 515;
pvObj.altoImpresion= 800;
pvObj.nFormasH = 1;
pvObj.nFormasV = 3;
pvObj.altoClick = 305;
break;
default:
break;
}
}
@ -488,7 +457,7 @@ function getVisibleTabs() {
$("#tableLineasPresupuesto tbody tr:visible").each(function () {
//console.log($(this).attr('id'));
console.log($(this).attr('id'));
if ($(this).attr('id').indexOf('cubierta') > -1) {
$("#" + $(this).attr('id').replace('lp_', 'tab-pv-')).show();
$("#" + $(this).attr('id').replace('lp_', 'tab-pv-esquema-')).show();