Init version
This commit is contained in:
119
DEC_GUI/Kolch_Shind/paintqwidget.cpp
Normal file
119
DEC_GUI/Kolch_Shind/paintqwidget.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#include "paintqwidget.h"
|
||||
#include "constants.h"
|
||||
|
||||
static const int DEFAULT_IMAGE_HEIGHT = 550;
|
||||
static const int DEFAULT_IMAGE_WIDTH = 800;
|
||||
static const int AXIS_DASH_STEP = 50;
|
||||
static const int INDENT_STEP = 50;
|
||||
static const int TOP_OFFSET = 100;
|
||||
|
||||
PaintQWidget::PaintQWidget(QWidget *parent) :
|
||||
QWidget(parent), image(DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, QImage::Format_RGB888)
|
||||
{
|
||||
|
||||
connect(&solver, SIGNAL(sendHistory(QVector<dataSet>, int)), SLOT(setHistory(QVector<dataSet>, int)));
|
||||
connect(&solver, SIGNAL(sendItersForProgressBar(int)), SLOT(setItersForProgressBar(int)));
|
||||
image.fill(QColor(Qt::white).rgb());
|
||||
|
||||
}
|
||||
|
||||
void PaintQWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.drawImage(0, 0, image);
|
||||
}
|
||||
|
||||
|
||||
void PaintQWidget::setHistory(QVector<dataSet> history, int iters)
|
||||
{
|
||||
hist = history;
|
||||
maxIters = iters;
|
||||
}
|
||||
|
||||
void PaintQWidget::setItersForProgressBar(int iters)
|
||||
{
|
||||
resentItersToProgressBar(iters); //cause I can't send it direct from the solver =(
|
||||
//std::cout << iters << std::endl;
|
||||
}
|
||||
|
||||
void PaintQWidget::drawSelectedModel(int wgt_type, QCustomPlot *pPlot, int model_num)
|
||||
{
|
||||
//std::cout << model_num << std::endl;
|
||||
if (model_num != -1)
|
||||
{
|
||||
draw(pPlot, wgt_type, model_num);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//draw graphics
|
||||
void PaintQWidget::draw(QCustomPlot *customPlot, int wgt_type, int model_num)
|
||||
{
|
||||
//std::cout << model_num << std::endl;
|
||||
if (wgt_type == WIDGET_XT)
|
||||
{
|
||||
customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||
customPlot->graph(0)->setData(hist[model_num].xRange, hist[model_num].withFeedbackVect);
|
||||
customPlot->graph(0)->setPen(QPen(Qt::blue));
|
||||
customPlot->graph(0)->setName("withFeedback");
|
||||
customPlot->graph(1)->setData(hist[model_num].xRange, hist[model_num].withoutFeedbackVect);
|
||||
customPlot->graph(1)->setPen(QPen(Qt::red));
|
||||
customPlot->graph(1)->setName("withoutFeedback");
|
||||
customPlot->xAxis->setRange(0, maxIters);
|
||||
//std::cout << maxIters << std::endl;
|
||||
customPlot->xAxis->setLabel("Iterations");
|
||||
customPlot->yAxis->setLabel("Feedbacks");
|
||||
customPlot->yAxis->setRange(0, qMax(hist[model_num].maxWithFeedVal, hist[model_num].maxWithoutFeedVal) + TOP_OFFSET);
|
||||
}
|
||||
else if (wgt_type == WIDGET_XY)
|
||||
{
|
||||
customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||
customPlot->graph(0)->setName("eMeans");
|
||||
customPlot->graph(0)->setData(hist[model_num].xRange, hist[model_num].meanE);
|
||||
customPlot->graph(0)->setPen(QPen(Qt::red));
|
||||
|
||||
customPlot->graph(1)->setName("fMeans");
|
||||
customPlot->graph(1)->setData(hist[model_num].xRange, hist[model_num].meanF);
|
||||
customPlot->graph(1)->setPen(QPen(Qt::blue));
|
||||
|
||||
customPlot->graph(2)->setName("c2Means");
|
||||
customPlot->graph(2)->setData(hist[model_num].xRange, hist[model_num].meanC2);
|
||||
customPlot->graph(2)->setPen(QPen(Qt::green));
|
||||
|
||||
customPlot->graph(3)->setName("individ");
|
||||
customPlot->graph(3)->setData(hist[model_num].xRange, hist[model_num].individ);
|
||||
customPlot->graph(3)->setPen(QPen(Qt::magenta));
|
||||
|
||||
customPlot->graph(4)->setName("individFeedback");
|
||||
customPlot->graph(4)->setData(hist[model_num].xRange, hist[model_num].individFeedback);
|
||||
customPlot->graph(4)->setPen(QPen(Qt::black));
|
||||
|
||||
customPlot->xAxis->setRange(0, maxIters);
|
||||
//std::cout << maxIters << std::endl;
|
||||
customPlot->xAxis->setLabel("Iterations");
|
||||
customPlot->yAxis->setLabel("Means");
|
||||
customPlot->yAxis->setRange(0, 300);
|
||||
}
|
||||
customPlot->replot();
|
||||
}
|
||||
|
||||
void PaintQWidget::setIters(int flag, int iter)
|
||||
{
|
||||
itersFlag = flag;
|
||||
newIters = iter;
|
||||
}
|
||||
|
||||
void PaintQWidget::drawAll(float c1, float c2, float c3, float c4, float c5, float sigC1, float sigC2, float sigC3, float sigC4, float sigC5,
|
||||
float e, float sigE, float sigX0, float delX0, float sigX, float Xopt, int popSize, int maxSteps, int N,
|
||||
int wgt_type, QCustomPlot* pPlot, int count, int modelCount, int model_num)
|
||||
{
|
||||
|
||||
if (count == 0) // cause solveModel launch two times other way
|
||||
{
|
||||
solver.solveModel(c1, c2, c3, c4, c5, sigC1, sigC2, sigC3, sigC4, sigC5, e, sigE, sigX0, delX0, sigX, Xopt, popSize, maxSteps, N, itersFlag, newIters, modelCount);
|
||||
}
|
||||
|
||||
draw(pPlot, wgt_type, model_num);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user