GraphicObject* GraphicUndoUtilities::getObject(const GraphicGroup* pGroup, const string& objectId) { if ((pGroup == NULL) || (objectId.empty() == true)) { return NULL; } const list<GraphicObject*>& objects = pGroup->getObjects(); for (list<GraphicObject*>::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) { GraphicObject* pObject = *iter; if (pObject != NULL) { if (pObject->getId() == objectId) { return pObject; } } GraphicGroup* pChildGroup = dynamic_cast<GraphicGroup*>(*iter); if (pChildGroup != NULL) { GraphicObject* pGroupObject = getObject(pChildGroup, objectId); if (pGroupObject != NULL) { return pGroupObject; } } } return NULL; }
void GroupUngroupGraphicObjects::ungroup() { GraphicLayer* pLayer = dynamic_cast<GraphicLayer*>(getSessionItem()); if ((pLayer != NULL) && (mGroupId.empty() == false)) { string viewId; View* pView = pLayer->getView(); if (pView != NULL) { viewId = pView->getId(); } GraphicGroup* pGroup = dynamic_cast<GraphicGroup*>(GraphicUndoUtilities::getObject(viewId, pLayer->getId(), mGroupId)); if (pGroup != NULL) { list<GraphicObject*> selectedObjects; pLayer->getSelectedObjects(selectedObjects); pLayer->deselectAllObjects(); pLayer->selectObject(pGroup); pLayer->ungroupSelection(); list<GraphicObject*> objects; pLayer->getSelectedObjects(objects); mObjectIds.clear(); for (list<GraphicObject*>::iterator iter = objects.begin(); iter != objects.end(); ++iter) { GraphicObject* pObject = *iter; if (pObject != NULL) { string objectId = pObject->getId(); if (objectId.empty() == false) { mObjectIds.push_back(objectId); } } } for (list<GraphicObject*>::iterator iter = selectedObjects.begin(); iter != selectedObjects.end(); ++iter) { GraphicObject* pObject = *iter; if ((pObject != NULL) && (pObject != pGroup)) { pLayer->selectObject(pObject); } } } } }
int ShapeFile::getAttributeIndex(const GraphicObject& graphicObject, const DynamicObject& dynObj) const { const string objectId = graphicObject.getId(); VERIFYRV(objectId.empty() == false, -1); DataVariant idsVar = dynObj.getAttribute(graphicObjectIdAttrName); vector<string> objectIds; idsVar.getValue(objectIds); for (vector<string>::size_type i = 0; i < objectIds.size(); ++i) { if (objectIds[i] == objectId) { return static_cast<int>(i); } } return -1; }
void CreateDestroyGraphicObject::createObject() { if (mpClone == NULL) { return; } GraphicGroup* pGroup = dynamic_cast<GraphicGroup*>(getSessionItem()); if (pGroup != NULL) { string oldObjectId = mObjectId; mObjectId.clear(); GraphicObject* pObject = pGroup->addObject(mpClone->getGraphicObjectType()); if (pObject != NULL) { mObjectId = pObject->getId(); GraphicObjectImp* pObjectImp = dynamic_cast<GraphicObjectImp*>(pObject); if (pObjectImp != NULL) { pObjectImp->replicateObject(dynamic_cast<GraphicObject*>(mpClone)); } if (mIndex != -1) { GraphicGroupImp* pGroupImp = dynamic_cast<GraphicGroupImp*>(pGroup); if (pGroupImp != NULL) { GraphicLayerImp* pLayer = dynamic_cast<GraphicLayerImp*>(pGroupImp->getLayer()); if (pLayer != NULL) { pLayer->setObjectStackingIndex(pObject, mIndex); } } } } emit sessionItemChanged(oldObjectId, mObjectId); } }
GroupUngroupGraphicObjects::GroupUngroupGraphicObjects(GraphicLayer* pLayer, GraphicGroup* pGroup) : UndoAction(pLayer) { if (pGroup != NULL) { const list<GraphicObject*>& objects = pGroup->getObjects(); for (list<GraphicObject*>::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) { GraphicObject* pObject = *iter; if (pObject != NULL) { string objectId = pObject->getId(); if (objectId.empty() == false) { mObjectIds.push_back(objectId); } } } mGroupId = pGroup->getId(); } }