Nuked the obsolete radial type now

Tue, 02 Jul 2013 00:15:52 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 02 Jul 2013 00:15:52 +0300
changeset 312
97620579d86c
parent 311
c6e38e5e4f33
child 313
7e2cc227cfa0

Nuked the obsolete radial type now

src/addObjectDialog.cpp file | annotate | diff | comparison | revisions
src/addObjectDialog.h file | annotate | diff | comparison | revisions
src/bbox.cpp file | annotate | diff | comparison | revisions
src/extprogs.cpp file | annotate | diff | comparison | revisions
src/file.cpp file | annotate | diff | comparison | revisions
src/gldraw.cpp file | annotate | diff | comparison | revisions
src/gui_editactions.cpp file | annotate | diff | comparison | revisions
src/ldtypes.cpp file | annotate | diff | comparison | revisions
src/ldtypes.h file | annotate | diff | comparison | revisions
--- a/src/addObjectDialog.cpp	Tue Jul 02 00:06:06 2013 +0300
+++ b/src/addObjectDialog.cpp	Tue Jul 02 00:15:52 2013 +0300
@@ -134,43 +134,6 @@
 			break;
 		}
 	
-	case LDObject::Radial:
-		coordCount = 3;
-		
-		lb_radType = new QLabel ("Type:");
-		lb_radResolution = new QLabel ("Resolution:");
-		lb_radSegments = new QLabel ("Segments:");
-		lb_radRingNum = new QLabel ("Ring number:");
-		
-		rb_radType = new RadioBox ("Type", {}, 0, Qt::Vertical);
-		
-		for (int i = 0; i < LDRadial::NumTypes; ++i) {
-			if (i % (LDRadial::NumTypes / 2) == 0)
-				rb_radType->rowBreak ();
-			
-			rb_radType->addButton (LDRadial::radialTypeName ((LDRadial::Type) i));
-		}
-		
-		connect (rb_radType, SIGNAL (buttonPressed (int)), this, SLOT (slot_radialTypeChanged (int)));
-		
-		cb_radHiRes = new QCheckBox ("Hi-Res");
-		
-		sb_radSegments = new QSpinBox;
-		sb_radSegments->setMinimum (1);
-		
-		sb_radRingNum = new QSpinBox;
-		sb_radRingNum->setEnabled (false);
-		
-		if (obj) {
-			LDRadial* rad = static_cast<LDRadial*> (obj);
-			
-			rb_radType->setValue (rad->type ());
-			sb_radSegments->setValue (rad->segments ());
-			cb_radHiRes->setChecked ((rad->divisions () == hires) ? Qt::Checked : Qt::Unchecked);
-			sb_radRingNum->setValue (rad->number ());
-		}
-		break;
-	
 	default:
 		critical (fmt ("Unhandled LDObject type %1 (%2) in AddObjectDialog", (int) type, g_saObjTypeNames[type]));
 		return;
@@ -225,15 +188,6 @@
 		layout->addWidget (rb_bfcType, 0, 1);
 		break;
 	
-	case LDObject::Radial:
-		layout->addWidget (rb_radType, 1, 1, 3, 2);
-		layout->addWidget (cb_radHiRes, 1, 3);
-		layout->addWidget (lb_radSegments, 2, 3);
-		layout->addWidget (sb_radSegments, 2, 4);
-		layout->addWidget (lb_radRingNum, 3, 3);
-		layout->addWidget (sb_radRingNum, 3, 4);
-		break;
-	
 	case LDObject::Subfile:
 		layout->addWidget (tw_subfileList, 1, 1, 1, 2);
 		layout->addWidget (lb_subfileName, 2, 1);
@@ -317,14 +271,6 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-void AddObjectDialog::slot_radialTypeChanged (int dType) {
-	LDRadial::Type eType = (LDRadial::Type) dType;
-	sb_radRingNum->setEnabled (eType == LDRadial::Ring || eType == LDRadial::Cone);
-}
-
-// =============================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =============================================================================
 void AddObjectDialog::slot_subfileTypeChanged () {
 	str name = currentSubfileName ();
 	
@@ -362,7 +308,7 @@
 		return;
 	
 	matrix transform = g_identity;
-	if (type == LDObject::Subfile || type == LDObject::Radial) {
+	if( type == LDObject::Subfile ) {
 		vector<str> matrixstrvals = container_cast<QStringList, vector<str>> (str (dlg.le_matrix->text ()).split (" "));
 		
 		if (matrixstrvals.size () == 9) {
@@ -416,21 +362,6 @@
 		}
 		break;
 	
-	case LDObject::Radial:
-		{
-			LDRadial* rad = initObj<LDRadial> (obj);
-			
-			for (const Axis ax : g_Axes)
-				rad->setCoordinate (ax, dlg.dsb_coords[ax]->value ());
-			
-			rad->setDivisions (dlg.cb_radHiRes->isChecked () ? hires : lores);
-			rad->setSegments (min<short> (dlg.sb_radSegments->value (), rad->divisions ()));
-			rad->setType ((LDRadial::Type) dlg.rb_radType->value ());
-			rad->setNumber (dlg.sb_radRingNum->value ());
-			rad->setTransform (transform);
-		}
-		break;
-	
 	case LDObject::Subfile:
 		{
 			str name = dlg.le_subfileName->text ();
--- a/src/addObjectDialog.h	Tue Jul 02 00:06:06 2013 +0300
+++ b/src/addObjectDialog.h	Tue Jul 02 00:15:52 2013 +0300
@@ -56,14 +56,6 @@
 	QTreeWidget* tw_subfileList;
 	QLineEdit* le_subfileName;
 	QLabel* lb_subfileName;
-	
-	// Radial stuff
-	QCheckBox* cb_radHiRes;
-	RadioBox* rb_radType;
-	QSpinBox* sb_radSegments, *sb_radRingNum;
-	QLabel* lb_radType, *lb_radResolution, *lb_radSegments,
-		*lb_radRingNum;
-	
 	QLineEdit* le_matrix;
 	
 private:
@@ -74,7 +66,6 @@
 	
 private slots:
 	void slot_colorButtonClicked ();
-	void slot_radialTypeChanged (int type);
 	void slot_subfileTypeChanged ();
 };
 
--- a/src/bbox.cpp	Tue Jul 02 00:06:06 2013 +0300
+++ b/src/bbox.cpp	Tue Jul 02 00:15:52 2013 +0300
@@ -66,18 +66,6 @@
 		}
 		break;
 	
-	case LDObject::Radial:
-		{
-			LDRadial* rad = static_cast<LDRadial*> (obj);
-			vector<LDObject*> objs = rad->decompose (true);
-			
-			for (LDObject* obj : objs) {
-				calcObject (obj);
-				delete obj;
-			}
-		}
-		break;
-	
 	default:
 		break;
 	}
--- a/src/extprogs.cpp	Tue Jul 02 00:06:06 2013 +0300
+++ b/src/extprogs.cpp	Tue Jul 02 00:15:52 2013 +0300
@@ -131,12 +131,6 @@
 			writeObjects (objs, f);
 			for (LDObject* obj : objs)
 				delete obj;
-		} else if (obj->getType () == LDObject::Radial) {
-			vector<LDObject*> objs = static_cast<LDRadial*> (obj)->decompose (true);
-			
-			writeObjects (objs, f);
-			for (LDObject* obj : objs)
-				delete obj;
 		} else
 			f.write (obj->raw () + "\r\n");
 	}
--- a/src/file.cpp	Tue Jul 02 00:06:06 2013 +0300
+++ b/src/file.cpp	Tue Jul 02 00:15:52 2013 +0300
@@ -672,43 +672,6 @@
 					
 					return obj;
 				}
-				
-				if( tokens[2] == "RADIAL" )
-				{
-					CHECK_TOKEN_COUNT (20)
-					CHECK_TOKEN_NUMBERS (4, 19)
-					
-					LDRadial::Type radtype = LDRadial::NumTypes;
-					
-					for( int i = 0; i < LDRadial::NumTypes; ++i )
-					{
-						str radname = LDRadial::radialTypeName( (LDRadial::Type) i );
-						if( radname.toUpper().remove( ' ' ) == tokens[3] )
-						{
-							radtype = (LDRadial::Type) i;
-							break;
-						}
-					}
-					
-					if ( radtype == LDRadial::NumTypes)
-						return new LDGibberish (line, fmt ("Unknown radial type %1", tokens[3]));
-					
-					LDRadial* obj = new LDRadial;
-					
-					obj->setType( radtype );
-					obj->setColor( tokens[4].toLong() );
-					obj->setSegments( tokens[5].toLong() );
-					obj->setDivisions( tokens[6].toLong() );
-					obj->setNumber( tokens[7].toLong() );
-					obj->setPosition( parseVertex( tokens, 8 )); // 8 - 10
-					
-					matrix transform;
-					for( short i = 0; i < 9; ++i )
-						transform[i] = tokens[i + 11].toDouble(); // 11 - 19
-					
-					obj->setTransform( transform );
-					return obj;
-				}
 			}
 			
 			// Just a regular comment:
--- a/src/gldraw.cpp	Tue Jul 02 00:06:06 2013 +0300
+++ b/src/gldraw.cpp	Tue Jul 02 00:15:52 2013 +0300
@@ -751,28 +751,6 @@
 		}
 		break;
 	
-	case LDObject::Radial:
-		{
-			LDRadial* rad = static_cast<LDRadial*> (obj);
-			vector<LDObject*> objs = rad->decompose (true);
-			
-			bool oldinvert = g_glInvert;
-			if (rad->transform ().determinant () < 0)
-				g_glInvert = !g_glInvert;
-			
-			LDObject* prev = rad->prev ();
-			if (prev && prev->getType () == LDObject::BFC && static_cast<LDBFC*> (prev)->type == LDBFC::InvertNext)
-				g_glInvert = !g_glInvert;
-			
-			for (LDObject* obj : objs) {
-				compileList (obj, list);
-				delete obj;
-			}
-			
-			g_glInvert = oldinvert;
-		}
-		break;
-	
 #if 0
 	TODO: find a proper way to draw vertices without having them be affected by zoom.
 	case LDObject::Vertex:
@@ -1282,15 +1260,11 @@
 	if (obj->vertices () >= 2)
 		for (int i = 0; i < obj->vertices (); ++i)
 			verts << obj->getVertex (i);
-	else if (obj->getType () == LDObject::Subfile || obj->getType () == LDObject::Radial) {
-		vector<LDObject*> objs;
+	else if( obj->getType() == LDObject::Subfile )
+	{
+		vector<LDObject*> objs = static_cast<LDSubfile*>( obj )->inlineContents( true, true );
 		
-		if (obj->getType () == LDObject::Subfile)
-			objs = static_cast<LDSubfile*> (obj)->inlineContents (true, true);
-		else
-			objs = static_cast<LDRadial*> (obj)->decompose (true);
-		
-		for (LDObject* obj : objs) {
+		for( LDObject* obj : objs ) {
 			verts << getVertices (obj);
 			delete obj;
 		}
@@ -1302,7 +1276,8 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-void GLRenderer::compileObject (LDObject* obj) {
+void GLRenderer::compileObject( LDObject* obj )
+{
 	deleteLists (obj);
 	
 	for (const GL::ListType listType : g_glListTypes) {
--- a/src/gui_editactions.cpp	Tue Jul 02 00:06:06 2013 +0300
+++ b/src/gui_editactions.cpp	Tue Jul 02 00:15:52 2013 +0300
@@ -107,8 +107,6 @@
 		
 		if (obj->getType() == LDObject::Subfile)
 			objs = static_cast<LDSubfile*> (obj)->inlineContents (deep, true);
-		else if (obj->getType() == LDObject::Radial)
-			objs = static_cast<LDRadial*> (obj)->decompose (true);
 		else
 			continue;
 		
@@ -137,50 +135,6 @@
 	doInline (true);
 }
 
-// =======================================================================================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =======================================================================================================================================
-MAKE_ACTION (radialConvert, "Radials to Subfiles", "radial-convert", "Convert radials into primitives.", (0)) {
-	vector<str> fails;
-	vector<LDObject*> sel = g_win->sel ();
-	
-	for (LDObject* obj : sel) {
-		if (obj->getType() != LDObject::Radial)
-			continue;
-		
-		LDRadial* rad = static_cast<LDRadial*> (obj);
-		str name = rad->makeFileName ();
-		
-		LDOpenFile* file = getFile (name);
-		if (file == null) {
-			fails << name;
-			continue;
-		}
-		
-		// Create the replacement primitive.
-		LDSubfile* prim = new LDSubfile;
-		prim->setPosition (rad->position ()); // inherit position
-		prim->setTransform (rad->transform ()); // inherit matrix
-		prim->setColor (rad->color ()); // inherit color
-		prim->setFileInfo (file);
-		
-		// Replace the radial with the primitive.
-		rad->replace (prim);
-	}
-	
-	// If it was not possible to replace everything, inform the user.
-	if (fails.size() > 0) {
-		str errmsg = fmt ("Couldn't replace %lu radials as replacement subfiles could not be loaded:<br />", (ulong)fails.size ());
-		
-		for (str& fail : fails) 
-			errmsg += fmt ("* %1<br />", fail);
-		
-		critical (errmsg);
-	}
-	
-	g_win->fullRefresh ();
-}
-
 // ===============================================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // ===============================================================================================
--- a/src/ldtypes.cpp	Tue Jul 02 00:06:06 2013 +0300
+++ b/src/ldtypes.cpp	Tue Jul 02 00:15:52 2013 +0300
@@ -26,7 +26,6 @@
 
 char const* g_saObjTypeNames[] = {
 	"subfile",
-	"radial",
 	"quadrilateral",
 	"triangle",
 	"line",
@@ -42,7 +41,6 @@
 // Should probably get rid of this array sometime
 char const* g_saObjTypeIcons[] = {
 	"subfile",
-	"radial",
 	"quad",
 	"triangle",
 	"line",
@@ -477,10 +475,6 @@
 	setPosition (position () + vect);
 }
 
-void LDRadial::move (vertex vect) {
-	setPosition (position () + vect);
-}
-
 void LDLine::move (vertex vect) {
 	for (short i = 0; i < 2; ++i)
 		setVertex (i, getVertex (i) + vect);
@@ -504,59 +498,6 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-static char const* g_saRadialTypeNames[] = {
-	"Circle",
-	"Cylinder",
-	"Disc",
-	"Disc Negative",
-	"Ring",
-	"Cone",
-	null
-};
-
-char const* LDRadial::radialTypeName () {
-	return g_saRadialTypeNames[type ()];
-}
-
-char const* LDRadial::radialTypeName (const LDRadial::Type typeval) {
-	return g_saRadialTypeNames[typeval];
-}
-
-vector<LDObject*> LDRadial::decompose( bool applyTransform )
-{
-	return vector<LDObject*>();
-}
-
-// =============================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =============================================================================
-str LDRadial::raw () {
-	return fmt ("0 !LDFORGE RADIAL %1 %2 %3 %4 %5 %6 %7",
-		str (radialTypeName ()).toUpper ().remove (' '),
-		color (), segments (), divisions (), number (),
-		position ().stringRep (false), transform ().stringRep());
-}
-
-char const* g_radialNameRoots[] = {
-	"edge",
-	"cyli",
-	"disc",
-	"ndis",
-	"ring",
-	"con",
-	null
-};
-
-// =============================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =============================================================================
-str LDRadial::makeFileName () {
-	return "";
-}
-
-// =============================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =============================================================================
 #define CHECK_FOR_OBJ(N) \
 	if (type == LDObject::N) \
 		return new LD##N;
@@ -565,7 +506,6 @@
 	CHECK_FOR_OBJ (BFC)
 	CHECK_FOR_OBJ (Line)
 	CHECK_FOR_OBJ (CondLine)
-	CHECK_FOR_OBJ (Radial)
 	CHECK_FOR_OBJ (Subfile)
 	CHECK_FOR_OBJ (Triangle)
 	CHECK_FOR_OBJ (Quad)
@@ -604,37 +544,30 @@
 	setVertex (3, tmp);
 }
 
-static void invertSubfile (LDObject* obj) {
-	// Subfiles and radials are inverted when they're prefixed with
+void LDSubfile::invert () {
+	// Subfiles are inverted when they're prefixed with
 	// a BFC INVERTNEXT statement. Thus we need to toggle this status.
 	// For flat primitives it's sufficient that the determinant is
 	// flipped but I don't have a method for checking flatness yet.
 	// Food for thought...
 	
-	ulong idx = obj->getIndex (g_curfile);
+	ulong idx = getIndex( g_curfile );
 	
 	if (idx > 0) {
-		LDBFC* bfc = dynamic_cast<LDBFC*> (obj->prev ());
+		LDBFC* bfc = dynamic_cast<LDBFC*>( prev() );
 		
-		if (bfc && bfc->type == LDBFC::InvertNext) {
-			// Object is prefixed with an invertnext, thus remove it.
-			g_curfile->forgetObject (bfc);
+		if( bfc && bfc->type == LDBFC::InvertNext )
+		{
+			// This is prefixed with an invertnext, thus remove it.
+			g_curfile->forgetObject( bfc );
 			delete bfc;
 			return;
 		}
 	}
 	
 	// Not inverted, thus prefix it with a new invertnext.
-	LDBFC* bfc = new LDBFC (LDBFC::InvertNext);
-	g_curfile->insertObj (idx, bfc);
-}
-
-void LDSubfile::invert () {
-	invertSubfile (this);
-}
-
-void LDRadial::invert () {
-	invertSubfile (this);
+	LDBFC* bfc = new LDBFC( LDBFC::InvertNext );
+	g_curfile->insertObj( idx, bfc );
 }
 
 static void invertLine (LDObject* line) {
--- a/src/ldtypes.h	Tue Jul 02 00:06:06 2013 +0300
+++ b/src/ldtypes.h	Tue Jul 02 00:15:52 2013 +0300
@@ -93,7 +93,6 @@
 	// Object type codes. Codes are sorted in order of significance.
 	enum Type {
 		Subfile,		// Object represents a sub-file reference
-		Radial,			// Object represents a generic radial
 		Quad,			// Object represents a quadrilateral
 		Triangle,		// Object represents a triangle
 		Line,			// Object represents a line
@@ -390,58 +389,6 @@
 };
 
 // =============================================================================
-// LDRadial
-// 
-// The generic radial primitive (radial for short) is another LDforge-specific
-// extension which represents an arbitrary circular primitive. Radials can appear
-// as circles, cylinders, rings, cones, discs and disc negatives; the point is to
-// allow part authors to add radial primitives to parts without much hassle about
-// non-existant primitive parts.
-// =============================================================================
-class LDRadial : public LDObject, public LDMatrixObject {
-public:
-	enum Type {
-		Circle,
-		Cylinder,
-		Disc,
-		DiscNeg,
-		Ring,
-		Cone,
-		NumTypes
-	};
-	
-	PROPERTY (LDRadial::Type, type, setType)
-	PROPERTY (short, divisions, setDivisions)
-	PROPERTY (short, segments, setSegments)
-	PROPERTY (short, number, setNumber)
-	
-public:
-	LDOBJ (Radial)
-	LDOBJ_VERTICES (0)
-	LDOBJ_COLORED
-	LDOBJ_SCEMANTIC
-	LDOBJ_HAS_MATRIX
-	
-	LDRadial () { setLinkPointer (this); }
-	LDRadial (LDRadial::Type radType, vertex pos, matrix transform, short divs, short segs, short ringNum) :
-		LDMatrixObject (transform, pos), PROP_NAME (type) (radType), PROP_NAME (divisions) (divs),
-		PROP_NAME (segments) (segs), PROP_NAME (number) (ringNum)
-	{
-		setLinkPointer (this);
-	}
-	
-	// Returns a set of objects that provide the equivalent of this radial.
-	// Note: objects are heap-allocated.
-	vector<LDObject*> decompose (bool applyTransform);
-	
-	// Compose a file name for this radial.
-	str makeFileName ();
-	
-	char const* radialTypeName ();
-	static char const* radialTypeName (const LDRadial::Type type);
-};
-
-// =============================================================================
 // Object type names. Pass the return value of getType as the index to get a
 // string representation of the object's type.
 extern const char* g_saObjTypeNames[];

mercurial