#include <iostream>
using namespace std;

#include "QTsupport.h"  // Headers required to use the Qdriver display 
#include "Qdriver.h"    // dialog. 
//
//######################################################################
//
// QtconsoleGraphicsTest.cpp : A QtConsoleGraphics Demonstration Program.
//
// This program invokes tests several member functions of the UCdriver 
// implemented by the Qdriver class. 
//
// When the program runs, graphics calls are captured by the Qdriver 
// display instance. When the frame() member function is called, a 
// dialog window appears containing the results of the graphics calls. 
// 
//
// Math 157                                                     1/16/09
//######################################################################
//

int main() 
{                                
    Qdriver display;
//       
//  Note : all of the calls using Qdriver assume coordinates in 
//  [0,1]X[0,1]. 
//
//  Plot a single red line from (x1,y1) to (x2,y2)
// 
    double x1 = 0.25;
    double y1 = 0.25;
    double x2 = 0.75;
    double y2 = 0.75;
    int dash_pattern      = 0; 
    unsigned user_pattern = 0;
    double width          = 0.003; 
    int   color           = UCdriver::RED;
    double rgb []         = {0,255,255};

    display.line(x1, y1, x2,  y2, dash_pattern, user_pattern, width, color, rgb);
//
//  Plot a blue bounding box for [0,1]x[0,1]
// 
    double  xb []  = {0.0, 1.0,1.0,0.0,0.0};
    double  yb []  =  {0.0, 0.0,1.0,1.0,0.0};
    dash_pattern   = 0; 
    user_pattern   = 0;
    width          = 0.; 
    color          = UCdriver::BLUE;
    
    display.lines(xb, yb, 5, dash_pattern, user_pattern, width, color, rgb);
//
//  Plot a green line from the points specified by the x and y arrays 
// 
    double x [] = {0.0,0.5,0.0};
    double y [] = {0.1,0.2,0.3};

    int npoints    = 3;
    dash_pattern   = 0; 
    user_pattern   = 0;
    width          = 0.0; 
    color          = UCdriver::GREEN;
    double* rgb2   = 0;

    display.lines(x, y, npoints, dash_pattern, user_pattern, width, color, rgb2);
    
//  Plot the string "It Works  3.14159" located at (0.5, 0.5). 
//
//
    double xf         = 0.5; 
    double yf         = 0.5;
    const char*  str  = "It Works 3.14159";
    const char* font  = 0;
    double size       = .05;
    double rotation   = 0.0;
    double horiz_just = 0.0;
    double vert_just  = 0.0;
    color             = UCdriver::BLUE;
    rgb2              = 0;

    display.text(xf, yf, str, font, size, rotation, 
    horiz_just,vert_just,color, rgb2);
//
//    Plot another string, default size, and 45 degree rotation in HersheySerif font
//
    xf                 = 0.5;
    yf                 = 0.35;
    const char* str2   = "Rotated String";
    const char* font2  = 0;
    size         = 0;
    rotation     = 45.0;
    horiz_just   = 0.0;
    vert_just    = 0.0;
    color        = UCdriver::RED;
    rgb2         = 0;
    size         = 0.0;

    display.text(xf,yf, str2, font2, size, rotation, 
    horiz_just,vert_just,color, rgb2);
//
//  Plot a "+" symbol at (0.25, 0.75). Make the symbol large by specifying
//  the size to be .1 (this means 1/10 the size of the drawing window)
//
    xf           = 0.25;
    yf           = 0.75;
    size         = 0.1;
    color        = UCdriver::MAGENTA;
    char p       = '+';
    display.point(xf, yf, p, font, size, color, rgb);
//
//  Plot several "*" symbols at the locations given by the arrays xp and yp.
//  Specify the default size by setting the size value to 0.0.
//
    double xp [] = {0.6, 0.7, 0.8};
    double yp [] = {0.3, 0.3, 0.3};
    p                  = '*';
    const char* font3  = "";
    size               = 0.00;
    color              = UCdriver::BLUE;
    rgb2               = 0;

    display.points(xp,yp,3,p,font3,size,color,rgb2); 
//
//  Demonstrate a filled triangle
//
    x[0] = .8;
    y[0] = .8;
    x[1] = .8;
    y[1] = .9;
    x[2] = .6;
    y[2] = .85;
    npoints = 3;
    rgb[0] =  200.0;
    rgb[1] =  50.0;
    rgb[2] =  100.0;
    
    display.region(x,y, npoints, rgb);
//
//  Display the graphics by invoking the frame() method.
//
    display.frame();

    
    return 0;
    
 }

