Minsky
minsky::BoundingBox Class Reference

bounding box information (at zoom=1 scale) More...

#include <item.h>

Collaboration diagram for minsky::BoundingBox:
Collaboration graph

Public Member Functions

void update (const Item &x)
 
bool contains (float x, float y) const
 
bool valid () const
 
float width () const
 
float height () const
 
float left () const
 
float right () const
 
float top () const
 
float bottom () const
 

Private Attributes

float m_left =0
 
float m_right =0
 
float m_top
 
float m_bottom
 

Detailed Description

bounding box information (at zoom=1 scale)

Definition at line 84 of file item.h.

Member Function Documentation

◆ bottom()

float minsky::BoundingBox::bottom ( ) const
inline

Definition at line 99 of file item.h.

References m_bottom.

99 {return m_bottom;}
float m_bottom
Definition: item.h:86

◆ contains()

bool minsky::BoundingBox::contains ( float  x,
float  y 
) const
inline

Definition at line 89 of file item.h.

References m_left, and m_top.

89  {
90  // extend each item by a portradius to solve ticket #903
91  return m_left-portRadius<=x && m_right+portRadius>=x && m_top-portRadius<=y && m_bottom+portRadius>=y;
92  }
float m_left
Definition: item.h:86

◆ height()

float minsky::BoundingBox::height ( ) const
inline

Definition at line 95 of file item.h.

References m_bottom, and m_top.

95 {return m_bottom-m_top;}
float m_bottom
Definition: item.h:86

◆ left()

float minsky::BoundingBox::left ( ) const
inline

Definition at line 96 of file item.h.

References m_left.

96 {return m_left;}
float m_left
Definition: item.h:86

◆ right()

float minsky::BoundingBox::right ( ) const
inline

Definition at line 97 of file item.h.

References m_right.

97 {return m_right;}
float m_right
Definition: item.h:86

◆ top()

float minsky::BoundingBox::top ( ) const
inline

Definition at line 98 of file item.h.

References m_top.

98 {return m_top;}

◆ update()

void minsky::BoundingBox::update ( const Item x)

Definition at line 46 of file item.cc.

References minsky::Item::draw(), M_PI, minsky::NoteBase::mouseFocus, minsky::Item::onResizeHandles, minsky::Item::rotation(), and minsky::Item::zoomFactor().

Referenced by minsky::IntOp::description(), minsky::Item::ensureBBValid(), minsky::Item::iHeight(), minsky::Item::iWidth(), minsky::VariableBase::name(), minsky::IntOp::resize(), minsky::Ravel::resize(), minsky::IntOp::toggleCoupled(), minsky::UserFunction::updateBB(), minsky::DataOp::updateBB(), minsky::GodleyIcon::updateBB(), and minsky::Item::updateBoundingBox().

47  {
48  const ecolab::cairo::Surface surf
49  (cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA,NULL));
50  auto savedMouseFocus=x.mouseFocus;
51  x.mouseFocus=false; // do not mark up icon with tooltips etc, which might invalidate this calc
52  x.onResizeHandles=false;
53  double stashedZf=1;
54  if (auto parent=x.group.lock())
55  {
56  stashedZf=parent->relZoom;
57  parent->relZoom/=x.zoomFactor(); // undo any zooming coming from owning group
58  }
59  try
60  {
61  const cairo::CairoSave cs(surf.cairo());
62  cairo_rotate(surf.cairo(),-x.rotation()*M_PI/180);
63  x.draw(surf.cairo());
64  }
65 #ifndef NDEBUG
66  catch (const std::exception& e)
67  {cerr<<"illegal exception caught in draw(): "<<e.what()<<endl;}
68  catch (...) {cerr<<"illegal exception caught in draw()";}
69 #else
70  catch(...) {}
71 #endif
72  x.mouseFocus=savedMouseFocus;
73  if (auto parent=x.group.lock())
74  parent->relZoom=stashedZf;
75 
76  double l,t,w,h;
77  cairo_recording_surface_ink_extents(surf.surface(),
78  &l,&t,&w,&h);
79  // note (0,0) is relative to the (x,y) of icon.
80  m_left=l;
81  m_right=(l+w);
82  m_top=t;
83  m_bottom=(t+h);
84  }
#define M_PI
some useful geometry types, defined from boost::geometry
Definition: geometry.h:29
float m_left
Definition: item.h:86
float m_right
Definition: item.h:86
float m_bottom
Definition: item.h:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ valid()

bool minsky::BoundingBox::valid ( ) const
inline

Definition at line 93 of file item.h.

References m_left, and m_right.

Referenced by minsky::Item::ensureBBValid().

93 {return m_left!=m_right;}
float m_left
Definition: item.h:86
float m_right
Definition: item.h:86
Here is the caller graph for this function:

◆ width()

float minsky::BoundingBox::width ( ) const
inline

Definition at line 94 of file item.h.

References m_left, and m_right.

94 {return m_right-m_left;}
float m_left
Definition: item.h:86
float m_right
Definition: item.h:86

Member Data Documentation

◆ m_bottom

float minsky::BoundingBox::m_bottom
private

Definition at line 86 of file item.h.

Referenced by bottom(), and height().

◆ m_left

float minsky::BoundingBox::m_left =0
private

Definition at line 86 of file item.h.

Referenced by contains(), left(), valid(), and width().

◆ m_right

float minsky::BoundingBox::m_right =0
private

Definition at line 86 of file item.h.

Referenced by right(), valid(), and width().

◆ m_top

float minsky::BoundingBox::m_top
private

Definition at line 86 of file item.h.

Referenced by contains(), height(), and top().


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