Skip to content

Commit

Permalink
New caption for omc messages
Browse files Browse the repository at this point in the history
also highlight error cells in red, warning cells in yellow
  • Loading branch information
hkiel committed May 24, 2017
1 parent a884b96 commit 2b12dca
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
11 changes: 11 additions & 0 deletions OMNotebook/OMNotebookGUI/graphcell.cpp
Expand Up @@ -1396,6 +1396,7 @@ namespace IAEX {
{
QString res = delegate->getResult();
QString error = delegate->getError();
int errorLevel= delegate->getErrorLevel();

//delete sender();
guard->unlock();
Expand All @@ -1422,6 +1423,16 @@ namespace IAEX {
output_->selectAll();
output_->textCursor().insertText( res );

QPalette pal = output_->palette(); // define pallete for textEdit..
if (errorLevel >= 2) {
pal.setColor(QPalette::Base, QColor(0xff,0xe0,0xe0));
} else if (errorLevel == 1) {
pal.setColor(QPalette::Base, QColor(0xff,0xff,0xe0));
} else {
pal.setColor(QPalette::Base, Qt::white);
}
output_->setPalette(pal);

QList<QAction*> actions;
while((p=res.indexOf(e, p)) > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion OMNotebook/OMNotebookGUI/graphcelldelegate.h
Expand Up @@ -54,7 +54,7 @@ namespace IAEX
{
public:
virtual QString getResult() = 0;
virtual QString getError() = 0; // Added 2006-02-02 AF
virtual QString getError() = 0; // Added 2006-02-02 AF
virtual void evalExpression(QString &expr) = 0;
virtual void closeConnection() = 0; // Added 2006-02-02 AF
virtual void reconnect() = 0; // Added 2006-02-02 AF
Expand Down
1 change: 1 addition & 0 deletions OMNotebook/OMNotebookGUI/inputcelldelegate.h
Expand Up @@ -55,6 +55,7 @@ namespace IAEX
public:
virtual QString getResult() = 0;
virtual QString getError() = 0; // Added 2006-02-02 AF
virtual int getErrorLevel() = 0; // Added 2006-02-02 AF
virtual void evalExpression(const QString expr) = 0;
};

Expand Down
23 changes: 22 additions & 1 deletion OMNotebook/OMNotebookGUI/omcinteractiveenvironment.cpp
Expand Up @@ -139,6 +139,17 @@ namespace IAEX
return error_;
}

/*!
* \author Hennning Kiel
* \date 2017-05-24
*
*\brief Method to get error message severity from OMC
*/
int OmcInteractiveEnvironment::getErrorLevel()
{
return severity;
}

// QMutex omcMutex;

/*!
Expand Down Expand Up @@ -172,14 +183,24 @@ namespace IAEX
error_ = MMC_STRINGDATA(reply_str);
error_ = error_.trimmed();
if( error_.size() > 2 ) {
error_ = QString( "OMC-ERROR: \n" ) + error_;
if (error_.contains("Error:")) {
severity = 2;
error_ = QString( "OMC-ERROR: \n" ) + error_;
} else if (error_.contains("Warning:")) {
severity = 1;
error_ = QString( "OMC-WARNING: \n" ) + error_;
} else {
severity = 0;
}
} else { // no errors, clear the error.
error_.clear();
severity = 0;
}

MMC_ELSE()
result_ = "";
error_ = "";
severity = 3;
fprintf(stderr, "Stack overflow detected and was not caught.\nSend us a bug report at https://trac.openmodelica.org/OpenModelica/newticket\n Include the following trace:\n");
printStacktraceMessages();
fflush(NULL);
Expand Down
2 changes: 2 additions & 0 deletions OMNotebook/OMNotebookGUI/omcinteractiveenvironment.h
Expand Up @@ -53,6 +53,7 @@ namespace IAEX
static OmcInteractiveEnvironment* getInstance();
virtual QString getResult();
virtual QString getError();
virtual int getErrorLevel();
virtual void evalExpression(const QString expr);
static QString OMCVersion();
static QString OpenModelicaHome();
Expand All @@ -62,6 +63,7 @@ namespace IAEX
static OmcInteractiveEnvironment* selfInstance;
QString result_;
QString error_;
int severity;
};
}
#endif

0 comments on commit 2b12dca

Please sign in to comment.