//Moves the current selection given amount void shift(char * argA, int delta) { int brotherSwitch = -1; if (!strcmp(argA, "brother")) brotherSwitch = 1; else if (!strcmp(argA, "pc")) brotherSwitch = 0; else return; while (delta != 0) { if (brotherSwitch) { Node *swapNode = getBrother(focusedNode, delta); swapNodes(focusedNode, swapNode); focusNode(focusedNode, NULL, True, True); delta = 0; } else { if (delta > 0) { return; } else { if (focusedNode -> parent && focusedNode -> parent -> parent) { Node *newParent = focusedNode -> parent -> parent; parentNode(focusedNode, newParent); rePlaceNode(newParent); } else { return; } delta++; } } } }
static void showGraph(Node n){ printf("Noeud %d\n", getNodeValue(n)); if (hasChild(n)){ showGraph(getChild(n)); } if (hasBrother(n)){ showGraph(getBrother(n)); } }
static int getGraph(Node n, double* array, int nbPlacedPoints){ *(array + nbPlacedPoints) = getNodeValue(n); nbPlacedPoints++; if (hasChild(n)){ nbPlacedPoints = getGraph(getChild(n), array, nbPlacedPoints); } if (hasBrother(n)){ nbPlacedPoints = getGraph(getBrother(n), array, nbPlacedPoints); } return nbPlacedPoints; }
void focus(char * argA, char * argB) { if (!focusedNode) return; int delta = atoi(argB); Node * newFocus = NULL; if (!strcmp(argA, "id")) { newFocus = getNodeById(delta); } else if (!strcmp(argA, "brother")) { newFocus = getBrother(focusedNode, delta); } else if (!strcmp(argA, "pc")) { while (delta != 0) { newFocus = (delta < 0) ? focusedNode -> parent : focusOrChildOf(focusedNode); delta = delta + ( delta > 0 ? -1 : 1); focusNode(newFocus, NULL, True, True); } return; } focusNode(newFocus, NULL, True, True); }