cppDrawEdges

UseCase1



// This propagation patter will traverse all the edges stored in a Graph
// object, collect all Position and Name data, and call either
// tclCEdge, or tclAEdge to draw a Construction Edge, or Alternation Edge
// appropriately.

(@
#include < iostream.h >
#include < strstream.h >
@)
 
*operation* void cppDrawEdges()
   *constraints*
      *classes* Graph, Edge, Vertex, AltEdge, ConstEdge, Coordinates, EdgeName, AltVertex, ConstVertex
      *directives*
         EdgeTo = *from* Edge *through* -> *,vto,*, -> *,position,* *to* Coordinates;

	 EdgeFrom = *from* Edge *through* -> *,vfrom,*, -> *,position,* *to* Coordinates;

         EdgeN = *from* ConstEdge *via* EdgeName *to* Coordinates;

         AllEdges = *from* Graph *through* -> *,edges,* *to* { AltEdge, ConstEdge };
    *end*

//-----------------old codes------------------------------------------
//	*carry* *in* EdgeData* data = (@ new edgeData() @)
//	   *along* AllEdges

//        *carry* *out* DemNumber* sX, *out*  DemNumber* sY
//	   *along* EdgeFrom
//	   *at* Coordinates
//	           sX = (@ get_x() @)
//	           sY = (@ get_y() @)

//	*carry* *out* DemNumber dX, *out* DemNumber* dY
//	   *along* EdgeTo
//	   *at* Coordinates
//	           dX = (@ get_x() @)
//	           dY = (@ get_y() @)

//        *carry* *out* DemIdent* lName, *out* DemNumber* lX, *out* DemNumber* lY
//	   *along* EdgeN
//	   *at* EdgeName lName = (@ get_name() @)
//	   *at* Coordinates
//	           lX = (@ get_x() @)
//	           lY = (@ get_y() @)
//------------------------------------------------------------------



*traverse* AllEdges
  *wrapper* AltEdge
    *suffix*
     (@ ostrstream str;
	
        // get x, y coordinates for vertices between alternation edges
       	str << "tclAEdge" << this->get_from()->get_position()->get_x(); 
        str << this->get_from()->get_position()->get_y() << " "         
        str << this->get_to()->get_position()->get_x() << " ";          
        str << this->get_to()->get_position()->get_y();
        cout << "+++ tcl call " << str.str() << endl;    //output to terminal
      @)

   *wrapper* ConstEdge
     *suffix*
      (@ ostrstream str;

	 // get x, y coordinates for vertices between construction edges
	 str << "tclCEdge" << this->get_from()->get_position()->get_x();
	 str << this->get_from()->get_position()->get_y() << " " ;
         str << this->get_to()->get_position()->get_x() << " "; 
         str << this->get_to()->get_position()->get_y();
	 cout << "+++ tcl call " << str.str() << endl;  //output to terminal
       @)