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)
51 double act = net->getNeuron(n);
52 double min = net->neuronrange[n][0];
53 double max = net->neuronrange[n][1];
56 return (
int)ceil(act);
59 void HolisticViewer::updateGrid()
61 int neuronsPerRow = ceil(sqrt((
double)net->getNoNeurons()));
64 if(labels.size() == 0)
69 for(
int r=0; r<neuronsPerRow; r++)
71 for(
int c=0; c<neuronsPerRow; c++)
73 int index = r*neuronsPerRow+c;
75 if(index < net->getNoNeurons())
77 name = net->neuronl[index];
80 neuronX->addItem(name);
81 neuronY->addItem(name);
85 if(index < net->getNoInputs())
87 if(index > net->getNoInputs()+net->getNoHiddens())
90 labels.append(
new QLabel(
this) );
91 labels[index]->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
92 labels[index]->setFont(font);
93 labels[index]->setText(
"<font color='"+ color +
"';>" + name +
"</font>");
95 grid->addWidget(labels[index], r, c);
102 for(
int r=0; r<neuronsPerRow; r++)
104 for(
int c=0; c<neuronsPerRow; c++)
106 int index = r*neuronsPerRow+c;
107 if(index < net->getNoNeurons())
109 labels[index]->setAutoFillBackground(
true);
110 int act256 = getNeuronAct(index);
111 labels[index]->setPalette(QPalette(QColor(act256,act256,act256, 255)));
113 int fontSize = (int)(width()+height())/70;
116 QFont font = labels[index]->font();
117 font.setPointSize(fontSize);
118 labels[index]->setFont(font);
124 void HolisticViewer::updatePlot()
131 void HolisticViewer::paintEvent(QPaintEvent* )
133 QPainter painter(
this);
135 QPen blackPen(Qt::black);
136 QPen bluePen(Qt::blue);
137 QPen greenPen(Qt::green);
138 QPen redPen(Qt::red);
140 painter.drawRect(0,0,100,100);
142 painter.fillRect(0,0,width(),height(),Qt::white);
143 painter.setPen(blackPen);
144 painter.setRenderHint(QPainter::Antialiasing,
false);