コード例 #1
0
/** \brief Delete the ground track for a satellite.
 *  \param satmap The satellite map widget.
 *  \param sat Pointer to the satellite object.
 *  \param qth Pointer to the QTH data.
 *  \param obj the satellite object.
 *  \param clear_ssp Flag indicating whether SSP data should be cleared as well (TRUE=yes);
 *
 */
void
ground_track_delete (GtkSatMap *satmap, sat_t *sat, qth_t *qth, sat_map_obj_t *obj, gboolean clear_ssp)
{
     guint              i,n;
     gint               j;
     GooCanvasItemModel *line;
     GooCanvasItemModel *root;

    (void) qth; /* avoid unusued parameter compiler warning */

    sat_log_log (SAT_LOG_LEVEL_DEBUG,
                     _("%s: Deleting ground track for %s"),
                 __FUNCTION__, sat->nickname);

     root = goo_canvas_get_root_item_model (GOO_CANVAS (satmap->canvas));

     /* remove plylines */
     if (obj->track_data.lines != NULL) {
          n = g_slist_length (obj->track_data.lines);

          for (i = 0; i < n; i++) {

               /* get line */
               line = GOO_CANVAS_ITEM_MODEL (g_slist_nth_data (obj->track_data.lines, i));

               /* find its ID and remove it */
               j = goo_canvas_item_model_find_child (root, line);
               if (j == -1) {
                    sat_log_log (SAT_LOG_LEVEL_ERROR,
                                    _("%s: Could not find part %d of ground track"),
                                    __FUNCTION__, j);
               }
               else {
                    goo_canvas_item_model_remove_child (root, j);
               }
          }

          g_slist_free (obj->track_data.lines);
          obj->track_data.lines = NULL;
               
     }

     /* clear SSP too? */
     if (clear_ssp == TRUE) {
          if (obj->track_data.latlon != NULL) {

               /* free allocated ssp_t */
               g_slist_foreach (obj->track_data.latlon, free_ssp, NULL);

               /* free the SList itself */
               g_slist_free (obj->track_data.latlon);
               obj->track_data.latlon = NULL;

          }

          obj->track_orbit = 0;
     }
}
コード例 #2
0
/**
 * goo_canvas_item_model_remove:
 * @model: an item model.
 * 
 * Removes a model from its parent. If the model is in a canvas it will be
 * removed.
 *
 * This would normally also result in the model being freed.
 **/
void
goo_canvas_item_model_remove         (GooCanvasItemModel *model)
{
  GooCanvasItemModel *parent;
  gint child_num;

  parent = goo_canvas_item_model_get_parent (model);
  if (!parent)
    return;

  child_num = goo_canvas_item_model_find_child (parent, model);
  if (child_num == -1)
    return;

  goo_canvas_item_model_remove_child (parent, child_num);
}
コード例 #3
0
/** \brief Manage toggling of Ground Track.
 *  \param item The menu item that was toggled.
 *  \param data Pointer to the GtkPolarView structure.
 *
 */
static void
        track_toggled (GtkCheckMenuItem *item, gpointer data)
{
    GtkPolarView       *pv = GTK_POLAR_VIEW (data);
    sat_obj_t          *obj = NULL;
    sat_t              *sat;
    qth_t              *qth;
    gint               idx,i;
    GooCanvasItemModel *root;
    pass_detail_t      *detail;
    guint              num;
    GooCanvasPoints    *points;
    gfloat             x,y;
    guint32            col;
    guint              tres,ttidx;


    /* get satellite object */
    obj = SAT_OBJ(g_object_get_data (G_OBJECT (item), "obj"));
    sat = SAT(g_object_get_data (G_OBJECT (item), "sat"));
    qth = (qth_t *)(g_object_get_data (G_OBJECT (item), "qth"));

    if (obj == NULL) {
        sat_log_log (SAT_LOG_LEVEL_BUG,
                     _("%s:%d: Failed to get satellite object."),
                     __FILE__, __LINE__);
        return;
    }

    /* toggle flag */
    obj->showtrack = !obj->showtrack;
    gtk_check_menu_item_set_active (item, obj->showtrack);

    root = goo_canvas_get_root_item_model (GOO_CANVAS (pv->canvas));

    if (obj->showtrack) {
        /* add sky track */

        /* create points */
        num = g_slist_length (obj->pass->details);
        if (num == 0) {
            sat_log_log (SAT_LOG_LEVEL_BUG,
                         _("%s:%d: Pass has no details."),
                         __FILE__, __LINE__);
            return;
        }

        /* time resolution for time ticks; we need
                   3 additional points to AOS and LOS ticks.
                */
        tres = (num-2) / (TRACK_TICK_NUM-1);

        points = goo_canvas_points_new (num);

        /* first point should be (aos_az,0.0) */
        azel_to_xy (pv, obj->pass->aos_az, 0.0, &x, &y);
        points->coords[0] = (double) x;
        points->coords[1] = (double) y;
        obj->trtick[0] = create_time_tick (pv, obj->pass->aos, x, y);

        ttidx = 1;

        for (i = 1; i < num-1; i++) {
            detail = PASS_DETAIL(g_slist_nth_data (obj->pass->details, i));
            if (detail->el >=0.0)
                azel_to_xy (pv, detail->az, detail->el, &x, &y);
            points->coords[2*i] = (double) x;
            points->coords[2*i+1] = (double) y;

            if (!(i % tres)) {
                /* create a time tick */
                if (ttidx<TRACK_TICK_NUM)
                    obj->trtick[ttidx] = create_time_tick (pv, detail->time, x, y);
                ttidx++;
            }
        }

        /* last point should be (los_az, 0.0)  */
        azel_to_xy (pv, obj->pass->los_az, 0.0, &x, &y);
        points->coords[2*(num-1)] = (double) x;
        points->coords[2*(num-1)+1] = (double) y;

        /* create poly-line */
        col = mod_cfg_get_int (pv->cfgdata,
                               MOD_CFG_POLAR_SECTION,
                               MOD_CFG_POLAR_TRACK_COL,
                               SAT_CFG_INT_POLAR_TRACK_COL);

        obj->track = goo_canvas_polyline_model_new (root, FALSE, 0,
                                                    "points", points,
                                                    "line-width", 1.0,
                                                    "stroke-color-rgba", col,
                                                    "line-cap", CAIRO_LINE_CAP_SQUARE,
                                                    "line-join", CAIRO_LINE_JOIN_MITER,
                                                    NULL);
        goo_canvas_points_unref (points);

        /* put track on the bottom of the sack */
        goo_canvas_item_model_lower (obj->track, NULL);

    }
    else {
        /* delete sky track */
        idx = goo_canvas_item_model_find_child (root, obj->track);

        if (idx != -1) {
            goo_canvas_item_model_remove_child (root, idx);
        }

        for (i = 0; i < TRACK_TICK_NUM; i++) {
            idx = goo_canvas_item_model_find_child (root, obj->trtick[i]);

            if (idx != -1) {
                goo_canvas_item_model_remove_child (root, idx);
            }
        }
    }

}