void Relation::updateCoordinates() { BasicBox *box = _scene->getBox(_abstract->firstBox()); if (box != NULL) { switch (_abstract->firstExtremity()) { case BOX_START: _start = box->getLeftGripPoint(); break; case BOX_END: _start = box->getRightGripPoint(); break; case NO_EXTREMITY: _start = box->getCenter(); break; } } box = _scene->getBox(_abstract->secondBox()); if (box != NULL) { switch (_abstract->secondExtremity()) { case BOX_START: if (box != NULL) { _end = box->getLeftGripPoint(); } break; case BOX_END: if (box != NULL) { _end = box->getRightGripPoint(); } break; case NO_EXTREMITY: if (box != NULL) { _end = box->getCenter(); } break; } } // std::cout<<"\t start = "<<_start.x()*MaquetteScene::MS_PER_PIXEL<<std::endl; // std::cout<<"\t end = "<<_end.x()*MaquetteScene::MS_PER_PIXEL<<std::endl; // std::cout<<"\t Length = "<<_abstract->_length*MaquetteScene::MS_PER_PIXEL<<std::endl; _abstract->_length = _end.x() - _start.x(); setPos(getCenter()); }
void ConditionalRelation::updateBoxesCoordinates(unsigned int boxId) { // Move related boxes, except boxId's box (already moved by user) QList<BasicBox *>::iterator it; BasicBox *box = _scene->getBox(boxId), *curBox; float curBoxX, boxX = box->getLeftGripPoint().x(); for(it=_boxesAttached.begin() ; it!=_boxesAttached.end() ; it++) { curBox = *it; if(curBox->ID() != box->ID()) { curBoxX = curBox->getLeftGripPoint().x(); if(boxX != curBoxX) { curBox->moveBy(boxX - curBoxX, 0.); _scene->boxMoved(curBox->ID()); } } } }