Skip to content

Commit

Permalink
Diagram: change direction and anchor of data flow
Browse files Browse the repository at this point in the history
  • Loading branch information
SecSimon committed Oct 3, 2023
1 parent 14af0da commit 75add1b
Show file tree
Hide file tree
Showing 14 changed files with 623 additions and 120 deletions.
1 change: 1 addition & 0 deletions src/app/model/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export enum PropertyEditTypes {
AssignNumberToAsset = 'Assign Number To Asset',
CheckBox = 'Check Box',
DevInterfaceName = 'Device Interface Name',
DataFlowChangeDirection = 'Data Flow Change Direction',
DataFlowDiagramReference = 'Data Flow Diagram Reference',
DiagramReference = 'Diagram Reference',
ElementName = 'Element Name',
Expand Down
13 changes: 13 additions & 0 deletions src/app/model/dfd-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,8 @@ export class DataFlow extends DFDElement implements ICanvasFlow {
public LineTypeChanged = new EventEmitter<FlowLineTypes>();
public ArrowPosChanged = new EventEmitter<FlowArrowPositions>();
public BendFlowChanged = new EventEmitter<boolean>();
public DirectionChanged = new EventEmitter<void>();
public AnchorChanged = new EventEmitter<any>();

constructor(data: {}, type: StencilType, pf: ProjectFile, cf: ConfigFile) {
super(data, type, pf, cf);
Expand All @@ -984,6 +986,16 @@ export class DataFlow extends DFDElement implements ICanvasFlow {
});
}

public ChangeDirection() {
let tmp = this.Sender;
this.Sender = this.Receiver;
this.Receiver = tmp;
tmp = this.SenderInterface;
this.SenderInterface = this.ReceiverInterface;
this.ReceiverInterface = tmp;
this.DirectionChanged.emit();
}

public GetProperty(id: string) {
if (!this.OverwriteProtocolProperties && this.protocolProperties?.includes(id)) {
return this.ProtocolStack.some(x => x.GetProperty(id));
Expand All @@ -1002,6 +1014,7 @@ export class DataFlow extends DFDElement implements ICanvasFlow {
this.AddProperty('properties.SenderInterface', 'SenderInterface', '', true, PropertyEditTypes.InterfaceElementSelect, true);
this.AddProperty('properties.Receiver', 'Receiver', '', true, PropertyEditTypes.ElementName, true);
this.AddProperty('properties.ReceiverInterface', 'ReceiverInterface', '', true, PropertyEditTypes.InterfaceElementSelect, true);
this.AddProperty('properties.Direction', '', '', false, PropertyEditTypes.DataFlowChangeDirection, true);
this.AddProperty('properties.ShowName', 'ShowName', '', true, PropertyEditTypes.CheckBox, true);
this.AddProperty('properties.ShowProtocolDetails', 'ShowProtocolDetails', '', true, PropertyEditTypes.CheckBox, true);
this.AddProperty('properties.BendFlow', 'BendFlow', '', true, PropertyEditTypes.CheckBox, true);
Expand Down
10 changes: 6 additions & 4 deletions src/app/model/project-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class ProjectFile extends DatabaseBase {
}

const arrayItemChanged = (event: IDataChanged, array: string, constr, getItem: string, title: string) => {
if (this.changeLog.findIndex(x => x.ID == event.ID && x.Type == event.Type) < 0 && !this.changeLog.some(y => y.ID == event.ID && y.Type > event.Type)) {
if (this.projectCopy && this.changeLog.findIndex(x => x.ID == event.ID && x.Type == event.Type) < 0 && !this.changeLog.some(y => y.ID == event.ID && y.Type > event.Type)) {
if (event.Type == DataChangedTypes.Removed) {
const existingEntry = this.changeLog.find(x => x.ID == event.ID);
let objName = null;
Expand All @@ -232,9 +232,11 @@ export class ProjectFile extends DatabaseBase {
}
else {
const obj = this[getItem](event.ID);
let objName = obj['Name'];
if (obj['GetLongName']) objName = obj.GetLongName();
this.changeLog.push({ Title: title, Name: objName, ID: event.ID, Type: event.Type });
if (obj) {
let objName = obj['Name'];
if (obj['GetLongName']) objName = obj.GetLongName();
this.changeLog.push({ Title: title, Name: objName, ID: event.ID, Type: event.Type });
}
}
}
};
Expand Down
12 changes: 12 additions & 0 deletions src/app/model/system-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ export interface ICanvasFlow {
BendFlowChanged: EventEmitter<boolean>;
ArrowPos: FlowArrowPositions;
ArrowPosChanged: EventEmitter<FlowArrowPositions>;
DirectionChanged: EventEmitter<void>;
AnchorChanged: EventEmitter<any>;
}

export class ContextFlow extends ContextElement implements ICanvasFlow {
Expand Down Expand Up @@ -613,6 +615,8 @@ export class ContextFlow extends ContextElement implements ICanvasFlow {
public LineTypeChanged = new EventEmitter<FlowLineTypes>();
public ArrowPosChanged = new EventEmitter<FlowArrowPositions>();
public BendFlowChanged = new EventEmitter<boolean>();
public DirectionChanged = new EventEmitter<void>();
public AnchorChanged = new EventEmitter<any>();

constructor(data: {}, pf: ProjectFile, cf: ConfigFile) {
super(data, ContextElementTypes.Flow, pf, cf);
Expand All @@ -623,11 +627,19 @@ export class ContextFlow extends ContextElement implements ICanvasFlow {
if (this.Data['ShowName'] == null) this.ShowName = false;
}

public ChangeDirection() {
let tmp = this.Sender;
this.Sender = this.Receiver;
this.Receiver = tmp;
this.DirectionChanged.emit();
}

protected initProperties() {
super.initProperties();

this.AddProperty('properties.Sender', 'Sender', '', true, PropertyEditTypes.ElementName, true);
this.AddProperty('properties.Receiver', 'Receiver', '', true, PropertyEditTypes.ElementName, true);
this.AddProperty('properties.Direction', '', '', false, PropertyEditTypes.DataFlowChangeDirection, true);
this.AddProperty('properties.FlowType', 'FlowType', '', true, PropertyEditTypes.FlowType, true);
this.AddProperty('properties.ShowName', 'ShowName', '', true, PropertyEditTypes.CheckBox, true);
this.AddProperty('properties.BendFlow', 'BendFlow', '', true, PropertyEditTypes.CheckBox, true);
Expand Down
Loading

0 comments on commit 75add1b

Please sign in to comment.