예제 #1
0
void Joystick::draw()
{
    if (_simpleDrawEnabled) {
        CC_NODE_DRAW_SETUP();
        switch (_state) {
            case jsTouched:
                drawCircle();
                break;
            case jsTouchMoved:
                drawArrow();
                break;
            default:
                break;
        }
    }
}
예제 #2
0
void unLOCK::redrawArrow(SDL_Surface* scr) {
	if(relY+relAY < ScreenHeight) {
		if(ScreenHeight - (relY+relAY) < arrow->h) {
			SDL_Rect clip = gfx.SetClip(relX+relAX, relY+relAY, arrow->w, ScreenHeight - (relY+relAY));
			gfx.AddSurface(relX+relAX, relY+relAY, bkgImage, scr, &clip);
			SDL_Rect clip2 = gfx.SetClip(relAX, relAY, arrow->w, ScreenHeight - (relY+relAY));
			gfx.AddSurface(relX+relAX, relY+relAY, ibg, scr, &clip2);
		}
		else {
			SDL_Rect clip = gfx.SetClip(relX+relAX, relY+relAY, arrow->w, arrow->h);
			gfx.AddSurface(relX+relAX, relY+relAY, bkgImage, scr, &clip);
			SDL_Rect clip2 = gfx.SetClip(relAX, relAY, arrow->w, arrow->h);
			gfx.AddSurface(relX+relAX, relY+relAY, ibg, scr, &clip2);
		}
		drawArrow(scr);
	}
}
예제 #3
0
파일: config.c 프로젝트: mconners/monochron
void set_backlight(void) {
  uint8_t mode = SET_BRIGHTNESS;

  display_menu();
  
  screenmutex++;
  displaySetAddress(0, 6);
  displayPutStr("Press MENU to exit   ", NORMAL);

  // put a small arrow next to 'set 12h/24h'
  drawArrow(0, 43, MENU_INDENT -1);
  screenmutex--;
  
  timeoutcounter = INACTIVITYTIMEOUT;  

  while (1) {
    if (just_pressed & 0x1) { // mode change
      return;
    }
    if (just_pressed || pressed) {
      timeoutcounter = INACTIVITYTIMEOUT;  
      // timeout w/no buttons pressed after 3 seconds?
    } else if (!timeoutcounter) {
      //timed out!
      displaymode = SHOW_TIME;     
      return;
    }
  
    if (just_pressed & 0x2) {
      just_pressed = 0;
      screenmutex++;

      if (mode == SET_BRIGHTNESS) {
	DEBUG(putstring("Setting backlight"));
	// ok now its selected
	mode = SET_BRT;
	// print the region 
	displaySetAddress(MENU_INDENT + 15*6, 5);
	printnumber(OCR2B>>OCR2B_BITSHIFT,INVERTED);
	
	// display instructions below
	displaySetAddress(0, 6);
	displayPutStr("Press + to change   ", NORMAL);
	displaySetAddress(0, 7);
	displayPutStr("Press SET to save   ", NORMAL);
      } else {
예제 #4
0
void unLOCK::moveArrow(int x) {
	if (x > ARR_MAX_REL_X) { x = ARR_MAX_REL_X; app.Running = false; }
	else if (x < UNLOCK_ARR_X)
		x = UNLOCK_ARR_X;
	
	if (x != relAX) {
		/*int x0, x1;
		if (x < relAX) {
			x0 = x;
			x1 = (relAX - x) + arrow->w;
		} else {
			x0 = relAX;
			x1 = (x - relAX) + arrow->w;
		}*/
		
		if(relY+relAY < ScreenHeight) {
			if(ScreenHeight - (relY+relAY) < arrow->h) {
				SDL_Rect clip = gfx.SetClip(relX+relAX, relY+relAY, arrow->w, ScreenHeight - (relY+relAY));
				gfx.AddSurface(relX+relAX, relY+relAY, bkgImage, gfx.Screen, &clip);
				SDL_Rect clip2 = gfx.SetClip(relAX, relAY, arrow->w, ScreenHeight - (relY+relAY));
				gfx.AddSurface(relX+relAX, relY+relAY, ibg, gfx.Screen, &clip2);
			}
			else {
				SDL_Rect clip = gfx.SetClip(relX+relAX, relY+relAY, arrow->w, arrow->h);
				gfx.AddSurface(relX+relAX, relY+relAY, bkgImage, gfx.Screen, &clip);
				SDL_Rect clip2 = gfx.SetClip(relAX, relAY, arrow->w, arrow->h);
				gfx.AddSurface(relX+relAX, relY+relAY, ibg, gfx.Screen, &clip2);
			}
		}
		relAX = x;
		drawArrow(gfx.Screen, false);

		// XXX: This thing is simply f*****g with my brain
		// XXX: FullScreen updates run way faster than local minimal updates.
/*		if(relY+relAY < ScreenHeight) {
			if(ScreenHeight - (relY+relAY) < arrow->h) {
				gfx.Update(gfx.Screen, relX+x0, relY+relAY, x1, ScreenHeight-(relY+relAY));
			}
			else {
				gfx.Update(gfx.Screen, relX+x0, relY+relAY, x1, arrow->h);
			}
		}*/
	}
}
예제 #5
0
void drawWorldModelSceneGraph(Canvas& canvas, const WorldModel2D& wm, const std::vector<Link>& links)
{
    drawWorld(canvas, wm);

    for(unsigned int i = 0; i < links.size(); ++i)
    {
        const Link& link = links[i];

        const Entity2D& e1 = wm.entities[link.i1];
        const Entity2D& e2 = wm.entities[link.i2];

        drawArrow(canvas, e1.pose.t, e2.pose.t, Color(150, 150, 150, 2));

        drawAxis(canvas, e1.pose);
        drawAxis(canvas, e2.pose);
    }

//    drawAxis(canvas, fromXYA(p0.x, p0.y, 0));
}
예제 #6
0
void MapView::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);

    painter.setRenderHints(QPainter::Antialiasing);

    QRect rect(contentsRect());

    painter.fillRect(rect, Qt::black);

    std::list<track_t> tracks;
    std::list<scan_area_t> scan_areas;

    collectTracks(tracks);
    collectScanAreas(scan_areas);

    for (std::list<scan_area_t>::const_iterator i = scan_areas.begin(); i != scan_areas.end(); i++) {
        QPainterPath path;
        path.addEllipse(i->first, i->second / 10, i->second / 10);
        painter.fillPath(path, QBrush(QColor(143, 29,12)));
    }

    painter.setPen(Qt::blue);

    for (std::list<track_t>::const_iterator i = tracks.begin() ; i != tracks.end() ; i++) {
        painter.drawLine(i->first, i->second);
    }

    if (selection != NULL) {
        drawArrow(painter, galaxyToScreen(QPoint(selection->GetPosX(), selection->GetPosY())));
    }

    unsigned num_planets = galaxy->GetPlanetCount();

    for(unsigned n = 1 ; n <= num_planets ; n++) {
        const Planet *planet = galaxy->GetPlanet(n);

        QPoint pos(galaxyToScreen(QPoint(planet->GetPosX(), planet->GetPosY())));

        (this->*planetDrawers[mapMode])(painter, planet, pos);
    }
}
/**
 *	This is called when the control is repainted.
 */
/*afx_msg*/ void ChunkWatchControl::OnPaint()
{
	ScopedDogWatch dogWatchScope(s_chunkWatchPaint);

	// The extents of the control:
	CRect fullExtents;
	GetClientRect(fullExtents);

	// The drawing contexts:
	CPaintDC				paintDC(this);
	controls::MemDCScope	memDCScope(memDC_, paintDC, &fullExtents);

	memDC_.FillSolidRect(fullExtents, ::GetSysColor(COLOR_BTNFACE));

	// Calculate the drawing area:
	getDrawConstants();

	// Draw the details:
	if ((drawOptions_ & DRAW_PROJECTVIEW) != 0) drawProject   (memDC_);
	if ((drawOptions_ & DRAW_CHUNKS     ) != 0) drawChunks    (memDC_);
	if ((drawOptions_ & DRAW_UNLOADABLE ) != 0) drawUnloadable(memDC_);
	if ((drawOptions_ & DRAW_WORKING    ) != 0) drawWorking   (memDC_);
	if ((drawOptions_ & DRAW_GRID       ) != 0) drawGrid      (memDC_);
	if ((drawOptions_ & DRAW_USERPOS    ) != 0) drawArrow     (memDC_);
	if ((drawOptions_ & DRAW_FRUSTUM    ) != 0) drawFrustum   (memDC_);

	// Draw the outsides:
	memDC_.Draw3dRect
	(
		extents_, // around the tiles itself
		CLR_BORDER,
		CLR_BORDER
	);
	memDC_.Draw3dRect
	(
		fullExtents, 
		::GetSysColor(COLOR_3DHILIGHT),
		::GetSysColor(COLOR_3DSHADOW )
	);
}
예제 #8
0
void GraphDrawer::drawEdge(int from, int to, ci::Color color, float width)
{
    if (from == to)
        return;

    ci::gl::lineWidth(width);
    ci::gl::color(color);

    // calculating the end points and drawing the lines/arrows
    ci::vec2 fromVec = nodeHandlers[from]->getPos();
    ci::vec2 toVec = nodeHandlers[to]->getPos();
    if (g->isDirected())
    {
        ci::vec2 dir = toVec - fromVec;        
        drawArrow(fromVec, toVec - settings.nodeSize * glm::normalize(dir),
            settings.arrowLength, settings.arrowAngle);
    }
    else
    {
        ci::gl::drawLine(fromVec, toVec);
    }
}
예제 #9
0
static void drawHSlider(struct colorDialog *c, ID2D1RenderTarget *rt)
{
	D2D1_SIZE_F size;
	D2D1_RECT_F rect;
	D2D1_GRADIENT_STOP stops[nStops];
	double r, g, b;
	int i;
	double h;
	ID2D1GradientStopCollection *collection;
	D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES lprop;
	D2D1_BRUSH_PROPERTIES bprop;
	ID2D1LinearGradientBrush *brush;
	double hypot;
	D2D1_POINT_2F center;
	HRESULT hr;

	size = realGetSize(rt);
	rect.left = size.width / 6;		// leftmost sixth for arrow
	rect.top = 0;
	rect.right = size.width;
	rect.bottom = size.height;

	for (i = 0; i < nStops; i++) {
		h = ((double) (i * degPerStop)) / 360.0;
		if (i == (nStops - 1))
			h = 0;
		hsv2RGB(h, 1.0, 1.0, &r, &g, &b);
		stops[i].position = ((double) i) * stopIncr;
		stops[i].color.r = r;
		stops[i].color.g = g;
		stops[i].color.b = b;
		stops[i].color.a = 1.0;
	}
	// and pin the last one
	stops[i - 1].position = 1.0;

	hr = rt->CreateGradientStopCollection(stops, nStops,
		// note that in this case this gamma is explicitly specified by the original
		D2D1_GAMMA_2_2, D2D1_EXTEND_MODE_CLAMP,
		&collection);
	if (hr != S_OK)
		logHRESULT(L"error creating stop collection for H slider gradient", hr);
	ZeroMemory(&lprop, sizeof (D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES));
	lprop.startPoint.x = (rect.right - rect.left) / 2;
	lprop.startPoint.y = 0;
	lprop.endPoint.x = (rect.right - rect.left) / 2;
	lprop.endPoint.y = size.height;
	ZeroMemory(&bprop, sizeof (D2D1_BRUSH_PROPERTIES));
	bprop.opacity = 1.0;
	bprop.transform._11 = 1;
	bprop.transform._22 = 1;
	hr = rt->CreateLinearGradientBrush(&lprop, &bprop,
		collection, &brush);
	if (hr != S_OK)
		logHRESULT(L"error creating gradient brush for H slider", hr);
	rt->FillRectangle(&rect, brush);
	brush->Release();
	collection->Release();

	// now draw a black arrow
	center.x = 0;
	center.y = c->h * size.height;
	hypot = rect.left;
	drawArrow(rt, center, hypot);
}
void drawArrow(rec2vector p, pol2vector v, double hLength, COLORREF c)
{
   drawArrow(p.x, p.y, v.angle, v.r, hLength, c);
}
예제 #11
0
void pauseIcons()
{	
	////////Play icon///////
	glPointSize(2);
	glColor3ub(200,0,0);

	pauseIconX[0]=3*width/9;
	pauseIconY[0]=3*height/8;

	drawColorBall(pauseIconX[0],pauseIconY[0],40);

	glColor4ub(0,0,0,40);
	glPointSize(4);
	drawCircle(pauseIconX[0],pauseIconY[0],40);

	glPointSize(2);
	glColor3ub(255,255,255);
	glPushMatrix();
	glTranslated(3*width/9-15,3*height/8,0);
	glRotated(-90,0,0,1);
	glBegin(GL_TRIANGLES);
	glVertex2d(35*sin(45*(M_PI/180)),0);
	glVertex2d(-35*cos(45*(M_PI/180)),0);
	glVertex2d(0,40);
	glEnd();
	glPopMatrix();

	////////////Restart Icon///////////

	glPointSize(2);
	glColor3ub(0,200,0);

	pauseIconX[1]=2*width/3;
	pauseIconY[1]=3*height/8;

	drawColorBall(pauseIconX[1],pauseIconY[1],40);

	glColor4ub(0,0,0,40);
	glPointSize(4);
	drawCircle(pauseIconX[1],pauseIconY[1],40);

	glLineWidth(8);
	glPointSize(5);
	glColor3ub(255,255,255);
	glPushMatrix();
	glTranslated(pauseIconX[1]-18,pauseIconY[1]-18,0);
	glScalef(0.5,0.5,1);
	strokeString("c");
	glPopMatrix();

	glLineWidth(8);
	glPointSize(4);
	glPushMatrix();
	glTranslated(pauseIconX[1]+10,pauseIconY[1]+10,0);
	glScalef(0.6,0.6,1);
	glRotated(-140,0,0,1);
	glBegin(GL_TRIANGLES);
	glVertex2d(20*sin(45*(M_PI/180)),0);
	glVertex2d(-20*cos(45*(M_PI/180)),0);
	glVertex2d(0,30);
	glEnd();
	glPopMatrix();

	///////////Return Icon////////////
	glPointSize(2);
	glColor3ub(204,0,204);

	pauseIconX[2]=width/2;
	pauseIconY[2]=height/8;

	drawColorBall(pauseIconX[2],pauseIconY[2],40);

	glColor4ub(0,0,0,40);
	glPointSize(4);
	drawCircle(pauseIconX[2],pauseIconY[2],40);

	glLineWidth(8);
	glPointSize(5);
	glColor3ub(255,255,255);
	glPushMatrix();
	glTranslated(pauseIconX[2]-25,pauseIconY[2]-5,0);
	glScalef(0.25,0.25,1);
	drawArrow();
	glPopMatrix();

	glLineWidth(4);
	glPointSize(2);
	glColor3ub(255,255,255);
	glPushMatrix();
	glTranslated(pauseIconX[2],pauseIconY[2],0);
	glScalef(1,1,1);
	glBegin(GL_LINES);
	glVertex2d(-10,20);
	glVertex2d(10,20);
	glVertex2d(10,20);
	glVertex2d(10,-20);
	glVertex2d(10,-20);
	glVertex2d(-10,-20);
	glVertex2d(-10,-20);
	glVertex2d(-10,20);
	glEnd();
	glPopMatrix();

}
예제 #12
0
/*!\reimp
 */
void QWindowsStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl )
{
#ifndef QT_NO_SCROLLBAR
#define ADD_LINE_ACTIVE ( activeControl == AddLine )
#define SUB_LINE_ACTIVE ( activeControl == SubLine )
    QColorGroup g  = sb->colorGroup();

    int sliderMin, sliderMax, sliderLength, buttonDim;
    scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );

    if (sliderStart > sliderMax) { // sanity check
	sliderStart = sliderMax;
    }

    int b = 0;
    int dimB = buttonDim;
    QRect addB;
    QRect subB;
    QRect addPageR;
    QRect subPageR;
    QRect sliderR;
    int addX, addY, subX, subY;
    int length = HORIZONTAL ? sb->width()  : sb->height();
    int extent = HORIZONTAL ? sb->height() : sb->width();

    if ( HORIZONTAL ) {
	subY = addY = ( extent - dimB ) / 2;
	subX = b;
	addX = length - dimB - b;
    } else {
	subX = addX = ( extent - dimB ) / 2;
	subY = b;
	addY = length - dimB - b;
    }

    subB.setRect( subX,subY,dimB,dimB );
    addB.setRect( addX,addY,dimB,dimB );

    int sliderEnd = sliderStart + sliderLength;
    int sliderW = extent - b*2;
    if ( HORIZONTAL ) {
	subPageR.setRect( subB.right() + 1, b,
			  sliderStart - subB.right() - 1 , sliderW );
	addPageR.setRect( sliderEnd, b, addX - sliderEnd, sliderW );
	sliderR .setRect( sliderStart, b, sliderLength, sliderW );
    } else {
	subPageR.setRect( b, subB.bottom() + 1, sliderW,
			  sliderStart - subB.bottom() - 1 );
	addPageR.setRect( b, sliderEnd, sliderW, addY - sliderEnd );
	sliderR .setRect( b, sliderStart, sliderW, sliderLength );
    }

    bool maxedOut = (sb->maxValue() == sb->minValue());
    if ( controls & AddLine ) {
	qDrawWinPanel( p, addB.x(), addB.y(),
		       addB.width(), addB.height(), g,
		       ADD_LINE_ACTIVE, &g.brush( QColorGroup::Button ) );
	drawArrow( p, VERTICAL ? DownArrow : RightArrow,
		   ADD_LINE_ACTIVE, addB.x()+2, addB.y()+2,
		   addB.width()-4, addB.height()-4, g, !maxedOut );
    }
    if ( controls & SubLine ) {
	qDrawWinPanel( p, subB.x(), subB.y(),
		       subB.width(), subB.height(), g,
		       SUB_LINE_ACTIVE, &g.brush( QColorGroup::Button )  );
	drawArrow( p, VERTICAL ? UpArrow : LeftArrow,
		   SUB_LINE_ACTIVE, subB.x()+2, subB.y()+2,
		   subB.width()-4, subB.height()-4, g, !maxedOut );
    }
    QBrush br =
	g.brush( QColorGroup::Light ).pixmap() ?
		 g.brush( QColorGroup::Light )     :
		 QBrush(g.light(), Dense4Pattern);
    p->setBrush( br );
    p->setPen( NoPen );
    p->setBackgroundMode( OpaqueMode );
    if ( maxedOut ) {
	p->drawRect( sliderR );
    } else {
	if ( (controls & SubPage && SubPage == activeControl) ||
	     (controls  & AddPage && AddPage == activeControl) ) {
	    QBrush b = p->brush();
	    QColor c = p->backgroundColor();
// 	    p->fillRect( AddPage == activeControl? addPageR : subPageR, g.fillDark() );
	    p->setBackgroundColor( g.dark() );
	    p->setBrush( QBrush(g.shadow(), Dense4Pattern) );
	    p->drawRect( AddPage == activeControl? addPageR : subPageR );
	    p->setBackgroundColor( c );
	    p->setBrush( b );
	}
	if ( controls & SubPage && SubPage != activeControl)
	    p->drawRect( subPageR );
	if ( controls & AddPage && AddPage != activeControl)
	    p->drawRect( addPageR );
	if ( controls & Slider ) {
	    if ( !maxedOut ) {
		QPoint bo = p->brushOrigin();
		if ( !sb->testWState(WState_GlobalBrushOrigin) )
		    p->setBrushOrigin(sliderR.topLeft());
		qDrawWinPanel( p, sliderR.x(), sliderR.y(),
				 sliderR.width(), sliderR.height(), g,
				 FALSE, &g.brush( QColorGroup::Button ) );
		p->setBrushOrigin(bo);
	    }
	}
    }
    // ### perhaps this should not be able to accept focus if maxedOut?
    if ( sb->hasFocus() && (controls & Slider) )
	drawFocusRect(p, QRect(sliderR.x()+2, sliderR.y()+2,
			       sliderR.width()-5, sliderR.height()-5), g,
		      &sb->backgroundColor());
#endif
}
void drawArrow(rec2vector p, double angle, double length, double hLength, COLORREF c)
{
   drawArrow(p.x, p.y, angle, length, hLength, c);
}
예제 #14
0
파일: main0.cpp 프로젝트: gakarak/convis
int main( int argc, char* argv[] ) {

	//IplImage* img = cvCreateImage(imSize,IPL_DEPTH_8U,3);
	IplImage* img = cvLoadImage(imcd0,CV_LOAD_IMAGE_UNCHANGED);
	IplImage* imgA = cvLoadImage(imcd0,CV_LOAD_IMAGE_GRAYSCALE);
	IplImage* imgB = cvLoadImage(imcd1,CV_LOAD_IMAGE_GRAYSCALE);
	imSize = cvSize(img->width,img->height);
	rmax=0.8*((imSize.width>imSize.height)?imSize.height/2:imSize.width/2);
	rmin=0.2*((imSize.width>imSize.height)?imSize.height/2:imSize.width/2);
	lx=0.5*imSize.width;
	ly=0.5*imSize.height;
	int win_siz	= 7;
	int arr_siz	= NUMX*NUMY;
	CvPoint2D32f p0 = cvPoint2D32f(imSize.width/2,imSize.height/2);
	IplImage*	pyr = cvCreateImage(imSize,8,1);
	IplImage*	pyr_old = cvCreateImage(imSize,8,1);
	char* status	=0;
	status = (char*)cvAlloc(arr_siz);


	cvNamedWindow("testWindow");
	cvNamedWindow("ImgA");
	cvShowImage("ImgA", imgA);
	cvNamedWindow("ImgB");
	cvShowImage("ImgB", imgB);

	CvPoint2D32f*	arrg		= new CvPoint2D32f[arr_siz];
	CvPoint2D32f*	arrg_old	= new CvPoint2D32f[arr_siz];

	int counter=0;
	for(int x=0; x<NUMX; x++) {
		for(int y=0; y<NUMY; y++) {
			arrg_old[counter].x = p0.x + (-lx/2) + lx*x/NUMX;
			arrg_old[counter].y = p0.y + (-ly/2) + lx*y/NUMY;
			counter++;
		}
	}
	cout << "f**k-0" << endl;
	for(int i=0; i<arr_siz; i++) {
		cvLine(img,cvPointFrom32f(arrg_old[i]),cvPointFrom32f(arrg_old[i]),CV_RGB(0,0,0),4);
	}
	cvShowImage("testWindow",img);
	cvWaitKey(100);
	cout << "f**k-1" << endl;

	cvFindCornerSubPix(imgA,
	        			arrg_old,
	        			arr_siz,
	        			cvSize(win_siz,win_siz),
	        			cvSize(2,2),
	        			cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03));
	//cvReleaseImage(&img);
	//img = cvLoadImage(imcd0,CV_LOAD_IMAGE_UNCHANGED);
	cout << "f**k-2" << endl;
	for(int i=0; i<arr_siz; i++) {
		cvLine(img,cvPointFrom32f(arrg_old[i]),cvPointFrom32f(arrg_old[i]),CV_RGB(255,0,255),4);
	}
	cvShowImage("testWindow",img);
	cvWaitKey(100);
	cout << "f**k-3" << endl;

	float errors[arr_siz];
	cvCalcOpticalFlowPyrLK(imgA,imgB,
	        			pyr_old, pyr,
	        			arrg_old,
	        			arrg,
	        			arr_siz,
	        			cvSize(win_siz,win_siz),
	        			5,
	        			status,
	        			errors,
	        			cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.3),
	        			0);

	CvPoint2D32f dp, dp2;
	CvPoint2D32f center = cvPoint2D32f(0., 0.);
	bool arr_draw[arr_siz];
	int count = 0;
	for(int i=0; i<arr_siz; i++) {
		cvLine(img,cvPointFrom32f(arrg[i]),cvPointFrom32f(arrg[i]),CV_RGB(0,255,0),4);
		CvScalar color = CV_RGB(255,0,0);
		dp = getDp(arrg[i],arrg_old[i]);
		double len = getLength(dp);
//		if(errors[i]<50) {
		if(getLength(dp)>3) {
			color = CV_RGB(255,0,0);
		} else {
			color = CV_RGB(100,255,100);
		}
		int nc = i+1;
		arr_draw[i] = false;
		if((nc>-1) && (nc<arr_siz) && len>3) {
			dp2=getDp(arrg[nc],arrg_old[nc]);
			if(getLength(dp2)>2) {
				CvPoint2D32f ctmp = getCrossPoint(arrg_old[i],getOrtoVec(dp), arrg_old[nc],getOrtoVec(dp2));
//				cvLine(img,cvPointFrom32f(arrg_old[i]),cvPointFrom32f(ctmp),CV_RGB(0,0,0),1);
//				cvLine(img,cvPointFrom32f(arrg[i]),cvPointFrom32f(ctmp),CV_RGB(0,0,0),1);
				center = getSum(center,ctmp);
				count++;
				arr_draw[i] = true;
			}
		}
		drawArrow(img,arrg_old[i],arrg[i],color,2,15.);
		cout << "status=[" << (int)status[i] << "], error=[" << errors[i] << "]" << endl;
//		cout << "[" << arrg[i].x << "," << arrg[i].y << "]" << endl;

	}
	center=getDiv(center,count);

	cvCircle(img,cvPointFrom32f(center),10,CV_RGB(0,200,0),1);
	double df = 0;
	for(int i=0; i<arr_siz; i++) {
		if(arr_draw[i]) {
			cvLine(img, cvPointFrom32f(center), cvPointFrom32f(arrg_old[i]),CV_RGB(0,0,0),1);
			cvLine(img, cvPointFrom32f(center), cvPointFrom32f(arrg[i]),CV_RGB(0,0,0),1);
			df += 180.0*(getLength(getDel(arrg[i],arrg_old[i])))
			/(CV_PI*getLength(getDel(arrg_old[i],center)));
		}
	}
	CvFont font, fontbg;
	cvInitFont(&font,CV_FONT_HERSHEY_PLAIN, 2, 2, 0.0, 2, CV_AA);
	cvInitFont(&fontbg,CV_FONT_HERSHEY_PLAIN, 2, 2, 0.0, 8, CV_AA);
	char buff[100];
	bzero(buff,sizeof(buff));
	sprintf(buff,"angle=%0.1f degres",(df/count));
	cvPutText(img,buff,cvPoint(10,25),&fontbg,CV_RGB(0,0,0));
	cvPutText(img,buff,cvPoint(10,25),&font,CV_RGB(255,0,0));

/*
	for(int r=0; r<NUMR; r++) {
		for(int f=0; f<NUMF; f++) {
			double pfi = 2*CV_PI*f/NUMF;
			double ro	= rmin + (rmax-rmin)*r/NUMR;
			p1.x = p0.x + ro*cos(pfi);
			p1.y = p0.y + ro*sin(pfi);
			//cvLine(img,cvPointFrom32f(p1),cvPointFrom32f(p1),CV_RGB(0,0,255),2);
			drawArrow(img,p0,p1,CV_RGB(255,0,0));
		}
	}
*/
	cvShowImage("testWindow",img);
	cvWaitKey(0);

	cvDestroyWindow("testWindow");
	cvReleaseImage(&img);
	cout << "Shutdown" << endl;
	return 0;
}
예제 #15
0
파일: config.c 프로젝트: mconners/monochron
void set_date(void) {
  uint8_t mode = SET_DATE;
  uint8_t day, month, year;
    
  day = date_d;
  month = date_m;
  year = date_y;

  display_menu();

  screenmutex++;
  // put a small arrow next to 'set date'
  drawArrow(0, 27, MENU_INDENT -1);
  screenmutex--;
  
  timeoutcounter = INACTIVITYTIMEOUT;  

  while (1) {
    if (just_pressed & 0x1) { // mode change
      return;
    }
    if (just_pressed || pressed) {
      timeoutcounter = INACTIVITYTIMEOUT;  
      // timeout w/no buttons pressed after 3 seconds?
    } else if (!timeoutcounter) {
      //timed out!
      displaymode = SHOW_TIME;     
      return;
    }
    if (just_pressed & 0x2) {
      just_pressed = 0;
      screenmutex++;

      if ((mode == SET_DATE) && ((region == REGION_US) || (region == DOW_REGION_US) || (region == DATELONG) || (region == DATELONG_DOW))) {
	DEBUG(putstring("Set date month"));
	// ok now its selected
	mode = SET_MONTH;

	// print the month inverted
	print_date(month,day,year,mode);
	// display instructions below
	displaySetAddress(0, 6);
	displayPutStr("Press + to change mon", NORMAL);
	displaySetAddress(0, 7);
	displayPutStr("Press SET to set mon.", NORMAL);
      } else if ((mode == SET_DATE) && ((region == REGION_EU) || (region == DOW_REGION_EU))) {
	DEBUG(putstring("Set date month"));
	// ok now its selected
	mode = SET_DAY;

	// print the day inverted
	print_date(month,day,year,mode);
	// display instructions below
	displaySetAddress(0, 6);
	displayPutStr("Press + to change day", NORMAL);
	displaySetAddress(0, 7);
	displayPutStr("Press SET to set date", NORMAL);
      } else if ((mode == SET_MONTH) && ((region == REGION_US) || (region == DOW_REGION_US) || (region == DATELONG) || (region == DATELONG_DOW))) {
	DEBUG(putstring("Set date day"));
	mode = SET_DAY;

	print_date(month,day,year,mode);
	// display instructions below
	displaySetAddress(0, 6);
	displayPutStr("Press + to change day", NORMAL);
	displaySetAddress(0, 7);
	displayPutStr("Press SET to set date", NORMAL);
      }else if ((mode == SET_DAY) && ((region == REGION_EU) || (region == DOW_REGION_EU))) {
	DEBUG(putstring("Set date month"));
	mode = SET_MONTH;

	print_date(month,day,year,mode);
	// display instructions below
	displaySetAddress(0, 6);
	displayPutStr("Press + to change mon", NORMAL);
	displaySetAddress(0, 7);
	displayPutStr("Press SET to set mon.", NORMAL);
      } else if ( ((mode == SET_DAY) && ((region == REGION_US) || (region == DOW_REGION_US) || (region == DATELONG) || (region == DATELONG_DOW))) ||
		  ((mode == SET_MONTH) && ((region == REGION_EU) || (region == DOW_REGION_EU))) )  {
	DEBUG(putstring("Set year"));
	mode = SET_YEAR;
	// print the date normal

	print_date(month,day,year,mode);
	// display instructions below
	displaySetAddress(0, 6);
	displayPutStr("Press + to change yr.", NORMAL);
	displaySetAddress(0, 7);
	displayPutStr("Press SET to set year", NORMAL);
      } else {
	// done!
	DEBUG(putstring("done setting date"));
	mode = SET_DATE;
	// print the seconds normal
	print_date(month,day,year,mode);
	// display instructions below
	displaySetAddress(0, 6);
	displayPutStr("Press MENU to advance", NORMAL);
	displaySetAddress(0, 7);
	displayPutStr("Press SET to set", NORMAL);
	
	date_y = year;
	date_m = month;
	date_d = day;
	writei2ctime(time_s, time_m, time_h, 0, date_d, date_m, date_y);
	init_crand();
      }
      screenmutex--;
    }
    if ((just_pressed & 0x4) || (pressed & 0x4)) {
      just_pressed = 0;

      screenmutex++;

      if (mode == SET_MONTH) {
	month++;
	if (month >= 13)
	  month = 1;
	if(month == 2) {
	  if(leapyear(year) && (day > 29))
	  	day = 29;
	  else if (!leapyear(year) && (day > 28))
	  	day = 28;
	} else if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) {
      if(day > 30)
      	day = 30;
	}
	print_date(month,day,year,mode);
	
      }
      if (mode == SET_DAY) {
	day++;
	if (day > 31)
	  day = 1;
	if(month == 2) {
	  if(leapyear(year) && (day > 29))
	  	day = 1;
	  else if (!leapyear(year) && (day > 28))
	  	day = 1;
	} else if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) {
      if(day > 30)
      	day = 1;
	}
	print_date(month,day,year,mode);
      }
      if (mode == SET_YEAR) {
	year = (year+1) % 100;
	print_date(month,day,year,mode);
      }
      screenmutex--;

      if (pressed & 0x4)
	_delay_ms(200);  
    }
  }

}
예제 #16
0
/** Paint a cell of the ViewItem when in TVS_INPROGRESS state
  *
  * \param painter The paint where we draw the item
  * \param cg The color group we can use to draw
  * \param column The index of the column to draw
  * \param width The width of the cell
  * \param align Not yet used
  *
  */
void RainbruRPG::Network::Ftp::TransferVisual::
drawInProgress(QPainter * painter,const QColorGroup & cg, int column, 
	   int width, int align){

  // controls
  if (ip.isEmpty()){
    LOGW("IP address is empty");
  }

  if (isSelected()){
    painter->setPen(Qt::NoPen);
    painter->setBrush(cg.color(QPalette::Highlight));
    painter->drawRect(0, 0, width, height());
  }

  QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height()));
  linearGrad.setColorAt(0,    QColor( 34,  80, 184));
  linearGrad.setColorAt(0.25, QColor(150, 189, 231));
  linearGrad.setColorAt(0.50, QColor( 88, 154, 227));
  linearGrad.setColorAt(0.75, QColor(150, 189, 231));
  linearGrad.setColorAt(1,    QColor(127, 205, 255));

  QLinearGradient linearGrad2(QPointF(0, 0), QPointF(0, height()));
  linearGrad2.setColorAt(0,    QColor(163, 163, 163));
  linearGrad2.setColorAt(0.25, QColor(231, 231, 231));
  linearGrad2.setColorAt(0.50, QColor(217, 217, 217));
  linearGrad2.setColorAt(0.75, QColor(244, 244, 244));
  linearGrad2.setColorAt(1,    QColor(248, 248, 248));

  QPen pen(Qt::gray, 1); 

  if (column==6){
    // Progress bar
    int totalW=width-4;
    int leftW=(int)(totalW*percent)/100;
    int rightW=totalW-leftW;

    // Drawing ProgressBar
    painter->setPen(Qt::NoPen);
    painter->setBrush(QBrush(linearGrad));
    painter->drawRect( 2, 2, leftW, height()-4 );
    painter->setBrush(QBrush(linearGrad2));
    painter->drawRect( leftW+2, 2, rightW, height()-4 );

    painter->setPen(pen);
    painter->setBrush(Qt::NoBrush);
    painter->drawRect(0, 0, width-1, height()-1);

    QFont f=painter->font();
    f.setPointSize(f.pointSize()-1);

    painter->setFont(f);
    painter->setPen(Qt::black);

    QString s=QString::number(percent, 'f', 2);
    s+=" %";
    painter->drawText( 0, 0, width, height(), Qt::AlignCenter, s );
  }
  else{

    painter->setPen(Qt::black);
    QString s;
    switch(column){
    case 0:
      drawIpPort(painter, width, height());
      break;
    case 1:
      // Filename
      s=absoluteFilename;
      painter->drawText( 0, 0, width, height(), 
			 Qt::AlignLeft|Qt::AlignVCenter, s);
      break;
    case 2:
      // Green or Red arrow
      drawArrow(painter, width, height());
      break;
    case 3:
      // Download rate
      s=QString::number(rate, 'f', 2);
      s+=" kB/s";
      painter->drawText( 0, 0, width, height(), 
			 Qt::AlignRight|Qt::AlignVCenter, s);
      break;
    case 4:
      // File size
      painter->drawText( 0, 0, width, height(), 
			 Qt::AlignRight|Qt::AlignVCenter, fileSizeToString());
      break;
    case 5:
      // Remaining time
      painter->drawText( 0, 0, width, height(), 
			 Qt::AlignRight|Qt::AlignVCenter, remainingTime);
      break;
   }
  }
}
void AppStage_MagnetometerCalibration::render()
{
    const float modelScale = 18.f;
    glm::mat4 scaleAndRotateModelX90= 
        glm::rotate(
            glm::scale(glm::mat4(1.f), glm::vec3(modelScale, modelScale, modelScale)),
            90.f, glm::vec3(1.f, 0.f, 0.f));  
    
    PSMoveIntVector3 rawSampleExtents = (m_maxSampleExtent - m_minSampleExtent).unsafe_divide(2);

    glm::vec3 boxMin = psmove_float_vector3_to_glm_vec3(m_minSampleExtent.castToFloatVector3());
    glm::vec3 boxMax = psmove_float_vector3_to_glm_vec3(m_maxSampleExtent.castToFloatVector3());
    glm::vec3 boxCenter = (boxMax + boxMin) * 0.5f;
    glm::vec3 boxExtents = (boxMax - boxMin) * 0.5f;

    glm::mat4 recenterMatrix = 
        glm::translate(glm::mat4(1.f), -eigen_vector3f_to_glm_vec3(m_sampleFitEllipsoid.center));

    switch (m_menuState)
    {
    case eCalibrationMenuState::waitingForStreamStartResponse:
        {
        } break;
    case eCalibrationMenuState::failedStreamStart:
    case eCalibrationMenuState::failedBadCalibration:
        {
        } break;
    case eCalibrationMenuState::measureBExtents:
        {

            float r= clampf01(static_cast<float>(m_led_color_r) / 255.f);
            float g= clampf01(static_cast<float>(m_led_color_g) / 255.f);
            float basis= clampf01(static_cast<float>(m_led_color_b) / 255.f);

            // Draw the psmove model in the middle
            drawPSMoveModel(scaleAndRotateModelX90, glm::vec3(r, g, basis));

            // Draw the sample point cloud around the origin
            drawPointCloud(
                recenterMatrix,
                glm::vec3(1.f, 1.f, 1.f),
                reinterpret_cast<float *>(&m_alignedSamples->magnetometerEigenSamples[0]),
                m_sampleCount);

            // Draw the sample bounding box
            // Label the min and max corners with the min and max magnetometer readings
            drawTransformedBox(recenterMatrix, boxMin, boxMax, glm::vec3(1.f, 1.f, 1.f));
            drawTextAtWorldPosition(recenterMatrix, boxMin, "%d,%d,%d",
                                    m_minSampleExtent.i, m_minSampleExtent.j, m_minSampleExtent.k);
            drawTextAtWorldPosition(recenterMatrix, boxMax, "%d,%d,%d",
                                    m_maxSampleExtent.i, m_maxSampleExtent.j, m_maxSampleExtent.k);

            // Draw and label the extent axes
            drawTransformedAxes(glm::mat4(1.f), boxExtents.x, boxExtents.y, boxExtents.z);
            drawTextAtWorldPosition(glm::mat4(1.f), glm::vec3(boxExtents.x, 0.f, 0.f), "%d", rawSampleExtents.i);
            drawTextAtWorldPosition(glm::mat4(1.f), glm::vec3(0.f, boxExtents.y, 0.f), "%d", rawSampleExtents.j);
            drawTextAtWorldPosition(glm::mat4(1.f), glm::vec3(0.f, 0.f, boxExtents.z), "%d", rawSampleExtents.k);

            // Draw the best fit ellipsoid
            {
                glm::mat3 basis = eigen_matrix3f_to_glm_mat3(m_sampleFitEllipsoid.basis);
                glm::vec3 center = eigen_vector3f_to_glm_vec3(m_sampleFitEllipsoid.center);
                glm::vec3 extents = eigen_vector3f_to_glm_vec3(m_sampleFitEllipsoid.extents);

                drawEllipsoid(
                    recenterMatrix,
                    glm::vec3(0.f, 0.4f, 1.f),
                    basis, center, extents);
                drawTextAtWorldPosition(
                    recenterMatrix,
                    center - basis[0]*extents.x,
                    "E:%.1f", m_sampleFitEllipsoid.error);
            }

            // Draw the current magnetometer direction
            {
                glm::vec3 m_start= boxCenter;
                glm::vec3 m_end= psmove_float_vector3_to_glm_vec3(m_lastMagnetometer.castToFloatVector3());

                drawArrow(recenterMatrix, m_start, m_end, 0.1f, glm::vec3(1.f, 0.f, 0.f));
                drawTextAtWorldPosition(recenterMatrix, m_end, "M");
            }
        } break;
    case eCalibrationMenuState::waitForGravityAlignment:
        {
            drawPSMoveModel(scaleAndRotateModelX90, glm::vec3(1.f, 1.f, 1.f));

            // Draw the current direction of gravity
            {
                const float renderScale = 200.f;
                glm::mat4 renderScaleMatrix = 
                    glm::scale(glm::mat4(1.f), glm::vec3(renderScale, renderScale, renderScale));
                glm::vec3 g= psmove_float_vector3_to_glm_vec3(m_lastAccelerometer);

                drawArrow(
                    renderScaleMatrix,
                    glm::vec3(), g, 
                    0.1f, 
                    glm::vec3(0.f, 1.f, 0.f));
                drawTextAtWorldPosition(renderScaleMatrix, g, "G");
            }
        } break;
    case eCalibrationMenuState::measureBDirection:
        {
            drawPSMoveModel(scaleAndRotateModelX90, glm::vec3(1.f, 1.f, 1.f));

            // Draw the current magnetometer direction
            {
                glm::vec3 m_start = boxCenter;
                glm::vec3 m_end = psmove_float_vector3_to_glm_vec3(m_lastMagnetometer.castToFloatVector3());

                drawArrow(recenterMatrix, m_start, m_end, 0.1f, glm::vec3(1.f, 0.f, 0.f));
                drawTextAtWorldPosition(recenterMatrix, m_end, "M");
            }

        } break;
    case eCalibrationMenuState::waitForSetCalibrationResponse:
        {
        } break;
    case eCalibrationMenuState::failedSetCalibration:
        {
        } break;
    case eCalibrationMenuState::complete:
        {
            // Get the orientation of the controller in world space (OpenGL Coordinate System)            
            glm::quat q= psmove_quaternion_to_glm_quat(m_controllerView->GetPSMoveView().GetOrientation());
            glm::mat4 worldSpaceOrientation= glm::mat4_cast(q);
            glm::mat4 worldTransform = glm::scale(worldSpaceOrientation, glm::vec3(modelScale, modelScale, modelScale));

            drawPSMoveModel(worldTransform, glm::vec3(1.f, 1.f, 1.f));
            drawTransformedAxes(glm::mat4(1.f), 200.f);
        } break;
    case eCalibrationMenuState::pendingExit:
        {
        } break;
    default:
        assert(0 && "unreachable");
    }
}
예제 #18
0
void winIcons()
{
	/////////Icon Restart///////

	glPointSize(2);
	glColor3ub(0,200,0);

	winIconX[0]=4*width/10;
	winIconY[0]=height/8;

	drawColorBall(winIconX[0],winIconY[0],40);

	glColor4ub(0,0,0,40);
	glPointSize(4);
	drawCircle(winIconX[0],winIconY[0],40);

	glLineWidth(8);
	glPointSize(5);
	glColor3ub(255,255,255);
	glPushMatrix();
	glTranslated(winIconX[0]-18,winIconY[0]-18,0);
	glScalef(0.5,0.5,1);
	strokeString("c");
	glPopMatrix();

	glLineWidth(8);
	glPointSize(4);
	glPushMatrix();
	glTranslated(winIconX[0]+10,winIconY[0]+10,0);
	glScalef(0.6,0.6,1);
	glRotated(-140,0,0,1);
	glBegin(GL_TRIANGLES);
	glVertex2d(20*sin(45*(M_PI/180)),0);
	glVertex2d(-20*cos(45*(M_PI/180)),0);
	glVertex2d(0,30);
	glEnd();
	glPopMatrix();

	/////////////Icon Return///////////
	glPointSize(2);
	glColor3ub(204,0,204);

	winIconX[1]=6*width/10;
	winIconY[1]=height/8;

	drawColorBall(winIconX[1],winIconY[1],40);

	glColor4ub(0,0,0,40);
	glPointSize(4);
	drawCircle(winIconX[1],winIconY[1],40);

	glLineWidth(8);
	glPointSize(5);
	glColor3ub(255,255,255);
	glPushMatrix();
	glTranslated(winIconX[1]-25,winIconY[1]-5,0);
	glScalef(0.25,0.25,1);
	drawArrow();
	glPopMatrix();

	glLineWidth(4);
	glPointSize(2);
	glColor3ub(255,255,255);
	glPushMatrix();
	glTranslated(winIconX[1],winIconY[1],0);
	glScalef(1,1,1);
	glBegin(GL_LINES);
	glVertex2d(-10,20);
	glVertex2d(10,20);
	glVertex2d(10,20);
	glVertex2d(10,-20);
	glVertex2d(10,-20);
	glVertex2d(-10,-20);
	glVertex2d(-10,-20);
	glVertex2d(-10,20);
	glEnd();
	glPopMatrix();

}
예제 #19
0
void BasicLocator::draw(M3dView& view,
						const MDagPath&,
						M3dView::DisplayStyle style,
						M3dView::DisplayStatus status)
{
	MPlug pDrawit(thisMObject(), aIsDrawing);
	bool drawItV;
	pDrawit.getValue(drawItV);

	if (drawItV == false)
		return;

	MPlug pTransparent(thisMObject(), aIsTransparent);
	MPlug pShapeColor(thisMObject(), aShapeColor);
	MPlug pShapeType(thisMObject(), aShapeType);
	float r, g, b, a;
	MObject color;


	//glStart
	view.beginGL();
	//setup states
	glPushAttrib(GL_CURRENT_BIT);

	glDepthMask(GL_FALSE);

	//setup for draw colors for maya(active, lead etc)
	MColor solidColor, wireColor;

	switch (status)
	{
	case M3dView::kActive:
		//white
			solidColor = MColor(1.0f, 1.0f, 1.0f, 0.1f);
			break;
	case M3dView::kLead:
		//green
			solidColor = MColor(0.26f, 1.0f, 0.64f, 0.1f);
			break;

	case M3dView::kActiveAffected:
		// maya magenta
		solidColor = MColor(0.78f, 1.0f, 0.78f);	
		break;

	case M3dView::kTemplate:
		// maya template gray
		solidColor = MColor(0.47f, 0.47f, 0.47f);	
		break;

	case M3dView::kActiveTemplate:
		// maya selected template pink
		solidColor = MColor(1.0f, 0.47f, 0.47f);	
		break;

	default:
	
		pShapeColor.getValue(color);
		MFnNumericData data(color);
		data.getData(r, g, b);
		pTransparent.getValue(a);
	
		if (a < 1.0f)
		{
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		}
		solidColor = MColor(r, g, b, a);
		//draw the solidColor
		glColor4f(solidColor.r, solidColor.g, solidColor.b, solidColor.a);
	}
	int sType;
	
	pShapeType.getValue(sType);
	switch (sType)
	{
	case 0:
		drawArrow();

	case 1:
		drawDisc(1.0, 32, true);
	
	default :
		drawArrow();
	}
	
	glDepthMask(GL_TRUE);
	glDisable(GL_BLEND);
	glPopAttrib();
	view.endGL();

}
예제 #20
0
파일: fresh.cpp 프로젝트: opieproject/opie
void FreshStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
				       const QPalette& pal,
				       bool act, bool enabled, int x, int y, int w, int h)
{
#ifndef QT_NO_MENUDATA
    const QColorGroup & g = pal.active();
    bool dis	  = !enabled;
    QColorGroup itemg = dis ? pal.disabled() : pal.active();

    if ( checkable )
	maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks

    int checkcol	  =     maxpmw;

    if ( mi && mi->isSeparator() ) {			// draw separator
	p->setPen( g.dark() );
	p->drawLine( x, y, x+w, y );
	p->setPen( g.light() );
	p->drawLine( x, y+1, x+w, y+1 );
	return;
    }

    QBrush fill = act? g.brush( QColorGroup::Highlight ) :
			    g.brush( QColorGroup::Button );
    p->fillRect( x, y, w, h, fill);

    if ( !mi )
	return;

    if ( mi->isChecked() ) {
	if ( act && !dis ) {
	    qDrawShadePanel( p, x, y, checkcol, h,
			     g, TRUE, 1, &g.brush( QColorGroup::Button ) );
	} else {
	    qDrawShadePanel( p, x, y, checkcol, h,
			     g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
	}
    } else if ( !act ) {
	p->fillRect(x, y, checkcol , h,
		    g.brush( QColorGroup::Button ));
    }

    if ( mi->iconSet() ) {		// draw iconset
	QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
	if (act && !dis )
	    mode = QIconSet::Active;
    QPixmap pixmap;
    if ( mode == QIconSet::Disabled )
        pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
    else
        pixmap = mi->iconSet()->pixmap();
	int pixw = pixmap.width();
	int pixh = pixmap.height();
	if ( act && !dis ) {
	    if ( !mi->isChecked() )
		qDrawShadePanel( p, x, y, checkcol, h, g, FALSE,  1, &g.brush( QColorGroup::Button ) );
	}
	QRect cr( x, y, checkcol, h );
	QRect pmr( 0, 0, pixw, pixh );
	pmr.moveCenter( cr.center() );
	p->setPen( itemg.text() );
	p->drawPixmap( pmr.topLeft(), pixmap );

	QBrush fill = act? g.brush( QColorGroup::Highlight ) :
			      g.brush( QColorGroup::Button );
	p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
    } else  if ( checkable ) {	// just "checking"...
	int mw = checkcol + motifItemFrame;
	int mh = h - 2*motifItemFrame;
	if ( mi->isChecked() ) {
	    drawCheckMark( p, x + motifItemFrame + 2,
			   y+motifItemFrame, mw, mh, itemg, act, dis );
	}
    }

    p->setPen( act ? g.highlightedText() : g.buttonText() );

    QColor discol;
    if ( dis ) {
	discol = itemg.text();
	p->setPen( discol );
    }

    int xm = motifItemFrame + checkcol + motifItemHMargin;

    if ( mi->custom() ) {
	int m = motifItemVMargin;
	p->save();
	if ( dis && !act ) {
	    p->setPen( g.light() );
	    mi->custom()->paint( p, itemg, act, enabled,
				 x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
	    p->setPen( discol );
	}
	mi->custom()->paint( p, itemg, act, enabled,
			     x+xm, y+m, w-xm-tab+1, h-2*m );
	p->restore();
    }
    QString s = mi->text();
    if ( !s.isNull() ) {			// draw text
	int t = s.find( '\t' );
	int m = motifItemVMargin;
	const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
	if ( t >= 0 ) {				// draw tab text
	    if ( dis && !act ) {
		p->setPen( g.light() );
		p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
			     y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
		p->setPen( discol );
	    }
	    p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame,
			 y+m, tab, h-2*m, text_flags, s.mid( t+1 ) );
	}
	if ( dis && !act ) {
	    p->setPen( g.light() );
	    p->drawText( x+xm+1, y+m+1, w-xm+1, h-2*m, text_flags, s, t );
	    p->setPen( discol );
	}
	p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
    } else if ( mi->pixmap() ) {			// draw pixmap
	QPixmap *pixmap = mi->pixmap();
	if ( pixmap->depth() == 1 )
	    p->setBackgroundMode( OpaqueMode );
	p->drawPixmap( x+xm, y+motifItemFrame, *pixmap );
	if ( pixmap->depth() == 1 )
	    p->setBackgroundMode( TransparentMode );
    }
    if ( mi->popup() ) {			// draw sub menu arrow
	int dim = (h-2*motifItemFrame) / 2;
	if ( act ) {
	    if ( !dis )
		discol = white;
	    QColorGroup g2( discol, g.highlight(),
			    white, white,
			    dis ? discol : white,
			    discol, white );
	    drawArrow( p, RightArrow, FALSE,
			       x+w - motifArrowHMargin - motifItemFrame - dim,  y+h/2-dim/2,
			       dim, dim, g2, TRUE );
	} else {
	    drawArrow( p, RightArrow,
			       FALSE,
			       x+w - motifArrowHMargin - motifItemFrame - dim,  y+h/2-dim/2,
			       dim, dim, g, mi->isEnabled() );
	}
    }
#endif
}
예제 #21
0
파일: fresh.cpp 프로젝트: opieproject/opie
void FreshStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl )
{
#define ADD_LINE_ACTIVE ( activeControl == AddLine )
#define SUB_LINE_ACTIVE ( activeControl == SubLine )
    QColorGroup g  = sb->colorGroup();

    int sliderMin, sliderMax, sliderLength, buttonDim;
    scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );

    if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) )
	p->fillRect( 0, 0, sb->width(), sb->height(), g.brush( QColorGroup::Mid ));

    if (sliderStart > sliderMax) { // sanity check
	sliderStart = sliderMax;
    }

    int dimB = buttonDim;
    QRect addB;
    QRect subB;
    QRect addPageR;
    QRect subPageR;
    QRect sliderR;
    int addX, addY, subX, subY;
    int length = HORIZONTAL ? sb->width()  : sb->height();
    int extent = HORIZONTAL ? sb->height() : sb->width();

    if ( HORIZONTAL ) {
	subY = addY = ( extent - dimB ) / 2;
	subX = length - dimB - dimB;
	addX = length - dimB;
    } else {
	subX = addX = ( extent - dimB ) / 2;
	subY = length - dimB - dimB;
	addY = length - dimB;
    }

    int sliderEnd = sliderStart + sliderLength;
    int sliderW = extent;
    if ( HORIZONTAL ) {
	subB.setRect( subX,subY+1,dimB,dimB-1 );
	addB.setRect( addX,addY+1,dimB,dimB-1 );

	subPageR.setRect( 0, 0,
			  sliderStart+1, sliderW );
	addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+1, sliderW );
	sliderR .setRect( sliderStart, 1, sliderLength, sliderW-1 );

    } else {
	subB.setRect( subX+1,subY,dimB-1,dimB );
	addB.setRect( addX+1,addY,dimB-1,dimB );

	subPageR.setRect( 0, 0, sliderW,
			  sliderStart+1 );
	addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+1 );
	sliderR .setRect( 1, sliderStart, sliderW-1, sliderLength );
    }

    bool maxedOut = (sb->maxValue() == sb->minValue());
    if ( controls & AddLine ) {
	drawBevelButton( p, addB.x(), addB.y(),
			 addB.width(), addB.height(), g,
			 ADD_LINE_ACTIVE);
	p->setPen(g.shadow());
	drawArrow( p, VERTICAL ? DownArrow : RightArrow,
		   FALSE, addB.x()+2, addB.y()+2,
		   addB.width()-4, addB.height()-4, g, !maxedOut,
				     &g.brush( QColorGroup::Button ));
    }
    if ( controls & SubLine ) {
	drawBevelButton( p, subB.x(), subB.y(),
			 subB.width(), subB.height(), g,
			 SUB_LINE_ACTIVE );
	p->setPen(g.shadow());
	drawArrow( p, VERTICAL ? UpArrow : LeftArrow,
		    FALSE, subB.x()+2, subB.y()+2,
		   subB.width()-4, subB.height()-4, g, !maxedOut,
				     &g.brush( QColorGroup::Button ));
    }


    if ( controls & SubPage )
	p->fillRect( subPageR.x(), subPageR.y(), subPageR.width(),
		    subPageR.height(), g.brush( QColorGroup::Mid ));
    if ( controls & AddPage )
	p->fillRect( addPageR.x(), addPageR.y(), addPageR.width(),
		     addPageR.height(), g.brush( QColorGroup::Mid ));
    if ( controls & Slider ) {
	QPoint bo = p->brushOrigin();
	p->setBrushOrigin(sliderR.topLeft());
	drawBevelButton( p, sliderR.x(), sliderR.y(),
			 sliderR.width(), sliderR.height(), g,
			 FALSE, &g.brush( QColorGroup::Button ) );
	p->setBrushOrigin(bo);
	drawRiffles( p, sliderR.x(), sliderR.y(),
		     sliderR.width(), sliderR.height(), g, HORIZONTAL );
    }

    // ### perhaps this should not be able to accept focus if maxedOut?
    if ( sb->hasFocus() && (controls & Slider) )
	p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2,
			     sliderR.width()-5, sliderR.height()-5,
			     sb->backgroundColor() );

}
예제 #22
0
void
Style::drawComboBox(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
{
    ASSURE_OPTION(cmb, ComboBox);
    B_STATES
    if ( widget && widget->inherits("WebView") )
    {
        if (!(config.btn.backLightHover || cmb->editable))
        {   // paints hardcoded black text bypassing the style?! grrr...
            QStyleOptionComboBox *_cmb = const_cast<QStyleOptionComboBox*>(cmb);
            _cmb->palette.setColor(config.btn.std_role[Bg], QColor(230,230,230,255));
            _cmb->palette.setColor(config.btn.active_role[Bg], QColor(255,255,255,255));
        }
        widget = 0;
    }

    const int f1 = F(1), f2 = F(2);
    QRect ar;
    const QComboBox *combo = widget ? qobject_cast<const QComboBox*>(widget) : 0;
    QColor c = CONF_COLOR(btn.std, Bg);

    const bool listShown = combo && combo->view() && ((QWidget*)(combo->view()))->isVisible();
    if (listShown) // this messes up hover
        hover = hover || QRect(widget->mapToGlobal(RECT.topLeft()), RECT.size()).contains(QCursor::pos());

    if (isEnabled && (cmb->subControls & SC_ComboBoxArrow) && (!combo || combo->count() > 0))
    {   // do we have an arrow?
        ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
        ar.setBottom(ar.bottom()-f2);
    }

    // the frame
    if ((cmb->subControls & SC_ComboBoxFrame) && cmb->frame)
    {
        if (cmb->editable)
            drawLineEdit(option, painter, widget, false);
        else
        {
            if (!ar.isNull())
            {
                animStep = (appType == GTK || !widget) ? 6*hover : Animator::Hover::step(widget);
                if (listShown)
                    animStep = 6;

                int btn_layer = config.btn.layer;
                Gradients::Type btn_grd = config.btn.gradient;
                config.btn.round = !config.btn.round;

                const bool comboNotSmallerThanTool = config.chooser.layer == Raised || config.chooser.layer == Inlay ||
                                                     config.btn.tool.frame == Sunken || config.btn.tool.frame == Relief;
                if (comboNotSmallerThanTool && widget && qobject_cast<QToolBar*>(widget->parentWidget()))
                {
                    GRAD(btn) = GRAD(btn.tool);
                    config.btn.layer = config.btn.tool.frame;
                }
                else
                {
                    GRAD(btn) = GRAD(chooser);
                    config.btn.layer = config.chooser.layer;
                }

                drawButtonFrame(option, painter, widget, animStep);

                config.btn.round = !config.btn.round;
                config.btn.layer = btn_layer;
                config.btn.gradient = btn_grd;
            }
            else
                shadows.sunken[!config.btn.round][isEnabled].render(RECT, painter);
        }
    }

    // the arrow
    if (!ar.isNull())
    {
        if (!(ar.width()%2) )
            ar.setWidth(ar.width()-1);
        const int dy = ar.height()/4;
        QRect rect = ar.adjusted(0, dy, 0, -dy);

        Navi::Direction dir = Navi::S;
        bool upDown = false;
        if (listShown)
            dir = (config.leftHanded) ? Navi::E : Navi::W;
        else if (combo)
        {
            if (combo->currentIndex() == 0)
                dir = Navi::S;
            else if (combo->currentIndex() == combo->count()-1)
                dir = Navi::N;
            else
                upDown = true;
        }

        painter->save();
        painter->setPen(Qt::NoPen);
        if (cmb->editable)
        {
            if (upDown || dir == Navi::N)
                dir = Navi::S;
            upDown = false; // shall never look like spinbox!
            hover = hover && (cmb->activeSubControls == SC_ComboBoxArrow);
            if (!sunken)
            {
                painter->setBrush(FCOLOR(Base).dark(105));
                rect.translate(0, f2);
                drawArrow(dir, rect, painter);
                rect.translate(0, -f2);
            }
            if (hover || listShown)
                painter->setBrush(FCOLOR(Highlight));
            else
                painter->setBrush( Colors::mid(FCOLOR(Base), FCOLOR(Text)) );
        }
        else if (config.btn.backLightHover)
            painter->setBrush(Colors::mid(c, CONF_COLOR(btn.std, Fg), 6-animStep, 3+animStep));
        else
        {
            c = Colors::mid(c, CONF_COLOR(btn.active, Bg));
            c = Colors::mid(c, CONF_COLOR(btn.active, Bg), 6-animStep, animStep);
            masks.rect[!config.btn.round].render(ar, painter, GRAD(chooser), ori[1], c, RECT.height()-f2, QPoint(0, ar.y() - RECT.y()) );
            painter->setBrush(Colors::mid(c, CONF_COLOR(btn.active, Fg), 1,2));
        }
        if (upDown)
        {
            rect.setBottom(rect.y() + rect.height()/2);
            rect.translate(0, -1);
            drawArrow(Navi::N, rect, painter);
            rect.translate(0, rect.height());
            drawArrow(Navi::S, rect, painter);
        }
        else
        {
            if (dir == Navi::N) // loooks unbalanced otherwise
                rect.translate(0, -f1);
            drawArrow(dir, rect, painter);
        }
        painter->restore();
    }
}
예제 #23
0
/*!
  \brief Draw the button label
  \sa The Qt Manual on QPushButton
*/
void QwtArrowButton::drawButtonLabel(QPainter *p)
{
    const bool isVertical = d_data->arrowType == Qt::UpArrow ||
        d_data->arrowType == Qt::DownArrow;

    const QRect r = labelRect();
    QSize boundingSize = labelRect().size();
    if ( isVertical )
        boundingSize.transpose();
        
    const int w = 
        (boundingSize.width() - (MaxNum - 1) * Spacing) / MaxNum;

    QSize arrow = arrowSize(Qt::RightArrow, 
        QSize(w, boundingSize.height()));

    if ( isVertical )
        arrow.transpose();

    QRect contentsSize; // aligned rect where to paint all arrows
    if ( d_data->arrowType == Qt::LeftArrow || d_data->arrowType == Qt::RightArrow )
    {
        contentsSize.setWidth(d_data->num * arrow.width() 
            + (d_data->num - 1) * Spacing);
        contentsSize.setHeight(arrow.height());
    }
    else
    {
        contentsSize.setWidth(arrow.width());
        contentsSize.setHeight(d_data->num * arrow.height() 
            + (d_data->num - 1) * Spacing);
    }

    QRect arrowRect(contentsSize);
    arrowRect.moveCenter(r.center());
    arrowRect.setSize(arrow);

    p->save();
    for (int i = 0; i < d_data->num; i++)
    {
        drawArrow(p, arrowRect, d_data->arrowType);

        int dx = 0;
        int dy = 0;

        if ( isVertical )
            dy = arrow.height() + Spacing;
        else
            dx = arrow.width() + Spacing;

#if QT_VERSION >= 0x040000
        arrowRect.translate(dx, dy);
#else
        arrowRect.moveBy(dx, dy);
#endif
    }
    p->restore();

    if ( hasFocus() )
    {
#if QT_VERSION >= 0x040000
        QStyleOptionFocusRect option;
        option.init(this);
        option.backgroundColor = palette().color(QPalette::Background);

        style()->drawPrimitive(QStyle::PE_FrameFocusRect, 
            &option, p, this);
#else
        const QRect focusRect =  
            style().subRect(QStyle::SR_PushButtonFocusRect, this);
        style().drawPrimitive(QStyle::PE_FocusRect, p,
            focusRect, colorGroup());
#endif
    }
}
void TrackShirt::ImageCallback(const sensor_msgs::ImageConstPtr& msg)
{
	cv_bridge::CvImagePtr cv_ptr;
	try
	{
	cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
	}
	catch (cv_bridge::Exception& e)
	{
	ROS_ERROR("cv_bridge exception: %s", e.what());
	return;
	}

	frame = cv_ptr->image;

	char key = (char)cvWaitKey(10);
	if (key ==27 )	{
		ros::requestShutdown();
	} else if ( key =='z' )	{
		IMSHOW = true;
		//namedWindow(OPENCV_WINDOW);
	} else if (key == 'x')	{
		IMSHOW =  false;
		cvDestroyAllWindows() ;
		//namedWindow(OPENCV_WINDOW);
	}

	if (trackObject == -1)	{
		//Initial stage, before selecting object. Do nothing. Camera view shown as is.
	} else if (trackObject == 0)	{
		rectangle(frame, Point(selection.x,selection.y),Point(selection.x+selection.width,selection.y+selection.height),Scalar(0,0,255),1);
	} else if (PerFoRoMode == 3)	{
		Mat imgHSV, imgThresh, binFrame;
		int contSize;

		cvtColor(frame, imgHSV, CV_BGR2HSV); 

		//Get binary image using HSV threshold
		inRange(imgHSV, mLowerBound, mUpperBound, imgThresh); 

		//Morphological operations to get smoother blobs with reduced noise                
		dilate( imgThresh, imgThresh, elemDilate );
		erode( imgThresh, imgThresh, elemErode ); 
		dilate( imgThresh, imgThresh, elemDilate );                               
		erode( imgThresh, imgThresh, elemErode );                                                       
		morphologyEx(imgThresh, imgThresh, MORPH_OPEN, structure_elem);  
			  
		imgThresh.copyTo(binFrame);
		vector<vector<Point> > contours;
		vector<Vec4i> hierarchy;
			      
		/// Find contours
		findContours( binFrame, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

		contSize = contours.size();
		//cout<<"contours size "<<contSize<<endl;
				                
		//If no contours 
		if (contSize==0)	{       
			navX = 0;
			navY = 0;
			if (IMSHOW)	{             
				imshow(OPENCV_WINDOW, frame);
				//imshow("Binary Image with Detected Object", imgThresh); 
			}
			return;
		}
				                    
		/// Approximate contours to polygons + get bounding rects 
		vector<vector<Point> > contours_poly( contSize );
		vector<Rect> boundRect( contSize );
				  
		/// Get the moments
		vector<Moments> mu(contSize );
		cv::Mat contArea = Mat::zeros(contSize,1,CV_32FC1);
		for( int i = 0; i < contSize; i++ )
		{ 
			approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );
			boundRect[i] = boundingRect( Mat(contours_poly[i]) );
				     
			mu[i] = moments( contours[i], false );
				     
			contArea.at<float>(i) = contourArea(contours[i]);
		}

		///  Get the mass centers:
		vector<Point2f> mc( contSize );
		for( int i = 0; i < contSize; i++ )
		{ 
			mc[i] = Point2f( mu[i].m10/mu[i].m00 , mu[i].m01/mu[i].m00 );
		}

				
		///Nearest centroid to previous position
		cv::Mat dist = Mat::zeros(contSize,1,CV_32FC1); 
		cv::Mat normDist = Mat::zeros(contSize,1,CV_32FC1);
				
		for( int i = 0; i < contSize; i++ )
		{ 
			dist.at<float>(i) = abs(mc[i].x - selectCentroid.x) + abs(mc[i].y - selectCentroid.y);

			normDist.at<float>(i) = maxDistance - dist.at<float>(i);
		}
				                   
				   
		cv::Mat normSelect= Mat::zeros(contSize,1,CV_32FC1);

		normSelect =  contArea + normDist; //

		cv::Mat sortedSelect = Mat::zeros(contSize,1,CV_32FC1);

		cv::sortIdx(normSelect, sortedSelect, CV_SORT_EVERY_COLUMN+CV_SORT_DESCENDING);
		       
		Point selectPt = mc[sortedSelect.at<int>(0)];

		//If first tracked frame, initialze Kalman
		if (trackObject == 1)	{
			initTracker();
			trackObject = 2;  
		}

		
		//Kalman estimate based on previous state and measurement   
		kalmanEstimatePt = kalmanTracker(selectPt);
		  
		///Distance of object position estimate from previous position
		distPrevCurrent = abs(kalmanEstimatePt.x - selectCentroid.x) + abs(kalmanEstimatePt.y - selectCentroid.y);
		distPrevCurrent = distPrevCurrent / maxDistance;


		if (missCount > 5)	{
			distThresh*=1.5;
		} else	{
			distThresh = minDistThresh;
		}                                               
				        
		/// /////////////////////////////////////////////////////////////
		///Threshold the detected centroid's distance from prev///////////////
		if (distPrevCurrent < distThresh && contArea.at<float>(sortedSelect.at<int>(0)) >= 10)	{
			//Final object position estimate using kalman
			selectCentroid = kalmanEstimatePt;
			if (IMSHOW)	{ 
				rectangle( frame, boundRect[sortedSelect.at<int>(0)], Scalar(255,255,255), 2, 8, 0 );
			}  
			shirt_msg.x = selectCentroid.x;
			shirt_msg.y = selectCentroid.y;
			shirt_msg.area = boundRect[sortedSelect.at<int>(0)].width * boundRect[sortedSelect.at<int>(0)].height;
			track_shirt_pub_.publish(shirt_msg);
			//cout<<"X="<<navX<<"Y="<<navY<<endl; 
			missCount = 0;
			drawArrow(frame, cv::Point(frame.cols/2, frame.rows/2), selectCentroid, Scalar(255,0,0));
		} else	{
			missCount++;
			navX = 0.0;
			navY = 0.0;
		}
	}
	// Update GUI Window
	//if (IMSHOW)	{
	//	imshow(OPENCV_WINDOW, frame);
		///imshow("Binary Image with Detected Object", imgThresh);
	//}
	//cv::waitKey(3);

	// Output modified video stream
	image_shirt_pub_.publish(cv_ptr->toImageMsg());
}
예제 #25
0
/*!*****************************************************************************
 *******************************************************************************
\note  drawFootSensor
\date  April 2013
   
\remarks 

 draws force/torque and acceleration at the foot sensor

 *******************************************************************************
 Function Parameters: [in]=input,[out]=output

 ******************************************************************************/
static void
drawFootSensor(void)

{
  int i,j,n;
  GLfloat   color_point1[4]={(float)1.0,(float)1.0,(float)0.5,(float)opacity};
  GLfloat   color_point2[4]={(float)0.0,(float)1.0,(float)0.5,(float)opacity};
  GLfloat   color_point3[4]={(float)0.0,(float)1.0,(float)1.0,(float)opacity};
  GLfloat   color_point4[4]={(float)0.5,(float)0.5,(float)1.0,(float)opacity};
  double    arrow_width = 0.01;
  double    s[N_CART+1];
  double    e[N_CART+1];
  double    acc_scale = 0.02;
  double    vel_scale = 1;
  double    force_scale  = fscale*0.1;
  double    torque_scale = fscale*2.0;


  glPushMatrix();

  // translate to L_FOOT
  glTranslated(link_pos_sim[L_FOOT][_X_],link_pos_sim[L_FOOT][_Y_],link_pos_sim[L_FOOT][_Z_]);

  // rotate into L_FOOT coordinates
  linkQuat(Alink_sim[L_FOOT],&(cart_orient[LEFT_FOOT]));
  glRotated((GLdouble)2.*acos(cart_orient[LEFT_FOOT].q[_Q0_])/PI*180.,
	    (GLdouble)cart_orient[LEFT_FOOT].q[_Q1_],
	    (GLdouble)cart_orient[LEFT_FOOT].q[_Q2_],
	    (GLdouble)cart_orient[LEFT_FOOT].q[_Q3_]);


  // the start and end point of the acceleration vector
  s[_X_] =  0.0;
  s[_Y_] =  0.0;
  s[_Z_] =  0.0;

  e[_X_] = s[_X_] + misc_sim_sensor[L_FOOT_XACC]*acc_scale;
  e[_Y_] = s[_Y_] + misc_sim_sensor[L_FOOT_YACC]*acc_scale;
  e[_Z_] = s[_Z_] + misc_sim_sensor[L_FOOT_ZACC]*acc_scale;

  glColor4fv(color_point1);
  drawArrow(s,e,arrow_width);

  // the start and end point of the force vector
  s[_X_] =  -ZTOE+FTA_Z_OFF;
  s[_Y_] =  FTA_X_OFF;
  s[_Z_] =  -FTA_Y_OFF;

  e[_X_] = s[_X_] + misc_sim_sensor[L_CFx]*force_scale;
  e[_Y_] = s[_Y_] + misc_sim_sensor[L_CFy]*force_scale;
  e[_Z_] = s[_Z_] + misc_sim_sensor[L_CFz]*force_scale;

  glColor4fv(color_point3);
  drawArrow(s,e,arrow_width);

  // the end point of the torque vector
  e[_X_] = s[_X_] + misc_sim_sensor[L_CTa]*torque_scale;
  e[_Y_] = s[_Y_] + misc_sim_sensor[L_CTb]*torque_scale;
  e[_Z_] = s[_Z_] + misc_sim_sensor[L_CTg]*torque_scale;

  glColor4fv(color_point4);
  drawArrow(s,e,arrow_width);


  glPopMatrix();


  glPushMatrix();

  // translate to R_FOOT
  glTranslated(link_pos_sim[R_FOOT][_X_],link_pos_sim[R_FOOT][_Y_],link_pos_sim[R_FOOT][_Z_]);

  // rotate into L_FOOT coordinates
  linkQuat(Alink_sim[R_FOOT],&(cart_orient[RIGHT_FOOT]));
  glRotated((GLdouble)2.*acos(cart_orient[RIGHT_FOOT].q[_Q0_])/PI*180.,
	    (GLdouble)cart_orient[RIGHT_FOOT].q[_Q1_],
	    (GLdouble)cart_orient[RIGHT_FOOT].q[_Q2_],
	    (GLdouble)cart_orient[RIGHT_FOOT].q[_Q3_]);


  // the start and end point of the acceleration vector
  s[_X_] =  0.0;
  s[_Y_] =  0.0;
  s[_Z_] =  0.0;

  e[_X_] = s[_X_] + misc_sim_sensor[R_FOOT_XACC]*acc_scale;
  e[_Y_] = s[_Y_] + misc_sim_sensor[R_FOOT_YACC]*acc_scale;
  e[_Z_] = s[_Z_] + misc_sim_sensor[R_FOOT_ZACC]*acc_scale;


  glColor4fv(color_point1);
  drawArrow(s,e,arrow_width);

  // the start and end point of the force vector
  s[_X_] =  -ZTOE+FTA_Z_OFF;
  s[_Y_] =  FTA_X_OFF;
  s[_Z_] =  FTA_Y_OFF;

  e[_X_] = s[_X_] + misc_sim_sensor[R_CFx]*force_scale;
  e[_Y_] = s[_Y_] + misc_sim_sensor[R_CFy]*force_scale;
  e[_Z_] = s[_Z_] + misc_sim_sensor[R_CFz]*force_scale;

  glColor4fv(color_point3);
  drawArrow(s,e,arrow_width);

  // the end point of the torque vector
  e[_X_] = s[_X_] + misc_sim_sensor[R_CTa]*torque_scale;
  e[_Y_] = s[_Y_] + misc_sim_sensor[R_CTb]*torque_scale;
  e[_Z_] = s[_Z_] + misc_sim_sensor[R_CTg]*torque_scale;

  glColor4fv(color_point4);
  drawArrow(s,e,arrow_width);




  glPopMatrix();

}
예제 #26
0
void PipelineFlowChart::paintEvent(QPaintEvent *e)
{
  if(m_StageNames.empty())
    return;

  QPainter p(this);

  p.fillRect(rect(), Qt::transparent);

  p.setRenderHint(QPainter::Antialiasing, true);

  const QRectF totalRect = totalAreaRect();
  const QRectF box0Rect = boxRect(0);

  const qreal radius = qMin(MaxBoxCornerRadius, box0Rect.height() * BoxCornerRadiusFraction);

  const qreal arrowY = totalRect.y() + totalRect.height() / 2;

  QColor base = palette().color(QPalette::Base);
  QColor baseText = palette().color(QPalette::Text);
  QColor inactiveWin = palette().color(QPalette::Inactive, QPalette::Dark);
  QColor inactiveWinText = palette().color(QPalette::Inactive, QPalette::WindowText);
  QColor tooltip = palette().color(QPalette::ToolTipBase);
  QColor tooltipText = palette().color(QPalette::ToolTipText);

  QPen pen(baseText);
  QPen selectedPen(Qt::red);

  int num = numGaps();
  for(int i = 0; i < num; i++)
  {
    if(!m_StageFlows[i] || !m_StageFlows[i + 1])
      continue;

    float right = totalRect.x() + (i + 1) * (box0Rect.width() + boxMargin());
    float left = right - boxMargin();

    p.setBrush(baseText);
    drawArrow(p, pen, ArrowHeadSize, arrowY, left, right);
  }

  num = numItems();
  for(int i = 0; i < num; i++)
  {
    QRectF boxrect = boxRect(i);

    QBrush backBrush(base);
    QPen textPen(baseText);
    QPen outlinePen = pen;

    if(!stageEnabled(i))
    {
      backBrush.setColor(inactiveWin);
      textPen.setColor(inactiveWinText);
    }

    if(i == m_HoverStage)
    {
      backBrush.setColor(tooltip);
      textPen.setColor(tooltipText);
    }

    if(i == m_SelectedStage)
    {
      outlinePen = selectedPen;
    }

    outlinePen.setWidthF(BoxBorderWidth);

    p.setPen(outlinePen);
    p.setBrush(backBrush);
    p.drawRoundedRect(boxrect, radius, radius);

    QTextOption opts(Qt::AlignCenter);
    opts.setWrapMode(QTextOption::NoWrap);

    QString s = m_StageNames[i];

    QRectF reqBox = p.boundingRect(QRectF(0, 0, 1, 1), m_StageNames[i], opts);

    if(reqBox.width() + BoxLabelMargin > (float)boxrect.width())
      s = m_StageAbbrevs[i];

    p.setPen(textPen);
    p.drawText(boxrect, s, opts);
  }
}
void AppStage_ComputeTrackerPoses::render()
{
    switch (m_menuState)
    {
    case eMenuState::inactive:
        break;
    case eMenuState::pendingControllerListRequest:
    case eMenuState::pendingControllerStartRequest:
    case eMenuState::pendingTrackerListRequest:
    case eMenuState::pendingTrackerStartRequest:
        break;
    case eMenuState::failedControllerListRequest:
    case eMenuState::failedControllerStartRequest:
    case eMenuState::failedTrackerListRequest:
    case eMenuState::failedTrackerStartRequest:
        break;
    case eMenuState::verifyTrackers:
        {
            render_tracker_video();
        } break;
    case eMenuState::calibrateWithMat:
        m_pCalibrateWithMat->render();
        break;
    case eMenuState::testTracking:
        {
            // Draw the chaperone origin axes
            drawTransformedAxes(glm::mat4(1.0f), 100.f);

            // Draw the frustum for each tracking camera.
            // The frustums are defined in PSMove tracking space.
            // We need to transform them into chaperone space to display them along side the HMD.
            for (t_tracker_state_map_iterator tracker_iter = m_trackerViews.begin(); tracker_iter != m_trackerViews.end(); ++tracker_iter)
            {
                const ClientTrackerView *trackerView = tracker_iter->second.trackerView;
                const PSMovePose trackerPose = trackerView->getTrackerPose();
                const glm::mat4 trackerMat4 = psmove_pose_to_glm_mat4(trackerPose);

                PSMoveFrustum frustum = trackerView->getTrackerFrustum();

				// use color depending on tracking status
				glm::vec3 color= does_tracker_see_any_controller(trackerView) ? k_psmove_frustum_color : k_psmove_frustum_color_no_track;

				drawTextAtWorldPosition(glm::mat4(1.f), psmove_position_to_glm_vec3(trackerPose.Position), "#%d", trackerView->getTrackerId());
                drawTransformedFrustum(glm::mat4(1.f), &frustum, color);

                drawTransformedAxes(trackerMat4, 20.f);
            }

            // Draw the psmove model
			for (t_controller_state_map_iterator controller_iter = m_controllerViews.begin(); controller_iter != m_controllerViews.end(); ++controller_iter)
            {
				const ClientControllerView *controllerView = controller_iter->second.controllerView;
				const PSMoveTrackingColorType trackingColorType= controller_iter->second.trackingColorType;

                PSMovePose controllerPose = controllerView->GetPose();
                glm::mat4 controllerMat4 = psmove_pose_to_glm_mat4(controllerPose);

				if (m_controllerViews.size() > 1)
				{
					drawTextAtWorldPosition(glm::mat4(1.f), psmove_position_to_glm_vec3(controllerPose.Position), "#%d", controllerView->GetControllerID());
				}
                drawController(controllerView, controllerMat4, trackingColorType);
                drawTransformedAxes(controllerMat4, 10.f);

				// Draw the acceleration and velocity arrows
				{
					const PSMovePhysicsData &physicsData = controllerView->GetPhysicsData();
					const glm::mat4 originMat4= glm::translate(glm::mat4(1.f), psmove_position_to_glm_vec3(controllerPose.Position));
					const glm::vec3 vel_endpoint = psmove_float_vector3_to_glm_vec3(physicsData.VelocityCmPerSec);
					const glm::vec3 acc_endpoint = psmove_float_vector3_to_glm_vec3(physicsData.AccelerationCmPerSecSqr)*k_centimeters_to_meters;
					
					const float vel= glm::length(vel_endpoint);
					if (vel > k_positional_epsilon)
					{
						drawArrow(originMat4, glm::vec3(0.f), vel_endpoint, 0.1f, glm::vec3(0.f, 1.f, 1.f));
						//drawTextAtWorldPosition(originMat4, vel_endpoint, "v=%.2fcm/s", vel);
					}

					const float acc = glm::length(acc_endpoint);
					if (acc > k_positional_epsilon)
					{
						drawArrow(originMat4, glm::vec3(0.f), acc_endpoint, 0.1f, glm::vec3(1.f, 1.f, 0.f));
						//drawTextAtWorldPosition(originMat4, acc_endpoint, "a=%.2fm/s^2", acc);
					}
				}
            }

        } break;
	case eMenuState::showTrackerVideo:
		{
			render_tracker_video();
		} break;
    case eMenuState::calibrateStepFailed:
        break;
    default:
        assert(0 && "unreachable");
    }
}
예제 #28
0
void RelatedPacketDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                              const QModelIndex &index) const
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    QStyleOptionViewItemV4 option_vi = option;
#else
    QStyleOptionViewItem option_vi = option;
#endif
    QStyledItemDelegate::initStyleOption(&option_vi, index);
    int em_w = option_vi.fontMetrics.height();
    int en_w = (em_w + 1) / 2;
    int line_w = (option_vi.fontMetrics.lineWidth());

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    option_vi.features |= QStyleOptionViewItemV4::HasDecoration;
#else
    option_vi.features |= QStyleOptionViewItem::HasDecoration;
#endif
    option_vi.decorationSize.setHeight(1);
    option_vi.decorationSize.setWidth(em_w);
    QStyledItemDelegate::paint(painter, option_vi, index);

    guint32 setup_frame = 0, last_frame = 0;
    if (conv_) {
        setup_frame = (int) conv_->setup_frame;
        last_frame = (int) conv_->last_frame;
    }

    const frame_data *fd;
    PacketListRecord *record = static_cast<PacketListRecord*>(index.internalPointer());
    if (!record || (fd = record->frameData()) == NULL) {
        return;
    }

    painter->save();

    if (QApplication::style()->objectName().contains("vista")) {
        // QWindowsVistaStyle::drawControl does this internally. Unfortunately there
        // doesn't appear to be a more general way to do this.
        option_vi.palette.setColor(QPalette::All, QPalette::HighlightedText, option_vi.palette.color(QPalette::Active, QPalette::Text));
    }

    QPalette::ColorGroup cg = option_vi.state & QStyle::State_Enabled
                              ? QPalette::Normal : QPalette::Disabled;
    QColor fg;
    if (cg == QPalette::Normal && !(option_vi.state & QStyle::State_Active))
        cg = QPalette::Inactive;
    if (option_vi.state & QStyle::State_Selected) {
        fg = option_vi.palette.color(cg, QPalette::HighlightedText);
    } else {
        fg = option_vi.palette.color(cg, QPalette::Text);
    }

    fg = ColorUtils::alphaBlend(fg, option_vi.palette.color(cg, QPalette::Base), 0.5);
    QPen line_pen(fg);
    line_pen.setWidth(line_w);
    line_pen.setJoinStyle(Qt::RoundJoin);

    painter->setPen(line_pen);
    painter->translate(option_vi.rect.x(), option_vi.rect.y());
    painter->translate(en_w + 0.5, 0.5);
    painter->setRenderHint(QPainter::Antialiasing, true);
    int height = option_vi.rect.height();

    // Uncomment to make the boundary visible.
//    painter->save();
//    painter->setPen(Qt::darkRed);
//    painter->drawRect(QRectF(0.5, 0.5, en_w - 1, height - 1));
//    painter->restore();

    // The current decorations are based on what looked good and were easy
    // to code.

    // It might be useful to have a JACKPOT_MODE define that shows each
    // decoration in sequence in order to make it easier to create
    // screenshots for the User's Guide.

    // Vertical line. Lower and upper half for the start and end of the
    // conversation respectively, solid for conversation member, dashed
    // for other packets in the start-end range.
    if (setup_frame > 0 && last_frame > 0 && setup_frame != last_frame) {
        if (fd->num == setup_frame) {
            QPoint start_line[] = {
                QPoint(en_w - 1, height / 2),
                QPoint(0, height / 2),
                QPoint(0, height)
            };
            painter->drawPolyline(start_line, 3);
        } else if (fd->num > setup_frame && fd->num < last_frame) {
            painter->save();
            if (conv_ != record->conversation()) {
                QPen other_pen(line_pen);
                other_pen.setStyle(Qt::DashLine);
                painter->setPen(other_pen);
            }
            painter->drawLine(0, 0, 0, height);
            painter->restore();
        } else if (fd->num == last_frame) {
            QPoint end_line[] = {
                QPoint(en_w - 1, height / 2),
                QPoint(0, height / 2),
                QPoint(0, 0)
            };
            painter->drawPolyline(end_line, 3);
        }
    }

    // Related packet indicator. Rightward arrow for requests, leftward
    // arrow for responses, circle for others.
    // XXX These are comically oversized when we have multi-line rows.
    if (related_frames_.contains(fd->num)) {
        painter->setBrush(fg);
        switch (related_frames_[fd->num]) {
        // Request and response arrows are moved forward one pixel in order to
        // maximize white space between the heads and the conversation line.
        case FT_FRAMENUM_REQUEST:
        {
            int hh = height / 2;
            QPoint tail(2 - en_w, hh);
            QPoint head(en_w, hh);
            drawArrow(painter, tail, head, hh / 2);
            break;
        }
        case FT_FRAMENUM_RESPONSE:
        {
            int hh = height / 2;
            QPoint tail(en_w - 1, hh);
            QPoint head(1 - en_w, hh);
            drawArrow(painter, tail, head, hh / 2);
            break;
        }
        case FT_FRAMENUM_ACK:
        {
            QRect bbox (2 - en_w, height / 3, em_w - 2, height / 2);
            drawCheckMark(painter, bbox);
            break;
        }
        case FT_FRAMENUM_DUP_ACK:
        {
            QRect bbox (2 - en_w, (height / 3) - (line_w * 2), em_w - 2, height / 2);
            drawCheckMark(painter, bbox);
            bbox.moveTop(bbox.top() + (line_w * 3));
            drawCheckMark(painter, bbox);
            break;
        }
        case FT_FRAMENUM_NONE:
        default:
            painter->drawEllipse(QPointF(0.0, option_vi.rect.height() / 2), 2, 2);
        }
    }

    painter->restore();
}
예제 #29
0
void ofxGuiArrow::draw() {
	// TODO
	drawArrow( mDirection );
}
예제 #30
0
파일: draw.c 프로젝트: vedantsonu/Carrom
void display(void)
{
double incAngle;
double tRadius = 0.2f;
double tempPar = 2.2f;

double tempPar2;
double xtemp;

xtemp = magnitude(1.2f,1.2f) + tRadius;
tempPar2 = magnitude(tempPar,tempPar);
incAngle = 1.0f/180.0f * PI;
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity ();

glPushMatrix();
    glRotatef((playerNo * 90), 0 , 0 , 1.0);
if(playerNo == 0){    
	glTranslatef(0,0.1,-6);
}else if(playerNo ==  1){
	glTranslatef(0.1,0,-6);
}else if(playerNo == 2){
glTranslatef(0,-0.1,-6);
}else{
glTranslatef(-0.1,0,-6);
}
	


    glDepthRange (0.8, 1.0);
    glColor3f(0.984375f,0.89453125f,0.73046875f);

// Main Board
    glBegin(GL_POLYGON);

        glVertex3f(2.5,2.5,0);
        glVertex3f(-2.5,2.5,0);
        glVertex3f(-2.5,-2.5,0);
        glVertex3f(2.5,-2.5,0);

    glEnd();

    glDepthRange (0.5, 0.8);

    glColor3f(0,0,0);

// Carrom lines

	glLineWidth(4.0f);
    glBegin(GL_LINES);

	
        glVertex3f(1.9,2.19,0);
        glVertex3f(-1.9,2.19,0);

        glVertex3f(1.9,-2.19,0);
        glVertex3f(-1.9,-2.19,0);

        glVertex3f(-2.19,1.9,0);
        glVertex3f(-2.19,-1.9,0);

        glVertex3f(2.19,1.9,0);
        glVertex3f(2.19,-1.9,0);
              
    glEnd();

	
	glLineWidth(1.5f);
    glBegin(GL_LINES);
	
        glVertex3f(1.9,2.02,0);
        glVertex3f(-1.9,2.02,0);

        glVertex3f(1.9,-2.02,0);
        glVertex3f(-1.9,-2.02,0);

        glVertex3f(-2.02,1.9,0);
        glVertex3f(-2.02,-1.9,0);

        glVertex3f(2.02,1.9,0);
        glVertex3f(2.02,-1.9,0);
              
    glEnd();
	
// Holes ...
static double angle = 0;
    	glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(2.3933,2.3933);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(2.3933 + sin(angle) * 0.107, 2.3933 + cos(angle) * 0.107);
 	 }
 	 glEnd();

 	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(-2.3933,2.3933);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(-2.3933 + sin(angle) * 0.107, 2.3933+ cos(angle) * 0.107);
 	 }
 	 glEnd();

 	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(-2.3933,-2.3933);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(-2.3933 + sin(angle) * 0.107 , -2.3933 + cos(angle) * 0.107);
 	 }
 	 glEnd();

 	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(2.3933,-2.3933);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(2.3933 + sin(angle) * 0.107, -2.3933 + cos(angle) * 0.107);
 	 }
 	 glEnd();

// Striker
	glDepthRange(0.0f,0.1f);
	glColor3f(1.0f/255.0f,108.0f/255.0f,178.0f/255.0f);
	if(striker.visible == 1)
{
    	glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(striker.X,striker.Y);
 for( angle = 0 ; angle <= 2 * PI + incAngle ; angle=angle + incAngle ){
	 glVertex2f(striker.X + sin(angle) * striker.radius, striker.Y + cos(angle) * striker.radius);
 	 }
 	 glEnd();
}
// Carrom Coins
	glColor3f(216.0f/255.0f,145.0f/255.0f,65.0f/255.0f); 
int t=0;
for(t=0;t < 2; t++){
if(coin[t].visible == 1){
	 glBegin(GL_TRIANGLE_FAN);
	glVertex2f(coin[t].X,coin[t].Y);
 for( angle = 0 ; angle <= 2 * PI + incAngle ; angle=angle + incAngle ){
	 glVertex2f(coin[t].X + sin(angle) * coin[t].radius, coin[t].Y + cos(angle) * coin[t].radius);
 	 }
 	 glEnd();	 
}
}
glColor3f(147.0f/255.0f,1.0/255.0f,138.0f/255.0f); 
if(coin[t].visible == 1){
	 glBegin(GL_TRIANGLE_FAN);
	glVertex2f(coin[t].X,coin[t].Y);
 for( angle = 0 ; angle <= 2 * PI + incAngle ; angle=angle + incAngle ){
	 glVertex2f(coin[t].X + sin(angle) * coin[t].radius, coin[t].Y + cos(angle) * coin[t].radius);
 	 }
 	 glEnd();	 
}
glColor3f(0,0,0); 
for(t=2;t < totalCoins; t++){
if(coin[t].visible == 1){
	 glBegin(GL_TRIANGLE_FAN);
	glVertex2f(coin[t].X,coin[t].Y);
 for( angle = 0 ; angle <= 2 * PI + incAngle ; angle=angle + incAngle ){
	 glVertex2f(coin[t].X + sin(angle) * coin[t].radius, coin[t].Y + cos(angle) * coin[t].radius);
 	 }
 	 glEnd();	 
}
}

// Carrom Centre circles
	 glDepthRange(0.4f,0.5f);
	 glColor3f(0.811764706f,0.168627451f,0.062745098f);
	 glLineWidth(0.1f);
 	 glBegin(GL_LINES);
 	 //glVertex2f(0,0)
	 for( angle = 0 ; angle < 360 ; angle=angle + 1 ){
	 glVertex2f(0 + sin(angle) * 0.6, 0 + cos(angle) * 0.6);
 	 }
 	 glEnd();

 	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(0,0);
	 for( angle = 0 ; angle < 360 ; angle=angle + 1 ){
	 glVertex2f(0 + sin(angle) * 0.1, 0 + cos(angle) * 0.1);
 	 }
 	 glEnd();

// Carrom lines(orange circles)
    	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(-1.91,-2.1);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(-1.91 + sin(angle) * 0.07, -2.1 + cos(angle) * 0.07);
 	 }
 	 glEnd();
		
	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(1.91,-2.1);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(1.91 + sin(angle) * 0.07, -2.1 + cos(angle) * 0.07);
 	 }
 	 glEnd();

	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(-1.91,2.1);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(-1.91 + sin(angle) * 0.07, 2.1 + cos(angle) * 0.07);
 	 }
 	 glEnd();

	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(1.91,2.1);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(1.91 + sin(angle) * 0.07, 2.1 + cos(angle) * 0.07);
 	 }
 	 glEnd();
	
  	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(-2.1,-1.91);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(-2.1  + sin(angle) * 0.07, -1.91 + cos(angle) * 0.07);
 	 }
 	 glEnd();

  	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(-2.1,1.91);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(-2.1  + sin(angle) * 0.07, 1.91 + cos(angle) * 0.07);
 	 }
 	 glEnd();
  	 
	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(2.1,1.91);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(2.1  + sin(angle) * 0.07, 1.91 + cos(angle) * 0.07);
 	 }
 	 glEnd();
  	 
	 glBegin(GL_TRIANGLE_FAN);
 	 glVertex2f(2.1,-1.91);
	 for( angle = 0 ; angle <= 2 * PI + 5*incAngle ; angle=angle + 5 * incAngle ){
	 glVertex2f(2.1  + sin(angle) * 0.07, -1.91 + cos(angle) * 0.07);
 	 }
 	 glEnd();

// Carrom centre triangles
 	 glBegin(GL_TRIANGLES);
 	 glVertex2f(-0.05f,0.11f);
	 glVertex2f(0.05f,0.11f);
	 glVertex2f(0.0f,0.6f); 

         glVertex2f(-0.05f,-0.11f);
	 glVertex2f(0.05f,-0.11f);
	 glVertex2f(0.0f,-0.6f);

	 glVertex2f(0.11f,-0.05f);
	 glVertex2f(0.11f,0.05f);
	 glVertex2f(0.6f,0.0f); 
 
	 glVertex2f(-0.11f,-0.05f);
	 glVertex2f(-0.11f,0.05f);
	 glVertex2f(-0.6f,0.0f); 
	 glEnd();

// Carrom line circles (outer periphery encircling red circles)
	 glColor3f(0,0,0);
	 glLineWidth(1.6f);
    	 glBegin(GL_LINE_STRIP);
 	 glVertex2f(-1.91,-2.1);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(-1.91 + sin(angle) * 0.09, -2.1 + cos(angle) * 0.09);
 	 }
 	 glEnd();

	 glBegin(GL_LINE_STRIP);
 	 glVertex2f(1.91,-2.1);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(1.91 + sin(angle) * 0.09, -2.1 + cos(angle) * 0.09);
 	 }
 	 glEnd();

	 glBegin(GL_LINE_STRIP);
 	 glVertex2f(-1.91,2.1);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(-1.91 + sin(angle) * 0.09, 2.1 + cos(angle) * 0.09);
 	 }
 	 glEnd();

    	 glBegin(GL_LINE_STRIP);
 	 glVertex2f(1.91,2.1);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(1.91 + sin(angle) * 0.09, 2.1 + cos(angle) * 0.09);
 	 }
 	 glEnd();

    	 glBegin(GL_LINE_STRIP);
 	 glVertex2f(2.1,1.91);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(2.1 + sin(angle) * 0.09, 1.91 + cos(angle) * 0.09);
 	 }
 	 glEnd();
	 
	 glBegin(GL_LINE_STRIP);
 	 glVertex2f(-2.1,1.91);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(-2.1 + sin(angle) * 0.09, 1.91 + cos(angle) * 0.09);
 	 }
 	 glEnd();

    	 glBegin(GL_LINE_STRIP);
 	 glVertex2f(2.1,-1.91);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(2.1 + sin(angle) * 0.09, -1.91 + cos(angle) * 0.09);
 	 }
 	 glEnd();

    	 glBegin(GL_LINE_STRIP);
 	 glVertex2f(-2.1,-1.91);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(-2.1 + sin(angle) * 0.09, -1.91 + cos(angle) * 0.09);
 	 }
 	 glEnd();	

 // Tangential circles
    	 glBegin(GL_LINE_STRIP);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(-2.005 + sin(angle) * 0.045, -2.005 + cos(angle) * 0.045);
 	 }
 	 glEnd();
	
	    	 glBegin(GL_LINE_STRIP);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(2.005 + sin(angle) * 0.045, -2.005 + cos(angle) * 0.045);
 	 }
 	 glEnd();

    	 glBegin(GL_LINE_STRIP);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(-2.005 + sin(angle) * 0.045, 2.005 + cos(angle) * 0.045);
 	 }
 	 glEnd();

    	 glBegin(GL_LINE_STRIP);
	 for( angle = 0 ; angle <= 2 * PI  ; angle=angle + 5 * incAngle ){
	 glVertex2f(2.005 + sin(angle) * 0.045, 2.005 + cos(angle) * 0.045);
 	 }
 	 glEnd();
	glPushMatrix();
	glRotatef(45.0f,0,0,1.0f);
 	 glBegin(GL_TRIANGLES);
 	 glVertex2f(-0.05f,0.11f);
	 glVertex2f(0.05f,0.11f);
	 glVertex2f(0.0f,0.6f); 

         glVertex2f(-0.05f,-0.11f);
	 glVertex2f(0.05f,-0.11f);
	 glVertex2f(0.0f,-0.6f);

	 glVertex2f(0.11f,-0.05f);
	 glVertex2f(0.11f,0.05f);
	 glVertex2f(0.6f,0.0f); 
 
	 glVertex2f(-0.11f,-0.05f);
	 glVertex2f(-0.11f,0.05f);
	 glVertex2f(-0.6f,0.0f); 
	 glEnd();
	glPopMatrix();
	 

	 glLineWidth(2.0f);
         glBegin(GL_LINES);
	 glVertex2f(-tempPar,-tempPar);
	 glVertex2f(-1.2f,-1.2f);

	 glVertex2f(-tempPar,tempPar);
	 glVertex2f(-1.2f,1.2f);
		
	 glVertex2f(tempPar,-tempPar);
	 glVertex2f(1.2f,-1.2f);
	 
	 glVertex2f(tempPar,tempPar);
	 glVertex2f(1.2f,1.2f);

	 glEnd();


	 glPushMatrix();
	 glRotatef(45.0f,0,0,1);
	 glBegin(GL_TRIANGLES);
	 glVertex2f(0.0f,-tempPar2 - 0.07f);
	 glVertex2f(0.03f,-tempPar2);
	 glVertex2f(-0.03f,-tempPar2);
	   
         glVertex2f(0.0f,tempPar2 + 0.07f);
	 glVertex2f(0.03f,tempPar2-0.001f);
	 glVertex2f(-0.03f,tempPar2-0.001f);
	 glEnd();
	 glRotatef(-90.0f,0,0,1);	 
	glBegin(GL_TRIANGLES);
	 glVertex2f(0.0f,-tempPar2 - 0.07f);
	 glVertex2f(0.03f,-tempPar2);
	 glVertex2f(-0.03f,-tempPar2);
	   
         glVertex2f(0.0f,tempPar2 + 0.07f);
	 glVertex2f(0.03f,tempPar2-0.001f);
	 glVertex2f(-0.03f,tempPar2-0.001f);
	 glEnd();
	 glPopMatrix();

	 glLineWidth(1.5f);

glPushMatrix(); 
	 glRotatef(45,0,0,1);
	 glBegin(GL_LINE_STRIP);
	 for( angle = 50 ; angle <= 310 ; angle=angle + 1 ){
	 glVertex2f(xtemp+ cos(angle/180.0f * PI ) * tRadius,  sin(angle/180.0f * PI) * tRadius);
 	 }
         glEnd();

	 glBegin(GL_TRIANGLES);

	 glVertex2f(xtemp +  (tRadius) * cos(25/180.0f * PI) , (tRadius) * sin(25/180.0f * PI) );	 
         glVertex2f(xtemp +  (tRadius+0.03f) * cos(50/180.0f * PI) , (tRadius+0.03f) * sin(50/180.0f * PI) );
	 glVertex2f(xtemp +  (tRadius-0.03f) * cos(50/180.0f * PI) , (tRadius-0.03f) * sin(50/180.0f * PI) );

         glVertex2f(xtemp +  (tRadius) * cos(335/180.0f * PI) , (tRadius) * sin(335/180.0f * PI) );	 
         glVertex2f(xtemp +  (tRadius+0.03f) * cos(310/180.0f * PI) , (tRadius+0.03f) * sin(310/180.0f * PI) );
	 glVertex2f(xtemp +  (tRadius-0.03f) * cos(310/180.0f * PI) , (tRadius-0.03f) * sin(310/180.0f * PI) );

	 glEnd();

		 glRotatef(90,0,0,1);
	 glBegin(GL_LINE_STRIP);
	 for( angle = 50 ; angle <= 310 ; angle=angle + 1 ){
	 glVertex2f(xtemp+ cos(angle/180.0f * PI ) * tRadius,  sin(angle/180.0f * PI) * tRadius);
 	 }
         glEnd();

	 glBegin(GL_TRIANGLES);

	 glVertex2f(xtemp +  (tRadius) * cos(25/180.0f * PI) , (tRadius) * sin(25/180.0f * PI) );	 
         glVertex2f(xtemp +  (tRadius+0.03f) * cos(50/180.0f * PI) , (tRadius+0.03f) * sin(50/180.0f * PI) );
	 glVertex2f(xtemp +  (tRadius-0.03f) * cos(50/180.0f * PI) , (tRadius-0.03f) * sin(50/180.0f * PI) );

         glVertex2f(xtemp +  (tRadius) * cos(335/180.0f * PI) , (tRadius) * sin(335/180.0f * PI) );	 
         glVertex2f(xtemp +  (tRadius+0.03f) * cos(310/180.0f * PI) , (tRadius+0.03f) * sin(310/180.0f * PI) );
	 glVertex2f(xtemp +  (tRadius-0.03f) * cos(310/180.0f * PI) , (tRadius-0.03f) * sin(310/180.0f * PI) );

	 glEnd();

		 glRotatef(90,0,0,1);
	 glBegin(GL_LINE_STRIP);
	 for( angle = 50 ; angle <= 310 ; angle=angle + 1 ){
	 glVertex2f(xtemp+ cos(angle/180.0f * PI ) * tRadius,  sin(angle/180.0f * PI) * tRadius);
 	 }
         glEnd();

	 glBegin(GL_TRIANGLES);

	 glVertex2f(xtemp +  (tRadius) * cos(25/180.0f * PI) , (tRadius) * sin(25/180.0f * PI) );	 
         glVertex2f(xtemp +  (tRadius+0.03f) * cos(50/180.0f * PI) , (tRadius+0.03f) * sin(50/180.0f * PI) );
	 glVertex2f(xtemp +  (tRadius-0.03f) * cos(50/180.0f * PI) , (tRadius-0.03f) * sin(50/180.0f * PI) );

         glVertex2f(xtemp +  (tRadius) * cos(335/180.0f * PI) , (tRadius) * sin(335/180.0f * PI) );	 
         glVertex2f(xtemp +  (tRadius+0.03f) * cos(310/180.0f * PI) , (tRadius+0.03f) * sin(310/180.0f * PI) );
	 glVertex2f(xtemp +  (tRadius-0.03f) * cos(310/180.0f * PI) , (tRadius-0.03f) * sin(310/180.0f * PI) );

	 glEnd();

		 glRotatef(90,0,0,1);
	 glBegin(GL_LINE_STRIP);
	 for( angle = 50 ; angle <= 310 ; angle=angle + 1 ){
	 glVertex2f(xtemp+ cos(angle/180.0f * PI ) * tRadius,  sin(angle/180.0f * PI) * tRadius);
 	 }
         glEnd();

	 glBegin(GL_TRIANGLES);

	 glVertex2f(xtemp +  (tRadius) * cos(25/180.0f * PI) , (tRadius) * sin(25/180.0f * PI) );	 
         glVertex2f(xtemp +  (tRadius+0.03f) * cos(50/180.0f * PI) , (tRadius+0.03f) * sin(50/180.0f * PI) );
	 glVertex2f(xtemp +  (tRadius-0.03f) * cos(50/180.0f * PI) , (tRadius-0.03f) * sin(50/180.0f * PI) );

         glVertex2f(xtemp +  (tRadius) * cos(335/180.0f * PI) , (tRadius) * sin(335/180.0f * PI) );	 
         glVertex2f(xtemp +  (tRadius+0.03f) * cos(310/180.0f * PI) , (tRadius+0.03f) * sin(310/180.0f * PI) );
	 glVertex2f(xtemp +  (tRadius-0.03f) * cos(310/180.0f * PI) , (tRadius-0.03f) * sin(310/180.0f * PI) );

	 glEnd();
glPopMatrix();	
	 
	
	 
	if(control == 1 ){
	double dX = (((mx-(width/2.0f)) * 2.5f) / (width/2.0f));
	double dY = (-((my-(height/2.0f)) * 2.5f) / (height/2.0f) );
	double temp = dX;
	if(playerNo == 1)
	{
	dX = dY;
	dY = -temp;
	}else if(playerNo == 2)
	{
	dX = -dX;
	dY = -dY;
	}else if(playerNo == 3)
	{
	dX = -dY;
	dY = temp;
	}
	drawArrow(2.9f,striker.X,striker.Y, dX -striker.X , dY -  striker.Y);
	}
glPopMatrix();
    glTranslatef(0,0.1,-6);
    glDepthRange (0.8, 1.0);
	drawPowerBar();
 RGB col;
col.r = 1.0f;
col.g = 1.0f;
col.b = 1.0f;
char pr[100];
sprintf(pr,"Power ");
RenderString(-2.6f, -2.69f, GLUT_BITMAP_TIMES_ROMAN_24, pr,col);

    glutSwapBuffers();



}