Geom::D2< Interval > Class Template Reference

Rect class. More...

#include <rect.h>

Collaboration diagram for Geom::D2< Interval >:

List of all members.

Public Member Functions

 D2 ()
 Best not to use this constructor, do not rely on what it initializes the object to.
 D2 (Interval const &a, Interval const &b)
 D2 (Point const &a, Point const &b)
Intervaloperator[] (unsigned i)
Interval const & operator[] (unsigned i) const
Point min () const
Point max () const
Point corner (unsigned i) const
 Returns the four corners of the rectangle in positive order (clockwise if +Y is up, anticlockwise if +Y is down).
double top () const
double bottom () const
double left () const
double right () const
double width () const
double height () const
Point dimensions () const
 Returns a vector from min to max.
Point midpoint () const
double area () const
 Compute the area of this rectangle.
bool hasZeroArea (double eps=EPSILON) const
double maxExtent () const
double minExtent () const
bool intersects (Rect const &r) const
bool contains (Rect const &r) const
bool contains (Point const &p) const
void expandTo (Point p)
void unionWith (Rect const &b)
void unionWith (OptRect const &b)
void expandBy (double amnt)
void expandBy (Point const p)

Private Attributes

Interval f [2]

Detailed Description

template<>
class Geom::D2< Interval >

Rect class.

The Rect class is actually a specialisation of D2<Interval>.

Definition at line 60 of file rect.h.


Constructor & Destructor Documentation

Geom::D2< Interval >::D2 (  )  [inline]

Best not to use this constructor, do not rely on what it initializes the object to.

The default constructor creates a rect of default intervals.

Geom::D2< Interval >::D2 ( Interval const &  a,
Interval const &  b 
) [inline]
Geom::D2< Interval >::D2 ( Point const &  a,
Point const &  b 
) [inline]

Member Function Documentation

double Geom::D2< Interval >::area (  )  const [inline]

Compute the area of this rectangle.

Note that a zero area rectangle is not empty - just as the interval [0,0] contains one point, the rectangle [0,0] x [0,0] contains 1 point and no area.

Return values:
For a valid return value, the rect must be tested for emptyness first.

Definition at line 116 of file rect.h.

References Geom::D2< T >::f, Geom::X, and Geom::Y.

Referenced by SPDesktop::zoom_quick().

00116 { return f[X].extent() * f[Y].extent(); }

double Geom::D2< Interval >::bottom (  )  const [inline]

Definition at line 99 of file rect.h.

References Geom::D2< T >::f, and Geom::Y.

Referenced by Geom::distanceSq(), and Inkscape::LivePathEffect::LPEMirrorSymmetry::doOnApply().

00099 { return f[Y].max(); }

bool Geom::D2< Interval >::contains ( Point const &  p  )  const [inline]

Definition at line 131 of file rect.h.

References Geom::D2< T >::f, Geom::X, and Geom::Y.

00131                                                 {
00132         return f[X].contains(p[X]) && f[Y].contains(p[Y]);
00133     }

bool Geom::D2< Interval >::contains ( Rect const &  r  )  const [inline]
Point Geom::D2< Interval >::corner ( unsigned  i  )  const [inline]

Returns the four corners of the rectangle in positive order (clockwise if +Y is up, anticlockwise if +Y is down).

Definition at line 88 of file rect.h.

References Geom::D2< T >::f, Geom::max(), Geom::min(), Point, Geom::X, and Geom::Y.

Referenced by Inkscape::UI::ControlPointSelection::_rotationRadius(), cornerFarthestFrom(), Inkscape::Text::Layout::createSelectionShape(), SPCurve::new_from_rect(), Inkscape::UI::TransformHandleSet::setBounds(), Inkscape::UI::SkewHandle::startTransform(), Inkscape::UI::RotateHandle::startTransform(), Inkscape::UI::ScaleSideHandle::startTransform(), Inkscape::UI::ScaleCornerHandle::startTransform(), and transform_rect().

00088                                    {
00089         switch(i % 4) {
00090             case 0:  return Point(f[X].min(), f[Y].min());
00091             case 1:  return Point(f[X].max(), f[Y].min());
00092             case 2:  return Point(f[X].max(), f[Y].max());
00093             default: return Point(f[X].min(), f[Y].max());
00094         }
00095     }

void Geom::D2< Interval >::expandBy ( Point const   p  )  [inline]

Definition at line 146 of file rect.h.

References Geom::D2< T >::f, Geom::X, and Geom::Y.

00146                                          { 
00147         f[X].expandBy(p[X]);  f[Y].expandBy(p[Y]); 
00148     }

void Geom::D2< Interval >::expandBy ( double  amnt  )  [inline]
void Geom::D2< Interval >::expandTo ( Point  p  )  [inline]
bool Geom::D2< Interval >::hasZeroArea ( double  eps = EPSILON  )  const [inline]

Definition at line 117 of file rect.h.

Referenced by get_scale_transform_with_stroke(), Inkscape::Filters::Filter::render(), and sp_export_png_file().

00117 { return (area() <= eps); }

bool Geom::D2< Interval >::intersects ( Rect const &  r  )  const [inline]

Definition at line 125 of file rect.h.

References Geom::D2< T >::f, Geom::X, and Geom::Y.

Referenced by Inkscape::ObjectSnapper::_findCandidates(), feed_curve_to_cairo(), geom_curve_bbox_wind_distance(), Geom::mono_intersect(), Geom::mono_pair(), and overlaps().

00125                                                 { 
00126         return f[X].intersects(r[X]) && f[Y].intersects(r[Y]); 
00127     }

double Geom::D2< Interval >::left (  )  const [inline]

Definition at line 100 of file rect.h.

References Geom::D2< T >::f, and Geom::X.

Referenced by Geom::distanceSq(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doOnApply(), and Geom::outer_crossing().

00100 { return f[X].min(); }

double Geom::D2< Interval >::maxExtent (  )  const [inline]

Definition at line 119 of file rect.h.

References Geom::D2< T >::f, Geom::max(), Geom::X, and Geom::Y.

Referenced by Inkscape::UI::TransformHandleSet::_updateVisibility(), Geom::mono_intersect(), and Geom::mono_pair().

00119 { return std::max(f[X].extent(), f[Y].extent()); }

Point Geom::D2< Interval >::min (  )  const [inline]

Definition at line 83 of file rect.h.

References Geom::D2< T >::f, min(), Point, Geom::X, and Geom::Y.

Referenced by Inkscape::SelTrans::_calcAbsAffineGeom(), Inkscape::Filters::Filter::_filter_resolution(), Inkscape::SelTrans::_getGeomHandlePos(), Inkscape::Filters::Filter::bbox_enlarge(), Inkscape::UI::Dialog::BBoxSort::BBoxSort(), Inkscape::Text::Layout::createSelectionShape(), Inkscape::Extension::Internal::Grid::effect(), Inkscape::Filters::Filter::filter_effect_area(), SPDocument::fitToRect(), from_2geom(), SPDesktop::get_display_area(), Inkscape::Filters::get_item_bbox(), get_scale_transform_with_stroke(), Inkscape::SelTrans::grab(), Box3D::Line::intersection_with_viewbox(), min(), perform_bitmap_scanline_check(), SPDesktop::point(), SPDesktop::push_current_zoom(), render_pixbuf(), SPDesktop::scroll_to_point(), SPDesktop::scroll_world(), SPDesktop::set_display_area(), NRArenaShape::setPaintBox(), sp_desktop_widget_update_scrollbars(), sp_dyna_draw_get_npoint(), sp_dyna_draw_get_vpoint(), sp_eraser_get_npoint(), sp_eraser_get_vpoint(), sp_export_bbox_equal(), sp_flood_do_flood_fill(), sp_generate_internal_bitmap(), sp_gradient_get_g2d_matrix(), sp_gradient_get_gs2d_matrix(), sp_gradient_set_gs2d_matrix(), sp_rect_drag(), sp_selection_tile(), sp_text_context_root_handler(), CtrlRect::update(), Inkscape::UI::View::EditWidget::updateRulers(), Inkscape::UI::View::EditWidget::updateScrollbars(), Inkscape::Extension::Internal::OdfOutput::writeTree(), and SPDesktop::zoom_relative_keep_point().

00083 { return Point(f[X].min(), f[Y].min()); }

double Geom::D2< Interval >::minExtent (  )  const [inline]

Definition at line 120 of file rect.h.

References Geom::D2< T >::f, Geom::min(), Geom::X, and Geom::Y.

Referenced by Inkscape::UI::TransformHandleSet::_updateVisibility(), and SPDesktop::zoom_page().

00120 { return std::min(f[X].extent(), f[Y].extent()); }

Interval const& Geom::D2< Interval >::operator[] ( unsigned  i  )  const [inline]

Definition at line 81 of file rect.h.

References Geom::D2< T >::f.

00081 { return f[i]; }

Interval& Geom::D2< Interval >::operator[] ( unsigned  i  )  [inline]

Definition at line 80 of file rect.h.

References Geom::D2< T >::f.

00080 { return f[i]; }

double Geom::D2< Interval >::right (  )  const [inline]

Definition at line 101 of file rect.h.

References Geom::D2< T >::f, and Geom::X.

Referenced by Geom::distanceSq().

00101 { return f[X].max(); }

double Geom::D2< Interval >::top (  )  const [inline]

Definition at line 98 of file rect.h.

References Geom::D2< T >::f, and Geom::Y.

Referenced by Geom::distanceSq(), and Inkscape::LivePathEffect::LPEMirrorSymmetry::doOnApply().

00098 { return f[Y].min(); }

void Geom::Rect::unionWith ( OptRect const &  b  )  [inline]

Definition at line 254 of file rect.h.

00254                                             { 
00255     if (b) {
00256         unionWith(*b);
00257     }
00258 }

void Geom::D2< Interval >::unionWith ( Rect const &  b  )  [inline]

Definition at line 138 of file rect.h.

References Geom::D2< T >::f, Geom::X, and Geom::Y.

Referenced by bounds_exact_transformed(), and Geom::union_list().

00138                                          { 
00139         f[X].unionWith(b[X]); f[Y].unionWith(b[Y]); 
00140     }


Member Data Documentation

Interval Geom::D2< Interval >::f[2] [private]

Definition at line 62 of file rect.h.


The documentation for this class was generated from the following file: