- removed the vertex object

Sat, 21 Feb 2015 19:35:43 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 21 Feb 2015 19:35:43 +0200
changeset 928
0fef7bb7b7a2
parent 927
409b82a4765e
child 929
66e8453e1768

- removed the vertex object

icons/add-vertex.png file | annotate | diff | comparison | revisions
icons/corner-verts.png file | annotate | diff | comparison | revisions
icons/vertex.png file | annotate | diff | comparison | revisions
ldforge.qrc file | annotate | diff | comparison | revisions
src/actions.cc file | annotate | diff | comparison | revisions
src/actionsEdit.cc file | annotate | diff | comparison | revisions
src/addObjectDialog.cc file | annotate | diff | comparison | revisions
src/editmodes/drawMode.cc file | annotate | diff | comparison | revisions
src/ldDocument.cc file | annotate | diff | comparison | revisions
src/ldObject.cc file | annotate | diff | comparison | revisions
src/ldObject.h file | annotate | diff | comparison | revisions
src/ldObjectMath.cpp file | annotate | diff | comparison | revisions
src/mainWindow.cc file | annotate | diff | comparison | revisions
src/mainWindow.h file | annotate | diff | comparison | revisions
src/version.cc file | annotate | diff | comparison | revisions
ui/ldforge.ui file | annotate | diff | comparison | revisions
Binary file icons/add-vertex.png has changed
Binary file icons/corner-verts.png has changed
Binary file icons/vertex.png has changed
--- a/ldforge.qrc	Sat Feb 21 18:51:33 2015 +0200
+++ b/ldforge.qrc	Sat Feb 21 19:35:43 2015 +0200
@@ -9,15 +9,14 @@
 	<file>./icons/add-radial.png</file>
 	<file>./icons/add-subfile.png</file>
 	<file>./icons/add-triangle.png</file>
-	<file>./icons/add-vertex.png</file>
 	<file>./icons/arrow-down.png</file>
 	<file>./icons/arrow-left.png</file>
 	<file>./icons/arrow-right.png</file>
 	<file>./icons/arrow-up.png</file>
 	<file>./icons/autocolor.png</file>
 	<file>./icons/axes.png</file>
+	<file>./icons/bfc-view.png</file>
 	<file>./icons/bfc.png</file>
-	<file>./icons/bfc-view.png</file>
 	<file>./icons/bomb.png</file>
 	<file>./icons/brick-new.png</file>
 	<file>./icons/brick.png</file>
@@ -30,16 +29,15 @@
 	<file>./icons/camera-top.png</file>
 	<file>./icons/checkerboard.png</file>
 	<file>./icons/colorcursor.png</file>
+	<file>./icons/colors.txt</file>
 	<file>./icons/colorselect.png</file>
-	<file>./icons/colors.txt</file>
 	<file>./icons/comment.png</file>
 	<file>./icons/condline.png</file>
 	<file>./icons/copy.png</file>
-	<file>./icons/corner-verts.png</file>
 	<file>./icons/coverer.png</file>
 	<file>./icons/cut.png</file>
+	<file>./icons/del-line.png</file>
 	<file>./icons/delete.png</file>
-	<file>./icons/del-line.png</file>
 	<file>./icons/empty.png</file>
 	<file>./icons/error.png</file>
 	<file>./icons/exit.png</file>
@@ -47,9 +45,9 @@
 	<file>./icons/file-import.png</file>
 	<file>./icons/file-new.png</file>
 	<file>./icons/file-open.png</file>
-	<file>./icons/file.png</file>
 	<file>./icons/file-save-as.png</file>
 	<file>./icons/file-save.png</file>
+	<file>./icons/file.png</file>
 	<file>./icons/flip.png</file>
 	<file>./icons/folder.png</file>
 	<file>./icons/grid-coarse.png</file>
@@ -84,8 +82,8 @@
 	<file>./icons/overlay.png</file>
 	<file>./icons/palette.png</file>
 	<file>./icons/paste.png</file>
+	<file>./icons/quad-split.png</file>
 	<file>./icons/quad.png</file>
-	<file>./icons/quad-split.png</file>
 	<file>./icons/radial-convert.png</file>
 	<file>./icons/radial.png</file>
 	<file>./icons/random-colors.png</file>
@@ -103,7 +101,6 @@
 	<file>./icons/triangle.png</file>
 	<file>./icons/uncolorize.png</file>
 	<file>./icons/undo.png</file>
-	<file>./icons/vertex.png</file>
 	<file>./icons/visibility-hide.png</file>
 	<file>./icons/visibility-show.png</file>
 	<file>./icons/visibility-toggle.png</file>
--- a/src/actions.cc	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/actions.cc	Sat Feb 21 19:35:43 2015 +0200
@@ -226,13 +226,6 @@
 
 // =============================================================================
 //
-void MainWindow::slot_actionNewVertex()
-{
-	AddObjectDialog::staticDialog (OBJ_Vertex, LDObjectPtr());
-}
-
-// =============================================================================
-//
 void MainWindow::slot_actionEdit()
 {
 	if (Selection().size() != 1)
--- a/src/actionsEdit.cc	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/actionsEdit.cc	Sat Feb 21 19:35:43 2015 +0200
@@ -293,33 +293,6 @@
 
 // =============================================================================
 //
-void MainWindow::slot_actionCornerVerts()
-{
-	int num = 0;
-
-	for (LDObjectPtr obj : Selection())
-	{
-		if (obj->numVertices() < 2)
-			continue;
-
-		int ln = obj->lineNumber();
-
-		for (int i = 0; i < obj->numVertices(); ++i)
-		{
-			QSharedPointer<LDVertex> vert (LDSpawn<LDVertex>());
-			vert->pos = obj->vertex (i);
-			vert->setColor (obj->color());
-			CurrentDocument()->insertObj (++ln, vert);
-			++num;
-		}
-	}
-
-	print (tr ("Added %1 vertices"), num);
-	refresh();
-}
-
-// =============================================================================
-//
 static void MoveSelection (const bool up)
 {
 	LDObjectList objs = Selection();
--- a/src/addObjectDialog.cc	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/addObjectDialog.cc	Sat Feb 21 19:35:43 2015 +0200
@@ -73,11 +73,6 @@
 			coordCount = 12;
 		} break;
 
-		case OBJ_Vertex:
-		{
-			coordCount = 3;
-		} break;
-
 		case OBJ_BFC:
 		{
 			rb_bfcType = new RadioGroup ("Statement", {}, 0, Qt::Vertical);
@@ -359,13 +354,6 @@
 			bfc->setStatement (BFCStatement (dlg.rb_bfcType->value()));
 		} break;
 
-		case OBJ_Vertex:
-		{
-			LDVertexPtr vert = InitObject<LDVertex> (obj);
-			vert->pos.apply ([&](Axis ax, double& value) { value = dlg.dsb_coords[ax]->value(); });
-		}
-		break;
-
 		case OBJ_Subfile:
 		{
 			QString name = dlg.le_subfileName->text();
--- a/src/editmodes/drawMode.cc	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/editmodes/drawMode.cc	Sat Feb 21 19:35:43 2015 +0200
@@ -91,14 +91,7 @@
 	switch (verts.size())
 	{
 		case 1:
-		{
-			// 1 vertex - add a vertex object
-			LDVertexPtr obj = LDSpawn<LDVertex>();
-			obj->pos = verts[0];
-			obj->setColor (MainColor());
-			objs << obj;
-			break;
-		}
+			return;
 
 		case 2:
 		{
--- a/src/ldDocument.cc	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/ldDocument.cc	Sat Feb 21 19:35:43 2015 +0200
@@ -958,19 +958,7 @@
 				if (tokens.size() > 2 and tokens[1] == "!LDFORGE")
 				{
 					// Handle LDForge-specific types, they're embedded into comments too
-					if (tokens[2] == "VERTEX")
-					{
-						// Vertex (0 !LDFORGE VERTEX)
-						CheckTokenCount (tokens, 7);
-						CheckTokenNumbers (tokens, 3, 6);
-
-						LDVertexPtr obj = LDSpawn<LDVertex>();
-						obj->setColor (LDColor::fromIndex (StringToNumber (tokens[3])));
-						obj->pos.apply ([&](Axis ax, double& value)
-							{ value = tokens[4 + ax].toDouble(); });
-						return obj;
-					}
-					elif (tokens[2] == "OVERLAY")
+					if (tokens[2] == "OVERLAY")
 					{
 						CheckTokenCount (tokens, 9);
 						CheckTokenNumbers (tokens, 5, 8);
--- a/src/ldObject.cc	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/ldObject.cc	Sat Feb 21 19:35:43 2015 +0200
@@ -66,7 +66,6 @@
 LDOBJ_DEFAULT_CTOR (LDTriangle, LDObject)
 LDOBJ_DEFAULT_CTOR (LDCondLine, LDLine)
 LDOBJ_DEFAULT_CTOR (LDQuad, LDObject)
-LDOBJ_DEFAULT_CTOR (LDVertex, LDObject)
 LDOBJ_DEFAULT_CTOR (LDOverlay, LDObject)
 LDOBJ_DEFAULT_CTOR (LDBFC, LDObject)
 LDOBJ_DEFAULT_CTOR (LDComment, LDObject)
@@ -177,13 +176,6 @@
 
 // =============================================================================
 //
-QString LDVertex::asText() const
-{
-	return format ("0 !LDFORGE VERTEX %1 %2", color(), pos);
-}
-
-// =============================================================================
-//
 QString LDEmpty::asText() const
 {
 	return "";
@@ -533,11 +525,6 @@
 			text += ", ";
 
 		QString noun = format ("%1%2", typeName (objType), Plural (count));
-
-		// Plural of "vertex" is "vertices", correct that
-		if (objType == OBJ_Vertex and count != 1)
-			noun = "vertices";
-
 		text += format ("%1 %2", count, noun);
 	}
 
@@ -610,11 +597,6 @@
 		LDMatrixObjectPtr mo = self().toStrongRef().dynamicCast<LDMatrixObject>();
 		mo->setPosition (mo->position() + vect);
 	}
-	elif (type() == OBJ_Vertex)
-	{
-		// ugh
-		self().toStrongRef().staticCast<LDVertex>()->pos += vect;
-	}
 	else
 	{
 		for (int i = 0; i < numVertices(); ++i)
@@ -637,7 +619,6 @@
 		case OBJ_Quad:			return LDSpawn<LDQuad>();
 		case OBJ_Empty:			return LDSpawn<LDEmpty>();
 		case OBJ_Error:			return LDSpawn<LDError>();
-		case OBJ_Vertex:		return LDSpawn<LDVertex>();
 		case OBJ_Overlay:		return LDSpawn<LDOverlay>();
 		case OBJ_NumTypes:		assert (false);
 	}
@@ -767,8 +748,6 @@
 	setVertex (1, tmp);
 }
 
-void LDVertex::invert() {}
-
 // =============================================================================
 //
 LDLinePtr LDCondLine::toEdgeLine()
@@ -944,8 +923,3 @@
 {
 	verts << fileInfo()->inlineVertices();
 }
-
-void LDVertex::getVertices (QVector<Vertex>& verts) const
-{
-	verts.append (pos);
-}
--- a/src/ldObject.h	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/ldObject.h	Sat Feb 21 19:35:43 2015 +0200
@@ -68,7 +68,6 @@
 	OBJ_Triangle,		//	Object represents a	triangle
 	OBJ_Line,			//	Object represents a	line
 	OBJ_CondLine,		//	Object represents a	conditional line
-	OBJ_Vertex,			//	Object is a	vertex,	LDForge extension object
 	OBJ_BFC,			//	Object represents a	BFC statement
 	OBJ_Overlay,		//	Object contains meta-info about an overlay image.
 	OBJ_Comment,		//	Object represents a	comment
@@ -540,32 +539,6 @@
 using LDQuadWeakPtr = QWeakPointer<LDQuad>;
 
 //
-// LDVertex
-//
-// The vertex is an LDForce-specific extension which represents a single
-// vertex which can be used as a parameter to tools or to store coordinates
-// with. Vertices are a part authoring tool and they should not appear in
-// finished parts.
-//
-class LDVertex : public LDObject
-{
-	LDOBJ (Vertex)
-	LDOBJ_NAME (vertex)
-	LDOBJ_VERTICES (0) // TODO: move pos to m_vertices[0]
-	LDOBJ_COLORED
-	LDOBJ_DEFAULTCOLOR (MainColor())
-	LDOBJ_NON_SCEMANTIC
-	LDOBJ_NO_MATRIX
-
-public:
-	Vertex pos;
-	virtual void getVertices (QVector<Vertex>& verts) const override;
-};
-
-using LDVertexPtr = QSharedPointer<LDVertex>;
-using LDVertexWeakPtr = QWeakPointer<LDVertex>;
-
-//
 // LDOverlay
 //
 // Overlay image meta, stored in the header of parts so as to preserve overlay
--- a/src/ldObjectMath.cpp	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/ldObjectMath.cpp	Sat Feb 21 19:35:43 2015 +0200
@@ -78,12 +78,5 @@
 			// Transform the matrix
 			mo->setTransform (transform * mo->transform());
 		}
-		elif (obj->type() == OBJ_Vertex)
-		{
-			LDVertexPtr vert = obj.staticCast<LDVertex>();
-			Vertex v = vert->pos;
-			RotateVertex (v, rotpoint, transform);
-			vert->pos = v;
-		}
 	}
 }
--- a/src/mainWindow.cc	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/mainWindow.cc	Sat Feb 21 19:35:43 2015 +0200
@@ -373,12 +373,6 @@
 				break;
 			}
 
-			case OBJ_Vertex:
-			{
-				descr = obj.staticCast<LDVertex>()->pos.toString (true);
-				break;
-			}
-
 			case OBJ_Subfile:
 			{
 				LDSubfilePtr ref = obj.staticCast<LDSubfile>();
--- a/src/mainWindow.h	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/mainWindow.h	Sat Feb 21 19:35:43 2015 +0200
@@ -212,7 +212,6 @@
 	void slot_actionNewCLine();
 	void slot_actionNewComment();
 	void slot_actionNewBFC();
-	void slot_actionNewVertex();
 	void slot_actionUndo();
 	void slot_actionRedo();
 	void slot_actionCut();
@@ -239,7 +238,6 @@
 	void slot_actionSplitQuads();
 	void slot_actionEditRaw();
 	void slot_actionBorders();
-	void slot_actionCornerVerts();
 	void slot_actionRoundCoordinates();
 	void slot_actionVisibilityHide();
 	void slot_actionVisibilityReveal();
--- a/src/version.cc	Sat Feb 21 18:51:33 2015 +0200
+++ b/src/version.cc	Sat Feb 21 19:35:43 2015 +0200
@@ -26,53 +26,55 @@
 #include "version.h"
 #include "hginfo.h"
 
-char g_versionString[64] = {'\0'};
-char g_fullVersionString[256] = {'\0'};
-char g_buildTime[256] = {'\0'};
-
 // =============================================================================
 //
 const char* VersionString()
 {
-	if (g_versionString[0] == '\0')
+	static char result[64] = {'\0'};
+
+	if (result[0] == '\0')
 	{
 #if VERSION_PATCH == 0
-		sprintf (g_versionString, "%d.%d", VERSION_MAJOR, VERSION_MINOR);
+		sprintf (result, "%d.%d", VERSION_MAJOR, VERSION_MINOR);
 #else
 		sprintf (g_versionString, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
 #endif // VERSION_PATCH
 	}
 
-	return g_versionString;
+	return result;
 }
 
 // =============================================================================
 //
 const char* FullVersionString()
 {
-	if (g_fullVersionString[0] == '\0')
+	static char result[256] = {'\0'};
+
+	if (result[0] == '\0')
 	{
 #if BUILD_ID != BUILD_RELEASE and defined (HG_NODE)
-		sprintf (g_fullVersionString, "%s-" HG_NODE, VersionString());
+		sprintf (result, "%s-" HG_NODE, VersionString());
 #else
 		sprintf (g_fullVersionString, "%s", VersionString());
 #endif
 	}
 
-	return g_fullVersionString;
+	return result;
 }
 
 // =============================================================================
 //
 const char* CommitTimeString()
 {
+	static char result[256] = {'\0'};
+
 #ifdef HG_DATE_TIME
-	if (g_buildTime[0] == '\0')
+	if (result[0] == '\0')
 	{
 		time_t timestamp = HG_DATE_TIME;
-		strftime (g_buildTime, sizeof g_buildTime, "%d %b %Y", localtime (&timestamp));
+		strftime (result, sizeof result, "%d %b %Y", localtime (&timestamp));
 	}
 #endif
 
-	return g_buildTime;
+	return result;
 }
--- a/ui/ldforge.ui	Sat Feb 21 18:51:33 2015 +0200
+++ b/ui/ldforge.ui	Sat Feb 21 19:35:43 2015 +0200
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1010</width>
+    <width>1008</width>
     <height>641</height>
    </rect>
   </property>
@@ -47,8 +47,8 @@
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>237</width>
-           <height>414</height>
+           <width>234</width>
+           <height>428</height>
           </rect>
          </property>
          <attribute name="label">
@@ -75,8 +75,8 @@
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>237</width>
-           <height>414</height>
+           <width>234</width>
+           <height>428</height>
           </rect>
          </property>
          <attribute name="label">
@@ -157,8 +157,8 @@
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>237</width>
-           <height>414</height>
+           <width>234</width>
+           <height>428</height>
           </rect>
          </property>
          <attribute name="label">
@@ -193,8 +193,8 @@
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>1010</width>
-     <height>26</height>
+     <width>1008</width>
+     <height>21</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
@@ -265,7 +265,6 @@
     <addaction name="actionNewCLine"/>
     <addaction name="actionNewComment"/>
     <addaction name="actionNewBFC"/>
-    <addaction name="actionNewVertex"/>
    </widget>
    <widget class="QMenu" name="menuEdit">
     <property name="title">
@@ -314,7 +313,6 @@
     <addaction name="actionSplitQuads"/>
     <addaction name="actionEditRaw"/>
     <addaction name="actionBorders"/>
-    <addaction name="actionCornerVerts"/>
     <addaction name="actionRoundCoordinates"/>
     <addaction name="actionReplaceCoords"/>
     <addaction name="actionFlip"/>
@@ -437,7 +435,6 @@
    <addaction name="actionNewCLine"/>
    <addaction name="actionNewComment"/>
    <addaction name="actionNewBFC"/>
-   <addaction name="actionNewVertex"/>
   </widget>
   <widget class="QToolBar" name="toolBarBasicTools">
    <property name="windowTitle">
@@ -517,7 +514,6 @@
    <addaction name="actionInline"/>
    <addaction name="actionEditRaw"/>
    <addaction name="actionBorders"/>
-   <addaction name="actionCornerVerts"/>
    <addaction name="actionReplaceCoords"/>
    <addaction name="actionRoundCoordinates"/>
    <addaction name="actionVisibilityHide"/>
@@ -843,15 +839,6 @@
     <string>New BFC Statement</string>
    </property>
   </action>
-  <action name="actionNewVertex">
-   <property name="icon">
-    <iconset resource="../ldforge.qrc">
-     <normaloff>:/icons/add-vertex.png</normaloff>:/icons/add-vertex.png</iconset>
-   </property>
-   <property name="text">
-    <string>New Vertex</string>
-   </property>
-  </action>
   <action name="actionUndo">
    <property name="icon">
     <iconset resource="../ldforge.qrc">
@@ -1145,18 +1132,6 @@
     <string>Add borders around given polygons.</string>
    </property>
   </action>
-  <action name="actionCornerVerts">
-   <property name="icon">
-    <iconset resource="../ldforge.qrc">
-     <normaloff>:/icons/corner-verts.png</normaloff>:/icons/corner-verts.png</iconset>
-   </property>
-   <property name="text">
-    <string>Make Corner Vertices</string>
-   </property>
-   <property name="statusTip">
-    <string>Adds vertex objects to the corners of the given polygons</string>
-   </property>
-  </action>
   <action name="actionRoundCoordinates">
    <property name="icon">
     <iconset resource="../ldforge.qrc">

mercurial