32 #include <QtPrintSupport/QPrinter>
33 #include <QtPrintSupport/QPrintDialog>
36 #define TR(id) OLocalizator::getString("TYSpectreWidget", (id))
54 QPrinter* printer =
new QPrinter();
55 if (pDialog->exec() == QDialog::Accepted)
57 QPrintDialog dialog(printer,
this);
60 QPainter paint(printer);
63 int mid = int(printer->width() / 2) -
64 int(paint.fontMetrics().horizontalAdvance(pDialog->
_lineEditTete->text()) / 2);
65 int midX = int(printer->width() / 2);
66 int midY = int(printer->height() / 2);
68 mid = int(printer->width() / 2) -
69 int(paint.fontMetrics().horizontalAdvance(pDialog->
_lineEditPied->text()) / 2);
70 paint.drawText(mid, printer->height() - 20, pDialog->
_lineEditPied->text());
71 paint.setFont(QFont(
"Helvetica", 15, QFont::Bold));
72 mid = int(printer->width() / 2) -
73 int(paint.fontMetrics().horizontalAdvance(pDialog->
_lineEditTitre->text()) / 2);
74 paint.drawText(mid, printer->height() * 14 / 15, pDialog->
_lineEditTitre->text());
75 paint.setFont(QFont());
77 double Wmetric = printer->width() * 9 / 10;
78 double Hmetric = printer->height() * 8 / 9;
82 double h = Wmetric * (y / x);
87 w = Hmetric * (x / y);
90 paint.translate(midX - (w / 2), midY - (h / 2));
100 QPainter* p =
new QPainter(
this);
117 size_t nbFreq =
tabFreq.size();
120 double width = double(w);
121 double height = double(h);
122 double value[50], hauteur = NAN, L = width * 2 / 3, hzero = NAN;
123 double hmax = 0, largeur = L / (nbFreq + 1), x = width * 1 / 6 + 10;
128 double textPos = NAN;
129 double midFreq = nbFreq / 2.0;
131 for (i = 0; i < nbFreq; i++)
142 else if (value[i] < hmin)
148 double echelle = height * 7 / 10 / (-hmin + hmax);
149 hzero = height * 8.5 / 10 + hmin * echelle;
150 if ((hmin == 0) && (hmax == 0))
159 hauteur = value[0] * echelle;
160 double hprev = hzero - hauteur;
162 painter->setPen(QPen(Qt::red, 2));
164 for (i = 1; i < nbFreq; i++)
166 hauteur = value[i] * echelle;
167 painter->drawLine((
int)x, (int)hprev, (
int)(x + largeur), (
int)(hzero - hauteur));
168 hprev = hzero - hauteur;
170 if (val !=
ROUND(value[i]))
172 val =
ROUND(value[i]);
173 valMax =
MAX(val, valMax);
176 if ((i ==
int(midFreq)) || (i == (nbFreq - 1)))
184 textPos = hzero + 17;
186 painter->drawLine((
int)x, (
int)(hzero + 5), (
int)x, (
int)(hzero - 5));
187 painter->drawText((
int)(x - 10), (
int)textPos, num.setNum(
tabFreq[i]));
194 painter->drawLine((
int)(width * 1 / 6 + 5), (
int)(hzero - valMax * echelle),
195 (
int)(width * 1 / 6 + 15), (
int)(hzero - valMax * echelle));
196 painter->drawText((
int)(width * 1 / 6 - 25), (
int)(hzero - valMax * echelle), num.setNum(valMax));
198 painter->drawLine((
int)(width * 1 / 6 + 5), (
int)(hzero - (valMax / 2) * echelle),
199 (
int)(width * 1 / 6 + 15), (
int)(hzero - (valMax / 2) * echelle));
200 painter->drawText((
int)(width * 1 / 6 - 25), (
int)(hzero - (valMax / 2) * echelle),
201 num.setNum((valMax / 2)));
203 painter->setPen(QPen(Qt::black, 2));
204 painter->drawLine((
int)(width * 1 / 6), (
int)(hzero), (
int)(width * 5 / 6), (
int)hzero);
205 painter->drawLine((
int)(width * 1 / 6 + 10), (
int)(height * 18 / 20), (
int)(width * 1 / 6 + 10),
206 (
int)(hzero - hmax * echelle - 10));
207 painter->drawText((
int)(width * 1 / 6), (
int)(hzero - hmax * echelle - 20),
"dB");
208 painter->drawText((
int)(width * 5 / 6), (
int)hzero,
TR(
"id_abscisse"));
int ROUND(double a)
Compute the rounded value of a number.
double MAX(double a, double b)
Return the biggest number of two ones.
Boite de dialogue des parametres d'impression (fichier header)
const std::vector< double > tabFreq
OTabFreq TYTabFreq
Collection des frequences.
double * getTabValReel() override
classe pour une boite de dialogue des parametres d'impression.
QGroupBox * _groupBoxCalcul
QLineEdit * _lineEditPied
QLineEdit * _lineEditTete
QGroupBox * _groupBoxProjet
QLineEdit * _lineEditTitre
virtual TYSpectreForm getForm()
Set/Get de la forme du spectre.
static const TYTabFreq getTabFreqNorm(TYSpectreForm form=SPECTRE_FORM_TIERS)