display concernements with less than 3 entites

This commit is contained in:
Bachir Soussi Chiadmi 2024-05-21 16:44:40 +02:00
parent 560c4eda72
commit 433383437d

View File

@ -103,7 +103,8 @@ export default {
// disable concernement if less than 3 entite // disable concernement if less than 3 entite
if(this.entites.length < 3){ if(this.entites.length < 3){
this.hideShowConcernement(this.concernement.id, false); this.hideShowConcernement(this.concernement.id, false);
} else{ }
// else{
// record canvas and ctx for rendering (drawing) // record canvas and ctx for rendering (drawing)
this.canvas = this.canvasMap.canvas this.canvas = this.canvasMap.canvas
this.ctx = this.canvasMap.ctx this.ctx = this.canvasMap.ctx
@ -112,7 +113,9 @@ export default {
this.ray = this.map_item_ray; this.ray = this.map_item_ray;
// console.log(`this.ray: ${this.ray}`); // console.log(`this.ray: ${this.ray}`);
// //
this.parseEntityPointsValues() this.parseEntityPointsValues();
// this.getSalientPoints() // this.getSalientPoints()
this.sailentEntites = this.concernement.sailentEntites = this.getJarvisEnvelopeConvexeEntites(this.entites) this.sailentEntites = this.concernement.sailentEntites = this.getJarvisEnvelopeConvexeEntites(this.entites)
@ -132,7 +135,7 @@ export default {
this.handleMapitemVisibility(false); this.handleMapitemVisibility(false);
} }
} }
} // }
// this.setConcernementMapItem(this.cid, this); // this.setConcernementMapItem(this.cid, this);
// this.setConcernementScale(this.cid, this.scale); // this.setConcernementScale(this.cid, this.scale);
@ -430,6 +433,7 @@ export default {
} }
} }
this.concernement.parsedEntites = true; this.concernement.parsedEntites = true;
}, },
getSalientPoints_OLD() { getSalientPoints_OLD() {
// debugger // debugger
@ -799,6 +803,7 @@ export default {
// then scale again to new size // then scale again to new size
this.paper_main_object.scale(this.details_zoom_scale); this.paper_main_object.scale(this.details_zoom_scale);
// resize entites (dim them while we zoomin) // resize entites (dim them while we zoomin)
if(this.paper_main_object.children){
this.paper_main_object.children['entites'].children.forEach((child) => { this.paper_main_object.children['entites'].children.forEach((child) => {
if(child.name === 'entite'){ if(child.name === 'entite'){
// revert to the original size (by reverting the previous scale) // revert to the original size (by reverting the previous scale)
@ -816,6 +821,7 @@ export default {
}) })
} }
}); });
}
// allow to go through walls if zoomed in // allow to go through walls if zoomed in
if (this.detailsZoomValue > 1) { if (this.detailsZoomValue > 1) {
@ -875,7 +881,7 @@ export default {
this.sailentEntites = this.getJarvisEnvelopeConvexeEntites(this.concernement.revisions_byid[this.active_revision].entites); this.sailentEntites = this.getJarvisEnvelopeConvexeEntites(this.concernement.revisions_byid[this.active_revision].entites);
// remove contours if already exists // remove contours if already exists
if (this.paper_main_object.children.contours) { if (this.paper_main_object.children && this.paper_main_object.children.contours) {
this.paper_main_object.children.contours.remove(); this.paper_main_object.children.contours.remove();
} }
// redraw contours // redraw contours
@ -921,8 +927,8 @@ export default {
} }
}, },
getPaddedRoundedSegments(points, scale){ getPaddedRoundedSegments(points, scale){
// console.log(`setPaperContour ${this.concernement.id}`); console.log(`setPaperContour ${this.concernement.id}, points`, points);
let getSegmentProps = (b,a,c,d) => { let getSegmentProps = (b,a,c) => {
const ac = { x: c.x - a.x, y: c.y - a.y } // get ac vecteur const ac = { x: c.x - a.x, y: c.y - a.y } // get ac vecteur
const lac = Math.sqrt(Math.pow(ac.x, 2) + Math.pow(ac.y, 2)); // get ac longueur ac const lac = Math.sqrt(Math.pow(ac.x, 2) + Math.pow(ac.y, 2)); // get ac longueur ac
const ab = { x: b.x - a.x, y: b.y - a.y } // get ab vecteur const ab = { x: b.x - a.x, y: b.y - a.y } // get ab vecteur
@ -985,6 +991,23 @@ export default {
setPaperContour(){ setPaperContour(){
// console.log('setPaperContour, this.sailentEntites', this.sailentEntites); // console.log('setPaperContour, this.sailentEntites', this.sailentEntites);
// convert sailent entites to x,y points // convert sailent entites to x,y points
if (this.sailentEntites.length < 3) {
// if we have less than 3 entities, draw a circle
let circle = new paper.Path.Circle({
name: 'contours',
center: this.pos,
radius: this.ray/3,
fillColor: 'rgba(255,255,255,0.4)',
// selected: true,
strokeColor: '#fff',
strokeWidth: 1,
pivot: new paper.Point(this.pos),
// scale: this.details_zoom_scale,
cid: this.cid,
})
return circle;
} else {
// if we have more than 3 entities, draw normal contour
let points = []; let points = [];
this.sailentEntites.forEach(entite => { this.sailentEntites.forEach(entite => {
points.push({ points.push({
@ -1004,7 +1027,7 @@ export default {
})) }))
}); });
// create the paper path with previous segments // create the paper path with previous segments
const contrs = new paper.Path({ let contrs = new paper.Path({
name: 'contours', name: 'contours',
segments: paper_segments, segments: paper_segments,
fillColor: 'rgba(255,255,255,0.4)', fillColor: 'rgba(255,255,255,0.4)',
@ -1017,6 +1040,8 @@ export default {
}); });
// return the paper path // return the paper path
return contrs; return contrs;
}
}, },
setPaperEntites(){ setPaperEntites(){
let g = new paper.Group({ let g = new paper.Group({