void Handle::reposition(void) { double sw = 0, sh = 0; double nxpos, nypos; CanvasItem *parent = dynamic_cast<CanvasItem *> (parentItem()); if (parent == NULL) { return; } int hflags = handleFlags(); if (hflags & HAN_POINT) { #if 0 int index = get_identn(3); Polygon *poly = dynamic_cast<Polygon *> (parentItem()); assert(poly != NULL); poly->getPointPos(index, &nxpos, &nypos); #endif } else if (hflags & HAN_SEPARA) { Separation *separation = dynamic_cast<Separation *> (parentItem()); nxpos = separation->handle_x; nypos = separation->handle_y; } else { sw = parent->width(); sh = parent->height(); if (xrel == HPLACE_MIN) { nxpos = - (sw / 2) + xoff; } else if (xrel == HPLACE_ZERO) { nxpos = 0 + xoff; } else // if (xrel == HPLACE_MAX) { nxpos = + (sw / 2) + xoff; } if (yrel == HPLACE_MIN) { nypos = - (sh / 2) + yoff; } else if (yrel == HPLACE_ZERO) { nypos = 0 + yoff; } else // if (yrel == HPLACE_MAX) { nypos = + (sh / 2) + yoff; } } if ((nxpos != x()) || (nypos != y())) { // If the handle has been moved. QGraphicsItem::setPos(nxpos, nypos); } }
int main(int argc, char *argv[]){ /* First, analyze the flags */ handleFlags(argc, argv); return EXIT_SUCCESS; }