I am working on an old C++ Console project which used Flash Graphics to plot data. I wish to upgrade this project so it calls GNUPlot to display the data. The original code was written so that it could accommodate other plotting software by placing all calls to Flash Graphics in a single C++ file so that it should be relatively simple to translate them to similar calls in another plotting package if required. I do not have the old Flash Graphics Libraries/code and so have had to comment out references to them to compile the project.
I understand that GNUPlot is probably one of the better open source plotting packages but cannot get GNUPlot to compile in the project. I think that GNUPlot was more designed to be used via "pipes" from the users project that called on the GNUPLot .exe to plot the data. Either way I'm a bit out of my depth now and would appreciate any help converting the Flash Graphics calls to GNUPlot (or any other plotting package suggested). I'm a newbie C++ student who is learning by customizing an old project but the graphics issue has really bogged me down. Any help would be appreciated. Using VS2008 console project.
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>
#include "disp.h"
#include <dos.h>
#include "const.h" // System, limitation constants, typedefs, structs
#include "classes.h" // Includes all class headers
#include "funcdefs.h" // Function prototypes
#include "fg.h" // FlashGraphics
static int mode ; static int drows, dcols ; static int crows, ccols ; static double aspect ;
int init_graphics ()
{
#ifdef FLASH_GRAPHICS
mode = fg_get_first () ;
while (mode) {
if (mode == FG_VGA12) {
drows = 480 ;
dcols = 640 ;
fg_set_8x16_font () ;
crows = fg.charbox[FG_Y2] + 1 ;
ccols = fg.charbox[FG_X2] + 1 ;
aspect = 3.0 / 4.0 ;
return 0 ; }
mode = fg_get_next () ;
}
mode = fg_get_first () ;
while (mode) {
if (mode == FG_VESA3) {
drows = 600 ;
dcols = 800 ;
fg_set_8x16_font () ;
crows = fg.charbox[FG_Y2] + 1 ;
ccols = fg.charbox[FG_X2] + 1 ;
aspect = 3.0 / 4.0 ;
return 0 ; }
mode = fg_get_next () ;
}
drows = -1 ; return 1 ; #endif // FLASH_GRAPHICS
return 1; }
void goto_graphics ( int *nrows , int *ncols , int *chrows , int *chcols ,
double *aspect_ratio )
{
#ifdef FLASH_GRAPHICS
if (drows <= 0)
return ;
fg_init_mode ( mode ) ;
*nrows = drows ;
*ncols = dcols ;
*aspect_ratio = aspect ;
*chrows = crows ;
*chcols = ccols ;
#endif // FLASH_GRAPHICS
}
void exit_graphics ()
{
#ifdef FLASH_GRAPHICS
if (drows <= 0)
return ;
fg_term () ;
#endif // FLASH_GRAPHICS
}
void drawline ( int x1 , int y1 , int x2 , int y2 , int color )
{
#ifdef FLASH_GRAPHICS
fg_line_t line ;
if (drows <= 0)
return ;
line[FG_X1] = x1 ;
line[FG_X2] = x2 ;
line[FG_Y1] = y1 ;
line[FG_Y2] = y2 ;
fg_drawline ( color , FG_MODE_SET , ~0 , FG_LINE_SOLID , line ) ;
#endif // FLASH_GRAPHICS
}
void write_graphics_text ( int row , int col , char *text , int color )
{
#ifdef FLASH_GRAPHICS
fg_box_t box ;
if (drows <= 0)
return ;
fg_make_box ( box , col , row , col + strlen ( text ) * ccols - 1 ,
row + crows - 1 ) ;
fg_box_normalize ( box ) ;
fg_fillbox ( 0 , FG_MODE_SET , ~0 , box ) ;
fg_puts ( color , FG_MODE_SET , ~0 , FG_ROT0 , col ,
row , text , fg.displaybox ) ;
#endif // FLASH_GRAPHICS
}
static unsigned short *screen = NULL ;
static unsigned short cursor_row, cursor_col ;
void init_textmode ()
{
#ifdef DISP_LIBRARY
if (disp_getmode () != 3)
disp_setmode ( 3 ) ;
disp_open () ;
#endif
}
void close_textmode ()
{
#ifdef DISP_LIBRARY
disp_close () ;
#endif
}
int save_screen ()
{
#ifdef DISP_LIBRARY
union REGS r ;
MEMTEXT ( "GRAPHICS: screen" ) ;
screen = MALLOC ( 25 * 80 * 2 ) ;
if (screen == NULL)
return 1 ;
r.h.ah = 3 ; r.h.bh = 0 ; int86 ( 0x10 , &r , &r ) ;
cursor_row = r.h.dh ;
cursor_col = r.h.dl ;
disp_peekbox ( screen , 0 , 0 , 24 , 79 ) ;
#endif
return 0 ;
}
void restore_screen ()
{
#ifdef DISP_LIBRARY
union REGS r ;
if (screen == NULL)
return ;
disp_pokebox ( screen , 0 , 0 , 24 , 79 ) ;
MEMTEXT ( "GRAPHICS: screen" ) ;
FREE ( screen ) ;
r.h.ah = 2 ; r.h.bh = 0 ; r.h.dh = cursor_row ;
r.h.dl = cursor_col ;
int86 ( 0x10 , &r , &r ) ;
#endif
}
What I have tried:
Have tried compiling GNUPlot within the project but run into so many problems that I cannot continue with that solution in the short term.