AddVertices::AddVertices(MultipointObjectImp* pObject, const vector<LocationType>& oldVertices, const vector<LocationType>& oldGeoVertices, const vector<LocationType>& newVertices, const vector<LocationType>& newGeoVertices) : UndoAction(dynamic_cast<SessionItem*>(pObject)), mOldVertices(oldVertices), mOldGeoVertices(oldGeoVertices), mNewVertices(newVertices), mNewGeoVertices(newGeoVertices) { if (pObject != NULL) { GraphicLayer* pLayer = pObject->getLayer(); if (pLayer != NULL) { View* pView = pLayer->getView(); if (pView != NULL) { mViewId = pView->getId(); } mLayerId = pLayer->getId(); } } setText("Add Vertices"); }
void GroupUngroupGraphicObjects::group() { GraphicLayer* pLayer = dynamic_cast<GraphicLayer*>(getSessionItem()); if (pLayer != NULL) { list<GraphicObject*> selectedObjects; pLayer->getSelectedObjects(selectedObjects); pLayer->deselectAllObjects(); for (list<string>::const_iterator iter = mObjectIds.begin(); iter != mObjectIds.end(); ++iter) { string objectId = *iter; if (objectId.empty() == false) { string viewId; View* pView = pLayer->getView(); if (pView != NULL) { viewId = pView->getId(); } GraphicObject* pObject = GraphicUndoUtilities::getObject(viewId, pLayer->getId(), objectId); if (pObject != NULL) { pLayer->selectObject(pObject); } } } pLayer->groupSelection(); list<GraphicObject*> newSelectedObjects; pLayer->getSelectedObjects(newSelectedObjects); VERIFYNRV(newSelectedObjects.size() == 1); GraphicGroup* pGroup = dynamic_cast<GraphicGroup*>(newSelectedObjects.front()); VERIFYNRV(pGroup != NULL); for (list<GraphicObject*>::iterator iter = selectedObjects.begin(); iter != selectedObjects.end(); ++iter) { GraphicObject* pObject = *iter; if ((pObject != NULL) && (pGroup->hasObject(pObject) == false)) { pLayer->selectObject(pObject); } } string oldGroupId = mGroupId; mGroupId = pGroup->getId(); emit sessionItemChanged(oldGroupId, mGroupId); } }
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); } } } } }
NewPath::NewPath(PolylineObjectImp* pObject, unsigned int path) : UndoAction(dynamic_cast<SessionItem*>(pObject)), mPath(path) { if (pObject != NULL) { GraphicLayer* pLayer = pObject->getLayer(); if (pLayer != NULL) { View* pView = pLayer->getView(); if (pView != NULL) { mViewId = pView->getId(); } mLayerId = pLayer->getId(); } } setText("New Path"); }
SetGraphicObjectName::SetGraphicObjectName(GraphicObject *pObject, const string &oldName, const string &newName) : UndoAction(pObject), mOldName(oldName), mNewName(newName) { GraphicObjectImp* pObjectImp = dynamic_cast<GraphicObjectImp*>(pObject); if (pObjectImp != NULL) { GraphicLayer* pLayer = pObjectImp->getLayer(); if (pLayer != NULL) { View* pView = pLayer->getView(); if (pView != NULL) { mViewId = pView->getId(); } mLayerId = pLayer->getId(); } } setText("Rename Graphic Object"); }
SetGraphicObjectProperty::SetGraphicObjectProperty(GraphicObject* pObject, const GraphicProperty* pOldProperty, const GraphicProperty* pNewProperty) : UndoAction(pObject), mpOldProperty(NULL), mpNewProperty(NULL) { GraphicObjectImp* pObjectImp = dynamic_cast<GraphicObjectImp*>(pObject); if (pObjectImp != NULL) { GraphicLayer* pLayer = pObjectImp->getLayer(); if (pLayer != NULL) { View* pView = pLayer->getView(); if (pView != NULL) { mViewId = pView->getId(); } mLayerId = pLayer->getId(); } } QString actionText = "Set Object Property"; if ((pOldProperty != NULL) && (pNewProperty != NULL)) { string oldName = pOldProperty->getName(); string newName = pNewProperty->getName(); if (oldName == newName) { actionText = "Set Object " + QString::fromStdString(oldName); mpOldProperty = pOldProperty->copy(); mpNewProperty = pNewProperty->copy(); } } setText(actionText); }