From b46c65c4924c94aad1eb2429dc08e956671a4ef2 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Wed, 16 Oct 2019 17:42:38 +0000 Subject: [PATCH] - improved DrawData() git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@552 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- Source/DrawComponent.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/DrawComponent.cpp b/Source/DrawComponent.cpp index 0c5b37f..442ca44 100644 --- a/Source/DrawComponent.cpp +++ b/Source/DrawComponent.cpp @@ -233,19 +233,19 @@ RowVectorXd& DrawComponent::getData () void DrawComponent::DrawData () { - RowVectorXd temp = m_data; - - for (int i=0; i < m_width*m_height; i++) + double max = m_data.array().abs().maxCoeff(); + + if (max < 1.0) { - temp[i] = std::min(1.0, (double)temp[i]); - temp[i] = std::max(-1.0, (double)temp[i]); + max = 1.0; } - + double scale = m_scale/max; + for (int i=0; i < m_height; i++) { for (int j=0; j < m_width; j++) { - m_pG->setColour(Colour(Colours::white).greyLevel(m_offset + m_scale*temp[i*m_width + j])); + m_pG->setColour(Colour(Colours::white).greyLevel(m_offset + scale*m_data[i*m_width + j])); m_pG->fillRect(m_scaleX*j, m_scaleY*i, m_scaleX, m_scaleY); } }