DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

PPM Menu

The previous assignments have built up several functions that allow the ability to read PPM images from files, modify the images, and write images to files.

This assignment will create an application with a menu based interface that allows users to select actions on PPM objects. It will combine the previous work with a few new functions to make a text based image editing program.

Assignment

In this assignment, you will add a new program to the project. This program will have the image editing capabilities mentioned above.

It is expected that all previous programs will still work unchanged.

Programming Requirements

Now that you have the ActionData and MenuData classes, most functions will need to be updated as noted below. For each function, update the parameter list to match the list shown below. Be sure to do this in the header file as well as the implementation file. After updating the parameter list, edit the rest of the function to use the ActionData object instead of the previous parameters. For example use action_data.getIS() where you used to use is. A similar substitution will be needed to replace os. See the Additional Documentation section below for an example.

The following files must be updated or created and stored in the src directory of your repository.

Update user_io.cpp and image_menu.h

Update these functions:

Add these functions:

Update image_drawing.cpp and image_menu.h

Update these functions:

Add these functions:

Update image_output.cpp and image_menu.h

Update these functions:

Add these functions:

Update controllers.cpp and image_menu.h

In each of the assignment*() functions create an ActionData object passing is and os to its constructor. Then, update all of the function calls in to pass the ActionData object as appropriate. If the function calls a function that modifies input image 1, then calls another that reads output image, copy the input image 1 to the output image between those calls. See the examples from the Additional Documentation section.

Update these functions:

Add these functions, they will support the menu driven application for editing images. They include imageMenu() the main loop that controls the new application.

Table of Commands

Command Name Function Name Description
draw-ascii drawAsciiImage “Write output image to terminal as ASCII art.”
write writeUserImage “Write output image to file.”
copy copyImage “Copy input image 1 to output image.”
read1 readUserImage1 “Read file into input image 1.”
# commentLine “Comment to end of line.”
size setSize “Set the size of input image 1.”
max-color-value setMaxColorValue “Set the max color value of input image 1.”
channel setChannel “Set a channel value in input image 1.”
pixel setPixel “Set a pixel’s 3 values in input image 1.”
clear clearAll “Set all pixels to 0,0,0 in input image 1.”
quit quit “Quit.”

ShowMenu() Example

If the following actions have been added to the MenuData via addAction():

menu_data.addAction("a", a_one_function, "A-One");
menu_data.addAction("b", balsamic_function, "Balsamic");
menu_data.addAction("c", chipotle_function, "Chipotle");
menu_data.addAction("d", dijon_function, "Dijon");

then the expected output would look like this:

a) A-One
b) Balsamic
c) Chipotle
d) Dijon

Create ppm_menu.cpp

This file must include the implementations of the following functions:

Update Makefile

This file must now also include the rules to build the program ppm_menu. The following commands should work correctly.

Additional Documentation

Show Off Your Work

To receive credit for this assignment, you must

Additionally, the programs must build, run and give correct output.

Last Updated 09/11/2023