Commit fbeffabf authored by Claes Sjofors's avatar Claes Sjofors

Merge branch 'master'

parents 31d1db7f 834f79f1
This diff is collapsed.
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
</div> </div>
</div> </div>
<canvas id="flowcanvas" width="1200" height="800"></canvas> <canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="babel.min.js"></script>
<script type="text/babel" src="pwr.ts"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="cli.ts"></script> <script type="text/babel" src="cli.ts"></script>
<script type="text/babel" src="gdh.ts"></script> <script type="text/babel" src="gdh.ts"></script>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</div> </div>
</div> </div>
<canvas id="flowcanvas" width="1200" height="800"></canvas> <canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="babel.min.js"></script>
<script type="text/babel" src="pwr.ts"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="gdh.ts"></script> <script type="text/babel" src="gdh.ts"></script>
<script type="text/babel" src="draw.ts"></script> <script type="text/babel" src="draw.ts"></script>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<body> <body>
<canvas id="flowcanvas" width="1200" height="800"></canvas> <canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="babel.min.js"></script>
<script type="text/babel" src="pwr.ts"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="cli.ts"></script> <script type="text/babel" src="cli.ts"></script>
<script type="text/babel" src="gdh.ts"></script> <script type="text/babel" src="gdh.ts"></script>
......
...@@ -203,21 +203,16 @@ class GlowNodeClass { ...@@ -203,21 +203,16 @@ class GlowNodeClass {
Math.abs(base.y0 - base.y1) < Number.MIN_VALUE)) { Math.abs(base.y0 - base.y1) < Number.MIN_VALUE)) {
// Borders are given i x0, y0, x1, y1 // Borders are given i x0, y0, x1, y1
// Will not work in rotated nodes // Will not work in rotated nodes
let kx1, kx2, ky1, ky2; let k1 = new Point(base.x0, base.y0);
let k2 = new Point(base.x1, base.y1);
if (t === null) { if (t !== null) {
kx1 = base.x0; k1 = t.apply(k1);
kx2 = base.x1; k2 = t.apply(k2);
ky1 = base.y0;
ky2 = base.y1;
} else {
kx1 = t.x(base.x0, base.y0);
kx2 = t.x(base.x1, base.y1);
ky1 = t.y(base.x0, base.y0);
ky2 = t.y(base.x1, base.y1);
} }
g.set(Rect.union(g, new Rect(Math.min(kx1, kx2), Math.min(ky1, ky2), Math.max(kx1, kx2), Math.max(ky1, ky2)))); g.set(Rect.union(g, new Rect(Math.min(k1.x, k2.x), Math.min(k1.y, k2.y),
Math.max(k1.x, k2.x), Math.max(k1.y, k2.y))));
} else { } else {
this.a.forEach(e => e.get_borders(t, g)); this.a.forEach(e => e.get_borders(t, g));
} }
......
...@@ -5,7 +5,7 @@ class GlowRect { ...@@ -5,7 +5,7 @@ class GlowRect {
draw_type; draw_type;
line_width; line_width;
display_level; display_level;
fill; fill: boolean;
constructor(ctx) { constructor(ctx) {
this.ctx = ctx; this.ctx = ctx;
...@@ -32,7 +32,7 @@ class GlowRect { ...@@ -32,7 +32,7 @@ class GlowRect {
this.display_level = parseInt(tokens[1], 10); this.display_level = parseInt(tokens[1], 10);
break; break;
case GlowSave.Rect_fill: case GlowSave.Rect_fill:
this.fill = parseInt(tokens[1], 10); this.fill = Boolean(parseInt(tokens[1], 10));
break; break;
case GlowSave.Rect_ll: case GlowSave.Rect_ll:
i = this.ll.open(lines, i + 1); i = this.ll.open(lines, i + 1);
...@@ -51,9 +51,11 @@ class GlowRect { ...@@ -51,9 +51,11 @@ class GlowRect {
return i; return i;
} }
draw(highlight, hot) { draw(pos, highlight = 0, hot = 0, node = null) {
} let idx = this.line_width + hot;
idx = clamp(idx, 0, DRAW_TYPE_SIZE - 1);
draw_shadow(border, shadow, highlight, hot) { this.ctx.gdraw.rect(this.ll.x + pos.x, this.ll.y + pos.y,
this.ur.x - this.ll.x, this.ur.y - this.ll.y,
this.draw_type, this.fill, idx * this.fill, highlight);
} }
} }
\ No newline at end of file
...@@ -47,9 +47,10 @@ class GlowText { ...@@ -47,9 +47,10 @@ class GlowText {
return i; return i;
} }
draw(hightlight, hot) { draw(pos, hightlight = 0, hot = 0, node = null) {
} let idx = clamp(this.text_size, 0, DRAW_TYPE_SIZE - 1);
this.ctx.gdraw.text(this.p.x + pos.x, this.p.y + pos.y, this.text,
draw_shadow(border, shadow, hightlight, hot) { this.draw_type, this.color_drawtype, idx, hightlight, Font.Helvetica,
(8 + 2 * this.text_size));
} }
} }
\ No newline at end of file
class GlowTransform { class Matrix {
a11 = 1; a11 = 1;
a12 = 0; a12 = 0;
a13 = 0; a13 = 0;
...@@ -6,24 +6,60 @@ class GlowTransform { ...@@ -6,24 +6,60 @@ class GlowTransform {
a22 = 1; a22 = 1;
a23 = 0; a23 = 0;
rotation = 0; rotation = 0;
s: GlowTransform;
stored = false;
set(o: GlowTransform) { set(m: Matrix) {
this.a11 = o.a11; this.a11 = m.a11;
this.a12 = o.a12; this.a12 = m.a12;
this.a13 = o.a13; this.a13 = m.a13;
this.a21 = o.a21; this.a21 = m.a21;
this.a22 = o.a22; this.a22 = m.a22;
this.a23 = o.a23; this.a23 = m.a23;
this.rotation = o.rotation; this.rotation = m.rotation;
}
apply(p: Point) {
return new Point(
p.x * this.a11 + p.y * this.a12 + this.a13,
p.x * this.a21 + p.y * this.a22 + this.a23
);
}
static multiply(a, b) {
if (b === null) {
return a;
}
if (a === null) {
return b;
}
let tmp = new Matrix();
tmp.a11 = a.a11 * b.a11 + a.a12 * b.a21;
tmp.a12 = a.a11 * b.a12 + a.a12 * b.a22;
tmp.a13 = a.a11 * b.a13 + a.a12 * b.a23 + a.a13;
tmp.a21 = a.a21 * b.a11 + a.a22 * b.a21;
tmp.a22 = a.a21 * b.a12 + a.a22 * b.a22;
tmp.a23 = a.a21 * b.a13 + a.a22 * b.a23 + a.a23;
tmp.rotation = a.rotation + b.rotation;
return tmp;
}
vertical_scale() {
return Math.sqrt(this.a12 * this.a12 + this.a22 * this.a22);
} }
}
class GlowTransform extends Matrix {
s: Matrix;
stored = false;
store() { store() {
this.s.set(this); this.s.set(this);
this.stored = true; this.stored = true;
} }
revert() {
this.set(this.s);
}
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
...@@ -65,68 +101,6 @@ class GlowTransform { ...@@ -65,68 +101,6 @@ class GlowTransform {
return i; return i;
} }
rot() {
if (arguments.length === 1 && arguments[0] !== null) {
let t = arguments[0];
return t.rotation + this.rotation;
} else {
return this.rotation;
}
}
x() {
if (arguments.length === 3 && arguments[0] !== null) {
let t = arguments[0];
let x1 = arguments[1];
let y1 = arguments[2];
let tmp = GlowTransform.multiply(t, this);
return x1 * tmp.a11 + y1 * tmp.a12 + tmp.a13;
} else {
let x1 = arguments[0];
let y1 = arguments[1];
return x1 * this.a11 + y1 * this.a12 + this.a13;
}
}
y() {
if (arguments.length === 3 && arguments[0] !== null) {
let t = arguments[0];
let x1 = arguments[1];
let y1 = arguments[2];
let tmp = GlowTransform.multiply(t, this);
return x1 * tmp.a21 + y1 * tmp.a22 + tmp.a23;
} else {
let x1 = arguments[0];
let y1 = arguments[1];
return x1 * this.a21 + y1 * this.a22 + this.a23;
}
}
static multiply(a, b) {
let tmp = new GlowTransform();
tmp.a11 = a.a11 * b.a11 + a.a12 * b.a21;
tmp.a12 = a.a11 * b.a12 + a.a12 * b.a22;
tmp.a13 = a.a11 * b.a13 + a.a12 * b.a23 + a.a13;
tmp.a21 = a.a21 * b.a11 + a.a22 * b.a21;
tmp.a22 = a.a21 * b.a12 + a.a22 * b.a22;
tmp.a23 = a.a21 * b.a13 + a.a22 * b.a23 + a.a23;
tmp.rotation = a.rotation + b.rotation;
return tmp;
}
set_from_stored(t) {
this.set(GlowTransform.multiply(t, this.s));
this.a11 = t.a11 * this.s.a11 + t.a12 * this.s.a21;
this.a12 = t.a11 * this.s.a12 + t.a12 * this.s.a22;
this.a13 = t.a11 * this.s.a13 + t.a12 * this.s.a23 + t.a13;
this.a21 = t.a21 * this.s.a11 + t.a22 * this.s.a21;
this.a22 = t.a21 * this.s.a12 + t.a22 * this.s.a22;
this.a23 = t.a21 * this.s.a13 + t.a22 * this.s.a23 + t.a23;
this.rotation = this.s.rotation + t.rotation;
}
scale(sx, sy, x0, y0) { scale(sx, sy, x0, y0) {
this.a13 = this.a13 * sx + x0 * (1 - sx); this.a13 = this.a13 * sx + x0 * (1 - sx);
this.a23 = this.a23 * sy + y0 * (1 - sy); this.a23 = this.a23 * sy + y0 * (1 - sy);
...@@ -136,15 +110,6 @@ class GlowTransform { ...@@ -136,15 +110,6 @@ class GlowTransform {
this.a22 *= sy; this.a22 *= sy;
} }
scale_from_stored(sx, sy, x0, y0) {
this.a13 = this.s.a13 * sx + x0 * (1 - sx);
this.a23 = this.s.a23 * sy + y0 * (1 - sy);
this.a11 = this.s.a11 * sx;
this.a12 = this.s.a12 * sx;
this.a21 = this.s.a21 * sy;
this.a22 = this.s.a22 * sy;
}
rotate(angle, x0, y0) { rotate(angle, x0, y0) {
let sin_a; let sin_a;
let cos_a; let cos_a;
...@@ -176,28 +141,6 @@ class GlowTransform { ...@@ -176,28 +141,6 @@ class GlowTransform {
this.rotation += angle; this.rotation += angle;
} }
rotate_from_stored(angle, x0, y0) {
let sin_a;
let cos_a;
if (-90.01 < this.s.rotation + angle && this.s.rotation + angle < -89.99) {
sin_a = -1.0;
cos_a = 0.0;
} else {
sin_a = Math.sin((this.s.rotation + angle) / 180 * 3.14159);
cos_a = Math.cos((this.s.rotation + angle) / 180 * 3.14159);
}
this.a11 = this.s.a11 * cos_a - this.s.a21 * sin_a;
this.a12 = this.s.a12 * cos_a - this.s.a22 * sin_a;
this.a13 =
this.s.a13 * cos_a - this.s.a23 * sin_a + x0 * (1 - cos_a) + y0 * sin_a;
this.a21 = this.s.a11 * sin_a + this.s.a21 * cos_a;
this.a22 = this.s.a21 * sin_a + this.s.a22 * cos_a;
this.a23 =
this.s.a13 * sin_a + this.s.a23 * cos_a + y0 * (1 - cos_a) - x0 * sin_a;
this.rotation = this.s.rotation + angle;
}
move(x0, y0) { move(x0, y0) {
this.a13 += x0; this.a13 += x0;
this.a23 += y0; this.a23 += y0;
...@@ -214,7 +157,7 @@ class GlowTransform { ...@@ -214,7 +157,7 @@ class GlowTransform {
} }
reverse(x, y) { reverse(x, y) {
let p = new GlowPoint(); let p = new Point();
if (this.a11 === 0 || (this.a12 * this.a21 - this.a11 * this.a22) === 0) { if (this.a11 === 0 || (this.a12 * this.a21 - this.a11 * this.a22) === 0) {
if (this.a11 === 0 && this.a22 === 0 && this.a12 !== 0 && if (this.a11 === 0 && this.a22 === 0 && this.a12 !== 0 &&
this.a21 !== 0) { this.a21 !== 0) {
...@@ -233,16 +176,6 @@ class GlowTransform { ...@@ -233,16 +176,6 @@ class GlowTransform {
return p; return p;
} }
vertical_scale(t) {
if (t === null) {
return Math.sqrt(this.a12 * this.a12 + this.a22 * this.a22);
}
let tmp = GlowTransform.multiply(t, this);
return Math.sqrt(tmp.a12 * tmp.a12 + tmp.a22 * tmp.a22);
}
is_stored() { is_stored() {
return this.stored; return this.stored;
} }
......
...@@ -49,7 +49,7 @@ class GrowAnnot extends GlowAnnot { ...@@ -49,7 +49,7 @@ class GrowAnnot extends GlowAnnot {
return; return;
} }
let trf_scale = this.trf.vertical_scale(t); let trf_scale = Matrix.multiply(t, this.trf).vertical_scale();
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y / let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3); this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y / let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
...@@ -75,11 +75,15 @@ class GrowAnnot extends GlowAnnot { ...@@ -75,11 +75,15 @@ class GrowAnnot extends GlowAnnot {
ldraw_type = this.draw_type; ldraw_type = this.draw_type;
} }
let x1 = Math.floor((this.trf.x(t, this.p.x, this.p.y) + offset_x) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p = tmp.apply(this.p);
let y1 = Math.floor((this.trf.y(t, this.p.x, this.p.y) + offset_y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let x1 = Math.floor((p.x + offset_x) * this.ctx.mw.zoom_factor_x) -
let rot = Math.floor(this.trf.rot(t)); this.ctx.mw.offset_x;
let y1 = Math.floor((p.y + offset_y) * this.ctx.mw.zoom_factor_y) -
this.ctx.mw.offset_y;
let rot = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rot = Math.floor(rot);
rot = rot < 0 ? rot % 360 + 360 : rot % 360; rot = rot < 0 ? rot % 360 + 360 : rot % 360;
switch (this.annot_type) { switch (this.annot_type) {
...@@ -157,7 +161,7 @@ class GrowAnnot extends GlowAnnot { ...@@ -157,7 +161,7 @@ class GrowAnnot extends GlowAnnot {
return new Point(); return new Point();
} }
let trf_scale = this.trf.vertical_scale(t); let trf_scale = Matrix.multiply(t, this.trf).vertical_scale();
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y / let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4); this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y / let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
......
...@@ -169,29 +169,24 @@ class GrowArc extends GlowArc { ...@@ -169,29 +169,24 @@ class GrowArc extends GlowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = Math.floor(this.trf.rot(t)); let rot = Math.floor(tmp.rotation);
if (rot % 90 !== 0 && if (rot % 90 !== 0 &&
Math.abs((this.ur.x - this.ll.x) - (this.ur.y - this.ll.y)) < Math.abs((this.ur.x - this.ll.x) - (this.ur.y - this.ll.y)) <
Number.MIN_VALUE) { Number.MIN_VALUE) {
let tmp = t ? GlowTransform.multiply(t, this.trf) : this.trf; let scale = Matrix.multiply(tmp, this.trf).vertical_scale();
let scale = this.trf.vertical_scale(tmp); let x_c = ((p.x * this.ctx.mw.zoom_factor_x - this.ctx.mw.offset_x) +
let x_c = ((this.trf.x(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_x - (p2.x * this.ctx.mw.zoom_factor_x - this.ctx.mw.offset_x)) / 2;
this.ctx.mw.offset_x) + let y_c = ((p.y * this.ctx.mw.zoom_factor_y - this.ctx.mw.offset_y) +
(this.trf.x(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_x - (p2.y * this.ctx.mw.zoom_factor_y - this.ctx.mw.offset_y)) / 2;
this.ctx.mw.offset_x)) / 2;
let y_c = ((this.trf.y(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_y -
this.ctx.mw.offset_y) +
(this.trf.y(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_y -
this.ctx.mw.offset_y)) / 2;
x1 = Math.floor(-scale * x1 = Math.floor(-scale *
((this.ur.x - this.ll.x) / 2 * this.ctx.mw.zoom_factor_x) + x_c + 0.5); ((this.ur.x - this.ll.x) / 2 * this.ctx.mw.zoom_factor_x) + x_c + 0.5);
...@@ -333,12 +328,12 @@ class GrowArc extends GlowArc { ...@@ -333,12 +328,12 @@ class GrowArc extends GlowArc {
} }
get_borders(t, g) { get_borders(t, g) {
let x1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let x2 = this.trf.x(t, this.ur.x, this.ur.y); let p1 = tmp.apply(this.ll);
let y1 = this.trf.y(t, this.ll.x, this.ll.y); let p2 = tmp.apply(this.ur);
let y2 = this.trf.y(t, this.ur.x, this.ur.y);
g.set(Rect.union(g, new Rect(Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)))); g.set(Rect.union(g, new Rect(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y),
Math.max(p1.x, p2.x), Math.max(p1.y, p2.y))));
} }
get_background_object_limits(t, type, x, y, bo) { get_background_object_limits(t, type, x, y, bo) {
......
...@@ -202,16 +202,17 @@ class GrowAxis extends GrowRect { ...@@ -202,16 +202,17 @@ class GrowAxis extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360; let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -459,15 +460,15 @@ class GrowAxis extends GrowRect { ...@@ -459,15 +460,15 @@ class GrowAxis extends GrowRect {
this.max_value = maxval; this.max_value = maxval;
this.min_value = minval; this.min_value = minval;
let x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) * let p1 = this.trf.apply(this.ll);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p2 = this.trf.apply(this.ur);
let y1 = Math.floor(this.trf.y(this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let x2 = Math.floor(this.trf.x(this.ur.x, this.ur.y) * let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(this.ur.x, this.ur.y) * let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation = (this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * let rotation = (this.trf.rotation / 360 - Math.floor(this.trf.rotation / 360)) *
360; 360;
if (keep_settings === 0) { if (keep_settings === 0) {
......
...@@ -133,16 +133,17 @@ class GrowAxisArc extends GrowArc { ...@@ -133,16 +133,17 @@ class GrowAxisArc extends GrowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360; let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -250,15 +251,15 @@ class GrowAxisArc extends GrowArc { ...@@ -250,15 +251,15 @@ class GrowAxisArc extends GrowArc {
this.max_value = maxval; this.max_value = maxval;
this.min_value = minval; this.min_value = minval;
let x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) * let p1 = this.trf.apply(this.ll);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p2 = this.trf.apply(this.ur);
let y1 = Math.floor(this.trf.y(this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let x2 = Math.floor(this.trf.x(this.ur.x, this.ur.y) * let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(this.ur.x, this.ur.y) * let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation = (this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * let rotation = (this.trf.rotation / 360 - Math.floor(this.trf.rotation / 360)) *
360; 360;
if (keep_settings === 0) { if (keep_settings === 0) {
......
...@@ -108,20 +108,20 @@ class GrowBar extends GrowRect { ...@@ -108,20 +108,20 @@ class GrowBar extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2); let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2); let ur_y = Math.max(y1, y2);
if (this.fill !== 0) { if (this.fill) {
let drawtype = let drawtype =
GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight, GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight,
highlight, colornode, 1, 0); highlight, colornode, 1, 0);
...@@ -130,7 +130,7 @@ class GrowBar extends GrowRect { ...@@ -130,7 +130,7 @@ class GrowBar extends GrowRect {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype, true, 0); drawtype, true, 0);
} else { } else {
let rotation = (t) ? this.trf.rot(t) : this.trf.rot(); let rotation = (t) ? this.trf.rotation + t.rotation : this.trf.rotation;
let fa1, fa2; let fa1, fa2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -155,7 +155,7 @@ class GrowBar extends GrowRect { ...@@ -155,7 +155,7 @@ class GrowBar extends GrowRect {
if (this.max_value !== this.min_value) { if (this.max_value !== this.min_value) {
let x0, y0, width, height, l_x0, l_y0, l_x1, l_y1; let x0, y0, width, height, l_x0, l_y0, l_x1, l_y1;
let rotation = (t) ? this.trf.rot(t) : this.trf.rot(); let rotation = (t) ? this.trf.rotation + t.rotation : this.trf.rotation;
rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360; rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
x0 = ll_x; x0 = ll_x;
y0 = ll_y; y0 = ll_y;
...@@ -201,7 +201,7 @@ class GrowBar extends GrowRect { ...@@ -201,7 +201,7 @@ class GrowBar extends GrowRect {
if (grad === Gradient.No) { if (grad === Gradient.No) {
this.ctx.gdraw.rect(x0, y0, width, height, dt, true, 0); this.ctx.gdraw.rect(x0, y0, width, height, dt, true, 0);
} else { } else {
rotation = (t) ? this.trf.rot(t) : this.trf.rot(); rotation = (t) ? this.trf.rotation + t.rotation : this.trf.rotation;
let fb1, fb2; let fb1, fb2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
......
...@@ -92,16 +92,17 @@ class GrowBarArc extends GrowArc { ...@@ -92,16 +92,17 @@ class GrowBarArc extends GrowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360; let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
......
...@@ -136,15 +136,17 @@ class GrowBarChart extends GrowRect { ...@@ -136,15 +136,17 @@ class GrowBarChart extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = Math.floor(this.trf.rot(t));
let rot = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rot = Math.floor(rot);
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
......
...@@ -386,20 +386,19 @@ class GrowFolder extends GrowWindow { ...@@ -386,20 +386,19 @@ class GrowFolder extends GrowWindow {
(8 + 2 * this.text_size); (8 + 2 * this.text_size);
text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1); text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1);
let dx1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let dy1 = this.trf.y(t, this.ll.x, this.ll.y); let d1 = tmp.apply(this.ll);
let dx2 = this.trf.x(t, this.ur.x, this.ur.y); let d2 = tmp.apply(this.ur);
let dy2 = this.trf.y(t, this.ur.x, this.ur.y); d1.x = Math.min(d1.x, d2.x);
dx1 = Math.min(dx1, dx2); d2.x = Math.max(d1.x, d2.x);
dx2 = Math.max(dx1, dx2); d1.y = Math.min(d1.y, d2.y);
dy1 = Math.min(dy1, dy2); d2.y = Math.max(d1.y, d2.y);
dy2 = Math.max(dy1, dy2);
let ll_x = Math.floor(dx1 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ll_x = Math.floor(d1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_x = Math.floor(dx2 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ur_x = Math.floor(d2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_y = Math.floor((dy1 + this.y_low_offs) * this.ctx.mw.zoom_factor_y) - let ur_y = Math.floor((d1.y + this.y_low_offs) * this.ctx.mw.zoom_factor_y) -
this.ctx.mw.offset_y; this.ctx.mw.offset_y;
let ll_y = Math.floor(dy1 * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let ll_y = Math.floor(d1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let drawtype = let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
......
...@@ -137,14 +137,14 @@ class GrowImage extends Rect { ...@@ -137,14 +137,14 @@ class GrowImage extends Rect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -155,12 +155,12 @@ class GrowImage extends Rect { ...@@ -155,12 +155,12 @@ class GrowImage extends Rect {
} }
get_borders(t, g) { get_borders(t, g) {
let x1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let x2 = this.trf.x(t, this.ur.x, this.ur.y); let p1 = tmp.apply(this.ll);
let y1 = this.trf.y(t, this.ll.x, this.ll.y); let p2 = tmp.apply(this.ur);
let y2 = this.trf.y(t, this.ur.x, this.ur.y);
g.set(Rect.union(g, new Rect(Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)))); g.set(Rect.union(g, new Rect(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y),
Math.max(p1.x, p2.x), Math.max(p1.y, p2.y))));
} }
get_node_borders() { get_node_borders() {
...@@ -206,7 +206,8 @@ class GrowImage extends Rect { ...@@ -206,7 +206,8 @@ class GrowImage extends Rect {
let old_x_right = this.ur_x; let old_x_right = this.ur_x;
let old_y_low = this.ll_y; let old_y_low = this.ll_y;
let old_y_high = this.ur_y; let old_y_high = this.ur_y;
this.trf.scale_from_stored(scale_x, scale_y, x0, y0); this.trf.revert();
this.trf.scale(scale_x, scale_y, x0, y0);
this.get_node_borders(); this.get_node_borders();
switch (type) { switch (type) {
......
...@@ -96,14 +96,14 @@ class GrowLine extends GlowLine { ...@@ -96,14 +96,14 @@ class GrowLine extends GlowLine {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.p1.x, this.p1.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.p1);
let y1 = Math.floor(this.trf.y(t, this.p1.x, this.p1.y) * let p2 = tmp.apply(this.p2);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.p2.x, this.p2.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.p2.x, this.p2.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
if (x1 === x2 && y1 === y2) { if (x1 === x2 && y1 === y2) {
return; return;
......
...@@ -46,18 +46,14 @@ class GrowMenu extends GrowRect { ...@@ -46,18 +46,14 @@ class GrowMenu extends GrowRect {
if (this.ctx.nodraw !== 0) { if (this.ctx.nodraw !== 0) {
return; return;
} }
let text_idx = Math.floor(this.trf.vertical_scale(t) * let tsize = Matrix.multiply(t, this.trf).vertical_scale() *
this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * (this.text_size + 4);
(this.text_size + 4) - 4); let text_idx = clamp(Math.floor(tsize - 4), 0, DRAW_TYPE_SIZE - 1);
let tsize = this.trf.vertical_scale(t) * this.ctx.mw.zoom_factor_y / tsize *= 2;
this.ctx.mw.base_zoom_factor * (8 + 2 * this.text_size);
text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1);
text_idx = Math.max(0, text_idx);
let idx = Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * let idx = Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
this.line_width - 1); this.line_width - 1);
idx += hot; idx = clamp(idx + hot, 0, DRAW_TYPE_SIZE-1);
idx = clamp(idx, 0, DRAW_TYPE_SIZE-1);
let z_width, z_descent; let z_width, z_descent;
let z_height = 0; let z_height = 0;
...@@ -118,7 +114,7 @@ class GrowMenu extends GrowRect { ...@@ -118,7 +114,7 @@ class GrowMenu extends GrowRect {
Math.floor(this.ll.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; Math.floor(this.ll.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.get_node_borders(); this.get_node_borders();
if (this.fill !== 0) { if (this.fill) {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
this.fill_drawtype, true, 0); this.fill_drawtype, true, 0);
} }
...@@ -176,7 +172,7 @@ class GrowMenu extends GrowRect { ...@@ -176,7 +172,7 @@ class GrowMenu extends GrowRect {
let ur_y = Math.max(this.ll.y, this.ur.y); let ur_y = Math.max(this.ll.y, this.ur.y);
if (ll_x <= x && x <= ur_x && ll_y <= y && y <= ur_y) { if (ll_x <= x && x <= ur_x && ll_y <= y && y <= ur_y) {
let vscale = this.trf.vertical_scale(null); let vscale = this.trf.vertical_scale();
let item = Math.floor((y - this.ll.y) / let item = Math.floor((y - this.ll.y) /
(this.item_height / vscale / this.ctx.mw.zoom_factor_y)); (this.item_height / vscale / this.ctx.mw.zoom_factor_y));
......
...@@ -213,7 +213,7 @@ class GrowNode extends GlowNode { ...@@ -213,7 +213,7 @@ class GrowNode extends GlowNode {
if (t === null) { if (t === null) {
this.nc.draw(this.trf, highlight, hot, node, node); this.nc.draw(this.trf, highlight, hot, node, node);
} else { } else {
let trf_tot = GlowTransform.multiply(t, this.trf); let trf_tot = Matrix.multiply(t, this.trf);
this.nc.draw(trf_tot, highlight, hot, this, this); this.nc.draw(trf_tot, highlight, hot, this, this);
} }
} else { } else {
...@@ -291,7 +291,7 @@ class GrowNode extends GlowNode { ...@@ -291,7 +291,7 @@ class GrowNode extends GlowNode {
if (t === null) { if (t === null) {
this.nc.draw(this.trf, highlight, hot, node, node); this.nc.draw(this.trf, highlight, hot, node, node);
} else { } else {
let trf_tot = GlowTransform.multiply(t, this.trf); let trf_tot = Matrix.multiply(t, this.trf);
// If this node has a trace pointer, use colors for this node // If this node has a trace pointer, use colors for this node
this.nc.draw(trf_tot, highlight, hot, this, this); this.nc.draw(trf_tot, highlight, hot, this, this);
} }
...@@ -351,7 +351,7 @@ class GrowNode extends GlowNode { ...@@ -351,7 +351,7 @@ class GrowNode extends GlowNode {
if (t === null) { if (t === null) {
this.nc.draw(this.trf, highlight, hot, node, node); this.nc.draw(this.trf, highlight, hot, node, node);
} else { } else {
let trf_tot = GlowTransform.multiply(t, this.trf); let trf_tot = Matrix.multiply(t, this.trf);
// If this node has a trace pointer, use colors for this node // If this node has a trace pointer, use colors for this node
this.nc.draw(trf_tot, highlight, hot, this, this); this.nc.draw(trf_tot, highlight, hot, this, this);
} }
...@@ -466,7 +466,8 @@ class GrowNode extends GlowNode { ...@@ -466,7 +466,8 @@ class GrowNode extends GlowNode {
old_x_right = this.ur_x; old_x_right = this.ur_x;
old_y_low = this.ll_y; old_y_low = this.ll_y;
old_y_high = this.ur_y; old_y_high = this.ur_y;
this.trf.scale_from_stored(scale_x, scale_y, x0, y0); this.trf.revert();
this.trf.scale(scale_x, scale_y, x0, y0);
this.get_node_borders(); this.get_node_borders();
this.ctx.draw(); this.ctx.draw();
...@@ -510,7 +511,7 @@ class GrowNode extends GlowNode { ...@@ -510,7 +511,7 @@ class GrowNode extends GlowNode {
let t = new GlowTransform(); let t = new GlowTransform();
t.rotate(angel, x0, y0); t.rotate(angel, x0, y0);
this.trf.set_from_stored(t); this.trf.set(Matrix.multiply(t, this.trf.s));
this.get_node_borders(); this.get_node_borders();
} }
...@@ -600,29 +601,27 @@ class GrowNode extends GlowNode { ...@@ -600,29 +601,27 @@ class GrowNode extends GlowNode {
} }
// Calculate max and min coordinates // Calculate max and min coordinates
let x1 = this.trf.x(0, this.nc.y0); let p1 = this.trf.apply(new Point(0, this.nc.y0));
let y1 = this.trf.y(0, this.nc.y0); let p2 = this.trf.apply(new Point(0, this.nc.y1));
let x2 = this.trf.x(0, this.nc.y1);
let y2 = this.trf.y(0, this.nc.y1);
let rotation = (this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * 360; let rotation = (this.trf.rotation / 360 - Math.floor(this.trf.rotation / 360)) * 360;
if (rotation <= 45 || rotation > 315) { if (rotation <= 45 || rotation > 315) {
limits.direction = Direction.Down; limits.direction = Direction.Down;
limits.min = y1; limits.min = p1.y;
limits.max = y2; limits.max = p2.y;
} else if (rotation > 45 && rotation <= 135) { } else if (rotation > 45 && rotation <= 135) {
limits.direction = Direction.Right; limits.direction = Direction.Right;
limits.min = x2; limits.min = p2.x;
limits.max = x1; limits.max = p1.x;
} else if (rotation > 135 && rotation <= 225) { } else if (rotation > 135 && rotation <= 225) {
limits.direction = Direction.Up; limits.direction = Direction.Up;
limits.min = y2; limits.min = p2.y;
limits.max = y1; limits.max = p1.y;
} else if (rotation > 225 && rotation <= 315) { } else if (rotation > 225 && rotation <= 315) {
limits.direction = Direction.Left; limits.direction = Direction.Left;
limits.min = x1; limits.min = p1.x;
limits.max = x2; limits.max = p2.x;
} }
limits.status = 1; limits.status = 1;
return limits; return limits;
...@@ -635,7 +634,7 @@ class GrowNode extends GlowNode { ...@@ -635,7 +634,7 @@ class GrowNode extends GlowNode {
} }
get_borders(t, g) { get_borders(t, g) {
let t2 = (t) ? GlowTransform.multiply(t, this.trf) : this.trf; let t2 = (t) ? Matrix.multiply(t, this.trf) : this.trf;
this.nc.get_borders(t2, g); this.nc.get_borders(t2, g);
} }
...@@ -655,30 +654,28 @@ class GrowNode extends GlowNode { ...@@ -655,30 +654,28 @@ class GrowNode extends GlowNode {
this.get_borders(t, g); this.get_borders(t, g);
if (g.hit(new Point(x, y))) { if (g.hit(new Point(x, y))) {
// Hit, calculate max and min koordinates // Hit, calculate max and min koordinates
let x1 = this.trf.x(t, 0, this.nc.y0); let tmp = Matrix.multiply(t, this.trf);
let y1 = this.trf.y(t, 0, this.nc.y0); let p1 = tmp.apply(new Point(0, this.nc.y0));
let x2 = this.trf.x(t, 0, this.nc.y1); let p2 = tmp.apply(new Point(0, this.nc.y1));
let y2 = this.trf.y(t, 0, this.nc.y1);
let rotation = let rotation = (tmp.rotation / 360 - Math.floor(tmp.rotation / 360)) * 360;
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360;
if (rotation <= 45 || rotation > 315) { if (rotation <= 45 || rotation > 315) {
b.direction = Direction.Down; b.direction = Direction.Down;
b.min = y1; b.min = p1.y;
b.max = y2; b.max = p2.y;
} else if (rotation > 45 && rotation <= 135) { } else if (rotation > 45 && rotation <= 135) {
b.direction = Direction.Left; b.direction = Direction.Left;
b.min = x2; b.min = p2.x;
b.max = x1; b.max = p1.x;
} else if (rotation > 135 && rotation <= 225) { } else if (rotation > 135 && rotation <= 225) {
b.direction = Direction.Up; b.direction = Direction.Up;
b.min = y2; b.min = p2.y;
b.max = y1; b.max = p1.y;
} else if (rotation > 225 && rotation <= 315) { } else if (rotation > 225 && rotation <= 315) {
b.direction = Direction.Right; b.direction = Direction.Right;
b.min = x1; b.min = p1.x;
b.max = x2; b.max = p2.x;
} }
b.background = this; b.background = this;
...@@ -875,7 +872,7 @@ class GrowNode extends GlowNode { ...@@ -875,7 +872,7 @@ class GrowNode extends GlowNode {
} }
getAnnotationTextExtent(num) { getAnnotationTextExtent(num) {
return this.nc.getAnnotationTextExtent(this.trf, this, num); return this.nc.getAnnotationTextExtent(t, this.trfhis, num);
} }
setColorThemeLightness() { setColorThemeLightness() {
......
...@@ -158,15 +158,17 @@ class GrowPie extends GrowArc { ...@@ -158,15 +158,17 @@ class GrowPie extends GrowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rot = Math.floor(this.trf.rot(t));
let rot = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rot = Math.floor(rot);
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
......
...@@ -290,7 +290,7 @@ class GrowPolyline extends GlowPolyline { ...@@ -290,7 +290,7 @@ class GrowPolyline extends GlowPolyline {
this.ctx.gdraw.polyline(this.points, this.a_points.size(), this.ctx.gdraw.polyline(this.points, this.a_points.size(),
drawtype, true, 0); drawtype, true, 0);
} else { } else {
let rotation = t ? this.trf.rot(t) : this.trf.rot(); let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let f1, f2; let f1, f2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -314,7 +314,7 @@ class GrowPolyline extends GlowPolyline { ...@@ -314,7 +314,7 @@ class GrowPolyline extends GlowPolyline {
0 && this.fill_eq_shadow === 0; 0 && this.fill_eq_shadow === 0;
if (display_shadow && this.shadow_width !== 0) { if (display_shadow && this.shadow_width !== 0) {
let trf_scale = this.trf.vertical_scale(t); let trf_scale = Matrix.multiply(t, this.trf).vertical_scale();
let ish = Math.floor(this.shadow_width / 100 * trf_scale * let ish = Math.floor(this.shadow_width / 100 * trf_scale *
Math.min((this.ur_x - this.ll_x) * this.ctx.mw.zoom_factor_x, Math.min((this.ur_x - this.ll_x) * this.ctx.mw.zoom_factor_x,
(this.ur_y - this.ll_y) * this.ctx.mw.zoom_factor_y) + 0.5); (this.ur_y - this.ll_y) * this.ctx.mw.zoom_factor_y) + 0.5);
...@@ -587,19 +587,18 @@ class GrowPolyline extends GlowPolyline { ...@@ -587,19 +587,18 @@ class GrowPolyline extends GlowPolyline {
} }
get_borders(t, g) { get_borders(t, g) {
let x2 = 0, y2 = 0; let tmp = Matrix.multiply(t, this.trf);
let p2 = new Point();
for (let i = 0; i < this.a_points.size() - 1; i++) { for (let i = 0; i < this.a_points.size() - 1; i++) {
let e = this.a_points.get(i); let e = this.a_points.get(i);
let x1 = x2; let p1 = new Point(p2.x, p2.y);
let y1 = y2;
if (i === 0) { if (i === 0) {
x1 = this.trf.x(t, e.x, e.y); p1 = tmp.apply(e);
y1 = this.trf.y(t, e.x, e.y);
} }
x2 = this.trf.x(t, e.x, e.y); p2 = tmp.apply(e);
y2 = this.trf.y(t, e.x, e.y);
g.set(Rect.union(g, new Rect(Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)))); g.set(Rect.union(g, new Rect(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y),
Math.max(p1.x, p2.x), Math.max(p1.y, p2.y))));
} }
} }
......
...@@ -172,14 +172,14 @@ class GrowRect extends GlowRect { ...@@ -172,14 +172,14 @@ class GrowRect extends GlowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = this.trf.x(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_x + let tmp = Matrix.multiply(t, this.trf);
0.5 - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = this.trf.y(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_y + let p2 = tmp.apply(this.ur);
0.5 - this.ctx.mw.offset_y;
let x2 = this.trf.x(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_x + let x1 = p1.x * this.ctx.mw.zoom_factor_x + 0.5 - this.ctx.mw.offset_x;
0.5 - this.ctx.mw.offset_x; let y1 = p1.y * this.ctx.mw.zoom_factor_y + 0.5 - this.ctx.mw.offset_y;
let y2 = this.trf.y(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_y + let x2 = p2.x * this.ctx.mw.zoom_factor_x + 0.5 - this.ctx.mw.offset_x;
0.5 - this.ctx.mw.offset_y; let y2 = p2.y * this.ctx.mw.zoom_factor_y + 0.5 - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -239,14 +239,14 @@ class GrowRect extends GlowRect { ...@@ -239,14 +239,14 @@ class GrowRect extends GlowRect {
]; ];
this.ctx.gdraw.polyline(points, 7, drawtype, true, 0); this.ctx.gdraw.polyline(points, 7, drawtype, true, 0);
} }
if (this.fill !== 0) { if (this.fill) {
if (display_shadow && ish !== 0) { if (display_shadow && ish !== 0) {
if (grad === Gradient.No || fillcolor === DrawType.ColorRed) { if (grad === Gradient.No || fillcolor === DrawType.ColorRed) {
let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null); let drawtype = (chot === 0) ? fillcolor : GlowColor.shift_drawtype(fillcolor, chot, null);
this.ctx.gdraw.rect(ll_x + ish, ll_y + ish, ur_x - ll_x - 2 * this.ctx.gdraw.rect(ll_x + ish, ll_y + ish, ur_x - ll_x - 2 *
ish, ur_y - ll_y - 2 * ish, drawtype, true, 0); ish, ur_y - ll_y - 2 * ish, drawtype, true, 0);
} else { } else {
let rotationa = t ? this.trf.rot(t) : this.trf.rot(); let rotationa = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let fa0, fa1, fa2; let fa0, fa1, fa2;
if (this.bgcolor_gradient !== 0 && if (this.bgcolor_gradient !== 0 &&
...@@ -281,7 +281,7 @@ class GrowRect extends GlowRect { ...@@ -281,7 +281,7 @@ class GrowRect extends GlowRect {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype, true, 0); drawtype, true, 0);
} else { } else {
let rotationb = t ? this.trf.rot(t) : this.trf.rot(); let rotationb = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let fb0, fb1, fb2; let fb0, fb1, fb2;
if (this.bgcolor_gradient !== 0 && if (this.bgcolor_gradient !== 0 &&
...@@ -313,7 +313,7 @@ class GrowRect extends GlowRect { ...@@ -313,7 +313,7 @@ class GrowRect extends GlowRect {
} }
} }
if (this.border !== 0 || if (this.border !== 0 ||
!(this.fill !== 0 || (display_shadow && this.shadow_width !== 0))) { !(this.fill || (display_shadow && this.shadow_width !== 0))) {
let drawtype = let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0); highlight, colornode, 0, 0);
...@@ -322,12 +322,12 @@ class GrowRect extends GlowRect { ...@@ -322,12 +322,12 @@ class GrowRect extends GlowRect {
} }
get_borders(t, g) { get_borders(t, g) {
let x1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let x2 = this.trf.x(t, this.ur.x, this.ur.y); let p1 = tmp.apply(this.ll);
let y1 = this.trf.y(t, this.ll.x, this.ll.y); let p2 = tmp.apply(this.ur);
let y2 = this.trf.y(t, this.ur.x, this.ur.y);
g.set(Rect.union(g, new Rect(Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)))); g.set(Rect.union(g, new Rect(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y),
Math.max(p1.x, p2.x), Math.max(p1.y, p2.y))));
} }
get_node_borders() { get_node_borders() {
...@@ -376,7 +376,8 @@ class GrowRect extends GlowRect { ...@@ -376,7 +376,8 @@ class GrowRect extends GlowRect {
let old_x_right = this.ur_x; let old_x_right = this.ur_x;
let old_y_low = this.ll_y; let old_y_low = this.ll_y;
let old_y_high = this.ur_y; let old_y_high = this.ur_y;
this.trf.scale_from_stored(scale_x, scale_y, x0, y0); this.trf.revert();
this.trf.scale(scale_x, scale_y, x0, y0);
this.get_node_borders(); this.get_node_borders();
switch (type) { switch (type) {
......
...@@ -120,14 +120,14 @@ class GrowRectRounded extends GrowRect { ...@@ -120,14 +120,14 @@ class GrowRectRounded extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
...@@ -135,7 +135,7 @@ class GrowRectRounded extends GrowRect { ...@@ -135,7 +135,7 @@ class GrowRectRounded extends GrowRect {
let ur_y = Math.max(y1, y2); let ur_y = Math.max(y1, y2);
let amount = Math.floor(this.round_amount / 100 * let amount = Math.floor(this.round_amount / 100 *
Math.min(ur_x - ll_x, ur_y - ll_y) + 0.5); Math.min(ur_x - ll_x, ur_y - ll_y) + 0.5);
if (this.fill !== 0) { if (this.fill) {
let ish = Math.floor(this.shadow_width / 100 * let ish = Math.floor(this.shadow_width / 100 *
Math.min(ur_x - ll_x, ur_y - ll_y) + 0.5); Math.min(ur_x - ll_x, ur_y - ll_y) + 0.5);
let display_shadow = ((node !== null && node.shadow !== 0) || let display_shadow = ((node !== null && node.shadow !== 0) ||
...@@ -169,7 +169,7 @@ class GrowRectRounded extends GrowRect { ...@@ -169,7 +169,7 @@ class GrowRectRounded extends GrowRect {
this.ctx.gdraw.arc(ur_x - 2 * amount, ll_y, 2 * amount, 2 * this.ctx.gdraw.arc(ur_x - 2 * amount, ll_y, 2 * amount, 2 *
amount, 0, 90, drawtype, true, 0); amount, 0, 90, drawtype, true, 0);
} else { } else {
let rotationa = t ? this.trf.rot(t) : this.trf.rot(); let rotationa = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let fa1, fa2; let fa1, fa2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -244,7 +244,7 @@ class GrowRectRounded extends GrowRect { ...@@ -244,7 +244,7 @@ class GrowRectRounded extends GrowRect {
2 * amount, ur_y - ll_y - 2 * amount, drawtype, true, 0); 2 * amount, ur_y - ll_y - 2 * amount, drawtype, true, 0);
} }
} else { } else {
let rotationb = t ? this.trf.rot(t) : this.trf.rot(); let rotationb = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let fb1, fb2; let fb1, fb2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -268,7 +268,7 @@ class GrowRectRounded extends GrowRect { ...@@ -268,7 +268,7 @@ class GrowRectRounded extends GrowRect {
} }
} }
} }
if (this.border !== 0 || this.fill === 0) { if (this.border !== 0 || !this.fill) {
let drawtype = let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0); highlight, colornode, 0, 0);
......
...@@ -22,7 +22,7 @@ class GrowScrollBar extends GrowRect { ...@@ -22,7 +22,7 @@ class GrowScrollBar extends GrowRect {
this.ur.y = y + h; this.ur.y = y + h;
this.draw_type = border_d_type; this.draw_type = border_d_type;
this.line_width = line_width; this.line_width = line_width;
this.fill = 1; this.fill = true;
this.border = 1; this.border = 1;
this.shadow = 0; this.shadow = 0;
this.fill_drawtype = fill_d_type; this.fill_drawtype = fill_d_type;
...@@ -48,14 +48,14 @@ class GrowScrollBar extends GrowRect { ...@@ -48,14 +48,14 @@ class GrowScrollBar extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
......
class GrowSubAnnot extends GlowAnnot {
trf: GlowTransform;
rect: GlowRect;
n_name = null;
ll_x: Number;
ll_y: Number;
ur_x: Number;
ur_y: Number;
adjustment: Adjustment;
text: GlowText;
constructor(ctx) {
super(ctx);
this.trf = new GlowTransform();
this.rect = new GlowRect(ctx);
this.text = new GlowText(ctx);
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case GlowSave.GrowSubAnnot:
break;
case GlowSave.GrowSubAnnot_n_name:
if (tokens.length > 1) {
this.n_name = tokens[1];
}
break;
case GlowSave.GrowSubAnnot_x_right:
this.ur_x = parseFloat(tokens[1]);
break;
case GlowSave.GrowSubAnnot_x_left:
this.ll_x = parseFloat(tokens[1]);
break;
case GlowSave.GrowSubAnnot_y_high:
this.ur_y = parseFloat(tokens[1]);
break;
case GlowSave.GrowSubAnnot_y_low:
this.ll_y = parseFloat(tokens[1]);
break;
case GlowSave.GrowSubAnnot_text:
this.text = tokens[1];
break;
case GlowSave.GrowSubAnnot_rect:
i = this.rect.open(lines, i + 1);
break;
case GlowSave.GrowSubAnnot_annot_part:
i = super.open(lines, i + 1);
break;
case GlowSave.GrowSubAnnot_trf:
i = this.trf.open(lines, i + 1);
break;
case GlowSave.GrowSubAnnot_adjustment:
this.adjustment = parseInt(tokens[1], 10);
case GlowSave.End:
return i;
default:
console.log("Syntax error in GrowSubAnnot");
break;
}
}
return i;
}
event_handler(event, fx, fy) {
return 0;
}
draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
let p = new Point();
if (t) {
p = Matrix.multiply(t, this.trf).apply(this.p);
let p2 = this.trf.apply(this.p);
p.x -= p2.x;
p.y -= p2.y;
}
this.rect.draw(p, highlight, hot);
this.text.draw(p, highlight, hot);
}
}
\ No newline at end of file
...@@ -391,22 +391,21 @@ class GrowTable extends GrowRect { ...@@ -391,22 +391,21 @@ class GrowTable extends GrowRect {
let header_tsize = this.ctx.mw.zoom_factor_y / let header_tsize = this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (8 + 2 * this.header_text_size); this.ctx.mw.base_zoom_factor * (8 + 2 * this.header_text_size);
let dx1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let dy1 = this.trf.y(t, this.ll.x, this.ll.y); let d1 = tmp.apply(this.ll);
let dx2 = this.trf.x(t, this.ur.x, this.ur.y); let d2 = tmp.apply(this.ur);
let dy2 = this.trf.y(t, this.ur.x, this.ur.y); d1.x = Math.min(d1.x, d2.x);
dx1 = Math.min(dx1, dx2); d2.x = Math.max(d1.x, d2.x);
dx2 = Math.max(dx1, dx2); d1.y = Math.min(d1.y, d2.y);
dy1 = Math.min(dy1, dy2); d2.y = Math.max(d1.y, d2.y);
dy2 = Math.max(dy1, dy2);
if (this.v_scrollbar !== null) { if (this.v_scrollbar !== null) {
if (this.h_scrollbar === null) { if (this.h_scrollbar === null) {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 + this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs)); this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs));
} else { } else {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 + this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs) - this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs) -
this.scrollbar_width); this.scrollbar_width);
} }
this.v_scrollbar.draw(); this.v_scrollbar.draw();
...@@ -414,12 +413,12 @@ class GrowTable extends GrowRect { ...@@ -414,12 +413,12 @@ class GrowTable extends GrowRect {
} }
if (this.h_scrollbar !== null) { if (this.h_scrollbar !== null) {
if (this.v_scrollbar === null) { if (this.v_scrollbar === null) {
this.h_scrollbar.set_position(dx1 + this.x_left_offs, dy2 - this.h_scrollbar.set_position(d1.x + this.x_left_offs, d2.y -
this.scrollbar_width, dx2 - (dx1 + this.x_left_offs), this.scrollbar_width, d2.x - (d1.x + this.x_left_offs),
this.scrollbar_width); this.scrollbar_width);
} else { } else {
this.h_scrollbar.set_position(dx1 + this.x_left_offs, dy2 - this.h_scrollbar.set_position(d1.x + this.x_left_offs, d2.y -
this.scrollbar_width, dx2 - (dx1 + this.x_left_offs) - this.scrollbar_width, d2.x - (d1.x + this.x_left_offs) -
this.scrollbar_width, this.scrollbar_width); this.scrollbar_width, this.scrollbar_width);
} }
this.h_scrollbar.draw(); this.h_scrollbar.draw();
...@@ -433,18 +432,18 @@ class GrowTable extends GrowRect { ...@@ -433,18 +432,18 @@ class GrowTable extends GrowRect {
let light_drawtype = GlowColor.shift_drawtype(this.fill_drawtype, -2, null); let light_drawtype = GlowColor.shift_drawtype(this.fill_drawtype, -2, null);
let sel_drawtype = (this.select_drawtype === DrawType.Inherit) ? dark_drawtype : this.select_drawtype; let sel_drawtype = (this.select_drawtype === DrawType.Inherit) ? dark_drawtype : this.select_drawtype;
let ll_x = Math.floor(dx1 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ll_x = Math.floor(d1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ll_y = Math.floor(dy1 * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let ll_y = Math.floor(d1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let ur_x = Math.floor(dx2 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ur_x = Math.floor(d2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_y = Math.floor(dy2 * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let ur_y = Math.floor(d2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let o_ll_x = Math.floor((dx1 + this.x_left_offs) * let o_ll_x = Math.floor((d1.x + this.x_left_offs) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let o_ll_y = Math.floor((dy1 + this.y_low_offs) * let o_ll_y = Math.floor((d1.y + this.y_low_offs) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let o_ur_x = Math.floor((dx2 - this.vertical_scrollbar * let o_ur_x = Math.floor((d2.x - this.vertical_scrollbar *
this.scrollbar_width) * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; this.scrollbar_width) * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let o_ur_y = Math.floor((dy2 - this.horizontal_scrollbar * let o_ur_y = Math.floor((d2.y - this.horizontal_scrollbar *
this.scrollbar_width) * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; this.scrollbar_width) * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let t_ll_x = o_ll_x - Math.floor(this.h_value * this.ctx.mw.zoom_factor_x); let t_ll_x = o_ll_x - Math.floor(this.h_value * this.ctx.mw.zoom_factor_x);
...@@ -464,7 +463,7 @@ class GrowTable extends GrowRect { ...@@ -464,7 +463,7 @@ class GrowTable extends GrowRect {
} }
if (this.header_row !== 0) { if (this.header_row !== 0) {
if (this.fill !== 0) { if (this.fill) {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, header_h, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, header_h,
this.fill_drawtype, true, 0); this.fill_drawtype, true, 0);
} }
...@@ -549,7 +548,7 @@ class GrowTable extends GrowRect { ...@@ -549,7 +548,7 @@ class GrowTable extends GrowRect {
} }
if (this.header_column !== 0) { if (this.header_column !== 0) {
if (this.fill !== 0) { if (this.fill) {
this.ctx.gdraw.rect(ll_x, ll_y + header_h, header_w, ur_y - ll_y - this.ctx.gdraw.rect(ll_x, ll_y + header_h, header_w, ur_y - ll_y -
header_h, this.fill_drawtype, true, 0); header_h, this.fill_drawtype, true, 0);
} }
...@@ -639,7 +638,7 @@ class GrowTable extends GrowRect { ...@@ -639,7 +638,7 @@ class GrowTable extends GrowRect {
} }
// Draw table // Draw table
if (this.fill !== 0) { if (this.fill) {
this.ctx.gdraw.rect(o_ll_x, o_ll_y, o_ur_x - o_ll_x, o_ur_y - o_ll_y, this.ctx.gdraw.rect(o_ll_x, o_ll_y, o_ur_x - o_ll_x, o_ur_y - o_ll_y,
this.fill_drawtype, true, 0); this.fill_drawtype, true, 0);
} }
......
...@@ -85,7 +85,7 @@ class GrowText extends GlowText { ...@@ -85,7 +85,7 @@ class GrowText extends GlowText {
} }
let z_descent; let z_descent;
let trf_scale = this.trf.vertical_scale(t); let trf_scale = Matrix.multiply(t, this.trf).vertical_scale();
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y / let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3); this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y / let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
...@@ -110,9 +110,12 @@ class GrowText extends GlowText { ...@@ -110,9 +110,12 @@ class GrowText extends GlowText {
let ry1 = 0; let ry1 = 0;
let z_width = 0; let z_width = 0;
let z_height = 0; let z_height = 0;
let x1 = Math.floor(this.trf.x(t, this.p.x, this.p.y) * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x; let tmp = Matrix.multiply(t, this.trf);
let y1 = Math.floor(this.trf.y(t, this.p.x, this.p.y) * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y; let p = tmp.apply(this.p);
let rot = Math.floor(this.trf.rot(t)); let x1 = Math.floor(p.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y1 = Math.floor(p.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = t ? this.trf.rotation + t.rotation : this.trf.rotation;
rot = Math.floor(rot);
if (this.adjustment === Adjustment.Center) { if (this.adjustment === Adjustment.Center) {
rot = rot < 0 ? rot % 360 + 360 : rot % 360; rot = rot < 0 ? rot % 360 + 360 : rot % 360;
} else { } else {
......
...@@ -157,21 +157,21 @@ class GrowTrend extends GrowRect { ...@@ -157,21 +157,21 @@ class GrowTrend extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) * let tmp = Matrix.multiply(t, this.trf);
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let p1 = tmp.apply(this.ll);
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) * let p2 = tmp.apply(this.ur);
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) * let x1 = Math.floor(p1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let y1 = Math.floor(p1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) * let x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2); let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2); let ur_y = Math.max(y1, y2);
if (this.fill !== 0) { if (this.fill) {
let grad = this.gradient; let grad = this.gradient;
if (this.gradient === Gradient.No && if (this.gradient === Gradient.No &&
(node !== null && node.gradient !== Gradient.No) && (node !== null && node.gradient !== Gradient.No) &&
...@@ -186,7 +186,7 @@ class GrowTrend extends GrowRect { ...@@ -186,7 +186,7 @@ class GrowTrend extends GrowRect {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype, true, 0); drawtype, true, 0);
} else { } else {
let rotation = t ? this.trf.rot(t) : this.trf.rot(); let rotation = t ? this.trf.rotation + t.rotation : this.trf.rotation;
let f1, f2; let f1, f2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
...@@ -211,10 +211,8 @@ class GrowTrend extends GrowRect { ...@@ -211,10 +211,8 @@ class GrowTrend extends GrowRect {
let curvetmp = this.curve.slice(0, this.curve_cnt).filter(e => e !== null); let curvetmp = this.curve.slice(0, this.curve_cnt).filter(e => e !== null);
if (this.fill_curve !== 0) { if (this.fill_curve !== 0) {
let tmp1 = t ? GlowTransform.multiply(t, this.trf) : this.trf;
curvetmp.forEach(e => e.border = 0); curvetmp.forEach(e => e.border = 0);
curvetmp.forEach(e => e.draw(tmp1, highlight, hot, node, colornode)); curvetmp.forEach(e => e.draw(Matrix.multiply(t, this.trf), highlight, hot, node, colornode));
curvetmp.forEach(e => e.border = 1); curvetmp.forEach(e => e.border = 1);
} }
...@@ -233,15 +231,16 @@ class GrowTrend extends GrowRect { ...@@ -233,15 +231,16 @@ class GrowTrend extends GrowRect {
if (this.fill_curve !== 0) { if (this.fill_curve !== 0) {
curvetmp.forEach(e => e.fill = 0); curvetmp.forEach(e => e.fill = 0);
} }
let tmp2 = t ? GlowTransform.multiply(t, this.trf) : this.trf; curvetmp.forEach(e => e.draw(Matrix.multiply(t, this.trf), highlight, hot, node, colornode));
curvetmp.forEach(e => e.draw(tmp2, highlight, hot, node, colornode));
if (this.fill_curve !== 0) { if (this.fill_curve !== 0) {
curvetmp.forEach(e => e.fill = 1); curvetmp.forEach(e => e.fill = 1);
} }
let tmp = Matrix.multiply(t, this.trf);
if (this.display_x_mark1 !== 0) { if (this.display_x_mark1 !== 0) {
let xm1 = Math.floor(this.trf.x(t, this.x_mark1, this.ll.y) * let p = tmp.apply(new Point(this.x_mark1, this.ll.y));
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let xm1 = Math.floor(p.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
if (xm1 >= ll_x && xm1 <= ur_x) { if (xm1 >= ll_x && xm1 <= ur_x) {
drawtype = this.mark1_color; drawtype = this.mark1_color;
if (drawtype === DrawType.Inherit) { if (drawtype === DrawType.Inherit) {
...@@ -251,8 +250,8 @@ class GrowTrend extends GrowRect { ...@@ -251,8 +250,8 @@ class GrowTrend extends GrowRect {
} }
} }
if (this.display_x_mark2 !== 0) { if (this.display_x_mark2 !== 0) {
let xm2 = Math.floor(this.trf.x(t, this.x_mark2, this.ll.y) * let p = tmp.apply(new Point(this.x_mark2, this.ll.y));
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let xm2 = Math.floor(p.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
if (xm2 >= ll_x && xm2 <= ur_x) { if (xm2 >= ll_x && xm2 <= ur_x) {
drawtype = this.mark2_color; drawtype = this.mark2_color;
if (drawtype === DrawType.Inherit) { if (drawtype === DrawType.Inherit) {
...@@ -262,14 +261,8 @@ class GrowTrend extends GrowRect { ...@@ -262,14 +261,8 @@ class GrowTrend extends GrowRect {
} }
} }
if (this.display_y_mark1 !== 0) { if (this.display_y_mark1 !== 0) {
let ym1; let p = tmp.apply(new Point(this.ll.x, this.y_mark1));
if (t === null) { let ym1 = Math.floor(p.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
ym1 = Math.floor(this.trf.y(this.ll.x, this.y_mark1) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
} else {
ym1 = Math.floor(this.trf.y(t, this.ll.x, this.y_mark1) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
}
if (ym1 >= ll_y && ym1 <= ur_y) { if (ym1 >= ll_y && ym1 <= ur_y) {
drawtype = this.mark1_color; drawtype = this.mark1_color;
if (drawtype === DrawType.Inherit) { if (drawtype === DrawType.Inherit) {
...@@ -279,14 +272,8 @@ class GrowTrend extends GrowRect { ...@@ -279,14 +272,8 @@ class GrowTrend extends GrowRect {
} }
} }
if (this.display_y_mark2 !== 0) { if (this.display_y_mark2 !== 0) {
let ym2; let p = tmp.apply(new Point(this.ll.x, this.y_mark2));
if (t === null) { let ym2 = Math.floor(p.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
ym2 = Math.floor(this.trf.y(this.ll.x, this.y_mark2) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
} else {
ym2 = Math.floor(this.trf.y(t, this.ll.x, this.y_mark2) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
}
if (ym2 >= ll_y && ym2 <= ur_y) { if (ym2 >= ll_y && ym2 <= ur_y) {
drawtype = this.mark2_color; drawtype = this.mark2_color;
if (drawtype === DrawType.Inherit) { if (drawtype === DrawType.Inherit) {
......
...@@ -117,46 +117,45 @@ class GrowWindow extends GrowRect { ...@@ -117,46 +117,45 @@ class GrowWindow extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let dx1 = this.trf.x(t, this.ll.x, this.ll.y); let tmp = Matrix.multiply(t, this.trf);
let dy1 = this.trf.y(t, this.ll.x, this.ll.y); let d1 = tmp.apply(this.ll);
let dx2 = this.trf.x(t, this.ur.x, this.ur.y); let d2 = tmp.apply(this.ur);
let dy2 = this.trf.y(t, this.ur.x, this.ur.y); d1.x = Math.min(d1.x, d2.x);
dx1 = Math.min(dx1, dx2); d2.x = Math.max(d1.x, d2.x);
dx2 = Math.max(dx1, dx2); d1.y = Math.min(d1.y, d2.y);
dy1 = Math.min(dy1, dy2); d2.y = Math.max(d1.y, d2.y);
dy2 = Math.max(dy1, dy2);
if (this.v_scrollbar !== null) { if (this.v_scrollbar !== null) {
if (this.h_scrollbar === null) { if (this.h_scrollbar === null) {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 + this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs)); this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs));
} else { } else {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 + this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs) - this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs) -
this.scrollbar_width); this.scrollbar_width);
} }
this.v_scrollbar.draw(null, 0, 0, null, null); this.v_scrollbar.draw(null, 0, 0, null, null);
} }
if (this.h_scrollbar !== null) { if (this.h_scrollbar !== null) {
if (this.v_scrollbar === null) { if (this.v_scrollbar === null) {
this.h_scrollbar.set_position(dx1, dy2 - this.scrollbar_width, dx2 - this.h_scrollbar.set_position(d1.x, d2.y - this.scrollbar_width, d2.x -
dx1, this.scrollbar_width); d1.x, this.scrollbar_width);
} else { } else {
this.h_scrollbar.set_position(dx1, dy2 - this.scrollbar_width, dx2 - this.h_scrollbar.set_position(d1.x, d2.y - this.scrollbar_width, d2.x -
dx1 - this.scrollbar_width, this.scrollbar_width); d1.x - this.scrollbar_width, this.scrollbar_width);
} }
this.h_scrollbar.draw(null, 0, 0, null, null); this.h_scrollbar.draw(null, 0, 0, null, null);
} }
let ll_x = Math.floor(dx1 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ll_x = Math.floor(d1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ll_y = Math.floor((dy1 + this.y_low_offs) * this.ctx.mw.zoom_factor_y) - let ll_y = Math.floor((d1.y + this.y_low_offs) * this.ctx.mw.zoom_factor_y) -
this.ctx.mw.offset_y; this.ctx.mw.offset_y;
if (this.windowCtx !== null) { if (this.windowCtx !== null) {
let ur_x = Math.floor((dx2 - this.vertical_scrollbar * this.scrollbar_width) * let ur_x = Math.floor((d2.x - this.vertical_scrollbar * this.scrollbar_width) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_y = let ur_y =
Math.floor((dy2 - this.horizontal_scrollbar * this.scrollbar_width) * Math.floor((d2.y - this.horizontal_scrollbar * this.scrollbar_width) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
this.windowCtx.mw.window_width = this.windowCtx.mw.window_width =
...@@ -179,7 +178,7 @@ class GrowWindow extends GrowRect { ...@@ -179,7 +178,7 @@ class GrowWindow extends GrowRect {
this.windowCtx.mw.subwindow_scale * this.ctx.mw.zoom_factor_y; this.windowCtx.mw.subwindow_scale * this.ctx.mw.zoom_factor_y;
// window_ctx->draw_buffer_only = ctx->draw_buffer_only; // window_ctx->draw_buffer_only = ctx->draw_buffer_only;
if (this.fill !== 0) { if (this.fill) {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
this.fill_drawtype, true, 0); this.fill_drawtype, true, 0);
} }
...@@ -197,8 +196,8 @@ class GrowWindow extends GrowRect { ...@@ -197,8 +196,8 @@ class GrowWindow extends GrowRect {
this.ctx.gdraw.reset_clip_rectangle(); this.ctx.gdraw.reset_clip_rectangle();
} }
let ur_x = Math.floor(dx2 * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; let ur_x = Math.floor(d2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_y = Math.floor(dy2 * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y; let ur_y = Math.floor(d2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let drawtype = let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
...@@ -253,7 +252,7 @@ class GrowWindow extends GrowRect { ...@@ -253,7 +252,7 @@ class GrowWindow extends GrowRect {
if (this.windowCtx.background_color !== DrawType.Inherit) { if (this.windowCtx.background_color !== DrawType.Inherit) {
this.fill_drawtype = this.windowCtx.background_color; this.fill_drawtype = this.windowCtx.background_color;
this.original_fill_drawtype = this.fill_drawtype; this.original_fill_drawtype = this.fill_drawtype;
this.fill = 1; this.fill = true;
} }
if (this.windowCtx.x0 !== this.windowCtx.x1 && if (this.windowCtx.x0 !== this.windowCtx.x1 &&
this.windowCtx.y0 !== this.windowCtx.y1) { this.windowCtx.y0 !== this.windowCtx.y1) {
...@@ -547,7 +546,7 @@ class GrowWindow extends GrowRect { ...@@ -547,7 +546,7 @@ class GrowWindow extends GrowRect {
} }
this.fill_drawtype = DrawType.Inherit; this.fill_drawtype = DrawType.Inherit;
this.original_fill_drawtype = this.fill_drawtype; this.original_fill_drawtype = this.fill_drawtype;
this.fill = 0; this.fill = false;
} }
this.file_name = this.input_file_name; this.file_name = this.input_file_name;
this.new_ctx(); this.new_ctx();
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<button id="logout_button" type="button" class="leftmenu-button">Logout</button> <button id="logout_button" type="button" class="leftmenu-button">Logout</button>
</div> </div>
</div> </div>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="babel.min.js"></script>
<script type="text/babel" src="crypt.ts"></script> <script type="text/babel" src="crypt.ts"></script>
<script type="text/babel" src="pwr.ts"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="gdh.ts"></script> <script type="text/babel" src="gdh.ts"></script>
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</div> </div>
</div> </div>
<canvas id="flowcanvas" width="1200" height="800"></canvas> <canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script src="babel.min.js"></script>
<script type="text/babel" src="pwr.ts"></script> <script type="text/babel" src="pwr.ts"></script>
<script type="text/babel" src="cli.ts"></script> <script type="text/babel" src="cli.ts"></script>
<script type="text/babel" src="gdh.ts"></script> <script type="text/babel" src="gdh.ts"></script>
......
...@@ -64,12 +64,11 @@ ...@@ -64,12 +64,11 @@
#include "rt_io_pnak_locals.h" #include "rt_io_pnak_locals.h"
#include "rt_pn_iface.h" #include "rt_pn_iface.h"
// static int count;
static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap); static pwr_tStatus IoAgentInit(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap); static pwr_tStatus IoAgentRead(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap); static pwr_tStatus IoAgentWrite(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap); static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap);
static pwr_tStatus IoAgentSwap(io_tCtx ctx, io_sAgent* ap, io_eEvent event);
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb_profiboard agent Init method for the Pb_profiboard agent
...@@ -345,6 +344,21 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap) ...@@ -345,6 +344,21 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
return sts; return sts;
} }
static pwr_tStatus IoAgentSwap(io_tCtx ctx, io_sAgent* ap, io_eEvent event)
{
switch (event) {
case io_eEvent_EmergencyBreak:
case io_eEvent_IoCommEmergencyBreak:
errh_Fatal("Emergency break detected shutting down profinet");
IoAgentClose(ctx, ap);
break;
default:
break;
}
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
...@@ -352,4 +366,4 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap) ...@@ -352,4 +366,4 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
pwr_dExport pwr_BindIoMethods(PnControllerSoftingPNAK) pwr_dExport pwr_BindIoMethods(PnControllerSoftingPNAK)
= { pwr_BindIoMethod(IoAgentInit), pwr_BindIoMethod(IoAgentRead), = { pwr_BindIoMethod(IoAgentInit), pwr_BindIoMethod(IoAgentRead),
pwr_BindIoMethod(IoAgentWrite), pwr_BindIoMethod(IoAgentClose), pwr_BindIoMethod(IoAgentWrite), pwr_BindIoMethod(IoAgentClose),
pwr_NullMethod }; pwr_BindIoMethod(IoAgentSwap), pwr_NullMethod };
...@@ -21,6 +21,7 @@ source_dirs := $(co_source) ...@@ -21,6 +21,7 @@ source_dirs := $(co_source)
-include jsw_local.mk -include jsw_local.mk
vpath %.js $(co_source) vpath %.js $(co_source)
vpath %.ts $(co_source)
vpath %.html $(co_source) vpath %.html $(co_source)
vpath %.png $(co_source) vpath %.png $(co_source)
...@@ -33,6 +34,15 @@ js_sources := $(sort \ ...@@ -33,6 +34,15 @@ js_sources := $(sort \
) \ ) \
) )
ts_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.ts) \
), $(notdir $(file)) \
) \
)
html_sources := $(sort \ html_sources := $(sort \
$(foreach file, \ $(foreach file, \
$(foreach dir, \ $(foreach dir, \
...@@ -61,10 +71,12 @@ css_sources := $(sort \ ...@@ -61,10 +71,12 @@ css_sources := $(sort \
) )
export_js := $(addprefix $(web_dir)/,$(js_sources)) export_js := $(addprefix $(web_dir)/,$(js_sources))
export_ts := $(addprefix $(web_dir)/,$(ts_sources))
export_html := $(addprefix $(web_dir)/,$(html_sources)) export_html := $(addprefix $(web_dir)/,$(html_sources))
export_png := $(addprefix $(web_dir)/,$(png_sources)) export_png := $(addprefix $(web_dir)/,$(png_sources))
export_css := $(addprefix $(web_dir)/,$(css_sources)) export_css := $(addprefix $(web_dir)/,$(css_sources))
clean_js := $(patsubst %.js,clean_%.js, $(js_sources)) clean_js := $(patsubst %.js,clean_%.js, $(js_sources))
clean_ts := $(patsubst %.ts,clean_%.ts, $(ts_sources))
clean_html := $(patsubst %.html,clean_%.html, $(html_sources)) clean_html := $(patsubst %.html,clean_%.html, $(html_sources))
clean_png := $(patsubst %.png,clean_%.png, $(png_sources)) clean_png := $(patsubst %.png,clean_%.png, $(png_sources))
clean_css := $(patsubst %.css,clean_%.css, $(css_sources)) clean_css := $(patsubst %.css,clean_%.css, $(css_sources))
...@@ -75,13 +87,13 @@ all : init copy lib exe | silent ...@@ -75,13 +87,13 @@ all : init copy lib exe | silent
init : init :
copy : $(export_js) $(export_html) $(export_png) $(export_css) | silent copy : $(export_js) $(export_ts) $(export_html) $(export_png) $(export_css) | silent
lib : lib :
exe : exe :
clean : $(clean_js) $(clean_html) $(clean_png) $(clean_css) clean : $(clean_js) $(clean_ts) $(clean_html) $(clean_png) $(clean_css)
clean_copy: $(clean) clean_copy: $(clean)
...@@ -94,6 +106,10 @@ $(clean_js) : clean_%.js : %.js ...@@ -94,6 +106,10 @@ $(clean_js) : clean_%.js : %.js
@ echo "Removing js: $(web_dir)/$*.js" @ echo "Removing js: $(web_dir)/$*.js"
@ $(rm) $(rmflags) $(web_dir)/$*.js @ $(rm) $(rmflags) $(web_dir)/$*.js
$(clean_ts) : clean_%.ts : %.ts
@ echo "Removing ts: $(web_dir)/$*.ts"
@ $(rm) $(rmflags) $(web_dir)/$*.ts
$(clean_html) : clean_%.html : %.html $(clean_html) : clean_%.html : %.html
@ echo "Removing html: $(web_dir)/$*.html" @ echo "Removing html: $(web_dir)/$*.html"
@ $(rm) $(rmflags) $(web_dir)/$*.html @ $(rm) $(rmflags) $(web_dir)/$*.html
......
...@@ -222,6 +222,8 @@ void wb_pkg::readConfig() ...@@ -222,6 +222,8 @@ void wb_pkg::readConfig()
n.push_back(pboot); n.push_back(pboot);
// Read bootfile, get plc and volumes // Read bootfile, get plc and volumes
vollist = 0;
volnamelist = 0;
sts = lfu_ReadBootFile(fname, &date, systemname, systemgroup, &vollist, sts = lfu_ReadBootFile(fname, &date, systemname, systemgroup, &vollist,
&volnamelist, &volcount, &plclist, &plccount); &volnamelist, &volcount, &plclist, &plccount);
if (EVEN(sts)) if (EVEN(sts))
...@@ -294,8 +296,10 @@ void wb_pkg::readConfig() ...@@ -294,8 +296,10 @@ void wb_pkg::readConfig()
} }
} }
free(volnamelist); if (volnamelist)
free(vollist); free(volnamelist);
if (vollist)
free(vollist);
} catch (wb_error& e) { } catch (wb_error& e) {
if (e.what() == std::string("No such node")) if (e.what() == std::string("No such node"))
......
...@@ -964,9 +964,9 @@ void CoWowQt::SetParent(QWidget* parent) ...@@ -964,9 +964,9 @@ void CoWowQt::SetParent(QWidget* parent)
object->setParent(parent); object->setParent(parent);
} }
static bool PrintDialog(QPrinter* printer, QImage *image, QWidget *parent) static bool PrintDialog(QPrinter* printer, QWidget *parent)
{ {
if (image->width() > image->height()) { if (parent->width() > parent->height()) {
printer->setOrientation(QPrinter::Landscape); printer->setOrientation(QPrinter::Landscape);
} else { } else {
printer->setOrientation(QPrinter::Portrait); printer->setOrientation(QPrinter::Portrait);
...@@ -984,7 +984,18 @@ typedef struct { ...@@ -984,7 +984,18 @@ typedef struct {
int offset_y; int offset_y;
} ctx_settings; } ctx_settings;
static ctx_settings BeginPrint(QPrinter* printer, QPainter *painter, flow_tCtx ctx, QImage *image) static int GetPrintHeaderMargin(QPainter* painter)
{
QFont tmpFont = painter->font();
QFont font("Lucida Sans", 9);
painter->setFont(font);
QFontMetrics fm(painter->font());
int height = fm.lineSpacing();
painter->setFont(tmpFont); // Restore font
return height;
}
static ctx_settings BeginPrint(QPrinter* printer, QPainter *painter, flow_tCtx ctx, QWidget *widget)
{ {
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);
painter->setRenderHint(QPainter::TextAntialiasing, true); painter->setRenderHint(QPainter::TextAntialiasing, true);
...@@ -992,13 +1003,15 @@ static ctx_settings BeginPrint(QPrinter* printer, QPainter *painter, flow_tCtx c ...@@ -992,13 +1003,15 @@ static ctx_settings BeginPrint(QPrinter* printer, QPainter *painter, flow_tCtx c
ctx_settings settings = {ctx->zoom_factor, ctx->window_width, ctx->window_height, ctx->offset_x, ctx->offset_y}; ctx_settings settings = {ctx->zoom_factor, ctx->window_width, ctx->window_height, ctx->offset_x, ctx->offset_y};
ctx->window_width = image->width(); widget->resize(printer->pageRect().width(), printer->pageRect().height() - GetPrintHeaderMargin(painter));
ctx->window_height = image->height();
ctx->window_width = widget->width();
ctx->window_height = widget->height();
return settings; return settings;
} }
static void EndPrint(flow_tCtx ctx, ctx_settings* settings) static void EndPrint(flow_tCtx ctx, ctx_settings* settings, QWidget *widget)
{ {
// Restore ctx zoom settings // Restore ctx zoom settings
ctx->zoom_factor = settings->zoom_factor; ctx->zoom_factor = settings->zoom_factor;
...@@ -1006,28 +1019,14 @@ static void EndPrint(flow_tCtx ctx, ctx_settings* settings) ...@@ -1006,28 +1019,14 @@ static void EndPrint(flow_tCtx ctx, ctx_settings* settings)
ctx->window_height = settings->window_height; ctx->window_height = settings->window_height;
ctx->offset_x = settings->offset_x; ctx->offset_x = settings->offset_x;
ctx->offset_y = settings->offset_y; ctx->offset_y = settings->offset_y;
widget->resize(ctx->window_width, ctx->window_height);
ctx->a.zoom(); ctx->a.zoom();
int nav_backup = ctx->no_nav;
ctx->no_nav = true;
ctx->set_dirty();
ctx->redraw_if_dirty();
ctx->no_nav = nav_backup;
ctx->nav_zoom(); ctx->nav_zoom();
ctx->change_scrollbar(); ctx->change_scrollbar();
ctx->set_dirty();
} }
static int GetPrintHeaderMargin(QPainter* painter) static void PrintPage(QPainter* painter, const char* title, flow_tCtx ctx, QWidget *widget, double ll_x, double ll_y, double ur_x, double ur_y, int page) {
{
QFont tmpFont = painter->font();
QFont font("Lucida Sans", 9);
painter->setFont(font);
QFontMetrics fm(painter->font());
int height = fm.lineSpacing();
painter->setFont(tmpFont); // Restore font
return height;
}
static void PrintPage(QPainter* painter, const char* title, flow_tCtx ctx, QImage* image, double ll_x, double ll_y, double ur_x, double ur_y, int page) {
double zoom = qMin( double zoom = qMin(
ctx->window_width / (ur_x - ll_x + 2 / ctx->zoom_factor), ctx->window_width / (ur_x - ll_x + 2 / ctx->zoom_factor),
ctx->window_height / (ur_y - ll_y + 2 / ctx->zoom_factor) ctx->window_height / (ur_y - ll_y + 2 / ctx->zoom_factor)
...@@ -1040,12 +1039,8 @@ static void PrintPage(QPainter* painter, const char* title, flow_tCtx ctx, QImag ...@@ -1040,12 +1039,8 @@ static void PrintPage(QPainter* painter, const char* title, flow_tCtx ctx, QImag
double width_backup = ctx->window_width; double width_backup = ctx->window_width;
double height_backup = ctx->window_height; double height_backup = ctx->window_height;
int nav_backup = ctx->no_nav;
ctx->window_width = (ur_x - ll_x) * zoom + 2; ctx->window_width = (ur_x - ll_x) * zoom + 2;
ctx->window_height = (ur_y - ll_y) * zoom + 2; ctx->window_height = (ur_y - ll_y) * zoom + 2;
ctx->no_nav = true;
ctx->set_dirty();
ctx->redraw_if_dirty();
double margin_y = GetPrintHeaderMargin(painter); double margin_y = GetPrintHeaderMargin(painter);
...@@ -1075,13 +1070,12 @@ static void PrintPage(QPainter* painter, const char* title, flow_tCtx ctx, QImag ...@@ -1075,13 +1070,12 @@ static void PrintPage(QPainter* painter, const char* title, flow_tCtx ctx, QImag
painter->setClipRect(0, 0, ctx->window_width, ctx->window_height); painter->setClipRect(0, 0, ctx->window_width, ctx->window_height);
painter->setClipping(true); painter->setClipping(true);
painter->drawImage(0, 0, *image); widget->render(painter);
painter->setClipping(false); painter->setClipping(false);
ctx->window_width = width_backup; ctx->window_width = width_backup;
ctx->window_height = height_backup; ctx->window_height = height_backup;
ctx->no_nav = nav_backup;
} }
#include <assert.h> #include <assert.h>
...@@ -1098,18 +1092,15 @@ pwr_tStatus CoWowQt::CreateBrowPrintDialogQt(const char* title, void* brow_ctx, ...@@ -1098,18 +1092,15 @@ pwr_tStatus CoWowQt::CreateBrowPrintDialogQt(const char* title, void* brow_ctx,
assert(dynamic_cast<QtScrollWidgetFlow*>(w) != NULL); assert(dynamic_cast<QtScrollWidgetFlow*>(w) != NULL);
QtScrollWidgetFlow* widget = dynamic_cast<QtScrollWidgetFlow*>(w); QtScrollWidgetFlow* widget = dynamic_cast<QtScrollWidgetFlow*>(w);
QImage imageTmp(widget->image);
// TODO: Change FlowDraw so that pixmaps can be scaled up in size. // TODO: Change FlowDraw so that pixmaps can be scaled up in size.
// Then, change this to QPrinter::HighResolution. // Then, change this to QPrinter::HighResolution.
QPrinter printer; QPrinter printer;
if (PrintDialog(&printer, &imageTmp, widget)) { if (PrintDialog(&printer, widget)) {
brow_tCtx ctx = (brow_tCtx)brow_ctx; brow_tCtx ctx = (brow_tCtx)brow_ctx;
QPainter painter(&printer); QPainter painter(&printer);
widget->image = QImage(printer.pageRect().width(), printer.pageRect().height() - GetPrintHeaderMargin(&painter), QImage::Format_RGB32);
// For some reason, the brow context cannot measure its width correctly // For some reason, the brow context cannot measure its width correctly
// So we estimate it to be 42 rows (portrait) or 60 rows (landscape). // So we estimate it to be 42 rows (portrait) or 60 rows (landscape).
// 60 * 42 is chosen because it is 2x the A4 size 29.7 * 21 cm // 60 * 42 is chosen because it is 2x the A4 size 29.7 * 21 cm
...@@ -1122,22 +1113,21 @@ pwr_tStatus CoWowQt::CreateBrowPrintDialogQt(const char* title, void* brow_ctx, ...@@ -1122,22 +1113,21 @@ pwr_tStatus CoWowQt::CreateBrowPrintDialogQt(const char* title, void* brow_ctx,
width = height / (210.0 / 297.0); width = height / (210.0 / 297.0);
} }
ctx_settings settings = BeginPrint(&printer, &painter, ctx, &(widget->image)); ctx_settings settings = BeginPrint(&printer, &painter, ctx, widget);
for (int i = 0;; i++) { for (int i = 0;; i++) {
ll_y = i * height; ll_y = i * height;
ur_y = ll_y + height; ur_y = ll_y + height;
if (ll_y > ctx->y_high) if (ll_y > ctx->y_high)
break; break;
PrintPage(&painter, title, ctx, &(widget->image), 0, ll_y, width, ur_y, i+1); PrintPage(&painter, title, ctx, widget, 0, ll_y, width, ur_y, i+1);
if (ur_y < ctx->y_high) { if (ur_y < ctx->y_high) {
printer.newPage(); printer.newPage();
} }
} }
widget->image = imageTmp; EndPrint(ctx, &settings, widget);
EndPrint(ctx, &settings);
} }
return WOW__SUCCESS; return WOW__SUCCESS;
} }
...@@ -1150,17 +1140,14 @@ pwr_tStatus CoWowQt::CreateFlowPrintDialogQt(const char* title, void* flow_ctx, ...@@ -1150,17 +1140,14 @@ pwr_tStatus CoWowQt::CreateFlowPrintDialogQt(const char* title, void* flow_ctx,
assert(dynamic_cast<QtScrollWidgetFlow*>(w) != NULL); assert(dynamic_cast<QtScrollWidgetFlow*>(w) != NULL);
QtScrollWidgetFlow* widget = dynamic_cast<QtScrollWidgetFlow*>(w); QtScrollWidgetFlow* widget = dynamic_cast<QtScrollWidgetFlow*>(w);
QImage imageTmp(widget->image);
QPrinter printer(QPrinter::HighResolution); QPrinter printer(QPrinter::HighResolution);
if (PrintDialog(&printer, &imageTmp, widget)) { if (PrintDialog(&printer, widget)) {
flow_tCtx ctx = (flow_tCtx)flow_ctx; flow_tCtx ctx = (flow_tCtx)flow_ctx;
QPainter painter(&printer); QPainter painter(&printer);
widget->image = QImage(printer.pageRect().width(), printer.pageRect().height() - GetPrintHeaderMargin(&painter), QImage::Format_RGB32); ctx_settings settings = BeginPrint(&printer, &painter, ctx, widget);
ctx_settings settings = BeginPrint(&printer, &painter, ctx, &(widget->image));
int num_pages = 0; int num_pages = 0;
for (int i = 0; i < ctx->a.size(); i++) { for (int i = 0; i < ctx->a.size(); i++) {
...@@ -1174,7 +1161,7 @@ pwr_tStatus CoWowQt::CreateFlowPrintDialogQt(const char* title, void* flow_ctx, ...@@ -1174,7 +1161,7 @@ pwr_tStatus CoWowQt::CreateFlowPrintDialogQt(const char* title, void* flow_ctx,
if (ctx->a[i]->type() == flow_eObjectType_Node) { if (ctx->a[i]->type() == flow_eObjectType_Node) {
FlowNode* elem = ((FlowNode*)ctx->a[i]); FlowNode* elem = ((FlowNode*)ctx->a[i]);
if (elem->nc->group == flow_eNodeGroup_Document) { if (elem->nc->group == flow_eNodeGroup_Document) {
PrintPage(&painter, title, ctx, &(widget->image), elem->x_left, elem->y_low, elem->x_right, elem->y_high, j); PrintPage(&painter, title, ctx, widget, elem->x_left, elem->y_low, elem->x_right, elem->y_high, j);
if (j < num_pages) { if (j < num_pages) {
printer.newPage(); printer.newPage();
...@@ -1184,8 +1171,7 @@ pwr_tStatus CoWowQt::CreateFlowPrintDialogQt(const char* title, void* flow_ctx, ...@@ -1184,8 +1171,7 @@ pwr_tStatus CoWowQt::CreateFlowPrintDialogQt(const char* title, void* flow_ctx,
} }
} }
widget->image = imageTmp; EndPrint(ctx, &settings, widget);
EndPrint(ctx, &settings);
} }
return WOW__SUCCESS; return WOW__SUCCESS;
} }
This diff is collapsed.
...@@ -42,21 +42,13 @@ ...@@ -42,21 +42,13 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "flow_draw.h" #include "flow_draw.h"
class DrawWind {
public:
GdkWindow* window = NULL;
GdkPixmap* buffer = NULL;
};
class FlowDrawGtk : public FlowDraw { class FlowDrawGtk : public FlowDraw {
public: public:
GtkWidget* toplevel; GtkWidget* toplevel;
GtkWidget* nav_shell; GtkWidget* nav_shell;
GtkWidget* nav_toplevel; GtkWidget* nav_toplevel;
GdkDisplay* display; GdkDisplay* display;
DrawWind m_wind; GdkWindow* w = NULL;
DrawWind nav_wind;
DrawWind* w = NULL;
GdkScreen* screen; GdkScreen* screen;
GdkGC* gc; GdkGC* gc;
GdkGC* gc_erase; GdkGC* gc_erase;
...@@ -75,7 +67,6 @@ public: ...@@ -75,7 +67,6 @@ public:
GdkColor color_vect[20]; GdkColor color_vect[20];
int color_vect_cnt; int color_vect_cnt;
int closing_down; int closing_down;
guint redraw_timer;
FlowDrawGtk(GtkWidget* toplevel, void** flow_ctx, FlowDrawGtk(GtkWidget* toplevel, void** flow_ctx,
int (*init_proc)(GtkWidget* w, FlowCtx* ctx, void* client_data), int (*init_proc)(GtkWidget* w, FlowCtx* ctx, void* client_data),
...@@ -85,16 +76,15 @@ public: ...@@ -85,16 +76,15 @@ public:
void event_handler(FlowCtx* ctx, GdkEvent event); void event_handler(FlowCtx* ctx, GdkEvent event);
void enable_event(FlowCtx* ctx, flow_eEvent event, flow_eEventType event_type, void enable_event(FlowCtx* ctx, flow_eEvent event, flow_eEventType event_type,
int (*event_cb)(FlowCtx* ctx, flow_tEvent event)); int (*event_cb)(FlowCtx* ctx, flow_tEvent event));
void create_buffer(DrawWind *wind); void create_buffer(void *wind);
void clear(); void clear();
void get_window_size(DrawWind *wind, int* width, int* height); void get_window_size(void *wind, int* width, int* height);
void set_window_size(DrawWind *wind, int width, int height); void set_window_size(void *wind, int width, int height);
int begin(DrawWind *wind); int begin(void *wind);
void end(); void end();
void start_redraw_timer(); void set_dirty(void *wind);
void cancel_redraw_timer();
void rect(int x, int y, int width, int height, flow_eDrawType gc_type, void rect(int x, int y, int width, int height, flow_eDrawType gc_type,
int fill, int idx, int highlight = 0, int dimmed = 0); int fill, int idx, int highlight = 0, int dimmed = 0);
...@@ -118,7 +108,7 @@ public: ...@@ -118,7 +108,7 @@ public:
void set_timer(FlowCtx* ctx, int time_ms, void (*callback_func)(FlowCtx* ctx), void set_timer(FlowCtx* ctx, int time_ms, void (*callback_func)(FlowCtx* ctx),
void** id); void** id);
void cancel_timer(void* id); void cancel_timer(void* id);
void set_cursor(DrawWind *wind, draw_eCursor cursor); void set_cursor(void *wind, draw_eCursor cursor);
void get_text_extent(const char* text, int len, flow_eDrawType gc_type, void get_text_extent(const char* text, int len, flow_eDrawType gc_type,
int idx, int* width, int* height, double size); int idx, int* width, int* height, double size);
void delete_secondary_ctx(FlowCtx* ctx); void delete_secondary_ctx(FlowCtx* ctx);
......
This diff is collapsed.
...@@ -46,20 +46,12 @@ ...@@ -46,20 +46,12 @@
#include <QPainter> #include <QPainter>
#include <QWidget> #include <QWidget>
class DrawWind {
public:
QWidget* window = NULL;
QImage* buffer = NULL;
};
class FlowDrawQt : private QObject, public FlowDraw { class FlowDrawQt : private QObject, public FlowDraw {
Q_OBJECT Q_OBJECT
public: public:
QWidget* toplevel; QWidget* toplevel;
DrawWind m_wind; QWidget* w = NULL;
DrawWind nav_wind;
DrawWind* w = NULL;
QColor background; QColor background;
QColor foreground; QColor foreground;
QTimer* timer_id; QTimer* timer_id;
...@@ -79,11 +71,12 @@ public: ...@@ -79,11 +71,12 @@ public:
void clear(); void clear();
void get_window_size(DrawWind *wind, int* width, int* height); void get_window_size(void *wind, int* width, int* height);
void set_window_size(DrawWind *wind, int width, int height); void set_window_size(void *wind, int width, int height);
int begin(DrawWind *wind); int begin(void *w);
void end(); void end();
void set_dirty(void *w);
void rect(int x, int y, int width, int height, flow_eDrawType gc_type, void rect(int x, int y, int width, int height, flow_eDrawType gc_type,
int fill, int idx, int highlight, int dimmed); int fill, int idx, int highlight, int dimmed);
...@@ -110,7 +103,7 @@ public: ...@@ -110,7 +103,7 @@ public:
void** id); void** id);
void cancel_timer(void* id); void cancel_timer(void* id);
void set_cursor(DrawWind *wind, draw_eCursor cursor); void set_cursor(void *wind, draw_eCursor cursor);
void get_text_extent(const char* text, int len, void get_text_extent(const char* text, int len,
flow_eDrawType gc_type, int idx, int* width, int* height, double size); flow_eDrawType gc_type, int idx, int* width, int* height, double size);
...@@ -137,13 +130,13 @@ public: ...@@ -137,13 +130,13 @@ public:
void* flow_ctx, int page_border, int* sts); void* flow_ctx, int page_border, int* sts);
private: private:
unique_ptr<QPainter> get_painter(int painter_type, int size); void get_painter(int painter_type, int size);
void event_timer(FlowCtx* ctx, QMouseEvent *event, QWidget *target); void event_timer(FlowCtx* ctx, QMouseEvent *event, QWidget *target);
void cancel_event_timer(FlowCtx* ctx);
void (*draw_timer_callback_func)(FlowCtx* ctx); void (*draw_timer_callback_func)(FlowCtx* ctx);
QTimer* draw_timer_id; QTimer* draw_timer_id;
QPainter painter;
public slots: public slots:
bool event_timer_cb(); bool event_timer_cb();
......
...@@ -47,23 +47,15 @@ ...@@ -47,23 +47,15 @@
#include <QTimer> #include <QTimer>
void QtScrollWidgetFlow::createBuffer(QSize size)
{
if (size.isEmpty()) {
return;
}
this->image = QImage(size, QImage::Format_RGB32);
QPainter imPainter(&image);
imPainter.fillRect(image.rect(), palette().color(QPalette::Background));
}
void QtScrollWidgetFlow::init(unsigned int eCtxType, void QtScrollWidgetFlow::init(unsigned int eCtxType,
int (*init_proc)(FlowCtx* ctx, void* client_data), void* client_data, int (*init_proc)(FlowCtx* ctx, void* client_data), void* client_data,
int (*init_proc2)(QWidget* w, FlowCtx* ctx, void* client_data)) int (*init_proc2)(QWidget* w, FlowCtx* ctx, void* client_data))
{ {
createBuffer(size());
setFocusPolicy(Qt::ClickFocus); setFocusPolicy(Qt::ClickFocus);
setMouseTracking(true); setMouseTracking(true);
if (getenv("DISPLAY")[0] != ':') {
setAttribute(Qt::WA_PaintOnScreen, true);
}
this->ctxType = eCtxType; this->ctxType = eCtxType;
this->init_proc = init_proc; this->init_proc = init_proc;
this->init_widget_proc = init_proc2; this->init_widget_proc = init_proc2;
...@@ -80,9 +72,11 @@ QWidget* QtScrollWidgetFlow::initScroll(unsigned int eCtxType, ...@@ -80,9 +72,11 @@ QWidget* QtScrollWidgetFlow::initScroll(unsigned int eCtxType,
int (*init_proc)(FlowCtx* ctx, void* client_data), void* client_data, int (*init_proc)(FlowCtx* ctx, void* client_data), void* client_data,
int (*init_proc2)(QWidget* w, FlowCtx* ctx, void* client_data)) int (*init_proc2)(QWidget* w, FlowCtx* ctx, void* client_data))
{ {
createBuffer(size());
setFocusPolicy(Qt::ClickFocus); setFocusPolicy(Qt::ClickFocus);
setMouseTracking(true); setMouseTracking(true);
if (getenv("DISPLAY")[0] != ':') {
setAttribute(Qt::WA_PaintOnScreen, true);
}
this->ctxType = eCtxType; this->ctxType = eCtxType;
this->init_proc = init_proc; this->init_proc = init_proc;
this->init_widget_proc = init_proc2; this->init_widget_proc = init_proc2;
...@@ -113,9 +107,11 @@ QWidget* QtScrollWidgetFlow::initScroll(unsigned int eCtxType, ...@@ -113,9 +107,11 @@ QWidget* QtScrollWidgetFlow::initScroll(unsigned int eCtxType,
void QtScrollWidgetFlow::init(unsigned int eCtxType, QWidget* main) void QtScrollWidgetFlow::init(unsigned int eCtxType, QWidget* main)
{ {
createBuffer(size());
setFocusPolicy(Qt::ClickFocus); setFocusPolicy(Qt::ClickFocus);
setMouseTracking(true); setMouseTracking(true);
if (getenv("DISPLAY")[0] != ':') {
setAttribute(Qt::WA_PaintOnScreen, true);
}
this->ctxType = eCtxType; this->ctxType = eCtxType;
this->scroll_timerid = new QTimer(this); this->scroll_timerid = new QTimer(this);
is_navigator = 1; is_navigator = 1;
...@@ -220,10 +216,15 @@ void QtScrollWidgetFlow::scroll_v_released(int value) ...@@ -220,10 +216,15 @@ void QtScrollWidgetFlow::scroll_v_released(int value)
void QtScrollWidgetFlow::paintEvent(QPaintEvent* event) void QtScrollWidgetFlow::paintEvent(QPaintEvent* event)
{ {
QPainter painter(this); FlowCtx* ctx = (FlowCtx*)parent_ctx;
QRect dirtyRect = event->rect(); draw_ctx->begin(this);
painter.drawImage(dirtyRect, image, dirtyRect); if (ctx->mw == this) {
QWidget::paintEvent(event); ctx->draw(0, 0, width(), height());
} else if (ctx->navw == this) {
ctx->nav_draw(0, 0, width(), height());
}
draw_ctx->end();
ctx->is_dirty = 0;
} }
void QtScrollWidgetFlow::closeEvent(QCloseEvent* event) void QtScrollWidgetFlow::closeEvent(QCloseEvent* event)
...@@ -248,19 +249,16 @@ void QtScrollWidgetFlow::handleEvent(QEvent* event) ...@@ -248,19 +249,16 @@ void QtScrollWidgetFlow::handleEvent(QEvent* event)
if (parent_ctx) { if (parent_ctx) {
FlowCtx* ctx = (FlowCtx*)parent_ctx; FlowCtx* ctx = (FlowCtx*)parent_ctx;
FlowDrawQt* drawer = ((FlowDrawQt*)ctx->fdraw); FlowDrawQt* drawer = ((FlowDrawQt*)ctx->fdraw);
if (event->type() == QEvent::MouseMove) { if (event->type() == QEvent::Resize || event->type() == QEvent::Show) {
drawer->m_wind.window->update(); ctx->set_dirty();
} }
drawer->event_handler((FlowCtx*)parent_ctx, event, this); drawer->event_handler(ctx, event, this);
} }
} }
} }
bool QtScrollWidgetFlow::event(QEvent* event) bool QtScrollWidgetFlow::event(QEvent* event)
{ {
if (event->type() == QEvent::Resize) {
createBuffer(((QResizeEvent*)event)->size());
}
if (!is_realized && event->type() == QEvent::Show) { if (!is_realized && event->type() == QEvent::Show) {
realize(); realize();
is_realized = true; is_realized = true;
......
...@@ -86,8 +86,6 @@ public: ...@@ -86,8 +86,6 @@ public:
int destroyed; int destroyed;
QScrollArea* form; QScrollArea* form;
QImage image;
virtual void handleEvent(QEvent* event); virtual void handleEvent(QEvent* event);
protected: protected:
...@@ -101,9 +99,6 @@ protected: ...@@ -101,9 +99,6 @@ protected:
bool is_realized; bool is_realized;
unsigned int ctxType; unsigned int ctxType;
private:
void createBuffer(QSize size);
public slots: public slots:
void scroll_h_action(int value); void scroll_h_action(int value);
void scroll_v_action(int value); void scroll_v_action(int value);
...@@ -112,4 +107,4 @@ public slots: ...@@ -112,4 +107,4 @@ public slots:
void scroll_callback_cb(); void scroll_callback_cb();
}; };
#endif // FLOW_SCROLL_WIDGET_QT_H #endif // FLOW_SCROLL_WIDGET_QT_H
\ No newline at end of file
...@@ -915,20 +915,6 @@ void FlowAnnot::nav_erase(void* pos, void* node) ...@@ -915,20 +915,6 @@ void FlowAnnot::nav_erase(void* pos, void* node)
int FlowAnnot::event_handler( int FlowAnnot::event_handler(
void* pos, flow_eEvent event, int x, int y, void* node) void* pos, flow_eEvent event, int x, int y, void* node)
{ {
FlowPoint* p;
p = (FlowPoint*)pos;
/**
if ( p1.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x < x &&
x < p2.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x &&
p1.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y < y &&
y < p2.z_y + ((FlowPoint *)pos)->z_y - ctx->offset_y)
{
std::cout << "Event handler: Hit in text\n";
return 1;
}
else
***/
return 0; return 0;
} }
...@@ -1109,8 +1095,7 @@ void FlowAnnot::open_annotation_input(void* pos, void* node) ...@@ -1109,8 +1095,7 @@ void FlowAnnot::open_annotation_input(void* pos, void* node)
int x, width_pix, height_pix; int x, width_pix, height_pix;
double width, height; double width, height;
int idx = int(ctx->zoom_factor / ctx->base_zoom_factor * (text_size + 4) - 4); int idx = int(ctx->zoom_factor / ctx->base_zoom_factor * (text_size + 4) - 4);
idx = MAX(0, idx); idx = CLAMP(idx, 0, DRAW_TYPE_SIZE - 1);
idx = MIN(idx, DRAW_TYPE_SIZE - 1);
switch (annot_type) { switch (annot_type) {
case flow_eAnnotType_OneLine: case flow_eAnnotType_OneLine:
measure_annot(((FlowNode*)node)->annotv[number], &width, &height); measure_annot(((FlowNode*)node)->annotv[number], &width, &height);
......
...@@ -238,21 +238,25 @@ void FlowAnnotPixmap::get_borders(double pos_x, double pos_y, double* x_right, ...@@ -238,21 +238,25 @@ void FlowAnnotPixmap::get_borders(double pos_x, double pos_y, double* x_right,
void FlowAnnotPixmap::move( void FlowAnnotPixmap::move(
void* pos, double x, double y, int highlight, int dimmed, int hot) void* pos, double x, double y, int highlight, int dimmed, int hot)
{ {
if (!feq(x, p.x) || !feq(y, p.y)) {
ctx->set_dirty();
}
p.x = x; p.x = x;
p.y = y; p.y = y;
zoom(); zoom();
nav_zoom(); nav_zoom();
ctx->set_dirty();
} }
void FlowAnnotPixmap::shift(void* pos, double delta_x, double delta_y, void FlowAnnotPixmap::shift(void* pos, double delta_x, double delta_y,
int highlight, int dimmed, int hot) int highlight, int dimmed, int hot)
{ {
if (!feq(delta_x, 0.0) || !feq(delta_y, 0.0)) {
ctx->set_dirty();
}
p.x += delta_x; p.x += delta_x;
p.y += delta_y; p.y += delta_y;
zoom(); zoom();
nav_zoom(); nav_zoom();
ctx->set_dirty();
} }
void FlowAnnotPixmap::configure_annotations(void* pos, void* node) void FlowAnnotPixmap::configure_annotations(void* pos, void* node)
......
...@@ -170,16 +170,10 @@ void FlowArc::nav_erase(void* pos, void* node) ...@@ -170,16 +170,10 @@ void FlowArc::nav_erase(void* pos, void* node)
int FlowArc::event_handler( int FlowArc::event_handler(
void* pos, flow_eEvent event, int x, int y, void* node) void* pos, flow_eEvent event, int x, int y, void* node)
{ {
FlowPoint* p; return (angle2 == 360 && ll.z_x + ((FlowPoint*)pos)->z_x - ctx->offset_x <= x
p = (FlowPoint*)pos;
if (angle2 == 360 && ll.z_x + ((FlowPoint*)pos)->z_x - ctx->offset_x <= x
&& x <= ur.z_x + ((FlowPoint*)pos)->z_x - ctx->offset_x && x <= ur.z_x + ((FlowPoint*)pos)->z_x - ctx->offset_x
&& ll.z_y + ((FlowPoint*)pos)->z_y - ctx->offset_y <= y && ll.z_y + ((FlowPoint*)pos)->z_y - ctx->offset_y <= y
&& y <= ur.z_y + ((FlowPoint*)pos)->z_y - ctx->offset_y) { && y <= ur.z_y + ((FlowPoint*)pos)->z_y - ctx->offset_y);
return 1;
} else
return 0;
} }
void FlowArc::get_borders(double pos_x, double pos_y, double* x_right, void FlowArc::get_borders(double pos_x, double pos_y, double* x_right,
...@@ -198,6 +192,10 @@ void FlowArc::get_borders(double pos_x, double pos_y, double* x_right, ...@@ -198,6 +192,10 @@ void FlowArc::get_borders(double pos_x, double pos_y, double* x_right,
void FlowArc::move(void* pos, double x1, double y1, double x2, double y2, void FlowArc::move(void* pos, double x1, double y1, double x2, double y2,
int ang1, int ang2, int highlight, int dimmed, int hot) int ang1, int ang2, int highlight, int dimmed, int hot)
{ {
if (!feq(ll.x, x1) || !feq(ll.y, y1) || !feq(ur.x, x2) || !feq(ur.y, y2) ||
angle1 != ang1 || angle2 != ang2) {
ctx->set_dirty();
}
ll.x = x1; ll.x = x1;
ll.y = y1; ll.y = y1;
ur.x = x2; ur.x = x2;
...@@ -206,19 +204,20 @@ void FlowArc::move(void* pos, double x1, double y1, double x2, double y2, ...@@ -206,19 +204,20 @@ void FlowArc::move(void* pos, double x1, double y1, double x2, double y2,
angle2 = ang2; angle2 = ang2;
zoom(); zoom();
nav_zoom(); nav_zoom();
ctx->set_dirty();
} }
void FlowArc::shift(void* pos, double delta_x, double delta_y, int highlight, void FlowArc::shift(void* pos, double delta_x, double delta_y, int highlight,
int dimmed, int hot) int dimmed, int hot)
{ {
if (!feq(delta_x, 0.0) || !feq(delta_y, 0.0)) {
ctx->set_dirty();
}
ll.x += delta_x; ll.x += delta_x;
ll.y += delta_y; ll.y += delta_y;
ur.x += delta_x; ur.x += delta_x;
ur.y += delta_y; ur.y += delta_y;
zoom(); zoom();
nav_zoom(); nav_zoom();
ctx->set_dirty();
} }
std::ostream& operator<<(std::ostream& o, const FlowArc a) std::ostream& operator<<(std::ostream& o, const FlowArc a)
......
...@@ -331,10 +331,7 @@ void FlowArray::brow_close(void* ctx, FlowArrayElem* element) ...@@ -331,10 +331,7 @@ void FlowArray::brow_close(void* ctx, FlowArrayElem* element)
{ {
int i; int i;
int idx = 0; int idx = 0;
int found; int found = 0;
FlowArrayElem* e;
found = 0;
for (i = 0; i < a_size; i++) { for (i = 0; i < a_size; i++) {
if (*(a + i) == element) { if (*(a + i) == element) {
idx = i; idx = i;
...@@ -355,7 +352,6 @@ void FlowArray::brow_close(void* ctx, FlowArrayElem* element) ...@@ -355,7 +352,6 @@ void FlowArray::brow_close(void* ctx, FlowArrayElem* element)
return; return;
for (i = idx + 1; i < next_idx; i++) { for (i = idx + 1; i < next_idx; i++) {
e = a[i];
((FlowCtx*)ctx)->delete_object(a[i]); ((FlowCtx*)ctx)->delete_object(a[i]);
i--; i--;
next_idx--; next_idx--;
......
...@@ -242,6 +242,8 @@ void FlowArrow::nav_erase(void* pos, void* node) ...@@ -242,6 +242,8 @@ void FlowArrow::nav_erase(void* pos, void* node)
void FlowArrow::move(void* pos, double x1, double y1, double x2, double y2, void FlowArrow::move(void* pos, double x1, double y1, double x2, double y2,
int highlight, int dimmed, int hot) int highlight, int dimmed, int hot)
{ {
double p1x = p1.x, p1y = p1.y, p2x = p2.x, p2y = p2.y;
if (fabs(x2 - x1) < DBL_EPSILON) { if (fabs(x2 - x1) < DBL_EPSILON) {
if (y1 > y2) { if (y1 > y2) {
p1.x = x2 + arrow_width / 2; p1.x = x2 + arrow_width / 2;
...@@ -273,16 +275,22 @@ void FlowArrow::move(void* pos, double x1, double y1, double x2, double y2, ...@@ -273,16 +275,22 @@ void FlowArrow::move(void* pos, double x1, double y1, double x2, double y2,
p2.x = x2 + (x1 - x2) * arrow_length / d - (y1 - y2) * arrow_width / d / 2; p2.x = x2 + (x1 - x2) * arrow_length / d - (y1 - y2) * arrow_width / d / 2;
p2.y = y2 + (y1 - y2) * arrow_length / d + (x1 - x2) * arrow_width / d / 2; p2.y = y2 + (y1 - y2) * arrow_length / d + (x1 - x2) * arrow_width / d / 2;
} }
if (!feq(p1x, p1.x) || !feq(p1y, p1.y) || !feq(p2x, p2.x) || !feq(p2y, p2.y)
|| !feq(p_dest.x, x2) || !feq(p_dest.y, y2)) {
ctx->set_dirty();
}
p_dest.x = x2; p_dest.x = x2;
p_dest.y = y2; p_dest.y = y2;
zoom(); zoom();
nav_zoom(); nav_zoom();
ctx->set_dirty();
} }
void FlowArrow::shift(void* pos, double delta_x, double delta_y, int highlight, void FlowArrow::shift(void* pos, double delta_x, double delta_y, int highlight,
int dimmed, int hot) int dimmed, int hot)
{ {
if (!feq(delta_x, 0.0) || !feq(delta_y, 0.0)) {
ctx->set_dirty();
}
p_dest.x += delta_x; p_dest.x += delta_x;
p_dest.y += delta_y; p_dest.y += delta_y;
p1.x += delta_x; p1.x += delta_x;
...@@ -291,7 +299,6 @@ void FlowArrow::shift(void* pos, double delta_x, double delta_y, int highlight, ...@@ -291,7 +299,6 @@ void FlowArrow::shift(void* pos, double delta_x, double delta_y, int highlight,
p2.y += delta_y; p2.y += delta_y;
zoom(); zoom();
nav_zoom(); nav_zoom();
ctx->set_dirty();
} }
int FlowArrow::event_handler( int FlowArrow::event_handler(
......
...@@ -44,17 +44,10 @@ ...@@ -44,17 +44,10 @@
int BrowCtx::insert(FlowArrayElem* element, FlowArrayElem* destination, int BrowCtx::insert(FlowArrayElem* element, FlowArrayElem* destination,
flow_eDest destination_code) flow_eDest destination_code)
{ {
int sts; int sts = a.brow_insert(element, destination, destination_code);
double y;
sts = a.brow_insert(element, destination, destination_code);
if (!sts) if (!sts)
return sts; return sts;
if (destination)
y = ((FlowNode*)destination)->y_low;
else
y = 0;
configure(); configure();
return 1; return 1;
} }
...@@ -143,30 +136,27 @@ void BrowCtx::zoom(double factor) ...@@ -143,30 +136,27 @@ void BrowCtx::zoom(double factor)
int BrowCtx::print(char* filename) int BrowCtx::print(char* filename)
{ {
int i;
double ll_x, ll_y, ur_x, ur_y;
double width, height;
int sts;
if (a.size() == 0) if (a.size() == 0)
return 0; return 0;
double ll_x, ll_y, ur_x, ur_y;
((FlowNode*)a[0])->measure(&ll_x, &ll_y, &ur_x, &ur_y); ((FlowNode*)a[0])->measure(&ll_x, &ll_y, &ur_x, &ur_y);
height = 60 * (ur_y - ll_y); double height = 60 * (ur_y - ll_y);
width = 0.70 * height; double width = 0.70 * height;
if (width < ur_x - ll_x) { if (width < ur_x - ll_x) {
// Portrait // Portrait
height = 40 * (ur_y - ll_y); height = 40 * (ur_y - ll_y);
width = height / 0.70; width = height / 0.70;
} }
int sts;
current_print = new FlowPscript(filename, this, 1, &sts); current_print = new FlowPscript(filename, this, 1, &sts);
if (EVEN(sts)) { if (EVEN(sts)) {
delete current_print; delete current_print;
return 0; return 0;
} }
for (i = 0;; i++) { for (int i = 0;; i++) {
ll_y = i * height; ll_y = i * height;
ur_y = ll_y + height; ur_y = ll_y + height;
ll_x = 0; ll_x = 0;
...@@ -218,21 +208,17 @@ void BrowCtx::print_draw_page(void* context, const char* title, int page, ...@@ -218,21 +208,17 @@ void BrowCtx::print_draw_page(void* context, const char* title, int page,
void BrowCtx::print_get_pages( void BrowCtx::print_get_pages(
flow_eOrientation orientation, double scale, int* pages) flow_eOrientation orientation, double scale, int* pages)
{ {
double ll_x, ll_y, ur_x, ur_y;
double width, height;
if (a.size() == 0) { if (a.size() == 0) {
*pages = 0; *pages = 0;
return; return;
} }
double ll_x, ll_y, ur_x, ur_y;
((FlowNode*)a[0])->measure(&ll_x, &ll_y, &ur_x, &ur_y); ((FlowNode*)a[0])->measure(&ll_x, &ll_y, &ur_x, &ur_y);
height = 60 * (ur_y - ll_y) * scale; double height = 60 * (ur_y - ll_y) * scale;
width = 0.70 * height;
if (orientation == flow_eOrientation_Landscape) { if (orientation == flow_eOrientation_Landscape) {
// Portrait // Portrait
height = 35 * (ur_y - ll_y) * scale; height = 35 * (ur_y - ll_y) * scale;
width = height / 0.70;
} }
*pages = int(y_high / height + 1); *pages = int(y_high / height + 1);
...@@ -292,14 +278,11 @@ void BrowCtx::center_object(FlowArrayElem* object, double factor) ...@@ -292,14 +278,11 @@ void BrowCtx::center_object(FlowArrayElem* object, double factor)
int BrowCtx::get_first_visible(FlowArrayElem** element) int BrowCtx::get_first_visible(FlowArrayElem** element)
{ {
double ll_x, ll_y, ur_x, ur_y; double window_low = double(offset_y) / zoom_factor;
double window_low, window_high; double window_high = double(offset_y + window_height) / zoom_factor;
int i;
window_low = double(offset_y) / zoom_factor; for (int i = 0; i < a.size(); i++) {
window_high = double(offset_y + window_height) / zoom_factor; double ll_x, ll_y, ur_x, ur_y;
for (i = 0; i < a.size(); i++) {
((FlowNode*)a[i])->measure(&ll_x, &ll_y, &ur_x, &ur_y); ((FlowNode*)a[i])->measure(&ll_x, &ll_y, &ur_x, &ur_y);
if (ll_y >= window_low || ur_y >= window_high) { if (ll_y >= window_low || ur_y >= window_high) {
*element = a[i]; *element = a[i];
...@@ -311,14 +294,11 @@ int BrowCtx::get_first_visible(FlowArrayElem** element) ...@@ -311,14 +294,11 @@ int BrowCtx::get_first_visible(FlowArrayElem** element)
int BrowCtx::get_last_visible(FlowArrayElem** element) int BrowCtx::get_last_visible(FlowArrayElem** element)
{ {
double ll_x, ll_y, ur_x, ur_y; double window_low = double(offset_y) / zoom_factor;
double window_low, window_high; double window_high = double(offset_y + window_height) / zoom_factor;
int i;
window_low = double(offset_y) / zoom_factor;
window_high = double(offset_y + window_height) / zoom_factor;
for (i = a.size() - 1; i >= 0; i--) { for (int i = a.size() - 1; i >= 0; i--) {
double ll_x, ll_y, ur_x, ur_y;
((FlowNode*)a[i])->measure(&ll_x, &ll_y, &ur_x, &ur_y); ((FlowNode*)a[i])->measure(&ll_x, &ll_y, &ur_x, &ur_y);
if (ur_y <= window_high || ll_y <= window_low) { if (ur_y <= window_high || ll_y <= window_low) {
*element = a[i]; *element = a[i];
......
...@@ -54,10 +54,6 @@ public: ...@@ -54,10 +54,6 @@ public:
void configure(); void configure();
void change_scrollbar(); void change_scrollbar();
void zoom(double factor); void zoom(double factor);
void unzoom()
{
zoom(base_zoom_factor / zoom_factor);
}
int print(char* filename); int print(char* filename);
void print_draw_page(void* context, const char* title, int page, void print_draw_page(void* context, const char* title, int page,
flow_eOrientation orientation, double scale); flow_eOrientation orientation, double scale);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -44,7 +44,7 @@ FlowDraw::~FlowDraw() ...@@ -44,7 +44,7 @@ FlowDraw::~FlowDraw()
{ {
} }
int FlowDraw::begin(DrawWind *wind) int FlowDraw::begin(void *wind)
{ {
return 0; return 0;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -47,8 +47,8 @@ static void tiptext_timer_cb(FlowCtx* ctx) ...@@ -47,8 +47,8 @@ static void tiptext_timer_cb(FlowCtx* ctx)
ctx->tiptext->active = true; ctx->tiptext->active = true;
ctx->set_dirty(); ctx->set_dirty();
ctx->redraw_if_dirty();
} }
FlowTipText::~FlowTipText() FlowTipText::~FlowTipText()
{ {
if (timer_id) if (timer_id)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment