示例#1
0
void ICLayerLineString::drawLine(Cairo::RefPtr<Cairo::Context> cr,
    OGRGeometry* ObjectGeo, double scale, bool select)
{

  OGRLineString* Line = static_cast<OGRLineString*> (ObjectGeo);
  cr->move_to(Line->getX(0), Line->getY(0));
  double lw = cr->get_line_width();

  for (int i = 1; i < Line->getNumPoints(); i++)
  {
    cr->line_to(Line->getX(i), Line->getY(i));
  }
  cr->save();
  if (select)
  {
    cr->set_line_width(lw + (4 / scale));
  }
  cr->stroke();
  cr->restore();
}
示例#2
0
void cairo::draw_window( const Cairo::RefPtr<Cairo::Context>& cr, const Window& window, const rgba_color_ref_t& color )
{

  const ps_t ps = window.pseudosource();

  cairo_coord_t B0( window.bound<LEFT>(), 0 );
  cairo_coord_t B1( window.bound<RIGHT>(), 0 );
  cairo_coord_t PS( ps[0], ps[1] );

  cr->save();

    cr->set_source_rgba( color[0], color[1], color[2], color[3] );

    cr->move_to( B0[0], B0[1] + cr->get_line_width() );

    cr->line_to( B1[0], B1[1] + cr->get_line_width() );

    cr->stroke();

    std::vector<double> dashes(2);
    dashes[0] = 2. * user_unit_distance( cr ).length();
    dashes[1] = 10. * user_unit_distance( cr ).length();

    cr->set_dash( dashes, 0. );

    cr->set_source_rgba( color[0], color[1], color[2], color[3]*.5 );

    cr->move_to( B1[0], B1[1] );

    cr->line_to( PS[0], PS[1] );

    cr->line_to( B0[0], B0[1] );

    cr->stroke();

  cr->restore();

  cr->save();

    cr->set_font_size( 8. * user_unit_distance( cr ).length() );

    cr->set_source_rgba( color[0], color[1], color[2], 1. );

    std::ostringstream nrss;
    nrss << window.id;

    cairo_coord_t pos = (B0+B1)*.5;
	pos[1] += 5.*user_unit_distance( cr ).length();

    cr->translate( pos[0], pos[1] );

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

    draw_centered_text( cr, nrss.str() );

  cr->restore();

  #if defined DBG_FLAT_MMP_VISUALIZER_DRAW_WINDOW
  std::clog << "mmp::visualizer::draw_window\t|"
            << window
            << std::endl
            << "\t\t\t\t\t|"
            << " color " << color
            << " bounds " << bb
            << std::endl;
  #endif
}