if (w_temp_item!=0 )
{
painter.drawPixmap(0,0,*pixMap_cached1);
// This is the big problem
// If I dont use it, I have not drawforeground , If I use it I have drawforeground but before repaint
// all items....
}
else
{
w_qtutil->time_start();
w_qtutil->time_stop();
qDebug()<< w_qtutil->time_spent()<<"";
}
}
Mousemove code for a rectangle example:
if (w_click_count==1)
{
w_current_Gitem
= new A_GItem
(WW
::Graph_rectangle,
QRect(0,
0,
0,
0), punteroo,
0);
w_current_Gitem->w_set_draw_props(1,1,1);
w_current_Gitem->setPos(x,y);
last_point_x=x;last_point_y=y;
w_click_count++;
G_view->w_set_temp_item(w_current_Gitem); // set the temporal item
G_view->w_pixmap_copy(); // copy screen
return;
}
else
{
double center_x=(last_point_x+x) /2;
double center_y=(last_point_y+y) /2;
double ix=W_MATH::my_abs(x-last_point_x)/2;
double iy=W_MATH::my_abs(y-last_point_y)/2;
w_current_Gitem
->w_set_rect
( QRectF(-ix,
-iy,ix
*2,iy
*2));
w_current_Gitem->setPos(center_x,center_y);
if (w_mouse_action==5) //click
{
w_click_count=0; // done.
G_scene->addItem(w_current_Gitem);
G_view->w_set_temp_item(0);
}
else
{ w_click_count++;
// x1,y1,xx,yy are the total scene limits.
return;
}
}
void A_Gview2D::paintEvent(QPaintEvent *event) {
if (w_temp_item!=0 )
{
QPainter painter(this->viewport());
painter.drawPixmap(0,0,*pixMap_cached1);
QGraphicsView::paintEvent(event);
// This is the big problem
// If I dont use it, I have not drawforeground , If I use it I have drawforeground but before repaint
// all items....
}
else
{
w_qtutil->time_start();
QGraphicsView::paintEvent(event);
w_qtutil->time_stop();
qDebug()<< w_qtutil->time_spent()<<"";
}
}
Mousemove code for a rectangle example:
if (w_click_count==1)
{
w_current_Gitem = new A_GItem(WW::Graph_rectangle, QRect(0,0,0,0), punteroo,0);
w_current_Gitem->w_set_draw_props(1,1,1);
w_current_Gitem->setPos(x,y);
last_point_x=x;last_point_y=y;
w_click_count++;
G_view->w_set_temp_item(w_current_Gitem); // set the temporal item
G_view->w_pixmap_copy(); // copy screen
return;
}
else
{
double center_x=(last_point_x+x) /2;
double center_y=(last_point_y+y) /2;
double ix=W_MATH::my_abs(x-last_point_x)/2;
double iy=W_MATH::my_abs(y-last_point_y)/2;
w_current_Gitem->w_set_rect( QRectF(-ix,-iy,ix*2,iy*2));
w_current_Gitem->setPos(center_x,center_y);
if (w_mouse_action==5) //click
{
w_click_count=0; // done.
G_scene->addItem(w_current_Gitem);
G_view->w_set_temp_item(0);
}
else
{ w_click_count++;
G_scene->invalidate(QRectF(x1,y1,xx,yy), QGraphicsScene::ForegroundLayer);
// x1,y1,xx,yy are the total scene limits.
return;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks