- moved LDMatrixObject to be an abstract class deriving from LDObject. LDSubfile only inherits from LDMatrixObject.

Wed, 16 Jul 2014 14:59:39 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Wed, 16 Jul 2014 14:59:39 +0300
changeset 843
9ac9060877cc
parent 842
e1c9010eb9e8
child 844
11587d419d2f

- moved LDMatrixObject to be an abstract class deriving from LDObject. LDSubfile only inherits from LDMatrixObject.

src/ldObject.cc file | annotate | diff | comparison | revisions
src/ldObject.h file | annotate | diff | comparison | revisions
--- a/src/ldObject.cc	Tue Jul 15 03:02:22 2014 +0300
+++ b/src/ldObject.cc	Wed Jul 16 14:59:39 2014 +0300
@@ -58,10 +58,7 @@
 }
 
 LDSubfile::LDSubfile (LDObjectPtr* selfptr) :
-	LDObject (selfptr)
-{
-	setLinkPointer (self());
-}
+	LDMatrixObject (selfptr) {}
 
 LDOBJ_DEFAULT_CTOR (LDEmpty, LDObject)
 LDOBJ_DEFAULT_CTOR (LDError, LDObject)
@@ -843,16 +840,14 @@
 //
 void LDMatrixObject::setPosition (const Vertex& a)
 {
-	LDObjectPtr ref = linkPointer().toStrongRef();
-	changeProperty (ref, &m_position, a);
+	changeProperty (self(), &m_position, a);
 }
 
 // =============================================================================
 //
 void LDMatrixObject::setTransform (const Matrix& val)
 {
-	LDObjectPtr ref = linkPointer().toStrongRef();
-	changeProperty (ref, &m_transform, val);
+	changeProperty (self(), &m_transform, val);
 }
 
 // =============================================================================
--- a/src/ldObject.h	Tue Jul 15 03:02:22 2014 +0300
+++ b/src/ldObject.h	Wed Jul 16 14:59:39 2014 +0300
@@ -255,23 +255,22 @@
 // and thus not used directly other than as a common storage point for matrices
 // and vertices.
 //
-// The link pointer is a pointer to this object's LDObject self - since this is
-// multiple-derived in, static_cast or dynamic_cast won't budge here.
-//
 // In 0.1-alpha, there was a separate 'radial' type which had a position and
 // matrix as well. Even though right now only LDSubfile uses this, I'm keeping
 // this class distinct in case I get new extension ideas. :)
 //
-class LDMatrixObject
+class LDMatrixObject : public LDObject
 {
-	PROPERTY (public,	LDObjectWeakPtr,	linkPointer,	setLinkPointer,	STOCK_WRITE)
 	PROPERTY (public,	Matrix,				transform,		setTransform,	CUSTOM_WRITE)
+	Vertex m_position;
 
 public:
-	LDMatrixObject() :
+	LDMatrixObject (LDObjectPtr* selfptr) :
+		LDObject (selfptr),
 		m_position (g_origin) {}
 
-	LDMatrixObject (const Matrix& transform, const Vertex& pos) :
+	LDMatrixObject (LDObjectPtr* selfptr, const Matrix& transform, const Vertex& pos) :
+		LDObject (selfptr),
 		m_transform (transform),
 		m_position (pos) {}
 
@@ -295,9 +294,6 @@
 	}
 
 	void setPosition (const Vertex& a);
-
-private:
-	Vertex m_position;
 };
 
 using LDMatrixObjectPtr = QSharedPointer<LDMatrixObject>;
@@ -418,7 +414,7 @@
 //
 // Represents a single code-1 subfile reference.
 //
-class LDSubfile : public LDObject, public LDMatrixObject
+class LDSubfile : public LDMatrixObject
 {
 	LDOBJ (Subfile)
 	LDOBJ_NAME (subfile)

mercurial