Spaces:
Sleeping
Sleeping
Upload proposed-GUI.html
Browse files- templates/proposed-GUI.html +132 -130
templates/proposed-GUI.html
CHANGED
|
@@ -3314,7 +3314,7 @@ function getData(form) {
|
|
| 3314 |
{
|
| 3315 |
var Thickness= document.getElementById("text002extra").value
|
| 3316 |
answers.push(tomeasureproj, 0,[], ratio1, ratio2,pdfpath,groupedValues,checkedItems,Thickness,shapeData,ratio3); //location of shape
|
| 3317 |
-
formData.append('file',dxffile)
|
| 3318 |
}
|
| 3319 |
formData.append('answers',JSON.stringify(answers))
|
| 3320 |
}
|
|
@@ -4603,146 +4603,147 @@ function drawCircle(x, y) {
|
|
| 4603 |
/*Set canvas code to be visible on the new window with the pdftoimg as the background*/
|
| 4604 |
|
| 4605 |
var levelsin = document.getElementById('levelcheckbox');
|
| 4606 |
-
var canvaswindow= document.getElementById('canvaswindow');
|
| 4607 |
-
var undoButtonId=document.getElementById('undoButtonId');
|
| 4608 |
-
NewShapeButtonId=document.getElementById('NewShapeButtonId');
|
| 4609 |
-
var savecanvas=document.getElementById('savecanvas');
|
| 4610 |
-
var scaleX=1;
|
| 4611 |
-
var scaleY=1;
|
| 4612 |
-
var shapeData = [];
|
| 4613 |
-
|
| 4614 |
-
|
| 4615 |
-
|
| 4616 |
-
|
| 4617 |
-
|
| 4618 |
-
|
| 4619 |
-
|
| 4620 |
-
|
| 4621 |
-
|
| 4622 |
-
|
| 4623 |
-
|
| 4624 |
-
|
| 4625 |
-
|
| 4626 |
-
|
| 4627 |
-
|
| 4628 |
-
|
| 4629 |
-
|
| 4630 |
-
|
| 4631 |
-
|
| 4632 |
-
|
| 4633 |
-
|
| 4634 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4635 |
|
| 4636 |
-
|
| 4637 |
-
|
| 4638 |
-
|
|
|
|
| 4639 |
|
| 4640 |
-
|
| 4641 |
-
|
| 4642 |
-
|
| 4643 |
-
|
| 4644 |
-
|
| 4645 |
|
| 4646 |
-
|
| 4647 |
-
|
| 4648 |
-
const displayHeight = canvaswindow.childNodes[1].offsetHeight;
|
| 4649 |
|
| 4650 |
-
|
| 4651 |
-
|
| 4652 |
-
|
|
|
|
| 4653 |
|
| 4654 |
-
|
| 4655 |
-
|
| 4656 |
-
console.log("ScaleX:", scaleX, "ScaleY:", scaleY);
|
| 4657 |
|
| 4658 |
-
|
| 4659 |
-
|
| 4660 |
|
| 4661 |
-
|
| 4662 |
-
|
| 4663 |
-
|
| 4664 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4665 |
|
| 4666 |
-
|
| 4667 |
-
|
| 4668 |
-
|
| 4669 |
-
|
| 4670 |
-
|
| 4671 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4672 |
|
| 4673 |
-
|
| 4674 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4675 |
|
| 4676 |
-
|
| 4677 |
-
|
| 4678 |
-
|
|
|
|
|
|
|
| 4679 |
} else {
|
| 4680 |
-
|
| 4681 |
-
ry[ry.length - 1].pop();
|
| 4682 |
-
}
|
| 4683 |
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
| 4684 |
-
ctx.drawImage(imgDrawon, 0, 0, displayWidth, displayHeight);
|
| 4685 |
-
drawChart();
|
| 4686 |
-
});
|
| 4687 |
-
|
| 4688 |
-
savecanvas.addEventListener('click', function () {
|
| 4689 |
-
var image = new Image();
|
| 4690 |
-
image.src = canvas.toDataURL("image/png");
|
| 4691 |
-
canvasimg = image.src;
|
| 4692 |
-
console.log('saved');
|
| 4693 |
-
|
| 4694 |
-
if (sectionNumber.startsWith('2.7') || sectionNumber.startsWith('3.2') || sectionNumber.startsWith('3.3')) {
|
| 4695 |
-
for (let i = 0; i < ry.length; i++) {
|
| 4696 |
-
let shape = ry[i];
|
| 4697 |
-
if (!Array.isArray(shape) || shape.length === 0) continue;
|
| 4698 |
-
|
| 4699 |
-
let coords = shape
|
| 4700 |
-
.filter(p => p && typeof p.x === "number" && typeof p.y === "number")
|
| 4701 |
-
.map(p => ({
|
| 4702 |
-
x: p.x * scaleX, // now accurate
|
| 4703 |
-
y: p.y * scaleY
|
| 4704 |
-
}));
|
| 4705 |
-
|
| 4706 |
-
shapeData.push({
|
| 4707 |
-
shapeIndex: i + 1,
|
| 4708 |
-
coordinates: coords
|
| 4709 |
-
});
|
| 4710 |
-
|
| 4711 |
-
ry.forEach(shape => {
|
| 4712 |
-
if (shape.length > 1) {
|
| 4713 |
-
const first = shape[0];
|
| 4714 |
-
const last = shape[shape.length - 1];
|
| 4715 |
-
|
| 4716 |
-
// Draw line between last and first point
|
| 4717 |
-
ctx.beginPath();
|
| 4718 |
-
ctx.moveTo(last.x, last.y);
|
| 4719 |
-
ctx.lineTo(first.x, first.y);
|
| 4720 |
-
ctx.strokeStyle = "red"; // you can change color
|
| 4721 |
-
ctx.lineWidth = 2; // and thickness
|
| 4722 |
-
ctx.stroke();
|
| 4723 |
-
ctx.closePath();
|
| 4724 |
-
}
|
| 4725 |
-
});
|
| 4726 |
-
}
|
| 4727 |
-
|
| 4728 |
-
console.log("Final ScaleX:", scaleX, "ScaleY:", scaleY);
|
| 4729 |
-
console.log("Scaled coordinates:", shapeData);
|
| 4730 |
}
|
| 4731 |
-
|
| 4732 |
-
|
| 4733 |
-
|
| 4734 |
-
|
| 4735 |
-
|
| 4736 |
-
document.getElementById('levelcheckbox').checked = false;
|
| 4737 |
-
});
|
| 4738 |
-
}
|
| 4739 |
-
}
|
| 4740 |
-
else{
|
| 4741 |
-
PopupElement.textContent='Levels are not supported in this Section. ';
|
| 4742 |
-
ShowPopUp();
|
| 4743 |
-
document.getElementById('levelcheckbox').checked=false;
|
| 4744 |
-
}
|
| 4745 |
-
})
|
| 4746 |
//___________________________________________________________________________________________________________
|
| 4747 |
function getSecondData(){
|
| 4748 |
document.getElementById('all').style.display='block';
|
|
@@ -5609,7 +5610,7 @@ function callrefreshAPI(){
|
|
| 5609 |
|
| 5610 |
//before all of this , u need to crrate a popup in html , give the div an id
|
| 5611 |
let pdfname2_7 = document.querySelector('input[name="measureCheckbox"]').value;
|
| 5612 |
-
|
| 5613 |
let LegendForm = new FormData();
|
| 5614 |
LegendForm.append("nameofPDF", pdfname2_7);
|
| 5615 |
LegendForm.append("groupedValues", JSON.stringify(groupedValues));
|
|
@@ -5624,6 +5625,7 @@ function callrefreshAPI(){
|
|
| 5624 |
processData: false,
|
| 5625 |
contentType: false,
|
| 5626 |
success: function(response) {
|
|
|
|
| 5627 |
console.log("Response:", response);
|
| 5628 |
ColorsCheckPopup = document.getElementById("LegendPopUp");
|
| 5629 |
LegendContent=document.getElementById("modalLegend");
|
|
|
|
| 3314 |
{
|
| 3315 |
var Thickness= document.getElementById("text002extra").value
|
| 3316 |
answers.push(tomeasureproj, 0,[], ratio1, ratio2,pdfpath,groupedValues,checkedItems,Thickness,shapeData,ratio3); //location of shape
|
| 3317 |
+
formData.append('file',dxffile)
|
| 3318 |
}
|
| 3319 |
formData.append('answers',JSON.stringify(answers))
|
| 3320 |
}
|
|
|
|
| 4603 |
/*Set canvas code to be visible on the new window with the pdftoimg as the background*/
|
| 4604 |
|
| 4605 |
var levelsin = document.getElementById('levelcheckbox');
|
| 4606 |
+
var canvaswindow = document.getElementById('canvaswindow');
|
| 4607 |
+
var undoButtonId = document.getElementById('undoButtonId');
|
| 4608 |
+
var NewShapeButtonId = document.getElementById('NewShapeButtonId');
|
| 4609 |
+
var savecanvas = document.getElementById('savecanvas');
|
| 4610 |
+
var scaleX = 1;
|
| 4611 |
+
var scaleY = 1;
|
| 4612 |
+
var shapeData = []; // Clear this on start
|
| 4613 |
+
var popup = null;
|
| 4614 |
+
|
| 4615 |
+
levelsin.addEventListener('click', function() {
|
| 4616 |
+
if (sectionNumber.startsWith('1.0') || sectionNumber.startsWith('2.7') || sectionNumber.startsWith('3.2') || sectionNumber.startsWith('3.3')) {
|
| 4617 |
+
|
| 4618 |
+
if (this.checked) {
|
| 4619 |
+
// ISSUE 2 FIX: Reset drawing data arrays so you start fresh
|
| 4620 |
+
shapeData = [];
|
| 4621 |
+
if (typeof ry !== 'undefined') ry = [[]]; // Reset your coordinate history array
|
| 4622 |
+
|
| 4623 |
+
document.getElementById("all").style.display = "block";
|
| 4624 |
+
|
| 4625 |
+
$.get('/canvaspdftoimgBackground/' + pdfname)
|
| 4626 |
+
.done(function(data) {
|
| 4627 |
+
document.getElementById("all").style.display = "none";
|
| 4628 |
+
|
| 4629 |
+
// 1. Setup Popup
|
| 4630 |
+
// popup = window.open('', '_blank', 'width=1100,height=900');
|
| 4631 |
+
var popup = window.open('');
|
| 4632 |
+
popup.document.write('<html><head><title>ADR Console</title><link rel="stylesheet" href="static/style.css"></head><body><div id="container"></div></body></html>');
|
| 4633 |
+
popup.document.close();
|
| 4634 |
+
|
| 4635 |
+
if (sectionNumber.startsWith('2.7') || sectionNumber.startsWith('3.2') || sectionNumber.startsWith('3.3')) {
|
| 4636 |
+
document.getElementById('colorpickers').setAttribute('hidden', true);
|
| 4637 |
+
document.getElementById('NewShapeButtonId').style.display = 'none';
|
| 4638 |
+
}
|
| 4639 |
|
| 4640 |
+
// 2. Move Canvas
|
| 4641 |
+
var container = popup.document.getElementById('container');
|
| 4642 |
+
canvaswindow.removeAttribute('hidden');
|
| 4643 |
+
container.appendChild(canvaswindow);
|
| 4644 |
|
| 4645 |
+
// 3. Scaling Logic
|
| 4646 |
+
const pdfWidth = data[2];
|
| 4647 |
+
const pdfHeight = data[1];
|
| 4648 |
+
var canvas = canvaswindow.querySelector('canvas') || canvaswindow.childNodes[1];
|
| 4649 |
+
var ctx = canvas.getContext('2d');
|
| 4650 |
|
| 4651 |
+
canvas.width = pdfWidth;
|
| 4652 |
+
canvas.height = pdfHeight;
|
|
|
|
| 4653 |
|
| 4654 |
+
const displayWidthCSS = 0.5 * screen.width;
|
| 4655 |
+
const displayHeightCSS = pdfHeight * (displayWidthCSS / pdfWidth);
|
| 4656 |
+
canvas.style.width = displayWidthCSS + 'px';
|
| 4657 |
+
canvas.style.height = displayHeightCSS + 'px';
|
| 4658 |
|
| 4659 |
+
scaleX = pdfWidth / displayWidthCSS;
|
| 4660 |
+
scaleY = pdfHeight / displayHeightCSS;
|
|
|
|
| 4661 |
|
| 4662 |
+
// Apply coordinate scaling
|
| 4663 |
+
ctx.setTransform(scaleX, 0, 0, scaleY, 0, 0);
|
| 4664 |
|
| 4665 |
+
var imgDrawon = new Image();
|
| 4666 |
+
imgDrawon.onload = function() {
|
| 4667 |
+
ctx.drawImage(imgDrawon, 0, 0, displayWidthCSS, displayHeightCSS);
|
| 4668 |
+
};
|
| 4669 |
+
imgDrawon.src = 'data:image/gif;base64,' + data[0];
|
| 4670 |
+
|
| 4671 |
+
// ISSUE 1 FIX: Re-incorporate Undo and Save Logic inside the context
|
| 4672 |
+
undoButtonId.onclick = function() {
|
| 4673 |
+
if (ry.length > 0) {
|
| 4674 |
+
if (ry[ry.length - 1].length > 0) {
|
| 4675 |
+
ry[ry.length - 1].pop();
|
| 4676 |
+
} else {
|
| 4677 |
+
ry.pop();
|
| 4678 |
+
if(ry.length > 0) ry[ry.length - 1].pop();
|
| 4679 |
+
}
|
| 4680 |
+
// Redraw background and shapes
|
| 4681 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
| 4682 |
+
ctx.drawImage(imgDrawon, 0, 0, displayWidthCSS, displayHeightCSS);
|
| 4683 |
+
if (typeof drawChart === "function") drawChart();
|
| 4684 |
+
}
|
| 4685 |
+
};
|
| 4686 |
|
| 4687 |
+
savecanvas.onclick = function() {
|
| 4688 |
+
var image = canvas.toDataURL("image/png");
|
| 4689 |
+
canvasimg = image;
|
| 4690 |
+
|
| 4691 |
+
// Process coordinates with the current scale
|
| 4692 |
+
if (sectionNumber.startsWith('2.7') || sectionNumber.startsWith('3.2') || sectionNumber.startsWith('3.3')) {
|
| 4693 |
+
shapeData = []; // Clear before re-calculating
|
| 4694 |
+
for (let i = 0; i < ry.length; i++) {
|
| 4695 |
+
let shape = ry[i];
|
| 4696 |
+
if (!Array.isArray(shape) || shape.length === 0) continue;
|
| 4697 |
+
|
| 4698 |
+
let coords = shape
|
| 4699 |
+
.filter(p => p && typeof p.x === "number" && typeof p.y === "number")
|
| 4700 |
+
.map(p => ({
|
| 4701 |
+
x: p.x * scaleX,
|
| 4702 |
+
y: p.y * scaleY
|
| 4703 |
+
}));
|
| 4704 |
+
|
| 4705 |
+
shapeData.push({
|
| 4706 |
+
shapeIndex: i + 1,
|
| 4707 |
+
coordinates: coords
|
| 4708 |
+
});
|
| 4709 |
+
|
| 4710 |
+
// Draw the closing red lines
|
| 4711 |
+
if (shape.length > 1) {
|
| 4712 |
+
const first = shape[0];
|
| 4713 |
+
const last = shape[shape.length - 1];
|
| 4714 |
+
ctx.beginPath();
|
| 4715 |
+
ctx.moveTo(last.x, last.y);
|
| 4716 |
+
ctx.lineTo(first.x, first.y);
|
| 4717 |
+
ctx.strokeStyle = "red";
|
| 4718 |
+
ctx.lineWidth = 2;
|
| 4719 |
+
ctx.stroke();
|
| 4720 |
+
ctx.closePath();
|
| 4721 |
+
}
|
| 4722 |
+
}
|
| 4723 |
+
console.log("Scaled coordinates saved:", shapeData);
|
| 4724 |
+
}
|
| 4725 |
+
};
|
| 4726 |
|
| 4727 |
+
// 4. Cleanup on close
|
| 4728 |
+
popup.onbeforeunload = function() {
|
| 4729 |
+
canvaswindow.setAttribute('hidden', true);
|
| 4730 |
+
document.body.appendChild(canvaswindow);
|
| 4731 |
+
// levelsin.checked = false;
|
| 4732 |
+
};
|
| 4733 |
|
| 4734 |
+
})
|
| 4735 |
+
.fail(function() {
|
| 4736 |
+
document.getElementById("all").style.display = "none";
|
| 4737 |
+
levelsin.checked = false;
|
| 4738 |
+
});
|
| 4739 |
} else {
|
| 4740 |
+
if (popup && !popup.closed) popup.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4741 |
}
|
| 4742 |
+
} else {
|
| 4743 |
+
alert('Levels are not supported in this Section.');
|
| 4744 |
+
this.checked = false;
|
| 4745 |
+
}
|
| 4746 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4747 |
//___________________________________________________________________________________________________________
|
| 4748 |
function getSecondData(){
|
| 4749 |
document.getElementById('all').style.display='block';
|
|
|
|
| 5610 |
|
| 5611 |
//before all of this , u need to crrate a popup in html , give the div an id
|
| 5612 |
let pdfname2_7 = document.querySelector('input[name="measureCheckbox"]').value;
|
| 5613 |
+
document.getElementById("loading").hidden = false;
|
| 5614 |
let LegendForm = new FormData();
|
| 5615 |
LegendForm.append("nameofPDF", pdfname2_7);
|
| 5616 |
LegendForm.append("groupedValues", JSON.stringify(groupedValues));
|
|
|
|
| 5625 |
processData: false,
|
| 5626 |
contentType: false,
|
| 5627 |
success: function(response) {
|
| 5628 |
+
document.getElementById("loading").hidden = true;
|
| 5629 |
console.log("Response:", response);
|
| 5630 |
ColorsCheckPopup = document.getElementById("LegendPopUp");
|
| 5631 |
LegendContent=document.getElementById("modalLegend");
|