Upstream version 2.11L

pull/2/head
Stelios Bounanos 2008-04-14 23:18:15 +01:00
rodzic 2f3f30ad0a
commit ded087d8f6
25 zmienionych plików z 780 dodań i 418 usunięć

Wyświetl plik

@ -9,7 +9,7 @@ dnl major and minor must be integers; patch may
dnl contain other characters or be empty
m4_define(FLDIGI_MAJOR, [2])
m4_define(FLDIGI_MINOR, [11])
m4_define(FLDIGI_PATCH, [J])
m4_define(FLDIGI_PATCH, [L])
AC_INIT([fldigi], FLDIGI_MAJOR.FLDIGI_MINOR[FLDIGI_PATCH], [w1hkj AT w1hkj DOT com])
@ -105,6 +105,11 @@ AC_FLDIGI_WIN32
# Substitute RTLIB in Makefile
AC_FLDIGI_STATIC
### optimizations
# Set ac_cv_opt to arg
# Substitute OPT_FLAGS in Makefile
AC_FLDIGI_OPT
### debug flag
# Set ac_cv_debug to yes/no
# Override CXXFLAGS
@ -145,7 +150,7 @@ AC_FLDIGI_OSS
# Set ac_cv_samplerate to yes/no (not used because we require samplerate)
# Define USE_SAMPLERATE in config.h (as above)
# Substitute SAMPLERATE_CFLAGS and SAMPLERATE_LIBS in Makefile
AC_FLDIGI_PKG_CHECK([samplerate], [samplerate >= 0.1.1], [no], [], [SAMPLERATE], [])
AC_FLDIGI_PKG_CHECK([samplerate], [samplerate >= 0.1.1], [], [], [SAMPLERATE], [])
### libsndfile
# Set ac_cv_sndfile to yes/no
@ -204,6 +209,7 @@ Configuration summary:
Version ............................. $VERSION
Static linking ...................... $ac_cv_static
Optimizations ....................... $ac_cv_opt
Debugging ........................... $ac_cv_debug
sndfile ............................. $ac_cv_sndfile

Wyświetl plik

@ -17,6 +17,7 @@ AC_DEFUN([AC_FLDIGI_RDYNAMIC], [
AC_DEFUN([AC_FLDIGI_DEBUG], [
AC_REQUIRE([AC_FLDIGI_OPT])
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug], [turn on debugging]),
[case "${enableval}" in
@ -26,19 +27,21 @@ AC_DEFUN([AC_FLDIGI_DEBUG], [
[ac_cv_debug=no])
if test "x$ac_cv_debug" = "xyes"; then
if test "x$GXX" = "xyes"; then
CXXFLAGS="-O0 -ggdb3 -Wall"
DEBUG_CFLAGS="-O0 -ggdb3 -Wall"
else
CXXFLAGS="-O0 -g -Wall"
DEBUG_CFLAGS="-O0 -g -Wall"
fi
AC_FLDIGI_RDYNAMIC()
AC_FLDIGI_RDYNAMIC
if test "x$ac_cv_rdynamic" = "xyes"; then
RDYNAMIC=-rdynamic
fi
CXXFLAGS=""
CFLAGS="$CXXFLAGS"
AC_MSG_NOTICE([debugging enabled; overriding CXXFLAGS])
fi
AM_CONDITIONAL([ENABLE_DEBUG], [test "x$ac_cv_debug" = "xyes"])
AC_SUBST([DEBUG_CFLAGS])
AC_SUBST([RDYNAMIC])
])

29
m4/opt.m4 100644
Wyświetl plik

@ -0,0 +1,29 @@
AC_DEFUN([AC_FLDIGI_OPT], [
AC_ARG_ENABLE([optimizations],
AC_HELP_STRING([--enable-optimizations],
[use x86 optimizations (none|sse|sse2|sse3|native) @<:@none@:>@]),
[case "${enableval}" in
none|sse|sse2|sse3|native) ac_cv_opt="${enableval}" ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-optimizations]) ;;
esac],
[ac_cv_opt=none])
OPT_CFLAGS="-O2 -ffast-math -finline-functions"
case "$ac_cv_opt" in
sse)
OPT_CFLAGS="$OPT_CFLAGS -msse -mfpmath=sse"
;;
sse2)
OPT_CFLAGS="$OPT_CFLAGS -msse2 -mfpmath=sse"
;;
sse3)
OPT_CFLAGS="$OPT_CFLAGS -msse3 -mfpmath=sse"
;;
native)
OPT_CFLAGS="$OPT_CFLAGS -march=native"
;;
none)
;;
esac
AC_SUBST([OPT_CFLAGS])
])

Wyświetl plik

@ -1,16 +1,15 @@
# name, version, optional?, opt-prefix, subst-var-prefix, help-text, [am-cond]
AC_DEFUN([AC_FLDIGI_PKG_CHECK], [
if test "x$3" = "xyes"; then
AC_ARG_WITH($1, AC_HELP_STRING([--[]$4-[]$1], [$6]),
[case "${withval}" in
yes|no) ac_cv_want_[]$1="${withval}" ;;
*) AC_MSG_ERROR([bad value "${withval}" for --[]$4-[]$1]) ;;
esac],
[ac_cv_want_[]$1=check])
else
ac_cv_want_[]$1=yes
fi
m4_ifval([$3],
[ AC_ARG_WITH($1, AC_HELP_STRING([--[]$4-[]$1], [$6]),
[case "${withval}" in
yes|no) ac_cv_want_[]$1="${withval}" ;;
*) AC_MSG_ERROR([bad value "${withval}" for --[]$4-[]$1]) ;;
esac],
[ac_cv_want_[]$1=check])
],
[ac_cv_want_[]$1=yes] )
if test "x$ac_cv_want_[]$1" = "xno"; then
AC_DEFINE([USE_][$5], 0)

Wyświetl plik

@ -9,7 +9,7 @@ AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/include -I$(srcdir)/irrxml -Ifileselector
AM_CXXFLAGS = @PORTAUDIO_CFLAGS@ @FLTK_CFLAGS@ @SNDFILE_CFLAGS@ \
@SAMPLERATE_CFLAGS@ @PULSEAUDIO_CFLAGS@ @HAMLIB_CFLAGS@ \
@MAC_UNIVERSAL_CFLAGS@ \
-pipe -Wall -O2 -ffast-math -fexceptions -finline-functions
-pipe -Wall -fexceptions @OPT_CFLAGS@ @DEBUG_CFLAGS@
AM_CFLAGS = $(AM_CXXFLAGS)
AM_LDFLAGS = @MAC_UNIVERSAL_LDFLAGS@
@ -188,6 +188,7 @@ fldigi_SOURCES += \
include/newinstall.h \
include/olivia.h \
include/picture.h \
include/progress.h \
include/psk.h \
include/viewpsk.h \
include/pskcoeff.h \
@ -286,6 +287,7 @@ fldigi_SOURCES += \
widgets/Fl_Text_Display_mod.cxx \
widgets/Fl_Text_Editor_mod.cxx \
widgets/picture.cxx \
widgets/progress.cxx \
wwv/analysis.cxx \
wwv/wwv.cxx

Wyświetl plik

@ -30,6 +30,10 @@
# include <sys/msg.h>
#endif
#ifdef __CYGWIN__
# include <w32api/windows.h>
#endif
#include <stdlib.h>
#include <string>
@ -41,9 +45,12 @@
#include <FL/Fl_Tile.H>
#include <FL/x.H>
#include <FL/Fl_Help_Dialog.H>
#include <FL/Fl_Progress.H>
#include "waterfall.h"
#include "raster.h"
#include "progress.h"
#include "main.h"
#include "threads.h"
#include "trx.h"
@ -93,6 +100,7 @@
Fl_Double_Window *fl_digi_main=(Fl_Double_Window *)0;
Fl_Help_Dialog *help_dialog = (Fl_Help_Dialog *)0;
Fl_Double_Window *scopeview = (Fl_Double_Window *)0;
MixerBase* mixer = 0;
@ -145,7 +153,7 @@ string strMacroName[NUMMACKEYS];
waterfall *wf = (waterfall *)0;
Digiscope *digiscope = (Digiscope *)0;
Fl_Slider *sldrSquelch = (Fl_Slider *)0;
Fl_Progress *pgrsSquelch = (Fl_Progress *)0;
Progress *pgrsSquelch = (Progress *)0;
Fl_RGB_Image *feld_image = 0;
@ -652,6 +660,7 @@ void cb_mnuAbout(Fl_Widget*, void*)
void cb_mnuVisitURL(Fl_Widget*, void* arg)
{
const char* url = reinterpret_cast<const char *>(arg);
#ifndef __CYGWIN__
const char* browsers[] = { getenv("BROWSER"), "xdg-open", "sensible-brower",
"firefox", "mozilla" };
switch (fork()) {
@ -666,6 +675,17 @@ void cb_mnuVisitURL(Fl_Widget*, void* arg)
"Open this URL manually:\n%s",
strerror(errno), url);
}
#else
// gurgle... gurgle... HOWL
// "The return value is cast as an HINSTANCE for backward
// compatibility with 16-bit Windows applications. It is
// not a true HINSTANCE, however. The only thing that can
// be done with the returned HINSTANCE is to cast it to an
// int and compare it with the value 32 or one of the error
// codes below." (Error codes omitted to preserve sanity).
if ((int)ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL) <= 32)
fl_alert("Could not open url:\n%s\n", url);
#endif
restoreFocus();
}
@ -751,6 +771,10 @@ void cbTune(Fl_Widget *w, void *) {
restoreFocus();
}
void cb_mnuDigiscope(Fl_Menu_ *w, void *d) {
scopeview->show();
}
void cb_mnuRig(Fl_Menu_ *, void *) {
if (!rigcontrol)
createRigDialog();
@ -761,6 +785,13 @@ void cb_mnuViewer(Fl_Menu_ *, void *) {
openViewer();
}
void cb_mnuPicViewer(Fl_Menu_ *, void *) {
if (picRxWin) {
picRx->redraw();
picRxWin->show();
}
}
void closeRigDialog() {
rigcontrol->hide();
}
@ -1027,11 +1058,13 @@ Fl_Menu_Item menu_[] = {
{"Save Config", 0, (Fl_Callback*)cb_mnuSaveConfig, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
{0,0,0,0,0,0,0,0,0},
{" ", 0, 0, 0, FL_MENU_INACTIVE, FL_NORMAL_LABEL, 0, 14, 0},
{"View", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
{"Digiscope", 0, (Fl_Callback*)cb_mnuDigiscope, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
{"MFSK Image", 0, (Fl_Callback*)cb_mnuPicViewer, 0, FL_MENU_INACTIVE, FL_NORMAL_LABEL, 0, 14, 0},
{"PSK Browser", 0, (Fl_Callback*)cb_mnuViewer, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
{"Rig", 0, (Fl_Callback*)cb_mnuRig, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
{" ", 0, 0, 0, FL_MENU_INACTIVE, FL_NORMAL_LABEL, 0, 14, 0},
{0,0,0,0,0,0,0,0,0},
{"Viewer", 0, (Fl_Callback*)cb_mnuViewer, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
{" ", 0, 0, 0, FL_MENU_INACTIVE, FL_NORMAL_LABEL, 0, 14, 0},
{"Help", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
@ -1091,6 +1124,24 @@ void activate_rig_menu_item(bool b)
mnu->redraw();
}
void activate_mfsk_image_item(bool b)
{
Fl_Menu_Item *rig = getMenuItem("MFSK Image");
if (!rig)
return;
if (b) {
bSaveFreqList = true;
rig->activate();
} else {
rig->deactivate();
if (rigcontrol)
rigcontrol->hide();
}
mnu->redraw();
}
#if !defined(__APPLE__) && !defined(__CYGWIN__)
void make_pixmap(Pixmap *xpm, const char **data)
{
@ -1177,6 +1228,7 @@ int below(Fl_Widget* w)
}
void create_fl_digi_main() {
int pad = wSpace, Y = 0;
fl_digi_main = new Fl_Double_Window(WNOM, HNOM, "fldigi");
@ -1266,7 +1318,7 @@ void create_fl_digi_main() {
qsoFrame2->end();
Y += Hnotes;
int sw = 15;
int sw = DEFAULT_SW;
MixerFrame = new Fl_Group(0,Y,sw, Hrcvtxt + Hxmttxt);
valRcvMixer = new Fl_Slider(0, Y, sw, (Htext)/2, "");
valRcvMixer->type(FL_VERT_NICE_SLIDER);
@ -1344,30 +1396,50 @@ void create_fl_digi_main() {
Fl_Pack *wfpack = new Fl_Pack(0, Y, WNOM, Hwfall);
wfpack->type(1);
wf = new waterfall(0, Y, Wwfall, Hwfall);
wf->end();
Fl_Pack *ypack = new Fl_Pack(WNOM-(Hwfall-24), Y, Hwfall-24, Hwfall);
ypack->type(0);
digiscope = new Digiscope (WNOM-(Hwfall-24), Y, Hwfall-24, Hwfall-24);
pgrsSquelch = new Fl_Progress(
WNOM-(Hwfall-24), Y + Hwfall - 24,
Hwfall - 24, 12, "");
pgrsSquelch->color(FL_BACKGROUND2_COLOR, FL_DARK_GREEN);
sldrSquelch = new Fl_Slider(
FL_HOR_NICE_SLIDER,
WNOM-(Hwfall-24), Y + Hwfall - 12,
Hwfall - 24, 12, "");
pgrsSquelch = new Progress(
0, Y+2,
DEFAULT_SW, Hwfall-4, "");
pgrsSquelch->color(FL_BACKGROUND2_COLOR, FL_DARK_GREEN);
pgrsSquelch->type(Progress::VERTICAL);
sldrSquelch = new Fl_Slider(
FL_VERT_NICE_SLIDER,
DEFAULT_SW, Y+2,
DEFAULT_SW, Hwfall-4, "");
sldrSquelch->minimum(0);
sldrSquelch->maximum(100);
sldrSquelch->step(1);
sldrSquelch->value(progStatus.sldrSquelchValue);
sldrSquelch->callback((Fl_Callback*)cb_sldrSquelch);
sldrSquelch->color(FL_INACTIVE_COLOR);
sldrSquelch->minimum(100);
sldrSquelch->maximum(0);
sldrSquelch->step(1);
sldrSquelch->value(progStatus.sldrSquelchValue);
sldrSquelch->callback((Fl_Callback*)cb_sldrSquelch);
sldrSquelch->color(FL_INACTIVE_COLOR);
// wf = new waterfall(0, Y, Wwfall, Hwfall);
wf = new waterfall(2*DEFAULT_SW, Y, Wwfall, Hwfall);//Wwfall, Hwfall);
wf->end();
ypack->end();
// Fl_Pack *ypack = new Fl_Pack(WNOM-(Hwfall-24 - 2*sw), Y, Hwfall-26, Hwfall);
// ypack->type(0);
// digiscope = new Digiscope (2*DEFAULT_SW + Wwfall - (Hwfall - 24), Y, Hwfall-24, Hwfall-24);
// digiscope->hide();
// pgrsSquelch = new Progress(
// WNOM-(Hwfall-24), Y + Hwfall - 24,
// Hwfall - 24, 12, "");
// pgrsSquelch->color(FL_BACKGROUND2_COLOR, FL_DARK_GREEN);
// sldrSquelch = new Fl_Slider(
// FL_HOR_NICE_SLIDER,
// WNOM-(Hwfall-24), Y + Hwfall - 12,
// Hwfall - 24, 12, "");
// sldrSquelch->minimum(0);
// sldrSquelch->maximum(100);
// sldrSquelch->step(1);
// sldrSquelch->value(progStatus.sldrSquelchValue);
// sldrSquelch->callback((Fl_Callback*)cb_sldrSquelch);
// sldrSquelch->color(FL_INACTIVE_COLOR);
// ypack->end();
Fl_Group::current()->resizable(wf);
wfpack->end();
Y += (Hwfall + 2);
@ -1452,6 +1524,11 @@ void create_fl_digi_main() {
#endif
fl_digi_main->xclass(PACKAGE_NAME);
scopeview = new Fl_Double_Window(0,0,140,140, "Scope");
digiscope = new Digiscope (0, 0, 140, 140);
scopeview->end();
scopeview->hide();
}
@ -1468,7 +1545,7 @@ void put_Bandwidth(int bandwidth)
void display_metric(double metric)
{
FL_LOCK_D();
REQ_DROP(static_cast<void (Fl_Progress::*)(float)>(&Fl_Progress::value), pgrsSquelch, metric);
REQ_DROP(static_cast<void (Progress::*)(double)>(&Progress::value), pgrsSquelch, metric);
FL_UNLOCK_D();
FL_AWAKE_D();
}

Wyświetl plik

@ -409,10 +409,8 @@ void feld::send_symbol(int currsymb, int nextsymb)
}
outbuf[outlen++] = Amp * nco(tone);
if (outlen >= OUTBUFSIZE) {
#ifndef __CYGWIN__
std::cout << "reset\n"; std::cout.flush();
#endif
if (outlen >= OUTBUFSIZE) {
std::cout << "feld reset\n"; std::cout.flush();
break;
}
txcounter += upsampleinc;

Wyświetl plik

@ -44,13 +44,7 @@ viterbi::viterbi(int k, int poly1, int poly2)
for (int i = 0; i < outsize; i++) {
output[i] = parity(poly1 & i) | (parity(poly2 & i) << 1);
#ifndef __CYGWIN__
// printf("%5d", output[i]);
}
// printf("\n");
#else
}
#endif
for (int i = 0; i < PATHMEM; i++) {
metrics[i] = new int[nstates];

Wyświetl plik

@ -33,7 +33,6 @@
#include <FL/Fl_Text_Buffer.H>
#include <FL/Fl_Browser.H>
#include <FL/Fl_Slider.H>
#include <FL/Fl_Progress.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Tile.H>
#include <FL/Fl_Light_Button.H>
@ -47,6 +46,7 @@
#include "digiscope.h"
#include "globals.h"
#include "mixer.h"
#include "progress.h"
extern Fl_Double_Window *fl_digi_main;
@ -62,7 +62,7 @@ extern Fl_Box *Status1;
extern Fl_Box *WARNstatus;
extern Fl_Button *MODEstatus;
extern Fl_Slider *sldrSquelch;
extern Fl_Progress *pgrsSquelch;
extern Progress *pgrsSquelch;
extern Fl_Button *btnMacro[];
extern Fl_Input *inpFreq;
extern Fl_ComboBox *cboBand;
@ -100,6 +100,7 @@ extern Fl_Menu_Item menu_[];
extern Fl_Menu_Item *getMenuItem(const char *caption);
extern void activate_rig_menu_item(bool b);
extern void activate_test_menu_item(bool b);
extern void activate_mfsk_image_item(bool b);
extern void put_freq(double frequency);

Wyświetl plik

@ -24,10 +24,10 @@
#ifndef FLDIGI_CONFIG_H
#define FLDIGI_CONFIG_H
#ifdef __CYGWIN__
#define IDI_ICON 101
#endif
#ifdef __CYGWIN__
#define IDI_ICON 101
#endif
// You can change the x1 width of the waterfall / spectrum display by modifying this
// constant.
@ -35,12 +35,14 @@
// DO NOT EXCEED 4000
// The larger the number the greater the cpu load will be for creating the
// waterfall display
#define DEFAULT_IMAGE_WIDTH 3000
#define DEFAULT_HWFALL 140
#define DEFAULT_SW 15
#define DEFAULT_IMAGE_WIDTH 3200
#define DEFAULT_HWFALL 144
#define DEFAULT_HNOM 570
#define DEFAULT_WNOM (DEFAULT_IMAGE_WIDTH / 4 + DEFAULT_HWFALL - BTN_HEIGHT)
#define DEFAULT_WNOM (DEFAULT_IMAGE_WIDTH / 4 + 2 * DEFAULT_SW)
//#define DEFAULT_WNOM (DEFAULT_IMAGE_WIDTH / 4 + DEFAULT_HWFALL - BTN_HEIGHT)
#define EMC_HWFALL 140
#define EMC_HWFALL 144
#define EMC_HNOM 500
#define EMC_WNOM (EMC_HWFALL - BTN_HEIGHT + 500)

Wyświetl plik

@ -31,19 +31,64 @@
#define POLY1 0x6d
#define POLY2 0x4f
class mfsk;
extern int print_time_left(size_t bytes, char *str, size_t len,
const char *prefix = "", const char *suffix = "");
extern void updateTxPic(unsigned char data, mfsk *me);
extern void updateRxPic(unsigned char data, int pos);
extern void TxViewerResize(int W, int H);
extern void showTxViewer(int W, int H, mfsk *who);
extern void createTxViewer(mfsk *who);
extern void createRxViewer(mfsk *who);
extern void showRxViewer(int W, int H, mfsk *who);
extern void deleteRxViewer();
extern void deleteTxViewer();
extern void cb_picRxClose( Fl_Widget *w, void *who);
extern void cb_picRxAbort( Fl_Widget *w, void *who);
extern void cb_picTxSendColor( Fl_Widget *w, void *who);
extern void cb_picTxSendGrey( Fl_Widget *w, void *who);
extern void cb_picTxSendAbort( Fl_Widget *w, void *who);
extern void load_file(const char *n);
extern Fl_Double_Window *picRxWin;
extern picture *picRx;
extern Fl_Button *btnpicRxSave;
extern Fl_Button *btnpicRxAbort;
extern Fl_Button *btnpicRxClose;
extern Fl_Double_Window *picTxWin;
extern picture *picTx;
extern Fl_Button *btnpicTxSendColor;
extern Fl_Button *btnpicTxSendGrey;
extern Fl_Button *btnpicTxSendAbort;
extern Fl_Button *btnpicTxLoad;
extern Fl_Button *btnpicTxClose;
extern Fl_Shared_Image *TxImg;
extern unsigned char *xmtimg;
extern unsigned char *xmtpicbuff;
struct rxpipe {
complex vector[MAX_SYMBOLS]; //numtones <= 32
};
struct history {
complex val;
int symnbr;
};
class mfsk : public modem {
friend void updateTxPic(unsigned char data, mfsk *me);
friend void cb_picRxClose( Fl_Widget *w, void *who);
friend void cb_picTxClose( Fl_Widget *w, void *who);
friend void cb_picTxLoad(Fl_Widget *,void *who);
friend void cb_picRxAbort( Fl_Widget *w, void *who);
friend void cb_picTxSendColor( Fl_Widget *w, void *who);
friend void cb_picTxSendGrey( Fl_Widget *w, void *who);
friend void cb_picTxSendAbort( Fl_Widget *w, void *who);
friend void cb_picRxSave( Fl_Widget *w, void *who);
public:
enum {
@ -80,6 +125,8 @@ protected:
sfft *binsfft;
C_FIR_filter *bpfilt;
Cmovavg *afcfilt;
Cmovavg *met1filt;
Cmovavg *met2filt;
viterbi *dec1;
viterbi *dec2;
@ -97,6 +144,8 @@ protected:
int currsymbol;
int prev1symbol;
int prev2symbol;
double maxval;
double prevmaxval;
double met1;
double met2;
@ -125,6 +174,7 @@ protected:
char picheader[PICHEADER];
complex prevz;
double picf;
int row;
int col;
int rgb;
@ -134,32 +184,11 @@ protected:
int picH;
bool color;
Fl_Window *picRxWin;
Fl_Box *picRxBox;
picture *picRx;
Fl_Button *btnpicRxSave;
Fl_Button *btnpicRxClose;
Fl_Window *picTxWin;
picture *picTx;
Fl_Button *btnpicTxSendColor;
Fl_Button *btnpicTxSendGrey;
Fl_Button *btnpicTxSendAbort;
Fl_Button *btnpicTxLoad;
Fl_Button *btnpicTxClose;
Fl_Shared_Image *TxImg;
unsigned char *xmtimg;
unsigned char *xmtpicbuff;
unsigned char picprologue[44];
int xmtbytes;
bool startpic;
bool abortxmt;
void updateTxPic(unsigned char data);
void TxViewerResize(int W, int H);
void updateRxPic(unsigned char data, int pos);
void makeRxViewer(int W, int H);
void load_file(const char *n);
void recvpic(complex z);
void recvchar(int c);
void recvbit(int bit);
@ -182,8 +211,6 @@ protected:
void clearbits();
void sendpic(unsigned char *data, int len);
bool check_picture_header(char c);
int print_time_left(size_t bytes, char *str, size_t len,
const char *prefix = "", const char *suffix = "");
public:
mfsk (trx_mode md);
~mfsk ();
@ -194,7 +221,6 @@ public:
int rx_process(const double *buf, int len);
int tx_process();
void shutdown();
void makeTxViewer(int W, int H);
};
#endif

Wyświetl plik

@ -35,36 +35,9 @@
#include <FL/fl_draw.H>
extern "C" {
// This is needed to avoid a boolean conflict with jmorecfg.h
#ifdef __CYGWIN__
# include <w32api/wtypes.h>
# define HAVE_BOOLEAN 1
#endif
// This is needed to avoid a conflict between a
// system-defined INT32 typedef, and a macro defined in
// jmorecfg.h, included by jpeglib.h. If ADDRESS_TAG_BIT
// is defined, basestd.h has been included and we will have
// the typedef from cygwin, so we define XMD_H to avoid
// defining the macro in jmorecfg.h
#if defined(__CYGWIN__) && !defined(XMD_H)
# define XMD_H
# define FLDIGI_JPEG_XMD_H
#endif
#include <jpeglib.h>
#ifdef FLDIGI_JPEG_XMD_H
# undef FLDIGI_JPEG_XMD_H
# undef XMD_H
#endif
//# include "transupp.h"
};
#include "threads.h"
class picture : Fl_Widget {
class picture : public Fl_Widget {
private:
unsigned char *vidbuf;
int bufsize;

Wyświetl plik

@ -0,0 +1,72 @@
//
// progress.h
//
// Progress bar widget routines.
//
// Based on Fl_Progress widget, Copyright 2000-2005 by Michael Sweet.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#ifndef _Progress_H_
# define _Progress_H_
//
// Include necessary headers.
//
#include <FL/Fl_Widget.H>
//
// Progress class...
//
class Progress : public Fl_Widget
{
public:
enum PTYPE {HORIZONTAL, VERTICAL};
private:
double value_,
minimum_,
maximum_;
PTYPE direction;
protected:
virtual void draw();
public:
Progress(int x, int y, int w, int h, const char *l = 0);
void type(PTYPE direc) { direction = direc;}
void maximum(double v) { maximum_ = v; redraw(); }
double maximum() const { return (maximum_); }
void minimum(double v) { minimum_ = v; redraw(); }
double minimum() const { return (minimum_); }
void value(double v) { value_ = v; redraw(); }
double value() const { return (value_); }
};
#endif // !_Progress_H_

Wyświetl plik

@ -117,6 +117,11 @@ void generate_version_text(void);
void debug_exec(char** argv);
void string_wrap(std::string& s, unsigned c);
#ifdef __CYGWIN__
void redirect_streams(const std::string& dir);
void restore_streams(void);
#endif
int main(int argc, char ** argv)
{
debug_exec(argv);
@ -144,6 +149,11 @@ int main(int argc, char ** argv)
#endif
HomeDir = szHomedir;
#ifdef __CYGWIN__
redirect_streams(HomeDir);
atexit(restore_streams);
#endif
generate_option_help();
generate_version_text();
string_wrap(version_text, 80);
@ -217,10 +227,10 @@ int main(int argc, char ** argv)
progdefaults.initInterface();
#ifdef __CYGWIN__
fl_digi_main->icon((char*)LoadIcon(fl_display, MAKEINTRESOURCE(IDI_ICON)));
#endif
#ifdef __CYGWIN__
fl_digi_main->icon((char*)LoadIcon(fl_display, MAKEINTRESOURCE(IDI_ICON)));
#endif
fl_digi_main->show(argc, argv);
progStatus.initLastState();
@ -610,3 +620,45 @@ void string_wrap(std::string& s, unsigned c)
if (s.length() - line > c)
s[prev] = '\n';
}
#ifdef __CYGWIN__
static ofstream outlogfile;
static ostringstream outlogstring;
static streambuf* streambufs[3];
void redirect_streams(const std::string& dir)
{
string log = dir;
if (*log.rbegin() != '/')
log += '/';
log += "status_log.txt";
outlogfile.open(log.c_str());
if (!isatty(STDOUT_FILENO)) {
streambufs[0] = cout.rdbuf();
if (outlogfile)
cout.rdbuf(outlogfile.rdbuf());
else
cout.rdbuf(outlogstring.rdbuf());
}
if (!isatty(STDERR_FILENO)) {
streambufs[1] = cerr.rdbuf();
streambufs[2] = clog.rdbuf();
if (outlogfile) {
cerr.rdbuf(outlogfile.rdbuf());
clog.rdbuf(outlogfile.rdbuf());
}
else {
cerr.rdbuf(outlogstring.rdbuf());
clog.rdbuf(outlogstring.rdbuf());
}
}
}
void restore_streams(void)
{
cout.rdbuf(streambufs[0]);
cerr.rdbuf(streambufs[1]);
clog.rdbuf(streambufs[2]);
}
#endif // __CYGWIN__

Wyświetl plik

@ -41,7 +41,8 @@
#include "qrunner.h"
#define AFC_COUNT 32
#define AFC_COUNT 16
//32
using namespace std;
@ -66,9 +67,10 @@ void mfsk::rx_init()
met1 = 0.0;
met2 = 0.0;
counter = 0;
for (int i = 0; i < 2 * symlen; i++)
for (int i = 0; i < 2 * symlen; i++) {
for (int j = 0; j < 32; j++)
(pipe[i].vector[j]).re = (pipe[i].vector[j]).im = 0.0;
}
reset_afc();
s2n = 0.0;
memset(picheader, ' ', PICHEADER - 1);
@ -94,6 +96,11 @@ mfsk::~mfsk()
if (pipe) delete [] pipe;
if (hbfilt) delete hbfilt;
if (binsfft) delete binsfft;
if (met1filt) delete met1filt;
if (met2filt) delete met2filt;
if (xmtimg) delete [] xmtimg;
deleteRxViewer();
deleteTxViewer();
}
mfsk::mfsk(trx_mode mfsk_mode) : modem()
@ -123,6 +130,8 @@ mfsk::mfsk(trx_mode mfsk_mode) : modem()
hbfilt = new C_FIR_filter();
hbfilt->init_hilbert(37, 1);
afcfilt = new Cmovavg(AFC_COUNT);
met1filt = new Cmovavg(32);
met2filt = new Cmovavg(32);
pipe = new rxpipe[ 2 * symlen ];
@ -141,8 +150,8 @@ mfsk::mfsk(trx_mode mfsk_mode) : modem()
bw = (numtones - 1) * tonespacing;
cf = 1000.0 + bw / 2.0;
flo = (cf - bw) / MFSKSampleRate;
fhi = (cf + bw) / MFSKSampleRate;
flo = (cf - bw/2 - tonespacing) / MFSKSampleRate;
fhi = (cf + bw/2 + tonespacing) / MFSKSampleRate;
bpfilt = new C_FIR_filter();
bpfilt->init_bandpass (127, 1, flo, fhi);
@ -153,13 +162,14 @@ mfsk::mfsk(trx_mode mfsk_mode) : modem()
fragmentsize = symlen;
bandwidth = (numtones - 1) * tonespacing;
picRxWin = 0;
picRxBox = 0;
picRx = 0;
picTxWin = 0;
picTx = 0;
picRxWin = (Fl_Double_Window *)0;
picRx = (picture *)0;
btnpicRxSave = (Fl_Button *)0;
btnpicRxClose = (Fl_Button *)0;
startpic = false;
abortxmt = false;
bitshreg = 0;
bitstate = 0;
phaseacc = 0;
@ -167,15 +177,17 @@ mfsk::mfsk(trx_mode mfsk_mode) : modem()
metric = 0;
prev1symbol = prev2symbol = 0;
symbolpair[0] = symbolpair[1] = 0;
init();
}
void mfsk::shutdown()
{
stopflag = true;
if (picTxWin)
if (picTxWin) {
picTxWin->hide();
activate_mfsk_image_item(false);
}
}
@ -241,7 +253,8 @@ void mfsk::recvpic(complex z)
if (color) {
pixelnbr = rgb + row + 3*col;
REQ(&mfsk::updateRxPic, this, byte, pixelnbr);
updateRxPic(byte, pixelnbr);
// REQ(&mfsk::updateRxPic, this, byte, pixelnbr);
if (++col == picW) {
col = 0;
if (++rgb == 3) {
@ -251,7 +264,8 @@ void mfsk::recvpic(complex z)
}
} else {
for (int i = 0; i < 3; i++)
REQ(&mfsk::updateRxPic, this, byte, pixelnbr++);
updateRxPic(byte, pixelnbr);
// REQ(&mfsk::updateRxPic, this, byte, pixelnbr++);
}
picf = 0.0;
@ -280,8 +294,9 @@ void mfsk::recvchar(int c)
picturesize = SAMPLES_PER_PIXEL * picW * picH * (color ? 3 : 1);
counter = 0;
makeRxViewer(picW, picH);
showRxViewer(picW, picH, this);
pixelnbr = 0;
col = 0;
row = 0;
@ -324,7 +339,7 @@ void mfsk::decodesymbol(unsigned char symbol)
if ((c = dec1->decode(symbolpair, &met)) == -1)
return;
met1 = decayavg(met1, met, 32.0);
met1 = met1filt->run(met);
if (met1 < met2)
return;
@ -334,7 +349,7 @@ void mfsk::decodesymbol(unsigned char symbol)
if ((c = dec2->decode(symbolpair, &met)) == -1)
return;
met2 = decayavg(met2, met, 32.0);
met2 = met2filt->run(met);
if (met2 < met1)
return;
@ -352,13 +367,10 @@ void mfsk::decodesymbol(unsigned char symbol)
void mfsk::softdecode(complex *bins)
{
double tone, sum, *b;
unsigned char *symbols;
double tone, sum, b[symbits];
unsigned char symbols[symbits];
int i, j, k;
b = new double [symbits];
symbols = new unsigned char[symbits];
for (i = 0; i < symbits; i++)
b[i] = 0.0;
@ -391,8 +403,6 @@ void mfsk::softdecode(complex *bins)
symbolbit = i + 1;
decodesymbol(symbols[i]);
}
delete [] b;
delete [] symbols;
}
complex mfsk::mixer(complex in, double f)
@ -426,19 +436,24 @@ int mfsk::harddecode(complex *in)
symbol = i;
}
}
maxval = max;
return symbol;
}
void mfsk::update_syncscope()
{
int j;
int pipelen = 2 * symlen;
double max = prevmaxval;
if (max == 0.0) max = 1e10;
memset(scopedata, 0, 2 * symlen * sizeof(double));
if (!progStatus.sqlonoff || metric >= progStatus.sldrSquelchValue)
for (int i = 0; i < 2 * symlen; i++) {
j = (i + pipeptr) % (2 * symlen);
scopedata[i] = (pipe[j].vector[prev1symbol]).mag();
for (int i = 0; i < pipelen; i++) {
j = (pipeptr - i);
if (j < 0) j += pipelen;
scopedata[i] = (pipe[j].vector[prev1symbol]).mag() / max;
}
set_scope(scopedata, 2 * symlen);
set_scope(scopedata, pipelen, false);
scopedata.next(); // change buffers
snprintf(mfskmsg, sizeof(mfskmsg), "s/n %3.0f dB", 20.0 * log10(s2n) );
put_Status1(mfskmsg);
@ -467,12 +482,14 @@ void mfsk::synchronize()
j = (j + 1) % (2 * symlen);
}
synccounter += (int) floor((syn - symlen) / numtones + 0.5); //16.0 + 0.5);
synccounter += (int) floor((syn - symlen) / numtones + 0.5);
update_syncscope();
}
void mfsk::reset_afc() {
freqerr = 0.0;
for (int i = 0; i < AFC_COUNT; i++) afcfilt->run(0.0);
afcfilt->reset();
return;
}
@ -486,21 +503,22 @@ void mfsk::afc()
reset_afc();
sigsearch = 0;
}
if (pipeptr == 0)
if (pipeptr == 0) {
prevvector = pipe[2*symlen - 1].vector[currsymbol];
else
} else {
prevvector = pipe[pipeptr - 1].vector[currsymbol];
}
z = prevvector % currvector;
f = z.arg() * samplerate / twopi;
f -= (1000 + tonespacing * currsymbol);
if (progStatus.afconoff && (metric > progStatus.sldrSquelchValue || progStatus.sqlonoff == false)) {
if (fabs(f) <= tonespacing / 2.0)
if (fabs(f) <= tonespacing / 2.0) {
freqerr = afcfilt->run(f / numtones);
set_freq(frequency + freqerr);
set_freq(frequency + freqerr);
}
}
}
@ -548,8 +566,10 @@ int mfsk::rx_process(const double *buf, int len)
rxstate = RX_STATE_DATA;
// REQ_FLUSH();
put_status("");
#ifndef __CYGWIN__
string autosave_dir = HomeDir + "mfsk_pics/";
picRx->save_jpeg(autosave_dir.c_str());
#endif
} else
recvpic(z);
continue;
@ -561,7 +581,7 @@ int mfsk::rx_process(const double *buf, int len)
// copy current vector to the pipe
for (i = 0; i < numtones; i++)
pipe[pipeptr].vector[i] = bins[i];
if (--synccounter <= 0) {
synccounter = symlen;
@ -569,18 +589,18 @@ int mfsk::rx_process(const double *buf, int len)
currvector = bins[currsymbol];
// frequency tracking
afc();
eval_s2n(currvector, bins[numtones + 2]);
// decode symbol
softdecode(bins);
// symbol sync
synchronize();
// update the scope
update_syncscope();
prev2symbol = prev1symbol;
prev2vector = prev1vector;
prev1symbol = currsymbol;
prev1vector = currvector;
prevmaxval = maxval;
}
pipeptr = (pipeptr + 1) % (2 * symlen);
}
@ -676,7 +696,8 @@ void mfsk::sendpic(unsigned char *data, int len)
for (i = 0; i < len; i++) {
if (txstate == TX_STATE_PICTURE)
REQ(&mfsk::updateTxPic, this, data[i]);
updateTxPic(data[i], this);
// REQ(&mfsk::updateTxPic, this, data[i]);
if (reverse)
f = get_txfreq_woffset() - bandwidth * (data[i] - 128) / 256.0;
else
@ -811,63 +832,97 @@ int mfsk::tx_process()
return 0;
}
//=============================================================================
// picture viewers for mfsk-pic mode
//=============================================================================
Fl_Double_Window *picRxWin = (Fl_Double_Window *)0;
picture *picRx = (picture *)0;
Fl_Button *btnpicRxSave = (Fl_Button *)0;
Fl_Button *btnpicRxAbort = (Fl_Button *)0;
Fl_Button *btnpicRxClose = (Fl_Button *)0;
Fl_Double_Window *picTxWin = (Fl_Double_Window *)0;
picture *picTx = (picture *)0;
Fl_Button *btnpicTxSendColor = (Fl_Button *)0;
Fl_Button *btnpicTxSendGrey = (Fl_Button *)0;
Fl_Button *btnpicTxSendAbort = (Fl_Button *)0;
Fl_Button *btnpicTxLoad = (Fl_Button *)0;
Fl_Button *btnpicTxClose = (Fl_Button *)0;
void mfsk::updateRxPic(unsigned char data, int pos)
Fl_Shared_Image *TxImg = (Fl_Shared_Image *)0;
unsigned char *xmtimg = (unsigned char *)0;
unsigned char *xmtpicbuff = (unsigned char *)0;
void updateRxPic(unsigned char data, int pos)
{
picRx->pixel(data, pos);
}
void cb_picRxClose( Fl_Widget *w, void *who)
{
mfsk *me = (mfsk *)who;
// FL_LOCK();
me->picRxWin->hide();
me->rxstate = mfsk::RX_STATE_DATA;
put_status("");
picRxWin->hide();
// FL_UNLOCK();
}
void cb_picRxAbort( Fl_Widget *w, void *who)
{
mfsk *me = (mfsk *)who;
me->rxstate = me->RX_STATE_DATA;
put_status("");
picRx->clear();
}
void cb_picRxSave( Fl_Widget *w, void *who)
{
mfsk *me = (mfsk *)who;
// mfsk *me = (mfsk *)who;
const char *fn =
file_saveas("Save image file", "Portable Network Graphics\t*.png\n"
"Independent JPEG Group\t*.{jpg,jif,jpeg,jpe}\n"
"Graphics Interchange Format\t*.gif");
file_saveas( "Save image as:", "Independent JPEG Group\t*.{jpg,jpeg}", NULL );
if (!fn) return;
me->picRx->save_jpeg(fn);
picRx->save_jpeg(fn);
}
void mfsk::makeRxViewer(int W, int H)
void createRxViewer(mfsk *who)
{
FL_LOCK_E();
picRxWin = new Fl_Double_Window(200, 140);
picRxWin->xclass(PACKAGE_NAME);
picRx = new picture(2, 2, 136, 104);
btnpicRxSave = new Fl_Button(5, 140 - 30, 60, 24,"Save");
btnpicRxSave->callback(cb_picRxSave, who);
#ifdef __CYGWIN__
btnpicRxSave->hide();
#endif
btnpicRxAbort = new Fl_Button(70, 140 - 30, 60, 24, "Abort");
btnpicRxAbort->callback(cb_picRxAbort, who);
btnpicRxClose = new Fl_Button(135, 140 - 30, 60, 24, "Hide");
btnpicRxClose->callback(cb_picRxClose, who);
activate_mfsk_image_item(true);
FL_UNLOCK_E();
}
void showRxViewer(int W, int H, mfsk *who)
{
if (!picRxWin) createRxViewer(who);
int winW, winH;
int picX, picY;
winW = W < 136 ? 140 : W + 4;
winH = H + 34;
picX = (winW - W) / 2;
picY = 2;
FL_LOCK_E();
if (!picRxWin) {
picRxWin = new Fl_Window(winW, winH);
picRxWin->xclass(PACKAGE_NAME);
picRx = new picture(picX, picY, W, H);
btnpicRxSave = new Fl_Button(winW/2 - 65, H + 6, 60, 24,"Save");
btnpicRxSave->callback(cb_picRxSave,this);
btnpicRxClose = new Fl_Button(winW/2 + 5, H + 6, 60, 24, "Close");
btnpicRxClose->callback(cb_picRxClose,this);
} else {
picRxWin->size(winW, winH);
picRx->resize(picX, picY, W, H);
btnpicRxSave->resize(winW/2 - 65, H + 6, 60, 24);
btnpicRxClose->resize(winW/2 + 5, H + 6, 60, 24);
picRx->clear();
}
FL_LOCK_D();
picRxWin->size(winW, winH);
picRx->resize(picX, picY, W, H);
btnpicRxSave->resize(winW/2 - 65, H + 6, 60, 24);
btnpicRxClose->resize(winW/2 + 5, H + 6, 60, 24);
picRx->clear();
#ifndef __CYGWIN__
picRxWin->show();
FL_UNLOCK_E();
#endif
FL_UNLOCK_D();
}
void mfsk::load_file(const char *n) {
void load_file(const char *n) {
int W, H, D;
unsigned char *img_data;
@ -917,53 +972,53 @@ void mfsk::load_file(const char *n) {
FL_UNLOCK_D();
}
void mfsk::updateTxPic(unsigned char data)
void updateTxPic(unsigned char data, mfsk *me)
{
if (color) {
pixelnbr = rgb + row + 3*col;
picTx->pixel(data, pixelnbr);
if (++col == TxImg->w()) {
col = 0;
if (++rgb == 3) {
rgb = 0;
row += 3 * TxImg->w();
if (me->color) {
me->pixelnbr = me->rgb + me->row + 3*me->col;
picTx->pixel(data, me->pixelnbr);
if (++me->col == TxImg->w()) {
me->col = 0;
if (++me->rgb == 3) {
me->rgb = 0;
me->row += 3 * TxImg->w();
}
}
} else {
picTx->pixel( data, pixelnbr++ );
picTx->pixel( data, pixelnbr++ );
picTx->pixel( data, pixelnbr++ );
picTx->pixel( data, me->pixelnbr++ );
picTx->pixel( data, me->pixelnbr++ );
picTx->pixel( data, me->pixelnbr++ );
}
}
void cb_picTxLoad(Fl_Widget *,void *who) {
mfsk *TxWho = (mfsk *)who;
// mfsk *TxWho = (mfsk *)who;
const char *fn =
file_select("Load image file", "Portable Network Graphics\t*.png\n"
"Independent JPEG Group\t*.{jpg,jif,jpeg,jpe}\n"
"Graphics Interchange Format\t*.gif");
if (!fn) return;
TxWho->load_file(fn);
load_file(fn);
}
void cb_picTxClose( Fl_Widget *w, void *who)
{
mfsk *me = (mfsk *)who;
// mfsk *me = (mfsk *)who;
FL_LOCK_D();
me->picTxWin->hide();
picTxWin->hide();
FL_UNLOCK_D();
}
void cb_picTxSendColor( Fl_Widget *w, void *who)
{
mfsk *my = (mfsk *)who;
mfsk *me = (mfsk *)who;
int W, H, rowstart;
W = my->TxImg->w();
H = my->TxImg->h();
if (my->xmtpicbuff) delete [] my->xmtpicbuff;
my->xmtpicbuff = new unsigned char [W*H*3];
unsigned char *outbuf = my->xmtpicbuff;
unsigned char *inbuf = my->xmtimg;
W = TxImg->w();
H = TxImg->h();
if (xmtpicbuff) delete [] xmtpicbuff;
xmtpicbuff = new unsigned char [W*H*3];
unsigned char *outbuf = xmtpicbuff;
unsigned char *inbuf = xmtimg;
int iy, ix, rgb;
for (iy = 0; iy < H; iy++) {
rowstart = iy * W * 3;
@ -971,20 +1026,20 @@ void cb_picTxSendColor( Fl_Widget *w, void *who)
for (ix = 0; ix < W; ix++)
outbuf[rowstart + rgb*W + ix] = inbuf[rowstart + rgb + ix*3];
}
snprintf(my->picheader, PICHEADER - 1, "\nSending Pic:%dx%dC;", W, H);
my->xmtbytes = W * H * 3;
my->color = true;
my->rgb = 0;
my->col = 0;
my->row = 0;
my->pixelnbr = 0;
snprintf(me->picheader, PICHEADER, "\nSending Pic:%dx%dC;", W, H);
me->xmtbytes = W * H * 3;
me->color = true;
me->rgb = 0;
me->col = 0;
me->row = 0;
me->pixelnbr = 0;
FL_LOCK_D();
my->btnpicTxSendColor->hide();
my->btnpicTxSendGrey->hide();
my->btnpicTxLoad->hide();
my->btnpicTxClose->hide();
my->btnpicTxSendAbort->show();
my->picTx->clear();
btnpicTxSendColor->hide();
btnpicTxSendGrey->hide();
btnpicTxLoad->hide();
btnpicTxClose->hide();
btnpicTxSendAbort->show();
picTx->clear();
FL_UNLOCK_D();
// start the transmission
fl_lock(&trx_mutex);
@ -992,34 +1047,34 @@ void cb_picTxSendColor( Fl_Widget *w, void *who)
trx_state = STATE_TX;
fl_unlock(&trx_mutex);
wf->set_XmtRcvBtn(true);
my->startpic = true;
me->startpic = true;
}
void cb_picTxSendGrey( Fl_Widget *w, void *who)
{
mfsk *my = (mfsk *)who;
mfsk *me = (mfsk *)who;
int W, H;
W = my->TxImg->w();
H = my->TxImg->h();
if (my->xmtpicbuff) delete [] my->xmtpicbuff;
my->xmtpicbuff = new unsigned char [W*H];
unsigned char *outbuf = my->xmtpicbuff;
unsigned char *inbuf = my->xmtimg;
W = TxImg->w();
H = TxImg->h();
if (xmtpicbuff) delete [] xmtpicbuff;
xmtpicbuff = new unsigned char [W*H];
unsigned char *outbuf = xmtpicbuff;
unsigned char *inbuf = xmtimg;
for (int i = 0; i < W*H; i++)
outbuf[i] = ( 31 * inbuf[i*3] + 61 * inbuf[i*3 + 1] + 8 * inbuf[i*3 + 2])/100;
snprintf(my->picheader, PICHEADER - 1, "\nSending Pic:%dx%d;", W, H);
my->xmtbytes = W * H;
my->color = false;
my->col = 0;
my->row = 0;
my->pixelnbr = 0;
my->picTx->clear();
snprintf(me->picheader, PICHEADER, "\nSending Pic:%dx%d;", W, H);
me->xmtbytes = W * H;
me->color = false;
me->col = 0;
me->row = 0;
me->pixelnbr = 0;
FL_LOCK_D();
my->btnpicTxSendColor->hide();
my->btnpicTxSendGrey->hide();
my->btnpicTxLoad->hide();
my->btnpicTxClose->hide();
my->btnpicTxSendAbort->show();
btnpicTxSendColor->hide();
btnpicTxSendGrey->hide();
btnpicTxLoad->hide();
btnpicTxClose->hide();
btnpicTxSendAbort->show();
picTx->clear();
FL_UNLOCK_D();
// start the transmission
fl_lock(&trx_mutex);
@ -1027,21 +1082,43 @@ void cb_picTxSendGrey( Fl_Widget *w, void *who)
trx_state = STATE_TX;
fl_unlock(&trx_mutex);
wf->set_XmtRcvBtn(true);
my->startpic = true;
me->startpic = true;
}
void cb_picTxSendAbort( Fl_Widget *w, void *who)
{
mfsk *my = (mfsk *)who;
my->abortxmt = true;
mfsk *me = (mfsk *)who;
me->abortxmt = true;
// reload the picture widget with the rgb image
FL_LOCK_D();
my->picTx->video(my->xmtimg, my->TxImg->w() * my->TxImg->h() * 3);
picTx->video(xmtimg, TxImg->w() * TxImg->h() * 3);
FL_UNLOCK_D();
}
void mfsk::TxViewerResize(int W, int H)
void createTxViewer(mfsk *who)
{
FL_LOCK_D();
picTxWin = new Fl_Double_Window(250, 180);
picTxWin->xclass(PACKAGE_NAME);
picTx = new picture (2, 2, 246, 150);
btnpicTxSendColor = new Fl_Button(250/2 - 123, 180 - 30, 60, 24, "XmtClr");
btnpicTxSendColor->callback(cb_picTxSendColor, who);
btnpicTxSendGrey = new Fl_Button(250/2 - 61, 180 - 30, 60, 24, "XmtGry");
btnpicTxSendGrey->callback( cb_picTxSendGrey, who);
btnpicTxSendAbort = new Fl_Button(250/2 - 123, 180 - 30, 122, 24, "Abort Xmt");
btnpicTxSendAbort->callback(cb_picTxSendAbort, who);
btnpicTxLoad = new Fl_Button(250/2 + 1, 180 - 30, 60, 24, "Load");
btnpicTxLoad->callback(cb_picTxLoad, who);
btnpicTxClose = new Fl_Button(250/2 + 63, 180 - 30, 60, 24, "Close");
btnpicTxClose->callback(cb_picTxClose, who);
btnpicTxSendAbort->hide();
btnpicTxSendColor->deactivate();
btnpicTxSendGrey->deactivate();
FL_UNLOCK_D();
}
void TxViewerResize(int W, int H)
{
int winW, winH;
int picX, picY;
@ -1061,8 +1138,10 @@ void mfsk::TxViewerResize(int W, int H)
FL_UNLOCK_D();
}
void mfsk::makeTxViewer(int W, int H)
void showTxViewer(int W, int H, mfsk *who)
{
if (picTxWin == 0)
createTxViewer(who);
int winW, winH;
int picX, picY;
winW = W < 246 ? 250 : W + 4;
@ -1070,42 +1149,37 @@ void mfsk::makeTxViewer(int W, int H)
picX = (winW - W) / 2;
picY = 2;
FL_LOCK_D();
if (!picTxWin) {
picTxWin = new Fl_Window(winW, winH);
picTxWin->xclass(PACKAGE_NAME);
picTx = new picture (picX, picY, W, H);
btnpicTxSendColor = new Fl_Button(winW/2 - 123, winH - 28, 60, 24, "XmtClr");
btnpicTxSendColor->callback(cb_picTxSendColor, this);
btnpicTxSendGrey = new Fl_Button(winW/2 - 61, winH - 28, 60, 24, "XmtGry");
btnpicTxSendGrey->callback( cb_picTxSendGrey, this);
btnpicTxSendAbort = new Fl_Button(winW/2 - 123, winH - 28, 122, 24, "Abort Xmt");
btnpicTxSendAbort->callback(cb_picTxSendAbort, this);
btnpicTxLoad = new Fl_Button(winW/2 + 1, winH - 28, 60, 24, "Load");
btnpicTxLoad->callback(cb_picTxLoad, this);
btnpicTxClose = new Fl_Button(winW/2 + 63, winH - 28, 60, 24, "Close");
btnpicTxClose->callback(cb_picTxClose,this);
btnpicTxSendAbort->hide();
btnpicTxSendColor->deactivate();
btnpicTxSendGrey->deactivate();
} else {
picTxWin->size(winW, winH);
picTx->resize(picX, picY, W, H);
btnpicTxSendColor->resize(winW/2 - 123, winH - 28, 60, 24);
btnpicTxSendGrey->resize(winW/2 - 61, winH - 28, 60, 24);
btnpicTxSendAbort->resize(winW/2 - 123, winH - 28, 122, 24);
btnpicTxLoad->resize(winW/2 + 1, winH - 28, 60, 24);
btnpicTxClose->resize(winW/2 + 63, winH - 28, 60, 24);
btnpicTxSendColor->show();
btnpicTxSendGrey->show();
btnpicTxLoad->show();
btnpicTxClose->show();
btnpicTxSendAbort->hide();
}
picTxWin->size(winW, winH);
picTx->resize(picX, picY, W, H);
btnpicTxSendColor->resize(winW/2 - 123, winH - 28, 60, 24);
btnpicTxSendGrey->resize(winW/2 - 61, winH - 28, 60, 24);
btnpicTxSendAbort->resize(winW/2 - 123, winH - 28, 122, 24);
btnpicTxLoad->resize(winW/2 + 1, winH - 28, 60, 24);
btnpicTxClose->resize(winW/2 + 63, winH - 28, 60, 24);
btnpicTxSendColor->show();
btnpicTxSendGrey->show();
btnpicTxLoad->show();
btnpicTxClose->show();
btnpicTxSendAbort->hide();
picTxWin->show();
FL_UNLOCK_D();
}
int mfsk::print_time_left(size_t bytes, char *str, size_t len,
void deleteTxViewer()
{
if (picTxWin == 0) return
delete picTxWin;
picTxWin = 0;
}
void deleteRxViewer()
{
if (picRxWin == 0) return
delete picRxWin;
picRxWin = 0;
}
int print_time_left(size_t bytes, char *str, size_t len,
const char *prefix, const char *suffix)
{
float time_sec = bytes * 0.001;

Wyświetl plik

@ -155,9 +155,6 @@ void initFilePtr()
fclose(infile);
}
bInitFilePtr = true;
#ifndef __CYGWIN__
std::cout << "Init file pointer = " << infileptr << std::endl; std::cout.flush();
#endif
}
#endif

Wyświetl plik

@ -56,9 +56,7 @@ void show_error(const char * a, const char * b)
msg.append(": ");
msg.append(b);
put_status((char*)msg.c_str());
#ifndef __CYGWIN__
std::cout << msg.c_str() << std::endl; std::cout.flush();
#endif
std::cout << msg.c_str() << std::endl;
}
bool hamlib_setRTSDTR()
@ -83,19 +81,8 @@ bool hamlib_setRTSDTR()
ioctl_bits |= TIOCM_DTR; // set DTR bit
else
ioctl_bits &= ~TIOCM_DTR; // clear DTR bit
#ifndef __CYGWIN__
std::cout << "TIOCM_RTS " << TIOCM_RTS << ", RTSplus " << progdefaults.RTSplus;
std::cout << std::endl;
std::cout << "TIOCM_DTR " << TIOCM_DTR << ", DTRplus " << progdefaults.DTRplus;
std::cout << std::endl;
std::cout << ioctl_bits;
#endif
ioctl(hamlibfd, TIOCMSET, &ioctl_bits);
close(hamlibfd);
#ifndef __CYGWIN__
std::cout << "=> setRTSDTR() => " << ioctl_bits << std::endl; std::cout.flush();
#endif
return true;
}
@ -207,9 +194,7 @@ bool hamlib_init(bool bPtt)
hamlib_rmode = RIG_MODE_NONE;//RIG_MODE_USB;
if (fl_create_thread(hamlib_thread, hamlib_loop, &dummy) < 0) {
#ifndef __CYGWIN__
std::cout << "Hamlib init: pthread_create failed\n"; std::cout.flush();
#endif
std::cout << "Hamlib init: pthread_create failed" << std::endl;
xcvr->close();
return false;
}
@ -237,9 +222,7 @@ void hamlib_close(void)
MilliSleep(50);
count--;
if (!count) {
#ifndef __CYGWIN__
std::cout << "\nHamlib stuck\n"; cout.flush();
#endif
std::cout << "\nHamlib stuck" << std::endl;
xcvr->close();
exit(0);
}

Wyświetl plik

@ -45,8 +45,7 @@ static long long llFreq = 0;
static int dummy = 0;
static void *rigCAT_loop(void *args);
#ifndef __CYGWIN__
void printhex(string s)
{
for (unsigned int i = 0; i < s.length(); i++) {
@ -70,7 +69,6 @@ char * printtime()
strftime(sztime, 79, "[%H:%M:%S]", now);
return sztime;
}
#endif
bool readpending = false;
int readtimeout;
@ -89,9 +87,7 @@ bool hexout( string s, int retnbr)
MilliSleep(1);
if (readtimeout == 0) {
readpending = false;
#ifndef __CYGWIN__
std::cout << "rigio timeout!" << std::endl; fflush(stdout);
#endif
std::cout << "rigio timeout!" << std::endl;
return false;
}
@ -118,15 +114,12 @@ bool hexout( string s, int retnbr)
if (retnbr > 0) {
num = rigio.ReadBuffer (replybuff, retnbr > 200 ? 200 : retnbr);
// debug code
#ifndef __CYGWIN__
// if (num) {
// std::cout << printtime() << "Rsp (" << n << "): ";
// printhex(replybuff, num);
// } else
// std::cout << printtime() << "Rsp (" << n << "): no reply" << std::endl;
// std::cout.flush();
// to here
#endif
}
if (retnbr == 0 || num == retnbr) {
@ -797,32 +790,24 @@ unused__ static void show_error(const char * a, const char * b)
string msg = a;
msg.append(": ");
msg.append(b);
#ifndef __CYGWIN__
std::cout << msg << std::endl;
#endif
}
bool rigCAT_init()
{
if (rigCAT_open == true) {
#ifndef __CYGWIN__
std::cout << "RigCAT already open file present\n"; fflush(stdout);
#endif
std::cout << "RigCAT already open file present" << std::endl;
return false;
}
if (readRigXML() == false) {
#ifndef __CYGWIN__
std::cout << "No rig.xml file present\n"; std::cout.flush();
#endif
std::cout << "No rig.xml file present" << std::endl;
return false;
}
if (rigio.OpenPort() == false) {
#ifndef __CYGWIN__
std::cout << "Cannot open serial port " << (char *)rigio.Device().c_str();
std::cout << std::endl; std::cout.flush();
#endif
std::cout << std::endl;
return false;
}
llFreq = 0;
@ -830,16 +815,12 @@ bool rigCAT_init()
sRigWidth = "";
if (rigCAT_getfreq() <= 0) {
#ifndef __CYGWIN__
std::cout << "Transceiver not responding\n"; std::cout.flush();
#endif
std::cout << "Transceiver not responding" << std::endl;
return false;
}
if (fl_create_thread(rigCAT_thread, rigCAT_loop, &dummy) < 0) {
#ifndef __CYGWIN__
std::cout << "rig init: pthread_create failed\n"; std::cout.flush();
#endif
std::cout << "rig init: pthread_create failed" << std::endl;
rigio.ClosePort();
return false;
}
@ -864,9 +845,7 @@ void rigCAT_close(void)
MilliSleep(50);
count--;
if (!count) {
#ifndef __CYGWIN__
std::cout << "\nRigCAT stuck\n"; fflush(stdout);
#endif
std::cout << "\nRigCAT stuck" << std::endl;
fl_lock(&rigCAT_mutex);
rigio.ClosePort();
fl_unlock(&rigCAT_mutex);

Wyświetl plik

@ -73,9 +73,7 @@ void parseDREV(size_t &);
void parseDMAKS(size_t &);
void parseDSHIFT(size_t &);
#ifndef __CYGWIN__
void print(size_t &);
#endif
list<XMLIOS> commands;
list<XMLIOS> reply;
@ -168,8 +166,7 @@ TAGS datatags[] = {
;
//=====================================================================
#ifndef __CYGWIN__
void print(size_t &p0, int indent)
{
#ifdef DEBUGXML
@ -179,7 +176,6 @@ void print(size_t &p0, int indent)
std::cout << strXML.substr(p0, tend - p0 + 1).c_str() << std::endl;
#endif
}
#endif
size_t tagEnd(size_t p0)
{
@ -335,9 +331,7 @@ void parseMODEdefs(size_t &p0, list<MODE> &lmd)
p0++;
return;
}
#ifndef __CYGWIN__
print(p0,0);
#endif
print(p0,0);
p0 = nextTag(p0);
while (p0 != string::npos && p0 < pend && tagIs(p0, "<ELEMENT")) {
elend = tagEnd(p0);
@ -346,9 +340,7 @@ void parseMODEdefs(size_t &p0, list<MODE> &lmd)
p0 = tagEnd(p0);
p0 = nextTag(p0);
while (p0 != string::npos && p0 < elend) {
#ifndef __CYGWIN__
print(p0,1);
#endif
print(p0,1);
if ( isBytes(p0, stemp) ) {
lmd.push_back(MODE(strELEMENT,stemp));
}
@ -392,15 +384,11 @@ void parseLSBMODES(size_t &p0)
{
size_t pend = tagEnd(p0);
string sMode;
#ifndef __CYGWIN__
print(p0,0);
#endif
print(p0,0);
p0 = nextTag(p0);
while (p0 < pend && isString(p0, sMode)) {
LSBmodes.push_back(sMode);
#ifndef __CYGWIN__
print (p0,1);
#endif
print (p0,1);
p0 = tagEnd(p0);
p0 = nextTag(p0);
}
@ -423,9 +411,7 @@ void parseBWdefs(size_t &p0, list<BW> &lbw)
p0++;
return;
}
#ifndef __CYGWIN__
print(p0,0);
#endif
print(p0,0);
p0 = nextTag(p0);
while (p0 != string::npos && p0 < pend && tagIs(p0, "<ELEMENT")) {
elend = tagEnd(p0);
@ -434,9 +420,7 @@ void parseBWdefs(size_t &p0, list<BW> &lbw)
p0 = tagEnd(p0);
p0 = nextTag(p0);
while (p0 != string::npos && p0 < elend) {
#ifndef __CYGWIN__
print(p0,1);
#endif
print(p0,1);
if ( isBytes(p0, stemp) ) {
lbw.push_back(BW(strELEMENT,stemp));
}
@ -574,9 +558,7 @@ void parsePORT(size_t &p0)
size_t p1;
TAGS *pv;
#ifndef __CYGWIN__
print(p0,0);
#endif
print(p0,0);
rig.clear();
p1 = nextTag(p0);
@ -584,9 +566,7 @@ void parsePORT(size_t &p0)
pv = porttags;
while (pv->tag) {
if (strXML.find(pv->tag, p1) == p1) {
#ifndef __CYGWIN__
print(p1, 1);
#endif
print(p1, 1);
if (pv->fp)
(pv->fp)(p1);
break;
@ -609,7 +589,6 @@ void parsePORT(size_t &p0)
}
p0 = pend;
#ifdef DEBUGXML
#ifndef __CYGWIN__
std::cout << "port: " << rig.port.c_str() << std::endl;
std::cout << "baud: " << rig.baud << std::endl;
std::cout << "retries: " << rig.retries << std::endl;
@ -619,7 +598,6 @@ void parsePORT(size_t &p0)
std::cout << "initial dts: " << (rig.dtr ? "+12" : "-12") << std::endl;
std::cout << "use dtr ptt: " << (rig.dtrptt ? "T" : "F") << std::endl;
std::cout << "use flowcontrol: " << (rig.rtscts ? "T" : "F") << std :: endl;
#endif
#endif
}
@ -666,65 +644,49 @@ void parseIOSint(size_t &p0)
void parseDTYPE(size_t &p1)
{
#ifndef __CYGWIN__
print(p1,2);
#endif
print(p1,2);
iosTemp.data.dtype = getElement(p1);
}
void parseDSIZE(size_t &p1)
{
#ifndef __CYGWIN__
print(p1,2);
#endif
print(p1,2);
iosTemp.data.size = getInt(p1);
}
void parseDMAX(size_t &p1)
{
#ifndef __CYGWIN__
print(p1,2);
#endif
print(p1,2);
iosTemp.data.max = getInt(p1);
}
void parseDMIN(size_t &p1)
{
#ifndef __CYGWIN__
print(p1,2);
#endif
print(p1,2);
iosTemp.data.min = getInt(p1);
}
void parseDRESOL(size_t &p1)
{
#ifndef __CYGWIN__
print(p1,2);
#endif
print(p1,2);
iosTemp.data.resolution = getFloat(p1);
}
void parseDREV(size_t &p1)
{
#ifndef __CYGWIN__
print(p1,2);
#endif
print(p1,2);
iosTemp.data.reverse = getBool(p1);
}
void parseDMAKS(size_t &p1)
{
#ifndef __CYGWIN__
print(p1,2);
#endif
print(p1,2);
iosTemp.data.andmask = getInt(p1);
}
void parseDSHIFT(size_t &p1)
{
#ifndef __CYGWIN__
print(p1,2);
#endif
print(p1,2);
iosTemp.data.shiftbits = getInt(p1);
}
@ -739,9 +701,7 @@ void parseIOSdata(size_t &p0)
pv = datatags;
while (pv->tag) {
if (strXML.find(pv->tag, p1) == p1) {
#ifndef __CYGWIN__
print(p1, 1);
#endif
print(p1, 1);
if (pv->fp)
(pv->fp)(p1);
break;
@ -797,9 +757,7 @@ bool parseIOS(size_t &p0, TAGS *valid)
size_t p1;
TAGS *pv;
#ifndef __CYGWIN__
print(p0,0);
#endif
print(p0,0);
iosTemp.clear();
p1 = nextTag(p0);
@ -807,9 +765,7 @@ bool parseIOS(size_t &p0, TAGS *valid)
pv = valid;
while (pv->tag) {
if (strXML.find(pv->tag, p1) == p1) {
#ifndef __CYGWIN__
print(p1, 1);
#endif
print(p1, 1);
if (pv->fp)
(pv->fp)(p1);
break;

Wyświetl plik

@ -110,7 +110,6 @@ void MixerOSS::initValues()
pcmlevel0 = PCMVolume();
vollevel0 = OutVolume();
/*
#ifndef __CYGWIN__
std::cout << "Sound card initial state:" << std::endl;
std::cout << " Dev mask " << hex << devmask << std::endl;
std::cout << " Rec mask " << hex << recmask << std::endl;
@ -119,8 +118,7 @@ void MixerOSS::initValues()
std::cout << " Line Level = " << linelevel0 << std::endl;
std::cout << " Mic Level = " << miclevel0 << std::endl;
std::cout << " Pcm Level = " << pcmlevel0 << std::endl;
std::cout << " Vol Level = " << vollevel0 << std::endl;
#endif
std::cout << " Vol Level = " << vollevel0 << std::endl;
*/
}

Wyświetl plik

@ -367,9 +367,7 @@ void trx_start_macro_timer()
void trx_start(void)
{
if (trxrunning) {
#ifndef __CYGWIN__
std::cout<< "trx already running!\n"; fflush(stdout);
#endif
std::cout<< "trx already running!" << std::endl;
return;
}
@ -402,9 +400,7 @@ void trx_start(void)
_trx_tune = 0;
active_modem = 0;
if (fl_create_thread(trx_thread, trx_loop, &dummy) < 0) {
#ifndef __CYGWIN__
std::cout << "trx pthread_create:" << std::endl; fflush(stdout);
#endif
std::cout << "trx pthread_create:" << std::endl;
trxrunning = false;
exit(1);
}

Wyświetl plik

@ -88,7 +88,6 @@ WFdisp::WFdisp (int x0, int y0, int w0, int h0, char *lbl) :
fft_sig_img = new uchar[image_area];
sig_img = new uchar[sig_image_area];
pwr = new double[IMAGE_WIDTH];
// fft_hist = new short int[image_area];
fft_db = new short int[image_area];
tmp_fft_db = new short int[image_area];
circbuff = new double[FFT_LEN * 2];
@ -142,7 +141,6 @@ WFdisp::~WFdisp() {
delete [] sig_img;
delete [] pwr;
delete [] scline;
// delete [] fft_hist;
delete [] fft_db;
delete [] tmp_fft_db;
}
@ -277,7 +275,6 @@ void WFdisp::setcolors() {
void WFdisp::initmaps() {
// for (int i = 0; i < image_area; i++) fft_hist[i] = -1000;
for (int i = 0; i < image_area; i++) fft_db[i] = log2disp(-1000);
memset (fft_img, 0, image_area * sizeof(RGBI) );
@ -336,8 +333,6 @@ int WFdisp::log2disp(int v)
void WFdisp::update_fft_db()
{
FL_LOCK_D();
// for (int i = 0; i < image_area; i++)
// fft_db[i] = log2disp( fft_hist[i] );
FL_UNLOCK_D();
}
@ -367,7 +362,6 @@ FL_LOCK_D();
else
pw = fftout[n]*fftout[n];
pwr[i] = pw;
//fft_hist[i] =
ffth = (int)(10.0 * log10(pw + 1e-10) );
fft_db[i] = log2disp(ffth);
}

Wyświetl plik

@ -39,6 +39,8 @@
#include "configuration.h"
#include "qrunner.h"
#include "mfsk.h"
using namespace std;
@ -961,7 +963,7 @@ void FTextEdit::menu_cb(int val)
break;
case TX_MENU_MFSK16_IMG:
if (active_modem->get_mode() == MODE_MFSK16)
active_modem->makeTxViewer(0, 0);
showTxViewer(0, 0, (mfsk *)active_modem);
break;
case TX_MENU_CLEAR:

Wyświetl plik

@ -22,14 +22,46 @@
// ----------------------------------------------------------------------------
#include <config.h>
#include <iostream>
#include <sys/stat.h>
#include <sys/types.h>
#include <FL/fl_ask.H>
extern "C" {
// This is needed to avoid a boolean conflict with jmorecfg.h
#ifdef __CYGWIN__
# include <w32api/wtypes.h>
# define HAVE_BOOLEAN 1
#endif
// This is needed to avoid a conflict between a
// system-defined INT32 typedef, and a macro defined in
// jmorecfg.h, included by jpeglib.h. If ADDRESS_TAG_BIT
// is defined, basestd.h has been included and we will have
// the typedef from cygwin, so we define XMD_H to avoid
// defining the macro in jmorecfg.h
#if defined(__CYGWIN__) && !defined(XMD_H)
# define XMD_H
# define FLDIGI_JPEG_XMD_H
#endif
#include <jpeglib.h>
#ifdef FLDIGI_JPEG_XMD_H
# undef FLDIGI_JPEG_XMD_H
# undef XMD_H
#endif
//# include "transupp.h"
};
#include "picture.h"
using namespace std;
picture::picture (int X, int Y, int W, int H) :
Fl_Widget (X, Y, W, H)
{

Wyświetl plik

@ -0,0 +1,117 @@
//
// progress.cxx
//
// Progress bar widget routines.
//
// Based on Fl_Progress widget, Copyright 2000-2005 by Michael Sweet.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
//
// Include necessary header files...
//
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include "progress.h"
//
// progress is a progress bar widget based off Fl_Widget that shows a
// standard progress bar in either horizontal or vertical format
//
// if direction == VERTICAL the indicator goes from lower to upper
// if direction == HORIZONTAL the indicator goes from left to right
void Progress::draw()
{
int progress; // Size of progress bar...
int bx, by, bw, bh; // Box areas...
int tx, tw; // Temporary X + width
int ty, th; // Temporary Y + height
// Get the box borders...
bx = Fl::box_dx(box());
by = Fl::box_dy(box());
bw = Fl::box_dw(box());
bh = Fl::box_dh(box());
tx = x() + bx;
tw = w() - bw;
ty = y() + by;
th = h() - bh;
// Draw the progress bar...
if (maximum_ > minimum_)
progress = (int)((direction == HORIZONTAL ? tw : th) * (value_ - minimum_) / (maximum_ - minimum_) + 0.5f);
else
progress = 0;
// Draw the box and label...
if (progress > 0) {
Fl_Color c = labelcolor();
labelcolor(fl_contrast(labelcolor(), color2()));
if (direction == HORIZONTAL) {
fl_clip(x(), y(), progress, h());
draw_box(box(), x(), y(), w(), h(), active_r() ? color2() : fl_inactive(color2()));
draw_label(tx, y() + by, tw, h() - bh);
fl_pop_clip();
labelcolor(c);
fl_clip(x() + progress, y(), tw - progress, h());
draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
draw_label(tx, y() + by, tw, h() - bh);
fl_pop_clip();
} else {
fl_clip(x(), y(), w(), h() - progress);
draw_box(box(), x(), y(), w(), h(), active_r() ? color() : fl_inactive(color()));
// draw_label(tx, y() + by, tw, h() - bh);
fl_pop_clip();
labelcolor(c);
fl_clip(x(), y() + h() - progress, w(), progress );
draw_box(box(), x(), y(), w(), h(), active_r() ? color2() : fl_inactive(color2()));
// draw_label(tx, y() + by, tw, h() - bh);
fl_pop_clip();
}
} else {
draw_box(box(), x(), y(), w(), h(), color());
if (direction == HORIZONTAL)
draw_label(tx, y() + by, tw, h() - bh);
}
}
Progress::Progress(int X, int Y, int W, int H, const char* l)
: Fl_Widget(X, Y, W, H, l)
{
align(FL_ALIGN_INSIDE);
box(FL_DOWN_BOX);
color(FL_BACKGROUND2_COLOR, FL_YELLOW);
minimum(0.0f);
maximum(100.0f);
value(0.0f);
direction = HORIZONTAL;
}
//
// End of "$Id: Progress.cxx 4288 2005-04-16 00:13:17Z mike $".
//