/*---------------------------------------------------------------------------------------------------------------------
- File      : ps_output.h                                                                 Project ELSE, EPFL - DI/LIA -
-                                                                       Evaluation in Language and Speech Engineering -
- Author    : Raphaël Rossi     Creation date : 18 Aug 1998                                                           -
- Eulogist  : -                 Approval date : -                  Version: 1.3                                       -
-                                                                                                                     -
- Descript. : Postscript output for the Grace Evaluation programs;                                                    -
-                                                                                                                     -
-             Define some private functions to draw line or to move to a point, and it gives two fonctions:           -
-             - one for drawing the score postscript file                                                             -
-             - one for drawing the box postscript file                                                               -
-                                                                                                                     -
-             It doesn't produce an optimized postscript file, cause of his generic fonction library.                 -
-                                                                                                                     -
- Requested : -                                                                                                       -
-                                                                                                                     -
- Gaps      : points, boxes and triangles must be defined in several separate classes, (idem for internal objects,    -
-             like title, subtitle, arrows collection).                                                               -
-                                                                                                                     -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Rev. date | Reviser               | Revise's description                                                            -
- - - - - - + - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 09/10/1998| Chappelier J.-C.      | -                                                                               -
- 30/09/1999| Seydoux F.            | Formatting source, and minor adjustements for regular strings instead of string -
- ../../....| ........              | ...                                                                             -
---------------------------------------------------------------------------------------------------------------------*/

#ifndef PS_OUTPUT_H
#define PS_OUTPUT_H

#include <string>
#include <fstream>
#include "globaldef.h"

#ifdef _USE_NAMESPACES
    namespace Else { 
#endif // _USE_NAMESPACES

class PsOutput {
 // Pre-definition (type, friend, inner classes) ............................................................

public:
	// Public types definition .............................................................................
	
	// Class's public methodes .............................................................................

	// Class's public attributes ...........................................................................

	// Intances's public methodes ..........................................................................
	// Spcl member methodes (Constructors, destructors, copy cstr) ......................
	PsOutput(const string& filename, const string& graph_title, const string& message,
	         const Real& originX = 50.0, const Real& originY = 550.0, const Real& scalelength = 400.0);
	~PsOutput();

    // Operators definition ............................................................
    // Others methodes .................................................................

	void triangle_print(const Real& P, const Real& D,
	                    const Real& Pmin, const Real& Pmoy, const Real& Pmax,
	                    const VeryLongNatural& nbCases);
        
	void box_print(const Real& subPmin, const Real& subPMoy,
                   const Real& Pmoy, const Real& supPmoy,
                   const Real& supPmax, const VeryLongNatural& nbCases);        

	// set the graph for multiple triangle drawing. Has to be called after the creation of the object.
	void triangles_print(const VeryLongNatural& nbrTrgl);

	void add_triangle(const Real& P, const Real& D, const Real& Pmin, const Real& Pmax,
                      const VeryLongNatural& nbCases, const Real& color, const string& name);

	// draw the graph like the triangle graph but only with the score points.
	void add_point(const Real& P, const Real& D, const VeryLongNatural& nbCases, const string& name);


	// set the graph for multiple boxes drawing. Has to be called after the creation of the object.
	void boxes_print(const VeryLongNatural& nbrBoxes);
    
	// add a box in a multiple boxes graph
	void add_box(const Real& minPmin, const Real& minMoyP, const Real& Pmoy, const Real& maxMoyP,
	             const Real& maxPmax, const VeryLongNatural& nbCases, const Real& y_position, const string& name);


	// Instances's public attributes .......................................................................

protected:
	// Class's protected methodes ..........................................................................

	// Class's protected attributes ........................................................................

	// Intances's protected methodes .......................................................................

	// Instances's protected attributes ....................................................................

private:
	// Class's private methodes ............................................................................

	// Class's private attributes ..........................................................................

	// Intances's private methodes .........................................................................

	void setscale(const string& name, const Real& scale_length);
	void set_current_color(const Real& color); // set gray level, 0.0 = black, 1.0 = white
	void setposition(const Real& x, const Real& y);
	void drawtitle(const Real& y = 50.0, const Real& titleSize = 30.0); // draw title at position x-centered y
	void drawsubtitle(const Real& y = 75.0, const Real& subTitleSize = 20.0);
	void drawarrow(const Real& x1, const Real& y1, const Real& x2, const Real& y2, const Real& x3, const Real& y3);
	void drawline(const Real& fromX, const Real& fromY, const Real& incrX, const Real& incrY);
	void drawgrid(const VeryLongNatural& line_number, const bool with_segment = true, const bool vertical_only = false);
	void draw_line_grid(const VeryLongNatural& line_number);
	void drawsegment(const Real& fromX, const Real& fromY, const Real& incrX, const Real& incrY);
	void drawbox(const Real& fromX, const Real& fromY, const Real& incrX, const Real& incrY); // draw empty box
	void drawlabel(const Real& x, const Real& y, const string& label, const Real& labelSize, const Real& width = 1.0);
	void drawtext(const Real& x, const Real& y, const string& text, const Real& textSize, const Real& width = 1.0);

	// Instances's private attributes ......................................................................

	ofstream* ps_file;     // handle of the postscript file
	string title;          // title of the graph
	string subtitle;       // subtitle of the graph
	Real scaleX0,scaleY0;  // graph origin points
	string scale_name;     // define the postscript name of the value of the scale
	Real info_pos_y;       // current legend position
	Real line_space;       // space between line legend
	Real scalelength;      // define the scale size of the graph
	char system_char;      // define the char that symbolize a system in the point graph
    
};

#ifdef _USE_NAMESPACES
}
#endif // _USE_NAMESPACES

#endif

