24 #include "holisticviewer.h"
28 HolisticViewer::HolisticViewer(Evonet* network, QWidget* parent, Qt::WindowFlags flags)
29 : QWidget(parent, flags),
33 mainLayout =
new QVBoxLayout(
this);
35 grid =
new QGridLayout();
37 mainLayout->addLayout(grid);
39 neuronChoice =
new QHBoxLayout();
40 neuronX =
new QComboBox(
this);
41 neuronY =
new QComboBox(
this);
42 neuronChoice->addWidget(neuronX);
43 neuronChoice->addWidget(neuronY);
44 mainLayout->addLayout(neuronChoice);
49 int HolisticViewer::getNeuronAct(
int n)
58 int intAct = (int)ceil(act);
59 intAct = (intAct < 0) ? 0 : ((intAct > 255) ? 255 : intAct);
63 void HolisticViewer::updateGrid()
65 int neuronsPerRow = ceil(sqrt((
double)net->
getNoNeurons()));
68 if(labels.size() == 0)
73 for(
int r=0; r<neuronsPerRow; r++)
75 for(
int c=0; c<neuronsPerRow; c++)
77 int index = r*neuronsPerRow+c;
79 if(index < net->getNoNeurons())
81 name = net->neuronl[index];
84 neuronX->addItem(name);
85 neuronY->addItem(name);
89 if(index < net->getNoInputs())
94 labels.append(
new QLabel(
this) );
95 labels[index]->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
96 labels[index]->setFont(font);
97 labels[index]->setText(
"<font color='"+ color +
"';>" + name +
"</font>");
99 grid->addWidget(labels[index], r, c);
106 for(
int r=0; r<neuronsPerRow; r++)
108 for(
int c=0; c<neuronsPerRow; c++)
110 int index = r*neuronsPerRow+c;
111 if(index < net->getNoNeurons())
113 labels[index]->setAutoFillBackground(
true);
114 int act256 = getNeuronAct(index);
115 labels[index]->setPalette(QPalette(QColor(act256,act256,act256, 255)));
117 int fontSize = (int)(width()+height())/70;
120 QFont font = labels[index]->font();
121 font.setPointSize(fontSize);
122 labels[index]->setFont(font);
128 void HolisticViewer::updatePlot()
135 void HolisticViewer::paintEvent(QPaintEvent* )
137 QPainter painter(
this);
139 QPen blackPen(Qt::black);
140 QPen bluePen(Qt::blue);
141 QPen greenPen(Qt::green);
142 QPen redPen(Qt::red);
144 painter.drawRect(0,0,100,100);
146 painter.fillRect(0,0,width(),height(),Qt::white);
147 painter.setPen(blackPen);
148 painter.setRenderHint(QPainter::Antialiasing,
false);
151 void HolisticViewer::setNet(Evonet* n)
FARSA_UTIL_TEMPLATE float linearMap(float x, float min=-10, float max=10, float outMin=-1, float outMax=1)
int getNoInputs()
return the number of sensory neurons
int getNoNeurons()
return the total number of neurons
FARSA_UTIL_TEMPLATE const T max(const T &t1, const U &t2)
float getNeuron(int in)
return the activation of a neuron
int getNoHiddens()
return the number of internal neurons
FARSA_UTIL_TEMPLATE const T min(const T &t1, const U &t2)
double neuronrange[MAXN][2]
the matrix that contain the variation range of neurons used by the neuron monitor graphic widget ...