[qet] [3455] element editor: minor improvement about line creation

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 3455
Author:   blacksun
Date:     2014-11-05 22:37:25 +0100 (Wed, 05 Nov 2014)
Log Message:
-----------
element editor: minor improvement about line creation

Modified Paths:
--------------
    trunk/sources/editor/esevent/eseventaddline.cpp
    trunk/sources/editor/esevent/eseventaddline.h
    trunk/sources/editor/partline.cpp
    trunk/sources/editor/partline.h

Modified: trunk/sources/editor/esevent/eseventaddline.cpp
===================================================================
--- trunk/sources/editor/esevent/eseventaddline.cpp	2014-11-05 10:09:12 UTC (rev 3454)
+++ trunk/sources/editor/esevent/eseventaddline.cpp	2014-11-05 21:37:25 UTC (rev 3455)
@@ -63,7 +63,6 @@
 		}
 
 		//Add new line to scene
-		m_line  -> setLine(QLineF(m_line->line().p1(), pos));
 		m_scene -> undoStack().push(new AddPartCommand(QObject::tr("ligne"), m_scene, m_line));
 
 		//Set m_line to nullptr for create new line at next mouse press
@@ -82,11 +81,9 @@
  */
 bool ESEventAddLine::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
 	updateHelpCross (event -> scenePos());
-
 	if (!m_line) return false;
 
-	QPointF pos = m_scene -> snapToGrid(event -> scenePos());
-	m_line -> setLine(QLineF(m_line->line().p1(), pos));
+	m_line -> setP2(m_scene -> snapToGrid(event -> scenePos()));
 	return true;
 }
 

Modified: trunk/sources/editor/esevent/eseventaddline.h
===================================================================
--- trunk/sources/editor/esevent/eseventaddline.h	2014-11-05 10:09:12 UTC (rev 3454)
+++ trunk/sources/editor/esevent/eseventaddline.h	2014-11-05 21:37:25 UTC (rev 3455)
@@ -24,6 +24,10 @@
 class PartLine;
 class QGraphicsSceneMouseEvent;
 
+/**
+ * @brief The ESEventAddLine class
+ * This ESEvent manage creation of line in a ElementScene
+ */
 class ESEventAddLine : public ESEventInterface
 {
 	public:

Modified: trunk/sources/editor/partline.cpp
===================================================================
--- trunk/sources/editor/partline.cpp	2014-11-05 10:09:12 UTC (rev 3454)
+++ trunk/sources/editor/partline.cpp	2014-11-05 21:37:25 UTC (rev 3455)
@@ -224,6 +224,15 @@
 }
 
 /**
+ * @brief PartLine::setP1
+ * set first point to P1
+ * @param p1
+ */
+void PartLine::setP1(QPointF p1) {
+	setLine(QLineF(p1, line().p2()));
+}
+
+/**
  * @brief PartLine::setX2
  * set x of P2
  * @param x2
@@ -246,6 +255,15 @@
 }
 
 /**
+ * @brief PartLine::setP2
+ * set second point to P2
+ * @param p2
+ */
+void PartLine::setP2(QPointF p2) {
+	setLine(QLineF(line().p1(), p2));
+}
+
+/**
 	Gere les changements intervenant sur cette partie
 	@param change Type de changement
 	@param value Valeur numerique relative au changement

Modified: trunk/sources/editor/partline.h
===================================================================
--- trunk/sources/editor/partline.h	2014-11-05 10:09:12 UTC (rev 3454)
+++ trunk/sources/editor/partline.h	2014-11-05 21:37:25 UTC (rev 3455)
@@ -74,35 +74,50 @@
 	static QList<QPointF> fourEndPoints(const QPointF &, const QPointF &, const qreal &);
 
 	///PROPERTY
-	// X value of the first point
+		// X value of the first point
 	Q_PROPERTY(qreal x1 READ x1 WRITE setX1)
 		qreal x1() const {return sceneP1().x();}
 		void setX1(qreal x1);
-	// Y value of the first point
+
+		// Y value of the first point
 	Q_PROPERTY(qreal y1 READ y1 WRITE setY1)
 		qreal y1() const {return sceneP1().y();}
 		void setY1(qreal y1);
-	// X value of the second point
+
+		//pos of firts point
+	Q_PROPERTY(QPointF p1 READ sceneP1 WRITE setP1)
+		void setP1 (QPointF p1);
+
+		// X value of the second point
 	Q_PROPERTY(qreal x2 READ x2 WRITE setX2)
 		qreal x2() const {return sceneP2().x();}
 		void setX2(qreal x2);
-	// Y value of the second point
+
+		// Y value of the second point
 	Q_PROPERTY(qreal y2 READ y2 WRITE setY2)
 		qreal y2() const {return sceneP2().y();}
 		void setY2(qreal y2);
-	// End type of the first point
+
+		//pos of second point
+	Q_PROPERTY(QPointF p2 READ sceneP2 WRITE setP2)
+		void setP2 (QPointF p2);
+
+		// End type of the first point
 	Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType)
 		Qet::EndType firstEndType() const {return first_end;}
 		void setFirstEndType(const Qet::EndType &et) {first_end = et;}
-	// End type of the second point
+
+		// End type of the second point
 	Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
 		Qet::EndType secondEndType() const {return second_end;}
 		void setSecondEndType(const Qet::EndType &et) {second_end = et;}
-	// Size of end type of first point
+
+		// Size of end type of first point
 	Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
 		qreal firstEndLength() const {return first_length;}
 		void setFirstEndLength(const qreal &l) {first_length = qMin(qAbs(l), line().length());}
-	// Size of end type of the second point
+
+		// Size of end type of the second point
 	Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
 		qreal secondEndLength() const {return second_length;}
 		void setSecondEndLength(const qreal &l) {second_length = qMin(qAbs(l), line().length());}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/