当前位置: 首页>>代码示例>>C++>>正文


C++ GraphAttributes::labelEdge方法代码示例

本文整理汇总了C++中GraphAttributes::labelEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphAttributes::labelEdge方法的具体用法?C++ GraphAttributes::labelEdge怎么用?C++ GraphAttributes::labelEdge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphAttributes的用法示例。


在下文中一共展示了GraphAttributes::labelEdge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getBasicGraphAttributes

//*************************************************************
// returns GraphAttributes associated with basic graph i
//
void SimDraw::getBasicGraphAttributes(int i, GraphAttributes &GA, Graph &G)
{
    G = m_G;
    GA.init(G,m_GA.attributes());
    
    List<edge> LE;
    m_G.allEdges(LE);
    forall_listiterators(edge,it,LE)
	if(m_GA.inSubGraph(*it,i))
	{
	    node v;
	    forall_nodes(v,G)
	    {
		if(compare(GA,v,m_GA,(*it)->source()))
		{
		    if(m_GA.attributes() & GraphAttributes::nodeGraphics)
		    {
			GA.x(v) = m_GA.x((*it)->source());
			GA.y(v) = m_GA.y((*it)->source());
			GA.height(v) = m_GA.height((*it)->source());
			GA.width(v) = m_GA.width((*it)->source());
		    }
				
		    if(m_GA.attributes() & GraphAttributes::nodeId)
			GA.idNode(v) = m_GA.idNode((*it)->source());
		    
		    if(m_GA.attributes() & GraphAttributes::nodeLabel)
			GA.labelNode(v) = m_GA.labelNode((*it)->source());
		}
			
		if(compare(GA,v,m_GA,(*it)->target()))
		{
		    if(m_GA.attributes() & GraphAttributes::nodeGraphics)
		    {
			GA.x(v) = m_GA.x((*it)->target());
			GA.y(v) = m_GA.y((*it)->target());
			GA.height(v) = m_GA.height((*it)->target());
			GA.width(v) = m_GA.width((*it)->target());
		    }
				
		    if(m_GA.attributes() & GraphAttributes::nodeId)
			GA.idNode(v) = m_GA.idNode((*it)->target());
		    
		    if(m_GA.attributes() & GraphAttributes::nodeLabel)
			GA.labelNode(v) = m_GA.labelNode((*it)->target());
		}
	    }
	    
	    edge e;
	    forall_edges(e,G)
	    {
		if(compare(GA,e->source(),m_GA,(*it)->source())
		&& compare(GA,e->target(),m_GA,(*it)->target()))
		{
		    if(m_GA.attributes() & GraphAttributes::edgeIntWeight)
			GA.intWeight(e) = m_GA.intWeight(*it);
		    
		    if(m_GA.attributes() & GraphAttributes::edgeLabel)
			GA.labelEdge(e) = m_GA.labelEdge(*it);
		    
		    if(m_GA.attributes() & GraphAttributes::edgeColor)
			GA.colorEdge(e) = m_GA.colorEdge(*it);
		    
		    if(m_GA.attributes() & GraphAttributes::edgeGraphics)
			GA.bends(e) = m_GA.bends(*it);
		}
	    }
	}
开发者ID:,项目名称:,代码行数:71,代码来源:

示例2: read


//.........这里部分代码省略.........
					if (edgeSon->m_valueType != gmlStringValue) break;
					label = edgeSon->m_stringValue;
					break;

				case graphicsPredefKey: {
					if (edgeSon->m_valueType != gmlListBegin) break;

					GmlObject *graphicsObject = edgeSon->m_pFirstSon;
					for(; graphicsObject;
						graphicsObject = graphicsObject->m_pBrother)
					{
						if(id(graphicsObject) == LinePredefKey &&
							graphicsObject->m_valueType == gmlListBegin)
						{
							readLineAttribute(graphicsObject->m_pFirstSon,bends);
						}
                        if(id(graphicsObject) == arrowPredefKey &&
                            graphicsObject->m_valueType == gmlStringValue)
                                arrow = graphicsObject->m_stringValue;
						if(id(graphicsObject) == fillPredefKey &&
							graphicsObject->m_valueType == gmlStringValue)
								fill = graphicsObject->m_stringValue;
						if (id(graphicsObject) == stipplePredefKey && //line style
							graphicsObject->m_valueType == gmlIntValue) 
								stipple = graphicsObject->m_intValue;
						if (id(graphicsObject) == lineWidthPredefKey && //line width
							graphicsObject->m_valueType == gmlDoubleValue) 
								lineWidth = graphicsObject->m_doubleValue;
						if (id(graphicsObject) == edgeWeightPredefKey &&
							graphicsObject->m_valueType == gmlDoubleValue)
							edgeWeight = graphicsObject->m_doubleValue;
					}//for graphics
				}

				case generalizationPredefKey:
					if (edgeSon->m_valueType != gmlIntValue) break;
					umlType = (edgeSon->m_intValue == 0) ?
						Graph::association : Graph::generalization;
					break;

				}
			}

			// check if everything required is defined correctly
			if (sourceId == notDefined || targetId == notDefined) {
				setError("source or target id not defined");
				return false;

			} else if (sourceId < minId || maxId < sourceId ||
				targetId < minId || maxId < targetId) {
				setError("source or target id out of range");
				return false;
			}

			// create adjacent nodes if necessary and new edge
			if (m_mapToNode[sourceId] == 0) m_mapToNode[sourceId] = G.newNode();
			if (m_mapToNode[targetId] == 0) m_mapToNode[targetId] = G.newNode();

			edge e = G.newEdge(m_mapToNode[sourceId],m_mapToNode[targetId]);
			if (AG.attributes() & GraphAttributes::edgeGraphics)
				AG.bends(e).conc(bends);
			if (AG.attributes() & GraphAttributes::edgeType)
				AG.type(e) = umlType;
			if(AG.attributes() & GraphAttributes::edgeSubGraph)
			        AG.subGraphBits(e) = subGraph;
			if (AG.attributes() & GraphAttributes::edgeLabel)
				AG.labelEdge(e) = label;

            if (AG.attributes() & GraphAttributes::edgeArrow)
                if (arrow == "none")
                    AG.arrowEdge(e) = GraphAttributes::none;
                else if (arrow == "last")
                    AG.arrowEdge(e) = GraphAttributes::last;
                else if (arrow == "first")
                    AG.arrowEdge(e) = GraphAttributes::first;
                else if (arrow == "both")
                    AG.arrowEdge(e) = GraphAttributes::both;
                else
                    AG.arrowEdge(e) = GraphAttributes::undefined;
			if (AG.attributes() & GraphAttributes::edgeColor)
				AG.colorEdge(e) = fill;
			if (AG.attributes() & GraphAttributes::edgeStyle)
			{
				AG.styleEdge(e) = AG.intToStyle(stipple);
				AG.edgeWidth(e) = lineWidth;
			}

			if (AG.attributes() & GraphAttributes::edgeDoubleWeight)
				AG.doubleWeight(e) = edgeWeight;

            break; }
		case directedPredefKey: {
			if(son->m_valueType != gmlIntValue) break;
			AG.directed(son->m_intValue > 0);
			break; }
		}
	}

	return true;
}//read
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的GraphAttributes::labelEdge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。