diff --git a/Circleoutline.h b/Circleoutline.h index 1ba3f219..a0a6aed0 100644 --- a/Circleoutline.h +++ b/Circleoutline.h @@ -26,7 +26,7 @@ #include #include void fillCircle(cv::Mat &m, double cx, double cy, double rad, void *color); -class CircleOutline: public boundary +class CircleOutline final: public boundary { public: CircleOutline(); @@ -35,7 +35,7 @@ class CircleOutline: public boundary CircleOutline(const QJsonObject &obj); void toJson(QJsonObject &obj); - virtual ~CircleOutline(); + ~CircleOutline(); void draw(QPainter& painter, double scale, double scale2 = -1.); bool isInside(QPointF& p , int offset = 0); bool isInside(double x, double y, int offset=0); @@ -48,17 +48,15 @@ class CircleOutline: public boundary double m_radius; gPlus m_p1; gPlus m_p2; - protected: - - private: }; -class ellipseOutline: public boundary +class ellipseOutline final: public boundary { public: ellipseOutline(); ellipseOutline(QPointF center, double minorAxis, double majorAxis); ellipseOutline(QPointF left, QPointF right, double ecc); + void draw(QPainter& painter, double scale, double scale2 = -1.); bool isInside(QPointF& p , int offset = 0); void enlarge(int del); void translate(QPointF del); @@ -76,11 +74,12 @@ class ellipseOutline: public boundary gPlus m_p2; }; -class rectangleOutline: public boundary +class rectangleOutline final: public boundary { public: rectangleOutline(); rectangleOutline(QPointF upperLeft, QPointF lowerRight); + void draw(QPainter& painter, double scale, double scale2 = -1.); bool isInside(QPointF& p , int offset = 0); void enlarge(int del); void translate(QPointF del); diff --git a/boundary.h b/boundary.h index 2a897147..aed9b276 100644 --- a/boundary.h +++ b/boundary.h @@ -18,17 +18,26 @@ #ifndef BOUNDARY_H #define BOUNDARY_H #include + +// asbtract base class. Zero risk of slicing. class boundary { + protected: + boundary() = default; + ~boundary() = default; + // Copy operations + boundary(const boundary&) = default; + boundary& operator=(const boundary&) = default; + // Move operations + boundary(boundary&&) noexcept = default; + boundary& operator=(boundary&&) noexcept = default; public: - virtual ~boundary() {} virtual void draw(QPainter& painter, double scale, double scale2 = -1.) = 0; virtual void enlarge(int del) = 0; virtual void translate(QPointF del) = 0; virtual void scale(double factor) = 0; virtual bool isValid() = 0; virtual bool isInside(QPointF& p, int offset = 0) = 0; - protected: private: }; QDataStream & operator<<(QDataStream & stream, const boundary &outline); diff --git a/gplus.h b/gplus.h index 25210d7a..296f0db0 100644 --- a/gplus.h +++ b/gplus.h @@ -24,7 +24,7 @@ class gPlus public: gPlus(QPointF p); gPlus(); - virtual ~gPlus(); + ~gPlus(); void draw(QPainter& dc, double scale, int size = 10); QPointF m_p; protected: