void ASI::EmitTo(CRef& cref, int receiver, DRef& data, bool release) { Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { pComponent->PostToReceiver(receiver, data, release); cref.ReleaseInstance(); } }
void ASI::DisconnectFromReceiver(CRef& src, int emitter, CRef& target) { Component* pComponent = src.GetInstance(); if (pComponent != NULL) { pComponent->DisconnectFromReceiver(emitter, target); src.ReleaseInstance(); } }
void ASI::SetFlag(CRef& cref, ComponentFlag flag, bool enabled) { Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { pComponent->SetFlag(flag, enabled); cref.ReleaseInstance(); } }
void ASI::RemoveFromLayout(CRef& cref, CRef& layout) { Component* pLayoutComponent = layout.GetInstance(); if (pLayoutComponent != NULL) { int funcSet = pLayoutComponent->GetFuncSet("{f742f223-bb7b-48f0-92a8-81702e14de16}"); int emitter = pLayoutComponent->GetEmitter("{b11a0db4-cb96-4bf6-9631-fd96f20ea6ab}"); int receiver = pLayoutComponent->GetReceiver("{6a7ab00f-1ab4-4324-9eb4-e614bfca4a16}"); if ((funcSet != -1) && (emitter != -1) && (receiver != -1)) { Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { if (pComponent->m_pData->inLayout && IsParent(pLayoutComponent, pComponent)) { /* * Tell the layout component to remove * the item with the given CRef id. */ DRef dref = NewData(BOI_STD_D(Int)); *dref.GetWriteInstance<int>() = cref.Id(); pLayoutComponent->CallFunc(funcSet, 2, dref, true); DisconnectFromReceiver(pLayoutComponent, emitter, cref); DisconnectFromReceiver(pComponent, BOI_STD_E(ParentBoundingBox), layout); pComponent->m_pData->inLayout = false; CRef invalidCRef; pComponent->SetParent(invalidCRef); } cref.ReleaseInstance(); } } layout.ReleaseInstance(); } }
void ASI::AddToLayout(CRef& cref, CRef& layout) { Component* pLayoutComponent = layout.GetInstance(); if (pLayoutComponent != NULL) { int funcSet = pLayoutComponent->GetFuncSet("{f742f223-bb7b-48f0-92a8-81702e14de16}"); int emitter = pLayoutComponent->GetEmitter("{b11a0db4-cb96-4bf6-9631-fd96f20ea6ab}"); int receiver = pLayoutComponent->GetReceiver("{6a7ab00f-1ab4-4324-9eb4-e614bfca4a16}"); if ((funcSet != -1) && (emitter != -1) && (receiver != -1)) { Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { if ((!pComponent->m_pData->inLayout) && (pComponent != pLayoutComponent)) { pComponent->SetParent(layout); /* * Tell the layout component to add * a new item with the given CRef id. */ DRef dref = NewData(BOI_STD_D(Int)); *dref.GetWriteInstance<int>() = cref.Id(); pLayoutComponent->CallFunc(funcSet, 1, dref, true); ConnectToReceiver(pLayoutComponent, emitter, cref, BOI_STD_R(SetPosition)); ConnectToReceiver(pComponent, BOI_STD_E(ParentBoundingBox), layout, receiver); pComponent->m_pData->inLayout = true; } cref.ReleaseInstance(); } } layout.ReleaseInstance(); } }
bool ASI::ConnectToReceiver(CRef src, int emitter, CRef target, int receiver) { bool connected = false; Component* pComponent = src.GetInstance(); if (pComponent != NULL) { connected = pComponent->ConnectToReceiver(emitter, target, receiver); src.ReleaseInstance(); } return connected; }
bool ASI::ConnectToFuncSet(CRef src, int caller, CRef target, int funcSet) { bool connected = false; Component* pComponent = src.GetInstance(); if (pComponent != NULL) { connected = pComponent->ConnectToFuncSet(caller, target, funcSet); src.ReleaseInstance(); } return connected; }
int ASI::GetReceiver(CRef& cref, const QString& uuid) { int receiver = -1; Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { receiver = pComponent->GetReceiver(uuid); cref.ReleaseInstance(); } return receiver; }
int ASI::GetFuncSet(CRef& cref, const QString& uuid) { int funcSet = -1; Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { funcSet = pComponent->GetFuncSet(uuid); cref.ReleaseInstance(); } return funcSet; }
void ASI::SetParent(CRef& cref, CRef& parent) { Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { if (!pComponent->m_pData->inLayout) { pComponent->SetParent(parent); } cref.ReleaseInstance(); } }
bool ASI::IsSelected(CRef& cref) { bool selected = false; Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { selected = pComponent->m_pData->selected; cref.ReleaseInstance(); } return selected; }
const QStringList ASI::GetProfile(CRef& cref, ProfileType type) { QStringList list; Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { list = pComponent->GetProfile(type); cref.ReleaseInstance(); } return list; }
bool ASI::DisconnectFromFuncSet(CRef& src, int caller) { bool disconnected = true; Component* pComponent = src.GetInstance(); if (pComponent != NULL) { disconnected = pComponent->DisconnectFromFuncSet(caller); src.ReleaseInstance(); } return disconnected; }
DRef ASI::CallFunc(CRef& cref, int funcSet, int func, DRef& dref, bool passThru) { DRef result; Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { result = pComponent->CallFunc(funcSet, func, dref, passThru); cref.ReleaseInstance(); } return result; }
QPointF ASI::MapFromViewToParent(CRef& cref, const QPoint& point) { QPointF mappedPoint; Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { mappedPoint = m_pView->MapToParent(&pComponent->m_pData->graphicsItem, point); cref.ReleaseInstance(); } return mappedPoint; }
void ASI::SetSelection(CRefList crefList) { CRefList prevSelection = m_pState->Selection(); int numCRefs = prevSelection.Count(); for (int i=0; i < numCRefs; i++) { CRef cref = prevSelection.Value(i); Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { pComponent->m_pData->selected = false; pComponent->Update(); cref.ReleaseInstance(); } } numCRefs = crefList.Count(); for (int i=0; i < numCRefs; i++) { CRef cref = crefList.Value(i); Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { pComponent->m_pData->selected = true; pComponent->Update(); cref.ReleaseInstance(); } } m_pState->SetSelection(crefList); }
QPointF ASI::MapToParent(CRef& cref, const QPointF& point) { QPointF mappedPoint; Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { GraphicsItem* pItem = &pComponent->m_pData->graphicsItem; mappedPoint = pItem->mapToParent(point); cref.ReleaseInstance(); } return mappedPoint; }
bool ASI::IsParent(CRef& parent, CRef& child) { bool isParent = false; Component* pParent = parent.GetInstance(); if (pParent != NULL) { Component* pChild = child.GetInstance(); if (pChild != NULL) { if (pChild->m_pData->graphicsItem.parentItem() == &pParent->m_pData->graphicsItem) { isParent = true; } child.ReleaseInstance(); } parent.ReleaseInstance(); } return isParent; }
void ASI::GetMenus(CRef& cref, MenuSet& menuSet) { int type = cref.Type(); if (!m_pMenuManager->GetMenus(type, menuSet)) { menuSet.Clear(); Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { const QStringList profile = pComponent->GetProfile(); m_pMenuManager->GetMenus(profile, menuSet, type); cref.ReleaseInstance(); } } }
void ASI::SetPosition(CRef cref, const QPointF& pos) { Component* pComponent = cref.GetInstance(); if (pComponent != NULL) { if (!pComponent->m_pData->inLayout) { GuiRequest request; request.cref = cref; request.data.point.x = pos.x(); request.data.point.y = pos.y(); request.type = GuiRequest::RequestType_SetPosition; m_pGuiRequestHandler->PostRequest(&request); } cref.ReleaseInstance(); } }