MIMO::Ptr MotionProfileTrapezoidal::clone() { MotionProfileTrapezoidal::Ptr tmp = boost::make_shared< MotionProfileTrapezoidal > (); tmp->setProgressExpression( getProgressExpression()->clone() ); for (int i=0;i<nrOfOutputs();++i) { tmp->addOutput( getStartValue(i)->clone(), getEndValue(i)->clone(), getMaxVelocity(i)->clone(), getMaxAcceleration(i)->clone() ); } return tmp; }
bool Editor::performMoving(unsigned int boxId, int x, int y, vector<unsigned int>& movedBoxes, int maxModification) { CSP* containingCSP = m_boxIdToContainingCSP[boxId]; ConstrainedBox* currentBox = containingCSP->getBoxById(boxId); ConstrainedBox* motherBox = currentBox->mother(); // if ((x > motherBox->lengthValue()) || (y > motherBox->lengthValue())) { // return false; // } containingCSP->changeAllBoxMaxSceneWidth(motherBox->lengthValue()); CSP* boxCSP = currentBox->getCSP(); int previousX = getBeginValue(boxId); int previousY = getEndValue(boxId); if (boxCSP != NULL) { std::vector<unsigned int> boxesId; boxCSP->getAllBoxesId(boxesId); if (boxesId.size() != 0) { unsigned int maxValue = 0; for (unsigned int i = 0; i < boxesId.size(); ++i) { unsigned int currentChildBoxEnd = boxCSP->getEndValue(boxesId[i]); if(currentChildBoxEnd > maxValue) { maxValue = currentChildBoxEnd; } } if ((unsigned int)(y - x) < maxValue) { return false; } } } int modificationX = abs(previousX - x); int modificationY = abs(previousY - y); if (maxModification < modificationX) { maxModification = modificationX; } if (maxModification < modificationY) { maxModification = modificationY; } unsigned int hierarchyRelation = currentBox->getHierarchyRelationId(); if (hierarchyRelation != NO_ID) { containingCSP->removeTemporalRelation(hierarchyRelation); } std::vector<unsigned int> hierarchyRelationMovedBoxes; if(containingCSP->performMoving(boxId, x, y, movedBoxes, maxModification)) { if (hierarchyRelation != NO_ID) { containingCSP->addAntPostRelation(hierarchyRelation, boxId, BEGIN_CONTROL_POINT_INDEX, boxId, END_CONTROL_POINT_INDEX, ANTPOST_ANTERIORITY, currentBox->lengthValue(), currentBox->lengthValue(), hierarchyRelationMovedBoxes, false); } movedBoxes.clear(); getAllBoxesId(movedBoxes); return true; } else { // put back the CSP into its previous state. containingCSP->performMoving(boxId, previousX, previousY, movedBoxes, maxModification); movedBoxes.clear(); getAllBoxesId(movedBoxes); return false; } }