Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef QCUSTOMRHOMBUS_H
- #define QCUSTOMRHOMBUS_H
- #include "qcustomquadrangle.h"
- class QDebug;
- class QCustomRhombus : public QCustomQuadrangle
- {
- public:
- QCustomRhombus(QCustomPlot *parent);
- bool isRhombus();
- int CheckOrtogonal(QPointF _p1, QPointF _p2,
- QPointF _p3, QPointF _p4 );
- };
- #endif // QCUSTOMRHOMBUS_H
- //-----------------------------------
- #include "qcustomrhombus.h"
- QCustomRhombus::QCustomRhombus(QCustomPlot *parent)
- : QCustomQuadrangle(parent) {
- }
- bool QCustomRhombus::isRhombus() {
- if ( CheckOrtogonal(getPoint_1(), getPoint_2(), getPoint_3(), getPoint_4()) == 0 ) {
- if ( getDiagonal_AC() != getDiagonal_BD() ) {
- if ( getPerimeter() == getAB() * 4 ) {
- return true;
- }
- }
- } else return false;
- return false;
- }
- int QCustomRhombus::CheckOrtogonal(QPointF _p1, QPointF _p2, QPointF _p3, QPointF _p4)
- {
- return (_p3.x() - _p1.x() ) * (_p3.x() - _p1.x() )
- + ( _p4.y() - _p2.y() ) * ( _p4.y() - _p2.y() );
- }
- //----------------------------------------
- // Rhombus
- r = new QCustomRhombus(ui->plot);
- r->setData(x, y);
- if ( r->isRhombus() ) {
- QMessageBox::information(this, tr("Информация"),
- tr("Это ромб!"));
- qDebug() << "THIS IS ROMB";
- isRhombus = true;
- } else {
- isRhombus = false;
- qDebug() << "THIS IS NO ROMB";
- }
- // Rhombus
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement