CMyShape* CVisualADSView::addResourceFrame(int iX, int iY) { //选中共享文件夹时的虚线框 resource if (m_frameShape != NULL) { CPoint ptOrigin = m_frameShape->GetCenterPoint(); if (ptOrigin.x == iX && ptOrigin.y == iY) { return m_frameShape; } else { GetCurrentModel()->RemoveShape(m_frameShape); //delete m_frameShape; m_frameShape = NULL; } } CRect rctPosition = CRect(iX - m_ptResourceFrameSize.x / 2, iY - m_ptResourceFrameSize.y / 2 - 1, iX + m_ptResourceFrameSize.x / 2, iY + m_ptResourceFrameSize.y / 2 + 1); CMyShape *pNode = new CMyShape(abstractADObject, this, FALSE); pNode->AddRef(); pNode->Create(IDR_COMPSRES_RESOURCE_FRAME, rctPosition, _T("resource_frame")); pNode->SetSelectProtect(TRUE); m_frameShape = pNode; GetCurrentModel()->InsertShape(pNode); pNode->UpdateComp(); pNode->Release(); return pNode; }
CMyShape* CVisualADSView::addGroup(ADObject *aDObject, CString strName, int iX, int iY) { //生成一个组的shape CRect rctPosition = CRect(iX - m_ptGroupSize.x/2, iY - m_ptGroupSize.y/2, iX + m_ptGroupSize.x/2, iY + m_ptGroupSize.y/2); CRect rctTitlePos = CRect(0, 0, m_ptGroupSize.x, m_ptGroupSize.y); CMyShape *pNode = new CMyShape(aDObject, this, TRUE); pNode->AddRef(); pNode->Create(IDR_COMPSRES_GROUP, rctPosition, _T("group")); pNode->AddText(_T(""), strName, rctTitlePos); for (int i = 0; i < 12; i ++) { pNode->GetPortAt(i)->SetPortType(FO_PORT_NOTSHOW); } //pNode->CreateDefaultPort(0, 0.5)->SetPortType(FO_PORT_NOTSHOW); //pNode->CreateDefaultPort(1, 0.5)->SetPortType(FO_PORT_NOTSHOW); //pNode->CreateDefaultPort(0.5, 0)->SetPortType(FO_PORT_NOTSHOW); //pNode->CreateDefaultPort(0.5, 1)->SetPortType(FO_PORT_NOTSHOW); pNode->AllowLabelSelect(FALSE); m_shapes.push_back(pNode); GetCurrentModel()->InsertShape(pNode); pNode->UpdateComp(); pNode->Release(); return pNode; }
void CVisualADSView::DoEventSingleClick(CFODrawShape *pShape) { //点击每个shape的时候调用 if(pShape != NULL) { if (pShape->GetObjectCaption() == "group" /*|| pShape->GetObjectCaption() == "user"*/) //判断shape的文字 { CPoint pt = pShape->GetCenterPoint(); addGroupFrame(pt.x, pt.y); //给shape加上合适的虚线框 } else if(pShape->GetObjectCaption() == "user"){ CPoint pt = pShape->GetCenterPoint(); addUserFrame(pt.x, pt.y); } else if (pShape->GetObjectCaption() == "computer") { CPoint pt = pShape->GetCenterPoint(); addComputerFrame(pt.x, pt.y); } else if (pShape->GetObjectCaption() == "resource") { CPoint pt = pShape->GetCenterPoint(); addResourceFrame(pt.x, pt.y); } else { if (m_frameShape != NULL) { GetCurrentModel()->RemoveShape(m_frameShape); //delete m_frameShape; m_frameShape = NULL; FOPInvalidate(); } } } else { if (m_frameShape != NULL) { GetCurrentModel()->RemoveShape(m_frameShape); //什么都没有选中则去掉虚线框 //delete m_frameShape; m_frameShape = NULL; FOPInvalidate(); } } }
void CVisualADSView::removeFrameShape() { //删除一个shape if (m_frameShape != NULL) { GetCurrentModel()->RemoveShape(m_frameShape); //delete m_frameShape; m_frameShape = NULL; } }
void CVisualADSView::deleteAllShapes() { GetCurrentModel()->ClearAll(); return; //删除所有E-XD++中的节点 for (int i = 0; i < m_shapes.size(); i ++) { delete m_shapes[m_shapes.size() - 1]; m_shapes.pop_back(); } }
void CVisualADSView::MyDoChangeModel(CPoint ptGraphSize) { CFODataModel *pModel = GetCurrentModel(); CFODrawView::DoChangeModel(pModel); // Adding your data model init codes here.. CSize szCanvas = CSize(ptGraphSize.x, ptGraphSize.y); pModel->SetCanvasSize(szCanvas); pModel->SetBorderShow(FALSE); GetCurrentModel()->SetPageBkColor(RGB(255, 255, 255)); pModel->ShowGrid(FALSE); pModel->SetDesignMode(FALSE); pModel->SetHlpLineVisible(FALSE); ResetToSelectMode(); EnableMirrorFreeMode(FALSE); EnableShearFreeMode(FALSE); //EnableScrollBar(SB_BOTH,ESB_DISABLE_BOTH); CSize sizeTotal; sizeTotal.cx = 1; sizeTotal.cy = 1; SetScrollSizes(MM_TEXT, sizeTotal); SetScrollRange(0, 0, 0); FOSetCursor(IDC_FO_CURSOR_RADIO2); }
CMyShape* CVisualADSView::addBigComputer(ADObject *aDObject, CString strName, int iX1, int iY1, int iX2, int iY2) { //生成一个带共享文件夹的计算机的shape CRect rctPosition = CRect(iX1, iY1, iX2, iY2); CRect rctTitlePos = CRect(0, (iY2-iY1)-25, iX2 - iX1, iY2-iY1); CMyShape *pNode = new CMyShape(aDObject, this, FALSE); pNode->AddRef(); pNode->Create(IDR_COMPSRES_BIG_COMPUTER, rctPosition, _T("big_computer")); pNode->AddText(_T(""), strName, rctTitlePos); pNode->AllowLabelSelect(FALSE); m_shapes.push_back(pNode); GetCurrentModel()->InsertShape(pNode); pNode->UpdateComp(); pNode->Release(); return pNode; }
CMyShape* CVisualADSView::addDomain(ADObject *aDObject, CString strName, int iX1, int iY1, int iX2, int iY2) { //生成一个域的shape CRect rctPosition = CRect(iX1, iY1, iX2, iY2); CRect rctTitlePos = CRect(0, (iY2-iY1)-25, (iX2 - iX1), iY2-iY1); //tech.adtest.net CMyShape *pNode = new CMyShape(aDObject, this, FALSE); pNode->AddRef(); pNode->Create(IDR_COMPSRES_DOMAIN, rctPosition, _T("domain")); pNode->AddText(_T(""), strName, rctTitlePos); pNode->AllowLabelSelect(FALSE); m_shapes.push_back(pNode); CFODataModel *pModel = GetCurrentModel(); pModel->InsertShape(pNode); pNode->UpdateComp(); pNode->Release(); return pNode; }
void cCustomTitleModelTable::resizeEvent(QResizeEvent *ev) { if (ModelTable) { QString Current=GetCurrentModel(); // Update view int ColumnWidth =ModelTable->ThumbnailSize.width()+20; int RowHeight =ModelTable->ThumbnailSize.height()+20; int NewColumnCount=width()/ColumnWidth; if (NewColumnCount<=0) NewColumnCount=1; int NewRowCount =ModelTable->List.count()/NewColumnCount; if (NewRowCount*NewColumnCount<ModelTable->List.count()) NewRowCount++; if ((NewColumnCount!=columnCount())||(NewRowCount!=rowCount())) { setColumnCount(NewColumnCount); setRowCount(NewRowCount); } for (int i=0;i<columnCount();i++) setColumnWidth(i,ColumnWidth); for (int i=0;i<rowCount();i++) setRowHeight(i,RowHeight); SetCurrentModel(Current); } QTableWidget::resizeEvent(ev); }
CMyShape* CVisualADSView::addComputer(ADObject *aDObject, CString strName, int iX, int iY) { //生成一个不带共享文件夹的计算机的shape CRect rctPosition = CRect(iX - m_ptComputerSize.x/2, iY - m_ptComputerSize.y/2, iX + m_ptComputerSize.x/2, iY + m_ptComputerSize.y/2); CRect rctTitlePos = CRect(0, 0, m_ptComputerSize.x, m_ptComputerSize.y); CMyShape *pNode = new CMyShape(aDObject, this, TRUE); pNode->AddRef(); pNode->Create(IDR_COMPSRES_COMPUTER, rctPosition, _T("computer")); pNode->AddText(_T(""), strName, rctTitlePos); for (int i = 0; i < 12; i ++) { pNode->GetPortAt(i)->SetPortType(FO_PORT_NOTSHOW); } pNode->AllowLabelSelect(FALSE); m_shapes.push_back(pNode); GetCurrentModel()->InsertShape(pNode); pNode->UpdateComp(); pNode->Release(); return pNode; }
void CVisualADSView::DoChangeCanvasSize(CPoint ptGraphSize) { CSize szCanvas = CSize(ptGraphSize.x, ptGraphSize.y); GetCurrentModel()->SetCanvasSize(szCanvas); }
CFOLinkShape* CVisualADSView::addShareRelation(CString strName, CFODrawPortsShape *pShape1, CFODrawPortsShape *pShape2, int iPermission, BOOL bBothRelation) { //生成share权限的linkshape CFOPortShape *pStart; CFOPortShape *pEnd; if (bBothRelation == TRUE) { if (pShape1->GetTopLeft().x < pShape2->GetTopLeft().x) { pStart = pShape1->GetPortAt(CLOCK_4); pEnd = pShape2->GetPortAt(CLOCK_9/*CLOCK_8*/); } else if (pShape1->GetTopLeft().x > pShape2->GetTopLeft().x) { pStart = pShape1->GetPortAt(CLOCK_8); pEnd = pShape2->GetPortAt(CLOCK_4); } else if (pShape1->GetTopLeft().y > pShape2->GetTopLeft().y) { pStart = pShape1->GetPortAt(CLOCK_3/*CLOCK_1*/); pEnd = pShape2->GetPortAt(CLOCK_3/*CLOCK_5*/); } else if (pShape1->GetTopLeft().y < pShape2->GetTopLeft().y) { pStart = pShape1->GetPortAt(CLOCK_3/*CLOCK_5*/); pEnd = pShape2->GetPortAt(CLOCK_3/*CLOCK_1*/); } else { MyMessageBox_Error(_T("addShareRelation Error."), _T("Error")); return NULL; } } else { if (pShape1->GetTopLeft().x < pShape2->GetTopLeft().x) { pStart = pShape1->GetPortAt(CLOCK_3); pEnd = pShape2->GetPortAt(CLOCK_9); } else if (pShape1->GetTopLeft().x > pShape2->GetTopLeft().x) { pStart = pShape1->GetPortAt(CLOCK_9); pEnd = pShape2->GetPortAt(CLOCK_3); } else if (pShape1->GetTopLeft().y > pShape2->GetTopLeft().y) { pStart = pShape1->GetPortAt(CLOCK_3/*CLOCK_0*/); pEnd = pShape2->GetPortAt(CLOCK_3/*CLOCK_6*/); } else if (pShape1->GetTopLeft().y < pShape2->GetTopLeft().y) { pStart = pShape1->GetPortAt(CLOCK_3/*CLOCK_6*/); pEnd = pShape2->GetPortAt(CLOCK_3/*CLOCK_0*/); } else { MyMessageBox_Error(_T("addShareRelation Error."), _T("Error")); return NULL; } } CFOLinkShape *pLinkComp = new CFOLinkShape(); pLinkComp->AddRef(); CPoint ptPoints[2]; ptPoints[0] = pStart->GetLinkPoint(); ptPoints[1] = pEnd->GetLinkPoint(); pLinkComp->Create(ptPoints, 2); pLinkComp->SetObjectCaption(strName); pLinkComp->SetFromPort(pStart); pLinkComp->SetToPort(pEnd); pLinkComp->SetLineWidth(2); pLinkComp->SetShadow(FALSE); if (iPermission == 0) { pLinkComp->SetLineColor(RGB(0, 0, 255)); } else if (iPermission == 1) { pLinkComp->SetLineColor(RGB(255, 0, 0)); } else if (iPermission == 2) { pLinkComp->SetLineColor(RGB(255, 0, 255)); } else { MyMessageBox_Error(_T("addShareRelation Error."), _T("Error")); return NULL; } pLinkComp->SetModel(GetCurrentModel()); pStart->AddLinkShape(pLinkComp); pEnd->AddLinkShape(pLinkComp); // Set arrow type. int nType = 5; pLinkComp->SetEndArrowType(nType); pLinkComp->DoEndPropChange(); GetCurrentModel()->AddChildAtTail(pLinkComp); pLinkComp->UpdateComp(); pLinkComp->RelayoutPoints(); //pLinkComp->Release(); m_links.push_back(pLinkComp); return pLinkComp; }
CFOLinkShape* CVisualADSView::addInheritRelation(CString strName, CFODrawPortsShape *pShape1, CFODrawPortsShape *pShape2) { //生成组成员关系的linkshape CFOPortShape *pStart; CFOPortShape *pEnd; if (pShape1->GetTopLeft().x < pShape2->GetTopLeft().x) { pStart = pShape1->GetPortAt(CLOCK_3); pEnd = pShape2->GetPortAt(CLOCK_9); } else if (pShape1->GetTopLeft().x > pShape2->GetTopLeft().x) { pStart = pShape1->GetPortAt(CLOCK_9); pEnd = pShape2->GetPortAt(CLOCK_3); } else if (pShape1->GetTopLeft().y > pShape2->GetTopLeft().y) { pStart = pShape1->GetPortAt(CLOCK_0); pEnd = pShape2->GetPortAt(CLOCK_6); } else if (pShape1->GetTopLeft().y < pShape2->GetTopLeft().y) { pStart = pShape1->GetPortAt(CLOCK_6); pEnd = pShape2->GetPortAt(CLOCK_0); } else { MyMessageBox_Error(_T("addInheritRelation Error."), _T("Error")); return NULL; } CFOLinkShape *pLinkComp = new CFOLinkShape(); pLinkComp->AddRef(); CPoint ptPoints[2]; ptPoints[0] = pStart->GetLinkPoint(); ptPoints[1] = pEnd->GetLinkPoint(); pLinkComp->Create(ptPoints, 2); pLinkComp->SetObjectCaption(strName); pLinkComp->SetFromPort(pStart); pLinkComp->SetToPort(pEnd); pLinkComp->SetLineWidth(2); pLinkComp->SetShadow(FALSE); pLinkComp->SetLineColor(RGB(0, 0, 51)); pLinkComp->SetModel(GetCurrentModel()); pStart->AddLinkShape(pLinkComp); pEnd->AddLinkShape(pLinkComp); // Set arrow type. int nType = 5; pLinkComp->SetEndArrowType(nType); pLinkComp->DoEndPropChange(); GetCurrentModel()->AddChildAtTail(pLinkComp); pLinkComp->UpdateComp(); pLinkComp->RelayoutPoints(); //pLinkComp->Release(); m_links.push_back(pLinkComp); return pLinkComp; }