/*
 GerberConversion
 Copyright (C) 2010 Martin Štrympl
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public
 License as published by the Free Software Foundation; either
 version 3.0 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 General Public License for more details.
 
 You should have received a copy of the GNU General Public
 License along with this program.
 
 Martin Štrympl
 xstrym00@stud.feec.vutbr.cz
 */

/*
 *  gerber.h
 *  GerberConversion
 *
 *  Created by Martin Štrympl on 10/31/10.
 *  Copyright 2010 School. All rights reserved.
 *
 */
 
#include "Headers.h"

#ifndef GERBER_H_INCLUDED
#define GERBER_H_INCLUDED

#include "Draw.h"

#include "Settings.h"

#include "Dcodes.h"

#include "Gcodes.h"

#include "Dynamic.h"

struct sGerber_Gerber_Actual
{
  struct sGerber_Gerber_Actual_Behavior s_behavior;
  
  struct sGerber_Gerber_Actual_XY s_xy;
  
  struct sGerber_Gerber_Actual_AS s_as;
  
  struct sGerber_Gerber_Actual_FS s_fs;
  
  struct sGerber_Gerber_Actual_IO s_io;
  struct sGerber_Gerber_Actual_IP s_ip;
  struct sGerber_Gerber_Actual_IR s_ir;
  
  struct sGerber_Gerber_Actual_LP s_lp;
  
  struct sGerber_Gerber_Actual_MO s_mo;
  struct sGerber_Gerber_Actual_MI s_mi;
  
  struct sGerber_Gerber_Actual_OF s_of;
  struct sGerber_Gerber_Actual_SF s_sf;
  
  struct sGerber_Gerber_Actual_Sets s_sets;
  
  //Dcodes
  struct sDcode_Dcodes s_dcodes;
  uint32_t u4_selectedDcode;
  
  fGcode_Gcodes_Gcode f_gcode;
};

struct sGerber_Gerber;

typedef int (*fGerber_Gerber_Code)(struct sGerber_Gerber *ps_gerber, struct sGerber_Gerber_Actual *ps_actual, char **pt_text);
typedef int (*fGerber_Gerber_Settings)(struct sGerber_Gerber *ps_gerber, struct sGerber_Gerber_Actual *ps_actual, char **pt_text);

#define Mac_Head_Gerber_Gerber_Code struct sGerber_Gerber *ps_gerber, struct sGerber_Gerber_Actual *ps_actual, char **pt_text
#define Mac_Head_Gerber_Gerber_Settings struct sGerber_Gerber *ps_gerber, struct sGerber_Gerber_Actual *ps_actual, char **pt_text

#define Mac_Fun_Gerber_Gerber_Code(name) int name(Mac_Head_Gerber_Gerber_Code)
#define Mac_Fun_Gerber_Gerber_Settings(name) int name(Mac_Head_Gerber_Gerber_Settings)

struct sGerber_Gerber;

struct sGerber_Gerber * Gerber_Gerber_Construct();
void Gerber_Gerber_Destruct(struct sGerber_Gerber *ps_gerber);

struct sGerber_Gerber_Actual * Gerber_Gerber_GetActual(struct sGerber_Gerber *ps_gerber);

bool Gerber_Gerber_RegisterCode(struct sGerber_Gerber *ps_gerber, const char *t_begin, fGerber_Gerber_Code f_code);
bool Gerber_Gerber_RegisterSettings(struct sGerber_Gerber *ps_gerber, const char *t_begin, fGerber_Gerber_Settings f_settings);
bool Gerber_Gerber_RegisterOutput(struct sGerber_Gerber *ps_gerber, DLHANDLE v_lib, void *v_memory, fGerber_Draw_LineSegment f_linesegment, fGerber_Draw_OvalSegment f_ovalsegment);

int Gerber_Gerber_LineSegment(struct sGerber_Gerber *ps_gerber, struct sGerber_Point *ps_From, struct sGerber_Point *ps_To, bool b_incut);
int Gerber_Gerber_OvalSegment(struct sGerber_Gerber *ps_gerber, struct sGerber_Point *ps_centre, double do_radiusX, double do_radiusY,
                                 double do_aglefrom, double do_agleto, bool b_incut);

bool Gerber_Gerber_LoadFile(struct sGerber_Gerber *ps_gerber, const char *t_file);


#endif //GERBER_H_INCLUDED
