Exemplo n.º 1
0
void test_table(void) {
  catdb::DBase::Database database("Billy_database");
  catdb::DBase::Database database1("Johnny_database");
  catdb::Column* temp = database.find_column("Cool");

  std::cout << temp->display_list() << std::endl;
  delete temp;
  temp = NULL;
  catdb::Container* container(new catdb::Container("Alex"));
  catdb::Container container1("Billy");
  catdb::Container container2("Fred");
  catdb::Container container3("Zen");

  container->insert_new_element("12.2", "Cool");
  container1.insert_new_element("14.3", "Cool");
  container2.insert_new_element("99.9", "Cool");
  container3.insert_new_element("80.2", "Cool");
  std::cout << container->obtain_element("12.2")->get_attribute() << std::endl;
  // not implemented yet!!
  database.add_container(container);
  database.add_container(&container1);
  database.add_container(&container2);
  database.add_container(&container3);

  std::cout << database.get_container("Alex")->get_container_name() << std::endl;
  std::cout << "Here is a list of stuff in this column" << std::endl;
  catdb::Column* column = database.find_column("Cool");
  catdb::Element* element = column->inspect_element("12.2", "Cool");
  column->sort_column(tools::sorting::quick_sort, tools::sorting::SORT_LITTLE_ENDIAN);
  std::cout << column->display_list() << std::endl;
  database.remove_container("Alex");
  database.remove_container("Billy");
  database.remove_container("Fred");
  database.remove_container("Zen");
  delete column;
  column = NULL;

  database1 = database;
  catdb::GreaterComparator<catdb::Element> _g;
  catdb::Comparator<catdb::Element>& _comp = catdb::LesserComparator<catdb::Element>();
  catdb::Element el1("Cooler", "Bool", "Mang");
  catdb::Element el2("Alex", "Benson", "Kol");
  std::cout << _comp(el1, el2) << std::endl;
  tools::data_structures::hash_map<int, int> mapping;


  //	if (database.get_container("Alex") == NULL)
  //	   std::cout << "Alex is deleted!" << std::endl;

  //	database.folder_create();
  //	catdb::DBase::display_db_error_msg();
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	SDL_Init(SDL_INIT_EVERYTHING);
		
	ekran = SDL_SetVideoMode( 800, 600, 32, SDL_SWSURFACE );
	DrawableSDL::surface = ekran;
    SDL_Flip( ekran );
	SDL_CDOpen(0);
	ekran->pixels;
	SDL_Event e;
	int frame_time;
	SDL_PollEvent(&e);

	FontFactory::initializeFont("simplePix", "pixelart.ttf", 10);

	SDL_Rect rect;
	rect.x=100;
	rect.y=10;
	rect.w=100;
	rect.h=100;

	TTF_Init();

	Rectangle object1;
	object1.setColor(0xff, 0xff, 0xff);
	
	Rectangle object2;
	object2.setColor(0xf1, 0x00, 0xda);
	object2.setX(50);

	object1.setX(10);

	Container helping(100,30);
	//helping.add(&object1);

	Container root(10,10);

	SimpleScrollBar scroll(100, 100, 10, 150, 0, 1000, Orientation::horizontal);
	SimpleScrollBar scroll2(100, 85, 10, 150, 0, 1000, Orientation::horizontal);
	root.add(&scroll);
	Button ok(100, 100, 60, 20, "Here i am");
	ok.setBorderSize(2);
	ok.setBackground(255,225,255);
	ok.setBorderColor(10,100,10);
	ok.setFontName("simplePix");
	smth e_inst;
	ok+= *(new Delegate(&e_inst));

	Button ok2(200, 200, 80, 20, "I am not here");
	ok2.setBorderSize(2);
	ok2.setBackground(255,225,255);
	ok2.setBorderColor(10,100,10);
	ok2.setFontName("simplePix");
	root.add(&ok);
	root.add(&scroll2);
	root.add(&ok2);
	//ok.setEnable(false);

	ListBoxElementSDL el(50);
	el.setText("hello");
	el.setSelection(false);
	el.cut(4, down);
	ListBoxElementSDL el1(50);
	el1.setText("welcome");
	el1.setSelection(false);
	ListBoxElementSDL el2(50);
	el2.setText("hejo");
	el2.setSelection(false);
	ListBoxElementSDL el3(50);
	el3.setText("hejo2");
	ListBoxElementSDL el4(50);
	el4.setText("hejo1");
	ListBoxElementSDL el5(50);
	el5.setText("hejo3");
	ListBoxElementSDL el6(50);
	el6.setText("Witam");
	ListBoxElementSDL el7(50);
	el7.setText("Witam");

	ListBoxSDL list(500, 200, 100, 50, 2);
	list.add(&el);
	list.add(&el1);
	list.add(&el2);
	list.add(&el3);
	list.add(&el4);
	list.add(&el5);
	list.add(&el6);
	list.add(&el7);
	root.add(&list);
	MovingRectangle movrect;
	MovingRectangle movrect2;
	movrect2.setColor(0x43, 0x52, 0xFF);

	//root.add(&movrect);
	//root.add(&movrect2);
	Uint32 color = SDL_MapRGB(ekran->format, 0xff, 0xff, 0xff);
	Uint32 color2 = SDL_MapRGB(ekran->format, 0x00, 0xff, 0xff);
	short int r=0,g=0,b=0;
	while(true)
	{
		frame_time = SDL_GetTicks();
		ok.setX(scroll.getValue());
		ok.setY(scroll2.getValue());
		SDL_FillRect(ekran, &(ekran->clip_rect), color2);
		root.draw(0,0);

		if(SDL_PollEvent(&e))
		{
			if(e.type == SDL_QUIT)
			{
				SDL_Quit();
				return 0;
			}
			root.spreadEvent(e);
		}
		SDL_Flip(ekran);
		if((SDL_GetTicks() - frame_time) < 1000/FPS)
			SDL_Delay(1000/FPS - (SDL_GetTicks() - frame_time));

	}


	return 0;
}
Exemplo n.º 3
0
void vtWThread::run()
{

    optFlowPos.resize(3,0.0);
    pf3dTrackerPos.resize(3,0.0);
    doubleTouchPos.resize(3,0.0);
    fgtTrackerPos.resize(3,0.0);

    bool isTarget = false;
    events.clear();

    // process the optFlow
    if (optFlowBottle = optFlowPort.read(false))
    {
        if (optFlowBottle->size()>=3)
        {
            yDebug("Computing data from the optFlowTracker %g\n",getEstUsed());
            optFlowPos.zero();
            
            optFlowPos[0]=optFlowBottle->get(0).asDouble();
            optFlowPos[1]=optFlowBottle->get(1).asDouble();
            optFlowPos[2]=optFlowBottle->get(2).asDouble();

            AWPolyElement el(optFlowPos,Time::now());
            optFlowVelEstimate=linEst_optFlow->estimate(el);

            events.push_back(IncomingEvent(optFlowPos,optFlowVelEstimate,0.05,"optFlow"));
            isTarget=true;
        }
    }

    // process the pf3dTracker
    if (pf3dTrackerBottle = pf3dTrackerPort.read(false))
    {
        if (pf3dTrackerBottle->size()>6)
        {
            if (pf3dTrackerBottle->get(6).asDouble()==1.0)
            {
                Vector fp(4);
                fp[0]=pf3dTrackerBottle->get(0).asDouble();
                fp[1]=pf3dTrackerBottle->get(1).asDouble();
                fp[2]=pf3dTrackerBottle->get(2).asDouble();
                fp[3]=1.0;

                if (!gsl_isnan(fp[0]) && !gsl_isnan(fp[1]) && !gsl_isnan(fp[2]))
                {
                    yDebug("Computing data from the pf3dTracker %g\n",getEstUsed());
                    Vector x,o;
                    igaze->getLeftEyePose(x,o);
                    
                    Matrix T=axis2dcm(o);
                    T(0,3)=x[0];
                    T(1,3)=x[1];
                    T(2,3)=x[2];

                    pf3dTrackerPos=T*fp;
                    pf3dTrackerPos.pop_back();
                    
                    AWPolyElement el(pf3dTrackerPos,Time::now());
                    pf3dTrackerVelEstimate=linEst_pf3dTracker->estimate(el);
                    
                    events.push_back(IncomingEvent(pf3dTrackerPos,pf3dTrackerVelEstimate,0.05,"pf3dTracker"));
                    isTarget=true;
                }
            }
        }
    }

    if (!rf->check("noDoubleTouch"))
    {
        // processes the fingertipTracker
        if(fgtTrackerBottle = fgtTrackerPort.read(false))
        {
            if (doubleTouchBottle = doubleTouchPort.read(false))
            {           
                if(fgtTrackerBottle != NULL && doubleTouchBottle != NULL)
                {
                    if (doubleTouchBottle->get(3).asString() != "" && fgtTrackerBottle->get(0).asInt() != 0)
                    {
                        yDebug("Computing data from the fingertipTracker %g\n",getEstUsed());
                        doubleTouchStep = doubleTouchBottle->get(0).asInt();
                        fgtTrackerPos[0] = fgtTrackerBottle->get(1).asDouble();
                        fgtTrackerPos[1] = fgtTrackerBottle->get(2).asDouble();
                        fgtTrackerPos[2] = fgtTrackerBottle->get(3).asDouble();
                        AWPolyElement el2(fgtTrackerPos,Time::now());
                        fgtTrackerVelEstimate=linEst_fgtTracker->estimate(el2);

                        if(doubleTouchStep<=1)
                        {
                            Vector ang(3,0.0);
                            igaze -> lookAtAbsAngles(ang);
                        }
                        else if(doubleTouchStep>1 && doubleTouchStep<8)
                        {
                            events.clear();
                            events.push_back(IncomingEvent(fgtTrackerPos,fgtTrackerVelEstimate,-1.0,"fingertipTracker"));
                            isTarget=true;
                        }
                    }
                }
            }
        }

        // processes the doubleTouch !rf->check("noDoubleTouch")
        if(doubleTouchBottle = doubleTouchPort.read(false))
        {
            if(doubleTouchBottle != NULL)
            {
                if (doubleTouchBottle->get(3).asString() != "")
                {
                    Matrix T = eye(4);
                    Vector fingertipPos(4,0.0);
                    doubleTouchPos.resize(4,0.0);
                    
                    currentTask = doubleTouchBottle->get(3).asString();
                    doubleTouchStep = doubleTouchBottle->get(0).asInt();
                    fingertipPos = iCub::skinDynLib::matrixFromBottle(*doubleTouchBottle,20,4,4).subcol(0,3,3); // fixed translation from the palm
                    fingertipPos.push_back(1.0);

                    if(doubleTouchStep<=1)
                    {
                        Vector ang(3,0.0);
                        igaze -> lookAtAbsAngles(ang);
                    }
                    else if(doubleTouchStep>1 && doubleTouchStep<8)
                    {
                        if(currentTask=="LtoR" || currentTask=="LHtoR") //right to left -> the right index finger will be generating events
                        { 
                            iencsR->getEncoders(encsR->data());
                            Vector qR=encsR->subVector(0,6);
                            armR -> setAng(qR*CTRL_DEG2RAD);                        
                            T = armR -> getH(3+6, true);  // torso + up to wrist
                            doubleTouchPos = T * fingertipPos; 
                            //optionally, get the finger encoders and get the fingertip position using iKin Finger based on the current joint values 
                            //http://wiki.icub.org/iCub/main/dox/html/icub_cartesian_interface.html#sec_cart_tipframe
                            doubleTouchPos.pop_back(); //take out the last dummy value from homogenous form
                        }
                        else if(currentTask=="RtoL" || currentTask=="RHtoL") //left to right -> the left index finger will be generating events
                        {   
                            iencsL->getEncoders(encsL->data());
                            Vector qL=encsL->subVector(0,6);
                            armL -> setAng(qL*CTRL_DEG2RAD);                        
                            T = armL -> getH(3+6, true);  // torso + up to wrist
                            doubleTouchPos = T * fingertipPos; 
                            //optionally, get the finger encoders and get the fingertip position using iKin Finger based on the current joint values 
                            //http://wiki.icub.org/iCub/main/dox/html/icub_cartesian_interface.html#sec_cart_tipframe
                            doubleTouchPos.pop_back(); //take out the last dummy value from homogenous form
                        } 
                        else
                        {
                            yError(" [vtWThread] Unknown task received from the double touch thread!");
                        }
                        
                        yDebug("Computing data from the doubleTouch %g\n",getEstUsed());
                        AWPolyElement el2(doubleTouchPos,Time::now());
                        doubleTouchVelEstimate=linEst_doubleTouch->estimate(el2);
                        events.push_back(IncomingEvent(doubleTouchPos,doubleTouchVelEstimate,-1.0,"doubleTouch"));
                        isTarget=true;
                    }
                }
            }
        }
    }
    
    if (pf3dTrackerPos[0]!=0.0 && pf3dTrackerPos[1]!=0.0 && pf3dTrackerPos[2]!=0.0)
        igaze -> lookAtFixationPoint(pf3dTrackerPos);
    else if (doubleTouchPos[0]!=0.0 && doubleTouchPos[1]!=0.0 && doubleTouchPos[2]!=0.0)
        igaze -> lookAtFixationPoint(doubleTouchPos);
    else if (optFlowPos[0]!=0.0 && optFlowPos[1]!=0.0 && optFlowPos[2]!=0.0)
        igaze -> lookAtFixationPoint(optFlowPos);
    
    if (isTarget)
    {        
        Bottle& eventsBottle = eventsPort.prepare();
        eventsBottle.clear();
        for (size_t i = 0; i < events.size(); i++)
        {
            eventsBottle.addList()= events[i].toBottle();
        }
        eventsPort.write();
        timeNow = yarp::os::Time::now();
        sendGuiTarget();
    }
    else if (yarp::os::Time::now() - timeNow > 1.0)
    {
        yDebug("No significant event in the last second. Resetting the velocity estimators..");
        timeNow = yarp::os::Time::now();

        linEst_optFlow     -> reset();
        linEst_pf3dTracker -> reset();
        linEst_doubleTouch -> reset();
        linEst_fgtTracker  -> reset();
        deleteGuiTarget();
    }
}
Exemplo n.º 4
0
int main (int argc, char *argv[])
{


  
  std::vector<double> punto1(1,0.0);
  std::vector<double> punto2(1,1.0);
  std::vector<double> punto3(1,2.0);
  std::vector<double> punto4(1,3.0);

  Punto<1> pt1(punto1);
  Punto<1> pt2(punto2);
  Punto<1> pt3(punto3);
  Punto<1> pt4(punto4);

  std::vector<Punto<1> >element1;
  element1.push_back(pt1);
  element1.push_back(pt2);
  std::vector<Punto<1> >element2;
  element2.push_back(pt2);
  element2.push_back(pt3);
  std::vector<Punto<1> >element3;
  element3.push_back(pt3);
  element3.push_back(pt4);
 
    myelement<1> el1(element1);
    myelement<1> el2(element2);
    myelement<1> el3(element3);

    std::vector<myelement<1> > raccoltael;
  raccoltael.push_back(el1);
  raccoltael.push_back(el2);
  raccoltael.push_back(el3);
  std::cout<<raccoltael.size()<<std::endl;
  mymesh<myelement<1> > dominiop(raccoltael);
  std::cout<<dominiop.size_element()<<std::endl;

  QuadFactory::RulesFactory & rulesFactory(QuadFactory::RulesFactory::Instance());
  const Quadrature1D * therule = rulesFactory.create("Trapezi");
  therule->ShowMe();
  NumericalQuad<1> integrale(therule,dominiop);
  std::cout<<integrale.apply(&xquad)<<std::endl;
  /*therule = rulesFactory.create("Simpson");
  therule->ShowMe();
  integrale.SetRule(therule);
  std::cout<<integrale.apply(&xquad)<<std::endl;
  therule = rulesFactory.create("MidPoint");
  therule->ShowMe();
  integrale.SetRule(therule);
  std::cout<<integrale.apply(&xquad)<<std::endl;
  */
/*
  MidPoint mid;
  Trapezi trap;
  Simpson simp;
 

  std::vector<double> dominio;
  double a = 0;
  double b = 6;
  double step = 0;
  double value = 0;

  NumericalQuad integrale;

  std::ofstream file("Errori.txt");

  unsigned int maxit = 15;
  for(size_t i(2);i<maxit;i++)
    {
      dominio.resize(i+1);
      step = (b-a)/i;
      for(size_t k(0);k<=i;k++) dominio[k]=a+k*step;

      integrale.SetDom(dominio);

      integrale.SetRule(&mid);
      value = integrale.apply(&xquad);
      std::cout<<"Midpoint = "<<value<<std::endl;
      file<<fabs(value - 6*6*6*6*6)<<'\t';

      integrale.SetRule(&trap);
      value = integrale.apply(&xquad);
      std::cout<<"Trapezi = "<<value<<std::endl;
      file<<fabs(value - 6*6*6*6*6)<<'\t';

      integrale.SetRule(&simp);
      value =  integrale.apply(&xquad);
      std::cout<<"Simpson = "<<value<<std::endl;
      file<<fabs(value - 6*6*6*6*6);

      file<<std::endl;
    }

    file.close();*/
  return 0;
}