/*********************************************************************** *Funtion : Hit test for the object *Return : integer handle id. *Parameter: QPoint local mouse point, scene bonding rect, bool selected flag. **********************************************************************/ int SamDrawItemBase::hitTest(QPointF qpPoint, QRectF &qrcBondingRect, bool bSelected) { if (this->getResizable() == false) { return 0; } /*Object is selected*/ if (bSelected) { /*Check the handle, if the mouse point in it's area*/ int iHandleCount = getHandleCount(); for (int iHandle = 1; iHandle <= iHandleCount; iHandle++) { // GetHandleRect returns in logical coords QRectF qrcRect = getHandleRect(iHandle, qrcBondingRect); if ( (qpPoint.rx() >= qrcRect.left()) && (qpPoint.rx() <= qrcRect.right()) && (qpPoint.ry() >= qrcRect.top()) && (qpPoint.ry() <= qrcRect.bottom()) ) { return iHandle; } } } /*Object is not selected*/ else { /*if ( qpPoint.rx() >= this->sceneBoundingRect().left() && qpPoint.rx() < this->sceneBoundingRect().right() && qpPoint.ry() <= this->sceneBoundingRect().top() && qpPoint.ry() > this->sceneBoundingRect().bottom() )*/ if ( qpPoint.rx() >= qrcBondingRect.left() && qpPoint.rx() < qrcBondingRect.right() && qpPoint.ry() <= qrcBondingRect.top() && qpPoint.ry() > qrcBondingRect.bottom() ) { return 1; } } return 0; }
/*********************************************************************** *Funtion : Draw the trackers of object (common function in base calss) *Return : none *Parameter: Tracker state, QGraphicsScene **********************************************************************/ void SamDrawItemBase::drawTracker(eTrackerState eState, QGraphicsScene *pScene, QRectF &qrcBondingRect) { if (!pScene) { return; } if (this->getResizable() == false) { return; } m_pvecTrackers.clear(); switch (eState) { case TRK_NORMAL: break; case TRK_SELECTED: case TRK_ACTIVE: { int iHandleCount = getHandleCount(); for (int iHandle = 1; iHandle <= iHandleCount; iHandle++) { QPointF qpHandle = getHandle(iHandle, qrcBondingRect); SamDrawTackerRect *pItem = new SamDrawTackerRect(qpHandle); pScene->addItem(pItem); if (pItem) { //item->setCursor(getHandleCursor(nHandle)); m_pvecTrackers.push_back(pItem); } } } break; default: break; } }
bool MgBaseShape::_rotateHandlePoint(int index, const Point2d& pt) { if (getFlag(kMgFixedLength)) { if (getFlag(kMgRotateDisnable)) { offset(pt - getHandlePoint(index), -1); } else { Point2d basept(_extent.center()); if (!getFlag(kMgSquare)) { int baseindex = index > 0 ? index - 1 : getHandleCount() - 1; while (baseindex > 0 && isHandleFixed(baseindex)) baseindex--; basept = (getHandlePoint(baseindex)); } float a1 = (pt - basept).angle2(); float a2 = (getHandlePoint(index) - basept).angle2(); transform(Matrix2d::rotation(a1 - a2, basept)); } return true; } return false; }
/* The following block is copied from the Java source code. It documents the counters array. * @param counters the results are returned in this array. * <ol> * <li>working set in bytes for this process * <li>peak working set in bytes for this process * <li>elapsed time in milliseconds * <li>user time in milliseconds * <li>kernel time in milliseconds * <li>page faults for the process * <li>commit charge total in bytes (working set for the entire machine). On some * machines we have problems getting this value so we return -1 in that case. * <li>number of GDI objects in the process * <li>number of USER objects in the process * <li>number of open handles in the process. returns -1 if this information is not available * <li>Number of read operations * <li>Number of write operations * <li>Number of bytes read * <li>Number of bytes written * </ol> */ JNIEXPORT jboolean JNICALL Java_org_eclipse_perfmsr_core_PerformanceMonitor_nativeGetPerformanceCounters (JNIEnv * jniEnv, jclass jniClass, jlongArray counters) { FILETIME creationTime, exitTime, kernelTime, userTime, systemTime; ULARGE_INTEGER uliCreation, uliSystem, uliKernel, uliUser; ULONGLONG diff; IO_COUNTERS ioCounters; jboolean result = TRUE; jsize len = (*jniEnv)->GetArrayLength(jniEnv, counters); jlong *body = (*jniEnv)->GetLongArrayElements(jniEnv, counters, 0); HANDLE me = GetCurrentProcess(); PROCESS_MEMORY_COUNTERS memCounters; DWORD cb = sizeof(PROCESS_MEMORY_COUNTERS); BOOL rc = GetProcessMemoryInfo(me, &memCounters, cb); if (rc != 0) { body[0] = memCounters.WorkingSetSize; body[1] = memCounters.PeakWorkingSetSize; body[5] = memCounters.PageFaultCount; } else { handleSystemError(jniEnv); return FALSE; } if (!GetProcessTimes(me, &creationTime, &exitTime, &kernelTime, &userTime)) { handleSystemError(jniEnv); return FALSE; } GetSystemTimeAsFileTime(&systemTime); memcpy(&uliCreation, &creationTime, sizeof(uliCreation)); memcpy(&uliSystem, &systemTime, sizeof(uliSystem)); memcpy(&uliKernel, &kernelTime, sizeof(uliSystem)); memcpy(&uliUser, &userTime, sizeof(ULARGE_INTEGER)); diff = uliSystem.QuadPart - uliCreation.QuadPart; body[2] = diff / 10000; body[3] = uliUser.QuadPart / 10000; body[4] = uliKernel.QuadPart / 10000; body[6] = getTotalCommitted(jniEnv); body[7] = GetGuiResources(me, GR_GDIOBJECTS); body[8] = GetGuiResources(me, GR_USEROBJECTS); body[9] = getHandleCount(jniEnv, me); if (!GetProcessIoCounters(me, &ioCounters)) { handleSystemError(jniEnv); return FALSE; } body[10] = ioCounters.ReadOperationCount; body[11] = ioCounters.WriteOperationCount; body[12] = ioCounters.ReadTransferCount; body[13] = ioCounters.WriteTransferCount; (*jniEnv)->ReleaseLongArrayElements(jniEnv, counters, body, 0); return result; }
AgentConsolidatorSystemHandlePtr getHandle (uint32_t pos) { return pos < getHandleCount() ? _consolidatorsyshandles[pos] : NULL; }