Skip to content

Commit

Permalink
VectorGraph_deleted_VectorGraphDataArray_effectors_cleared2
Browse files Browse the repository at this point in the history
  • Loading branch information
szeli1 committed Mar 31, 2024
1 parent e4c59d7 commit 02505d0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/VectorGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class LMMS_EXPORT VectorGraphDataArray
void setAutomatedColor(QColor colorIn);
// returns true if successful

bool setEffectorArrayLocation(int locationIn);
bool setEffectorArrayLocation(int locationIn, bool callDataChangedIn);

bool getIsFixedSize();
bool getIsFixedValue();
Expand Down
5 changes: 4 additions & 1 deletion plugins/FFTFilter/FFTFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ bool FFTFilterEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)
graphInput[i] = graphInput[i] / static_cast<float>(avgCount);
}
// DEBUG
/*
for (unsigned int i = 0; i < FFTSpectrumOutput.size(); i++)
{
qDebug("FFTFilterEffect: [%d], %f", i, FFTSpectrumOutput[i]);
}
*/
//m_filterControls.setGraph(&graphInput);
}
//std::vector<float>* output;
Expand All @@ -131,9 +133,10 @@ bool FFTFilterEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)
//}
//std::vector<float> testVector = {0.0f, 0.3f, 0.5f, -0.5f, 0.2f};
//std::vector<float> testVector = {0.0f, 1.3f, 0.5f, -2.5f, 0.2f};
std::vector<float> testVector = {0.0f, 0.1f, 0.5f, 0.7f, 0.5f, 0.2f, 0.1f, -1.0f, -0.1f, -0.1f, 0.2f};


//m_filterControls.setGraph(&testVector);
m_filterControls.setGraph(&testVector);

/*
const ValueBuffer* volumeBuf = m_filterControls.m_volumeModel.valueBuffer();
Expand Down
3 changes: 2 additions & 1 deletion plugins/FFTFilter/FFTFilterControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ FFTFilterControls::FFTFilterControls(FFTFilterEffect* effect) :
m_graphModel.getDataArray(arrayLocationB)->setAutomatedColor(QColor(10, 50, 255, 255));

// effectors:
m_graphModel.getDataArray(arrayLocation)->setEffectorArrayLocation(arrayLocationB);
// true -> m_graphModel will call update() -> paintEvent()
m_graphModel.getDataArray(arrayLocation)->setEffectorArrayLocation(arrayLocationB, true);
}


Expand Down
39 changes: 32 additions & 7 deletions src/gui/widgets/VectorGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,15 +1427,34 @@ unsigned int VectorGraphModel::addArray()
void VectorGraphModel::delArray(unsigned int locationIn)
{
// TODO test
std::vector<int> effectorArrayLocations(m_dataArrays.size());
for (unsigned int i = locationIn; i < m_dataArrays.size() - 1; i++)
{
if (m_dataArrays[i].getEffectorArrayLocation() == locationIn)
{
m_dataArrays[i].setEffectorArrayLocation(-1);
m_dataArrays[i].setEffectorArrayLocation(-1, false);
}
m_dataArrays[i] = m_dataArrays[i + 1];
}
m_dataArrays.pop_back();
// reset effector locations to the correct locations
for (unsigned int i = 0; i < m_dataArrays.size(); i++)
{
effectorArrayLocations[i] = m_dataArrays[i].getEffectorArrayLocation();
if (effectorArrayLocations[i] >= locationIn)
{
effectorArrayLocations[i]--;
}
// effectorLocations are cleared to avoid the
// dataArrays detecting loops and then not setting
m_dataArrays[i].setEffectorArrayLocation(-1, false);
}
// setting updated locations
for (unsigned int i = 0; i < m_dataArrays.size(); i++)
{
m_dataArrays[i].setEffectorArrayLocation(effectorArrayLocations[i], false);
}
emit dataChanged();
}

void VectorGraphModel::dataArrayChanged()
Expand Down Expand Up @@ -1572,7 +1591,7 @@ void VectorGraphDataArray::updateConnections(VectorGraphModel* parentIn)
m_parent = parentIn;
m_id = m_parent->getDataArrayNewId();
// reseting effectors
setEffectorArrayLocation(-1);
setEffectorArrayLocation(-1, true);
}

void VectorGraphDataArray::setIsFixedSize(bool valueIn)
Expand Down Expand Up @@ -1617,11 +1636,11 @@ void VectorGraphDataArray::setIsAutomatableEffectable(bool valueIn)
m_isAutomatableEffectable = valueIn;
if (valueIn == false)
{
setEffectorArrayLocation(-1);
// setEffectorArray will call dataChanged()
setEffectorArrayLocation(-1, true);
}
else
{
// setEffectorArray will call dataChanged()
getUpdatingFromPoint(-1);
dataChanged();
}
Expand Down Expand Up @@ -1656,7 +1675,7 @@ void VectorGraphDataArray::setAutomatedColor(QColor colorIn)
m_automatedColor = colorIn;
styleChanged();
}
bool VectorGraphDataArray::setEffectorArrayLocation(int locationIn)
bool VectorGraphDataArray::setEffectorArrayLocation(int locationIn, bool callDataChangedIn)
{
qDebug("setEffectorArrayLocation start");
bool found = true;
Expand Down Expand Up @@ -1687,7 +1706,10 @@ bool VectorGraphDataArray::setEffectorArrayLocation(int locationIn)
{
m_effectorLocation = locationIn;
getUpdatingFromPoint(-1);
dataChanged();
if (callDataChangedIn == true)
{
dataChanged();
}
}
}
else
Expand All @@ -1696,7 +1718,10 @@ bool VectorGraphDataArray::setEffectorArrayLocation(int locationIn)
{
m_effectorLocation = -1;
getUpdatingFromPoint(-1);
dataChanged();
if (callDataChangedIn == true)
{
dataChanged();
}
}
}
return !found;
Expand Down

0 comments on commit 02505d0

Please sign in to comment.