- added Robbins-Monro (but doesn't work well)
- added DrawListener - added realtime reconstruct - additional LayerArray constructor git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@20 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -30,6 +30,7 @@ void mylog(const char* format, ...);
|
||||
|
||||
//==============================================================================
|
||||
DrawComponent::DrawComponent (int width, int height)
|
||||
: m_pListener(nullptr)
|
||||
{
|
||||
|
||||
//[UserPreSize]
|
||||
@@ -130,8 +131,10 @@ void DrawComponent::mouseDown (const MouseEvent& e)
|
||||
}
|
||||
else
|
||||
{
|
||||
drawAt(e.x, e.y);
|
||||
drawAt(e.x, e.y, true);
|
||||
}
|
||||
if (m_pListener)
|
||||
m_pListener->onDraw(*this);
|
||||
//[/UserCode_mouseDown]
|
||||
}
|
||||
|
||||
@@ -141,7 +144,9 @@ void DrawComponent::mouseDrag (const MouseEvent& e)
|
||||
// mylog("%s x:%d, y:%d\n", __func__, e.x, e.y);
|
||||
if (e.mods.isLeftButtonDown())
|
||||
{
|
||||
drawAt(e.x, e.y);
|
||||
drawAt(e.x, e.y, false);
|
||||
if (m_pListener)
|
||||
m_pListener->onDraw(*this);
|
||||
}
|
||||
//[/UserCode_mouseDrag]
|
||||
}
|
||||
@@ -170,7 +175,12 @@ void DrawComponent::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails
|
||||
|
||||
|
||||
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
|
||||
void DrawComponent::drawAt(int x, int y)
|
||||
void DrawComponent::setListener(DrawListener *pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
}
|
||||
|
||||
void DrawComponent::drawAt(int x, int y, bool setColor)
|
||||
{
|
||||
int index;
|
||||
double fx = (double)x / m_scaleX;
|
||||
@@ -180,12 +190,29 @@ void DrawComponent::drawAt(int x, int y)
|
||||
// mylog("Write(%d)\n", index);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
if (index < m_width*m_height)
|
||||
m_pData[index] = 1.0;
|
||||
{
|
||||
if (setColor)
|
||||
{
|
||||
if (m_pData[index] > 0.0)
|
||||
{
|
||||
m_currData = 0.0;
|
||||
m_currColor = (Colours::black);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currData = 1.0;
|
||||
m_currColor = (Colours::white);
|
||||
}
|
||||
}
|
||||
m_pData[index] = m_currData;
|
||||
m_pG->setColour (m_currColor);
|
||||
}
|
||||
}
|
||||
|
||||
x = (int)fx * m_scaleX;
|
||||
y = (int)fy * m_scaleY;
|
||||
m_pG->setColour (Colours::white);
|
||||
m_pG->fillRect((float)x, (float)y, m_scaleX, m_scaleY);
|
||||
repaint();
|
||||
}
|
||||
@@ -239,8 +266,9 @@ BEGIN_JUCER_METADATA
|
||||
|
||||
<JUCER_COMPONENT documentType="Component" className="DrawComponent" componentName=""
|
||||
parentClasses="public Component" constructorParams="int width, int height"
|
||||
variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1"
|
||||
overlayOpacity="0.330" fixedSize="0" initialWidth="80" initialHeight="80">
|
||||
variableInitialisers="m_pListener(nullptr)" snapPixels="8" snapActive="1"
|
||||
snapShown="1" overlayOpacity="0.330" fixedSize="0" initialWidth="80"
|
||||
initialHeight="80">
|
||||
<METHODS>
|
||||
<METHOD name="mouseUp (const MouseEvent& e)"/>
|
||||
<METHOD name="mouseMove (const MouseEvent& e)"/>
|
||||
|
||||
Reference in New Issue
Block a user