File: gtk-sat-map.h

package info (click to toggle)
gpredict 1.1-7
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 8,280 kB
  • ctags: 2,873
  • sloc: ansic: 34,903; sh: 10,151; makefile: 417
file content (188 lines) | stat: -rw-r--r-- 7,344 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
  Gpredict: Real-time satellite tracking and orbit prediction program

  Copyright (C)  2001-2009  Alexandru Csete, OZ9AEC.
  Copyright (C)  2006-2007  William J Beksi, KC2EXL.

  Authors: Alexandru Csete <oz9aec@gmail.com>
  William J Beksi <wjbeksi@users.sourceforge.net>

  Comments, questions and bugreports should be submitted via
  http://sourceforge.net/projects/gpredict/
  More details can be found at the project home page:

  http://gpredict.oz9aec.net/
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program; if not, visit http://www.fsf.org/
*/
#ifndef __GTK_SAT_MAP_H__
#define __GTK_SAT_MAP_H__ 1

#include <glib.h>
#include <glib/gi18n.h>
#include <gdk/gdk.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkvbox.h>
#include "gtk-sat-data.h"
#include <goocanvas.h>


#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


#define SAT_MAP_RANGE_CIRCLE_POINTS    180  /*!< Number of points used to plot a satellite range half circle. */


#define GTK_SAT_MAP(obj)          GTK_CHECK_CAST (obj, gtk_sat_map_get_type (), GtkSatMap)
#define GTK_SAT_MAP_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, gtk_sat_map_get_type (), GtkSatMapClass)
#define GTK_IS_SAT_MAP(obj)       GTK_CHECK_TYPE (obj, gtk_sat_map_get_type ())
#define GTK_TYPE_SAT_MAP          (gtk_sat_map_get_type ())
#define IS_GTK_SAT_MAP(obj)       GTK_CHECK_TYPE (obj, gtk_sat_map_get_type ())


//typedef struct _GtkSatMap        GtkSatMap;
typedef struct _GtkSatMapClass   GtkSatMapClass;


/** \brief Structure that define a sub-satellite point. */
typedef struct {
    double lat;   /*!< Latitude in decimal degrees North. */
    double lon;   /*!< Longitude in decimal degrees West. */
} ssp_t;


/** \brief Data storage for ground tracks */
typedef struct {
    GSList    *latlon;   /*!< List of ssp_t */
    GSList    *lines;    /*!< List of GooCanvasPolyLine */
} ground_track_t;


/** \brief Satellite object.
 *
 * This data structure represents a satellite object on the map. It consists of a
 * small square representing the position, a label showinf the satellite name, and
 * the range circle. The range circle can have one or two parts, depending on
 * whether it is split or not. The oldrcnum and newrcnum fields are used for
 * keeping track of whether the range circle has one or two parts.
 *
 */
typedef struct {
        
    /* flags */
    gboolean        selected;     /*!< Is satellite selected? */
    gboolean        showtrack;    /*!< Show ground track */
    gboolean        showcov;      /*!< Show coverage area. */
    gboolean        istarget;     /*!< is this object the target */
    
    /* graphical elements */
    GooCanvasItemModel  *marker;  /*!< A small rectangle showing sat pos. */
    GooCanvasItemModel  *label;   /*!< Satellite name. */
    GooCanvasItemModel  *range1;  /*!< First part of the range circle. */
    GooCanvasItemModel  *range2;  /*!< Second part of the range circle. */
    
    /* book keeping */
    guint           oldrcnum;     /*!< Number of RC parts in prev. cycle. */
    guint           newrcnum;     /*!< Number of RC parts in this cycle. */
    
    ground_track_t  track_data;   /*!< Ground track data. */
    unsigned long   track_orbit;  /*!< Orbit when the ground track has been updated. */
    
} sat_map_obj_t;
    

#define SAT_MAP_OBJ(obj) ((sat_map_obj_t *)obj)


/** \brief The satellite map data structure. */
typedef struct {
    GtkVBox vbox;

    GtkWidget  *canvas;                 /*!< The canvas widget. */
    
    GooCanvasItemModel *map;            /*!< The canvas map item. */
    
    GooCanvasItemModel *qthmark;        /*!< QTH marker, e.g. small rectangle. */
    GooCanvasItemModel *qthlabel;       /*!< Label showing the QTH name. */
    
    GooCanvasItemModel *locnam;         /*!< Location name. */
    GooCanvasItemModel *curs;           /*!< Cursor tracking text. */
    GooCanvasItemModel *next;           /*!< Next event text. */
    GooCanvasItemModel *sel;            /*!< Text showing info about the selected satellite. */
    
    GooCanvasItemModel *gridv[11];      /*!< Vertical grid lines, 30 deg resolution. */
    GooCanvasItemModel *gridvlab[11];   /*!< Vertical grid  labels. */
    GooCanvasItemModel *gridh[5];       /*!< Horizontal grid lines, 30 deg resolution. */
    GooCanvasItemModel *gridhlab[5];    /*!< Horizontal grid labels. */
    
    gdouble     naos;                   /*!< Next event time. */
    gint        ncat;                   /*!< Next event catnum. */
    
    gdouble     tstamp;                 /*!< Time stamp for calculations; set by GtkSatModule */
    
    GKeyFile   *cfgdata;                /*!< Module configuration data. */
    GHashTable *sats;                   /*!< Pointer to satellites (owned by parent GtkSatModule). */
    qth_t      *qth;                    /*!< Pointer to current location. */
    
    GHashTable *obj;                    /*!< Canvas items representing each satellite. */
    
    guint       x0;                     /*!< X0 of the canvas map. */
    guint       y0;                     /*!< Y0 of the canvas map. */
    guint       width;                  /*!< Map width. */
    guint       height;                 /*!< Map height. */
    
    guint       refresh;                /*!< Refresh rate. */
    guint       counter;                /*!< Cycle counter. */
    
    gboolean    qthinfo;                /*!< Show the QTH info. */
    gboolean    eventinfo;              /*!< Show info about the next event. */
    gboolean    cursinfo;               /*!< Track the mouse cursor. */
    gboolean    showgrid;               /*!< Show grid on map. */
    gboolean    keepratio;              /*!< Keep map aspect ratio. */
    gboolean    resize;                 /*!< Flag indicating that the map has been resized. */
    
    gchar      *infobgd;                /*!< Background color of info text. */
    
    GdkPixbuf  *origmap;                /*!< Original map kept here for high quality scaling. */
    
} GtkSatMap;
    

struct _GtkSatMapClass
{
    GtkVBoxClass parent_class;
};


GtkType        gtk_sat_map_get_type (void);
GtkWidget*     gtk_sat_map_new      (GKeyFile   *cfgdata,
                                     GHashTable *sats,
                                     qth_t      *qth);
void           gtk_sat_map_update   (GtkWidget  *widget);
void           gtk_sat_map_reconf   (GtkWidget  *widget, GKeyFile *cfgdat);

void           gtk_sat_map_lonlat_to_xy (GtkSatMap *m,
                                         gdouble lon, gdouble lat,
                                         gdouble *x, gdouble *y);

void gtk_sat_map_reload_sats (GtkWidget *satmap, GHashTable *sats);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __GTK_SAT_MAP_H__ */