///
/// show(): Generates the SVG drawing output file for each pedigree.
///
void DrawingCanvas::show(const char* filename){
	
	// If label and/or icon legends are present
	// readjust the x and y extents:
	if(_labelSet->getNumberOfLabels() != 0 || _iconLegendFlag){ 
		_xMinimum -= _labelLegend.getWidth();
		double height = _labelLegend.getHeight();
		if(_iconLegendFlag) height += _iconLegend.getHeight();
		if(height > getYRange()) {
			_yMaximum += (height - getYRange());
		}
	}
	//
	// Only set the header now because at this point the
	// true x and y extents (width and height) are known:
	_setHeader();
	
	//
	// Add the legends:
	//
	_drawLegends();
	
	std::ofstream svgfile(filename);
	if(svgfile.is_open()){
		svgfile << _header.str() << std::endl;
		
		/////////////////////////////////////////////////////
		//
		// 2009.05.21.ET:
		// Dump the bottommost layer (for curved connectors)
		//
		/////////////////////////////////////////////////////
		svgfile << " <g id=\"bottomLayer" << "\" class=\"layer\" >\n";
		svgfile << _bottomLayer.str() << std::endl;
		svgfile << " </g>\n";
		
		
		for(unsigned i=0;i<_layers.size();i++){
			
			svgfile << _layers[i] << std::endl;
			
		}
		
		svgfile << _body.str()   << std::endl;
		svgfile << _footer.str() << std::endl;
		svgfile.close();
		
	}else{
		
		std::cout << "Unable to open file " << filename << std::endl;
		
	}
}
///
/// show(): Generates the SVG drawing output file for each pedigree.
///
void DrawingCanvas::show(const char* filename){
	
	
	// DEBUG:
	//std::cout << _header << std::endl;
	// Show the layers before the body
	//for(unsigned i=0;i<_layers.size();i++)
	//	std::cout << _layers[i] << std::endl;
	//std::cout << _body << std::endl;
	//std::cout << _footer << std::endl;
	// Write to file with name : pedigree_id+".xml"
	
	// If label and/or icon legends are present
	// readjust the x and y extents:
	if(_labelSet->getNumberOfLabels() != 0 || _iconLegendFlag){ 
		_xMinimum -= _labelLegend.getWidth();
		double height = _labelLegend.getHeight();
		if(_iconLegendFlag) height += _iconLegend.getHeight();
		if(height > getYRange()) {
			_yMaximum += (height - getYRange());
		}
	}
	//
	// Only set the header now because at this point the
	// true x and y extents (width and height) are known:
	_setHeader();
	
	//
	// Add the legends:
	//
	_drawLegends();
	
	std::ofstream svgfile(filename);
	if(svgfile.is_open()){
		svgfile << _header.str() << std::endl;
		
		for(unsigned i=0;i<_layers.size();i++){
			
			svgfile << _layers[i] << std::endl;
			
		}
		
		svgfile << _body.str()   << std::endl;
		svgfile << _footer.str() << std::endl;
		svgfile.close();
		
	}else{
		
		std::cout << "Unable to open file " << filename << std::endl;
		
	}
}
示例#3
0
文件: Packet.cpp 项目: songjundev/b
void Packet::setBuffer(uint16 wType, const char* buf, uint16 size)
{
	if( _wpos + size <= PACKET_BUFFER_SIZE )
	{
		memcpy(&data[DATA_PARAM], buf, size);
		_wpos += size;
		_setHeader(wType);
	}
	else
	{
		LOGGER_ERROR("setBuffer failed, type:%d _wpos:%d size:%d", wType, _wpos, size);
	}
}