예제 #1
0
BoundingBox::BoundingBox(int aLength,
			 int aHeight,
			 const IPoint& aBottomRight) 
  throw(QgarErrorDomain)

  : topLeft_(aBottomRight.x() - aLength + 1, 
	     aBottomRight.y() - aHeight + 1),
    bottomRight_(aBottomRight)

{
  // Ensure that width and height are greater than 1.
  // Throw exception otherwise.

  if (aLength <= 0) 
    {
      ostringstream os;
      os << "Bounding box length must be greater than 0: "
	 << aLength;
      throw QgarErrorDomain(__FILE__, __LINE__,
			    "qgar::BoundingBox::BoundingBox(int, int, const qgar::GenPoint<int>&)",
			    os.str());
    }

  if (aHeight <= 0) 
    {
      ostringstream os;
      os << "Bounding box height must be greater than 0: "
	 << aHeight;
      throw QgarErrorDomain(__FILE__, __LINE__,
			    "qgar::BoundingBox::BoundingBox(int, int, const qgar::GenPoint<int>&)",
			    os.str());
    }
}
예제 #2
0
BoundingBox::BoundingBox(const IPoint& aTopLeft,
			 int aLength,
			 int aHeight)
 throw(QgarErrorDomain)

  : topLeft_(aTopLeft),
    bottomRight_(aTopLeft.x() + aLength - 1, 
		 aTopLeft.y() + aHeight - 1)

{
  // Ensure that width and height are greater than 0

  if (aLength <= 0) 
    {
      ostringstream os;
      os << "Bounding box length must be greater than 0: "
	 << aLength;
      throw QgarErrorDomain(__FILE__, __LINE__,
			    "qgar::BoundingBox::BoundingBox(const qgar::GenPoint<int>&, int, int)",
			    os.str());
    }

  if (aHeight <= 0) 
    {
      ostringstream os;
      os << "Bounding box height must be greater than 0: "
	 << aHeight;
      throw QgarErrorDomain(__FILE__, __LINE__,
			    "qgar::BoundingBox::BoundingBox(const qgar::GenPoint<int>&, int, int)",
			    os.str());
    }
}
ListBoxItem::TgtLocation
  ListBoxItem :: targetLocation ( IListBox *pLB, const IPoint &pt )
  {
  // Target position is in desktiop coordinates.
  // We must map this to listbox window coordinates.
  IPoint
    lbPt = IWindow::mapPoint( pt,
                              IWindow::desktopWindow()->handle(),
                              pLB->handle() );
  // Get index of target item:
  unsigned
    index = sourceIndex( pLB, lbPt );
  LocType
    type = on;
  if ( index != nil )
    { // Drop at item, see if before or after:
    unsigned
      dy  = pLB->rect().height() - lbPt.y(),
      i   = itemHeight(pLB),
      rem = dy % i;
    if ( rem < i/4 )
      type = before;
    else if ( rem > 3*i/4 )
      type = after;
    }
  else
    { // Drop off end.
    type = after;
    index = pLB->count() - 1;
    }
  return TgtLocation( type, index );
  }
예제 #4
0
void 
BoundingBox::setBottomRight(const IPoint& aPt)

  throw(QgarErrorDomain)

{
  // Is the new point a valid bottom right corner?
  if ((aPt.x() < topLeft_.x()) || (aPt.y() < bottomRight_.y()))
    {
      ostringstream os;
      os << "New bottom right corner (" << aPt.x() << ',' << aPt.y()
	 << ") does not fit current box: top left("
	 << topLeft_.x() << ',' << topLeft_.y()
	 << "), bottom right("
	 << bottomRight_.x() << ',' << bottomRight_.y()
	 << ')';
      throw QgarErrorDomain(__FILE__, __LINE__,
			    "void qgar::BoundingBox::BottomRight(const qgar::GenPoint<int>&)",
			    os.str());
    }
  bottomRight_ = aPt;
}
/*------------------------------------------------------------------------------
| angleFromPoints                                                              |
|                                                                              |
| Given two points determine the angle between the horizontal line through     |
| the first point and the line from the first point to the second point.       |
------------------------------------------------------------------------------*/
double angleFromPoints( const IPoint& center, const IPoint& drop )
{
  IPoint temp;
  double angle;

  temp  = drop - center;
  angle = atan2((double)temp.y(), (double)temp.x());
  angle *= 57.295779;

  if ( angle < 0.0 )
    angle += 360.0;

  return angle;
}
unsigned ListBoxItem :: sourceIndex ( IListBox *pLB, 
                                      const IPoint &pt ) 
  {
  // If there are no items, indicate no match.
  if ( pLB->isEmpty() )
    return nil;

  // Calculate index of dragged item:
  unsigned
    dy = pLB->rect().height() - pt.y(),
    i  = itemHeight(pLB),
    row = dy / i,
    index = pLB->top() + row;

  // If off end, indicate that.
  if ( index >= pLB->count() )
    index = nil;

  return index;
  }
예제 #7
0
void
BoundingBox::setCorners(const IPoint& aPt1, const IPoint& aPt2)
{
  setCorners(aPt1.x(), aPt1.y(), aPt2.x(), aPt2.y());
}
예제 #8
0
FPoint TPaintCoord::ToActualSys(const IPoint& position) const
{
	IPoint zoomXY = position - m_origin;
	return FPoint(zoomXY.x()/m_scaleX, zoomXY.y()/m_scaleY);
}