When a warning appears on the output pane, there is another message that pops
up at the top of the preview window. Is there a way to generate text in the
output pane such that I can get such a message at the top of the preview
window?
--
View this message in context: http://forum.openscad.org/Generating-my-own-warnings-tp20114.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On 01/16/2017 03:26 PM, adrian wrote:
When a warning appears on the output pane, there is another message
that pops up at the top of the preview window. Is there a way to
generate text in the output pane such that I can get such a message
at the top of the preview window?
I don't think that's possible. Right now the ECHO: prefix prevents
that. The dev snapshot will show the popup when assert() fails.
ciao,
Torsten.
How does OpenSCAD determine what is a Warning and what is not? Does it look
for a new line? Colour? Particular tag?
--
View this message in context: http://forum.openscad.org/Generating-my-own-warnings-tp20114p20127.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
The message has WARNING: or ERROR: at the beginning.
Then this outputs the message.
void MainWindow::consoleOutput(const QString &msg)
{
QString qmsg;
if (msg.startsWith("WARNING:") || msg.startsWith("DEPRECATED:")) {
this->compileWarnings++;
qmsg = "<html>" + QT_HTML_ESCAPE(QString(msg)) + "</html>\n";
} else if (msg.startsWith("ERROR:")) {
this->compileErrors++;
qmsg = "<html>" + QT_HTML_ESCAPE(QString(msg)) + "</html>\n";
}
else {
qmsg = msg;
}
QTextCursor c = this->console->textCursor();
c.movePosition(QTextCursor::End);
this->console->setTextCursor(c);
this->console->append(qmsg);
if (this->procevents) QApplication::processEvents();
}
After compile this does the message at the top:
void MainWindow::updateCompileResult()
{
if ((compileErrors == 0) && (compileWarnings == 0)) {
frameCompileResult->hide();
return;
}
Settings::Settings *s = Settings::Settings::inst();
if (!s->get(Settings::Settings::showWarningsIn3dView).toBool()) {
return;
}
QString msg;
if (compileErrors > 0) {
if (fileName.isEmpty()) {
msg = QString(_("Compile error."));
} else {
QFileInfo fileInfo(fileName);
msg = QString(_("Error while compiling '%1'.")).arg(fileInfo.fileName());
}
toolButtonCompileResultIcon->setIcon(QIcon(QString::fromUtf8(":/icons/information-icons-error.png")));
} else {
const char *fmt = ngettext("Compilation generated %1 warning.",
"Compilation generated %1 warnings.", compileWarnings);
msg = QString(fmt).arg(compileWarnings);
toolButtonCompileResultIcon->setIcon(QIcon(QString::fromUtf8(":/icons/information-icons-warning.png")));
}
QFontMetrics fm(labelCompileResultMessage->font());
int sizeIcon = std::max(12, std::min(32, fm.height()));
int sizeClose = std::max(10, std::min(32, fm.height()) - 4);
toolButtonCompileResultIcon->setIconSize(QSize(sizeIcon, sizeIcon));
toolButtonCompileResultClose->setIconSize(QSize(sizeClose, sizeClose));
msg += _(" For details see console window <\"#console\"> .");
labelCompileResultMessage->setText(msg);
frameCompileResult->show();
}
Both bits of code are here:
https://github.com/openscad/openscad/blob/1fd9f05b441e85d5f827ce96154ce79ca334ce32/src/mainwin.cc
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/Generating-my-own-warnings-tp20114p20128.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Beginning of what? How is the console output broken up? Is it a line? Some
arbitrary thing such that echo() cannot cause this to work? Why doesn't this
show up as a warning?
echo(str(chr(13),"WARNING: blah"));
--
View this message in context: http://forum.openscad.org/Generating-my-own-warnings-tp20114p20129.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Beginning of what?
The error message in the application. eg
if (steps >= 10000) {
PRINTB("WARNING: Bad range parameter in for statement: too many elements
(%lu).", steps);
Some arbitrary thing such that echo() cannot cause this to work?
Correct, as tp3 mentioned above, "I don't think that's possible. Right now
the ECHO: prefix prevents
that."
Why doesn't this show up as a warning?
Because it is the string 'ECHO: <cr>"
WARNING: blah" '
It begins with "ECHO:"
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/Generating-my-own-warnings-tp20114p20130.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Note that you can use HTML to highlight echo() output, see HTML references in
the wiki
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Echo_Statements
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/Generating-my-own-warnings-tp20114p20131.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Thanks Michael. I do realize I can do my own highlighting. However, I would
like to make it such that if I have an issue, that it is visible at the top
of the GUI, making it immediately visible to the user in case it gets
scrolled off screen.
--
View this message in context: http://forum.openscad.org/Generating-my-own-warnings-tp20114p20151.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
You could stick a big 'ERROR' in the middle of the preview, using
color("magenta") %text("ERROR!",size=50);
That would be noticeable.
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/Generating-my-own-warnings-tp20114p20153.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I agree - this is what I prefer to do in the thingiverse customiser.
So when a parameter creates a weird result I can test for - I print a
warning as text in the scene.
E.g. if an angle results in self intersecting geometery...
--
View this message in context: http://forum.openscad.org/Generating-my-own-warnings-tp20114p20156.html
Sent from the OpenSCAD mailing list archive at Nabble.com.