Skip to content

Commit 8b26775

Browse files
Laura DevendorfLaura Devendorf
authored andcommitted
shaft view fixes, inlets default to 0, recompute on delete operation
1 parent 2b12b24 commit 8b26775

File tree

10 files changed

+89
-67
lines changed

10 files changed

+89
-67
lines changed

src/app/core/draftviewer/draftviewer.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ export class DraftviewerComponent implements OnInit {
292292
//this is called anytime a new draft object is loaded.
293293
onNewDraftLoaded() {
294294
var dims = this.render.getCellDims("base");
295-
296295
this.canvasEl.width = this.weave.warps * dims.w;
297296
this.canvasEl.height = this.weave.wefts * dims.h;
298297
this.threadingCanvas.width = this.weave.warps * dims.w;
@@ -1279,7 +1278,7 @@ export class DraftviewerComponent implements OnInit {
12791278
* @returns {void}
12801279
*/
12811280
private drawOnThreading( currentPos: Interlacement ) {
1282-
1281+
12831282

12841283
if (!this.cxThreading || !currentPos) { return; }
12851284

@@ -1563,7 +1562,7 @@ export class DraftviewerComponent implements OnInit {
15631562
const sys_id = this.weave.colSystemMapping[j];
15641563
const sys = this.ss.getWarpSystem(sys_id)
15651564

1566-
if(sys.isVisible()){
1565+
if(sys !== undefined && sys.isVisible()){
15671566
this.drawCell(this.cx, i, j, "drawdown");
15681567
}else{
15691568

@@ -2096,7 +2095,7 @@ public drawWeftEnd(top, left, shuttle){
20962095
//else this.drawBlank(this.cxTieups,this.tieupsCanvas);
20972096

20982097

2099-
2098+
console.log("this.loom.threading", this.loom.threading);
21002099
for (var j = 0; j < this.loom.threading.length; j++) {
21012100
this.drawCell(this.cxThreading, this.loom.threading[j], j, "threading");
21022101
}
@@ -2151,6 +2150,7 @@ public drawDrawdown(){
21512150
//takes inputs about what, exactly to redraw
21522151
public redraw(flags:any){
21532152

2153+
21542154
var base_dims = this.render.getCellDims("base");
21552155

21562156
if(flags.drawdown !== undefined){
@@ -2182,7 +2182,8 @@ public redraw(flags:any){
21822182
this.drawWarpMaterials(this.cxWarpMaterials, this.warpMaterialsCanvas);
21832183
}
21842184

2185-
if(flags.loom !== undefined && this.loom.isFrame()){
2185+
2186+
if(flags.loom !== undefined){
21862187
this.redrawLoom();
21872188
}
21882189

src/app/core/provider/file.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export class FileService {
221221
node_id: data.node_id,
222222
name: data.name,
223223
params: data.params,
224-
inlets: (data.inlets === undefined) ? [] : data.inlets
224+
inlets: (data.inlets === undefined) ? [0] : data.inlets
225225
}
226226
return op;
227227
});

src/app/mixer/mixer.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ export class MixerComponent implements OnInit {
316316
const internal_op = this.ops.getOp(op.name);
317317
if(internal_op === undefined) return;
318318
const param_types = internal_op.params.map(el => el.type);
319-
console.log(param_types, op.params);
320319
param_types.forEach((p, ndx) => {
321320
if(p === 'file') images_to_load.push(op.params[ndx]);
322321
});
@@ -416,7 +415,7 @@ export class MixerComponent implements OnInit {
416415
if(this.tree.hasParent(el.id)){
417416
el.draft = new Draft({warps: 1, wefts: 1, pattern: [[new Cell(false)]]});
418417
} else{
419-
// console.log("removing node ", el.id, el.type, this.tree.hasParent(el.id));
418+
console.log("removing node ", el.id, el.type, this.tree.hasParent(el.id));
420419
this.tree.removeNode(el.id);
421420
}
422421
})

src/app/mixer/modal/draftdetail/draftdetail.component.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@ export class DraftdetailComponent implements OnInit {
6666
this.ink = data.ink;
6767
this.loom = data.loom;
6868
this.viewonly = data.viewonly;
69-
console.log('this.ink:', this.ink);
7069

7170

7271

73-
74-
75-
76-
72+
7773

7874

7975
// this.modal_height = (this.draft.wefts+20) * this.render.getCellDims('base').h;

src/app/mixer/modal/ops/ops.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export class OpsComponent implements OnInit {
5353
}
5454

5555
addOpFromSearch(event: any){
56-
console.log("event", event);
5756
//need to convert display name toname here
5857
const ndx = this.displaynames.findIndex(el => el === event.option.value);
5958
if(ndx !== -1){

src/app/mixer/palette/connection/connection.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit, Input } from '@angular/core';
2+
import { i } from 'mathjs';
23
import { Bounds, Point } from '../../../core/model/datatypes';
34
import { TreeService } from '../../provider/tree.service';
45
import { OperationComponent } from '../operation/operation.component';
@@ -93,8 +94,11 @@ export class ConnectionComponent implements OnInit {
9394
// get the inlet value
9495
const ndx = this.tree.getInletOfCxn(to.id, this.id);
9596
if(ndx !== -1){
96-
const left_offset = document.getElementById('inlet'+to.id+"-"+ndx).offsetLeft;
97-
this.b_to = {x: to.bounds.topleft.x + left_offset*this.scale/this.default_cell_size, y: to.bounds.topleft.y}
97+
const element = document.getElementById('inlet'+to.id+"-"+ndx);
98+
if(element !== undefined && element !== null){
99+
const left_offset = element.offsetLeft;
100+
this.b_to = {x: to.bounds.topleft.x + left_offset*this.scale/this.default_cell_size, y: to.bounds.topleft.y}
101+
}
98102
}
99103
}
100104

src/app/mixer/palette/operation/operation.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ export class OperationComponent implements OnInit {
162162
dynamic_value = graph_node.params[dynamic_param];
163163
}
164164

165-
console.log("inlet values", inlet_values)
166-
167165

168166
//if inlet values is greater than 1, then we need to load the existing values in
169167
if(inlet_values.length > 1){
@@ -209,7 +207,7 @@ export class OperationComponent implements OnInit {
209207
}
210208

211209
}else{
212-
210+
console.log(graph_node.inlets);
213211
graph_node.inlets.forEach(inlet => {
214212
this.inlets.push(new FormControl(0));
215213
});
@@ -414,14 +412,17 @@ export class OperationComponent implements OnInit {
414412
case 'system':
415413
if(value > this.inlets.length){
416414
for(let i = this.inlets.length; i < value; i++){
415+
417416
if(type === 'number'){
418417
this.inlets.push(new FormControl(i));
418+
opnode.inlets.push(i);
419419
}else{
420420
this.inlets.push(new FormControl(this.systems.weft_systems[i-1].name))
421421
this.systems.weft_systems[i-1].in_use = true;
422+
opnode.inlets.push(i-1);
422423
}
423-
opnode.inlets.push(i-1);
424424
}
425+
425426
}else if(value < this.inlets.length){
426427
this.inlets.splice(value, this.inlets.length - value);
427428
opnode.inlets.splice(value, opnode.inlets.length - value);

src/app/mixer/palette/palette.component.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ export class PaletteComponent implements OnInit{
802802
this.viewport.removeObj(node.id);
803803
})
804804

805-
806805
outputs.forEach(out => {
807806
this.performAndUpdateDownstream(out);
808807
})
@@ -819,11 +818,21 @@ export class PaletteComponent implements OnInit{
819818

820819
if(id === undefined) return;
821820

822-
const delted_nodes = this.tree.removeOperationNode(id);
821+
const drafts_out = this.tree.getNonCxnOutputs(id);
822+
823+
const outputs:Array<number> = drafts_out.reduce((acc, el) => {
824+
return acc.concat(this.tree.getNonCxnOutputs(el));
825+
}, []);
823826

827+
828+
const delted_nodes = this.tree.removeOperationNode(id);
824829
delted_nodes.forEach(node => {
825830
this.removeFromViewContainer(node.ref);
826831
this.viewport.removeObj(node.id);
832+
});
833+
834+
outputs.forEach(out => {
835+
this.performAndUpdateDownstream(out);
827836
})
828837

829838
}

src/app/mixer/provider/operation.service.ts

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ export class OperationService {
341341
row.forEach((cell, j) =>{
342342
const select_col = (factor_in_repeats === 1) ? j % op_input.drafts[select_array].warps : j;
343343
if(op_input.drafts[select_array].hasCell(select_row, select_col)){
344-
cell.setHeddle(op_input.drafts[select_array].pattern[select_row][select_col].getHeddle());
344+
const pattern = op_input.drafts[select_array].pattern;
345+
cell.setHeddle(pattern[select_row][select_col].getHeddle());
345346
}else{
346347
cell.setHeddle(null);
347348
}
@@ -669,63 +670,71 @@ export class OperationService {
669670
const selvedge: Operation = {
670671
name: 'selvedge',
671672
displayname: 'selvedge',
672-
dx: 'adds a selvedge of a user defined with both sides of the input draft. User can specify the number of row repeats in the selvedge',
673+
dx: 'adds a selvedge of a user defined width (in ends) on both sides of the input draft. The second input functions as the selvedge pattern, and if none is selected, a selvedge is generated',
673674
params: [
674675
{name: 'width',
675676
type: 'number',
676677
min: 1,
677678
max: 100,
678679
value: 12,
679680
dx: "the width in warps of the selvedge"
680-
},
681-
{name: 'repeats',
682-
type: 'number',
683-
min: 1,
684-
max: 100,
685-
value: 1,
686-
dx: "the number of pics to repeat each selvedge structure, usually equal to the number of shuttles thrown"
687681
}
688682
],
689-
max_inputs: 1,
683+
max_inputs: 2,
690684
perform: (op_inputs: Array<OpInput>)=> {
691685
const op_input = op_inputs[0];
686+
if(op_input.drafts.length == 0) return Promise.resolve([]);
687+
688+
const num_systems = utilInstance.filterToUniqueValues(op_input.drafts[0].rowSystemMapping).length;
689+
const height = 2*num_systems;
692690

693-
const height = 2*op_input.params[1];
694691

695-
const pattern:Array<Array<Cell>> = [];
696-
for(let i = 0; i < height; i++){
697-
pattern.push([]);
698-
let alt: boolean = i <op_input.params[1];
699-
for(let j = 0; j < 2; j++){
700-
pattern[i][j] = ((alt && j%2 ==0) || (!alt && j%2 ==1)) ? new Cell(true) : new Cell(false);
692+
let pattern:Array<Array<Cell>> = [];
693+
694+
if(op_input.drafts.length == 2){
695+
pattern = op_input.drafts[1].pattern;
696+
}else{
697+
for(let i = 0; i < height; i++){
698+
pattern.push([]);
699+
let alt: boolean = i <num_systems;
700+
for(let j = 0; j < 2; j++){
701+
pattern[i][j] = ((alt && j%2 ==0) || (!alt && j%2 ==1)) ? new Cell(true) : new Cell(false);
702+
}
701703
}
702704
}
705+
706+
707+
708+
const input: Draft = op_input.drafts[0];
709+
const d: Draft = new Draft({warps: input.warps +op_input.params[0]*2, wefts: input.wefts});
710+
711+
712+
for(let i = 0; i < d.wefts; i++){
713+
for(let j = 0; j < d.warps; j++){
714+
if(j < op_input.params[0]){
715+
//left selvedge
716+
d.pattern[i][j].setHeddle(pattern[(i+1)%pattern.length][j%pattern[0].length].getHeddle());
703717

704-
let outputs: Array<Draft> = [];
705-
if(op_input.drafts.length == 0){
706-
const d: Draft = new Draft({warps:op_input.params[0]*2, wefts: height});
707-
d.fill(pattern, 'original');
708-
outputs.push(d);
709-
}else{
710-
outputs =op_input.drafts.map(input => {
711-
const d: Draft = new Draft({warps: input.warps +op_input.params[0]*2, wefts: input.wefts});
712-
d.fill(pattern, 'original');
713-
if(op_input.drafts.length > 0){
714-
this.transferSystemsAndShuttles(d,op_input.drafts,op_input.params, 'first');
715-
d.gen_name = this.formatName(op_input.drafts, "sel")
718+
}else if(j < op_input.params[0]+input.warps){
719+
//pattern
720+
d.pattern[i][j].setHeddle(input.pattern[i][j - op_input.params[0]].getHeddle());
721+
722+
}else{
723+
//right selvedge
724+
d.pattern[i][j].setHeddle(pattern[i%pattern.length][j%pattern[0].length].getHeddle());
716725

717726
}
718-
for(let i = 0; i < input.wefts; i++){
719-
for(let j = 0; j < input.warps; j++){
720-
d.pattern[i][j+op_input.params[0]].setHeddle(input.pattern[i][j].getHeddle()) ;
721-
}
722-
}
727+
}
728+
}
729+
730+
if(op_input.drafts.length > 0){
731+
this.transferSystemsAndShuttles(d,op_input.drafts,op_input.params, 'first');
732+
d.gen_name = this.formatName(op_input.drafts, "sel")
723733

724-
return d;
725-
});
726734
}
727735

728-
return Promise.resolve(outputs);
736+
737+
return Promise.resolve([d]);
729738
}
730739
}
731740

@@ -3028,8 +3037,7 @@ export class OperationService {
30283037
total_warps = utilInstance.lcm(all_warps);
30293038

30303039

3031-
//create a map from layers to drafts
3032-
const section_draft_map: Array<any> = child_inputs.map(el => { return {section: el.params[0]-1, draft: el.drafts.shift()}});
3040+
const section_draft_map: Array<any> = child_inputs.map(el => { return {section: el.inlet-1, draft: el.drafts.shift()}});
30333041
const first_draft: Draft = section_draft_map[0].draft;
30343042

30353043
const d:Draft = new Draft({
@@ -3282,8 +3290,8 @@ export class OperationService {
32823290
this.ops.push(shifty);
32833291
this.ops.push(layer);
32843292
this.ops.push(selvedge);
3285-
this.ops.push(bindweftfloats);
3286-
this.ops.push(bindwarpfloats);
3293+
// this.ops.push(bindweftfloats);
3294+
// this.ops.push(bindwarpfloats);
32873295
this.ops.push(joinleft);
32883296
this.ops.push(jointop);
32893297
this.ops.push(slope);
@@ -3322,7 +3330,7 @@ export class OperationService {
33223330
this.classification.push(
33233331
{category: 'block design',
33243332
dx: "1 input, 1 output, describes the arragements of regions in a weave. Fills region with input draft",
3325-
ops: [imagemap, rect, crop, trim, margin, tile]
3333+
ops: [rect, crop, trim, margin, tile]
33263334
}
33273335
);
33283336
this.classification.push(
@@ -3334,7 +3342,7 @@ export class OperationService {
33343342
this.classification.push(
33353343
{category: 'combine',
33363344
dx: "2 inputs, 1 output, operations take more than one input and integrate them into a single draft in some way",
3337-
ops: [interlace, splicein, assignlayers, layer, fill, joinleft, dynamic_join_left, jointop]}
3345+
ops: [imagemap, interlace, splicein, assignlayers, layer, fill, joinleft, dynamic_join_left, jointop]}
33383346
);
33393347

33403348
this.classification.push(

src/app/mixer/provider/tree.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export class TreeService {
113113
/** scan through nodes and return all that our valid */
114114
async validateNodes() : Promise<boolean>{
115115

116+
116117
const err_ops: Array<Node> = this.nodes
117118
.filter(el => el.type === "op")
118119
.filter(el => this.ops.getOp((<OpNode> el).name) === undefined)
@@ -126,6 +127,8 @@ export class TreeService {
126127

127128
///also check to see that all connections exist
128129
const cxns = this.getUnusuedConnections();
130+
console.log("in validate nodes", cxns);
131+
129132
// console.log("unusued connections found", cxns);
130133
cxns.forEach(el => this.removeNode(el));
131134

@@ -445,11 +448,12 @@ export class TreeService {
445448

446449
//filter out inputs that are matched to an index highter than what we offer
447450
const missing_inlets: Array<TreeNode> = inputs_to_op
448-
.filter((el) => el.ndx >= opnode.inlets.length)
451+
.filter((el) => el.ndx > opnode.inlets.length)
449452
.map(el => el.tn);
450453

454+
451455
const viewRefs = missing_inlets.map(el => el.node.ref);
452-
console.log("IN SWEEP", inputs_to_op, opnode.inlets, missing_inlets);
456+
453457

454458
missing_inlets.forEach(el => {
455459
this.removeConnectionNode(el.inputs[0].tn.node.id, el.outputs[0].tn.node.id);
@@ -1010,6 +1014,7 @@ removeOperationNode(id:number) : Array<Node>{
10101014
const deleted:Array<Node> = [];
10111015
if(cxn_id === undefined) return;
10121016

1017+
console.log("removeing node in connection")
10131018
deleted.push(this.removeNode(cxn_id));
10141019

10151020
return deleted;

0 commit comments

Comments
 (0)