int Unscented_Kalman_Filter::SP_Init(void)
{
      int Nx=  M.l;
      int Nw= sqrt_Qw.n;
      int N= Nx+Nw;
      int i;
      dgematrix  sqrt_R;
      double phi = sqrt(N+lambda);

      if(sqrtm(R,sqrt_R))
            {
                  return 1;
            }
      sX[0]=M;
      sW[0].zero();

      for(i=1;i<1+Nx;i++){
	    sX[i]=M + phi*get_column(sqrt_R,i-1);
	    sW[i].zero();
      }
      for(i=Nx+1;i<1+Nx+Nw;i++){
	    sX[i]=M;
	    sW[i]=phi*get_column(sqrt_Qw,i-(Nx+1));
      }
      for(i=1+Nx+Nw;i<1+2*Nx+Nw;i++){
	    sX[i]=M-phi*get_column(sqrt_R,i-(1+Nx+Nw));
	    sW[i].zero();
      }
      for(i=1+2*Nx+Nw;i<1+2*Nx+2*Nw;i++){
	    sX[i]=M;
	    sW[i]=-phi*get_column(sqrt_Qw,i-(1+2*Nx+Nw));
      }
      return 0;
}
void ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_dereference *result,
	ir_dereference *a, ir_dereference *b)
{
	int b_col, i;
	ir_assignment *assign;
	ir_expression *expr;

	for (b_col = 0; b_col < b->type->matrix_columns; b_col++)
	{
		/* first column */
		expr = new(mem_ctx)ir_expression(ir_binop_mul,
			get_column(a, 0),
			get_element(b, b_col, 0));

		/* following columns */
		for (i = 1; i < a->type->matrix_columns; i++)
		{
			ir_expression *mul_expr;

			mul_expr = new(mem_ctx)ir_expression(ir_binop_mul,
				get_column(a, i),
				get_element(b, b_col, i));
			expr = new(mem_ctx)ir_expression(ir_binop_add,
				expr,
				mul_expr);
		}

		assign = new(mem_ctx)ir_assignment(get_column(result, b_col), expr);
		base_ir->insert_before(assign);
	}
}
void GtkPeerTreeView::setupColumns()
{
	int cid;
	Gtk::TreeViewColumn *col;
	cid = append_column("IP"      , m_cols.m_col_ip);
	col = get_column(cid - 1);
	col->set_sort_column(m_cols.m_col_ip);
	append_column("Port", m_cols.m_col_port);
	cid = append_column("Client"  , m_cols.m_col_client);
	col = get_column(cid - 1);
	col->set_sort_column(m_cols.m_col_client);
	append_column("Flags", m_cols.m_col_flags);
	append_column("%", m_cols.m_col_percent);
	append_column("Relevance", m_cols.m_col_relevance);
	cid = append_column("Down Speed", m_cols.m_col_down);
	col = get_column(cid - 1);
	col->set_sort_column(m_cols.m_col_down);
	cid = append_column("Up Speed"  , m_cols.m_col_up);
	col = get_column(cid - 1);
	col->set_sort_column(m_cols.m_col_up);
	append_column("Reqs", m_cols.m_col_reqs);
	append_column("Waited", m_cols.m_col_waited);
	append_column("Downloaded", m_cols.m_col_downloaded);
	append_column("Uploaded", m_cols.m_col_uploaded);
	append_column("Hasherr", m_cols.m_col_hasherr);
	append_column("Peer Download Rate", m_cols.m_col_peer_download_rate);
	append_column("MaxDown", m_cols.m_col_max_down);
	append_column("MaxUp", m_cols.m_col_max_up);
	append_column("Queued", m_cols.m_col_queued);
	append_column("Inactive", m_cols.m_col_inactive);
	append_column("Debug", m_cols.m_col_debug);
}
void ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_dereference *result,
	ir_dereference *a, ir_dereference *b)
{
	int i;
	ir_assignment *assign;
	ir_expression *expr;

	/* first column */
	expr = new(mem_ctx)ir_expression(ir_binop_mul,
		get_column(a, 0),
		get_element(b, 0, 0));

	/* following columns */
	for (i = 1; i < a->type->matrix_columns; i++)
	{
		ir_expression *mul_expr;

		mul_expr = new(mem_ctx)ir_expression(ir_binop_mul,
			get_column(a, i),
			get_element(b, 0, i));
		expr = new(mem_ctx)ir_expression(ir_binop_add, expr, mul_expr);
	}

	result = result->clone(mem_ctx, NULL);
	assign = new(mem_ctx)ir_assignment(result, expr);
	base_ir->insert_before(assign);
}
void
ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_variable *result_var,
					    ir_variable *a_var,
					    ir_variable *b_var)
{
   int i;

   for (i = 0; i < a_var->type->matrix_columns; i++) {
      ir_rvalue *a = get_column(a_var, i);
      ir_rvalue *b = new(mem_ctx) ir_dereference_variable(b_var);
      ir_rvalue *result = get_column(result_var, i);
      ir_expression *column_expr;
      ir_assignment *column_assign;

      column_expr = new(mem_ctx) ir_expression(ir_binop_mul,
					       result->type,
					       a,
					       b);

      column_assign = new(mem_ctx) ir_assignment(result,
						 column_expr,
						 NULL);
      base_ir->insert_before(column_assign);
   }
}
Exemple #6
0
/**
   * @brief Determines row and column of key press then returns value from map
   * @retval Returns exact key pressed
   */
int get_key(void) {
	
	int i = 0;
	
	uint8_t key;
	uint8_t row, column;
	
	// Interupt handling, and debouncing;
	if((column = get_column()) == 9) return -1;
	if((row = get_row()) == 9) return -1;
	
	// Hold code in wait state until button released/held long enough
	key = keypad_map[row][column];
	while(1){
		
		// Wait state
		while(keypad_map[get_row()][get_column()] == key){ 
			i++;
			//printf("Key:%d\n", key);
			delay(25); 
		}
		
		// Key held long enough and isn't noise
		if(i > 2) break;
		else return get_key();
		
	}

	printf("%d made it dad!\n", key);
	return key;		
	
}
void hk_Matrix3::set_cols( const hk_Vector3& c0,			   
						    const hk_Vector3& c1,
							const hk_Vector3& c2)
{
	get_column(0) = c0;
	get_column(1) = c1;
	get_column(2) = c2;
}
Exemple #8
0
//==============================================================================
int main() {
    std::string input(u8"Hallo äöüß\n¡Bye! ✿➂➿♫");

    typedef boost::spirit::line_pos_iterator<std::string::const_iterator> source_iterator;

    typedef boost::u8_to_u32_iterator<source_iterator> iterator_type;

    source_iterator soi(input.begin()), 
                    eoi(input.end());
    iterator_type   first(soi), 
                    last(eoi);

    qi::rule<iterator_type, std::u32string()> string_u32 = +encoding::graph;
    qi::rule<iterator_type, std::string()>    string     = string_u32 [qi::_val = to_utf8_(qi::_1)];

    std::vector<boost::iterator_range<iterator_type> > ast;
    // note the trick with `raw` to expose the iterators
    bool result = qi::phrase_parse(first, last, *qi::raw[ string ], encoding::space, ast);

    if (result) {
        for (auto const& range : ast)
        {
            source_iterator 
                base_b(range.begin().base()), 
                base_e(range.end().base());
            auto lbound = get_line_start(soi, base_b);

            // RAW access to the base iterators:
            std::cout << "Fragment: '" << std::string(base_b, base_e) << "'\t" 
                << "raw: L" << get_line(base_b) << ":" << get_column(lbound, base_b, /*tabs:*/4)
                <<     "-L" << get_line(base_e) << ":" << get_column(lbound, base_e, /*tabs:*/4);

            // "cooked" access:
            auto line = get_current_line(lbound, base_b, eoi);
            // std::cout << "Line: '" << line << "'\n";

            // iterator_type is an alias for u8_to_u32_iterator<...>
            size_t cur_pos = 0, start_pos = 0, end_pos = 0;
            for(iterator_type it = line.begin(), _eol = line.end(); ; ++it, ++cur_pos)
            {
                if (it.base() == base_b) start_pos = cur_pos;
                if (it.base() == base_e) end_pos   = cur_pos;

                if (it == _eol)
                    break;
            }
            std::cout << "\t// in u32 code _units_: positions " << start_pos << "-" << end_pos << "\n";
        }
        std::cout << "\n";
    } else {
        std::cout << "Failure" << std::endl;
    }

    if (first!=last)
    {
        std::cout << "Remaining: '" << std::string(first, last) << "'\n";
    }
}
void ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_dereference *result,
	ir_dereference *a, ir_dereference *b, bool test_equal)
{
	/* This essentially implements the following GLSL:
	*
	* bool equal(mat4 a, mat4 b)
	* {
	*   return !any(bvec4(a[0] != b[0],
	*                     a[1] != b[1],
	*                     a[2] != b[2],
	*                     a[3] != b[3]);
	* }
	*
	* bool nequal(mat4 a, mat4 b)
	* {
	*   return any(bvec4(a[0] != b[0],
	*                    a[1] != b[1],
	*                    a[2] != b[2],
	*                    a[3] != b[3]);
	* }
	*/
	const unsigned columns = a->type->matrix_columns;
	const glsl_type *const bvec_type =
		glsl_type::get_instance(GLSL_TYPE_BOOL, columns, 1);

	ir_variable *const tmp_bvec =
		new(this->mem_ctx) ir_variable(bvec_type, "mat_cmp_bvec",
		ir_var_temporary);
	this->base_ir->insert_before(tmp_bvec);

	for (unsigned i = 0; i < columns; i++)
	{
		ir_expression *const cmp =
			new(this->mem_ctx) ir_expression(ir_binop_any_nequal,
			get_column(a, i),
			get_column(b, i));

		ir_dereference *const lhs =
			new(this->mem_ctx) ir_dereference_variable(tmp_bvec);

		ir_assignment *const assign =
			new(this->mem_ctx) ir_assignment(lhs, cmp, NULL, (1U << i));

		this->base_ir->insert_before(assign);
	}

	ir_rvalue *const val = new(this->mem_ctx) ir_dereference_variable(tmp_bvec);
	ir_expression *any = new(this->mem_ctx) ir_expression(ir_unop_any, val);

	if (test_equal)
		any = new(this->mem_ctx) ir_expression(ir_unop_logic_not, any);

	ir_assignment *const assign =
		new(mem_ctx)ir_assignment(result->clone(mem_ctx, NULL), any);
	base_ir->insert_before(assign);
}
Exemple #10
0
void * create_hashtable_on_column(struct Block * block, const char * column_name)
{
  if (block == NULL) { fprintf(stderr, "%s called on NULL block.\n", __func__); return NULL; }
  
  int column_id = get_column_id_by_name_or_exit(block, column_name);
  if (column_id == -1) { fprintf(stderr, "%s couldn't find '%s' column.\n", __func__, column_name); return NULL; }
  
  if (get_column(block, column_id)->type == TYPE_CHAR) return _create_string_hashtable_on_column(block, column_name);
  else if (get_column(block, column_id)->type == TYPE_INT) return _create_int_hashtable_on_column(block, column_name);
  else { fprintf(stderr, "%s called on column which is not a string.\n", __func__); return NULL; }
}
void hk_Matrix3::set_mul3_inv( const hk_Rotation& Ma, const hk_Matrix3& Mb )
{
	for( int i = 0; i < 3; i++ ){
		hk_real x = Ma(0,0)*Mb(0,i) + Ma(1,0)*Mb(1,i) + Ma(2,0)*Mb(2,i);
		hk_real y = Ma(0,1)*Mb(0,i) + Ma(1,1)*Mb(1,i) + Ma(2,1)*Mb(2,i);
		hk_real z = Ma(0,2)*Mb(0,i) + Ma(1,2)*Mb(1,i) + Ma(2,2)*Mb(2,i);

		get_column(i).x = x;
		get_column(i).y = y;
		get_column(i).z = z;
	}
}
Exemple #12
0
std::string source_locationt::as_string(bool print_cwd) const
{
  std::string dest;

  const irep_idt &file=get_file();
  const irep_idt &line=get_line();
  const irep_idt &column=get_column();
  const irep_idt &function=get_function();

  if(!file.empty())
  {
    if(dest!="") dest+=' ';
    dest+="file ";
    if(print_cwd)
      dest+=concat_dir_file(id2string(get_working_directory()),
                            id2string(file));
    else
      dest+=id2string(file);
  }
  if(!line.empty())     { if(dest!="") dest+=' '; dest+="line "+id2string(line); }
  if(!column.empty())   { if(dest!="") dest+=' '; dest+="column "+id2string(column); }
  if(!function.empty()) { if(dest!="") dest+=' '; dest+="function "+id2string(function); }

  return dest;
}
void PresentationTreeView::initialize() {
	//  We only need single copies of these renderers since all instances of PresentationTreeView have
	//  identical properties. Cannot make them global though as that would require them to be
	//  initialized before the call to the GTK initialization and so leads to an initialization error.
	//  Having them in this scope means they are not initialized until the first instance of a
	//  PresentationTreeView is made which is after the GTK+ system is initialized.
	static Gtk::CellRendererText font_style_renderer;
	static Gtk::CellRendererText visibility_renderer;
	static Gtk::CellRendererText sample_text_renderer;
	static Gtk::CellRendererText file_name_renderer;
	PresentationListStore::ColumnRecord const & column_record{PresentationListStore::get_column_record()};
	font_style_column.pack_start(font_style_renderer, true);
	font_style_column.set_title(_("Font Style"));
	font_style_column.add_attribute(font_style_renderer.property_text(), column_record.style_name);
	visibility_column.pack_start(visibility_renderer, true);
	visibility_column.set_title(" ");
	visibility_column.add_attribute(visibility_renderer.property_text(), column_record.visibility);
	sample_text_column.pack_start(sample_text_renderer, true);
	sample_text_column.set_title(_("Sample Text"));
	sample_text_column.add_attribute(sample_text_renderer.property_font_desc(), column_record.font_description);
	sample_text_column.add_attribute(sample_text_renderer.property_text(), column_record.sample_text);
	file_name_column.pack_start(file_name_renderer, true);
	file_name_column.set_title(_("File Name"));
	file_name_column.add_attribute(file_name_renderer.property_text(), column_record.file_name);
	append_column(font_style_column);
	append_column(visibility_column);
	append_column(sample_text_column);
	append_column(file_name_column);
	for (auto i = 0; i < 4; ++i) { get_column(i)->set_resizable(true); }
	Registry::registry.insert(this);
}
Exemple #14
0
void init_whole_blocks(void)
{
    struct Column *colmn;
    struct Column lcolmn;
    long i;
    game.field_149E6E = -1;
    LbMemorySet(&lcolmn, 0, sizeof(struct Column));
    // Prepare the local column
    lcolmn.baseblock = 22;
    lcolmn.cubes[0] = 10;
    lcolmn.cubes[1] = 1;
    lcolmn.cubes[2] = 1;
    lcolmn.cubes[3] = 1;
    lcolmn.cubes[4] = 141;
    make_solidmask(&lcolmn);
    // Find it or add to column list
    i = find_column(&lcolmn);
    if (i == 0)
      i = create_column(&lcolmn);
    colmn = get_column(i);
    // Update its parameters
    colmn->bitfields |= 0x01;
    game.field_149E7C = 24;
    game.unrevealed_column_idx = i;
}
Exemple #15
0
	void World::Remove (SmartPointer<Client> client, ColumnID id, bool force) {
	
		if (clients_lock.Execute([&] () {
		
			auto iter=clients.find(client);
			
			if (iter==clients.end()) return false;
			
			return iter->second.erase(id)!=0;
		
		})) {
		
			auto column=get_column(id);
			
			try {
			
				column->RemovePlayer(
					std::move(client),
					force
				);
			
			} catch (...) {
			
				column->EndInterest();
				
				throw;
			
			}
			
			column->EndInterest();
			
		}
	
	}
ir_rvalue *
ir_mat_op_to_vec_visitor::get_element(ir_dereference *val, int col, int row)
{
   val = get_column(val, col);

   return new(mem_ctx) ir_swizzle(val, row, 0, 0, 0, 1);
}
Exemple #17
0
int main()
{
	FILE *i = fopen("tmp.txt", "r");
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	getc(i);
	printf("Answer: %d\n", get_column(i));
	return 0;
}
Exemple #18
0
	void World::Interested (ColumnID id, bool prepare) {
	
		//	This automatically acquires
		//	interest
		auto column=get_column(id);
		
		if (prepare) {
		
			//	Column must be prepared -- fully
			//	populated
		
			try {
			
				if (!column->WaitUntil(ColumnState::Populated)) process(*column);
			
			} catch (...) {
			
				//	Don't leak interest
				column->EndInterest();
				
				throw;
			
			}
			
		}
	
	}
TbBool columns_add_static_entries(void)
{
    struct Column *colmn;
    struct Column lcolmn;
    short *wptr;
    short c[3];
    long ncol;
    long i,k;

    for (i=0; i < 3; i++)
      c[i] = 0;
    LbMemorySet(&lcolmn,0,sizeof(struct Column));
    wptr = &game.field_14A818[0];
    for (i=0; i < 3; i++)
    {
        LbMemorySet(&lcolmn, 0, sizeof(struct Column));
        lcolmn.baseblock = c[i];
        for (k=0; k < 6; k++)
        {
          lcolmn.cubes[0] = player_cubes[k];
          make_solidmask(&lcolmn);
          ncol = find_column(&lcolmn);
          if (ncol == 0)
            ncol = create_column(&lcolmn);
          colmn = get_column(ncol);
          colmn->bitfields |= 0x01;
          *wptr = -(short)ncol;
          wptr++;
        }
    }
    return true;
}
Exemple #20
0
int	main(int ac, char **av)
{
  if (ac == 1)
    without_arg();
  else if (ac % 2 != 1 && ac != 3)
    {
      printf("Bad usage: ./sudoki-bi -option number\n\n");
      printf("Possible options:\n\t-l: have line\n\t-c:have column\n\n");
      printf("Number must be from 1 to 9\n\n");
    }
  else
    {
      if (av[1][0] == '-' && av[1][1] == 'l')
        get_line(atoi(av[2]));
      else if (av[1][0] == '-' && av[1][1] == 'c')
        get_column(atoi(av[2]));
      else
	{
	  printf("Bad option !\n");
	  printf("Possible options:\n\t-l: have line\n\t-c:have column\n\n");
	  printf("Number must be from 1 to 9\n\n");
	}
    }
  return (0);
}
Exemple #21
0
struct Block * multiply(struct Block * block, struct Block * opt)
{
  const char * column_name = get_attribute_value_as_string(opt, "column_name");
  double multiple          = get_attribute_value_as_double(opt, "multiple");
  
  int column_id = get_column_id_by_name_or_exit(block, (char*)column_name);
  if (column_id == -1)
  {
    fprintf(stderr, "%s() called on '%s' field, wasn't found\n", __func__, column_name);
    return block;
  }
  struct Column * column = get_column(block, column_id);
  
  if (column->type != TYPE_FLOAT)
  {
    fprintf(stderr, "%s() called on '%s' field, which is of type '%s' (only supports floating point)\n", __func__, column_name, get_type_name(column->type, column->bsize));
    return block;
  }
  
  char temp[100];
  snprintf(temp, sizeof(temp), "multiply(column:\"%s\" by %lf)", column_name, multiple);
  block = add_string_attribute(block, "command", temp);
  
  int i;
  for (i = 0 ; i < block->num_rows ; i++)
    set_cell_from_double(block, i, column_id, get_cell_as_double(block, i, column_id) * multiple);
  
  return block;
}
Exemple #22
0
void gtk216_init(void)
{
	const SortColumnId *scd;

	for (scd = sort_column_ids; scd->id; scd++)
		gtk_tree_view_column_set_sort_column_id(get_column(scd->id), scd->sort_column_id);
}
void inventory_selector::set_active_column( size_t index )
{
    if( index < columns.size() && index != active_column_index && get_column( index ).activatable() ) {
        get_active_column().on_deactivate();
        active_column_index = index;
        get_active_column().on_activate();
    }
}
Exemple #24
0
void EditorCamera::Draw()
{
	Mat4 to_look_at = rotation_y(DegToRad(m_yaw)) * rotation_x(DegToRad(m_pitch));
	Vec3 vec = m_zoom * get_column(to_look_at, 2);               
	m_camera.SetPosition(m_target+vec);
	m_camera.SetLookDir(-vec);
	m_camera.Draw();
}
Exemple #25
0
int main(int argc, char *argv[]){

	if ( argc == 2 ){
		time_t start, stop;
	    clock_t ticks; 
		time(&start);
		FILE *log = init_log(argv[1]);
		printf("%s : Log activated\n", curdate());
		generate_triplets(log, argv[1]);
		if ( !fork() ){
			if ( !fork() ){
				get_column( init_log("g-col1"), 1, 0 );
			}else{
				get_column( init_log("g-col2"), 2, 0 ); // this is the lighter one!! 
				// I'm gonna re-use this process to generate the hash of the triplets
				insertTrip();
			}
			return 0;
		}else{
			if ( !fork()) {
				get_column( init_log("g-col3"), 3, 1 );
				return 0;
			}
			while (1) {
				int status;
				pid_t done = wait(&status);
				if (done == -1) {
					if (errno == ECHILD) break; // no more child processes
				} else {
					if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
						exit(1);
					}
				}
			}
			time(&stop);
			printf("Finished in about %.3f seconds. \n\n", difftime(stop, start));
			fprintf(log, "Finished in about %.3f seconds. \n\n", difftime(stop, start));
		}
		fclose(log);
	}else{
		puts("USAGE: ./run rdf-file.ttl");

	}

	return 0;
}
Exemple #26
0
static int read_ursa_line(char *header, int n,char *line, ursa_type_t *ursa)
{
  int ii, ok;
  char *test = (char *) MALLOC(sizeof(char)*255);
  for (ii=0; ii<n; ii++) {
    test = get_column(header, ii);
    test[strlen(test)-1] = '\0';
    test++;
    if (strcmp(test, "Granule Name") == 0)
      strcpy(ursa->granule_name, get_str(line, ii));
    else if (strcmp(test, "Granule Type") == 0)
      strcpy(ursa->granule_type, get_str(line, ii));
    else if (strcmp(test, "Platform") == 0)
      strcpy(ursa->platform, get_str(line, ii));
    else if (strcmp(test, "Sensor") == 0)
      strcpy(ursa->sensor, get_str(line, ii));
    else if (strcmp(test, "Orbit") == 0)
      ursa->orbit = get_int(line, ii);
    else if (strcmp(test, "Beam Mode") == 0)
      strcpy(ursa->beam_mode, get_str(line, ii));
    else if (strcmp(test, "Off Nadir Angle") == 0)
      ursa->off_nadir_angle = get_double(line, ii);
    else if (strcmp(test, "Start Time") == 0)
      strcpy(ursa->start_time, get_str(line, ii));
    else if (strcmp(test, "End Time") == 0)
      strcpy(ursa->end_time, get_str(line, ii));
    else if (strcmp(test, "Near Start Lat") == 0)
      ursa->near_start_lat = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Near Start Lon") == 0)
      ursa->near_start_lon = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Far Start Lat") == 0)
      ursa->far_start_lat = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Far Start Lon") == 0)
      ursa->far_start_lon = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Near End Lat") == 0)
      ursa->near_end_lat = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Near End Lon") == 0)
      ursa->near_end_lon = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Far End Lat") == 0)
      ursa->far_end_lat = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Far End Lon") == 0)
      ursa->far_end_lon = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Center Lat") == 0)
      ursa->center_lat = get_double(line, ii);
    else if (strcmp(test, "Center Lon") == 0)
      ursa->center_lon = get_double(line, ii);
    else if (strcmp(test, "Path Number") == 0)
      ursa->path_number = get_int(line, ii);
    else if (strcmp(test, "Frame Number") == 0)
      ursa->frame_number = get_int(line, ii);
    else if (strcmp(test, "Cloud Cover") == 0)
      ursa->cloud_cover = get_int(line, ii);
    else if (strcmp(test, "Faraday Rotation") == 0)
      ursa->faraday_rotation = get_double(line, ii);
  }

  return ok;
}
Exemple #27
0
void init_columns(void)
{
    //_DK_init_columns();
    int i;
    for (i=1; i < COLUMNS_COUNT; i++)
    {
        struct Column *col;
        col = get_column(i);
        if (col->use)
        {
            unsigned long mskbit;
            mskbit = 1;
            col->solidmask = 0;
            int n;
            for (n=0; n < COLUMN_STACK_HEIGHT; n++)
            {
                if (col->cubes[n] != 0) {
                    col->solidmask |= mskbit;
                }
                mskbit *= 2;
            }
            if (col->solidmask)
            {
                for (n=0; n < COLUMN_STACK_HEIGHT; n++)
                {
                    if (col->cubes[n] == 0) {
                        break;
                    }
                }
            } else
            {
                n = 0;
            }
            set_column_floor_filled_subtiles(col, n);
            n = get_column_floor_filled_subtiles(col);
            for (;n < COLUMN_STACK_HEIGHT; n++)
            {
                if (col->cubes[n] != 0) {
                  break;
                }
            }
            if (n >= COLUMN_STACK_HEIGHT)
            {
                col->bitfields &= ~0x0E;
            } else
            {
                mskbit = 0;
                for (n=COLUMN_STACK_HEIGHT-1; n > 0; n--)
                {
                    if (col->cubes[n] != 0) {
                        col->bitfields ^= (mskbit ^ col->bitfields) & 0xE;
                    }
                    mskbit += 2;
                }
            }
        }
    }
}
Exemple #28
0
void CanvasController::MoveCamera(wxMouseEvent& event)
{
	if(event.Entering() || event.Leaving()) {
		m_track_x.Reset();
		m_track_y.Reset();
		m_wheel_rot = 0;
	}
	m_track_x.Update( event.GetX() );
	m_track_y.Update( event.GetY() );

	if(event.Dragging())
	{
		if(event.LeftIsDown())
		{
			const float kYawRate = -0.2f;
			const float kPitchRate = -0.2f;
			m_camera.RotateYaw( m_track_x.GetRel() * kYawRate );
			m_camera.RotatePitch( m_track_y.GetRel() * kPitchRate );
		} 
		else if(event.RightIsDown())
		{
			// Move relative to the camera
			const Mat4& mat = m_camera.GetMatrix();
			Vec3 x_axis = get_column(mat, 0);
			Vec3 y_axis = get_column(mat, 1);
			
			const float kScale = 0.02f;
			Vec3 move_by = -m_track_x.GetRel() * kScale * x_axis +
				m_track_y.GetRel() * kScale * y_axis ;
			m_camera.MoveBy( move_by );
		}
	}
	else if(event.GetWheelRotation() != 0) 
	{
		m_wheel_rot += event.GetWheelRotation();
		while(m_wheel_rot > event.GetWheelDelta()) {
			m_wheel_rot -= event.GetWheelDelta();
			m_camera.ZoomBy(1.f);	 
		}
		while(m_wheel_rot < -event.GetWheelDelta()) {
			m_wheel_rot += event.GetWheelDelta();
			m_camera.ZoomBy(-1.f);
		}
	}
}
// TODO REFACTOR THE LIVING HELL OUT OF THIS ABOMINATION -- nyanpasu
void GtkTorrentTreeView::setupColumns()
{
	Gtk::TreeViewColumn *col = nullptr;
	Gtk::CellRendererProgress *cell = nullptr;

	vector<pair<int, int>> columns; //First element id second element size
	columns.push_back(make_pair(this->append_column("#", m_cols.m_col_queue), 30));
	columns.push_back(make_pair(this->append_column("Status", m_cols.m_col_name), 200));
	columns.push_back(make_pair(this->append_column("Name", m_cols.m_col_name), 200));
	columns.push_back(make_pair(this->append_column("Size", m_cols.m_col_size), 80));
	columns.push_back(make_pair(this->append_column("Down", m_cols.m_col_dl_speed), 60));
	columns.push_back(make_pair(this->append_column("Up", m_cols.m_col_ul_speed), 60));
	columns.push_back(make_pair(this->append_column("Ratio", m_cols.m_col_dl_ratio), 60));
	columns.push_back(make_pair(this->append_column("Downloaded", m_cols.m_col_dl_total), 80));
	get_column(columns.back().first - 1)->set_visible(false);
	columns.push_back(make_pair(this->append_column("Uploaded", m_cols.m_col_ul_total), 80));
	get_column(columns.back().first - 1)->set_visible(false);
	columns.push_back(make_pair(this->append_column("Seed", m_cols.m_col_seeders), 60));
	columns.push_back(make_pair(this->append_column("Leech", m_cols.m_col_leechers), 60));
	columns.push_back(make_pair(this->append_column("Age", m_cols.m_col_age), 50));
	columns.push_back(make_pair(this->append_column("ETA", m_cols.m_col_eta), 80));
	cell = Gtk::manage(new Gtk::CellRendererProgress());
	columns.push_back(make_pair(this->append_column("Progress", *cell), 160));
	col = this->get_column(columns.back().first - 1);
	col->add_attribute(cell->property_value(), m_cols.m_col_percent);
	col->add_attribute(cell->property_text(), m_cols.m_col_percent_text);



	columns.push_back(make_pair(this->append_column("Remains", m_cols.m_col_remaining), 80));
	get_column(columns.back().first - 1)->set_visible(false);

	for (pair<int, int> colpair : columns)
	{
		Gtk::Button *butt = get_column(colpair.first - 1)->get_button();
		butt->signal_button_press_event().connect(sigc::mem_fun(*this, &GtkTorrentTreeView::torrentColumns_onClick));
		get_column(colpair.first - 1)->set_sizing(Gtk::TreeViewColumnSizing::TREE_VIEW_COLUMN_FIXED);
		get_column(colpair.first - 1)->set_alignment(0.5f);
		get_column(colpair.first - 1)->set_clickable();
		get_column(colpair.first - 1)->set_resizable();
		get_column(colpair.first - 1)->set_reorderable();
		get_column(colpair.first - 1)->set_fixed_width(colpair.second);

	}
}
Exemple #30
0
int html_table::add_column (int coln, int hstart, int hend, char align)
{
  cols *c = get_column(coln);

  if (c == NULL)
    return insert_column(coln, hstart, hend, align);
  else
    return modify_column(c, hstart, hend, align);
}