Пример #1
0
static  gboolean
filter_check_value (const gchar * ext, const gchar * name)
{
    if (!string_is_ascii_printable (ext) || !string_is_ascii_printable (name))
    {
	dialog_message (_("Error"), _("String includes invalid character!\n"
				      "Only ASCII is available."), NULL);
	return FALSE;
    }

    if (strchr (ext, ',') || strchr (name, ','))
    {
	dialog_message (_("Error"),
			_("Sorry, cannot include \",\" character!"), NULL);
	return FALSE;
    }

    if (strchr (ext, ';') || strchr (name, ';'))
    {
	dialog_message (_("Error"),
			_("Sorry, cannot include \";\" character!"), NULL);
	return FALSE;
    }

    return TRUE;
}
Пример #2
0
void partMover::home_all(GtkButton *button, partMover* currentPart)
{
  IPositionControl *ipos = currentPart->pos;
  IEncoders *iiencs = currentPart->iencs;
  IAmplifierControl *iamp = currentPart->amp;
  IPidControl *ipid = currentPart->pid;
  IControlCalibration2 *ical = currentPart->cal;
  int NUMBER_OF_JOINTS;
  ipos->getAxes(&NUMBER_OF_JOINTS);

  //fprintf(stderr, "Retrieving finder \n");
  ResourceFinder *fnd = currentPart->finder;
  //fprintf(stderr, "Retrieved finder: %p \n", fnd);
  char buffer1[800];
  char buffer2[800];

  strcpy(buffer1, currentPart->partLabel);
  strcpy(buffer2, strcat(buffer1, "_zero"));
  //fprintf(stderr, "Finder retrieved %s\n", buffer2);


  if (!fnd->findGroup(buffer2).isNull() && !fnd->isNull())
    {
      bool ok = true;
      Bottle xtmp, ytmp;
      xtmp = fnd->findGroup(buffer2).findGroup("PositionZero");
      ok = ok && (xtmp.size() == NUMBER_OF_JOINTS+1);
      ytmp = fnd->findGroup(buffer2).findGroup("VelocityZero");
      ok = ok && (ytmp.size() == NUMBER_OF_JOINTS+1);
      if(ok)
	{
	  for (int joint = 0; joint < NUMBER_OF_JOINTS; joint++)
	    {
	      double positionZero = xtmp.get(joint+1).asDouble();
	      //fprintf(stderr, "%f ", positionZero);

	      double velocityZero = ytmp.get(joint+1).asDouble();
	      //fprintf(stderr, "%f ", velocityZero);

	      ipos->setRefSpeed(joint, velocityZero);
	      ipos->positionMove(joint, positionZero);
	    }
	}
      else
	dialog_message(GTK_MESSAGE_ERROR,(char *) "Check the number of entries in the group",  buffer2, true);
    }
  else
    {
      //		currentPart->dialog_message(GTK_MESSAGE_ERROR,"No calib file found", strcat("Define a suitable ", strcat(currentPart->partLabel, "Calib")), true);        
      dialog_message(GTK_MESSAGE_ERROR,(char *) "No zero group found in the supplied file. Define a suitable",  buffer2, true);   
    }
  return;
}
void partMover::home_click(GtkButton *button, gtkClassData* currentClassData)
{
  partMover *currentPart = currentClassData->partPointer;
  int * joint = currentClassData->indexPointer;
  IPositionControl *ipos = currentPart->pos;
  IEncoders *iiencs = currentPart->iencs;
  IAmplifierControl *iamp = currentPart->amp;
  IPidControl *ipid = currentPart->pid;
  IControlCalibration2 *ical = currentPart->cal;
  int NUMBER_OF_JOINTS;
  ipos->getAxes(&NUMBER_OF_JOINTS);

  //fprintf(stderr, "Retrieving finder \n");
  ResourceFinder *fnd = currentPart->finder;
  //fprintf(stderr, "Retrieved finder: %p \n", fnd);
  char buffer1[800];
  char buffer2[800];

  strcpy(buffer1, currentPart->partLabel);
  strcpy(buffer2, strcat(buffer1, "_zero"));
  //fprintf(stderr, "Finder retrieved %s\n", buffer2);

  if (!fnd->findGroup(buffer2).isNull() && !fnd->isNull())
    {
      //fprintf(stderr, "Home group was not empty \n");
      bool ok = true;
      Bottle xtmp;
      xtmp = fnd->findGroup(buffer2).findGroup("PositionZero");
      ok = ok && (xtmp.size() == NUMBER_OF_JOINTS+1);
      double positionZero = xtmp.get(*joint+1).asDouble();
      //fprintf(stderr, "%f\n", positionZero);

      xtmp = fnd->findGroup(buffer2).findGroup("VelocityZero");
      //fprintf(stderr, "VALUE VEL is %d \n", fnd->findGroup(buffer2).find("VelocityZero").toString().c_str());
      ok = ok && (xtmp.size() == NUMBER_OF_JOINTS+1);
      double velocityZero = xtmp.get(*joint+1).asDouble();
      //fprintf(stderr, "%f\n", velocityZero);

      if(!ok)
    dialog_message(GTK_MESSAGE_ERROR,(char *) "Check the number of entries in the group",  buffer2, true);
      else
    {
      ipos->setRefSpeed(*joint, velocityZero);
      ipos->positionMove(*joint, positionZero);
    }
    }
  else
    {
      //        currentPart->dialog_message(GTK_MESSAGE_ERROR,"No calib file found", strcat("Define a suitable ", strcat(currentPart->partLabel, "Calib")), true);        
      dialog_message(GTK_MESSAGE_ERROR,(char *) "No zero group found in the supplied file. Define a suitable",  buffer2, true);   
    }
  return;
}
Пример #4
0
int get_cartesian_index_selection(cartesianMover *cm)
{
    GtkTreeIter iter;
    GtkTreeSelection *treeSelection 	= NULL;
    GtkWidget *tree_view = cm->treeview;
    treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
    GtkTreeModel* myModel = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));

    bool selected = (gtk_tree_selection_get_selected (treeSelection, NULL, &iter)?true:false);
    //gchar *buffer[10000];
    //gtk_tree_model_get(myModel, &iter, 0, buffer, -1);


    if(selected==false)
    {
        dialog_message(GTK_MESSAGE_ERROR,(char *) "Select a entry in the table", (char *) "before performing a movement", true);
        return -1;
    }
    else
    {
        GtkTreePath* treePath = gtk_tree_model_get_path(myModel, &iter);
        int *i = gtk_tree_path_get_indices (treePath);
        //gtk_tree_path_free (treePath);
        return (*i);
    }
}
Пример #5
0
static  gboolean
check_value (const gchar * key, const gchar * name)
{
    gchar   message[BUF_SIZE];

    if (!string_is_ascii_graphable (key))
    {
	dialog_message (_("Error"),
			_("Key string includes invalid character!\n"
			  "Only ASCII (except space) is available."), NULL);
	return FALSE;
    }

    if (strchr (key, ',') || strchr (name, ','))
    {
	dialog_message (_("Error"),
			_("Sorry, cannot include \",\" character!"), NULL);
	return FALSE;
    }

    if (strchr (key, ';') || strchr (name, ';'))
    {
	dialog_message (_("Error"),
			_("Sorry, cannot include \";\" character!"), NULL);
	return FALSE;
    }

    if (!key || !*key)
    {
	g_snprintf (message, BUF_SIZE, _("\"Key name\" must be defined."));
	dialog_message (_("Error!!"), message, NULL);
	return FALSE;
    }
    if (!name || !*name)
    {
	g_snprintf (message, BUF_SIZE,
		    _("\"Display name\" must be defined."));
	dialog_message (_("Error!!"), message, NULL);
	return FALSE;
    }

    return TRUE;
}
Пример #6
0
//*********************************************************************************
// This callback loads all sequences
void sequence_all_load (GtkButton *button, partMover** currentPartMover)
{
  GtkWidget *dialog;
  dialog = gtk_file_chooser_dialog_new ("Open File",
                    (GtkWindow*) window,
                    GTK_FILE_CHOOSER_ACTION_OPEN,
                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                    GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                    NULL);

  if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
    {
      char *filenameIn;
      int i, lengthStr;

      filenameIn = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));

      //store the file describing the poses
      for (i = 0; i < NUMBER_OF_ACTIVATED_PARTS; i++)
    {
      fprintf(stderr, "Loading file for PART %d/%d \n", i, NUMBER_OF_ACTIVATED_PARTS);
      Property p;
      bool fileExists;
      char buffer[800];

      fileExists = p.fromConfigFile(filenameIn);
      if (fileExists)
        {
          Bottle& xtmp = p.findGroup(currentPartMover[i]->partLabel);

          sprintf(buffer, "%s",(const char*)xtmp.get(1).toString().c_str());
          lengthStr = strlen(buffer);
          *(buffer + (lengthStr-1)*sizeof(char)) = (char) NULL;
          currentPartMover[i]->load_from_file(buffer+(sizeof(char)),currentPartMover[i]);
        }
      else
        {
          dialog_message(GTK_MESSAGE_ERROR,
                 (char *)"Couldn't find the file describing the positions ",
                 (char *)"associated to the currently activated parts", true);
        }
    }
      g_free (filenameIn);
    }
  gtk_widget_destroy (dialog);

  return;


  //int i;
  //for (i = 0; i < NUMBER_OF_ACTIVATED_PARTS; i++)
  //    currentPartMover[i]->sequence_load(NULL, currentPartMover[i]);
  //return;
}
Пример #7
0
static void url_cb(Fl_Widget *)
{
  char errmsg[512] = {0};
  std::string warnmsg;
  if (!fl_open_uri(PROJECT_URL, errmsg, sizeof(errmsg))) {
    title = "Error";
    warnmsg = "Error: " + std::string(errmsg);
    msg = warnmsg.c_str();
    dialog_message(MESSAGE_TYPE_INFO);
  }
}
Пример #8
0
bool SearchInfo::dialog (bool default_backward)
{
	std::wstring new_pattern;
	bool new_backward;
	bool new_regex;

	ui::dialog_search (new_pattern, new_backward, new_regex,
			get_pattern (), default_backward, get_use_regex ());
	if (new_pattern.empty ()) {
		return false;
	}
	if (StringMatch::assign (new_pattern, new_regex)) {
		backward = new_backward;
		return true;
	}
	else {
		dialog_message (L"Invalid regular expression", L"Error");
		return false;
	}
}
Пример #9
0
void cartesianMover::edited_cartesian_timing (GtkCellRendererText *cell, GtkTreePath *path_str, gchar *new_text, cartesianMover *cm)
{
    GtkWidget *tree_view = cm->treeview;


    //retrieve new val from edited
    gdouble  new_val = atof (new_text);

    //get the current row index
    int i = get_cartesian_index_selection(cm);
    //fprintf(stderr, "Getting index %d", i);
    if (i != -1)
    {
        if (new_val > 0)
            cm->TIMING[i] = new_val;
        else
            dialog_message(GTK_MESSAGE_ERROR, (char *) "Timing must be positive", (char *) "Change your selection", true);
    }

    //redisplay list
    gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), refresh_cartesian_list_model(cm));
    gtk_widget_draw(tree_view, NULL);
}
Пример #10
0
void cartesianMover::edited_cartesian_sequence (GtkCellRendererText *cell, GtkTreePath *path_str, gchar *new_text, cartesianMover *cm)
{

    GtkWidget *tree_view = cm->treeview;

    gint  new_val = atoi (new_text);
    if	 (new_val <-1 || new_val>= NUMBER_OF_STORED) return;
    if	 (new_val == NUMBER_OF_STORED -1)
    {
        dialog_message(GTK_MESSAGE_ERROR,
                       (char *) "Please do not use the entire table (leave at least one row). Otherwise increase NUMBER_OF_STORED",
                       (char *) "Unfortunately maximum sequence length is not set at runtime (recompile)", true);
        return;
    }
    //---

    //get the current row index
    int i = get_cartesian_index_selection(cm);
    if (i != -1)
        cm->SEQUENCE[i] = atoi(new_text);

    gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), refresh_cartesian_list_model(cm));
    gtk_widget_draw(tree_view, NULL);
}
Пример #11
0
static  gboolean
filter_check_duplicate (const gchar * ext, gint row, gboolean dialog)
{
    EditableList *editlist = EDITABLE_LIST (prefs_win.filter_editlist);
    gchar  *text, message[BUF_SIZE];
    gint    i, rows = editable_list_get_n_rows (editlist);

    if (!ext || !*ext)
	return FALSE;

    for (i = 0; i < rows; i++)
    {
	if (i == row)
	    continue;

	text = editable_list_get_cell_text (editlist, i, 0);
	if (!text)
	    continue;

	if (text && *text && !strcasecmp (ext, text))
	{
	    if (dialog)
	    {
		g_snprintf (message, BUF_SIZE,
			    _("\"%s\" is already defined."), ext);
		dialog_message (_("Error!!"), message, NULL);
	    }
	    g_free (text);
	    return TRUE;
	}

	g_free (text);
    }

    return FALSE;
}
Пример #12
0
static void
cb_comment_editlist_confirm (EditableList * editlist,
			     EditableListActionType type,
			     gint selected_row,
			     EditableListConfirmFlags * flags, gpointer data)
{
    GtkWidget *t_auto = prefs_win.comment_auto_toggle;
    GtkWidget *key_entry = prefs_win.comment_key_entry;
    GtkWidget *name_entry = prefs_win.comment_name_entry;
    CommentDataEntry *entry = NULL;
    const gchar *key, *name;
    gchar   message[BUF_SIZE];
    gboolean duplicate = FALSE;

    key = gtk_entry_get_text (GTK_ENTRY (key_entry));
    name = gtk_entry_get_text (GTK_ENTRY (name_entry));

    gtk_widget_set_sensitive (key_entry, TRUE);
    gtk_widget_set_sensitive (name_entry, TRUE);
    gtk_widget_set_sensitive (t_auto, TRUE);

    if (selected_row < 0)
    {
	gtk_widget_set_sensitive (t_auto, FALSE);
    }
    else
    {
	entry = editable_list_get_row_data (editlist, selected_row);
	if (entry)
	{
	    gtk_widget_set_sensitive (key_entry, entry->userdef);
	    gtk_widget_set_sensitive (name_entry, entry->userdef);

	    if (!entry->def_val_fn)
		gtk_widget_set_sensitive (t_auto, FALSE);

	    if (!entry->userdef)
	    {
		*flags |= EDITABLE_LIST_CONFIRM_CANNOT_ADD;
		*flags |= EDITABLE_LIST_CONFIRM_CANNOT_DELETE;
	    }
	}
    }

    if (!key || !*key || !name || !*name)
    {
	*flags |= EDITABLE_LIST_CONFIRM_CANNOT_ADD;
	*flags |= EDITABLE_LIST_CONFIRM_CANNOT_CHANGE;
    }

    if ((!key || !*key) && (!name || !*name) && selected_row < 0)
	*flags |= EDITABLE_LIST_CONFIRM_CANNOT_NEW;


    if (type != EDITABLE_LIST_ACTION_ADD
	&& type != EDITABLE_LIST_ACTION_CHANGE)
	return;

    if (!check_value (key, name))
    {
	*flags |= EDITABLE_LIST_CONFIRM_CANNOT_ADD;
	*flags |= EDITABLE_LIST_CONFIRM_CANNOT_CHANGE;
	gtk_signal_emit_stop_by_name (GTK_OBJECT (editlist),
				      "action_confirm");
	return;
    }


#if 0
    if ((type == EDITABLE_LIST_ACTION_CHANGE) && entry && !entry->userdef)
    {
	if (strcmp (entry->key, key))
	{
	    /*
	     * FIXME!! add error handling 
	     */
	    *flags |= EDITABLE_LIST_CONFIRM_CANNOT_CHANGE;
	    return;
	}
	if (strcmp (_(entry->display_name), name))
	{
	    /*
	     * FIXME!! add error handling 
	     */
	    *flags |= EDITABLE_LIST_CONFIRM_CANNOT_CHANGE;
	    return;
	}
    }
#endif


    if (type == EDITABLE_LIST_ACTION_ADD)
	duplicate = check_duplicate_comment_key (key, -1);
    else if ((type == EDITABLE_LIST_ACTION_CHANGE) && entry && entry->userdef)
	duplicate = check_duplicate_comment_key (key, selected_row);

    if (duplicate)
    {
	g_snprintf (message, BUF_SIZE, _("\"%s\" is already defined."), key);
	dialog_message (_("Error!!"), message, NULL);
	*flags |= EDITABLE_LIST_CONFIRM_CANNOT_ADD;
	*flags |= EDITABLE_LIST_CONFIRM_CANNOT_CHANGE;
	gtk_signal_emit_stop_by_name (GTK_OBJECT (editlist),
				      "action_confirm");
    }
}
Пример #13
0
void AddTooltip(GtkWidget* w, int idc)
{
	gtk_widget_set_tooltip_text(w, dialog_message(idc));
}
void partMover::calib_click(GtkButton *button, gtkClassData* currentClassData)
{
  //ask for confirmation
  if (!dialog_question("Do you really want to recalibrate the joint?")) 
  {
     return;
  }

  partMover *currentPart = currentClassData->partPointer;
  int * joint = currentClassData->indexPointer;
  IPositionControl *ipos = currentPart->pos;
  IEncoders *iiencs = currentPart->iencs;
  IAmplifierControl *iamp = currentPart->amp;
  IPidControl *ipid = currentPart->pid;
  IControlCalibration2 *ical = currentPart->cal;
  int NUMBER_OF_JOINTS;
  ipos->getAxes(&NUMBER_OF_JOINTS);

  ResourceFinder *fnd = currentPart->finder;
  //fprintf(stderr, "opening file \n");
  char buffer1[800];
  char buffer2[800];

  strcpy(buffer1, currentPart->partLabel);
  strcpy(buffer2, strcat(buffer1, "_calib"));

  if (!fnd->findGroup(buffer2).isNull())
    {
      bool ok = true;
      Bottle xtmp;

      xtmp.clear();
      xtmp = fnd->findGroup(buffer2).findGroup("CalibrationType");
      ok = ok && (xtmp.size() == NUMBER_OF_JOINTS+1);
      unsigned char type = (unsigned char) xtmp.get(*joint+1).asDouble();
      fprintf(stderr, "%d ", type);

      xtmp.clear();
      xtmp = fnd->findGroup(buffer2).findGroup("Calibration1");
      ok = ok && (xtmp.size() == NUMBER_OF_JOINTS+1);
      double param1 = xtmp.get(*joint+1).asDouble();
      fprintf(stderr, "%f ", param1);

      xtmp.clear();
      xtmp = fnd->findGroup(buffer2).findGroup("Calibration2");
      ok = ok && (xtmp.size() == NUMBER_OF_JOINTS+1);
      double param2 = xtmp.get(*joint+1).asDouble();
      fprintf(stderr, "%f ", param2);

      xtmp.clear();
      xtmp = fnd->findGroup(buffer2).findGroup("Calibration3");
      ok = ok && (xtmp.size() == NUMBER_OF_JOINTS+1);
      double param3 = xtmp.get(*joint+1).asDouble();
      fprintf(stderr, "%f \n", param3);


      if(!ok)
    dialog_message(GTK_MESSAGE_ERROR,(char *)"Check number of calib entries in the group",  buffer2, true);
      else
    ical->calibrate2(*joint, type, param1, param2, param3);
    }
  else
    dialog_message(GTK_MESSAGE_ERROR,(char *)"The supplied file does not conatain a group named:",  buffer2, true);

  return;
}
Пример #15
0
int dialog_checklist(std::string checklist_options, bool return_value, bool check_all, char separator)
{
  Fl_Group         *g, *g_inside, *buttongroup;
  Fl_Box           *dummy1, *dummy2;
  Fl_Return_Button *but_ok;
  Fl_Button        *but_cancel;
  Fl_Check_Browser *browser;

  std::vector<std::string> vec;
  size_t vec_size;
  int range;

  split(checklist_options, separator, vec);
  vec_size = vec.size();

  if (vec_size < 2) {
    title = "error: checklist";
    msg = "Two or more options required!";
    dialog_message(MESSAGE_TYPE_INFO);
    return 1;
  }

  if (!title) {
    title = "Select your option(s)";
  }

  win = new Fl_Double_Window(420, 356, title);
  win->callback(close_cb, 1);
  {
    g = new Fl_Group(0, 0, 420, 310);
    {
      g_inside = new Fl_Group(0, 0, 420, 310);
      {
        browser = new Fl_Check_Browser(10, 10, 400, 299);
        browser->box(FL_THIN_DOWN_BOX);
        browser->color(fl_lighter(fl_lighter(FL_BACKGROUND_COLOR)));
        browser->clear_visible_focus();
        for (auto it = vec.begin(); it != vec.end(); ++it) {
          std::string &s = *it;
          browser->add(s.c_str());
        }
        if (check_all) {
          browser->check_all();
        }
        dummy1 = new Fl_Box(10, 308, 400, 1);
        dummy1->box(FL_NO_BOX);
        vec.clear();
      }
      g_inside->resizable(dummy1);
      g_inside->end();
    }
    g->resizable(g_inside);
    g->end();

    buttongroup = new Fl_Group(0, 310, 420, 42);
    {
      int but_w = measure_button_width(fl_cancel, 20);
      range = but_w + 40;
      but_cancel = new Fl_Button(win->w() - 10 - but_w, 320, but_w, 26, fl_cancel);
      but_cancel->callback(close_cb, 1);
      but_w = measure_button_width(fl_ok, 40);
      but_ok = new Fl_Return_Button(but_cancel->x() - 10 - but_w, 320, but_w, 26, fl_ok);
      but_ok->callback(close_cb, 0);
      dummy2 = new Fl_Box(but_ok->x() - 1, 310, 1, 1);
      dummy2->box(FL_NO_BOX);
    }
    buttongroup->resizable(dummy2);
    buttongroup->end();
  }
  run_window(win, g, range, 100);

  if (ret == 0) {
    std::string list;
    for (size_t i = 1; i <= vec_size; ++i) {
      if (return_value) {
        if (browser->checked(i)) {
          list.append(quote);
          list.append(browser->text(i));
          list.append(quote);
          list.push_back(separator);
        }
      } else {
        list.append(quote);
        list += (browser->checked(i)) ? "TRUE" : "FALSE";
        list.append(quote);
        list.push_back(separator);
      }
    }
    /* strip trailing separator */
    list.pop_back();
    std::cout << list << std::endl;
  }

  return ret;
}
Пример #16
0
/*
 * Enable all PID and refresh position sliders
 */
void partMover::calib_all(GtkButton *button, partMover* currentPart)
{
  //ask for confirmation
  if (!dialog_question("Do you really want to recalibrate the whole part?")) 
  {
     return;
  }

  IPositionControl *ipos = currentPart->pos;
  IControlCalibration2 *ical = currentPart->cal;
	 
  int joint;
  int NUMBER_OF_JOINTS;
  ipos->getAxes(&NUMBER_OF_JOINTS);

  ResourceFinder *fnd = currentPart->finder;
  //fprintf(stderr, "opening file \n");
  char buffer1[800];
  char buffer2[800];

  strcpy(buffer1, currentPart->partLabel);
  strcpy(buffer2, strcat(buffer1, "_calib"));

  if (!fnd->findGroup(buffer2).isNull())
    {
      bool ok = true;
      Bottle p1 = fnd->findGroup(buffer2).findGroup("Calibration1");
      ok = ok && (p1.size() == NUMBER_OF_JOINTS+1);
      Bottle p2 = fnd->findGroup(buffer2).findGroup("Calibration2");
      ok = ok && (p2.size() == NUMBER_OF_JOINTS+1);
      Bottle p3 = fnd->findGroup(buffer2).findGroup("Calibration3");
      ok = ok && (p3.size() == NUMBER_OF_JOINTS+1);
      Bottle ty = fnd->findGroup(buffer2).findGroup("CalibrationType");
      ok = ok && (ty.size() == NUMBER_OF_JOINTS+1);
      if (ok)
	{
	  for (joint=0; joint < NUMBER_OF_JOINTS; joint++)
	    {

	      double param1 = p1.get(joint+1).asDouble();
	      //fprintf(stderr, "%f ", param1);


	      double param2 = p2.get(joint+1).asDouble();
	      //fprintf(stderr, "%f ", param2);


	      double param3 = p3.get(joint+1).asDouble();
	      //fprintf(stderr, "%f ", param3);

	      unsigned char type = (unsigned char) ty.get(joint+1).asDouble();
	      //fprintf(stderr, "%d ", type);

	      ical->calibrate2(joint, type, param1, param2, param3);
	    }
	}
      else
	dialog_message(GTK_MESSAGE_ERROR,(char *) "Check number of entries in the file",  buffer1, true);
    }
  else
    {
      dialog_message(GTK_MESSAGE_ERROR,(char *) "No calib file found. Define a suitable file called:",  buffer1, true);   
    }
  return;

}
Пример #17
0
/*
 * Load from file the current list of positions
 */
void partMover::load_from_file(char* filenameIn, partMover* currentPart)
{
  IPositionControl *ipos = currentPart->pos;
  IEncoders *iiencs = currentPart->iencs;
  IAmplifierControl *iamp = currentPart->amp;
  IPidControl *ipid = currentPart->pid;
  int *SEQUENCE_TMP = currentPart->SEQUENCE;
  double *TIMING_TMP = currentPart->TIMING;
  double **STORED_POS_TMP = currentPart->STORED_POS;
  double **STORED_VEL_TMP = currentPart->STORED_VEL;
  GtkWidget **sliderAry = currentPart->sliderArray;
  GtkWidget **sliderVelAry = currentPart->sliderVelArray;
  GtkWidget *tree_view = currentPart->treeview;

  int j, k, extensionLength, filenameLength;
  char buffer[800];
  char filenameExtension[800];

  Property p;
  bool fileExists = p.fromConfigFile(filenameIn);	
  strcpy(filenameExtension, ".pos");
  strcat(filenameExtension, currentPart->partLabel);
  extensionLength = strlen(filenameExtension);
  filenameLength = strlen(filenameIn);
  if ((filenameLength - extensionLength) > 0)
    fileExists &= (strcmp(filenameIn + 
			  (sizeof(char))*(filenameLength - extensionLength), 
			  filenameExtension) == 0 );
  else
    fileExists=false;
	
  if (fileExists)
    {
      int NUMBER_OF_JOINTS;
      ipos->getAxes(&NUMBER_OF_JOINTS);
		
      for (j = 0; j < NUMBER_OF_STORED; j++)
	{
	  sprintf(buffer, "POSITION%d", j);
	  Bottle& xtmp = p.findGroup(buffer).findGroup("jointPositions");
	  if (xtmp.size() == NUMBER_OF_JOINTS+1 && j < NUMBER_OF_STORED - 1)
	    {
	      for (k = 0; k < NUMBER_OF_JOINTS; k++)
		STORED_POS_TMP[j][k] = xtmp.get(k+1).asDouble();
				
	      xtmp = p.findGroup(buffer).findGroup("jointVelocities");
	      for (k = 0; k < NUMBER_OF_JOINTS; k++)
		STORED_VEL_TMP[j][k] = xtmp.get(k+1).asDouble();
				
				
	      xtmp = p.findGroup(buffer).findGroup("timing");
	      TIMING_TMP[j] = xtmp.get(1).asDouble();
	      SEQUENCE_TMP[j] = j;
	    }
	  else
	    {
	      for (k = 0; k < NUMBER_OF_JOINTS; k++)
		STORED_POS_TMP[j][k] = 0.0;
	      SEQUENCE_TMP[j] = -1;
	      if(j==0)
		{
		  dialog_message(GTK_MESSAGE_ERROR,
				 (char *) "Couldn't load a valid position file.", 
				 (char *) "Check the format of the supplied file.", true);
		  return;
		}
	      if(j == NUMBER_OF_STORED - 1 && xtmp.size() == NUMBER_OF_JOINTS+1)
		{
		  dialog_message(GTK_MESSAGE_ERROR,
			      (char *) "Truncating the current sequence which is too long. You need to recompile with a greater value of NUMBER_OF_STORED", 
			      (char *) "Unfortunately maximum sequence length is not set at runtime", true);
		}
	    }
	}
      if(GTK_IS_TREE_VIEW (tree_view))	
	{
	  gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), refresh_position_list_model(currentPart));
	  gtk_widget_draw(GTK_WIDGET(tree_view), NULL);
	}
    }
  else
    dialog_message(GTK_MESSAGE_ERROR,
				(char *) "Wrong format (check estensions) of the file associated with:", 
				currentPart->partLabel, true);
  return;
}
Пример #18
0
void main_linux ( int argc, char **argv )
{
    GtkWidget *vbox;
    gboolean first_use = FALSE;
    cmdline_options  opt;
    gint status = CMDLINE_SYNTAX_OK;

    /* initialisation des différents répertoires */
    gsb_dirs_init ( );

    bindtextdomain ( PACKAGE, gsb_dirs_get_locale_dir ( ) );
    bind_textdomain_codeset ( PACKAGE, "UTF-8" );
    textdomain ( PACKAGE );

    /* Setup locale/gettext */
    setlocale (LC_ALL, "");
    gsb_locale_init ( );

#if IS_DEVELOPMENT_VERSION == 1
    gsb_grisbi_print_environment_var ( );
#endif

    gtk_init ( &argc, &argv );

    /* initialisation libgoffice */
    libgoffice_init ( );
    /* Initialize plugins manager */
    go_plugins_init (NULL, NULL, NULL, NULL, TRUE, GO_TYPE_PLUGIN_LOADER_MODULE);

    /* on commence par détourner le signal SIGSEGV */
    gsb_grisbi_trappe_signal_sigsegv ( );

    /* parse command line parameter, exit with correct error code when needed */
    if ( !parse_options (argc, argv, &opt, &status ) )
        exit ( status );
    /* initialise les données de l'application */
    first_use = gsb_grisbi_init_app ( );

    /* create the toplevel window and the main menu */
    vbox = gsb_main_create_main_window ( );
    gsb_grisbi_create_main_menu ( vbox );
    main_window_set_size_and_position ( );

    gtk_widget_show ( run.window );

#if IS_DEVELOPMENT_VERSION == 1
    dialog_message ( "development-version", VERSION );
#endif

    /* check the command line, if there is something to open */
    gsb_grisbi_load_file_if_necessary ( &opt );

    if ( first_use && !nom_fichier_comptes )
        gsb_assistant_first_run ();
    else
        display_tip ( FALSE );

    gtk_main ();

    /* sauvegarde les raccourcis claviers */
    gtk_accel_map_save ( gsb_dirs_get_accelerator_filename () );

    /* libération de mémoire */
    gsb_locale_shutdown ( );
    gsb_dirs_shutdown ( );

    /* liberation libgoffice */
    libgoffice_shutdown ( );

#if GSB_GMEMPROFILE
    g_mem_profile();
#endif

    exit ( 0 );
}
Пример #19
0
void cartesianMover::position_slider_changed(GtkRange *range, cartesianMover *cm)
{

    ICartesianControl *icrt = cm->crt;
    GtkWidget **sliderPosArray = (GtkWidget **) cm->sliderArray;
    GtkWidget *sliderVel      = (GtkWidget *) cm->sliderVelocity;
  
    int sliderIndex;
    for(int i=0; i < NUMBER_OF_CARTESIAN_COORDINATES; i++)
        if(sliderPosArray[i]==(GtkWidget*) range)
            sliderIndex=i;

    gboolean focus;
    g_object_get((gpointer) range, "has-focus", &focus, NULL);
    if (focus)
        {
            if (sliderIndex<3)
                {
                    Vector xd(3);   Vector x;   Vector o;
                    xd(0) = gtk_range_get_value((GtkRange *) sliderPosArray[0]);
                    xd(1) = gtk_range_get_value((GtkRange *) sliderPosArray[1]);  
                    xd(2) = gtk_range_get_value((GtkRange *) sliderPosArray[2]); 

                    if(!icrt->getPose(x,o))
                        fprintf(stderr, "Troubles in gettin the cartesian pose for %s\n", cm->partLabel);

                    double time = gtk_range_get_value((GtkRange *) sliderVel);
                    if(!icrt->goToPoseSync(xd,o,time))
                        fprintf(stderr, "Troubles in executing the cartesian pose for %s\n", cm->partLabel);
                    //else
                    //    fprintf(stderr, "Sent %s new cartesian for %s with time %.1f\n", xd.toString().c_str(),cm->partLabel, time);

                    int count= 0;
                    bool checkDone=false;
                    while(checkDone==false && count*10<2*time*1000)
                        {
                            icrt->checkMotionDone(&checkDone);
                            //fprintf(stderr, "Check %d\n", checkDone);
                            Time::delay(0.01);
                            count++;
                        }
                    if(!checkDone)
                        {
                            //fprintf(stderr, "Aborting since trajectory was not completed in 2*Time\n");
                            dialog_message(GTK_MESSAGE_ERROR,(char *)"Aborting cartesian trajectory", (char *)"Final point reaching was taking too much time", true);
                            icrt->stopControl();
                        }
                }
                        
            else
                {
                    Vector eud(3);  Vector x;   Vector o;
                    eud(0) = gtk_range_get_value((GtkRange *) sliderPosArray[3]) * M_PI/180;
                    eud(1) = gtk_range_get_value((GtkRange *) sliderPosArray[4]) * M_PI/180;  
                    eud(2) = gtk_range_get_value((GtkRange *) sliderPosArray[5]) * M_PI/180;  

                    //fprintf(stderr, "Will move to x=%s, o=%s\n", x.toString().c_str(), o.toString().c_str());
                    Matrix Rd = euler2dcm(eud);
                    Vector od = dcm2axis(Rd);

                    if(!icrt->getPose(x,o))
                        fprintf(stderr, "Troubles in gettin the cartesian pose for %s\n", cm->partLabel);

                    double time = gtk_range_get_value((GtkRange *) sliderVel);
                    if(!icrt->goToPoseSync(x,od,time))
                        fprintf(stderr, "Troubles in executing the cartesian pose for %s\n", cm->partLabel);
                    //else
                    //    fprintf(stderr, "Sent %s new orientation for %s\n", od.toString().c_str(), cm->partLabel);

                    int count= 0;
                    bool checkDone=false;
                    while(checkDone==false && count*10<2*time*1000)
                        {
                            icrt->checkMotionDone(&checkDone);
                            //fprintf(stderr, "Check %d\n", checkDone);
                            Time::delay(0.01);
                            count++;
                        }
                        
                    if(!checkDone)
                        {
                            //fprintf(stderr, "Aborting since trajectory was not completed in 2*Time\n");
                            dialog_message(GTK_MESSAGE_ERROR,(char *)"Aborting cartesian trajectory", (char *)"Final point reaching was taking too much time", true);
                            icrt->stopControl();
                        }
                }
        }
}
Пример #20
0
void main_win_32 (  int argc, char **argv )
{
#ifdef _WIN32
    GtkWidget *vbox;
    gboolean first_use = FALSE;
    cmdline_options  opt;
    gint status = CMDLINE_SYNTAX_OK;    /* be optimistic ;-) */

    /* Retrieve exception information and store them under grisbi.rpt file!
     * see http://jrfonseca.dyndns.org/projects/gnu-win32/software/drmingw/index.html for more information */
    LoadLibrary("exchndl.dll");

    /* we store the path of the running file to use it for pixmaps, help and locales .... */
    win32_set_app_path(argv[0]);

     /* needed to be able to use the "common" installation of GTK libraries */
    win32_make_sure_the_gtk2_dlls_path_is_in_PATH();

    /* initialisation des différents répertoires */
    gsb_dirs_init ( );

    bindtextdomain ( PACKAGE, gsb_dirs_get_locale_dir ( ) );
    bind_textdomain_codeset ( PACKAGE, "UTF-8" );
    textdomain ( PACKAGE );

    /* Setup locale/gettext */
    setlocale( LC_ALL, NULL );

    gsb_locale_init ( );

    /* initialisation libgoffice */
    libgoffice_init ( );
    /* Initialize plugins manager */
    go_plugins_init (NULL, NULL, NULL, NULL, TRUE, GO_TYPE_PLUGIN_LOADER_MODULE);

    gtk_init ( &argc, &argv );

    win32_parse_gtkrc ( "gtkrc" );

    /* parse command line parameter, exit with correct error code when needed */
    if ( !parse_options (argc, argv, &opt, &status ) )
        exit ( status );

    /* initialise les données de l'application */
    first_use = gsb_grisbi_init_app ( );

    /* create the toplevel window and the main menu */
    vbox = gsb_main_create_main_window ( );
    gsb_grisbi_create_main_menu ( vbox );
    main_window_set_size_and_position ( );

    gtk_widget_show ( run.window );

#if IS_DEVELOPMENT_VERSION == 1
    dialog_message ( "development-version", VERSION );
#endif

    gsb_grisbi_load_file_if_necessary ( &opt );

    if ( first_use && !nom_fichier_comptes )
        gsb_assistant_first_run ();
    else
        display_tip ( FALSE );

    gtk_main ();

    /* sauvegarde les raccourcis claviers */
    gtk_accel_map_save ( gsb_dirs_get_accelerator_filename () );

    gsb_locale_shutdown ( );
    gsb_dirs_shutdown ( );

    /* liberation libgoffice */
    libgoffice_shutdown ( );

#if GSB_GMEMPROFILE
    g_mem_profile();
#endif

    exit ( 0 );

#endif /* WIN_32 */
}
Пример #21
0
void main_mac_osx ( int argc, char **argv )
{
#ifdef GTKOSXAPPLICATION
    GtkWidget *vbox;
    GtkWidget *menubar;
    GdkPixbuf *pixbuf;
    cmdline_options  opt;
    gboolean first_use = FALSE;
    gint status = CMDLINE_SYNTAX_OK;
    GtkOSXApplication *theApp;

    devel_debug ("main_mac_osx");

#if IS_DEVELOPMENT_VERSION == 1
    gsb_grisbi_print_environment_var ( );
#endif

    gtk_init ( &argc, &argv );

    /* initialisation libgoffice */
    libgoffice_init ( );
    /* Initialize plugins manager */
    go_plugins_init (NULL, NULL, NULL, NULL, TRUE, GO_TYPE_PLUGIN_LOADER_MODULE);

    /* init the app */
    theApp = g_object_new ( GTK_TYPE_OSX_APPLICATION, NULL );

    /* initialisation des différents répertoires */
    gsb_dirs_init ( );

    bindtextdomain ( PACKAGE,  gsb_dirs_get_locale_dir ( ) );
    bind_textdomain_codeset ( PACKAGE, "UTF-8" );
    textdomain ( PACKAGE );

    /* Setup locale/gettext */
    setlocale (LC_ALL, "");
    gsb_locale_init ( );

    /* on commence par détourner le signal SIGSEGV */
    gsb_grisbi_trappe_signal_sigsegv ( );

    /* parse command line parameter, exit with correct error code when needed */
    if ( !parse_options (argc, argv, &opt, &status ) )
        exit ( status );

    /* initialise les données de l'application */
    first_use = gsb_grisbi_init_app ( );

    vbox = gsb_main_create_main_window ( );
    {
        gboolean falseval = FALSE;
        gboolean trueval = TRUE;

        g_signal_connect ( theApp,
                        "NSApplicationDidBecomeActive",
                        G_CALLBACK ( grisbi_osx_app_active_cb ),
                        &trueval );
        g_signal_connect ( theApp,
                        "NSApplicationWillResignActive",
                        G_CALLBACK ( grisbi_osx_app_active_cb ),
                        &falseval);
        g_signal_connect ( theApp,
                        "NSApplicationBlockTermination",
                        G_CALLBACK ( gsb_main_grisbi_close ),
                        NULL);
        g_signal_connect ( theApp,
                        "NSApplicationWillTerminate",
                        G_CALLBACK ( main_window_destroy_event ),
                        NULL );
    }
    menubar = gsb_grisbi_create_main_menu ( vbox );
    grisbi_osx_init_menus ( main_window, menubar );
    main_window_set_size_and_position ( );

    gtk_widget_show ( run.window );

#if IS_DEVELOPMENT_VERSION == 1
    dialog_message ( "development-version", VERSION );
#endif

    gsb_grisbi_load_file_if_necessary ( &opt );

    if ( first_use && !nom_fichier_comptes )
        gsb_assistant_first_run ();
    else
        display_tip ( FALSE );

    if ( quartz_application_get_bundle_id ( ) == NULL )
    {
        pixbuf = gdk_pixbuf_new_from_file ( g_build_filename
                        (gsb_dirs_get_pixmaps_dir ( ), "grisbi-logo.png", NULL), NULL );
        if ( pixbuf )
            gtk_osxapplication_set_dock_icon_pixbuf ( theApp, pixbuf );
    }

    gtk_osxapplication_set_use_quartz_accelerators ( theApp, TRUE );

    gtk_osxapplication_ready ( theApp );

    gtk_main ();

    /* sauvegarde les raccourcis claviers */
    gtk_accel_map_save ( gsb_dirs_get_accelerator_filename () );

    g_object_unref ( theApp );

    gsb_locale_shutdown ( );
    gsb_dirs_shutdown ( );

    /* liberation libgoffice */
    libgoffice_shutdown ( );

#if GSB_GMEMPROFILE
    g_mem_profile();
#endif

    exit ( 0 );

#endif /* GTKOSXAPPLICATION */
}