예제 #1
0
void PlotWidget::drawData( const ChartAxisIndex &axisSet ) 
{
    kDebug();
    int dataCount = model.dataSetCount( axisSet );
    for ( int i = 0; i < dataCount; ++i ) {
        kDebug()<<"create data index";
        ChartDataIndex di = model.index( i, axisSet );
        kDebug()<<"created data index:"<<di.number()<<di.userData;
        if ( ! di.isValid() ) {
            kDebug()<<"Invalid index";
            continue;
        }
        if ( model.hasChildren( di ) ) {
            kDebug()<<"sections";
            int c = model.childCount( di );
            for ( int ii = 0; ii < c; ++ii ) {
                ChartDataIndex cidx = model.index( ii, di );
                drawData( cidx, axisSet );
            }
        } else {
            kDebug()<<"no sections, go direct to data";
            drawData( di, axisSet );
        }
    }
}
예제 #2
0
파일: Canvas.cpp 프로젝트: opiette/wxsand
inline void found(particle *p, particle *otherp, int center, int other){
	particle tempp = *p;
	*p = *otherp;
	*otherp = tempp;

  drawData(center);
  drawData(other);
  p->calc = true;
  otherp->calc = true;
}
예제 #3
0
int showdatawindow::routinedrawgroup(void)
{
    int i;

    if(newdata&&(!ui->CheckPauseShow->isChecked()))  //show the data when get new package
    {
        calNewPack();
        saveData();
        for( i= 0;i< NUMPOINTSAMPLE; i++)
        {
            if(!ui->checkReverse->isChecked())
                adc_new_data[i]=(float)adc_new_data[i]*zoomrate;
            else
                adc_new_data[i]=(float)adc_new_data[i]*zoomrate*-1;
        }
        //after save new data to array we write the new data on the scene
        //from here
        if(ui->checkTemp->isChecked())
        {
            drawData(ui->drawTemp,sceneTemp ,MAX_TEMP,MIN_TEMP,saveTemp,counttemp,NUMPATHTEMP,NUMPOINTSAMPLE_TEMP,0,false);  //no use countguileline and firsttimesample
        }
        if(ui->checkAccx->isChecked())
        {
            drawData(ui->drawAccx,sceneX ,MAX_MIN_X,-1*MAX_MIN_X,saveX,countx,NUMPATHX,NUMPOINTSAMPLE_X,0,false); //no use countguileline and firsttimesample
        }
        if(ui->checkAccy->isChecked())
        {
            drawData(ui->drawAccy,sceneY ,MAX_MIN_Y,-1*MAX_MIN_Y,saveY,county,NUMPATHY,NUMPOINTSAMPLE_Y,0,false); //no use countguileline and firsttimesample
        }
        if(ui->checkAccz->isChecked())
        {
            drawData(ui->drawAccz,sceneZ ,MAX_MIN_Z,-1*MAX_MIN_Z,saveZ,countz,NUMPATHZ,NUMPOINTSAMPLE_Z,&countguidelinez,first_Time_Samplez); //use countguileline and firsttimesample
        }
        if(ui->checkADC->isChecked())
        {
            drawData(ui->drawADC,sceneADC ,MAX_MIN_ADC,-1*MAX_MIN_ADC,adc_new_data,countadc,numScaleADC,NUMPOINTSAMPLE,&countguidelineadc,first_Time_Sampleadc);// use countguileline and firsttimesample
        }
        if(ui->checkSpectrogram->isChecked())
        {
//            QTime nowtime = QTime::currentTime();
            drawFFT();
//            QTime newtime = QTime::currentTime();
//            qDebug()<< "Spectrogram" <<nowtime.toString("hhmmsszzz")<<newtime.toString("hhmmsszzz");
        }
        //end
        showDataControl();
        newdata=false;
        return 1;
    }
    return 0;
}
예제 #4
0
void OkcViewDisplay::paint() {
    OkcVisualMapResult* vmr = getOkcVisualMapResult();

	// If the VisualMapResult is NULL, do nothing
	if (!vmr) {
		return;
	}

    // Set parameters about data size, dimension size and dimension attributes
	setParameters();

	// If the dataset does not have enough dimensions, do nothing
	if (!testDimensionality()) return;

	Data* data = vmr->getData();
	assert ( typeid(*data)==typeid(OkcData));
	// if the brush is not null, draw it
	Brush* curBrush = vmr->getBrush();
	if (curBrush) {
		drawSingleBrush(curBrush);
	}

	drawData();

	drawAxes();

}
예제 #5
0
  sp<Retval> GdMonCpustat::draw(int num, sp<info>& info, sp<MonBase>& dest
                        , const char* path)
  {
      sp<Retval> retval;
      if( DFW_RET(retval, MonCpustat::draw(num, info, dest, path)) )
          return DFW_RETVAL_D(retval);
      if( DFW_RET(retval, baseInit()) )
          return DFW_RETVAL_D(retval);

      struct max_st  max;
      struct data_st dt;
      getMax(&max, info, m_g.cs.w);
      setData(&dt);

      drawHead(dest->m_sec, info->m_sec);

      uint64_t first_sec;
      uint64_t last_sec = dest->m_sec;
      for(int k=info->m_aLists.size(), dx=m_g.cr.ex; ((k>0)&&(dx>m_g.cr.sx));)
      {
          sp<GdMonCpustat> p  = info->m_aLists.get(k-1);
          sp<GdMonCpustat> pp = info->m_aLists.get(k-2);
          procData(dx, &max, &dt, p, pp);
          drawData(dx, &dt);
          k--;
          dx--;
          first_sec = p->m_sec;
      }

      drawBottom(dest, &max, &dt);
      drawLast(first_sec, last_sec);
      if( DFW_RET(retval, savePng(path, savename(), 0)) )
          return DFW_RETVAL_D(retval);
      return NULL;
  }
예제 #6
0
파일: VCanvas.cpp 프로젝트: GhostVIRUS/VV3D
void VCanvas::paintGL()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glTranslatef(0.0, 0.0, -10.0);

	qglColor(Qt::darkBlue);

	glBegin(GL_POINTS);
	glVertex3f(0.0, 0.0, 0.0);
	glEnd();

	glScalef(scaling, scaling, scaling);

	glRotatef(rotationX, 1.0, 0.0, 0.0);
	glRotatef(rotationY, 0.0, 1.0, 0.0);
	glRotatef(rotationZ, 0.0, 0.0, 1.0);

	glTranslatef(translX, translY, translZ); //

	//drawAxes(axesLength);
	if (drawingData != 0)
		drawData();
	if (areAxesVisible)
		drawAxes(axesLength);
}
예제 #7
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    ui->tableWidget->setColumnCount(4);
    ui->tableWidget->setHorizontalHeaderLabels(QStringList() << "Id" << "Date" << "Hour" << "Temperature");
    ui->tableWidget->verticalHeader()->setVisible(false);
    ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
    ui->tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);

    connect(ui->tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(setId(int, int)));
    connect(ui->customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(showCoordinates(QMouseEvent *)));

    if (!readXML()) {
        qFatal("read XML err");
    }
    dbInit();
    drawData("");

    plotPaint();
    ui->tabWidget->setCurrentIndex(0);
    setWindowTitle("Body Temperature Monitor");
}
예제 #8
0
/////////////////////////////////////////////  
// Draw the HDS
///////////////////////////////////////////
void SubdivScene::drawHDS(bool select) {

  GLuint faceCounter = 0;

  LOG(Log::DEBUG) << "Drawing the HDS";
  FaceIterator fitr = HDS.faceBegin();

  for(; fitr != HDS.faceEnd(); fitr++) {
    
    if (select)
      glLoadName(faceCounter++);

    glBegin(MODE_LIST[currentMode]);

    Face::iterator itr = (*fitr)->begin();
    Face::iterator end = (*fitr)->begin();
    
    int iteration = 0;
    do {
      if (iteration > 6) {
	      printf("ERROR IN DRAWING\n");
	      break;
      }
      drawData(itr->getData());
      ++itr;
      ++iteration;
    } while (itr != end);
    
    glEnd();

  }
}
void SpeechAudiometryWidget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    drawGrid();
    drawData();
    painter.drawPicture(0, 0, m_rooster);
    painter.drawPicture(0, 0, m_data);
}
예제 #10
0
void ofxFFTBase::draw(int x, int y, int width, int height) {
    renderSingleBandWidth = width / (float)binSize;
    
    ofPushMatrix();
    ofTranslate(x, y);
    drawData(fftData, width, height);
    ofPopMatrix();
}
void PureToneAudiometryWidget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    drawGrid();
    drawData();
    painter.drawPicture(0, 0, m_grid);
    painter.drawPicture(0, 0, m_data);
}
예제 #12
0
void MainWindow::on_pushButtonShowDayCurve_clicked()
{
    ui->lineEditDateShow->setText(ui->listWidgetDaysInfo->currentItem()->text());
    ui->tabWidget->setCurrentIndex(0);

    drawData(ui->lineEditDateShow->text());
    plotPaint();
}
예제 #13
0
파일: gpu.c 프로젝트: anumula2/g9impulse
void drawFullscreen(uint32 address)
{
    load_t_addr(0x00000000);
    load_s_addr(address);
    load_s_lines(SCREEN_HEIGHT);
    load_l_size(SCREEN_WIDTH);
    load_alphaOp(false);
    drawData();
}
예제 #14
0
void ARenderPrivate::drawPlay(QPainter *painter, QRect rect)
{
	painter->fillRect(rect, Qt::black);
	if (music){
		painter->drawImage(rect.center() - QRect(QPoint(0, 0), sound.size()).center(), sound);
	}
	else{
		drawData(painter, rect);
	}
	drawDanm(painter, rect);
}
예제 #15
0
void ofxFFTBase :: draw( int x, int y, int width, int height )
{
    renderSingleBandWidth = width / (float)audioNoOfBandsHalf;
    
	glPushMatrix();
	glTranslatef( x, y, 0 );
	{
        drawData( fftData, width, height );
	}
	glPopMatrix();
}
예제 #16
0
void plWxsec_APS() {
  gStyle->SetOptStat(0); 
  gStyle->SetOptDate(0);
  initTheory();
  initData();

  //make legend
  leg=new TLegend(0.47,0.48,0.88,0.35);
  leg->SetNColumns(2);
  //leg->SetColumnSeparation(0.01);
  leg->SetEntrySeparation(0.01);
  leg->SetMargin(0.2);
  leg->SetFillColor(0);
  leg->SetTextSize(0.023);
  leg->AddEntry(grD[0][0]," STAR Data","pl");
  leg->AddEntry(grT[0][2],theoN[2],"p");
  leg->AddEntry(grD[0][2]," Lumi. Uncert.","f");
  leg->AddEntry(grT[0][1],theoN[1],"p");
  leg->AddEntry(grT[0][2],"#splitline{  Theoretical}{ Scale Uncert.}","f");
  leg->AddEntry(grT[0][0],theoN[0],"p");
  
  c=new TCanvas("aa","bb",550,700);
  c->SetTopMargin(0.025); c->SetBottomMargin(0.05);
  gPad->SetGridy(false); gPad->SetGridx(false);
  initHisto();
  hBase->GetXaxis()->SetTickLength(0);
  hBase->GetXaxis()->SetLabelColor(0);
  hBase->GetYaxis()->SetTitleOffset(1.2);
  hBase->SetMinimum(0); hBase->SetMaximum(99.9);
  hBase->Draw();
  for(int iq=0; iq<mxQ;iq++) {
    drawTheo(iq);
    drawData(iq);
    //break;
  }

  leg->Draw("same");

  //insert text
  TLatex *lat0 = new TLatex(0.13,0.945,"Run 9 STAR Preliminary  #font[52]{p+p}  #sqrt{#font[72]{s}}_{ }=_{ }500 GeV");
  lat0->SetNDC(); lat0->SetTextSize(0.04); lat0->Draw("same");
  TLatex *lat1 = new TLatex(0.18,0.915,"Kinematic acceptance: |#eta_{#font[52]{e}}| < 1 and #font[52]{E_{T}^{e}} > 25 GeV");
  lat1->SetNDC(); lat1->SetTextSize(0.03); lat1->Draw("same");
  TLatex *lat2 = new TLatex(0.6,0.86,"#sigma(#font[52]{W^{#scale[1.2]{#pm}} #rightarrow e^{#scale[1.2]{#pm}} + #nu_{e}})");
  lat2->SetNDC(); lat2->SetTextSize(0.042); lat2->Draw("same");
  TLatex *lat3 = new TLatex(0.7,0.59,"#font[52]{W^{+}}");
  lat3->SetNDC(); lat3->SetTextSize(0.09); lat3->Draw("same");
  TLatex *lat4 = new TLatex(0.7,0.18,"#font[52]{W^{#scale[1.2]{-}}}");
  lat4->SetNDC(); lat4->SetTextSize(0.09); lat4->Draw("same");
  

}
예제 #17
0
void MidiDisplay::draw(GlInterface &gl)
{
	if(visible && isolateViewport(gl))
	{
		drawBackground(gl);
		if(midiData)
			drawData(gl);

		//(No children)

		restoreViewport(gl);
	}
}
예제 #18
0
void AudioDisplay::draw(GlInterface &gl)
{
	if(visible && isolateViewport(gl))
	{
		drawBackground(gl);
		
		if(audioData && audioData->size() > 0)
			((*audioData)[0]->getType() == ChunkType::AUDIO ? drawData(gl) : drawDataVel(gl));

		//(No children)

		restoreViewport(gl);
	}
}
예제 #19
0
파일: gpu.c 프로젝트: anumula2/g9impulse
void drawPixel(int x, int y, uint8 color)
{
    uint32 destAddress = y * SCREEN_WIDTH + x;

    setSoftwareDraw();

    loadDrawColor(color); 
    load_alphaOp(true);
    load_t_addr(destAddress);
    load_s_lines(2);
    load_l_size(4);
    drawData();

    setHardwareDraw();
}
예제 #20
0
파일: Canvas.cpp 프로젝트: opiette/wxsand
void drawCircle(int centerx, int centery, int diameter, int sandtype){
  int r = diameter/2;
  int rr = r*r;
  for(int dx=-r;dx<=r;++dx){
    int x = centerx+dx;
    int dy = (int)round(sqrt(rr - dx*dx));
    for(int y=centery-dy;y<=centery+dy;++y){
      if (x >= 0 && x <= g_width-1 && y >= 0 && y <= g_height-1){
				int center = (g_width*y)+x;
				particle *p = &particles[center];
				if (drawEmptyCheckBox->IsChecked() && p->data > 0)
					continue;
				p->data = sandtype;
				p->energy = 0;
				p->xspeed = 0;
				p->yspeed = 0;
				p->calc = false;
				drawData(center);
      }
    }
  }
}
예제 #21
0
파일: area3.cpp 프로젝트: zhangxiaxia/pro
void Area3::paintGL()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();	
	glEnable(GL_POLYGON_SMOOTH);
	glEnable(GL_LINE_SMOOTH);
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); // Make round points, not square points
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Antialias the lines
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glTranslatef(DISFONT, DISFONT, -5.0);//move (0 , 0) to (disfont, disfont)
	qglColor(Qt::black);

	initializeAxis();

	//draw labels in x and y axises
	drawLabel();
	//draw data
	drawData();
	glFlush();
}
예제 #22
0
파일: Canvas.cpp 프로젝트: opiette/wxsand
void Canvas::Refresh(){
	g_isPainting = true;
  
  wxString str(_(""));
  str.Printf(_("%s [%d]"), names[particles[(g_width*mousey)+mousex].data].c_str(), int(particles[(g_width*mousey)+mousex].energy));
  statusbar->SetStatusText(str, 2);


  if (doDraw){
    wxClientDC dc(this);

    dc.BeginDrawing();
    
    wxMemoryDC memdc;
    wxImage image(g_width, g_height, bitmapdata, true);
    wxBitmap bmp(image);
    memdc.SelectObject(bmp);

    dc.Blit(0, 0, g_width, g_height, &memdc, 0, 0);
   
    if (!drawAll){
      dc.EndDrawing();
      g_isPainting = false;
      return;
    }
    else{
      for(int center=0;center<g_width*g_height;++center){
      	drawData(center);
      	}
      drawAll = false;
    }
    

    dc.EndDrawing();

  }
	g_isPainting = false;
}
예제 #23
0
DataWidget::DataWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DataWidget)
{
    ui->setupUi(this);

    ui->graphicsView->setScene(&scene_1);
    ui->graphicsView_2->setScene(&scene_2);
    ui->graphicsView_3->setScene(&scene_3);

    QPen pen;
    pen.setColor(Qt::white);
    pen.setWidth(2);

    scene_1.addRect(QRect(0,0,185,20),pen, QBrush(Qt::NoBrush));
    scene_1.addRect(QRect(0,40,185,20),pen, QBrush(Qt::NoBrush));
    scene_1.addRect(QRect(0,80,185,20),pen, QBrush(Qt::NoBrush));

    scene_2.addRect(QRect(0,0,185,20),pen, QBrush(Qt::NoBrush));
    scene_2.addRect(QRect(0,40,185,20),pen, QBrush(Qt::NoBrush));
    scene_2.addRect(QRect(0,80,185,20),pen, QBrush(Qt::NoBrush));

    line1 = scene_1.addLine(QLineF(0.5*185,0,0.5*185,20),pen);
    line2 = scene_1.addLine(QLineF(0.5*185,40,0.5*185,60),pen);
    line3 = scene_1.addLine(QLineF(0.5*185,80,0.5*185,100),pen);

    line4 = scene_2.addLine(QLineF(0.5*185,0,0.5*185,20),pen);
    line5 = scene_2.addLine(QLineF(0.5*185,40,0.5*185,60),pen);
    line6 = scene_2.addLine(QLineF(0.5*185,80,0.5*185,100),pen);

    circle1 = scene_3.addEllipse(QRect(0,0,30,30),pen);
    circle2 = scene_3.addEllipse(QRect(0,35,30,30),pen);
    circle3 = scene_3.addEllipse(QRect(0,70,30,30),pen);

    changeLabelsColor();
    drawData();
}
예제 #24
0
void drawFigure() {
  XSetWindowBackground( curDisplay, curWindow, 0x00FFFFFF );
  XClearWindow( curDisplay, curWindow );

  // Determine how large the window is
  Window root;
  int x_ret, y_ret;
  unsigned int width, height, bw, dr;
  XGetGeometry(curDisplay, curWindow, &root, &x_ret, &y_ret,
               &width, &height, &bw, &dr );

  int xoff = 0;
  int yoff = 0;
  // make the min and max positions extend beyond the data
  float rd = maxr-minr;
  float ed = maxElongation-minElongation;
  float pd = maxPolarization-minPolarization;
  float minRRange = minr - 0.1*rd;
  float maxRRange = maxr + 0.1*rd;
  float minPolarizationRange = minPolarization - 0.1*pd;
  if (minPolarizationRange > 0.0)
    minPolarizationRange = 0.0;
  float maxPolarizationRange = maxPolarization + 0.1*pd;
  if (maxPolarizationRange < 1.1)
    maxPolarizationRange = 1.1;
  // We want to align the elongation range so that it makes
  // sense to use steps of size 0.5
  float minElongationRange;
  float maxElongationRange;
  if (maxElongation-minElongation < 0.5) {
    minElongationRange = minElongation - 0.1*ed;
    maxElongationRange = maxElongation + 0.1*ed;
  }
  else {
    float cnt = floor(minElongation/0.5);
    minElongationRange = cnt*0.5;
    cnt = ceil(maxElongation/0.5);
    maxElongationRange = cnt*0.5;
  }

  // determine height of r-ruler area
  int stra, strd, strw;
  getStringBoundingBox("0.123r",5,&strw,&stra,&strd);
  // from top to bottom: tick, space, label, space, "r", space
  int rHeight = 2*(stra+strd) + 2*STRPAD + TICK_LEN;
  getStringBoundingBox("PolarizationElongation",22,&strw,&stra,&strd);
  int tHeight = stra+strd+2*STRPAD; // title height
  int eHeight = (height-yoff)/2;
  int pHeight = (height-yoff)/2;
  float elongationScale = (float)(eHeight-rHeight-tHeight)/
    (maxElongationRange-minElongationRange);
  float polarizationScale = (float)(pHeight-rHeight-tHeight)/
    (maxPolarizationRange-minPolarizationRange);

  // total width of subfigure, total height of sub-figure
  // xoff of left of subfigure
  // yoff of top of subfigure
  // yoff of top of y-axis in subfigure
  // height of y-ruler drawing space
  // min y value at bottom of y-ruler
  // max y value at top of y-ruler
  // scale translating y-value to pixel value
  int erw = drawElongationRuler(width-xoff, eHeight, xoff, yoff, 
                      yoff+tHeight, eHeight-rHeight-tHeight,
                      minElongationRange, maxElongationRange, elongationScale);
  float rscale = (float)(width-xoff-erw) / (maxRRange-minRRange);
  // total width of subfigure, total height of sub-figure
  // xoff of left of subfigure
  // yoff of top of subfigure
  // xoff of left of x-axis in subfigure
  // yoff of top of x-ruler in subfigure
  // width of x-ruler drawing space
  // height of x-ruler drawing space
  // min x value at left of x-ruler
  // max x value at right of x-ruler
  // scale translating y-value to pixel value
  drawRRuler(width-xoff, eHeight, xoff, yoff,
             xoff+erw, yoff+eHeight-rHeight, width-xoff-erw, rHeight,
	     minRRange, maxRRange, rscale );
  drawData(width-xoff-erw, eHeight-rHeight-tHeight, 
           xoff+erw, yoff+tHeight, 
           numR, r, mean_elongation,
           minRRange, maxRRange, 
           minElongationRange, maxElongationRange,
           rscale, elongationScale);
  char title[100];
  int tlen = sprintf(title,"Elongation");
  getStringBoundingBox(title,tlen,&strw,&stra,&strd);
  XDrawString( curDisplay, curWindow, curGC,
               xoff+erw+(width-xoff-erw)/2-strw/2, // middle of data area
               yoff+tHeight-STRPAD,
               title, tlen ); 

  int prw = drawPolarizationRuler(width-xoff, pHeight, xoff, yoff+eHeight, 
                      yoff+eHeight+tHeight, pHeight-rHeight-tHeight,
                      minPolarizationRange, maxPolarizationRange, 
                      polarizationScale);
  rscale = (float)(width-xoff-prw) / (maxRRange-minRRange);
  drawRRuler(width-xoff, eHeight, xoff, yoff+eHeight,
             xoff+prw, yoff+eHeight+pHeight-rHeight,
             width-xoff-prw, rHeight,
	     minRRange, maxRRange, rscale );
  drawData(width-xoff-prw, pHeight-rHeight-tHeight, 
           xoff+prw, yoff+eHeight+tHeight,
           numR, r, mean_polarization,
           minRRange, maxRRange,
           minPolarizationRange, maxPolarizationRange,
           rscale, polarizationScale);
  tlen = sprintf(title,"Polarization");
  getStringBoundingBox(title,tlen,&strw,&stra,&strd);
  XDrawString( curDisplay, curWindow, curGC,
               xoff+erw+(width-xoff-erw)/2-strw/2, // middle of data area
               yoff+eHeight+tHeight-STRPAD,
               title, tlen ); 
  
  // draw separator bar
  // set the drawing color to gray     00rrggbb
  XSetForeground( curDisplay, curGC, 0x00AAAAAA );
  XDrawLine( curDisplay, curWindow, curGC, 
             0, eHeight, width, eHeight ); 
} // end drawFigure
예제 #25
0
    kTestMatrix, &kTestPaint));
SIMPLE_TEST_STEP(DrawBitmapNine, drawBitmapNine(kTestBitmap, kTestIRect,
    kTestRect, NULL));
SIMPLE_TEST_STEP(DrawBitmapNinePaint, drawBitmapNine(kTestBitmap, kTestIRect,
    kTestRect, &kTestPaint));
SIMPLE_TEST_STEP(DrawSprite, drawSprite(kTestBitmap, 0, 0, NULL));
SIMPLE_TEST_STEP(DrawSpritePaint, drawSprite(kTestBitmap, 0, 0, &kTestPaint));
SIMPLE_TEST_STEP(DrawText, drawText(kTestText.c_str(), kTestText.size(),
    0, 1, kTestPaint));
SIMPLE_TEST_STEP(DrawPosText, drawPosText(kTestText.c_str(),
    kTestText.size(), kTestPoints2, kTestPaint));
SIMPLE_TEST_STEP(DrawTextOnPath, drawTextOnPath(kTestText.c_str(),
    kTestText.size(), kTestPath, NULL, kTestPaint));
SIMPLE_TEST_STEP(DrawTextOnPathMatrix, drawTextOnPath(kTestText.c_str(),
    kTestText.size(), kTestPath, &kTestMatrix, kTestPaint));
SIMPLE_TEST_STEP(DrawData, drawData(kTestText.c_str(), kTestText.size()));
SIMPLE_TEST_STEP(BeginGroup, beginCommentGroup(kTestText.c_str()));
SIMPLE_TEST_STEP(AddComment, addComment(kTestText.c_str(), kTestText.c_str()));
SIMPLE_TEST_STEP(EndGroup, endCommentGroup());

///////////////////////////////////////////////////////////////////////////////
// Complex test steps

// Save/restore calls cannot be in isolated simple test steps because the test
// cases that use SkPicture require that save and restore calls be balanced.
static void SaveMatrixStep(SkCanvas* canvas,
                           skiatest::Reporter* reporter,
                           CanvasTestStep* testStep) {
    int saveCount = canvas->getSaveCount();
    canvas->save(SkCanvas::kMatrix_SaveFlag);
    canvas->clipRegion(kTestRegion);
예제 #26
0
파일: main.cpp 프로젝트: Mric26/M2-S1
int main() {

    // importation des donnees
    Csv_meteoFranceParser* csvPoste = new Csv_meteoFranceParser(pathPoste);
    Csv_meteoFranceParser* csvDatas = new Csv_meteoFranceParser(pathDatas);
    Csv_meteoFranceParser* csvJoin = csv_join_force(csvPoste, csvDatas, std::string("ID"), std::string("numer_sta"), std::string("Id_Fusion"));

    // selection des donnes requises (latitude, longitude, temperature, ...)
    std::vector<std::string>* cities = (*csvJoin)[std::string("Nom")];
    std::vector<std::string>* latitude = (*csvJoin)[std::string("Latitude")];
    std::vector<std::string>* longitude = (*csvJoin)[std::string("Longitude")];
    std::vector<std::string>* kelvin = (*csvJoin)[std::string("t")];

    float minT, maxT;
    findExtrema(minT, maxT, kelvin);

    float minLat, maxLat;
    float minLong, maxLong;
    findExtrema(minLat, maxLat, latitude);
    findExtrema(minLong, maxLong, longitude);

    ////////////////////////////// Instanciation //////////////////////////////
    std::vector< std::vector< float >* >* interpoleShepard = new std::vector< std::vector< float >* >(resolution);
    for (int i = 0; i < resolution; ++i) {
        (*interpoleShepard)[i] = new std::vector<float>(resolution);
    }

    std::vector< std::vector< float >* >* interpoleHardy = new std::vector< std::vector< float >* >(resolution);
    for (int i = 0; i < resolution; ++i) {
        (*interpoleHardy)[i] = new std::vector<float>(resolution);
    }

    int resoSquare = resolution-1;
    std::vector< std::vector< short >* >* square = new std::vector< std::vector< short >* >(resoSquare);
    for (int i = 0; i < resoSquare; ++i) {
        (*square)[i] = new std::vector<short>(resoSquare);
    }


    ////////////////////////////// Interpolation //////////////////////////////
    // interpolation des temperatures
    computeShepard(interpoleShepard, latitude, longitude, kelvin);
    computeHardy(interpoleHardy, latitude, longitude, kelvin);
    std::vector< std::vector< float >* >* interpoleData = interpoleHardy;


    ////////////////////////////// Creation des images //////////////////////////////
    QImage *imgSquare = new QImage(resoSquare * RESO, resoSquare * RESO, QImage::Format_ARGB32);
    int count = 1;

    // calcul des isolignes avec le marching square
    for (float isoLine = minT; isoLine < maxT; isoLine += 1) {

        computeMarchingSquare(square, interpoleData, isoLine);
        drawMarchingSquare(imgSquare, square, interpoleData, isoLine);

        imgSquare->save(QString("../Images/anim" + QString::number(count) + ".png"));
        std::cout << "n° : " << count << " --> " <<  isoLine << std::endl;
        count++;
    }

    // creation de la colormap
    Colormap *colorMap = createColorMap(minT, maxT);

    // calcul de la map des couleurs
    QImage *imgColor = new QImage(resoSquare, resoSquare, QImage::Format_ARGB32);
    imgColor->fill(qRgba(0,0,0,0));
    drawData(imgColor, colorMap, interpoleData);

    // dessine la colormap
    QImage *imgColormap = new QImage(50, 200, QImage::Format_RGB32);
    drawColorMap(imgColormap, colorMap, minT, maxT);

    // ecriture dans les fichiers de sorties
    imgColormap->save(QString("../Images/colorMap.png"));
    imgColor->save(QString("../Images/colorData.png"));
    writeKmlInfoFile(QString("../cities.kml"), cities, latitude, longitude);
    writeKmlImgFile(QString("../colorData.kml"), latitude, longitude, QString("colorData.png"));
    writeKmlImgFile(QString("../isoLine.kml"), latitude, longitude, QString("anim4.png"));


    ////////////////////////////// Free Memory //////////////////////////////
    std::cout << "Delete memory" << std::endl;
    delete csvPoste;
    delete csvDatas;
    delete csvJoin;
    delete cities;
    delete latitude;
    delete longitude;
    delete kelvin;
    delete imgSquare;
    delete imgColor;
    delete colorMap;
    delete imgColormap;

    std::cout << "Fin" << std::endl;
    return 0;
}
예제 #27
0
namespace SkRecords {

// FIXME: SkBitmaps are stateful, so we need to copy them to play back in multiple threads.
static SkBitmap shallow_copy(const SkBitmap& bitmap) {
    return bitmap;
}

// 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());
DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
DRAW(PopCull, popCull());
DRAW(PushCull, pushCull(r.rect));
DRAW(Clear, clear(r.color));
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(BeginCommentGroup, beginCommentGroup(r.description));
DRAW(AddComment, addComment(r.key, r.value));
DRAW(EndCommentGroup, endCommentGroup());

DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint));
DRAW(DrawBitmapMatrix, drawBitmapMatrix(shallow_copy(r.bitmap), r.matrix, r.paint));
DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.paint));
DRAW(DrawBitmapRectToRect,
        drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, r.flags));
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint));
DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint));
DRAW(DrawOval, drawOval(r.oval, r.paint));
DRAW(DrawPaint, drawPaint(r.paint));
DRAW(DrawPath, drawPath(r.path, r.paint));
DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode, r.paint));
DRAW(DrawPicture, drawPicture(r.picture, r.matrix, 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(shallow_copy(r.bitmap), r.left, r.top, r.paint));
DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint));
DRAW(DrawTextBlob, drawTextBlob(r.blob, 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));
DRAW(DrawData, drawData(r.data, r.length));
#undef DRAW

// This is an SkRecord visitor that fills an SkBBoxHierarchy.
//
// The interesting part here is how to calculate bounds for ops which don't
// have intrinsic bounds.  What is the bounds of a Save or a Translate?
//
// We answer this by thinking about a particular definition of bounds: if I
// don't execute this op, pixels in this rectangle might draw incorrectly.  So
// the bounds of a Save, a Translate, a Restore, etc. are the union of the
// bounds of Draw* ops that they might have an effect on.  For any given
// Save/Restore block, the bounds of the Save, the Restore, and any other
// non-drawing ("control") ops inside are exactly the union of the bounds of
// the drawing ops inside that block.
//
// To implement this, we keep a stack of active Save blocks.  As we consume ops
// inside the Save/Restore block, drawing ops are unioned with the bounds of
// the block, and control ops are stashed away for later.  When we finish the
// block with a Restore, our bounds are complete, and we go back and fill them
// in for all the control ops we stashed away.
class FillBounds : SkNoncopyable {
public:
    FillBounds(const SkRect& cullRect, const SkRecord& record, SkBBoxHierarchy* bbh) 
        : fCullRect(cullRect)
        , fBounds(record.count()) {
        // Calculate bounds for all ops.  This won't go quite in order, so we'll need
        // to store the bounds separately then feed them in to the BBH later in order.
        fCTM = &SkMatrix::I();
        fCurrentClipBounds = fCullRect;
        for (fCurrentOp = 0; fCurrentOp < record.count(); fCurrentOp++) {
            record.visit<void>(fCurrentOp, *this);
        }

        // If we have any lingering unpaired Saves, simulate restores to make
        // sure all ops in those Save blocks have their bounds calculated.
        while (!fSaveStack.isEmpty()) {
            this->popSaveBlock();
        }

        // Any control ops not part of any Save/Restore block draw everywhere.
        while (!fControlIndices.isEmpty()) {
            this->popControl(fCullRect);
        }

        // Finally feed all stored bounds into the BBH.  They'll be returned in this order.
        SkASSERT(bbh);
        bbh->insert(&fBounds, record.count());
    }

    template <typename T> void operator()(const T& op) {
        this->updateCTM(op);
        this->updateClipBounds(op);
        this->trackBounds(op);
    }

private:
    // In this file, SkRect are in local coordinates, Bounds are translated back to identity space.
    typedef SkRect Bounds;

    struct SaveBounds {
        int controlOps;        // Number of control ops in this Save block, including the Save.
        Bounds bounds;         // Bounds of everything in the block.
        const SkPaint* paint;  // Unowned.  If set, adjusts the bounds of all ops in this block.
    };

    // Only Restore and SetMatrix change the CTM.
    template <typename T> void updateCTM(const T&) {}
    void updateCTM(const Restore& op)   { fCTM = &op.matrix; }
    void updateCTM(const SetMatrix& op) { fCTM = &op.matrix; }

    // Most ops don't change the clip.
    template <typename T> void updateClipBounds(const T&) {}

    // Clip{Path,RRect,Rect,Region} obviously change the clip.  They all know their bounds already.
    void updateClipBounds(const ClipPath&   op) { this->updateClipBoundsForClipOp(op.devBounds); }
    void updateClipBounds(const ClipRRect&  op) { this->updateClipBoundsForClipOp(op.devBounds); }
    void updateClipBounds(const ClipRect&   op) { this->updateClipBoundsForClipOp(op.devBounds); }
    void updateClipBounds(const ClipRegion& op) { this->updateClipBoundsForClipOp(op.devBounds); }

    // The bounds of clip ops need to be adjusted for the paints of saveLayers they're inside.
    void updateClipBoundsForClipOp(const SkIRect& devBounds) {
        Bounds clip = SkRect::Make(devBounds);
        // We don't call adjustAndMap() because as its last step it would intersect the adjusted
        // clip bounds with the previous clip, exactly what we can't do when the clip grows.
        fCurrentClipBounds = this->adjustForSaveLayerPaints(&clip) ? clip : fCullRect;
    }

    // Restore holds the devBounds for the clip after the {save,saveLayer}/restore block completes.
    void updateClipBounds(const Restore& op) {
        // This is just like the clip ops above, but we need to skip the effects (if any) of our
        // paired saveLayer (if it is one); it has not yet been popped off the save stack.  Our
        // devBounds reflect the state of the world after the saveLayer/restore block is done,
        // so they are not affected by the saveLayer's paint.
        const int kSavesToIgnore = 1;
        Bounds clip = SkRect::Make(op.devBounds);
        fCurrentClipBounds =
            this->adjustForSaveLayerPaints(&clip, kSavesToIgnore) ? clip : fCullRect;
    }

    // We also take advantage of SaveLayer bounds when present to further cut the clip down.
    void updateClipBounds(const SaveLayer& op)  {
        if (op.bounds) {
            // adjustAndMap() intersects these layer bounds with the previous clip for us.
            fCurrentClipBounds = this->adjustAndMap(*op.bounds, op.paint);
        }
    }

    // The bounds of these ops must be calculated when we hit the Restore
    // from the bounds of the ops in the same Save block.
    void trackBounds(const Save&)          { this->pushSaveBlock(NULL); }
    void trackBounds(const SaveLayer& op)  { this->pushSaveBlock(op.paint); }
    void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(); }

    void trackBounds(const SetMatrix&)         { this->pushControl(); }
    void trackBounds(const ClipRect&)          { this->pushControl(); }
    void trackBounds(const ClipRRect&)         { this->pushControl(); }
    void trackBounds(const ClipPath&)          { this->pushControl(); }
    void trackBounds(const ClipRegion&)        { this->pushControl(); }
    void trackBounds(const PushCull&)          { this->pushControl(); }
    void trackBounds(const PopCull&)           { this->pushControl(); }
    void trackBounds(const BeginCommentGroup&) { this->pushControl(); }
    void trackBounds(const AddComment&)        { this->pushControl(); }
    void trackBounds(const EndCommentGroup&)   { this->pushControl(); }
    void trackBounds(const DrawData&)          { this->pushControl(); }

    // For all other ops, we can calculate and store the bounds directly now.
    template <typename T> void trackBounds(const T& op) {
        fBounds[fCurrentOp] = this->bounds(op);
        this->updateSaveBounds(fBounds[fCurrentOp]);
    }

    void pushSaveBlock(const SkPaint* paint) {
        // Starting a new Save block.  Push a new entry to represent that.
        SaveBounds sb;
        sb.controlOps = 0;
        // If the paint affects transparent black, the bound shouldn't be smaller
        // than the current clip bounds.
        sb.bounds =
            PaintMayAffectTransparentBlack(paint) ? fCurrentClipBounds : Bounds::MakeEmpty();
        sb.paint = paint;

        fSaveStack.push(sb);
        this->pushControl();
    }

    static bool PaintMayAffectTransparentBlack(const SkPaint* paint) {
        if (paint) {
            // FIXME: this is very conservative
            if (paint->getImageFilter() || paint->getColorFilter()) {
                return true;
            }

            // Unusual Xfermodes require us to process a saved layer
            // even with operations outisde the clip.
            // For example, DstIn is used by masking layers.
            // https://code.google.com/p/skia/issues/detail?id=1291
            // https://crbug.com/401593
            SkXfermode* xfermode = paint->getXfermode();
            SkXfermode::Mode mode;
            // SrcOver is ok, and is also the common case with a NULL xfermode.
            // So we should make that the fast path and bypass the mode extraction
            // and test.
            if (xfermode && xfermode->asMode(&mode)) {
                switch (mode) {
                    // For each of the following transfer modes, if the source
                    // alpha is zero (our transparent black), the resulting
                    // blended alpha is not necessarily equal to the original
                    // destination alpha.
                    case SkXfermode::kClear_Mode:
                    case SkXfermode::kSrc_Mode:
                    case SkXfermode::kSrcIn_Mode:
                    case SkXfermode::kDstIn_Mode:
                    case SkXfermode::kSrcOut_Mode:
                    case SkXfermode::kDstATop_Mode:
                    case SkXfermode::kModulate_Mode:
                        return true;
                        break;
                    default:
                        break;
                }
            }
        }
        return false;
    }

    Bounds popSaveBlock() {
        // We're done the Save block.  Apply the block's bounds to all control ops inside it.
        SaveBounds sb;
        fSaveStack.pop(&sb);

        while (sb.controlOps --> 0) {
            this->popControl(sb.bounds);
        }

        // This whole Save block may be part another Save block.
        this->updateSaveBounds(sb.bounds);

        // If called from a real Restore (not a phony one for balance), it'll need the bounds.
        return sb.bounds;
    }

    void pushControl() {
        fControlIndices.push(fCurrentOp);
        if (!fSaveStack.isEmpty()) {
            fSaveStack.top().controlOps++;
        }
    }

    void popControl(const Bounds& bounds) {
        fBounds[fControlIndices.top()] = bounds;
        fControlIndices.pop();
    }

    void updateSaveBounds(const Bounds& bounds) {
        // If we're in a Save block, expand its bounds to cover these bounds too.
        if (!fSaveStack.isEmpty()) {
            fSaveStack.top().bounds.join(bounds);
        }
    }

    // FIXME: this method could use better bounds
    Bounds bounds(const DrawText&) const { return fCurrentClipBounds; }

    Bounds bounds(const Clear&) const { return fCullRect; }             // Ignores the clip.
    Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; }
    Bounds bounds(const NoOp&)  const { return Bounds::MakeEmpty(); }    // NoOps don't draw.

    Bounds bounds(const DrawSprite& op) const {
        const SkBitmap& bm = op.bitmap;
        return Bounds::MakeXYWH(op.left, op.top, bm.width(), bm.height());  // Ignores the matrix.
    }

    Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); }
    Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); }
    Bounds bounds(const DrawRRect& op) const {
        return this->adjustAndMap(op.rrect.rect(), &op.paint);
    }
    Bounds bounds(const DrawDRRect& op) const {
        return this->adjustAndMap(op.outer.rect(), &op.paint);
    }
    Bounds bounds(const DrawImage& op) const {
        const SkImage* image = op.image;
        SkRect rect = SkRect::MakeXYWH(op.left, op.top, image->width(), image->height());

        return this->adjustAndMap(rect, op.paint);
    }
    Bounds bounds(const DrawImageRect& op) const {
        return this->adjustAndMap(op.dst, op.paint);
    }
    Bounds bounds(const DrawBitmapRectToRect& op) const {
        return this->adjustAndMap(op.dst, op.paint);
    }
    Bounds bounds(const DrawBitmapNine& op) const {
        return this->adjustAndMap(op.dst, op.paint);
    }
    Bounds bounds(const DrawBitmap& op) const {
        const SkBitmap& bm = op.bitmap;
        return this->adjustAndMap(SkRect::MakeXYWH(op.left, op.top, bm.width(), bm.height()),
                                  op.paint);
    }
    Bounds bounds(const DrawBitmapMatrix& op) const {
        const SkBitmap& bm = op.bitmap;
        SkRect dst = SkRect::MakeWH(bm.width(), bm.height());
        op.matrix.mapRect(&dst);
        return this->adjustAndMap(dst, op.paint);
    }

    Bounds bounds(const DrawPath& op) const {
        return op.path.isInverseFillType() ? fCurrentClipBounds
                                           : this->adjustAndMap(op.path.getBounds(), &op.paint);
    }
    Bounds bounds(const DrawPoints& op) const {
        SkRect dst;
        dst.set(op.pts, op.count);

        // Pad the bounding box a little to make sure hairline points' bounds aren't empty.
        SkScalar stroke = SkMaxScalar(op.paint.getStrokeWidth(), 0.01f);
        dst.outset(stroke/2, stroke/2);

        return this->adjustAndMap(dst, &op.paint);
    }
    Bounds bounds(const DrawPatch& op) const {
        SkRect dst;
        dst.set(op.cubics, SkPatchUtils::kNumCtrlPts);
        return this->adjustAndMap(dst, &op.paint);
    }
    Bounds bounds(const DrawVertices& op) const {
        SkRect dst;
        dst.set(op.vertices, op.vertexCount);
        return this->adjustAndMap(dst, &op.paint);
    }

    Bounds bounds(const DrawPicture& op) const {
        SkRect dst = op.picture->cullRect();
        if (op.matrix) {
            op.matrix->mapRect(&dst);
        }
        return this->adjustAndMap(dst, op.paint);
    }

    Bounds bounds(const DrawPosText& op) const {
        const int N = op.paint.countText(op.text, op.byteLength);
        if (N == 0) {
            return Bounds::MakeEmpty();
        }

        SkRect dst;
        dst.set(op.pos, N);
        AdjustTextForFontMetrics(&dst, op.paint);
        return this->adjustAndMap(dst, &op.paint);
    }
    Bounds bounds(const DrawPosTextH& op) const {
        const int N = op.paint.countText(op.text, op.byteLength);
        if (N == 0) {
            return Bounds::MakeEmpty();
        }

        SkScalar left = op.xpos[0], right = op.xpos[0];
        for (int i = 1; i < N; i++) {
            left  = SkMinScalar(left,  op.xpos[i]);
            right = SkMaxScalar(right, op.xpos[i]);
        }
        SkRect dst = { left, op.y, right, op.y };
        AdjustTextForFontMetrics(&dst, op.paint);
        return this->adjustAndMap(dst, &op.paint);
    }
    Bounds bounds(const DrawTextOnPath& op) const {
        SkRect dst = op.path.getBounds();

        // Pad all sides by the maximum padding in any direction we'd normally apply.
        SkRect pad = { 0, 0, 0, 0};
        AdjustTextForFontMetrics(&pad, op.paint);

        // That maximum padding happens to always be the right pad today.
        SkASSERT(pad.fLeft == -pad.fRight);
        SkASSERT(pad.fTop  == -pad.fBottom);
        SkASSERT(pad.fRight > pad.fBottom);
        dst.outset(pad.fRight, pad.fRight);

        return this->adjustAndMap(dst, &op.paint);
    }

    Bounds bounds(const DrawTextBlob& op) const {
        SkRect dst = op.blob->bounds();
        dst.offset(op.x, op.y);
        return this->adjustAndMap(dst, &op.paint);
    }

    static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) {
#ifdef SK_DEBUG
        SkRect correct = *rect;
#endif
        // crbug.com/373785 ~~> xPad = 4x yPad
        // crbug.com/424824 ~~> bump yPad from 2x text size to 2.5x
        const SkScalar yPad = 2.5f * paint.getTextSize(),
                       xPad = 4.0f * yPad;
        rect->outset(xPad, yPad);
#ifdef SK_DEBUG
        SkPaint::FontMetrics metrics;
        paint.getFontMetrics(&metrics);
        correct.fLeft   += metrics.fXMin;
        correct.fTop    += metrics.fTop;
        correct.fRight  += metrics.fXMax;
        correct.fBottom += metrics.fBottom;
        // See skia:2862 for why we ignore small text sizes.
        SkASSERTF(paint.getTextSize() < 0.001f || rect->contains(correct),
                  "%f %f %f %f vs. %f %f %f %f\n",
                  -xPad, -yPad, +xPad, +yPad,
                  metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom);
#endif
    }

    // Returns true if rect was meaningfully adjusted for the effects of paint,
    // false if the paint could affect the rect in unknown ways.
    static bool AdjustForPaint(const SkPaint* paint, SkRect* rect) {
        if (paint) {
            if (paint->canComputeFastBounds()) {
                *rect = paint->computeFastBounds(*rect, rect);
                return true;
            }
            return false;
        }
        return true;
    }

    bool adjustForSaveLayerPaints(SkRect* rect, int savesToIgnore = 0) const {
        for (int i = fSaveStack.count() - 1 - savesToIgnore; i >= 0; i--) {
            if (!AdjustForPaint(fSaveStack[i].paint, rect)) {
                return false;
            }
        }
        return true;
    }

    // Adjust rect for all paints that may affect its geometry, then map it to identity space.
    Bounds adjustAndMap(SkRect rect, const SkPaint* paint) const {
        // Inverted rectangles really confuse our BBHs.
        rect.sort();

        // Adjust the rect for its own paint.
        if (!AdjustForPaint(paint, &rect)) {
            // The paint could do anything to our bounds.  The only safe answer is the current clip.
            return fCurrentClipBounds;
        }

        // Adjust rect for all the paints from the SaveLayers we're inside.
        if (!this->adjustForSaveLayerPaints(&rect)) {
            // Same deal as above.
            return fCurrentClipBounds;
        }

        // Map the rect back to identity space.
        fCTM->mapRect(&rect);

        // Nothing can draw outside the current clip.
        // (Only bounded ops call into this method, so oddballs like Clear don't matter here.)
        rect.intersect(fCurrentClipBounds);
        return rect;
    }

    // We do not guarantee anything for operations outside of the cull rect
    const SkRect fCullRect;

    // Conservative identity-space bounds for each op in the SkRecord.
    SkAutoTMalloc<Bounds> fBounds;

    // We walk fCurrentOp through the SkRecord, as we go using updateCTM()
    // and updateClipBounds() to maintain the exact CTM (fCTM) and conservative
    // identity-space bounds of the current clip (fCurrentClipBounds).
    unsigned fCurrentOp;
    const SkMatrix* fCTM;
    Bounds fCurrentClipBounds;

    // Used to track the bounds of Save/Restore blocks and the control ops inside them.
    SkTDArray<SaveBounds> fSaveStack;
    SkTDArray<unsigned>   fControlIndices;
};

}  // namespace SkRecords
예제 #28
0
void spline::drawRawData()
{
	drawData(rawPoints);
}
예제 #29
0
void spline::drawSpline()
{
	drawData(points);
}
예제 #30
0
파일: gpu.c 프로젝트: anumula2/g9impulse
void draw(uint32 address, uint16 width, uint16 height, int16 x, int16 y, bool isTransparent)
{
    //
    // we are assuming a screen of 160 addresses x 240 lines
    //
    uint32 destAddress;
    uint32 readAddress = address;
    int16 drawWidth = (int16)width;
    int16 drawHeight = (int16)height;

    int16 right;
    int16 bottom;
    
    //clear WDT, set WDT period to about 30 seconds, if no draw operation 
    //happens during that time, it is probably safe to assume that the system
    //has crashed and a restart is in order.
    // 
    ClrWdt();

    right = x + (int16)width;
    if (right > SCREEN_WIDTH)
    {
        //
        // right clipping
        //
        drawWidth -= (right - SCREEN_WIDTH);
        if (drawWidth <= 0)
            return;
    }

    if (x < 0)
    {
        //
        // left clipping
        //
        readAddress += (int32)(-x);

        drawWidth -= -x;
        if (drawWidth <= 0)
            return;
    }

    bottom = y + (int16)height;
    if (bottom > SCREEN_HEIGHT)
    {
        //
        // bottom clipping
        //
        drawHeight -= (bottom - SCREEN_HEIGHT);
        if (drawHeight <= 0)
            return;
    }

    if (y < 0)
    {
        //
        // top clipping
        //
        readAddress += (int32)((int32)(-y) * SCREEN_WIDTH);

        drawHeight -= -y;
        if (drawHeight <= 0)
            return;
    }

    destAddress = max(y, 0) * SCREEN_WIDTH + max(x, 0);

    load_t_addr(destAddress);
    load_s_addr(readAddress);
    load_s_lines(drawHeight);
    load_l_size(drawWidth);

    load_alphaOp(isTransparent);

    drawData();
}