Exemplo n.º 1
0
QSizeF DiagramItem::calcMinimumGeometry() const
{
    double width = MINIMUM_WIDTH;
    double height = 0.0;

    if (m_customIcon) {
        return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(),
                                         CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
    }

    height += BODY_VERT_BORDER;
    if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
        width = std::max(width, stereotypeIconItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
        height += std::max(FOLD_HEIGHT, stereotypeIconItem->boundingRect().height());
    } else {
        height += FOLD_HEIGHT;
    }
    if (StereotypesItem *stereotypesItem = this->stereotypesItem()) {
        width = std::max(width, stereotypesItem->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
        height += stereotypesItem->boundingRect().height();
    }
    if (nameItem()) {
        width = std::max(width, nameItem()->boundingRect().width() + 2 * BODY_HORIZ_BORDER);
        height += nameItem()->boundingRect().height();
    }
    height += BODY_VERT_BORDER;

    return GeometryUtilities::ensureMinimumRasterSize(QSizeF(width, height), 2 * RASTER_WIDTH, 2 * RASTER_HEIGHT);
}
Exemplo n.º 2
0
QSizeF ItemItem::calcMinimumGeometry() const
{
    double width = 0.0;
    double height = 0.0;

    if (m_customIcon) {
        QSizeF sz = stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(),
                                              CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT);
        if (shapeIcon().textAlignment() != qmt::StereotypeIcon::TextalignTop
                  && shapeIcon().textAlignment() != qmt::StereotypeIcon::TextalignCenter)
            return sz;
        width = sz.width();
    }

    height += BODY_VERT_BORDER;
    if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
        width = std::max(width, stereotypeIconItem->boundingRect().width());
        height += stereotypeIconItem->boundingRect().height();
    }
    if (StereotypesItem *stereotypesItem = this->stereotypesItem()) {
        width = std::max(width, stereotypesItem->boundingRect().width());
        height += stereotypesItem->boundingRect().height();
    }
    if (nameItem()) {
        width = std::max(width, nameItem()->boundingRect().width());
        height += nameItem()->boundingRect().height();
    }
    if (m_contextLabel)
        height += m_contextLabel->height();
    height += BODY_VERT_BORDER;

    width = BODY_HORIZ_BORDER + width + BODY_HORIZ_BORDER;

    return GeometryUtilities::ensureMinimumRasterSize(QSizeF(width, height), 2 * RASTER_WIDTH, 2 * RASTER_HEIGHT);
}
Exemplo n.º 3
0
void ImageCollection::layoutImmCollapsed()
{
    tl.complete();

    _collapseLayer.moveToParent(&_iconItem);
    QPoint p = collapsePoint();

    for(int ii = 0; ii < count(); ++ii) {

        Image *img = image(ii);
        img->imageParent().setValue(0.);
        img->moveToParent(iconItem());

#define PHOTO_OFFSET 7
        switch(ii) {
            case 0:
                img->x().setValue( p.x() - PHOTO_OFFSET);
                img->y().setValue( p.y() - PHOTO_OFFSET);
                img->quality().setValue( 1.);
                img->visible().setValue( 1.);
                break;
            case 1:
                img->x().setValue( p.x() + PHOTO_OFFSET);
                img->y().setValue( p.y() - PHOTO_OFFSET);
                img->quality().setValue( 1.);
                img->visible().setValue( 1.);
                break;
            case 2:
                img->x().setValue( p.x() + PHOTO_OFFSET);
                img->y().setValue( p.y() + PHOTO_OFFSET);
                img->quality().setValue( 1.);
                img->visible().setValue( 1.);
                break;
            case 3:
                img->x().setValue( p.x() - PHOTO_OFFSET);
                img->y().setValue( p.y() + PHOTO_OFFSET);
                img->quality().setValue( 1.);
                img->visible().setValue( 1.);
                break;
            default:
                img->x().setValue( p.x());
                img->y().setValue( p.y());
                img->visible().setValue( 0.);
                break;
        }
        img->imageParent().setValue(1.);
        img->scale().setValue( SMALL_ZOOM * .7);

        int rotate = (qrand() % 40) - 20;
        img->rotate().setValue(rotate);
        img->imageParent().setValue(1.);
    } 
    GfxCanvasItem *i = nameItem();
    i->visible().setValue(1.);
}
Exemplo n.º 4
0
void ImageCollection::layoutExpanded()
{
    tl.complete();

    _collapseLayer.moveToParent(&_listItem);
    _collapseLayer.z().setValue(1.);
    GfxCanvasItem *i = nameItem(false);
    if(i) i->visible().setValue(0.);
    int pauses = 0;

    int f = focused();
    for(int ii = count() - 1; ii >= 0; --ii) {

        Image *img = image(ii);

        if(!isOnScreen(ii)) {
            img->imageParent().setValue(0.);
            img->visible().setValue(1.);
            img->quality().setValue(0.);
            img->x().setValue(0);
            img->y().setValue(0);
            img->scale().setValue( SMALL_ZOOM );
            img->rotate().setValue(0);
        } else {
            int pauseTime = pauses * 50 + 150;
            pauses++;
            tl.pause(img->visible(), pauseTime);
            tl.pause(img->x(), pauseTime);
            tl.pause(img->y(), pauseTime);
            tl.pause(img->rotate(), pauseTime);
            tl.pause(img->scale(), pauseTime);
            tl.pause(img->quality(), pauseTime);
            tl.pause(img->imageParent(), pauseTime);
            tl.set(img->imageParent(), 0.);
            tl.set(img->visible(), 1.);
            tl.set(img->quality(), 0.);
            tl.move(img->x(), 0, 150);
            tl.move(img->y(), 0, 150);

            if(f == ii) {
                tl.move(img->scale(), SMALL_ZOOM, 150);
                tl.sync(img->z(), img->scale());
                tl.set(img->z(), 1.);
                tl.move(img->scale(), ZOOMED_ZOOM, 50);
            } else {
                tl.move(img->scale(), SMALL_ZOOM, 150);
            }
            tl.move(img->rotate(), 0, 150);
        }
    } 
}
Exemplo n.º 5
0
void ImageCollection::layoutTime()
{
    tl.complete();

    // Collapse focus
    if(focused() != -1) {
        Image *foc = image(focused());
        tl.move(foc->scale(), SMALL_ZOOM, 50);
    }
    tl.sync();
    int seen = 0;
    for(int ii = 0; ii < count(); ++ii) {
        Image *img = image(ii);

        if(!isOnScreen(ii)) {
            img->imageParent().setValue(2.);
            img->visible().setValue(0.);
            img->scale().setValue(SMALL_ZOOM);
        } else {
            if(!seen) {
                QPoint p = img->mapTo(&_timeItem, QPoint(0, 0));
                _subTimeItem.x().setValue(p.x());
                _subTimeItem.y().setValue(p.y());
                tl.move(img->scale(), TIMEVIEW_ZOOM, 200);
                tl.move(_subTimeItem.x(), 0, 200);
                tl.move(_subTimeItem.y(), 0, 200);
            } 

            tl.pause(img->x(), seen * 20);
            tl.pause(img->y(), seen * 20);
            tl.pause(img->imageParent(), seen * 20);
            tl.set(img->imageParent(), 2.);
            tl.move(img->x(), 0, 150);
            tl.move(img->y(), 0, 150);
            if(seen) {
                tl.sync(img->visible(), img->y());
                tl.set(img->visible(), 0.);
            }

            seen++;
        }
    }
    GfxCanvasItem *i = nameItem();
    i->visible().setValue(0.);
}
Exemplo n.º 6
0
		int32 FindString(FArrayHelper* arrayHelper, const TCHAR* item)
		{
			// FString
			if (arrayHelper->GetElementProperty()->IsA<UStrProperty>())
			{
				FString strItem(item);
				return arrayHelper->Find(&strItem);
			}
			// FName
			if (arrayHelper->GetElementProperty()->IsA<UNameProperty>())
			{
				FName nameItem(item);
				return arrayHelper->Find(&nameItem);
			}
			// couldn't convert the string to the array element type
			check(false);
			return INDEX_NONE;
		}
Exemplo n.º 7
0
void ImageCollection::layoutImmExpanded()
{
    tl.complete();

    GfxCanvasItem *i = nameItem(false);
    if(i) i->visible().setValue(0.);
    
    int f = focused();
    for(int ii = 0; ii < count(); ++ii) {
        Image *img = image(ii);
        img->imageParent().setValue(0.);
        img->x().setValue(0);
        img->y().setValue(0);
        img->visible().setValue(1.);

        if(f == ii)
            img->scale().setValue(ZOOMED_ZOOM);
        else
            img->scale().setValue(SMALL_ZOOM);

        img->rotate().setValue(0.);
    }
}
Exemplo n.º 8
0
void ImageCollection::layoutImmTime()
{
    tl.complete();

    for(int ii = 0; ii < count(); ++ii) {

        Image *img = image(ii);
        img->imageParent().setValue(2.);

        img->x().setValue(0);
        img->y().setValue(0);
        img->rotate().setValue(0);

        if(ii) {
            img->visible().setValue(0.);
            img->scale().setValue(SMALL_ZOOM);
        } else {
            img->visible().setValue(1.);
            img->scale().setValue(TIMEVIEW_ZOOM);
        }
    } 
    GfxCanvasItem *i = nameItem();
    i->visible().setValue(0.);
}
Exemplo n.º 9
0
void ImageCollection::layoutCollapsed()
{
    tl.complete();

    _collapseLayer.moveToParent(&_iconItem);

    QPoint p = collapsePoint();

    int seenOnScreen = 0;
    int f = focused();

    _collapseLayer.z().setValue(-10000.);
    for(int ii = count() - 1; ii >= 0; --ii) {

        Image *img = image(ii);
        img->moveToParent(iconItem());

        if(!isOnScreen(ii))
            continue;

        seenOnScreen++;

        int pauseTime = (seenOnScreen - 1) * 50;
        tl.pause(img->x(), pauseTime);
        tl.pause(img->y(), pauseTime);
        tl.pause(img->rotate(), pauseTime);
        img->z().setValue(-ii);

        if(ii == f) {
            tl.move(img->scale(), SMALL_ZOOM, 50);
            tl.sync(img->z(), img->scale());
            img->z().setValue(1);
            tl.set(img->z(), -ii);

            if(pauseTime > 50)
                tl.pause(img->scale(), pauseTime - 50);
        } else {
            tl.pause(img->scale(), pauseTime);
        }
    }
    seenOnScreen = 0;
    for(int ii = 0; ii < count(); ++ii) {
        if(!isOnScreen(ii))
            continue;
        seenOnScreen++;

        Image *img = image(ii);

#define PHOTO_OFFSET 7
        int idx = seenOnScreen;
        switch(idx) {
            case 0:
                tl.move(img->x(), p.x() - PHOTO_OFFSET, 150);
                tl.move(img->y(), p.y() - PHOTO_OFFSET, 150);
                tl.sync(img->quality(), img->x());
                tl.set(img->quality(), 1.);
                break;
            case 1:
                tl.move(img->x(), p.x() + PHOTO_OFFSET, 150);
                tl.move(img->y(), p.y() - PHOTO_OFFSET, 150);
                tl.sync(img->quality(), img->x());
                tl.set(img->quality(), 1.);
                break;
            case 2:
                tl.move(img->x(), p.x() + PHOTO_OFFSET, 150);
                tl.move(img->y(), p.y() + PHOTO_OFFSET, 150);
                tl.sync(img->quality(), img->x());
                tl.set(img->quality(), 1.);
                break;
            case 3:
                tl.move(img->x(), p.x() - PHOTO_OFFSET, 150);
                tl.move(img->y(), p.y() + PHOTO_OFFSET, 150);
                tl.sync(img->quality(), img->x());
                tl.set(img->quality(), 1.);
                break;
            default:
                tl.move(img->x(), p.x(), 150);
                tl.move(img->y(), p.y(), 150);
                //tl.set(img->quality(), 0.);
                break;
        }
        int rotate = (qrand() % 40) - 20;
        if(isOnScreen(ii)) {
            tl.move(img->scale(), SMALL_ZOOM * .7, 150);
            tl.move(img->rotate(), rotate, 150);
            tl.sync(image(ii)->imageParent(), image(ii)->x());
            tl.set(image(ii)->imageParent(), 1.);
        } else {
            img->scale().setValue(SMALL_ZOOM * .7);
            img->rotate().setValue(rotate);
            img->visible().setValue(0.);
            img->imageParent().setValue(1.);
        }
    } 
    tl.sync();
    seenOnScreen = 0;
    for(int ii = 0; ii < count(); ++ii) {
        if(!isOnScreen(ii))
            continue;
        seenOnScreen++;

        if(seenOnScreen > 4) 
            tl.set(image(ii)->visible(), 0.);
    }
    GfxCanvasItem *i = nameItem();
    tl.move(i->visible(), 1., 300);
}
Exemplo n.º 10
0
void DiagramItem::updateGeometry()
{
    prepareGeometryChange();

    // calc width and height
    double width = 0.0;
    double height = 0.0;

    QSizeF geometry = calcMinimumGeometry();
    width = geometry.width();
    height = geometry.height();

    if (object()->isAutoSized()) {
        if (!m_customIcon) {
            if (width < MINIMUM_AUTO_WIDTH)
                width = MINIMUM_AUTO_WIDTH;
            if (height < MINIMUM_AUTO_HEIGHT)
                height = MINIMUM_AUTO_HEIGHT;
        }
    } else {
        QRectF rect = object()->rect();
        if (rect.width() > width)
            width = rect.width();
        if (rect.height() > height)
            height = rect.height();
    }

    // update sizes and positions
    double left = -width / 2.0;
    double top = -height / 2.0;
    double y = top;

    setPos(object()->pos());

    QRectF rect(left, top, width, height);

    // the object is updated without calling DiagramController intentionally.
    // attribute rect is not a real attribute stored on DObject but
    // a backup for the graphics item used for manual resized and persistency.
    object()->setRect(rect);

    if (m_customIcon) {
        m_customIcon->setPos(left, top);
        m_customIcon->setActualSize(QSizeF(width, height));
        y += height;
    }

    if (m_body) {
        QPolygonF bodyPolygon;
        bodyPolygon
                << rect.topLeft()
                << rect.topRight() + QPointF(-FOLD_WIDTH, 0.0)
                << rect.topRight() + QPointF(0.0, FOLD_HEIGHT)
                << rect.bottomRight()
                << rect.bottomLeft();
        m_body->setPolygon(bodyPolygon);
    }
    if (m_fold) {
        QPolygonF foldPolygon;
        foldPolygon
                << rect.topRight() + QPointF(-FOLD_WIDTH, 0.0)
                << rect.topRight() + QPointF(0.0, FOLD_HEIGHT)
                << rect.topRight() + QPointF(-FOLD_WIDTH, FOLD_HEIGHT);
        m_fold->setPolygon(foldPolygon);
    }

    y += BODY_VERT_BORDER;
    if (!m_customIcon) {
        if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
            stereotypeIconItem->setPos(left + BODY_HORIZ_BORDER, y);
            y += std::max(FOLD_HEIGHT, stereotypeIconItem->boundingRect().height());
        } else {
            y += FOLD_HEIGHT;
        }
    }
    if (StereotypesItem *stereotypesItem = this->stereotypesItem()) {
        stereotypesItem->setPos(-stereotypesItem->boundingRect().width() / 2.0, y);
        y += stereotypesItem->boundingRect().height();
    }
    if (nameItem()) {
        nameItem()->setPos(-nameItem()->boundingRect().width() / 2.0, y);
        y += nameItem()->boundingRect().height();
    }

    updateSelectionMarkerGeometry(rect);
    updateAlignmentButtonsGeometry(rect);
    updateDepth();
}
Exemplo n.º 11
0
void ItemItem::updateGeometry()
{
    prepareGeometryChange();

    // calc width and height
    double width = 0.0;
    double height = 0.0;

    QSizeF geometry = calcMinimumGeometry();
    width = geometry.width();
    height = geometry.height();

    if (object()->isAutoSized()) {
        // nothing
    } else {
        QRectF rect = object()->rect();
        if (rect.width() > width)
            width = rect.width();
        if (rect.height() > height)
            height = rect.height();
    }

    // update sizes and positions
    double left = -width / 2.0;
    double right = width / 2.0;
    double top = -height / 2.0;
    double y = top;

    setPos(object()->pos());

    QRectF rect(left, top, width, height);

    // the object is updated without calling DiagramController intentionally.
    // attribute rect is not a real attribute stored on DObject but
    // a backup for the graphics item used for manual resized and persistency.
    object()->setRect(rect);

    if (m_customIcon) {
        m_customIcon->setPos(left, top);
        m_customIcon->setActualSize(QSizeF(width, height));
    }

    if (m_shape)
        m_shape->setRect(rect);

    if (m_customIcon) {
        switch (shapeIcon().textAlignment()) {
        case qmt::StereotypeIcon::TextalignBelow:
            y += height + BODY_VERT_BORDER;
            break;
        case qmt::StereotypeIcon::TextalignCenter:
        {
            double h = 0.0;
            if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem())
                h += stereotypeIconItem->boundingRect().height();
            if (StereotypesItem *stereotypesItem = this->stereotypesItem())
                h += stereotypesItem->boundingRect().height();
            if (nameItem())
                h += nameItem()->boundingRect().height();
            if (m_contextLabel)
                h += m_contextLabel->height();
            y = top + (height - h) / 2.0;
            break;
        }
        case qmt::StereotypeIcon::TextalignNone:
            // nothing to do
            break;
        case qmt::StereotypeIcon::TextalignTop:
            y += BODY_VERT_BORDER;
            break;
        }
    } else {
        y += BODY_VERT_BORDER;
    }
    if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) {
        stereotypeIconItem->setPos(right - stereotypeIconItem->boundingRect().width() - BODY_HORIZ_BORDER, y);
        y += stereotypeIconItem->boundingRect().height();
    }
    if (StereotypesItem *stereotypesItem = this->stereotypesItem()) {
        stereotypesItem->setPos(-stereotypesItem->boundingRect().width() / 2.0, y);
        y += stereotypesItem->boundingRect().height();
    }
    if (nameItem()) {
        nameItem()->setPos(-nameItem()->boundingRect().width() / 2.0, y);
        y += nameItem()->boundingRect().height();
    }
    if (m_contextLabel) {
        if (m_customIcon) {
            m_contextLabel->resetMaxWidth();
        } else {
            double maxContextWidth = width - 2 * BODY_HORIZ_BORDER;
            m_contextLabel->setMaxWidth(maxContextWidth);
        }
        m_contextLabel->setPos(-m_contextLabel->boundingRect().width() / 2.0, y);
    }

    updateSelectionMarkerGeometry(rect);
    updateRelationStarterGeometry(rect);
    updateAlignmentButtonsGeometry(rect);
    updateDepth();
}