If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.

2013-03-21

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 21 Mar 2013 18:26:57 +0200 (2013-03-21)
changeset 61
109b07334fa0
parent 60
961663d05463
child 62
915fc477cb6a

If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.

bbox.cpp file | annotate | diff | comparison | revisions
zz_setContentsDialog.cpp file | annotate | diff | comparison | revisions
zz_setContentsDialog.h file | annotate | diff | comparison | revisions
--- a/bbox.cpp	Thu Mar 21 16:25:03 2013 +0200
+++ b/bbox.cpp	Thu Mar 21 18:26:57 2013 +0200
@@ -107,13 +107,15 @@
 	double fXScale = (v0.x - v1.x);
 	double fYScale = (v0.y - v1.y);
 	double fZScale = (v0.z - v1.z);
-	double* fpSize = &fZScale;
+	double fSize = fZScale;
 	
 	if (fXScale > fYScale) {
 		if (fXScale > fZScale)
-			fpSize = &fXScale;
+			fSize = fXScale;
 	} else if (fYScale > fZScale)
-		fpSize = &fYScale;
+		fSize = fYScale;
 	
-	return (*fpSize) / 2;
+	if (fSize >= 2.0f)
+		return (fSize / 2);
+	return 1.0f;
 }
--- a/zz_setContentsDialog.cpp	Thu Mar 21 16:25:03 2013 +0200
+++ b/zz_setContentsDialog.cpp	Thu Mar 21 18:26:57 2013 +0200
@@ -39,12 +39,25 @@
 		"standard</a> for further information.");
 	qContents->setMinimumWidth (384);
 	
+	if (obj->getType() == OBJ_Gibberish) {
+		qErrorLabel = new QLabel;
+		qErrorLabel->setText (str::mkfmt ("<span style=\"color: #900\">%s</span>",
+			static_cast<LDGibberish*> (obj)->zReason.chars()));
+	}
+	
 	IMPLEMENT_DIALOG_BUTTONS
 	
 	QVBoxLayout* layout = new QVBoxLayout;
 	layout->addWidget (qContentsLabel);
 	layout->addWidget (qContents);
-	layout->addWidget (qButtons);
+	
+	QHBoxLayout* layout2 = new QHBoxLayout;
+	
+	if (obj->getType() == OBJ_Gibberish)
+		layout2->addWidget (qErrorLabel);
+	
+	layout2->addWidget (qButtons);
+	layout->addLayout (layout2);
 	setLayout (layout);
 	
 	setWindowTitle (APPNAME_DISPLAY " - setting contents");
--- a/zz_setContentsDialog.h	Thu Mar 21 16:25:03 2013 +0200
+++ b/zz_setContentsDialog.h	Thu Mar 21 18:26:57 2013 +0200
@@ -31,7 +31,7 @@
 // =============================================================================
 class SetContentsDialog : public QDialog {
 public:
-	QLabel* qContentsLabel;
+	QLabel* qContentsLabel, *qErrorLabel;
 	QLineEdit* qContents;
 	QDialogButtonBox* qButtons;
 	

mercurial