Skip to content

Commit 0825a3c

Browse files
committed
Add layout feature
1 parent 4f636a5 commit 0825a3c

14 files changed

+414
-428
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.2)
22

3-
project(algorithm-visualizer VERSION 2.1.0)
3+
project(algorithm-visualizer VERSION 2.3.0)
44

55
set(CMAKE_CXX_STANDARD 11)
66

include/Array1DTracer.h

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,17 @@
11
#ifndef CPP_ARRAY1DTRACER_H
22
#define CPP_ARRAY1DTRACER_H
33

4-
#include "Tracer.h"
4+
#include "BaseArray1DTracer.h"
55
#include "ChartTracer.h"
66

7-
class Array1DTracer : public Tracer {
7+
class Array1DTracer : public BaseArray1DTracer {
88
public:
9-
Array1DTracer(string title = "") : Tracer("Array1DTracer", title) {
9+
Array1DTracer(const string &title = "", const string &className = "Array1DTracer") : BaseArray1DTracer(title,
10+
className) {
1011
}
1112

12-
Array1DTracer set(json array1d) {
13-
addTrace(key, "set", {array1d});
14-
return *this;
15-
}
16-
17-
Array1DTracer set() {
18-
addTrace(key, "set", {});
19-
return *this;
20-
}
21-
22-
Array1DTracer reset() {
23-
addTrace(key, "reset", {});
24-
return *this;
25-
}
26-
27-
Array1DTracer delay() {
28-
addTrace(key, "delay", {});
29-
return *this;
30-
}
31-
32-
Array1DTracer patch(json x, json v) {
33-
addTrace(key, "patch", {x, v});
34-
return *this;
35-
}
36-
37-
Array1DTracer depatch(json x) {
38-
addTrace(key, "depatch", {x});
39-
return *this;
40-
}
41-
42-
Array1DTracer select(json x) {
43-
addTrace(key, "select", {x});
44-
return *this;
45-
}
46-
47-
Array1DTracer select(json sx, json ex) {
48-
addTrace(key, "select", {sx, ex});
49-
return *this;
50-
}
51-
52-
Array1DTracer deselect(json x) {
53-
addTrace(key, "deselect", {x});
54-
return *this;
55-
}
56-
57-
Array1DTracer deselect(json sx, json ex) {
58-
addTrace(key, "deselect", {sx, ex});
59-
return *this;
60-
}
61-
62-
Array1DTracer chart(ChartTracer chartTracer) {
63-
addTrace(key, "chart", {chartTracer.key});
64-
return *this;
13+
void chart(const ChartTracer &chartTracer) {
14+
command("chart", {chartTracer.key});
6515
}
6616
};
6717

include/Array2DTracer.h

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,77 +5,55 @@
55

66
class Array2DTracer : public Tracer {
77
public:
8-
Array2DTracer(string title = "") : Tracer("Array2DTracer", title) {
8+
Array2DTracer(const string &title = "", const string &className = "Array2DTracer") : Tracer(title, className) {
99
}
1010

11-
Array2DTracer set(json array2d) {
12-
addTrace(key, "set", {array2d});
13-
return *this;
11+
void set(const json &array2d) {
12+
command("set", {array2d});
1413
}
1514

16-
Array2DTracer set() {
17-
addTrace(key, "set", {});
18-
return *this;
15+
void patch(int x, int y, const json &v) {
16+
command("patch", {x, y, v});
1917
}
2018

21-
Array2DTracer reset() {
22-
addTrace(key, "reset", {});
23-
return *this;
19+
void patch(int x, int y) {
20+
command("patch", {x, y});
2421
}
2522

26-
Array2DTracer delay() {
27-
addTrace(key, "delay", {});
28-
return *this;
23+
void depatch(int x, int y) {
24+
command("depatch", {x, y});
2925
}
3026

31-
Array2DTracer patch(json x, json y, json v) {
32-
addTrace(key, "patch", {x, y, v});
33-
return *this;
27+
void select(int sx, int sy, int ex, int ey) {
28+
command("select", {sx, sy, ex, ey});
3429
}
3530

36-
Array2DTracer depatch(json x, json y) {
37-
addTrace(key, "depatch", {x, y});
38-
return *this;
31+
void select(int x, int y) {
32+
command("select", {x, y});
3933
}
4034

41-
Array2DTracer select(json x, json y) {
42-
addTrace(key, "select", {x, y});
43-
return *this;
35+
void selectRow(int x, int sy, int ey) {
36+
command("selectRow", {x, sy, ey});
4437
}
4538

46-
Array2DTracer select(json sx, json sy, json ex, json ey) {
47-
addTrace(key, "select", {sx, sy, ex, ey});
48-
return *this;
39+
void selectCol(int y, int sx, int ex) {
40+
command("selectCol", {y, sx, ex});
4941
}
5042

51-
Array2DTracer selectRow(json x, json sy, json ey) {
52-
addTrace(key, "selectRow", {x, sy, ey});
53-
return *this;
43+
void deselect(int sx, int sy, int ex, int ey) {
44+
command("deselect", {sx, sy, ex, ey});
5445
}
5546

56-
Array2DTracer selectCol(json y, json sx, json ex) {
57-
addTrace(key, "selectCol", {y, sx, ex});
58-
return *this;
47+
void deselect(int x, int y) {
48+
command("deselect", {x, y});
5949
}
6050

61-
Array2DTracer deselect(json x, json y) {
62-
addTrace(key, "deselect", {x, y});
63-
return *this;
51+
void deselectRow(int x, int sy, int ey) {
52+
command("deselectRow", {x, sy, ey});
6453
}
6554

66-
Array2DTracer deselect(json sx, json sy, json ex, json ey) {
67-
addTrace(key, "deselect", {sx, sy, ex, ey});
68-
return *this;
69-
}
70-
71-
Array2DTracer deselectRow(json x, json sy, json ey) {
72-
addTrace(key, "deselectRow", {x, sy, ey});
73-
return *this;
74-
}
75-
76-
Array2DTracer deselectCol(json y, json sx, json ex) {
77-
addTrace(key, "deselectCol", {y, sx, ex});
78-
return *this;
55+
void deselectCol(int y, int sx, int ex) {
56+
command("deselectCol", {y, sx, ex});
7957
}
8058
};
8159

include/BaseArray1DTracer.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#ifndef CPP_BASEARRAY1DTRACER_H
2+
#define CPP_BASEARRAY1DTRACER_H
3+
4+
#include "Array2DTracer.h"
5+
6+
class BaseArray1DTracer : public Array2DTracer {
7+
public:
8+
BaseArray1DTracer(const string &title = "", const string &className = "BaseArray1DTracer") : Array2DTracer(title,
9+
className) {
10+
}
11+
12+
void set(const json &array1d) {
13+
command("set", {array1d});
14+
}
15+
16+
void patch(int x, const json &v) {
17+
command("patch", {x, v});
18+
}
19+
20+
void patch(int x) {
21+
command("patch", {x});
22+
}
23+
24+
void depatch(int x) {
25+
command("depatch", {x});
26+
}
27+
28+
void select(int sx, int ex) {
29+
command("select", {sx, ex});
30+
}
31+
32+
void select(int x) {
33+
command("select", {x});
34+
}
35+
36+
void deselect(int sx, int ex) {
37+
command("deselect", {sx, ex});
38+
}
39+
40+
void deselect(int x) {
41+
command("deselect", {x});
42+
}
43+
};
44+
45+
#endif

include/ChartTracer.h

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,16 @@
11
#ifndef CPP_CHARTTRACER_H
22
#define CPP_CHARTTRACER_H
33

4-
#include "Tracer.h"
4+
#include "Array1DTracer.h"
55

6-
class ChartTracer : public Tracer {
6+
class ChartTracer : public BaseArray1DTracer {
77
public:
8-
ChartTracer(string title = "") : Tracer("ChartTracer", title) {
8+
ChartTracer(const string &title = "", const string &className = "ChartTracer") : BaseArray1DTracer(title,
9+
className) {
910
}
1011

11-
ChartTracer set(json array1d) {
12-
addTrace(key, "set", {array1d});
13-
return *this;
14-
}
15-
16-
ChartTracer set() {
17-
addTrace(key, "set", {});
18-
return *this;
19-
}
20-
21-
ChartTracer reset() {
22-
addTrace(key, "reset", {});
23-
return *this;
24-
}
25-
26-
ChartTracer delay() {
27-
addTrace(key, "delay", {});
28-
return *this;
29-
}
30-
31-
ChartTracer patch(json x, json v) {
32-
addTrace(key, "patch", {x, v});
33-
return *this;
34-
}
35-
36-
ChartTracer depatch(json x) {
37-
addTrace(key, "depatch", {x});
38-
return *this;
39-
}
40-
41-
ChartTracer select(json x) {
42-
addTrace(key, "select", {x});
43-
return *this;
44-
}
45-
46-
ChartTracer select(json sx, json ex) {
47-
addTrace(key, "select", {sx, ex});
48-
return *this;
49-
}
50-
51-
ChartTracer deselect(json x) {
52-
addTrace(key, "deselect", {x});
53-
return *this;
54-
}
55-
56-
ChartTracer deselect(json sx, json ex) {
57-
addTrace(key, "deselect", {sx, ex});
58-
return *this;
59-
}
60-
61-
ChartTracer chart(ChartTracer chartTracer) {
62-
addTrace(key, "chart", {chartTracer.key});
63-
return *this;
12+
void chart(const ChartTracer &chartTracer) {
13+
command("chart", {chartTracer.key});
6414
}
6515
};
6616

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy