21 #if defined(__WXMSW__)
26 #if wxUSE_STD_IOSTREAM
27 #include <wx/ioswrap.h>
29 #include <wx/wfstream.h>
30 #include <wx/sstream.h>
33 #if wxART2D_USE_FREETYPE
38 #include <freetype/freetype.h>
39 #include <freetype/ftoutln.h>
42 #include FT_FREETYPE_H
51 #define AFFINESTACKSIZE 16
52 #define TEXT_MAXSIZE_INPIXELS 3000 //related to screen size in pixels
66 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
67 : m_initCurrentSmartPointerOwner(
this )
70 m_width = size.GetWidth();
71 m_height = size.GetHeight();
78 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
79 : m_initCurrentSmartPointerOwner(
this )
91 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
92 , m_initCurrentSmartPointerOwner( this )
127 m_smallTextThreshold = SMALLTEXTTHRESHOLD;
179 wxASSERT_MSG(
m_affineStack.empty(), _(
"Unbalanced Push/PopTransform" ) );
191 wxRect rect( x, y, width, height );
212 m_display->GetEventHandler()->ProcessEvent( changedZoom );
275 double scalex, scaley, transx, transy;
296 transx = transx * scalex;
297 transy = transy * scaley;
323 m_display->GetEventHandler()->ProcessEvent( changedZoom );
338 if ( yupp == 0 || xupp == 0 )
360 double vx1, vy1, width, height;
369 if ( yupp == 0 || xupp == 0 )
374 double xc = vx1 + width/2.0;
375 double yc = vy1 + height/2.0;
482 wxASSERT_MSG( !
m_affineStack.empty(), _(
"Unbalanced Push/PopTransform" ) );
501 int xd1, yd1, xd2, yd2;
523 tmparea.width = xd2 - xd1;
524 tmparea.height = yd2 - yd1;
533 for (
int i = 0; i < n; i++ )
561 DoSetDrawStyle( drawstyle );
733 wxPen dcpen = *wxTRANSPARENT_PEN;
739 dcpen = *wxTRANSPARENT_PEN;
743 dcpen = *wxTRANSPARENT_PEN;
747 dcpen = *wxBLACK_PEN;
787 dcpen = wxPen( stroke1, 0, style );
801 dcpen = wxPen( stroke1, 0, wxBRUSHSTYLE_SOLID );
807 dcpen = wxPen( stroke1, width, wxBRUSHSTYLE_SOLID );
812 #if defined(__WXMSW__)
817 style = wxBRUSHSTYLE_STIPPLE;
818 dcpen.SetStyle( style );
826 noMask.SetMask( NULL );
827 style = wxBRUSHSTYLE_STIPPLE;
828 dcpen.SetStyle( style );
829 dcpen.SetStipple( noMask );
833 style = wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE;
834 dcpen.SetStyle( style );
838 default: style = wxBRUSHSTYLE_SOLID;
839 dcpen.SetStyle( style );
849 wxBrush dcbrush = *wxTRANSPARENT_BRUSH;
859 dcbrush = *wxTRANSPARENT_BRUSH;
864 dcbrush = *wxTRANSPARENT_BRUSH;
869 dcbrush = *wxTRANSPARENT_BRUSH;
877 style = wxBRUSHSTYLE_TRANSPARENT;
878 dcbrush.SetColour( fill1 );
879 dcbrush.SetStyle( style );
882 dcbrush.SetColour( fill1 );
883 dcbrush.SetStyle( style );
886 style = wxBRUSHSTYLE_BDIAGONAL_HATCH;
887 dcbrush.SetColour( fill1 );
888 dcbrush.SetStyle( style );
891 style = wxBRUSHSTYLE_CROSSDIAG_HATCH;
892 dcbrush.SetColour( fill1 );
893 dcbrush.SetStyle( style );
896 style = wxBRUSHSTYLE_FDIAGONAL_HATCH;
897 dcbrush.SetColour( fill1 );
898 dcbrush.SetStyle( style );
901 style = wxBRUSHSTYLE_CROSS_HATCH;
902 dcbrush.SetColour( fill1 );
903 dcbrush.SetStyle( style );
906 style = wxBRUSHSTYLE_HORIZONTAL_HATCH;
907 dcbrush.SetColour( fill1 );
908 dcbrush.SetStyle( style );
911 style = wxBRUSHSTYLE_VERTICAL_HATCH;
912 dcbrush.SetColour( fill1 );
913 dcbrush.SetStyle( style );
915 default: style = wxBRUSHSTYLE_SOLID;
916 dcbrush.SetColour( fill1 );
917 dcbrush.SetStyle( style );
926 style = wxBRUSHSTYLE_TRANSPARENT;
927 dcbrush.SetColour( fill1 );
928 dcbrush.SetStyle( style );
931 style = wxBRUSHSTYLE_BDIAGONAL_HATCH;
932 dcbrush.SetColour( fill1 );
933 dcbrush.SetStyle( style );
936 style = wxBRUSHSTYLE_CROSSDIAG_HATCH;
937 dcbrush.SetColour( fill1 );
938 dcbrush.SetStyle( style );
941 style = wxBRUSHSTYLE_FDIAGONAL_HATCH;
942 dcbrush.SetColour( fill1 );
943 dcbrush.SetStyle( style );
946 style = wxBRUSHSTYLE_CROSS_HATCH;
947 dcbrush.SetColour( fill1 );
948 dcbrush.SetStyle( style );
951 style = wxBRUSHSTYLE_HORIZONTAL_HATCH;
952 dcbrush.SetColour( fill1 );
953 dcbrush.SetStyle( style );
956 style = wxBRUSHSTYLE_VERTICAL_HATCH;
957 dcbrush.SetColour( fill1 );
958 dcbrush.SetStyle( style );
961 style = wxBRUSHSTYLE_SOLID;
962 dcbrush.SetColour( fill1 );
963 dcbrush.SetStyle( style );
972 style = wxBRUSHSTYLE_STIPPLE;
973 dcbrush.SetColour( fill1 );
975 dcbrush.SetStyle( style );
982 noMask.SetMask( NULL );
983 style = wxBRUSHSTYLE_STIPPLE;
984 dcbrush.SetColour( fill1 );
985 dcbrush.SetStipple( noMask );
989 style = wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE;
990 dcbrush.SetColour( fill1 );
993 dcbrush.SetStyle( style );
995 default: style = wxBRUSHSTYLE_SOLID;
996 dcbrush.SetColour( fill1 );
997 dcbrush.SetStyle( style );
1002 wxFAIL_MSG( wxT(
"can not convert gradients to wxBrush" ) );
1007 #if wxART2D_USE_GRAPHICS_CONTEXT
1009 wxGraphicsPen a2dDrawer2D::ConvertActiveToGraphicsPen( wxGraphicsContext* context )
1011 wxPen dcpen = *wxTRANSPARENT_PEN;
1017 dcpen = *wxTRANSPARENT_PEN;
1021 dcpen = *wxTRANSPARENT_PEN;
1025 dcpen = *wxBLACK_PEN;
1065 dcpen = wxPen( stroke1, 0, style );
1079 dcpen = wxPen( stroke1, 0, wxBRUSHSTYLE_SOLID );
1085 dcpen = wxPen( stroke1, width, wxBRUSHSTYLE_SOLID );
1090 #if defined(__WXMSW__)
1095 style = wxBRUSHSTYLE_STIPPLE;
1096 dcpen.SetStyle( style );
1104 noMask.SetMask( NULL );
1105 style = wxBRUSHSTYLE_STIPPLE;
1106 dcpen.SetStyle( style );
1107 dcpen.SetStipple( noMask );
1111 style = wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE;
1112 dcpen.SetStyle( style );
1116 default: style = wxBRUSHSTYLE_SOLID;
1117 dcpen.SetStyle( style );
1122 return context->CreatePen( dcpen );
1125 wxGraphicsBrush a2dDrawer2D::ConvertActiveToGraphicsBrush( wxGraphicsContext* context )
1127 wxBrush dcbrush = *wxTRANSPARENT_BRUSH;
1137 dcbrush = *wxTRANSPARENT_BRUSH;
1139 return context->CreateBrush( dcbrush );
1143 dcbrush = *wxTRANSPARENT_BRUSH;
1145 return context->CreateBrush( dcbrush );
1149 dcbrush = *wxTRANSPARENT_BRUSH;
1151 return context->CreateBrush( dcbrush );
1158 style = wxBRUSHSTYLE_TRANSPARENT;
1159 dcbrush.SetColour( fill1 );
1160 dcbrush.SetStyle( style );
1163 dcbrush.SetColour( fill1 );
1164 dcbrush.SetStyle( style );
1167 style = wxBRUSHSTYLE_BDIAGONAL_HATCH;
1168 dcbrush.SetColour( fill1 );
1169 dcbrush.SetStyle( style );
1172 style = wxBRUSHSTYLE_CROSSDIAG_HATCH;
1173 dcbrush.SetColour( fill1 );
1174 dcbrush.SetStyle( style );
1177 style = wxBRUSHSTYLE_FDIAGONAL_HATCH;
1178 dcbrush.SetColour( fill1 );
1179 dcbrush.SetStyle( style );
1182 style = wxBRUSHSTYLE_CROSS_HATCH;
1183 dcbrush.SetColour( fill1 );
1184 dcbrush.SetStyle( style );
1187 style = wxBRUSHSTYLE_HORIZONTAL_HATCH;
1188 dcbrush.SetColour( fill1 );
1189 dcbrush.SetStyle( style );
1192 style = wxBRUSHSTYLE_VERTICAL_HATCH;
1193 dcbrush.SetColour( fill1 );
1194 dcbrush.SetStyle( style );
1196 default: style = wxBRUSHSTYLE_SOLID;
1197 dcbrush.SetColour( fill1 );
1198 dcbrush.SetStyle( style );
1200 return context->CreateBrush( dcbrush );
1208 style = wxBRUSHSTYLE_TRANSPARENT;
1209 dcbrush.SetColour( fill1 );
1210 dcbrush.SetStyle( style );
1213 style = wxBRUSHSTYLE_BDIAGONAL_HATCH;
1214 dcbrush.SetColour( fill1 );
1215 dcbrush.SetStyle( style );
1218 style = wxBRUSHSTYLE_CROSSDIAG_HATCH;
1219 dcbrush.SetColour( fill1 );
1220 dcbrush.SetStyle( style );
1223 style = wxBRUSHSTYLE_FDIAGONAL_HATCH;
1224 dcbrush.SetColour( fill1 );
1225 dcbrush.SetStyle( style );
1228 style = wxBRUSHSTYLE_CROSS_HATCH;
1229 dcbrush.SetColour( fill1 );
1230 dcbrush.SetStyle( style );
1233 style = wxBRUSHSTYLE_HORIZONTAL_HATCH;
1234 dcbrush.SetColour( fill1 );
1235 dcbrush.SetStyle( style );
1238 style = wxBRUSHSTYLE_VERTICAL_HATCH;
1239 dcbrush.SetColour( fill1 );
1240 dcbrush.SetStyle( style );
1243 style = wxBRUSHSTYLE_SOLID;
1244 dcbrush.SetColour( fill1 );
1245 dcbrush.SetStyle( style );
1247 return context->CreateBrush( dcbrush );
1255 style = wxBRUSHSTYLE_STIPPLE;
1256 dcbrush.SetColour( fill1 );
1258 dcbrush.SetStyle( style );
1265 noMask.SetMask( NULL );
1266 style = wxBRUSHSTYLE_STIPPLE;
1267 dcbrush.SetColour( fill1 );
1268 dcbrush.SetStipple( noMask );
1272 style = wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE;
1273 dcbrush.SetColour( fill1 );
1276 dcbrush.SetStyle( style );
1278 default: style = wxBRUSHSTYLE_SOLID;
1279 dcbrush.SetColour( fill1 );
1280 dcbrush.SetStyle( style );
1282 return context->CreateBrush( dcbrush );
1291 return context->CreateLinearGradientBrush( x1, y1, x2, y2, fill1, fill2 );
1300 return context->CreateRadialGradientBrush( xf, yf, xc, yc, r, fill1, fill2 );
1302 return wxNullGraphicsBrush;
1305 #endif // wxART2D_USE_GRAPHICS_CONTEXT
1312 unsigned int segments = 0;
1315 for ( i = 0; i < points->size(); i++ )
1319 if ( seg->GetArc() )
1323 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
1325 if ( cseg->
CalcR( *( points->Item( i ? i - 1 : 0 ) ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
1328 unsigned int circlesegments;
1331 segments += circlesegments + 1;
1343 unsigned int count = 0;
1344 double x, y, lastx, lasty;
1345 for ( i = 0; i < points->size(); i++ )
1349 if ( !seg->GetArc() )
1354 if( !count || fabs( x - lastx ) > 0.001 || fabs( y - lasty ) > 0.001 )
1368 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
1370 if ( cseg->
CalcR( *( points->Item( i ? i - 1 : 0 ) ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
1373 unsigned int segments;
1377 double theta = beginrad;
1381 for ( step = 0; step < segments + 1; step++ )
1386 if( !count || fabs( x - lastx ) > 0.001 || fabs( y - lasty ) > 0.001 )
1395 theta = theta + dphi;
1404 if( !count || fabs( x - lastx ) > 0.001 || fabs( y - lasty ) > 0.001 )
1420 if ( replaceByRectangle )
1434 unsigned int segments = 0;
1436 if ( list->empty() )
1439 a2dVertexList::const_iterator iterprev = list->end();
1440 if ( iterprev != list->begin() )
1442 a2dVertexList::const_iterator iter = list->begin();
1443 while ( iter != list->end() )
1447 if ( seg->GetArc() )
1451 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
1453 if ( cseg->
CalcR( *( *iterprev ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
1456 unsigned int circlesegments;
1459 segments += circlesegments + 1;
1473 unsigned int count = 0;
1474 double x, y, lastx, lasty;
1475 iterprev = list->end();
1476 if ( iterprev != list->begin() )
1478 iter = list->begin();
1479 while ( iter != list->end() )
1483 if ( !seg->GetArc() )
1488 if( !count || fabs( x - lastx ) > 0.001 || fabs( y - lasty ) > 0.001 )
1502 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
1504 if ( cseg->
CalcR( *( *iterprev ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
1507 unsigned int segments;
1511 double theta = beginrad;
1515 for ( step = 0; step < segments + 1; step++ )
1520 if( !count || fabs( x - lastx ) > 0.001 || fabs( y - lasty ) > 0.001 )
1529 theta = theta + dphi;
1538 if( !count || fabs( x - lastx ) > 0.001 || fabs( y - lasty ) > 0.001 )
1555 if ( replaceByRectangle )
1579 bool nostrokeparts =
false;
1582 for ( i = 0; i < path->size(); i++ )
1585 switch ( seg->GetType() )
1607 nostrokeparts =
true;
1611 nostrokeparts =
true;
1616 double xwl = path->operator[]( i ? i - 1 : 0 )->m_x1;
1617 double ywl = path->operator[]( i ? i - 1 : 0 )->m_y1;
1624 xw = xwl * pow( 1 - t, 3 ) + cseg->
m_x2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_x3 * ( 1 - t ) * t * t * 3 + cseg->
m_x1 * pow( t, 3 );
1625 yw = ywl * pow( 1 - t, 3 ) + cseg->
m_y2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_y3 * ( 1 - t ) * t * t * 3 + cseg->
m_y1 * pow( t, 3 );
1634 nostrokeparts =
true;
1639 double xwl = path->operator[]( i ? i - 1 : 0 )->m_x1;
1640 double ywl = path->operator[]( i ? i - 1 : 0 )->m_y1;
1647 xw = xwl * pow( 1 - t, 2 ) + cseg->
m_x2 * ( 1 - t ) * t * 2 + cseg->
m_x1 * pow( t, 2 );
1648 yw = ywl * pow( 1 - t, 2 ) + cseg->
m_y2 * ( 1 - t ) * t * 2 + cseg->
m_y1 * pow( t, 2 );
1657 nostrokeparts =
true;
1662 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
1664 if ( cseg->
CalcR( path->operator[]( i ? i - 1 : 0 ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
1667 unsigned int segments;
1671 double theta = beginrad;
1674 for ( step = 0; step < segments + 1; step++ )
1678 theta = theta + dphi;
1707 nostrokeparts =
true;
1718 else if ( i == path->size() - 1 )
1724 if ( nostrokeparts )
1729 nostrokeparts =
false;
1731 double lastmovex = 0;
1732 double lastmovey = 0;
1734 for ( i = 0; i < path->size(); i++ )
1737 switch ( seg->GetType() )
1743 lastmovex = seg->m_x1;
1744 lastmovey = seg->m_y1;
1771 nostrokeparts =
true;
1779 double xwl = path->operator[]( i ? i - 1 : 0 )->m_x1;
1780 double ywl = path->operator[]( i ? i - 1 : 0 )->m_y1;
1787 xw = xwl * pow( 1 - t, 3 ) + cseg->
m_x2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_x3 * ( 1 - t ) * t * t * 3 + cseg->
m_x1 * pow( t, 3 );
1788 yw = ywl * pow( 1 - t, 3 ) + cseg->
m_y2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_y3 * ( 1 - t ) * t * t * 3 + cseg->
m_y1 * pow( t, 3 );
1800 double xwl = path->operator[]( i ? i - 1 : 0 )->m_x1;
1801 double ywl = path->operator[]( i ? i - 1 : 0 )->m_y1;
1808 xw = xwl * pow( 1 - t, 2 ) + cseg->
m_x2 * ( 1 - t ) * t * 2 + cseg->
m_x1 * pow( t, 2 );
1809 yw = ywl * pow( 1 - t, 2 ) + cseg->
m_y2 * ( 1 - t ) * t * 2 + cseg->
m_y1 * pow( t, 2 );
1821 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
1823 if ( cseg->
CalcR( path->operator[]( i ? i - 1 : 0 ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
1826 unsigned int segments;
1830 double theta = beginrad;
1833 for ( step = 0; step < segments + 1; step++ )
1837 theta = theta + dphi;
1852 if ( move || nostrokeparts )
1856 nostrokeparts =
false;
1868 nostrokeparts =
false;
1873 else if ( i == path->size() )
1895 bool smallPoly =
false;
1898 if ( segments == 0 )
1916 bool smallPoly =
false;
1919 if ( segments == 0 )
1937 bool smallPoly =
false;
1950 bool smallPoly =
false;
1962 double dx = x1 - xc;
1963 double dy = y1 - yc;
1967 double radius = sqrt( dx * dx + dy * dy );
1969 if ( x1 == x2 && y1 == y2 )
1979 start = atan2( dy, dx );
1987 end = atan2( dy, dx );
1990 if ( end <= 0 ) end += 2.0 *
wxPI;
1991 if ( start < 0 ) start += 2.0 *
wxPI;
2009 if ( end <= 0 ) end += 2.0 *
wxPI;
2011 if ( start < 0 ) start += 2.0 *
wxPI;
2016 unsigned int segments;
2023 double theta = start;
2025 for ( i = 0; i < segments + 1; i++ )
2028 theta = theta + dphi;
2064 static const double sintab[9] =
2067 1 - 0.19509032201612826784828486847702,
2068 1 - 0.38268343236508977172845998403040,
2069 1 - 0.55557023301960222474283081394853,
2070 1 - 0.70710678118654752440084436210485,
2071 1 - 0.83146961230254523707878837761791,
2072 1 - 0.92387953251128675612818318939679,
2073 1 - 0.98078528040323044912618223613424,
2081 for( i = 0; i <= 8; i++ )
2083 for( i = 0; i <= 8; i++ )
2085 for( i = 0; i <= 8; i++ )
2087 for( i = 0; i <= 8; i++ )
2092 for( i = 0; i <= 8; i++ )
2094 for( i = 0; i <= 8; i++ )
2096 for( i = 0; i <= 8; i++ )
2098 for( i = 0; i <= 8; i++ )
2118 DrawEllipse( xc, yc, 2.0 * radius, 2.0 * radius );
2127 unsigned int segments;
2129 if ( width == 0 && height == 0 )
2149 double n = fabs( m00 + m10 ) + fabs( m01 + m11 );
2152 segments = ( int ) ceil( n );
2153 dphi = 2.0 *
wxPI / segments;
2159 for ( i = 0; i < segments ; i++ )
2185 if ( c != wxChar(
' ' ) )
2190 DrawLine( 0.1 * width, desc, 0.9 * width, desc + size );
2191 DrawLine( 0.9 * width, desc, 0.1 * width, desc + size );
2216 for (
size_t i = 0; i < text.Length(); i++ )
2220 if ( c == wxChar(
' ' ) )
2223 DrawLine( start, h / 2.0, x, h / 2.0 );
2229 DrawLine( start, h / 2.0, x, h / 2.0 );
2253 if ( widthdevice < 1 )
2294 bool textwasvisible =
false;
2298 const size_t n = text.Length();
2299 for (
size_t i = 0; i < n; i++ )
2301 const wxChar oldc = c;
2317 ( this->*drawchar )( c );
2318 textwasvisible =
true;
2320 else if ( textwasvisible )
2335 double dx, dy, size;
2341 if ( size > TEXT_MAXSIZE_INPIXELS )
2396 affine.
Mirror(
true,
false );
2408 case a2dFONT_STROKED:
2411 case a2dFONT_FREETYPE:
2439 int walk = ( index + direction + n ) % n;
2440 while ( points[walk].y < horline )
2442 if ( points[walk].y < points[index].y )
2448 walk = ( index + direction + n ) % n;
2461 bool candidate =
false;
2464 for ( i = 0; i < n; i++ )
2470 if ( points[i].y > points[j].y )
2473 else if ( ( points[i].y < points[j].y ) && candidate )
2476 bool inserted =
false;
2477 a2dCriticalPointList::compatibility_iterator node =
m_CRlist.GetFirst();
2481 int* ind = node->GetData();
2482 if ( points[*ind].y > points[i].y )
2484 m_CRlist.Insert( node,
new int( i ) );
2488 node = node->GetNext();
2497 for ( i = 0; i < n; i++ )
2503 if ( points[i].y > points[j].y )
2506 else if ( ( points[i].y < points[j].y ) && candidate )
2509 bool inserted =
false;
2510 a2dCriticalPointList::compatibility_iterator node =
m_CRlist.GetFirst();
2514 int* ind = node->GetData();
2515 if ( points[*ind].y > points[i].y )
2517 m_CRlist.Insert( node,
new int( i ) );
2521 node = node->GetNext();
2531 static int SortonXs(
const void* f,
const void* s )
2536 if ( ( *first )->m_xs < ( *second )->m_xs )
2538 else if ( ( *first )->m_xs > ( *second )->m_xs )
2544 void a2dDrawer2D::ColourXYLinear(
int x1,
int x2,
int y )
2550 if ( m_dx1 == m_dx2 )
2554 double stepcol = m_max_y - m_min_y;
2556 double curcol = y - m_min_y;
2559 wxColour gradcol( (
unsigned char ) ( m_colour1redFill + dred * curcol / stepcol ),
2560 (
unsigned char ) ( m_colour1greenFill + dgreen * curcol / stepcol ),
2561 (
unsigned char ) ( m_colour1blueFill + dblue * curcol / stepcol ) );
2570 for ( j = x1; j <= x2; j++ )
2572 a2dLine perstroke( j, y, j + m_dy2 - m_dy1, y + m_dx2 - m_dx1 );
2574 perstroke.CalculateLineParameters();
2575 perstroke.Intersect( m_line, crossing );
2577 double length = sqrt( (
double ) ( crossing.m_x - m_dx1 ) * ( crossing.m_x - m_dx1 ) + ( crossing.m_y - m_dy1 ) * ( crossing.m_y - m_dy1 ) );
2579 if ( length > m_length )
2582 DeviceDrawPixel( j, y, m_colour1redFill + dred *
int( length / m_length ),
2583 m_colour1greenFill + dgreen *
int( length / m_length ),
2584 m_colour1blueFill + dblue *
int( length / m_length ) );
2589 void a2dDrawer2D::ColourXYRadial(
int x1,
int x2,
int y )
2596 for ( j = x1; j <= x2; j++ )
2598 double cradius = sqrt( (
double ) ( j - m_dx1 ) * ( j - m_dx1 ) + ( y - m_dy1 ) * ( y - m_dy1 ) );
2601 if ( m_radiusd == 0 )
2603 else if ( cradius > m_radiusd )
2606 delta = cradius / m_radiusd;
2608 DeviceDrawPixel( j, y, (
unsigned char ) ( m_colour1redFill + dred * delta ),
2609 (
unsigned char ) ( m_colour1greenFill + dgreen * delta ),
2610 (
unsigned char ) ( m_colour1blueFill + dblue * delta ) );
2620 m_min_y = points[0].y;
2621 m_max_y = points[0].y;
2622 m_min_x = points[0].x;
2623 m_max_x = points[0].x;
2624 double centroidx = 0;
2625 double centroidy = 0;
2627 for ( i = 0; i < n; i++ )
2629 m_min_y = wxMin( m_min_y, points[i].y );
2630 m_max_y = wxMax( m_max_y, points[i].y );
2631 m_min_x = wxMin( m_min_x, points[i].x );
2632 m_max_x = wxMax( m_max_x, points[i].x );
2633 centroidx += points[i].x;
2634 centroidy += points[i].y;
2637 centroidx /= double( n );
2638 centroidy /= double( n );
2650 if ( m_dx1 == m_dx2 && m_dy1 == m_dy2 )
2657 if ( m_dx1 == m_dx2 && m_dy1 == m_dy2 )
2658 m_dx2 = m_dx2 + 100;
2660 m_length = sqrt ( ( m_dx1 - m_dx2 ) * ( m_dx1 - m_dx2 ) + ( m_dy1 - m_dy2 ) * ( m_dy1 - m_dy2 ) );
2661 m_line =
a2dLine( m_dx1, m_dy1, m_dx2, m_dy2 );
2672 if ( m_dx1 == m_dx2 && m_dy1 == m_dy2 )
2680 if ( m_dx1 == m_dx2 && m_dy1 == m_dy2 )
2685 m_radiusd = sqrt ( ( dx3 - m_dx2 ) * ( dx3 - m_dx2 ) + ( dy3 - m_dy2 ) * ( dy3 - m_dy2 ) );
2690 int min = ( int ) wxMax ( m_min_y, clip.y );
2691 int max = ( int ) wxMin ( m_max_y, clip.y + clip.height );
2693 for ( i = min; i < max; i++ )
2695 a2dAETList::compatibility_iterator node =
m_AETlist.GetFirst();
2699 a2dAET* ele = node->GetData();
2700 index = ele->m_index;
2701 int direction = ele->m_direction;
2702 if ( !
MoveUp( n, points, i, index, direction ) )
2704 a2dAETList::compatibility_iterator h = node;
2706 node = node->GetNext();
2707 delete h->GetData();
2712 if ( ele->m_index != index )
2714 ele->m_index = index;
2715 int h = ( index + direction + n ) % n;
2716 ele->CalculateLineParameters( points[h], points[index] );
2718 if ( ele->m_horizontal )
2719 ele->m_xs = ( int ) points[index].x;
2721 ele->CalculateXs( i );
2722 node = node->GetNext();
2727 a2dCriticalPointList::compatibility_iterator nodec =
m_CRlist.GetFirst();
2728 while (
m_CRlist.size() && points[*nodec->GetData()].y <= i )
2731 for ( DI = -1; DI <= 1 ; DI += 2 )
2733 index = *nodec->GetData();
2734 if (
MoveUp( n, points, i, index, DI ) )
2737 ele->m_index = index;
2738 ele->m_direction = DI;
2739 int h = ( index + DI + n ) % n;
2740 ele->CalculateLineParameters( points[h], points[index] );
2741 if ( ele->m_horizontal )
2742 ele->m_xs = ( int ) points[index].x;
2744 ele->CalculateXs( i );
2747 bool inserted =
false;
2752 if ( ele->m_xs < ( node->GetData() )->m_xs )
2759 node = node->GetNext();
2766 a2dCriticalPointList::compatibility_iterator h = nodec;
2767 nodec = nodec->GetNext();
2768 delete h->GetData();
2778 else if (
m_AETlist.GetFirst()->GetData()->m_xs >
m_AETlist.GetLast()->GetData()->m_xs )
2792 a2dAET* ele = node->GetData();
2793 out += ele->m_direction;
2797 int x1 = ( int ) ele->m_xs;
2798 node = node->GetNext();
2801 ele = node->GetData();
2802 int x2 = ( int ) ele->m_xs;
2804 if ( x1 < clip.x ) x1 = clip.x;
2805 if ( x2 > clip.x + clip.width ) x2 = clip.x + clip.width;
2806 if ( i >= clip.y && i <= clip.y + clip.height && ( x1 != x2 ) )
2809 ColourXYLinear( x1, x2, i );
2811 ColourXYRadial( x1, x2, i );
2819 node = node->GetNext();
2823 a2dAETList::compatibility_iterator node =
m_AETlist.GetFirst();
2826 a2dAETList::compatibility_iterator h = node;
2827 delete h->GetData();
2832 a2dCriticalPointList::compatibility_iterator nodec =
m_CRlist.GetFirst();
2835 a2dCriticalPointList::compatibility_iterator h = nodec;
2836 delete h->GetData();
2880 int clipcode1, clipcode2;
2881 int nr_of_intersections = 0;
2884 double intersectionpoint1[2];
2885 double intersectionpoint2[2];
2886 double A, B, temppoint;
2895 if ( !clipcode1 && !clipcode2 )
return true;
2901 intersectionpoint1[0] = x1;
2902 intersectionpoint2[0] = y1;
2904 nr_of_intersections = 1;
2910 intersectionpoint1[0] = x2;
2911 intersectionpoint2[0] = y2;
2913 nr_of_intersections = 1;
2916 clipcode1 ^= clipcode2;
2930 if ( clipcode1 & 0x0004 )
2934 else temppoint = x1;
2939 intersectionpoint1[nr_of_intersections] = temppoint;
2944 if ( clipcode1 & 0x0008 )
2948 else temppoint = x1;
2952 intersectionpoint1[nr_of_intersections] = temppoint;
2957 if ( clipcode1 & 0x0001 )
2963 intersectionpoint2[nr_of_intersections] = temppoint;
2968 if ( clipcode1 & 0x0002 )
2974 intersectionpoint2[nr_of_intersections] = temppoint;
2979 if ( nr_of_intersections != 2 )
return false;
2982 x1 = intersectionpoint1[0];
2983 y1 = intersectionpoint2[0];
2984 x2 = intersectionpoint1[1];
2985 y2 = intersectionpoint2[1];
3018 for ( i = 0; i < n; i++ )
3024 if ( deviceaber < 5 )
3025 deviceaber = THRESHOLD;
3034 a2dVertexList::iterator iter = h.begin();
3035 for ( i = 0; i < n; i++ )
3050 for ( i = 0; i < n; i++ )
3056 if ( deviceaber < 5 )
3057 deviceaber = THRESHOLD;
3060 h.ConvertIntoSplinedPolyline( deviceaber );
3065 a2dVertexList::iterator iter = h.begin();
3066 for ( i = 0; i < n; i++ )
3070 iter = h.erase( iter );
3077 wxFAIL_MSG( wxT(
"if used, must be implemented in derived class" ) );
3082 wxFAIL_MSG( wxT(
"if used, must be implemented in derived class" ) );
3087 wxFAIL_MSG( wxT(
"if used, must be implemented in derived class" ) );
3092 wxFAIL_MSG( wxT(
"if used, must be implemented in derived class" ) );
3097 wxFAIL_MSG( wxT(
"if used, must be implemented in derived class" ) );
3102 wxFAIL_MSG( wxT(
"if used, must be implemented in derived class" ) );
3112 a2dBlindDrawer2D::a2dBlindDrawer2D( const wxSize& size ):
a2dDrawer2D( size )
3131 wxASSERT_MSG(
m_beginDraw_endDraw >= 0, wxT(
"a2dBlindDrawer2D, unbalanced BeginDraw EndDraw" ) );
3138 wxASSERT_MSG(
m_beginDraw_endDraw >= 0, wxT(
"a2dBlindDrawer2D, unbalanced BeginDraw EndDraw" ) );
3149 wxFAIL_MSG( wxT(
"a2dBlindDrawer2D has no buffer" ) );
3185 void a2dBlindDrawer2D::DoSetDrawStyle(
a2dDrawStyle WXUNUSED( drawstyle ) )
3188 void a2dBlindDrawer2D::DrawImage(
const wxImage& WXUNUSED( imagein ),
double WXUNUSED( x ),
double WXUNUSED( y ),
double WXUNUSED( width ),
double WXUNUSED( height ), wxUint8 WXUNUSED( Opacity ) )
3249 wxFAIL_MSG( wxT(
"not useful here" ) );
3254 wxFAIL_MSG( wxT(
"not useful here" ) );
3260 #if wxART2D_USE_GRAPHICS_CONTEXT
3268 a2dGcBaseDrawer::a2dGcBaseDrawer(
int width,
int height, wxGraphicsRenderer* render, wxGraphicsContext* context ):
a2dDrawer2D( width, height )
3271 m_context = context;
3274 a2dGcBaseDrawer::a2dGcBaseDrawer(
const a2dGcBaseDrawer& other )
3277 m_render = other.m_render;
3278 m_context = other.m_context;
3281 a2dGcBaseDrawer::a2dGcBaseDrawer(
const a2dDrawer2D& other )
3288 a2dGcBaseDrawer::~a2dGcBaseDrawer()
3292 void a2dGcBaseDrawer::SetTransform(
const a2dAffineMatrix& userToWorld )
3296 wxGraphicsMatrix m = m_context->CreateMatrix(
3297 m_usertodevice( 0, 0 ), m_usertodevice( 0, 1 ),
3298 m_usertodevice( 1, 0 ), m_usertodevice( 1, 1 ),
3299 m_usertodevice( 2, 0 ), m_usertodevice( 2, 1 ) );
3300 m_context->SetTransform( m );
3303 void a2dGcBaseDrawer::PushTransform()
3307 wxGraphicsMatrix m = m_context->CreateMatrix();
3309 m_usertodevice( 0, 0 ), m_usertodevice( 0, 1 ),
3310 m_usertodevice( 1, 0 ), m_usertodevice( 1, 1 ),
3311 m_usertodevice( 2, 0 ), m_usertodevice( 2, 1 ) );
3312 m_context->SetTransform( m );
3319 wxGraphicsMatrix m = m_context->CreateMatrix();
3321 m_usertodevice( 0, 0 ), m_usertodevice( 0, 1 ),
3322 m_usertodevice( 1, 0 ), m_usertodevice( 1, 1 ),
3323 m_usertodevice( 2, 0 ), m_usertodevice( 2, 1 ) );
3324 m_context->SetTransform( m );
3327 void a2dGcBaseDrawer::PushIdentityTransform()
3331 wxGraphicsMatrix m = m_context->CreateMatrix();
3333 m_usertodevice( 0, 0 ), m_usertodevice( 0, 1 ),
3334 m_usertodevice( 1, 0 ), m_usertodevice( 1, 1 ),
3335 m_usertodevice( 2, 0 ), m_usertodevice( 2, 1 ) );
3336 m_context->SetTransform( m );
3339 void a2dGcBaseDrawer::PopTransform(
void )
3343 wxGraphicsMatrix m = m_context->CreateMatrix();
3345 m_usertodevice( 0, 0 ), m_usertodevice( 0, 1 ),
3346 m_usertodevice( 1, 0 ), m_usertodevice( 1, 1 ),
3347 m_usertodevice( 2, 0 ), m_usertodevice( 2, 1 ) );
3348 m_context->SetTransform( m );
3351 void a2dGcBaseDrawer::BeginDraw()
3353 wxASSERT_MSG( m_beginDraw_endDraw >= 0, wxT(
"a2dMemDcDrawer, unbalanced BeginDraw EndDraw" ) );
3355 if ( m_beginDraw_endDraw == 0 )
3357 SetDrawerFill( m_currentfill );
3358 SetDrawerStroke( m_currentstroke );
3359 DestroyClippingRegion();
3360 SetDrawStyle( m_drawstyle );
3364 m_beginDraw_endDraw++;
3367 void a2dGcBaseDrawer::EndDraw()
3369 m_beginDraw_endDraw--;
3371 wxASSERT_MSG( m_beginDraw_endDraw >= 0, wxT(
"a2dMemDcDrawer, unbalanced BeginDraw EndDraw" ) );
3373 if ( m_beginDraw_endDraw == 0 )
3378 void a2dGcBaseDrawer::BlitBuffer( wxRect rect,
const wxPoint& bufferpos )
3383 wxClientDC deviceDC( m_display );
3384 m_display->PrepareDC( deviceDC );
3385 BlitBuffer( &deviceDC, rect, bufferpos );
3390 void a2dGcBaseDrawer::SetClippingRegion(
a2dVertexList* points,
bool spline, wxPolygonFillMode fillStyle )
3392 unsigned int n = points->size();
3394 m_cpointsDouble.resize( n );
3402 GetUserToDeviceTransform().TransformPoint( point.m_x, point.m_y, x, y );
3403 m_cpointsDouble[i].x = x;
3404 m_cpointsDouble[i].y = y;
3409 n = ConvertSplinedPolygon2( n );
3411 wxPoint* intpoints = _convertToIntPointCache( n, &m_cpointsDouble[0] );
3412 m_clip = wxRegion( n, intpoints, fillStyle );
3414 m_clipboxdev = m_clip.GetBox();
3415 m_clipboxworld = ToWorld( m_clipboxdev );
3418 void a2dGcBaseDrawer::ExtendAndPushClippingRegion(
a2dVertexList* points,
bool spline, wxPolygonFillMode fillStyle,
a2dBooleanClip clipoperation )
3420 wxRegion* push =
new wxRegion( m_clip );
3422 m_clipregionlist.Insert( push );
3424 ExtendClippingRegion( points, spline, fillStyle, clipoperation );
3427 void a2dGcBaseDrawer::ExtendClippingRegion(
a2dVertexList* points,
bool spline, wxPolygonFillMode WXUNUSED( fillStyle ),
a2dBooleanClip clipoperation )
3433 bool smallPoly =
false;
3434 unsigned int segments = ToDeviceLines( points, devbox, smallPoly );
3436 if ( segments == 0 )
3440 segments = ConvertSplinedPolygon2( segments );
3442 wxPoint* int_cpts = _convertToIntPointCache( segments, &m_cpointsDouble[0] );
3443 wxRegion add = wxRegion( segments, int_cpts, wxWINDING_RULE );
3450 totaladd.Union( add );
3452 if ( !m_clip.Empty() )
3455 switch ( clipoperation )
3458 result = m_clip.Intersect( totaladd );
3462 result = m_clip.Union( totaladd );
3466 result = m_clip.Xor( totaladd );
3470 result = m_clip.Subtract( totaladd );
3481 m_context->ResetClip();
3487 m_context->ResetClip();
3490 m_clipboxdev = m_clip.GetBox();
3491 m_clipboxworld = ToWorld( m_clipboxdev );
3492 m_context->Clip( m_clipboxworld.GetMinX(), m_clipboxworld.GetMinY(),
3493 m_clipboxworld.GetWidth(), m_clipboxworld.GetHeight() );
3496 void a2dGcBaseDrawer::PopClippingRegion()
3498 if ( !m_clipregionlist.GetCount() )
3501 m_clip = *m_clipregionlist.GetFirst()->GetData();
3502 delete m_clipregionlist.GetFirst()->GetData();
3503 m_clipregionlist.DeleteNode( m_clipregionlist.GetFirst() );
3505 m_clipboxdev = m_clip.GetBox();
3506 m_clipboxworld = ToWorld( m_clipboxdev );
3507 m_context->Clip( m_clipboxworld.GetMinX(), m_clipboxworld.GetMinY(),
3508 m_clipboxworld.GetWidth(), m_clipboxworld.GetHeight() );
3511 void a2dGcBaseDrawer::SetClippingRegionDev( wxCoord minx, wxCoord miny, wxCoord width, wxCoord height )
3513 m_clip = wxRegion( minx, miny, width, height );
3514 m_clipboxdev = wxRect( minx, miny, width, height );
3515 m_clipboxworld = ToWorld( m_clipboxdev );
3519 PushIdentityTransform();
3520 m_context->ResetClip();
3521 m_context->Clip( m_clipboxdev.x, m_clipboxdev.y,
3522 m_clipboxdev.GetWidth(), m_clipboxdev.GetHeight() );
3527 void a2dGcBaseDrawer::SetClippingRegion(
double minx,
double miny,
double maxx,
double maxy )
3529 int iminx = WorldToDeviceX( minx );
3530 int iminy = WorldToDeviceY( miny );
3531 int imaxx = WorldToDeviceX( maxx );
3532 int imaxy = WorldToDeviceY( maxy );
3535 m_clip = wxRegion( iminx, imaxy, imaxx - iminx, iminy - imaxy );
3536 m_clipboxdev = wxRect( iminx, imaxy, imaxx - iminx, iminy - imaxy );
3540 m_clip = wxRegion( iminx, iminy, imaxx - iminx, imaxy - iminy );
3541 m_clipboxdev = wxRect( iminx, iminy, imaxx - iminx, imaxy - iminy );
3544 m_context->ResetClip();
3547 PushIdentityTransform();
3548 m_context->Clip( m_clipboxdev.x, m_clipboxdev.y,
3549 m_clipboxdev.GetWidth(), m_clipboxdev.GetHeight() );
3554 void a2dGcBaseDrawer::DestroyClippingRegion()
3557 m_clipboxdev = wxRect( 0, 0, m_width, m_height );
3558 m_clipboxworld = ToWorld( m_clipboxdev );
3560 m_context->ResetClip();
3563 void a2dGcBaseDrawer::ResetStyle()
3568 SetDrawStyle( m_drawstyle );
3571 void a2dGcBaseDrawer::DoSetActiveFont(
const a2dFont& font )
3574 unsigned int fontsize;
3575 fontsize = m_currentfont.GetSize();
3578 switch ( m_currentfont.GetType() )
3582 m_currentfont.GetFont().SetPointSize( fontsize );
3583 wxGraphicsFont f = m_render->CreateFont( m_currentfont.GetFont() );
3584 m_context->SetFont( f );
3588 wxFont wxfont = *wxNORMAL_FONT;
3589 wxfont.SetPointSize( fontsize );
3590 wxGraphicsFont f = m_render->CreateFont( wxfont );
3591 m_context->SetFont( f );
3595 void a2dGcBaseDrawer::DoSetActiveStroke()
3597 wxGraphicsPen graphpen = ConvertActiveToGraphicsPen( m_context );
3598 m_context->SetPen( graphpen );
3603 void a2dGcBaseDrawer::DoSetActiveFill()
3605 wxGraphicsBrush graphbrush = ConvertActiveToGraphicsBrush( m_context );
3606 m_context->SetBrush( graphbrush );
3611 void a2dGcBaseDrawer::DoSetDrawStyle(
a2dDrawStyle drawstyle )
3616 m_drawstyle = drawstyle;
3623 #if wxCHECK_VERSION(2,9,0)
3625 m_context->SetLogicalFunction( wxINVERT );
3632 #if wxCHECK_VERSION(2,9,0)
3633 #if wxCHECK_VERSION(2,9,0)
3635 m_context->SetLogicalFunction( wxCOPY );
3644 #if wxCHECK_VERSION(2,9,0)
3646 m_context->SetLogicalFunction( wxCOPY );
3653 #if wxCHECK_VERSION(2,9,0)
3655 m_context->SetLogicalFunction( wxINVERT );
3660 SetActiveStroke( m_currentstroke );
3661 SetActiveFill( m_currentfill );
3662 #if wxCHECK_VERSION(2,9,0)
3664 m_context->SetLogicalFunction( wxCOPY );
3670 m_fixStrokeRestore = m_currentstroke;
3671 m_fixFillRestore = m_currentfill;
3672 m_fixDrawstyle = m_drawstyle;
3673 SetActiveStroke( m_currentstroke );
3674 SetActiveFill( m_currentfill );
3677 #if wxCHECK_VERSION(2,9,0)
3679 m_context->SetLogicalFunction( wxCOPY );
3685 #if wxCHECK_VERSION(2,9,0)
3687 m_context->SetLogicalFunction( wxINVERT );
3700 void a2dGcBaseDrawer::DrawImage(
const wxImage& imagein,
double x,
double y,
double width,
double height, wxUint8 Opacity )
3702 if ( m_disableDrawing )
3709 affine.
Mirror(
true,
false );
3712 PushTransform( affine );
3714 wxGraphicsBitmap bitmap = m_render->CreateBitmap( imagein );
3715 #if wxCHECK_VERSION(2,9,0)
3716 m_context->DrawBitmap( bitmap, x - width / 2.0, y - height / 2.0, width, height );
3718 m_context->DrawGraphicsBitmap( bitmap, x - width / 2.0, y - height / 2.0, width, height );
3724 void a2dGcBaseDrawer::DrawImage(
const a2dImageRGBA& image,
double x,
double y,
double width,
double height, wxUint8 Opacity )
3726 if ( m_disableDrawing )
3729 wxImage wximage = image.GetImage();
3730 wxGraphicsBitmap bitmap = m_render->CreateBitmap( wximage );
3731 #if wxCHECK_VERSION(2,9,0)
3732 m_context->DrawBitmap( bitmap, x - width / 2.0, y - height / 2.0, width, height );
3734 m_context->DrawGraphicsBitmap( bitmap, x - width / 2.0, y - height / 2.0, width, height );
3738 void a2dGcBaseDrawer::DrawLines(
const a2dVertexList* list,
bool spline )
3740 if ( m_disableDrawing )
3743 wxGraphicsPath path = m_context->CreatePath();
3745 a2dVertexList::const_iterator iter = list->begin();
3747 while ( iter != list->end() )
3751 path.MoveToPoint( seg->
m_x, seg->
m_y );
3753 path.AddLineToPoint( seg->
m_x, seg->
m_y );
3758 m_context->StrokePath( path );
3761 void a2dGcBaseDrawer::DrawLines(
a2dVertexArray* points,
bool spline )
3763 if ( m_disableDrawing )
3766 wxGraphicsPath path = m_context->CreatePath();
3769 for ( i = 0; i < points->size(); i++ )
3773 path.MoveToPoint( seg->
m_x, seg->
m_y );
3775 path.AddLineToPoint( seg->
m_x, seg->
m_y );
3778 m_context->StrokePath( path );
3781 void a2dGcBaseDrawer::DrawPolygon(
a2dVertexArray* points,
bool spline, wxPolygonFillMode fillStyle )
3783 if ( m_disableDrawing )
3786 wxGraphicsPath path = m_context->CreatePath();
3789 for ( i = 0; i < points->size(); i++ )
3793 path.MoveToPoint( seg->
m_x, seg->
m_y );
3795 path.AddLineToPoint( seg->
m_x, seg->
m_y );
3797 path.CloseSubpath();
3799 m_context->DrawPath( path , fillStyle );
3802 void a2dGcBaseDrawer::DrawPolygon(
const a2dVertexList* list,
bool spline, wxPolygonFillMode fillStyle )
3804 if ( m_disableDrawing )
3807 wxGraphicsPath path = m_context->CreatePath();
3809 a2dVertexList::const_iterator iter = list->begin();
3811 while ( iter != list->end() )
3815 path.MoveToPoint( seg->
m_x, seg->
m_y );
3817 path.AddLineToPoint( seg->
m_x, seg->
m_y );
3821 path.CloseSubpath();
3823 m_context->DrawPath( path , fillStyle );
3826 void a2dGcBaseDrawer::DrawCircle(
double xc,
double yc,
double radius )
3828 if ( m_disableDrawing )
3831 m_context->DrawEllipse( xc - radius, yc - radius, 2.0 * radius, 2.0 * radius );
3834 void a2dGcBaseDrawer::DrawEllipse(
double xc,
double yc,
double width,
double height )
3836 if ( m_disableDrawing )
3839 m_context->DrawEllipse( xc - width / 2.0, yc - height / 2.0, width, height );
3842 void a2dGcBaseDrawer::DrawLine(
double x1,
double y1,
double x2,
double y2 )
3844 if ( m_disableDrawing )
3847 m_context->StrokeLine( x1, y1, x2, y2 );
3851 void a2dGcBaseDrawer::DrawRoundedRectangle(
double x,
double y,
double width,
double height,
double radius,
bool pixelsize )
3853 if ( m_disableDrawing )
3866 m_context->DrawRoundedRectangle( x, y, width, height, radius );
3869 void a2dGcBaseDrawer::DrawPoint(
double xc,
double yc )
3871 if ( m_disableDrawing )
3875 GetUserToDeviceTransform().TransformPoint( xc, yc, xt, yt );
3879 void a2dGcBaseDrawer::DrawText(
const wxString& text,
double x,
double y,
int alignment,
bool Background )
3881 if ( m_disableDrawing )
3885 a2dBoundingBox bbox = m_currentfont.GetTextExtent( text, alignment );
3894 double dx, dy, size;
3895 dx = m_usertodevice.GetValue( 1, 0 );
3896 dy = m_usertodevice.GetValue( 1, 1 );
3897 size = m_currentfont.GetSize() * sqrt( dx * dx + dy * dy );
3901 worldbbox.MapBbox( m_usertoworld );
3903 if ( m_clipboxworld.Intersect( worldbbox ) !=
_OUT )
3906 if ( Background && !GetDrawerFill().IsNoFill() && !GetDrawerFill().GetStyle() ==
a2dFILL_TRANSPARENT )
3912 SetDrawerStroke( oldstroke );
3915 const double h = m_currentfont.GetLineHeight();
3920 affine.
Mirror(
true,
false );
3923 PushTransform( affine );
3929 if ( size > m_drawingthreshold )
3930 m_context->DrawText( text, x, y );
3933 DrawTextUnknown( text, x, y,
true );
3941 IMPLEMENT_DYNAMIC_CLASS( a2dNativeGcDrawer, a2dGcBaseDrawer )
3947 void a2dNativeGcDrawer::InitContext()
3950 m_buffer = wxBitmap( m_width, m_height );
3951 m_memdc.SelectObject( m_buffer );
3953 m_render = wxGraphicsRenderer::GetDefaultRenderer();
3955 m_context = m_render->CreateContext( m_memdc );
3958 a2dNativeGcDrawer::a2dNativeGcDrawer(
const wxSize& size ): a2dGcBaseDrawer( size.GetWidth(), size.GetHeight() )
3963 a2dNativeGcDrawer::a2dNativeGcDrawer(
int width,
int height, wxGraphicsRenderer* render, wxGraphicsContext* context )
3964 : a2dGcBaseDrawer( width, height )
3967 m_context = context;
3971 a2dNativeGcDrawer::a2dNativeGcDrawer(
const a2dNativeGcDrawer& other )
3972 : a2dGcBaseDrawer( other )
3979 a2dNativeGcDrawer::a2dNativeGcDrawer(
const a2dDrawer2D& other )
3980 : a2dGcBaseDrawer( other )
3985 a2dNativeGcDrawer::~a2dNativeGcDrawer()
3987 m_memdc.SelectObject( wxNullBitmap );
3990 wxBitmap a2dNativeGcDrawer::GetBuffer()
const
3995 void a2dNativeGcDrawer::SetBufferSize(
int w,
int h )
3999 wxBitmap helpbuf = wxBitmap( w, h );
4004 mdch.SelectObject( helpbuf );
4005 mdch.Blit( 0, 0, w, h, &m_memdc, 0, 0 );
4006 mdch.SelectObject( wxNullBitmap );
4008 m_memdc.SelectObject( wxNullBitmap );
4010 m_memdc.SelectObject( m_buffer );
4012 m_context = m_render->CreateContext( m_memdc );
4015 wxBitmap a2dNativeGcDrawer::GetSubBitmap( wxRect rect )
const
4017 wxBitmap ret( rect.width, rect.height, m_buffer.GetDepth() );
4018 wxASSERT_MSG( ret.Ok(), wxT(
"GetSubImage error" ) );
4022 dcb.SelectObject( ret );
4023 dcb.Blit( 0, 0, rect.width, rect.height, const_cast< wxMemoryDC* >( &m_memdc ), rect.x, rect.y, wxCOPY,
false );
4024 dcb.SelectObject( wxNullBitmap );
4029 void a2dNativeGcDrawer::CopyIntoBuffer(
const wxBitmap& bitm )
4031 m_memdc.SelectObject( wxNullBitmap );
4033 m_memdc.SelectObject( m_buffer );
4036 void a2dNativeGcDrawer::BlitBuffer( wxDC* dc, wxRect rect,
const wxPoint& bufferpos )
4041 rect.width += rect.x;
4044 if ( rect.width <= 0 )
return;
4048 rect.height += rect.y;
4051 if ( rect.height <= 0 )
return;
4053 if ( rect.x + rect.width > m_width )
4055 rect.width = m_width - rect.x;
4057 if ( rect.width <= 0 )
return;
4059 if ( rect.y + rect.height > m_height )
4061 rect.height = m_height - rect.y;
4063 if ( rect.height <= 0 )
return;
4065 dc->Blit( rect.x - bufferpos.x, rect.y - bufferpos.y, rect.width, rect.height, &m_memdc, rect.x, rect.y, wxCOPY,
false );
4068 void a2dNativeGcDrawer::ShiftBuffer(
int dxy,
bool yshift )
4070 int bw = GetBuffer().GetWidth();
4071 int bh = GetBuffer().GetHeight();
4074 if ( dxy > 0 && dxy < bh )
4076 wxRect rect( 0, 0, bw, bh - dxy );
4077 wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
4079 dcm.SelectObject( m_buffer );
4080 dcm.DrawBitmap( sub_bitmap, 0, dxy,
true );
4081 dcm.SelectObject( wxNullBitmap );
4083 else if ( dxy < 0 && dxy > -bh )
4085 wxRect rect( 0, -dxy, bw, bh + dxy );
4086 wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
4088 dcm.SelectObject( m_buffer );
4089 dcm.DrawBitmap( sub_bitmap, 0, 0,
true );
4090 dcm.SelectObject( wxNullBitmap );
4093 wxFAIL_MSG( wxT(
"you can only shift within height of buffer" ) );
4098 if ( dxy > 0 && dxy < bw )
4100 wxRect rect( 0, 0, bw - dxy, bh );
4101 wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
4103 dcm.SelectObject( m_buffer );
4104 dcm.DrawBitmap( sub_bitmap, dxy, 0,
true );
4105 dcm.SelectObject( wxNullBitmap );
4107 else if ( dxy < 0 && dxy > -bw )
4109 wxRect rect( -dxy, 0, bw + dxy, bh );
4110 wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
4112 dcm.SelectObject( m_buffer );
4113 dcm.DrawBitmap( sub_bitmap, 0, 0,
true );
4114 dcm.SelectObject( wxNullBitmap );
4117 wxFAIL_MSG( wxT(
"you can only shift within width of buffer" ) );
4121 void a2dNativeGcDrawer::DrawPoint(
double xc,
double yc )
4123 if ( m_disableDrawing )
4127 GetUserToDeviceTransform().TransformPoint( xc, yc, xt, yt );
4131 #endif // wxART2D_USE_GRAPHICS_CONTEXT
void SetMappingUpp(double vx1, double vy1, double xpp, double ypp)
Give the virtual size to be displayed, the mapping matrix will be calculated.
virtual void SetYaxis(bool up)
set if the Yaxis goes up or down
a2dBoundingBox GetVisibleBbox() const
get visible area as a boundingbox in world coordinates
int WorldToDeviceXRel(double x) const
convert x relative from world to device coordinates
a2dAffineMatrix m_usertodevice
pointer to current user-to-device transform matrix ( so includes mapping matrix ) ...
a2dStroke m_activestroke
used while rendering
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
virtual double GetVisibleMaxX() const
get Maximum X of the visible part in world coordinates
a2dBoundingBox & GetClippingBox()
what is the current clipping region in world coordinates
a2dDrawStyle m_drawstyle
drawstyle (like invert mode)
a2dAffineMatrix & Mirror(bool y=true, bool x=false)
mirror a matrix in x, y
double GetHeight() const
returns height of the boundingbox
double m_xpp
user units per pixel in x
wxUint8 m_StrokeOpacityCol2
active stroke alpha
bool m_asrectangle
underneath the threshold draw rectangles if true else nothing
double GetSize() const
Get the font size.
double GetStrokeWidth() const
Get stroke width.
wxUint8 m_StrokeOpacityCol1
active stroke alpha
Base class for all types of strokes, understood by a2dDrawer2D classes.
void EndRefreshDisplayDisable()
see StartRefreshDisplayDisable()
virtual void SetTransform(const a2dAffineMatrix &userToWorld)
set user-to-world transform matrix.
virtual void DeviceDrawPixel(int x1, int y1, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
draw a single, unstroked pixel in device coordinates with the given color
a2dStroke m_fixStrokeRestore
used to restore an overruled fix style
void DrawVpath(const a2dVpath *path)
Draw vector path in world coordinates.
a2dVertexList m_tempPoints
used internally in some methods to avoid constructor, new, ...
a2dFill m_activefill
used while rendering
virtual void DrawArc(double x1, double y1, double x2, double y2, double xc, double yc, bool chord)
Draw Arc in world coordinates.
unsigned int ConvertSplinedPolyline2(unsigned int n)
converts internal device points array to spline. Returns new number of points.
void SetDrawStyle(a2dDrawStyle drawstyle)
set drawstyle to use for drawing,
int WorldToDeviceY(double y) const
convert y from world to device coordinates
void DestroyClippingRegion()
set clipping region off
static wxUint16 GetPrimitiveThreshold()
get drawing threshold
const a2dStroke * a2dBLACK_STROKE
global a2dStroke stock object for BLACK stroking
Stroke and fill base classes.
void SetBufferSize(int w, int h)
set buffer size to w pixel wide and h pixels heigh
virtual void PopTransform(void)
Recall the previously saved user-to-world transform off the matrix stack.
bool m_realScale
If true use real scale else different scale by x and y.
std::vector< a2dAffineMatrix > m_affineStack
Affine transform stack.
void DrawRoundedRectangle(double x, double y, double width, double height, double radius, bool pixelsize=false)
Draw RoundedRectangle in world coordinates.
a2dPoint2D GetStop() const
Get stop for gradient fill colour change.
double GetVisibleMinX() const
get Minimal X of the visible part in world coordinates
unsigned char m_colour2blueFill
active fill colours
wxColour GetColour2() const
return colour 2
const int SPLINE_STEP
number of steps when converting a spline to lines.
a2dStroke m_currentstroke
used while rendering
a2dDrawStyle m_fixDrawstyle
used to restore an overruled fix style
OVERLAP Intersect(const a2dBoundingBox &, double Marge=0) const
wxPen ConvertActiveToPen()
get active stroke as wxPen
const a2dFill * a2dBLACK_FILL
global a2dFill stock object for BLACK filling
int m_refreshDisplay
see SetRefreshDisplay()
void DrawEllipticArc(double xc, double yc, double width, double height, double sa, double ea, bool chord)
Draw Elliptic Arc in world coordinates.
void PopClippingRegion()
pop a previously pushed clipping region
virtual void DrawVpath(const a2dVpath *path)
Draw vector path in world coordinates.
a2dBlindDrawer2D(int w=100, int h=100)
Drawer having a buffer of w pixel wide and h pixels heigh.
double wxDegToRad(double deg)
conversion from degrees to radians
virtual void DestroyClippingRegion()=0
set clipping region off
void SetMappingDeviceRect(int mapx, int mapy, int mapWidth, int mapHeight, bool remap=false)
to change the default mapping (to the complete buffer).
std::vector< wxRealPoint > m_cpointsDouble
cached array for containing transformed device coordinates (double)
double DeviceToWorldYRel(double y) const
convert y relative from device to world coordinates
double m_y3
control point 2
wxUint16 m_polygonFillThreshold
polygon smaller than this value will be rendered non filled.
double GetDescent() const
Get descent.
void SetDrawerStroke(const a2dStroke &stroke)
Used to set the current stroke.
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
double m_x3
control point 2
double GetRadius() const
Get stop for gradient fill colour change.
virtual void DrawPolygon(a2dVertexArray *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)
Draw polygon in world coordinates using pointarray.
bool GetPixelStroke() const
if the width is pixels or not.
double GetValue(int col, int row) const
get the value in the matrix at col,row
unsigned char m_colour1redFill
active fill colours
bool GetYaxis() const
get y axis orientation
void SetClippingRegion(a2dVertexList *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)
set clipping region from polygon to which everything drawn will be clipped.
a2dGlobal * a2dGlobals
global a2dCanvasGlobal to have easy access to global settings
a2dFont m_currentfont
current font set
a2dBoundingBox m_clipboxworld
current clipping area in world coordinates
double GetVisibleMinY() const
get Minimal X of the visible part in world coordinates
a2dDrawer2D(int width=0, int height=0)
constructor
wxUint16 GetPolygonFillThreshold()
get threshold at which polygon is drawn filled or only outline
a2dAffineMatrix m_usertoworld
pointer to current user-to-world transform matrix
virtual ~a2dBlindDrawer2D()
destructor
void SetFont(const a2dFont &font)
set font to use for drawing text
wxRect ToDevice(const a2dBoundingBox &bbox)
convert the bounding box in world coordinates to device coordinates and return that rectangle...
Arc Segment in a2dVertexList.
void ReStoreFixedStyle()
when fixed drawing style is set, it can be overruled.
vertex array of line and arc segments.
int m_mapHeight
height for mapping in device coordinates
bool m_fixedStyledOverRuled
keep track of this
wxColour GetColour() const
return colour 1
unsigned char m_colour1blueStroke
active stroke colours
a2dAffineMatrix a2dIDENTITY_MATRIX
global a2dAffineMatrix to set/pass the identity matrix.
double m_y2
control point 1
bool Clipping(double &x1, double &y1, double &x2, double &y2)
clip lines
virtual void EndDraw()
end drawing on this context (used to reset a specific drawer)
unsigned char m_colour2redFill
active fill colours
double m_virt_minY
virtual coordinates box its miminum Y
std::vector< wxPoint > m_cpointsInt
cached array for containing transformed device coordinates (integer)
vertex list of line and arc segments.
unsigned char m_colour1blueFill
active fill colours
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
virtual void DeviceDrawVerticalLine(int x1, int y1, int y2, bool use_stroke_color)
Draw a pixel-width, unstroked vertical line in device (pixel) coordinates.
void DoSetActiveStroke()
per drawer implementation
virtual void DrawCenterRoundedRectangle(double xc, double yc, double width, double height, double radius, bool pixelsize=false)
Draw CenterRoundedRectangle in world coordinates.
a2dStrokeGlyph GetGlyphStroke(wxChar c) const
Get the glyph of a single character.
double TransformDistance(double distance) const
Transform a distance.
virtual void ExtendAndPushClippingRegion(a2dVertexList *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE, a2dBooleanClip clipoperation=a2dCLIP_AND)
push on stack the current clipping region and extend clipping region
virtual void DrawCharStroke(wxChar c)
Draw a stroke character.
void DrawTextGeneric(const wxString &text, double x, double y, void(a2dDrawer2D::*drawchar)(wxChar))
#define NORMFONT
Normalization font size used for bigger size drawing of text.
a2dBoundingBox GetTextExtent(const wxString &string, int alignment=wxMINX|wxMINY, double *w=NULL, double *h=NULL, double *descent=NULL, double *externalLeading=NULL) const
Get the dimensions in world coordinates of the string.
virtual void SetActiveFill(const a2dFill &fill)
sync with actual API graphical context
virtual double GetVisibleHeight() const
get Height of visible part in world coordinates
a2dDrawStyle
Define the manner in which a2dCanvasView draws to the device.
void DrawLines(a2dVertexArray *points, bool spline=false)
Draw polyline in world coordinates using pointarray.
void SetDrawerFill(const a2dFill &fill)
Used to set the current fill.
bool Ok() const
Check font validity.
void DrawLine(double x1, double y1, double x2, double y2)
Draw line in world coordinates.
virtual void PushTransform()
Save the current user-to-world transform on the affine stack.
double GetWidth(wxChar c)
Get width of a single character.
double DeviceToWorldY(double y) const
convert y from device to world coordinates
bool CalcR(const a2dLineSegment &prev, double &radius, double ¢er_x, double ¢er_y, double &beginrad, double &midrad, double &endrad, double &phit) const
Calculation of center for the Arc.
void Expand(const a2dPoint2D &, const a2dPoint2D &)
expand boundingbox width two points
const a2dBoundingBox & Translate(a2dPoint2D &)
translate with given vector
double GetMinX() const
get minimum X of the boundingbox
virtual void DrawRoundedRectangle(double x, double y, double width, double height, double radius, bool pixelsize=false)
Draw RoundedRectangle in world coordinates.
void DrawArc(double x1, double y1, double x2, double y2, double xc, double yc, bool chord)
Draw Arc in world coordinates.
a2dAffineMatrix m_worldtodevice
world to device coordinate mapping
double GetLineHeight() const
Get the line height.
void Init()
Initialize a drawer.
double m_displayaberration
accuracy of arc segment calculation etc. in device coordinates
virtual void ResetStyle()
set a pre-defined style reseting cashed values.
#define forEachIn(listtype, list)
easy iteration for a2dlist
class draws nothing, still can be used as a drawing context.
virtual void DrawPoint(double xc, double yc)=0
draw a single point
unsigned char m_colour1greenStroke
active stroke colours
const a2dFont * a2dNullFONT
global a2dFont stock object for NO font
void SetUppX(double x)
set world units per pixel in X
void DetectCriticalPoints(int n, wxRealPoint points[])
Used for filling with Gradient fill style.
wxUint16 m_drawingthreshold
object smaller than this value will not be rendered
double m_ypp
user units per pixel in y
void GetClippingMinMax(double &xmin, double &ymin, double &xmax, double &ymax) const
what is the current clipping region in world coordinates
virtual void DrawPolyPolygon(a2dListOfa2dVertexList polylist, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)
draw a list of polygons ( contour clockwise becomes hole )
a2dPoint2D GetStart() const
Get start for gradient fill colour change.
virtual double GetVisibleWidth() const
get Width of visible part in world coordinates
a2dPoint2D GetCenter() const
Get start for gradient fill colour change.
Drawing context abstraction.
Normal straight line segment in a2dVertexList and a2dVertexArray.
bool CalcR(a2dVpathSegmentPtr prev, double &radius, double ¢er_x, double ¢er_y, double &beginrad, double &midrad, double &endrad, double &phit)
Calculation of center for the Arc.
void CalculateLineParameters()
Calculate the parameters if invalid.
void SetUppY(double y)
set world units per pixel in Y
virtual void DrawTextFreetype(const wxString &text, double x, double y)
Draw text in world coordinates, based on a freetype font .
virtual void DoSetActiveStroke()=0
per drawer implementation
unsigned char m_colour2greenFill
active fill colours
void DrawImage(const wxImage &image, double x, double y, double width, double height, wxUint8 Opacity=255)
Draw wxImage in world coordinates.
int WorldToDeviceX(double x) const
convert x from world to device coordinates
int m_mapX
X mapping position in device coordinates.
virtual void DrawLine(double x1, double y1, double x2, double y2)
Draw line in world coordinates.
virtual void DrawTextUnknown(const wxString &text, double x, double y, bool words=false)
Draw a cross, indicating an unsupported font type for this drawer.
a2dAETList m_AETlist
scanline list of intersections with polygon
virtual void DoSetActiveFill()=0
per drawer implementation
a2dPoint2D GetFocal() const
Get start for gradient fill colour change.
virtual void DeviceDrawLine(double x1, double y1, double x2, double y2)
draw in pixels
wxBrush ConvertActiveToBrush()
get active fill as wxBrush
int GetClipCode(double x, double y)
clip code of a point
void DrawPoint(double xc, double yc)
draw a single point
void ResetFixedStyle()
only way to reset style after SetDrawStyle( a2dFIXED*** );
bool Identity(void)
Make into identity matrix.
virtual void DrawTextDc(const wxString &text, double x, double y)
Draw text in user coordinates, based on a dc font .
double m_x2
control point 1
virtual void DrawText(const wxString &text, double x, double y, int alignment=wxMINX|wxMINY, bool Background=true)
Draw text in user coordinates.
A 2x3 affine matrix class for 2D transformations.
void DrawCenterRoundedRectangle(double xc, double yc, double width, double height, double radius, bool pixelsize=false)
Draw CenterRoundedRectangle in world coordinates.
a2dStroke GetDrawerStroke() const
get the current stroke
virtual void SetActiveStroke(const a2dStroke &stroke)
sync with actual API graphical context
a2dBoundingBox ToWorld(const wxRect &rect)
convert the rect in device coordinates to a bounding box in world coordinates and return that boundin...
double GetMaxX() const
get maximum X of the boundingbox
void DrawCharStrokeCb(wxChar c)
Wrapper for DrawCharStroke.
void SetMappingMatrix(const a2dAffineMatrix &mapping)
int m_height
device size height
bool m_disableDrawing
all drawing is disabled when this is true
bool GetFilling() const
if true, filling is on else filling is transparent.
void ConvertIntoSplinedPolygon(double Aber)
static const a2dSignal sig_changedZoom
Contains graphical drawing context specific classes. a2dDrawer2D and derived classes are used for dra...
wxPoint * _convertToIntPointCache(int n, wxRealPoint *pts)
Convert double points to integer coords in the point cache and return pointer.
double m_x
x endpoint of line
virtual void DrawEllipticArc(double xc, double yc, double width, double height, double sa, double ea, bool chord)
Draw Elliptic Arc in world coordinates.
virtual ~a2dDrawer2D()
destructor
void DrawCircle(double x, double y, double radius)
Draw Circle in world coordinates.
void MapBbox(const a2dAffineMatrix &matrix)
a2dBooleanClip
Used for defining how a ClippingRegion defined as a polygon is combined with.
wxRect m_clipboxdev
current clipping area in device coordinates
double m_y
y endpoint of line
void FillPolygon(int n, wxRealPoint points[])
Used for filling with Gradient fill style.
a2dCriticalPointList m_CRlist
critical point list for polygon
void Aberration(double aber, double angle, double radius, double &dphi, unsigned int &segments)
calculate number of segments in an arc such that a certain accuracy is maintained ...
bool m_printingMode
can be used to modify drawing features when used as context for printing
virtual void DrawTextStroke(const wxString &text, double x, double y)
Draw text in user coordinates, based on a stroke font.
void SetMinX(double x)
Set Minimal X of the visible part in world coordinates.
void SetClippingRegionDev(wxCoord minx, wxCoord miny, wxCoord width, wxCoord height)
set clipping region using x y values in device coordinates
bool m_virtualarea_set
is the virtual area set already (used during startup)
int m_beginDraw_endDraw
counter for BeginDraw EndDraw calls
double m_virt_minX
virtual coordinates box its miminum X
virtual void ExtendClippingRegion(a2dVertexList *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE, a2dBooleanClip clipoperation=a2dCLIP_AND)
extend clipping region with a polygon to which everything drawn will be clipped.
int m_width
device size width
void DoSetActiveFill()
per drawer implementation
virtual void DrawCharUnknown(wxChar c)
Draw a cross instead of a character.
double DeviceToWorldX(double x) const
convert x from device to world coordinates
double m_y1
y endpoint of line
unsigned char m_colour1greenFill
active fill colours
double GetMaxY() const
get maximum Y of the boundingbox
double GetWidth() const
returns width of the boundingbox
bool m_pendingSig_changedZoom
When display refresh is on hold, this triggers a delayed zoom signal, when released.
virtual void DeviceDrawPolygon(unsigned int n, bool spline, wxPolygonFillMode fillStyle)
draw an internal polygon in device coordinates
bool MoveUp(int n, wxRealPoint points[], double horline, int &index, int direction)
Used for filling with Gradient fill style.
unsigned char m_colour1redStroke
active stroke colours
void BlitBuffer()
blit whole buffer to device
wxColour GetColour() const
return colour
bool Scale(double scale)
Scale by scale (isotropic scaling i.e. the same in x and y):
bool Translate(double x, double y)
Translate by dx, dy:
double GetKerning(wxChar c1, wxChar c2) const
Get kerning space between two characters.
static bool GetThresholdDrawRectangle()
underneath the threshold draw rectangles instead of the real object.
void DeviceDrawAnnotation(const wxString &text, wxCoord x, wxCoord y, const wxFont &font)
text drawn in device coordinates
int m_mapWidth
width for mapping in device coordinates
const a2dStroke * a2dTRANSPARENT_STROKE
global a2dStroke stock object for TRANSPARENT stroking
wxWindow * m_display
view its window.
command processor and intializing and event handling classes specific for wxDocview.
a2dFill GetDrawerFill() const
get the current fill
wxUint8 m_FillOpacityCol1
active fill alpha
bool m_forceNormalizedFont
up or down
void SetMinY(double y)
Set Minimal Y of the visible part in world coordinates.
int ToDeviceLines(a2dVertexArray *points, a2dBoundingBox &devbbox, bool &smallPoly, bool replaceByRectangle=false)
convert vertex array containing line and arc segments in user coordinates to device coordinate lines...
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
virtual void BeginDraw()
start to draw on this context (used to initialize a specific drawer)
const a2dAffineMatrix & GetTransform() const
get the user-to-world transform matrix.
void SetValue(int col, int row, double value)
set the value in the matrix at col,row
double GetMinY() const
get minimum Y of the boundingbox
virtual double GetVisibleMaxY() const
get Maximum Y of the visible part in world coordinates
double m_x1
x endpoint of line
virtual void DrawEllipse(double x, double y, double width, double height)
Draw Ellipse in world coordinates.
void DrawEllipse(double x, double y, double width, double height)
Draw Ellipse in world coordinates.
wxRect & GetClippingBoxDev()
what is the current clipping region in device coordinates
#define Round(x)
round to integer such that e.g 2.5 < x < 3.5 becomes 3
virtual void DrawCircle(double x, double y, double radius)
Draw Circle in world coordinates.
void SetSplineAberration(double aber)
Set the detail level for spline drawing.
virtual void DrawLines(a2dVertexArray *points, bool spline=false)
Draw polyline in world coordinates using pointarray.
int m_mapY
Y mapping position in device coordinates.
void ResetStyle()
set a pre-defined style reseting cashed values.
virtual void DeviceDrawHorizontalLine(int x1, int y1, int x2, bool use_stroke_color)
Draw a pixel-width, unstroked horizontal line in device (pixel) coordinates.
a2dFill m_currentfill
used while rendering
bool m_frozen
buffer updating activity possible or not
void SetOpacityFactor(wxUint8 OpacityFactor)
when enabling m_useOpacityFactor, this is how transparent
void DrawPolygon(a2dVertexArray *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)
Draw polygon in world coordinates using pointarray.
wxUint8 m_OpacityFactor
opacity will be the one set, derived by this
double DeviceToWorldXRel(double x) const
convert x relative from device to world coordinates
virtual void SetMappingWidthHeight(double vx1, double vy1, double width, double height)
Give the virtual size to be displayed, the mapping matrix will be calculated.
const a2dAffineMatrix & GetUserToDeviceTransform() const
get matrix which transforms directly from user coordinates to device
wxUint8 m_FillOpacityCol2
active fill alpha
double m_splineaberration
accuracy of spline
virtual void DeviceDrawLines(unsigned int n, bool spline)
draw an internal polyline in device coordinates
wxBitmap GetSubBitmap(wxRect sub_rect) const
get part of the buffer given a rect
const double wxPI
defines PI
virtual void PushIdentityTransform()
push no transform, to draw directly in device coordinates
unsigned int ConvertSplinedPolygon2(unsigned int n)
converts internal device points array to spline. Returns new number of points.
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
a2dFill m_fixFillRestore
used to restore an overruled fix style
Used internal for scanned ( gradient etc. ) polygon filling.
void OverRuleFixedStyle()
id style is FIXED, saves current style and sets style to a2dFILLED