示例#1
0
// Initialise the sample interface
int sample_init(imagewnd_t *imagewnd, colorwnd_t *colorwnd, mezz_mmap_t *mmap)
{
  int i;
  double r;

  sample = malloc(sizeof(sample_t));

  sample->mmap = mmap;
  sample->radius = 5;

  // Create sample point figures on the image
  for (i = 0; i < ARRAYSIZE(sample->figs); i++)
  {
    sample->figs[i] = rtk_fig_create(imagewnd->canvas, imagewnd->imagefig, 1);
    rtk_fig_movemask(sample->figs[i], RTK_MOVE_TRANS);
    rtk_fig_origin(sample->figs[i], sample->mmap->width/2, sample->mmap->height/2, 0);
    rtk_fig_color(sample->figs[i], COLOR_SAMPLE);
    r = sample->radius + 2;
    rtk_fig_rectangle(sample->figs[i], 0, 0, 0, r, r, 0);
    rtk_fig_line(sample->figs[i], -2 * r, 0, -r, 0);
    rtk_fig_line(sample->figs[i], +2 * r, 0, +r, 0);
    rtk_fig_line(sample->figs[i], 0, -2 * r, 0, -r);
    rtk_fig_line(sample->figs[i], 0, +2 * r, 0, +r);
  }

  // Create figures to put on the color space
  sample->vufig = rtk_fig_create(colorwnd->canvas, colorwnd->vufig, 2);
  sample->yufig = rtk_fig_create(colorwnd->canvas, colorwnd->yufig, 2);
  sample->vyfig = rtk_fig_create(colorwnd->canvas, colorwnd->vyfig, 2);
  
  return 0;
}
void actarray_allocate(actarray_t *actarray, int size)
{
  int ii;
  if (size == actarray->fig_count)
    return;
  if (size < actarray->fig_count)
  {
    for (ii=size; ii < actarray->fig_count; ++ii)
    {
      rtk_fig_destroy(actarray->actuator_fig[ii]);
      rtk_fig_destroy(actarray->actuator_fig_cmd[ii]);
    }
  }
  actarray->actuator_fig = realloc(actarray->actuator_fig, size * sizeof(rtk_fig_t*));
  actarray->actuator_fig_cmd = realloc(actarray->actuator_fig_cmd, size * sizeof(rtk_fig_t*));
  actarray->lastvalue = realloc(actarray->lastvalue, size*sizeof(double));
  if (size > actarray->fig_count)
  {
    for (ii=actarray->fig_count; ii < size; ++ii)
    {
      actarray->lastvalue[ii] = 1e10;
      actarray->actuator_fig[ii] = rtk_fig_create(actarray->mainwnd->canvas, actarray->mainwnd->robot_fig, 10);
      actarray->actuator_fig_cmd[ii] = rtk_fig_create(actarray->mainwnd->canvas, actarray->mainwnd->robot_fig, 11);
      rtk_fig_movemask(actarray->actuator_fig_cmd[ii], RTK_MOVE_TRANS);
      rtk_fig_origin(actarray->actuator_fig_cmd[ii], ARRAY_SPACING*ii+ARRAY_X_OFFSET, 0, 0);
      rtk_fig_color_rgb32(actarray->actuator_fig_cmd[ii], COLOR_ACTARRAY_CMD);
      rtk_fig_ellipse(actarray->actuator_fig_cmd[ii], 0, 0, 0, 0.2, 0.2, 0);

    }
  }
  actarray->fig_count = size;
}
示例#3
0
// Create a ptz device
ptz_t *ptz_create(mainwnd_t *mainwnd, opt_t *opt, playerc_client_t *client,
                  int index, const char *drivername, int subscribe)
{
  char section[64];
  char label[64];
  ptz_t *ptz;
  
  ptz = malloc(sizeof(ptz_t));
  ptz->datatime = 0;
  ptz->drivername = strdup(drivername);
  ptz->proxy = playerc_ptz_create(client, index);

  // Set initial device state
  snprintf(section, sizeof(section), "ptz:%d", index);
  if (subscribe)
  {
    if (playerc_ptz_subscribe(ptz->proxy, PLAYER_OPEN_MODE) != 0)
      PRINT_ERR1("libplayerc error: %s", playerc_error_str());
  }

  // Construct the menu
  snprintf(label, sizeof(label), "ptz:%d (%s)", index, ptz->drivername);
  ptz->menu = rtk_menu_create_sub(mainwnd->device_menu, label);
  ptz->subscribe_item = rtk_menuitem_create(ptz->menu, "Subscribe", 1);
  ptz->command_item = rtk_menuitem_create(ptz->menu, "Command", 1);
  
  // Set the initial menu state
  rtk_menuitem_check(ptz->subscribe_item, ptz->proxy->info.subscribed);

  // Construct figures
  ptz->data_fig = rtk_fig_create(mainwnd->canvas, mainwnd->robot_fig, 10);
  ptz->cmd_fig = rtk_fig_create(mainwnd->canvas, mainwnd->robot_fig, 11);
  ptz->data_fig_tilt = rtk_fig_create(mainwnd->canvas, mainwnd->robot_fig, 12);
  ptz->cmd_fig_tilt = rtk_fig_create(mainwnd->canvas, mainwnd->robot_fig, 13);
  rtk_fig_movemask(ptz->cmd_fig, RTK_MOVE_TRANS);
  rtk_fig_origin(ptz->cmd_fig, 1, 0, 0);
  rtk_fig_color_rgb32(ptz->cmd_fig, COLOR_PTZ_CMD);
  rtk_fig_ellipse(ptz->cmd_fig, 0, 0, 0, 0.2, 0.2, 0);
  
  rtk_fig_movemask(ptz->cmd_fig_tilt, RTK_MOVE_TRANS);
  rtk_fig_origin(ptz->cmd_fig_tilt, 0.8, 0, 0);
  rtk_fig_color_rgb32(ptz->cmd_fig_tilt, COLOR_PTZ_CMD_TILT);
  rtk_fig_ellipse(ptz->cmd_fig_tilt, 0, 0, 0, 0.2, 0.2, 0);
  
  
  return ptz;
}