map_popup for superpositions OK
This commit is contained in:
@@ -38,6 +38,7 @@ export default {
|
||||
return {
|
||||
id: null,
|
||||
entities: null,
|
||||
superposedEntitesIDsList: [],
|
||||
canvas: null,
|
||||
ctx: null,
|
||||
pos : {
|
||||
@@ -100,14 +101,14 @@ export default {
|
||||
// this.getSalientPoints()
|
||||
this.getJarvisEnvelopeConvexe()
|
||||
|
||||
// if (this.canvasMap) {
|
||||
// define init position of the item
|
||||
this.pos = this.getRandomPos();
|
||||
//
|
||||
this.initMatterBody()
|
||||
//
|
||||
this.initPaperObjects()
|
||||
// }
|
||||
// define init position of the item
|
||||
this.pos = this.getRandomPos();
|
||||
//
|
||||
this.getSuperposedEntitesIDsList();
|
||||
//
|
||||
this.initMatterBody()
|
||||
//
|
||||
this.initPaperObjects()
|
||||
}
|
||||
|
||||
// this.setConcernementMapItem(this.cid, this);
|
||||
@@ -177,7 +178,7 @@ export default {
|
||||
hover_elmt: {
|
||||
handler (n, o) {
|
||||
// console.log(`watch hover_elmt ${this.id}`, o, n);
|
||||
if (n && n.type === 'concernement' && n.id === this.id) {
|
||||
if (n && (n.type === 'concernement' || n.type === 'superposition') && n.id === this.id) {
|
||||
this.is_hover = true;
|
||||
} else {
|
||||
this.is_hover = false;
|
||||
@@ -374,6 +375,47 @@ export default {
|
||||
if (num > 1 || num < 0) return this.getGaussianRandom() // resample between 0 and 1
|
||||
return num
|
||||
},
|
||||
getSuperposedEntitesIDsList(){
|
||||
|
||||
// find the right entite(s) to display on this original map_item vs cloned map item
|
||||
// (clones are needed for multiple superpositions by concernement couples)
|
||||
// let eids = [];
|
||||
if (this.superposition_id) {
|
||||
// console.log('has superposition_id', this.superposition_id);
|
||||
// if we have a superposition_id prop then we are on a temporary concernement map_item clone
|
||||
// find the right entite id from the superposition_id prop
|
||||
let ids = this.superposition_id.match(/(\d+)_(\d+)__(\d+)_(\d+)/i)
|
||||
// console.log('ids', ids);
|
||||
switch (this.cid) { // get the right eid regarding the cid
|
||||
case parseInt(ids[1]):
|
||||
this.superposedEntitesIDsList.push(parseInt(ids[2]));
|
||||
break;
|
||||
case parseInt(ids[3]):
|
||||
this.superposedEntitesIDsList.push(parseInt(ids[4]));
|
||||
break;
|
||||
}
|
||||
} else if (this.concernement.superpositions) {
|
||||
// console.log('DONOT has superposition_id');
|
||||
// if we do not have a superposition_id prop then we are on the regular concernement map_item
|
||||
// loop through all concernement superpositions and select only thoose which are not part of a temporary cloned
|
||||
for(let [couple_id, superpositions] of Object.entries(this.concernement.superpositions)){
|
||||
for(let [superposition_id, superposition] of Object.entries(superpositions)){
|
||||
if (!superposition.cloned) { // not part of a clone
|
||||
switch (this.cid) { // get the right eid regarding the cid
|
||||
case superposition[0].cid:
|
||||
this.superposedEntitesIDsList.push(superposition[0].eid);
|
||||
break;
|
||||
case superposition[1].cid:
|
||||
this.superposedEntitesIDsList.push(superposition[1].eid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log('eids', eids);
|
||||
|
||||
},
|
||||
// MATTER BODY
|
||||
initMatterBody (){
|
||||
|
||||
@@ -659,45 +701,7 @@ export default {
|
||||
return g;
|
||||
},
|
||||
setPaperEntitesSuperposees(){
|
||||
console.log('setPaperSuperpositions, superpositions', this.concernement.superpositions);
|
||||
|
||||
// find the right entite(s) to display on this original map_item vs cloned map item
|
||||
// (clones are needed for multiple superpositions by concernement couples)
|
||||
let eids = [];
|
||||
if (this.superposition_id) {
|
||||
// console.log('has superposition_id', this.superposition_id);
|
||||
// if we have a superposition_id prop then we are on a temporary concernement map_item clone
|
||||
// find the right entite id from the superposition_id prop
|
||||
let ids = this.superposition_id.match(/(\d+)_(\d+)__(\d+)_(\d+)/i)
|
||||
// console.log('ids', ids);
|
||||
switch (this.cid) { // get the right eid regarding the cid
|
||||
case parseInt(ids[1]):
|
||||
eids.push(parseInt(ids[2]));
|
||||
break;
|
||||
case parseInt(ids[3]):
|
||||
eids.push(parseInt(ids[4]));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// console.log('DONOT has superposition_id');
|
||||
// if we do not have a superposition_id prop then we are on the regular concernement map_item
|
||||
// loop through all concernement superpositions and select only thoose which are not part of a temporary cloned
|
||||
for(let [couple_id, superpositions] of Object.entries(this.concernement.superpositions)){
|
||||
for(let [superposition_id, superposition] of Object.entries(superpositions)){
|
||||
if (!superposition.cloned) { // not part of a clone
|
||||
switch (this.cid) { // get the right eid regarding the cid
|
||||
case superposition[0].cid:
|
||||
eids.push(superposition[0].eid);
|
||||
break;
|
||||
case superposition[1].cid:
|
||||
eids.push(superposition[1].eid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log('eids', eids);
|
||||
// console.log('setPaperSuperpositions, superpositions', this.concernement.superpositions);
|
||||
|
||||
let g = new paper.Group({
|
||||
pivot: new paper.Point(this.pos),
|
||||
@@ -706,7 +710,7 @@ export default {
|
||||
for (let i = 0; i < this.concernement.revisions_byid[this.concernement.active_revision].entites.length; i++) {
|
||||
let entite = this.concernement.revisions_byid[this.concernement.active_revision].entites[i];
|
||||
if (entite.entite // check if we have an entite object with all the contents
|
||||
&& eids.indexOf(entite.entite.id) >= 0) // check if entite id is in the list builded above
|
||||
&& this.superposedEntitesIDsList.indexOf(entite.entite.id) >= 0) // check if entite id is in the list builded above
|
||||
{
|
||||
// console.log(`entite ${entite.entite.id}`, entite, entite.entite.superposition);
|
||||
// use paper symbol
|
||||
@@ -1277,15 +1281,18 @@ export default {
|
||||
if (!this.is_opened) {
|
||||
if (!this.opened_concernement && this.isFocused()) { // only if no concernement is opened and is this focused
|
||||
if (this.map_mode === 'superposition') {
|
||||
// get the superposed entite
|
||||
this.setHoverElmt({
|
||||
type: 'superposition',
|
||||
cid: this.id,
|
||||
eid: 0 // TODO
|
||||
id: this.id,
|
||||
cid: this.cid,
|
||||
eids: this.superposedEntitesIDsList
|
||||
});
|
||||
} else {
|
||||
this.setHoverElmt({
|
||||
type: 'concernement',
|
||||
id: this.id
|
||||
id: this.id,
|
||||
cid: this.cid
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user