本文整理汇总了C++中cairo::RefPtr::move_to方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::move_to方法的具体用法?C++ RefPtr::move_to怎么用?C++ RefPtr::move_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo::RefPtr
的用法示例。
在下文中一共展示了RefPtr::move_to方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawObstacles
void MapDrawArea::DrawObstacles(const Cairo::RefPtr<Cairo::Context>& cr)
{
// Get size characteristics of the window
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
const int lesser = MIN(width, height);
// We should be able to just store the obstacles and path once
// Do need to update based on the window size
std::vector<Coord> vObstacles = guiMapData.copyObstacles();
Coord maxXY = guiMapData.copyMaxCoord();
Coord originCoord = guiMapData.copyStartCoord();
Coord goalCoord = guiMapData.copyEndCoord();
// These have to be updated each iteration
originCoord.x = int( float(width)*float(originCoord.x)/float(maxXY.x) );
originCoord.y = int( float(height)*float(originCoord.y)/float(maxXY.y) );
goalCoord.x = int( float(width)*float(goalCoord.x)/float(maxXY.x) );
goalCoord.y = int( float(height)*float(goalCoord.y)/float(maxXY.y) );
// Draw obstacles
std::vector<Coord> scaledObstacleCoord;
std::vector<Coord> rawObstacleCoord = guiMapData.copyObstacles();
Coord stdCoord;
// Adjust obstacle values based on window size
for(std::vector<Coord>::const_iterator itr=rawObstacleCoord.begin();itr!=rawObstacleCoord.end();++itr)
{
stdCoord.x = int( float(width)*float(itr->x)/float(maxXY.x) );
stdCoord.y = int( height*float(itr->y)/float(maxXY.y) );
scaledObstacleCoord.push_back(stdCoord);
}
cr->save();
cr->set_source_rgb(0.0, 0.0, 0.0); // black for obstacles
cr->set_line_width(lesser * 0.005);
cr->set_line_cap(Cairo::LINE_CAP_ROUND);
// Plot obstacles
for(std::vector<Coord>::iterator itr=scaledObstacleCoord.begin();itr != scaledObstacleCoord.end();++itr)
{
cr->move_to( itr->x,itr->y );
cr->line_to( itr->x,itr->y );
cr->stroke();
}
// Plot start/end coord
cr->save();
cr->set_line_width(lesser * 0.015);
cr->set_source_rgb(1.0, 0.0, 0.0); // red for start point
cr->move_to( originCoord.x,originCoord.y );
cr->line_to( originCoord.x,originCoord.y );
cr->stroke();
cr->save();
cr->set_source_rgb(0.0, 1.0, 0.0); // green for end point
cr->move_to( goalCoord.x,goalCoord.y );
cr->line_to( goalCoord.x,goalCoord.y );
cr->stroke();
}
示例2: drawAxis
void ActivityDrawingArea::drawAxis() {
// draw a reference axis and pod info
Glib::RefPtr < Gdk::Window > window = get_window();
Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
//draw axis
cr->save();
cr->set_line_width(2.0);
this->setSourceRGB(cr, currentColourScheme.getAxisColour());
cr->set_font_size(12);
cr->move_to(0, height / 2);
cr->line_to(width, height / 2);
cr->move_to(190, 25 + height / 2);
cr->show_text("20");
cr->move_to(390, 25 + height / 2);
cr->show_text("40");
cr->move_to(590, 25 + height / 2);
cr->show_text("60");
cr->move_to(790, 25 + height / 2);
cr->show_text("80");
cr->stroke();
cr->restore();
}
示例3: on_draw
/* Callback on_draw */
bool SensorsMap::on_draw (const Cairo::RefPtr<Cairo::Context>& cr)
{
/* Get window allocation */
Gtk::Allocation allocation = get_allocation ();
const int width = allocation.get_width ();
const int height = allocation.get_height ();
/* Get center of the window */
int xc, yc;
xc = width / 2;
yc = height / 2;
// DEBUG
cr->set_line_width(10.0);
// draw red lines out from the center of the window
cr->set_source_rgb(0.8, 0.0, 0.0);
cr->move_to(0, 0);
cr->line_to(xc, yc);
cr->line_to(0, height);
cr->move_to(xc, yc);
cr->line_to(width, yc);
cr->stroke();
// END DEBUG
/* Return success */
return true;
}
示例4:
bool
ButtonWidget::on_expose_event(GdkEventExpose* event)
{
Gtk::DrawingArea::on_expose_event(event);
Glib::RefPtr<Gdk::Window> window = get_window();
if(window)
{
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
int w = get_allocation().get_width() - 10;
int h = get_allocation().get_height() - 10;
cr->set_source_rgb(0.0, 0.0, 0.0);
cr->set_line_width(1.0);
cr->translate(5, 5);
cr->rectangle(0, 0, w, h);
if (down)
cr->fill_preserve();
cr->stroke();
if (down)
cr->set_source_rgb(1.0, 1.0, 1.0);
// FIXME: There are better ways to center text
if (name.size() == 2)
cr->move_to(w/2-6, h/2+3);
else
cr->move_to(w/2-4, h/2+3);
cr->show_text(name);
}
return true;
}
示例5: draw
void enigma_rotor_window::draw(Cairo::RefPtr<Cairo::Context> cr)
{
vector<double> dashes;
// Pattern used to draw a dashed line (15 pixels of line followed by 15 "empty" pixels)
dashes.push_back(15.0);
dashes.push_back(15.0);
if (has_ellipse)
{
cr->save();
// Draw background ellipse
cr->set_source_rgb(bkg_r, bkg_g, bkg_b);
draw_ellipse(cr, x, y, ellipse_width, ellipse_height);
cr->fill();
// Draw black border of background ellipse
cr->set_source_rgb(BLACK);
cr->set_line_width(1.2);
draw_ellipse(cr, x, y, ellipse_width, ellipse_height);
cr->stroke();
cr->restore();
}
cr->save();
// Draw a line of width rotor_rim_width in the dash background colour
cr->set_line_width(rotor_rim_width);
cr->set_source_rgb(dash_bkg_r, dash_bkg_g, dash_bkg_b);
cr->move_to(x + window_size, y - (2 * window_size));
cr->line_to(x + window_size, y + (2 * window_size));
cr->stroke();
// Draw a dashed line in the dash colour inside the previously drawn line
// This creates the impression of "notches" on the handle/rim
cr->set_source_rgb(dash_r, dash_g, dash_b);
cr->set_dash(dashes, ((wheel_pos - 'A') & 1) * 15); // modifying the offset creates illusion of movement
cr->move_to(x + window_size, y - (2 * window_size));
cr->line_to(x + window_size, y + (2 * window_size));
cr->stroke();
// Draw border around handle/rim
cr->set_line_width(2.0);
cr->unset_dash();
cr->set_source_rgb(DARK_GREY);
cr->rectangle(x + padded_size, y - (2 * window_size), rotor_rim_width, (4 * window_size));
cr->stroke();
cr->restore();
draw_wheel_pos(cr, wheel_pos);
if (has_ellipse)
{
// Draw screws
upper->draw(cr);
lower->draw(cr);
}
}
示例6: draw_grid
void Simple_GOL_Area::draw_grid(const Cairo::RefPtr<Cairo::Context>& cr, int window_width, int window_height)
{
int data_amount = sim_data->get_size();
if (data_amount != 0)
{
//sim_data->set_width(20);
double step_value_x = double(window_width)/double(sim_data->get_width());
double step_value_y = double(window_height)/double(sim_data->get_height());
cr->save();
cr->set_line_width(1.0);
cr->set_source_rgb(0.5,0.5,1);
cr->move_to(0,0);
for(double i=0; i<window_width; i = i+ step_value_x)
{
cr->move_to(i, 0);
cr->line_to(i, window_height);
}
for(double i=0; i<window_height; i = i+step_value_y)
{
cr->move_to(0, i);
cr->line_to(window_width, i);
}
cr->stroke();
cr->restore();
}
}
示例7: drawPoints
void ActivityDrawingArea::drawPoints(std::map<double, double> & ps, const double reference_line) {
//std::cout<<"ActivityDrawingArea::drawPoints: " <<std::endl;
// This is where we draw on the window
Glib::RefPtr < Gdk::Window > window = get_window();
Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
cr->save();
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
cr->set_line_width(2.0);
// std::cout<<"ActivityDrawingArea::drawPoints: colour: "<<"("<<main_colour[0]<<","<<main_colour[1]<<","<< main_colour[2] <<std::endl;
this->setSourceRGB(cr, currentColourScheme.getMainColour());
//scale the drawing in x and y
double maxy = 0;
std::map<double, double>::iterator it_ps = ps.begin();
while (it_ps != ps.end()) {
if (it_ps->second < 0 && -(it_ps->second) > maxy) {
maxy = -(it_ps->second);
} else if (it_ps->second > 0 && (it_ps->second) > maxy) {
maxy = (it_ps->second);
}
++it_ps;
}
double scaley = 0.2 * (double) ActivityDrawingArea::ACTIVITY_HEIGHT / maxy;
double scalex = 10;
it_ps = ps.begin();
if (it_ps != ps.end()) {
cr->move_to(scalex * it_ps->first, (0.5 * height) - (scaley * it_ps->second));
} else {
cr->move_to(0, height / 2);
}
while (it_ps != ps.end()) {
// std::cout<<"ActivityDrawingArea::drawPoints: " << it_ps->first <<","<<-it_ps->second<<std::endl;
cr->line_to((scalex * it_ps->first), (0.5 * height) - (scaley * it_ps->second));
++it_ps;
}
cr->stroke();
// draw reference line if not zero
if (reference_line>0.00001 || reference_line < -0.00001) {
Gdk::Color temp_colour(currentColourScheme.getMainColour());
this->setSourceRGB(cr, Gdk::Color("tomato"));
cr->set_line_width(1.0);
const std::vector<double> dashed= { 1.0 };
cr->set_dash(dashed, 1);
double scaled_reference_line = (0.5 * height) - (scaley * reference_line);
double neg_scaled_reference_line = (0.5 * height) + (scaley * reference_line);
cr->move_to(0, scaled_reference_line);
cr->line_to(width, scaled_reference_line);
cr->move_to(0, neg_scaled_reference_line);
cr->line_to(width, neg_scaled_reference_line);
cr->stroke();
}
cr->restore();
}
示例8: drawCairo
int drawCairo(const string& fname,
const valarray<double>& Xin, const valarray<double>& Yin,
const Hull& hull) {
#ifdef CAIRO_HAS_SVG_SURFACE
unsigned n=Xin.size();
assert(Yin.size()==n);
// normalise coords to range 0-1
valarray<double> X=Xin, Y=Yin;
X-=X.min();
Y-=Y.min();
X/=X.max();
Y/=Y.max();
Cairo::RefPtr<Cairo::SvgSurface> surface =
Cairo::SvgSurface::create(fname, width+2*border, height+2*border);
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
cr->save(); // save the state of the context
cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);
// draw a circle at each coordinate
for(unsigned i=0;i<n;i++) {
dot(cr,xcoord(X[i]),ycoord(Y[i]));
}
cr->set_source_rgba(0.0, 0.0, 0.0, 0.3);
cr->move_to(xcoord(X[hull[0]]),ycoord(Y[hull[0]]));
for(unsigned i=1;i<hull.size();i++) {
cr->line_to(xcoord(X[hull[i]]),ycoord(Y[hull[i]]));
}
cr->line_to(xcoord(X[hull[0]]),ycoord(Y[hull[0]]));
cr->stroke();
cr->set_source_rgba(0.0, 0.0, 0.0, 1.);
for(vector<unsigned>::const_iterator i=hull.begin();i!=hull.end();++i) {
unsigned j=*i;
stringstream ss;
ss<<j;
printf("p[%d]=(%f,%f)\n",j,X[j],Y[j]);
cr->move_to(xcoord(X[j]),ycoord(Y[j]));
cr->show_text(ss.str());
cr->stroke();
}
cr->restore();
cr->show_page();
cout << "Wrote SVG file \"" << fname << "\"" << endl;
return 0;
#else
cout << "You must compile cairo with SVG support for this example to work."
<< endl;
return 1;
#endif
}
示例9: draw
void DependencyArrow::draw(const Cairo::RefPtr<Cairo::Context>& context) const
{
// the way to compute the (tcx, tcy) single control point of the
// quadratic
double dX = mControlPoint.getX() - mOrigin->getX();
double dY = mControlPoint.getY() - mOrigin->getY();
double d1 = std::sqrt(dX * dX + dY * dY);
double d = d1;
dX = mDestination->getX() - mControlPoint.getX();
dY = mDestination->getY() - mControlPoint.getY();
d += std::sqrt(dX * dX + dY * dY);
double t = d1/d;
double t1 = 1.0 - t;
double tSq = t * t;
double denom = 2.0 * t * t1;
double tcx = (mControlPoint.getX() - t1 * t1 * mOrigin->getX() -
tSq * mDestination->getX()) / denom;
double tcy = (mControlPoint.getY() - t1 * t1 * mOrigin->getY() -
tSq * mDestination->getY()) / denom;
// from the single point of the quadratic to the both of the cubic
double tcxq1 = mOrigin->getX() + 2. * (tcx - mOrigin->getX()) / 3.;
double tcyq1 = mOrigin->getY() + 2. * (tcy - mOrigin->getY()) / 3.;
double tcxq2 = mDestination->getX() +
2. * (tcx - mDestination->getX()) / 3.;
double tcyq2 = mDestination->getY() +
2. * (tcy - mDestination->getY()) / 3.;
// and now to draw,
std::valarray< double > dashes(2);
double angle = atan2 (mDestination->getY() - tcyq2,
mDestination->getX() - tcxq2) + M_PI;
double x1 = mDestination->getX() + 9 * std::cos(angle - 0.35);
double y1 = mDestination->getY() + 9 * std::sin(angle - 0.35);
double x2 = mDestination->getX() + 9 * std::cos(angle + 0.35);
double y2 = mDestination->getY() + 9 * std::sin(angle + 0.35);
dashes[0] = 8.0;
dashes[1] = 3.0;
context->save();
context->set_line_width(1);
context->move_to(mDestination->getX(), mDestination->getY());
context->line_to(x1,y1);
context->line_to(x2,y2);
context->line_to(mDestination->getX(), mDestination->getY());
context->fill();
context->set_dash(dashes,0.);
context->move_to(mOrigin->getX(), mOrigin->getY());
context->curve_to(tcxq1, tcyq1, tcxq2, tcyq2, mDestination->getX(),
mDestination->getY());
context->stroke();
context->restore();
}
示例10: sprintf
void Format7DrawingArea::DrawImageDimensionsText(
Cairo::RefPtr<Cairo::Context> refCairo,
unsigned int left, unsigned int top, unsigned int width, unsigned int height )
{
refCairo->save();
// Set the font parameters
refCairo->select_font_face(
"monospace",
Cairo::FONT_SLANT_NORMAL,
Cairo::FONT_WEIGHT_BOLD );
refCairo->set_font_size( 10 );
// Set draw color to black
refCairo->set_source_rgb(0.0, 0.0, 0.0);
// Get width / height of widget
int widgetWidth = 0;
int widgetHeight = 0;
get_window()->get_size( widgetWidth, widgetHeight );
// Create text for image offset
char imageOffsets[128];
sprintf(
imageOffsets,
"Start: (%d,%d) End: (%d,%d)",
left,
top,
left + width,
top + height );
Cairo::TextExtents offsetExtents;
refCairo->get_text_extents(imageOffsets, offsetExtents);
// Draw the offset text
refCairo->move_to(
(widgetWidth/2) - (offsetExtents.width/2),
(widgetHeight/2) - offsetExtents.height - (offsetExtents.height/2));
refCairo->show_text( imageOffsets );
// Create text for image dimensions
char imageDimensions[128];
sprintf(
imageDimensions,
"Dimensions: %d x %d",
width,
height);
Cairo::TextExtents dimensionsExtents;
refCairo->get_text_extents(imageDimensions, dimensionsExtents);
// Draw the dimensions text
refCairo->move_to(
(widgetWidth/2) - (dimensionsExtents.width/2),
(widgetHeight/2) + dimensionsExtents.height + (dimensionsExtents.height/2));
refCairo->show_text( imageDimensions );
refCairo->restore();
}
示例11: draw_keyboard
void RegionChooser::draw_keyboard(const Cairo::RefPtr<Cairo::Context>& cr,
int clip_low, int clip_high) {
const int h = KEYBOARD_HEIGHT;
const int w = get_width() - 1;
const int bh = int(h * 0.55);
Gdk::Cairo::set_source_rgba(cr, black);
cr->rectangle(0.5, h1 + 0.5, w, h - 1);
cr->stroke();
int x1 = key_to_x(20.5, w);
Gdk::Cairo::set_source_rgba(cr, grey1);
cr->rectangle(1, h1 + 1, x1 - 1, h - 2);
cr->fill();
int x2 = key_to_x(109.5, w);
Gdk::Cairo::set_source_rgba(cr, white);
cr->rectangle(x1 + 1, h1 + 1, x2 - x1 - 1, h - 2);
cr->fill();
Gdk::Cairo::set_source_rgba(cr, grey1);
cr->rectangle(x2 + 1, h1 + 1, w - x2 - 1, h - 2);
cr->fill();
Gdk::Cairo::set_source_rgba(cr, black);
int clipkey1 = std::max(0, x_to_key_right(clip_low - 1, w));
int clipkey2 = std::min(x_to_key_right(clip_high - 1, w) + 1, 128);
for (int i = clipkey1 ; i < clipkey2 ; i++) {
int note = (i + 3) % 12;
int x = key_to_x(i, w);
if (note == 1 || note == 4 || note == 6 ||
note == 9 || note == 11) {
// black key: short line in the middle, with a rectangle
// on top
int x2 = key_to_x(i + 0.5, w);
cr->move_to(x2 + 0.5, h1 + bh + 0.5);
cr->line_to(x2 + 0.5, h1 + h - 1);
cr->stroke();
int x3 = key_to_x(i + 1, w);
cr->rectangle(x, h1 + 1, x3 - x + 1, bh);
cr->fill();
} else if (note == 3 || note == 8) {
// C or F: long line to the left
cr->move_to(x + 0.5, h1 + 1);
cr->line_to(x + 0.5, h1 + h - 1);
cr->stroke();
}
if (key_pressed[i]) draw_key(cr, i);
if (note == 3) draw_digit(cr, i);
}
}
示例12: dibujar_ejes
void MonitorInterface::dibujar_ejes(Cairo::RefPtr < Cairo::Context >& cr){
cr->set_line_width(0.0059);
// eje x
cr->move_to(0+offset_x, 1 - offset_y);
cr->line_to(1, 1 - offset_y);
// eje y
cr->move_to(0+offset_x, 1 - offset_y);
cr->line_to(offset_x, 0);
cr->stroke();
}
示例13: on_expose_event
bool VistaDiagrama::on_expose_event(GdkEventExpose* event) {
this->set_size_request(this->ancho, this->alto);
// Gonzalo : TEST
Glib::RefPtr<Gdk::Window> window = get_window();
if (window) {
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
// coordinates for the center of the window
int xc, yc;
xc = width / 2;
yc = height / 2;
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
cr->set_line_width(10.0);
// clip to the area indicated by the expose event so that we only redraw
// the portion of the window that needs to be redrawn
cr->rectangle(event->area.x, event->area.y, event->area.width,
event->area.height);
cr->clip();
// draw red lines out from the center of the window
cr->set_line_cap(Cairo::LINE_CAP_ROUND);
cr->set_source_rgb(0.8, 0.0, 0.0);
cr->move_to(20, 20);
cr->line_to(xc, yc);
cr->line_to(20, height - 20);
cr->move_to(xc, yc);
cr->line_to(width - 20, yc);
cr->stroke();
//RefPtr<Context> cr = this->get_window()->create_cairo_context();
/*cr->set_source_rgba(1, 1, 1, 1); // white
cr->paint();
cr->set_source_rgba(0, 0, 0, 1); // negro
cr->move_to(0, 0);
cr->line_to(this->ancho, this->alto);
VistaEntidad * entidad = new VistaEntidad();
entidad->setposfin(10, 10);
entidad->setposfin(20, 20);
entidad->dibujar(cr);*/
}
//delete entidad;
return true;
}
示例14: on_expose_event
bool CompVis::on_expose_event(GdkEventExpose* event) {
Glib::RefPtr<Gdk::Window> window = get_window();
Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
// clip to the area indicated by the expose event so that we only redraw
// the portion of the window that needs to be redrawn
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->clip();
rms_dB = 20*log10(rms);
thresh_fraction = (threshold - p_ports[p_threshold].min)/threshold_range;
rms_dB_fraction = (rms_dB - p_ports[p_threshold].min)/threshold_range;
// Draw the graph
cr->set_source_rgb(0.5,0.1,0.1);
cr->set_line_width(2);
cr->move_to(0,height);
if (rms_dB <= threshold) {
cr->line_to(rms_dB_fraction*width, height-rms_dB_fraction*height);
cr->line_to(rms_dB_fraction*width, height);
cr->line_to(0,height);
} else {
cr->line_to(thresh_fraction*width, height-thresh_fraction*height);
cr->line_to(rms_dB_fraction*width, height-(thresh_fraction*height + height*(rms_dB_fraction-thresh_fraction)/ratio));
cr->line_to(rms_dB_fraction*width, height);
cr->line_to(0,height);
}
cr->fill();
// draw the compression curve:
cr->set_source_rgb(0.1,0.1,0.1);
cr->move_to(0, height);
cr->line_to(thresh_fraction*width, height-thresh_fraction*height);
cr->line_to(width, height-(thresh_fraction*height + height*(1-thresh_fraction)/ratio));
cr->stroke();
// Draw the gain
cr->set_source_rgb(0.1,0.8,0.1);
cr->rectangle(0,(float)height - (float)height*gain, 10, height);
cr->fill();
return true;
}
示例15: drawTime
void ItemView::drawTime(const Cairo::RefPtr<Cairo::Context>& cr, const int width, const int height)
{
int text_width;
int text_height;
Glib::RefPtr<Pango::Layout> layTime = Pango::Layout::create(cr);
layTime->set_font_description(fontTime);
layTime->set_text(data.getTimeText());
layTime->get_pixel_size(text_width, text_height);
rectTime.set_x((TIME_WIDTH * 0.5) - (text_width * 0.5));
rectTime.set_y((int)PADDING);
rectTime.set_width(text_width);
rectTime.set_height(text_height);
//highlight
const int highlightSize = 1;
cr->move_to(rectTime.get_x(), rectTime.get_y() - highlightSize);
//set colors
ColorMode colorMode = getColorMode();
if (colorMode == COLOR_INACTIVE)
{
//gray
cr->set_source_rgb(0.6, 0.6, 0.6);
}
if (colorMode == COLOR_ALARM)
{
//orange
cr->set_source_rgb(0.8, 0.40, 0.0);
}
if (colorMode == COLOR_OK)
{
//green
cr->set_source_rgb(0.0, 0.55, 0.0);
}
layTime->show_in_cairo_context(cr);
//inner color
cr->move_to(rectTime.get_x(), rectTime.get_y());
cr->set_source_rgb(1.0, 1.0, 1.0);
layTime->show_in_cairo_context(cr);
}