1 /* === S Y N F I G ========================================================= */
3 ** \brief Template File
5 ** $Id: renderer_bbox.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_bbox.h"
33 #include "canvasview.h"
36 /* === U S I N G =========================================================== */
40 using namespace synfig;
41 using namespace studio;
43 /* === M A C R O S ========================================================= */
45 /* === G L O B A L S ======================================================= */
47 /* === P R O C E D U R E S ================================================= */
49 /* === M E T H O D S ======================================================= */
51 Renderer_BBox::Renderer_BBox()
55 Renderer_BBox::~Renderer_BBox()
60 Renderer_BBox::get_bbox()
62 return get_work_area()->get_canvas_view()->get_bbox();
66 Renderer_BBox::render_vfunc(
67 const Glib::RefPtr<Gdk::Drawable>& drawable,
68 const Gdk::Rectangle& expose_area
71 assert(get_work_area());
75 // const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
77 const synfig::Vector focus_point(get_work_area()->get_focus_point());
79 // std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
81 int drawable_w,drawable_h;
82 drawable->get_size(drawable_w,drawable_h);
84 // Calculate the window coordinates of the top-left
85 // corner of the canvas.
86 // const synfig::Vector::value_type
87 // x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
88 // y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
90 /*const synfig::Vector::value_type window_startx(window_tl[0]);
91 const synfig::Vector::value_type window_endx(window_br[0]);
92 const synfig::Vector::value_type window_starty(window_tl[1]);
93 const synfig::Vector::value_type window_endy(window_br[1]);
96 // tile_w(get_work_area()->get_tile_w()),
97 // tile_h(get_work_area()->get_tile_h());
103 Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
105 //const synfig::Vector grid_size(get_grid_size());
107 const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
108 // const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
109 const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
110 // const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
111 const float pw(get_pw()),ph(get_ph());
113 const synfig::Point curr_point(get_bbox().get_min());
114 const synfig::Point drag_point(get_bbox().get_max());
115 if(get_bbox().area()<10000000000000000.0)
117 gc->set_function(Gdk::INVERT);
118 gc->set_rgb_fg_color(Gdk::Color("#FFFFFF"));
119 //gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
120 gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
122 Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
123 Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));
125 tl[0]=(tl[0]-window_startx)/pw;
126 tl[1]=(tl[1]-window_starty)/ph;
127 br[0]=(br[0]-window_startx)/pw;
128 br[1]=(br[1]-window_starty)/ph;
134 drawable->draw_rectangle(gc,false,
137 round_to_int(br[0]-tl[0]),
138 round_to_int(br[1]-tl[1])