omrobjectptr_t GC_ObjectModel::initializeAllocation(MM_EnvironmentBase *env, void *allocatedBytes, MM_AllocateInitialization *allocateInitialization) { Assert_MM_true(OMR_EXAMPLE_ALLOCATION_CATEGORY == allocateInitialization->getAllocationCategory()); omrobjectptr_t objectPtr = (omrobjectptr_t)allocatedBytes; if (NULL != objectPtr) { setObjectSize(objectPtr, allocateInitialization->getAllocateDescription()->getBytesRequested(), false); } return objectPtr; }
void EllipseObject::init(qreal centerX, qreal centerY, qreal width, qreal height, QRgb rgb, Qt::PenStyle lineType) { setData(OBJ_TYPE, type()); setData(OBJ_NAME, OBJ_NAME_ELLIPSE); //WARNING: DO NOT enable QGraphicsItem::ItemIsMovable. If it is enabled, //WARNING: and the item is double clicked, the scene will erratically move the item while zooming. //WARNING: All movement has to be handled explicitly by us, not by the scene. setFlag(QGraphicsItem::ItemIsSelectable, true); setObjectSize(width, height); setObjectCenter(centerX, centerY); setObjectColor(rgb); setObjectLineType(lineType); setObjectLineWeight(0.35); //TODO: pass in proper lineweight setPen(objectPen()); updatePath(); }
void ObjectEditorWidget::onObjectDataChanged(const QVariantMap & data) { int w=-1, h=-1; mXSpin->blockSignals(true); mYSpin->blockSignals(true); if (data.contains("x") && data.value("x").canConvert(QVariant::Int)) mXSpin->setValue(data.value("x").toInt()); if (data.contains("y") && data.value("y").canConvert(QVariant::Int)) mYSpin->setValue(data.value("y").toInt()); if (data.contains("width") && data.value("width").canConvert(QVariant::String)) w = data.value("width").toInt(); if (data.contains("height") && data.value("height").canConvert(QVariant::String)) h = data.value("height").toInt(); setObjectSize(w, h); mXSpin->blockSignals(false); mYSpin->blockSignals(false); }
void EllipseObject::updateRubber(QPainter* painter) { int rubberMode = objectRubberMode(); if(rubberMode == OBJ_RUBBER_ELLIPSE_LINE) { QPointF sceneLinePoint1 = objectRubberPoint("ELLIPSE_LINE_POINT1"); QPointF sceneLinePoint2 = objectRubberPoint("ELLIPSE_LINE_POINT2"); QPointF itemLinePoint1 = mapFromScene(sceneLinePoint1); QPointF itemLinePoint2 = mapFromScene(sceneLinePoint2); QLineF itemLine(itemLinePoint1, itemLinePoint2); if(painter) painter->drawLine(itemLine); updatePath(); } else if(rubberMode == OBJ_RUBBER_ELLIPSE_MAJORDIAMETER_MINORRADIUS) { QPointF sceneAxis1Point1 = objectRubberPoint("ELLIPSE_AXIS1_POINT1"); QPointF sceneAxis1Point2 = objectRubberPoint("ELLIPSE_AXIS1_POINT2"); QPointF sceneCenterPoint = objectRubberPoint("ELLIPSE_CENTER"); QPointF sceneAxis2Point2 = objectRubberPoint("ELLIPSE_AXIS2_POINT2"); qreal ellipseWidth = objectRubberPoint("ELLIPSE_WIDTH").x(); qreal ellipseRot = objectRubberPoint("ELLIPSE_ROT").x(); //TODO: incorporate perpendicularDistance() into libcgeometry qreal px = sceneAxis2Point2.x(); qreal py = sceneAxis2Point2.y(); qreal x1 = sceneAxis1Point1.x(); qreal y1 = sceneAxis1Point1.y(); QLineF line(sceneAxis1Point1, sceneAxis1Point2); QLineF norm = line.normalVector(); qreal dx = px-x1; qreal dy = py-y1; norm.translate(dx, dy); QPointF iPoint; norm.intersect(line, &iPoint); qreal ellipseHeight = QLineF(px, py, iPoint.x(), iPoint.y()).length()*2.0; setObjectCenter(sceneCenterPoint); setObjectSize(ellipseWidth, ellipseHeight); setRotation(-ellipseRot); QPointF itemCenterPoint = mapFromScene(sceneCenterPoint); QPointF itemAxis2Point2 = mapFromScene(sceneAxis2Point2); QLineF itemLine(itemCenterPoint, itemAxis2Point2); if(painter) painter->drawLine(itemLine); updatePath(); } else if(rubberMode == OBJ_RUBBER_ELLIPSE_MAJORRADIUS_MINORRADIUS) { QPointF sceneAxis1Point2 = objectRubberPoint("ELLIPSE_AXIS1_POINT2"); QPointF sceneCenterPoint = objectRubberPoint("ELLIPSE_CENTER"); QPointF sceneAxis2Point2 = objectRubberPoint("ELLIPSE_AXIS2_POINT2"); qreal ellipseWidth = objectRubberPoint("ELLIPSE_WIDTH").x(); qreal ellipseRot = objectRubberPoint("ELLIPSE_ROT").x(); //TODO: incorporate perpendicularDistance() into libcgeometry qreal px = sceneAxis2Point2.x(); qreal py = sceneAxis2Point2.y(); qreal x1 = sceneCenterPoint.x(); qreal y1 = sceneCenterPoint.y(); QLineF line(sceneCenterPoint, sceneAxis1Point2); QLineF norm = line.normalVector(); qreal dx = px-x1; qreal dy = py-y1; norm.translate(dx, dy); QPointF iPoint; norm.intersect(line, &iPoint); qreal ellipseHeight = QLineF(px, py, iPoint.x(), iPoint.y()).length()*2.0; setObjectCenter(sceneCenterPoint); setObjectSize(ellipseWidth, ellipseHeight); setRotation(-ellipseRot); QPointF itemCenterPoint = mapFromScene(sceneCenterPoint); QPointF itemAxis2Point2 = mapFromScene(sceneAxis2Point2); QLineF itemLine(itemCenterPoint, itemAxis2Point2); if(painter) painter->drawLine(itemLine); updatePath(); } }