Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
flatsiedatsie authored Jan 16, 2024
1 parent 41eb0c3 commit 04883ad
Show file tree
Hide file tree
Showing 4 changed files with 357 additions and 119 deletions.
23 changes: 18 additions & 5 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,14 @@ background-color: #5bc0de;
}

#extension-floorplanner-content #extension-floorplanner-panel #extension-floorplanner-select_mode{
padding: 1.5rem 0 2rem 0;
/*padding: 1.5rem 0 2rem 0;*/
display: flex;
justify-content: center;
}
#extension-floorplanner-content #extension-floorplanner-panel #extension-floorplanner-select_mode:not(.extension-floorplanner-btn-success){
fill:blue;
}


#extension-floorplanner-select_mode > span{
display:inline-block;
Expand Down Expand Up @@ -814,7 +818,8 @@ body:not(.developer) .extension-floorplanner-show-if-developer{
*/

#extension-floorplanner-content .extension-floorplanner-btn-success{
background-color:blue;
/*background-color:blue;*/
background-color:#08d;
color:white;
}

Expand Down Expand Up @@ -1283,9 +1288,10 @@ g#extension-floorplanner-boxbind{
border-radius:.5rem;
background-color:rgba(128,128,128,.5);
margin-bottom:.5rem;
padding:.5rem;
padding:0;
cursor:pointer;
overflow:hidden;
box-sizing:border-box;
}
.extension-floorplanner-floorplan-item:hover{
background-color:#ccc;
Expand All @@ -1303,6 +1309,9 @@ g#extension-floorplanner-boxbind{
display:block;
text-align:center;
color:black;
font-size:0.85rem;
padding:.4rem .4rem .4rem .4rem;
background-color:rgba(255,255,255,.4);
}


Expand Down Expand Up @@ -1461,7 +1470,7 @@ g#extension-floorplanner-boxbind{
}

.extension-floorplanner-floorplan-icon-current{
background-color:red!important;
background-color:#08d!important;
}


Expand Down Expand Up @@ -1530,7 +1539,11 @@ g#extension-floorplanner-boxbind{
}



#extension-floorplanner-clone-button{
display:flex;
align-items:center;
justify-content:center;
}



Expand Down
148 changes: 78 additions & 70 deletions floorplanEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,22 +581,25 @@ var floorplanEditor = {
}

//console.log("floorplanEditor: obj2D: init: calling cc with: classe, type, size, thick, value", classe, type, size, thick, value);
var cc = carpentryCalc(classe, type, size, thick, value);
var cc = carpentryCalc(classe, type, size, thick, value);
//console.log("floorplanEditor: obj2D: init: cc result: ", cc);
var blank;
var blank;

for (var tt = 0; tt < cc.length; tt++) {
for (var tt = 0; tt < cc.length; tt++) {
try{
//console.log(tt,": path cc[tt]: ", cc[tt]);
}
catch(e){
console.error("floorplaneditor.js: tt error: ", e);
}

if (cc[tt].path) {
if(classe == 'boundingBox' || classe == 'text' || classe == 'measure'){
cc[tt].opacity = '1'; // not needed anymore?
}
if (cc[tt].path) {
if(classe == 'boundingBox' || classe == 'text' || classe == 'measure'){
cc[tt].opacity = '1'; // not needed anymore?
}

//newpath = document.createElementNS('http://www.w3.org/2000/svg',"path");

blank = qSVG.create('none', 'path', {
d: cc[tt].path,
"stroke-width": 1,
Expand All @@ -621,9 +624,8 @@ var floorplanEditor = {
});
blank.textContent = cc[tt].text;
}
//console.log("blank: ", blank);
//console.log("blank: ", blank);
this.graph.append(blank);

} // ENDFOR
var bbox = this.graph.getBoundingClientRect();
bbox.x = (bbox.x * factor) - (offset.left * factor) + originX_viewbox;
Expand All @@ -635,97 +637,103 @@ var floorplanEditor = {
//this.realBbox = [{ x: -this.size, y: -this.thick }, { x: this.size, y: -this.thick }, { x: this.size, y: this.thick }, { x: -this.size, y: this.thick }];
if (family == "byObject") this.family = cc.family;
this.params = cc.params; // (bindBox, move, resize, rotate)
if(load == false && typeof cc.params.width != 'undefined'){
cc.params.width ? this.size = cc.params.width : this.size = size;
cc.params.height ? this.thick = cc.params.height : this.thick = thick;
}
else{
this.size = size
this.thick = thick
}

if(load == false && typeof cc.params.width != 'undefined'){
cc.params.width ? this.size = cc.params.width : this.size = size;
cc.params.height ? this.thick = cc.params.height : this.thick = thick;
}
else{
this.size = size
this.thick = thick
}

//console.log("obj2D: original size and thick at end of init: ", this.size);
this.original_size = this.size;
this.original_thick = this.thick;
console.log("obj2D: original size and thick at end of init: ", this.size);
this.original_size = this.size;
this.original_thick = this.thick;


this.update = function () {
//console.log("in update. this.size, this.thick, meter: ", this.size, this.thick);
if(this.class == 'energy' || this.class == 'text'){
if(document.querySelector('#extension-floorplanner-tool-root.extension-floorplanner-scale-linked')){
this.thick = this.size;
this.update = function () {
console.log("in update. this.size, this.thick, meter: ", this.size, this.thick);
if(this.class == 'energy' || this.class == 'text'){
if(document.querySelector('#extension-floorplanner-tool-root.extension-floorplanner-scale-linked')){
this.thick = this.size;
}
}
if(this.class == 'measure'){
this.width = this.size; //(this.size / meter).toFixed(2);
this.height = this.thick; //(this.thick / meter).toFixed(2);
}
else{
this.width = (this.size / meter).toFixed(2);
this.height = (this.thick / meter).toFixed(2);
}


console.log("floorplanEditor: obj2D: update: calling cc with: classe, type, size, thick, value", this.class, this.type, this.size, this.thick, this.value);
cc = carpentryCalc(this.class, this.type, this.size, this.thick, this.value);
console.log("floorplanEditor: obj2D: update: cc result: ", cc);

for (var tt = 0; tt < cc.length; tt++) {
console.log("tt: ", tt, cc[tt]);
console.log("cc[tt]: ", cc[tt]);
if (cc[tt].path) {
console.log("tt path exists: ", cc[tt].path);
console.log("tt this.graph.querySelectorAll('path'): ", this.graph.querySelectorAll('path'));
console.log("tt this.graph.querySelectorAll('path')[tt]: ", this.graph.querySelectorAll('path')[tt]);
this.graph.querySelectorAll('path')[tt].setAttribute("d", cc[tt].path);
}
}
if(this.class == 'measure'){
this.width = this.size; //(this.size / meter).toFixed(2);
this.height = this.thick; //(this.thick / meter).toFixed(2);
}
else{
this.width = (this.size / meter).toFixed(2);
this.height = (this.thick / meter).toFixed(2);
}


//console.log("floorplanEditor: obj2D: update: calling cc with: classe, type, size, thick, value", this.class, this.type, this.size, this.thick, this.value);
cc = carpentryCalc(this.class, this.type, this.size, this.thick, this.value);
//console.log("floorplanEditor: obj2D: update: cc result: ", cc);
for (var tt = 0; tt < cc.length; tt++) {
if (cc[tt].path) {
this.graph.querySelectorAll('path')[tt].setAttribute("d", cc[tt].path);
}
else {
console.error("cc update would have set text now... cc[tt]:", cc[tt]);
else {
console.error("cc update would have set text now...? cc[tt]:", cc[tt]);
//this.graph.find('text').context.textContent = cc[tt].text;
//this.graph.querySelectorAll('text')[tt].context.textContent = cc[tt].text;
}
}
var hingeStatus = this.hinge; // normal - reverse
var hingeUpdate;
if (hingeStatus == 'normal') hingeUpdate = 1;
else hingeUpdate = -1;
var hingeStatus = this.hinge; // normal - reverse
var hingeUpdate;
if (hingeStatus == 'normal') hingeUpdate = 1;
else hingeUpdate = -1;
if(this.class == 'energy' || this.class == 'text'){ // || this.class == 'measure'
//console.warn("UPDATE: this.width: ", this.width);
if(this.class != 'measure' && document.querySelector('#extension-floorplanner-scale-link-toggle-button-container').classList.contains('extension-floorplanner-scale-linked')){
this.height = this.width;
}

this.graph.setAttribute("transform", "translate(" + (this.x) + "," + (this.y) + ") rotate(" + this.angle + ",0,0) scale(" + this.width + ", " + this.height + ")" );
}
else{
this.graph.setAttribute("transform", "translate(" + (this.x) + "," + (this.y) + ") rotate(" + this.angle + ",0,0) scale(" + hingeUpdate + ", 1)" );
}
}

var bbox = this.graph.getBoundingClientRect();
bbox.x = (bbox.x * factor) - (offset.left * factor) + originX_viewbox;
bbox.y = (bbox.y * factor) - (offset.top * factor) + originY_viewbox;
bbox.origin = { x: this.x, y: this.y };
this.bbox = bbox;

/*
if (this.class == "text" && this.angle == 0) {
this.realBbox = [
{ x: this.bbox.x, y: this.bbox.y }, { x: this.bbox.x + this.bbox.width, y: this.bbox.y }, { x: this.bbox.x + this.bbox.width, y: this.bbox.y + this.bbox.height }, { x: this.bbox.x, y: this.bbox.y + this.bbox.height }];
this.size = this.bbox.width;
this.thick = this.bbox.height;
}
*/
/*
if (this.class == "text" && this.angle == 0) {
this.realBbox = [
{ x: this.bbox.x, y: this.bbox.y }, { x: this.bbox.x + this.bbox.width, y: this.bbox.y }, { x: this.bbox.x + this.bbox.width, y: this.bbox.y + this.bbox.height }, { x: this.bbox.x, y: this.bbox.y + this.bbox.height }];
this.size = this.bbox.width;
this.thick = this.bbox.height;
}
*/

var angleRadian = -(this.angle) * (Math.PI / 180);
//this.realBbox = [{ x: -this.size / 2, y: -this.thick / 2 }, { x: this.size / 2, y: -this.thick / 2 }, { x: this.size / 2, y: this.thick / 2 }, { x: -this.size / 2, y: this.thick / 2 }];
//this.realBbox = [{ x: -this.size / 4, y: -this.thick / 4 }, { x: this.size / 4, y: -this.thick / 4 }, { x: this.size / 4, y: this.thick / 4 }, { x: -this.size / 4, y: this.thick / 4 }];
this.realBbox = [{ x: -this.size / 3, y: -this.thick / 3 }, { x: this.size / 3, y: -this.thick / 3 }, { x: this.size / 3, y: this.thick / 3 }, { x: -this.size / 3, y: this.thick / 3 }];
var angleRadian = -(this.angle) * (Math.PI / 180);
//this.realBbox = [{ x: -this.size / 2, y: -this.thick / 2 }, { x: this.size / 2, y: -this.thick / 2 }, { x: this.size / 2, y: this.thick / 2 }, { x: -this.size / 2, y: this.thick / 2 }];
//this.realBbox = [{ x: -this.size / 4, y: -this.thick / 4 }, { x: this.size / 4, y: -this.thick / 4 }, { x: this.size / 4, y: this.thick / 4 }, { x: -this.size / 4, y: this.thick / 4 }];
this.realBbox = [{ x: -this.size / 3, y: -this.thick / 3 }, { x: this.size / 3, y: -this.thick / 3 }, { x: this.size / 3, y: this.thick / 3 }, { x: -this.size / 3, y: this.thick / 3 }];

var newRealBbox = [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }];
newRealBbox[0].x = (this.realBbox[0].y * Math.sin(angleRadian) + this.realBbox[0].x * Math.cos(angleRadian)) + this.x;
var newRealBbox = [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }];
newRealBbox[0].x = (this.realBbox[0].y * Math.sin(angleRadian) + this.realBbox[0].x * Math.cos(angleRadian)) + this.x;
newRealBbox[1].x = (this.realBbox[1].y * Math.sin(angleRadian) + this.realBbox[1].x * Math.cos(angleRadian)) + this.x;
newRealBbox[2].x = (this.realBbox[2].y * Math.sin(angleRadian) + this.realBbox[2].x * Math.cos(angleRadian)) + this.x;
newRealBbox[3].x = (this.realBbox[3].y * Math.sin(angleRadian) + this.realBbox[3].x * Math.cos(angleRadian)) + this.x;
newRealBbox[0].y = (this.realBbox[0].y * Math.cos(angleRadian) - this.realBbox[0].x * Math.sin(angleRadian)) + this.y;
newRealBbox[1].y = (this.realBbox[1].y * Math.cos(angleRadian) - this.realBbox[1].x * Math.sin(angleRadian)) + this.y;
newRealBbox[2].y = (this.realBbox[2].y * Math.cos(angleRadian) - this.realBbox[2].x * Math.sin(angleRadian)) + this.y;
newRealBbox[3].y = (this.realBbox[3].y * Math.cos(angleRadian) - this.realBbox[3].x * Math.sin(angleRadian)) + this.y;
this.realBbox = newRealBbox;
this.realBbox = newRealBbox;
/*
if(this.class == 'energy' || this.class == 'text' || this.class == 'measure'){
console.log("obj2D: update: at the end:")
Expand All @@ -738,9 +746,9 @@ var floorplanEditor = {
console.log("update: newRealBbox: ", newRealBbox);
}
*/
return true;
}
},
return true;
}
},

roomMaker: function (Rooms) {
globalArea = 0;
Expand Down
5 changes: 5 additions & 0 deletions img/mouse_cursor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 04883ad

Please sign in to comment.