Class Image
#include <Image.h >
This class represents images within the MAE system.
Images may be drawn by the app or pulled from ImageLib database table.
Drawn images draw into a coordinate system with the size (height, width) and origin specified by the application. For example, to create an image with a coordinate system that is 5 units wide and 4 units tall with the origin(0,0) in the center, you specify setSize(5, 4) and setOrigin(-2.5,-2). How large the image is when it is displayed depends upon the unit size. If you'd like your 5 unit wide image to be 50 pixes wide, then specify setSize(5, 4, 10).
To display an image to the user, see the UserDevice class.
Use this class to communicate with imager, which renders them appropriately for the user.
This data structure abstracts a vector image. The API is used to describe the image. It is not rendered into JPG, PNG, SVG, or other specific image technology until it is ready to be rendered to the end-user. Rendering is performed by the imager daemon.
The API could be richer, but the API must be able to render to each of the ultimate image types.
The Image class may refer to an existing image file in a specific format via ImageLib class, which specifies where to retrieve the image and the image's size.
setSize(double newWidth, double newHeight, int newUnitSize)
Set the canvas dimensions and specify how many pixes per unit. For example, a 4.0x5.0 image where unit size is 10 would create a 40x50 pixel image.
setOrigin(double newOriginX, double newOriginY)
Specify how many units over the origin should be located if (0,0) is the lower left
setWindow(double minX, double minY, double maxX, double maxY, int newUnitSize)
Specify the width and origin implicitly by specifying the window into the view. Use this instead of setSize() setOrigin()
drawBox([[#Point]] corner1, Point corner2, string color, bool fill, string link)
Draw a rectangle with the corners specified. Default color is black. The box may be an outline or solid/fiilled.
An optional link (e.g. URL) may be provided if resulting image supports linking.
drawLine([[#Point]] p1, Point p2, string color, string link)
Draw a line from p1 to p2 of the color specified.
An optional link (e.g. URL) may be provided if resulting image supports linking.
drawCircle([[#Point]] center, double radius, string color, bool fill, string link)
Draw a full circle with the specified center and radius. The default color is black. The circle may be an outline or solid/fiilled.
An optional link (e.g. URL) may be provided if resulting image supports linking.
drawText([[#Point]] start, string text, string color, string link)
Draw text into the image with the lower left corner of the text at the start point.
bool drawArc([[#Point]] center, double startang, double endang, double radius, string color, bool fill)
drawPolygon([[#Point]]List p, string color, bool fill, string link)
Given a series of points, draw the enclosed polygon. The default color is black. The polygon may be an outline or solid/fiilled.
An optional link (e.g. URL) may be provided if resulting image supports linking.
drawPolyline([[#Point]]List p, string color, string link)
Given a series of points, the the line that connects them from start to end. The default color is black.
An optional link (e.g. URL) may be provided if resulting image supports linking.
int group_id |
this is an application-specific number to differentiate this image name from others; it is used to help create a unique image name for the user's display device Default value: 0 |
const string& imageName |
this is the application-specific name given to the image Default value: "" |
const string& module |
this is the application-specific category for the image, such as the application's name Default value: "" |
Construct an empty image.
const ImageLib& imagelib |
image library image; see ImageLib |
Construct an image from the ImageLib database table.
const XMLData& data |
XML data that describes how to create the image, from toXML() |
Construct an image from data.
double newWidth |
the width of the image in your defined coordinate system |
double newHeight |
the height of the image in your defined coordinate system |
double newUnitSize |
number of pixels that represents a unit in your defined coordinate system; the width in pixels will be newWidth * newUnitSize; if you specify 0, then the previous value will hold Default value: 0 |
Specify how many units wide and tall the image is; specify how many pixels are in a unit
double newOriginX |
specify how many units to the left from the right side is x=0 |
double newOriginY |
specify how many units to the down from the top side is y=0 |
Specify how many units over the origin should be located if (0,0) is the upper right
Return value: true if successfully set
double minX |
The value of x at the leftmost side of the image |
double minY |
The value of y at the bottom side of the image |
double maxX |
The value of x at the rightmost side of the image |
double maxY |
The value of x at the top side of the image |
double newUnitSize |
Default value: 0 |
Specify the width and origin implicitly by specifying the window into the view.
Use this instead of setSize() & setOrigin()
Return value: true if new window accepted
double length |
length in image's coordinate system |
When you need to know display size, you can query how many pixels it takes to draw the provided length.
This can be helpful to understand how much detail to draw into an image.
Return value: number of pixels
double width |
line thickness (in coordinate system units) Default value: 0.0 |
Specify the thickness of a line (if too small, it will still be one pixel wide)
Return value: true if successfully added to the image
const string& linetype |
the line type to use to draw, e.g. solid, dotted, dashed, dotdash Default value: "solid" |
Specify the type of line, e.g. solid, dotted, dashed, dotdash - if supported
Return value: true if successfully added to the image
const Point& corner1 |
(x,y) coordinates of a corner of the box |
const Point& corner2 |
(x,y) coordinates of the opposite corner |
Clip the commands that follow so only what is inside the provided box is visible.
Return value: true if successfully added to the image
Turn off the clip box so all is drawn again.
Return value: true if successfully added to the image
const Point& corner1 |
(x,y) coordinates of a corner of the box |
const Point& corner2 |
(x,y) coordinates of the opposite corner |
const string& color |
the color to use to draw this Default value: "black" |
bool fill |
true to fill in the shape; false to draw only the outline Default value: true |
const string& link |
address of where to go if the user clicks on this shape Default value: "" |
Draw a rectangle of a color, solid or outline
Return value: true if successfully added to the image
const Point& pt1 |
(x,y) coordinates of the start of the line segment |
const Point& pt2 |
(x,y) coordinates of the end of the line segment |
const string& color |
the color to use to draw this Default value: "black" |
const string& link |
address of where to go if the user clicks on this shape Default value: "" |
Draw a line segment between two points of a color
Return value: true if successfully added to the image
const Point& center |
(x,y) coordinates of center of the circle |
double radius |
the radius of the circle from its center out to its perimeter |
const string& color |
the color to use to draw this Default value: "black" |
bool fill |
true to fill in the shape; false to draw only the outline Default value: true |
const string& link |
address of where to go if the user clicks on this shape Default value: "" |
Draw a circle with a center and radius of a color, solid or outline
Return value: true if successfully added to the image
const Point& center |
(x,y) coordinates of center of the arc |
double startang |
the start angle of the arc, in radians |
double endang |
the ending angle of the arc, in radians |
double radius |
the radius of the arc from its center out to its perimeter |
const string& color |
the color to use to draw this Default value: "black" |
bool fill |
true to fill in the shape; false to draw only the outline Default value: true |
const string& link |
address of where to go if the user clicks on this shape Default value: "" |
Draw an arc with a center and radius of a color, solid or outline
Return value: true if successfully added to the image
const PointList& ptlist |
a list of points that specifies a polygon's outline; the last point will automatically be connected to the first point |
const string& color |
the color to use to draw this Default value: "black" |
bool fill |
true to fill in the shape; false to draw only the outline Default value: true |
const string& link |
address of where to go if the user clicks on this shape Default value: "" |
Draw a polygon from a series of points of a color, solid or outline
Return value: true if successfully added to the image
Point* ptlist |
a list of points that specifies a polygon's outline; the last point will automatically be connected to the first point |
int size |
the number of points in ptlist |
const string& color |
the color to use to draw this Default value: "black" |
bool fill |
true to fill in the shape; false to draw only the outline Default value: true |
const string& link |
address of where to go if the user clicks on this shape Default value: "" |
Draw a polygon from a series of points of a color, solid or outline
Return value: true if successfully added to the image
const PointList& ptlist |
a list of points that specifies a polygon's outline; the last point will automatically be connected to the first point |
const string& color |
the color to use to draw this Default value: "black" |
const string& link |
address of where to go if the user clicks on this shape Default value: "" |
Draw a series of line segments from a series of points of a color, solid or outline
Return value: true if successfully added to the image
Point* ptlist |
a list of points that specifies a polygon's outline; the last point will automatically be connected to the first point |
int size |
the number of points in ptlist |
const string& color |
the color to use to draw this Default value: "black" |
const string& link |
address of where to go if the user clicks on this shape Default value: "" |
Draw a series of line segments from a series of points of a color, solid or outline
Return value: true if successfully added to the image
const Point& start |
(x,y) location where the text starts; this is the lower left corner of the first character |
string text |
the text to display |
const string& color |
the color to use to draw this Default value: "black" |
const string& link |
address of where to go if the user clicks on this shape Default value: "" |
Write text into the image of a color
Return value: true if successfully added to the image
const string& comment |
the text of the comment |
Add a comment, that may or may not appear in the final image source as a comment.
Return value: true if successfully added to the image
Point center |
the target (x,y) location where the new image will be centered |
const Image& image |
the image to draw |
double scaler |
as the new image is draw, it can be scalled up ( >1.0) or down (0.0-1.0) Default value: 1 |
double rotation |
how much to rotate the image before it is drawn, in radians Default value: 0 |
Put an image into an image, possibly scaled or rotated
Return value: true if successfully added to the image
const string& format |
the binary format of the image, e.g. svg, gdplot Default value: "gdplot" |
Convert the image into representation as text in a string
Return value: true if successfully added to the image
FILE* f |
the file where the image representation will be written |
const string& format |
the binary format of the image, e.g. svg, gdplot Default value: "gdplot" |
Convert the image into representation as text in a file
Return value: true if successfully added to the image
const XMLData& command |
an XML representation of a drawing command to add |
Add a command into the image. This is provided so images can be transmitted and reconstructed. An app should not construct its own commands and add them.
Return value: true if successfully added to the image
int cmdPos |
location of command to get |
Query a specific drawing command from the image. This is provided so images can be transmitted and reconstructed.
Return value: an XML representation of a drawing command
Get all the commands used to create the drawing. This is provided so images can be transmitted and reconstructed.
Return value: the full drawing as XML commands
Get the image's id, which is contructed from its group id, name, and module.
Return value: the image's id
Get the group id of the image
Return value: the group id
Get the module name of the image
Return value: the module name
Get the name of the image
Return value: the image name
Get the image record id in ImageLib database table.
Return value: 0 if no record, otherwise the record id
Get the image full name (include group id and module).
Point& ll |
(output) the lower left (x,y) coordinates of the image |
Point& ur |
(output) the upper right (x,y) coordinates of the image |
Query the window corners in the image; this is the drawable area.
This is not the clipped region.
const string& id |
the id for the image |
Set an image's id.
Return value: image id
int group_id |
this is an application-specific number to differentiate this image name from others; it is used to help create a unique image name for the user's display device |
const string& imageName |
this is the application-specific name given to the image |
const string& module |
this is the application-specific category for the image, such as the application's name |
Set the id by its parts - group id, image name, and module
DbRecNum id |
new group id |
Set the group id
ImageLibId id |
record id: 0 if none, 1+ for the record |
Set the image record id in ImageLib database table.
const string& newModule |
the module/category for image |
Set the module for the image
const string& newName |
image name |
Set the name of the image
Determine if image has been saved
Return value: true if image has been saved; false if image needs to be saved
Determine if image has been changed and needs to be saved
Return value: true if image needs to be saved; false if image unchanged
Make note that the image has saved.
Make note that the image has changed and needs to be saved.
Query the size of the image, as measured by number of commands.
Return value: number of commands / image size
Query the width of the image in image-defined units.
Return value: width of image
Query the width of the image in pixels.
Return value: width of image in pixels
Query the height of the image in image-defined units.
Return value: height of image
Query the height of the image in pixels.
Return value: height of image in pixels
Get the unit size - the number of pixels per unit.
Return value: pixels in a unit
Query the location of the origin in the image
Return value: the (x,y) offset from the upper right corner
Get the full width of the image in pixels.
Get the full height of the image in pixels.
Reset the image back to a blank, empty image.
Clear all the commands that make the image (but keep the drawing window and settings)
const Point& corner1 |
One corner of the box to erase |
const Point& corner2 |
The opposite corner of the box to erase |
bool whole |
true if whole component to erase is drawn within the box; false if just part of a component is drawn within the box to erase it Default value: true |
Clear all commands that draw in the area specified. You can specify whether the whole image or just part of the image must be in the box to be erased.
Query if the current image is valid.
Return value: true if valid; false if invalid
Convert the image to XML.
Return value: XML representation of the image
const XMLData& data |
XML representation |
bool imageOnly |
true to copy only the commands; false to copy commands, window, and setings Default value: false |
Create an image from XML representation, appended into current image
Return value: the image instance
svgTagFN start |
method to call to create start of SVG tag text |
svgTagFN end |
method to call to create end of SVG tag text |
Override the default SVG tag generators
int group_id |
The image's group id |
string name |
The image's name |
string module |
The image's module/category |
ImageLibId imageLibId |
If from the ImageLib library, its id |
bool changed |
Flag: has our data changed? |
double width |
The window size in app-define coordinates |
double height |
The window size in app-define coordinates |
Point origin |
The origin as measured from the lower left |
double unit_size |
The number of pixes per coordinate system unit |
vector <XMLData > commands |
The command needed to construct the image |
static svgTagFN svgStartTag |
method for starting an SVG image |
static svgTagFN svgEndTag |
method for starting an SVG image |
svgEndTag; svgEndTag |
method for finishing an SVG image |
Point& p |
the point to transform |
Point translate |
the amount to translate (shift) the point |
double scale |
the amount to scale the point (distance from origin) |
double rotate |
the amount to rotate the point around the origin |
Transform a point by translating, scaling, and rotating it.
PointList& p |
the list of points to transform |
Point translate |
the amount to translate (shift) the points |
double scale |
the amount to scale the points (distance from origin) |
double rotate |
the amount to rotate the points around the origin |
Transform a series of points by translating, scaling, and rotating them.
double x |
x-axis distance to convert |
Get the horizontal pixel distance from the origin for the x coordinate
Return value: number of pixels
double y |
y-axis distance to convert |
Get the vertical pixel distance from the origin for the y coordinate
Return value: number of pixels
double x |
x-axis distance to convert |
The number of pixels to move amount along x direction
Return value: number of pixels
double y |
y-axis distance to convert |
The number of pixels to move amount along y direction
const string& link |
Create the start of a SVG link.
const string& link |
Create the end of a SVG link.
Render to GD image library.
Render to an SVG image.
const Point& pt |
|
const Point& ll |
|
const Point& ur |
Determine if the provided point lands inside the specified box.