[Igarden-commit] CommonSource/YAAFExtensions RGGLSVGDraw.cpp, 1.26, 1.26.2.1 RGHypertext.cpp, 1.24,
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2006-10-29 03:32:00
|
Update of /cvsroot/igarden/CommonSource/YAAFExtensions In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv14378 Modified Files: Tag: Release_branch_v1 RGGLSVGDraw.cpp RGHypertext.cpp Log Message: Add color, rectangles, and depth to the rendering. Add three new materials which make use of these features. Index: RGGLSVGDraw.cpp =================================================================== RCS file: /cvsroot/igarden/CommonSource/YAAFExtensions/RGGLSVGDraw.cpp,v retrieving revision 1.26 retrieving revision 1.26.2.1 diff -C2 -d -r1.26 -r1.26.2.1 *** RGGLSVGDraw.cpp 4 Nov 2005 02:09:05 -0000 1.26 --- RGGLSVGDraw.cpp 29 Oct 2006 03:31:56 -0000 1.26.2.1 *************** *** 56,60 **** void GetGrowConstraints(glSize_t &minSize, glSize_t &incrSize, glSize_t &maxSize); void FindDrawingSize(XGXMLData *data, glSize_t size, glRectangle_t &bounds); ! void ParseDrawingTags(XGXMLData *data, double xOffset, double yOffset, double xSize, double ySize, double scaleX, double scaleY); const char *ParseOnePoint(const char *val, bool doTranslate, double xSize, double ySize, double top, double left, double &x, double &y); double StringToLength(const char* text); --- 56,60 ---- void GetGrowConstraints(glSize_t &minSize, glSize_t &incrSize, glSize_t &maxSize); void FindDrawingSize(XGXMLData *data, glSize_t size, glRectangle_t &bounds); ! void ParseDrawingTags(XGXMLData *data, double xOffset, double yOffset, double zOffset, double xSize, double ySize, double scaleX, double scaleY); const char *ParseOnePoint(const char *val, bool doTranslate, double xSize, double ySize, double top, double left, double &x, double &y); double StringToLength(const char* text); *************** *** 63,66 **** --- 63,72 ---- void GetInitialSize(double &width, double &length); void GetRepeatCounts(double width, double length, long &widthCount, long &lengthCount); + const char *GetArcParameters(const char *val, glPoint_t start, bool doTranslate, glSize_t mySize, glPoint_t &end, glPoint_t ¢er, double &rx, double &ry, bool &sweep, bool &large, bool &isClosed); + void EnumeratePathVertices(const char *val, double xOffset, double yOffset, double zOffset, double xSize, double ySize, double scaleX, double scaleY, double translateX, double translateY); + bool IsStrokeStyleVisible(XGXMLData *data); + void SetStrokeStyle(XGXMLData *data, double xScale, double yScale); + bool IsFillStyleVisible(XGXMLData *data); + void SetFillStyle(XGXMLData *data); XGFileSpecifier _spec; *************** *** 296,300 **** /// off in a routine of their own. // ! void SVGCacheEntry::ParseDrawingTags(XGXMLData *data, double xOffset, double yOffset, double xSize, double ySize, double scaleX, double scaleY) { XGXMLObject *sub2; --- 302,306 ---- /// off in a routine of their own. // ! void SVGCacheEntry::ParseDrawingTags(XGXMLData *data, double xOffset, double yOffset, double zOffset, double xSize, double ySize, double scaleX, double scaleY) { XGXMLObject *sub2; *************** *** 302,309 **** const char *val; double xPos, yPos, offsetShiftX, offsetShiftY, midXPlan, midYPlan; titleTag_t tag, tag2; bool forX, forY, xGrows, yGrows; long xReps, yReps, xIndex, yIndex; ! const char *nextCh, *tmp, *widthStr; if(strcmp(data->GetTag(), "g") == 0) --- 308,316 ---- const char *val; double xPos, yPos, offsetShiftX, offsetShiftY, midXPlan, midYPlan; + double zPos = -0.1; titleTag_t tag, tag2; bool forX, forY, xGrows, yGrows; long xReps, yReps, xIndex, yIndex; ! const char *nextCh, *tmp; if(strcmp(data->GetTag(), "g") == 0) *************** *** 499,509 **** for(xIndex = 0, xNew = xOffset; xIndex < xReps; xIndex++, xNew += _midXSize*_fixScale) { ! ParseDrawingTags(subData, xNew, yNew, xSize, ySize, scaleX, scaleY); } } } else ! ParseDrawingTags(subData, xOffset, yOffset, xSize, ySize, scaleX, scaleY); sub2 = sub2->GetSibling(); } --- 506,517 ---- for(xIndex = 0, xNew = xOffset; xIndex < xReps; xIndex++, xNew += _midXSize*_fixScale) { ! ParseDrawingTags(subData, xNew, yNew, zPos, xSize, ySize, scaleX, scaleY); } } } else ! ParseDrawingTags(subData, xOffset, yOffset, zPos, xSize, ySize, scaleX, scaleY); + zPos += 0.001; sub2 = sub2->GetSibling(); } *************** *** 520,628 **** glEnd(); } else if(strcmp(data->GetTag(), "path") == 0) { ! val = data->GetArgValue("style"); ! if(CIstrstr(val, "stroke:#FFFFFF") == NULL) { ! widthStr = CIstrstr(val, "stroke-width:"); ! if(widthStr != NULL) { ! char *temp; ! widthStr += strlen("stroke-width:"); ! glLineWidth(strtod(widthStr, &temp)+0.5); } ! else ! glLineWidth(1.5); ! val = data->GetArgValue("d"); ! glPushAttrib(GL_DEPTH_BUFFER_BIT); ! glDisable(GL_LINE_STIPPLE); ! glDisable(GL_DEPTH_TEST); ! glEnable(GL_LINE_SMOOTH); ! glColor3f (0.0, 0.0, 0.0); ! glEnable(GL_MAP1_VERTEX_3); ! ! while(*val != '\0') { while(*val == ' ' || *val == '\t') val++; ! if(*val == 'C') { ! GLfloat ctrlpoints[4][3]; ! int i; ! val++; ! ctrlpoints[0][0] = (xPos * scaleX) + xOffset; ! ctrlpoints[0][1] = (yPos * scaleY) + yOffset; ! ctrlpoints[0][2] = 0.0; ! ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! ctrlpoints[1][0] = (xPos * scaleX) + xOffset; ! ctrlpoints[1][1] = (yPos * scaleY) + yOffset; ! ctrlpoints[1][2] = 0.0; ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! ctrlpoints[2][0] = (xPos * scaleX) + xOffset; ! ctrlpoints[2][1] = (yPos * scaleY) + yOffset; ! ctrlpoints[2][2] = 0.0; ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! ctrlpoints[3][0] = (xPos * scaleX) + xOffset; ! ctrlpoints[3][1] = (yPos * scaleY) + yOffset; ! ctrlpoints[3][2] = 0.0; ! glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]); ! ! glBegin(GL_LINE_STRIP); ! for(i= 0; i <= 30; i++) { ! glEvalCoord1f(((GLfloat)i)/30.0); } - glEnd(); } else { ! if(*val == 'M') ! { val++; ! while(*val == ' ' || *val == '\t') ! val++; ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! } ! else if(*val == 'L') ! { val++; ! while(*val == ' ' || *val == '\t') ! val++; ! glBegin(GL_LINE_STRIP); ! glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, 0.0); // Z axis taken care of on glTranslate ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, 0.0); // Z axis taken care of on glTranslate ! glEnd(); ! } ! else { ! if(*val == 'A') ! val++; ! if(*val == 'z') ! val++; ! while(*val == ' ' || *val == '\t') ! val++; ! if(*val != '\0') ! { ! glBegin(GL_LINE_STRIP); ! glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, 0.0); // Z axis taken care of on glTranslate ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, 0.0); // Z axis taken care of on glTranslate ! glEnd(); ! } } } } - glPopAttrib(); } } } // --------------------------------------------------------------------------- /// FindDrawingSize PRIVATE --- 528,877 ---- glEnd(); } + else if(strcmp(data->GetTag(), "rect") == 0) + { + double height, width; + char *junk; + + val = data->GetArgValue("width"); + width = strtod(val, &junk); + val = data->GetArgValue("height"); + height = strtod(val, &junk); + val = data->GetArgValue("x"); + xPos = strtod(val, &junk); + val = data->GetArgValue("y"); + yPos = strtod(val, &junk); + + xPos -= _bounds.left; + yPos -= _bounds.top; + // Translate the coordinates to centered around zero + xPos = (xPos - (xSize/2)); + // In addition, the SVG Y coordinate needs to be translated to an OpenGL coordinate + yPos = ((ySize-yPos) - (ySize/2)); + + if(IsStrokeStyleVisible(data)) + { + glBegin(GL_LINE_STRIP); + SetStrokeStyle(data, scaleX, scaleY); + + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, 0.0); + xPos += width; + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, 0.0); + yPos -= height; + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, 0.0); + xPos -= width; + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, 0.0); + yPos += height; + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, 0.0); + glEnd(); + } + + if(IsFillStyleVisible(data)) + { + glBegin(GL_POLYGON); + SetFillStyle(data); + + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, zOffset); + xPos += width; + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, zOffset); + yPos -= height; + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, zOffset); + xPos -= width; + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, zOffset); + yPos += height; + glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, zOffset); + glEnd(); + } + } else if(strcmp(data->GetTag(), "path") == 0) { ! double translateX = 0.0, translateY = 0.0; ! const char *transform, *dval; ! ! transform = data->GetArgValue("transform"); ! if(transform != NULL) { ! if(strncmp(transform, "translate(",10) == 0) { ! (void)ParseOnePoint(transform+10, false, 0.0, 0.0, 0.0, 0.0, translateX, translateY); ! } ! else if(strncmp(transform, "matrix(",7) == 0) ! { ! float a, b, c, d, e, f; ! long numValid; ! numValid = sscanf(transform, "matrix(%f,%f,%f,%f,%f,%f", &a, &b, &c, &d, &e, &f); ! if(b == 0.0 && c == 0.0) ! { ! // scaleX *= a; ! // scaleY *= d; ! translateX = (-1*e)*a; ! translateY = (-1*f)*d; ! } ! else ! printf("Transform not implemented\n"); } ! } ! ! dval = data->GetArgValue("d"); ! ! glPushAttrib(GL_DEPTH_BUFFER_BIT); ! glDisable(GL_LINE_STIPPLE); ! glDisable(GL_DEPTH_TEST); ! glEnable(GL_LINE_SMOOTH); ! glColor3f (0.0, 0.0, 0.0); ! glEnable(GL_MAP1_VERTEX_3); ! ! if(IsStrokeStyleVisible(data)) ! { ! glBegin(GL_LINE_STRIP); ! SetStrokeStyle(data, scaleX, scaleY); ! EnumeratePathVertices(dval, xOffset, yOffset, 0.0, xSize, ySize, scaleX, scaleY, translateX, translateY); ! glEnd(); ! } ! ! if(IsFillStyleVisible(data)) ! { ! dval = data->GetArgValue("d"); ! glBegin(GL_POLYGON); ! SetFillStyle(data); ! EnumeratePathVertices(dval, xOffset, yOffset, zOffset, xSize, ySize, scaleX, scaleY, translateX, translateY); ! glEnd(); ! } ! ! glPopAttrib(); ! ! } ! } ! ! void SVGCacheEntry::EnumeratePathVertices(const char *val, double xOffset, double yOffset, double zOffset, double xSize, double ySize, double scaleX, double scaleY, double translateX, double translateY) ! { ! double xPos, yPos, xPosSVG, yPosSVG, startXPos, startYPos, span; ! bool startPosSet = false; ! ! while(*val != '\0') ! { ! while(*val == ' ' || *val == '\t') ! val++; ! if(*val == 'C') ! { ! GLfloat ctrlpoints[4][3]; ! int i; ! val++; ! ctrlpoints[0][0] = (xPos * scaleX) + xOffset; ! ctrlpoints[0][1] = (yPos * scaleY) + yOffset; ! ctrlpoints[0][2] = 0.0; ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! ctrlpoints[1][0] = (xPos * scaleX) + xOffset; ! ctrlpoints[1][1] = (yPos * scaleY) + yOffset; ! ctrlpoints[1][2] = 0.0; ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! ctrlpoints[2][0] = (xPos * scaleX) + xOffset; ! ctrlpoints[2][1] = (yPos * scaleY) + yOffset; ! ctrlpoints[2][2] = 0.0; ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! ctrlpoints[3][0] = (xPos * scaleX) + xOffset; ! ctrlpoints[3][1] = (yPos * scaleY) + yOffset; ! ctrlpoints[3][2] = 0.0; ! ! glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]); ! ! for(i= 0; i <= 30; i++) ! { ! glEvalCoord1f(((GLfloat)i)/30.0); ! } ! glEnd(); ! } ! else ! { ! if(*val == 'M') { + val++; while(*val == ' ' || *val == '\t') val++; ! ParseOnePoint(val, false, xSize, ySize, _bounds.top, _bounds.left, xPosSVG, yPosSVG); ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! } ! else if(*val == 'L') ! { ! val++; ! while(*val == ' ' || *val == '\t') ! val++; ! glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, zOffset); // Z axis taken care of on glTranslate ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, zOffset); // Z axis taken care of on glTranslate ! } ! else ! { ! if(*val == 'A') { ! glPoint_t start, end, center; ! double rx, ry; ! double startA, endA, delta; ! long count; ! bool sweep, large, isClosed; ! glSize_t mySize; ! start.x = xPosSVG; ! start.y = yPosSVG; ! mySize.x = xSize; ! mySize.y = ySize; ! val = GetArcParameters(val, start, false, mySize, end, center, rx, ry, sweep, large, isClosed); ! start.x += translateX; ! start.y += translateY; ! end.x += translateX; ! end.y += translateY; ! center.x += translateX; ! center.y += translateY; ! ! if(start.x != end.x || start.y != end.y) { ! delta = (3.0/360.0)*2*3.14; ! startA = atan2(start.y-center.y,start.x-center.x); //*(360/(2*3.14)); ! endA = atan2(end.y-center.y,end.x-center.x); //*(360/(2*3.14)); ! span = endA-startA; ! if(span < 0) ! span *= -1.0; ! if((span < 3.14) && large) ! span = (2*3.14) - span; ! count = span/delta; ! ! double t, x, y; ! long n; ! ! x = start.x; //- center.x; ! y = start.y; //- center.y; ! if(!sweep) ! delta *= -1.0; ! ! // printf("Count = %ld center = %f,%f, startAnd %f endAng %f\n", count, center.x, center.y, startA, startA+(count*delta)); ! if(startA != NAN && endA != NAN) ! { ! if(!startPosSet) ! { ! startXPos = (cos(startA) * rx*cos(startA) - sin(startA)*ry*sin(startA)); //+ (center.x - (xSize/2)); ! startYPos = (sin(startA) * rx*cos(startA) + cos(startA)*ry*sin(startA)); //+ (center.y - (ySize/2)); ! startPosSet = true; ! } ! ! for(t = startA, n = 0; n < count; n++, t += delta) ! { ! x = (cos(t) * rx*cos(t) - sin(t)*ry*sin(t)); //+ (center.x - (xSize/2)); ! y = (sin(t) * rx*cos(t) + cos(t)*ry*sin(t)); //+ (center.y - (ySize/2)); ! glVertex3f((x * scaleX) + xOffset, (y * scaleY) + yOffset, 0.0); // Z axis taken care of on glTranslate ! } ! ! x = (cos(endA) * rx*cos(endA) - sin(endA)*ry*sin(endA)); //+ (center.x - (xSize/2)); ! y = (sin(endA) * rx*cos(endA) + cos(endA)*ry*sin(endA)); //+ (center.y - (ySize/2)); ! glVertex3f((x * scaleX) + xOffset, (y * scaleY) + yOffset, 0.0); // Z axis taken care of on glTranslate ! } ! if(isClosed && startPosSet) ! { ! // glBegin(GL_LINES); ! // glVertex3f((x * scaleX) + xOffset, (y * scaleY) + yOffset, 0.0); // Z axis taken care of on glTranslate ! // glVertex3f((startXPos * scaleX) + xOffset, (startYPos * scaleY) + yOffset, 0.0); // Z axis taken care of on glTranslate ! // glEnd(); ! } ! xPosSVG = end.x; ! yPosSVG = end.y; } } else { ! if(*val == 'z') val++; ! while(*val == ' ' || *val == '\t') val++; ! if(*val != '\0') { ! glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, zOffset); // Z axis taken care of on glTranslate ! val = ParseOnePoint(val, true, xSize, ySize, _bounds.top, _bounds.left, xPos, yPos); ! glVertex3f((xPos * scaleX) + xOffset, (yPos * scaleY) + yOffset, zOffset); // Z axis taken care of on glTranslate } } } } } } + const char *SVGCacheEntry::GetArcParameters(const char *val, glPoint_t start, bool doTranslate, glSize_t mySize, + glPoint_t &end, glPoint_t ¢er, double &rx, double &ry, bool &isSweep, bool &isLarge, bool &isClosed) + { + double rot, x1, y1, x2, y2, scalar, scalarSq; + double x1p, y1p, cxp, cyp; + long largeArc, sweep; + char *next; + + isClosed = false; + val++; + rx = strtod(val, &next); + val = next; + ry = strtod(val, &next); + val = next; + rot = strtod(val, &next); + val = next; + largeArc = strtol(val, &next, 10); + val = next; + sweep = strtol(val, &next, 10); + val = next; + x1 = start.x; + y1 = start.y; + val = ParseOnePoint(val, doTranslate, mySize.x, mySize.y, 0.0, 0.0, x2, y2); + if(*val == 'z') + { + isClosed = true; + val++; + } + + if(rx < 0) + rx *= -1.0; + if(ry < 0) + ry *= -1.0; + rot *= (2*3.14/360); // To radians + + // Formula F.6.5.1 + x1p = (cos(rot) * (x1-x2) / 2.0) + (sin(rot) * (y1-y2)/2.0); + y1p = (-sin(rot) * (x1-x2) / 2.0) + (cos(rot) * (y1-y2)/2.0); + + // Formula F.6.5.2 + scalarSq = ((rx*rx*ry*ry) - (rx*rx*y1p*y1p) - (ry*ry*x1p*x1p))/((rx*rx*y1p*y1p)+(ry*ry*x1p*x1p)); + if(scalarSq < 0) + scalarSq *= -1.0; + scalar = sqrt(scalarSq); + if(largeArc == sweep) + scalar *= -1; + + cxp = scalar*rx*y1p/ry; + cyp = scalar* -ry *x1p/rx; + + end.x = x2; + end.y = y2; + // Formula F.6.5.3 + center.x = cos(rot)*cxp - sin(rot)*cyp + ((x1+x2)/2.0); + center.y = sin(rot)*cxp + cos(rot)*cyp + ((y1+y2)/2.0); + isSweep = sweep; + isLarge = largeArc; + + #if 0 + if(start.x != end.x || start.y != end.y) + { + printf("ARC: doTranslate = %s\n", doTranslate ? "True" : "False"); + printf(" Start Point = %f,%f End Point = %f,%f\n", x1, y1, x2, y2); + printf(" rx = %f, ry = %f\n", rx, ry); + printf(" x1' = %f, y1' = %f\n", x1p, y1p); + printf(" cx' = %f, cy' = %f\n", cxp, cyp); + printf(" scalar = %f\n", scalar); + printf(" scalar^2Num = %f\n", (rx*rx*ry*ry) - (rx*rx*y1p*y1p) - (ry*ry*x1p*x1p)); + printf(" scalar^2Den = %f\n", ((rx*rx*y1p*y1p)+(ry*ry*x1p*x1p))); + printf(" Center = %f,%f\n", center.x, center.y); + } + #endif + + return val; + } + + // --------------------------------------------------------------------------- /// FindDrawingSize PRIVATE *************** *** 634,638 **** XGXMLObject *sub2; XGXMLData *subData; ! const char *val; double xPos, yPos, localXSize, localYSize; glRectangle_t localBounds; --- 883,887 ---- XGXMLObject *sub2; XGXMLData *subData; ! const char *val, *transform; double xPos, yPos, localXSize, localYSize; glRectangle_t localBounds; *************** *** 798,804 **** --- 1047,1101 ---- } } + else if(strcmp(data->GetTag(), "rect") == 0) + { + double height, width; + char *junk; + + val = data->GetArgValue("width"); + width = strtod(val, &junk); + val = data->GetArgValue("height"); + height = strtod(val, &junk); + val = data->GetArgValue("x"); + xPos = strtod(val, &junk); + val = data->GetArgValue("y"); + yPos = strtod(val, &junk); + + if(xPos < bounds.left) + bounds.left = xPos; + if(xPos+width > bounds.right) + bounds.right = xPos+width; + if(yPos < bounds.top) + bounds.top = yPos; + if(yPos+height > bounds.bottom) + bounds.bottom = yPos+height; + } else if(strcmp(data->GetTag(), "path") == 0) { + double translateX = 0.0, translateY = 0.0; + double scaleX = 1.0, scaleY = 1.0; + val = data->GetArgValue("d"); + transform = data->GetArgValue("transform"); + if(transform != NULL) + { + if(strncmp(transform, "translate(",10) == 0) + { + (void)ParseOnePoint(transform+10, false, 0.0, 0.0, 0.0, 0.0, translateX, translateY); + } + else if(strncmp(transform, "matrix(",10) == 0) + { + double a, b, c, d, e, f; + + (void)ParseOnePoint(transform+10, false, 0.0, 0.0, 0.0, 0.0, translateX, translateY); + sscanf(transform, "matrix(%lf,%lf,%lf,%lf,%lf,%lf", &a, &b, &c, &d, &e, &f); + if(b == 0.0 && c == 0.0 && e == 0.0 && f == 0.0) + { + scaleX = a; + scaleY = d; + } + else + printf("Transform not implemented\n"); + } + } while(*val != '\0') { *************** *** 806,810 **** val++; if(*val == 'M' || *val == 'C' || *val == 'L' || *val == 'A') ! val++; if(*val == 'z') val++; --- 1103,1176 ---- val++; if(*val == 'M' || *val == 'C' || *val == 'L' || *val == 'A') ! { ! if(*val == 'A') ! { ! glPoint_t start, end, center; ! glSize_t mySize; ! double rx, ry; ! bool sweep, large, isClosed; ! double startA, endA, delta; ! long count; ! ! start.x = xPos; ! start.y = yPos; ! mySize.x = 0.0; ! mySize.y = 0.0; ! val = GetArcParameters(val, start, false, mySize, end, center, rx, ry, sweep, large, isClosed); ! ! if(start.x != end.x || start.y != end.y) ! { ! delta = (3.0/360.0)*2*3.14; ! startA = atan2(start.y-center.y,start.x-center.x); //*(360/(2*3.14)); ! if(isClosed) ! { ! count = 120; ! endA = startA; ! } ! else ! { ! double span; ! endA = atan2(end.y-center.y,end.x-center.x); //*(360/(2*3.14)); ! span = endA-startA; ! if(span < 0) ! span *= -1.0; ! if((span < 3.14) && large) ! span = (2*3.14) - span; ! count = span/delta; ! } ! ! if(startA != NAN && endA != NAN) ! { ! double t, x, y; ! long n; ! ! x = start.x; //- center.x; ! y = start.y; //- center.y; ! if(!sweep) ! delta += -1.0; ! ! for(t = startA, n = 0; n < count; n++, t += delta) ! { ! x = cos(t) * rx*cos(t) - sin(t)*ry*sin(t) + center.x + translateX; ! y = sin(t) * rx*cos(t) + cos(t)*ry*sin(t) + center.y + translateY; ! if(x < bounds.left) ! bounds.left = x; ! if(x > bounds.right) ! bounds.right = x; ! if(y < bounds.top) ! bounds.top = y; ! if(y > bounds.bottom) ! bounds.bottom = y; ! } ! } ! xPos = end.x; ! yPos = end.y; ! continue; ! } ! } ! else ! val++; ! } ! if(*val == 'z') val++; *************** *** 814,825 **** { val = ParseOnePoint(val, false, 0.0, 0.0, 0.0, 0.0, xPos, yPos); ! if(xPos < bounds.left) ! bounds.left = xPos; ! if(xPos > bounds.right) ! bounds.right = xPos; ! if(yPos < bounds.top) ! bounds.top = yPos; ! if(yPos > bounds.bottom) ! bounds.bottom = yPos; } } --- 1180,1191 ---- { val = ParseOnePoint(val, false, 0.0, 0.0, 0.0, 0.0, xPos, yPos); ! if(xPos+translateX < bounds.left) ! bounds.left = xPos+translateX; ! if(xPos+translateX > bounds.right) ! bounds.right = xPos+translateX; ! if(yPos+translateY < bounds.top) ! bounds.top = yPos+translateY; ! if(yPos+translateY > bounds.bottom) ! bounds.bottom = yPos+translateY; } } *************** *** 1164,1168 **** drawingHeight = _bounds.bottom - _bounds.top; drawingWidth = _bounds.right - _bounds.left; ! ParseDrawingTags(data, 0.0, 0.0, drawingWidth, drawingHeight, _growScaleX, _growScaleY); parseTree = data->GetSibling(); --- 1530,1534 ---- drawingHeight = _bounds.bottom - _bounds.top; drawingWidth = _bounds.right - _bounds.left; ! ParseDrawingTags(data, 0.0, 0.0, 0.0, drawingWidth, drawingHeight, _growScaleX, _growScaleY); parseTree = data->GetSibling(); *************** *** 1264,1267 **** --- 1630,1723 ---- } + bool SVGCacheEntry::IsStrokeStyleVisible(XGXMLData *data) + { + const char *val; + val = data->GetArgValue("style"); + if(CIstrstr(val, "stroke:white") || CIstrstr(val, "stroke:#FFFFFF") || CIstrstr(val, "stroke:none") || CIstrstr(val, "stroke-opacity:0")) + return false; + else + return true; + } + + void SVGCacheEntry::SetStrokeStyle(XGXMLData *data, double xScale, double yScale) + { + char *fill; + char *junk; + const char *val, *widthStr; + + val = data->GetArgValue("style"); + widthStr = CIstrstr(val, "stroke-width:"); + if(widthStr != NULL) + { + char *temp; + + widthStr += strlen("stroke-width:"); + glLineWidth((strtod(widthStr, &temp)* xScale)+0.5); + } + else + glLineWidth(1.5 * xScale); + + fill = strstr(val, "stroke:"); + if(fill != NULL) + { + fill += 7; + if(strncmp(fill, "none", 4) != 0) + { + long color; + double red, green, blue; + + if(CIstrncmp(fill, "black", 5) == 0) + color = 0; + else if(*fill == '#') + { + fill++; + color = strtol(fill, &junk, 16); + } + else + color = 0xffffff; + red = ((color >> 16L) & 0xFF)/255.0; + green = ((color >> 8L) & 0xFF)/255.0; + blue = (color & 0xFF)/255.0; + glColor4f (red, green, blue, 1.0); + } + } + } + + bool SVGCacheEntry::IsFillStyleVisible(XGXMLData *data) + { + const char *val; + val = data->GetArgValue("style"); + if(CIstrstr(val, "fill:white") || CIstrstr(val, "fill:#FFFFFF") || CIstrstr(val, "fill:none") || CIstrstr(val, "fill-opacity:0")) + return false; + else + return true; + } + + void SVGCacheEntry::SetFillStyle(XGXMLData *data) + { + char *junk, *fill; + const char *val; + + val = data->GetArgValue("style"); + fill = strstr(val, "fill:"); + if(fill != NULL) + { + fill += 5; + if(strncmp(fill, "none", 4) != 0) + { + long color; + double red, green, blue; + + fill++; + color = strtol(fill, &junk, 16); + red = ((color >> 16L) & 0xFF)/255.0; + green = ((color >> 8L) & 0xFF)/255.0; + blue = (color & 0xFF)/255.0; + glColor4f (red, green, blue, 1.0); + } + } + } + + #if 0 double _leftSize; double _midXSize; *************** *** 1272,1274 **** double _midYSize; double _bottomSize; ! --- 1728,1730 ---- double _midYSize; double _bottomSize; ! #endif Index: RGHypertext.cpp =================================================================== RCS file: /cvsroot/igarden/CommonSource/YAAFExtensions/RGHypertext.cpp,v retrieving revision 1.24 retrieving revision 1.24.2.1 diff -C2 -d -r1.24 -r1.24.2.1 *** RGHypertext.cpp 2 Feb 2006 00:10:02 -0000 1.24 --- RGHypertext.cpp 29 Oct 2006 03:31:56 -0000 1.24.2.1 *************** *** 38,42 **** --- 38,44 ---- #include <XDrawSupport.h> #include <ctype.h> + #if OPT_MACOS #include <quickdraw.h> + #endif #include "MyAssert.h" #include "PluginUtils.h" |