1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-15 12:25:12 +03:00

printdialog - internal and external modules, skip not defined curves in printing

This commit is contained in:
Romolo Manfredini 2015-04-22 19:06:21 +02:00 committed by Romolo Manfredini
parent 6e0eec364c
commit 2fdde52fcd

View file

@ -85,8 +85,14 @@ void PrintDialog::printSetup()
str.append(fv(tr("EEprom Size"), QString("%1").arg(firmware->getEepromInterface()->getSize(*g_model))));
str.append(fv(tr("Timer1"), getTimerStr(g_model->timers[0]))); //value, mode, count up/down
str.append(fv(tr("Timer2"), getTimerStr(g_model->timers[1]))); //value, mode, count up/down
str.append(fv(tr("Protocol"), getProtocol(g_model))); //proto, numch, delay,
str.append(fv(tr("Pulse Polarity"), g_model->moduleData[0].polarityToString()));
if (firmware->getCapability(NumModules)>1) {
str.append("<b>"+tr("Internal module")+"</b><br>"); //proto, numch, delay,
}
str.append(fv(tr("Protocol"), getProtocol(g_model->moduleData[0]))); //proto, numch, delay,
if (firmware->getCapability(NumModules)>1) {
str.append("<b>"+tr("External module")+"</b><br>"); //proto, numch, delay,
str.append(fv(tr("Protocol"), getProtocol(g_model->moduleData[1]))); //proto, numch, delay,
}
str.append(fv(tr("Throttle Trim"), g_model->thrTrim ? tr("Enabled") : tr("Disabled")));
str.append(fv(tr("Trim Increment"), getTrimInc(g_model)));
str.append(fv(tr("Center Beep"), getCenterBeepStr(g_model))); // specify which channels beep
@ -436,7 +442,7 @@ void PrintDialog::printLimits()
void PrintDialog::printCurves()
{
int i,r,g,b,c,count;
int i,r,g,b,c,count,usedcurves=0;
char buffer[16];
QPen pen(Qt::black, 2, Qt::SolidLine);
@ -447,7 +453,7 @@ void PrintDialog::printCurves()
if (numcurves==0) {
numcurves=16;
}
{
QImage qi(ISIZEW+1,ISIZEW+1,QImage::Format_RGB32);
QPainter painter(&qi);
painter.setBrush(QBrush("#FFFFFF"));
@ -455,19 +461,30 @@ void PrintDialog::printCurves()
painter.drawRect(0,0,ISIZEW,ISIZEW);
str.append("<table border=0 cellspacing=0 cellpadding=3 width=\"100%\">"+QString("<tr><td width=\"400\"><img src=\"%1\" border=0></td><td><table border=1 cellspacing=0 cellpadding=3 width=\"100%\">").arg(curvefile5));
for(i=0; i<numcurves; i++) {
pen.setColor(colors[i]);
pen.setColor(colors[usedcurves]);
painter.setPen(pen);
colors[i].getRgb(&r,&g,&b);
colors[usedcurves].getRgb(&r,&g,&b);
c=r;
c*=256;
c+=g;
c*=256;
c+=b;
sprintf(buffer,"%06x",c);
if(i%2 == 0) str.append("<tr>");
str.append(QString("<td width=\"70\"><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td>").arg(i+1));
if(i%2) str.append("</tr>");
int curvepoints=g_model->curves[i].count;
count=0;
for(int j=0; j<curvepoints; j++) {
if (g_model->curves[i].points[j].y!=0)
count++;
}
if ((count>0) || (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)|| (g_model->curves[i].count !=5)) {
if(usedcurves%2 == 0) str.append("<tr>");
str.append(QString("<td width=\"70\"><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td>").arg(i+1));
if(usedcurves%2) str.append("</tr>");
usedcurves++;
}
}
if (!(usedcurves%2)) str.append("</tr>");
if (usedcurves!=0) {
str.append("</table></td></tr><tr><td colspan=2><table border=1 cellspacing=0 cellpadding=3 width=\"100%\">");
str.append("<tr>");
str.append(doTC("&nbsp;"));
@ -481,6 +498,13 @@ void PrintDialog::printCurves()
str.append(doTC(tr("pt %1").arg(i+1), "", true));
str.append("</tr>");
for(i=0; i<numcurves; i++) {
int curvepoints=g_model->curves[i].count;
count=0;
for(int j=0; j<curvepoints; j++) {
if (g_model->curves[i].points[j].y!=0)
count++;
}
if ((count>0) || (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)) {
pen.setColor(colors[i]);
painter.setPen(pen);
colors[i].getRgb(&r,&g,&b);
@ -491,19 +515,13 @@ void PrintDialog::printCurves()
c+=b;
sprintf(buffer,"%06x",c);
str.append("<tr>");
int curvepoints=g_model->curves[i].count;
if (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)
str.append(QString("<td width=\"70\" rowspan=2 valign=middle><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td><td width=5>Y</td>").arg(i+1));
else
str.append(QString("<td width=\"70\"><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td><td width=5>Y</td>").arg(i+1));
count=0;
for(int j=0; j<curvepoints; j++) {
if (g_model->curves[i].points[j].y!=0)
count++;
}
for(int j=0; j<curvepoints; j++) {
str.append(doTR(QString::number(g_model->curves[i].points[j].y),"green"));
if (j>0 && count!=0) {
if (j>0 && (count!=0 ||(g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM))) {
if (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)
painter.drawLine(ISIZEW/2+(ISIZEW*g_model->curves[i].points[j-1].x)/200,ISIZEW/2-(ISIZEW*g_model->curves[i].points[j-1].y)/200,ISIZEW/2+(ISIZEW*g_model->curves[i].points[j].x)/200,ISIZEW/2-(ISIZEW*g_model->curves[i].points[j].y)/200);
else
@ -525,6 +543,7 @@ void PrintDialog::printCurves()
str.append("</tr>");
}
}
}
str.append("</table></td></tr></table></td></tr></table>");
str.append("<br>");
painter.setPen(QColor(0,0,0));
@ -534,11 +553,9 @@ void PrintDialog::printCurves()
painter.drawLine(ISIZEW/2-5,(ISIZEW*i)/(20),ISIZEW/2+5,(ISIZEW*i)/(20));
painter.drawLine((ISIZEW*i)/(20),ISIZEW/2-5,(ISIZEW*i)/(20),ISIZEW/2+5);
}
qi.save(curvefile5, "png",100);
}
te->append(str);
}
}
void PrintDialog::printSwitches()