void Build_StairStep(vec3_t min, vec3_t max, const char* mainTexture, const char* riserTexture, int direction) { NodeSmartReference newBrush(GlobalBrushCreator().createBrush()); //----- Build Outer Bounds --------- vec3_t v1, v2, v3, v5, v6, v7; VectorCopy(min, v1); VectorCopy(min, v2); VectorCopy(min, v3); VectorCopy(max, v5); VectorCopy(max, v6); VectorCopy(max, v7); v2[0] = max[0]; v3[1] = max[1]; v6[0] = min[0]; v7[1] = min[1]; //---------------------------------- AddFaceWithTexture(newBrush, v6, v5, v7, mainTexture, false); // top gets current texture if(direction == MOVE_EAST) AddFaceWithTexture(newBrush, v1, v3, v6, riserTexture, false); else AddFaceWithTexture(newBrush, v1, v3, v6, "textures/common/caulk", false); // west facing side, etc... if(direction == MOVE_NORTH) AddFaceWithTexture(newBrush, v1, v7, v2, riserTexture, false); else AddFaceWithTexture(newBrush, v1, v7, v2, "textures/common/caulk", false); if(direction == MOVE_SOUTH) AddFaceWithTexture(newBrush, v3, v5, v6, riserTexture, false); else AddFaceWithTexture(newBrush, v3, v5, v6, "textures/common/caulk", false); if(direction == MOVE_WEST) AddFaceWithTexture(newBrush, v7, v5, v2, riserTexture, false); else AddFaceWithTexture(newBrush, v7, v5, v2, "textures/common/caulk", false); AddFaceWithTexture(newBrush, v1, v2, v3, "textures/common/caulk", false); // base is caulked Node_getTraversable(GlobalRadiant().getMapWorldEntity())->insert(newBrush); // finish brush }
// internal use only, to get a box without finishing construction scene::Node& Build_Get_BoundingCube_Selective(vec3_t min, vec3_t max, char* texture, bool* useFaces) { NodeSmartReference newBrush(GlobalBrushCreator().createBrush()); //----- Build Outer Bounds --------- vec3_t v1, v2, v3, v5, v6, v7; VectorCopy(min, v1); VectorCopy(min, v2); VectorCopy(min, v3); VectorCopy(max, v5); VectorCopy(max, v6); VectorCopy(max, v7); v2[0] = max[0]; v3[1] = max[1]; v6[0] = min[0]; v7[1] = min[1]; //---------------------------------- //----- Add Six Cube Faces --------- if(useFaces[0]) AddFaceWithTexture(newBrush, v1, v2, v3, texture, false); if(useFaces[1]) AddFaceWithTexture(newBrush, v1, v3, v6, texture, false); if(useFaces[2]) AddFaceWithTexture(newBrush, v1, v7, v2, texture, false); if(useFaces[3]) AddFaceWithTexture(newBrush, v5, v6, v3, texture, false); if(useFaces[4]) AddFaceWithTexture(newBrush, v5, v2, v7, texture, false); if(useFaces[5]) AddFaceWithTexture(newBrush, v5, v7, v6, texture, false); //---------------------------------- return newBrush; }
void QgsComposerScaleBarWidget::on_mColorPushButton_clicked() { if ( !mComposerScaleBar ) { return; } QColor oldColor = mComposerScaleBar->brush().color(); QColor newColor = QColorDialog::getColor( oldColor, 0 ); if ( !newColor.isValid() ) //user canceled the dialog { return; } mComposerScaleBar->beginCommand( tr( "Scalebar color changed" ) ); disconnectUpdateSignal(); QBrush newBrush( newColor ); mComposerScaleBar->setBrush( newBrush ); mComposerScaleBar->update(); connectUpdateSignal(); mComposerScaleBar->endCommand(); }
// Paint the contents of an item in local coordinates void UvmPortView::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) { // Paint an in port if(model->getMode() == UvmPort::DUT && model->getDirection() == UvmPort::PORT_IN) { painter->setRenderHint(QPainter::Antialiasing); QBrush newBrush(QColor(0,255,0)); painter->setBrush(newBrush); painter->drawPolygon(poly, Qt::WindingFill); painter->drawText(12, 3, model->getName()); } // Paint an out port if(model->getMode() == UvmPort::DUT && model->getDirection() == UvmPort::PORT_OUT) { painter->setRenderHint(QPainter::Antialiasing); QBrush newBrush(QColor(0,0,255)); painter->setBrush(newBrush); painter->drawPolygon(poly, Qt::WindingFill); QRect bounding = painter->boundingRect(QRect(-70,-8,65,20), Qt::AlignRight, model->getName()); painter->drawText(bounding, Qt::AlignRight, model->getName()); } // Paint an inout port if(model->getMode() == UvmPort::DUT && model->getDirection() == UvmPort::PORT_INOUT) { } // Paint an interface port if(model->getMode() == UvmPort::DUT_INTERFACE || model->getMode() == UvmPort::VC_INTERFACE || model->getMode() == UvmPort::VCTODUT_INTERFACE) { painter->setRenderHint(QPainter::Antialiasing); QBrush newBrush(QColor(255,0,0)); painter->setBrush(newBrush); painter->drawPolygon(poly, Qt::WindingFill); //painter->drawText(poly.boundingRect(), Qt::AlignCenter, model->getName()); } // Paint a tlm round port if((model->getMode() == UvmPort::UVM_ANALYSIS_IMP)|| (model->getMode() == UvmPort::UVM_BLOCKING_PUT_IMP)|| (model->getMode() == UvmPort::UVM_BLOCKING_GET_IMP)|| (model->getMode() == UvmPort::UVM_SEQ_ITEM_PULL_IMP)|| (model->getMode() == UvmPort::UVM_BLOCKING_PEEK_IMP)) { painter->setRenderHint(QPainter::Antialiasing); QBrush newBrush(QColor(255,0,0)); painter->setBrush(newBrush); painter->drawEllipse(QPointF(0, 0), 5, 5); } // Paint a tlm diamond port if((model->getMode() == UvmPort::UVM_ANALYSIS_PORT && false /* doit etre sur un moniteur!*/)) { painter->setRenderHint(QPainter::Antialiasing); QBrush newBrush(QColor(255,0,0)); painter->setBrush(newBrush); painter->drawPolygon(poly, Qt::WindingFill); } // Paint a tlm square port if((model->getMode() == UvmPort::UVM_ANALYSIS_PORT) || (model->getMode() == UvmPort::UVM_BLOCKING_PUT_PORT) || (model->getMode() == UvmPort::UVM_BLOCKING_GET_PORT) || (model->getMode() == UvmPort::UVM_SEQ_ITEM_PULL_PORT) || (model->getMode() == UvmPort::UVM_BLOCKING_PEEK_PORT)) { painter->setRenderHint(QPainter::Antialiasing); QBrush newBrush(QColor(255,0,0)); painter->setBrush(newBrush); painter->drawPolygon(poly, Qt::WindingFill); } //Do not paint the global one }
void CardsList::paintEvent(QPaintEvent *) { QPainter painter(this); if(!ls.empty()) { int fmHeight = painter.fontMetrics().height(); int h = height(), cardHeight = cardSize.height(), cardWidth = cardSize.width(); cardsPerColumn = h / cardHeight; decltype(items) newItems; double varHeight = h - cardHeight * 1.0; for(int i : range(std::min(cardsPerColumn, ls.size() - pos))) { quint32 id = ls[i + pos]; auto it = newItems.insert(i + pos, CardItem(id)); auto &item = it.value(); int y = varHeight * i / (cardsPerColumn - 1); current = itemAt(mapFromGlobal(QCursor::pos())); if(i + pos == current) { QBrush brush = painter.brush(), newBrush(Qt::lightGray); QPen pen = painter.pen(); painter.setPen(Qt::transparent); QColor color(newBrush.color()); color.setAlpha(160); newBrush.setColor(color); painter.setBrush(newBrush); painter.drawRect(QRect(QPoint(0, y), QSize(sb->geometry().x(), cardSize.height()))); painter.setBrush(brush); painter.setPen(pen); } item.setPos(QPoint(0, y)); painter.drawPixmap(0, y, cardWidth, cardHeight, *item.getPixmap().data()); int lim = limitCards->getLimit(it->getId()); if(lim < 3) { auto data = limitCards->getPixmap(lim); if(data) { painter.drawPixmap(0, y, 16, 16, *data); } } call_with_ref([&](Card &card) { painter.drawText(cardWidth + 5, y + fmHeight, card.name); QString ot; QString level = (card.type & Const::TYPE_XYZ) ? "R" : "L"; level = "[" + level + QString::number(card.level) + "]"; if((card.ot & 0x3) == 1) { ot = tr("[OCG]"); } else if((card.ot & 0x3) == 2) { ot = tr("[TCG]"); } if(card.type & Const::TYPE_MONSTER) { painter.drawText(cardWidth + 5, y + 5 + fmHeight * 2, card.cardRace() + "/" + card.cardAttr() + level); painter.drawText(cardWidth + 5, y + 10 + fmHeight * 3, adToString(card.atk) + "/" + adToString(card.def) + ot); } else if(card.type & (Const::TYPE_SPELL | Const::TYPE_TRAP)) { painter.drawText(cardWidth + 5, y + 5 + fmHeight * 2, card.cardType()); painter.drawText(cardWidth + 5, y + 10 + fmHeight * 3, ot); } }, cardPool->getCard(id)); } items.swap(newItems); } if(needRefreshId) { refreshCurrentId(); needRefreshId = false; } refresh(); }
void CHistogramDlg::OnPaint() { CDialog::OnPaint(); // color definition COLORREF black = RGB(0, 0, 0); COLORREF gray; // Get max value of histogram int hmax = 0; for(size_t i = 0; i < hist_value_.size(); i++ ) { if( hmax < hist_value_[i] ) { hmax = hist_value_[i]; } } // drawing CPaintDC dc(&show_hist_); // device context for painting // select new pen and new brush CPen newPen(PS_SOLID, 1, black); CPen* pOldPen = dc.SelectObject(&newPen); CBrush newBrush(black); CBrush* pOldBrush = dc.SelectObject(&newBrush); // get client size CRect rect; show_hist_.GetClientRect(&rect); // draw border dc.MoveTo( rect.left, rect.top ); dc.LineTo( rect.right, rect.top ); dc.MoveTo( rect.right, rect.top ); dc.LineTo( rect.right, rect.bottom ); dc.MoveTo( rect.right, rect.bottom ); dc.LineTo( rect.left, rect.bottom ); dc.MoveTo( rect.left, rect.bottom ); dc.LineTo( rect.left, rect.top ); // draw histogram float width = rect.right - rect.left - 1; float height = rect.bottom - rect.top - 1; float xstart = 1; float top = height; float step = width / hist_value_.size(); rect.bottom = height + 1; for(size_t i = 0; i < hist_value_.size() ; i++) { rect.left = (long)xstart; rect.right = (long)(xstart + step); rect.top = (long)(height + 1 - ((float)hist_value_[i] / hmax) * top); dc.FillRect( rect, &newBrush ); xstart += step; } dc.SelectObject( pOldBrush ); dc.SelectObject( pOldPen ); // IDC_HISTOGRAM_GRAY CPaintDC dc2(&show_gray_); // device context for painting show_gray_.GetClientRect(&rect); // draw border dc2.MoveTo( rect.left, rect.top ); dc2.LineTo( rect.right, rect.top ); dc2.MoveTo( rect.right, rect.top ); dc2.LineTo( rect.right, rect.bottom ); dc2.MoveTo( rect.right, rect.bottom ); dc2.LineTo( rect.left, rect.bottom ); dc2.MoveTo( rect.left, rect.bottom ); dc2.LineTo( rect.left, rect.top ); width = rect.right - rect.left - 1; height = rect.bottom - rect.top - 1; xstart = 1; step = 1; rect.bottom = height + 1; rect.top = 1; for(int i = 0; i < (int)width; i++) { rect.left = (long) xstart; rect.right = (long) (xstart + step); char component = (int)((float)i / width * 256.0); gray = RGB( component, component, component ); CBrush brush(gray); pOldBrush = dc2.SelectObject(&brush); dc2.FillRect( rect, &brush ); xstart += step; dc2.SelectObject( pOldBrush ); } }
void Build_StairStep_Wedge(int dir, vec3_t min, vec3_t max, const char* mainTexture, const char* riserTexture, bool detail) { NodeSmartReference newBrush(GlobalBrushCreator().createBrush()); //----- Build Outer Bounds --------- vec3_t v1, v2, v3, v5, v6, v7, v8; VectorCopy(min, v1); VectorCopy(min, v2); VectorCopy(min, v3); VectorCopy(max, v5); VectorCopy(max, v6); VectorCopy(max, v7); VectorCopy(max, v8); v2[0] = max[0]; v3[1] = max[1]; v6[0] = min[0]; v7[1] = min[1]; v8[2] = min[2]; //v8 needed this time, becoz of sloping faces (2-4-6-8) //---------------------------------- AddFaceWithTexture(newBrush, v6, v5, v7, mainTexture, detail); if(dir != MOVE_EAST) { if(dir == MOVE_WEST) AddFaceWithTexture(newBrush, v5, v2, v7, riserTexture, detail); else AddFaceWithTexture(newBrush, v5, v2, v7, "textures/common/caulk", detail); } if(dir != MOVE_WEST) { if(dir == MOVE_EAST) AddFaceWithTexture(newBrush, v1, v3, v6, riserTexture, detail); else AddFaceWithTexture(newBrush, v1, v3, v6, "textures/common/caulk", detail); } if(dir != MOVE_NORTH) { if(dir == MOVE_SOUTH) AddFaceWithTexture(newBrush, v3, v5, v6, riserTexture, detail); else AddFaceWithTexture(newBrush, v3, v5, v6, "textures/common/caulk", detail); } if(dir != MOVE_SOUTH) { if(dir == MOVE_NORTH) AddFaceWithTexture(newBrush, v1, v7, v2, riserTexture, detail); else AddFaceWithTexture(newBrush, v1, v7, v2, "textures/common/caulk", detail); } if(dir == MOVE_EAST) AddFaceWithTexture(newBrush, v1, v5, v3, "textures/common/caulk", detail); if(dir == MOVE_WEST) AddFaceWithTexture(newBrush, v2, v8, v6, "textures/common/caulk", detail); if(dir == MOVE_NORTH) AddFaceWithTexture(newBrush, v1, v5, v6, "textures/common/caulk", detail); if(dir == MOVE_SOUTH) AddFaceWithTexture(newBrush, v7, v8, v3, "textures/common/caulk", detail); Node_getTraversable(GlobalRadiant().getMapWorldEntity())->insert(newBrush); }
void Build_Wedge(int dir, vec3_t min, vec3_t max, bool bUp) { NodeSmartReference newBrush(GlobalBrushCreator().createBrush()); vec3_t v1, v2, v3, v5, v6, v7, v8; VectorCopy(min, v1); VectorCopy(min, v2); VectorCopy(min, v3); VectorCopy(max, v5); VectorCopy(max, v6); VectorCopy(max, v7); VectorCopy(max, v8); v2[0] = max[0]; v3[1] = max[1]; v6[0] = min[0]; v7[1] = min[1]; v8[2] = min[2]; if(bUp) { if(dir != MOVE_EAST) AddFaceWithTexture(newBrush, v1, v3, v6, "textures/common/caulk", false); if(dir != MOVE_WEST) AddFaceWithTexture(newBrush, v7, v5, v8, "textures/common/caulk", false); if(dir != MOVE_NORTH) AddFaceWithTexture(newBrush, v1, v7, v2, "textures/common/caulk", false); if(dir != MOVE_SOUTH) AddFaceWithTexture(newBrush, v3, v8, v6, "textures/common/caulk", false); AddFaceWithTexture(newBrush, v1, v2, v3, "textures/common/caulk", false); if(dir == MOVE_EAST) AddFaceWithTexture(newBrush, v1, v3, v5, "textures/common/caulk", false); if(dir == MOVE_WEST) AddFaceWithTexture(newBrush, v2, v6, v8, "textures/common/caulk", false); if(dir == MOVE_NORTH) AddFaceWithTexture(newBrush, v1, v6, v5, "textures/common/caulk", false); if(dir == MOVE_SOUTH) AddFaceWithTexture(newBrush, v7, v3, v8, "textures/common/caulk", false); } else { if(dir != MOVE_WEST) AddFaceWithTexture(newBrush, v7, v5, v8, "textures/common/caulk", false); if(dir != MOVE_EAST) AddFaceWithTexture(newBrush, v1, v3, v6, "textures/common/caulk", false); if(dir != MOVE_NORTH) AddFaceWithTexture(newBrush, v3, v8, v6, "textures/common/caulk", false); if(dir != MOVE_SOUTH) AddFaceWithTexture(newBrush, v1, v7, v2, "textures/common/caulk", false); AddFaceWithTexture(newBrush, v6, v5, v7, "textures/common/caulk", false); if(dir == MOVE_WEST) AddFaceWithTexture(newBrush, v1, v5, v3, "textures/common/caulk", false); if(dir == MOVE_EAST) AddFaceWithTexture(newBrush, v2, v8, v6, "textures/common/caulk", false); if(dir == MOVE_NORTH) AddFaceWithTexture(newBrush, v1, v5, v6, "textures/common/caulk", false); if(dir == MOVE_SOUTH) AddFaceWithTexture(newBrush, v7, v8, v3, "textures/common/caulk", false); } Node_getTraversable(GlobalRadiant().getMapWorldEntity())->insert(newBrush); }
void CMdlPanel::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: add draw code here //创建新的字体 CFont font; VERIFY(font.CreateFontIndirect(&m_mylf)); HFONT hFont = (HFONT)font; HFONT hOldFont = (HFONT)::SelectObject(pDC->m_hDC, hFont); pDC->SetBkMode(TRANSPARENT); //设置背景透明,防止字体底色同组件背景色不符 //====================== 画连线 ================================================== for (unsigned int i = 0; i < g_pApp->m_miseModel.connlines.size(); i++) { //被选中的连线 if (g_pApp->m_miseModel.connlines[i].m_isSelected) { CPen newPen, *oldPen; newPen.CreatePen(PS_SOLID, 1, SLCT_LINE_CLR); oldPen = pDC->SelectObject(&newPen); pDC->MoveTo(g_pApp->m_miseModel.connlines[i].startPoint); if ( g_pApp->m_miseModel.connlines[i].break2y == -1 ) { pDC->LineTo(g_pApp->m_miseModel.connlines[i].break1x, g_pApp->m_miseModel.connlines[i].startPoint.y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].break1x, g_pApp->m_miseModel.connlines[i].endPoint.y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].endPoint); } else { pDC->LineTo(g_pApp->m_miseModel.connlines[i].break1x,g_pApp->m_miseModel.connlines[i].startPoint.y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].break1x, g_pApp->m_miseModel.connlines[i].break2y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].break3x, g_pApp->m_miseModel.connlines[i].break2y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].break3x, g_pApp->m_miseModel.connlines[i].endPoint.y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].endPoint); } pDC->SelectObject(oldPen); newPen.DeleteObject(); } //未被选中的连线 else { CPen newPen, *oldPen; newPen.CreatePen(PS_SOLID, 1, LINE_CLR); oldPen = pDC->SelectObject(&newPen); pDC->MoveTo(g_pApp->m_miseModel.connlines[i].startPoint); if ( g_pApp->m_miseModel.connlines[i].break2y == -1 ) { pDC->LineTo(g_pApp->m_miseModel.connlines[i].break1x, g_pApp->m_miseModel.connlines[i].startPoint.y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].break1x, g_pApp->m_miseModel.connlines[i].endPoint.y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].endPoint); } else { pDC->LineTo(g_pApp->m_miseModel.connlines[i].break1x,g_pApp->m_miseModel.connlines[i].startPoint.y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].break1x, g_pApp->m_miseModel.connlines[i].break2y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].break3x, g_pApp->m_miseModel.connlines[i].break2y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].break3x, g_pApp->m_miseModel.connlines[i].endPoint.y); pDC->LineTo(g_pApp->m_miseModel.connlines[i].endPoint); } pDC->SelectObject(oldPen); newPen.DeleteObject(); } } //========================== end of 画连线 ================================================== //===================== 画组件 ============================================== for(unsigned int i = 0; i < g_pApp->m_miseModel.components.size(); i++) { CRect nameRect; if ( g_pApp->m_miseModel.components[i]->isSelected ) { CPen newPen, *pOldPen; newPen.CreatePen(PS_SOLID, 1, SLCT_COMP_CLR); pOldPen = pDC->SelectObject(&newPen); CBrush newBrush(COM_BKCLR); CBrush* pOldBrush = pDC->SelectObject(&newBrush); pDC->Rectangle(g_pApp->m_miseModel.components[i]->GetRect()); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); newPen.DeleteObject(); newBrush.DeleteObject(); } else { CPen newPen, *pOldPen; newPen.CreatePen(PS_SOLID, 1, COMP_CLR); pOldPen = pDC->SelectObject(&newPen); CBrush newBrush(COM_BKCLR); CBrush* pOldBrush = pDC->SelectObject(&newBrush); pDC->Rectangle(g_pApp->m_miseModel.components[i]->GetRect()); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); newPen.DeleteObject(); newBrush.DeleteObject(); } //显示模块名称和执行顺序 nameRect.top = g_pApp->m_miseModel.components[i]->GetRect().bottom + 1; nameRect.bottom = nameRect.top + 10; nameRect.left = g_pApp->m_miseModel.components[i]->GetRect().left - 20; nameRect.right = g_pApp->m_miseModel.components[i]->GetRect().right + 20; CString strNameAndOrder; strNameAndOrder.Format("%s [%d]", g_pApp->m_miseModel.components[i]->GetName(), i); pDC->DrawText(strNameAndOrder, strNameAndOrder.GetLength(), &nameRect, DT_TOP | DT_CENTER | DT_NOCLIP); //--------------- 画输入输出接口------------------------------------------------- for (unsigned int j = 0; j < g_pApp->m_miseModel.components[i]->inputs.size(); j++) { pDC->MoveTo(g_pApp->m_miseModel.components[i]->inputs[j].pos.x - IO_ARROW_SIZE, g_pApp->m_miseModel.components[i]->inputs[j].pos.y - IO_ARROW_SIZE); pDC->LineTo(g_pApp->m_miseModel.components[i]->inputs[j].pos.x, g_pApp->m_miseModel.components[i]->inputs[j].pos.y); pDC->LineTo(g_pApp->m_miseModel.components[i]->inputs[j].pos.x - IO_ARROW_SIZE, g_pApp->m_miseModel.components[i]->inputs[j].pos.y + IO_ARROW_SIZE); if ( g_pApp->m_miseModel.components[i]->m_displayPortName ) { //定义显示接口名称的区域 nameRect.top = g_pApp->m_miseModel.components[i]->inputs[j].pos.y -5; nameRect.bottom = g_pApp->m_miseModel.components[i]->inputs[j].pos.y + 5; nameRect.left = g_pApp->m_miseModel.components[i]->inputs[j].pos.x + 2; nameRect.right = (g_pApp->m_miseModel.components[i]->GetRect().left + g_pApp->m_miseModel.components[i]->GetRect().right) / 2 - 1; //加法器特殊处理,只显示正负号 if ( g_pApp->m_miseModel.components[i]->type == MATH_ADD) { if(g_pApp->m_miseModel.components[i]->inputs[j].name.GetAt(0) == '-') { pDC->DrawText("-", 1, &nameRect, DT_VCENTER | DT_LEFT); } else { pDC->DrawText("+", 1, &nameRect, DT_VCENTER | DT_LEFT); } } else { pDC->DrawText(g_pApp->m_miseModel.components[i]->inputs[j].name, g_pApp->m_miseModel.components[i]->inputs[j].name.GetLength(), &nameRect, DT_VCENTER | DT_LEFT); } } } for (unsigned int j = 0; j < g_pApp->m_miseModel.components[i]->outputs.size(); j++) { pDC->MoveTo(g_pApp->m_miseModel.components[i]->outputs[j].pos.x, g_pApp->m_miseModel.components[i]->outputs[j].pos.y - IO_ARROW_SIZE); pDC->LineTo(g_pApp->m_miseModel.components[i]->outputs[j].pos.x + IO_ARROW_SIZE, g_pApp->m_miseModel.components[i]->outputs[j].pos.y); pDC->LineTo(g_pApp->m_miseModel.components[i]->outputs[j].pos.x, g_pApp->m_miseModel.components[i]->outputs[j].pos.y + IO_ARROW_SIZE); if ( g_pApp->m_miseModel.components[i]->m_displayPortName && g_pApp->m_miseModel.components[i]->type != MATH_ADD && g_pApp->m_miseModel.components[i]->type != MATH_POW) { //定义显示接口名称的区域 nameRect.top = g_pApp->m_miseModel.components[i]->outputs[j].pos.y -5; nameRect.bottom = g_pApp->m_miseModel.components[i]->outputs[j].pos.y + 5; nameRect.left = (g_pApp->m_miseModel.components[i]->GetRect().left + g_pApp->m_miseModel.components[i]->GetRect().right) / 2 + 1; nameRect.right = g_pApp->m_miseModel.components[i]->outputs[j].pos.x - 2; pDC->DrawText(g_pApp->m_miseModel.components[i]->outputs[j].name, g_pApp->m_miseModel.components[i]->outputs[j].name.GetLength(), &nameRect, DT_VCENTER | DT_RIGHT); } } //----------------- end of 画输入输出接口 ------------------------------------ //根据不同类型得组件显示不同的信息,便于观察 switch ( g_pApp->m_miseModel.components[i]->type ) { case(SRC_CLOCK): { Mise_source_clock *pSourceClock = (Mise_source_clock*)(g_pApp->m_miseModel.components[i]); CPoint ptTmp = pSourceClock->rect.CenterPoint(); int radius = pSourceClock->rect.Width() < pSourceClock->rect.Height() ? pSourceClock->rect.Width() / 2 : pSourceClock->rect.Height() / 2; ASSERT (radius > 0); if(radius > 30 ) { radius = 30; } CRect rectTmp( ptTmp.x - radius + 6, ptTmp.y - radius + 6, ptTmp.x + radius - 6, ptTmp.y + radius - 6 ); pDC->Ellipse(&rectTmp); pDC->MoveTo(ptTmp.x, ptTmp.y - radius + 10 ); pDC->LineTo(ptTmp); pDC->LineTo(ptTmp.x + radius - 13, ptTmp.y); break; } case(SRC_STEP): { Mise_source_step *pSourceStep = (Mise_source_step*)(g_pApp->m_miseModel.components[i]); CPoint ptTmp = pSourceStep->rect.CenterPoint(); int radius = pSourceStep->rect.Width() < pSourceStep->rect.Height() ? pSourceStep->rect.Width() / 2 : pSourceStep->rect.Height() / 2; ASSERT (radius > 0); if(radius > 30 ) { radius = 30; } pDC->MoveTo(ptTmp.x - radius + 10, ptTmp.y + radius - 15); pDC->LineTo(ptTmp.x, ptTmp.y + radius - 15); pDC->LineTo(ptTmp.x, ptTmp.y - radius + 15); pDC->LineTo(ptTmp.x + radius - 10, ptTmp.y - radius + 15); break; } case(SRC_SIN): { Mise_source_sin *pSourceSin = (Mise_source_sin*)(g_pApp->m_miseModel.components[i]); pDC->DrawText(pSourceSin->m_title, pSourceSin->m_title.GetLength(), &(pSourceSin->rect), DT_SINGLELINE | DT_VCENTER | DT_CENTER); break; } case(SRC_COS): { Mise_source_cos *pSourceCos = (Mise_source_cos*)(g_pApp->m_miseModel.components[i]); pDC->DrawText(pSourceCos->m_title, pSourceCos->m_title.GetLength(), &(pSourceCos->rect), DT_SINGLELINE | DT_VCENTER | DT_CENTER); break; } case(SRC_CONST): { Mise_source_const *pSourceConst = (Mise_source_const*)(g_pApp->m_miseModel.components[i]); CString strTmp; strTmp.Format("%f", pSourceConst->m_value); DelEndZeroFromStr(strTmp); pDC->DrawText(strTmp, strTmp.GetLength(), &(g_pApp->m_miseModel.components[i]->rect), DT_SINGLELINE | DT_VCENTER | DT_CENTER); break; } case(CONT_TRANSFUN): { Mise_cont_transfunction *pContTranFun = (Mise_cont_transfunction*)(g_pApp->m_miseModel.components[i]); int maxLength = max(pContTranFun->m_title_up.GetLength(), pContTranFun->m_title_down.GetLength()); CPoint ptTmp = pContTranFun->rect.CenterPoint(); CRect rectTmp(pContTranFun->rect.left, ptTmp.y - 12, pContTranFun->rect.right, ptTmp.y - 2); pDC->DrawText(pContTranFun->m_title_up, pContTranFun->m_title_up.GetLength(), &(rectTmp), DT_SINGLELINE | DT_VCENTER | DT_CENTER); rectTmp.top = ptTmp.y + 2; rectTmp.bottom = ptTmp.y + 12; pDC->DrawText(pContTranFun->m_title_down, pContTranFun->m_title_down.GetLength(), &(rectTmp), DT_SINGLELINE | DT_VCENTER | DT_CENTER); CString strTmp; for ( int i = 0; i < maxLength + 1; i++ ) { strTmp += "-"; } rectTmp.top = ptTmp.y - 2; rectTmp.bottom = ptTmp.y + 2; pDC->DrawText(strTmp, strTmp.GetLength(), &(rectTmp), DT_SINGLELINE | DT_VCENTER | DT_CENTER); break; } case(CONT_ZEROPOLE): { Mise_cont_ZeroPole *pContZeroPole = (Mise_cont_ZeroPole*)(g_pApp->m_miseModel.components[i]); int maxLength = max(pContZeroPole->m_title_up.GetLength(), pContZeroPole->m_title_down.GetLength()); CPoint ptTmp = pContZeroPole->rect.CenterPoint(); CRect rectTmp(pContZeroPole->rect.left, ptTmp.y - 12, pContZeroPole->rect.right, ptTmp.y - 2); pDC->DrawText(pContZeroPole->m_title_up, pContZeroPole->m_title_up.GetLength(), &(rectTmp), DT_SINGLELINE | DT_VCENTER | DT_CENTER); rectTmp.top = ptTmp.y + 2; rectTmp.bottom = ptTmp.y + 12; pDC->DrawText(pContZeroPole->m_title_down, pContZeroPole->m_title_down.GetLength(), &(rectTmp), DT_SINGLELINE | DT_VCENTER | DT_CENTER); CString strTmp; for ( int i = 0; i < maxLength + 1; i++ ) { strTmp += "-"; } rectTmp.top = ptTmp.y - 2; rectTmp.bottom = ptTmp.y + 2; pDC->DrawText(strTmp, strTmp.GetLength(), &(rectTmp), DT_SINGLELINE | DT_VCENTER | DT_CENTER); break; } default: { break; } } } //====================== end of 画组件 =========================================== //恢复字体 ::SelectObject(pDC->m_hDC, hOldFont); //restore old font ::DeleteObject(hFont); }