void GraphGraphicsView::drawShortestPath(int from, int to)
{
    clearArrows();
    clearWeights();
    int next = prevs[to];
    while(next != from)
    {
        drawPath(nodes[to],nodes[next]);
        to = next;
        next = prevs[next];
    }
    drawPath(nodes[to],nodes[next]);

}
Exemple #2
0
void Graphics::drawGraphicsDatum(IGraphicsData *inData)
{
   switch(inData->GetType())
   {
      case gdtUnknown: break;
      case gdtTrianglePath: break;
      case gdtPath:
         {
         GraphicsPath *path = inData->AsPath();
         drawPath(path->commands, path->data, path->winding);
         break;
         }
      case gdtEndFill:
         endFill();
         break;
      case gdtSolidFill:
      case gdtGradientFill:
      case gdtBitmapFill:
         {
         IGraphicsFill *fill = inData->AsIFill();
         if (fill->isSolidStyle())
         {
            Flush(false,true);
            endTiles();
            if (mFillJob.mFill)
               mFillJob.mFill->DecRef();
            mFillJob.mFill = fill;
            mFillJob.mFill->IncRef();
            if (mFillJob.mCommand0 == mPathData->commands.size())
               mPathData->initPosition(mCursor);
         }
         else if (mLineJob.mStroke)
         {
            Flush(true,false);
            mLineJob.mStroke = mLineJob.mStroke->CloneWithFill(fill);
         }
         }
         break;
      case gdtStroke:
         {
         Flush(true,false);
         if (mLineJob.mStroke)
         {
            mLineJob.mStroke->DecRef();
            mLineJob.mStroke = 0;
         }
         GraphicsStroke *stroke = inData->AsStroke();
         if (stroke->thickness>=0 && stroke->fill)
         {
            mLineJob.mStroke = stroke;
            mLineJob.mStroke->IncRef();
            if (mLineJob.mCommand0 == mPathData->commands.size())
               mPathData->initPosition(mCursor);
         }
         }
         break;

   }
   OnChanged();
}
void PathCache::PathProcessor::onProcess(const sp<Task<SkBitmap*> >& task) {
    PathTask* t = static_cast<PathTask*>(task.get());
    ATRACE_NAME("pathPrecache");

    float left, top, offset;
    uint32_t width, height;
    PathCache::computePathBounds(&t->path, &t->paint, left, top, offset, width, height);

    PathTexture* texture = t->texture;
    texture->left = left;
    texture->top = top;
    texture->offset = offset;
    texture->width = width;
    texture->height = height;

    if (width <= mMaxTextureSize && height <= mMaxTextureSize) {
        SkBitmap* bitmap = new SkBitmap();
        drawPath(&t->path, &t->paint, *bitmap, left, top, offset, width, height);
        t->setResult(bitmap);
    } else {
        texture->width = 0;
        texture->height = 0;
        t->setResult(NULL);
    }
}
Exemple #4
0
void 
drawElement(e2dElement* elem)  {
    glPushMatrix();
    
    multMatrix(&elem->localTransform);
    switch(elem->type)
    {
            
        case(E2D_GROUP):
            drawGroup((e2dGroup*)elem);
            break;
           
        case(E2D_PATH):
            drawPath((e2dPath*)elem);
            break;
            
        case(E2D_IMAGE):
            drawImage((e2dImage*)elem);
            break;
          
        case(E2D_CLONE):
            drawClone((e2dClone*)elem);
            break;
            
        default:
            break;
    }
        
    drawAxis();
    drawRect(elem->bboxPosition, elem->bboxWidth, elem->bboxHeight);
    glPopMatrix();
}
void ConnectionItem::update()
{
    QPointF start(m_start.x() + ConnectorItem::SIZE, m_start.y());
    QPointF end(m_end.x() - ConnectorItem::SIZE, m_end.y());
    
    QPainterPath path = drawPath(start, end);
    m_path->setPath(path);
    m_path->setPen(m_pen);
    
    updateArrowPositions(start, end);
    
    QBrush lightBrush = QBrush(m_pen.color().lighter(130));
    QBrush darkBrush =  QBrush(m_pen.color().darker(130));
    
    if(m_outputOccupied)
        m_startArrow->setBrush(darkBrush);
    else
        m_startArrow->setBrush(lightBrush);
    
    if(m_inputOccupied && m_outputOccupied)
        m_centerArrow->setBrush(darkBrush);
    else
        m_centerArrow->setBrush(lightBrush);
    
    if(m_inputOccupied)
        m_endArrow->setBrush(darkBrush);
    else
        m_endArrow->setBrush(lightBrush);
}
void MainWindow::fillRoutesTableWidget(QTableWidget* routesTableWidget, int index) {
    routesTableWidget->clearContents();
    routesTableWidget->setRowCount(0);

    if(index == 0) {
        // сортировка по времени
        vvPaths = getSortedByTime(vvPaths);
    } else {
        // сортировка по стоимости
        vvPaths = getSortedByMoney(vvPaths);
    }

    routesTableWidget->setRowCount(vvPaths.size());

    qDebug() << "vvPaths.size: " << vvPaths.size();
    for(int i = 0; i < vvPaths.size(); i++) {
        std::vector<SearchParameters> path = vvPaths.at(i);

        int start = path.at(0).getStart();
        QString startStr = QString::fromStdString(CityMap::Instance().getPlaceById(start).getName());

        int finish = path.at(path.size() - 1).getFinish();
        QString finishStr = QString::fromStdString(CityMap::Instance().getPlaceById(finish).getName());

        int cost = getCost(path);
        QString costStr = QString::number(cost);

        QTime time = getTime(path);

        routesTableWidget->setItem(i, 0, new QTableWidgetItem(startStr));
        routesTableWidget->setItem(i, 1, new QTableWidgetItem(finishStr));
        routesTableWidget->setItem(i, 2, new QTableWidgetItem(costStr));
        routesTableWidget->setItem(i, 3, new QTableWidgetItem(time.toString()));

        QHBoxLayout* layout = new QHBoxLayout();
        layout->setMargin(0);

        QPushButton* btn1 = new QPushButton(QIcon(":/map/icons/road.png"), "");
        QPushButton* btn2 = new QPushButton(QIcon(":/routes/icons/Get-Info-icon.png"), "");

        layout->setSizeConstraint(QLayout::SetMaximumSize);

        btn1->setProperty("index", QVariant(i));
        btn2->setProperty("index", QVariant(i));

        layout->setSpacing(0);

        layout->addWidget(btn1);
        layout->addWidget(btn2);

        connect(btn1, SIGNAL(clicked()), this, SLOT(drawPath()));
        connect(btn2, SIGNAL(clicked()), this, SLOT(showFullInfo()));

        QWidget* widget = new QWidget();
        widget->setLayout(layout);

        routesTableWidget->setCellWidget(i, 4, widget);
    }
}
Exemple #7
0
void display(void) {
	int i=0;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	drawText();
	glCallList(textList);

	glPushMatrix();
	glTranslatef(xx, yy, -zoom);
	glRotatef(rotx, 1.0, 0.0, 0.0);
	glRotatef(roty, 0.0, 1.0, 0.0);
	glRotatef(rotz, 0.0, 0.0, 1.0);

	GLfloat ambient1[] = {0.15f, 0.15f, 0.15f, 1.0f};
	GLfloat diffuse1[] = {0.8f, 0.8f, 0.8f, 1.0f};
	GLfloat specular1[] = {1.0f, 1.0f, 1.0f, 1.0f};
	GLfloat position1[] = {0.0f, 0.0f, 20.0f, 1.0f};
	glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, specular1);
	glLightfv(GL_LIGHT1, GL_POSITION, position1);
	glEnable(GL_LIGHT1);

	if (axe) { drawAxes(); }
	for (i=0; i<sampleSize; i++) {
		if (planetsList[i].displayed) {
			drawPlanet(planetsList[i], i);
		}
		if (trace) {
			if (planetsList[i].selected) {
				drawPath(planetsList[i]);
			}
		}
		if (allTraces) {
			drawPath(planetsList[i]);
		}
	}
	glPopMatrix();

	glutSwapBuffers();
	glutPostRedisplay();
}
// This method is only used to draw the little circles used in lists.
void GraphicsContext::drawEllipse(const IntRect& rect)
{
    if (paintingDisabled())
        return;

    Path path;
    path.addEllipse(rect);
    drawPath(path);
}
namespace SkRecords {

bool Draw::skip(const PairedPushCull& r) {
    if (fCanvas->quickReject(r.base->rect)) {
        fIndex += r.skip;
        return true;
    }
    return false;
}

bool Draw::skip(const BoundedDrawPosTextH& r) {
    return fCanvas->quickRejectY(r.minY, r.maxY);
}

// NoOps draw nothing.
template <> void Draw::draw(const NoOp&) {}

#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
DRAW(Restore, restore());
DRAW(Save, save(r.flags));
DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
DRAW(PopCull, popCull());
DRAW(PushCull, pushCull(r.rect));
DRAW(Clear, clear(r.color));
DRAW(Concat, concat(r.matrix));
DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));

DRAW(ClipPath, clipPath(r.path, r.op, r.doAA));
DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA));
DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA));
DRAW(ClipRegion, clipRegion(r.region, r.op));

DRAW(DrawBitmap, drawBitmap(r.bitmap, r.left, r.top, r.paint));
DRAW(DrawBitmapMatrix, drawBitmapMatrix(r.bitmap, r.matrix, r.paint));
DRAW(DrawBitmapNine, drawBitmapNine(r.bitmap, r.center, r.dst, r.paint));
DRAW(DrawBitmapRectToRect, drawBitmapRectToRect(r.bitmap, r.src, r.dst, r.paint, r.flags));
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
DRAW(DrawOval, drawOval(r.oval, r.paint));
DRAW(DrawPaint, drawPaint(r.paint));
DRAW(DrawPath, drawPath(r.path, r.paint));
DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint));
DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint));
DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint));
DRAW(DrawRRect, drawRRect(r.rrect, r.paint));
DRAW(DrawRect, drawRect(r.rect, r.paint));
DRAW(DrawSprite, drawSprite(r.bitmap, r.left, r.top, r.paint));
DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint));
DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.paint));
DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors,
                                r.xmode.get(), r.indices, r.indexCount, r.paint));
#undef DRAW

template <> void Draw::draw(const PairedPushCull& r) { this->draw(*r.base); }
template <> void Draw::draw(const BoundedDrawPosTextH& r) { this->draw(*r.base); }

}  // namespace SkRecords
Exemple #10
0
void section_gl::drawFrom(point loc, int scale)
{
  if (!render) { return; }
   
  //TODO: implement variable path granularity
  if (pathLength > 1)
  {
    for (int lp=1; lp < pathLength; lp++)
      drawPath(loc, cameraPath[lp-1], cameraPath[lp], 8);
  }
}
void GraphGraphicsView::drawAllEdges()
{
    for (int i = 0; i < adj.length(); ++i) {
        adj[i].First();
        while(adj[i].Current() != 0)
        {
            drawPath(nodes[adj[i].Current()->Dest], nodes[i]);
            adj[i].Next();
        }
    }
}
Exemple #12
0
/*!
    \fn void QPaintEngine::drawEllipse(const QRectF &rect)

    Reimplement this function to draw the largest ellipse that can be
    contained within rectangle \a rect.

    The default implementation calls drawPolygon().
*/
void QPaintEngine::drawEllipse(const QRectF &rect)
{
    QPainterPath path;
    path.addEllipse(rect);
    if (hasFeature(PainterPaths)) {
        drawPath(path);
    } else {
        QPolygonF polygon = path.toFillPolygon();
        drawPolygon(polygon.data(), polygon.size(), ConvexMode);
    }
}
Exemple #13
0
void WPainter::drawRect(double x, double y, double width, double height)
{
    WPainterPath path(WPointF(x, y));

    path.lineTo(x + width, y);
    path.lineTo(x + width, y + height);
    path.lineTo(x, y + height);
    path.closeSubPath();

    drawPath(path);
}
//--------------------------------------------------------------------------
//  void wxPLDevAGG::DrawLine( short x1a, short y1a, short x2a, short y2a )
//
//  Draw a line from (x1a, y1a) to (x2a, y2a).
//--------------------------------------------------------------------------
void wxPLDevAGG::DrawLine( short x1a, short y1a, short x2a, short y2a )
{
    mPath.remove_all();
    mPath.move_to( x1a, y1a );
    mPath.line_to( x2a, y2a );

    if ( !resizing && ownGUI )
        AGGAddtoClipRegion( x1a, y1a, x2a, y2a );

    drawPath( Stroke );
}
//--------------------------------------------------------------------------
//  void wxPLDevAGG::DrawPolyline( short *xa, short *ya, PLINT npts )
//
//  Draw a poly line - coordinates are in the xa and ya arrays.
//--------------------------------------------------------------------------
void wxPLDevAGG::DrawPolyline( short *xa, short *ya, PLINT npts )
{
    mPath.remove_all();
    mPath.move_to( xa[0], ya[0] );
    for ( PLINT i = 1; i < npts; i++ )
    {
        mPath.line_to( xa[i], ya[i] );
        if ( !resizing && ownGUI )
            AGGAddtoClipRegion( xa[i - 1], ya[i - 1], xa[i], ya[i] );
    }

    drawPath( Stroke );
}
void MainWindow::evolve(){
    *pop = GeneticEngine::evolvePopulation(*pop);
    generation++;
    ui->statPlot->graph(0)->addData(generation, pop->getFittest().getDistance());
    ui->statPlot->graph(1)->addData(generation, pop->getAverage());
    for(int populationIndex=0; populationIndex<pop->populationSize();populationIndex++){
        QModelIndex index = model->index(populationIndex, 0, QModelIndex());
        model->setData(index, pop->getTour(populationIndex), Qt::EditRole);
    }
    ui->statPlot->replot();
    if(ui->listView->selectionModel()->selection().count() != 0)
        drawPath(ui->listView->selectionModel()->selection());
}
Exemple #17
0
void WPainter::strokePath(const WPainterPath& path, const WPen& p)
{
    WBrush oldBrush = WBrush(brush());
    WPen   oldPen = WPen(pen());

    setBrush(WBrush());
    setPen(p);

    drawPath(path);

    setBrush(oldBrush);
    setPen(oldPen);
}
Exemple #18
0
void WPainter::fillPath(const WPainterPath& path, const WBrush& b)
{
    WBrush oldBrush = WBrush(brush());
    WPen   oldPen = WPen(pen());

    setBrush(b);
    setPen(NoPen);

    drawPath(path);

    setBrush(oldBrush);
    setPen(oldPen);
}
Exemple #19
0
  void ShapeRenderer::drawArc(m2::PointD const & center, double startA, double endA, double r, graphics::Color const & c, double depth)
  {
    vector<m2::PointD> pts;
    approximateArc(center, startA, endA, r, pts);

    if (pts.size() < 2)
      return;

    drawPath(&pts[0],
             pts.size(),
             0,
             base_t::mapInfo(graphics::Pen::Info(c, 3, 0, 0, 0)),
             depth);
  }
Exemple #20
0
void WPainter::drawPolyline(const WT_ARRAY WPointF *points, int pointCount)
{
    if (pointCount < 2)
        return;

    WPainterPath path;

    path.moveTo(points[0]);
    for (int i = 1; i < pointCount; ++i)
        path.lineTo(points[i]);

    WBrush oldBrush = WBrush(brush());
    setBrush(WBrush());
    drawPath(path);
    setBrush(oldBrush);
}
Exemple #21
0
void WPainter::drawPolygon(const WT_ARRAY WPointF *points, int pointCount
                           /*, FillRule fillRule */)
{
    if (pointCount < 2)
        return;

    WPainterPath path;

    path.moveTo(points[0]);
    for (int i = 1; i < pointCount; ++i)
        path.lineTo(points[i]);

    path.closeSubPath();

    drawPath(path);
}
Exemple #22
0
void WPainter::drawPie(const WRectF& rectangle, int startAngle, int spanAngle)
{
    WTransform oldTransform = WTransform(worldTransform());

    translate(rectangle.center().x(), rectangle.center().y());
    scale(1., rectangle.height() / rectangle.width());

    WPainterPath path(WPointF(0.0, 0.0));
    path.arcTo(0.0, 0.0, rectangle.width() / 2.0,
               startAngle / 16., spanAngle / 16.);
    path.closeSubPath();

    drawPath(path);

    setWorldTransform(oldTransform);
}
void drawScene(void)
{
  if (renderMode == DEF_RENDER) {
    drawAllAlxes();
    drawGrid();
    drawRelevantParameters();
    drawBackground(3.5*dim);
    drawLight();
    
    drawBoard();
    drawPath();
    drawShots();
  }
  drawMinions();
  drawObjects();
  
}
Exemple #24
0
// Draws the grid to the specified location and device context with
// (x_pos,y_pos) representing the upper-left hand corner of where to draw from
// If the path finding has been completed, drawGrid() also draws the path
// from the start CCell to the destination CCell
void CGrid::draw(HDC dest_dc, int x_pos, int y_pos)
{
	// Debug error checking
	assert(dest_dc != NULL);

	// First draw the values of the grid squares
	drawValues(dest_dc,x_pos,y_pos);

	HPEN hpen;
	HPEN old_pen;

	// Create a "red pen" to draw the grid with
	hpen = CreatePen(PS_SOLID,2,RGB(255,10,10));

	// Select into the destination device context
	old_pen = (HPEN)SelectObject(dest_dc,hpen);

	int grid_wid = getWidth(); // Get the total grid width in pixels
	int grid_hgt = getHeight(); // Get the total grid height in pixels

	// Draw the vertical lines
	for(int x = x_pos; x <= (grid_wid + x_pos); x += CCell::width)
	{
		MoveToEx(dest_dc,x,y_pos,NULL);
		LineTo(dest_dc,x,y_pos + grid_hgt);
	}

	// Draw the horizontal lines
	for(int y = y_pos; y <= (grid_hgt + y_pos); y += CCell::height)
	{
		MoveToEx(dest_dc,x_pos,y,NULL);
		LineTo(dest_dc,x_pos + grid_wid,y);
	}

	// Put back the original pen
	SelectObject(dest_dc,old_pen);
	DeleteObject(hpen); // Delete the HPEN we made

	// If we found the destination -- Draw the path as well
	if(dest_found)
	{
		drawPath(dest_dc,x_pos,y_pos);
		Sleep(200);
			return;
	}
}
//--------------------------------------------------------------------------
//  void wxPLDevAGG::FillPolygon( PLStream *pls )
//
//  Draw a filled polygon.
//--------------------------------------------------------------------------
void wxPLDevAGG::FillPolygon( PLStream *pls )
{
    short *xa = pls->dev_x;
    short *ya = pls->dev_y;

    mPath.remove_all();
    mPath.move_to( xa[0], ya[0] );
    for ( PLINT i = 1; i < pls->dev_npts; i++ )
    {
        mPath.line_to( xa[i], ya[i] );
        if ( !resizing && ownGUI )
            AGGAddtoClipRegion( xa[i - 1], ya[i - 1], xa[i], ya[i] );
    }
    mPath.line_to( xa[0], ya[0] );
    mPath.close_polygon();

    drawPath( FillAndStroke );
}
Exemple #26
0
void WPainter::drawChord(const WRectF& rectangle, int startAngle, int spanAngle)
{
    WTransform oldTransform = WTransform(worldTransform());

    translate(rectangle.center().x(), rectangle.center().y());
    scale(1., rectangle.height() / rectangle.width());

    double start = startAngle / 16.;
    double span = spanAngle / 16.;

    WPainterPath path;
    path.arcMoveTo(0, 0, rectangle.width()/2., start);
    path.arcTo(0, 0, rectangle.width()/2., start, span);
    path.closeSubPath();

    drawPath(path);

    setWorldTransform(oldTransform);
}
void SkPDFDevice::drawPath(const SkDraw& d, const SkPath& path,
                           const SkPaint& paint, const SkMatrix* prePathMatrix,
                           bool pathIsMutable) {
    NOT_IMPLEMENTED(prePathMatrix != NULL, true);

    if (paint.getPathEffect()) {
        // Apply the path effect to path and draw it that way.
        SkPath noEffectPath;
        paint.getFillPath(path, &noEffectPath);

        SkPaint noEffectPaint(paint);
        SkSafeUnref(noEffectPaint.setPathEffect(NULL));
        drawPath(d, noEffectPath, noEffectPaint, NULL, true);
        return;
    }
    updateGSFromPaint(paint, false);

    SkPDFUtils::EmitPath(path, &fContent);
    SkPDFUtils::PaintPath(paint.getStyle(), path.getFillType(), &fContent);
}
Exemple #28
0
void GraphicsContext::drawConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased)
{
    if (paintingDisabled())
        return;

    if (numberOfPoints <= 1)
        return;

    CGContextRef context = platformContext();

    if (antialiased != shouldAntialias())
        CGContextSetShouldAntialias(context, antialiased);

    Path path;
    addConvexPolygonToPath(path, numberOfPoints, points);
    drawPath(path);

    if (antialiased != shouldAntialias())
        CGContextSetShouldAntialias(context, shouldAntialias());
}
Exemple #29
0
int main(int argc, char *argv[]) {
   maze_t maze;

   maze.start.x = 1;
   maze.start.y = 1;

   maze.end.x = 15;
   maze.end.y = 15;

   path_t path;
   int pathLength;

   generateMaze(&maze);

   pathLength = aStar_shortestPath(
      (location_t)&(maze.start),
      isGoal,
      &path,
      expandCoord,
      coordHeuristic,
      coordHash,
      isEqualCoord,
      (void *)&maze
   );

   if (pathLength == NO_PATH) {
      printf("No Path Found\n");
   } else {
      printf("Path Length: %d\n", pathLength);
   }

   drawPath(&maze, path, pathLength);

   printMaze(&maze);

   assert(pathLength == 32);

   printf("All Tests Passed\n");

   return EXIT_SUCCESS;
}
PathTexture* PathCache::addTexture(const PathDescription& entry, const SkPath *path,
        const SkPaint* paint) {
    ATRACE_CALL();

    float left, top, offset;
    uint32_t width, height;
    computePathBounds(path, paint, left, top, offset, width, height);

    if (!checkTextureSize(width, height)) return NULL;

    purgeCache(width, height);

    SkBitmap bitmap;
    drawPath(path, paint, bitmap, left, top, offset, width, height);

    PathTexture* texture = createTexture(left, top, offset, width, height,
            path->getGenerationID());
    generateTexture(entry, &bitmap, texture);

    return texture;
}