Files: | canvas.cpp canvas.h |
Authors: | Jonathan Poole Jonathan Fazakerley Marc Cecere Eric Montplaisir |
Date: | Aug 8th 2000 |
Technical Advisor : |
Carlos Moreno |
Member |
Purpose |
int client_height, client_width: | Keeps Height and width of client DC. |
wxImage* original_image: | Image loaded from file. |
wxImage* working_image: | Image used for manipulation and displaying. |
wxBitmap* bm: | Bitmap for printing any image to the panel. |
wxRect subimage_frame Rectangle | from original image that will be expanded. |
wxRect initial_frame: | Rectangle of the original image scaled to fit screen. |
wxRect current_frame: | Rectangle of the current image. |
wxRect drag_rect: | Rectangle chosen from user by mouse dragging. |
wxPoint prev_zoom_point: | Top left corner of the sub-image frame. |
wxPoint subimage_center: | Center of sub-image frame. |
wxPoint click_down: | Location of user click on screen image. |
double magnification: | Current magnification. |
double scale_original_to_screen: | Magnification needed to scale original image to fit screen. |
double user_zoom Magnification: | Chosen by user. |
bool dragging_event: | If user has clicked within image and is dragging the mouse. |
bool interpolating: | If zoom method is set to interpolation. |
bool h_flipped: | If a horizontal flip has been done. |
bool point_zoom: | If a point zoom has been done . |
int rotation_angle: | Current angle of rotation. |
int brightness: | Current brightness. |
int clarity: | Current contrast. |
Canvas constructor |
|
Receive: | parent frame, parent ID, panel size, |
Return: | void |
Description: | Initializes a working canvas |
Canvas destructor |
|
Receive: | void |
Return: | void |
Description: | releases memory of all dynamically allocated data members |
display_image |
|
Receive: | file name (const wxString &) |
Return: | void |
Description: | displays an image file centered and sized (if too large) to fit on the panel |
on_size |
|
Receive: | void |
Return: | void |
Description: | called when panel size is changed. Re-sizes image on screen and redisplays |
rectangles_overlap |
|
Receive: | 2 rectangles (2 wxRect) |
Return: | bool |
Description: | using the panel reference system, determines if 2 passed wxRect's overlap |
on_paint |
|
Receive: | void |
Return: | void |
Description: | Re-displays destroyed parts of image when covered portions are removed. |
reset_image_parameters |
|
Receive: | void |
Return: | void |
Description: | Resets all the variables associated with imaging |
load_file |
|
Receive: | file name (const wxString) |
Return: | void |
Description: | loads an image file, resets the working image, imaging parameters and frames, and displays image sized (if necessary) to screen. |
change_zoom_type |
|
Receive: | bool |
Return: | void |
Description: | toggles method of zooming boolean (interpolation vs. stretching). |
original |
|
Receive: | void |
Return: | void |
Description: | resets working image, imaging parameters and frames, and displays original image sized (if necessary) to fit screen |
undraw_rectangle |
|
Receive: | void |
Return: | void |
Description: | Removes dragging rectangle by reprinting with opposite colours |
on_leaving |
|
Receive: | void |
Return: | void |
Description: | If, during a dragging event, the mouse leaves the panel, the dragging event is cancelled . |
on_motion |
|
Receive: | void |
Return: | void |
Description: | If dragging is occuring, displays a drag rectangle on the image in opposite colours |
on_left_down |
|
Receive: | void |
Return: | void |
Description: | Records location of left down click on image. |
on_left_up |
|
Receive: | void |
Return: | void |
Description: | Records location of left mouse click-up: zooming into either a completed dragged rectangle or the event point |
adjust_working_image |
|
Receive: | void |
Return: | void |
Description: | Given the current angle and flip state rotates and then flips the working image if necessary |
shift_rect_into_rect |
|
Receive: | 2 wxRect |
Return: | void |
Description: | adjusts coordinates of the 1st passed rectangle so that it is shifted and fully conatined by the larger rectangle |
scale_current_frame |
|
Receive: | scaling factor, scaling frame (double, wxRect) |
Return: | void |
Description: | reassigns the current frame to a scaled version of a passed frame |
Canvas::draw_image |
|
Receive: | const wxImage &, printing point (x and y int) |
Return: | void |
Description: | Initializes bit map data member to a passed image and displays on panel |
Canvas::draw_image |
|
Receive: | printing point (int x, int y) |
Return: | void |
Description: | draws bitmap on screen. The 4 rectangles that describe the panel regions around the image are also drawn to achieve the background default colour on the panel |
Canvas::recreate_working_image |
|
Receive: | void |
Return: | void |
Description: | Recreates working image with all current imaging variables |
Canvas::resize_working_image |
|
Receive: | void |
Return: | void |
Description: | If the image is too large for the panel, initializes the
current frame to the down scaled dimensions of the working image and
down scales the working image into that frame |
get_scale_to_screen_factor |
|
Receive: | const wxImage & |
Return: | double |
Description: | Calculates the factor required to down scale an image into the panel (>0 <1) |
get_image_frame |
|
Receive: | image, scale to screen factor (const wxImage &, double) |
Return: | frame (wxRect) |
Description: | given an image and a scaling factor, returns a down scaled frame of the image dimensions |
zoom_center |
|
Receive: | void |
Return: | void |
Description: | zooms into center of image |
zoom_into_point |
|
Receive: | point of magnification on panel (wxPoint) |
Return: | bool |
Description: | calculates the effective point of magnification on the original image and the effective frame that when magnified will fill the largest possible area on the panel, and displays the magnified subimage or the downscaled original depending on the new magnification |
set_effective_zoom_point |
|
Receive: | point of magnification on panel (wxPoint) |
Return: | bool |
Description: | Given the point of zooming on the panel, calculates the effective point of magnification on the original image taking into account any horizontal flipping and any 180 degree rotations |
set_point_zoom_sub_image_frame |
|
Receive: | new magnification (double) |
Return: | bool |
Description: | calculates the effective frame that when magnified will fill the largest possible area on the panel. |
set_sub_image_with_rect_zoom |
|
Receive: | scaling factor (double) |
Return: | bool |
Description: | calculates the effective frame on the original image that was marked out by the dragging rectangle on the panel taking into account horizontally flipping and 180 degree rotations |
zoom_out |
|
Receive: | void |
Return: | void |
Description: | Depending on the new magnification either displays a downscaled original image or a less magnified image - recalculating the effective point of magnification and the effective frame of the subimage |
magnify_working_image |
|
Receive: | new magnification and the frame the image will be scaled up into (double, wxRect) |
Return: | void |
Description: | magnifies the subimage denoted by the frame of the sub-image by stretching or interpolating |
zoom_out_original |
|
Receive: | new magnification (double) |
Return: | void |
Description: | when the new magnification is less then 1, down sizes the working image |
interpolate_image |
|
Receive: | wxImage *, double |
Return: | wxImage * |
Description: | given a magnification, returns a pointer to an interpolated version of a passed image, |
rotate_working_image |
|
Receive: | void |
Return: | void |
Description: | assigns the working image to a rotated version of itself. The mask is set to background because rotations produce a new rectangular image. |
flip_working_image |
|
Receive: | void |
Return: | void |
Description: | assigns the working image to a horizontally flipped version of itself |
Canvas::on_rotate |
|
Receive: | void |
Return: | void |
Description: | Prompts user for rotation angle and re-displays rotated image. |
adjust_rotation_angle |
|
Receive: | void |
Return: | void |
Description: | Adjusts an angle -360 to 360 to a -180 to 180 angle |
on_v_flip |
|
Receive: | void |
Return: | void |
Description: | Vertically flips working image by increasing the rotation
angle by 180 degrees, toggling the horizontal flip boolean, and re-displaying
the image (note: rotation must be done before flipping to achieve proper vertical flip) |
on_h_flip |
|
Receive: | void |
Return: | void |
Description: | toggles horizontal flip boolean and redisplays working image |
switch_h_flip |
|
Receive: | void |
Return: | void |
Description: | toggles horizontal flip boolean |
flip_horizontal |
|
Receive: | const wxImage * |
Return: | wxImage * |
Description: | Returns a pointer to a horizantally flipped version of a passed image. |
rotated90 |
|
Receive: | const wxImage * |
Return: | wxImage * |
Description: | returns a pointer to a 90 degree rotated version of a passed image. |
rotated_minus90 |
|
Receive: | const wxImage * |
Return: | wxImage * |
Description: | returns a pointer to a -90 degree rotated version of a passed image. |
rotated180 |
|
Receive: | const wxImage * |
Return: | wxImage * |
Description: | returns a pointer to a 180 degree rotated version of a passed image. |
reset_initial_frame |
|
Receive: | void |
Return: | void |
Description: | Given the original image, initializes the "scale to screen"
factor to 1 or ,if the image is too large, to a number that when multiplied
by the dimensions of the image gives the initial frame in which the image wiil be displayed on the panel |
Canvas::on_bright |
|
Receive: | void |
Return: | void |
Description: | increments the current brightness of working image and redisplays |
brighten |
|
Receive: | const wxImage *, int |
Return: | wxImage * |
Description: | returns a pointer to a brightened version of a passed image |
Canvas::adjust_brightness_on_working_image |
|
Receive: | N/A |
Return: | N/A |
Description: | Depending on current brightness setting, dims or brightens the working image by the current amount. |
Canvas::on_dim |
|
Receive: | N/A |
Return: | N/A |
Description: | Decrements the current brightness of working image and redisplays |
dim |
|
Receive: | const wxImage *, int |
Return: | wxImage * |
Description: | returns a pointer to a dimmed version of a passed image |
Canvas::on_plus_contrast |
|
Receive: | N/A |
Return: | N/A |
Description: | Increments the current contrast of the working image and redisplays |
clarify |
|
Receive: | const wxImage *, int |
Return: | wxImage * |
Description: | returns a pointer to a contrasted version of a passed image |
Canvas::adjust_contrast_on_working_image |
|
Receive: | N/A |
Return: | N/A |
Description: | Depending on current contrast setting, clarifies or dulls the working image by the current amount. |
Canvas::on_minus_contrast |
|
Receive: | N/A |
Return: | N/A |
Description: | Decrements the current contrast of the working image and redisplays |
dull |
|
Receive: | const wxImage *, int |
Return: | wxImage * |
Description: | returns a pointer to a dulled version of a passed image |
reset_working_image_with_colour_settings |
|
Receive: | void |
Return: | void |
Description: | reinitializes contrast and brightness of the working image |
change_zoom_factor |
|
Receive: | default zoom factor |
Return: | void |
Description: | changes the zooming factor performed in point zooms and zoom outs |
shift_left |
|
Receive: | percentage of the current subimage frame by which to shift (double) |
Return: | void |
Description: | shifts the view of a zoomed image to the left. -shifts the bitmap, draws the new sliver of magnified area on the old bitmap, draws new bitmap -shifts at least 1 pixel by default |
shift_right |
|
Receive: | percentage of the current subimage frame by which to shift (double) |
Return: | void |
Description: | shifts the view of a zoomed image to the right. -shifts the bitmap, draws the new sliver of magnified area on the old bitmap, draws new bitmap -shifts at least 1 pixel by default |
shift_up |
|
Receive: | percentage of the current subimage frame by which to shift (double) |
Return: | void |
Description: | shifts the view of a zoomed image up. -shifts the bitmap, draws the new sliver of magnified area on the old bitmap, draws new bitmap -shifts at least 1 pixel by default |
shift_down |
|
Receive: | percentage of the current subimage frame by which to shift (double) |
Return: | void |
Description: | shifts the view of a zoomed image down. -shifts the bitmap, draws the new sliver of magnified area on the old bitmap, draws new bitmap -shifts at least 1 pixel by default |
draw_rest_of_shifted_image |
|
Receive: | the frame of the newly viewable are on the original image, position to draw on the bitmap (wxRect, wxPoint) |
Return: | void |
Description: | magnifies the frame and draws the image at a given position on the old bitmap |
pop_up_menu |
|
Receive: | void |
Return: | void |
Description: | displays a pop up menu on the panel |
on_key_down |
|
Receive: | void |
Return: | void |
Description: | captures key events passing to parent window |
|
Back |