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()); } }
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()); } }
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; }
void BoundingBox::setCorners(const IPoint& aPt1, const IPoint& aPt2) { setCorners(aPt1.x(), aPt1.y(), aPt2.x(), aPt2.y()); }
FPoint TPaintCoord::ToActualSys(const IPoint& position) const { IPoint zoomXY = position - m_origin; return FPoint(zoomXY.x()/m_scaleX, zoomXY.y()/m_scaleY); }