void wxSFLayoutHorizontalTree::ProcessNode(wxSFShapeBase* node, double x) { wxASSERT( node ); if( node ) { node->MoveTo( x, m_nMinY ); wxRect rctBB = node->GetBoundingBox(); if( rctBB.GetHeight() > m_nCurrMaxHeight ) m_nCurrMaxHeight = rctBB.GetHeight(); ShapeList lstNeighbours; node->GetNeighbours( lstNeighbours, CLASSINFO(wxSFShapeBase), wxSFShapeBase::lineSTARTING ); if( lstNeighbours.IsEmpty() ) { m_nMinY += m_nCurrMaxHeight + m_VSpace; } else { for( ShapeList::iterator it = lstNeighbours.begin(); it != lstNeighbours.end(); ++it ) { if( ! (*it)->GetParentShape() ) ProcessNode( *it, x + rctBB.GetWidth() + m_HSpace ); } } } }
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 wxSFAutoLayout::Layout(wxSFDiagramManager& manager, const wxString& algname) { wxSFLayoutAlgorithm *pAlg = m_mapAlgorithms[ algname ]; if( pAlg ) { ShapeList lstShapes; manager.GetShapes( CLASSINFO(wxSFShapeBase), lstShapes ); // remove all child shapes ShapeList::compatibility_iterator it = lstShapes.GetFirst(); while( it ) { wxSFShapeBase *pShape = it->GetData(); if( pShape->GetParentShape() || pShape->IsKindOf(CLASSINFO(wxSFLineShape)) ) { lstShapes.DeleteNode( it ); it = lstShapes.GetFirst(); } else it = it->GetNext(); } pAlg->DoLayout( lstShapes ); manager.MoveShapesFromNegatives(); if( manager.GetShapeCanvas() ) UpdateCanvas( manager.GetShapeCanvas() ); } }
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 TableSettings::OnInit(wxInitDialogEvent& event) { m_textName->SetValue( m_pTable->GetName() ); // fill database data types wxArrayString* pDbTypes = m_pDbAdapter->GetDbTypes(); if( pDbTypes ) { wxArrayString choices; for (unsigned int i = 0; i < pDbTypes->GetCount(); ++i) { choices.Add( pDbTypes->Item(i) ); } m_dvColumns->DeleteColumn( m_dvColumns->GetColumn(1) ); m_dvColumns->InsertColumn( 1, new wxDataViewColumn( _("Type"), new wxDataViewChoiceRenderer( choices, wxDATAVIEW_CELL_EDITABLE, wxDVR_DEFAULT_ALIGNMENT), 1, -2, wxALIGN_LEFT)); pDbTypes->Clear(); delete pDbTypes; } // fill referenced tables ShapeList tables; m_choiceRefTable->Append( wxT("") ); m_pDiagramManager->GetShapes( CLASSINFO(ErdTable), tables ); for( ShapeList::iterator it = tables.begin(); it != tables.end(); ++it ) { Table *t = (Table*) (*it)->GetUserData(); if( t && t->GetName() != m_pTable->GetName() ) m_choiceRefTable->Append( t->GetName() ); } UpdateView(); event.Skip(); }
void wxSFLayoutMesh::DoLayout(ShapeList& shapes) { int i = 0, cols = floor( sqrt( (float)shapes.GetCount() ) ); double roffset, coffset, maxh = -m_HSpace; roffset = coffset = 0; wxRealPoint nStart = GetTopLeft( shapes ); for( ShapeList::iterator it = shapes.begin(); it != shapes.end(); ++ it ) { wxSFShapeBase *pShape = *it; if( i++ % cols == 0 ) { coffset = 0; roffset += maxh + m_HSpace; maxh = 0; } pShape->MoveTo( nStart.x + coffset, nStart.y + roffset ); wxRect rctBB = pShape->GetBoundingBox(); coffset += rctBB.GetWidth() + m_VSpace; if( rctBB.GetHeight() > maxh ) maxh = rctBB.GetHeight(); } }
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); } } } }
bool wxSFShapeBase::IsAncestor(wxSFShapeBase *child) { ShapeList lstChildren; GetChildShapes( NULL, lstChildren, sfRECURSIVE ); return ( lstChildren.IndexOf(child) != wxNOT_FOUND ); }
bool wxSFShapeBase::IsDescendant(wxSFShapeBase *parent) { ShapeList lstChildren; if( parent ) parent->GetChildShapes( NULL, lstChildren, sfRECURSIVE ); return ( lstChildren.IndexOf(this) != wxNOT_FOUND ); }
void wxSFShapeBase::GetNeighbours(ShapeList& neighbours, wxClassInfo *shapeInfo, CONNECTMODE condir, bool direct) { if( !this->IsKindOf(CLASSINFO(wxSFLineShape)) ) { m_lstProcessed.Clear(); this->_GetNeighbours(neighbours, shapeInfo, condir, direct); // delete starting object if necessary (can be added in a case of complex connection network) neighbours.DeleteObject(this); } }
Table* TableSettings::GetRefTable(const wxString& name) { ShapeList tables; m_pDiagramManager->GetShapes( CLASSINFO(ErdTable), tables ); for( ShapeList::iterator it = tables.begin(); it != tables.end(); ++it ) { Table *t = (Table*) (*it)->GetUserData(); if( t->GetName() == name ) return t; } return NULL; }
bool DatabaseCanvas::IsTableDisplayed(const std::wstring &name) { ShapeList listShapes; m_pManager.GetShapes( CLASSINFO( MyErdTable ), listShapes ); bool found = false; for( ShapeList::iterator it = listShapes.begin(); it != listShapes.end() && !found; ++it ) { if( dynamic_cast<MyErdTable *>( (*it) )->GetTableName() == name ) found = true; } return found; }
void shapeGroup::RefteshTotalData() { ShapeList TMPShapeList = SG_ShapeData; ShapeList::iterator SG_ShapeData_Iterator = TMPShapeList.begin(); SG_Size = TMPShapeList.size(); const int VAOSize = SG_Size * 12; const int ItemSize = SG_Size * 20; GLfloat* SG_TmpTotalData = (GLfloat*)malloc(sizeof(GLfloat) * ItemSize); if (SG_TmpTotalData == nullptr) { std::cout << "[Warning]Can't malloc(" << sizeof(GLfloat) * ItemSize << ")" << std::endl; return; } //start to copy for (int LoopShapeNumber = 0; LoopShapeNumber < SG_Size; LoopShapeNumber++) { //VAO SG_TmpTotalData[LoopShapeNumber * 12 + 0] = SG_ShapeData_Iterator->Shape->VAO_Data[0] + SG_ShapeData_Iterator->Location[0]; SG_TmpTotalData[LoopShapeNumber * 12 + 1] = SG_ShapeData_Iterator->Shape->VAO_Data[1] + SG_ShapeData_Iterator->Location[1]; SG_TmpTotalData[LoopShapeNumber * 12 + 2] = SG_ShapeData_Iterator->Shape->VAO_Data[2] + SG_ShapeData_Iterator->Location[2]; SG_TmpTotalData[LoopShapeNumber * 12 + 3] = SG_ShapeData_Iterator->Shape->VAO_Data[3] + SG_ShapeData_Iterator->Location[0]; SG_TmpTotalData[LoopShapeNumber * 12 + 4] = SG_ShapeData_Iterator->Shape->VAO_Data[4] + SG_ShapeData_Iterator->Location[1]; SG_TmpTotalData[LoopShapeNumber * 12 + 5] = SG_ShapeData_Iterator->Shape->VAO_Data[5] + SG_ShapeData_Iterator->Location[2]; SG_TmpTotalData[LoopShapeNumber * 12 + 6] = SG_ShapeData_Iterator->Shape->VAO_Data[6] + SG_ShapeData_Iterator->Location[0]; SG_TmpTotalData[LoopShapeNumber * 12 + 7] = SG_ShapeData_Iterator->Shape->VAO_Data[7] + SG_ShapeData_Iterator->Location[1]; SG_TmpTotalData[LoopShapeNumber * 12 + 8] = SG_ShapeData_Iterator->Shape->VAO_Data[8] + SG_ShapeData_Iterator->Location[2]; SG_TmpTotalData[LoopShapeNumber * 12 + 9] = SG_ShapeData_Iterator->Shape->VAO_Data[9] + SG_ShapeData_Iterator->Location[0]; SG_TmpTotalData[LoopShapeNumber * 12 + 10] = SG_ShapeData_Iterator->Shape->VAO_Data[10] + SG_ShapeData_Iterator->Location[1]; SG_TmpTotalData[LoopShapeNumber * 12 + 11] = SG_ShapeData_Iterator->Shape->VAO_Data[11] + SG_ShapeData_Iterator->Location[2]; //TexturePos for (int i = 0; i < 8; i++) { SG_TmpTotalData[VAOSize + LoopShapeNumber * 8 + i] = SG_ShapeData_Iterator->Shape->TexturePos_Data[i]; } SG_ShapeData_Iterator++; } SG_TotalData = SG_TmpTotalData; SG_NeedRefreshBuffer = true; SG_IsRefreshingData = false; }
void Rectangle::saveRectangle(string fileName, ShapeList& s_list) // 파일 쓰기용 { ofstream fout; fout.open(fileName, ios_base::out); for (int i = 0; i < s_list.getCount(); i++) { Shape* s = s_list.getShapeList(i); s->print(); } fout.close(); }
void udLoopCaseAlgorithm::ProcessState(wxSFShapeBase *state) { wxASSERT(state); if(!state)return; // check whether the state is already processed if( m_lstProcessedElements.IndexOf(state) != wxNOT_FOUND )return; wxSFDiagramManager *pDiagManager = state->GetShapeManager(); udLanguage *pLang = m_pParentGenerator->GetActiveLanguage(); pLang->SingleLineCommentCmd(wxT("State ID: ") + m_pParentGenerator->MakeIDName(state)); // find state neighbours ShapeList lstNeighbours; pDiagManager->GetNeighbours(state, lstNeighbours, CLASSINFO(umlTransitionItem), wxSFShapeBase::lineSTARTING, sfDIRECT); // find next processable state if( !lstNeighbours.IsEmpty() && ( m_lstProcessedElements.IndexOf(lstNeighbours.GetFirst()->GetData()) == wxNOT_FOUND ) ) { m_pNextElement = lstNeighbours.GetFirst()->GetData(); } else m_pNextElement = NULL; // process given element udElementProcessor *pProcessor = GetElementProcessor(state->GetClassInfo()->GetClassName()); if(pProcessor) { pProcessor->ProcessElement(state); } else { pLang->SingleLineCommentCmd(wxString::Format(wxT( "!!! WARNING: UNSUPPORTED ELEMENT ('%s') !!!"), ((udProjectItem*)state->GetUserData())->GetName().c_str())); IPluginManager::Get()->Log(wxString::Format(wxT("WARNING: '%s' element is not supported by this algorithm."), ((udProjectItem*)state->GetUserData())->GetName().c_str())); } // set the state as processes m_lstProcessedElements.Append(state); m_pPrevElement = state; // process connected states ShapeList::compatibility_iterator node = lstNeighbours.GetFirst(); while(node) { wxSFShapeBase *pNext = node->GetData(); ProcessState( pNext ); node = node->GetNext(); } }
wxRealPoint wxSFLayoutAlgorithm::GetShapesCenter(const ShapeList& shapes) { wxRealPoint nCenter; for( ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) { nCenter = nCenter + (*it)->GetAbsolutePosition(); } nCenter.x /= shapes.GetCount(); nCenter.y /= shapes.GetCount(); return nCenter; }
wxSize wxSFLayoutAlgorithm::GetShapesExtent(const ShapeList& shapes) { int nTotalWidth = 0, nTotalHeight = 0; for( ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) { wxRect rctBB = (*it)->GetBoundingBox(); nTotalWidth += rctBB.GetWidth(); nTotalHeight += rctBB.GetHeight(); } return wxSize( nTotalWidth, nTotalHeight ); }
wxRealPoint wxSFLayoutAlgorithm::GetTopLeft(const ShapeList& shapes) { double startx = INT_MAX, starty = INT_MAX; for( ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) { wxSFShapeBase *pShape = *it; wxRealPoint nPos = pShape->GetAbsolutePosition(); if( nPos.x < startx ) startx = nPos.x; if( nPos.y < starty ) starty = nPos.y; } return wxRealPoint( startx, starty ); }
wxRect wxSFLayoutAlgorithm::GetBoundingBox(const ShapeList& shapes) { wxRect rctBB; for( ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) { wxSFShapeBase *pShape = *it; if( it == shapes.begin() ) rctBB = pShape->GetBoundingBox(); else rctBB.Union( pShape->GetBoundingBox() ); } return rctBB; }
void Entity::init(const ShapeList & list, const MassProperties mass, const Transform t){ std::vector< ::std::pair<size_t, Transform> > shapes; size_t compound; //Create the shapes for_each(list.begin(), list.end(), [&](const ShapeList::value_type & shape){ switch(shape.first.type){ case E_CAPSULE: case E_SPHERE: case E_BOX: case E_PLANE: { size_t s = createShape( shape.first.type, Math::Vec4ToVec3(shape.first.data), Math::VecLast(shape.first.data) ); Transform t = shape.second; ::std::pair<size_t, Transform> p(s,t); shapes.push_back(p); } break; case E_MESH: { size_t s = createShape( shape.first.type, shape.first.rawMesh ); Transform t = shape.second; ::std::pair<size_t, Transform> p(s,t); shapes.push_back(p); } break; default: { throw "Not valid shape type!"; } } }); //Got a list of shapes, make the compound shape compound = _world->compoundShapes(shapes); //Put it back on with the compound object first _shape_index.push_back(compound); for_each(shapes.begin(),shapes.end(),[&](decltype(shapes)::value_type s){ _shape_index.push_back(s.first); }); //create body makeBody(t, mass); }
void wxSFShapeBase::_OnDragging(const wxPoint& pos) { //wxASSERT(m_pParentManager); if( !m_pParentManager )return; if(m_fVisible && m_fActive && (m_nStyle & sfsPOSITION_CHANGE)) { if(m_fFirstMove) { m_nMouseOffset = wxRealPoint(pos.x, pos.y) - this->GetAbsolutePosition(); } // get shape BB BEFORE movement and combine it with BB of assigned lines wxRect prevBB; GetCompleteBoundingBox(prevBB, bbSELF | bbCONNECTIONS | bbCHILDREN | bbSHADOW); this->MoveTo(pos.x - m_nMouseOffset.x, pos.y - m_nMouseOffset.y); this->OnDragging(pos); // GUI controls in child control shapes must be updated explicitely wxSFControlShape *pCtrl; ShapeList lstChildCtrls; GetChildShapes( CLASSINFO(wxSFControlShape), lstChildCtrls, sfRECURSIVE ); ShapeList::compatibility_iterator node = lstChildCtrls.GetFirst(); while( node ) { pCtrl = (wxSFControlShape*) node->GetData(); pCtrl->UpdateControl(); node = node->GetNext(); } // get shape BB AFTER movement and combine it with BB of assigned lines wxRect currBB; GetCompleteBoundingBox(currBB, bbSELF | bbCONNECTIONS | bbCHILDREN | bbSHADOW); // update canvas Refresh( prevBB.Union(currBB), sfDELAYED ); m_fFirstMove = false; } if( GetParentShape() && (m_nStyle & sfsPROPAGATE_DRAGGING) ) { GetParentShape()->_OnDragging( pos ); } }
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 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 wxSFMultiSelRect::OnEndHandle(wxSFShapeHandle& handle) { // inform all selected shapes about end of the handle dragging if(GetParentCanvas()) { ShapeList lstShapes; GetParentCanvas()->GetSelectedShapes(lstShapes); ShapeList::compatibility_iterator node = lstShapes.GetFirst(); while(node) { node->GetData()->OnEndHandle(handle); node = node->GetNext(); } } }
void wxSFDiagramManager::UpdateAll() { wxSFShapeBase *pShape; ShapeList lstShapes; GetShapes( CLASSINFO(wxSFShapeBase), lstShapes ); ShapeList::compatibility_iterator node = lstShapes.GetFirst(); while( node ) { pShape = node->GetData(); // update only shapes withour children because the Update() function is called recursively on all parents if( !HasChildren( pShape ) ) pShape->Update(); node = node->GetNext(); } }
void wxSFDiagramManager::MoveShapesFromNegatives() { wxSFShapeBase *pShape; wxRealPoint shapePos; double minx = 0, miny = 0; // find the maximal negative position value ShapeList shapes; GetShapes(CLASSINFO(wxSFShapeBase), shapes); ShapeList::compatibility_iterator node = shapes.GetFirst(); while(node) { shapePos = node->GetData()->GetAbsolutePosition(); if(node == shapes.GetFirst()) { minx = shapePos.x; miny = shapePos.y; } else { if(shapePos.x < minx)minx = shapePos.x; if(shapePos.y < miny)miny = shapePos.y; } node = node->GetNext(); } // move all parents shape so they (and their children) will be located in the positive values only if((minx < 0) || (miny < 0)) { node = shapes.GetFirst(); while(node) { pShape = node->GetData(); if(pShape->GetParentShape() == NULL) { if(minx < 0)pShape->MoveBy(abs((int)minx), 0); if(miny < 0)pShape->MoveBy(0, abs((int)miny)); } node = node->GetNext(); } } }
void wxSFShapePasteEvent::SetPastedShapes(const ShapeList &list) { ShapeList::compatibility_iterator node = list.GetFirst(); while(node) { m_lstPastedShapes.Append(node->GetData()); node = node->GetNext(); } }
int ShapeList::maxDepth() const { int res = std::numeric_limits<int>::min(); int d; ShapeList * sl; std::vector< Shape* >::const_iterator i = _shapes.begin(); std::vector< Shape* >::const_iterator end = _shapes.end(); while ( i != end ) { sl = dynamic_cast<ShapeList*>( *i ); if ( sl ) { d = sl->maxDepth(); } else { d = (*i)->depth(); } if ( d > res ) res = d; ++i; } return res; }
void Rectangle::loadRectangle(string fileName, ShapeList& s_list) // 파일 읽기용 { ifstream fin; fin.open(fileName, ios_base::in); int centerX; int centerY; int width; int height; while (!fin.eof()) // 파일의 끝에 도달하지 않았다면 계속 반복 { fin >> centerX >> centerY >> width >> height; // 파일의 값을 읽음 Rectangle* r = new Rectangle(centerX, centerY, width, height); // Student 임시 객체 생성 s_list.insertShape(r); s_list.plusCount(); } fin.close(); }
void DatabaseCanvas::AddQuickQueryFields(const wxString &tbl, std::vector<Field *> &quickSelectFields, bool quickSelect) { ShapeList shapes; m_pManager.GetShapes( CLASSINFO( FieldShape ), shapes ); for( ShapeList::iterator it = shapes.begin (); it != shapes.end (); ++it ) { auto fld = wxDynamicCast( (*it), FieldShape ); auto fieldName = wxDynamicCast( (*it), FieldShape )->GetField()->GetFieldName(); auto found = false; for( std::vector<Field *>::iterator it2 = quickSelectFields.begin(); it2 < quickSelectFields.end() && !false; ++it2 ) { if( (*it2)->GetFieldName() == fieldName ) { found = true; (*it)->Select( true ); dynamic_cast<DrawingView *>( m_view )->AddFieldToQuery( *fld, fld->IsSelected(), tbl.ToStdWstring(), quickSelect ); } } } Refresh(); }