void DrawMapBoundsPoly (CMap* theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings, Boolean erasePolygon) { long numPts = (**MapPolyHdl).pointCount; PolyHandle poly; LongPoint** thisPointsHdl=nil; Point pt,startPt; LongPoint wPt; long i; Boolean offQuickDrawPlane = false; RGBColor saveColor; // JLM ?? wouldn't compile without this GetForeColor (&saveColor); /* save original forecolor */ thisPointsHdl = (LongPoint**) (**MapPolyHdl).objectDataHdl; poly = OpenPoly(); wPt = INDEXH(thisPointsHdl,0); startPt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane); MyMoveTo(startPt.h,startPt.v); for(i = 1; i< numPts;i++) { wPt = INDEXH(thisPointsHdl,i); pt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane); MyLineTo(pt.h,pt.v); } MyLineTo(startPt.h,startPt.v); ClosePoly(); if (erasePolygon) ErasePoly(poly); FramePoly(poly); ErasePoly(poly); KillPoly(poly); RGBForeColor (&saveColor); }
static void fill_routine(int n, double *px, double *py, int tnr) { PolyHandle poly; register int i; double x, y; int ix, iy; poly = OpenPoly(); for (i = 0; i < n; i++) { WC_to_NDC(px[i], py[i], tnr, x, y); seg_xform(&x, &y); NDC_to_DC(x, y, ix, iy); if (i == 0) MoveTo(ix, iy); else LineTo(ix, iy); } ClosePoly(); if (p->pat) FillPoly(poly, p->pat); else PaintPoly(poly); KillPoly(poly); }
void XFillPolygon( Display* display, /* Display. */ Drawable d, /* Draw on this. */ GC gc, /* Use this GC. */ XPoint* points, /* Array of points. */ int npoints, /* Number of points. */ int shape, /* Shape to draw. */ int mode) /* Drawing mode. */ { MacDrawable *macWin = (MacDrawable *) d; PolyHandle polygon; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; int i; destPort = TkMacGetDrawablePort(d); display->request++; GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacSetUpClippingRgn(d); TkMacSetUpGraphicsPort(gc); PenNormal(); polygon = OpenPoly(); MoveTo((short) (macWin->xOff + points[0].x), (short) (macWin->yOff + points[0].y)); for (i = 1; i < npoints; i++) { if (mode == CoordModePrevious) { Line((short) (macWin->xOff + points[i].x), (short) (macWin->yOff + points[i].y)); } else { LineTo((short) (macWin->xOff + points[i].x), (short) (macWin->yOff + points[i].y)); } } ClosePoly(); FillCPoly(polygon, gPenPat); KillPoly(polygon); SetGWorld(saveWorld, saveDevice); }
static void MacInversePolygon (SHORT_POINT *points, INT n) { int i; PolyHandle myPoly; if (n<3) return; myPoly = OpenPoly(); MoveTo (points[0].x, points[0].y); for (i=1; i<n; i++) LineTo (points[i].x, points[i].y); LineTo (points[0].x, points[0].y); ClosePoly(); InvertPoly(myPoly); KillPoly(myPoly); }
Ptr _HYPlatformGraphicPane::_DefinePolygon (_SimpleList& points) { if ((points.lLength>=6)&&(points.lLength%2==0)) { PolyHandle rgn = OpenPoly (); checkPointer (rgn); MoveTo (points.lData[0], points.lData[1]); for (long k=2; k<points.lLength; k+=2) LineTo (points.lData[k], points.lData[k+1]); LineTo (points.lData[0], points.lData[1]); ClosePoly (); return (Ptr)rgn; } return nil; }
static void MacErasePolygon (SHORT_POINT *points, INT n) { int i; PolyHandle myPoly; RGBColor ForeColor, BackColor; if (n<3) return; GetForeColor(&ForeColor); GetBackColor(&BackColor); myPoly = OpenPoly(); MoveTo (points[0].x, points[0].y); for (i=1; i<n; i++) LineTo (points[i].x, points[i].y); LineTo (points[0].x, points[0].y); ClosePoly(); ErasePoly(myPoly); RGBForeColor(&BackColor); FramePoly(myPoly); KillPoly(myPoly); RGBForeColor(&ForeColor); }
void XFillArc( Display* display, /* Display. */ Drawable d, /* Draw on this. */ GC gc, /* Use this GC. */ int x, /* Upper left of */ int y, /* bounding rect. */ unsigned int width, /* Width & height. */ unsigned int height, int angle1, /* Staring angle of arc. */ int angle2) /* Ending angle of arc. */ { MacDrawable *macWin = (MacDrawable *) d; Rect theRect; short start, extent; PolyHandle polygon; double sin1, cos1, sin2, cos2, angle; double boxWidth, boxHeight; double vertex[2], center1[2], center2[2]; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; destPort = TkMacGetDrawablePort(d); display->request++; GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacSetUpClippingRgn(d); TkMacSetUpGraphicsPort(gc); theRect.left = (short) (macWin->xOff + x); theRect.top = (short) (macWin->yOff + y); theRect.right = (short) (theRect.left + width); theRect.bottom = (short) (theRect.top + height); start = (short) (90 - (angle1 / 64)); extent = (short) (- (angle2 / 64)); if (gc->arc_mode == ArcChord) { boxWidth = theRect.right - theRect.left; boxHeight = theRect.bottom - theRect.top; angle = -(angle1/64.0)*PI/180.0; sin1 = sin(angle); cos1 = cos(angle); angle -= (angle2/64.0)*PI/180.0; sin2 = sin(angle); cos2 = cos(angle); vertex[0] = (theRect.left + theRect.right)/2.0; vertex[1] = (theRect.top + theRect.bottom)/2.0; center1[0] = vertex[0] + cos1*boxWidth/2.0; center1[1] = vertex[1] + sin1*boxHeight/2.0; center2[0] = vertex[0] + cos2*boxWidth/2.0; center2[1] = vertex[1] + sin2*boxHeight/2.0; polygon = OpenPoly(); MoveTo((short) ((theRect.left + theRect.right)/2), (short) ((theRect.top + theRect.bottom)/2)); LineTo((short) (center1[0] + 0.5), (short) (center1[1] + 0.5)); LineTo((short) (center2[0] + 0.5), (short) (center2[1] + 0.5)); ClosePoly(); ShowPen(); FillCArc(&theRect, start, extent, gPenPat); FillCPoly(polygon, gPenPat); KillPoly(polygon); } else { ShowPen(); FillCArc(&theRect, start, extent, gPenPat); } SetGWorld(saveWorld, saveDevice); }
static int RasterizeFile (FILE *stream, AWindowRecord *myWindow, short wx, short wy) { char *buffer; /* input buffer */ long blockSize; /* METABUFFERSIZE */ long blockUsed; /* actual buffer size used */ long itemCounter; /* number of commands in buffer */ char *data; /* data pointer in buffer */ short fx,fy; /* file screen size */ Fixed sx,sy; /* scaling factors */ int i,error,j,size; char opCode; short x,y,r,g,b,n,lw,ts,m,ms,w; short x1,y1,x2,y2; short xx[SIZE],yy[SIZE]; PolyHandle myPoly; char s[CSIZE]; unsigned char c; RGBColor newColor; PaletteHandle myPalette; long l; /* get file parameters */ rewind(stream); error = fread(&blockSize,4,1,stream); if (error!=1) return(1); /* block size */ error = fread(&fx,2,1,stream); if (error!=1) return(1); /* x size */ error = fread(&fy,2,1,stream); if (error!=1) return(1); /* y size */ /* compute scaling factors */ sx = FixRatio(wx-1,fx-1); sy = FixRatio(wy-1,fy-1); /* default values */ lw = 1; ts = 12; m = 0; ms = 6; /* allocate input buffer */ buffer = malloc(blockSize); if (buffer==NULL) return(1); SetPort((GrafPtr)(myWindow->theWindow)); EraseRect(&(myWindow->usableRect)); /* loop through the blocks */ while (!feof(stream)) { /* read block parameters */ error = fread(&blockUsed,4,1,stream); if (error!=1) {free(buffer); return(1);} error = fread(&itemCounter,4,1,stream); if (error!=1) {free(buffer); return(1);} error = fread(buffer,blockUsed,1,stream);if (error!=1) {free(buffer); return(1);} /* init pointer to next item */ data = buffer; /* for all items */ for (i=0; i<itemCounter; i++) { /* get op code */ opCode = *(data++); switch (opCode) { case opMove : x = *((short *)data); data += 2; y = *((short *)data); data += 2; TRFMX(x); TRFMY(y); MoveTo(x,y); break; case opDraw : x = *((short *)data); data += 2; y = *((short *)data); data += 2; TRFMX(x); TRFMY(y); LineTo(x,y); break; case opPolyline : n = *((short *)data); data += 2; if (n>=SIZE) {free(buffer); return(2);} size = n<<1; memcpy(xx,data,size); data += size; memcpy(yy,data,size); data += size; for (j=0; j<n; j++) { TRFMX(xx[j]); TRFMY(yy[j]); } MoveTo(xx[0],yy[0]); for (j=1; j<n; j++) LineTo(xx[j],yy[j]); break; case opPolygon : n = *((short *)data); data += 2; if (n>=SIZE) {free(buffer); return(2);} size = n<<1; memcpy(xx,data,size); data += size; memcpy(yy,data,size); data += size; for (j=0; j<n; j++) { TRFMX(xx[j]); TRFMY(yy[j]); } if (n<3) break; myPoly = OpenPoly(); MoveTo(xx[0],yy[0]); for (j=1; j<n; j++) LineTo(xx[j],yy[j]); LineTo(xx[0],yy[0]); ClosePoly(); PaintPoly(myPoly); FramePoly(myPoly); KillPoly(myPoly); break; case opPolymark : n = *((short *)data); data += 2; if (n>=SIZE) {free(buffer); return(2);} size = n<<1; memcpy(xx,data,size); data += size; memcpy(yy,data,size); data += size; for (j=0; j<n; j++) { TRFMX(xx[j]); TRFMY(yy[j]); } for (j=0; j<n; j++) Marker(m,ms,xx[j],yy[j]); break; case opText : n = *((short *)data); data += 2; if (n>=CSIZE-1) {free(buffer); return(2);} memcpy(s,data,n); s[n] = 0; data += n; DrawString((ConstStr255Param)c2pstr(s)); break; case opCenteredText : x = *((short *)data); data += 2; y = *((short *)data); data += 2; TRFMX(x); TRFMY(y); n = *((short *)data); data += 2; if (n>=CSIZE-1) {free(buffer); return(2);} memcpy(s,data,n); s[n] = 0; data += n; c2pstr(s); w = StringWidth((ConstStr255Param)s); MoveTo(x-w/2,y+ts/2); DrawString((ConstStr255Param)s); break; case opSetLineWidth : n = *((short *)data); data += 2; lw = n; PenSize(n,n); break; case opSetTextSize : n = *((short *)data); data += 2; ts = n; TextSize(n); break; case opSetMarker : n = *((short *)data); data += 2; m = n; break; case opSetMarkerSize : n = *((short *)data); data += 2; ms = n; break; case opSetColor : c = *((unsigned char *)data); data++; PmForeColor((short)c); break; case opSetEntry : c = *((unsigned char *)data); data++; r = (short) (*((unsigned char *)data)); data++; g = (short) (*((unsigned char *)data)); data++; b = (short) (*((unsigned char *)data)); data++; myPalette = GetPalette(myWindow->theWindow); myWindow->red[c] = newColor.red = r<<8; myWindow->green[c] = newColor.green = g<<8; myWindow->blue[c] = newColor.blue = b<<8; SetEntryColor(myPalette,(short) c,&newColor); ActivatePalette(myWindow->theWindow); break; case opSetPalette : x = (short) (*((unsigned char *)data)); data++; y = (short) (*((unsigned char *)data)); data++; myPalette = GetPalette(myWindow->theWindow); for (j=x; j<=y; j++) { r = (short) (*((unsigned char *)data)); data++; g = (short) (*((unsigned char *)data)); data++; b = (short) (*((unsigned char *)data)); data++; myWindow->red[j] = newColor.red = r<<8; myWindow->green[j] = newColor.green = g<<8; myWindow->blue[j] = newColor.blue = b<<8; SetEntryColor(myPalette,(short) j,&newColor); } ActivatePalette(myWindow->theWindow); break; case opNewLine : lw = *((unsigned char *)data); data++; c = *((unsigned char *)data); data++; x1 = *((short *)data); data += 2; y1 = *((short *)data); data += 2; x2 = *((short *)data); data += 2; y2 = *((short *)data); data += 2; TRFMX(x1); TRFMY(y1); TRFMX(x2); TRFMY(y2); PenSize(lw,lw); PmForeColor((short)c); MoveTo(x1,y1); LineTo(x2,y2); break; case opNewPolyline : lw = *((unsigned char *)data); data++; c = *((unsigned char *)data); data++; n = *((short *)data); data += 2; if (n>=SIZE) {free(buffer); return(2);} size = n<<1; memcpy(xx,data,size); data += size; memcpy(yy,data,size); data += size; for (j=0; j<n; j++) { TRFMX(xx[j]); TRFMY(yy[j]); } PenSize(lw,lw); PmForeColor((short)c); MoveTo(xx[0],yy[0]); for (j=1; j<n; j++) LineTo(xx[j],yy[j]); break; case opNewPolygon : c = *((unsigned char *)data); data++; n = *((short *)data); data += 2; if (n>=SIZE) {free(buffer); return(2);} size = n<<1; memcpy(xx,data,size); data += size; memcpy(yy,data,size); data += size; for (j=0; j<n; j++) { TRFMX(xx[j]); TRFMY(yy[j]); } if (n<3) break; PmForeColor((short)c); myPoly = OpenPoly(); MoveTo(xx[0],yy[0]); for (j=1; j<n; j++) LineTo(xx[j],yy[j]); LineTo(xx[0],yy[0]); ClosePoly(); PaintPoly(myPoly); FramePoly(myPoly); KillPoly(myPoly); break; case opNewPolymark : m = *((unsigned char *)data); data++; ms = *((unsigned char *)data); data++; c = *((unsigned char *)data); data++; n = *((short *)data); data += 2; if (n>=SIZE) {free(buffer); return(2);} size = n<<1; memcpy(xx,data,size); data += size; memcpy(yy,data,size); data += size; for (j=0; j<n; j++) { TRFMX(xx[j]); TRFMY(yy[j]); } PmForeColor((short)c); for (j=0; j<n; j++) Marker(m,ms,xx[j],yy[j]); break; case opNewText : ts = *((unsigned char *)data); data++; c = *((unsigned char *)data); data++; x = *((short *)data); data += 2; y = *((short *)data); data += 2; TRFMX(x); TRFMY(y); n = *((short *)data); data += 2; if (n>=CSIZE-1) {free(buffer); return(2);} memcpy(s,data,n); s[n] = 0; data += n; MoveTo(x,y); TextSize(ts); PmForeColor((short)c); DrawString((ConstStr255Param)c2pstr(s)); break; case opNewCenteredText : ts = *((unsigned char *)data); data++; c = *((unsigned char *)data); data++; x = *((short *)data); data += 2; y = *((short *)data); data += 2; TRFMX(x); TRFMY(y); n = *((short *)data); data += 2; if (n>=CSIZE-1) {free(buffer); return(2);} memcpy(s,data,n); s[n] = 0; data += n; c2pstr(s); w = StringWidth((ConstStr255Param)s); TextSize(ts); PmForeColor((short)c); MoveTo(x-w/2,y+ts/2); DrawString((ConstStr255Param)c2pstr(s)); break; default : break; } } } return(0); }
static void Marker (short n, short s, short x, short y) { Rect r; PolyHandle myPoly; s = s/2; r.top = y-s; r.bottom = y+s; r.left = x-s; r.right = x+s; n = n%11; switch (n) { case 0 : FrameRect(&r); break; case 1 : PenPat(&qd.gray); PaintRect(&r); PenNormal(); break; case 2 : PaintRect(&r); break; case 3 : FrameOval(&r); break; case 4 : PenPat(&qd.gray); PaintOval(&r); PenNormal(); break; case 5 : PaintOval(&r); break; case 6 : MoveTo(x,y+s); LineTo(x+s,y); LineTo(x,y-s); LineTo(x-s,y); LineTo(x,y+s); break; case 7 : PenPat(&qd.gray); myPoly = OpenPoly(); MoveTo(x,y+s); LineTo(x+s,y); LineTo(x,y-s); LineTo(x-s,y); LineTo(x,y+s); ClosePoly(); PaintPoly(myPoly); KillPoly(myPoly); PenNormal(); break; case 8 : myPoly = OpenPoly(); MoveTo(x,y+s); LineTo(x+s,y); LineTo(x,y-s); LineTo(x-s,y); LineTo(x,y+s); ClosePoly(); PaintPoly(myPoly); KillPoly(myPoly); PenNormal(); break; case 9 : MoveTo(x,y+s); LineTo(x,y-s); MoveTo(x-s,y); LineTo(x+s,y-s); break; case 10 : MoveTo(x-s,y+s); LineTo(x+s,y-s); MoveTo(x-s,y-s); LineTo(x+s,y+s); break; } }
BOOL CRVTrackerDrawPoly::OnUpdate(const CUIEvent &cEvent) { //see if they want to finish drawing the polygon if(m_bFinishDrawingPoly) { // Make sure we don't cancel when the focus goes away m_bAllowCancel = FALSE; // Create the brush m_pView->FinishDrawingPoly(); m_bAllowCancel = TRUE; //we are no longer drawing a poly, so we can start another one m_bFinishDrawingPoly = FALSE; return FALSE; } BOOL bCancel = FALSE; // Handle any events that happen if (m_pUndoTracker) { BOOL bOldActive = m_pUndoTracker->GetActive(); m_pUndoTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pUndoTracker->GetActive()) bCancel = OnUndo(); } if (m_pNewVertexTracker) { BOOL bOldActive = m_pNewVertexTracker->GetActive(); m_pNewVertexTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pNewVertexTracker->GetActive()) bCancel = OnNewVertex(); } if (m_pSplitTracker) { BOOL bOldActive = m_pSplitTracker->GetActive(); m_pSplitTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pSplitTracker->GetActive()) bCancel = OnSplit(); } if (m_pRotateTracker) { BOOL bOldActive = m_pRotateTracker->GetActive(); m_pRotateTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pRotateTracker->GetActive()) bCancel = OnRotate(); } if (m_pInsertEdgeTracker) { BOOL bOldActive = m_pInsertEdgeTracker->GetActive(); m_pInsertEdgeTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pInsertEdgeTracker->GetActive()) bCancel = OnNewEdge(); } if(m_pVertSnapTracker) { m_pVertSnapTracker->ProcessEvent(cEvent); m_bVertSnap = m_pVertSnapTracker->GetActive(); } if(m_pCloseTracker) { BOOL bOldActive = m_pCloseTracker->GetActive(); m_pCloseTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pCloseTracker->GetActive()) bCancel = ClosePoly(); } if (bCancel) // End the tracker return FALSE; // Only update everything else on idle events if (cEvent.GetType() != UIEVENT_NONE) return TRUE; // Don't update if it hasn't moved if (m_cCurPt == m_cLastPt) return TRUE; // Do the autoscroll of the window DoAutoScroll(); switch( m_pView->m_EditState ) { case EDIT_DRAWINGPOLY: { UpdateDrawPolyVertex(m_cCurPt); break; } } // Update the views... m_pView->GetDocument()->UpdateAllViews(m_pView); m_pView->DrawRect(); m_cLastPt = m_cCurPt; return TRUE; }
void DrawNoSectPolyRecursive (CMap *theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings,Rect subRect) { long PointCount, PlotCount = 0, PointIndex; LongPoint MatrixPt; Point LastScrPt, ThisScrPt, FirstScrPt; LongPoint **RgnPtsHdl; PolyHandle PolyHdl = nil; //////////// Boolean alwaysIn123 = true; Boolean alwaysIn174 = true; Boolean alwaysIn456 = true; Boolean alwaysIn386 = true; Boolean canSkipDrawingPolygon = false; // 1 7 4 // 2 0 5 // 3 8 6 //////////////// PointCount = GetPolyPointCount (MapPolyHdl); RgnPtsHdl = GetPolyPointsHdl (MapPolyHdl); Boolean bDrawBlackAndWhite = (sharedPrinting && settings.printMode != COLORMODE); #define MAXNUMSEGMENTS 8000 // JLM, It seems the limit is 32K not 64K at the documentation says short thisSectionOfPlane,prevSectionOfPlane; Boolean canSkipThisPt,skippedAPt,offQuickDrawPlane=false; Point lastSkippedPt; Rect fuzzyRect = subRect; long lineWidth = 1, esiCode; long outsetPixels = 2*lineWidth+2; // needs to be wider that the line width //long penWidth = 3; long penWidth = 2; long halfPenWidth = 0; InsetRect(&fuzzyRect,-outsetPixels,-outsetPixels); if (RgnPtsHdl != nil) { // must clip to this rect in addtion to the original clip Rect clippingRect = subRect; RgnHandle saveClip = NewRgn(), addition = NewRgn() , newClip = NewRgn(); GetClip(saveClip); GetClip(newClip); RectRgn(addition, &clippingRect); SectRgn(newClip, addition, newClip); SetClip(newClip); if(newClip) DisposeRgn(newClip); if(addition) DisposeRgn(addition); if (drawSettings -> fillCode != kNoFillCode) PolyHdl = OpenPoly (); else { PolyHdl = OpenPoly (); //Our_PmForeColor (gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd); Our_PmForeColor (drawSettings -> foreColorInd); } GetObjectESICode ((ObjectRecHdl) MapPolyHdl,&esiCode); if (esiCode>0) // -500 is the default { //halfPenWidth = penWidth/2; #ifdef MAC PenSize(penWidth,penWidth); #else PenStyle(BLACK,penWidth); #endif } for (PointIndex = 0,skippedAPt = false,prevSectionOfPlane = -1; PointIndex < PointCount; ++PointIndex) { MatrixPt = (*RgnPtsHdl) [PointIndex]; // theMap -> GetScrPoint (&MatrixPt, &ThisScrPt); //ThisScrPt.h = SameDifferenceX(MatrixPt.h); //ThisScrPt.v = (gRect.bottom + gRect.top) - SameDifferenceY(MatrixPt.v); ThisScrPt = GetQuickDrawPt(MatrixPt.h, MatrixPt.v, &gRect, &offQuickDrawPlane); // code goes here, what to do when point is off quickdraw plane? //if (offQuickDrawPlane) break; ThisScrPt.h += drawSettings -> offsetDx; ThisScrPt.v += drawSettings -> offsetDy; if(PolyHdl) { //// JLM 2/18/99 // for points outside the drawing area, it is not necessary to move to the correct point, // as long as we preserve the winding. This allows us to ignore many of the points outside // the drawing rectangle gRect thisSectionOfPlane = SectionOfPlane(&fuzzyRect,ThisScrPt); if( thisSectionOfPlane > 0 // outside of the rectangle && thisSectionOfPlane == prevSectionOfPlane // we have not changed sections of the plane && PointIndex < PointCount -1) // not the last point canSkipThisPt = true; else canSkipThisPt = false; prevSectionOfPlane = thisSectionOfPlane; if(canSkipThisPt) { skippedAPt = true; lastSkippedPt =ThisScrPt; continue; } /// JLM 3/6/01 switch(thisSectionOfPlane) { case 1: alwaysIn456 = false; alwaysIn386 = false; break; case 2: alwaysIn174 = false; alwaysIn456 = false; alwaysIn386 = false; break; case 3: alwaysIn174 = false; alwaysIn456 = false; break; case 4: alwaysIn123 = false; alwaysIn386 = false; break; case 5: alwaysIn123 = false; alwaysIn174 = false; alwaysIn386 = false; break; case 6: alwaysIn123 = false; alwaysIn174 = false; break; case 7: alwaysIn123 = false; alwaysIn456 = false; alwaysIn386 = false; break; case 8: alwaysIn123 = false; alwaysIn174 = false; alwaysIn456 = false; break; default: alwaysIn123 = false; alwaysIn174 = false; alwaysIn456 = false; alwaysIn386 = false; break; } ////// if(skippedAPt) { // then we have to draw to the previous point // before we draw to the current point PointIndex--; //so we do the previous point below ThisScrPt = lastSkippedPt; // restore the coordinates of the previous point prevSectionOfPlane = -1; // force the next point to not be skipped } skippedAPt = false; if(PlotCount > MAXNUMSEGMENTS) { // there is a bug on the max when the number of points gets too large // try recusion ClosePoly(); KillPoly(PolyHdl); SetClip(saveClip);// JLM 8/4/99 goto recursion; } ////////////// } if (PointIndex == 0) { MyMoveTo (ThisScrPt.h-halfPenWidth, ThisScrPt.v-halfPenWidth); FirstScrPt = ThisScrPt; LastScrPt = ThisScrPt; PlotCount = 0; } else { if (LastScrPt.h != ThisScrPt.h || LastScrPt.v != ThisScrPt.v) { MyLineTo (ThisScrPt.h-halfPenWidth, ThisScrPt.v-halfPenWidth); LastScrPt = ThisScrPt; ++PlotCount; } } } if (drawSettings -> bClosed) /* draw a line from last point to first point if requested */ { MyLineTo (FirstScrPt.h-halfPenWidth, FirstScrPt.v-halfPenWidth); ++PlotCount; } if (PolyHdl != nil) { ClosePoly (); ////////////// JLM 3/6/01 if(alwaysIn123 || alwaysIn174 || alwaysIn456 || alwaysIn386) canSkipDrawingPolygon = true; if(canSkipDrawingPolygon) PlotCount = 0; // so that we skip the code below //////////// if (PlotCount > 0) { if (PlotCount > 2) /* polygon must contain more than 2 line-to points */ { if (drawSettings -> bErase || (drawSettings -> fillCode == kNoFillCode && drawSettings -> backColorInd == kWaterColorInd)) ErasePoly (PolyHdl); if (drawSettings -> fillCode == kPaintFillCode) { // this is the usual drawing code Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM if(bDrawBlackAndWhite) SetPenPat(UPSTRIPES); PaintPoly(PolyHdl);//JLM if(bDrawBlackAndWhite) SetPenPat(BLACK); } else if (drawSettings -> fillCode == kPatFillCode) FillPoly (PolyHdl, &(drawSettings -> backPattern)); } if (drawSettings -> frameCode == kPaintFrameCode) { Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd); FramePoly (PolyHdl); } else if (drawSettings -> frameCode == kPatFrameCode) { PenPat (&(drawSettings -> forePattern)); FramePoly (PolyHdl); } } KillPoly (PolyHdl); } SetClip(saveClip); if(saveClip) DisposeRgn(saveClip); } #ifdef MAC PenSize(1,1); #else PenStyle(BLACK,1); #endif return; //////////////////////////////// recursion: //////////////////////////////// { #define MAXRECURSION 20 static short sRecursionValue = 0; if(sRecursionValue >= MAXRECURSION) { printError("max recusion exceeded"); } else { // use recursion Rect subBoundingRect; long middleH = (subRect.left+subRect.right)/2; long middleV = (subRect.top+subRect.bottom)/2; long index; sRecursionValue++; // divide the points up and Draw again for(index = 0; index < 4; index++) { subBoundingRect = subRect; switch(index) { case 0: subBoundingRect.top = middleV; subBoundingRect.left = middleH; break; case 1: subBoundingRect.top = middleV; subBoundingRect.right = middleH; break; case 2: subBoundingRect.bottom = middleV; subBoundingRect.left = middleH; break; default: subBoundingRect.bottom = middleV; subBoundingRect.right = middleH; break; } // the recursive call DrawNoSectPolyRecursive (theMap,MapPolyHdl,drawSettings,subBoundingRect); } // all done sRecursionValue--; return; } } }
OSErr DrawSectPoly (CMap* theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings) { long SegCount, SegIndex, SegIndexPlus, PlotCount; LongPoint MatrixPt; Point ThisScrPt; OSErr ErrCode = 0; Boolean DrawFromSegFlag; PolyHandle PolyHdl = nil; SegmentsHdl SectSegHdl = nil; LongRect sectLRect; Rect ScrPolyRect; theMap -> GetMapDrawRect (&ScrPolyRect); InsetRect (&ScrPolyRect, -1, -1); theMap -> GetMatrixLRect (&ScrPolyRect, §LRect); SectSegHdl = MakeSectPoly (§LRect, MapPolyHdl); if (SectSegHdl != nil) { SegCount = _GetHandleSize ((Handle) SectSegHdl) / sizeof (Segment); PolyHdl = OpenPoly (); DrawFromSegFlag = true; PlotCount = 0; Boolean bDrawBlackAndWhite = (sharedPrinting && settings.printMode != COLORMODE); for (SegIndex = 0; SegIndex < SegCount; ++SegIndex) { if (DrawFromSegFlag) /* start of new poly */ { MatrixPt.h = (*SectSegHdl) [SegIndex].fromLong; MatrixPt.v = (*SectSegHdl) [SegIndex].fromLat; theMap -> GetScrPoint (&MatrixPt, &ThisScrPt); MyMoveTo (ThisScrPt.h, ThisScrPt.v); DrawFromSegFlag = false; PlotCount = 0; } MatrixPt.h = (*SectSegHdl) [SegIndex].toLong; MatrixPt.v = (*SectSegHdl) [SegIndex].toLat; theMap -> GetScrPoint (&MatrixPt, &ThisScrPt); MyLineTo (ThisScrPt.h, ThisScrPt.v); ++PlotCount; SegIndexPlus = SegIndex + 1; if (SegIndexPlus == SegCount) SegIndexPlus = 0; /* check for end of current poly */ if (((*SectSegHdl) [SegIndex].toLat != (*SectSegHdl) [SegIndexPlus].fromLat || (*SectSegHdl) [SegIndex].toLong != (*SectSegHdl) [SegIndexPlus].fromLong)) { ClosePoly (); if (PlotCount > 0) { if (PlotCount > 2) { if (drawSettings -> bErase) ErasePoly (PolyHdl); if (drawSettings -> fillCode == kPaintFillCode) { // this is the usual drawing code Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM if(bDrawBlackAndWhite) SetPenPat(UPSTRIPES); PaintPoly(PolyHdl);//JLM if(bDrawBlackAndWhite) SetPenPat(BLACK); } else if (drawSettings -> fillCode == kPatFillCode) FillPoly (PolyHdl, &(drawSettings -> backPattern)); } if (drawSettings -> frameCode == kPaintFrameCode) { Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd); FramePoly (PolyHdl); } else if (drawSettings -> frameCode == kPatFrameCode) { PenPat (&(drawSettings -> forePattern)); FramePoly (PolyHdl); } } KillPoly (PolyHdl); /* now open a new poly for the next set of segments */ PolyHdl = OpenPoly (); DrawFromSegFlag = true; } } ClosePoly (); if (PlotCount > 0) { if (PlotCount > 2) /* must have at least 3 segments to fill-poly */ { if (drawSettings -> bErase) ErasePoly (PolyHdl); if (drawSettings -> fillCode == kPaintFillCode) { Our_PmForeColor (drawSettings -> backColorInd); FillPoly (PolyHdl, &(drawSettings -> backPattern)); } else if (drawSettings -> fillCode == kPatFillCode) FillPoly (PolyHdl, &(drawSettings -> backPattern)); } if (drawSettings -> frameCode == kPaintFrameCode) { Our_PmForeColor (drawSettings -> foreColorInd); FramePoly (PolyHdl); } else if (drawSettings -> frameCode == kPatFrameCode) { PenPat (&(drawSettings -> forePattern)); FramePoly (PolyHdl); } } KillPoly (PolyHdl); DisposeHandle ((Handle) SectSegHdl); } return (ErrCode); }
static void InvMarker (SHORT_POINT point) { Rect r; PolyHandle myPoly; short n,s,S,x,y; s = currgw->marker_size/2; S = 1.41*s; n = currgw->marker_id; x = point.x; y = point.y; r.top = y-s; r.bottom = y+s; r.left = x-s; r.right = x+s; switch (n) { case EMPTY_SQUARE_MARKER : PenMode(patXor); FrameRect(&r); break; case GRAY_SQUARE_MARKER : PenMode(patXor); PenPat(qdgray); PaintRect(&r); PenNormal(); break; case FILLED_SQUARE_MARKER : PenMode(patXor); PenPat(qdgray); PaintRect(&r); break; case EMPTY_CIRCLE_MARKER : PenMode(patXor); FrameOval(&r); break; case GRAY_CIRCLE_MARKER : PenMode(patXor); PenPat(qdgray); PaintOval(&r); PenNormal(); break; case FILLED_CIRCLE_MARKER : PenMode(patXor); PenPat(qdgray); PaintOval(&r); break; case EMPTY_RHOMBUS_MARKER : PenMode(patXor); PenPat(qdgray); MoveTo(x,y+S); LineTo(x+S,y); LineTo(x,y-S); LineTo(x-S,y); LineTo(x,y+S); break; case GRAY_RHOMBUS_MARKER : PenMode(patXor); PenPat(qdgray); myPoly = OpenPoly(); MoveTo(x,y+S); LineTo(x+S,y); LineTo(x,y-s); LineTo(x-S,y); LineTo(x,y+S); ClosePoly(); InvertPoly(myPoly); KillPoly(myPoly); PenNormal(); break; case FILLED_RHOMBUS_MARKER : myPoly = OpenPoly(); MoveTo(x,y+S); LineTo(x+S,y); LineTo(x,y-S); LineTo(x-S,y); LineTo(x,y+S); ClosePoly(); InvertPoly(myPoly); KillPoly(myPoly); PenNormal(); break; case PLUS_MARKER : PenMode(patXor); PenPat(qdgray); MoveTo(x,y+s); LineTo(x,y-s); MoveTo(x-s,y); LineTo(x+s,y); break; case CROSS_MARKER : PenMode(patXor); PenPat(qdgray); MoveTo(x-s,y+s); LineTo(x+s,y-s); MoveTo(x-s,y-s); LineTo(x+s,y+s); break; default : break; } PenNormal(); }
static void draw_marker(double xn, double yn, int mtype, double mscale, int mcolor) { int r, x, y, i; double scale, xr, yr; int pc, op; PolyHandle poly; Rect rect; static int marker[26][57] = { { 5, 9, -4, 7, 4, 7, 7, 4, 7, -4, /* omark */ 4, -7, -4, -7, -7, -4, -7, 4, -4, 7, 3, 9, -4, 7, 4, 7, 7, 4, 7, -4, 4, -7, -4, -7, -7, -4, -7, 4, -4, 7, 0 }, { 5, 13, -2, 8, 2, 8, 2, 2, 8, 2, /* hollow plus */ 8, -2, 2, -2, 2, -8, -2, -8, -2, -2, -8, -2, -8, 2, -2, 2, -2, 8, 3, 13, -2, 8, 2, 8, 2, 2, 8, 2, 8, -2, 2, -2, 2, -8, -2, -8, -2, -2, -8, -2, -8, 2, -2, 2, -2, 8, 0 }, { 4, 4, -8, 0, 4, 7, 4, -7, /* solid triangle right */ -8, 0, 0 }, { 4, 4, 8, 0, -4, -7, -4, 7, /* solid triangle left */ 8, 0, 0 }, { 5, 4, 0, 8, 7, -4, -7, -4, 0, 8, /* triangle up down */ 5, 4, 0, -8, -7, 4, 7, 4, 0, -8, 3, 4, 0, 8, 7, -4, -7, -4, 0, 8, 3, 4, 0, -8, -7, 4, 7, 4, 0, -8, 0 }, { 4, 11, 0, 9, 2, 2, 9, 3, 3, -1, /* solid star */ 6, -8, 0, -3, -6, -8, -3, -1, -9, 3, -2, 2, 0, 9, 0 }, { 5, 11, 0, 9, 2, 2, 9, 3, 3, -1, /* hollow star */ 6, -8, 0, -3, -6, -8, -3, -1, -9, 3, -2, 2, 0, 9, 3, 11, 0, 9, 2, 2, 9, 3, 3, -1, 6, -8, 0, -3, -6, -8, -3, -1, -9, 3, -2, 2, 0, 9, 0 }, { 4, 5, 0, 9, 9, 0, 0, -9, -9, 0, /* solid diamond */ 0, 9, 0 }, { 5, 5, 0, 9, 9, 0, 0, -9, -9, 0, /* hollow diamond */ 0, 9, 3, 5, 0, 9, 9, 0, 0, -9, -9, 0, 0, 9, 0 }, { 4, 5, 9, 9, -9, -9, 9, -9, -9, 9, /* solid hourglass */ 9, 9, 0 }, { 5, 5, 9, 9, -9, -9, 9, -9, -9, 9, /* hollow hourglass */ 9, 9, 3, 5, 9, 9, -9, -9, 9, -9, -9, 9, 9, 9, 0 }, { 4, 5, 9, 9, 9, -9, -9, 9, -9, -9, /* solid bowtie */ 9, 9, 0 }, { 5, 5, 9, 9, 9, -9, -9, 9, -9, -9, /* hollow bowtie */ 9, 9, 3, 5, 9, 9, 9, -9, -9, 9, -9, -9, 9, 9, 0 }, { 4, 5, 9, 9, 9, -9, -9, -9, -9, 9, /* solid square */ 9, 9, 0 }, { 5, 5, 9, 9, 9, -9, -9, -9, -9, 9, /* hollow square */ 9, 9, 3, 5, 9, 9, 9, -9, -9, -9, -9, 9, 9, 9, 0 }, { 4, 4, -9, 9, 9, 9, 0, -9, -9, 9, /* solid triangle down */ 0 }, { 5, 4, -9, 9, 9, 9, 0, -9, -9, 9, /* hollow triangle down */ 3, 4, -9, 9, 9, 9, 0, -9, -9, 9, 0 }, { 4, 4, 0, 9, 9, -9, -9, -9, 0, 9, /* solid triangle up */ 0 }, { 5, 4, 0, 9, 9, -9, -9, -9, 0, 9, /* hollow triangle up */ 3, 4, 0, 9, 9, -9, -9, -9, 0, 9, 0 }, { 7, 0 }, /* solid circle */ { 0 }, /* not used */ { 1, 0 }, /* dot */ { 2, 0, 0, 0, 9, 2, 0, 0, 9, 0, /* plus */ 2, 0, 0, 0, -9, 2, 0, 0, -9, 0, 0 }, { 2, 0, 0, 0, 9, 2, 0, 0, 9, 3, /* asterisk */ 2, 0, 0, 6, -9, 2, 0, 0, -6, -9, 2, 0, 0, -9, 3, 0 }, { 8, 6, 0 }, /* circle */ { 2, 0, 0, 9, 9, 2, 0, 0, 9, -9, /* diagonal cross */ 2, 0, 0, -9, -9, 2, 0, 0, -9, 9, 0 } }; if (gkss->version > 4) mscale *= p->height / 500.0; r = (int)(3 * mscale); scale = mscale / 3.0; xr = r; yr = 0; seg_xform_rel(&xr, &yr); r = nint(sqrt(xr * xr + yr * yr)); NDC_to_DC(xn, yn, x, y); pc = 0; mtype = (r > 0) ? mtype + 20 : 21; do { op = marker[mtype][pc]; switch (op) { case 1: /* point */ MoveTo(x, y); LineTo(x, y); break; case 2: /* line */ for (i = 0; i < 2; i++) { xr = scale * marker[mtype][pc + 2 * i + 1]; yr = -scale * marker[mtype][pc + 2 * i + 2]; seg_xform_rel(&xr, &yr); if (i == 0) MoveTo(x - xr, y + yr); else LineTo(x - xr, y + yr); } pc += 4; break; case 3: /* polyline */ for (i = 0; i < marker[mtype][pc + 1]; i++) { xr = scale * marker[mtype][pc + 2 + 2 * i]; yr = -scale * marker[mtype][pc + 3 + 2 * i]; seg_xform_rel(&xr, &yr); if (i == 0) MoveTo(x - xr, y + yr); else LineTo(x - xr, y + yr); } pc += 1 + 2 * marker[mtype][pc + 1]; break; case 4: /* filled polygon */ case 5: /* hollow polygon */ poly = OpenPoly(); if (op == 5) set_color(0); for (i = 0; i < marker[mtype][pc + 1]; i++) { xr = scale * marker[mtype][pc + 2 + 2 * i]; yr = -scale * marker[mtype][pc + 3 + 2 * i]; seg_xform_rel(&xr, &yr); if (i == 0) MoveTo(x - xr, y + yr); else LineTo(x - xr, y + yr); } ClosePoly(); PaintPoly(poly); KillPoly(poly); pc += 1 + 2 * marker[mtype][pc + 1]; if (op == 5) set_color(mcolor); break; case 6: /* arc */ rect.top = y - r; rect.left = x - r; rect.bottom = y + r; rect.right = x + r; FrameArc(&rect, 0, 360); break; case 7: /* filled arc */ case 8: /* hollow arc */ if (op == 8) set_color(0); rect.top = y - r; rect.left = x - r; rect.bottom = y + r; rect.right = x + r; PaintArc(&rect, 0, 360); if (op == 8) set_color(mcolor); break; } pc++; } while (op != 0); }