Skip to content

Commit

Permalink
Moved the contents of PendulumWindowWindow::customizeZincContext() in…
Browse files Browse the repository at this point in the history
…to PendulumWindowWindow::initData().
  • Loading branch information
agarny committed Jun 27, 2017
1 parent aa51d6a commit 072fd0c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 60 deletions.
107 changes: 49 additions & 58 deletions src/plugins/simulation/PendulumWindow/src/pendulumwindowwindow.cpp
Expand Up @@ -170,64 +170,6 @@ void PendulumWindowWindow::initData(const int &pDataSize,
mQ1Values = pQ1Values;
mThetaValues = pThetaValues;

// Customise our Zinc context

customizeZincContext();
}

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

void PendulumWindowWindow::addData(const int &pCurrentDataSize)
{
// Make sure that we have a valid field module

if (!mFieldModule.isValid())
return;

// Assign the time-varying parameters for mR0, mQ1 and mTheta

mFieldModule.beginChange();
for (int i = mCurrentDataSize; i < pCurrentDataSize; ++i) {
mFieldCache.setTime(mTimeValues[i]);

mR0.assignReal(mFieldCache, 1, mR0Values+i);
mQ1.assignReal(mFieldCache, 1, mQ1Values+i);
mTheta.assignReal(mFieldCache, 1, mThetaValues+i);
}
mFieldModule.endChange();

mCurrentDataSize = pCurrentDataSize;

// Enable/disable our time-related widgets

mTimeCheckBox->setEnabled(pCurrentDataSize);
mTimeSlider->setEnabled(pCurrentDataSize);

mTimeSlider->setValue(pCurrentDataSize);
}

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

void PendulumWindowWindow::createAndSetZincContext()
{
// Keep track of our current scene viewer's description

mZincSceneViewerDescription = mZincWidget->sceneViewer().writeDescription();

// Create and set our Zinc context

mZincContext = new OpenCMISS::Zinc::Context("PendulumWindowWindow");

mZincContext->getMaterialmodule().defineStandardMaterials();
mZincContext->getGlyphmodule().defineStandardGlyphs();

mZincWidget->setContext(mZincContext);
}

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

void PendulumWindowWindow::customizeZincContext()
{
// 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 @@ -456,6 +398,55 @@ void PendulumWindowWindow::customizeZincContext()

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

void PendulumWindowWindow::addData(const int &pCurrentDataSize)
{
// Make sure that we have a valid field module

if (!mFieldModule.isValid())
return;

// Assign the time-varying parameters for mR0, mQ1 and mTheta

mFieldModule.beginChange();
for (int i = mCurrentDataSize; i < pCurrentDataSize; ++i) {
mFieldCache.setTime(mTimeValues[i]);

mR0.assignReal(mFieldCache, 1, mR0Values+i);
mQ1.assignReal(mFieldCache, 1, mQ1Values+i);
mTheta.assignReal(mFieldCache, 1, mThetaValues+i);
}
mFieldModule.endChange();

mCurrentDataSize = pCurrentDataSize;

// Enable/disable our time-related widgets

mTimeCheckBox->setEnabled(pCurrentDataSize);
mTimeSlider->setEnabled(pCurrentDataSize);

mTimeSlider->setValue(pCurrentDataSize);
}

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

void PendulumWindowWindow::createAndSetZincContext()
{
// Keep track of our current scene viewer's description

mZincSceneViewerDescription = mZincWidget->sceneViewer().writeDescription();

// Create and set our Zinc context

mZincContext = new OpenCMISS::Zinc::Context("PendulumWindowWindow");

mZincContext->getMaterialmodule().defineStandardMaterials();
mZincContext->getGlyphmodule().defineStandardGlyphs();

mZincWidget->setContext(mZincContext);
}

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

void PendulumWindowWindow::graphicsInitialized()
{
// Set our 'new' scene viewer's description
Expand Down
Expand Up @@ -118,8 +118,6 @@ class PendulumWindowWindow : public Core::WindowWidget
double *mQ1Values;
double *mThetaValues;

void customizeZincContext();

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

0 comments on commit 072fd0c

Please sign in to comment.