1 /* === S I N F G =========================================================== */
5 ** $Id: renddesc.cpp,v 1.1.1.1 2005/01/04 01:23:14 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 ======================================================= */
36 /* === U S I N G =========================================================== */
40 using namespace sinfg;
42 /* === M A C R O S ========================================================= */
44 /* === G L O B A L S ======================================================= */
46 /* === M E T H O D S ======================================================= */
49 RendDesc::apply(const RendDesc &x)
56 RendDesc::get_bg_color()const
62 RendDesc::set_bg_color(const Color &bg)
64 background=bg; return *this;
68 RendDesc::get_physical_w()const
70 return (Real)get_w()/get_x_res();
74 RendDesc::get_physical_h()const
76 return (Real)get_h()/get_y_res();
80 RendDesc::set_physical_w(Real w)
82 set_w(round_to_int(w*get_x_res()));
87 RendDesc::set_physical_h(Real h)
89 set_h(round_to_int(h*get_y_res()));
94 RendDesc::get_w()const
100 RendDesc::set_w(int x)
102 if(FLAGS(flags,LINK_PX_ASPECT))
107 else if(FLAGS(flags,LINK_PX_AREA))
112 else if(FLAGS(flags,PX_ASPECT))
115 float old_span=get_span();
117 // If we should preserve image width
118 if( FLAGS(flags,IM_W)
119 || (FLAGS(flags,IM_ZOOMIN) && d[1]>d[1]/x*w_)
120 || (FLAGS(flags,IM_ZOOMOUT) && d[1]<d[1]/x*w_))
140 if(FLAGS(flags,IM_SPAN))
143 else if(FLAGS(flags,PX_AREA))
155 RendDesc::get_h()const
161 RendDesc::set_h(int y)
163 if(FLAGS(flags,LINK_PX_ASPECT))
168 else if(FLAGS(flags,LINK_PX_AREA))
173 else if(FLAGS(flags,PX_ASPECT))
176 float old_span=get_span();
178 // If we should preserve image width
179 if( FLAGS(flags,IM_W)
180 || (FLAGS(flags,IM_ZOOMIN) && d[0]>d[0]/y*h_)
181 || (FLAGS(flags,IM_ZOOMOUT) && d[0]<d[0]/y*h_))
201 if(FLAGS(flags,IM_SPAN))
204 else if(FLAGS(flags,PX_AREA))
216 RendDesc::set_wh(int x, int y)
218 // FIXME: This is a working hack...
226 RendDesc::get_x_res()const
232 RendDesc::set_x_res(Real x)
234 x_res=x; return *this;
238 RendDesc::get_y_res()const
244 RendDesc::set_y_res(Real y)
246 y_res=y; return *this;
250 RendDesc::get_frame_start()const
252 return time_begin*frame_rate;
256 RendDesc::set_frame_start(int x)
258 return set_time_start(Time(x)/frame_rate);
262 RendDesc::get_frame_end()const
264 return time_end*frame_rate;
268 RendDesc::set_frame_end(int x)
270 return set_time_end(Time(x)/frame_rate);
275 RendDesc::get_time_start()const
281 RendDesc::set_time_start(Time x)
284 time_begin=time_end=x;
292 RendDesc::get_time_end()const
298 RendDesc::set_time_end(Time x)
301 time_end=time_begin=x;
308 RendDesc::set_time(Time x)
310 time_end=time_begin=x;
315 RendDesc::set_frame(int x)
317 return set_time(Time(x)/frame_rate);
321 RendDesc::get_frame_rate()const
327 RendDesc::set_frame_rate(float x)
334 RendDesc::get_interlaced()const
340 RendDesc::set_interlaced(bool x)
341 { interlaced=x; return *this; }
343 //! Return the status of the clamp flag
345 RendDesc::get_clamp()const
348 //! Set the clamp flag
350 RendDesc::set_clamp(bool x)
351 { clamp=x; return *this; }
353 //! Set constraint flags
355 RendDesc::set_flags(const int &x)
356 { flags=x; return *this; }
358 //! Clear constraint flags
360 RendDesc::clear_flags()
361 { flags=0; return *this; }
364 RendDesc::get_flags()const
368 //! Return the aspect ratio of a single pixel
370 RendDesc::get_pixel_aspect()const
381 //! Return the aspect ratio of the entire image
383 RendDesc::get_image_aspect()const
393 //! Return the antialias amount
395 RendDesc::get_antialias()const
398 //! Set the antilaias amount
400 RendDesc::set_antialias(const int &x)
401 { a=x; return *this; }
404 //! Return the distance from the bottom-right to the top-left
406 RendDesc::get_span()const
408 return (br_-tl_).mag();
411 //! Set the span distance
413 RendDesc::set_span(const Real &x)
415 Vector::value_type ratio=x/get_span();
417 if(!FLAGS(flags,IM_W|IM_H) || FLAGS(flags,IM_ASPECT))
426 else if(FLAGS(flags,IM_W))
428 //! \writeme or fix me
437 //! \writeme or fix me
452 RendDesc::get_gamma()const
456 RendDesc::set_gamma(const Gamma &x)
457 { gamma=x; return *this; }
461 RendDesc::get_focus()const
465 RendDesc::set_focus(const Point &x)
466 { focus=x; return *this; }
470 RendDesc::get_tl()const
474 RendDesc::get_br()const
478 RendDesc::set_tl(const Point &x)
480 if(FLAGS(flags,PX_ASPECT))
482 Vector new_size(x-br_);
483 new_size[0]=abs(new_size[0]);
484 new_size[1]=abs(new_size[1]);
486 Vector old_size(tl_-br_);
487 old_size[0]=abs(old_size[0]);
488 old_size[1]=abs(old_size[1]);
490 if(new_size[0]!=old_size[0])
491 w_=round_to_int(new_size[0]*w_/old_size[0]);
493 if(new_size[1]!=old_size[1])
494 h_=round_to_int(new_size[1]*h_/old_size[1]);
501 RendDesc::set_br(const Point &x)
503 if(FLAGS(flags,PX_ASPECT))
505 Vector new_size(x-tl_);
506 new_size[0]=abs(new_size[0]);
507 new_size[1]=abs(new_size[1]);
509 Vector old_size(tl_-br_);
510 old_size[0]=abs(old_size[0]);
511 old_size[1]=abs(old_size[1]);
513 if(new_size[0]!=old_size[0])
514 w_=round_to_int(new_size[0]*w_/old_size[0]);
516 if(new_size[1]!=old_size[1])
517 h_=round_to_int(new_size[1]*h_/old_size[1]);
523 RendDesc::set_viewport(const Point &__tl, const Point &__br)
524 { tl_=__tl; br_=__br; return *this; }
527 RendDesc::set_viewport(Real a,Real b,Real c,Real d)
528 { tl_=Point(a,b); br_=Point(c,d); return *this; }
531 RendDesc::get_pw()const
533 return (br_[0] - tl_[0]) / w_;
537 RendDesc::get_ph()const
539 return (br_[1] - tl_[1]) / h_;
543 RendDesc::set_subwindow(int x, int y, int w, int h)
545 const Real pw(get_pw());
546 const Real ph(get_ph());
551 br_[0]-=pw*(w_-(x+w));
552 br_[1]-=ph*(h_-(y+h));