Changeset 669 for trunk

Show
Ignore:
Timestamp:
03/17/08 17:04:22 (8 months ago)
Author:
artem
Message:

fixed line_pattern_symbolizer transformations

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/cairo_renderer.cpp

    r656 r669  
    8282            delete [] data_; 
    8383         } 
     84          
     85         void set_matrix(Cairo::Matrix const& matrix) 
     86         { 
     87            pattern_->set_matrix(matrix); 
     88         } 
    8489 
    8590         void set_origin(double x, double y) 
    8691         { 
    8792            Cairo::Matrix matrix; 
    88  
     93             
    8994            pattern_->get_matrix(matrix); 
    90  
     95      
    9196            matrix.x0 = -x; 
    9297            matrix.y0 = -y; 
    93  
     98             
    9499            pattern_->set_matrix(matrix); 
    95100         } 
    96  
    97          void set_angle(double angle) 
    98          { 
    99             Cairo::Matrix matrix; 
    100  
    101             pattern_->get_matrix(matrix); 
    102  
    103             cairo_matrix_invert(&matrix); 
    104  
    105             matrix.xx = cos(angle); 
    106             matrix.xy = sin(angle); 
    107             matrix.yx = -sin(angle); 
    108             matrix.yy = cos(angle); 
    109  
    110             cairo_matrix_invert(&matrix); 
    111  
    112             pattern_->set_matrix(matrix); 
    113          } 
    114  
     101          
    115102         void set_extend(Cairo::Extend extend) 
    116103         { 
     
    814801                                    proj_transform const& prj_trans) 
    815802   { 
    816 #ifdef CAIRO_LINE_PATTERN 
     803//#ifdef CAIRO_LINE_PATTERN 
    817804      typedef coord_transform2<CoordTransform,geometry2d> path_type; 
    818805 
     
    847834               else if (cm == SEG_LINETO) 
    848835               { 
    849                   double angle = atan2(y0 - y, x - x0); 
     836                  double dx = x - x0; 
     837                  double dy = y - y0; 
     838                  double angle = atan2(dy, dx); 
    850839                  double offset = fmod(length, width); 
    851                   double xoff = height / 2.0 * sin(angle) - offset * cos(angle); 
    852                   double yoff = height / 2.0 * cos(angle) + offset * sin(angle); 
    853  
    854                   pattern.set_origin(x0 + xoff, y0 - yoff); 
    855                   pattern.set_angle(angle); 
     840                   
     841                  Cairo::Matrix matrix; 
     842                  cairo_matrix_init_identity(&matrix); 
     843                  cairo_matrix_translate(&matrix,x0,y0); 
     844                  cairo_matrix_rotate(&matrix,angle); 
     845                  cairo_matrix_translate(&matrix,-offset,0.5*height); 
     846                  cairo_matrix_invert(&matrix); 
     847 
     848                  pattern.set_matrix(matrix); 
     849      
    856850                  context.set_pattern(pattern); 
    857  
     851                   
    858852                  context.move_to(x0, y0); 
    859853                  context.line_to(x, y); 
     
    868862         } 
    869863      } 
    870 #endif 
     864//#endif 
    871865   } 
    872866