コード例 #1
0
ファイル: globals.cpp プロジェクト: RD3BAX/BrainBay
void set_dimensions(struct LINKStruct * act,float max, float min, char * dim, char * desc)
{
	
	struct LINKStruct * next;
	int t;


		act->max=max; 
		act->min=min; 
		strcpy(act->dimension,dim);
		strcpy(act->description,desc);

		if(objects[act->to_object]->in_ports[act->to_port].get_range)
		{
			objects[act->to_object]->in_ports[act->to_port].in_min=min;
			objects[act->to_object]->in_ports[act->to_port].in_max=max;
			strcpy(objects[act->to_object]->in_ports[act->to_port].in_dim,dim);
			strcpy(objects[act->to_object]->in_ports[act->to_port].in_desc,desc);
		}

		
		for(next=objects[act->to_object]->out;next->to_port!=-1;next++)
		{	
			for (t=0;t<objects[act->to_object]->outports;t++)
			if (objects[act->to_object]->out_ports[t].get_range==act->to_port)
			{
				objects[act->to_object]->out_ports[t].out_max=act->max;
				objects[act->to_object]->out_ports[t].out_min=act->min;
				strcpy(objects[act->to_object]->out_ports[t].out_dim,act->dimension);
				strcpy(objects[act->to_object]->out_ports[t].out_desc,act->description);
	  		    set_dimensions(next,act->max,act->min,act->dimension,act->description);
			}
		}
	
}
コード例 #2
0
ファイル: TreeSystem.cpp プロジェクト: Lucretiel/Art2D
	TreeNode(TreeNode& p, bool first):
		parent(&p),
		trunk(first && p.trunk),
		inverse(!p.inverse),
		id(p.id + 1)
	{
		if(first)
			if(p.trunk)
				set_dimensions(p.length * ratio1, 0);
			else
				set_dimensions(p.length * ratio1, randuniform(min_ba1, max_ba1));
		else
			if(p.trunk)
				set_dimensions(p.length * ratio2, randuniform(min_ca, max_ca));
			else
				set_dimensions(p.length * ratio2, -randuniform(min_ba2, max_ba2));
	}
コード例 #3
0
ファイル: WindowLoader.cpp プロジェクト: Valtis/sdl_gui
void WindowLoader::set_generic_parameters(const serialization::Node &node, WindowBase *base) {
	set_dimensions(node, base);
	set_color(node, base);
	base->set_renderer(m_renderer.get());
	base->m_name = node.value(NAME);
	set_handlers(node, base);

}
コード例 #4
0
ファイル: TreeSystem.cpp プロジェクト: Lucretiel/Art2D
	TreeNode(b2Vec2 new_root, float length):
		parent(nullptr),
		trunk(true),
		inverse(false),
		id(0)
	{
		root = new_root;
		set_dimensions(length, 90);
	}
コード例 #5
0
    void ParserKeyword::initData(const Json::JsonObject& jsonConfig) {
        this->m_fixedSize = 1U;
        this->m_keywordSizeType = FIXED;

        const Json::JsonObject dataConfig = jsonConfig.get_item("data");
        if (!dataConfig.has_item("value_type") )
            throw std::invalid_argument("The 'value_type' JSON item of keyword "+getName()+" is missing");

        ParserValueTypeEnum valueType = ParserValueTypeEnumFromString(dataConfig.get_string("value_type"));
        const std::string itemName("data");
        bool hasDefault = dataConfig.has_item("default");

        ParserRecord record;
        ParserItem item( itemName, ParserItem::item_size::ALL );

        switch (valueType) {
            case INT:
                {
                    item.setType( int() );
                    if(hasDefault) {
                        int defaultValue = dataConfig.get_int("default");
                        item.setDefault(defaultValue);
                    }
                    record.addDataItem( item );
                }
                break;
            case STRING:
                {
                    item.setType( std::string() );
                    if (hasDefault) {
                        std::string defaultValue = dataConfig.get_string("default");
                        item.setDefault(defaultValue);
                    }
                    record.addItem( item );
                }
                break;
            case DOUBLE:
                {
                    item.setType( double() );
                    if (hasDefault) {
                        double defaultValue = dataConfig.get_double("default");
                        item.setDefault(defaultValue);
                    }
                    set_dimensions( item, dataConfig, this->getName() );
                    record.addDataItem( item );
                }
                break;
            default:
                throw std::invalid_argument("While initializing keyword "+getName()+": Values of type "+dataConfig.get_string("value_type")+" are not implemented.");
        }

        this->addDataRecord( record );
    }
コード例 #6
0
ファイル: globals.cpp プロジェクト: RD3BAX/BrainBay
void update_dimensions(void)
{
	int t,i;
	struct LINKStruct * act;

	for(t=0;t<GLOBAL.objects;t++)
	  for(act=objects[t]->out;act->to_port!=-1;act++)
	  {
		  i=objects[t]->out_ports[act->from_port].get_range;
		  if (i>-1)
		  {
			  objects[t]->out_ports[act->from_port].out_max=objects[t]->in_ports[i].in_max;
			  objects[t]->out_ports[act->from_port].out_min=objects[t]->in_ports[i].in_min;
		
		  }
		  if (objects[t]->out_ports[act->from_port].get_range==-1)
			  set_dimensions(act,objects[t]->out_ports[act->from_port].out_max,objects[t]->out_ports[act->from_port].out_min,objects[t]->out_ports[act->from_port].out_dim,objects[t]->out_ports[act->from_port].out_desc);
	  }
	for(t=0;t<GLOBAL.objects;t++) objects[t]->update_inports();
}
コード例 #7
0
ファイル: main.c プロジェクト: fatduckling/MatrixEngine
/**
 * Initialises settings based on command line arguments.
 */
void init(int argc, char** argv) {

	if (argc != 3) {
		goto invalid;
	}

	g_order = atol(argv[1]);
	g_nthreads = atol(argv[2]);

	if (g_order < 1 || g_nthreads < 1) {
		goto invalid;
	}

	set_nthreads(g_nthreads);
	set_dimensions(g_order);
	return;

invalid:
	puts("Usage: matrix <width> <threads>");
	exit(1);
}
コード例 #8
0
ファイル: main.c プロジェクト: namoshizun/myBase
/**
 * Defines settings based on command line arguments
 */
void define_settings(int argc, char** argv) {

    if (argc != 3) {
        goto invalid;
    }

    g_order = atoll(argv[1]);
    g_nthreads = atoll(argv[2]);

    if (g_order < 1 || g_nthreads < 1) {
        goto invalid;
    }

    set_nthreads(g_nthreads);
    set_dimensions(g_order);
    return;

invalid:
    puts("Invalid command line arguments");
    puts("Usage: matrix <width> <# threads>");
    exit(1);
}
コード例 #9
0
ファイル: menu.cpp プロジェクト: confuzedskull/G2
void ui::menu::format()
{
    int total_width=0;//width of buttons and the spaces between
    int total_height=0;//height of buttons and spaces between
    int widest;//width of the widest item
    if(title.get_width()>subtitle.get_width())
        widest=title.get_width();
    else
        widest=subtitle.get_width();
    if(get_type()=="dropdown menu" && widest<width)
        widest=width;
    //arrange the items
    for(unsigned i=0;i<items.size();i++)//use regular 'for' loop because 'i' is used as number
    {
        if(items[i]->combined_width()>widest)
            widest=items[i]->combined_width();
        if(layout=="vertical")
        {
            if(items[i]->get_type()=="checkbox")
                items[i]->set_position(xmax-margin-items[i]->get_width(),ymax-margin-title.get_height()-total_height);
            else
                items[i]->set_position(position.x,ymax-margin-title.get_height()-items[i]->get_height()-total_height);
        }
        if(layout=="horizontal")
        {
            if(subtitle.visible)
                items[i]->set_position(xmin+margin+total_width,ymax-margin-title.get_height()-spacing-subtitle.get_height()-spacing-(items[0]->get_height()/2));
            else
                items[i]->set_position(xmin+margin+total_width,ymax-margin-title.get_height()-spacing-(items[0]->get_height()/2));
            total_width+=spacing;
        }
        items[i]->text.set_position(items[i]->get_x(),items[i]->get_y());
        total_width+=items[i]->combined_width();
        total_height+=(items[i]->get_height()+spacing);
    }
    //resize the menu
    if(layout=="vertical")
    {
        if(title.visible)
        {
            if(subtitle.visible)
                set_dimensions(widest+(margin*2),total_height+title.get_height()+subtitle.get_height()+spacing+(margin*2));
            else
                set_dimensions(widest+(margin*2),total_height+title.get_height()+spacing+(margin*2));
        }
        else
            set_dimensions(widest+(margin*2),total_height+(margin*2));
    }
    if(layout=="horizontal")
    {
        if(title.visible)
        {
            if(subtitle.visible)
                set_dimensions(total_width+(margin*2),items[0]->get_height()+title.get_height()+spacing+subtitle.get_height()+spacing+(margin*2));
            else
                set_dimensions(total_width+(margin*2),items[0]->get_height()+title.get_height()+spacing+(margin*2));
        }
        else
            set_dimensions(total_width+(margin*2),items[0]->get_height()+(margin*2));
    }
    title.set_position(position.x,ymax-margin-(title.get_height()/2));
    subtitle.set_position(position.x,ymax-margin-title.get_height()-spacing-(subtitle.get_height()/2));
}