1 /* === S I N F G =========================================================== */
3 ** \brief Template File
5 ** $Id: renderer_grid.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "renderer_grid.h"
37 /* === U S I N G =========================================================== */
41 using namespace sinfg;
42 using namespace studio;
44 /* === M A C R O S ========================================================= */
46 /* === G L O B A L S ======================================================= */
48 /* === P R O C E D U R E S ================================================= */
50 /* === M E T H O D S ======================================================= */
52 Renderer_Grid::~Renderer_Grid()
57 Renderer_Grid::get_enabled_vfunc()const
59 return get_work_area()->grid_status();
63 Renderer_Grid::get_grid_size()const
65 return get_work_area()->get_grid_size();
69 Renderer_Grid::render_vfunc(
70 const Glib::RefPtr<Gdk::Drawable>& drawable,
71 const Gdk::Rectangle& expose_area
74 assert(get_work_area());
78 // const sinfg::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
80 const sinfg::Vector focus_point(get_work_area()->get_focus_point());
82 // std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
84 int drawable_w,drawable_h;
85 drawable->get_size(drawable_w,drawable_h);
87 // Calculate the window coordinates of the top-left
88 // corner of the canvas.
89 // const sinfg::Vector::value_type
90 // x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
91 // y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
93 /*const sinfg::Vector::value_type window_startx(window_tl[0]);
94 const sinfg::Vector::value_type window_endx(window_br[0]);
95 const sinfg::Vector::value_type window_starty(window_tl[1]);
96 const sinfg::Vector::value_type window_endy(window_br[1]);
99 // tile_w(get_work_area()->get_tile_w()),
100 // tile_h(get_work_area()->get_tile_h());
106 Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
108 const sinfg::Vector grid_size(get_grid_size());
110 const sinfg::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
111 const sinfg::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
112 const sinfg::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
113 const sinfg::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
114 const float pw(get_pw()),ph(get_ph());
117 if(grid_size[0]>pw*3.5 && grid_size[1]>ph*3.5)
119 sinfg::Vector::value_type x,y;
121 x=floor(window_startx/grid_size[0])*grid_size[0];
122 y=floor(window_starty/grid_size[1])*grid_size[1];
124 gc->set_function(Gdk::COPY);
125 gc->set_rgb_fg_color(Gdk::Color("#9f9f9f"));
126 gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
129 for(;x<window_endx;x+=grid_size[0])
131 drawable->draw_line(gc,
132 round_to_int((x-window_startx)/pw),
134 round_to_int((x-window_startx)/pw),
139 for(;x>window_endx;x-=grid_size[0])
141 drawable->draw_line(gc,
142 round_to_int((x-window_startx)/pw),
144 round_to_int((x-window_startx)/pw),
150 for(;y<window_endy;y+=grid_size[1])
152 drawable->draw_line(gc,
154 round_to_int((y-window_starty)/ph),
156 round_to_int((y-window_starty)/ph)
160 for(;y>window_endy;y-=grid_size[1])
162 drawable->draw_line(gc,
164 round_to_int((y-window_starty)/ph),
166 round_to_int((y-window_starty)/ph)