/* applyDelta: * Recursively apply rotation rotate followed by translation (x,y) * to block sn and its children. */ static void applyDelta(block_t * sn, double x, double y, double rotate) { block_t *child; Agraph_t *subg; Agnode_t *n; subg = sn->sub_graph; for (n = agfstnode(subg); n; n = agnxtnode(subg, n)) { double X, Y; if (rotate != 0) { double tmpX, tmpY; double cosR, sinR; tmpX = ND_pos(n)[0]; tmpY = ND_pos(n)[1]; cosR = cos(rotate); sinR = sin(rotate); X = tmpX * cosR - tmpY * sinR; Y = tmpX * sinR + tmpY * cosR; } else { X = ND_pos(n)[0]; Y = ND_pos(n)[1]; } /* translate */ ND_pos(n)[0] = X + x; ND_pos(n)[1] = Y + y; } for (child = sn->children.first; child; child = child->next) applyDelta(child, x, y, rotate); }
WebKitPlatformWheelEvent::WebKitPlatformWheelEvent(QWheelEvent* e) { m_timestamp = WTF::currentTime(); mouseEventModifiersFromQtKeyboardModifiers(e->modifiers(), m_modifiers); m_position = e->pos(); m_globalPosition = e->globalPos(); m_granularity = ScrollByPixelWheelEvent; m_directionInvertedFromDevice = false; applyDelta(e->delta(), e->orientation()); }
PlatformWheelEvent::PlatformWheelEvent(const EA::WebKit::MouseWheelEvent* wheelEvent) { m_position = IntPoint(wheelEvent->mX, wheelEvent->mY); m_globalPosition = IntPoint(wheelEvent->mGlobalX, wheelEvent->mGlobalY); m_shiftKey = (wheelEvent->mModifiers & EA::WebKit::kModifierMaskShift); m_ctrlKey = (wheelEvent->mModifiers & EA::WebKit::kModifierMaskControl); m_altKey = (wheelEvent->mModifiers & EA::WebKit::kModifierMaskAlt); m_metaKey = (wheelEvent->mModifiers & EA::WebKit::kModifierMaskOS); applyDelta(wheelEvent->mZDelta, fabs(wheelEvent->mNumLines), !m_shiftKey); m_granularity = ScrollByPixelWheelEvent; m_isAccepted = false; }
/* position: * Assume childCount > 0 * For each node in the block with children, getInfo is called, with the * information stored in the parents array. * This information is used by setInfo to compute the amount of space allocated * to each parent and the radius at which to place its children. * Finally, positionChildren is called to do the actual positioning. * If length is 1, keeps track of minimum and maximum child angle. */ static double position(Agraph_t * g, int childCount, int length, nodelist_t * path, block_t * sn, double min_dist) { nodelistitem_t *item; Agnode_t *n; posstate state; int i, counter = 0; double maxRadius = 0.0; double angle; double theta = 0.0; posinfo_t* parents = N_NEW(childCount, posinfo_t); int num_parents = 0; posinfo_t* next; posinfo_t* curr; double delta; state.cp = sn->children.first; state.subtreeR = sn->radius; state.radius = sn->radius; state.neighbor = CHILD(sn); state.nodeAngle = 2 * M_PI / length; state.firstAngle = -1; state.lastAngle = -1; for (item = path->first; item; item = item->next) { n = item->curr; theta = counter * state.nodeAngle; counter++; if (ISPARENT(n)) { parents[num_parents].n = n; parents[num_parents].theta = theta; maxRadius = getInfo (parents+num_parents, &state, min_dist); num_parents++; } } if (num_parents == 1) parents->scale = 1.0; else if (num_parents == 2) { curr = parents; next = parents+1; delta = next->theta - curr->theta; if (delta > M_PI) delta = 2*M_PI - delta; setInfo (curr, next, delta); } else { curr = parents; for (i = 0; i < num_parents; i++) { if (i+1 == num_parents) { next = parents; delta = next->theta - curr->theta + 2*M_PI; } else { next = curr+1; delta = next->theta - curr->theta; } setInfo (curr, next, delta); curr++; } } for (i = 0; i < num_parents; i++) { positionChildren (g, parents + i, &state, length, min_dist); } free (parents); /* If block has only 1 child, to save space, we coalesce it with the * child. Instead of having final radius sn->radius + max child radius, * we have half that. However, the origin of the block is no longer in * the center of the block, so we cannot do a simple rotation to get * the neighbor node next to the parent block in getRotate. */ if (childCount == 1) { applyDelta(sn, -(maxRadius + min_dist / 2), 0, 0); sn->radius += min_dist / 2 + maxRadius; SET_COALESCED(sn); } else sn->radius = state.subtreeR; angle = (state.firstAngle + state.lastAngle) / 2.0 - M_PI; return angle; }
/* positionChildren: */ static void positionChildren (Agraph_t* g, posinfo_t* pi, posstate * stp, int length, double min_dist) { block_t *child; double childAngle, childRadius, incidentAngle; double mindistAngle, rotateAngle, midAngle = 0.0; int midChild, cnt = 0; double snRadius = stp->subtreeR; /* max subtree radius */ double firstAngle = stp->firstAngle; double lastAngle = stp->lastAngle; double d, deltaX, deltaY; childRadius = pi->scale * pi->minRadius; if (length == 1) { childAngle = 0; d = pi->diameter/(2*M_PI); childRadius = MAX(childRadius, d); d = 2*M_PI*childRadius - pi->diameter; if (d > 0) min_dist += d/pi->childCount; } else childAngle = pi->theta - pi->diameter/(2 * childRadius); if ((childRadius + pi->maxRadius) > snRadius) snRadius = childRadius + pi->maxRadius; mindistAngle = min_dist / childRadius; midChild = (pi->childCount + 1) / 2; for (child = stp->cp; child; child = child->next) { if (BLK_PARENT(child) != pi->n) continue; if (sizeNodelist(child->circle_list) <= 0) continue; incidentAngle = child->radius / childRadius; if (length == 1) { if (childAngle != 0) { if (pi->childCount == 2) childAngle = M_PI; else childAngle += incidentAngle; } if (firstAngle < 0) firstAngle = childAngle; lastAngle = childAngle; } else { if (pi->childCount == 1) { childAngle = pi->theta; } else { childAngle += incidentAngle + mindistAngle / 2; } } deltaX = childRadius * cos(childAngle); deltaY = childRadius * sin(childAngle); /* first apply the delta to the immediate child and see if we need * to rotate it for better edge link * should return the theta value if there was a rotation else zero */ rotateAngle = getRotation(child, g, deltaX, deltaY, childAngle); applyDelta(child, deltaX, deltaY, rotateAngle); if (length == 1) { childAngle += incidentAngle + mindistAngle; } else { childAngle += incidentAngle + mindistAngle / 2; } cnt++; if (cnt == midChild) midAngle = childAngle; } if ((length > 1) && (pi->n == stp->neighbor)) { PSI(pi->n) = midAngle; } stp->subtreeR = snRadius; stp->firstAngle = firstAngle; stp->lastAngle = lastAngle; }