Added the source code of OxyPlot as of commit d190d7748a73 (6.5.2013).
1 // --------------------------------------------------------------------------------------------------------------------
2 // <copyright file="IRenderContext.cs" company="OxyPlot">
3 // The MIT License (MIT)
5 // Copyright (c) 2012 Oystein Bjorke
7 // Permission is hereby granted, free of charge, to any person obtaining a
8 // copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
15 // The above copyright notice and this permission notice shall be included
16 // in all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 // Render context interface.
29 // --------------------------------------------------------------------------------------------------------------------
32 using System.Collections.Generic;
35 /// Defines rendering functionality.
37 public interface IRenderContext
40 /// Gets a value indicating whether the context renders to screen.
43 /// <c>true</c> if the context renders to screen; otherwise, <c>false</c>.
45 bool RendersToScreen { get; }
50 /// <param name="rect">
53 /// <param name="fill">
56 /// <param name="stroke">
59 /// <param name="thickness">
62 void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness = 1.0);
65 /// Draws the collection of ellipses, where all have the same stroke and fill.
66 /// This performs better than calling DrawEllipse multiple times.
68 /// <param name="rectangles">
71 /// <param name="fill">
74 /// <param name="stroke">
77 /// <param name="thickness">
78 /// The stroke thickness.
80 void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness = 1.0);
83 /// Draws the polyline from the specified points.
85 /// <param name="points">
88 /// <param name="stroke">
91 /// <param name="thickness">
92 /// The stroke thickness.
94 /// <param name="dashArray">
97 /// <param name="lineJoin">
98 /// The line join type.
100 /// <param name="aliased">
101 /// if set to <c>true</c> the shape will be aliased.
104 IList<ScreenPoint> points,
106 double thickness = 1.0,
107 double[] dashArray = null,
108 OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter,
109 bool aliased = false);
112 /// Draws the multiple line segments defined by points (0,1) (2,3) (4,5) etc.
113 /// This should have better performance than calling DrawLine for each segment.
115 /// <param name="points">
118 /// <param name="stroke">
119 /// The stroke color.
121 /// <param name="thickness">
122 /// The stroke thickness.
124 /// <param name="dashArray">
127 /// <param name="lineJoin">
128 /// The line join type.
130 /// <param name="aliased">
131 /// if set to <c>true</c> the shape will be aliased.
133 void DrawLineSegments(
134 IList<ScreenPoint> points,
136 double thickness = 1.0,
137 double[] dashArray = null,
138 OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter,
139 bool aliased = false);
142 /// Draws the polygon from the specified points. The polygon can have stroke and/or fill.
144 /// <param name="points">
147 /// <param name="fill">
150 /// <param name="stroke">
151 /// The stroke color.
153 /// <param name="thickness">
154 /// The stroke thickness.
156 /// <param name="dashArray">
159 /// <param name="lineJoin">
160 /// The line join type.
162 /// <param name="aliased">
163 /// if set to <c>true</c> the shape will be aliased.
166 IList<ScreenPoint> points,
169 double thickness = 1.0,
170 double[] dashArray = null,
171 OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter,
172 bool aliased = false);
175 /// Draws a collection of polygons, where all polygons have the same stroke and fill.
176 /// This performs better than calling DrawPolygon multiple times.
178 /// <param name="polygons">
181 /// <param name="fill">
184 /// <param name="stroke">
185 /// The stroke color.
187 /// <param name="thickness">
188 /// The stroke thickness.
190 /// <param name="dashArray">
193 /// <param name="lineJoin">
194 /// The line join type.
196 /// <param name="aliased">
197 /// if set to <c>true</c> the shape will be aliased.
200 IList<IList<ScreenPoint>> polygons,
203 double thickness = 1.0,
204 double[] dashArray = null,
205 OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter,
206 bool aliased = false);
209 /// Draws the rectangle.
211 /// <param name="rect">
214 /// <param name="fill">
217 /// <param name="stroke">
218 /// The stroke color.
220 /// <param name="thickness">
221 /// The stroke thickness.
223 void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness = 1.0);
226 /// Draws a collection of rectangles, where all have the same stroke and fill.
227 /// This performs better than calling DrawRectangle multiple times.
229 /// <param name="rectangles">
232 /// <param name="fill">
235 /// <param name="stroke">
236 /// The stroke color.
238 /// <param name="thickness">
239 /// The stroke thickness.
241 void DrawRectangles(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness = 1.0);
249 /// <param name="text">
252 /// <param name="fill">
255 /// <param name="fontFamily">
258 /// <param name="fontSize">
259 /// Size of the font.
261 /// <param name="fontWeight">
264 /// <param name="rotate">
265 /// The rotation angle.
267 /// <param name="halign">
268 /// The horizontal alignment.
270 /// <param name="valign">
271 /// The vertical alignment.
273 /// <param name="maxSize">
274 /// The maximum size of the text.
280 string fontFamily = null,
281 double fontSize = 10,
282 double fontWeight = 500,
284 HorizontalAlignment halign = HorizontalAlignment.Left,
285 VerticalAlignment valign = VerticalAlignment.Top,
286 OxySize? maxSize = null);
289 /// Measures the text.
291 /// <param name="text">
294 /// <param name="fontFamily">
297 /// <param name="fontSize">
298 /// Size of the font.
300 /// <param name="fontWeight">
306 OxySize MeasureText(string text, string fontFamily = null, double fontSize = 10, double fontWeight = 500);
309 /// Sets the tool tip for the following items.
312 /// This is only used in the plot controls.
314 /// <param name="text">
315 /// The text in the tooltip.
317 void SetToolTip(string text);
320 /// Cleans up resources not in use.
323 /// This method is called at the end of each rendering.
328 /// Gets the size of the specified image.
330 /// <param name="source">The image source.</param>
331 /// <returns>The image info.</returns>
332 OxyImageInfo GetImageInfo(OxyImage source);
335 /// Draws the specified portion of the specified <see cref="OxyImage"/> at the specified location and with the specified size.
337 /// <param name="source">The source.</param>
338 /// <param name="srcX">The x-coordinate of the upper-left corner of the portion of the source image to draw.</param>
339 /// <param name="srcY">The y-coordinate of the upper-left corner of the portion of the source image to draw.</param>
340 /// <param name="srcWidth">Width of the portion of the source image to draw.</param>
341 /// <param name="srcHeight">Height of the portion of the source image to draw.</param>
342 /// <param name="destX">The x-coordinate of the upper-left corner of drawn image.</param>
343 /// <param name="destY">The y-coordinate of the upper-left corner of drawn image.</param>
344 /// <param name="destWidth">The width of the drawn image.</param>
345 /// <param name="destHeight">The height of the drawn image.</param>
346 /// <param name="opacity">The opacity.</param>
347 /// <param name="interpolate">interpolate if set to <c>true</c>.</param>
348 void DrawImage(OxyImage source, uint srcX, uint srcY, uint srcWidth, uint srcHeight, double destX, double destY, double destWidth, double destHeight, double opacity, bool interpolate);
351 /// Sets the clip rectangle.
353 /// <param name="rect">The clip rectangle.</param>
354 /// <returns>True if the clip rectangle was set.</returns>
355 bool SetClip(OxyRect rect);
358 /// Resets the clip rectangle.
364 /// Provides information about the size of an image.
366 public class OxyImageInfo
369 /// Gets or sets the width in pixels.
374 public uint Width { get; set; }
377 /// Gets or sets the height in pixels.
382 public uint Height { get; set; }
385 /// Gets or sets the horizontal resolution in dpi.
390 public double DpiX { get; set; }
393 /// Gets or sets the vertical resolution in dpi.
398 public double DpiY { get; set; }