Skip to content

Commit

Permalink
- Added new configure option --with-Coin (Coin disabled by default).
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5385 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 25, 2010
1 parent f5e60b4 commit 8b221f1
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 48 deletions.
4 changes: 4 additions & 0 deletions OMNotebook/3Dpkg/SimulationData.cpp
Expand Up @@ -31,6 +31,8 @@
*/


#ifdef HAVE_COIN

#include "SimulationData.h"
#include <iostream>

Expand Down Expand Up @@ -657,3 +659,5 @@ namespace IAEX {
// // n = n.nextSibling();
// }
//}

#endif
4 changes: 4 additions & 0 deletions OMNotebook/3Dpkg/SimulationData.h
Expand Up @@ -38,6 +38,7 @@
#include <QtCore/QVector>
#include <QtCore/QHash>

#ifdef HAVE_COIN
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoTranslation.h>
#include <Inventor/nodes/SoRotation.h>
Expand Down Expand Up @@ -145,3 +146,6 @@ namespace IAEX
float end_time;
};
}

#endif

54 changes: 36 additions & 18 deletions OMNotebook/3Dpkg/VisualizationWidget.cpp
Expand Up @@ -36,7 +36,7 @@ namespace IAEX {

VisualizationWidget::VisualizationWidget(QWidget *parent) : QWidget(parent)
{
#ifndef __APPLE_CC__
//#ifdef HAVE_COIN
this->setMinimumWidth(600);
this->setMinimumHeight(300);
this->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
Expand All @@ -45,8 +45,10 @@ namespace IAEX {

visframe_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));

#ifdef HAVE_COIN
simdata_ = new SimulationData();
simdata_->setFrame(0);
#endif

QFrame *buttonframe = new QFrame();
QPushButton *playbutton = new QPushButton("Play");
Expand All @@ -58,9 +60,13 @@ namespace IAEX {
label_ = new QLabel();
label_->setText("0");
slider_ = new QSlider(Qt::Vertical);
#ifdef HAVE_COIN
slider_->setRange(1000*simdata_->get_start_time(), 1000*simdata_->get_end_time());
#endif
slider_->setValue(0);
#ifdef HAVE_COIN
currentTime_ = 1000*simdata_->get_start_time();
#endif
timer_ = new QTimer(this);
// 40 fps
timer_->setInterval(25);
Expand All @@ -85,11 +91,15 @@ namespace IAEX {

buttonframe->setLayout(buttonlayout_);

#ifdef HAVE_COIN
eviewer_ = new SoQtExaminerViewer(visframe_, NULL, TRUE, SoQtFullViewer::BUILD_NONE);
//eviewer_->setSize(SbVec2s(600,400));
//eviewer_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
eviewer_->setSceneGraph(simdata_->getSceneGraph());
eviewer_->setBackgroundColor(SbColor(0.95f, 0.95f, 0.95f));
#else
new QLabel(QString("Coin3D was disabled on this build.\nThe rest of the widget still works so\nthe application won't crash when we send it data."), visframe_);
#endif

//SoCamera *cam = eviewer_->getCamera();
//cam->
Expand All @@ -102,50 +112,52 @@ namespace IAEX {
server = new QTcpServer(this);
server->setMaxPendingConnections(500);
activeSocket = 0;
#endif
//#endif

}

VisualizationWidget::~VisualizationWidget(void)
{
#ifndef __APPLE_CC__
delete slider_;
#ifdef HAVE_COIN
delete eviewer_;
#endif
delete visframe_;
delete server;
delete buttonlayout_;
delete timer_;
#endif
}

void VisualizationWidget::sliderChanged(int val) {
#ifndef __APPLE_CC__
currentTime_ = val;
QString num;
num.setNum(currentTime_/1000.0);
label_->setText(num);
#ifdef HAVE_COIN
simdata_->setFrame(currentTime_/1000.0);
#endif
}

void VisualizationWidget::nextFrame() {
#ifndef __APPLE_CC__
currentTime_ += 25; // FIIIIX!
#ifdef HAVE_COIN
if (currentTime_ > 1000*simdata_->get_end_time()) {
currentTime_ = 0;
}
#endif

QString num;
num.setNum(currentTime_/1000.0);
label_->setText(num);
slider_->setValue(currentTime_);
#ifdef HAVE_COIN
simdata_->setFrame(currentTime_/1000.0);
#endif
}

void VisualizationWidget::setServerState(bool listen)
{
#ifndef __APPLE_CC__
//#ifdef HAVE_COIN
if(listen)
{

Expand Down Expand Up @@ -188,21 +200,21 @@ namespace IAEX {
emit newMessage("Port closed");
emit serverState(false);
}
#endif
//#endif
}

bool VisualizationWidget::getServerState()
{
#ifndef __APPLE_CC__
//#ifdef HAVE_COIN
return server->isListening();
#else
//#else
return 0;
#endif
//#endif
}

void VisualizationWidget::acceptConnection()
{
#ifndef __APPLE_CC__
//#ifdef HAVE_COIN
while(server && server->hasPendingConnections())
{
if( (activeSocket && (activeSocket->state() == QAbstractSocket::UnconnectedState) || !activeSocket))
Expand All @@ -221,11 +233,11 @@ namespace IAEX {

qApp->processEvents();
}
#endif
//#endif
}

void VisualizationWidget::getData() {
#ifndef __APPLE_CC__
//#ifdef HAVE_COIN
disconnect(activeSocket, SIGNAL(readyRead()), 0, 0);
connect(activeSocket, SIGNAL(readyRead()), this, SLOT(getData()));

Expand Down Expand Up @@ -253,7 +265,9 @@ namespace IAEX {
}
else if(command == QString("ptolemyDataStream"))
{
#ifdef HAVE_COIN
simdata_->clear();
#endif
emit newMessage("Recieving streaming data...");
disconnect(activeSocket, SIGNAL(readyRead()), 0, 0);

Expand All @@ -270,13 +284,13 @@ namespace IAEX {
}

connect(activeSocket, SIGNAL(readyRead()), this, SLOT(getData()));
#endif
//#endif
}



void VisualizationWidget::readPtolemyDataStream() {
#ifndef __APPLE_CC__
//#ifdef HAVE_COIN
QString tmp;
//qint32 variableCount = 0;
// qint32 packetSize = 0;
Expand Down Expand Up @@ -334,7 +348,9 @@ namespace IAEX {
std::cout << "name: " << objname.toStdString()
<< " & type: " << objtype.toStdString()
<< " & params: " << params.toStdString() << std::endl;
#ifdef HAVE_COIN
simdata_->addObject(objtype, objname, params);
#endif
}
}

Expand All @@ -356,6 +372,7 @@ namespace IAEX {
}

ds >> variableCount;
#ifdef HAVE_COIN
SimulationKeypoint *point = new SimulationKeypoint();

for(quint32 i = 0; i < variableCount; ++i)
Expand All @@ -374,16 +391,17 @@ namespace IAEX {

packetSize = 0;
++it;
#endif
}
while(activeSocket->bytesAvailable() >= sizeof(quint32));

if(activeSocket->state() != QAbstractSocket::ConnectedState)
ptolemyDataStreamClosed();
#endif
//#endif
}

void VisualizationWidget::ptolemyDataStreamClosed() {
#ifndef __APPLE_CC__
#ifdef HAVE_COIN
slider_->setRange(1000*simdata_->get_start_time(), 1000*simdata_->get_end_time());
slider_->setValue(0);
//for(map<QString, VariableData*>::iterator i = variables.begin(); i != variables.end(); ++i)
Expand Down
6 changes: 4 additions & 2 deletions OMNotebook/3Dpkg/VisualizationWidget.h
Expand Up @@ -46,7 +46,7 @@
#include <QtGui/QMessageBox>
#include <QtGui/QApplication>

#ifndef __APPLE_CC__
#ifdef HAVE_COIN
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/SoQtRenderArea.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
Expand Down Expand Up @@ -88,14 +88,16 @@ namespace IAEX {
void ptolemyDataStreamClosed();

private:
#ifndef __APPLE_CC__
#ifdef HAVE_COIN
SoQtExaminerViewer *eviewer_;
SoQtRenderArea *renderarea_;
#endif
QFrame *frame_;
QSlider *slider_;
QLabel *label_;
#ifdef HAVE_COIN
SimulationData *simdata_;
#endif
QWidget *visframe_;
QVBoxLayout *buttonlayout_;
QTimer* timer_;
Expand Down
10 changes: 10 additions & 0 deletions OMNotebook/OMNotebookQT4/OMNotebook.config.in
@@ -0,0 +1,10 @@
COIN_LIBS = @COIN_LIBS@
SOQT_LIBS = @SOQT_LIBS@
COIN_INCLUDE = @COIN_INCLUDE@
SOQT_INCLUDE = @SOQT_INCLUDE@
HAVE_COIN = @HAVE_COIN@

CORBALIBS = @CORBALIBS@
CORBAINC = @CORBACFLAGS@
USE_CORBA = @QT_USE_CORBA@

34 changes: 15 additions & 19 deletions OMNotebook/OMNotebookQT4/OMNotebook.pro
Expand Up @@ -13,16 +13,23 @@ win32 {
CORBAINC = $$system(mico-config --prefix)/include
CORBALIBS = $$system(mico-config --libs)
DEFINES += HAVE_MICO
COIN_INCLUDE = $$system(coin-config --includedir)
SOQT_INCLUDE = $$system(soqt-config --includedir)
COIN_LIBS = $$system(coin-config --ldflags --libs)
SOQT_LIBS = $$system(soqt-config --ldflags --libs)
} else {
CORBAINC = $$(CORBACFLAGS)
CORBALIBS = $$(CORBALIBS)
DEFINES += $$(USE_CORBA)
include(OMNotebook.config)
}

COIN_LIBS = $$system(coin-config --ldflags --libs)
SOQT_LIBS = $$system(soqt-config --ldflags --libs)
unix:LIBS += -L${ANTLRHOME}/lib -lantlr $${CORBALIBS} $${COIN_LIBS} $${SOQT_LIBS}

LIBS += -L${ANTLRHOME}/lib -lantlr $${CORBALIBS} $${COIN_LIBS} $${SOQT_LIBS}
INCLUDEPATH += $${CORBAINC} \
$${COIN_INCLUDE} \
$${SOQT_INCLUDE} \
/usr/include/qt4/ \
${ANTLRHOME}/include \
../NotebookParser \
../Pltpkg2 \
../3Dpkg

TARGET = OMNotebook

Expand All @@ -34,19 +41,8 @@ QMAKE_LFLAGS+=
#If omc is installed on system. Set includepath and objects
#correctly. If omc not is installed on the system. Comment out
#theese three lines below.
DEFINES += OMC
COIN_INCLUDE = $$system(coin-config --includedir)
SOQT_INCLUDE = $$system(soqt-config --includedir)
INCLUDEPATH += $${CORBAINC} \
$${COIN_INCLUDE} \
$${SOQT_INCLUDE} \
/usr/include/qt4/ \
${ANTLRHOME}/include \
../NotebookParser \
../Pltpkg2 \
../3Dpkg
DEFINES += OMC $${HAVE_COIN} $${USE_CORBA}

unix:LIBS +=
QT += network xml core gui opengl

# Input
Expand Down
6 changes: 4 additions & 2 deletions OMNotebook/OMNotebookQT4/cellapplication.cpp
Expand Up @@ -92,8 +92,10 @@ namespace IAEX
: QObject()
{
app_ = new QApplication(argc, argv);
#ifndef __APPLE_CC__
mainWindow = SoQt::init(argc, argv, argv[0]);
#ifdef HAVE_COIN
mainWindow = SoQt::init(argc, argv, argv[0]);
#else
mainWindow = new QMainWindow();
#endif
QDir dir;

Expand Down
1 change: 1 addition & 0 deletions OMNotebook/OMNotebookQT4/celldocument.cpp
Expand Up @@ -133,6 +133,7 @@ namespace IAEX
{
filename_ = filename;
//Initialize SoQT

mainFrame_ = new QFrame(a->getMainWindow());

mainFrame_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,
Expand Down
2 changes: 1 addition & 1 deletion OMNotebook/Pltpkg2/compoundWidget.cpp
Expand Up @@ -73,7 +73,7 @@ CompoundWidget::CompoundWidget(QWidget* parent): QWidget(parent)
gwMain->compoundwidget = this;

//Initialize SoQT
//#ifndef __APPLE_CC__
//#ifdef HAVE_COIN
// SoQt::init(this);
//#endif
visWidget = new IAEX::VisualizationWidget(this);
Expand Down
5 changes: 5 additions & 0 deletions OMNotebook/ext/OMPlotWindow.config.in
@@ -0,0 +1,5 @@
HAVE_COIN = @HAVE_COIN@
COIN_LIBS = @COIN_LIBS@
SOQT_LIBS = @SOQT_LIBS@
COIN_INCLUDE = @COIN_INCLUDE@
SOQT_INCLUDE = @SOQT_INCLUDE@
14 changes: 9 additions & 5 deletions OMNotebook/ext/OMPlotWindow.pro
Expand Up @@ -8,12 +8,16 @@ DEPENDPATH += .
INCLUDEPATH += . \
../Pltpkg2

COIN_LIBS = $$system(coin-config --ldflags --libs)
SOQT_LIBS = $$system(soqt-config --ldflags --libs)
unix:LIBS += $${MICO_LIBS} $${COIN_LIBS} $${SOQT_LIBS}
win32 {
COIN_LIBS = $$system(coin-config --ldflags --libs)
SOQT_LIBS = $$system(soqt-config --ldflags --libs)
COIN_INCLUDE = $$system(coin-config --includedir)
SOQT_INCLUDE = $$system(soqt-config --includedir)
} else {
include(OMPlotWindow.config)
}

COIN_INCLUDE = $$system(coin-config --includedir)
SOQT_INCLUDE = $$system(soqt-config --includedir)
LIBS += $${COIN_LIBS} $${SOQT_LIBS}
INCLUDEPATH += $${COIN_INCLUDE} $${SOQT_INCLUDE}

QT += network xml
Expand Down

0 comments on commit 8b221f1

Please sign in to comment.