refactored mapitem (main and clones) generation for better superpositions opening
This commit is contained in:
@@ -19,6 +19,9 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
id: null,
|
||||
cid: null,
|
||||
concernement: null,
|
||||
active_revision: null,
|
||||
entities: null,
|
||||
superposedEntitesIDsList: [],
|
||||
canvas: null,
|
||||
@@ -47,7 +50,7 @@ export default {
|
||||
paper_groups: {}
|
||||
}
|
||||
},
|
||||
props: ['concernement', 'active_revision', 'superposition_id'],
|
||||
props: ['mapitem'],
|
||||
computed: {
|
||||
...mapState(ConcernementsStore,['map_mode',
|
||||
'concernementsByID',
|
||||
@@ -61,8 +64,13 @@ export default {
|
||||
'paper_symbol_definitions'])
|
||||
},
|
||||
created () {
|
||||
console.log('ConcernementMapItem', this.mapitem);
|
||||
// this.id = this.superposition_id ? `${this.cid}___${this.superposition_id}` : this.cid;
|
||||
this.id = this.mapitem.id;
|
||||
this.concernement = this.mapitem.concernement;
|
||||
this.cid = this.concernement.id;
|
||||
this.id = this.superposition_id ? `${this.cid}___${this.superposition_id}` : this.cid;
|
||||
this.active_revision = this.concernement.active_revision;
|
||||
|
||||
// console.log(`ConcernementsMapItem ${this.id} created`);
|
||||
// this.entites = this.concernement.entites
|
||||
this.entites = this.concernement.revisions_byid[this.concernement.revision_id].entites;
|
||||
@@ -103,7 +111,7 @@ export default {
|
||||
// beforeUnmount () {
|
||||
unmounted () {
|
||||
// console.log(`mapitem ${this.id} unmounted`);
|
||||
if(this.superposition_id) {
|
||||
if(this.mapitem.clone) {
|
||||
// console.log(`this.paper_main_object ${this.paper_main_object.id}`, this.paper_main_object);
|
||||
paper.project.getItem({id:this.paper_main_object.id}).remove();
|
||||
};
|
||||
@@ -185,7 +193,9 @@ export default {
|
||||
active_revision: {
|
||||
handler (n, o) {
|
||||
console.log(`concernementMapItem watch active_revision o:${o}, n:${n}`);
|
||||
this.resetPaperActiveRevision();
|
||||
if(o & n){ // do not trigger on first variable filling (if o is null)
|
||||
this.resetPaperActiveRevision();
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
@@ -372,31 +382,12 @@ export default {
|
||||
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
|
||||
if (this.concernement.superpositions) {
|
||||
// loop through all concernement superpositions couples of this concernement
|
||||
for(let [couple_id, superpositions] of Object.entries(this.concernement.superpositions)){
|
||||
// loop through all superpositions of each couple
|
||||
for(let [superposition_id, superposition] of Object.entries(superpositions)){
|
||||
if (!superposition.cloned) { // not part of a clone
|
||||
if (this.mapitem.superposition_ids.indexOf(superposition_id) >= 0) {
|
||||
switch (this.cid) { // get the right eid regarding the cid
|
||||
case superposition[0].cid:
|
||||
this.superposedEntitesIDsList.push(superposition[0].eid);
|
||||
@@ -409,7 +400,7 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log('eids', eids);
|
||||
console.log('superposedEntitesIDsList', this.superposedEntitesIDsList);
|
||||
|
||||
},
|
||||
// MATTER BODY
|
||||
@@ -514,7 +505,7 @@ export default {
|
||||
pivot: new paper.Point(this.pos),
|
||||
name: `main_${this.id}`,
|
||||
cid: this.cid,
|
||||
superposition_id: this.superposition_id
|
||||
superposition_id: this.mapitem.superposition_ids[0] // TODO what to do with multiples superpositions ids
|
||||
});
|
||||
|
||||
// the sub items for one concernement
|
||||
@@ -667,7 +658,7 @@ export default {
|
||||
const contrs = new paper.Path({
|
||||
name: 'contours',
|
||||
segments: segments,
|
||||
fillColor: 'rgba(255,255,255,0.4)', // this.superposition_id ? 'rgba(255,0,0,0.4)' : 'rgba(255,255,255,0.4)',
|
||||
fillColor: 'rgba(255,255,255,0.4)',
|
||||
// selected: true,
|
||||
strokeColor: '#fff',
|
||||
strokeWidth: 1,
|
||||
@@ -1171,9 +1162,9 @@ export default {
|
||||
handlePaperVisibilityOnAfterEnginUpdate(){
|
||||
// contours focused
|
||||
if (!this.isFocused()){
|
||||
this.paper_main_object.children['contours'].fillColor = 'rgba(255,255,255,0.1)'; //this.superposition_id ? "rgba(255,0,0,0.1)" : "rgba(255,255,255,0.1)";
|
||||
this.paper_main_object.children['contours'].fillColor = this.mapitem.clone ? "rgba(255,0,0,0.1)" : "rgba(255,255,255,0.1)";
|
||||
}else{
|
||||
this.paper_main_object.children['contours'].fillColor = 'rgba(255,255,255,0.4)'; //this.superposition_id ? "rgba(255,0,0,0.4)" : "rgba(255,255,255,0.4)";
|
||||
this.paper_main_object.children['contours'].fillColor = this.mapitem.clone ? "rgba(255,0,0,0.4)" : "rgba(255,255,255,0.4)";
|
||||
if (this.is_hover) {
|
||||
this.paper_main_object.children['contours'].strokeColor = "#01ffe2";
|
||||
this.paper_main_object.children['contours'].strokeWidth = 2;
|
||||
@@ -1398,7 +1389,8 @@ export default {
|
||||
params: {cid: this.cid},
|
||||
query: {
|
||||
mapitemid: this.id,
|
||||
superposition_id: this.superposition_id
|
||||
// TODO when mapitem not a clone, there is no superposition_id prop
|
||||
superposition_id: this.mapitem.superposition_ids[0]
|
||||
},
|
||||
hash: `#${this.map_mode}`
|
||||
});
|
||||
|
@@ -1159,8 +1159,7 @@ export default {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
clearSuperpositionsMatterConstraints(){
|
||||
|
Reference in New Issue
Block a user