Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Henrik Eriksson committed Apr 27, 2007
1 parent 1bebf35 commit 5b5e46e
Show file tree
Hide file tree
Showing 14 changed files with 776 additions and 221 deletions.
3 changes: 2 additions & 1 deletion OMNotebook/OMNotebookQT4/cellparserfactory.cpp
Expand Up @@ -79,7 +79,8 @@ namespace IAEX


if( filename.endsWith(".onb", Qt::CaseInsensitive) ||
filename.endsWith(".xml", Qt::CaseInsensitive) )
filename.endsWith(".xml", Qt::CaseInsensitive) ||
filename.endsWith(".onbz", Qt::CaseInsensitive))
{
return new XMLParser(filename, f, document, readmode);//openXMLFile(filename);
}
Expand Down
30 changes: 30 additions & 0 deletions OMNotebook/OMNotebookQT4/evalthread.cpp
@@ -0,0 +1,30 @@
#include "evalthread.h"
#include <QPushButton>
#include <fstream>
#include <QApplication>
using namespace std;




EvalThread::EvalThread(InputCellDelegate* delegate_, QString expr_, QObject* parent): QThread(parent), delegate(delegate_), expr(expr_)
{



}

EvalThread::~EvalThread()
{

}

void EvalThread::run()
{

delegate->evalExpression(expr);




}
25 changes: 25 additions & 0 deletions OMNotebook/OMNotebookQT4/evalthread.h
@@ -0,0 +1,25 @@
#ifndef EVALTHREAD_H
#define EVALTHREAD_H
#include <QThread>
#include "inputcelldelegate.h"
#include <QString>
using namespace std;
using namespace IAEX;

class EvalThread: public QThread
{
public:
EvalThread(InputCellDelegate* delegate_, QString expr, QObject * parent = 0);
~EvalThread();

void run();


private:
InputCellDelegate* delegate;
QString expr;


};

#endif
90 changes: 78 additions & 12 deletions OMNotebook/OMNotebookQT4/graphcell.cpp
Expand Up @@ -72,6 +72,8 @@ licence: http://www.trolltech.com/products/qt/licensing.html
#include <QtGui/QResizeEvent>
#include <QtGui/QFrame>
#include <QtGui/QTextFrame>
#include <QAction>
#include <QActionGroup>

//IAEX Headers
#include "graphcell.h"
Expand All @@ -80,13 +82,10 @@ licence: http://www.trolltech.com/products/qt/licensing.html
#include "commandcompletion.h"
#include "highlighterthread.h"
#include "omcinteractiveenvironment.h"

//#include <QSlider>
//#include "../graphWidget/graphWidget.h"
#include "../Pltpkg2/graphWidget.h"
#include "../Pltpkg2/compoundWidget.h"
#include <QAction>
#include <QActionGroup>

#include "evalthread.h"

namespace IAEX
{
Expand Down Expand Up @@ -749,8 +748,9 @@ namespace IAEX
input_->document()->blockSignals(false);
// input_->document()->setHtml( input_->toHtml() );
bool b = input_->document()->isEmpty();
input_->document()->setPlainText(QString("uu"));
input_->document()->setPlainText(text);
// input_->document()->setPlainText( input_->toPlainText() );

input_->document()->rootFrame()->setFrameFormat( (*style_.textFrameFormat()) );

contentChanged();
Expand Down Expand Up @@ -999,11 +999,18 @@ namespace IAEX
void GraphCell::setClosed(const bool closed, bool update)
{
if( closed )
{
output_->hide();
compoundwidget->hide();

}
else
{
if( evaluated_ )
{
output_->show();
compoundwidget->show();
}
}

closed_ = closed;
Expand Down Expand Up @@ -1207,7 +1214,7 @@ namespace IAEX
QString expr = input_->toPlainText();
//expr = expr.simplified();


/*
QString openmodelica( getenv( "OPENMODELICAHOME" ) );
if( openmodelica.isEmpty() )
QMessageBox::critical( 0, "OpenModelica Error", "Could not find environment variable OPENMODELICAHOME; OMNotebook will therefore not work correctly" );
Expand All @@ -1227,7 +1234,7 @@ namespace IAEX
filename += "/";
filename += imagename;
// 2006-02-17 AF,
*/ // 2006-02-17 AF,
evaluated_ = true;
setClosed(false);

Expand Down Expand Up @@ -1266,7 +1273,10 @@ namespace IAEX
// 2006-02-02 AF, Added try-catch
try
{
delegate()->evalExpression( expr );
EvalThread* et = new EvalThread(delegate(), expr);
connect(et, SIGNAL(finished()), this, SLOT(delegateFinished()));
et->start();
// delegate()->evalExpression( expr );
}
catch( exception &e )
{
Expand All @@ -1284,7 +1294,7 @@ namespace IAEX
output_->blockSignals(false);
return;
}

/*
// get the result
QString res = delegate()->getResult();
QString error;
Expand All @@ -1301,7 +1311,7 @@ namespace IAEX
output_->blockSignals(false);
return;
}

*/
// if the expression is a plot command and the is no errors
// in the result, find the image and insert it into the
// output part of the cell.
Expand Down Expand Up @@ -1376,7 +1386,8 @@ namespace IAEX
{
*/
// check if resualt is empty
if( res.isEmpty() && error.isEmpty() )
/*
if( res.isEmpty() && error.isEmpty() )
res = "[done]";
if( !error.isEmpty() )
Expand All @@ -1401,8 +1412,63 @@ namespace IAEX
input_->blockSignals(false);
output_->blockSignals(false);
*/
}


else
cout << "Not delegate on GraphCell" << endl;

input_->blockSignals(false);
output_->blockSignals(false);



}

void GraphCell::delegateFinished()
{
// QMessageBox::information(0, "uu", "vv");

delete sender();

QString res = delegate()->getResult();
QString error;

// 2006-02-02 AF, Added try-catch
try
{
error = delegate()->getError();
}
catch( exception &e )
{
exceptionInEval(e);
input_->blockSignals(false);
output_->blockSignals(false);
return;
}


if( res.isEmpty() && error.isEmpty() )
res = "[done]";

if( !error.isEmpty() )
res += QString("\n") + error;

output_->selectAll();
output_->textCursor().insertText( res );
//output_->setPlainText( res );
// }

++numEvals_;
// dir.remove( imagename );


contentChanged();

//Emit that the text have changed
emit textChanged(true);
}
/*!
* \author Anders Fernström
* \date 2006-02-02
Expand Down
10 changes: 5 additions & 5 deletions OMNotebook/OMNotebookQT4/graphcell.h
Expand Up @@ -65,17 +65,15 @@ licence: http://www.trolltech.com/products/qt/licensing.html
#include <QtGui/QGridLayout>
#include <QtGui/QResizeEvent>
#include <QtCore/QEvent>
//#include <QSlider>
//#include "../Pltpkg2/graphWidget.h"
#include "../Pltpkg2/compoundWidget.h"

//IAEX Headers
#include "cell.h"
//#include "graphcelldelegate.h"
#include "inputcelldelegate.h"
#include "syntaxhighlighter.h"
//#include "highlighter.h"
#include "document.h"
#include <QToolBar>
//#include <QToolBar>

namespace IAEX
{
Expand Down Expand Up @@ -138,6 +136,7 @@ namespace IAEX
virtual void setFocus(const bool focus);
virtual void setFocusOutput(const bool focus); // Added 2006-02-03 AF

void delegateFinished();


protected:
Expand Down Expand Up @@ -179,8 +178,9 @@ namespace IAEX
Document *document_;

// GraphWidget* graphwidget;
public:
CompoundWidget* compoundwidget;
QToolBar *toolbar;
// QToolBar *toolbar;
// QSlider* slider;
};

Expand Down

0 comments on commit 5b5e46e

Please sign in to comment.