Пример #1
0
MCentral::MCentral(){
	//
	#ifdef MYDEBUG
		qDebug() << "Startuje MCentral::MCentral()";
	#endif
	//
	ioActions = new IOActions();
	combo = new QComboBox; //
	combo-> setEnabled(false);
	textEdit = new QTextEdit(tr("Tu wyswietlaja sie rezultaty"));
	mainTextEdit = new QTextEdit(tr("Tu wyswietla sie graf"));
	refreshButton = new QPushButton(tr("Wyczysc rezultaty"));
	refreshButton->setEnabled(false);
	saveButton = new QPushButton(tr("Zapisz zmiany"));
	saveButton->setEnabled(false);
	restoreButton = new QPushButton(tr("Anuluj zmiany"));
	restoreButton->setEnabled(false);
	//
	connect(refreshButton, SIGNAL(clicked()), this, SLOT(repaintGraph())); //Obs³uga przycisku odœwie¿
	connect(combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(repaintGraph(QString))); //Obs³uga comboboxa
	connect(combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(disableSaveRestore())); //
	connect(mainTextEdit, SIGNAL(textChanged()), ioActions,  SLOT(modify()));
	connect(mainTextEdit, SIGNAL(textChanged()), this,  SLOT(enableSaveRestore()));
	connect(saveButton, SIGNAL(clicked()), this, SLOT(saveClicked()));
	connect(saveButton, SIGNAL(clicked()), this, SLOT(disableSaveRestore()));
	connect(restoreButton, SIGNAL(clicked()), this, SLOT(restoreClicked()));
	connect(restoreButton, SIGNAL(clicked()), this, SLOT(disableSaveRestore()));
	//
	horizontalGroupBox = new QGroupBox(tr("Opcje edycji:"));
	QHBoxLayout *horizontalLayout = new QHBoxLayout;
    horizontalLayout->addWidget(saveButton);
    horizontalLayout->addWidget(restoreButton);
	horizontalLayout->addWidget(refreshButton);
    horizontalGroupBox->setLayout(horizontalLayout);
	//
	layout = new QVBoxLayout; 
	layout->addWidget(combo);
	layout->addWidget(mainTextEdit);
	layout->addWidget(horizontalGroupBox);
	layout->addWidget(textEdit);
	//layout->addStretch(); //to nie daje ¿adnych zmian
	setLayout(layout); 
	//
	#ifdef MYDEBUG
		qDebug() << "Konczy sie MCentral::MCentral()";
	#endif
}
Пример #2
0
void Dialog::mkGraph()
{
	QCPGraph * gr;
	QPen pn;

	QVector<double> timeLabels, tempLabels, drosselLabels;
	for (int x=0; x<mdl.simTime; x+=10) timeLabels.push_back(x);
	for (int x=0; x<=80; x+=5) tempLabels.push_back(x);
	for (int x=0; x<=120; x+=10) drosselLabels.push_back(x);

	gr = ui->plot->addGraph();
	gr->setData(mdl.xTime, mdl.yTempOutput);
	pn.setColor(Qt::red);
	pn.setWidth(3);
	gr->setPen(pn);
	gr->setName("Реальное значение, °C");

	gr = ui->plot->addGraph();
	gr->setData(mdl.xTime, mdl.yTempSet);
	pn.setColor(0x0000FF);
	pn.setWidth(2);
	pn.setStyle(Qt::DotLine);
	gr->setPen(pn);
	gr->setName("Конечное значение, °C");

	gr = ui->plot->addGraph();
	gr->setData(mdl.xTime, mdl.yTempCurrent);
	pn.setColor(0x808000);
	pn.setWidth(2);
	pn.setStyle(Qt::SolidLine);
	gr->setPen(pn);
	gr->setName("Желаемая температура, °C");

	gr = ui->plot->addGraph(0, ui->plot->yAxis2);
	gr->setData(mdl.xTime, mdl.yServoPos);
	pn.setColor(0x006600);
	pn.setWidth(2);
	pn.setStyle(Qt::DotLine);
	gr->setPen(pn);
	gr->setName("Дроссель, %");

	gr = ui->plot->addGraph(0, ui->plot->yAxis2);
	gr->setData(mdl.xTime, mdl.yPressure);
	pn.setColor(0x800080);
	pn.setWidth(2);
	pn.setStyle(Qt::SolidLine);
	gr->setPen(pn);
	gr->setName("Сила нагрева, %");

	ui->plot->xAxis->setLabel("Время, сек");
	ui->plot->xAxis->setRange(0, mdl.simTime);
	ui->plot->xAxis->setAutoTicks(false);
	ui->plot->xAxis->setTickVector(timeLabels);
	//ui->plot->xAxis->setAutoTickCount(15);
	ui->plot->xAxis->setSubTickCount(10);

	ui->plot->yAxis->setLabel("Температура, °C");
	ui->plot->yAxis->setRange(20, 80);
	ui->plot->yAxis->setAutoTicks(false);
	ui->plot->yAxis->setTickVector(tempLabels);
	ui->plot->yAxis->setSubTickCount(5);

	ui->plot->yAxis2->setLabel("Параметры, %");
	ui->plot->yAxis2->setRange(0, 150);
	ui->plot->yAxis2->setVisible(true);
	ui->plot->yAxis2->setAutoTicks(false);
	ui->plot->yAxis2->setTickVector(drosselLabels);

	ui->plot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignLeft|Qt::AlignTop);
	ui->plot->legend->setVisible(true);

	mdl.reset();
	mdl.tempCurrent = 40;
	mdl.pressureCoef = 1.0;
	repaintGraph("ideal");
/*
	mdl.reset();
	mdl.simTime = 180;
	mdl.tempCurrent = 35;
	mdl.pressureCoef = 1.2;
	mdl.paramsChanged.push_back(ParamChange(20.0, 0, 40));
	repaintGraph("hotrun");

	mdl.reset();
	mdl.tempCurrent = 35;
	mdl.pressureCoef = 1.2;
	mdl.paramsChanged.push_back(ParamChange(20.0, 0, 30));
	repaintGraph("hotrun-low");
// return;

	mdl.reset();
	mdl.tempCurrent = 45;
	mdl.pressureCoef = 0.5;
	mdl.paramsChanged.push_back(ParamChange(20.0, 0, 40));
	mdl.paramsChanged.push_back(ParamChange(30.0, 1.2, 0));
	repaintGraph("plow-hi");

	mdl.reset();
	mdl.tempCurrent = 45;
	mdl.pressureCoef = 0.5;
	mdl.paramsChanged.push_back(ParamChange(30.0, 0.8, 0));
	repaintGraph("plow");

	mdl.reset();
	mdl.tempOutput = 40;
	mdl.tempCurrent = 30;
	mdl.paramsChanged.push_back(ParamChange(50.0, 0.8, 0));
	repaintGraph("hotstart");

	mdl.reset();
	mdl.simTime = 180;
	mdl.tempCurrent = 30;
	mdl.paramsChanged.push_back(ParamChange(20.0, 0.8, 0));
	mdl.paramsChanged.push_back(ParamChange(40.0, 0, 40));
	mdl.paramsChanged.push_back(ParamChange(50.0, 0.9, 0));
	mdl.paramsChanged.push_back(ParamChange(90.0, 1.1, 0));
	mdl.paramsChanged.push_back(ParamChange(130.0, 1.0, 0));
	repaintGraph("longrun");

	// ui->plot->savePdf("graph-test.pdf", false, 800, 600);

	// qDebug() << QImageWriter::supportedImageFormats();
	*/
}