示例#1
0
void QGLWindow::renderFace() {
  // calculate the ratio of between the original image and the rendered image
  float ratio = static_cast<float>(m_width)
                /static_cast<float>(m_renderedImage.width());

  // scale and set the new origin for each ellipse
  // in order to draw it on top of the face

  drawEllipse(m_face.face.scale(ratio).setOrigin(m_posX, -m_posY));
  drawEllipse(m_face.eyes[0].scale(ratio).setOrigin(m_posX, -m_posY));
  drawEllipse(m_face.eyes[1].scale(ratio).setOrigin(m_posX, -m_posY));
  drawEllipse(m_face.smile.scale(ratio).setOrigin(m_posX, -m_posY));
}
示例#2
0
void TipsPainter::drawVelocityDots(const BallTraj& traj)
{
	QListIterator<Mark> it(traj.velMarks);
	while(it.hasNext())
	{
		Mark item = it.next();
		if (!item.isNull())
		{
			drawEllipse(round(item), 2,2); 
			drawEllipse(round(item), 3,3); 
			//drawBall(Ball(round(item),traj.radius,traj.type,0), true);
		}
	}
}
示例#3
0
static void
eyeLiner(EyesWidget	w,
	 Boolean	draw,
	 int		num)
{
    drawEllipse(w, draw ? PART_OUTLINE : PART_SHAPE,
		EYE_X(num), EYE_Y(num),
		TPOINT_NONE, TPOINT_NONE,
		EYE_DIAM + 2.0*EYE_THICK);
    if (draw) {
	drawEllipse(w, PART_CENTER, EYE_X(num), EYE_Y(num),
		    TPOINT_NONE, TPOINT_NONE,
		    EYE_DIAM);
    }
}
void MapStorage::renderGrid(void)
{
    int wc, hc;
    wc = (int)(xMax/cellSz);
    hc = (int)(yMax/cellSz);
    assert(wc > 0);
    assert(hc > 0);
    map->info.width = wc;
    map->info.height = hc;
    assert(wc*hc < 100000000);
    map->data.resize(wc*hc);
    *distMap = *map;
    *inflMap = *map;

    if(cr!=nullptr)
        cairo_destroy(cr);
    if(surface!=nullptr)
        cairo_surface_destroy(surface);
    
    surface = cairo_image_surface_create (CAIRO_FORMAT_A8, wc, hc);
    cr = cairo_create (surface);
    
    for(int i = 0; i<wallSt.size(); i++)
        drawWall(wallSt[i].x0, wallSt[i].y0, wallSt[i].x1, wallSt[i].y1, wallSt[i].thickness);
    for(int i = 0; i<lineSt.size(); i++)
        drawWall(lineSt[i].x0, lineSt[i].y0, lineSt[i].x1, lineSt[i].y1, lineSt[i].thickness);
    for(int i = 0; i<ellipseSt.size(); i++)
        drawEllipse(ellipseSt[i].x, ellipseSt[i].y, ellipseSt[i].a, ellipseSt[i].b, ellipseSt[i].th);
    
    unsigned char *data = cairo_image_surface_get_data (surface);
    map->data.assign(data, data+(wc*hc));
    renderDistMap();
    renderInflMap();
}
示例#5
0
void MainWindow::drawEllipse(){
    ui->graphicsView->setScene(scene);
    item3 = new ellipse;
    scene->addItem(item3);
    qDebug() << "Ellipse Created";
    connect(item3, SIGNAL(DrawFinished()), this, SLOT(drawEllipse()));
}
void ImageGeneratorSource::process()
    {
    if ((int)mSize[0] != property("width").toInt())
        {
        mImageFrame.release();
        mSize[0] = property("width").toInt();
        }
    if ((int)mSize[1] != property("height").toInt())
        {
        mImageFrame.release();
        mSize[1] = property("height").toInt();
        }

    // Create an image
    if (!mImageFrame.isEmpty())
        emit processingCompleted();
    else
        {
        mImageFrame.resize(mSize);
        mImageFrame.clear();

        // Make a square
        ColorImageFrame::ImageType::IndexType pixelIndex;
        ColorImageFrame::PixelType pixel;
        pixel[0] = 255;
        pixel[1] = 0;
        pixel[2] = 0;
        for (pixelIndex[0] = 0; pixelIndex[0] < (int)mSize[0]; ++pixelIndex[0])
            for (pixelIndex[1] = 0; pixelIndex[1] < (int)mSize[1]; ++pixelIndex[1])
                if (drawEllipse((double)pixelIndex[0]/(double)mSize[0], (double)pixelIndex[1]/(double)mSize[1]))
                    ((ColorImageFrame::ImageType::Pointer)mImageFrame)->SetPixel(pixelIndex, pixel);

        emit framesReady();
        }
    }
示例#7
0
static void infoData (pScene sc, pMesh mesh, int k, int typel) {
	pSolution ps;

	if (!mesh->nbb) return;

	ps = &mesh->sol[k];
	if (mesh->nfield == 1) {
		fprintf(stdout, "  Data (scalar): %f\n", ps->bb);
	} else if (mesh->nfield == mesh->dim) {
		fprintf(stdout, "  Data (vector): %f %f", ps->m[0], ps->m[1]);
		if (mesh->dim == 3) fprintf(stdout, " %f", ps->m[2]);

		fprintf(stdout, "\n");
	} else if (mesh->dim == 2 && mesh->nfield == 3) {
		fprintf(stdout, "  Data (tensor): %f %f %f\n",
		        ps->m[0], ps->m[1], ps->m[2]);
		drawEllipse(sc, mesh, typel, k);
	} else if (mesh->dim == 3 && mesh->nfield == 6) {
		if (mesh->ne)
			fprintf(stdout, "  Data (tensor): %f %f %f %f %f %f\n",
			        ps->m[0], ps->m[1], ps->m[2], ps->m[3], ps->m[4], ps->m[5]);

		drawEllipsoid(sc, mesh, typel, k);
	}

	fflush(stdout);	/* add J. Morice 12/2008 */
}
示例#8
0
void SkyQPainter::drawPointSource(const QPointF& pos, float size, char sp)
{
    int isize = qMin(static_cast<int>(size), 14);
    if( !m_vectorStars || starColorMode == 0  ) {
        // Draw stars as bitmaps, either because we were asked to, or because we're painting real colors
        QPixmap* im = imageCache[ harvardToIndex(sp) ][isize];
        float offset = 0.5 * im->width();
        drawPixmap( QPointF(pos.x()-offset, pos.y()-offset), *im );
    }
    else {
        // Draw stars as vectors, for better printing / SVG export etc.
        if ( starColorMode != 4 ) {
            setPen( m_starColor );
            setBrush( m_starColor );
        }
        else {
            // Note: This is not efficient, but we use vector stars only when plotting SVG, not when drawing the skymap, so speed is not very important.
            QColor c = ColorMap.value( sp, Qt::white );
            setPen( c );
            setBrush( c );
        }

        // Be consistent with old raster representation
        if( size > 14 )
            size = 14;
        if( size >= 2 )
            drawEllipse( pos.x() - 0.5 * size, pos.y() - 0.5 * size, int(size), int(size) );
        else if( size >= 1 )
            drawPoint( pos.x(), pos.y() );
    }
}
示例#9
0
	void drawControlPoints(){
		glColor3f(1.0f, 0.0f, 0.0f);
		for (int i = 0; i < numberOfPoints; i++){
			drawEllipse(points[i].pos, 1.0f, 1.0f);

		}
	}
示例#10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);
    setWindowTitle(tr("GD CAD"));
    newFile();

    qApp->installEventFilter(this);
//    scene =  new QGraphicsScene;

    /*or(int x = 0; x <= ui->graphicsView->width(); x += 10){
        scene->addLine(x,0,x,ui->graphicsView->height(),QPen(Qt::green));
    }
    for(int y = 0; y <= ui->graphicsView->height(); y += 10){
        scene->addLine(0,y,ui->graphicsView->width(),y,QPen(Qt::green));
    }

    for(int x = 10; x <= ui->graphicsView->width(); x += 100){
        scene->addLine(x,0,x,ui->graphicsView->height(),QPen(Qt::darkGreen));
    }

    for(int y = 10; y <= ui->graphicsView->height(); y += 100){
        scene->addLine(0,y,ui->graphicsView->width(),y,QPen(Qt::darkGreen));
    }

    ui->graphicsView->setScene(scene);*/

    connect(ui->pointButton, SIGNAL(clicked()), this, SLOT(drawPoint()));
    connect(ui->lineButton, SIGNAL(clicked()), this, SLOT(drawLine()));
    connect(ui->circleButton, SIGNAL(clicked()), this, SLOT(drawCircle()));
    connect(ui->ellipseButton, SIGNAL(clicked()), this, SLOT(drawEllipse()));

    connect(ui->actionPoints, SIGNAL(triggered()), this, SLOT(drawPoint()));
    connect(ui->actionLine, SIGNAL(triggered()), this, SLOT(drawLine()));
    connect(ui->actionCircle, SIGNAL(triggered()), this, SLOT(drawCircle()));
    connect(ui->actionEllipse, SIGNAL(triggered()), this, SLOT(drawEllipse()));

    connect(actionNew, SIGNAL(triggered()), this, SLOT(newFile()));
    connect(actionQuit, SIGNAL(triggered()), this, SLOT(close()));
    connect(actionNew, SIGNAL(triggered()), this, SLOT(newFile()));
    connect(actionQuit, SIGNAL(triggered()), this, SLOT(close()));
    connect(actionPrint, SIGNAL(triggered()), this, SLOT(filePrint()));
    connect(actionPrintPreview, SIGNAL(triggered()), this, SLOT(filePrintPreview()));

}
void FieldPainter::drawBallRR (const BallInfo &ball, const AbsCoord &robot)
{
   save ();
   translateRR(ball.rr, robot);
   setPen (QColor ("black"));
   setBrush(QBrush(QColor(255, 127, 0)));
   drawEllipse (QPoint(0, 0), 40, 40);
   restore ();
}
void FieldPainter::drawPostAbs (const AbsCoord &post, QColor colour)
{
   save();
   translate(post.x(), post.y());
   setPen("white");
   setBrush(colour);
   drawEllipse (QPoint(0, 0), 80, 80);
   restore();
}
示例#13
0
文件: load81.c 项目: r043v/load81
int ellipseBinding(lua_State *L) {
    int x,y,rx,ry;

    x = lua_tonumber(L,-4);
    y = lua_tonumber(L,-3);
    rx = lua_tonumber(L,-2);
    ry = lua_tonumber(L,-1);
    drawEllipse(l81.fb,x,y,rx,ry,l81.r,l81.g,l81.b,l81.alpha);
    return 0;
}
示例#14
0
void GraphicsContext::drawRaisedEllipse(const FloatRect& rect, const Color& ellipseColor, const Color& shadowColor)
{
    if (paintingDisabled())
        return;

    save();

    setStrokeColor(shadowColor);
    setFillColor(shadowColor);

    drawEllipse(FloatRect(rect.x(), rect.y() + 1, rect.width(), rect.height()));

    setStrokeColor(ellipseColor);
    setFillColor(ellipseColor);

    drawEllipse(rect);  

    restore();
}
示例#15
0
static void
eyeBall(EyesWidget	w,
	Boolean draw,
	TPoint	*old,
	int	num)
{
    drawEllipse(w, draw ? PART_PUPIL : PART_CLEAR,
		w->eyes.pupil[num].x, w->eyes.pupil[num].y,
		old ? old->x : TPOINT_NONE, old ? old->y : TPOINT_NONE,
		BALL_DIAM);
}
示例#16
0
task main()
{

	//varibles!!!!!!!!
	int offset = 10;
	int noseOffset = 0;


	//draws a mouth
	drawRect(5 + offset,12,65 + offset,8);

	//
	//draws eyes
	//

	//left
	drawEllipse(10 + offset,50,20 + offset,35);
	//right
	drawEllipse(50 + offset,50,60 + offset,35);

	while (true)
	{
		if (noseOffset == 0)
		{
			noseOffset = 5;
		}
		else
		{
			noseOffset = 0;
		}

		//draws nose
		drawEllipse(30 + offset,30 + noseOffset,40 + offset,20 + noseOffset);

		wait1Msec(1000);

		eraseEllipse(30 + offset,30 + noseOffset,40 + offset,20 + noseOffset);

	}

}
void FieldPainter::drawBallPosAbs(const AbsCoord &ball, QColor colour)
{
   save();
   QPoint newBall = QPoint(ball.x(), ball.y());
   QPen absPen(colour);
   setPen(absPen);
   setBrush(QBrush(colour));
   drawEllipse(newBall, 40, 40);
   restore();

   drawAbsCovEllipse(ball, absPen);
}
示例#18
0
bool SkyQPainter::drawPlanet(KSPlanetBase* planet)
{
    if( !m_proj->checkVisibility(planet) ) return false;

    bool visible = false;
    QPointF pos = m_proj->toScreen(planet,true,&visible);
    if( !visible || !m_proj->onScreen(pos) ) return false;

    float fakeStarSize = ( 10.0 + log10( Options::zoomFactor() ) - log10( MINZOOM ) ) * ( 10 - planet->mag() ) / 10;
    if( fakeStarSize > 15.0 )
        fakeStarSize = 15.0;

    float size = planet->angSize() * dms::PI * Options::zoomFactor()/10800.0;
    if( size < fakeStarSize && planet->name() != "Sun" && planet->name() != "Moon" ) {
        // Draw them as bright stars of appropriate color instead of images
        char spType;
        //FIXME: do these need i18n?
        if( planet->name() == i18n("Mars") ) {
            spType = 'K';
        } else if( planet->name() == i18n("Jupiter") || planet->name() == i18n("Mercury") || planet->name() == i18n("Saturn") ) {
            spType = 'F';
        } else {
            spType = 'B';
        }
        drawPointSource(pos,fakeStarSize,spType);
    } else {
        float sizemin = 1.0;
        if( planet->name() == "Sun" || planet->name() == "Moon" )
            sizemin = 8.0;

        float size = planet->angSize() * dms::PI * Options::zoomFactor()/10800.0;
        if( size < sizemin )
            size = sizemin;
        if( Options::showPlanetImages() && !planet->image().isNull() ) {
            //Because Saturn has rings, we inflate its image size by a factor 2.5
            if( planet->name() == "Saturn" )
                size = int(2.5*size);
            // Scale size exponentially so it is visible at large zooms
            else if (planet->name() == "Pluto")
                size = int(size*exp(1.5*size));

            save();
            translate(pos);
            rotate( m_proj->findPA( planet, pos.x(), pos.y() ) );
            drawImage( QRect(-0.5*size, -0.5*size, size, size),
                       planet->image() );
            restore();
        } else { //Otherwise, draw a simple circle.
            drawEllipse( pos, size, size );
        }
    }
    return true;
}
void FieldPainter::drawGoalArea(const PostInfo::Type &goalArea){
   
   save ();
   if(goalArea & PostInfo::pAway){
      setPen("white");
      setBrush(QColor("red"));
      translate(3000, 705);
      drawEllipse (QPoint(0, 0), 5, 140);
      translate(3000, -705);
      drawEllipse (QPoint(0, 0), 5, 140);

   } else if (goalArea & PostInfo::pHome){
      setPen("white");
      setBrush(QColor("blue"));
      translate(-3000, 705);
      drawEllipse (QPoint(0, 0), 5, 140);
      translate(-3000, -705);
      drawEllipse (QPoint(0, 0), 5, 140);
   }   
   restore ();
}
示例#20
0
void spinEllipse(GLfloat increment,int id){			//speedLimiter - da se ne vrti prebrzo, da se mogu uociti prazni lukovi!
	glPushMatrix();
	glTranslatef(increment,0,0);
	if(matrixProperties[id][0]<speedMax)
		matrixProperties[id][0]++;
	else{
		if(matrixProperties[id][1]<6)
			drawEllipse(matrixDistance[id][0],matrixDistance[id][1],matrixAngle[matrixProperties[id][1]][0],matrixAngle[matrixProperties[id][1]++][1]);
		else
			matrixProperties[id][1]=0;
		matrixProperties[id][0]=0;
		}
	glPopMatrix();
}
示例#21
0
void TipsPainter::drawBall(const Ball& ball, bool drawCenter)
{
	QPen old = pen();
	setCircledPointPen(ball.type); 

	drawEllipse(round(ball.center),int(ball.radius),int(ball.radius));

	if (drawCenter){
		double koeff = 0.5;
		drawLine(QPoint(round(ball.center.x() + koeff*ball.radius), round(ball.center.y())), QPoint(round(ball.center.x() - koeff*ball.radius), round(ball.center.y())));
		drawLine(QPoint(round(ball.center.x()), round(ball.center.y() - koeff*ball.radius)), QPoint(round(ball.center.x()), round(ball.center.y() + koeff*ball.radius)));
	}

	setPen(old);
}
void FieldPainter::drawPostRR (const PostInfo &post, const AbsCoord &robot)
{
   save();
   translateRR(post.rr, robot);
   setPen("white");
   if (post.type & PostInfo::pAway) {
      setBrush(QColor("red"));
   } else if (post.type & PostInfo::pHome){
      setBrush(QColor("blue"));
   } else {
      setBrush(QColor("yellow"));
   }
   drawEllipse (QPoint(0, 0), 80, 80);
   restore();
}
void FieldPainter::drawBallPosRRC(const AbsCoord &ballPos, const AbsCoord &ballVel, bool moving, const AbsCoord &robot)
{
   save();
   translate(robot.x(), robot.y());
   rotate(RAD2DEG(robot.theta()));
   QPoint newBall = QPoint(ballPos.x(), ballPos.y());
   QPoint nextBall = QPoint(ballPos.x() + ballVel.x(), ballPos.y() + ballVel.y());
   setPen(QPen(QColor(255, 0, 0)));
   setBrush(QBrush(QColor(255, 0, 0)));
   drawEllipse(newBall, 40, 40);
   if (moving) drawLine(newBall, nextBall);
   restore();

   drawRRCovEllipse(ballPos, robot);
}
void FieldPainter::drawRobotRR (const RobotInfo &robot, const AbsCoord &robotPos) 
{
   save ();
   translateRR(robot.rr, robotPos);
   if(robot.type == RobotInfo::rRed) {
      setBrush(QBrush(Qt::red));
   } else if(robot.type == RobotInfo::rBlue) {
      setBrush(QBrush(Qt::blue));
   } else {
      setBrush(QBrush(Qt::green));
   }
   setPen(QColor(255, 127, 0));
   drawEllipse (QPoint(0, 0), 120, 120);
   restore ();
}
示例#25
0
void drawTrackerRPhi(TPad* pad)
{
    pad->cd();
    double r = 0, x = 0, y = 0;
    TEllipse *e;
    // PXB
    drawEllipse(x,y,4.4);
    drawEllipse(x,y,7.3);
    drawEllipse(x,y,10.2);
    // TIB
    drawEllipse(x,y,25.5);
    drawEllipse(x,y,33.9);
    drawEllipse(x,y,41.9);
    drawEllipse(x,y,49.8);
}
示例#26
0
void Point::paint(){
   if(visible){
     float curr_x = center.GetXDistance();
     float curr_y = center.GetYDistance();

     XPoint res_center;
     res_center.x = int(curr_x * xscale * cos(orientation*PI/180.0) - 
		    curr_y * yscale * sin(orientation*PI/180.0) + 
			origin.GetXDistance());
     res_center.y = int(curr_x * xscale * sin(orientation*PI/180.0) + 
		    curr_y * yscale * cos(orientation*PI/180.0) + 
		    origin.GetYDistance());
    // Draw a circle
     drawEllipse(res_center, int(radius*2 * xscale), int(radius*2 * yscale),
		 fill_color, fill);  // need x and y diameter 
  }
}
// draw absolute position covariance ellipse
void FieldPainter::drawAbsCovEllipse(const AbsCoord &pos, QPen variancePen) {
   variancePen.setWidth(20);

   Eigen::VectorXf eigenvalues = pos.var.block<2, 2>(0,0).marked<Eigen::SelfAdjoint>().eigenvalues();
   int r_major_axis = sqrt(MAX(eigenvalues[0], eigenvalues[1]));
   int r_minor_axis = sqrt(MIN(eigenvalues[0], eigenvalues[1]));
   float theta = atan2(2*pos.var(0,1), pos.var(0,0)-pos.var(1,1))/2.0;

   save();
   translate(pos.x(), pos.y());
   rotate(RAD2DEG(theta));
   QRect varRect(-r_major_axis, -r_minor_axis, r_major_axis*2, r_minor_axis*2);
   setPen(variancePen);
   setBrush(QBrush(Qt::NoBrush));
   drawEllipse(varRect);
   restore();
}
示例#28
0
文件: scene.cpp 项目: AKorezin/image
void scene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
	if(selecting)
	{
		switch (tool) {
		case 0:
			drawEllipse(start,event->scenePos().toPoint());
			break;
		case 1:
			drawLine(start,event->scenePos().toPoint());
			break;
		case 2:
			drawRect(start,event->scenePos().toPoint());
			break;
		case 3:
			drawMarker(event->scenePos().toPoint());
			break;
		default:
			break;
		}
	}
	if(!handles.empty())
	{
		int check=0;
		for(int i=0;i<handles.size();i++)
		{
			if(handles.at(i)->contains(event->scenePos()))
				check=i+1;
		}
		QPen pen;
		pen.setWidth(0);
		pen.setColor(Qt::red);
		for(int i=0;i<handles.size();i++)
		{
			handles.at(i)->setPen(pen);
		}
		if(check)
		{
			QPen pen;
			pen.setWidthF(penwidth);
			pen.setColor(Qt::green);
			handles.at(check-1)->setPen(pen);
		}
	}
}
示例#29
0
void CEllipseWindow::OnPaint()
{
	RECT rect;
	PAINTSTRUCT paintStruct;
	::GetClientRect(handle, &rect);
	HDC handleDC = ::BeginPaint(handle, &paintStruct);
	HDC memoryDC = CreateCompatibleDC(handleDC);
	HBITMAP memoryBuffer = CreateCompatibleBitmap(handleDC, rect.right - rect.left,
		rect.bottom - rect.top);
	HGDIOBJ oldMemoryBuffer = SelectObject(memoryDC, memoryBuffer);
	drawEllipse(memoryDC, rect);
	BitBlt(handleDC, rect.left, rect.top, rect.right - rect.left,
		rect.bottom - rect.top, memoryDC, 0, 0, SRCCOPY);
	SelectObject(memoryDC, oldMemoryBuffer);
	DeleteObject(memoryBuffer);
	DeleteDC(memoryDC);
	::EndPaint(handle, &paintStruct);
}
void FieldPainter::drawRobotAbs (const AbsCoord &pos, QColor colour, bool ellipse, QColor varColour)
{
   static const int robot_radius = 120;
   QRect roboRect(-robot_radius,-robot_radius,robot_radius*2,robot_radius*2);
   QPen variancePen(varColour);
   variancePen.setWidth(20);

   // draw pacman
   save();
   translate(pos.x(), pos.y());
   setPen("black");
   int fov;
   if (pos.var(2,2) > 0) {
      fov = MIN(160, RAD2DEG(sqrt(pos.var(2,2))));
   } else {
      fov = 0;
   }
   setBrush(QBrush(colour));
   rotate((RAD2DEG(pos.theta())-(fov/2)));
   drawPie(roboRect, 0, (360-fov)*16);
   restore();

   /* Converting covariance matrix to ellipse representation
    * Eigenvalues of the matrix are the major and minor axis lengths
    * Eigenvectors are the vectors from the center along the axes (should be perpendicular)
    */
   if (ellipse) {
      Eigen::VectorXf eigenvalues = pos.var.block<2, 2>(0,0).marked<Eigen::SelfAdjoint>().eigenvalues();
      int r_major_axis = MAX(sqrt(MAX(eigenvalues[0], eigenvalues[1])), robot_radius);
      int r_minor_axis = MAX(sqrt(MIN(eigenvalues[0], eigenvalues[1])), robot_radius);
      float theta = atan2(2*pos.var(0,1), pos.var(0,0)-pos.var(1,1))/2.0;

      // draw position covariance ellipse
      save();
      translate(pos.x(), pos.y());
      rotate(RAD2DEG(theta));
      QRect varRect(-r_major_axis, -r_minor_axis, r_major_axis*2, r_minor_axis*2);
      setPen(variancePen);
      setBrush(QBrush(Qt::NoBrush));
      drawEllipse(varRect);
      restore();
   }
}