123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- deferred class CD_PRIMITIVES_MARKS
- -- A mark is a punctual representation. It can have different sizes and types.
- -- All types are affected only by mark attributes and by the foreground color.
- --
- -- All marks in all drivers are simulated using other CD primitives, except
- -- CanvasPixel.
- inherit
- CANVAS_DRAW
- feature {ANY}
- -- Pixel
- draws_pixel (x, y, red, green, blue: INTEGER)
- -- Configures the pixel (x,y) with the color defined. It is the smallest
- -- element of the canvas. It depends only on global attributes of the
- -- canvas. It can be very slow on some drivers. Sometimes it is
- -- implemented as a rectangle with size 1x1.
- local
- cl: INTEGER
- do
- cl := encode_color (red, green, blue)
- int_canvas_pixel (cnvs, x, y, cl)
- end
- draws_pixel_real (x, y: REAL_64; red, green, blue: INTEGER)
- -- As "canvas_pixel" but with REAL_64 for coordinates.
- local
- cl: INTEGER
- do
- cl := encode_color (red, green, blue)
- int_canvas_c_double_pixel (cnvs, x, y, cl)
- end
- wd_draws_pixel (x, y: REAL_64; red, green, blue: INTEGER)
- -- As "canvas_pixel_real" but use World coordinates.
- local
- cl: INTEGER
- do
- cl := encode_color (red, green, blue)
- int_wd_canvas_pixel (cnvs, x, y, cl)
- end
- -- Mark operations
- draws_mark (x, y: INTEGER)
- -- Draws a mark in (x,y) using the current foreground color. It is not
- -- possible to use this function between a call to functions "begin" and
- -- "end" if the type of mark is set to diamond. If the active driver does
- -- not include this primitive, it will be simulated using other
- -- primitives from the library.
- --
- -- If you will call this function several times in a sequence, then it is
- -- recommended that the application changes the filling and line
- -- attributes to those used by this function:
- --
- -- set_interior_style_solid
- -- set_line_style_continuous
- -- set_line_width(1)
- --
- -- This will greatly increase this function's performance. Also in this
- -- case, if the mark is very small, we suggest using the "canvas_pixel"
- -- function so that the application itself draws the mark. In many cases,
- -- this also increases this function's performance.
- do
- int_canvas_mark (cnvs, x, y)
- end
- draws_mark_real (x, y: REAL_64)
- -- As "canvas_mark" but with REAL_64 for coordinates.
- do
- int_canvas_c_double_mark (cnvs, x, y)
- end
- wd_draws_mark (x, y: REAL_64)
- -- As "canvas_mark_real" but use World coordinates.
- do
- int_wd_canvas_mark (cnvs, x, y)
- end
- -- Mark size
- set_mark_size (size: INTEGER)
- -- Configures the mark size in pixels.
- -- Default value: 10.
- require
- size >= 1
- local
- i: INTEGER
- do
- i := int_canvas_mark_size (cnvs, size)
- end
- set_wd_mark_size (size: REAL_64)
- -- Set the current size in millimeters.
- require
- size >= 1
- local
- i: REAL_64
- do
- i := int_wd_canvas_mark_size (cnvs, size)
- end
- get_mark_size: INTEGER
- -- Return the size in pixels.
- do
- Result := int_canvas_mark_size (cnvs, -1)
- end
- get_wd_mark_size: REAL_64
- -- Return the size in millimeters.
- do
- Result := int_wd_canvas_mark_size (cnvs, -1)
- end
- -- Mark attributes
- mark_type_plus: STRING
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, 0)
- Result := int_mark_type_integer_to_string(i)
- end
- mark_type_star: STRING
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, 1)
- Result := int_mark_type_integer_to_string(i)
- end
- mark_type_circle: STRING
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, 2)
- Result := int_mark_type_integer_to_string(i)
- end
- mark_type_x: STRING
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, 3)
- Result := int_mark_type_integer_to_string(i)
- end
- mark_type_box: STRING
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, 4)
- Result := int_mark_type_integer_to_string(i)
- end
- mark_type_diamond: STRING
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, 5)
- Result := int_mark_type_integer_to_string(i)
- end
- mark_type_hollow_circle: STRING
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, 6)
- Result := int_mark_type_integer_to_string(i)
- end
- mark_type_hollow_box: STRING
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, 7)
- Result := int_mark_type_integer_to_string(i)
- end
- mark_type_hollow_diamond: STRING
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, 8)
- Result := int_mark_type_integer_to_string(i)
- end
- mark_type: STRING
- -- Return the type of the mark. One of the follwing string:
- --
- -- "CD_PLUS"
- -- "CD_STAR"
- -- "CD_CIRCLE"
- -- "CD_X"
- -- "CD_BOX"
- -- "CD_DIAMOND"
- -- "CD_HOLLOW_CIRCLE"
- -- "CD_HOLLOW_BOX"
- -- "CD_HOLLOW_DIAMOND"
- local
- i: INTEGER
- do
- i := int_canvas_mark_type (cnvs, -1)
- Result := int_mark_type_integer_to_string(i)
- end
-
- feature {}
- -- Internals
- int_canvas_pixel (wgt: POINTER; x, y, cl: INTEGER)
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "cdCanvasPixel"
- }"
- end
- int_canvas_c_double_pixel (wgt: POINTER; x, y: REAL_64; cl: INTEGER)
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "cdfCanvasPixel"
- }"
- end
- int_wd_canvas_pixel (wgt: POINTER; x, y: REAL_64; cl: INTEGER)
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "wdCanvasPixel"
- }"
- end
- int_canvas_mark (wgt: POINTER; x, y: INTEGER)
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "cdCanvasMark"
- }"
- end
- int_canvas_c_double_mark (wgt: POINTER; x, y: REAL_64)
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "cdfCanvasMark"
- }"
- end
- int_wd_canvas_mark (wgt: POINTER; x, y: REAL_64)
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "wdCanvasMark"
- }"
- end
- int_canvas_mark_size (wgt: POINTER; s: INTEGER): INTEGER
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "cdCanvasMarkSize"
- }"
- end
- int_wd_canvas_mark_size (wgt: POINTER; s: REAL_64): REAL_64
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "wdCanvasMarkSize"
- }"
- end
- int_canvas_mark_type (wgt: POINTER; type: INTEGER): INTEGER
- external "plug_in"
- alias "{
- location: "${sys}/plugins"
- module_name: "iup"
- feature_name: "cdCanvasMarkType"
- }"
- end
- int_mark_type_integer_to_string (t: INTEGER): STRING
- do
- if t.is_equal(0) then
- Result := "CD_PLUS"
- elseif t.is_equal(1) then
- Result := "CD_STAR"
- elseif t.is_equal(2) then
- Result := "CD_CIRCLE"
- elseif t.is_equal(3) then
- Result := "CD_X"
- elseif t.is_equal(4) then
- Result := "CD_BOX"
- elseif t.is_equal(5) then
- Result := "CD_DIAMOND"
- elseif t.is_equal(6) then
- Result := "CD_HOLLOW_CIRCLE"
- elseif t.is_equal(7) then
- Result := "CD_HOLLOW_BOX"
- elseif t.is_equal(8) then
- Result := "CD_HOLLOW_DIAMOND"
- end
- end
- end
- -- The MIT License (MIT)
- -- Copyright (c) 2016 by German A. Arias
- -- Permission is hereby granted, free of charge, to any person obtaining a copy
- -- of this software and associated documentation files (the "Software"), to deal
- -- in the Software without restriction, including without limitation the rights
- -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- -- copies of the Software, and to permit persons to whom the Software is
- -- furnished to do so, subject to the following conditions:
- --
- -- The above copyright notice and this permission notice shall be included in
- -- all copies or substantial portions of the Software.
- --
- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- -- SOFTWARE.
|