Skip to content

Commit

Permalink
fixed size after view change, edge outline
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianoNaraku committed Sep 29, 2023
1 parent d1adad5 commit b7565f7
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 35 deletions.
3 changes: 3 additions & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ body .ui-icon{ // override jqueryui fixed resizable handles at 16px, making drag
//////////// edge paths
path{
pointer-events: stroke;
&:focus{
outline: none;
}
}
/*
.hoverable>.preview, .hoverable>svg>.preview{
Expand Down
8 changes: 5 additions & 3 deletions src/common/DV.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,15 @@ class DefaultView {
true && data.suggestedEdges.extend &&
data.suggestedEdges.extend.map(
se => (!se.vertexOverlaps)
&& <DamEdge start={se.start} end={se.end} view={"Pointer_ViewEdgeInheritance"} key={se.start.node.id+"~"+se.end.node.id}/>)]
&& <DamEdge start={se.start} end={se.end} view={"Pointer_ViewEdgeInheritance"} key={"EXT_"+se.start.node.id+"~"+se.end.node.id}/>)]
}
</div>
{data && data.packages.map((pkg, index) => {
{data && data["$default"] && <DefaultNode key={"default package"} data={data["$default"].id} />}
{data && data.packages.map((pkg) => {
if (pkg.name === "default") return undefined;
return <DefaultNode key={pkg.id} data={pkg.id}></DefaultNode>
})}
{data && data.allSubObjects.map((child, index) => {
{data && data.allSubObjects.map((child) => {
return <DefaultNode key={child.id} data={child.id}></DefaultNode>
})}
</div>`;
Expand Down
2 changes: 1 addition & 1 deletion src/graph/vertex/Vertex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class VertexComponent<AllProps extends AllPropss = AllPropss, ThisState e


getSize(): Readonly<GraphSize> {
return this.props.node.size;
return this.props.node.getSize(false, !this.props.node.isResized && this.props.view.adaptWidth);
/*console.log('get_size('+(this.props?.data as any).name+')', {
view:this.props.view.getSize(this.props.dataid || this.props.nodeid as string),
node:this.props.node?.size,
Expand Down
3 changes: 2 additions & 1 deletion src/joiner/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,8 @@ export class Pointers{
return typeof data === "string" ? data : (data as any).id;
}

static isPointer(val: any): val is Pointer {
static isPointer(val: any, state?: DState): val is Pointer {
if (state) return !!state.idlookup[val];
// todo: must refine this in a safer way
return typeof val === "string" ? val.includes("Pointer") : false;
}
Expand Down
5 changes: 5 additions & 0 deletions src/model/dataStructure/GraphDataElements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ export class LGraphElement<Context extends LogicContext<DGraphElement> = any, C
__info_of__innerSize: Info = {type:"GraphSize", txt:"the size of the current element relative to the last (most nested) graph level."};
__info_of__size: Info = {type:"GraphSize", txt: "same as innerSize."};


getSize(outer: boolean = false, canTriggerSet: boolean = true): Readonly<GraphSize> { return this.wrongAccessMessage("getSize()"); }
get_getSize(c: Context): ((outer?: boolean, canTriggerSet?: boolean) => Readonly<GraphSize>) {
return (outer: boolean = true, canTriggerSet: boolean = true) => this.get_innerSize(c, canTriggerSet, outer); }

get_outerSize(context: Context, canTriggerSet: boolean = true): Readonly<GraphSize> {
return this.get_innerSize(context, canTriggerSet, true);
}
Expand Down
72 changes: 44 additions & 28 deletions src/model/logicWrapper/LModelElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3330,12 +3330,12 @@ export class EdgeStarter<T1=any, T2=any>{ // <T1 extends LPointerTargetable = LP
this.startNode = sn;
this.endNode = en;
this.otherEnds = otherPossibleEnds || end.nodes;
this.startSize = sn.size;
this.endSize = en.size;
this.startSize = sn.outerSize;
this.endSize = en.outerSize;
this.startVertex = sn.vertex as any;
this.endVertex = en.vertex as any;
this.startVertexSize = this.startVertex === sn ? this.startSize : this.startVertex.size;
this.endVertexSize = this.endVertex === en ? this.endSize : this.endVertex.size;
this.startVertexSize = this.startVertex === sn ? this.startSize : this.startVertex.outerSize;
this.endVertexSize = this.endVertex === en ? this.endSize : this.endVertex.outerSize;
this.overlaps = this.startSize?.isOverlapping(this.endSize);
this.vertexOverlaps = this.startVertexSize?.isOverlapping(this.endVertexSize);
}
Expand Down Expand Up @@ -3395,6 +3395,7 @@ export class LModel<Context extends LogicContext<DModel> = any, C extends Contex
allSubAnnotations!: LAnnotation[];
allSubPackages!: LPackage[];
allSubObjects!: LObject[];
allSubValues!: LValue[];
suggestedEdges!: {extend: EdgeStarter[], reference:EdgeStarter[], packageDependencies: EdgeStarter[]}; //, model: EdgeStarter[], package:EdgeStarter[], class:EdgeStarter[]};
__info_of__suggestedEdges: Info = {type: 'Dictionary<"extend" | "reference" | "packageDependencies" | DmodelName, EdgeStarter[]>', txt: "A map to access all possible kind of edges based on model data." +
"<br/>extend and reference are the most commonly used for horizontal references (outside the containment tree schema)." +
Expand Down Expand Up @@ -3453,21 +3454,40 @@ export class LModel<Context extends LogicContext<DModel> = any, C extends Contex
let ret: this["suggestedEdges"];
if (context.data.isMetamodel) ret = this.get_suggestedEdgesM2(context);
else ret = this.get_suggestedEdgesM1(context);
/*
ret.extend = ret.extend || [];
ret.packageDependencies = ret.packageDependencies || [];
ret.reference = ret.reference || [];
console.log("suggested edges, pre filter", {...ret});
ret.extend = ret.extend.filter( r => !r.startNode.size.isOverlapping(r.endNode.size));
ret.packageDependencies = ret.packageDependencies.filter( r => !r.startNode.size.isOverlapping(r.endNode.size));
ret.reference = ret.reference.filter( r => !r.startNode.size.isOverlapping(r.endNode.size));
return ret;
}

console.log("suggested edges, post filter", {...ret});*/
private get_suggestedEdgesM1(context: Context, state?: DState): this["suggestedEdges"]{
let ret: this["suggestedEdges"] = {extend: [], reference: [], packageDependencies: []};
let s: DState = store.getState();
let values: LValue[] = this.get_allSubValues(context, s);
let map: Dictionary<DocString<"starting dvalue id">, EdgeStarter[]> = {};
if (!state) state = store.getState();
outer:
for (let lval of values) {
if (!lval) continue;
let dval = lval.__raw;
// NB: ELiterals can be pointers in L, but string or ordinal numbers in D, but they won't make edges, so i use .__raw
inner:
for (let v of (dval.values || [])) {
if (!Pointers.isPointer(v, state)) continue inner;
let snode = lval.node;
if (!snode) continue outer;
if (v === dval.id) continue inner; // pointing to itself
let ltarget: undefined | LEnumLiteral | LObject = LPointerTargetable.fromPointer(v, state);
if (!ltarget) continue;
if (ltarget.className !== DObject.cname) continue inner;
let enode = ltarget.node;
if (!enode) continue inner;
if (!map[dval.id]) map[dval.id] = [];
map[dval.id].push(new EdgeStarter(lval, ltarget, snode, enode, undefined));
}
}
ret.reference = Object.values(map).flat();
return ret;
}
private get_suggestedEdgesM2(context: Context): this["suggestedEdges"]{
let ret: this["suggestedEdges"] = {} as any;
let ret: this["suggestedEdges"] = {extend: [], reference: [], packageDependencies: []};
let s: DState = store.getState();
let classes: LClass[] = this.get_classes(context, s);
let references: LReference[] = classes.flatMap(c=>c.references);
Expand Down Expand Up @@ -3528,10 +3548,6 @@ export class LModel<Context extends LogicContext<DModel> = any, C extends Contex
ret.packageDependencies = pkgdependencies.flatMap( pd => ( Object.values(pd.ends).map((end) => new EdgeStarter(pd.src, end.end, pd.sn, end.en)))); // todo: check
return ret; }

private get_suggestedEdgesM1(context: Context): this["suggestedEdges"]{
let ret: this["suggestedEdges"] = {todo:true} as any;
return ret;// todo
}

protected get_models(context: Context): LModel[] {
return LModel.fromPointer(context.data.models);
Expand Down Expand Up @@ -3660,9 +3676,17 @@ export class LModel<Context extends LogicContext<DModel> = any, C extends Contex
}
return LPointerTargetable.from(Object.keys(checked), state);
}

protected get_allSubValues(context: Context, state?: DState): this["allSubValues"] {
state = state || store.getState();
return (Selectors.getAll(DValue, undefined, state, true, true) as LValue[])
.filter( (o: LValue) => o.model.id === context.data.id);
}

protected get_allSubObjects(context: Context, state?: DState): this["allSubObjects"] {
state = state || store.getState();
return (Selectors.getAll(DObject, undefined, state, true, true) as LObject[]).filter( (o: LObject) => o.model.id === context.data.id);
return (Selectors.getAll(DObject, undefined, state, true, true) as LObject[])
.filter( (o: LObject) => o.model.id === context.data.id);
/*
let tocheck: Pointer<DObject>[] = context.data.objects || [];
let checked: Dictionary<DObject, true> = {};
Expand Down Expand Up @@ -4276,7 +4300,6 @@ export class LValue<Context extends LogicContext<DValue> = any, C extends Contex
let ret: any[] = [...context.data.values] as [];
let meta: LAttribute | LReference | undefined = shapeless ? undefined : context.proxyObject.instanceof;
let dmeta: undefined | DAttribute | DReference = meta?.__raw;
console.trace("$gval 0", {v: {...ret}, v0:context.data.values, meta});

// if (meta && meta.className === DReference.name) ret = LPointerTargetable.fromArr(ret as DObject[]);
let typestr: string = meta ? meta.typeToShortString() : "shapeless";
Expand All @@ -4292,7 +4315,6 @@ export class LValue<Context extends LogicContext<DValue> = any, C extends Contex
// console.log("get_values sizefixed", {fitSize, arguments, upperbound:dmeta?.upperBound, lowerbound: dmeta?.lowerBound, len: ret.length, len0: context.data.values.length});
let numbermax = 0, numbermin = 0, round = true;
// ret is always an array of raw values before this point, eventually padded with lowerbound or trimmed at upperbound
console.log("$gval 1", {v: {...ret}, v0:context.data.values, typestr, meta});

let index = 0;
if (withmetainfo) { ret = ret.map(r => {return {value:r, rawValue: r, index: index++, hidden: false} as ValueDetail}); }
Expand Down Expand Up @@ -4328,7 +4350,6 @@ export class LValue<Context extends LogicContext<DValue> = any, C extends Contex
default: // it's a reference or enum
let lenum: LEnumerator = undefined as any;
let type: LClassifier = (meta as LStructuralFeature)?.type;
console.log("$gval 2", {v: {...ret}, v0:context.data.values, type, typestr, meta});
if (type?.className === DEnumerator.cname) {
lenum = type as LEnumerator;
mapperfunc = (r: any) => {
Expand All @@ -4350,7 +4371,6 @@ export class LValue<Context extends LogicContext<DValue> = any, C extends Contex
else mapperfunc = (r: any) => r;
if (withmetainfo) ret.forEach((struct: ValueDetail) => { struct.value = mapperfunc(struct.value); });
else ret = ret.map(mapperfunc);
console.log("$gval 3", {v: {...ret}, v0:context.data.values, type, typestr, meta, solveLiterals});

// now ret is pointed DEnumLiteral or DObject or MetaInfoStructure<>
if (type?.className === DEnumerator.cname) {
Expand All @@ -4371,13 +4391,11 @@ export class LValue<Context extends LogicContext<DValue> = any, C extends Contex
else ret = ret.filter(filterfunc);
// todo: questo comportamento implica che quando importo un literal come testo da .ecore, devo assegnargli
// il puntatore al suo literal se trovato, altrimenti resta val[i] di tipo string/shapeless
console.log("$gval 4", {v: {...ret}, namedPointers, v0:context.data.values, type, typestr, meta});
if (namedPointers) {
mapperfunc = (lit?: LEnumLiteral) => lit?.name;
if (withmetainfo) ret.forEach((struct: ValueDetail) => { struct.value = mapperfunc(struct.value); });
else ret = ret.map(mapperfunc);
}
console.log("$gval 5", {v: {...ret}, namedPointers, v0:context.data.values, type, typestr, meta});
break;
}
// is reference with assigned shape (and type) -> filter correct typed targets
Expand Down Expand Up @@ -4615,10 +4633,8 @@ export class LValue<Context extends LogicContext<DValue> = any, C extends Contex
protected set_values(val: orArr<D["values"]>, context: Context): boolean {
const list: D["values"] = ((Array.isArray(val)) ? val : [val]) as D["values"];
let modified = false;
console.log("$sval", {list, modified});
for (let i = 0; i < list.length; i++) {
modified = this.get_setValueAtPosition(context)(i, list[i], {setMirage: false} as any).success || modified;
console.log("$sval loop "+i, {i, v:list[i], list, modified});
}
if (modified) context.data.isMirage && SetFieldAction.new(context.data, 'isMirage', false, '', false);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/redux/action/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class Action extends RuntimeAccessibleClass {
this.field = field;
this.value = value;
this.type = (this.constructor as any).type;
// this.src = new Error().stack?.split('\n').splice( 4);
this.stack = new Error().stack?.split('\n').splice( 4);
this.subType = subType;
this.className = (this.constructor as typeof RuntimeAccessibleClass).cname || this.constructor.name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/redux/selectors/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export class Selectors{
W extends undefined | true | false = false, RP extends undefined | true | false = true, RET = W extends false ? (RP extends false ? Pointer<D, 1, 1, L> : D) : L>
(Classe?: DT, condition?: (e:RET) => boolean, state?: DState, resolvePointers?: RP /**/, wrap?: W /* = true */): RET[] {
if (!state) state = store.getState();
let GClass = (Classe as GObject) || {name:"idlookup"};
let GClass = (Classe as GObject) || {name:"idlookup", cname:"idlookup"};
const className: string = (GClass?.staticClassName || GClass.cname).toLowerCase();
const allIdByClassName: Pointer<D, 1, 1, L>[]
= (state as GObject)[className]
Expand Down

0 comments on commit b7565f7

Please sign in to comment.