third version of superpositions is almost done
This commit is contained in:
parent
9b70d8071b
commit
9e180f59d8
87
src/App.vue
87
src/App.vue
@ -35,6 +35,7 @@ export default {
|
|||||||
'concernements_loaded',
|
'concernements_loaded',
|
||||||
'concernementsByID',
|
'concernementsByID',
|
||||||
'allSuperpositions_bycids',
|
'allSuperpositions_bycids',
|
||||||
|
'allSuperpositions_clustered',
|
||||||
'allMapItems_byid',
|
'allMapItems_byid',
|
||||||
'opened_recit']),
|
'opened_recit']),
|
||||||
},
|
},
|
||||||
@ -52,74 +53,46 @@ export default {
|
|||||||
...mapActions(ConcernementsStore,['loadConcernements']),
|
...mapActions(ConcernementsStore,['loadConcernements']),
|
||||||
...mapActions(ConcernementsStore,['loadContentTypeDefinition']),
|
...mapActions(ConcernementsStore,['loadContentTypeDefinition']),
|
||||||
...mapActions(UserStore,['checkUser']),
|
...mapActions(UserStore,['checkUser']),
|
||||||
// parseSuperposedMapitemsClones () {
|
|
||||||
// let clones = [];
|
|
||||||
// // loop through all superposition grouped by concernements couples
|
|
||||||
// for(let [couple_id, superpositions] of Object.entries(this.allSuperpositions_bycids)){
|
|
||||||
// // loop through all superpositions for one concernement couple and mark the first as NOT cloned and clone the others and mark them as cloned
|
|
||||||
// let i = 0;
|
|
||||||
// for(let [superposition_id, superposition] of Object.entries(superpositions)){
|
|
||||||
// i++
|
|
||||||
// if (i === 1) {
|
|
||||||
// // first superposition of the couple is not cloned
|
|
||||||
// this.allSuperpositions_bycids[couple_id][superposition_id].cloned = false;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// // following superpositions of the couple generate concernement map_item clones
|
|
||||||
// // first concernement of the couple
|
|
||||||
// clones.push({
|
|
||||||
// concernement: this.concernementsByID[superposition[0].cid],
|
|
||||||
// superposition_id: superposition_id
|
|
||||||
// })
|
|
||||||
// // second concernement of the couple
|
|
||||||
// clones.push({
|
|
||||||
// concernement: this.concernementsByID[superposition[1].cid],
|
|
||||||
// superposition_id: superposition_id
|
|
||||||
// })
|
|
||||||
|
|
||||||
// this.allSuperpositions_bycids[couple_id][superposition_id].cloned = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// this.superposed_cloned_mapitems = clones;
|
|
||||||
// },
|
|
||||||
parseMapitems() {
|
parseMapitems() {
|
||||||
let couple_ids = Object.keys(this.allSuperpositions_bycids);
|
// let couple_ids = Object.keys(this.allSuperpositions_bycids);
|
||||||
console.log('App couple_ids', couple_ids);
|
// console.log('App couple_ids', couple_ids);
|
||||||
// loop through all concernement
|
// loop through all concernement
|
||||||
for(let [concernement_id, concernement] of Object.entries(this.concernementsByID)){
|
for(let [concernement_id, concernement] of Object.entries(this.concernementsByID)){
|
||||||
// create the main mapitem object
|
// create the main mapitem object
|
||||||
let mapitem = {
|
let mapitem = {
|
||||||
id: concernement.id,
|
id: concernement.id,
|
||||||
concernement: concernement,
|
concernement: concernement,
|
||||||
superposition_ids: [],
|
// superposition_ids: [],
|
||||||
|
superposition_cluster_index: -1,
|
||||||
clone: false,
|
clone: false,
|
||||||
}
|
}
|
||||||
// loop through all superposistions couples
|
|
||||||
couple_ids.forEach(couple_id => {
|
// loop through all superposition_clusters
|
||||||
let cids = couple_id.match(/(\d+)-(\d+)/i);
|
for( let [cluster_index, cluster] of this.allSuperpositions_clustered.entries()){
|
||||||
// console.log('cids', cids);
|
let cids = [];
|
||||||
if (concernement.id === parseInt(cids[1]) || concernement.id === parseInt(cids[2])) {
|
// console.log(`cluster ${cluster_index}`, cluster);
|
||||||
let i = 0;
|
for( let s of cluster){
|
||||||
// loop through all superpositions of couple
|
cids.push(s.cid)
|
||||||
for(let [superposition_id, superposition] of Object.entries(this.allSuperpositions_bycids[couple_id])){
|
}
|
||||||
i++;
|
// console.log(`cids:${cids}`);
|
||||||
if (!mapitem.superposition_ids.length) {
|
if(cids.indexOf(concernement.id) !== -1){
|
||||||
// if main map item does not yet have a superposition use it and alter his id (for matter constraints)
|
// console.log('concernement in cluster');
|
||||||
mapitem.superposition_ids.push(superposition_id)
|
if (mapitem.superposition_cluster_index === -1) {
|
||||||
mapitem.id = `${concernement.id}___${superposition_id}`
|
// if main map item does not yet have a superposition use it and alter his id (for matter constraints)
|
||||||
}else{
|
mapitem.superposition_cluster_index = cluster_index
|
||||||
let mapitem_superposition = {
|
mapitem.id = `${concernement.id}___${cluster_index}`
|
||||||
id: `${concernement.id}___${superposition_id}`,
|
}else{
|
||||||
concernement: concernement,
|
let mapitem_superposition = {
|
||||||
superposition_ids: [superposition_id],
|
id: `${concernement.id}___${cluster_index}`,
|
||||||
clone: true
|
concernement: concernement,
|
||||||
};
|
superposition_cluster_index: cluster_index,
|
||||||
this.mapitems.push(mapitem_superposition);
|
clone: true
|
||||||
this.allMapItems_byid[mapitem_superposition.id] = mapitem_superposition;
|
};
|
||||||
}
|
this.mapitems.push(mapitem_superposition);
|
||||||
|
this.allMapItems_byid[mapitem_superposition.id] = mapitem_superposition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
this.mapitems.push(mapitem)
|
this.mapitems.push(mapitem)
|
||||||
this.allMapItems_byid[mapitem.id] = mapitem;
|
this.allMapItems_byid[mapitem.id] = mapitem;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@ export default {
|
|||||||
concernement: null,
|
concernement: null,
|
||||||
active_revision: null,
|
active_revision: null,
|
||||||
entities: null,
|
entities: null,
|
||||||
superposedEntitesIDsList: [],
|
superposedEntiteID: null,
|
||||||
|
// superposedEntitesIDsList: [],
|
||||||
canvas: null,
|
canvas: null,
|
||||||
ctx: null,
|
ctx: null,
|
||||||
pos : {
|
pos : {
|
||||||
@ -60,6 +61,7 @@ export default {
|
|||||||
'concernementsByID',
|
'concernementsByID',
|
||||||
'allEntitesById',
|
'allEntitesById',
|
||||||
'allSuperpositions_bycids',
|
'allSuperpositions_bycids',
|
||||||
|
'allSuperpositions_clustered',
|
||||||
'allMapItems_byid',
|
'allMapItems_byid',
|
||||||
'opened_concernement',
|
'opened_concernement',
|
||||||
'opened_entite_id']),
|
'opened_entite_id']),
|
||||||
@ -72,6 +74,7 @@ export default {
|
|||||||
created () {
|
created () {
|
||||||
// console.log('ConcernementMapItem created', this.mapitem);
|
// console.log('ConcernementMapItem created', this.mapitem);
|
||||||
// this.id = this.superposition_id ? `${this.cid}___${this.superposition_id}` : this.cid;
|
// this.id = this.superposition_id ? `${this.cid}___${this.superposition_id}` : this.cid;
|
||||||
|
// console.log(`this.mapitem.id`, this.mapitem.id);
|
||||||
this.id = this.mapitem.id;
|
this.id = this.mapitem.id;
|
||||||
this.concernement = this.mapitem.concernement;
|
this.concernement = this.mapitem.concernement;
|
||||||
this.cid = this.concernement.id;
|
this.cid = this.concernement.id;
|
||||||
@ -102,7 +105,7 @@ export default {
|
|||||||
// define init position of the item
|
// define init position of the item
|
||||||
this.pos = this.getRandomPos();
|
this.pos = this.getRandomPos();
|
||||||
//
|
//
|
||||||
this.getSuperposedEntitesIDsList();
|
this.getSuperposedEntiteID();
|
||||||
//
|
//
|
||||||
this.initMatterBody()
|
this.initMatterBody()
|
||||||
//
|
//
|
||||||
@ -383,27 +386,20 @@ export default {
|
|||||||
if (num > 1 || num < 0) return this.getGaussianRandom() // resample between 0 and 1
|
if (num > 1 || num < 0) return this.getGaussianRandom() // resample between 0 and 1
|
||||||
return num
|
return num
|
||||||
},
|
},
|
||||||
getSuperposedEntitesIDsList(){
|
getSuperposedEntiteID(){
|
||||||
if (this.concernement.superpositions) {
|
if (this.concernement.has_superpositions) {
|
||||||
// loop through all concernement superpositions couples of this concernement
|
let ids = this.id.match(/(\d+)___(\d+)/i);
|
||||||
for(let [couple_id, superpositions] of Object.entries(this.concernement.superpositions)){
|
if (ids) {
|
||||||
// loop through all superpositions of each couple
|
let cluster_index = ids[2];
|
||||||
for(let [superposition_id, superposition] of Object.entries(superpositions)){
|
// console.log(ids, cluster_index);
|
||||||
if (this.mapitem.superposition_ids.indexOf(superposition_id) >= 0) {
|
for(let cid_eid of this.allSuperpositions_clustered[cluster_index] ){
|
||||||
switch (this.cid) { // get the right eid regarding the cid
|
if(this.cid === cid_eid.cid){
|
||||||
case superposition[0].cid:
|
this.superposedEntiteID = cid_eid.eid;
|
||||||
this.superposedEntitesIDsList.push(superposition[0].eid);
|
break;
|
||||||
break;
|
|
||||||
case superposition[1].cid:
|
|
||||||
this.superposedEntitesIDsList.push(superposition[1].eid);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log('superposedEntitesIDsList', this.superposedEntitesIDsList);
|
|
||||||
|
|
||||||
},
|
},
|
||||||
// MATTER BODY
|
// MATTER BODY
|
||||||
initMatterBody (){
|
initMatterBody (){
|
||||||
@ -509,7 +505,7 @@ export default {
|
|||||||
pivot: new paper.Point(this.pos),
|
pivot: new paper.Point(this.pos),
|
||||||
name: `main_${this.id}`,
|
name: `main_${this.id}`,
|
||||||
cid: this.cid,
|
cid: this.cid,
|
||||||
superposition_id: this.mapitem.superposition_ids[0]
|
// superposition_id: this.mapitem.superposition_ids[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
// fadein intro
|
// fadein intro
|
||||||
@ -765,7 +761,7 @@ export default {
|
|||||||
for (let i = 0; i < this.concernement.revisions_byid[this.concernement.active_revision].entites.length; i++) {
|
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];
|
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
|
if (entite.entite // check if we have an entite object with all the contents
|
||||||
&& this.superposedEntitesIDsList.indexOf(entite.entite.id) >= 0) // check if entite id is in the list builded above
|
&& this.superposedEntiteID === entite.entite.id) // check if entite id
|
||||||
{
|
{
|
||||||
// console.log(`entite ${entite.entite.id}`, entite, entite.entite.superposition);
|
// console.log(`entite ${entite.entite.id}`, entite, entite.entite.superposition);
|
||||||
// use paper symbol
|
// use paper symbol
|
||||||
@ -779,6 +775,7 @@ export default {
|
|||||||
instance.item_type = 'entite_superpose';
|
instance.item_type = 'entite_superpose';
|
||||||
instance.is_symbol_instance = true;
|
instance.is_symbol_instance = true;
|
||||||
g.addChild(instance)
|
g.addChild(instance)
|
||||||
|
break; // there is only one superposed entite by mapitem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return g;
|
return g;
|
||||||
@ -1513,23 +1510,23 @@ export default {
|
|||||||
if (this.$route.query.superposition_id) {
|
if (this.$route.query.superposition_id) {
|
||||||
let superposition_id = this.$route.query.superposition_id;
|
let superposition_id = this.$route.query.superposition_id;
|
||||||
if(superposition_id){
|
if(superposition_id){
|
||||||
let ids = superposition_id.match(/(\d+)_(\d+)__(\d+)_(\d+)/i)
|
// let ids = superposition_id.match(/(\d+)_(\d+)__(\d+)_(\d+)/i)
|
||||||
group.children.forEach((item) => {
|
// group.children.forEach((item) => {
|
||||||
if ( (this.cid === parseInt(ids[1]) && item.item_id === parseInt(ids[2]))
|
// if ( (this.cid === parseInt(ids[1]) && item.item_id === parseInt(ids[2]))
|
||||||
|| (this.cid === parseInt(ids[3]) && item.item_id === parseInt(ids[4])) ) {
|
// || (this.cid === parseInt(ids[3]) && item.item_id === parseInt(ids[4])) ) {
|
||||||
item.definition = this.paper_symbol_definitions.entite_hover;
|
// item.definition = this.paper_symbol_definitions.entite_hover;
|
||||||
if(!item.focused){
|
// if(!item.focused){
|
||||||
item.scale(2)
|
// item.scale(2)
|
||||||
item.focused = true;
|
// item.focused = true;
|
||||||
}
|
// }
|
||||||
} else if(!this.is_hover) {
|
// } else if(!this.is_hover) {
|
||||||
item.definition = this.paper_symbol_definitions.entite;
|
// item.definition = this.paper_symbol_definitions.entite;
|
||||||
if (item.focused) {
|
// if (item.focused) {
|
||||||
item.scale(0.5)
|
// item.scale(0.5)
|
||||||
item.focused = false;
|
// item.focused = false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
group.children.forEach((item) => {
|
group.children.forEach((item) => {
|
||||||
@ -1659,7 +1656,7 @@ export default {
|
|||||||
type: 'superposition',
|
type: 'superposition',
|
||||||
id: this.id,
|
id: this.id,
|
||||||
cid: this.cid,
|
cid: this.cid,
|
||||||
eids: this.superposedEntitesIDsList
|
eid: this.superposedEntiteID
|
||||||
});
|
});
|
||||||
} else{
|
} else{
|
||||||
this.setHoverElmt({
|
this.setHoverElmt({
|
||||||
@ -1678,7 +1675,7 @@ export default {
|
|||||||
type: 'superposition',
|
type: 'superposition',
|
||||||
id: this.id,
|
id: this.id,
|
||||||
cid: this.cid,
|
cid: this.cid,
|
||||||
eids: this.superposedEntitesIDsList
|
eid: this.superposedEntiteID
|
||||||
});
|
});
|
||||||
document.body.style.cursor = "pointer";
|
document.body.style.cursor = "pointer";
|
||||||
}
|
}
|
||||||
@ -1759,13 +1756,16 @@ export default {
|
|||||||
console.log(`Open me ${this.id}`);
|
console.log(`Open me ${this.id}`);
|
||||||
// push route (keep the hash for map_mode)
|
// push route (keep the hash for map_mode)
|
||||||
// wait for routing to be finished before opening the mapItem
|
// wait for routing to be finished before opening the mapItem
|
||||||
|
let params = {cid: parseInt(this.cid)}
|
||||||
|
|
||||||
let query = {mapitemid: this.id};
|
let query = {mapitemid: this.id};
|
||||||
if (this.map_mode === "superposition") {
|
if (this.map_mode === "superposition") {
|
||||||
query.superposition_id = this.mapitem.superposition_ids[0];
|
params.eid = this.superposedEntiteID
|
||||||
|
query.superposition_cluster_index = this.mapitem.superposition_cluster_index;
|
||||||
}
|
}
|
||||||
await this.$router.push({
|
await this.$router.push({
|
||||||
name: 'concernement',
|
name: 'concernement',
|
||||||
params: {cid: parseInt(this.cid)},
|
params: params,
|
||||||
query: query,
|
query: query,
|
||||||
hash: `#${this.map_mode}`
|
hash: `#${this.map_mode}`
|
||||||
});
|
});
|
||||||
@ -1773,18 +1773,19 @@ export default {
|
|||||||
this.openCloseConcernements(this.cid, this.id)
|
this.openCloseConcernements(this.cid, this.id)
|
||||||
// reset the mousehover
|
// reset the mousehover
|
||||||
this.resetHoverElmt();
|
this.resetHoverElmt();
|
||||||
} else if (this.map_mode === 'superposition'){
|
} else if (this.map_mode === 'superposition'){ // si un concernement est ouvert et qu'on est en mode superposition
|
||||||
// if this mapitem is superposed to the opened mapitem
|
// if this mapitem is superposed to the opened mapitem
|
||||||
if(this.opened_concernement.all_superposed_concernements_id.indexOf(this.cid) >= 0){
|
if(this.opened_concernement.all_superposed_concernements_id.indexOf(this.cid) >= 0){
|
||||||
// push route (keep the hash for map_mode)
|
// push route (keep the hash for map_mode)
|
||||||
// wait for routing to be finished before opening the mapItem
|
// wait for routing to be finished before opening the mapItem
|
||||||
console.log('click on superposed this.mapitem.superposition_ids', this.mapitem.superposition_ids);
|
console.log('click on superposed this.mapitem.superposition_cluster_index', this.mapitem.superposition_cluster_index);
|
||||||
await this.$router.push({
|
await this.$router.push({
|
||||||
name: 'concernement',
|
name: 'concernement',
|
||||||
params: {cid: this.opened_concernement.cid},
|
params: {cid: this.opened_concernement.cid, eid: this.$route.params.eid},
|
||||||
query: {
|
query: {
|
||||||
mapitemid: this.opened_concernement.opened_mapitem_id,
|
mapitemid: this.opened_concernement.opened_mapitem_id,
|
||||||
superposition_id: this.mapitem.superposition_ids[0]
|
superposition_cluster_index: this.mapitem.superposition_cluster_index,
|
||||||
|
superposed_cid: this.cid
|
||||||
},
|
},
|
||||||
hash: `#${this.map_mode}`
|
hash: `#${this.map_mode}`
|
||||||
});
|
});
|
||||||
@ -1825,7 +1826,7 @@ export default {
|
|||||||
params: {cid: this.cid, eid: result.item.item_id},
|
params: {cid: this.cid, eid: result.item.item_id},
|
||||||
query: {
|
query: {
|
||||||
mapitemid: this.id,
|
mapitemid: this.id,
|
||||||
superposition_id: this.mapitem.superposition_ids[0]
|
// superposition_id: this.mapitem.superposition_ids[0]
|
||||||
},
|
},
|
||||||
hash: `#${this.map_mode}`,
|
hash: `#${this.map_mode}`,
|
||||||
});
|
});
|
||||||
@ -2078,23 +2079,14 @@ export default {
|
|||||||
// push all aside mapitems not superposed the the opened mapitem
|
// push all aside mapitems not superposed the the opened mapitem
|
||||||
let pushaside = true;
|
let pushaside = true;
|
||||||
|
|
||||||
// BUT NOT push aside mapitems superposed to superposed mapitems
|
// BUT NOT push aside mapitems superposed to this item
|
||||||
// opened_mapitem <-- superposed_mapitems <-- superposed_mapitem
|
// opened_mapitem <-- superposed_mapitems
|
||||||
if (this.opened_concernement.superposed_mapitem_id_by_mapitem_id
|
if (this.opened_concernement.superposed_mapitem_id_by_mapitem_id
|
||||||
&& this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id])
|
&& this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id])
|
||||||
{ // if opened mapitem has superposed mapitems
|
{ // if opened mapitem has superposed mapitems
|
||||||
let superposed_ids = this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id]
|
let superposed_ids = this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id]
|
||||||
if (superposed_ids.indexOf(this.id) >= 0) { //this mapitem is directly superposed to the opened mapitem
|
if (superposed_ids.indexOf(this.id) >= 0) { //this mapitem is directly superposed to the opened mapitem
|
||||||
pushaside = false;
|
pushaside = false;
|
||||||
} else { // else we look for second stage of the rockette ... superposed to superposed to opened
|
|
||||||
superposed_ids.forEach(mapitem_id => { // for each superposed map_item, check if this mapitem is in their superposed
|
|
||||||
let mapitem = this.allMapItems_byid[mapitem_id]; // get the superposed (stage 1) mapitem
|
|
||||||
mapitem.superposition_ids.forEach(sup_id => { // for each superposed (stage 2) of the superposed (stage 1)
|
|
||||||
if (this.mapitem.superposition_ids.indexOf(sup_id) >= 0) {
|
|
||||||
pushaside = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,11 +82,7 @@ export default {
|
|||||||
break;
|
break;
|
||||||
case 'superposition':
|
case 'superposition':
|
||||||
this.concernement = this.concernementsByID[this.infos.cid];
|
this.concernement = this.concernementsByID[this.infos.cid];
|
||||||
// this.entite = this.allEntitesById[this.infos.eid];
|
this.entites = [this.allEntitesById[this.infos.eid]];
|
||||||
this.entites = [];
|
|
||||||
for (let eid of this.infos.eids) {
|
|
||||||
this.entites.push(this.allEntitesById[eid])
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -63,7 +63,8 @@ export default {
|
|||||||
'opened_entite_id',
|
'opened_entite_id',
|
||||||
'opened_recit',
|
'opened_recit',
|
||||||
'allSuperpositions',
|
'allSuperpositions',
|
||||||
'allSuperpositions_bycids'
|
// 'allSuperpositions_bycids',
|
||||||
|
'allSuperpositions_clustered'
|
||||||
]),
|
]),
|
||||||
...mapState(CommonStore,['map_item_ray',
|
...mapState(CommonStore,['map_item_ray',
|
||||||
'hover_elmt',
|
'hover_elmt',
|
||||||
@ -1147,25 +1148,25 @@ export default {
|
|||||||
},
|
},
|
||||||
async setSuperpositionsMatterConstraints(){
|
async setSuperpositionsMatterConstraints(){
|
||||||
await nextTick(); // wait for dom to be upadted before applying constraint
|
await nextTick(); // wait for dom to be upadted before applying constraint
|
||||||
console.log('setSuperpositionsMatterConstraints this.allSuperpositions', this.allSuperpositions);
|
// console.log('setSuperpositionsMatterConstraints this.allSuperpositions_clustered', this.allSuperpositions_clustered);
|
||||||
|
|
||||||
// loop through all supperposition couple
|
// loop through all supperposition couple
|
||||||
for(let [couple_id, superpositions] of Object.entries(this.allSuperpositions_bycids)){
|
for(let [cluster_index, cluster] of Object.entries(this.allSuperpositions_clustered)){
|
||||||
// if couple has only one superposition, use regular mapItems
|
|
||||||
// let superpositions_ids = Object.keys(superpositions);
|
for(let [i, cid_eid_A] of cluster.entries()){
|
||||||
let i = 0;
|
// console.log(`i:${i}, cid_eid_A cid:${cid_eid_A.cid}, eid:${cid_eid_A.eid}`);
|
||||||
for(let [superposition_id, superposition] of Object.entries(superpositions)){
|
let cid_eid_B = i === cluster.length -1 ? cluster[0] : cluster[i+1];
|
||||||
i++;
|
// console.log(`i:${i}, cid_eid_B cid:${cid_eid_B.cid}, eid:${cid_eid_B.eid}`);
|
||||||
|
|
||||||
let concernementA = this.concernementsByID[superposition[0].cid];
|
let concernementA = this.concernementsByID[cid_eid_A.cid];
|
||||||
// console.log('concernementA', concernementA);
|
// console.log('concernementA', concernementA);
|
||||||
let concernementB = this.concernementsByID[superposition[1].cid];
|
let concernementB = this.concernementsByID[cid_eid_B.cid];
|
||||||
// console.log('concernementB', concernementB);
|
// console.log('concernementB', concernementB);
|
||||||
|
|
||||||
// console.log('superposition', superposition_id, superposition);
|
// console.log('superposition', superposition_id, superposition);
|
||||||
let mapitemA_id = `${superposition[0].cid}___${superposition_id}`
|
let mapitemA_id = `${cid_eid_A.cid}___${cluster_index}`
|
||||||
let mapitemB_id = `${superposition[1].cid}___${superposition_id}`
|
let mapitemB_id = `${cid_eid_B.cid}___${cluster_index}`
|
||||||
|
// console.log(`mapitemA_id: ${mapitemA_id}, mapitemB_id: ${mapitemB_id}`);
|
||||||
|
|
||||||
// get the concernement matter bodies with id
|
// get the concernement matter bodies with id
|
||||||
let bodyA = Matter.Composite.get(this.world, mapitemA_id, 'body'); // matter body id is the same as mapitem_id
|
let bodyA = Matter.Composite.get(this.world, mapitemA_id, 'body'); // matter body id is the same as mapitem_id
|
||||||
@ -1175,7 +1176,7 @@ export default {
|
|||||||
// get the entite coordinates inside the concernement body
|
// get the entite coordinates inside the concernement body
|
||||||
let pointA = null;
|
let pointA = null;
|
||||||
for(let entiteA of concernementA.revisions_byid[concernementA.active_revision].entites){
|
for(let entiteA of concernementA.revisions_byid[concernementA.active_revision].entites){
|
||||||
if (entiteA.entite && entiteA.entite.id === superposition[0].eid && entiteA.display) {
|
if (entiteA.entite && entiteA.entite.id === cid_eid_A.eid && entiteA.display) {
|
||||||
// console.log('entiteA', entiteA);
|
// console.log('entiteA', entiteA);
|
||||||
pointA = Matter.Vector.create(entiteA.display.pos.x, entiteA.display.pos.y);
|
pointA = Matter.Vector.create(entiteA.display.pos.x, entiteA.display.pos.y);
|
||||||
break;
|
break;
|
||||||
@ -1183,7 +1184,7 @@ export default {
|
|||||||
}
|
}
|
||||||
let pointB = null;
|
let pointB = null;
|
||||||
for(let entiteB of concernementB.revisions_byid[concernementB.active_revision].entites){
|
for(let entiteB of concernementB.revisions_byid[concernementB.active_revision].entites){
|
||||||
if (entiteB.entite && entiteB.entite.id === superposition[1].eid && entiteB.display) {
|
if (entiteB.entite && entiteB.entite.id === cid_eid_B.eid && entiteB.display) {
|
||||||
// console.log('entiteB', entiteB);
|
// console.log('entiteB', entiteB);
|
||||||
pointB = Matter.Vector.create(entiteB.display.pos.x, entiteB.display.pos.y);
|
pointB = Matter.Vector.create(entiteB.display.pos.x, entiteB.display.pos.y);
|
||||||
break;
|
break;
|
||||||
|
@ -161,7 +161,7 @@ export default {
|
|||||||
<!-- TODO update entite with revisions -->
|
<!-- TODO update entite with revisions -->
|
||||||
<span v-if="entite && concernement.entites_byid[eid].menacemaintien < 0" class="menacemaintient">est menacé par</span>
|
<span v-if="entite && concernement.entites_byid[eid].menacemaintien < 0" class="menacemaintient">est menacé par</span>
|
||||||
<span v-if="entite && concernement.entites_byid[eid].menacemaintien > 0" class="menacemaintient">est maintenu par</span>
|
<span v-if="entite && concernement.entites_byid[eid].menacemaintien > 0" class="menacemaintient">est maintenu par</span>
|
||||||
<h3 v-if="entite">hello {{ entite.title }}</h3>
|
<h3 v-if="entite">{{ entite.title }}</h3>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ export const ConcernementsStore = defineStore({
|
|||||||
allBesoinsById: {},
|
allBesoinsById: {},
|
||||||
allSuperpositions: [],
|
allSuperpositions: [],
|
||||||
allSuperpositions_bycids: {},
|
allSuperpositions_bycids: {},
|
||||||
|
allSuperpositions_clustered: [],
|
||||||
allMapItems_byid: {},
|
allMapItems_byid: {},
|
||||||
allProximites: [],
|
allProximites: [],
|
||||||
opened_concernement: false,
|
opened_concernement: false,
|
||||||
@ -173,8 +174,7 @@ export const ConcernementsStore = defineStore({
|
|||||||
this.concernements.push(concernement);
|
this.concernements.push(concernement);
|
||||||
this.concernementsByID[concernement.id] = concernement;
|
this.concernementsByID[concernement.id] = concernement;
|
||||||
|
|
||||||
});
|
}); // end of concernements loop
|
||||||
|
|
||||||
console.log('temp_allSuperpositions', temp_allSuperpositions);
|
console.log('temp_allSuperpositions', temp_allSuperpositions);
|
||||||
|
|
||||||
// cleaning superpositions, removing all incomplète onces
|
// cleaning superpositions, removing all incomplète onces
|
||||||
@ -185,47 +185,59 @@ export const ConcernementsStore = defineStore({
|
|||||||
this.concernementsByID[s[1].cid].has_superpositions = true;
|
this.concernementsByID[s[1].cid].has_superpositions = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('this.allSuperpositions', this.allSuperpositions);
|
console.log('this.allSuperpositions', this.allSuperpositions);
|
||||||
|
|
||||||
|
|
||||||
|
// get superpositions by cluster
|
||||||
// Handle multiple superpositions accross two concernements
|
for(let superpos_to_record of this.allSuperpositions){
|
||||||
for(let superposition of this.allSuperpositions){
|
let recorded = false;
|
||||||
let superposition_couple_id = `${superposition[0].cid}-${superposition[1].cid}`;
|
// console.log('-- -- --');
|
||||||
let superposition_id = `${superposition[0].cid}_${superposition[0].eid}__${superposition[1].cid}_${superposition[1].eid}`
|
// console.log(`superpos_to_record : ${superpos_to_record[0].cid}-${superpos_to_record[0].eid}, ${superpos_to_record[1].cid}-${superpos_to_record[1].eid}`);
|
||||||
// record allSuperpositions_bycids
|
// loop through alredy recorded clusters
|
||||||
if (!this.allSuperpositions_bycids[superposition_couple_id]) {
|
for(let [cluster_index, superpo_cluster] of this.allSuperpositions_clustered.entries()){
|
||||||
this.allSuperpositions_bycids[superposition_couple_id] = {};
|
// console.log('cluster_index', cluster_index);
|
||||||
}
|
// for each cluster loop throug each superposition
|
||||||
this.allSuperpositions_bycids[superposition_couple_id][superposition_id] = superposition;
|
in_cluster_loop:{
|
||||||
|
for(let s of superpo_cluster){
|
||||||
// record allSuperpositions_bycid
|
// console.log(`s : ${s.cid}-${s.eid}`);
|
||||||
for (let i = 0; i < 2; i++) {
|
// loop through each cid_eid couple of superpo to be recorded
|
||||||
// i is the current concernement, j is the target
|
for(let i = 0; i <= 1; i++){
|
||||||
let j = i === 0 ? 1 : 0;
|
// if one couple already recorded in the cluster, add the other one to the same cluster
|
||||||
// if (!this.allSuperpositions_bycid[superposition[i].cid]) {
|
if (superpos_to_record[i].cid === s.cid && superpos_to_record[i].eid === s.eid){
|
||||||
// this.allSuperpositions_bycid[superposition[i].cid] = [];
|
// console.log('-- recorded');
|
||||||
// }
|
let j = i === 0 ? 1 : 0;
|
||||||
if(this.concernementsByID[superposition[i].cid]){
|
// add the right item to the cluster
|
||||||
if (!this.concernementsByID[superposition[i].cid].superpositions[superposition_couple_id]) {
|
this.allSuperpositions_clustered[cluster_index].push(superpos_to_record[j]);
|
||||||
this.concernementsByID[superposition[i].cid].superpositions[superposition_couple_id] = {};
|
// record the superposition on the concernement BY cluster index
|
||||||
|
// console.log(`superpos_to_record[j].cid:${superpos_to_record[j].cid}`);
|
||||||
|
// console.log('concernement', this.concernementsByID[superpos_to_record[j].cid]);
|
||||||
|
// create array if not already exists
|
||||||
|
if(typeof this.concernementsByID[superpos_to_record[j].cid].superpositions[cluster_index] === 'undefined'){
|
||||||
|
this.concernementsByID[superpos_to_record[j].cid].superpositions[cluster_index] = [superpos_to_record];
|
||||||
|
}else{
|
||||||
|
this.concernementsByID[superpos_to_record[j].cid].superpositions[cluster_index].push(superpos_to_record);
|
||||||
|
}
|
||||||
|
recorded = true;
|
||||||
|
break in_cluster_loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// let s = {
|
|
||||||
// eid: superposition[i].eid,
|
|
||||||
// target_cid: superposition[j].cid,
|
|
||||||
// target_eid: superposition[j].eid,
|
|
||||||
// };
|
|
||||||
// this.allSuperpositions_bycid[superposition[i].cid].push(s)
|
|
||||||
// this.concernementsByID[superposition[i].cid].superpositions.push(s);
|
|
||||||
this.concernementsByID[superposition[i].cid].superpositions[superposition_couple_id][superposition_id] = superposition;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!recorded){
|
||||||
|
// console.log('-- not recorded');
|
||||||
|
// create cluster and fill it it with first couple
|
||||||
|
this.allSuperpositions_clustered.push(superpos_to_record);
|
||||||
|
// record superposition on each concernement of each couple member BY cluster index
|
||||||
|
for( let i=0; i <= 1; i++){
|
||||||
|
this.concernementsByID[superpos_to_record[i].cid].superpositions[this.allSuperpositions_clustered.length-1] = [superpos_to_record];
|
||||||
|
// console.log(`concernement ${superpos_to_record[i].cid} superposition by cluster index`,this.concernementsByID[superpos_to_record[i].cid].superpositions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('this.allSuperpositions_bycids', this.allSuperpositions_bycids);
|
console.log('this.allSuperpositions_clustered', this.allSuperpositions_clustered);
|
||||||
// console.log('this.allSuperpositions_bycid', this.allSuperpositions_bycid);
|
|
||||||
|
|
||||||
this.concernements_loaded = true;
|
this.concernements_loaded = true;
|
||||||
})
|
})
|
||||||
|
@ -30,7 +30,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
// entite: null,
|
// entite: null,
|
||||||
proximite_cid_eid: null,
|
proximite_cid_eid: null,
|
||||||
superposition_id: null,
|
superposition_cluster_index: null,
|
||||||
superposition: null,
|
superposition: null,
|
||||||
opened_besoin_id: null,
|
opened_besoin_id: null,
|
||||||
arrowup_path: mdiArrowUp
|
arrowup_path: mdiArrowUp
|
||||||
@ -40,7 +40,7 @@ export default {
|
|||||||
...mapState(ConcernementsStore,['map_mode',
|
...mapState(ConcernementsStore,['map_mode',
|
||||||
'opened_concernement',
|
'opened_concernement',
|
||||||
'concernements_loaded',
|
'concernements_loaded',
|
||||||
'allSuperpositions_bycids']),
|
'allSuperpositions_clustered']),
|
||||||
...mapState(CommonStore,['cartouch_width']),
|
...mapState(CommonStore,['cartouch_width']),
|
||||||
//
|
//
|
||||||
main_cid_eid () {
|
main_cid_eid () {
|
||||||
@ -82,7 +82,7 @@ export default {
|
|||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
console.log(`Concernement view created, id: ${this.cid}, eid: ${this.eid}, opened_concernement:${this.opened_concernement}`);
|
console.log(`Concernement view created, id: ${this.cid}, eid: ${this.eid}, opened_concernement:${this.opened_concernement}`);
|
||||||
console.log('Concernement view created, allSuperpositions_bycids', this.allSuperpositions_bycids);
|
console.log('Concernement view created, allSuperpositions_clustered', this.allSuperpositions_clustered);
|
||||||
console.log("superposition", this.superposition);
|
console.log("superposition", this.superposition);
|
||||||
|
|
||||||
if(this.map_mode === "proximite" && this.$route.query.proximite_cid && this.$route.query.proximite_eid){
|
if(this.map_mode === "proximite" && this.$route.query.proximite_cid && this.$route.query.proximite_eid){
|
||||||
@ -93,7 +93,7 @@ export default {
|
|||||||
// as we have two content to show multiply the cartouch with by 2
|
// as we have two content to show multiply the cartouch with by 2
|
||||||
// necessary for mapitem opening scale and position
|
// necessary for mapitem opening scale and position
|
||||||
this.setCartoucheWidth(2)
|
this.setCartoucheWidth(2)
|
||||||
}else if(this.map_mode === "superposition" && this.$route.query.superposition_id){
|
}else if(this.map_mode === "superposition" && this.$route.query.superposition_cluster_index){
|
||||||
this.getSuperposition()
|
this.getSuperposition()
|
||||||
// as we have two content to show multiply the cartouch with by 2
|
// as we have two content to show multiply the cartouch with by 2
|
||||||
// necessary for mapitem opening scale and position
|
// necessary for mapitem opening scale and position
|
||||||
@ -131,7 +131,7 @@ export default {
|
|||||||
$route: {
|
$route: {
|
||||||
handler (n, o) {
|
handler (n, o) {
|
||||||
console.log("concernement view $route watcher o, n", o, n);
|
console.log("concernement view $route watcher o, n", o, n);
|
||||||
if (n.query && n.query.superposition_id) {
|
if (n.query && n.query.superposition_cluster_index) {
|
||||||
this.getSuperposition()
|
this.getSuperposition()
|
||||||
}
|
}
|
||||||
if (n.query && n.query.proximite_cid && n.query.proximite_eid) {
|
if (n.query && n.query.proximite_cid && n.query.proximite_eid) {
|
||||||
@ -157,17 +157,28 @@ export default {
|
|||||||
...mapActions(CommonStore,['setCartoucheWidth']),
|
...mapActions(CommonStore,['setCartoucheWidth']),
|
||||||
getSuperposition(){
|
getSuperposition(){
|
||||||
console.log('getSuperposition');
|
console.log('getSuperposition');
|
||||||
// get superposition_id and superposition object
|
// get superposition_cluster_id and superposition object
|
||||||
if (this.$route.query.superposition_id) {
|
if (this.$route.query.superposition_cluster_index) {
|
||||||
this.superposition_id = this.$route.query.superposition_id;
|
this.superposition_cluster_index = this.$route.query.superposition_cluster_index;
|
||||||
console.log('this.superposition_id', this.superposition_id);
|
console.log('this.superposition_cluster_index', this.superposition_cluster_index);
|
||||||
if(this.superposition_id){
|
if(this.superposition_cluster_index){
|
||||||
let ids = this.superposition_id.match(/(\d+)_(\d+)__(\d+)_(\d+)/i)
|
// let ids = this.superposition_id.match(/(\d+)_(\d+)__(\d+)_(\d+)/i)
|
||||||
let couple_key = `${ids[1]}-${ids[3]}`
|
// let couple_key = `${ids[1]}-${ids[3]}`
|
||||||
// console.log('superposition_id', this.superposition_id, couple_key, ids);
|
// // console.log('superposition_id', this.superposition_id, couple_key, ids);
|
||||||
if (this.allSuperpositions_bycids[couple_key][this.superposition_id]) {
|
// if (this.allSuperpositions_bycids[couple_key][this.superposition_id]) {
|
||||||
this.superposition = this.allSuperpositions_bycids[couple_key][this.superposition_id]
|
// this.superposition = this.allSuperpositions_bycids[couple_key][this.superposition_id]
|
||||||
console.log("this.superposition", this.superposition);
|
// console.log("this.superposition", this.superposition);
|
||||||
|
// }
|
||||||
|
let cluster = this.allSuperpositions_clustered[this.superposition_cluster_index];
|
||||||
|
this.superposition = []
|
||||||
|
for(let cid_eid of cluster){
|
||||||
|
if (cid_eid.cid === this.cid) {
|
||||||
|
this.superposition.push(cid_eid)
|
||||||
|
}
|
||||||
|
if (cid_eid.cid === parseInt(this.$route.query.superposed_cid)){
|
||||||
|
this.superposition.push(cid_eid)
|
||||||
|
// console.log('this.superposition', this.superposition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user