• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ plot函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中plot函数的典型用法代码示例。如果您正苦于以下问题:C++ plot函数的具体用法?C++ plot怎么用?C++ plot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了plot函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: plot

void ArrowMarker::setBoundingRect(double xs, double ys, double xe, double ye) {
  if (d_rect.left() == xs && d_rect.top() == ys && d_rect.right() == xe &&
      d_rect.bottom() == ye)
    return;

  d_rect.setLeft(xs);
  d_rect.setTop(ys);
  d_rect.setRight(xe);
  d_rect.setBottom(ye);

  if (!plot())
    return;

  plot()->updateLayout();
  d_start =
      QPoint(plot()->transform(xAxis(), xs), plot()->transform(yAxis(), ys));
  d_end =
      QPoint(plot()->transform(xAxis(), xe), plot()->transform(yAxis(), ye));
}
开发者ID:DanNixon,项目名称:mantid,代码行数:19,代码来源:ArrowMarker.cpp


示例2: run

function run()
{
	set(PLOTNOW);
	NumYears = 1;
	MaxBars = 210;
	PlotScale = 8;
	PlotWidth = 800;
	PlotHeight1 = 350;
	PlotHeight2 = 80;
	vars Price = series(price());
	
// plot Bollinger bands
	BBands(Price,30,2,2,MAType_SMA);
	plot("Bollinger1",rRealUpperBand,BAND1,0x00CC00);
	plot("Bollinger2",rRealLowerBand,BAND2,0xCC00FF00);
	plot("SAR",SAR(0.02,0.02,0.2),DOT,RED);
	ZigZag(Price,20*PIP,5,BLUE);
	
// plot some other indicators	
	plot("ATR (PIP)",ATR(20)/PIP,NEW,RED);
	plot("Doji",CDLDoji(),NEW+BARS,BLUE);
	plot("FractalDim",FractalDimension(Price,30),NEW,RED);
	plot("ShannonGain",ShannonGain(Price,40),NEW,RED);
}
开发者ID:czarcrab,项目名称:Zorro,代码行数:24,代码来源:IndicatorTest.c


示例3: plot

void QtDensity::runRandomDataCmd(void) {
    std::string cmd = "y <- " + m_cmd.toStdString();
    m_R.parseEvalQ(cmd);
    plot();                     // after each random draw, update plot with estimate
}
开发者ID:lab616,项目名称:third_party,代码行数:5,代码来源:qtdensity.cpp


示例4: while

void Mandelbrot::generate(int maxIterations, unsigned int ty, unsigned int height)
{
    double real = (m_maxReal - m_minReal) / m_width;
    double imag = (m_maxImag - m_minImag) / m_height;

    for(unsigned int x = 0; x < m_width; x++)
    {
        for(unsigned int y = ty; y < height; y++)
        {
            double cx = m_minReal + x * real + m_center.x * real; 
            double cy = m_maxImag - y * imag - m_center.y * imag;

            double zx = cx;
            double zy = cy;

            int iteration = 0;

            while(zx*zx + zy*zy < 4 && iteration < maxIterations)
            {
                double tempX = zx*zx - zy*zy + cx;
                double tempY = 2 * zx * zy + cy;

                if(zx == tempX && zy == tempY) {
                    iteration = maxIterations;
                    break;
                }

                zx = tempX;
                zy = tempY;

                iteration++;
            }

            if(iteration == maxIterations)
                plot(x, y, sf::Color::Black);
            else 
            {
                sf::Color color;

                if (iteration == maxIterations) {
                  color = sf::Color(0, 0, 0);
                } else if (iteration < 64) {
                  color = sf::Color(iteration * 2, 0, 0);
                } else if (iteration < 128) {
                  color = sf::Color((((iteration - 64) * 128) / 126) + 128, 0, 0);
                } else if (iteration < 256) {
                  color = sf::Color((((iteration - 128) * 62) / 127) + 193, 0, 0); 
                } else if (iteration < 512) {
                  color = sf::Color(255, (((iteration - 256) * 62) / 255) + 1, 0);
                } else if (iteration < 1024) {
                  color = sf::Color(255, (((iteration - 512) * 63) / 511) + 64, 0);
                } else if (iteration < 2048) {
                  color = sf::Color(255, (((iteration - 1024) * 63) / 1023) + 128, 0);
                } else if (iteration < 4096) {
                  color = sf::Color(255, (((iteration - 2048) * 63) / 2047) + 192, 0);
                } else {
                  color = sf::Color(iteration, iteration, 0);
                }

                plot(x, y, color);
            }
        }
    }

    m_texture.update(m_pixels);
}
开发者ID:tobsa,项目名称:Mandelbrot-Fractal,代码行数:66,代码来源:Mandelbrot.cpp


示例5: plot

void LegendItem::paint(QPainter *painter) {
  if (!isVisible()) {
    return;
  }

  RelationList legendItems;
  if (_auto) {
    legendItems = plot()->renderItem(PlotRenderItem::Cartesian)->relationList();
  } else {
    legendItems = _relations;
  }

  int count = legendItems.count();
  if (count <= 0) { // no legend or box if there are no legend items
    return;
  }


  QFont font(_font);
  font.setPointSizeF(view()->scaledFontSize(_fontScale, *painter->device()));

  painter->setFont(font);

  // generate string list of relation names
  QStringList names;
  bool allAuto = true;
  bool sameX = true;
  bool sameYUnits = true;

  LabelInfo label_info = legendItems.at(0)->xLabelInfo();
  QString yUnits =  legendItems.at(0)->yLabelInfo().units;

  for (int i = 0; i<count; i++) {
    RelationPtr relation = legendItems.at(i);
    if (relation->descriptiveNameIsManual()) {
      allAuto = false;
    }
    if (relation->xLabelInfo() != label_info) {
      sameX = false;
    }
    // sameYUnits is false if any non empty units are defined differently.
    if (yUnits.isEmpty()) {
      yUnits = relation->yLabelInfo().units;
    } else if (relation->yLabelInfo().units != yUnits) {
      if (!relation->yLabelInfo().units.isEmpty()) {
        sameYUnits = false;
      }
    }
  }

  if (!allAuto) {
    for (int i = 0; i<count; i++) {
      names.append(legendItems.at(i)->descriptiveName());
    }
  } else {
    for (int i = 0; i<count; i++) {
      RelationPtr relation = legendItems.at(i);
      QString label = relation->titleInfo().singleRenderItemLabel();
      if (label.isEmpty()) {
        label_info = relation->yLabelInfo();
        QString y_label = label_info.name;
        if (!sameYUnits) {
          if (!label_info.units.isEmpty()) {
            y_label = tr("%1 \\[%2\\]", "axis labels.  %1 is quantity, %2 is units.  eg Time [s].  '[' must be escaped.").arg(y_label).arg(label_info.units);
          }
        }
        if (!y_label.isEmpty()) {
          LabelInfo xlabel_info = relation->xLabelInfo();
          if (!sameX) {
            label = tr("%1 vs %2", "describes a plot. %1 is X axis.  %2 is Y axis").arg(y_label).arg(xlabel_info.name);
          } else if (xlabel_info.quantity.isEmpty()) {
            label = y_label;
          } else if (xlabel_info.quantity != xlabel_info.name) {
            label = tr("%1 vs %2", "describes a plot. %1 is X axis.  %2 is Y axis").arg(y_label).arg(xlabel_info.name);
          } else {
            label = y_label;
          }
        } else {
          label = relation->descriptiveName();
        }
      }
      int i_dup = names.indexOf(label);
      if (i_dup<0) {
        names.append(label);
      } else {
        RelationPtr dup_relation = legendItems.at(i_dup);
        if (!dup_relation->yLabelInfo().file.isEmpty()) {
          names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().escapedFile() + ')');
        }
        if (!relation->yLabelInfo().file.isEmpty()) {
          names.append(label + " (" + relation->yLabelInfo().escapedFile() + ')');
        }
      }
    }
  }


  QSize legendSize(0, 0);
  QSize titleSize(0,0);
  Label::Parsed *parsed = Label::parse(_title);
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:kst-plot,代码行数:101,代码来源:legenditem.cpp


示例6: main


//.........这里部分代码省略.........
        //
        epochs=0;

        unsigned last_best_perc_epoch=0;
        unsigned last_sync_epoch=0;
        unsigned last_ftest_secs=0;

        last_sync_epoch=0;
        last_best_perc_epoch=0;
        if (good_ann)
            fann_destroy(good_ann);

        good_ann=fann_copy(ann);
        unlink(histfile);
        for (u=0;u<1000;u++)
        {
            fflush(NULL);
            train_mse=fann_train_epoch(ann, train_data);

            if (jitter_train)
                apply_jjit(train_data,cln_train_data);


            if (time(NULL)-last_ftest_secs>=1)
            {
                //printf("\r\n%5u %9.6f %5.2f ",epochs,train_mse,test_perc);
                //printf(" %4.2f",test_perc);
                printf(".");


                last_ftest_secs=time(NULL);
            }
            ftest_data();
            plot(epochs,train_mse,test_mse);

            /*         if (epochs>10&&((int)test_perc==43||(int)test_perc==57))
                    {
                        printf(" [excluded %.2f] ",test_perc);
                        break;
                    }            else            {

                    } */
            //printf("excluded %f ",test_perc);

            double prev_test_perc;
            //   if (prev_epoch_mse==best_perc)
            //  printf("o");
            if ((int)test_perc>(int)train_perc&&epochs-last_stat_epoch>10)
            {
                fann_destroy(good_ann);
                good_ann=fann_copy(ann);

                if (test_perc!=prev_test_perc)
                    printf("%.2f [%f]",test_perc,train_mse);

                //printf(" sync[%4.2f]",test_perc);
                last_stat_epoch=epochs;
            }
            else 	if (epochs-last_sync_epoch>111500)
            {
                last_sync_epoch=epochs;
            }
            if (epochs>210&&test_perc>best_perc)
            {
                //	u--;
                //  fann_destroy(good_ann);
开发者ID:kilitary,项目名称:fann-related,代码行数:67,代码来源:mutate.cpp


示例7: plot

void GeomGlut::plot( GLfloat x, GLfloat y )
{
    plot(x, y, DEFAULT_SIZE_POINT);
}
开发者ID:Edstr,项目名称:AlgoNum,代码行数:4,代码来源:GeomGlut.cpp


示例8: compare_Mtt_distribution_fitting

void compare_Mtt_distribution_fitting(){

  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gStyle->SetPadRightMargin(0.03);
  gStyle->SetPadLeftMargin(0.16);


  TFile *file;
  TH1F* h_vbf_tight[3];
  TH1F* h_vbf_loose[3];
  TH1F* h_1jet[3];
  TH1F* h_vbf_tight_signal[3];
  TH1F* h_vbf_loose_signal[3];
  TH1F* h_1jet_signal[3];


  /*
   * VBF tight category for 8TeV
   */

  for(int ichannel=0; ichannel < 3; ichannel++){
     
    TString fname = file_8TeV[ichannel];
    file = new TFile(fname);
    
    TString getname = ch_name[ichannel];
    getname += "_vbf_tight/";
    TString name = getname + process_name[ichannel];
    h_vbf_tight[ichannel] = (TH1F*) file->Get(name);

    // signal 

    TString sname = getname;
    sname += "ggH125";
    h_vbf_tight_signal[ichannel] = (TH1F*) file->Get(sname);

    sname = getname;
    sname += "qqH125";
    h_vbf_tight_signal[ichannel]->Add((TH1F*) file->Get(sname));
    
    sname = getname;
    sname += "VH125";
    h_vbf_tight_signal[ichannel]->Add((TH1F*) file->Get(sname));


    //////////////////////////

    getname = ch_name[ichannel];
    getname += "_vbf_loose/";
    TString name = getname + process_name[ichannel];
    h_vbf_loose[ichannel] = (TH1F*) file->Get(name);

    // signal

    sname = getname;
    sname += "ggH125";
    h_vbf_loose_signal[ichannel] = (TH1F*) file->Get(sname);

    sname = getname;
    sname += "qqH125";
    h_vbf_loose_signal[ichannel]->Add((TH1F*) file->Get(sname));
    
    sname = getname;
    sname += "VH125";
    h_vbf_loose_signal[ichannel]->Add((TH1F*) file->Get(sname));
				

    /////////////////////////


    getname = ch_name[ichannel];
    if(ichannel==2) getname += "_1jet_high/";
    else getname += "_1jet_high_mediumhiggs/";

    TString name = getname + process_name[ichannel];
    h_1jet[ichannel] = (TH1F*) file->Get(name);

    
    // signal

    sname = getname;
    sname += "ggH125";
    h_1jet_signal[ichannel] = (TH1F*) file->Get(sname);

    sname = getname;
    sname += "qqH125";
    h_1jet_signal[ichannel]->Add((TH1F*) file->Get(sname));
    
    sname = getname;
    sname += "VH125";
    h_1jet_signal[ichannel]->Add((TH1F*) file->Get(sname));
				
  }



  plot(h_vbf_tight_signal, h_vbf_tight, "VBF_tight","8TeV");
  plot(h_vbf_loose_signal, h_vbf_loose, "VBF_loose","8TeV");
  plot(h_1jet_signal, h_1jet, "1jet_high","8TeV");
//.........这里部分代码省略.........
开发者ID:gitytakahas,项目名称:YutaMemo,代码行数:101,代码来源:compare_Mtt_distribution_fitting.C


示例9: drawvect


//.........这里部分代码省略.........

    if (zoomit != DO_WARP) {
	Curses_clear_window(INFO_WINDOW);
	Curses_write_window(INFO_WINDOW, 1, 13, "COORDINATES");
	Curses_write_window(INFO_WINDOW, 3, 2, "MAIN WINDOW");

	sprintf(msg, "N = %10.2f   E = %10.2f", VIEW_MAP2->cell.head.north,
		VIEW_MAP2->cell.head.east);
	Curses_write_window(INFO_WINDOW, 5, 4, msg);
	sprintf(msg, "S = %10.2f   W = %10.2f", VIEW_MAP2->cell.head.south,
		VIEW_MAP2->cell.head.west);
	Curses_write_window(INFO_WINDOW, 6, 4, msg);

	Curses_write_window(INFO_WINDOW, 9, 2, "ZOOM WINDOW");
	sprintf(msg, "N = %10.2f   E = %10.2f",
		VIEW_MAP2_ZOOM->cell.head.north,
		VIEW_MAP2_ZOOM->cell.head.east);
	Curses_write_window(INFO_WINDOW, 11, 4, msg);
	sprintf(msg, "S = %10.2f   W = %10.2f",
		VIEW_MAP2_ZOOM->cell.head.south,
		VIEW_MAP2_ZOOM->cell.head.west);
	Curses_write_window(INFO_WINDOW, 12, 4, msg);
    }

    if (zoomit) {		/* ie ! DO_NEW */

	dsp_setup(blank, &cellhd);

	for (i = 0; i < numfiles; i++) {
	    sprintf(msg, "Displaying %s", vect_file[i]);
	    Menu_msg(msg);
	    R_standard_color(vectclr[i]);
	    if (zoomit != DO_WARP)
		stat = plot(vect_file[i], vect_mapset[i], Points);
	    else
		stat = plot_warp(vect_file[i], vect_mapset[i],
				 Points, E, N, trans_order);
	}
    }
    else {			/* ie DO_NEW */

	if (numfiles == 1) {	/* let first file set window */
	    G_copy(&VIEW_MAP2->cell.head, &cellhd, sizeof(cellhd));

	    cellhd.rows = VIEW_MAP2->nrows;
	    cellhd.cols = VIEW_MAP2->ncols;
	    cellhd.ns_res = (cellhd.north - cellhd.south) / cellhd.rows;
	    cellhd.ew_res = (cellhd.east - cellhd.west) / cellhd.cols;
	    if (cellhd.ns_res > cellhd.ew_res)
		cellhd.ew_res = cellhd.ns_res;
	    else
		cellhd.ns_res = cellhd.ew_res;

	    VIEW_MAP2->cell.ns_res = cellhd.ns_res;
	    VIEW_MAP2->cell.ew_res = cellhd.ew_res;

	    G_copy(&VIEW_MAP2->cell.head, &cellhd, sizeof(cellhd));

	    G_adjust_window_to_box(&cellhd, &VIEW_MAP2->cell.head,
				   VIEW_MAP2->nrows, VIEW_MAP2->ncols);

	    if (!cellmap_present) {
		Configure_view(VIEW_MAP2, vect_file[numfiles - 1],
			       vect_mapset[numfiles - 1], cellhd.ns_res,
			       cellhd.ew_res);
	    }
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:67,代码来源:drawvect.c


示例10: main

int main() {

  //Basic Matrix Math
  struct matrix *a;
  struct matrix *b;

  a=new_matrix(4,4);
  b=new_matrix(4,2);
 
  
  printf("Identity matrix:\n");
  ident(a);
  print_matrix(a);
  
  b->m[0][0]=1;
  b->m[0][1]=2;
  b->m[1][0]=3;
  b->m[1][1]=4;
  b->m[2][0]=5;
  b->m[2][1]=6;
  b->m[3][0]=7;
  b->m[3][1]=8;
  
  printf("Matrix #2:\n");
  print_matrix(b);
  
  printf("Scalar Multiplication by 2:\n");
  scalar_mult(2, b);
  print_matrix(b);
  
  printf("New Matrix #1:\n");
  a->m[2][1]=3;
  a->m[0][3]=2;
  print_matrix(a);
  
  printf("Matrix Multiplication:\n");
  matrix_mult(a, b);
  print_matrix(b);

  printf("Adding points/edges:\n");
  struct matrix *d;
  d = new_matrix(3, 3);
  add_point(d, 200,400,70);
  add_point(d, 200,0,7);
  print_matrix(d);
  printf("\n");
  add_edge(d, 300,500,100,300,100,134);
  add_edge(d, 100,500,100,100,100,134);
  add_edge(d, 400,00,100,400,400,134);
  print_matrix(d);
  printf("\n");


  screen s;
  color c;

  c.red = 200;
  c.green = 100;
  c.blue = 250;

  int i, j;



  for( i=0; i<XRES; i++) 
    for ( j=0; j<YRES; j++) {
      plot( s, c, i, j);
    }

  c.red=0;
  c.green=200;
  c.blue=200;

  draw_lines(d, s, c);
 
  display( s );    
  save_ppm(s,  "image" );
  save_extension(s, "image.jpg");
  
}  
开发者ID:stuydw,项目名称:matrix,代码行数:80,代码来源:main.c


示例11: testPaintAttribute

void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground ) 
{
    bool hackStyledBackground = false;

    if ( withBackground && testAttribute( Qt::WA_StyledBackground ) 
        && testPaintAttribute( HackStyledBackground ) )
    {
        // Antialiasing rounded borders is done by
        // inserting pixels with colors between the 
        // border color and the color on the canvas,
        // When the border is painted before the plot items
        // these colors are interpolated for the canvas
        // and the plot items need to be clipped excluding
        // the anialiased pixels. In situations, where
        // the plot items fill the area at the rounded
        // borders this is noticeable.
        // The only way to avoid these annoying "artefacts"
        // is to paint the border on top of the plot items.

        if ( d_data->styleSheet.hasBorder &&
            !d_data->styleSheet.borderPath.isEmpty() )
        {
            // We have a border with at least one rounded corner
            hackStyledBackground = true;
        }
    }

    if ( withBackground )
    {
        painter->save();

        if ( testAttribute( Qt::WA_StyledBackground ) )
        {
            if ( hackStyledBackground )
            {
                // paint background without border

                painter->setPen( Qt::NoPen );
                painter->setBrush( d_data->styleSheet.background.brush ); 
                painter->setBrushOrigin( d_data->styleSheet.background.origin );
                painter->setClipPath( d_data->styleSheet.borderPath );
                painter->drawRect( contentsRect() );
            }
            else
            {
                qwtDrawStyledBackground( this, painter );
            }
        }
        else if ( autoFillBackground() )
        {
            painter->setPen( Qt::NoPen );
            painter->setBrush( palette().brush( backgroundRole() ) );

            if ( d_data->borderRadius > 0.0 && ( rect() == frameRect() ) )
            {
                if ( frameWidth() > 0 )
                {
                    painter->setClipPath( borderPath( rect() ) );
                    painter->drawRect( rect() );
                }
                else
                {
                    painter->setRenderHint( QPainter::Antialiasing, true );
                    painter->drawPath( borderPath( rect() ) );
                }
            }
            else
            {
                painter->drawRect( rect() );
            }
        }

        painter->restore();
    }

    painter->save();

    if ( !d_data->styleSheet.borderPath.isEmpty() )
    {
        painter->setClipPath( 
            d_data->styleSheet.borderPath, Qt::IntersectClip );
    }
    else
    {
        if ( d_data->borderRadius > 0.0 )
            painter->setClipPath( borderPath( frameRect() ), Qt::IntersectClip );
        else
            painter->setClipRect( contentsRect(), Qt::IntersectClip );
    }

    plot()->drawCanvas( painter );

    painter->restore();

    if ( withBackground && hackStyledBackground )
    {
        // Now paint the border on top
        QStyleOptionFrame opt;
        opt.initFrom(this);
        style()->drawPrimitive( QStyle::PE_Frame, &opt, painter, this);
//.........这里部分代码省略.........
开发者ID:Alex-Rongzhen-Huang,项目名称:OpenPilot,代码行数:101,代码来源:qwt_plot_canvas.cpp


示例12: main

int main() {

  screen s;
  color c;
 
  
  c.red = 0;
  c.green = 0;
  c.blue = 0;
  
  clear_screen(s);

  int i, j;

  for (i=0; i < YRES; i++)
    for (j=0; j < XRES; j++ )
      plot(s, c, i, j);
  
   c.green = MAX_COLOR;
  draw_line(250, 0, 250, 500, s, c);
  draw_line(125, 0, 375, 500, s, c);
  draw_line(0, 0, 500, 500, s, c);
  draw_line(0, 125, 500, 375, s, c);
  draw_line(0, 250, 500, 250, s, c);
  draw_line(0, 375, 500, 125, s, c);
  draw_line(0, 500, 500, 0, s, c);
  draw_line(125, 500, 375, 0, s, c);

  /*  c.green = 0;
  c.red = MAX_COLOR;

  draw_line(125, 0, 125, 250, s, c);
  draw_line(62, 0, 187, 250, s, c);
  draw_line(0, 0, 250, 250, s, c);
  draw_line(0, 62, 250, 187, s, c);
  draw_line(0, 125, 250, 125, s, c);
  draw_line(0, 187, 250, 62, s, c);
  draw_line(0, 250, 250, 0, s, c);
  draw_line(62, 250, 187, 0, s, c);

  c.red = 0;
  c.blue = MAX_COLOR;

  draw_line(375, 0, 375, 250, s, c);
  draw_line(312, 0, 427, 250, s, c);
  draw_line(250, 0, 500, 250, s, c);
  draw_line(250, 62, 500, 187, s, c);
  draw_line(250, 125, 500, 125, s, c);
  draw_line(250, 187, 500, 62, s, c);
  draw_line(250, 250, 500, 0, s, c);
  draw_line(312, 250, 427, 0, s, c);

  c.red = MAX_COLOR;

  draw_line(125, 250, 125, 500, s, c);
  draw_line(62, 250, 187, 500, s, c);
  draw_line(0, 250, 250, 500, s, c);
  draw_line(0, 312, 250, 427, s, c);
  draw_line(0, 375, 500, 375, s, c);
  draw_line(0, 427, 250, 312, s, c);
  draw_line(0, 500, 250, 250, s, c);
  draw_line(62, 500, 187, 250, s, c);

  c.blue = 0;
  c.green = MAX_COLOR;

  draw_line(375, 250, 375, 500, s, c);
  draw_line(312, 250, 427, 500, s, c);
  draw_line(250, 500, 500, 250, s, c);
  draw_line(250, 312, 500, 427, s, c);
  draw_line(250, 375, 500, 375, s, c);
  draw_line(250, 427, 500, 312, s, c);
  draw_line(250, 250, 500, 500, s, c);
  draw_line(312, 500, 427, 250, s, c);
  */

  //Note: Display may not work on your system
  //save_ppm and save_extension should be fine
  //display(s);
  save_ppm(s, "pic.ppm");
  save_extension(s, "whatevs.png");
}  
开发者ID:stuydw,项目名称:line,代码行数:82,代码来源:main.c


示例13: main

int main ()
{
#if defined(VISP_HAVE_DISPLAY)
  try {
    //Create a window with one graphic
    vpPlot plot(1);

    // Change the default font
    //plot.setFont("-misc-fixed-bold-r-semicondensed--0-0-75-75-c-0-iso8859-10");

    //The graphic contains 2 curves
    plot.initGraph(0,2);

    //Set the graphic parameters
    plot.setTitle(0, "First graphic");
    plot.setUnitX(0, "time (s)");
    plot.setUnitY(0, "y");
    plot.setUnitZ(0, "z");
    plot.setLegend(0,0, "y^2+z^2=1 and y(0) = 1");
    plot.setLegend(0,1, "y^2+z^2=1 and y(0) = -1");
    plot.setColor(0,0,vpColor::red);
    plot.setColor(0,1,vpColor::green);

    double x = 0;
    double y = 1;
    double z = 0 ;
    double dx = 0.08;
    double dy = 0.04;
    double zsign = 1.0;

    unsigned long iter = 0;

    std::cout << "Hit CTRL-C to or right mouse button to exit..." << std::endl;
    bool end = false;
    while( !end ) {
      if (iter < 300) {
        //y*y+z*z = 1
        if (fabs(y) < 1.0)
          z = sqrt(1.0-y*y);
        else z = 0;

        //Add points to the graphic
        if (plot.plot(0,0, x,  y,  z*zsign) == vpMouseButton::button3)
          end = true;
        if (plot.plot(0,1, x, -y, -z*zsign) == vpMouseButton::button3)
          end = true;

        x += dx;

        if (fabs(y) >= 1.0 )
          dy = -dy;
        y += dy;
        if (fabs(y) >= 1.0 )
          zsign = -zsign;
      }
      else {
        // Tip: to allows modifying the point of view with the mouse we
        // plot always the last point
        if (plot.plot(0,0, x, y,z*zsign) == vpMouseButton::button3)
          end = true;
        if (plot.plot(0,1, x, -y,-z*zsign) == vpMouseButton::button3)
          end = true;
      }
      iter ++;
    }
    return 0;
  }
  catch(vpException e) {
    std::cout << "Catch an exception: " << e << std::endl;
    return 1;
  }
#else
  std::cout << "Plot functionalities are not avalaible since no display is available." << std::endl;
#endif
}
开发者ID:tswang,项目名称:visp,代码行数:75,代码来源:plot3d.cpp


示例14: plot

void LegendItem::paint(QPainter *painter) {
  if (!isVisible()) {
    return;
  }

  RelationList legendItems;
  if (_auto) {
    legendItems = plot()->renderItem(PlotRenderItem::Cartesian)->relationList();
  } else {
    legendItems = _relations;
  }

  int count = legendItems.count();
  if (count <= 0) { // no legend or box if there are no legend items
    return;
  }


  QList<DrawnLegendItem> legendPixmaps;
  QSize legendSize(0, 0);

  QFont font(_font);
  font.setPointSizeF(view()->viewScaledFontSize(_fontScale));

  // generate string list of relation names
  QStringList names;
  bool allAuto = true;
  bool sameX = true;
  bool sameYUnits = true;

  LabelInfo label_info = legendItems.at(0)->xLabelInfo();
  QString yUnits =  legendItems.at(0)->yLabelInfo().units;

  for (int i = 0; i<count; i++) {
    RelationPtr relation = legendItems.at(i);
    if (relation->descriptiveNameIsManual()) {
      allAuto = false;
    }
    if (relation->xLabelInfo() != label_info) {
      sameX = false;
    }
    // sameYUnits is false if any non empty units are defined differently.
    if (yUnits.isEmpty()) {
      yUnits = relation->yLabelInfo().units;
    } else if (relation->yLabelInfo().units != yUnits) {
      if (!relation->yLabelInfo().units.isEmpty()) {
        sameYUnits = false;
      }
    }
  }

  if (!allAuto) {
    for (int i = 0; i<count; i++) {
      names.append(legendItems.at(i)->descriptiveName());
    }
  } else {
    for (int i = 0; i<count; i++) {
      RelationPtr relation = legendItems.at(i);
      QString label = relation->titleInfo().singleRenderItemLabel();
      if (label.isEmpty()) {
        label_info = relation->yLabelInfo();
        QString y_label = label_info.name;
        if (!sameYUnits) {
          if (!label_info.units.isEmpty()) {
            y_label = i18n("%1 \\[%2\\]").arg(y_label).arg(label_info.units);
          }
        }
        if (!y_label.isEmpty()) {
          LabelInfo xlabel_info = relation->xLabelInfo();
          if (!sameX) {
            label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
          } else if (xlabel_info.quantity.isEmpty()) {
            label = y_label;
          } else if (xlabel_info.quantity != xlabel_info.name) {
            label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
          } else {
            label = y_label;
          }
        } else {
          label = relation->descriptiveName();
        }
      }
      int i_dup = names.indexOf(label);
      if (i_dup<0) {
        names.append(label);
      } else {
        RelationPtr dup_relation = legendItems.at(i_dup);
        if (!dup_relation->yLabelInfo().file.isEmpty()) {
          names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().file + ')');
        }
        if (!relation->yLabelInfo().file.isEmpty()) {
          names.append(label + " (" + relation->yLabelInfo().file + ')');
        }
      }
    }
  }

  for (int i = 0; i<count; i++) {
    RelationPtr relation = legendItems.at(i);
    DrawnLegendItem item;
//.........这里部分代码省略.........
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:101,代码来源:legenditem.cpp


示例15: sp_setup_line

/**
 * Do setup for line rasterization, then render the line.
 * Single-pixel width, no stipple, etc.  We rely on the 'draw' module
 * to handle stippling and wide lines.
 */
void
sp_setup_line(struct setup_context *setup,
              const float (*v0)[4],
              const float (*v1)[4])
{
   int x0 = (int) v0[0][0];
   int x1 = (int) v1[0][0];
   int y0 = (int) v0[0][1];
   int y1 = (int) v1[0][1];
   int dx = x1 - x0;
   int dy = y1 - y0;
   int xstep, ystep;
   uint layer = 0;
   unsigned viewport_index = 0;

#if DEBUG_VERTS
   debug_printf("Setup line:\n");
   print_vertex(setup, v0);
   print_vertex(setup, v1);
#endif

   if (setup->softpipe->no_rast || setup->softpipe->rasterizer->rasterizer_discard)
      return;

   if (dx == 0 && dy == 0)
      return;

   if (!setup_line_coefficients(setup, v0, v1))
      return;

   assert(v0[0][0] < 1.0e9);
   assert(v0[0][1] < 1.0e9);
   assert(v1[0][0] < 1.0e9);
   assert(v1[0][1] < 1.0e9);

   if (dx < 0) {
      dx = -dx;   /* make positive */
      xstep = -1;
   }
   else {
      xstep = 1;
   }

   if (dy < 0) {
      dy = -dy;   /* make positive */
      ystep = -1;
   }
   else {
      ystep = 1;
   }

   assert(dx >= 0);
   assert(dy >= 0);
   assert(setup->softpipe->reduced_prim == PIPE_PRIM_LINES);

   setup->quad[0].input.x0 = setup->quad[0].input.y0 = -1;
   setup->quad[0].inout.mask = 0x0;
   if (setup->softpipe->layer_slot > 0) {
      layer = *(unsigned *)setup->vprovoke[setup->softpipe->layer_slot];
      layer = MIN2(layer, setup->max_layer);
   }
   setup->quad[0].input.layer = layer;

   if (setup->softpipe->viewport_index_slot > 0) {
      unsigned *udata = (unsigned*)setup->vprovoke[setup->softpipe->viewport_index_slot];
      viewport_index = sp_clamp_viewport_idx(*udata);
   }
   setup->quad[0].input.viewport_index = viewport_index;

   /* XXX temporary: set coverage to 1.0 so the line appears
    * if AA mode happens to be enabled.
    */
   setup->quad[0].input.coverage[0] =
   setup->quad[0].input.coverage[1] =
   setup->quad[0].input.coverage[2] =
   setup->quad[0].input.coverage[3] = 1.0;

   if (dx > dy) {
      /*** X-major line ***/
      int i;
      const int errorInc = dy + dy;
      int error = errorInc - dx;
      const int errorDec = error - dx;

      for (i = 0; i < dx; i++) {
         plot(setup, x0, y0);

         x0 += xstep;
         if (error < 0) {
            error += errorInc;
         }
         else {
            error += errorDec;
            y0 += ystep;
         }
//.........这里部分代码省略.........
开发者ID:ChristophHaag,项目名称:mesa-mesa,代码行数:101,代码来源:sp_setup.c


示例16: clear

void DeJong::reseed(){
    clear();
    seed();
    plot(1);
}
开发者ID:limzykenneth,项目名称:DeJong-lasercut,代码行数:5,代码来源:DeJong.cpp


示例17: main

int main() {

  screen s;
  color c;
  int i, j; 
  
  c.red = 0;
  c.green = MAX_COLOR;
  c.blue = 0;
  
  clear_screen(s);

  /*
  //octant 1
  draw_line( 0, 0, XRES-1, YRES - 75, s, c);  
  //  draw_line( XRES-1, YRES - 75, 0, 0, s, c);  

  //octant 2
  draw_line( 0, 0, XRES - 75, YRES-1, s, c); 
  //octant 8
  draw_line( 0, YRES-1, XRES-1, 75, s, c);  
  //octant 7
  draw_line( 0, YRES-1, XRES - 75, 0, s, c);

  c.green = 0;
  c.blue = MAX_COLOR;
  //octant 5
  draw_line( XRES - 1, YRES - 1, 0, 75, s, c);
  //octant 6
  draw_line( XRES - 1, YRES -1, 75, 0, s, c);
  //octant 4
  draw_line( XRES - 1, 0, 0, YRES - 75, s, c);
  //octant 3
  draw_line( XRES - 1, 0, 75, YRES - 1, s, c);
  
  c.blue = 0;
  c.red = MAX_COLOR;
  //y = x, y = -x
  draw_line( 0, 0, XRES - 1, YRES - 1, s, c);
  draw_line( 0, YRES - 1, XRES - 1, 0, s, c);

  //horizontal, vertical line
  draw_line( 0, YRES / 2, XRES - 1, YRES / 2, s, c);
  draw_line( XRES / 2, 0, XRES / 2, YRES - 1, s, c);

  draw_coord(s, c);
  draw_border(s, c);
  */
  c.red = MAX_COLOR;
  c.green = 0;
  c.blue = 0;
  for ( i = 0; i < XRES; i+=6 ) {
    draw_line( XRES / 2, YRES / 2, i, 0, s, c );
    c.red = c.red - 3;
    c.green = c.green + 3;
  }

  c.red = 0;
  c.green = MAX_COLOR;
  for ( i = 0; i < YRES; i+=6 ) {
    draw_line( XRES / 2, YRES / 2, YRES, i, s, c );
    c.green = c.green - 3;
    c.blue = c.blue + 3;
  }

  c.green = 0;
  c.blue = MAX_COLOR;
  for (i = 0; i < XRES; i+=6 ) {
    draw_line( XRES / 2, YRES /2, XRES - i, YRES, s, c );
    c.blue = c.blue - 3;
    c.green += 3;
    c.red += 3;
  }

  c.blue = 0;
  for (i = 0; i < XRES; i+=6 ) {
    draw_line( XRES / 2, YRES /2, 0, YRES - i, s, c );
    c.green -= 3;
  }

  for ( i = 0; i < XRES; i++ ) {
    for ( j = 0; j < YRES; j++ ) {
      if ( i % 100 <= 3 || j % 100 <= 3 ) {
	c.red = MAX_COLOR;
	c.green = MAX_COLOR / 2 + 50;
	c.blue = MAX_COLOR;
	plot (s, c, i, j);
      }
    }
  }

  for ( i = 0; i < XRES; i+=10 ) {
    c.red = 0;
    c.green = 0;
    c.blue = 0;
    draw_line( i, 0, 0, i, s, c );
    draw_line( i, 0, YRES - i, XRES, s, c );
    draw_line( 0, i, XRES, YRES - i, s, c );
  }

//.........这里部分代码省略.........
开发者ID:mayankvanjani,项目名称:mayank_el_lines,代码行数:101,代码来源:main.c


示例18: draw_line

void draw_line(int x0, int y0, int x1, int y1, screen s, color c) {
 
  int x, y, dx, dy, d, A, B;
  x = x0;
  y = y0;
  //swap values if octants 3-6
  if ( x0 > x1 ) {
    x = x1;
    y = y1;
    x1 = x0;
    y1 = y0;
  }

  dx = x1 - x;
  dy = y1 - y;
  A = dy * 2;
  B = -2 * dx;
    
  //positive slope: Octants 1,2
  if ( dy > 0 ) {

    //Octant 1
    if ( dx > dy ) {
      
      d = A + B/2;
      while ( x <= x1 ) {
	plot( s, c, x, y );
	if ( d > 0 ) {
	  y++;
	  d+= B;
	}
	x++;
	d+= A;
      }
    }// end octant 1

    //Octant 2
    else {
      
      d = A/2 + B;
      while ( y <= y1 ) {
	plot( s, c, x, y );
	if ( d < 0 ) {
	  x++;
	  d+=A;
	}
	y++;
	d+= B;
      }
    }//Octant 2
  }//octants: 1, 2
  
  //negative slope: Octants: 7, 8
  else {
    //Octant 8
    if ( dx > (-1 * dy) ) {
      d = A - B/2;
      while ( x <= x1 ) {
	plot(s, c, x, y);
	if ( d < 0 ) {
	  y--;
	  d-=B;
	}
	x++;
	d+= A;
      }
    }//end octant 8
    
    //octant 7
    else {
      d = A/2 - B;
      while( y >= y1 ) {
	plot(s, c, x, y);
	if ( d > 0 ) {
	  x++;
	  d+= A;
	}
	y--;
	d-= B;
      }
    } //end octant 7
  }//end Octants 7,8
}
开发者ID:stuydw,项目名称:matrix,代码行数:83,代码来源:draw.c


示例19: graph

graph (struct s_record r[])
{
int i, j;
long max, max_d;
char buf[200];
	if (!strncmp (buf, "CARBONE", 7))
		break_debug();
	/* printf ("%s", r[0].nom); */
	sprintf (buf, "%s", r[0].nom);
#ifdef TEST
#else
#ifdef LOWLEVEL
#else
/*	if (strncmp (buf, "SOPRA", 5)) */
	outtextxy (1, 1, buf);
#endif
#endif
	if (!strcmp (r[0].nom, "CARBONE LORRAINE"))
		restorecrtmode();

	max = 0;
        for (i=0; r[i].status; i++)
        {
                if (r[i].clot > max)
                        max = r[i].clot;
        }
        max_d = 0;
        for (i=1; r[i].status; i++)
        {
                if (r[i].dl > max_d)
                        max_d = r[i].dl;
                if (-r[i].dl > max_d)
                        max_d = -r[i].dl;
        }
        if (max == 0)
                max = 1;
        if (max_d == 0)
                max_d = 1;
        for (i=0; r[i].status; i++)
        {
                plot (i*10, HAUT + BAS - r[i].clot * BAS / max, 15);
                plot (i*10, AXE_X - r[i].dl * AXE_X / max_d / DIV_D, 15);
        }
        for (i=0; r[i+1].status; i++)
        {
                /* plot (i*4, 100-r[i].clot / 100, 1); */
                /* plot (i*10, 800 - r[i].clot, 15); */
                for (j=0; j<=N; j++)
                {
                        plot (i*10+j, HAUT + BAS - (r[i].l * (N-j) + r[i+1].l * j) / N * BAS / max, 7);
                        plot (XD0 + (r[i].dl * (N-j) + r[i+1].dl * j) * AXE_X / N / max_d / DIV_D,
                              HAUT + BAS - (r[i].l * (N-j) + r[i+1].l * j) / N * BAS / max, 7);
                        /*
                        plot (i*10+j, BAS - (r[i].dl * (N-j) + r[i+1].dl * j) / N * BAS / max, 6);
                        plot (i*10+j, BAS - (r[i].ldl * (N-j) + r[i+1].ldl * j) / N * BAS / max, 5);
                        */
                        plot (i*10+j, AXE_X, 6);
                        /* plot (i*10+j, AXE_X - (r[i].dl * (N-j) + r[i+1].dl * j) / N * AXE_X / max_d , 15); */
                        plot (i*10+j, AXE_X - (r[i].ldl * (N-j) + r[i+1].ldl * j) * AXE_X / N / max_d / DIV_D, 7);

                }
                /* printf ("%d\n", r[i].clot); */
                /* printf ("%d %d %d %d\n", r[i].clot, r[i].l, r[i].dl, r[i].ldl);  */
	}
	/*
	if (!strcmp (r[0].nom, "CARBONE LORRAINE"))
		restorecrtmode();
	*/

}
开发者ID:jbailhache,项目名称:log,代码行数:70,代码来源:nbourse.c


示例20: SARRERA_pantailenAukerak

void SARRERA_pantailenAukerak(int x, int y, int zabalera, int altuera, int pantailaKopurua){
	//aldagaiak
	int i = 0, t = 0;

	//programa

	borraCopiaPantalla();
	for (i = y; i < y + altuera; i++){
		for (t = x; t < x + zabalera; t++){
			plot(t, i, URDINA_FONDO);
		}
	}
	if (pantailaKopurua == 1){
		escribirTexto(225, 50, TITULOA);
		escribirTexto(150, 150, AUKERA0);
		escribirTexto(150, 200, EXIT);
	}
	if (pantailaKopurua == 2){
		escribirTexto(225, 50, TITULOA);
		escribirTexto(150, 150, AUKERA0);
		escribirTexto(150, 200, AUKERA1);
		escribirTexto(150, 250, EXIT);
	}
	if (pantailaKopurua == 3){
		escribirTexto(225, 50, TITULOA);
		escribirTexto(150, 150, AUKERA0);
		escribirTexto(150, 200, AUKERA1);
		escribirTexto(150, 250, AUKERA2);
		escribirTexto(150, 300, EXIT);
	}
	if (pantailaKopurua == 4){
		escribirTexto(225, 50, TITULOA);
		escribirTexto(150, 150, AUKERA0);
		escribirTexto(150, 200, AUKERA1);
		escribirTexto(150, 250, AUKERA2);
		escribirTexto(150, 300, AUKERA3);
		escribirTexto(150, 350, EXIT);
	}
	if (pantailaKopurua == 5){
		escribirTexto(225, 50, TITULOA);
		escribirTexto(150, 150, AUKERA0);
		escribirTexto(150, 200, AUKERA1);
		escribirTexto(150, 250, AUKERA2);
		escribirTexto(150, 300, AUKERA3);
		escribirTexto(150, 350, AUKERA4);
		escribirTexto(150, 400, EXIT);
	}
	if (pantailaKopurua == 6){
		escribirTexto(225, 50, TITULOA);
		escribirTexto(150, 150, AUKERA0);
		escribirTexto(150, 200, AUKERA1);
		escribirTexto(150, 250, AUKERA2);
		escribirTexto(150, 300, AUKERA3);
		escribirTexto(150, 350, AUKERA4);
		escribirTexto(150, 400, AUKERA5);
		escribirTexto(150, 450, EXIT);
	}
	if (pantailaKopurua == 7){

	}
	actualizaPantalla();
}
开发者ID:urrutiaitor,项目名称:POPBL1,

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ plotLayout函数代码示例发布时间:2022-05-30
下一篇:
C++ plonk_assert函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap