/* Filename: MouseInput.cpp * * Author: Br. Isidore Minerd * * Date: August 6, 2009 * * Description: This application will build a file which will be used to render a drawing * comprised of circles and rectangles. * The output data file's format is explained in the included file named * "fileformat.txt" * * The file which is generated is named "drawing.txt" */ #include #include using namespace std; #define RECTANGLE_TYPE 1 #define CIRCLE_TYPE 2 int main() { char imageShape; int filled,ulx,uly,lrx,lry,cx,cy,r; fstream outFile; outFile.open("drawing.txt",ios::out); if(outFile.fail()) { cout << "Error opening drawing.txt for writing!"; return 0; } cout << "Let's create an image file!\n"; do { cout << "-- Shape types --\nR: Rectangle\nC: Circle\nEnter a shape code ('Q' to quit): "; cin >> imageShape; imageShape = toupper(imageShape); switch(imageShape) { case 'R': cout << "Filled (0 for no, any other number for yes):"; cin >> filled; if(filled != 0) { filled = 1; } cout << "Enter coordinates separated by spaces in the order ULX ULY LRX LRY: "; cin >> ulx >> uly >> lrx >> lry; cout << "Thank you very much. Please enter another...\n\n"; outFile << RECTANGLE_TYPE << " " << filled << " " << ulx << " " << uly << " " << lrx << " " << lry << "\n"; break; case 'C': cout << "Filled (0 for no, any other number for yes):"; cin >> filled; if(filled != 0) { filled = 1; } cout << "Enter coordinates for the center separated by spaces in the order CX CY: "; cin >> cx >> cy; cout << "Enter Radius: "; cin >> r; cout << "Thank you very much. Please enter another...\n\n"; outFile << CIRCLE_TYPE << " " << filled << " " << cx << " " << cy << " " << r << "\n"; break; case 'Q': break; default: cout << "\nInvalid shape code!\n\n"; } } while(imageShape != 'Q'); outFile.close(); }