Scroom  0.14
Scroom::Utils Namespace Reference

Namespaces

 Detail
 

Classes

class  Base
 
class  Count
 
class  Counted
 
class  Counter
 
class  Observable
 
class  on_scope_exit
 
class  optional_cleanup
 
class  Point
 
class  ProgressInterfaceBroadcaster
 
class  ProgressInterfaceFromProgressStateInterface
 
class  ProgressInterfaceFromProgressStateInterfaceForwarder
 
class  ProgressInterfaceMultiplexer
 
class  ProgressStateInterface
 
class  ProgressStateInterfaceFromProgressInterface
 
class  ProgressStateInterfaceFromProgressInterfaceForwarder
 
class  Rectangle
 
class  Segment
 
class  Timer
 

Typedefs

using Stuff = boost::shared_ptr< void >
 
using StuffWeak = boost::weak_ptr< void >
 
using StuffList = std::list< Stuff >
 

Functions

template<typename T >
bool isZero (T v)
 
template<>
bool isZero< int > (int v)
 
template<>
bool isZero< double > (double v)
 
template<typename T >
bool areEqual (T a, T b)
 
template<typename T >
Segment< T > make_segment (T start, T size)
 
template<typename T >
Segment< T > make_segment_from_start_end (T start, T end)
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const Segment< T > &s)
 
Segment< double > roundOutward (Segment< double > s)
 
template<typename T >
center (Segment< T > s)
 
template<typename T >
Point< T > make_point (T x, T y)
 
template<typename T >
Point< T > make_point (T c)
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const Point< T > &p)
 
template<typename T , typename U >
Point< typename std::common_type< T, U >::type > operator- (Point< T > left, Point< U > right)
 
template<typename T , typename U >
Point< typename std::common_type< T, U >::type > operator+ (Point< T > left, Point< U > right)
 
template<typename T , typename U >
Point< typename std::common_type< T, U >::type > operator* (Point< T > left, Point< U > right)
 
template<typename T , typename U >
Point< typename std::common_type< T, U >::type > operator/ (Point< T > left, Point< U > right)
 
template<typename T , typename U >
Point< typename std::common_type< T, U >::type > operator/ (T left, Point< U > right)
 
template<typename T , typename U >
Point< typename std::common_type< T, U >::type > operator/ (Point< T > left, U right)
 
template<typename T >
Point< T > rounded_divide_by (Point< T > value, T factor)
 
template<typename T >
Point< T > ceiled_divide_by (Point< T > value, T factor)
 
template<typename T >
Point< T > floored_divide_by (Point< T > value, T factor)
 
template<typename T >
Point< T > rounded_divide_by (Point< T > value, Point< T > factor)
 
template<typename T >
Point< T > ceiled_divide_by (Point< T > value, Point< T > factor)
 
template<typename T >
Point< T > floored_divide_by (Point< T > value, Point< T > factor)
 
template<typename T >
Point< T > ceil (Point< T > p)
 
template<typename T >
Rectangle< T > make_rect (T x, T y, T width, T height)
 
template<typename T >
Rectangle< T > make_rect (Point< T > position, Point< T > size)
 
template<typename T >
Rectangle< T > make_rect_from_start_end (Point< T > start, Point< T > end)
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const Rectangle< T > &r)
 
std::ostream & operator<< (std::ostream &os, const cairo_rectangle_int_t &r)
 
template<typename T , typename U >
Rectangle< typename std::common_type< T, U >::type > operator* (Rectangle< T > left, U right)
 
template<typename T , typename U >
Rectangle< typename std::common_type< T, U >::type > operator* (T left, Rectangle< U > right)
 
Rectangle< double > operator* (cairo_rectangle_int_t const &r, Point< double > const &p)
 
Rectangle< double > operator* (Point< double > const &p, cairo_rectangle_int_t const &r)
 
template<typename T , typename U >
Rectangle< typename std::common_type< T, U >::type > operator- (Rectangle< T > left, Point< U > right)
 
Rectangle< double > roundOutward (Rectangle< double > r)
 
Rectangle< double > roundCorners (Rectangle< double > r)
 
template<typename T >
Point< T > center (Rectangle< T > r)
 
Stuff Empty ()
 
template<typename F >
boost::shared_ptr< void > on_destruction (F f)
 
void dumpCounts ()
 

Variables

constexpr double epsilon = 1e-6
 

Typedef Documentation

◆ Stuff

using Scroom::Utils::Stuff = typedef boost::shared_ptr<void>

Stuff is a pointer to some private data.

◆ StuffList

using Scroom::Utils::StuffList = typedef std::list<Stuff>

◆ StuffWeak

using Scroom::Utils::StuffWeak = typedef boost::weak_ptr<void>

Function Documentation

◆ areEqual()

template<typename T >
bool Scroom::Utils::areEqual ( a,
b 
)
39  {
40  return isZero(a - b);
41  }

Referenced by Scroom::Utils::Segment< value_type >::operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ceil()

template<typename T >
Point<T> Scroom::Utils::ceil ( Point< T >  p)
229  {
230  using std::ceil;
231  return {ceil(p.x), ceil(p.y)};
232  }

Referenced by ceiled_divide_by(), createProvider(), TransformPresentation::redraw(), and testCorrectIntervalForMinWidth().

Here is the caller graph for this function:

◆ ceiled_divide_by() [1/2]

template<typename T >
Point<T> Scroom::Utils::ceiled_divide_by ( Point< T >  value,
Point< T >  factor 
)
215  {
217  return {ceiled_divide_by(value.x, factor.x), ceiled_divide_by(value.y, factor.y)};
218  }

Referenced by ceiled_divide_by().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ceiled_divide_by() [2/2]

template<typename T >
Point<T> Scroom::Utils::ceiled_divide_by ( Point< T >  value,
factor 
)
194  {
196  return {ceiled_divide_by(value.x, factor), ceiled_divide_by(value.y, factor)};
197  }

Referenced by ceiled_divide_by().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ center() [1/2]

template<typename T >
Point<T> Scroom::Utils::center ( Rectangle< T >  r)
inline
353  {
354  return make_point(center(r.getHorizontally()), center(r.getVertically()));
355  }
Here is the call graph for this function:

◆ center() [2/2]

template<typename T >
T Scroom::Utils::center ( Segment< T >  s)
247  {
248  return s.getStart() + s.getSize() / 2;
249  }

Referenced by center(), TweakPositionTextBox::display(), and find_closest_corner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dumpCounts()

void Scroom::Utils::dumpCounts ( )
23 { Counter::instance()->dump(); }
Here is the call graph for this function:

◆ Empty()

Stuff Scroom::Utils::Empty ( )
inline
22 { return {}; }

Referenced by Tiff::open().

Here is the caller graph for this function:

◆ floored_divide_by() [1/2]

template<typename T >
Point<T> Scroom::Utils::floored_divide_by ( Point< T >  value,
Point< T >  factor 
)
222  {
224  return {floored_divide_by(value.x, factor.x), floored_divide_by(value.y, factor.y)};
225  }

Referenced by floored_divide_by().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ floored_divide_by() [2/2]

template<typename T >
Point<T> Scroom::Utils::floored_divide_by ( Point< T >  value,
factor 
)
201  {
203  return {floored_divide_by(value.x, factor), floored_divide_by(value.y, factor)};
204  }

Referenced by floored_divide_by().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isZero()

template<typename T >
bool Scroom::Utils::isZero ( v)

Referenced by areEqual(), and Scroom::Utils::Segment< value_type >::isEmpty().

Here is the caller graph for this function:

◆ isZero< double >()

template<>
bool Scroom::Utils::isZero< double > ( double  v)
inline
33  {
34  return std::abs(v) < epsilon;
35  }

◆ isZero< int >()

template<>
bool Scroom::Utils::isZero< int > ( int  v)
inline
27  {
28  return v == 0;
29  }

◆ make_point() [1/2]

template<typename T >
Point<T> Scroom::Utils::make_point ( c)
123  {
124  return Point<T>(c, c);
125  }

◆ make_point() [2/2]

◆ make_rect() [1/2]

template<typename T >
Rectangle<T> Scroom::Utils::make_rect ( Point< T >  position,
Point< T >  size 
)
291  {
292  return Rectangle<T>(position.x, position.y, size.x, size.y);
293  }

◆ make_rect() [2/2]

template<typename T >
Rectangle<T> Scroom::Utils::make_rect ( x,
y,
width,
height 
)
285  {
286  return Rectangle<T>(x, y, width, height);
287  }

Referenced by BOOST_AUTO_TEST_CASE(), View::redraw(), TEST(), and TweakRulers::tweakRulers().

Here is the caller graph for this function:

◆ make_rect_from_start_end()

template<typename T >
Rectangle<T> Scroom::Utils::make_rect_from_start_end ( Point< T >  start,
Point< T >  end 
)
297  {
298  return Rectangle<T>(make_segment_from_start_end(start.x, end.x), make_segment_from_start_end(start.y, end.y));
299  }

Referenced by PipetteHandler::onSelectionEnd(), roundCorners(), and toRectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_segment()

template<typename T >
Segment<T> Scroom::Utils::make_segment ( start,
size 
)
224  {
225  return Segment<T>(start, size);
226  }

Referenced by BOOST_AUTO_TEST_CASE().

Here is the caller graph for this function:

◆ make_segment_from_start_end()

template<typename T >
Segment<T> Scroom::Utils::make_segment_from_start_end ( start,
end 
)
230  {
231  return Segment<T>(start, end - start);
232  }

Referenced by make_rect_from_start_end(), and roundOutward().

Here is the caller graph for this function:

◆ on_destruction()

template<typename F >
boost::shared_ptr<void> Scroom::Utils::on_destruction ( f)
76  {
77  return boost::make_shared<on_scope_exit<F>>(std::move(f));
78  }

Referenced by BOOST_AUTO_TEST_CASE(), and Scroom::TiledBitmap::scheduleLoadingBitmap().

Here is the caller graph for this function:

◆ operator*() [1/5]

Rectangle<double> Scroom::Utils::operator* ( cairo_rectangle_int_t const &  r,
Point< double > const &  p 
)
inline
325 { return Rectangle<double>(r) * p; }

◆ operator*() [2/5]

Rectangle<double> Scroom::Utils::operator* ( Point< double > const &  p,
cairo_rectangle_int_t const &  r 
)
inline
327 { return Rectangle<double>(r) * p; }

◆ operator*() [3/5]

template<typename T , typename U >
Point<typename std::common_type<T, U>::type> Scroom::Utils::operator* ( Point< T >  left,
Point< U >  right 
)
155  {
156  using R = typename std::common_type<T, U>::type;
157 
158  Point<R> result(left);
159  result *= Point<R>(right);
160  return result;
161  }

◆ operator*() [4/5]

template<typename T , typename U >
Rectangle<typename std::common_type<T, U>::type> Scroom::Utils::operator* ( Rectangle< T >  left,
right 
)
313  {
314  Rectangle<typename std::common_type<T, U>::type> result(left);
315  result *= static_cast<typename std::common_type<T, U>::type>(right);
316  return result;
317  }

◆ operator*() [5/5]

template<typename T , typename U >
Rectangle<typename std::common_type<T, U>::type> Scroom::Utils::operator* ( left,
Rectangle< U >  right 
)
321  {
322  return right * left;
323  }

◆ operator+()

template<typename T , typename U >
Point<typename std::common_type<T, U>::type> Scroom::Utils::operator+ ( Point< T >  left,
Point< U >  right 
)
145  {
146  using R = typename std::common_type<T, U>::type;
147 
148  Point<R> result(left);
149  result += Point<R>(right);
150  return result;
151  }

◆ operator-() [1/2]

template<typename T , typename U >
Point<typename std::common_type<T, U>::type> Scroom::Utils::operator- ( Point< T >  left,
Point< U >  right 
)
135  {
136  using R = typename std::common_type<T, U>::type;
137 
138  Point<R> result(left);
139  result -= Point<R>(right);
140  return result;
141  }

◆ operator-() [2/2]

template<typename T , typename U >
Rectangle<typename std::common_type<T, U>::type> Scroom::Utils::operator- ( Rectangle< T >  left,
Point< U >  right 
)
331  {
332  using R = typename std::common_type<T, U>::type;
333 
334  return Rectangle<R>(left) - Point<R>(right);
335  }

◆ operator/() [1/3]

template<typename T , typename U >
Point<typename std::common_type<T, U>::type> Scroom::Utils::operator/ ( Point< T >  left,
Point< U >  right 
)
165  {
166  using R = typename std::common_type<T, U>::type;
167 
168  Point<R> result(left);
169  result /= Point<R>(right);
170  return result;
171  }

◆ operator/() [2/3]

template<typename T , typename U >
Point<typename std::common_type<T, U>::type> Scroom::Utils::operator/ ( Point< T >  left,
right 
)
181  {
182  return left / make_point(right, right);
183  }
Here is the call graph for this function:

◆ operator/() [3/3]

template<typename T , typename U >
Point<typename std::common_type<T, U>::type> Scroom::Utils::operator/ ( left,
Point< U >  right 
)
175  {
176  return make_point(left, left) / right;
177  }
Here is the call graph for this function:

◆ operator<<() [1/4]

std::ostream& Scroom::Utils::operator<< ( std::ostream &  os,
const cairo_rectangle_int_t &  r 
)
inline
309 { return os << Rectangle<double>(r); }

◆ operator<<() [2/4]

template<typename T >
std::ostream& Scroom::Utils::operator<< ( std::ostream &  os,
const Point< T > &  p 
)
129  {
130  return os << '(' << p.x << ',' << p.y << ')';
131  }

◆ operator<<() [3/4]

template<typename T >
std::ostream& Scroom::Utils::operator<< ( std::ostream &  os,
const Rectangle< T > &  r 
)
303  {
304  os << '<' << r.getLeft() << ',' << r.getTop() << ',' << r.getWidth() << ',' << r.getHeight() << '>';
305 
306  return os;
307  }
Here is the call graph for this function:

◆ operator<<() [4/4]

template<typename T >
std::ostream& Scroom::Utils::operator<< ( std::ostream &  os,
const Segment< T > &  s 
)
236  {
237  return os << '(' << s.getStart() << ',' << s.getSize() << ')';
238  }
Here is the call graph for this function:

◆ roundCorners()

Rectangle<double> Scroom::Utils::roundCorners ( Rectangle< double >  r)
inline

Referenced by TweakGridSelection::tweakSelection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rounded_divide_by() [1/2]

template<typename T >
Point<T> Scroom::Utils::rounded_divide_by ( Point< T >  value,
Point< T >  factor 
)
208  {
210  return {rounded_divide_by(value.x, factor.x), rounded_divide_by(value.y, factor.y)};
211  }

Referenced by rounded_divide_by().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rounded_divide_by() [2/2]

template<typename T >
Point<T> Scroom::Utils::rounded_divide_by ( Point< T >  value,
factor 
)
187  {
189  return {rounded_divide_by(value.x, factor), rounded_divide_by(value.y, factor)};
190  }

Referenced by rounded_divide_by().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ roundOutward() [1/2]

Rectangle<double> Scroom::Utils::roundOutward ( Rectangle< double >  r)
inline
338  {
339  return {
342  };
343  }
Here is the call graph for this function:

◆ roundOutward() [2/2]

Segment<double> Scroom::Utils::roundOutward ( Segment< double >  s)
inline

Variable Documentation

◆ epsilon

constexpr double Scroom::Utils::epsilon = 1e-6
constexpr

Referenced by isZero< double >().

Scroom::Utils::isZero
bool isZero(T v)
Scroom::Utils::Rectangle::getTopLeft
xy_type getTopLeft() const
Definition: rectangle.hh:133
round_up_to_multiple_of
T round_up_to_multiple_of(T value, T factor)
Definition: rounding.hh:38
round_down_to_multiple_of
T round_down_to_multiple_of(T value, T factor)
Definition: rounding.hh:44
Scroom::Utils::Rectangle::getVertically
const Segment< value_type > & getVertically() const
Definition: rectangle.hh:259
Scroom::Utils::make_point
Point< T > make_point(T x, T y)
Definition: point.hh:116
Scroom::Utils::epsilon
constexpr double epsilon
Definition: linearsegment.hh:20
Scroom::Utils::roundOutward
Rectangle< double > roundOutward(Rectangle< double > r)
Definition: rectangle.hh:337
Scroom::Utils::make_segment_from_start_end
Segment< T > make_segment_from_start_end(T start, T end)
Definition: linearsegment.hh:229
Scroom::Utils::ceil
Point< T > ceil(Point< T > p)
Definition: point.hh:228
Scroom::Utils::rounded_divide_by
Point< T > rounded_divide_by(Point< T > value, Point< T > factor)
Definition: point.hh:207
Scroom::Utils::floored_divide_by
Point< T > floored_divide_by(Point< T > value, Point< T > factor)
Definition: point.hh:221
Scroom::Utils::Rectangle::getBottomRight
xy_type getBottomRight() const
Definition: rectangle.hh:139
round_to_multiple_of
T round_to_multiple_of(T value, T factor)
Definition: rounding.hh:32
anonymous_namespace{progressbarmanager.cc}::instance
ProgressBarPulser::Ptr instance()
Definition: progressbarmanager.cc:43
Scroom::Utils::make_rect_from_start_end
Rectangle< T > make_rect_from_start_end(Point< T > start, Point< T > end)
Definition: rectangle.hh:296
Scroom::Utils::make_point
Point< T > make_point(T c)
Definition: point.hh:122
Scroom::Utils::Rectangle::getHorizontally
const Segment< value_type > & getHorizontally() const
Definition: rectangle.hh:257
Scroom::Utils::center
Point< T > center(Rectangle< T > r)
Definition: rectangle.hh:352
b
static void b(const B::Ptr &)
Definition: gtkhelper-tests.cc:32
Scroom::Utils::ceiled_divide_by
Point< T > ceiled_divide_by(Point< T > value, Point< T > factor)
Definition: point.hh:214