当前位置: 首页>>代码示例>>C++>>正文


C++ RefPtr::save方法代码示例

本文整理汇总了C++中cairo::RefPtr::save方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::save方法的具体用法?C++ RefPtr::save怎么用?C++ RefPtr::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cairo::RefPtr的用法示例。


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

示例1: 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);    
    }
}
开发者ID:rmsk2,项目名称:rmsk2,代码行数:60,代码来源:rotor_window.cpp

示例2: 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();
}
开发者ID:fultoncjb,项目名称:astar,代码行数:60,代码来源:menuwindow.cpp

示例3: draw_face_edge_sequences

void cairo::draw_face_edge_sequences( const Cairo::RefPtr<Cairo::Context>& cr, const Geodesics::surface_type::edge_descriptor& edge, const Geodesics& m_geodesics )
{
  const auto    e0out = Geodesics::edge_handle( edge, m_geodesics.get_surface() );
  const auto 	e0w   = m_geodesics.edge_windows( e0out );
  const auto 	e0in  = e0out.opposite();
  const coord_t e0len = e0out.length();

  // draw base
  draw_edge_sequences( cr, e0w.first, e0w.second, m_geodesics );

  // draw lower left edge

  if( ! e0in.second ) return ;
  auto e1out = e0in.first.next().opposite();

  if( e1out.second )
  {
	auto e1w = m_geodesics.edge_windows( e1out.first );
    const coord_t e1len = e1out.first.length();
    cr->save();

      cr->rotate( - e0in.first.next_inner_angle() );

	  cr->translate( e1len, 0. );

	  cr->rotate( M_PI );
	  //cr->scale( -1., -1. );

      draw_edge_sequences( cr, e1w.first, e1w.second, m_geodesics );

    cr->restore();
  }


  // draw lower right edge

  const Geodesics::edge_handle e2in = e0in.first.previous();
  const auto e2out = e2in.opposite();

  if( ! e2out.second ) return;

  auto e2w = m_geodesics.edge_windows( e2out.first );

  cr->save();

	cr->translate( e0len, 0. );

    cr->rotate( e2in.next_inner_angle() );

    cr->scale( -1., -1. );

    draw_edge_sequences( cr, e2w.first, e2w.second, m_geodesics );

  cr->restore();
}
开发者ID:urp,项目名称:urban-robots,代码行数:55,代码来源:cairo_visualizer.cpp

示例4: draw

void Window::draw(Cairo::RefPtr<Cairo::Context> ctx)
{
	ctx->save();
    ctx->set_source_rgb(0.9, 0.9, 0.9);
    ctx->paint();
    ctx->restore();

    ctx->save();
    ctx->set_line_width(1.0);
    ctx->rectangle(0, 0, width, height);
    ctx->stroke();
    ctx->restore();
}
开发者ID:fabianschuiki,项目名称:Settlement,代码行数:13,代码来源:Window.cpp

示例5: on_expose_event

bool Canvas::on_expose_event(GdkEventExpose * evt) {
	Glib::RefPtr<Gdk::Window> window = get_window();
	if (!window) return false; // no window yet?

	if (!seen_first_expose_event) {
		seen_first_expose_event = true;
		main->controlsWindow().starting_position();
	}

	Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();

	if (!surface) return true; // Haven't rendered yet? Nothing we can do
	if (evt) {
		cr->rectangle(evt->area.x, evt->area.y, evt->area.width, evt->area.height);
		cr->clip();
	}

	cr->set_source(surface, 0, 0);
	cr->paint();

	if (main->dragrect.is_active() && main->dragrect.surface_valid()) {
		cr->save();
		cr->set_source(main->dragrect.get_surface(), 0, 0);
		cr->paint();
		cr->restore();
	}

	if (main->hud_active()) {
		Cairo::RefPtr<Cairo::Surface>& sfc = main->get_hud_surface();
		if (sfc)
			cr->set_source(sfc, 0, 0); // TODO HUD position
		cr->paint();
	}
	return true;
}
开发者ID:crazyscot,项目名称:brot2,代码行数:35,代码来源:Canvas.cpp

示例6: on_draw

bool RegionChooser::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
    double clipx1, clipx2, clipy1, clipy2;
    cr->get_clip_extents(clipx1, clipy1, clipx2, clipy2);
#endif

    cr->save();
    cr->set_line_width(1);

#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
    const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL);
#else
    const Gdk::RGBA bg = get_style_context()->get_background_color();
#endif
    Gdk::Cairo::set_source_rgba(cr, bg);
    cr->paint();

    if (clipy2 > h1) {
        draw_keyboard(cr, clipx1, clipx2);
    }

    if (clipy1 < h1 && instrument) {
        draw_regions(cr, clipx1, clipx2);
    }

    cr->restore();

    return true;
}
开发者ID:lxlxlo,项目名称:LS-gigedit,代码行数:28,代码来源:regionchooser.cpp

示例7: 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();
}
开发者ID:niallcreech,项目名称:cryoviewer,代码行数:29,代码来源:ActivityDrawingArea.cpp

示例8: pw

void
Renderer_Dragbox::render_vfunc(
	const Glib::RefPtr<Gdk::Window>& drawable,
	const Gdk::Rectangle& /*expose_area*/
)
{
	assert(get_work_area());
	if(!get_work_area())
		return;

	// const synfig::Vector focus_point(get_work_area()->get_focus_point());
	// Warning : Unused focus_point
	int drawable_w = drawable->get_width();
	int drawable_h = drawable->get_height();

	Cairo::RefPtr<Cairo::Context> cr = drawable->create_cairo_context();

	const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
	const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
	const float pw(get_pw()),ph(get_ph());

	const synfig::Point& curr_point(get_curr_point());
	const synfig::Point& drag_point(get_drag_point());

	{
		cr->save();
		cr->set_line_cap(Cairo::LINE_CAP_BUTT);
		cr->set_line_join(Cairo::LINE_JOIN_MITER);
		cr->set_antialias(Cairo::ANTIALIAS_NONE);

		cr->set_line_width(1.0);
		cr->set_source_rgb(0,0,0);
		std::valarray<double> dashes(2);
		dashes[0]=5.0;
		dashes[1]=5.0;
		cr->set_dash(dashes, 0);

		Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
		Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));

		tl[0]=(tl[0]-window_startx)/pw;
		tl[1]=(tl[1]-window_starty)/ph;
		br[0]=(br[0]-window_startx)/pw;
		br[1]=(br[1]-window_starty)/ph;
		if(tl[0]>br[0])
			swap(tl[0],br[0]);
		if(tl[1]>br[1])
			swap(tl[1],br[1]);

		cr->rectangle(
			tl[0],
			tl[1],
			br[0]-tl[0],
			br[1]-tl[1]
		);
		cr->stroke();

		cr->restore();
	}
}
开发者ID:binarytemple,项目名称:synfig,代码行数:60,代码来源:renderer_dragbox.cpp

示例9: draw

void Drawable::draw(const Cairo::RefPtr<Cairo::Context>& context,
                    ImageBuffer& buff) {
  context->save();
  // std::cout << getImageName() << std::endl;
  auto image = buff.getImage(getImageName(), flipped_, scaleX, scaleY);

  // int width = image->get_width();
  // int height = image->get_height();
  proto::Position pos = getPosition();

  int x = c_.scaleWidth(pos.x);
  int y = c_.scaleHeight(pos.y);

  // Gdk::Cairo::set_source_pixbuf(context, image, pos.x + width / 2,
  //                               pos.y - height / 2);
  Gdk::Cairo::set_source_pixbuf(context, image, x, offset_ + y);
  context->paint();

  // context->set_source_rgb(0.8, 0.0, 0.0);
  // context->move_to(pos.x, pos.y);
  // context->line_to(pos.x + width / 2, pos.y - height / 2);
  // context->line_to(pos.x + width / 2, pos.y + height / 2);
  // context->line_to(pos.x - width / 2, pos.y + height / 2);
  // context->line_to(pos.x - width / 2, pos.y - height / 2);
  // context->line_to(pos.x + width / 2, pos.y - height / 2);
  // context->stroke();

  context->restore();
}
开发者ID:gseva,项目名称:zetaman,代码行数:29,代码来源:drawable.cpp

示例10: on_draw

bool Balls::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
  Gtk::Allocation allocation = get_allocation();
  const int width = allocation.get_width();
  const int height = allocation.get_height();

  cr->save();
  cr->scale(width, height);

  cr->set_line_width(0.001);
  for (auto ball : balls_)
    {
      cr->set_source_rgb(ball.color_r,ball.color_g,ball.color_b);
      cr->arc(ball.p.x,ball.p.y,
              ball.rad,
              0,2*M_PI);
      cr->fill();
      cr->stroke();
    }

  cr->restore();

  const Ball &ball1 = balls_[balls_.size()-1];
  std::ostringstream info;
  info << "x = " << ball1.p.x << "\ny = " << ball1.p.y;
  infobox_.show(cr,width,height,info.str());

  return true;
}
开发者ID:jogojapan,项目名称:simul,代码行数:29,代码来源:balls.cpp

示例11: drawReminderIcon

void ItemView::drawReminderIcon(const Cairo::RefPtr<Cairo::Context>& cr, const int width, const int height)
{
    cr->save();

    //draw reminder icon
    cr->set_antialias(Cairo::ANTIALIAS_NONE);

    if (data.isReminder())
    {
        Gtk::Image* image = Resources::res->imgReminderIcon;

        if (getColorMode() == COLOR_ALARM)
            image = Resources::res->imgReminderOnIcon;

        const Glib::RefPtr<Gdk::Pixbuf> icon = image->get_pixbuf();

        const int iconLeft = (TIME_WIDTH * 0.5) - (icon->get_width() * 0.5);
        const int iconTop = (height - icon->get_height()) - (PADDING * 3);

        Gdk::Cairo::set_source_pixbuf(cr, icon, iconLeft, iconTop);

        cr->rectangle(iconLeft, iconTop, icon->get_width(), icon->get_height());
        cr->fill();
    }

    cr->restore();
}
开发者ID:pzagawa,项目名称:myagenda,代码行数:27,代码来源:NoteItemView.cpp

示例12: label

void NodeRenderer::label(const Cairo::RefPtr<Cairo::Context>& cr,
		std::list<shared_ptr<Label> >& labels,
		AssetCache& cache)
{
	// nothing to print
	if (s->text.str().size() == 0 || s->font_size <= 0)
		return;

	cr->save();

	cr->set_font_size(s->font_size);

	cr->set_font_face(cache.getFont(
			s->font_family.str(),
			s->font_style == Style::STYLE_ITALIC ? Cairo::FONT_SLANT_ITALIC : Cairo::FONT_SLANT_NORMAL,
			s->font_weight == Style::WEIGHT_BOLD ? Cairo::FONT_WEIGHT_BOLD : Cairo::FONT_WEIGHT_NORMAL
		));

	Cairo::TextExtents textSize;
	cr->get_text_extents(s->text.str(), textSize);

	addLabel(labels, location + FloatPoint(0.0, s->text_offset), textSize);

	cr->restore();
}
开发者ID:AMDmi3,项目名称:alacarte,代码行数:25,代码来源:node_renderer.cpp

示例13: DrawOptimalPath

void MapDrawArea::DrawOptimalPath(const Cairo::RefPtr<Cairo::Context>& cr)
{
	// This is where we draw on 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);
	const Coord maxXY = guiMapData.copyMaxCoord();

	// Copy the optimal path to the draw area
	std::vector<Coord> optimalPath = guiMapData.copyOptPath();

	// Plot the path
	cr->save();
	cr->set_source_rgb(1.0, 0.08, 0.58);	// pink for path
	cr->set_line_width(lesser * 0.005);
	cr->set_line_cap(Cairo::LINE_CAP_ROUND);

	for(std::vector<Coord>::iterator itr=optimalPath.begin();itr != optimalPath.end();++itr)
	{
		cr->move_to( int( float(width)*float(itr->x)/float(maxXY.x) ),int( height*float(itr->y)/float(maxXY.y)));
		cr->line_to( int( float(width)*float(itr->x)/float(maxXY.x) ),int( height*float(itr->y)/float(maxXY.y)));
		cr->stroke();
	}
}
开发者ID:fultoncjb,项目名称:astar,代码行数:25,代码来源:menuwindow.cpp

示例14: HomPoint

void
HomVectorDrawer::draw(Cairo::RefPtr<Cairo::Context>& context)
{
  context->save();

  HomPoint start, end;
  if (m_offset)
    {
      start = HomPoint( m_offset->x(), m_offset->y() );
      end   = HomPoint( m_offset->x() + m_vector->x(),
			m_offset->y() + m_vector->y() );
    }
  else
    {
      start = HomPoint( 0.0, 0.0 );
      end   = HomPoint( m_vector->x(), m_vector->y() );
    }

  context->move_to( start.x(), start.y() );
  context->line_to( end.x()  , end.y()   );
  context->arc( end.x(), end.y(), 0.06, 0.0, 2.0 * M_PI);
  context->fill();

  context->stroke();
  context->restore();
}
开发者ID:fuxiang90,项目名称:fawkes,代码行数:26,代码来源:hom_vector_drawer.cpp

示例15: 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();
	}	
}
开发者ID:SeanFC,项目名称:Conways_GOL,代码行数:32,代码来源:Conways_Game_Of_Life.cpp


注:本文中的cairo::RefPtr::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。