void wxSFDiagramManager::GetAssignedConnections(wxSFShapeBase* parent, wxClassInfo* shapeInfo, wxSFShapeBase::CONNECTMODE mode, ShapeList& lines) { wxSFLineShape* pLine; if( parent->GetId() == -1 ) return; SerializableList lstLines; // lines are children of root item only so we have not to search recursively... GetRootItem()->GetChildren( shapeInfo, lstLines ); if( !lstLines.IsEmpty() ) { SerializableList::compatibility_iterator node = lstLines.GetFirst(); while(node) { pLine = (wxSFLineShape*)node->GetData(); switch(mode) { case wxSFShapeBase::lineSTARTING: if( pLine->GetSrcShapeId() == parent->GetId() ) lines.Append(pLine); break; case wxSFShapeBase::lineENDING: if( pLine->GetTrgShapeId() == parent->GetId() ) lines.Append(pLine); break; case wxSFShapeBase::lineBOTH: if( ( pLine->GetSrcShapeId() == parent->GetId() ) || ( pLine->GetTrgShapeId() == parent->GetId() ) ) lines.Append(pLine); break; } node = node->GetNext(); } } }
void DbViewerPanel::OnDnDStart(wxTreeEvent& event) { ShapeList lstDnD; lstDnD.DeleteContents(true); DbItem* item = (DbItem*)m_treeDatabases->GetItemData(event.GetItem()); ErdPanel* pPanel = wxDynamicCast(m_mgr->GetActivePage(), ErdPanel); if(item != NULL) { if(pPanel) { Table* table = wxDynamicCast(item->GetData(), Table); if(table) { table = (Table*)table->Clone(); wxSFShapeBase* pShape = new dndTableShape(table); lstDnD.Append(pShape); pPanel->GetCanvas()->DoDragDrop(lstDnD); } View* view = wxDynamicCast(item->GetData(), View); if(view) { view = (View*)view->Clone(); wxSFShapeBase* pShape = new dndTableShape(view); lstDnD.Append(pShape); pPanel->GetCanvas()->DoDragDrop(lstDnD); } } } }
void udStateChartOptimizer::FindTransWithIdenticalActions(ShapeList& transitions, ShapeList& sublist) { sublist.Clear(); ShapeList::compatibility_iterator node = transitions.GetFirst(); if( !node ) return; udTransElementItem *pTransElement; wxSFLineShape *pTrans = (wxSFLineShape*)node->GetData(); wxString sActions, sTemplate = ((udTransElementItem*)pTrans->GetUserData())->GetActionsString(); sTemplate.Replace(wxT(" "), wxT("")); while(node) { pTrans = (wxSFLineShape*)node->GetData(); pTransElement = (udTransElementItem*)pTrans->GetUserData(); sActions = pTransElement->GetActionsString(); sActions.Replace(wxT(" "), wxT("")); if( sActions == sTemplate ) { node = node->GetNext(); transitions.DeleteObject(pTrans); sublist.Append(pTrans); } else node = node->GetNext(); } }
void wxSFDiagramManager::RemoveShape(wxSFShapeBase* shape, bool refresh) { if(shape) { wxSFShapeBase *pParent = shape->GetParentShape(); // remove connected lines (to all children) ShapeList lstChildren; ShapeList lstConnections; ShapeList lstRemovedConnections; // get all shape's children shape->GetChildShapes(sfANY, lstChildren, sfRECURSIVE); lstChildren.Append(shape); // retrieve all assigned lines ShapeList::compatibility_iterator snode = lstChildren.GetFirst(); while(snode) { GetAssignedConnections(snode->GetData(), CLASSINFO(wxSFLineShape), wxSFShapeBase::lineBOTH, lstConnections); snode = snode->GetNext(); } // remove all assigne lines ShapeList::compatibility_iterator node = lstConnections.GetFirst(); while(node) { // one connection may be used by the parent and also by his child if(lstRemovedConnections.IndexOf(node->GetData()) == wxNOT_FOUND) { lstRemovedConnections.Append(node->GetData()); RemoveShape(node->GetData(), false); } node = node->GetNext(); } // remove the shape also from m_lstCurrentShapes list if( m_pShapeCanvas ) m_pShapeCanvas->RemoveFromTemporaries( shape ); // remove the shape RemoveItem(shape); if( pParent ) pParent->Update(); if( refresh && m_pShapeCanvas ) m_pShapeCanvas->Refresh(false); } }
void wxSFDiagramManager::GetShapesInside(const wxRect& rct, ShapeList& shapes) { shapes.Clear(); wxSFShapeBase* pShape; ShapeList lstShapes; GetShapes(CLASSINFO(wxSFShapeBase), lstShapes); ShapeList::compatibility_iterator node = lstShapes.GetFirst(); while(node) { pShape = node->GetData(); if(pShape->IsVisible() && pShape->IsActive() && pShape->Intersects(rct))shapes.Append(pShape); node = node->GetNext(); } }
void wxSFDiagramManager::GetShapesAtPosition(const wxPoint& pos, ShapeList& shapes) { shapes.Clear(); wxSFShapeBase *pShape; ShapeList lstShapes; GetShapes(CLASSINFO(wxSFShapeBase), lstShapes); ShapeList::compatibility_iterator node = lstShapes.GetFirst(); while(node) { pShape = node->GetData(); if(pShape->IsVisible() && pShape->IsActive() && pShape->Contains(pos))shapes.Append(pShape); node = node->GetNext(); } }
void udStateChartOptimizer::FindTransWithIdenticalTarget(ShapeList& transitions, ShapeList& sublist) { sublist.Clear(); ShapeList::compatibility_iterator node = transitions.GetFirst(); if( !node ) return; wxSFLineShape *pTrans = (wxSFLineShape*)node->GetData(); int nTrgId = pTrans->GetTrgShapeId(); while(node) { pTrans = (wxSFLineShape*)node->GetData(); if( pTrans->GetTrgShapeId() == nTrgId ) { node = node->GetNext(); transitions.DeleteObject(pTrans); sublist.Append(pTrans); } else node = node->GetNext(); } }
void wxSFShapeBase::_GetNeighbours(ShapeList& neighbours, wxClassInfo *shapeInfo, CONNECTMODE condir, bool direct) { //wxASSERT(m_pParentManager); if( m_pParentManager ) { if( m_lstProcessed.IndexOf(this) != wxNOT_FOUND )return; ShapeList lstConnections; wxSFLineShape *pLine; wxSFShapeBase *pOposite = NULL; GetAssignedConnections(shapeInfo, condir, lstConnections); // find oposite shpes in direct branches ShapeList::compatibility_iterator node = lstConnections.GetFirst(); while(node) { pLine = (wxSFLineShape*)node->GetData(); switch(condir) { case lineSTARTING: pOposite = GetShapeManager()->FindShape(pLine->GetTrgShapeId()); break; case lineENDING: pOposite = GetShapeManager()->FindShape(pLine->GetSrcShapeId()); break; case lineBOTH: { if(GetId() == pLine->GetSrcShapeId())pOposite = GetShapeManager()->FindShape(pLine->GetTrgShapeId()); else pOposite = GetShapeManager()->FindShape(pLine->GetSrcShapeId()); } } // add oposite shape to the list (if applicable) if(pOposite && !pOposite->IsKindOf(CLASSINFO(wxSFLineShape)) && ( neighbours.IndexOf(pOposite) == wxNOT_FOUND )) neighbours.Append(pOposite); // find next shapes if( !direct && pOposite ) { // in the case of indirect branches we must differentiate between connections // and ordinary shapes m_lstProcessed.Append(this); if( pOposite->IsKindOf(CLASSINFO(wxSFLineShape)) ) { pLine = (wxSFLineShape*)pOposite; switch(condir) { case lineSTARTING: { pOposite = GetShapeManager()->FindShape( pLine->GetSrcShapeId() ); if( pOposite->IsKindOf(CLASSINFO(wxSFLineShape)) )pOposite->_GetNeighbours(neighbours, shapeInfo, condir, direct); else if( neighbours.IndexOf(pOposite) == wxNOT_FOUND )neighbours.Append(pOposite); } break; case lineENDING: { pOposite = GetShapeManager()->FindShape( pLine->GetTrgShapeId() ); if( pOposite->IsKindOf(CLASSINFO(wxSFLineShape)) )pOposite->_GetNeighbours(neighbours, shapeInfo, condir, direct); else if( neighbours.IndexOf(pOposite) == wxNOT_FOUND )neighbours.Append(pOposite); } break; case lineBOTH: { pOposite = GetShapeManager()->FindShape( pLine->GetSrcShapeId() ); if( pOposite->IsKindOf(CLASSINFO(wxSFLineShape)) )pOposite->_GetNeighbours(neighbours, shapeInfo, condir, direct); else if( neighbours.IndexOf(pOposite) == wxNOT_FOUND )neighbours.Append(pOposite); pOposite = GetShapeManager()->FindShape( pLine->GetTrgShapeId() ); if( pOposite->IsKindOf(CLASSINFO(wxSFLineShape)) )pOposite->_GetNeighbours(neighbours, shapeInfo, condir, direct); else if( neighbours.IndexOf(pOposite) == wxNOT_FOUND )neighbours.Append(pOposite); } break; } } else pLine->_GetNeighbours(neighbours, shapeInfo, condir, direct); } node = node->GetNext(); } } }
void wxSFShapeBase::_GetCompleteBoundingBox(wxRect &rct, int mask) { //wxASSERT(m_pParentManager); if(!m_pParentManager)return; if( m_lstProcessed.IndexOf(this) != wxNOT_FOUND )return; else m_lstProcessed.Append(this); ShapeList lstChildren; //SerializableList lstConnections; // firts, get bounding box of the current shape if(mask & bbSELF) { if(rct.IsEmpty())rct = this->GetBoundingBox().Inflate( abs(m_nHBorder), abs(m_nVBorder) ); else rct.Union(this->GetBoundingBox().Inflate( abs(m_nHBorder), abs(m_nVBorder)) ); // add also shadow offset if neccessary if( (mask & bbSHADOW) && (m_nStyle & sfsSHOW_SHADOW) && GetParentCanvas() ) { wxRealPoint nOffset = GetParentCanvas()->GetShadowOffset(); if( nOffset.x < 0 ) { rct.SetX(rct.GetX() + (int)nOffset.x); rct.SetWidth(rct.GetWidth() - (int)nOffset.x); } else rct.SetWidth(rct.GetWidth() + (int)nOffset.x); if( nOffset.y < 0 ) { rct.SetY(rct.GetY() + (int)nOffset.y); rct.SetHeight(rct.GetHeight() - (int)nOffset.y); } else rct.SetHeight(rct.GetHeight() + (int)nOffset.y);; } } else mask |= bbSELF; // get list of all connection lines assigned to the shape and find their child shapes if(mask & bbCONNECTIONS) { wxSFShapeBase *pLine; ShapeList lstLines; GetAssignedConnections( CLASSINFO(wxSFLineShape), lineBOTH, lstLines ); ShapeList::compatibility_iterator node = lstLines.GetFirst(); while(node) { pLine = node->GetData(); //rct.Union(pLine->GetBoundingBox()); lstChildren.Append(pLine); // get children of the connections pLine->GetChildShapes(sfANY, lstChildren); node = node->GetNext(); } } // get children of this shape if(mask & bbCHILDREN) { this->GetChildShapes(sfANY, lstChildren, sfNORECURSIVE); // now, call this function for all children recursively... ShapeList::compatibility_iterator node = lstChildren.GetFirst(); while(node) { node->GetData()->_GetCompleteBoundingBox(rct, mask); node = node->GetNext(); } } }