- add enable button for up down pass abort

git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@655 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-11-11 17:42:29 +00:00
parent 5bb8d7a442
commit 12f08b38bc
2 changed files with 49 additions and 11 deletions
+33 -8
View File
@@ -34,14 +34,18 @@ RbmComponent::RbmComponent (const std::string &name, size_t id, size_t numVisibl
addAndMakeVisible (DrawTraining = new DrawComponent (numVisibleX, numVisibleY));
DrawTraining->setListener(this);
addAndMakeVisible (DrawReconstruction = new DrawComponent (numVisibleX, numVisibleY));
addAndMakeVisible (DrawWeights = new DrawComponent (numVisibleX, numVisibleY, 0.5, 0.5));
addAndMakeVisible (DrawHidden = new DrawComponent (numHidden, 1));
DrawHidden->setListener(this);
addAndMakeVisible (DrawReconstruction = new DrawComponent (numVisibleX, numVisibleY));
addAndMakeVisible (DrawWeights = new DrawComponent (numVisibleX, numVisibleY, 0.5, 0.5));
addAndMakeVisible (m_toggleEnable = new ToggleButton ("Enable layer"));
m_toggleEnable->setTooltip (TRANS("Enable layer for up pass"));
m_toggleEnable->setButtonText (TRANS("Enable"));
m_toggleEnable->addListener (this);
redrawWeights();
// redrawReconstruction();
setSize (430, 130);
resized();
@@ -139,6 +143,7 @@ void RbmComponent::resized()
DrawReconstruction->setBoundsRelative(110./430, 0, 100./430, 100./130);
DrawWeights->setBoundsRelative (220./430, 0, 100./430, 100./130);
DrawHidden->setBoundsRelative (0, 110./130, 430./430, 20./130);
m_toggleEnable->setBoundsRelative (330./430, 0, 80./430, 24./130);
}
void RbmComponent::mouseMove (const MouseEvent& e)
@@ -203,6 +208,19 @@ void RbmComponent::onDraw(DrawComponent &obj)
}
}
void RbmComponent::buttonClicked(Button* buttonThatWasClicked)
{
if (buttonThatWasClicked == m_toggleEnable)
{
bool state = isEnabled();
if (next)
{
RbmComponent *pComp = static_cast<RbmComponent*> (next);
pComp->enable(state);
}
}
}
void RbmComponent::redrawReconstruction(const arma::mat& v)
{
uint32_t i;
@@ -228,9 +246,9 @@ void RbmComponent::upPass(const arma::mat& v)
if (next)
{
RbmComponent *pComp = static_cast<RbmComponent*> (next);
pComp->upPass(DrawHidden->getData());
pComp->upPass(DrawHidden->getData());
}
}
}
void RbmComponent::downPass(const arma::mat& h)
{
@@ -257,7 +275,14 @@ void RbmComponent::upDownPass(const arma::mat& v)
if (next)
{
RbmComponent *pComp = static_cast<RbmComponent*> (next);
pComp->upDownPass(DrawHidden->getData());
if (pComp->isEnabled())
{
pComp->upDownPass(DrawHidden->getData());
}
else
{
return;
}
}
else if (prev)
{
+16 -3
View File
@@ -34,9 +34,10 @@
Describe your class and how it works here!
//[/Comments]
*/
class RbmComponent : public Component
, public Layer
, public DrawListener
class RbmComponent : public Component
, public Layer
, public DrawListener
, public ButtonListener
{
public:
//==============================================================================
@@ -76,8 +77,20 @@ private:
//[UserVariables] -- You can add your own custom variables in this section.
ScopedPointer<DrawComponent> DrawReconstruction;
ScopedPointer<DrawComponent> DrawWeights;
ScopedPointer<ToggleButton> m_toggleEnable;
bool isEnabled()
{
return m_toggleEnable->getToggleState();
}
void enable(bool state)
{
m_toggleEnable->setToggleState(state, NotificationType::sendNotification);
}
size_t m_currWeightIndexToDraw;
void onDraw(DrawComponent &obj) override;
void buttonClicked(Button* buttonThatWasClicked) override;
//[/UserVariables]
//==============================================================================