dcv.plot.figure

Module implements on-screen image plotting utilities.

DCV offers simple interface to show an image on screen:

Image image = imread("image.png");

// Simply, show the image
image.imshow();

// Optionally, show the image on the figure with given title:
image.imshow("Some Image");

// ... or do some processing, then show it in-line
image
    .sliced
    .as!float
    .slice
    .conv!symmetric(gaussian!float(1.0f, 3, 3))
    .imshow;

// ... or instantiate new figure to setup some useful callbacks, than use the
// Figure interface to draw on it's canvas, and show it:

auto f = figure("Figure title");  // create the figure with given title

// set the mouse move callback
f.setCursorCallback( (Figure figure, double x, double y)
{
    writeln("Mouse moved to: ", [x, y]);
})

// set the mouse button click callback
f.setMouseCallback( (Figure figure, int button, int scancode, int mods)
{
    writeln("Mouse clicked: ", [button, scancode, mods]);
});

f.draw(image); // draw an image to the figure's canvas.
f.show(); // show the figure on screen.

// Once figure's image buffer is drawn out (say you have an image, and few plots drawn on it),
// it can be extracted from the figure, and used in rest of the code:
Image plotImage = figure(title).image;
plotImage.imwrite("my_plot.png");

// And at the end, you can run the event loop for each previously set up figure, to wait
// for key input, or given time to pass.
waitKey!"seconds"(10);

Figure mechanism is integrated with ggplotd library, so GGPlotD context can be directly plotted onto existing figure. To use GGPlotD library integration with DCV (dcv.plot.figure.plot), define ggplotd subConfiguration of dcv in dub configuration file:

"dependencies": {
    "dcv": "~>0.1.2"
},
"subConfigurations":{
    "dcv": "ggplotd"
}

This configuration is actually in dcv:plot subpackage, so if you define dcv:plot as dependency, you should define your subConfigurations as:

"dependencies": {
    "dcv:plot": "~>0.1.2"
},
"subConfigurations":{
    "dcv:plot": "ggplotd"
}

Members

Aliases

CharCallback
alias CharCallback = void delegate(uint key)

Character callback function.

KeyPressCallback
alias KeyPressCallback = void delegate(int key, int scancode, int action, int mods)

Key press callback function.

Classes

ContextNotInitialized
class ContextNotInitialized

Exception thrown if drawing context hasn't been properly initialized.

Figure
class Figure

Plotting figure type.

Functions

figure
Figure figure(string title)

Create a plotting figure.

imdestroy
void imdestroy(string title)

Destroy figure.

imshow
Figure imshow(Image image, string title)
Figure imshow(Slice!(kind, packs, Iterator) slice, string title)
Figure imshow(Slice!(kind, packs, Iterator) slice, ImageFormat format, string title)

Show an image to screen.

plot
Figure plot(Image image, GGPlotD gg, string title)
Figure plot(Slice!(kind, packs, Iterator) slice, GGPlotD gg, string title)
Figure plot(Slice!(kind, packs, Iterator) slice, ImageFormat format, GGPlotD gg, string title)

Show given image, and then plot given GGPlotD context on top of it.

plot
Figure plot(GGPlotD gg, string title)

Plot GGPlotD context onto figure with given title.

setCharCallback
void setCharCallback(CharCallback clbck)

Assign character input callback function.

setKeyPressCallback
void setKeyPressCallback(KeyPressCallback clbck)

Assign key press callback function.

waitKey
int waitKey(ulong count)

Run the event loop for each present figure, and wait for key and/or given time.

Variables

KEY_APOSTROPHE
auto KEY_APOSTROPHE;
Undocumented in source.
KEY_BACKSLASH
auto KEY_BACKSLASH;
Undocumented in source.
KEY_BACKSPACE
auto KEY_BACKSPACE;
Undocumented in source.
KEY_CAPS_LOCK
auto KEY_CAPS_LOCK;
Undocumented in source.
KEY_COMMA
auto KEY_COMMA;
Undocumented in source.
KEY_DELETE
auto KEY_DELETE;
Undocumented in source.
KEY_DOWN
auto KEY_DOWN;
Undocumented in source.
KEY_END
auto KEY_END;
Undocumented in source.
KEY_ENTER
auto KEY_ENTER;
Undocumented in source.
KEY_EQUAL
auto KEY_EQUAL;
Undocumented in source.
KEY_ESCAPE
auto KEY_ESCAPE;
Undocumented in source.
KEY_F1
auto KEY_F1;
Undocumented in source.
KEY_F10
auto KEY_F10;
Undocumented in source.
KEY_F11
auto KEY_F11;
Undocumented in source.
KEY_F12
auto KEY_F12;
Undocumented in source.
KEY_F13
auto KEY_F13;
Undocumented in source.
KEY_F14
auto KEY_F14;
Undocumented in source.
KEY_F15
auto KEY_F15;
Undocumented in source.
KEY_F16
auto KEY_F16;
Undocumented in source.
KEY_F17
auto KEY_F17;
Undocumented in source.
KEY_F18
auto KEY_F18;
Undocumented in source.
KEY_F19
auto KEY_F19;
Undocumented in source.
KEY_F2
auto KEY_F2;
Undocumented in source.
KEY_F20
auto KEY_F20;
Undocumented in source.
KEY_F21
auto KEY_F21;
Undocumented in source.
KEY_F22
auto KEY_F22;
Undocumented in source.
KEY_F23
auto KEY_F23;
Undocumented in source.
KEY_F24
auto KEY_F24;
Undocumented in source.
KEY_F25
auto KEY_F25;
Undocumented in source.
KEY_F3
auto KEY_F3;
Undocumented in source.
KEY_F4
auto KEY_F4;
Undocumented in source.
KEY_F5
auto KEY_F5;
Undocumented in source.
KEY_F6
auto KEY_F6;
Undocumented in source.
KEY_F7
auto KEY_F7;
Undocumented in source.
KEY_F8
auto KEY_F8;
Undocumented in source.
KEY_F9
auto KEY_F9;
Undocumented in source.
KEY_GRAVE_ACCENT
auto KEY_GRAVE_ACCENT;
Undocumented in source.
KEY_HOME
auto KEY_HOME;
Undocumented in source.
KEY_INSERT
auto KEY_INSERT;
Undocumented in source.
KEY_KP_0
auto KEY_KP_0;
Undocumented in source.
KEY_KP_1
auto KEY_KP_1;
Undocumented in source.
KEY_KP_2
auto KEY_KP_2;
Undocumented in source.
KEY_KP_3
auto KEY_KP_3;
Undocumented in source.
KEY_KP_4
auto KEY_KP_4;
Undocumented in source.
KEY_KP_5
auto KEY_KP_5;
Undocumented in source.
KEY_KP_6
auto KEY_KP_6;
Undocumented in source.
KEY_KP_7
auto KEY_KP_7;
Undocumented in source.
KEY_KP_8
auto KEY_KP_8;
Undocumented in source.
KEY_KP_9
auto KEY_KP_9;
Undocumented in source.
KEY_KP_ADD
auto KEY_KP_ADD;
Undocumented in source.
KEY_KP_DECIMAL
auto KEY_KP_DECIMAL;
Undocumented in source.
KEY_KP_DIVIDE
auto KEY_KP_DIVIDE;
Undocumented in source.
KEY_KP_ENTER
auto KEY_KP_ENTER;
Undocumented in source.
KEY_KP_EQUAL
auto KEY_KP_EQUAL;
Undocumented in source.
KEY_KP_MULTIPLY
auto KEY_KP_MULTIPLY;
Undocumented in source.
KEY_KP_SUBTRACT
auto KEY_KP_SUBTRACT;
Undocumented in source.
KEY_LAST
auto KEY_LAST;
Undocumented in source.
KEY_LEFT
auto KEY_LEFT;
Undocumented in source.
KEY_LEFT_ALT
auto KEY_LEFT_ALT;
Undocumented in source.
KEY_LEFT_BRACKET
auto KEY_LEFT_BRACKET;
Undocumented in source.
KEY_LEFT_CONTROL
auto KEY_LEFT_CONTROL;
Undocumented in source.
KEY_LEFT_SHIFT
auto KEY_LEFT_SHIFT;
Undocumented in source.
KEY_LEFT_SUPER
auto KEY_LEFT_SUPER;
Undocumented in source.
KEY_MENU
auto KEY_MENU;
Undocumented in source.
KEY_MINUS
auto KEY_MINUS;
Undocumented in source.
KEY_NUM_LOCK
auto KEY_NUM_LOCK;
Undocumented in source.
KEY_PAGE_DOWN
auto KEY_PAGE_DOWN;
Undocumented in source.
KEY_PAGE_UP
auto KEY_PAGE_UP;
Undocumented in source.
KEY_PAUSE
auto KEY_PAUSE;
Undocumented in source.
KEY_PERIOD
auto KEY_PERIOD;
Undocumented in source.
KEY_PRINT_SCREEN
auto KEY_PRINT_SCREEN;
Undocumented in source.
KEY_RIGHT
auto KEY_RIGHT;
Undocumented in source.
KEY_RIGHT_ALT
auto KEY_RIGHT_ALT;
Undocumented in source.
KEY_RIGHT_BRACKET
auto KEY_RIGHT_BRACKET;
Undocumented in source.
KEY_RIGHT_CONTROL
auto KEY_RIGHT_CONTROL;
Undocumented in source.
KEY_RIGHT_SHIFT
auto KEY_RIGHT_SHIFT;
Undocumented in source.
KEY_RIGHT_SUPER
auto KEY_RIGHT_SUPER;
Undocumented in source.
KEY_SCROLL_LOCK
auto KEY_SCROLL_LOCK;
Undocumented in source.
KEY_SEMICOLON
auto KEY_SEMICOLON;
Undocumented in source.
KEY_SLASH
auto KEY_SLASH;
Undocumented in source.
KEY_SPACE
auto KEY_SPACE;
Undocumented in source.
KEY_TAB
auto KEY_TAB;
Undocumented in source.
KEY_UNKNOWN
auto KEY_UNKNOWN;
Undocumented in source.
KEY_UP
auto KEY_UP;
Undocumented in source.
MOD_ALT
auto MOD_ALT;
Undocumented in source.
MOD_CONTROL
auto MOD_CONTROL;
Undocumented in source.
MOD_SHIFT
auto MOD_SHIFT;
Undocumented in source.
MOD_SUPER
auto MOD_SUPER;
Undocumented in source.
MOUSE_BUTTON_1
auto MOUSE_BUTTON_1;
Undocumented in source.
MOUSE_BUTTON_2
auto MOUSE_BUTTON_2;
Undocumented in source.
MOUSE_BUTTON_3
auto MOUSE_BUTTON_3;
Undocumented in source.
MOUSE_BUTTON_4
auto MOUSE_BUTTON_4;
Undocumented in source.

Examples

immutable title = "Image With Point Plot";
// show the image
image.imshow(title);
// construct the plot
auto gg = GGPlotD().put(geomPoint(Aes!(double[], "x", double[], "y")([100.00, 200.0], [200.0,100.0])));
// draw it onto the figure with given title...
gg.plot(title);
Module contains:
imshow plot waitKey imdestroy Figure

Meta

Authors

Relja Ljubobratovic

License

$(LINK3 http://www.boost.org/LICENSE_1_0.txt, Boost Software License - Version 1.0).