A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
graphlib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Cleanup.
[graphlib.git]
/
DrawingWindow.cpp
diff --git
a/DrawingWindow.cpp
b/DrawingWindow.cpp
index
bb6a3e2
..
ad74339
100644
(file)
--- a/
DrawingWindow.cpp
+++ b/
DrawingWindow.cpp
@@
-142,14
+142,14
@@
public:
{ }
};
-//! Demande de tracé de texte.
+//! Demande de tracé de texte.
class DrawTextEvent: public QEvent {
public:
const int x;
const int y;
const char *text;
const int flags;
- DrawTextEvent(int x_, int y_, const char
*
text_, int flags_)
+ DrawTextEvent(int x_, int y_, const char
*
text_, int flags_)
: QEvent(static_cast<QEvent::Type>(DrawTextRequest))
, x(x_), y(y_), text(text_), flags(flags_)
{ }
@@
-345,11
+345,24
@@
void DrawingWindow::setBgColor(float red, float green, float blue)
setBgColor(QColor::fromRgbF(red, green, blue));
}
+//! Change l'épaisseur du pinceau
+/*!
+ * Le pinceau à une épaisseur de 1 par défaut.
+ *
+ * \param width épaisseur du pinceau
+ */
+void DrawingWindow::setPenWidth(int width)
+{
+ QPen pen(painter->pen());
+ pen.setWidth(width);
+ painter->setPen(pen);
+}
+
//! Retourne la fonte courante utilisée pour dessiner du texte.
/*!
* \see QFont, setFont
*/
-const QFont
&
DrawingWindow::getFont() const
+const QFont
&
DrawingWindow::getFont() const
{
return painter->font();
}
@@
-358,11
+371,25
@@
const QFont& DrawingWindow::getFont() const
/*!
* \see QFont, getFont
*/
-void DrawingWindow::setFont(const QFont
&
font)
+void DrawingWindow::setFont(const QFont
&
font)
{
painter->setFont(font);
}
+//! Active ou non l'antialiasing.
+/*!
+ * Permet de lisser le dessin.
+ * Fonctionnalité désactivée par défaut.
+ *
+ * \param state état de l'antialiasing
+ *
+ * \bug expérimental
+ */
+void DrawingWindow::setAntialiasing(bool state)
+{
+ painter->setRenderHint(QPainter::Antialiasing, state);
+}
+
//! Efface la fenêtre.
/*!
* La fenêtre est effacée avec la couleur de fond courante.
@@
-545,6
+572,7
@@
void DrawingWindow::fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
* \param text texte à écrire
* \param flags paramètres d'alignement
*
+ * \see drawText(int, int, const std::string &, int)
* \see drawTextBg, setColor
* \see QPainter::drawText
*/
@@
-558,6
+586,15
@@
void DrawingWindow::drawText(int x, int y, const char *text, int flags)
safeUnlock(syncMutex);
}
+//! Écrit du texte.
+/*!
+ * \see drawText(int, int, const char *, int)
+ */
+void DrawingWindow::drawText(int x, int y, const std::string &text, int flags)
+{
+ drawText(x, y, text.c_str(), flags);
+}
+
//! Écrit du texte sur fond coloré.
/*!
* Écrit du texte comme drawText, mais l'arrière-plan est coloré avec
@@
-567,6
+604,7
@@
void DrawingWindow::drawText(int x, int y, const char *text, int flags)
* \param text texte à écrire
* \param flags paramètres d'alignement
*
+ * \see drawTextBg(int, int, const std::string &, int)
* \see drawText, setColor, setColorBg
*/
void DrawingWindow::drawTextBg(int x, int y, const char *text, int flags)
@@
-576,6
+614,14
@@
void DrawingWindow::drawTextBg(int x, int y, const char *text, int flags)
painter->setBackgroundMode(Qt::TransparentMode);
}
+//! Écrit du texte sur fond coloré.
+/*!
+ * \see drawTextBg(int, int, const char *, int)
+ */
+void DrawingWindow::drawTextBg(int x, int y, const std::string &text, int flags)
+{
+ drawTextBg(x, y, text.c_str(), flags);
+}
//! Retourne la couleur d'un pixel.
/*!
@@
-588,7
+634,7
@@
void DrawingWindow::drawTextBg(int x, int y, const char *text, int flags)
*
* \see setColor(unsigned int), setBgColor(unsigned int)
*/
-unsigned int DrawingWindow::getPointColor(int x, int y)
+unsigned int DrawingWindow::getPointColor(int x, int y)
const
{
return image->pixel(x, y);
}
@@
-727,7
+773,7
@@
void DrawingWindow::customEvent(QEvent *ev)
close();
break;
case DrawTextRequest:
- DrawTextEvent
*
tev = dynamic_cast<DrawTextEvent *>(ev);
+ DrawTextEvent
*
tev = dynamic_cast<DrawTextEvent *>(ev);
realDrawText(tev->x, tev->y, tev->text, tev->flags);
break;
}
@@
-837,7
+883,7
@@
void DrawingWindow::initialize(DrawingWindow::ThreadFunction fun)
* \param color couleur
*/
inline
-void DrawingWindow::setColor(const QColor
&
color)
+void DrawingWindow::setColor(const QColor
&
color)
{
QPen pen(painter->pen());
pen.setColor(color);
@@
-849,7
+895,7
@@
void DrawingWindow::setColor(const QColor& color)
* \param color couleur
*/
inline
-void DrawingWindow::setBgColor(const QColor
&
color)
+void DrawingWindow::setBgColor(const QColor
&
color)
{
painter->setBackground(color);
}
@@
-1034,7
+1080,7
@@
void DrawingWindow::realDrawText(int x, int y, const char *text, int flags)
r.setTop(y);
}
syncMutex.lock();
- painter->drawText(r, flags,
text
, &r);
+ painter->drawText(r, flags,
QString::fromUtf8(text)
, &r);
dirty(r);
syncCondition.wakeAll();
syncMutex.unlock();