diff --git a/images/eq-graph.png b/images/eq-graph.png new file mode 100644 index 00000000..54bb55c8 Binary files /dev/null and b/images/eq-graph.png differ diff --git a/images/eq-xgraph.png b/images/eq-xgraph.png new file mode 100644 index 00000000..decedf95 Binary files /dev/null and b/images/eq-xgraph.png differ diff --git a/images/exp-xgraph.png b/images/exp-xgraph.png index a18ccf2a..aae930ab 100644 Binary files a/images/exp-xgraph.png and b/images/exp-xgraph.png differ diff --git a/images/pat-eq-graph.png b/images/pat-eq-graph.png new file mode 100644 index 00000000..79e2e7f7 Binary files /dev/null and b/images/pat-eq-graph.png differ diff --git a/images/pat-eq-xgraph.png b/images/pat-eq-xgraph.png new file mode 100644 index 00000000..decedf95 Binary files /dev/null and b/images/pat-eq-xgraph.png differ diff --git a/src/graphics.cc b/src/graphics.cc index ac5d85d3..e62987a8 100644 --- a/src/graphics.cc +++ b/src/graphics.cc @@ -733,6 +733,19 @@ COMMAND_BODY(Show) } +COMMAND_BODY(ToGrob) +// ---------------------------------------------------------------------------- +// Convert an object to graphical form +// ---------------------------------------------------------------------------- +{ + if (object_p obj = rt.top()) + if (grob_p gr = obj->graph()) + if (rt.top(gr)) + return OK; + return ERROR; +} + + static void graphics_dirty(coord x1, coord y1, coord x2, coord y2, size lw) // ---------------------------------------------------------------------------- // Mark region as dirty with extra size diff --git a/src/graphics.h b/src/graphics.h index 9105cc56..80bcb580 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -130,6 +130,7 @@ COMMAND_DECLARE(RRect,3); COMMAND_DECLARE(ClLCD,0); COMMAND_DECLARE(Clip,1); COMMAND_DECLARE(CurrentClip,0); +COMMAND_DECLARE(ToGrob, 1); COMMAND_DECLARE(GXor,3); COMMAND_DECLARE(GOr,3); COMMAND_DECLARE(GAnd,3); diff --git a/src/ids.tbl b/src/ids.tbl index eda0f60c..503341dc 100644 --- a/src/ids.tbl +++ b/src/ids.tbl @@ -420,6 +420,7 @@ NAMED(Gray, "GrayPattern") ALIAS(Gray, "GreyPattern") ALIAS(Gray, "Grey") NAMED(RGB, "RGBPattern") +NAMED(ToGrob, "→Graphic") ALIAS(ToGrob, "→Grob") NAMED(GXor, "GraphicXor") NAMED(GOr, "GraphicOr") NAMED(GAnd, "GraphicAnd") diff --git a/src/menu.cc b/src/menu.cc index 75e73122..73e42a47 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -1419,25 +1419,32 @@ MENU(GraphicsMenu, // ---------------------------------------------------------------------------- // Graphics operations // ---------------------------------------------------------------------------- - "Disp", ID_Disp, "Line", ID_Line, "Rect", ID_Rect, "Rounded", ID_RRect, "Ellipse", ID_Ellipse, "Circle", ID_Circle, - "DispXY", ID_DispXY, - "Pict", ID_Pict, + "→Grob", ID_ToGrob, + "ClLCD", ID_ClLCD, "GOr", ID_GOr, "GXor", ID_GXor, - "GXor", ID_And, - "ClLCD", ID_ClLCD, + "GAnd", ID_And, + "RGB", ID_RGB, "LnWidth", ID_LineWidth, + "Pict", ID_Pict, + "Clip", ID_Clip, + "Current", ID_CurrentClip, + + "Gray", ID_Gray, "Foregnd", ID_Foreground, "Bckgnd", ID_Background, - "Clip", ID_Clip, - "Current", ID_CurrentClip); + "Disp", ID_Disp, + "DispXY", ID_DispXY, + + "Show", ID_Show, + "Plot", ID_PlotMenu); MENU(MemoryMenu, // ---------------------------------------------------------------------------- diff --git a/src/tests.cc b/src/tests.cc index d67e65e4..6b450525 100644 --- a/src/tests.cc +++ b/src/tests.cc @@ -157,7 +157,7 @@ void tests::run(bool onlyCurrent) if (onlyCurrent) { here().begin("Current"); - global_variables(); + graphic_commands(); } else { @@ -7154,6 +7154,27 @@ void tests::graphic_commands() .image("pixtest") .test(ENTER).expect("400"); + step("Convert to graph") + .test(CLEAR, "'X+Y' cbrt inv 1 + sqrt dup 1 + 2 * /", ENTER, EXIT) + .image_noheader("eq-xgraph") + .test("→Grob", ENTER) + .image_noheader("eq-graph") + .test("→Grob", ENTER) + .image_noheader("eq-graph"); + + step("Pattern in graph conversion") + .test(CLEAR, "0.85 GRAY FOREGROUND 0.15 GRAY BACKGROUND", ENTER) + .noerror() + .test(CLEAR, "'X+Y' cbrt inv 1 + sqrt dup 1 + 2 * /", ENTER, EXIT) + .image_noheader("pat-eq-xgraph") + .test("→Grob", ENTER) + .image_noheader("pat-eq-graph") + .test("→Grob", ENTER) + .image_noheader("pat-eq-graph"); + + step("Reset pattern") + .test(CLEAR, "0 GRAY FOREGROUND 1 GRAY BACKGROUND", ENTER) + .noerror(); }