Beispiel #1
0
void generateSVG(NODE* node, FILE* drawing, DOT* origin){
	NODE* current=node;
	while(current!=NULL){
		printf("Node analysed: %s, %d, %s\n", current->instruction, current->number, current->subroutine->instruction);
		if(strcmp(current->instruction,"FORWARD")==0){
			printf("Forward %d\n", current->number);
			fprintf(drawing,"<line x1=\"%.3f\" y1=\"%.3f\"",origin->x,origin->y);
			origin->x = origin->x + current->number*cos(origin->angle);
			origin->y = origin->y + current->number*sin(origin->angle);
			fprintf(drawing," x2=\"%.3f\" y2=\"%.3f\" stroke=\"red\" />\n",origin->x,origin->y);
		}
		if(strcmp(current->instruction,"RIGHT")==0){
			printf("Right %d\n", current->number);
			origin->angle+=(current->number)*PI/180;
		}
		if(strcmp(current->instruction,"LEFT")==0){
			printf("Left %d\n", current->number);
			origin->angle-=(current->number)*PI/180;
		}
		if(strcmp(current->instruction,"REPEAT")==0){
			int i;
			printf("Repeating %s %d times...\n", current->subroutine->instruction, current->number);
			for(i=0; i<current->number; i++){
				generateSVG(current->subroutine, drawing, origin);
			}
			printf("Out of repeat\n");
		}
		current=current->next;
	}
}
OutputGenerator::OutputGenerator(std::string sourcePath, VHDLEntity sourceEntity)
{
	MSG(GROUP::DEBUG, DEBUG::FUNCTIONCALL) << "OutputGenerator::OutputGenerator(std::string sourcePath, VHDLEntity sourceEntity)";

	mSourcePath = sourcePath;
	mSourceEntity = sourceEntity;
	mSourceName = mSourceEntity.getEntityName();

	// Check if source entity has a valid name and path
	if (mSourceName.empty() || mSourcePath.empty())
	{
		MSG(GROUP::ERROR) << "Empty source name or source path.";
	}
	else
	{
		// Start to generate the OpenDocument file. This is needed for some subsequent steps
		if ((cfg.getBool("FODG.enableExport")) || (cfg.getBool("PNG.enableExport")))
			generateFODG();

		// Create several other output formats if requested
		if (cfg.getBool("SVG.enableExport"))
			generateSVG();
		if (cfg.getBool("PNG.enableExport"))
			generatePNG();
		if (cfg.getBool("DokuWiki.enableExport"))	
			generateDokuWikiMarkup();
		if (cfg.getBool("Markdown.enableExport"))
			generateMarkdown();
		if (cfg.getBool("LaTeX.enableExport"))
			generateLaTeX();
	}	
}
Beispiel #3
0
void draw(NODE *program){
	FILE* drawing=fopen("drawing.svg", "aw+");
	DOT* origin=(DOT*) malloc(sizeof(DOT));
	origin->x=250;
	origin->y=250;
	origin->angle=0;

	fprintf(drawing,"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"500\" height=\"500\">\n");
	generateSVG(program, drawing, origin);
	fprintf(drawing,"</svg>");

	memFree(program);
	free(origin);
}