//--------------------------------------------------------- // A class to implement a graphics operations on a // normal Cartesian coordinate system. // // D. Searls // REPLACE THIS LINE WITH YOUR NAME!! //--------------------------------------------------------- #include #include using namespace std; #ifndef WORLDTYPE_H #define WORLDTYPE_H class worldType { private: double a, b; // screenX = a * worldX + b double c, d; // screenY = c * worldY + d int myID; // window identifier //----------------------------------------------------- // init // // Initialize the graphics window using the specified // properties. // // In Parameters: // width and height of window in pixels // title of the window // location on screen of upper-left corner (x, y) // // This function is called by each of the constructors. //----------------------------------------------------- void init(int width, int height, string title, int x, int y) { int grErrCode; myID = initwindow(width, height, title.c_str(), x, y, false, false); grErrCode = graphresult(); // Get result of initialization if( grErrCode != grOk ) // Error occured during init { cout << " Graphics System Error: " << grapherrormsg(grErrCode) << endl; exit( 1 ); } } //----------------------------------------------------- // screenX // // Given the specified world x-coordinate, return the // corresponding pixel coordinate. // // In parameter: worldX //----------------------------------------------------- int screenX(const double& worldX) { } //----------------------------------------------------- // screenY // // Given the specified world y-coordinate, return the // corresponding pixel coordinate. // // In parameter: worldY //----------------------------------------------------- int screenY(const double& worldY) { } public: //----------------------------------------------------- // Construct a world that is centered in the middle of // a 601 x 601 graphics window. The lower-left corner // of this window corresponds to (-1.0, -1.0) and the // upper-right corner corresponds to (1.0, 1.0). // // The title of the default graphics window is "World // Coordinate System" and it will be located in the // middle of the computer screen. //----------------------------------------------------- worldType() { // Set location of upper-left corner of window. int x = getmaxwidth()/2 - 300; int y = getmaxheight()/2 - 300; // Set coefficients of x mapping function. a = 300.0; b = 300.5; // Set coefficients of y mapping function. c = -300.0; d = 300.5; // Initialize graphics window init(601, 601, "World Coordinate System", x, y); } //----------------------------------------------------- // Construct a world based on the specified values. // // In Parameters: // width and height of graphics window // location of upper-left corner of graphics window (locx, locy) // lower-left corner of window corresponds to (x1, y1) // upper-right corner of window corresponds to (x2, y2) // title of graphics window //----------------------------------------------------- worldType(int width, int height, int locx, int locy, double x1, double y1, double x2, double y2, string title) { } //----------------------------------------------------- // reset // // Reset the coordinates of the lower-left corner of // this world to (x1, y1) and the upper-right corner // to (x2, y2). // // In parameters: x1, y1, x2, y2 //----------------------------------------------------- void reset(double x1, double y1, double x2, double y2) { } //----------------------------------------------------- // setActive // // Make this world the active world. //----------------------------------------------------- void setActive() { setcurrentwindow(myID); } //----------------------------------------------------- // close // // Close this world's graphic window. //----------------------------------------------------- void close() { closegraph(myID); } //----------------------------------------------------- // moveTo // // Move the current position to the specified point. // // In Parameters: x, y //----------------------------------------------------- void moveTo(double x, double y) { moveto(screenX(x), screenY(y)); } //----------------------------------------------------- // lineTo // // Draw a line from the current position to the // specified point and update the current position. // // In Parameters: x, y //----------------------------------------------------- void lineTo(double x, double y) { } //----------------------------------------------------- // drawLine // // Draw a line from (x1,y1) to (x2,y2) and set the // current position to (x2,y2). // // In Parameters: x1, y1, x2, y2 //----------------------------------------------------- void drawLine(double x1, double y1, double x2, double y2) { } }; #endif