model_server/gra/src/graSymbol.h.cxx
//------------------------------------------
// set_layers
//
// Clear the old symbol and turn on the reqested layers
//------------------------------------------
set_layers
Clear the old symbol and turn on the reqested layers
set_layers Clear the old symbol and turn on the reqested layers
void graParametricSymbol::set_layers( int layers )
{
    Initialize (graParametricSymbol::set_layers);
    float scale = (text_height == 0) ? 1.0 : float(text_height) / 13.0;
    this->layers = (graSymbolModes) layers;
    for(Graphic* graphic = First(), *next = NULL; graphic; graphic = next)
    {
	next = Next();
	if (graphic != false_bottom1 && graphic != false_bottom2)
	{
	    Remove(graphic);
	    delete graphic;
	}
    }
    clear_attachment_points();
    if (bottom_line)
	bottom_line = (Graphic*)1;
    int i;
    for(i = 0; i< GRA_MAX_MODES; i++ )
    {
	if ( layers & (1 << i) )
	{
            graAttachableSymbol* pp = get_pictel(i);
	    if (pp)
	    {
                if (text_mode == graTextModeInside ||
		    text_mode == graTextModeInsideNoBox)
		{
                    Graphic* left_half = pp->First();
                    Graphic* right_half = pp->Last();
                    if (!left_half || !right_half || left_half == right_half)
		    {
                        Graphic* g = new Instance(pp);
			g->Scale(1.0, scale);
			if (i == graLayerNoDecorationLC ||
			    i == graLayerNoDecorationUC)
			    g->Translate(text_width / 2.0, 0);
			else if (i == graLayerNoDecorationLR ||
				 i == graLayerNoDecorationCR ||
				 i == graLayerNoDecorationUR)
			    g->Translate(text_width, 0);
                        Append(g);
                    }
                    else
		    {
                        left_half = new Instance(left_half);
			left_half->Scale(1.0, scale);
                        right_half = new Instance(right_half);
			right_half->Scale(1.0, scale);
			right_half->Translate(text_width, 0.0);
			Append(left_half);
			Append(right_half);
                    }
                }
		else {
		   Graphic* g = new Instance(pp);
		   g->Scale(1.0, scale);
		   Append(g);
		}
                for (int j = 0; j < graNumAttachmentPoints; j++)
		{
                    int layer_x, layer_y;
                    pp->get_attachment_point(
			graAttachmentPoint(j), layer_x, layer_y);
                    if (layer_x != 0 || layer_y != 0)
		    {
                        if (text_mode == graTextModeInside ||
			    text_mode == graTextModeInsideNoBox)
			{
                            if (j == graAttachLC || j == graAttachUC)
                                layer_x += text_width / 2;
                            else if (j == graAttachLR ||
				     j == graAttachCR ||
				     j == graAttachUR)
                                layer_x += text_width;
                        }
                        x[j] = layer_x;
                        y[j] = int(layer_y * scale + 0.5);
                    }
                }
            }
        }
    }
    for (i = 0; i < GRA_MAX_MODES; i++ )
        if (layers & (1 << i))
            if (param_overlay[i])
   	        Append (new Instance(param_overlay[i]));
    if (bottom_line)
	add_bottom_line();
}
void graParametricSymbol :: set_layers ( int layers ) { Initialize ( graParametricSymbol :: set_layers ) ; float scale = ( text_height == 0 ) ? 1.0 : float ( text_height ) / 13.0 ; this -> layers = ( graSymbolModes ) layers ; for ( Graphic * graphic = First ( ) , * next = NULL ; graphic ; graphic = next ) { next = Next ( ) ; if ( graphic != false_bottom1 && graphic != false_bottom2 ) { Remove ( graphic ) ; delete graphic ; } } clear_attachment_points ( ) ; if ( bottom_line ) bottom_line = ( Graphic * ) 1 ; int i ; for ( i = 0 ; i < GRA_MAX_MODES ; i ++ ) { if ( layers & ( 1 << i ) ) { graAttachableSymbol * pp = get_pictel ( i ) ; if ( pp ) { if ( text_mode == graTextModeInside || text_mode == graTextModeInsideNoBox ) { Graphic * left_half = pp -> First ( ) ; Graphic * right_half = pp -> Last ( ) ; if ( ! left_half || ! right_half || left_half == right_half ) { Graphic * g = new Instance ( pp ) ; g -> Scale ( 1.0 , scale ) ; if ( i == graLayerNoDecorationLC || i == graLayerNoDecorationUC ) g -> Translate ( text_width / 2.0 , 0 ) ; else if ( i == graLayerNoDecorationLR || i == graLayerNoDecorationCR || i == graLayerNoDecorationUR ) g -> Translate ( text_width , 0 ) ; Append ( g ) ; } else { left_half = new Instance ( left_half ) ; left_half -> Scale ( 1.0 , scale ) ; right_half = new Instance ( right_half ) ; right_half -> Scale ( 1.0 , scale ) ; right_half -> Translate ( text_width , 0.0 ) ; Append ( left_half ) ; Append ( right_half ) ; } } else { Graphic * g = new Instance ( pp ) ; g -> Scale ( 1.0 , scale ) ; Append ( g ) ; } for ( int j = 0 ; j < graNumAttachmentPoints ; j ++ ) { int layer_x , layer_y ; pp -> get_attachment_point ( graAttachmentPoint ( j ) , layer_x , layer_y ) ; if ( layer_x != 0 || layer_y != 0 ) { if ( text_mode == graTextModeInside || text_mode == graTextModeInsideNoBox ) { if ( j == graAttachLC || j == graAttachUC ) layer_x += text_width / 2 ; else if ( j == graAttachLR || j == graAttachCR || j == graAttachUR ) layer_x += text_width ; } x [ j ] = layer_x ; y [ j ] = int ( layer_y * scale + 0.5 ) ; } } } } } for ( i = 0 ; i < GRA_MAX_MODES ; i ++ ) if ( layers & ( 1 << i ) ) if ( param_overlay [ i ] ) Append ( new Instance ( param_overlay [ i ] ) ) ; if ( bottom_line ) add_bottom_line ( ) ; }
set_layers
Clear the old symbol and turn on the reqested layers
set_layers Clear the old symbol and turn on the reqested layers
// Symbols are built assuming a 12-pixel-high font; if we are using // a different font size, we must scale the graphics accordingly (the // factor of "13.0" is because we use text_height, which came from // GetBounds on the label, which adds a pixel to the true height. // Remove all current layer graphics // !!!KLUGE!!! Set bottom_line pointer to 1, so that we know it should be // re-created later // Turn on requested layers // Turn on requested parameters