Пример #1
0
//********************************************************
void WordsEdit::do_add_word(void)
{
 
  QString str = lineword->text();
  char *word = (char *)str.latin1();
  
  FindLastWord = 0;
  FindLastGroup = 0;
  int curgroup = listgroup->currentItem();
  if(find_down(word)){
    sprintf(tmp,"This word already exists (in group %d).\nDo you wish to remove this occurance and add it to this group ?",wordlist->WordGroup[FindLastGroup].GroupNum);
    
    switch( QMessageBox::information( this, "Remove duplicate word ?",
                                      tmp,
                                      "Yes", "No", 
                                      0,      // Enter == button 0
                                      1 ) ) { // Escape == button 1
    case 0: //yes
      wordlist->WordGroup[FindLastGroup].Words.del(FindLastWord);
      update_group(FindLastGroup);
      changed=true;
      break;
    case 1: //no
      return;
    }
  }

  wordlist->WordGroup[curgroup].Words.addsorted(word); 
  changed=true;
  select_group(curgroup);
  update_group(curgroup);

}
void Roulette_wheel::select_second_group(const int *mum, int *dad ){
  *dad = *mum;
  int iter = 0;
  do{
    select_group( dad );
    iter++;
  }while(*mum == *dad && iter < 5);
}
Пример #3
0
//---------------------------------------------------------------------------------------
void ToolPageTopLevel::create_tool_groups()
{
    wxBoxSizer *pMainSizer = GetMainSizer();

    add_group( LENMUS_NEW GrpTopLevel(this, pMainSizer, k_mouse_mode_data_entry) );

	create_layout();
    select_group(k_grp_Harmony);
}
//---------------------------------------------------------------------------------------
void ToolPageRhythmicDictation::create_tool_groups()
{
    wxBoxSizer *pMainSizer = GetMainSizer();

    add_group( LENMUS_NEW GrpNoteDuration(this, pMainSizer) );
    add_group( LENMUS_NEW GrpNoteDots(this, pMainSizer) );
    add_group( LENMUS_NEW GrpBarlines2(this, pMainSizer) );


	create_layout();
	select_group(k_grp_NoteDuration);
}
Пример #5
0
//********************************************************
void WordsEdit::delete_group_cb(void)
{

  int rm = listgroup->currentItem();
  if(rm != -1){
    wordlist->delete_group(rm);
    listgroup->removeItem(rm);
    if(wordlist->NumGroups>0){
      listgroup->setCurrentItem(rm);
      select_group(rm);
    }
    else listwords->clear();
    changed=true;
  }
}
Пример #6
0
int com_group(FILE *client, char **args) {
  int id;
  int buffer[3];

  if (*args == NULL)
    message(client, 501, "newsgroup");
  else if ((id = group_name_to_id(*args)) == 0)
    message(client, 411, "No such group");
  else {
    if (select_group(*args)) {
      lseek(active_file, id * 4 * 3, SEEK_SET);
      read_block(active_file, (char *)buffer, 12);
      fprintf(client, "211 %d %d %d %s\r\n", 
	      buffer[2], buffer[0], buffer[1], *args);
    } else {
      message(client, 401, "Error when selecting group");
    }
  }
  return 0;
}
void Roulette_wheel::breeding_group_selection ( void ){
  for(int g = 0; g < num_groups; g++){
    if( g < num_elite ){
      for(int ind = 0; ind < num_agents_per_group; ind++){
	tmp_chromosome[g][ind] = chromosome[fitness[num_tot_solutions-1-g].index][ind]; //since sorting is descending order for fitness
      }
    }
    else{
      for(int ind = 0; ind < num_agents_per_group; ind++){
	int mum, first_ind; 
	select_group ( &mum ); //select index of indivdual mum from fitness vector using roulette wheel propability 
#ifdef _HETERO_GROUP_SELECTION_
	first_ind = gsl_rng_uniform_int (GSL_randon_generator::r_rand, num_agents_per_group );
#else
	first_ind = 0; 
#endif
	if( gsl_rng_uniform(GSL_randon_generator::r_rand)  < prob_cross_over ) {
	  int dad, second_ind;
	  select_second_group( &mum, &dad );
#ifdef _HETERO_GROUP_SELECTION_
	  second_ind = gsl_rng_uniform_int (GSL_randon_generator::r_rand, num_agents_per_group );
#else
	  second_ind = 0;
#endif
	  tmp_chromosome[g][ind].create_with_cross_over_and_mutate_operators ( chromosome[mum][first_ind], 
									       chromosome[dad][second_ind], &prob_mutation );
	}
	else{
	  tmp_chromosome[g][ind].create_with_mutate_operator ( chromosome[mum][first_ind], &prob_mutation );
	}
      }
    }
  }
  
  for(int g = 0; g < num_groups; g++){
    for(int ind = 0; ind < num_agents_per_group; ind++){
      chromosome[g][ind] = tmp_chromosome[g][ind];
    }
  }
}
Пример #8
0
type_groupe * gere_groupe(TxPoint point)
{
  type_groupe *group = NULL;
  selected_group *sel_group = NULL;
  int x_center = 0, y_center = 0, nb_selected_groups = 0;

  if ((group = test_group_position(sc->point_courant_leto)) != NULL)
  {
    if (is_selected(group) == NULL)
    {
      select_group(group);
    }

    if (sc->flag_create_link == LINK_CREATE_NO_ACTION)
    {
      sc->flag_drag_group = 1;

      for (sel_group = sc->groupes_courants; sel_group != NULL; sel_group = sel_group->next)
      {
        x_center += sel_group->group->posx;
        y_center += sel_group->group->posy;
        nb_selected_groups++;
      }

      sc->pointer_selection_center.x = point.x - x_center / nb_selected_groups;
      sc->pointer_selection_center.y = point.y - y_center / nb_selected_groups;
    }
    return group;
  }
  else
  {
    reset_selection_groups();
    sc->flag_drag_group = 0;
    return NULL;
  }
}