surkhe 6 months ago
parent
commit
03196ec4a8
  1. 8
      AboutWindow.cpp
  2. 8
      AboutWindow.h
  3. 17
      GBCSolution.cpp
  4. 13
      GBCSolution.h
  5. 45
      GNU_Ballistics.cpp
  6. 327
      InputWindow.cpp
  7. 36
      InputWindow.h
  8. 10
      LicenseWindow.cpp
  9. 9
      LicenseWindow.h
  10. 57
      Makefile
  11. 52
      Makefile.slack
  12. 57
      Makefile.win32
  13. 12
      PBRWindow.cpp
  14. 18
      PBRWindow.h
  15. 14
      PlotWindow.cpp
  16. 26
      PlotWindow.h
  17. 36
      RangeWindow.cpp
  18. 20
      RangeWindow.h
  19. 27
      Readme.txt
  20. 20
      blib/_angle.c
  21. 38
      blib/_atmosphere.c
  22. 113
      blib/_pbr.c
  23. 116
      blib/_retard.c
  24. 73
      blib/_retrieve.c
  25. 70
      blib/_solve.c
  26. 19
      blib/_windage.c
  27. 78
      blib/_zero.c
  28. 46
      blib/example.c
  29. 4
      blib/src/Makefile
  30. 591
      blib/src/ballistics.c
  31. 109
      blib/src/ballistics.h
  32. 63
      blib/src/internal.h

8
AboutWindow.cpp

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
#include "AboutWindow.h"
AboutWindow::AboutWindow(void) : Fl_Window(600,400,"About GNU Ballistics Computer"){
begin();
lic = new Fl_Text_Display(5,5,590,390);
Fl_Text_Buffer* buf = new Fl_Text_Buffer(36000);
buf = new Fl_Text_Buffer(36000);
buf->text("GNU Exterior Ballistics Computer v1.00\n\
Created by: Derek R. Yates\n\
@ -49,9 +49,7 @@ and wish you the best shooting.\n"); @@ -49,9 +49,7 @@ and wish you the best shooting.\n");
}
AboutWindow::~AboutWindow(void){
delete lic;
delete buf;
}

8
AboutWindow.h

@ -1,6 +1,13 @@ @@ -1,6 +1,13 @@
#ifndef __ABOUTWINDOW
#define __ABOUTWINDOW
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Text_Buffer.H>
#include <stdio.h>
#include <stdlib.h>
class AboutWindow : public Fl_Window {
public:
@ -9,6 +16,7 @@ class AboutWindow : public Fl_Window { @@ -9,6 +16,7 @@ class AboutWindow : public Fl_Window {
private:
Fl_Text_Display* lic;
Fl_Text_Buffer* buf;
};

17
GBCSolution.cpp

@ -1,8 +1,10 @@ @@ -1,8 +1,10 @@
#include "GBCSolution.h"
GBCSolution::GBCSolution(void){
}
GBCSolution::GBCSolution(double* isolution, const char* iname, double ibc, double isightheight, int iweight, int imv, int iangle, int izerorange, int iwindspeed, int iwindangle, int itemp, int ihumidity, double ipressure, int ialtitude, int entries, int useweather){
GBCSolution::GBCSolution(double* isolution, const char* iname, double ibc, double isightheight, int iweight, int imv, int iangle, int izerorange, int iwindspeed, int iwindangle, int itemp, int ihumidity, double ipressure, int ialtitude, int entries, int useweather, int idf){
sln=isolution;
strcpy(name,iname);
@ -20,16 +22,19 @@ GBCSolution::GBCSolution(double* isolution, const char* iname, double ibc, doubl @@ -20,16 +22,19 @@ GBCSolution::GBCSolution(double* isolution, const char* iname, double ibc, doubl
altitude=ialtitude;
rows=entries;
ckweather=useweather;
df = idf;
}
GBCSolution::~GBCSolution(){
//delete[] name;
}
GBCSolution::~GBCSolution(){
if (this->sln != NULL) {
free(this->sln);
}
}
const char* GBCSolution::Name(void){

13
GBCSolution.h

@ -1,3 +1,10 @@ @@ -1,3 +1,10 @@
#ifndef GBCSOLUTION_H
#define GBCSOLUTION_H
#include "blib/src/ballistics.h"
#include <stdio.h>
#include <string.h>
class GBCSolution {
public:
@ -18,7 +25,8 @@ class GBCSolution { @@ -18,7 +25,8 @@ class GBCSolution {
double ipressure,
int ialtitude,
int rows,
int ckweather
int ckweather,
int df
);
~GBCSolution();
@ -51,6 +59,8 @@ class GBCSolution { @@ -51,6 +59,8 @@ class GBCSolution {
double GetVx(int yardage);
double GetVy(int yardage);
double GetEnergy(int yardage);
int df;
private:
double* solution;
@ -73,3 +83,4 @@ class GBCSolution { @@ -73,3 +83,4 @@ class GBCSolution {
};
#endif

45
GNU_Ballistics.cpp

@ -1,54 +1,9 @@ @@ -1,54 +1,9 @@
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Output.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Round_Button.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Int_Input.H>
#include <FL/Fl_Float_Input.H>
#include <FL/Fl_Multiline_Output.H>
#include <FL/Fl_BMP_Image.H>
#include <FL/Fl_Multi_Browser.H>
#include <FL/Fl_File_Input.H>
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Help_Dialog.H>
#include <FL/Fl_Chart.H>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "AboutWindow.h"
#include "LicenseWindow.h"
#include "GBCSolution.h"
#include "blib/ballistics.h"
#include "InputWindow.h"
#include "RangeWindow.h"
#include "PlotWindow.h"
#include "PBRWindow.h"
#include "PlotWindow.cpp"
#include "InputWindow.cpp"
#include "RangeWindow.cpp"
#include "GBCSolution.cpp"
#include "LicenseWindow.cpp"
#include "AboutWindow.cpp"
#include "PBRWindow.cpp"
using namespace std;
void InitMenu(InputWindow*);
int main (){
InputWindow win(400,500,"GNU Exterior Ballistics Computer");
return Fl::run();
}

327
InputWindow.cpp

@ -1,29 +1,32 @@ @@ -1,29 +1,32 @@
#include "blib/src/ballistics.h"
#include "InputWindow.h"
InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){
// Solution pointers. Right now we only use gsln as the general solution pointer.
// Solution pointers. Must be initialized to NULL so we don't accidentally try to free them later.
gsln=NULL;
mem1=NULL;
mem2=NULL;
// A (double*) pointer to the actual solution data. Initialize to
// Null so we can make sure to free any memory it has after a solution
// is closed.
Solution=NULL;
Smem1=NULL;
Smem2=NULL;
useSolution=1;
// A (double*) pointer to the actual solution data. Initialize to
// Null so we can make sure to free any memory it has after a solution
// is closed.
Solution=NULL;
Smem1=NULL;
Smem2=NULL;
// *** To be removed at next build useSolution=1;
// Start drawing the widgets on screen.
begin();
begin();
// Draw any general purpose borders or labels.
Fl_Box* GBox = new Fl_Box(250,80,140,95,"Drag Function");
GBox->box(FL_BORDER_BOX);
GBox->align(FL_ALIGN_LEFT | FL_ALIGN_TOP | FL_ALIGN_INSIDE);
// Create and place the Drag Function inputs on the form.
inG1 = new Fl_Round_Button(270,105,30,15,"G1");
inG2 = new Fl_Round_Button(270,125,30,15,"G2");
@ -31,18 +34,18 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){ @@ -31,18 +34,18 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){
inG6 = new Fl_Round_Button(330,105,30,15,"G6");
inG7 = new Fl_Round_Button(330,125,30,15,"G7");
inG8 = new Fl_Round_Button(330,145,30,15,"G8");
inG1->type(FL_RADIO_BUTTON);
inG2->type(FL_RADIO_BUTTON);
inG5->type(FL_RADIO_BUTTON);
inG6->type(FL_RADIO_BUTTON);
inG7->type(FL_RADIO_BUTTON);
inG8->type(FL_RADIO_BUTTON);
inG1->set();
// Create and place the input fields on the form.
inName = new Fl_Input(55,45,335,20,"Name ");
inBC = new Fl_Float_Input(10,80,50,20," Drag Coefficient");
@ -127,13 +130,7 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){ @@ -127,13 +130,7 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){
Fl_Menu_Item mc_New = {"&New...",0,(Fl_Callback*)cb_mNew,this};
Fl_Menu_Item mc_Open = {"&Open...",0,(Fl_Callback*)cb_Open,this};
Fl_Menu_Item mc_Save = {"&Save...",0,(Fl_Callback*)cb_Save,this};
//Fl_Menu_Item mc_Export = {"&Export Data...",0,(Fl_Callback*)cb_Nothing};
Fl_Menu_Item mc_Quit = {"&Quit",0,(Fl_Callback*)cb_Quit};
//Fl_Menu_Item m_Edit = {"&Edit",0,0,0, FL_SUBMENU};
//Fl_Menu_Item mc_Copy = {"&Copy",0,(Fl_Callback*)cb_Copy,this};
//Fl_Menu_Item mc_Paste = {"&Paste",0,(Fl_Callback*)cb_Paste,this};
//Fl_Menu_Item mc_Options = {"&Options",0,(Fl_Callback*)cb_Nothing};
Fl_Menu_Item m_Analyze = {"&Analyze",0,0,0, FL_SUBMENU};
Fl_Menu_Item mc_Table = {"&Range Table",0,(Fl_Callback*)cb_RangeTable,this};
@ -143,19 +140,14 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){ @@ -143,19 +140,14 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){
Fl_Menu_Item m_Aids = {"Shooting &Aids",0,0,0, FL_SUBMENU};
Fl_Menu_Item mc_RangeCard = {"&Range Card",0,(Fl_Callback*)cb_Nothing};
Fl_Menu_Item mc_ClickChart = {"&Click Chart",0,(Fl_Callback*)cb_Nothing};
//Fl_Menu_Item mc_RangeTable = {"&Range Table",0,(Fl_Callback*)cb_Nothing};
Fl_Menu_Item m_Solution = {"&Analysis",0,0,0, FL_SUBMENU};
//Fl_Menu_Item mc_Solve = {"&Solve",0,(Fl_Callback*)cb_Solve,this};
Fl_Menu_Item mc_Advanced = {"&Advanced Settings",0,(Fl_Callback*)cb_Nothing};
Fl_Menu_Item m_Help = {"&Help",0,0,0, FL_SUBMENU};
Fl_Menu_Item mc_Help = {"&Help",0,(Fl_Callback*)cb_HelpWindow};
Fl_Menu_Item mc_License = {"&License",0,(Fl_Callback*)cb_LicenseWindow};
Fl_Menu_Item mc_About = {"&About",0,(Fl_Callback*)cb_AboutWindow};
Fl_Menu_Item m_Tools = {"&Tools",0,0,0, FL_SUBMENU};
Fl_Menu_Item mc_OptimizePBR = {"&Optimize PBR",0,(Fl_Callback*)cb_PBR,this};
Fl_Menu_Item mc_CalcBC = {"&Calculate Drag Coefficient",0,(Fl_Callback*)cb_Nothing};
@ -163,9 +155,6 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){ @@ -163,9 +155,6 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){
Fl_Menu_Item m_Compare = {"&Solution Memory",0,0,0, FL_SUBMENU};
Fl_Menu_Item mc_Store1 = {"Store to Memory 1 ",0,(Fl_Callback*)cb_Store1,this};
Fl_Menu_Item mc_Store2 = {"Store to Memory 2 ",0,(Fl_Callback*)cb_Store2,this};
//Fl_Menu_Item mc_Store3 = {"Save to Memory 3 ",0,(Fl_Callback*)cb_Store3,this};
//Fl_Menu_Item mc_Store4 = {"Save to Memory 4 ",0,(Fl_Callback*)cb_Store4,this};
//Fl_Menu_Item mc_Store5 = {"Save to Memory 5 ",0,(Fl_Callback*)cb_Store5,this,FL_MENU_DIVIDER};
// Set initial condition for menu items.
@ -176,17 +165,11 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){ @@ -176,17 +165,11 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){
// These are planned features, but haven't been done yet.
////// TODO //////
mc_Advanced.deactivate(); // Maybe no need?
mc_Copy.deactivate(); // Can't figure out how to make this work. User can use Ctrl-c until I get some help.
mc_Options.deactivate(); // Eventually add support for metric
mc_Compare.deactivate();
mc_RangeCard.deactivate();
mc_ClickChart.deactivate();
//mc_RangeTable.deactivate();
//mc_Table.deactivate();
mc_CalcBC.deactivate();
//mc_OptimizePBR.deactivate();
//mc_Plot.deactivate();
m_Solution.deactivate();
m_Compare.deactivate();
@ -197,19 +180,12 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){ @@ -197,19 +180,12 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){
mc_Save,
mc_Quit,
{0},//5
//m_Edit,
//mc_Copy,
//mc_Paste,
//mc_Options,
//{0},
m_Solution, //6
//mc_Solve,
mc_Table,
mc_Plot,
mc_Compare,
mc_RangeCard,
mc_ClickChart,
//mc_RangeTable,
{0}, // 12
m_Tools,
mc_OptimizePBR,
@ -218,24 +194,20 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){ @@ -218,24 +194,20 @@ InputWindow::InputWindow(int w, int h, const char* title):Fl_Window(w,h,title){
m_Compare, //17
mc_Store1, //18
mc_Store2, //19
//mc_Store3,
//mc_Store4,
//mc_Store5,
{0},
m_Help, //26
mc_Help,
mc_License,
mc_About,
mc_Bug,
{0}, //31
{0}
};
menu->copy(menuitems);
end();
show();
{0}
};
menu->copy(menuitems);
end();
show();
}
@ -272,6 +244,31 @@ InputWindow::~InputWindow(){ @@ -272,6 +244,31 @@ InputWindow::~InputWindow(){
Solution=NULL;
}
delete inG1;
delete inG2;
delete inG5;
delete inG6;
delete inG7;
delete inG8;
delete inName;
delete inBC;
delete inWeight;
delete inMV;
delete inZero;
delete inSH;
delete inAngle;
delete inVwind;
delete inAwind;
delete ckWeather;
delete inAltitude;
delete inTemp;
delete inPressure;
delete inHumidity;
delete oStatus;
delete btSolve;
delete btReset;
}
void InputWindow::cb_ckWeather(Fl_Widget* o, void* v){
InputWindow* T=(InputWindow*)v;
@ -298,12 +295,12 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) { @@ -298,12 +295,12 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) {
// Disable the analysis menu.
DisableMenu(vd);
InputWindow* T = (InputWindow*)vd;
// Make some local pointers to use in the function, before we assign the solution
// to the currently selected "working" solution on the UI.
GBCSolution* lsln = NULL;
double* lSolution = NULL;
GBCSolution* lsln = NULL;
double* lSolution = NULL;
double bc=-1; // The ballistic coefficient for the projectile.
double v=-1; // Intial velocity, in ft/s
double sh=-1; // The Sight height over bore, in inches.
@ -314,9 +311,9 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) { @@ -314,9 +311,9 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) {
int df=0;
int numRows=0;
char txt1[1024];
double zeroangle=-1; // The bore / sight angle.
bc = atof(T->inBC->value());
v = atof(T->inMV->value());
sh = atof(T->inSH->value());
@ -324,32 +321,32 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) { @@ -324,32 +321,32 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) {
zero=atof(T->inZero->value());
windspeed=atof(T->inVwind->value());
windangle=atof(T->inAwind->value());
if (T->inG1->value()==1) df=G1;
else if (T->inG2->value()==1) df=G2;
else if (T->inG5->value()==1) df=G5;
else if (T->inG6->value()==1) df=G6;
else if (T->inG7->value()==1) df=G7;
else if (T->inG8->value()==1) df=G8;
// If the Enable Weather checkbox is activated, we correct the
// Ballistic coefficient for the non-std weather conditions.
if (T->ckWeather->value()==1){
double Altitude = atof(T->inAltitude->value());
double Barometer = atof(T->inPressure->value());
double Temperature = atof(T->inTemp->value());
double RH = atof(T->inHumidity->value())/100;
bc = AtmCorrect(bc, Altitude,Barometer,Temperature,RH);
}
}
// Find the zero angle of the bore relative to the sighting system.
zeroangle=ZeroAngle(df,bc,v,sh,zero,0);
// Generate a solution using the GNU Ballistics library call.
numRows = SolveAll(df,bc,v,sh,angle,zeroangle,windspeed,windangle,&(lSolution));
// If we get a valid solution, store it as a new GBC Solution.
// T->gsln was cleaned up at the beginning of this function,
// so we know it points to NULL already.
@ -371,8 +368,9 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) { @@ -371,8 +368,9 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) {
atoi(T->inHumidity->value()),
atof(T->inPressure->value()),
atoi(T->inAltitude->value()),
(int)T->Solution[10*__BCOMP_MAXRANGE__+1],
T->ckWeather->value()
(int)lSolution[10*__BCOMP_MAXRANGE__+1],
T->ckWeather->value(),
df
);
// Update the maximum valid range of the solution.
@ -394,23 +392,22 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) { @@ -394,23 +392,22 @@ void InputWindow::cb_Solve(Fl_Widget* o, void* vd) {
// Now we need to figure out which solution the user wanted to store this as, and
// assign our local pointers to the user's requested solution.
if (T->gsln!=NULL){
if (T->gsln->sln != NULL) free(T->gsln->sln);
if (T->gsln != NULL){
//if (T->gsln->sln != NULL) printf("398: T->gsln->sln = %p",T->gsln->sln); //free(T->gsln->sln);
delete(T->gsln);
}
T->gsln=lsln;
}
return;
}
}
T->gsln=lsln;
}
return;
}
void InputWindow::EnableMenu(void* v){
InputWindow* T = (InputWindow*)v;
@ -461,7 +458,7 @@ void InputWindow::cb_Quit(Fl_Widget*, void* v) { @@ -461,7 +458,7 @@ void InputWindow::cb_Quit(Fl_Widget*, void* v) {
void InputWindow::cb_Clear(Fl_Widget* o, void* v) {
InputWindow* T=(InputWindow*)v;
// When the "Reset" button is clicked, we want to
// clear out the old solution and restore std. conditions.
DisableMenu(v);
@ -481,6 +478,14 @@ void InputWindow::cb_Clear(Fl_Widget* o, void* v) { @@ -481,6 +478,14 @@ void InputWindow::cb_Clear(Fl_Widget* o, void* v) {
T->ckWeather->clear();
T->cb_ckWeather(o,v);
T->oStatus->value("GNU Ballistic Computer: Solution Reset");
T->inG1->value(1);
T->inG2->value(0);
T->inG5->value(0);
T->inG6->value(0);
T->inG7->value(0);
T->inG8->value(0);
// Free up any memory we have been using.
if (T->Solution != NULL) {
@ -489,11 +494,16 @@ void InputWindow::cb_Clear(Fl_Widget* o, void* v) { @@ -489,11 +494,16 @@ void InputWindow::cb_Clear(Fl_Widget* o, void* v) {
}
if (T->gsln != NULL) {
if (T->gsln->sln!=NULL) free (T->gsln->sln);
if (T->gsln->sln!=NULL) {
free (T->gsln->sln);
T->gsln->sln=NULL;
}
T->gsln->~GBCSolution();
delete(T->gsln);
T->gsln=NULL;
}
delete(T->gsln);
T->gsln=NULL;
}
if (T->mem1 != NULL) {
if (T->mem1->sln!=NULL) free (T->mem1->sln);
@ -660,58 +670,72 @@ void InputWindow::cb_Save(Fl_Widget*, void*v){ @@ -660,58 +670,72 @@ void InputWindow::cb_Save(Fl_Widget*, void*v){
void InputWindow::cb_Open(Fl_Widget* o, void*v){
InputWindow* T = (InputWindow*)v;
// A solution for locally working with gsln (hence the name lsln)
GBCSolution* lsln = NULL;
// Get the file name to load
char* fname=NULL;
fname = fl_file_chooser("Please select a file to open.","*.gbc","",0);
if (fname==NULL) {
T->oStatus->value("GNU Ballistic Computer: Error opening file!");
return;
}
}
// and open it for binary read.
FILE* ofile = fopen(fname,"rb");
// Free an old solution if there is one, because we want to
// write over it.
// Free an old solution if there is one, because we want to
// write over it.
if (T->gsln != NULL) {
free(T->gsln);
T->gsln=NULL;
}
}
// Allocate some space for the loaded solution.
if (lsln != NULL) free(lsln);
if (lsln != NULL) {
free(lsln);
lsln=NULL;
}
// Assign some new memory for lsln.
lsln = (GBCSolution*)malloc(sizeof(GBCSolution));
if (lsln==NULL){
if (lsln==NULL){
T->oStatus->value("GNU Ballistic Computer: Memory allocation error.");
return;
}
return;
}
// Read the GBCSolution class from the file and load it into program
// memory. check to make sure we read the right amount of data.
int read;
read=fread(lsln,1,sizeof(GBCSolution),ofile);
fclose(ofile);
fclose(ofile);
if (read!=sizeof(GBCSolution)){
T->oStatus->value("GNU Ballistic Computer: Error reading file data!\nPlease ensure the file is a valid GNUBC solution.");
if (lsln!=NULL) free(lsln);
if (T->gsln!=NULL) free(T->gsln);
return;
}
if (lsln!=NULL) {
free(lsln);
lsln=NULL;
}
if (T->gsln!=NULL) {
free(T->gsln);
T->gsln=NULL;
}
return;
}
// Set the parent's solution pointer to the local one we just imported.
T->gsln = lsln;
T->gsln=lsln;
// Load the solution data into the INPUT fields in the InputWindow.
char buff[1024];
T->inName->value(lsln->Name());
@ -730,20 +754,37 @@ void InputWindow::cb_Open(Fl_Widget* o, void*v){ @@ -730,20 +754,37 @@ void InputWindow::cb_Open(Fl_Widget* o, void*v){
T->ckWeather->value(lsln->UseWeather());
T->cb_ckWeather(o,v);
// And now solve the loaded parameters.
DisableMenu(T);
T->cb_Solve(o,v);
// Finally inform the user of our success.
T->oStatus->value("GNU Ballistics Computer: File loaded successfully.");
return;
}
T->inG1->value(0);
T->inG2->value(0);
T->inG5->value(0);
T->inG6->value(0);
T->inG7->value(0);
T->inG8->value(0);
if (lsln->df==G1) T->inG1->set();
if (lsln->df==G2) T->inG2->set();
if (lsln->df==G5) T->inG5->set();
if (lsln->df==G6) T->inG6->set();
if (lsln->df==G7) T->inG7->set();
if (lsln->df==G8) T->inG8->set();
// We don't actually have a valid solution, so make sure to set the solution
// double* pointer to NULL before we call solve.
T->gsln->sln=NULL;
// And now solve the loaded parameters.
DisableMenu(T);
T->cb_Solve(o,v);
// Finally inform the user of our success.
T->oStatus->value("GNU Ballistics Computer: File loaded successfully.");
return;
}
void InputWindow::cb_Plot(Fl_Widget* o, void* v){
InputWindow* T = (InputWindow*)v;
@ -788,10 +829,10 @@ void InputWindow::cb_Store2(Fl_Widget* o, void* v){ @@ -788,10 +829,10 @@ void InputWindow::cb_Store2(Fl_Widget* o, void* v){
if (T->mem2 != NULL) {
if (T->mem2->sln!=NULL) free(T->mem2->sln);
delete(T->mem1);
delete(T->mem2);
}
if (T->Smem2!= NULL) free(T->Smem1);
if (T->Smem2!= NULL) free(T->Smem2);
T->mem2=T->gsln;
T->Smem2=T->Solution;

36
InputWindow.h

@ -1,6 +1,34 @@ @@ -1,6 +1,34 @@
#ifndef __INPUTWINDOW
#define __INPUTWINDOW
#include <FL/Fl_BMP_Image.H>
#include "blib/src/ballistics.h"
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Help_Dialog.H>
#include <FL/Fl_Output.H>
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_BMP_Image.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Round_Button.H>
#include <FL/Fl_Int_Input.H>
#include <FL/Fl_Float_Input.H>
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Multiline_Output.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Text_Display.H>
#include <stdlib.h>
#include <stdio.h>
#include "GBCSolution.h"
#include "RangeWindow.h"
#include "AboutWindow.h"
#include "LicenseWindow.h"
#include "PlotWindow.h"
class InputWindow : public Fl_Window{
@ -45,8 +73,7 @@ class InputWindow : public Fl_Window{ @@ -45,8 +73,7 @@ class InputWindow : public Fl_Window{
Fl_Int_Input* inZero;
Fl_Int_Input* inVwind;
Fl_Int_Input* inAwind;
Fl_Int_Input* inTemp;
Fl_Float_Input* inPressure;
Fl_Int_Input* inTemp; Fl_Float_Input* inPressure;
Fl_Int_Input* inHumidity;
Fl_Int_Input* inAltitude;
@ -134,5 +161,8 @@ class InputWindow : public Fl_Window{ @@ -134,5 +161,8 @@ class InputWindow : public Fl_Window{
};
#include "PBRWindow.h"
#endif

10
LicenseWindow.cpp

File diff suppressed because one or more lines are too long

9
LicenseWindow.h

@ -1,11 +1,20 @@ @@ -1,11 +1,20 @@
#ifndef __LICENSEWINDOW
#define __LICENSEWINDOW
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Text_Buffer.H>
class LicenseWindow : public Fl_Window {
public:
LicenseWindow(void);
~LicenseWindow(void);
private:
Fl_Text_Buffer* buf;
Fl_Text_Display* lic;
};

57
Makefile

@ -1,7 +1,56 @@ @@ -1,7 +1,56 @@
CFLAGS = -I/usr/local/include -I/usr/local/include/FL/images -mwindows -DWIN32 -mno-cygwin
LDFLAGS = -L./blib/ -lballistics -L/usr/local/lib -lhpdf -lfltk_images -lfltk_png -lfltk_jpeg -lz -mwindows -mno-cygwin -lfltk_z -lfltk -lole32 -luuid -lcomctl32 -lwsock32
BFLAGS = -c -O3 -Wall
all: InputWindow.o LicenseWindow.o PlotWindow.o AboutWindow.o RangeWindow.o PBRWindow.o GBCSolution.o GNU_Ballistics.o ./blib/libballistics.a
g++ -Wall -O3 -o GNU_Ballistics.exe InputWindow.o PlotWindow.o LicenseWindow.o AboutWindow.o RangeWindow.o PBRWindow.o GBCSolution.o GNU_Ballistics.o ${LDFLAGS}
rm -f *.o
rm -f *.*~
mv GNU_Ballistics.exe ../
GNU_Ballistics.o: GNU_Ballistics.cpp
g++ ${BFLAGS} GNU_Ballistics.cpp -o GNU_Ballistics.o
PBRWindow.o: PBRWindow.cpp PBRWindow.h
g++ ${BFLAGS} PBRWindow.cpp -o PBRWindow.o
RangeWindow.o: RangeWindow.h GBCSolution.h InputWindow.h InputWindow.cpp
g++ ${BFLAGS} RangeWindow.cpp -o RangeWindow.o
AboutWindow.o: AboutWindow.h AboutWindow.cpp
g++ ${BFLAGS} AboutWindow.cpp -o AboutWindow.o
LicenseWindow.o: LicenseWindow.h LicenseWindow.cpp
g++ ${BFLAGS} LicenseWindow.cpp -o LicenseWindow.o
InputWindow.o: InputWindow.h InputWindow.cpp
g++ ${BFLAGS} InputWindow.cpp -o InputWindow.o
PlotWindow.o: PlotWindow.h PlotWindow.cpp
g++ ${BFLAGS} PlotWindow.cpp -o PlotWindow.o
GBCSolution.o: GBCSolution.h GBCSolution.cpp
g++ ${BFLAGS} GBCSolution.cpp -o GBCSolution.o
./blib/libballistics.a: ./blib/src/ballistics.h ./blib/src/ballistics.c
g++ ${BFLAGS} ./blib/src/ballistics.c -o ./blib/src/ballistics.o
ar rcs ./blib/libballistics.a ./blib/src/ballistics.o
rm -f ./blib/src/ballistics.o
clean:
rm -f GBCSolution.o
rm -f PlotWindow.o
rm -f InputWindow.o
rm -f AboutWindow.o
rm -f LicenseWindow.o
rm -f PBRWindow.o
rm -f ballistics.o
rm -f *.o
rm -f *.*~
rm -f GNU_Ballistics
rm -f ./blib/libballistics.a
LDFLAGS = -L/usr/local/lib -mwindows -mno-cygwin -lfltk -lfltk_images -lfltk_png -lfltk_z -lfltk_jpeg -lfltk -lole32 -luuid -lcomctl32 -lwsock32 -lhpdf -lz -lm
All:
g++ -Wall -g ${CFLAGS} -o GNU_Ballistics.exe GNU_ballistics.cpp ${LDFLAGS}

52
Makefile.slack

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
CFLAGS =
LDFLAGS = -lfltk_images -lpng -lz -ljpeg -lfltk -ldl -lm -lXext -lX11 -lhpdf -L./blib/ -lballistics
BFLAGS = -c -O3 -Wall
all: InputWindow.o LicenseWindow.o PlotWindow.o AboutWindow.o RangeWindow.o PBRWindow.o GBCSolution.o GNU_Ballistics.o ./blib/libballistics.a
g++ -Wall -O3 -o GNU_Ballistics InputWindow.o PlotWindow.o LicenseWindow.o AboutWindow.o RangeWindow.o PBRWindow.o GBCSolution.o GNU_Ballistics.o ${LDFLAGS}
rm -f *.o
rm -f *.*~
mv GNU_Ballistics ../
GNU_Ballistics.o: GNU_Ballistics.cpp
g++ ${BFLAGS} GNU_Ballistics.cpp -o GNU_Ballistics.o
PBRWindow.o: PBRWindow.cpp PBRWindow.h
g++ ${BFLAGS} PBRWindow.cpp -o PBRWindow.o
RangeWindow.o: RangeWindow.h GBCSolution.h InputWindow.h InputWindow.cpp
g++ ${BFLAGS} RangeWindow.cpp -o RangeWindow.o
AboutWindow.o: AboutWindow.h AboutWindow.cpp
g++ ${BFLAGS} AboutWindow.cpp -o AboutWindow.o
LicenseWindow.o: LicenseWindow.h LicenseWindow.cpp
g++ ${BFLAGS} LicenseWindow.cpp -o LicenseWindow.o
InputWindow.o: InputWindow.h InputWindow.cpp
g++ ${BFLAGS} InputWindow.cpp -o InputWindow.o
PlotWindow.o: PlotWindow.h PlotWindow.cpp
g++ ${BFLAGS} PlotWindow.cpp -o PlotWindow.o
GBCSolution.o: GBCSolution.h GBCSolution.cpp
g++ ${BFLAGS} GBCSolution.cpp -o GBCSolution.o
./blib/libballistics.a: ./blib/src/ballistics.h ./blib/src/ballistics.c
g++ ${BFLAGS} ./blib/src/ballistics.c -o ./blib/src/ballistics.o
ar rcs ./blib/libballistics.a ./blib/src/ballistics.o
rm -f ./blib/src/ballistics.o
clean:
rm -f GBCSolution.o
rm -f PlotWindow.o
rm -f InputWindow.o
rm -f AboutWindow.o
rm -f LicenseWindow.o
rm -f PBRWindow.o
rm -f ballistics.o
rm -f *.o
rm -f *.*~
rm -f GNU_Ballistics
rm -f ./blib/libballistics.a

57
Makefile.win32

@ -1,7 +1,56 @@ @@ -1,7 +1,56 @@
CFLAGS = -I/usr/local/include -I/usr/local/include/FL/images -mwindows -DWIN32 -mno-cygwin
LDFLAGS = -L./blib/ -lballistics -L/usr/local/lib -lhpdf -lfltk_images -lfltk_png -lfltk_jpeg -lz -mwindows -mno-cygwin -lfltk_z -lfltk -lole32 -luuid -lcomctl32 -lwsock32
BFLAGS = -c -O3 -Wall
all: InputWindow.o LicenseWindow.o PlotWindow.o AboutWindow.o RangeWindow.o PBRWindow.o GBCSolution.o GNU_Ballistics.o ./blib/libballistics.a
g++ -Wall -O3 -o GNU_Ballistics.exe InputWindow.o PlotWindow.o LicenseWindow.o AboutWindow.o RangeWindow.o PBRWindow.o GBCSolution.o GNU_Ballistics.o ${LDFLAGS}
rm -f *.o
rm -f *.*~
mv GNU_Ballistics.exe ../
GNU_Ballistics.o: GNU_Ballistics.cpp
g++ ${BFLAGS} GNU_Ballistics.cpp -o GNU_Ballistics.o
PBRWindow.o: PBRWindow.cpp PBRWindow.h
g++ ${BFLAGS} PBRWindow.cpp -o PBRWindow.o
RangeWindow.o: RangeWindow.h GBCSolution.h InputWindow.h InputWindow.cpp
g++ ${BFLAGS} RangeWindow.cpp -o RangeWindow.o
AboutWindow.o: AboutWindow.h AboutWindow.cpp
g++ ${BFLAGS} AboutWindow.cpp -o AboutWindow.o
LicenseWindow.o: LicenseWindow.h LicenseWindow.cpp
g++ ${BFLAGS} LicenseWindow.cpp -o LicenseWindow.o
InputWindow.o: InputWindow.h InputWindow.cpp
g++ ${BFLAGS} InputWindow.cpp -o InputWindow.o
PlotWindow.o: PlotWindow.h PlotWindow.cpp
g++ ${BFLAGS} PlotWindow.cpp -o PlotWindow.o
GBCSolution.o: GBCSolution.h GBCSolution.cpp
g++ ${BFLAGS} GBCSolution.cpp -o GBCSolution.o
./blib/libballistics.a: ./blib/src/ballistics.h ./blib/src/ballistics.c
g++ ${BFLAGS} ./blib/src/ballistics.c -o ./blib/src/ballistics.o
ar rcs ./blib/libballistics.a ./blib/src/ballistics.o
rm -f ./blib/src/ballistics.o
clean:
rm -f GBCSolution.o
rm -f PlotWindow.o
rm -f InputWindow.o
rm -f AboutWindow.o
rm -f LicenseWindow.o
rm -f PBRWindow.o
rm -f ballistics.o
rm -f *.o
rm -f *.*~
rm -f GNU_Ballistics
rm -f ./blib/libballistics.a
LDFLAGS = -L/usr/local/lib -mwindows -mno-cygwin -lfltk -lfltk_images -lfltk_png -lfltk_z -lfltk_jpeg -lfltk -lole32 -luuid -lcomctl32 -lwsock32 -lhpdf -lz -lm
All:
g++ ${CFLAGS} -o GNU_Ballistics.exe GNU_ballistics.cpp ${LDFLAGS}

12
PBRWindow.cpp

@ -1,4 +1,6 @@ @@ -1,4 +1,6 @@
PBRWindow::PBRWindow(InputWindow* IW):Fl_Window(250,270,"Optimize Point Blank Range") {
#include "PBRWindow.h"
PBRWindow::PBRWindow(InputWindow* IW):Fl_Window(250,300,"Optimize Point Blank Range") {
inW = IW;
if (inW==NULL) return;
@ -24,7 +26,7 @@ PBRWindow::PBRWindow(InputWindow* IW):Fl_Window(250,270,"Optimize Point Blank Ra @@ -24,7 +26,7 @@ PBRWindow::PBRWindow(InputWindow* IW):Fl_Window(250,270,"Optimize Point Blank Ra
Calc->callback(cb_calc, this);
oStatus = new Fl_Multiline_Output(10,190,230,70,"");
oStatus = new Fl_Multiline_Output(10,190,230,100,"");
oStatus->value("Waiting for input...");
end();
@ -47,7 +49,7 @@ PBRWindow::~PBRWindow(void){ @@ -47,7 +49,7 @@ PBRWindow::~PBRWindow(void){
void PBRWindow::cb_calc(Fl_Widget* o, void* v){
PBRWindow* T = (PBRWindow*)v;
int result[4];
int result[5];
int df=0;
@ -68,8 +70,8 @@ void PBRWindow::cb_calc(Fl_Widget* o, void* v){ @@ -68,8 +70,8 @@ void PBRWindow::cb_calc(Fl_Widget* o, void* v){
double vs = atof(T->VitalSize->value());
pbr(df,cd,mv, sh, vs,(int*)&result);
char txt[64];
sprintf(txt,"Optimum Zero Range: %d yards\nMinimum PBR: %d yards\nMaximum PBR: %d yards",result[0], result[1], result[2]);
char txt[255];
sprintf(txt,"Near Zero: %d yards\nFar Zero: %d yards\nMinimum PBR: %d yards\nMaximum PBR: %d yards\nSight-in at 100yds: %.2f\" High",result[0], result[1], result[2],result[3],float((float)result[4]/(float)100));
T->oStatus->value(txt);
}

18
PBRWindow.h

@ -2,14 +2,25 @@ @@ -2,14 +2,25 @@
#define __PBRWINDOW
class PBRWindow : public Fl_Window {
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Int_Input.H>
#include <FL/Fl_Float_Input.H>
#include "InputWindow.h"
#include "blib/src/ballistics.h"
#include <stdio.h>
#include <stdlib.h>
class PBRWindow : public Fl_Window {
public:
PBRWindow(InputWindow*);
PBRWindow( InputWindow* );
~PBRWindow();
private:
InputWindow* inW;
InputWindow* inW;
Fl_Int_Input* VI;
Fl_Float_Input* CD;
Fl_Float_Input* SH;
@ -21,7 +32,6 @@ class PBRWindow : public Fl_Window { @@ -21,7 +32,6 @@ class PBRWindow : public Fl_Window {
static void cb_calc(Fl_Widget*, void*);
};
#endif

14
PlotWindow.cpp

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#include "PlotWindow.h"
PlotWindow::PlotWindow(int w, int h, GBCSolution* Gsln, GBCSolution* GMEM1, GBCSolution* GMEM2) : Fl_Window(w,h,"Solution Visualization Tools"){
// Store a pointer to the calling solution.
@ -13,7 +13,7 @@ PlotWindow::PlotWindow(int w, int h, GBCSolution* Gsln, GBCSolution* GMEM1, GBCS @@ -13,7 +13,7 @@ PlotWindow::PlotWindow(int w, int h, GBCSolution* Gsln, GBCSolution* GMEM1, GBCS
begin();
// Put a simple menu, for saving or closing the window.
Fl_Menu_Bar* menu = new Fl_Menu_Bar(0,0,w,25,"MENU");
menu = new Fl_Menu_Bar(0,0,w,25,"MENU");
Fl_Menu_Item items[]= {
{"&File",0,0,0,FL_SUBMENU},
@ -86,6 +86,14 @@ PlotWindow::PlotWindow(int w, int h, GBCSolution* Gsln, GBCSolution* GMEM1, GBCS @@ -86,6 +86,14 @@ PlotWindow::PlotWindow(int w, int h, GBCSolution* Gsln, GBCSolution* GMEM1, GBCS
PlotWindow::~PlotWindow(void){
delete menu;
delete sl_x;
delete rbPlotPath;
delete rbPlotVelocity;
delete rbPlotEnergy;
delete btMem1;
delete btMem2;
}

26
PlotWindow.h

@ -1,9 +1,21 @@ @@ -1,9 +1,21 @@
#ifndef __PLOTWINDOW
#define __PLOTWINDOW
#include <FL/Fl_Value_Slider.h>
#ifndef __PLOTWINDOW
#define __PLOTWINDOW
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Round_Button.H>
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Value_Slider.H>
#include <FL/fl_draw.h>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Item.H>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "GBCSolution.h"
class PlotWindow : public Fl_Window {
public:
PlotWindow(int, int, GBCSolution*, GBCSolution*, GBCSolution*);
@ -37,6 +49,8 @@ class PlotWindow : public Fl_Window { @@ -37,6 +49,8 @@ class PlotWindow : public Fl_Window {
Fl_Value_Slider* sl_x;
Fl_Menu_Bar* menu;
virtual int handle(int);
static void cb_nothing(Fl_Widget* o, void* v);
static void cb_Close(Fl_Widget* o, void* v);

36
RangeWindow.cpp

@ -1,3 +1,5 @@ @@ -1,3 +1,5 @@
#include "RangeWindow.h"
RangeWindow::RangeWindow(int w, int h, GBCSolution* inSLN):Fl_Window(w,h,inSLN->Name()){
begin();
menu = new Fl_Menu_Bar(0,0,w,30,"MENU");
@ -77,6 +79,15 @@ RangeWindow::RangeWindow(int w, int h, GBCSolution* inSLN):Fl_Window(w,h,inSLN-> @@ -77,6 +79,15 @@ RangeWindow::RangeWindow(int w, int h, GBCSolution* inSLN):Fl_Window(w,h,inSLN->
show();
}
RangeWindow::~RangeWindow(){
delete tbl;
delete menu;
free(colwidths);
}
void RangeWindow::GenTable(){
@ -130,9 +141,7 @@ void RangeWindow::GenTable(){ @@ -130,9 +141,7 @@ void RangeWindow::GenTable(){
}
RangeWindow::~RangeWindow(){
}
void RangeWindow::cb_Nothing(Fl_Widget* t, void* v){
//exit(0);
@ -279,8 +288,8 @@ void RangeWindow::cb_ExportCSV(Fl_Widget* f, void* vtt){ @@ -279,8 +288,8 @@ void RangeWindow::cb_ExportCSV(Fl_Widget* f, void* vtt){
int MAX=T->max;
int STEP=T->step;
fprintf(ofile, "Range,Drop,Drop,Velocity,Energy,Wind Drift,Windage,Time",0);
fprintf(ofile, "\n(yards),(inches),(MOA),(ft/s),(ft-lb),(inches),(MOA),(s)",0);
fprintf(ofile, "Range,Drop,Drop,Velocity,Energy,Wind Drift,Windage,Time");
fprintf(ofile, "\n(yards),(inches),(MOA),(ft/s),(ft-lb),(inches),(MOA),(s)");
int num=T->Sln->MaxRows();
if (MAX>num) MAX=num;
@ -322,7 +331,7 @@ void RangeWindow::cb_ExportExcel(Fl_Widget* f, void* vtt){ @@ -322,7 +331,7 @@ void RangeWindow::cb_ExportExcel(Fl_Widget* f, void* vtt){
int MAX=T->max;
int STEP=T->step;
fprintf(ofile, "\n<html><head><title>$s</title></head>",0);
fprintf(ofile, "\n<html><head><title>$s</title></head>");
fprintf(ofile, "\n\n<table><tr>");
fprintf(ofile, "<td>Range</td>\
<td>Drop</td>\
@ -339,7 +348,7 @@ void RangeWindow::cb_ExportExcel(Fl_Widget* f, void* vtt){ @@ -339,7 +348,7 @@ void RangeWindow::cb_ExportExcel(Fl_Widget* f, void* vtt){
<td>(inches)</td>\
<td>(MOA)</td>\
<td>(ft/s)</td>\
<td>(ft-lb/grn)</td>\
<td>(ft-lb)</td>\
<td>(inches)</td>\
<td>(MOA)</td>\
<td>(s)</td>"
@ -400,7 +409,7 @@ void RangeWindow::cb_ExportOO(Fl_Widget* f, void* vtt){ @@ -400,7 +409,7 @@ void RangeWindow::cb_ExportOO(Fl_Widget* f, void* vtt){
int MAX=T->max;
int STEP=T->step;
fprintf(ofile, "\n<html><head><title>%s</title></head>",0);
fprintf(ofile, "\n<html><head><title>%s</title></head>","TO DO ");
fprintf(ofile, "\n\n<table><tr>");
fprintf(ofile, "\n<td>Range</td>\
\n<td>Drop</td>\
@ -417,7 +426,7 @@ void RangeWindow::cb_ExportOO(Fl_Widget* f, void* vtt){ @@ -417,7 +426,7 @@ void RangeWindow::cb_ExportOO(Fl_Widget* f, void* vtt){
\n<td>(inches)</td>\
\n<td>(MOA)</td>\
\n<td>(ft/s)</td>\
\n<td>(ft-lb/grn)</td>\
\n<td>(ft-lb)</td>\
\n<td>(inches)</td>\
\n<td>(MOA)</td>\
\n<td>(s)</td>"
@ -475,7 +484,7 @@ void RangeWindow::cb_ExportHTML(Fl_Widget* f , void* vtt){ @@ -475,7 +484,7 @@ void RangeWindow::cb_ExportHTML(Fl_Widget* f , void* vtt){
int STEP=T->step;
fprintf(ofile, "\n<html><head><title>%s</title></head>",0);
fprintf(ofile, "\n<html><head><title>%s</title></head>","");
fprintf(ofile, "\n\n<table width=560 bgcolor=black><tr>");
fprintf(ofile, "\n<td width=70 bgcolor=white align=center><b>Range</b></td>\
\n<td width=70 bgcolor=white align=center><b>Drop</b></td>\
@ -492,7 +501,7 @@ void RangeWindow::cb_ExportHTML(Fl_Widget* f , void* vtt){ @@ -492,7 +501,7 @@ void RangeWindow::cb_ExportHTML(Fl_Widget* f , void* vtt){
\n<td width=70 bgcolor=white align=center><b>(inches)</b></td>\
\n<td width=70 bgcolor=white align=center><b>(MOA)</b></td>\
\n<td width=70 bgcolor=white align=center><b>(ft/s)</b></td>\
\n<td width=70 bgcolor=white align=center><b>(ft-lb/grn)</b></td>\
\n<td width=70 bgcolor=white align=center><b>(ft-lb)</b></td>\
\n<td width=70 bgcolor=white align=center><b>(inches)</b></td>\
\n<td width=70 bgcolor=white align=center><b>(MOA)</b></td>\
\n<td width=70 bgcolor=white align=center><b>(s)</b></td>"
@ -604,7 +613,7 @@ void RangeWindow::cb_ExportXML(Fl_Widget* f, void* vtt){ @@ -604,7 +613,7 @@ void RangeWindow::cb_ExportXML(Fl_Widget* f, void* vtt){
fprintf(ofile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
fprintf(ofile, "\n<SolutionTitle>%s</SolutionTitle>",0);
fprintf(ofile, "\n<SolutionTitle>%s</SolutionTitle>","TEST");
fprintf(ofile, "\n\n<SolutionData>");
int num=T->Sln->MaxRows();
@ -660,7 +669,6 @@ void RangeWindow::cb_ExportPDF(Fl_Widget*, void* vtt){ @@ -660,7 +669,6 @@ void RangeWindow::cb_ExportPDF(Fl_Widget*, void* vtt){
const char *page_title = T->Sln->Name();
HPDF_Doc pdf;
//char fname[256];
HPDF_Page page;
HPDF_Font def_font;
HPDF_REAL tw;
@ -682,9 +690,9 @@ void RangeWindow::cb_ExportPDF(Fl_Widget*, void* vtt){ @@ -682,9 +690,9 @@ void RangeWindow::cb_ExportPDF(Fl_Widget*, void* vtt){
HPDF_Page_EndText (page);
HPDF_Page_SetFontAndSize(page,def_font,8);
tw = HPDF_Page_TextWidth(page,"GNU Exterior Ballistics, 0.100a");
tw = HPDF_Page_TextWidth(page,"GNU Exterior Ballistics, v1.05");
HPDF_Page_BeginText(page);
HPDF_Page_TextOut (page, (width-tw)/2, height-62, "GNU Exterior Ballistics, 0.100a");
HPDF_Page_TextOut (page, (width-tw)/2, height-62, "GNU Exterior Ballistics, v1.05");
HPDF_Page_EndText(page);

20
RangeWindow.h

@ -1,10 +1,20 @@ @@ -1,10 +1,20 @@
#ifndef __RANGEWINDOW
#define __RANGEWINDOW
#include "hpdf.h"
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Browser.H>
#include <FL/Fl_Widget.H>
#include <FL/Fl_File_Chooser.H>
#include <stdlib.h>
#include <stdio.h>
#include "GBCSolution.h"
#include "hpdf.h"
class RangeWindow : public Fl_Window {
public:

27
Readme.txt

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
GNU Exterior Ballistics, Version 1.05
Changes:
Fixed bug in save / load sequence that did not restore the drag function used
in the saved file
Fixed numerous small memory leaks when opening / closing various solutions.
Fixed data export titles which were incorrect from previous version (ft-lb/grn) is now (ft-lb)
Recompiled GNU Ballistics library into a static module, and linked against the source.
Turned on GCC high-optimization (level "O3")
Updated Makefile to compile GNU Ballistics Library on the fly, and link against it.
----------- V. 1.04 changes
Changes:
Improved PBR computation algorithm for accuracy of far zero. (No longer assumes
a parabolic trajectory, it now computes actual trajectory)
Added PBR "zero-in" at 100 yds, to make achieving PBR easier at a standard range.
Memory leak fixed for file open / close sequence.
Windage MOA calculation corrected for RangeWindow display
Bug for file open / close repaired.
Memory allocation and segmentation bugs fixed.
Source Changes:
Code base reorganized to be more in line with standard C practice.
Makefile altered to compile each window separately to avoid dependency errors.
Confirmed source builds on Slackware 12, included Makefile as Makefile.slack

20
blib/_angle.c

@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
// Specialty angular conversion functions
double DegtoMOA(double deg){
return deg*60;
}
double DegtoRad(double deg){
return deg*M_PI/180;
}
double MOAtoDeg(double moa){
return moa/60;
}
double MOAtoRad(double moa){
return moa/60*M_PI/180;
}
double RadtoDeg(double rad){
return rad*180/M_PI;
}
double RadtoMOA(double rad){
return rad*60*180/M_PI;
}

38
blib/_atmosphere.c

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
double calcFR(double Temperature, double Pressure, double RelativeHumidity){
double VPw=4e-6*pow(Temperature,3) - 0.0004*pow(Temperature,2)+0.0234*Temperature-0.2517;
double FRH=0.995*(Pressure/(Pressure-(0.3783)*(RelativeHumidity)*VPw));
return FRH;
}
double calcFP(double Pressure){
double Pstd=29.53; // in-hg
double FP=0;
FP = (Pressure-Pstd)/(Pstd);
return FP;
}
double calcFT(double Temperature,double Altitude){
double Tstd=-0.0036*Altitude+59;
double FT = (Temperature-Tstd)/(459.6+Tstd);
return FT;
}
double calcFA(double Altitude){
double fa=0;
fa=-4e-15*pow(Altitude,3)+4e-10*pow(Altitude,2)-3e-5*Altitude+1;
return (1/fa);
}
double AtmCorrect(double DragCoefficient, double Altitude, double Barometer, double Temperature, double RelativeHumidity){