本文整理汇总了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());
}
示例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());
}
示例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();
}
示例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)
}
}
示例5: foreach
foreach(QGraphicsItem* grItem, childItems())
{
if (SCgObject::isSCgObjectType(grItem->type()))
{
SCgObject *scgObject = static_cast<SCgObject*>(grItem);
if(!scgObject->isDead())
scgObject->del(delList);
}
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
}
}
示例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();
}
}
}
}
示例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());
}
示例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();
}
示例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();
}
}
示例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);
}