本文整理汇总了C++中plot函数的典型用法代码示例。如果您正苦于以下问题:C++ plot函数的具体用法?C++ plot怎么用?C++ plot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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);
}
示例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
}
示例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);
}
示例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);
//.........这里部分代码省略.........
示例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);
示例7: plot
void GeomGlut::plot( GLfloat x, GLfloat y )
{
plot(x, y, DEFAULT_SIZE_POINT);
}
示例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");
//.........这里部分代码省略.........
示例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);
}
示例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");
}
示例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);
//.........这里部分代码省略.........
示例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");
}
示例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
}
示例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;
//.........这里部分代码省略.........
示例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;
}
//.........这里部分代码省略.........