void PainterWidget
::centerChanged(QPoint center
) { QTransform pInvertTransform = pTransform.inverted();
QPoint mapped_center
= pInvertTransform.
map(center
);
currentCenter = mapped_center;
int newx = mapped_center.x()+(-rectOriginalFunction.width()/2);
int newy = -mapped_center.y()+(-rectOriginalFunction.height()/2);
//Don't change the dimensions of the graph
int samew = rectOriginalFunction.width();
int sameh = rectOriginalFunction.height();
//Clicking on the origin of a 20x20 graph [Rect(-10,-10,20,20)] results in
// the rect (-9,-12,20,20) and a center at (1,-2)
// etc.
setOriginalFunctionRect
(QRect(newx,newy,samew,sameh
));
}
void PainterWidget::centerChanged(QPoint center) {
QTransform pInvertTransform = pTransform.inverted();
QPoint mapped_center = pInvertTransform.map(center);
currentCenter = mapped_center;
int newx = mapped_center.x()+(-rectOriginalFunction.width()/2);
int newy = -mapped_center.y()+(-rectOriginalFunction.height()/2);
//Don't change the dimensions of the graph
int samew = rectOriginalFunction.width();
int sameh = rectOriginalFunction.height();
//Clicking on the origin of a 20x20 graph [Rect(-10,-10,20,20)] results in
// the rect (-9,-12,20,20) and a center at (1,-2)
// etc.
setOriginalFunctionRect(QRect(newx,newy,samew,sameh));
}
To copy to clipboard, switch view to plain text mode
Bookmarks