Ejemplo n.º 1
0
void VectorFileRenderRegion::InitAttributes()
{
	// We don't use pens and brushes.
	SetOSDrawingMode();
	SetLineAttributes();
	SetFillAttributes();

	// Set up the Last Output attributes for this device, first making sure that
	// any we might have lying around already are cleaned up.
	DeInitAttributes();
	LastOutputAttrs = AttributeManager::GetDefaultAttributes();

	if ( LastOutputAttrs != NULL )
	{
		for ( INT32 i = 0; i < NumCurrentAttrs; i++ )
		{
			// NULL all the pointers to begin with,
			// so that all default attribute are output
			// with the first object
			LastOutputAttrs[i].pAttr 	= NULL;
			LastOutputAttrs[i].Temp 	= FALSE;
			LastOutputAttrs[i].Ignore 	= FALSE;
		}
	}
}
Ejemplo n.º 2
0
void UDrawObject(DrawContext* ctx, objinstptr theinstance, short level, int passcolor, pushlistptr *stack)
{
   genericptr	*areagen;
   float	tmpwidth;
   int		defaultcolor = passcolor;
   int		curcolor = passcolor;
   short	savesel;
   XPoint 	bboxin[2], bboxout[2];
   u_char	xm, ym;
   objectptr	theobject = theinstance->thisobject;

   /* Save the number of selections and set it to zero while we do the	*/
   /* object drawing.							*/

   savesel = areawin->selects;
   areawin->selects = 0;

   /* All parts are given in the coordinate system of the object, unless */
   /* this is the top-level object, in which they will be interpreted as */
   /* relative to the screen.						 */

   ctx->UPushCTM();

   if (stack) push_stack(stack, theinstance);
   if (level != 0)
       ctx->CTM().preMult(theinstance->position, theinstance->scale,
                        theinstance->rotation);

   /* do a quick test for intersection with the display window */

   bboxin[0].x = theobject->bbox.lowerleft.x;
   bboxin[0].y = theobject->bbox.lowerleft.y;
   bboxin[1].x = theobject->bbox.lowerleft.x + theobject->bbox.width;
   bboxin[1].y = theobject->bbox.lowerleft.y + theobject->bbox.height;
   if (level == 0)
      extendschembbox(theinstance, &(bboxin[0]), &(bboxin[1]));
   ctx->CTM().transform(bboxin, bboxout, 2);

   xm = (bboxout[0].x < bboxout[1].x) ? 0 : 1;
   ym = (bboxout[0].y < bboxout[1].y) ? 0 : 1;

   if (bboxout[xm].x < areawin->width() && bboxout[ym].y < areawin->height() &&
       bboxout[1 - xm].x > 0 && bboxout[1 - ym].y > 0) {

     /* make parameter substitutions */
     psubstitute(theinstance);

     /* draw all of the elements */

     tmpwidth = ctx->UTopTransScale(xobjs.pagelist[areawin->page].wirewidth);
     SetLineAttributes(ctx->gc(), tmpwidth, LineSolid, CapRound,
                JoinBevel);

     /* guard against plist being regenerated during a redraw by the	*/
     /* expression parameter mechanism (should that be prohibited?)	*/

     for (areagen = 0; theobject->values(areagen); ) {

       if (defaultcolor != DOFORALL) {
          if ((*areagen)->color != curcolor) {
             if ((*areagen)->color == DEFAULTCOLOR)
                curcolor = defaultcolor;
             else
                curcolor = (*areagen)->color;
             XcTopSetForeground(ctx, curcolor);
          }
       }

       switch(ELEMENTTYPE(*areagen)) {
          case(POLYGON):
             if (level == 0 || !((TOPOLY(areagen))->style & BBOX))
                TOPOLY(areagen)->draw(ctx);
             break;

          case(OBJINST):
             if (areawin->editinplace && stack && (TOOBJINST(areagen)
                        == areawin->topinstance)) {
                /* If stack matches areawin->stack, then don't draw */
                /* because it would be redundant.		 */
                pushlistptr alist = *stack, blist = areawin->stack;
                while (alist && blist) {
                   if (alist->thisinst != blist->thisinst) break;
                   alist = alist->next;
                   blist = blist->next;
                }
                if ((!alist) || (!blist)) break;
             }
             UDrawObject(ctx, TOOBJINST(areagen), level + 1, curcolor, stack);
             break;

          case(LABEL):
             if (level == 0 || TOLABEL(areagen)->pin == false)
                UDrawString(ctx, TOLABEL(areagen), curcolor, theinstance);
             else if ((TOLABEL(areagen)->justify & PINVISIBLE) && areawin->pinpointon)
                UDrawString(ctx, TOLABEL(areagen), curcolor, theinstance);
             else if (TOLABEL(areagen)->justify & PINVISIBLE)
                UDrawString(ctx, TOLABEL(areagen), curcolor, theinstance, false);
             else if (level == 1 && TOLABEL(areagen)->pin &&
                        TOLABEL(areagen)->pin != INFO && areawin->pinpointon)
                UDrawXDown(ctx, TOLABEL(areagen));
             break;

          default:
             TOGENERIC(areagen)->draw(ctx);
             break;
       }
     }

     /* restore the color passed to the object, if different from current color */

     if ((defaultcolor != DOFORALL) && (passcolor != curcolor)) {
        XTopSetForeground(ctx->gc(), passcolor);
     }
   }

   /* restore the selection list (if any) */
   areawin->selects = savesel;
   ctx->UPopCTM();
   if (stack) pop_stack(stack);
}