当前位置: 首页>>代码示例>>C++>>正文


C++ SCgObject类代码示例

本文整理汇总了C++中SCgObject的典型用法代码示例。如果您正苦于以下问题:C++ SCgObject类的具体用法?C++ SCgObject怎么用?C++ SCgObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SCgObject类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mapToScene

void SCgView::contextMenuEvent(QContextMenuEvent *event)
{
    if (event->reason() == QContextMenuEvent::Keyboard || event->reason() == QContextMenuEvent::Other)
        return;
    // get scg-object under mouse
    QPointF mousePos = mapToScene(event->pos());/* +
                                QPointF(horizontalScrollBar()->value(), verticalScrollBar()->value()) -
                                scene()->sceneRect().topLeft();*/

    SCgObject *object = static_cast<SCgScene*>(scene())->objectAt(mousePos);

    // create context menu
    if (mContextMenu)
    {
        delete mContextMenu;
        mContextMenu = 0;
    }

    // selection by right mouse click
    if(object && !object->isSelected())
    {
        scene()->clearSelection();
        object->setSelected(true);
    }

    // create new context menu
    mContextMenu = new QMenu;
    mContextMenu->addActions(mActionsList);

    mContextMenu->exec(event->globalPos());
}
开发者ID:deniskoronchik,项目名称:kbe,代码行数:31,代码来源:scgview.cpp

示例2: Q_ASSERT

void SCgTupleArranger::startOperation()
{
    // affect changes to bus
    SCgBus *bus = mTupleNode->bus();
    Q_ASSERT(bus != 0);
    SCgBus *ghostBus = qgraphicsitem_cast<SCgBus*>(mGhosts[bus]);
    Q_ASSERT(ghostBus != 0);

    // map points into bus coordinates
    registerCommand(bus, ghostBus->points());

    // affect pairs and objects
    foreach(SCgPair *pair, mBusPairs)
    {
        SCgObject *end = pair->endObject();
        SCgObject *beg = pair->beginObject();
        Q_ASSERT(end != 0 && beg != 0);
        SCgPair *ghostPair = qgraphicsitem_cast<SCgPair*>(mGhosts[pair]);
        Q_ASSERT(ghostPair != 0);

        registerCommand(pair, ghostPair->points());

        if (beg->type() == SCgBus::Type)
            registerCommand(end, mGhosts[end]->pos());
        else
            registerCommand(beg, mGhosts[beg]->pos());
    }
开发者ID:AlexKlybik,项目名称:kbe,代码行数:27,代码来源:scgarrangertuple.cpp

示例3: writeStartElement

void GwfStreamWriter::writePair(SCgObject *obj)
{
    QString type = mTypeAlias2GWFType[obj->typeAlias()].mid(0,3);
    if(type=="arc")
        writeStartElement(type);
    else
        writeStartElement("pair");
    writeObjectAttributes(obj);
    SCgPair* pair = static_cast<SCgPair*>(obj);
    SCgObject* b = pair->getBeginObject();
    SCgObject* e = pair->getEndObject();
    writeAttribute("id_b", QString::number(b->id()));
    writeAttribute("id_e", QString::number(e->id()));

    writePosition(b,"b_x","b_y");
    writePosition(e,"e_x","e_y");

    writeAttribute("dotBBalance", QString::number(pair->getBeginDot()));
    writeAttribute("dotEBalance", QString::number(pair->getEndDot()));
    QVector<QPointF> points = pair->scenePoints();
    points.pop_back();
    points.pop_front();
    writePoints(points);
    writeEndElement();
}
开发者ID:SadTigger,项目名称:kbe,代码行数:25,代码来源:gwfstreamwriter.cpp

示例4: startLineCreation

void SCgPairModeEventHandler::mousePress(QGraphicsSceneMouseEvent *event)
{
    SCgEventHandler::mousePress(event);
    if (event->button() == Qt::LeftButton)
    {
        QPointF mousePos = event->scenePos();

        SCgObject *obj = mScene->objectAt(mousePos);
        // if we not create pair yet and press on scg-object, then
        // start pair creation
        if (obj && !mPathItem)
            startLineCreation(mousePos);
        else
        if (obj && obj != mPathItem->parentItem())
        {
            SCgObject *begObj = mObjectAtFirstPoint;
            SCgObject *endObj = obj;

            // do not create lines with equivalent begin end end object
            if (begObj != endObj && begObj && !begObj->isDead())
            {
                SCgContour* c=0;
                // get parent contour
                QGraphicsItem* parent = begObj->parentItem();
                if(parent && parent == endObj->parentItem())
                    if (parent->type() == SCgContour::Type)
                        c = static_cast<SCgContour*>(parent);

                mScene->createPairCommand(mLinePoints, begObj, endObj, c);
            }

            endLineCreation();
        } // if (obj)
    }
}
开发者ID:DavidBermuda,项目名称:kbe,代码行数:35,代码来源:SCgPairModeEventHandler.cpp

示例5: foreach

 foreach(QGraphicsItem* grItem, childItems())
 {
     if (SCgObject::isSCgObjectType(grItem->type()))
     {
         SCgObject *scgObject = static_cast<SCgObject*>(grItem);
         if(!scgObject->isDead())
             scgObject->del(delList);
     }
 }
开发者ID:FilatovEvgeniy,项目名称:kbe,代码行数:9,代码来源:scgcontour.cpp

示例6: foreach

void DefaultSCgObjectBuilder::buildObjects(const AbstractSCgObjectBuilder::TypeToObjectsMap& objects)
{
    SCgObjectInfo* info;
    // parse nodes
    foreach(info, objects[SCgNode::Type])
        buildNode(static_cast<SCgNodeInfo*>(info));
    // parse pairs
    foreach(info, objects[SCgPair::Type])
        buildPair(static_cast<SCgPairInfo*>(info));
    // parse buses
    foreach(info, objects[SCgBus::Type])
        buildBus(static_cast<SCgBusInfo*>(info));
    // parse contours
    foreach(info, objects[SCgContour::Type])
        buildContour(static_cast<SCgContourInfo*>(info));

    // set parents relation
    ParentChildMap::iterator parentIt;
    for (parentIt = mParentChild.begin(); parentIt != mParentChild.end(); parentIt++)
    {
        if (!mId2SCgObj.contains(parentIt.value()))
            continue;

        SCgObject *parent = mId2SCgObj[parentIt.value()];
        SCgObject *child = mId2SCgObj[parentIt.key()];

        child->setParentItem(parent);
    }

    // holds true, if there are errors while setting begin and end objects.
    bool isConnectedDuty = false;
    // set begin and end objects for pairs
    foreach(SCgObjectInfo* info, objects[SCgPair::Type])
    {
        SCgPairInfo* pairInfo = static_cast<SCgPairInfo*>(info);
        SCgPair *pair = static_cast<SCgPair*>(mId2SCgObj[pairInfo->id()]);

        // we can't build pair without begin or end objects
        if (!mId2SCgObj.contains(pairInfo->beginObjectId()) ||
            !mId2SCgObj.contains(pairInfo->endObjectId()))
        {
            mErrors.append(QObject::tr("Can't find begin or end object for pair id=\"%1\"")
                                            .arg(pairInfo->id()));
            mId2SCgObj.remove(pairInfo->id());
            isConnectedDuty = true;
            delete pair;
            continue;
        }

        SCgObject *begObject = mId2SCgObj[pairInfo->beginObjectId()];
        SCgObject *endObject = mId2SCgObj[pairInfo->endObjectId()];

        pair->setBeginObject(begObject);
        pair->setEndObject(endObject);
    }
开发者ID:DavidBermuda,项目名称:kbe,代码行数:55,代码来源:scgdefaultobjectbuilder.cpp

示例7: resolveUri

SCgObject* SCgMainWindow::resolveUri(const ScUri &uri)
{
    // trying to find scg-object with uri
    const SCgObject::SCgObjectList& list = SCgObject::objectsByScUri(uri);

    //! TODO: resolve situation with multiply
    if (!list.empty()) return list.front();

    UiRootInterface *root = SCgPlugin::rootInterface();

    ScMemoryInterface *memory = root->scMemory();
    SCgObject *res = 0;

    // get element type and create scg-object
    ScElementType type = memory->get_el_type(uri);

    // create new scg-object
    if (type.check(ScNode))
    {
        // check if it a command
        if (isCommand(uri))
        {
            SCgControl *control = mScene->construction()->createControl();
            res = control;
        }else
        {
            SCgNode *node = mScene->construction()->createNode();
            res = node;
        }
    }else
        if (type.check(ScArcMask))
        {

        }else
            if (type.check(ScLink))
            {

            }

    // setup identifier
    QString idtf_value = root->scHelper()->stringIdtf(uri, root->currentLanguage());
    if (!idtf_value.isEmpty())
        res->setIdentifier(idtf_value);

    if (res != 0)
    {
        res->setUri(uri);
        res->setObjectType(type);
    }



    return res;
}
开发者ID:asvitenkov,项目名称:sui,代码行数:54,代码来源:scgmainwindow.cpp

示例8: mousePress

void SCgInsertMode::mousePress(QGraphicsSceneMouseEvent *event)
{
    SCgMode::mousePress(event);
    if (mInsertedObjectGroup)
    {
        SCgObject* underMouseObj = mScene->objectAt(event->scenePos());
        SCgContour* parent = 0;
        if (underMouseObj && underMouseObj->type() == SCgContour::Type)
            parent = static_cast<SCgContour*>(underMouseObj);
        mScene->pasteCommand(mInsertedObjectGroup->childItems(), parent);
    }
    else
        mScene->setEditMode(mScene->previousMode());
    clean();
}
开发者ID:AlexKlybik,项目名称:kbe,代码行数:15,代码来源:scginsertmode.cpp

示例9: undo

//back
void SCgCommandObjectDelete::undo()
{
    SCgBaseCommand::undo();

    QList<SCgObject*>::iterator it;
    for (it = mDelList.begin(); it != mDelList.end(); ++it)
    {
        SCgObject *object = *it;
        if(!object->parentItem())
        {
            QGraphicsItem *parent = mParents[object];

            object->undel(mScene);

            object->setParentItem(parent);
            object->positionChanged();
        }
    }

}
开发者ID:FilatovEvgeniy,项目名称:kbe,代码行数:21,代码来源:scgcommandobjectdelete.cpp

示例10: mousePress

void SCgBusModeEventHandler::mousePress(QGraphicsSceneMouseEvent *event)
{
    SCgEventHandler::mousePress(event);
    if (event->button() == Qt::LeftButton)
    {
        QPointF mousePos = event->scenePos();

        if (!mPathItem)
        {
            SCgObject *obj = mScene->objectAt(mousePos);
            SCgNode *owner = (obj != 0 && obj->type() == SCgNode::Type) ? static_cast<SCgNode*>(obj) : 0;

            if (owner != 0 && owner->bus())
                QMessageBox::information(0, qAppName(), tr("Node can't have more than one bus!"));
            else
                if(owner)
                    startLineCreation(mousePos);

        }else
        {
            QVector2D vec(*(mLinePoints.end() - 2) - mousePos);
            Q_ASSERT(mObjectAtFirstPoint);
            if (mLinePoints.size() > 2 && vec.length() < 5.f && !mObjectAtFirstPoint->isDead())
            {
                mLinePoints.pop_back();

                SCgContour* contour = 0;
                // get parent contour
                QGraphicsItem* parent = mObjectAtFirstPoint->parentItem();

                if (parent && parent->type() == SCgContour::Type)
                    contour = static_cast<SCgContour*>(parent);

                SCgNode *owner = static_cast<SCgNode*>(mObjectAtFirstPoint);
                mScene->createBusCommand(owner, mLinePoints, contour);
                endLineCreation();
            }
        }
    }
}
开发者ID:DavidBermuda,项目名称:kbe,代码行数:40,代码来源:SCgBusModeEventHandler.cpp

示例11: Q_ASSERT

void SCgTupleArranger::startOperation()
{
    // affect changes to bus
    SCgBus *bus = mTupleNode->bus();
    Q_ASSERT(bus != 0);
    SCgBus *ghostBus = qgraphicsitem_cast<SCgBus*>(mGhosts[bus]);
    Q_ASSERT(ghostBus != 0);

    registerCommand(bus, ghostBus->points());

    // affect pairs and objects
    foreach(SCgPair *pair, mBusPairs)
    {
        SCgObject *end = pair->getEndObject();
        Q_ASSERT(end != 0);
        SCgObject *ghostEnd = mGhosts[end];
        Q_ASSERT(ghostEnd != 0);
        SCgPair *ghostPair = qgraphicsitem_cast<SCgPair*>(mGhosts[pair]);
        Q_ASSERT(ghostPair != 0);

        registerCommand(pair, ghostPair->points());
        registerCommand(end, ghostEnd->pos());
    }
开发者ID:DavidBermuda,项目名称:kbe,代码行数:23,代码来源:scgarrangertuple.cpp

示例12: redo

void SCgCommandObjectDelete::redo()
{
    mDelList.clear();
    mParents.clear();

    mObject->del(mDelList);

    QList<SCgObject*>::iterator it;
    for (it = mDelList.begin(); it != mDelList.end(); ++it)
    {
        SCgObject *object = *it;
        QGraphicsItem *parent = object->parentItem();

        mParents[object] = parent;

        if(object->scene() == mScene)
        {
            object->setParentItem(0);
            mScene->removeItem(object);
        }
    }

    SCgBaseCommand::redo();
}
开发者ID:FilatovEvgeniy,项目名称:kbe,代码行数:24,代码来源:scgcommandobjectdelete.cpp

示例13: mapToScene

void SCgView::contextMenuEvent(QContextMenuEvent *event)
{
    if (event->reason() == QContextMenuEvent::Keyboard || event->reason() == QContextMenuEvent::Other)
        return;
    // get scg-object under mouse
    QPointF mousePos = mapToScene(event->pos());/* +
                                QPointF(horizontalScrollBar()->value(), verticalScrollBar()->value()) -
                                scene()->sceneRect().topLeft();*/

    SCgObject *object = static_cast<SCgScene*>(scene())->objectAt(mousePos);

    // create context menu
    if (mContextMenu)
    {
        delete mContextMenu;
        mContextMenu = 0;
    }

    // selection by right mouse click
    if(object && !object->isSelected())
    {
        scene()->clearSelection();
        object->setSelected(true);
    }

    // create new context menu
    mContextMenu = new QMenu;

    if (mContextObject)
    {
        // creating menu actions depending on object type
        if (mContextObject->type() == SCgNode::Type || mContextObject->type() == SCgPair::Type)
        {
            // type changing
            QMenu *menu = mContextMenu->addMenu(tr("Change type"));

            connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(changeType(QAction*)));

            QMenu* constSub = menu->addMenu(tr("Const"));
            QMenu* varSub = menu->addMenu(tr("Var"));

            QString stype;
            SCgAlphabet::SCgObjectTypesMap types;
            SCgAlphabet::SCgObjectTypesMap::const_iterator iter;

            if (mContextObject->type() == SCgNode::Type)
                stype = "node";
            else if (mContextObject->type() == SCgPair::Type)
                stype = "pair";

            SCgAlphabet::getInstance().getObjectTypes(stype, SCgAlphabet::Const, types);
            for (iter = types.begin(); iter != types.end(); ++iter)
                constSub->addAction(iter.value(), iter.key())->setData(QVariant(iter.key()));
            types.clear();
            SCgAlphabet::getInstance().getObjectTypes(stype, SCgAlphabet::Var, types);
            for (iter = types.begin(); iter != types.end(); ++iter)
                varSub->addAction(iter.value(), iter.key())->setData(QVariant(iter.key()));
            types.clear();

            SCgAlphabet::getInstance().getObjectTypes(stype, SCgAlphabet::ConstUnknown, types);
            for (iter = types.begin(); iter != types.end(); ++iter)
                menu->addAction(iter.value(), iter.key())->setData(QVariant(iter.key()));
            types.clear();
        }
    }
开发者ID:pkkazantsev,项目名称:kbe,代码行数:65,代码来源:scgview.cpp

示例14: endPairCreation

void SCgModePair::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent, bool afterSceneEvent )
{
    if(afterSceneEvent)
    {
        if(mDecoratedMode)
            mDecoratedMode->mousePressEvent(mouseEvent, afterSceneEvent);
        return;
    }

    if (mPathItem)
    {
        mouseEvent->accept();
        QPointF mousePos = mouseEvent->scenePos();

        if (mouseEvent->button() == Qt::LeftButton)
            mPathItem->pushPoint(mousePos);

        if (mouseEvent->button() == Qt::RightButton)
        {
            mPathItem->popPoint();
            // If there is no more points
            if (mPathItem->points().isEmpty())
                endPairCreation(false);
        }
    }

    if (mouseEvent->button() == Qt::LeftButton)
    {
        QPointF mousePos = mouseEvent->scenePos();

        SCgVisualObject *obj = scene()->scgVisualObjectAt(mousePos);
        // if we have not createed pair yet and press on scg-object, then
        // start pair creation
        if (obj && !mPathItem)
        {
            mouseEvent->accept();
            startPairCreation(obj, mousePos);
            return;
        }

        if (obj && obj != mObjectAtFirstPoint->parentItem())
        {
            mouseEvent->accept();

            SCgVisualObject *begObj = mObjectAtFirstPoint;
            SCgVisualObject *endObj = obj;
            bool success = begObj != endObj && begObj;

            // do not create lines with equivalent begin end end object
            if (success)
            {
                SCgContour* c=0;
                // get parent contour
                SCgObject* parent = begObj->baseObject()->parentObject();
                if(parent && parent == endObj->baseObject()->parentObject())
                    if (parent->type() == SCgObject::Contour)
                        c = static_cast<SCgContour*>(parent);

                scene()->pushCommand(new SCgCommandCreatePair(scene(), mPathItem->points(),
                                                                    begObj->baseObject(),
                                                                    endObj->baseObject(), c));
            }

            endPairCreation(success);

            return;
        } // if (obj && obj != mObjectAtFirstPoint->parentItem())
    } // if (mouseEvent->button() == Qt::LeftButton)

    mPassMouseReleaseEvent = true;
    if (mDecoratedMode)
        mDecoratedMode->mousePressEvent(mouseEvent, afterSceneEvent);
}
开发者ID:mcdir,项目名称:sui,代码行数:73,代码来源:scgmodepair.cpp


注:本文中的SCgObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。