cppDrawVertices

UseCase3



// COM1205 Propagation Pattern for DemDraw Project
//
// Created by Tom Kneeland (tomk@ccs.neu.edu)
//
//	This propagation pattern traverses all the verticies stored in the
// vertex list, and calls the appropriate tcl functions to draw the object
// on the DemDraw Canvas.
//	tclAVert is called for alternation verticies, and is of the form:
//
//		tclAVert name location labeloffset
//
//	tclCVert is called for construction verticies, and is of the form:
//
//		tclCVert name location labeloffset
//
//	These tcl function calls are built into strings, which are passed to
// tcl using the tclexec command provided in tclexec.h after runing ishtmus.
//	For debugging purposes all tcl calls are printed to stdout before
// being passed to tcl. 
//
// Modification History:
//
// 11/29/95 - Tom Kneeland (tomk@ccs.neu.edu)
//	Added a call to cppGetVertexLabelCoordinate(), which will traverse
//	from a VertexName to Coordinates, returning the DemString that
//	represents the Vertex Label Offset.  This removes the violation
//	to the Law Of Demeter that existed from development of UseCase1.
//
// 11/21/95 - Tom Kneeland (tomk@ccs.neu.edu)
//	Modified to take advantage of the fact that coordinates are stored as
//	as strings - Use Case 2.

(@
#include <iostream.h>
#include <strstream.h>
//#include "tclexec.h"
@)

*operation* void cppDrawVertices()
   *constraints*
	*classes* Graph, Vertex, Coordinates, VertexName
	*directives*
	    VertexN = *from* Vertex *via* vertexname *to* Coordinates;
            AllVertices = *from* Graph *through* -> *,vertices,* *to* { AltVertex, ConstVertex };
   *end*

    *traverse* AllVertices

    *wrapper* AltVertex
	*suffix*
	(@ 
	   ostrstream str;
	   char tempchar[300];

	   str << "tclAVert " << get_vertexname()->get_name();

	   strcpy(tempchar,*this-> get_position()->get_coords());
           str << tempchar << " "; 


	   strcpy(tempchar, *this->get_vertexname()->cppGetVertexLabelCoordinates());
	   str << tempchar << " "; 

	   cout << "+++ tcl call " << str.str() << endl;
	   //tclexec << str.str();
	 @)

    *wrapper* ConstVertex
	*suffix*
	(@ ostrstream str;
	   char tempchar[300];

	   str << "tclCVert " << get_vertexname()->get_name();

	   strcpy(tempchar, *this->get_position()->get_coords());
           str << tempchar << " "; 

	   strcpy(tempchar, *this->get_vertexname()->cppGetVertexLabelCoordinates());
	   str << tempchar << " "; 

	   cout << "+++ tcl call " << str.str() << endl;
	   //tclexec << str.srt();
	 @)

UseCase3