Ejemplo n.º 1
0
void CSG_Doc_SVG::Draw_LinkedPolygon(CSG_Points &Points, 
							  const SG_Char* Link,
							  int Fill_Color, 
							  int Line_Color, 
							  double Line_Width)
{
	if( Points.Get_Count() > 2 )
	{
		int i;
		CSG_String sPoints;
		CSG_String sWidth;
		CSG_String sLink;
		
		for (i = 0; i < Points.Get_Count(); i++)
		{
			sPoints.Append(SG_Get_String(Points.Get_X(i),2));
			sPoints.Append(SG_T(","));
			sPoints.Append(SG_Get_String(Points.Get_Y(i),2));
			sPoints.Append(SG_T(" "));
		}
		m_sSVGCode.Append(SG_T("<polygon "));
		_AddAttribute(SG_T("points"), sPoints);
		sWidth.Append(SG_Get_String(Line_Width,2));
		sWidth.Append(g_Unit);
		_AddAttribute(SG_T("stroke-width"), sWidth);				
		_AddAttribute(SG_T("stroke"), _Get_SVGColor(Line_Color));
		_AddAttribute(SG_T("fill"), _Get_SVGColor(Fill_Color));
		sLink = SG_T("window.open('");
		sLink.Append(Link);
		sLink.Append(SG_T("')"));
		_AddAttribute(SG_T("onclick"), sLink);
		m_sSVGCode.Append(SG_T("/>\n"));
	}
}
Ejemplo n.º 2
0
void CSG_Doc_SVG::Draw_Polygon(CSG_Points &Points, 
							  int Fill_Color, 
							  int Line_Color, 
							  double Line_Width)
{
	if( Points.Get_Count() > 2 )
	{
		int i;
		CSG_String sPoints;
		CSG_String sWidth;
		
		for (i = 0; i < Points.Get_Count(); i++)
		{
			sPoints.Append(SG_Get_String(Points.Get_X(i),2));
			sPoints.Append(SG_T(","));
			sPoints.Append(SG_Get_String(Points.Get_Y(i),2));
			sPoints.Append(SG_T(" "));
		}
		m_sSVGCode.Append(SG_T("<polygon "));
		_AddAttribute(SG_T("points"), sPoints);
		sWidth.Append(SG_Get_String(Line_Width,2));
		sWidth.Append(g_Unit);
		_AddAttribute(SG_T("stroke-width"), sWidth);				
		_AddAttribute(SG_T("stroke"), _Get_SVGColor(Line_Color));
		_AddAttribute(SG_T("fill"), _Get_SVGColor(Fill_Color));
		m_sSVGCode.Append(SG_T("/>\n"));
	}
}
Ejemplo n.º 3
0
void CSG_Doc_SVG::Draw_Line(CSG_Points &Points, 
						   double Width, 
						   int Color)
{
	int i;
	CSG_String sPoints;
	CSG_String sWidth;
	
	for (i = 0; i < Points.Get_Count(); i++)
	{
		sPoints.Append(SG_Get_String(Points.Get_X(i),2));
		sPoints.Append(SG_T(","));
		sPoints.Append(SG_Get_String(Points.Get_Y(i),2));
		sPoints.Append(SG_T(" "));
	}
	m_sSVGCode.Append(SG_T("<polyline "));
	_AddAttribute(SG_T("points"), sPoints);	
	sWidth.Append(SG_Get_String(Width,2));
	sWidth.Append(g_Unit);
	_AddAttribute(SG_T("stroke-width"), sWidth);
	_AddAttribute(SG_T("stroke"), _Get_SVGColor(Color));
	_AddAttribute(SG_T("fill"), SG_T("none"));
	m_sSVGCode.Append(SG_T("/>\n"));

}
Ejemplo n.º 4
0
void CSG_Doc_SVG::Draw_Rectangle(double xa, 
								double ya, 
								double xb, 
								double yb, 
								int Fill_Color, 
								int Line_Color, 
								double Line_Width)
{
	CSG_Points	Points;

	Points.Add(xa, ya);
	Points.Add(xb, ya);
	Points.Add(xb, yb);
	Points.Add(xa, yb);

	Draw_Polygon(Points, Fill_Color, Line_Color, Line_Width);
}
Ejemplo n.º 5
0
//---------------------------------------------------------
double		SG_Get_Polygon_Area(const CSG_Points &Points)
{
	double	Area	= 0.0;

	if( Points.Get_Count() >= 3 )
	{
		for(int i=0, j=Points.Get_Count()-1; i<Points.Get_Count(); j=i++)
		{
			Area	+= (Points.Get_X(j) * Points.Get_Y(i))
					 - (Points.Get_X(i) * Points.Get_Y(j));
		}

		Area	/= 2.0;
	}

	return( Area );
}
Ejemplo n.º 6
0
//---------------------------------------------------------
bool CAtlas_BNA_Export::On_Execute(void)
{
	int			iShape, iPart, iPoint, iName1, iName2;
	FILE		*Stream;
	TSG_Point	p;
	CSG_Points	Pts;
	CSG_Shape	*pShape;
	CSG_Shapes	*pShapes;
	CSG_String	fName;

	//-----------------------------------------------------
	pShapes	= Parameters("SHAPES")	->asShapes();
	fName	= Parameters("FILE")	->asString();

	iName1	= Parameters("PNAME")	->asInt();
	iName2	= Parameters("SNAME")	->asInt();

	//-----------------------------------------------------
	if( (Stream = fopen(fName.b_str(), "w")) != NULL )
	{
		for(iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
		{
			pShape	= pShapes->Get_Shape(iShape);

			switch( pShapes->Get_Type() )
			{
			default:
				break;

			//---------------------------------------------
			case SHAPE_TYPE_Point:
				fprintf(Stream, "\"%s\",\"%s\",%d\n",
					pShape->asString(iName1),
					pShape->asString(iName2),
					1
				);

				p	= pShape->Get_Point(0);
				fprintf(Stream, "%f,%f\n", p.x, p.y);
				break;

			//---------------------------------------------
			case SHAPE_TYPE_Line:
				for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
				{
					fprintf(Stream, "\"%s\",\"%s\",%d\n",
						pShape->asString(iName1),
						pShape->asString(iName2),
						-pShape->Get_Point_Count(iPart)
					);

					for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
					{
						p	= pShape->Get_Point(iPoint, iPart);
						fprintf(Stream, "%f,%f\n", p.x, p.y);
					}
				}
				break;

			//---------------------------------------------
			case SHAPE_TYPE_Polygon:
				if( pShape->Get_Part_Count() > 0 && pShape->Get_Point_Count(0) > 2 )
				{
					Pts.Clear();

					for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
					{
						for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
						{
							Pts.Add(pShape->Get_Point(iPoint, iPart));
						}

						if( iPart > 0 )
						{
							Pts.Add(pShape->Get_Point(0, 0));
						}
					}

					if( Pts.Get_Count() > 2 )
					{
						fprintf(Stream, "\"%s\",\"%s\",%d\n",
							pShape->asString(iName1),
							pShape->asString(iName2),
							Pts.Get_Count()
						);

						for(iPoint=0; iPoint<Pts.Get_Count(); iPoint++)
						{
							fprintf(Stream, "%f,%f\n", Pts[iPoint].x, Pts[iPoint].y);
						}
					}
				}
				break;
			}
		}

		fclose(Stream);

		return( true );
	}

	//-----------------------------------------------------
	return( false );
}