//**************************************************************************//
//* FRIDA: flexible rapid interactive data analysis                        *//
//* dualplot: different mechanisms for screen and paper output             *//
//* (C) Joachim Wuttke 1990-, v2(C++) 2001-                                *//
//* http://apps.jcns.fz-juelich.de                                         *//
//**************************************************************************//

#include "axis.h"

//! One plot window.

class CPlot {
 public:
    uint iPlot;             ///< The index of this window in NPloWin::Plots.
    CAxis X, Y;
    // For data plotting:
    uint maxpoints;
    bool with_errors;
    // For curve plotting:
    uint equipoints;
    bool refine;

    CPlot( uint _iPlot, bool _logx, bool _logy );

    void gp_write( string );
    void clearFrame();
    void plotFrame( string xlabel, string ylabel );
    void addSpec( bool as_line, bool new_style, int style_no,
                  const vector<double>& xp,
                  const vector<double>& yp, const vector<double>& dyp,
                  const vector<double>& z,
                  string xco, string yco, string info );
    void showSpecs();
    void docTxLine( const string& line );
    void docPtTxLine( const string& line, uint num );
    void docCvTxLine( const string& line, uint num );
    void writePostscript( string ps_outdir, string ps_head, string ps_dict );
    void setAux( string cmd );
    string info() const;

private:
    int gp_fifo;
    int gp_fno;
    string gp_fnames;

    uint ps_fnum; // file
    uint ps_snum; // spectrum
    uint ps_pnum; // spectrum with pstyle
    uint ps_cnum; // spectrum with cstyle
    void ps_ticktack( const vector<double>& Tacks, int ntpt,
                      const double *ticklim, const CAxis *A );
    vector<string> ps_Doc;
    vector<string> ps_accu; // future output is accumulated here
};

//! Direct access to plot windows collection.

namespace NPloWin {
    extern vector<CPlot*> Plots; ///< This vector holds all plot windows.
    extern uint nPlot;           ///< Must be kept equal to Plots.size().
    extern uint iPlot;           ///< Index of currently active plot window.

    void initialize();
};