Man, the position of ellipse's center is determined by it's top-left and bottom-right points.
E.g. center.x == (topLeft.x + bottomRight.x)/2
and center.y == (topLeft.y + bottomRight.y)/2
. That's how ellipses work in math :).
In your code, center will be in (0,0) if (lowestX + hightX) == 0
& (lowestY + hightY) == 0
.
Or maybe I'm not getting what are you talking about?
If you want to move center of ellipse in easy way, you can create class derived from QCPItemEllipse
with field QCPItemTracer *mCenterTracer
and with following stuff in constructor:
mCenterTracer->setStyle(QCPItemTracer::tsNone);
topLeft->setParentAnchor(mCenterTracer->position);
bottomRight->setParentAnchor(mCenterTracer->position);
topLeft->setCoords(-xRadius/2.0, -yRadius/2.0);
bottomRight->setCoords(xRadius/2.0, yRadius/2.0);
So method for moving center (without changing radiuses) will look like:
void FreakingEllipse::moveCenter(double x, double y) {
mCenterTracer->position->setCoords(x, y);
}
By the way, you can add following if you want your ellipse to have constant radius in pixels, while it's center is still stick to plot coordinates:
topLeft->setType(QCPItemPosition::ptAbsolute);
bottomRight->setType(QCPItemPosition::ptAbsolute);