exampleDraWin.cpp
This is an example for the usage of the DraWin class. More details about this example.
#include <CommonOptions.h>
#include <DraWinGL.h>
#define DEBUG 0
using namespace MipResources;
int main(int argc,const char* argv[]){
CommonOptions::init(argc,(char* const *)argv);
commonOptions->updateValues();
unsigned int draList;
DraWin *draWin = new DraWinGL( argc, argv );
while(!draWin->addList(Time(0,1000),draList)){
usleep(1000);
}
unsigned int draList2;
while(!draWin->addList(Time(0,1000),draList2)){
usleep(1000);
}
cout << "Enter to start" << endl;
getchar();
Timer timer;
Timer timer2;
Decimal speed = 0.05;
Decimal pulsation = 1.0;
Position position(1.0,0.0);
Decimal radius(1.0);
Position target(0.0,0.0);
bool forward = true;
while(1){
if(fabs(radius)> 1.0){
forward = !forward;
}
if (forward){
radius -= speed*timer2.get().dCast();
}else{
radius += speed*timer2.get().dCast();
}
position = Position(cos(pulsation*timer.get().dCast()),sin(pulsation*timer.get().dCast()))*radius;
Pose pose(position, 0.0);
DraWinObj *robot = new MobileRob2D(pose,0.1);
robot->setColor(Colors::blue());
while(!draWin->pushObj(robot, Time(0,5000),draList)){
usleep(1000);
}
DraWinObj *point2 = new Point2D(position,4.0);
point2->setColor(Colors::blue());
while(!draWin->pushObj(point2, Time(0,5000),draList)){
usleep(1000);
}
DraWinObj *point = new Point2D(position,2.0);
point->setColor(Colors::lightBlue());
while(!draWin->overlapObj(point, Time(0,5000),draList2)){
usleep(1000);
}
DraWinObj *segment = new Segment2D(position,target);
while(!draWin->pushObj(segment, Time(0,5000),draList)){
usleep(1000);
}
DraWinObj *point3 = new Point2D(target,4.0);
point3->setColor(Colors::red());
while(!draWin->pushObj(point3, Time(0,5000),draList)){
usleep(1000);
}
DraWinObj *bb = new CmdBB2D(target,1.2,1.2);
while(!draWin->pushObj(bb, Time(0,5000),draList)){
usleep(1000);
}
while(!draWin->swapList(Time(0,500),draList)){
usleep(1000);
}
timer2.reset();
usleep(20000);
}
return 0;
}