Commit fbeffabf authored by Claes Sjofors's avatar Claes Sjofors

Merge branch 'master'

parents 31d1db7f 834f79f1
This diff is collapsed.
......@@ -45,7 +45,7 @@
</div>
</div>
<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="cli.ts"></script>
<script type="text/babel" src="gdh.ts"></script>
......
......@@ -21,7 +21,7 @@
</div>
</div>
<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="gdh.ts"></script>
<script type="text/babel" src="draw.ts"></script>
......
......@@ -7,7 +7,7 @@
<body>
<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="cli.ts"></script>
<script type="text/babel" src="gdh.ts"></script>
......
......@@ -203,21 +203,16 @@ class GlowNodeClass {
Math.abs(base.y0 - base.y1) < Number.MIN_VALUE)) {
// Borders are given i x0, y0, x1, y1
// 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) {
kx1 = base.x0;
kx2 = base.x1;
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);
if (t !== null) {
k1 = t.apply(k1);
k2 = t.apply(k2);
}
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 {
this.a.forEach(e => e.get_borders(t, g));
}
......
......@@ -5,7 +5,7 @@ class GlowRect {
draw_type;
line_width;
display_level;
fill;
fill: boolean;
constructor(ctx) {
this.ctx = ctx;
......@@ -32,7 +32,7 @@ class GlowRect {
this.display_level = parseInt(tokens[1], 10);
break;
case GlowSave.Rect_fill:
this.fill = parseInt(tokens[1], 10);
this.fill = Boolean(parseInt(tokens[1], 10));
break;
case GlowSave.Rect_ll:
i = this.ll.open(lines, i + 1);
......@@ -51,9 +51,11 @@ class GlowRect {
return i;
}
draw(highlight, hot) {
}
draw_shadow(border, shadow, highlight, hot) {
draw(pos, highlight = 0, hot = 0, node = null) {
let idx = this.line_width + hot;
idx = clamp(idx, 0, DRAW_TYPE_SIZE - 1);
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 {
return i;
}
draw(hightlight, hot) {
}
draw_shadow(border, shadow, 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,
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;
a12 = 0;
a13 = 0;
......@@ -6,24 +6,60 @@ class GlowTransform {
a22 = 1;
a23 = 0;
rotation = 0;
s: GlowTransform;
stored = false;
set(o: GlowTransform) {
this.a11 = o.a11;
this.a12 = o.a12;
this.a13 = o.a13;
this.a21 = o.a21;
this.a22 = o.a22;
this.a23 = o.a23;
this.rotation = o.rotation;
set(m: Matrix) {
this.a11 = m.a11;
this.a12 = m.a12;
this.a13 = m.a13;
this.a21 = m.a21;
this.a22 = m.a22;
this.a23 = m.a23;
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() {
this.s.set(this);
this.stored = true;
}
revert() {
this.set(this.s);
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
......@@ -65,68 +101,6 @@ class GlowTransform {
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) {
this.a13 = this.a13 * sx + x0 * (1 - sx);
this.a23 = this.a23 * sy + y0 * (1 - sy);
......@@ -136,15 +110,6 @@ class GlowTransform {
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) {
let sin_a;
let cos_a;
......@@ -176,28 +141,6 @@ class GlowTransform {
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) {
this.a13 += x0;
this.a23 += y0;
......@@ -214,7 +157,7 @@ class GlowTransform {
}
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.a22 === 0 && this.a12 !== 0 &&
this.a21 !== 0) {
......@@ -233,16 +176,6 @@ class GlowTransform {
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() {
return this.stored;
}
......
......@@ -49,7 +49,7 @@ class GrowAnnot extends GlowAnnot {
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 /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
......@@ -75,11 +75,15 @@ class GrowAnnot extends GlowAnnot {
ldraw_type = this.draw_type;
}
let x1 = Math.floor((this.trf.x(t, this.p.x, this.p.y) + offset_x) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
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 rot = Math.floor(this.trf.rot(t));
let tmp = Matrix.multiply(t, this.trf);
let p = tmp.apply(this.p);
let x1 = Math.floor((p.x + offset_x) * this.ctx.mw.zoom_factor_x) -
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;
switch (this.annot_type) {
......@@ -157,7 +161,7 @@ class GrowAnnot extends GlowAnnot {
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 /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
......
......@@ -169,29 +169,24 @@ class GrowArc extends GlowArc {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = Math.floor(this.trf.rot(t));
let tmp = Matrix.multiply(t, this.trf);
let p = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = Math.floor(tmp.rotation);
if (rot % 90 !== 0 &&
Math.abs((this.ur.x - this.ll.x) - (this.ur.y - this.ll.y)) <
Number.MIN_VALUE) {
let tmp = t ? GlowTransform.multiply(t, this.trf) : this.trf;
let scale = this.trf.vertical_scale(tmp);
let x_c = ((this.trf.x(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_x -
this.ctx.mw.offset_x) +
(this.trf.x(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_x -
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;
let scale = Matrix.multiply(tmp, this.trf).vertical_scale();
let x_c = ((p.x * this.ctx.mw.zoom_factor_x - this.ctx.mw.offset_x) +
(p2.x * this.ctx.mw.zoom_factor_x - this.ctx.mw.offset_x)) / 2;
let y_c = ((p.y * this.ctx.mw.zoom_factor_y - this.ctx.mw.offset_y) +
(p2.y * this.ctx.mw.zoom_factor_y - this.ctx.mw.offset_y)) / 2;
x1 = Math.floor(-scale *
((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 {
}
get_borders(t, g) {
let x1 = this.trf.x(t, this.ll.x, this.ll.y);
let x2 = this.trf.x(t, this.ur.x, this.ur.y);
let y1 = this.trf.y(t, this.ll.x, this.ll.y);
let y2 = this.trf.y(t, this.ur.x, this.ur.y);
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
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) {
......
......@@ -202,16 +202,17 @@ class GrowAxis extends GrowRect {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.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 tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
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 ur_x = Math.max(x1, x2);
......@@ -459,15 +460,15 @@ class GrowAxis extends GrowRect {
this.max_value = maxval;
this.min_value = minval;
let x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
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 x2 = Math.floor(this.trf.x(this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(this.ur.x, this.ur.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 p1 = this.trf.apply(this.ll);
let p2 = this.trf.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation = (this.trf.rotation / 360 - Math.floor(this.trf.rotation / 360)) *
360;
if (keep_settings === 0) {
......
......@@ -133,16 +133,17 @@ class GrowAxisArc extends GrowArc {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.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 tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
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 ur_x = Math.max(x1, x2);
......@@ -250,15 +251,15 @@ class GrowAxisArc extends GrowArc {
this.max_value = maxval;
this.min_value = minval;
let x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
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 x2 = Math.floor(this.trf.x(this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(this.ur.x, this.ur.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 p1 = this.trf.apply(this.ll);
let p2 = this.trf.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let rotation = (this.trf.rotation / 360 - Math.floor(this.trf.rotation / 360)) *
360;
if (keep_settings === 0) {
......
......@@ -108,20 +108,20 @@ class GrowBar extends GrowRect {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
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 ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2);
if (this.fill !== 0) {
if (this.fill) {
let drawtype =
GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight,
highlight, colornode, 1, 0);
......@@ -130,7 +130,7 @@ class GrowBar extends GrowRect {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype, true, 0);
} 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;
if (this.gradient_contrast >= 0) {
......@@ -155,7 +155,7 @@ class GrowBar extends GrowRect {
if (this.max_value !== this.min_value) {
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;
x0 = ll_x;
y0 = ll_y;
......@@ -201,7 +201,7 @@ class GrowBar extends GrowRect {
if (grad === Gradient.No) {
this.ctx.gdraw.rect(x0, y0, width, height, dt, true, 0);
} else {
rotation = (t) ? this.trf.rot(t) : this.trf.rot();
rotation = (t) ? this.trf.rotation + t.rotation : this.trf.rotation;
let fb1, fb2;
if (this.gradient_contrast >= 0) {
......
......@@ -92,16 +92,17 @@ class GrowBarArc extends GrowArc {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.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 tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
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 ur_x = Math.max(x1, x2);
......
......@@ -136,15 +136,17 @@ class GrowBarChart extends GrowRect {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = Math.floor(this.trf.rot(t));
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y2 = Math.floor(p2.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);
let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2);
......
......@@ -386,20 +386,19 @@ class GrowFolder extends GrowWindow {
(8 + 2 * this.text_size);
text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1);
let dx1 = this.trf.x(t, this.ll.x, this.ll.y);
let dy1 = this.trf.y(t, this.ll.x, this.ll.y);
let dx2 = this.trf.x(t, this.ur.x, this.ur.y);
let dy2 = this.trf.y(t, this.ur.x, this.ur.y);
dx1 = Math.min(dx1, dx2);
dx2 = Math.max(dx1, dx2);
dy1 = Math.min(dy1, dy2);
dy2 = Math.max(dy1, dy2);
let tmp = Matrix.multiply(t, this.trf);
let d1 = tmp.apply(this.ll);
let d2 = tmp.apply(this.ur);
d1.x = Math.min(d1.x, d2.x);
d2.x = Math.max(d1.x, d2.x);
d1.y = Math.min(d1.y, d2.y);
d2.y = Math.max(d1.y, d2.y);
let ll_x = Math.floor(dx1 * 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_y = Math.floor((dy1 + this.y_low_offs) * this.ctx.mw.zoom_factor_y) -
let ll_x = Math.floor(d1.x * 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((d1.y + this.y_low_offs) * this.ctx.mw.zoom_factor_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 =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
......
......@@ -137,14 +137,14 @@ class GrowImage extends Rect {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
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 ur_x = Math.max(x1, x2);
......@@ -155,12 +155,12 @@ class GrowImage extends Rect {
}
get_borders(t, g) {
let x1 = this.trf.x(t, this.ll.x, this.ll.y);
let x2 = this.trf.x(t, this.ur.x, this.ur.y);
let y1 = this.trf.y(t, this.ll.x, this.ll.y);
let y2 = this.trf.y(t, this.ur.x, this.ur.y);
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
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() {
......@@ -206,7 +206,8 @@ class GrowImage extends Rect {
let old_x_right = this.ur_x;
let old_y_low = this.ll_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();
switch (type) {
......
......@@ -96,14 +96,14 @@ class GrowLine extends GlowLine {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.p1.x, this.p1.y) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.p1.x, this.p1.y) *
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) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.p2.x, this.p2.y) *
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.p1);
let p2 = tmp.apply(this.p2);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y2 = Math.floor(p2.y * this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
if (x1 === x2 && y1 === y2) {
return;
......
......@@ -46,18 +46,14 @@ class GrowMenu extends GrowRect {
if (this.ctx.nodraw !== 0) {
return;
}
let text_idx = Math.floor(this.trf.vertical_scale(t) *
this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
(this.text_size + 4) - 4);
let tsize = this.trf.vertical_scale(t) * this.ctx.mw.zoom_factor_y /
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 tsize = Matrix.multiply(t, this.trf).vertical_scale() *
this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * (this.text_size + 4);
let text_idx = clamp(Math.floor(tsize - 4), 0, DRAW_TYPE_SIZE - 1);
tsize *= 2;
let idx = Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
this.line_width - 1);
idx += hot;
idx = clamp(idx, 0, DRAW_TYPE_SIZE-1);
idx = clamp(idx + hot, 0, DRAW_TYPE_SIZE-1);
let z_width, z_descent;
let z_height = 0;
......@@ -118,7 +114,7 @@ class GrowMenu extends GrowRect {
Math.floor(this.ll.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
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.fill_drawtype, true, 0);
}
......@@ -176,7 +172,7 @@ class GrowMenu extends GrowRect {
let ur_y = Math.max(this.ll.y, this.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) /
(this.item_height / vscale / this.ctx.mw.zoom_factor_y));
......
......@@ -213,7 +213,7 @@ class GrowNode extends GlowNode {
if (t === null) {
this.nc.draw(this.trf, highlight, hot, node, node);
} 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);
}
} else {
......@@ -291,7 +291,7 @@ class GrowNode extends GlowNode {
if (t === null) {
this.nc.draw(this.trf, highlight, hot, node, node);
} 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
this.nc.draw(trf_tot, highlight, hot, this, this);
}
......@@ -351,7 +351,7 @@ class GrowNode extends GlowNode {
if (t === null) {
this.nc.draw(this.trf, highlight, hot, node, node);
} 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
this.nc.draw(trf_tot, highlight, hot, this, this);
}
......@@ -466,7 +466,8 @@ class GrowNode extends GlowNode {
old_x_right = this.ur_x;
old_y_low = this.ll_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.ctx.draw();
......@@ -510,7 +511,7 @@ class GrowNode extends GlowNode {
let t = new GlowTransform();
t.rotate(angel, x0, y0);
this.trf.set_from_stored(t);
this.trf.set(Matrix.multiply(t, this.trf.s));
this.get_node_borders();
}
......@@ -600,29 +601,27 @@ class GrowNode extends GlowNode {
}
// Calculate max and min coordinates
let x1 = this.trf.x(0, this.nc.y0);
let y1 = this.trf.y(0, this.nc.y0);
let x2 = this.trf.x(0, this.nc.y1);
let y2 = this.trf.y(0, this.nc.y1);
let p1 = this.trf.apply(new Point(0, this.nc.y0));
let p2 = this.trf.apply(new Point(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) {
limits.direction = Direction.Down;
limits.min = y1;
limits.max = y2;
limits.min = p1.y;
limits.max = p2.y;
} else if (rotation > 45 && rotation <= 135) {
limits.direction = Direction.Right;
limits.min = x2;
limits.max = x1;
limits.min = p2.x;
limits.max = p1.x;
} else if (rotation > 135 && rotation <= 225) {
limits.direction = Direction.Up;
limits.min = y2;
limits.max = y1;
limits.min = p2.y;
limits.max = p1.y;
} else if (rotation > 225 && rotation <= 315) {
limits.direction = Direction.Left;
limits.min = x1;
limits.max = x2;
limits.min = p1.x;
limits.max = p2.x;
}
limits.status = 1;
return limits;
......@@ -635,7 +634,7 @@ class GrowNode extends GlowNode {
}
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);
}
......@@ -655,30 +654,28 @@ class GrowNode extends GlowNode {
this.get_borders(t, g);
if (g.hit(new Point(x, y))) {
// Hit, calculate max and min koordinates
let x1 = this.trf.x(t, 0, this.nc.y0);
let y1 = this.trf.y(t, 0, this.nc.y0);
let x2 = this.trf.x(t, 0, this.nc.y1);
let y2 = this.trf.y(t, 0, this.nc.y1);
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(new Point(0, this.nc.y0));
let p2 = tmp.apply(new Point(0, this.nc.y1));
let rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360;
let rotation = (tmp.rotation / 360 - Math.floor(tmp.rotation / 360)) * 360;
if (rotation <= 45 || rotation > 315) {
b.direction = Direction.Down;
b.min = y1;
b.max = y2;
b.min = p1.y;
b.max = p2.y;
} else if (rotation > 45 && rotation <= 135) {
b.direction = Direction.Left;
b.min = x2;
b.max = x1;
b.min = p2.x;
b.max = p1.x;
} else if (rotation > 135 && rotation <= 225) {
b.direction = Direction.Up;
b.min = y2;
b.max = y1;
b.min = p2.y;
b.max = p1.y;
} else if (rotation > 225 && rotation <= 315) {
b.direction = Direction.Right;
b.min = x1;
b.max = x2;
b.min = p1.x;
b.max = p2.x;
}
b.background = this;
......@@ -875,7 +872,7 @@ class GrowNode extends GlowNode {
}
getAnnotationTextExtent(num) {
return this.nc.getAnnotationTextExtent(this.trf, this, num);
return this.nc.getAnnotationTextExtent(t, this.trfhis, num);
}
setColorThemeLightness() {
......
......@@ -158,15 +158,17 @@ class GrowPie extends GrowArc {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let rot = Math.floor(this.trf.rot(t));
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(p2.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);
let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2);
......
......@@ -290,7 +290,7 @@ class GrowPolyline extends GlowPolyline {
this.ctx.gdraw.polyline(this.points, this.a_points.size(),
drawtype, true, 0);
} 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;
if (this.gradient_contrast >= 0) {
......@@ -314,7 +314,7 @@ class GrowPolyline extends GlowPolyline {
0 && this.fill_eq_shadow === 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 *
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);
......@@ -587,19 +587,18 @@ class GrowPolyline extends GlowPolyline {
}
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++) {
let e = this.a_points.get(i);
let x1 = x2;
let y1 = y2;
let p1 = new Point(p2.x, p2.y);
if (i === 0) {
x1 = this.trf.x(t, e.x, e.y);
y1 = this.trf.y(t, e.x, e.y);
p1 = tmp.apply(e);
}
x2 = this.trf.x(t, e.x, e.y);
y2 = this.trf.y(t, e.x, e.y);
p2 = tmp.apply(e);
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 {
idx = Math.max(0, idx);
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 +
0.5 - this.ctx.mw.offset_x;
let y1 = this.trf.y(t, this.ll.x, this.ll.y) * this.ctx.mw.zoom_factor_y +
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 +
0.5 - this.ctx.mw.offset_x;
let y2 = this.trf.y(t, this.ur.x, this.ur.y) * this.ctx.mw.zoom_factor_y +
0.5 - this.ctx.mw.offset_y;
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = p1.x * this.ctx.mw.zoom_factor_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 x2 = p2.x * this.ctx.mw.zoom_factor_x + 0.5 - this.ctx.mw.offset_x;
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 ur_x = Math.max(x1, x2);
......@@ -239,14 +239,14 @@ class GrowRect extends GlowRect {
];
this.ctx.gdraw.polyline(points, 7, drawtype, true, 0);
}
if (this.fill !== 0) {
if (this.fill) {
if (display_shadow && ish !== 0) {
if (grad === Gradient.No || fillcolor === DrawType.ColorRed) {
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 *
ish, ur_y - ll_y - 2 * ish, drawtype, true, 0);
} 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;
if (this.bgcolor_gradient !== 0 &&
......@@ -281,7 +281,7 @@ class GrowRect extends GlowRect {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype, true, 0);
} 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;
if (this.bgcolor_gradient !== 0 &&
......@@ -313,7 +313,7 @@ class GrowRect extends GlowRect {
}
}
if (this.border !== 0 ||
!(this.fill !== 0 || (display_shadow && this.shadow_width !== 0))) {
!(this.fill || (display_shadow && this.shadow_width !== 0))) {
let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0);
......@@ -322,12 +322,12 @@ class GrowRect extends GlowRect {
}
get_borders(t, g) {
let x1 = this.trf.x(t, this.ll.x, this.ll.y);
let x2 = this.trf.x(t, this.ur.x, this.ur.y);
let y1 = this.trf.y(t, this.ll.x, this.ll.y);
let y2 = this.trf.y(t, this.ur.x, this.ur.y);
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
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() {
......@@ -376,7 +376,8 @@ class GrowRect extends GlowRect {
let old_x_right = this.ur_x;
let old_y_low = this.ll_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();
switch (type) {
......
......@@ -120,14 +120,14 @@ class GrowRectRounded extends GrowRect {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y + 0.5) - this.ctx.mw.offset_y;
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x + 0.5) - this.ctx.mw.offset_x;
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 ur_x = Math.max(x1, x2);
......@@ -135,7 +135,7 @@ class GrowRectRounded extends GrowRect {
let ur_y = Math.max(y1, y2);
let amount = Math.floor(this.round_amount / 100 *
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 *
Math.min(ur_x - ll_x, ur_y - ll_y) + 0.5);
let display_shadow = ((node !== null && node.shadow !== 0) ||
......@@ -169,7 +169,7 @@ class GrowRectRounded extends GrowRect {
this.ctx.gdraw.arc(ur_x - 2 * amount, ll_y, 2 * amount, 2 *
amount, 0, 90, drawtype, true, 0);
} 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;
if (this.gradient_contrast >= 0) {
......@@ -244,7 +244,7 @@ class GrowRectRounded extends GrowRect {
2 * amount, ur_y - ll_y - 2 * amount, drawtype, true, 0);
}
} 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;
if (this.gradient_contrast >= 0) {
......@@ -268,7 +268,7 @@ class GrowRectRounded extends GrowRect {
}
}
}
if (this.border !== 0 || this.fill === 0) {
if (this.border !== 0 || !this.fill) {
let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0);
......
......@@ -22,7 +22,7 @@ class GrowScrollBar extends GrowRect {
this.ur.y = y + h;
this.draw_type = border_d_type;
this.line_width = line_width;
this.fill = 1;
this.fill = true;
this.border = 1;
this.shadow = 0;
this.fill_drawtype = fill_d_type;
......@@ -48,14 +48,14 @@ class GrowScrollBar extends GrowRect {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
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 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 {
let header_tsize = this.ctx.mw.zoom_factor_y /
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 dy1 = this.trf.y(t, this.ll.x, this.ll.y);
let dx2 = this.trf.x(t, this.ur.x, this.ur.y);
let dy2 = this.trf.y(t, this.ur.x, this.ur.y);
dx1 = Math.min(dx1, dx2);
dx2 = Math.max(dx1, dx2);
dy1 = Math.min(dy1, dy2);
dy2 = Math.max(dy1, dy2);
let tmp = Matrix.multiply(t, this.trf);
let d1 = tmp.apply(this.ll);
let d2 = tmp.apply(this.ur);
d1.x = Math.min(d1.x, d2.x);
d2.x = Math.max(d1.x, d2.x);
d1.y = Math.min(d1.y, d2.y);
d2.y = Math.max(d1.y, d2.y);
if (this.v_scrollbar !== null) {
if (this.h_scrollbar === null) {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs));
this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs));
} else {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs) -
this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs) -
this.scrollbar_width);
}
this.v_scrollbar.draw();
......@@ -414,12 +413,12 @@ class GrowTable extends GrowRect {
}
if (this.h_scrollbar !== null) {
if (this.v_scrollbar === null) {
this.h_scrollbar.set_position(dx1 + this.x_left_offs, dy2 -
this.scrollbar_width, dx2 - (dx1 + this.x_left_offs),
this.h_scrollbar.set_position(d1.x + this.x_left_offs, d2.y -
this.scrollbar_width, d2.x - (d1.x + this.x_left_offs),
this.scrollbar_width);
} else {
this.h_scrollbar.set_position(dx1 + this.x_left_offs, dy2 -
this.scrollbar_width, dx2 - (dx1 + this.x_left_offs) -
this.h_scrollbar.set_position(d1.x + this.x_left_offs, d2.y -
this.scrollbar_width, d2.x - (d1.x + this.x_left_offs) -
this.scrollbar_width, this.scrollbar_width);
}
this.h_scrollbar.draw();
......@@ -433,18 +432,18 @@ class GrowTable extends GrowRect {
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 ll_x = Math.floor(dx1 * 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 ur_x = Math.floor(dx2 * 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 ll_x = Math.floor(d1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ll_y = Math.floor(d1.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let ur_x = Math.floor(d2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
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;
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;
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;
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;
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 {
}
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.fill_drawtype, true, 0);
}
......@@ -549,7 +548,7 @@ class GrowTable extends GrowRect {
}
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 -
header_h, this.fill_drawtype, true, 0);
}
......@@ -639,7 +638,7 @@ class GrowTable extends GrowRect {
}
// 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.fill_drawtype, true, 0);
}
......
......@@ -85,7 +85,7 @@ class GrowText extends GlowText {
}
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 /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
......@@ -110,9 +110,12 @@ class GrowText extends GlowText {
let ry1 = 0;
let z_width = 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 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 rot = Math.floor(this.trf.rot(t));
let tmp = Matrix.multiply(t, this.trf);
let p = tmp.apply(this.p);
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) {
rot = rot < 0 ? rot % 360 + 360 : rot % 360;
} else {
......
......@@ -157,21 +157,21 @@ class GrowTrend extends GrowRect {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let tmp = Matrix.multiply(t, this.trf);
let p1 = tmp.apply(this.ll);
let p2 = tmp.apply(this.ur);
let x1 = Math.floor(p1.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 x2 = Math.floor(p2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
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 ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2);
if (this.fill !== 0) {
if (this.fill) {
let grad = this.gradient;
if (this.gradient === Gradient.No &&
(node !== null && node.gradient !== Gradient.No) &&
......@@ -186,7 +186,7 @@ class GrowTrend extends GrowRect {
this.ctx.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype, true, 0);
} 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;
if (this.gradient_contrast >= 0) {
......@@ -211,10 +211,8 @@ class GrowTrend extends GrowRect {
let curvetmp = this.curve.slice(0, this.curve_cnt).filter(e => e !== null);
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.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);
}
......@@ -233,15 +231,16 @@ class GrowTrend extends GrowRect {
if (this.fill_curve !== 0) {
curvetmp.forEach(e => e.fill = 0);
}
let tmp2 = t ? GlowTransform.multiply(t, this.trf) : this.trf;
curvetmp.forEach(e => e.draw(tmp2, highlight, hot, node, colornode));
curvetmp.forEach(e => e.draw(Matrix.multiply(t, this.trf), highlight, hot, node, colornode));
if (this.fill_curve !== 0) {
curvetmp.forEach(e => e.fill = 1);
}
let tmp = Matrix.multiply(t, this.trf);
if (this.display_x_mark1 !== 0) {
let xm1 = Math.floor(this.trf.x(t, this.x_mark1, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let p = tmp.apply(new Point(this.x_mark1, this.ll.y));
let xm1 = Math.floor(p.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
if (xm1 >= ll_x && xm1 <= ur_x) {
drawtype = this.mark1_color;
if (drawtype === DrawType.Inherit) {
......@@ -251,8 +250,8 @@ class GrowTrend extends GrowRect {
}
}
if (this.display_x_mark2 !== 0) {
let xm2 = Math.floor(this.trf.x(t, this.x_mark2, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let p = tmp.apply(new Point(this.x_mark2, this.ll.y));
let xm2 = Math.floor(p.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
if (xm2 >= ll_x && xm2 <= ur_x) {
drawtype = this.mark2_color;
if (drawtype === DrawType.Inherit) {
......@@ -262,14 +261,8 @@ class GrowTrend extends GrowRect {
}
}
if (this.display_y_mark1 !== 0) {
let ym1;
if (t === null) {
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;
}
let p = tmp.apply(new Point(this.ll.x, this.y_mark1));
let ym1 = Math.floor(p.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
if (ym1 >= ll_y && ym1 <= ur_y) {
drawtype = this.mark1_color;
if (drawtype === DrawType.Inherit) {
......@@ -279,14 +272,8 @@ class GrowTrend extends GrowRect {
}
}
if (this.display_y_mark2 !== 0) {
let ym2;
if (t === null) {
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;
}
let p = tmp.apply(new Point(this.ll.x, this.y_mark2));
let ym2 = Math.floor(p.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
if (ym2 >= ll_y && ym2 <= ur_y) {
drawtype = this.mark2_color;
if (drawtype === DrawType.Inherit) {
......
......@@ -117,46 +117,45 @@ class GrowWindow extends GrowRect {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let dx1 = this.trf.x(t, this.ll.x, this.ll.y);
let dy1 = this.trf.y(t, this.ll.x, this.ll.y);
let dx2 = this.trf.x(t, this.ur.x, this.ur.y);
let dy2 = this.trf.y(t, this.ur.x, this.ur.y);
dx1 = Math.min(dx1, dx2);
dx2 = Math.max(dx1, dx2);
dy1 = Math.min(dy1, dy2);
dy2 = Math.max(dy1, dy2);
let tmp = Matrix.multiply(t, this.trf);
let d1 = tmp.apply(this.ll);
let d2 = tmp.apply(this.ur);
d1.x = Math.min(d1.x, d2.x);
d2.x = Math.max(d1.x, d2.x);
d1.y = Math.min(d1.y, d2.y);
d2.y = Math.max(d1.y, d2.y);
if (this.v_scrollbar !== null) {
if (this.h_scrollbar === null) {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs));
this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs));
} else {
this.v_scrollbar.set_position(dx2 - this.scrollbar_width, dy1 +
this.y_low_offs, this.scrollbar_width, dy2 - (dy1 + this.y_low_offs) -
this.v_scrollbar.set_position(d2.x - this.scrollbar_width, d1.y +
this.y_low_offs, this.scrollbar_width, d2.y - (d1.y + this.y_low_offs) -
this.scrollbar_width);
}
this.v_scrollbar.draw(null, 0, 0, null, null);
}
if (this.h_scrollbar !== null) {
if (this.v_scrollbar === null) {
this.h_scrollbar.set_position(dx1, dy2 - this.scrollbar_width, dx2 -
dx1, this.scrollbar_width);
this.h_scrollbar.set_position(d1.x, d2.y - this.scrollbar_width, d2.x -
d1.x, this.scrollbar_width);
} else {
this.h_scrollbar.set_position(dx1, dy2 - this.scrollbar_width, dx2 -
dx1 - this.scrollbar_width, this.scrollbar_width);
this.h_scrollbar.set_position(d1.x, d2.y - this.scrollbar_width, d2.x -
d1.x - this.scrollbar_width, this.scrollbar_width);
}
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_y = Math.floor((dy1 + this.y_low_offs) * this.ctx.mw.zoom_factor_y) -
let ll_x = Math.floor(d1.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ll_y = Math.floor((d1.y + this.y_low_offs) * this.ctx.mw.zoom_factor_y) -
this.ctx.mw.offset_y;
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;
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.windowCtx.mw.window_width =
......@@ -179,7 +178,7 @@ class GrowWindow extends GrowRect {
this.windowCtx.mw.subwindow_scale * this.ctx.mw.zoom_factor_y;
// 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.fill_drawtype, true, 0);
}
......@@ -197,8 +196,8 @@ class GrowWindow extends GrowRect {
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_y = Math.floor(dy2 * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let ur_x = Math.floor(d2.x * this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
let ur_y = Math.floor(d2.y * this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
......@@ -253,7 +252,7 @@ class GrowWindow extends GrowRect {
if (this.windowCtx.background_color !== DrawType.Inherit) {
this.fill_drawtype = this.windowCtx.background_color;
this.original_fill_drawtype = this.fill_drawtype;
this.fill = 1;
this.fill = true;
}
if (this.windowCtx.x0 !== this.windowCtx.x1 &&
this.windowCtx.y0 !== this.windowCtx.y1) {
......@@ -547,7 +546,7 @@ class GrowWindow extends GrowRect {
}
this.fill_drawtype = DrawType.Inherit;
this.original_fill_drawtype = this.fill_drawtype;
this.fill = 0;
this.fill = false;
}
this.file_name = this.input_file_name;
this.new_ctx();
......
......@@ -20,7 +20,7 @@
<button id="logout_button" type="button" class="leftmenu-button">Logout</button>
</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="pwr.ts"></script>
<script type="text/babel" src="gdh.ts"></script>
......
......@@ -33,7 +33,7 @@
</div>
</div>
<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="cli.ts"></script>
<script type="text/babel" src="gdh.ts"></script>
......
......@@ -64,12 +64,11 @@
#include "rt_io_pnak_locals.h"
#include "rt_pn_iface.h"
// static int count;
static pwr_tStatus IoAgentInit(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 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
......@@ -345,6 +344,21 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
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.
\*----------------------------------------------------------------------------*/
......@@ -352,4 +366,4 @@ static pwr_tStatus IoAgentClose(io_tCtx ctx, io_sAgent* ap)
pwr_dExport pwr_BindIoMethods(PnControllerSoftingPNAK)
= { pwr_BindIoMethod(IoAgentInit), pwr_BindIoMethod(IoAgentRead),
pwr_BindIoMethod(IoAgentWrite), pwr_BindIoMethod(IoAgentClose),
pwr_NullMethod };
pwr_BindIoMethod(IoAgentSwap), pwr_NullMethod };
......@@ -21,6 +21,7 @@ source_dirs := $(co_source)
-include jsw_local.mk
vpath %.js $(co_source)
vpath %.ts $(co_source)
vpath %.html $(co_source)
vpath %.png $(co_source)
......@@ -33,6 +34,15 @@ js_sources := $(sort \
) \
)
ts_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.ts) \
), $(notdir $(file)) \
) \
)
html_sources := $(sort \
$(foreach file, \
$(foreach dir, \
......@@ -61,10 +71,12 @@ css_sources := $(sort \
)
export_js := $(addprefix $(web_dir)/,$(js_sources))
export_ts := $(addprefix $(web_dir)/,$(ts_sources))
export_html := $(addprefix $(web_dir)/,$(html_sources))
export_png := $(addprefix $(web_dir)/,$(png_sources))
export_css := $(addprefix $(web_dir)/,$(css_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_png := $(patsubst %.png,clean_%.png, $(png_sources))
clean_css := $(patsubst %.css,clean_%.css, $(css_sources))
......@@ -75,13 +87,13 @@ all : init copy lib exe | silent
init :
copy : $(export_js) $(export_html) $(export_png) $(export_css) | silent
copy : $(export_js) $(export_ts) $(export_html) $(export_png) $(export_css) | silent
lib :
exe :
clean : $(clean_js) $(clean_html) $(clean_png) $(clean_css)
clean : $(clean_js) $(clean_ts) $(clean_html) $(clean_png) $(clean_css)
clean_copy: $(clean)
......@@ -94,6 +106,10 @@ $(clean_js) : clean_%.js : %.js
@ echo "Removing js: $(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
@ echo "Removing html: $(web_dir)/$*.html"
@ $(rm) $(rmflags) $(web_dir)/$*.html
......
......@@ -222,6 +222,8 @@ void wb_pkg::readConfig()
n.push_back(pboot);
// Read bootfile, get plc and volumes
vollist = 0;
volnamelist = 0;
sts = lfu_ReadBootFile(fname, &date, systemname, systemgroup, &vollist,
&volnamelist, &volcount, &plclist, &plccount);
if (EVEN(sts))
......@@ -294,8 +296,10 @@ void wb_pkg::readConfig()
}
}
free(volnamelist);
free(vollist);
if (volnamelist)
free(volnamelist);
if (vollist)
free(vollist);
} catch (wb_error& e) {
if (e.what() == std::string("No such node"))
......
......@@ -964,9 +964,9 @@ void CoWowQt::SetParent(QWidget* 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);
} else {
printer->setOrientation(QPrinter::Portrait);
......@@ -984,7 +984,18 @@ typedef struct {
int offset_y;
} 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::TextAntialiasing, true);
......@@ -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->window_width = image->width();
ctx->window_height = image->height();
widget->resize(printer->pageRect().width(), printer->pageRect().height() - GetPrintHeaderMargin(painter));
ctx->window_width = widget->width();
ctx->window_height = widget->height();
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
ctx->zoom_factor = settings->zoom_factor;
......@@ -1006,28 +1019,14 @@ static void EndPrint(flow_tCtx ctx, ctx_settings* settings)
ctx->window_height = settings->window_height;
ctx->offset_x = settings->offset_x;
ctx->offset_y = settings->offset_y;
widget->resize(ctx->window_width, ctx->window_height);
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->change_scrollbar();
ctx->set_dirty();
}
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 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) {
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) {
double zoom = qMin(
ctx->window_width / (ur_x - ll_x + 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
double width_backup = ctx->window_width;
double height_backup = ctx->window_height;
int nav_backup = ctx->no_nav;
ctx->window_width = (ur_x - ll_x) * 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);
......@@ -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->setClipping(true);
painter->drawImage(0, 0, *image);
widget->render(painter);
painter->setClipping(false);
ctx->window_width = width_backup;
ctx->window_height = height_backup;
ctx->no_nav = nav_backup;
}
#include <assert.h>
......@@ -1098,18 +1092,15 @@ pwr_tStatus CoWowQt::CreateBrowPrintDialogQt(const char* title, void* brow_ctx,
assert(dynamic_cast<QtScrollWidgetFlow*>(w) != NULL);
QtScrollWidgetFlow* widget = dynamic_cast<QtScrollWidgetFlow*>(w);
QImage imageTmp(widget->image);
// TODO: Change FlowDraw so that pixmaps can be scaled up in size.
// Then, change this to QPrinter::HighResolution.
QPrinter printer;
if (PrintDialog(&printer, &imageTmp, widget)) {
if (PrintDialog(&printer, widget)) {
brow_tCtx ctx = (brow_tCtx)brow_ctx;
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
// 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
......@@ -1122,22 +1113,21 @@ pwr_tStatus CoWowQt::CreateBrowPrintDialogQt(const char* title, void* brow_ctx,
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++) {
ll_y = i * height;
ur_y = ll_y + height;
if (ll_y > ctx->y_high)
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) {
printer.newPage();
}
}
widget->image = imageTmp;
EndPrint(ctx, &settings);
EndPrint(ctx, &settings, widget);
}
return WOW__SUCCESS;
}
......@@ -1150,17 +1140,14 @@ pwr_tStatus CoWowQt::CreateFlowPrintDialogQt(const char* title, void* flow_ctx,
assert(dynamic_cast<QtScrollWidgetFlow*>(w) != NULL);
QtScrollWidgetFlow* widget = dynamic_cast<QtScrollWidgetFlow*>(w);
QImage imageTmp(widget->image);
QPrinter printer(QPrinter::HighResolution);
if (PrintDialog(&printer, &imageTmp, widget)) {
if (PrintDialog(&printer, widget)) {
flow_tCtx ctx = (flow_tCtx)flow_ctx;
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->image));
ctx_settings settings = BeginPrint(&printer, &painter, ctx, widget);
int num_pages = 0;
for (int i = 0; i < ctx->a.size(); i++) {
......@@ -1174,7 +1161,7 @@ pwr_tStatus CoWowQt::CreateFlowPrintDialogQt(const char* title, void* flow_ctx,
if (ctx->a[i]->type() == flow_eObjectType_Node) {
FlowNode* elem = ((FlowNode*)ctx->a[i]);
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) {
printer.newPage();
......@@ -1184,8 +1171,7 @@ pwr_tStatus CoWowQt::CreateFlowPrintDialogQt(const char* title, void* flow_ctx,
}
}
widget->image = imageTmp;
EndPrint(ctx, &settings);
EndPrint(ctx, &settings, widget);
}
return WOW__SUCCESS;
}
This diff is collapsed.
......@@ -42,21 +42,13 @@
#include <gtk/gtk.h>
#include "flow_draw.h"
class DrawWind {
public:
GdkWindow* window = NULL;
GdkPixmap* buffer = NULL;
};
class FlowDrawGtk : public FlowDraw {
public:
GtkWidget* toplevel;
GtkWidget* nav_shell;
GtkWidget* nav_toplevel;
GdkDisplay* display;
DrawWind m_wind;
DrawWind nav_wind;
DrawWind* w = NULL;
GdkWindow* w = NULL;
GdkScreen* screen;
GdkGC* gc;
GdkGC* gc_erase;
......@@ -75,7 +67,6 @@ public:
GdkColor color_vect[20];
int color_vect_cnt;
int closing_down;
guint redraw_timer;
FlowDrawGtk(GtkWidget* toplevel, void** flow_ctx,
int (*init_proc)(GtkWidget* w, FlowCtx* ctx, void* client_data),
......@@ -85,16 +76,15 @@ public:
void event_handler(FlowCtx* ctx, GdkEvent event);
void enable_event(FlowCtx* ctx, flow_eEvent event, flow_eEventType event_type,
int (*event_cb)(FlowCtx* ctx, flow_tEvent event));
void create_buffer(DrawWind *wind);
void create_buffer(void *wind);
void clear();
void get_window_size(DrawWind *wind, int* width, int* height);
void set_window_size(DrawWind *wind, int width, int height);
void get_window_size(void *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 start_redraw_timer();
void cancel_redraw_timer();
void set_dirty(void *wind);
void rect(int x, int y, int width, int height, flow_eDrawType gc_type,
int fill, int idx, int highlight = 0, int dimmed = 0);
......@@ -118,7 +108,7 @@ public:
void set_timer(FlowCtx* ctx, int time_ms, void (*callback_func)(FlowCtx* ctx),
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,
int idx, int* width, int* height, double size);
void delete_secondary_ctx(FlowCtx* ctx);
......
This diff is collapsed.
......@@ -46,20 +46,12 @@
#include <QPainter>
#include <QWidget>
class DrawWind {
public:
QWidget* window = NULL;
QImage* buffer = NULL;
};
class FlowDrawQt : private QObject, public FlowDraw {
Q_OBJECT
public:
QWidget* toplevel;
DrawWind m_wind;
DrawWind nav_wind;
DrawWind* w = NULL;
QWidget* w = NULL;
QColor background;
QColor foreground;
QTimer* timer_id;
......@@ -79,11 +71,12 @@ public:
void clear();
void get_window_size(DrawWind *wind, int* width, int* height);
void set_window_size(DrawWind *wind, int width, int height);
void get_window_size(void *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 set_dirty(void *w);
void rect(int x, int y, int width, int height, flow_eDrawType gc_type,
int fill, int idx, int highlight, int dimmed);
......@@ -110,7 +103,7 @@ public:
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, int idx, int* width, int* height, double size);
......@@ -137,13 +130,13 @@ public:
void* flow_ctx, int page_border, int* sts);
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 cancel_event_timer(FlowCtx* ctx);
void (*draw_timer_callback_func)(FlowCtx* ctx);
QTimer* draw_timer_id;
QPainter painter;
public slots:
bool event_timer_cb();
......
......@@ -47,23 +47,15 @@
#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,
int (*init_proc)(FlowCtx* ctx, void* client_data), void* client_data,
int (*init_proc2)(QWidget* w, FlowCtx* ctx, void* client_data))
{
createBuffer(size());
setFocusPolicy(Qt::ClickFocus);
setMouseTracking(true);
if (getenv("DISPLAY")[0] != ':') {
setAttribute(Qt::WA_PaintOnScreen, true);
}
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
......@@ -80,9 +72,11 @@ QWidget* QtScrollWidgetFlow::initScroll(unsigned int eCtxType,
int (*init_proc)(FlowCtx* ctx, void* client_data), void* client_data,
int (*init_proc2)(QWidget* w, FlowCtx* ctx, void* client_data))
{
createBuffer(size());
setFocusPolicy(Qt::ClickFocus);
setMouseTracking(true);
if (getenv("DISPLAY")[0] != ':') {
setAttribute(Qt::WA_PaintOnScreen, true);
}
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
......@@ -113,9 +107,11 @@ QWidget* QtScrollWidgetFlow::initScroll(unsigned int eCtxType,
void QtScrollWidgetFlow::init(unsigned int eCtxType, QWidget* main)
{
createBuffer(size());
setFocusPolicy(Qt::ClickFocus);
setMouseTracking(true);
if (getenv("DISPLAY")[0] != ':') {
setAttribute(Qt::WA_PaintOnScreen, true);
}
this->ctxType = eCtxType;
this->scroll_timerid = new QTimer(this);
is_navigator = 1;
......@@ -220,10 +216,15 @@ void QtScrollWidgetFlow::scroll_v_released(int value)
void QtScrollWidgetFlow::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
QRect dirtyRect = event->rect();
painter.drawImage(dirtyRect, image, dirtyRect);
QWidget::paintEvent(event);
FlowCtx* ctx = (FlowCtx*)parent_ctx;
draw_ctx->begin(this);
if (ctx->mw == this) {
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)
......@@ -248,19 +249,16 @@ void QtScrollWidgetFlow::handleEvent(QEvent* event)
if (parent_ctx) {
FlowCtx* ctx = (FlowCtx*)parent_ctx;
FlowDrawQt* drawer = ((FlowDrawQt*)ctx->fdraw);
if (event->type() == QEvent::MouseMove) {
drawer->m_wind.window->update();
if (event->type() == QEvent::Resize || event->type() == QEvent::Show) {
ctx->set_dirty();
}
drawer->event_handler((FlowCtx*)parent_ctx, event, this);
drawer->event_handler(ctx, event, this);
}
}
}
bool QtScrollWidgetFlow::event(QEvent* event)
{
if (event->type() == QEvent::Resize) {
createBuffer(((QResizeEvent*)event)->size());
}
if (!is_realized && event->type() == QEvent::Show) {
realize();
is_realized = true;
......
......@@ -86,8 +86,6 @@ public:
int destroyed;
QScrollArea* form;
QImage image;
virtual void handleEvent(QEvent* event);
protected:
......@@ -101,9 +99,6 @@ protected:
bool is_realized;
unsigned int ctxType;
private:
void createBuffer(QSize size);
public slots:
void scroll_h_action(int value);
void scroll_v_action(int value);
......@@ -112,4 +107,4 @@ public slots:
void scroll_callback_cb();
};
#endif // FLOW_SCROLL_WIDGET_QT_H
\ No newline at end of file
#endif // FLOW_SCROLL_WIDGET_QT_H
......@@ -915,20 +915,6 @@ void FlowAnnot::nav_erase(void* pos, void* node)
int FlowAnnot::event_handler(
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;
}
......@@ -1109,8 +1095,7 @@ void FlowAnnot::open_annotation_input(void* pos, void* node)
int x, width_pix, height_pix;
double width, height;
int idx = int(ctx->zoom_factor / ctx->base_zoom_factor * (text_size + 4) - 4);
idx = MAX(0, idx);
idx = MIN(idx, DRAW_TYPE_SIZE - 1);
idx = CLAMP(idx, 0, DRAW_TYPE_SIZE - 1);
switch (annot_type) {
case flow_eAnnotType_OneLine:
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,
void FlowAnnotPixmap::move(
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.y = y;
zoom();
nav_zoom();
ctx->set_dirty();
}
void FlowAnnotPixmap::shift(void* pos, double delta_x, double delta_y,
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.y += delta_y;
zoom();
nav_zoom();
ctx->set_dirty();
}
void FlowAnnotPixmap::configure_annotations(void* pos, void* node)
......
......@@ -170,16 +170,10 @@ void FlowArc::nav_erase(void* pos, void* node)
int FlowArc::event_handler(
void* pos, flow_eEvent event, int x, int y, void* node)
{
FlowPoint* p;
p = (FlowPoint*)pos;
if (angle2 == 360 && ll.z_x + ((FlowPoint*)pos)->z_x - ctx->offset_x <= x
return (angle2 == 360 && ll.z_x + ((FlowPoint*)pos)->z_x - ctx->offset_x <= x
&& x <= ur.z_x + ((FlowPoint*)pos)->z_x - ctx->offset_x
&& ll.z_y + ((FlowPoint*)pos)->z_y - ctx->offset_y <= y
&& y <= ur.z_y + ((FlowPoint*)pos)->z_y - ctx->offset_y) {
return 1;
} else
return 0;
&& y <= ur.z_y + ((FlowPoint*)pos)->z_y - ctx->offset_y);
}
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,
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.y = y1;
ur.x = x2;
......@@ -206,19 +204,20 @@ void FlowArc::move(void* pos, double x1, double y1, double x2, double y2,
angle2 = ang2;
zoom();
nav_zoom();
ctx->set_dirty();
}
void FlowArc::shift(void* pos, double delta_x, double delta_y, int highlight,
int dimmed, int hot)
{
if (!feq(delta_x, 0.0) || !feq(delta_y, 0.0)) {
ctx->set_dirty();
}
ll.x += delta_x;
ll.y += delta_y;
ur.x += delta_x;
ur.y += delta_y;
zoom();
nav_zoom();
ctx->set_dirty();
}
std::ostream& operator<<(std::ostream& o, const FlowArc a)
......
......@@ -331,10 +331,7 @@ void FlowArray::brow_close(void* ctx, FlowArrayElem* element)
{
int i;
int idx = 0;
int found;
FlowArrayElem* e;
found = 0;
int found = 0;
for (i = 0; i < a_size; i++) {
if (*(a + i) == element) {
idx = i;
......@@ -355,7 +352,6 @@ void FlowArray::brow_close(void* ctx, FlowArrayElem* element)
return;
for (i = idx + 1; i < next_idx; i++) {
e = a[i];
((FlowCtx*)ctx)->delete_object(a[i]);
i--;
next_idx--;
......
......@@ -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,
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 (y1 > y2) {
p1.x = x2 + arrow_width / 2;
......@@ -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.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.y = y2;
zoom();
nav_zoom();
ctx->set_dirty();
}
void FlowArrow::shift(void* pos, double delta_x, double delta_y, int highlight,
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.y += delta_y;
p1.x += delta_x;
......@@ -291,7 +299,6 @@ void FlowArrow::shift(void* pos, double delta_x, double delta_y, int highlight,
p2.y += delta_y;
zoom();
nav_zoom();
ctx->set_dirty();
}
int FlowArrow::event_handler(
......
......@@ -44,17 +44,10 @@
int BrowCtx::insert(FlowArrayElem* element, FlowArrayElem* destination,
flow_eDest destination_code)
{
int sts;
double y;
sts = a.brow_insert(element, destination, destination_code);
int sts = a.brow_insert(element, destination, destination_code);
if (!sts)
return sts;
if (destination)
y = ((FlowNode*)destination)->y_low;
else
y = 0;
configure();
return 1;
}
......@@ -143,30 +136,27 @@ void BrowCtx::zoom(double factor)
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)
return 0;
double 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);
width = 0.70 * height;
double height = 60 * (ur_y - ll_y);
double width = 0.70 * height;
if (width < ur_x - ll_x) {
// Portrait
height = 40 * (ur_y - ll_y);
width = height / 0.70;
}
int sts;
current_print = new FlowPscript(filename, this, 1, &sts);
if (EVEN(sts)) {
delete current_print;
return 0;
}
for (i = 0;; i++) {
for (int i = 0;; i++) {
ll_y = i * height;
ur_y = ll_y + height;
ll_x = 0;
......@@ -218,21 +208,17 @@ void BrowCtx::print_draw_page(void* context, const char* title, int page,
void BrowCtx::print_get_pages(
flow_eOrientation orientation, double scale, int* pages)
{
double ll_x, ll_y, ur_x, ur_y;
double width, height;
if (a.size() == 0) {
*pages = 0;
return;
}
double 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;
width = 0.70 * height;
double height = 60 * (ur_y - ll_y) * scale;
if (orientation == flow_eOrientation_Landscape) {
// Portrait
height = 35 * (ur_y - ll_y) * scale;
width = height / 0.70;
}
*pages = int(y_high / height + 1);
......@@ -292,14 +278,11 @@ void BrowCtx::center_object(FlowArrayElem* object, double factor)
int BrowCtx::get_first_visible(FlowArrayElem** element)
{
double ll_x, ll_y, ur_x, ur_y;
double window_low, window_high;
int i;
double window_low = double(offset_y) / zoom_factor;
double window_high = double(offset_y + window_height) / zoom_factor;
window_low = double(offset_y) / zoom_factor;
window_high = double(offset_y + window_height) / zoom_factor;
for (i = 0; i < a.size(); i++) {
for (int i = 0; i < a.size(); i++) {
double 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) {
*element = a[i];
......@@ -311,14 +294,11 @@ int BrowCtx::get_first_visible(FlowArrayElem** element)
int BrowCtx::get_last_visible(FlowArrayElem** element)
{
double ll_x, ll_y, ur_x, ur_y;
double window_low, window_high;
int i;
window_low = double(offset_y) / zoom_factor;
window_high = double(offset_y + window_height) / zoom_factor;
double window_low = double(offset_y) / zoom_factor;
double 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);
if (ur_y <= window_high || ll_y <= window_low) {
*element = a[i];
......
......@@ -54,10 +54,6 @@ public:
void configure();
void change_scrollbar();
void zoom(double factor);
void unzoom()
{
zoom(base_zoom_factor / zoom_factor);
}
int print(char* filename);
void print_draw_page(void* context, const char* title, int page,
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()
{
}
int FlowDraw::begin(DrawWind *wind)
int FlowDraw::begin(void *wind)
{
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)
ctx->tiptext->active = true;
ctx->set_dirty();
ctx->redraw_if_dirty();
}
FlowTipText::~FlowTipText()
{
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