mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-04 04:28:20 +00:00
Add graph.body and graph.bubble config vars, move sin/cos into r_util ##graph
This commit is contained in:
parent
ef1b1f5dd6
commit
027fd8c494
@ -540,17 +540,18 @@ R_API void r_cons_canvas_circle(RConsCanvas *c, int x, int y, int w, int h, cons
|
||||
if (color) {
|
||||
c->attr = color;
|
||||
}
|
||||
int i;
|
||||
double xfactor = 1; //(double)w / (double)h;
|
||||
double yfactor = (double)h / 24; // 0.8; // 24 10
|
||||
double size = w;
|
||||
float a = 0.0;
|
||||
double s = size / 2;
|
||||
while (a < (2 * PI)) {
|
||||
double cx = s * cos (a) + (size / 2);
|
||||
double cy = s * sin (a) + (size / 4);
|
||||
double sa = r_num_sin (a);
|
||||
double ca = r_num_cos (a);
|
||||
double cx = s * ca + (size / 2);
|
||||
double cy = s * sa + (size / 4);
|
||||
int X = x + (xfactor * cx) - 2;
|
||||
int Y = y + (yfactor * cy);
|
||||
int Y = y + ((yfactor/2) * cy);
|
||||
if (G (X, Y)) {
|
||||
W ("=");
|
||||
}
|
||||
@ -562,11 +563,6 @@ R_API void r_cons_canvas_circle(RConsCanvas *c, int x, int y, int w, int h, cons
|
||||
}
|
||||
|
||||
R_API void r_cons_canvas_box(RConsCanvas *c, int x, int y, int w, int h, const char *color) {
|
||||
#if 0
|
||||
// for testing bubble graphs
|
||||
r_cons_canvas_circle(c, x, y, w, h, color);
|
||||
return;
|
||||
#endif
|
||||
const char *hline = useUtf8? RUNECODESTR_LINE_HORIZ : "-";
|
||||
const char *vtmp = useUtf8? RUNECODESTR_LINE_VERT : "|";
|
||||
RStrBuf *vline = r_strbuf_new (NULL);
|
||||
|
@ -323,7 +323,7 @@ static void normal_RANode_print(const RAGraph *g, const RANode *n, int cur) {
|
||||
char *body;
|
||||
int x, y;
|
||||
const bool showTitle = g->show_node_titles;
|
||||
const bool showBody = true; // g->show_node_body
|
||||
const bool showBody = g->show_node_body;
|
||||
|
||||
x = n->x + g->can->sx;
|
||||
y = n->y + g->can->sy;
|
||||
@ -400,10 +400,18 @@ static void normal_RANode_print(const RAGraph *g, const RANode *n, int cur) {
|
||||
// TODO: check if node is traced or not and show proper color
|
||||
// This info must be stored inside RANode* from RCore*
|
||||
RCons *cons = r_cons_singleton ();
|
||||
if (cur) {
|
||||
r_cons_canvas_box (g->can, n->x, n->y, n->w, n->h, cons->context->pal.graph_box2);
|
||||
if (g->show_node_bubble) {
|
||||
if (cur) {
|
||||
r_cons_canvas_circle (g->can, n->x, n->y, n->w, n->h, cons->context->pal.graph_box2);
|
||||
} else {
|
||||
r_cons_canvas_circle(g->can, n->x, n->y, n->w, n->h, cons->context->pal.graph_box);
|
||||
}
|
||||
} else {
|
||||
r_cons_canvas_box (g->can, n->x, n->y, n->w, n->h, cons->context->pal.graph_box);
|
||||
if (cur) {
|
||||
r_cons_canvas_box (g->can, n->x, n->y, n->w, n->h, cons->context->pal.graph_box2);
|
||||
} else {
|
||||
r_cons_canvas_box (g->can, n->x, n->y, n->w, n->h, cons->context->pal.graph_box);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3545,6 +3553,7 @@ static void agraph_init(RAGraph *g) {
|
||||
g->is_instep = false;
|
||||
g->need_reload_nodes = true;
|
||||
g->show_node_titles = true;
|
||||
g->show_node_body = true;
|
||||
g->force_update_seek = true;
|
||||
g->graph = r_graph_new ();
|
||||
g->nodes = sdb_new0 ();
|
||||
@ -4079,6 +4088,8 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int
|
||||
g->can = can;
|
||||
g->movspeed = r_config_get_i (core->config, "graph.scroll");
|
||||
g->show_node_titles = r_config_get_i (core->config, "graph.ntitles");
|
||||
g->show_node_body = r_config_get_i (core->config, "graph.body");
|
||||
g->show_node_bubble = r_config_get_i (core->config, "graph.bubble");
|
||||
g->on_curnode_change = (RANodeCallback) seek_to_node;
|
||||
g->on_curnode_change_data = core;
|
||||
g->edgemode = r_config_get_i (core->config, "graph.edges");
|
||||
|
@ -3363,6 +3363,8 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETI ("graph.scroll", 5, "Scroll speed in ascii-art graph");
|
||||
SETPREF ("graph.invscroll", "false", "Invert scroll direction in ascii-art graph");
|
||||
SETPREF ("graph.title", "", "Title of the graph");
|
||||
SETPREF ("graph.body", "true", "Show body of the nodes in the graph");
|
||||
SETPREF ("graph.bubble", "false", "Show nodes as bubbles");
|
||||
SETPREF ("graph.ntitles", "true", "Display title of node");
|
||||
SETPREF ("graph.gv.node", "", "Graphviz node style. (color=gray, style=filled shape=box)");
|
||||
SETPREF ("graph.gv.edge", "", "Graphviz edge style. (arrowhead=\"vee\")");
|
||||
|
@ -67,6 +67,8 @@ typedef struct r_ascii_graph_t {
|
||||
void *on_curnode_change_data;
|
||||
bool dummy; // enable the dummy nodes for better layouting
|
||||
bool show_node_titles;
|
||||
bool show_node_body;
|
||||
bool show_node_bubble;
|
||||
|
||||
int x, y;
|
||||
int w, h;
|
||||
|
@ -755,6 +755,7 @@ R_API void r_cons_canvas_write(RConsCanvas *c, const char *_s);
|
||||
R_API bool r_cons_canvas_gotoxy(RConsCanvas *c, int x, int y);
|
||||
R_API void r_cons_canvas_goto_write(RConsCanvas *c,int x,int y, const char * s);
|
||||
R_API void r_cons_canvas_box(RConsCanvas *c, int x, int y, int w, int h, const char *color);
|
||||
R_API void r_cons_canvas_circle(RConsCanvas *c, int x, int y, int w, int h, const char *color);
|
||||
R_API void r_cons_canvas_line(RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style);
|
||||
R_API void r_cons_canvas_line_diagonal(RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style);
|
||||
R_API void r_cons_canvas_line_square(RConsCanvas *c, int x, int y, int x2, int y2, RCanvasLineStyle *style);
|
||||
|
@ -78,6 +78,8 @@ R_API int r_num_str_len(const char *str);
|
||||
R_API int r_num_str_split(char *str);
|
||||
R_API RList *r_num_str_split_list(char *str);
|
||||
R_API void *r_num_dup(ut64 n);
|
||||
R_API double r_num_cos(double a);
|
||||
R_API double r_num_sin(double a);
|
||||
R_API double r_num_get_float(RNum *num, const char *str);
|
||||
|
||||
static inline st64 r_num_abs(st64 num) {
|
||||
|
@ -870,3 +870,11 @@ R_API void *r_num_dup(ut64 n) {
|
||||
*hn = n;
|
||||
return (void*)hn;
|
||||
}
|
||||
|
||||
R_API double r_num_cos(double a) {
|
||||
return cos (a);
|
||||
}
|
||||
|
||||
R_API double r_num_sin(double a) {
|
||||
return sin(a);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user