code format

This commit is contained in:
2022-12-14 14:13:52 +03:00
parent 430a41fefc
commit c2b8a8d6da
297 changed files with 27331 additions and 24162 deletions

View File

@@ -4,22 +4,22 @@
//! \~english Rect class
//! \~russian Класс прямоугольника
/*
PIP - Platform Independent Primitives
Rect class
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
PIP - Platform Independent Primitives
Rect class
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIRECT_H
#define PIRECT_H
@@ -36,6 +36,7 @@
template<typename Type>
class PIP_EXPORT PIRect {
static_assert(std::is_arithmetic<Type>::value, "Type must be arithmetic");
public:
//!
PIRect() {}
@@ -55,10 +56,10 @@ public:
normalize();
}
// PIRect(const PIPoint<Type> & p0, const PIPoint<Type> & p1, const PIPoint<Type> & p2) {
// set(piMin<Type>(p0.x, p1.x, p2.x), piMin<Type>(p0.y, p1.y, p2.y),
// piMax<Type>(p0.x, p1.x, p2.x), piMax<Type>(p0.y, p1.y, p2.y));
// }
// PIRect(const PIPoint<Type> & p0, const PIPoint<Type> & p1, const PIPoint<Type> & p2) {
// set(piMin<Type>(p0.x, p1.x, p2.x), piMin<Type>(p0.y, p1.y, p2.y),
// piMax<Type>(p0.x, p1.x, p2.x), piMax<Type>(p0.y, p1.y, p2.y));
// }
//!
PIRect<Type> & set(Type left_, Type bottom_, Type width_, Type height_) {
@@ -76,20 +77,14 @@ public:
//! \brief
//! \~russian Возвращает true если точка с указанными координатами принадлежит прямоугольнику
bool pointIn(Type x, Type y) const {
return (x <= bl.x && x >= tr.x && y <= bl.y && y >= tr.y);
}
bool pointIn(Type x, Type y) const { return (x <= bl.x && x >= tr.x && y <= bl.y && y >= tr.y); }
//! \brief
//! \~russian Возвращает true если точка с указанными координатами принадлежит прямоугольнику
bool pointIn(const PIPoint<Type> & p) const {
return pointIn(p.x, p.y);
}
bool pointIn(const PIPoint<Type> & p) const { return pointIn(p.x, p.y); }
//!
bool isEmpty() const {
return (width() == 0 && height() == 0);
}
bool isEmpty() const { return (width() == 0 && height() == 0); }
//!
PIRect<Type> & translate(Type x, Type y) {
@@ -120,10 +115,10 @@ public:
}
//!
PIRect<Type> & move(Type x, Type y) {return translate(x, y);}
PIRect<Type> & move(Type x, Type y) { return translate(x, y); }
//!
PIRect<Type> & move(const PIPoint<Type> & p) {return translate(p);}
PIRect<Type> & move(const PIPoint<Type> & p) { return translate(p); }
//!
PIRect<Type> moved(Type x, Type y) const {
@@ -147,10 +142,10 @@ public:
}
//!
PIRect<Type> & scale(Type s) {return scale(s, s);}
PIRect<Type> & scale(Type s) { return scale(s, s); }
//!
PIRect<Type> & scale(const PIPoint<Type> & p) {return scale(p.x, p.y);}
PIRect<Type> & scale(const PIPoint<Type> & p) { return scale(p.x, p.y); }
//!
PIRect<Type> scaled(Type x, Type y) const {
@@ -221,74 +216,98 @@ public:
}
//!
Type top() const {return tr.y;}
Type top() const { return tr.y; }
//!
Type left() const {return bl.x;}
Type left() const { return bl.x; }
//!
Type right() const {return tr.x;}
Type right() const { return tr.x; }
//!
Type bottom() const {return bl.y;}
Type bottom() const { return bl.y; }
//!
Type width() const {return tr.x - bl.x;}
Type width() const { return tr.x - bl.x; }
//!
Type height() const {return tr.y - bl.y;}
Type height() const { return tr.y - bl.y; }
//!
PIPoint<Type> topLeft() const {return PIPoint<Type>(bl.x, tr.y);}
PIPoint<Type> topLeft() const { return PIPoint<Type>(bl.x, tr.y); }
//!
PIPoint<Type> topRigth() const {return tr;}
PIPoint<Type> topRigth() const { return tr; }
//!
PIPoint<Type> bottomLeft() const {return bl;}
PIPoint<Type> bottomLeft() const { return bl; }
//!
PIPoint<Type> bottomRight() const {return PIPoint<Type>(tr.x, bl.y);}
PIPoint<Type> bottomRight() const { return PIPoint<Type>(tr.x, bl.y); }
//!
PIPoint<Type> center() const {return bl.moved(width()/2, height()/2);}
PIPoint<Type> center() const { return bl.moved(width() / 2, height() / 2); }
//!
void setTop(Type v) {tr.y = v; normalize();}
void setTop(Type v) {
tr.y = v;
normalize();
}
//!
void setLeft(Type v) {bl.x = v; normalize();}
void setLeft(Type v) {
bl.x = v;
normalize();
}
//!
void setRigth(Type v) {tr.x = v; normalize();}
void setRigth(Type v) {
tr.x = v;
normalize();
}
//!
void setBottom(Type v) {bl.y = v; normalize();}
void setBottom(Type v) {
bl.y = v;
normalize();
}
//!
void setWidth(Type v) {setTop(bl.x + v);}
void setWidth(Type v) { setTop(bl.x + v); }
//!
void setHeight(Type v) {setRigth(bl.y + v);}
void setHeight(Type v) { setRigth(bl.y + v); }
//!
void setTopLeft(const PIPoint<Type> & p) {setLeft(p.x); setTop(p.y);}
void setTopLeft(const PIPoint<Type> & p) {
setLeft(p.x);
setTop(p.y);
}
//!
void setBottomRight(const PIPoint<Type> & p) {setRigth(p.x); setBottom(p.y);}
void setBottomRight(const PIPoint<Type> & p) {
setRigth(p.x);
setBottom(p.y);
}
//!
void setBottomLeft(const PIPoint<Type> & p) {bl = p; normalize();}
void setBottomLeft(const PIPoint<Type> & p) {
bl = p;
normalize();
}
//!
void setTopRigth(const PIPoint<Type> & p) {tr = p; normalize();}
void setTopRigth(const PIPoint<Type> & p) {
tr = p;
normalize();
}
//!
void setCenter(const PIPoint<Type> & p) {
Type w = width();
Type h = height();
bl = p.translated(-w/2, -h/2);
tr = PIPoint<Type>(bl.x + w, bl.y + h);
bl = p.translated(-w / 2, -h / 2);
tr = PIPoint<Type>(bl.x + w, bl.y + h);
}
//!
@@ -298,40 +317,40 @@ public:
}
//!
void operator +=(Type x) {translate(x, x);}
void operator+=(Type x) { translate(x, x); }
//!
void operator +=(const PIPoint<Type> & p) {translate(p);}
void operator+=(const PIPoint<Type> & p) { translate(p); }
//!
void operator -=(Type x) {translate(-x, -x);}
void operator-=(Type x) { translate(-x, -x); }
//!
void operator -=(const PIPoint<Type> & p) {translate(-p);}
void operator-=(const PIPoint<Type> & p) { translate(-p); }
//!
void operator |=(const PIRect<Type> & r) {unite(r);}
void operator|=(const PIRect<Type> & r) { unite(r); }
//!
void operator &=(const PIRect<Type> & r) {intersect(r);}
void operator&=(const PIRect<Type> & r) { intersect(r); }
//!
PIRect<Type> operator +(const PIPoint<Type> & p) {return translated(p);}
PIRect<Type> operator+(const PIPoint<Type> & p) { return translated(p); }
//!
PIRect<Type> operator -(const PIPoint<Type> & p) {return translated(-p);}
PIRect<Type> operator-(const PIPoint<Type> & p) { return translated(-p); }
//!
PIRect<Type> operator |(const PIRect<Type> & r) {return united(r);}
PIRect<Type> operator|(const PIRect<Type> & r) { return united(r); }
//!
PIRect<Type> operator &(const PIRect<Type> & r) {return intersected(r);}
PIRect<Type> operator&(const PIRect<Type> & r) { return intersected(r); }
//!
bool operator ==(const PIRect<Type> & r) const {return (bl == r.bl && tr == r.tr);}
bool operator==(const PIRect<Type> & r) const { return (bl == r.bl && tr == r.tr); }
//!
bool operator !=(const PIRect<Type> & r) const {return (bl != r.bl || tr != r.tr);}
bool operator!=(const PIRect<Type> & r) const { return (bl != r.bl || tr != r.tr); }
private:
PIPoint<Type> bl;
@@ -340,7 +359,7 @@ private:
template<typename Type>
PICout operator <<(PICout & s, const PIRect<Type> & v) {
PICout operator<<(PICout & s, const PIRect<Type> & v) {
s.saveAndSetControls(0);
s << "Rect{" << v.bottomLeft() << ":" << v.width() << "x" << v.height() << "}";
s.restoreControls();