{
if (display.isNull()) {
return;
}
/* color to pen */
QColor fillrectcolor
= Qt
::red;
QColor shapepicture
= Qt
::white;
/////////////////////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 */ painter.
setRenderHint(QPainter::Antialiasing,
true);
painter.drawPixmap(0,0,picscaled);
/*
QFontMetrics fm( this->font() );
int stringWidth = fm.width(selectionText);
int stringHeight = fm.ascent();
*/
const int TEXT_MARGIN = 4;
int bordershade = 26;
int textX = 0;
int textY = 0;
int Top_startX = QMIN(mousePRESSPoint.x(), mouseRELEASEPoint.x());
int Top_startY = QMIN(mousePRESSPoint.y(), mouseRELEASEPoint.y()) ;
int Bot_endX = QMAX(mousePRESSPoint.x(), mouseRELEASEPoint.x());
int Bot_endY = QMAX(mousePRESSPoint.y(), mouseRELEASEPoint.y());
/* display rect mesure image crop !!! */
QPoint topLeft
( Top_startX , Top_startY
);
QPoint bottomRight
( Bot_endX , Bot_endY
);
QRect selectionIMAGE
( topLeft, bottomRight
);
/* display rect mesure image crop !!! */
/* display rect mesure text crop !!! */
QPoint topLeftT
( Top_startX , Top_startY
- 20 );
QPoint bottomRightT
( Bot_endX
- TEXT_MARGIN , Bot_endY
- TEXT_MARGIN
);
QRect selectionTEXT
( topLeftT, bottomRightT
);
/* display rect mesure text crop !!! */
/* shade border */
QPoint topLeftout
( Top_startX
- (bordershade
/ 2) , Top_startY
- (bordershade
/ 2) );
QPoint bottomRightout
( Bot_endX
+ (bordershade
/ 2) , Bot_endY
+ (bordershade
/ 2) );
QRect selectionOutIMAGE
(topLeftout,bottomRightout
);
/* shade border */
/////////qDebug() << "### Top_startX->" << Top_startX << " Bot_endX->" << Bot_endX;
///////////qDebug() << "### Top_startY->" << Top_startY << " Bot_endY->" << Bot_endY;
int HighteResult = selectionIMAGE.height(); /* correct */
int LargeResult = selectionIMAGE.width(); /* correct */
qreal cento;
qreal ratio;
cento = 100.0;
ratio = (actual_result.width()*cento) / origImageSize.width();
///////////qDebug() << "### originale foto " << origImageSize.width() << "x" << origImageSize.height();
////////////qDebug() << "### a video misura " << actual_result.width() << "x" << actual_result.height();
//////////qDebug() << "### taglio uguale " << LargeResult << "x" << HighteResult;
////////////qDebug() << "### ratio " << ratio;
int LargeReal = ( LargeResult / ratio ) * cento;
int HighteReal = ( HighteResult / ratio ) * cento;
selectionText
= QString("%1x%2 px (ratio \%%3)") .arg(LargeReal)
.arg(HighteReal)
.arg(ratio);
if ( LargeResult < 9 ) {
currentDragMode = NO_EFFECT;
}
pen.setStyle( Qt::SolidLine );
///////////// qDebug() << "### currentDragMode -> " << currentDragMode ;
if ( currentDragMode == DRAW_SELECTION || currentDragMode == DRAW_LINE ) {
OneWorkImage = selectionIMAGE;
pen.setWidth( bordershade );
pen.setColor( shapepicture );
painter.setPen( pen);
painter.drawRect(selectionOutIMAGE);
/* display rect to crop image !!! */
pen.setWidth( 2 );
pen.setColor( fillrectcolor );
painter.setPen( pen);
painter.drawRect(selectionIMAGE);
/* display rect to crop image !!! */
/* display text image ratio text on crop image !!! */
pen.setColor( fillrectcolor );
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::paintEvent(QPaintEvent *e)
{
if (display.isNull()) {
return;
}
QString selectionText;
/* color to pen */
QColor textColor = Qt::black;
QColor fillrectcolor = Qt::red;
QColor shapepicture = Qt::white;
/////////////////////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 */
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.drawPixmap(0,0,picscaled);
/*
QFontMetrics fm( this->font() );
int stringWidth = fm.width(selectionText);
int stringHeight = fm.ascent();
*/
const int TEXT_MARGIN = 4;
int bordershade = 26;
int textX = 0;
int textY = 0;
int Top_startX = QMIN(mousePRESSPoint.x(), mouseRELEASEPoint.x());
int Top_startY = QMIN(mousePRESSPoint.y(), mouseRELEASEPoint.y()) ;
int Bot_endX = QMAX(mousePRESSPoint.x(), mouseRELEASEPoint.x());
int Bot_endY = QMAX(mousePRESSPoint.y(), mouseRELEASEPoint.y());
/* display rect mesure image crop !!! */
QPoint topLeft( Top_startX , Top_startY );
QPoint bottomRight( Bot_endX , Bot_endY );
QRect selectionIMAGE( topLeft, bottomRight );
/* display rect mesure image crop !!! */
/* display rect mesure text crop !!! */
QPoint topLeftT( Top_startX , Top_startY - 20 );
QPoint bottomRightT( Bot_endX - TEXT_MARGIN , Bot_endY - TEXT_MARGIN );
QRect selectionTEXT( topLeftT, bottomRightT );
/* display rect mesure text crop !!! */
/* shade border */
QPoint topLeftout( Top_startX - (bordershade / 2) , Top_startY - (bordershade / 2) );
QPoint bottomRightout( Bot_endX + (bordershade / 2) , Bot_endY + (bordershade / 2) );
QRect selectionOutIMAGE(topLeftout,bottomRightout);
/* shade border */
/////////qDebug() << "### Top_startX->" << Top_startX << " Bot_endX->" << Bot_endX;
///////////qDebug() << "### Top_startY->" << Top_startY << " Bot_endY->" << Bot_endY;
int HighteResult = selectionIMAGE.height(); /* correct */
int LargeResult = selectionIMAGE.width(); /* correct */
qreal cento;
qreal ratio;
cento = 100.0;
ratio = (actual_result.width()*cento) / origImageSize.width();
///////////qDebug() << "### originale foto " << origImageSize.width() << "x" << origImageSize.height();
////////////qDebug() << "### a video misura " << actual_result.width() << "x" << actual_result.height();
//////////qDebug() << "### taglio uguale " << LargeResult << "x" << HighteResult;
////////////qDebug() << "### ratio " << ratio;
int LargeReal = ( LargeResult / ratio ) * cento;
int HighteReal = ( HighteResult / ratio ) * cento;
selectionText = QString("%1x%2 px (ratio \%%3)")
.arg(LargeReal)
.arg(HighteReal)
.arg(ratio);
if ( LargeResult < 9 ) {
currentDragMode = NO_EFFECT;
}
QPen pen;
pen.setStyle( Qt::SolidLine );
///////////// qDebug() << "### currentDragMode -> " << currentDragMode ;
if ( currentDragMode == DRAW_SELECTION || currentDragMode == DRAW_LINE ) {
OneWorkImage = selectionIMAGE;
pen.setWidth( bordershade );
pen.setColor( shapepicture );
painter.setPen( pen);
painter.drawRect(selectionOutIMAGE);
/* display rect to crop image !!! */
pen.setWidth( 2 );
pen.setColor( fillrectcolor );
painter.setPen( pen);
painter.drawRect(selectionIMAGE);
/* display rect to crop image !!! */
/* display text image ratio text on crop image !!! */
pen.setColor( fillrectcolor );
painter.setPen( pen);
/* display text image ratio text on crop image !!! */
painter.drawText(selectionTEXT,selectionText);
}
//////// Show_Actual_Params(); /* debug display coordinate all */
}
To copy to clipboard, switch view to plain text mode
Bookmarks