Skip to content

Commit

Permalink
chore: updating scene to serve the region growing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamel-Mohammed committed May 3, 2023
1 parent ba64a25 commit 47e9759
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
30 changes: 20 additions & 10 deletions utilities/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
Scene::~Scene()
{
}
Scene::Scene()
Scene::Scene(bool multiPoints)
{
this->multiPoints = multiPoints;
}

void Scene::setRad(double rad)
Expand All @@ -30,22 +31,31 @@ QPointF Scene::getCenter()



void Scene::drawCircle()
void Scene::drawCircle(bool isFilled)
{

this->addEllipse(this->center.x()-this->rad, this->center.y()-this->rad, this->rad*2.0, this->rad*2.0,
QPen());

QPen pen;
if(isFilled){
QBrush brush(Qt::red);
this->addEllipse(this->center.x()-this->rad, this->center.y()-this->rad, this->rad*2.0, this->rad*2.0, pen, brush);
}else{
this->addEllipse(this->center.x()-this->rad, this->center.y()-this->rad, this->rad*2.0, this->rad*2.0, pen);
}
// This Line for region growing segmentation only
this->seeds.push_back(cv::Point(this->center.y(), this->center.x()));
}


void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(!this->drawFlag){
QPointF point = event->scenePos();
this->center= point;
// this->drawFlag=true;
drawCircle();
QPointF point = event->scenePos();
this->center= point;
if(!this->multiPoints){
this->drawFlag=true;
drawCircle(false);
}else{
drawCircle(true);
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions utilities/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <qpainter.h>
#include <vector>
#include <opencv2/core.hpp>>



Expand All @@ -12,13 +14,14 @@ class Scene : public QGraphicsScene
{

public:
explicit Scene();
explicit Scene(bool multiPoints);
~Scene();
void setRad(double rad);
void drawCircle();
void drawCircle(bool isFilled);
void setDrawFlag(bool flag);
double getRad();
QPointF getCenter();
std::vector<cv::Point> seeds;



Expand All @@ -30,5 +33,6 @@ class Scene : public QGraphicsScene
QPointF center;
double rad;
bool drawFlag=false;
bool multiPoints;
};
#endif // SCENE_H

0 comments on commit 47e9759

Please sign in to comment.