Skip to content

Commit

Permalink
Make it possible to set some model parameters to our pendulum window.
Browse files Browse the repository at this point in the history
Just calls and storage, no actual use of those parameters in our
pendulum window at this stage.
  • Loading branch information
agarny committed Jun 26, 2017
1 parent 148c2c4 commit a4fee8a
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 24 deletions.
7 changes: 0 additions & 7 deletions src/plugins/simulation/PendulumWindow/src/data.inc

This file was deleted.

84 changes: 67 additions & 17 deletions src/plugins/simulation/PendulumWindow/src/pendulumwindowwindow.cpp
Expand Up @@ -60,7 +60,12 @@ PendulumWindowWindow::PendulumWindowWindow(QWidget *pParent) :
mGui(new Ui::PendulumWindowWindow),
mZincContext(0),
mZincSceneViewerDescription(0),
mAxesFontPointSize(0)
mAxesFontPointSize(0),
mDataSize(0),
mTimeValues(0),
mQ1Values(0),
mThetaValues(0),
mR0Value(0)
{
// Set up the GUI

Expand Down Expand Up @@ -94,6 +99,7 @@ PendulumWindowWindow::PendulumWindowWindow(QWidget *pParent) :

mTimeCheckBox = new QCheckBox(timeWidget);

mTimeCheckBox->setEnabled(false);
mTimeCheckBox->setText(tr("Auto"));

connect(mTimeCheckBox, SIGNAL(toggled(bool)),
Expand All @@ -107,6 +113,7 @@ PendulumWindowWindow::PendulumWindowWindow(QWidget *pParent) :

mTimeSlider = new QSlider(this);

mTimeSlider->setEnabled(false);
mTimeSlider->setOrientation(Qt::Horizontal);

connect(mTimeSlider, SIGNAL(valueChanged(int)),
Expand Down Expand Up @@ -148,6 +155,51 @@ void PendulumWindowWindow::retranslateUi()

//==============================================================================

void PendulumWindowWindow::setDataSize(const int &pDataSize)
{
// Set our data size

mDataSize = pDataSize;
}

//==============================================================================

void PendulumWindowWindow::setTimeValues(double *pTimeValues)
{
// Set our time values

mTimeValues = pTimeValues;
}

//==============================================================================

void PendulumWindowWindow::setQ1Values(double *pQ1Values)
{
// Set our q1 values

mQ1Values = pQ1Values;
}

//==============================================================================

void PendulumWindowWindow::setThetaValues(double *pThetaValues)
{
// Set our theta values

mThetaValues = pThetaValues;
}

//==============================================================================

void PendulumWindowWindow::setR0Value(const double &pR0Value)
{
// Set our r0 value

mR0Value = pR0Value;
}

//==============================================================================

void PendulumWindowWindow::createAndSetZincContext()
{
// Keep track of our current scene viewer's description
Expand All @@ -163,10 +215,6 @@ void PendulumWindowWindow::createAndSetZincContext()

mZincWidget->setContext(mZincContext);

// Some data

#include "data.inc"

// Get the field module of our default region and do a few things with it

OpenCMISS::Zinc::Region defaultRegion = mZincContext->getDefaultRegion();
Expand Down Expand Up @@ -210,7 +258,7 @@ void PendulumWindowWindow::createAndSetZincContext()
// Create a single node with storage for constant r0 and time-varying q1
// and theta

OpenCMISS::Zinc::Timesequence timeSequence = fieldModule.getMatchingTimesequence(DataSize, timeValues);
OpenCMISS::Zinc::Timesequence timeSequence = fieldModule.getMatchingTimesequence(mDataSize, mTimeValues);
OpenCMISS::Zinc::Nodeset nodeSet = fieldModule.findNodesetByFieldDomainType(OpenCMISS::Zinc::Field::DOMAIN_TYPE_NODES);
OpenCMISS::Zinc::Nodetemplate nodeTemplate = nodeSet.createNodetemplate();

Expand Down Expand Up @@ -273,7 +321,7 @@ void PendulumWindowWindow::createAndSetZincContext()

// First the constant value for r0 at the node

const double r0Data[] = { r0Value };
const double r0Data[] = { mR0Value };

r0.assignReal(fieldCache, 1, r0Data);

Expand All @@ -287,11 +335,11 @@ void PendulumWindowWindow::createAndSetZincContext()
double q1Data[1];
double thetaData[1];

for (int i = 0; i < DataSize; ++i) {
fieldCache.setTime(timeValues[i]);
for (int i = 0; i < mDataSize; ++i) {
fieldCache.setTime(mTimeValues[i]);

q1Data[0] = q1Values[i];
thetaData[0] = thetaValues[i];
q1Data[0] = mQ1Values[i];
thetaData[0] = mThetaValues[i];

q1.assignReal(fieldCache, 1, q1Data);
theta.assignReal(fieldCache, 1, thetaData);
Expand All @@ -306,7 +354,7 @@ void PendulumWindowWindow::createAndSetZincContext()
OpenCMISS::Zinc::Tessellationmodule tessellationModule = scene.getTessellationmodule();
OpenCMISS::Zinc::Tessellation tessellation = tessellationModule.createTessellation();

const int tessellationData[] = { DataSize };
const int tessellationData[] = { mDataSize };

tessellation.setMinimumDivisions(1, tessellationData);

Expand All @@ -322,13 +370,15 @@ void PendulumWindowWindow::createAndSetZincContext()

mTimeKeeper = timeKeeperModule.getDefaultTimekeeper();

mTimeKeeper.setMinimumTime(timeValues[0]);
mTimeKeeper.setMaximumTime(timeValues[DataSize-1]);
if (mDataSize) {
mTimeKeeper.setMinimumTime(mTimeValues[0]);
mTimeKeeper.setMaximumTime(mTimeValues[mDataSize-1]);

mTimeSlider->setMinimum(timeValues[0]);
mTimeSlider->setMaximum(100*timeValues[DataSize-1]);
mTimeSlider->setMinimum(mTimeValues[0]);
mTimeSlider->setMaximum(100*mTimeValues[mDataSize-1]);

updateScene(timeValues[0]);
updateScene(mTimeValues[0]);
}

// Now set up some graphics

Expand Down
16 changes: 16 additions & 0 deletions src/plugins/simulation/PendulumWindow/src/pendulumwindowwindow.h
Expand Up @@ -81,6 +81,14 @@ class PendulumWindowWindow : public Core::WindowWidget

virtual void retranslateUi();

void setDataSize(const int &pDataSize);

void setTimeValues(double *pTimeValues);
void setQ1Values(double *pQ1Values);
void setThetaValues(double *pThetaValues);

void setR0Value(const double &pR0Value);

private:
Ui::PendulumWindowWindow *mGui;

Expand All @@ -98,6 +106,14 @@ class PendulumWindowWindow : public Core::WindowWidget

int mAxesFontPointSize;

int mDataSize;

double *mTimeValues;
double *mQ1Values;
double *mThetaValues;

double mR0Value;

private slots:
void createAndSetZincContext();
void graphicsInitialized();
Expand Down

0 comments on commit a4fee8a

Please sign in to comment.