浏览代码

Adding max line number in WorkArea

Rémi Synave 2 年之前
父节点
当前提交
d13d0e19ee
共有 2 个文件被更改,包括 10 次插入3 次删除
  1. 8 3
      WorkArea/WorkArea.cpp
  2. 2 0
      WorkArea/WorkArea.hpp

+ 8 - 3
WorkArea/WorkArea.cpp

@@ -18,7 +18,7 @@ WorkArea::WorkArea (int screenSizeX, int screenSizeY, QWidget * parent):
   img = NULL;
   resizeFactor = 1;
   indexPointClicked = -1;
-
+  maxLines = 0;
 }
 
 WorkArea::WorkArea (int screenSizeX, int screenSizeY, const std::string & filename, QWidget * parent):QWidget(parent)
@@ -29,6 +29,7 @@ WorkArea::WorkArea (int screenSizeX, int screenSizeY, const std::string & filena
   img = NULL;
   resizeFactor = 1;
   indexPointClicked = -1;
+  maxLines = 0;
   loadImage(filename);
 }
 
@@ -39,6 +40,7 @@ WorkArea::WorkArea (int screenSizeX, int screenSizeY, const std::string & imageF
   img = NULL;
   resizeFactor = 1;
   indexPointClicked = -1;
+  maxLines = 0;
   loadImage(imageFilename);
   this->readOnly = readOnly;
   loadSL(SLFilename);  
@@ -60,6 +62,7 @@ WorkArea::loadImage (const std::string & filename)
   liste_points.clear ();
   
   setFixedSize (img->width (), img->height ());
+  maxLines = 3;
 }
 
 void
@@ -164,8 +167,10 @@ WorkArea::mousePressEvent (QMouseEvent * event)
 	    {
 	      if (indexPointClicked == -1)
 		{
-		  indexPointClicked = liste_points.size ();
-		  liste_points << new QPoint (event->x (), event->y ());
+		  if((maxLines == 0) || (liste_points.size()<(maxLines*2))){
+		    indexPointClicked = liste_points.size ();
+		    liste_points << new QPoint (event->x (), event->y ());
+		  }
 		}
 	    }
 	  // Clic droit

+ 2 - 0
WorkArea/WorkArea.hpp

@@ -29,6 +29,8 @@ private:
   QList < QPoint * >liste_points;
   int indexPointClicked;
 
+  int maxLines;
+
   
 protected:
   void paintEvent (QPaintEvent * event) override;