30 #include <QMouseEvent>
33 #include <QActionGroup>
34 #include <QInputDialog>
44 setAttribute(Qt::WA_StaticContents);
49 menu_ =
new QMenu(tr(
""),
this);
60 QActionGroup * group =
new QActionGroup(
this);
85 map_.height() == modifiedMap.rows);
86 UASSERT(modifiedMap.type() == CV_8UC1);
87 for(
int j=0;
j<
map_.height(); ++
j)
89 for(
int i=0;
i<
map_.width(); ++
i)
91 modifiedMap.at<
unsigned char>(
j,
i) = qRed(
map_.pixel(
i,
j));
112 if (event->button() == Qt::LeftButton) {
113 float scale, offsetX, offsetY;
124 if ((event->buttons() & Qt::LeftButton) &&
scribbling_)
126 float scale, offsetX, offsetY;
129 to.setX((event->pos().x()-offsetX)/
scale);
130 to.setY((event->pos().y()-offsetY)/
scale);
137 if (event->button() == Qt::LeftButton &&
scribbling_) {
138 float scale, offsetX, offsetY;
141 to.setX((event->pos().x()-offsetX)/
scale);
142 to.setY((event->pos().y()-offsetY)/
scale);
156 float w =
map_.width();
157 float h =
map_.height();
158 float widthRatio =
float(targetRect.width()) /
w;
159 float heightRatio =
float(targetRect.height()) /
h;
162 if(widthRatio < heightRatio)
176 if(
w < targetRect.width())
178 offsetX = (targetRect.width() -
w)/2.0
f;
180 if(
h < targetRect.height())
182 offsetY = (targetRect.height() -
h)/2.0
f;
191 float ratio, offsetX, offsetY;
193 QPainter painter(
this);
195 painter.translate(offsetX, offsetY);
197 painter.drawImage(QPoint(0,0),
map_);
202 QWidget::resizeEvent(event);
211 int width = QInputDialog::getInt(
this, tr(
"Set Pen Width"), tr(
"Width:"),
penWidth(), 1, 99, 1, &ok);
225 QPainter painter(&
map_);
235 color.setRgb(178,178,178);
239 color.setRgb(89,89,89);
241 painter.setPen(QPen(color,
myPenWidth_, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));