{
if (display.isNull()) {
qDebug() << "### display pixmap broken!!!! " << display.isNull();
return;
}
qDebug() << "### paintEvent go starter...... ";
Load_Actual_Desktop(); /* widget size setting e resolution X11 */
int hi_now = widgetSize.height();
int wi_now = widgetSize.width();
picscaled = display.scaled(wi_now,hi_now,Qt::KeepAspectRatio); /* scaled to widget displayer */
QSize actual_result
= picscaled.
size();
/* get */ Ratio_On_Work(actual_result);
painter.drawPixmap(0,0,picscaled);
selectionText
= QString("Image %1 x %2").
arg(actual_result.
width()).
arg(actual_result.
height());
int stringWidth = fm.width(selectionText);
int stringHeight = fm.ascent();
const int TEXT_MARGIN = 4;
/* color to pen */
QColor fillrectcolor
= Qt
::red;
int textX = 0;
int textY = 0;
/* display rect mesure image crop !!! */
QPoint topLeft
( QMIN
(mousePRESSPoint.
x(), mouseRELEASEPoint.
x()),
QMIN(mousePRESSPoint.y(), mouseRELEASEPoint.y()) );
QPoint bottomRight
( QMAX
(mousePRESSPoint.
x(), mouseRELEASEPoint.
x()),
QMAX(mousePRESSPoint.y(), mouseRELEASEPoint.y()) );
QRect selectionIMAGE
( topLeft, bottomRight
);
/* display rect mesure image crop !!! */
/* display rect mesure text crop !!! */
QPoint topLeftT
( QMIN
(mousePRESSPoint.
x(), mouseRELEASEPoint.
x()) + TEXT_MARGIN ,
QMIN(mousePRESSPoint.y(), mouseRELEASEPoint.y()) + TEXT_MARGIN );
QPoint bottomRightT
( QMAX
(mousePRESSPoint.
x(), mouseRELEASEPoint.
x()) + TEXT_MARGIN ,
QMAX(mousePRESSPoint.y(), mouseRELEASEPoint.y()) + TEXT_MARGIN );
QRect selectionTEXT
( topLeftT, bottomRightT
);
/* display rect mesure text crop !!! */
pen.setStyle( Qt::SolidLine );
pen.setCapStyle( Qt::RoundCap );
pen.setColor( fillrectcolor );
pen.setWidth( 2 );
/* display rect to crop image !!! */
painter.setPen( pen);
painter.drawRect(selectionIMAGE);
/* display rect to crop image !!! */
/* display text image ratio text on crop image !!! */
pen.setColor( textColor );
painter.setPen( pen);
/* display text image ratio text on crop image !!! */
painter.drawText(selectionTEXT,selectionText);
//////// Show_Actual_Params(); /* debug display coordinate all */
}
{
qDebug() << "### mousePressEvent -> " << e->x() << "x" << e->y();
mousePRESSPoint = e->pos();
}
{
qDebug() << "### mouseReleaseEvent -> " << e->x() << "x" << e->y();
mouseRELEASEPoint = e->pos();
}
{
qDebug() << "### mouseReleaseEvent -> " << e->x() << "x" << e->y();
mouseMOVEPoint = e->pos();
}
void Image_Operator::paintEvent(QPaintEvent *e)
{
if (display.isNull()) {
qDebug() << "### display pixmap broken!!!! " << display.isNull();
return;
}
qDebug() << "### paintEvent go starter...... ";
Load_Actual_Desktop(); /* widget size setting e resolution X11 */
int hi_now = widgetSize.height();
int wi_now = widgetSize.width();
picscaled = display.scaled(wi_now,hi_now,Qt::KeepAspectRatio); /* scaled to widget displayer */
QSize actual_result = picscaled.size(); /* get */
Ratio_On_Work(actual_result);
QPainter painter(this);
painter.drawPixmap(0,0,picscaled);
QString selectionText;
selectionText = QString("Image %1 x %2").arg(actual_result.width()).arg(actual_result.height());
QFontMetrics fm( this->font() );
int stringWidth = fm.width(selectionText);
int stringHeight = fm.ascent();
const int TEXT_MARGIN = 4;
/* color to pen */
QColor textColor = Qt::black;
QColor fillrectcolor = Qt::red;
int textX = 0;
int textY = 0;
/* display rect mesure image crop !!! */
QPoint topLeft( QMIN(mousePRESSPoint.x(), mouseRELEASEPoint.x()),
QMIN(mousePRESSPoint.y(), mouseRELEASEPoint.y()) );
QPoint bottomRight( QMAX(mousePRESSPoint.x(), mouseRELEASEPoint.x()),
QMAX(mousePRESSPoint.y(), mouseRELEASEPoint.y()) );
QRect selectionIMAGE( topLeft, bottomRight );
/* display rect mesure image crop !!! */
/* display rect mesure text crop !!! */
QPoint topLeftT( QMIN(mousePRESSPoint.x(), mouseRELEASEPoint.x()) + TEXT_MARGIN ,
QMIN(mousePRESSPoint.y(), mouseRELEASEPoint.y()) + TEXT_MARGIN );
QPoint bottomRightT( QMAX(mousePRESSPoint.x(), mouseRELEASEPoint.x()) + TEXT_MARGIN ,
QMAX(mousePRESSPoint.y(), mouseRELEASEPoint.y()) + TEXT_MARGIN );
QRect selectionTEXT( topLeftT, bottomRightT );
/* display rect mesure text crop !!! */
QPen pen;
pen.setStyle( Qt::SolidLine );
pen.setCapStyle( Qt::RoundCap );
pen.setColor( fillrectcolor );
pen.setWidth( 2 );
/* display rect to crop image !!! */
painter.setPen( pen);
painter.drawRect(selectionIMAGE);
/* display rect to crop image !!! */
/* display text image ratio text on crop image !!! */
pen.setColor( textColor );
painter.setPen( pen);
/* display text image ratio text on crop image !!! */
painter.drawText(selectionTEXT,selectionText);
//////// Show_Actual_Params(); /* debug display coordinate all */
}
void Image_Operator::mousePressEvent(QMouseEvent *e)
{
qDebug() << "### mousePressEvent -> " << e->x() << "x" << e->y();
mousePRESSPoint = e->pos();
}
void Image_Operator::mouseReleaseEvent(QMouseEvent *e)
{
qDebug() << "### mouseReleaseEvent -> " << e->x() << "x" << e->y();
mouseRELEASEPoint = e->pos();
}
void Image_Operator::mouseMoveEvent(QMouseEvent *e)
{
qDebug() << "### mouseReleaseEvent -> " << e->x() << "x" << e->y();
mouseMOVEPoint = e->pos();
}
To copy to clipboard, switch view to plain text mode
Bookmarks