コード例 #1
0
ファイル: poly.cpp プロジェクト: CyberWalkingGuy/repsnapper
void draw_poly (const ExPoly &expoly, int gl_type, int linewidth, int pointsize,
		const float *rgb, float a, bool randomized)
{
  draw_poly(expoly.outer,  gl_type, linewidth, pointsize, rgb, a, randomized);
  for(size_t p=0; p < expoly.holes.size();p++)
    draw_poly(expoly.holes[p],  gl_type, linewidth, pointsize, rgb, a, randomized);
}
コード例 #2
0
ファイル: poly.cpp プロジェクト: CyberWalkingGuy/repsnapper
void draw_polys(const vector <ExPoly> &expolys, int gl_type, int linewidth, int pointsize,
		const float *rgb, float a, bool randomized)
{
  for(size_t p=0; p < expolys.size();p++) {
    draw_poly(expolys[p],  gl_type, linewidth, pointsize, rgb, a, randomized);
  }
}
コード例 #3
0
ファイル: poly2.c プロジェクト: ipozgaj/playground_sources
void mouse_handler(int button, int state, int x, int y)
{
	if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && current_point < num_points) {
		points[current_point].x = x;
		points[current_point].y = window_height - y;

		if (current_point == 0)
			points[num_points] = points[0];
		
		glBegin(GL_POINTS);
		glVertex2i(points[current_point].x, points[current_point].y);
		glEnd();
		glFlush();
		
		++current_point;
		
		printf("Kordinate tocke %d: (%d, %d)\n", current_point, x, y);
	} else if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) {
		resize_scene(window_width, window_height);
	}

	if (current_point == num_points && state == GLUT_DOWN) {
		draw_poly();
		
		if (is_in_poly(x, window_height - y))
			printf("Toèka (%d, %d) je unutar poligona\n", x, y);
		else
			printf("Toèka (%d, %d) nije unutar poligona\n", x, y);

		return;
	}

}
コード例 #4
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolGeomShift::update(bool global){
	if(!global){
		clearTempPathContext(false);
	}	
	if(get_on_drag()){
ivertices*	vxs=get_output();
        if(vxs){
            draw_poly(vxs,false);
            ivs_free(vxs);
        }
//ivertices*	vxs=NULL;
//		for(;;){
//			if(!_vxs){
//				break;
//			}
//			ivs2ivs(_vxs,&vxs);
//			if(!_vxs){
//				break;
//			}	
//			ivs_shift(&vxs,_d);
//			if(!vxs){
//				break;
//			}
//			break;
//		}
//		draw_poly(vxs,false);
//		ivs_free(vxs);
	}
	if(!global){
		validTempPathContext();
	}	
}
コード例 #5
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolLength::update(bool global){
	if(!get_active()){
		return;
	}
	draw_poly(false,true);
	report_len();
}
コード例 #6
0
ファイル: layer.cpp プロジェクト: asheikh91/repsnapper
void Layer::Draw(bool DrawVertexNumbers, bool DrawLineNumbers, 
		 bool DrawOutlineNumbers, bool DrawCPLineNumbers, 
		 bool DrawCPVertexNumbers, bool DisplayInfill) const 
{
  draw_polys(polygons, GL_LINE_LOOP, 1, 3, 1,0,0,1);
  draw_polys(polygons, GL_POINTS, 1, 3, 1,0,0,1);

  if(DrawOutlineNumbers)
    for(size_t p=0; p<polygons.size();p++)
      {
	ostringstream oss;
	oss << p;
	renderBitmapString(Vector3f(polygons[p].center.x, polygons[p].center.y, Z) , 
			   GLUT_BITMAP_8_BY_13 , oss.str());
      }

  draw_polys(shellPolygons, GL_LINE_LOOP, 1, 3, 1,1,.2,1);

  glColor4f(0.5,0.9,1,1);
  glLineWidth(1);
  double zs = Z;
  for(size_t s=0;s<skins;s++){
    for(size_t p=0;p<skinPolygons.size();p++)
      skinPolygons[p].draw(GL_LINE_LOOP,zs);
    zs-=thickness/skins;
  }

  draw_polys(fillPolygons, GL_LINE_LOOP, 1, 3, 1,1,1,1);
  draw_polys(supportPolygons, GL_LINE_LOOP, 3, 3, 0.5,0.5,1.0,1);
  draw_poly(hullPolygon, GL_LINE_LOOP, 3, 3, 0.8,0.6,0.0,0.5);
  draw_polys(bridgePolygons, GL_LINE_LOOP, 3, 3, 0.8,0.5,0.5,0.8);
  draw_polys(fullFillPolygons, GL_LINE_LOOP, 1, 3, 0.5,0.5,0.5,1);
  draw_polys(decorPolygons, GL_LINE_LOOP, 1, 3, 0.5,0.5,0.5,1);
  draw_polys(skinFullFillPolygons, GL_LINE_LOOP, 1, 3, 0.5,0.5,0.5,1);
  if(DisplayInfill)
    {
      if (normalInfill)
	draw_polys(normalInfill->infillpolys, GL_LINE_LOOP, 1, 3, 0.1,1,0.1,0.8);
      if (fullInfill)
	draw_polys(fullInfill->infillpolys, GL_LINE_LOOP, 1, 3, 0.1,1,0.1,0.8);
      if (decorInfill)
	draw_polys(decorInfill->infillpolys, GL_LINE_LOOP, 1, 3, 0.1,1,0.1,0.8);
      if (bridgeInfill)
	draw_polys(bridgeInfill->infillpolys, GL_LINE_LOOP, 1, 3, 0.8,0.3,0.1,0.8);
      if (supportInfill)
	draw_polys(supportInfill->infillpolys, GL_LINE_LOOP, 1, 3, 0.1,1,0.1,0.8);
      for(size_t s=0;s<skinFullInfills.size();s++) 
	draw_polys(skinFullInfills[s]->infillpolys, GL_LINE_LOOP, 3, 3, 0.2,1,0.2,0.6);
    }
  glLineWidth(1);  
  if(DrawCPVertexNumbers)
    for(size_t p=0; p<polygons.size();p++)
      polygons[p].drawVertexNumbers();
  
  if(DrawCPLineNumbers)
    for(size_t p=0; p<polygons.size();p++)
      polygons[p].drawLineNumbers();
}
コード例 #7
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolCut::update(bool global){
	if(!global){
		clearTempPathContext(false);
	}
	if(get_use_locs()){
		draw_poly(true,true);
	}
	bToolGeomWithJoin::update(global);
	if(!global){
		validTempPathContext();
	}
}
コード例 #8
0
void draw_drawing( BITMAP *bmp, drawingtype *drawing, float x, float y, float z ){
	int i ;
	
	if ( z > 0 ){
		drawing_mode(DRAW_MODE_TRANS,0,0,0);
		
		for ( i = 0; i < drawing->num_polys; i++ ){
			 color_poly( bmp, &drawing->poly[i], x, y, z );
		}
		for ( i = 0; i < drawing->num_polys; i++ ){
			draw_poly( bmp, &drawing->poly[i], x, y, z );
		}
		
		drawing_mode(DRAW_MODE_SOLID,0,0,0);
	}
}
コード例 #9
0
ファイル: egetriangle.cpp プロジェクト: Dorislu/xege
int main()
{
    static struct polys p[10] = {{0}};
    int n_points[10] = {3,3,3,6,7};
    int n_poly[10] = {1,1,1,1,1};
    int n_polys = 3, i;
    randomize();
    //图形初始化
    {
        setinitmode(INIT_ANIMATION);
        initgraph(width, height);
        width  = getmaxx();
        height = getmaxy();
        setrendermode(RENDER_MANUAL);
    }
    //多边形对象初始化
    for (i=0; i< n_polys; ++i)
    {
        initpolys(&p[i], n_poly[i], n_points[i]);
    }
    fps ui_fps;
    //主循环
    for ( ; is_run(); delay_fps(60))
    {
        if (kbhit() > 0) //有按键按下就退出
        {
            break;
        }
        for (i=0; i< n_polys; ++i)
        {
            movepoly(p[i].p);
        }
        cleardevice();
        for (i=0; i< n_polys; ++i)
        {
            draw_poly(p[i].p);
        }
        //imagefilter_blurring(NULL, 0xff, 0x100);
    }
    closegraph();
    return 0;
}
コード例 #10
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolRedraw::update(bool global){
	if(get_active()){
		if(!global){
			clearTempPathContext(false);
		}
		if(get_use_locs()){
			if(_ec>1){
i2dvertex		bck;
				get_cur(&bck);
				if(bck.h!=LONG_MIN){
					get_locs()->add(&bck);
					get_locs()->add(&_vxb);
					draw_poly(true,false);
					get_locs()->rmv(get_locs()->count());
					get_locs()->rmv(get_locs()->count());
				}
			}
		}
		bToolGeomWithJoin::update(global);
		if(!global){
			validTempPathContext();
		}
	}
}
コード例 #11
0
ファイル: poly.c プロジェクト: qeedquan/qmap
void draw_face(int face)
{
   int n = dfaces[face].numedges;
   int se = dfaces[face].firstedge;
   int i,codes_or=0,codes_and=0xff;
   point_3d **vlist;

   for (i=0; i < n; ++i) {
      int edge = dsurfedges[se+i];
      if (edge < 0)
         transform_point(&pts[i], (vector *) VERTEX(dedges[-edge].v[1]));
      else
         transform_point(&pts[i], (vector *) VERTEX(dedges[ edge].v[0]));
      codes_or  |= pts[i].ccodes;
      codes_and &= pts[i].ccodes;
   }

   if (codes_and) return;  // abort if poly outside frustrum

   if (codes_or) {
      // poly crosses frustrum, so clip it
      n = clip_poly(n, default_vlist, codes_or, &vlist);
   } else
      vlist = default_vlist;

   if (n) {
      bitmap bm;
      float u,v;
      int tex = dfaces[face].texinfo;
      int mip = compute_mip_level(face);
      get_tmap(&bm, face, texinfo[tex].miptex, mip, &u, &v);
      qmap_set_texture(&bm);
      compute_texture_gradients(face, tex, mip, u, v);
      draw_poly(n, vlist);
   }
}
コード例 #12
0
ファイル: ArtifactCanvas.cpp プロジェクト: kralf/bouml
void ArtifactCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  const BasicData * data = browser_node->get_data();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);
  
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(browser_node->get_data()->get_stereotype(), the_canvas()->zoom());
  
  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
    
    r.moveBy(0, px->height());
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
    p.drawText(r, ::Qt::AlignHCenter, browser_node->get_name());
    
    if (fp != 0) {
      draw_text(r, ::Qt::AlignHCenter, browser_node->get_name(), p.font(), fp);
      fputs("</g>\n", fp);
    }
  }
  else {  
    QColor bckgrnd = p.backgroundColor();
    
    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    
    QColor co = color(used_color);
    
    p.setBackgroundColor(co);
    
    // <<artifact>>/stereotype on 2*font_height with the icon on the right
    // the icon height = 2*font_height
    // the icon width = 3*height/4
    // name on font_height+4 points
    const int four = (int) (4 * the_canvas()->zoom());
    QFontMetrics fm(the_canvas()->get_font(UmlNormalBoldFont));
    const int he = fm.height();
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();
      
      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);
	
	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);
	  
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    QRect re = r;
    
    if (used_color != UmlTransparent) {
      p.fillRect(r, co);
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
    }
    else if (fp != 0)
      fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      r.x(), r.y(), r.width() - 1, r.height() - 1);
    
    p.drawRect(r);
    
    r.setHeight(he*2);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    if (data->get_stereotype()[0]) {
      p.drawText(r, ::Qt::AlignCenter,
		 QString("<<") + toUnicode(data->get_short_stereotype()) + ">>");
      if (fp != 0)
	draw_text(r, ::Qt::AlignCenter,
		  QString("<<") + toUnicode(data->get_short_stereotype()) + ">>",
		  p.font(), fp);
    }
    else {
      p.drawText(r, ::Qt::AlignCenter, "<<artifact>>");
      if (fp != 0)
	draw_text(r, ::Qt::AlignCenter, "<<artifact>>",
		  p.font(), fp);
    }
    
    r.moveBy(0, r.height());
    r.setHeight(he+four);
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
    p.drawText(r, ::Qt::AlignCenter, browser_node->get_name());
    if (fp != 0)
      draw_text(r, ::Qt::AlignCenter, browser_node->get_name(),
		p.font(), fp);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    
    // draw icon
    re.setLeft(re.right() - 6*he/4 + four);
    re.setRight(re.right() - four);
    re.setTop(re.top() + four);
    re.setHeight(2*(he - four));
    
    Q3PointArray a(7);
    const int corner_size = re.width()/3;
    
    a.setPoint(0, re.left(), re.top());
    a.setPoint(1, re.right() - corner_size, re.top());
    a.setPoint(2, re.right() - corner_size, re.top() + corner_size);
    a.setPoint(3, re.right(), re.top() + corner_size);
    a.setPoint(4, re.right(), re.bottom());
    a.setPoint(5, re.left(), re.bottom());
    a.setPoint(6, re.left(), re.top());
    p.drawPolyline(a);
    //p.moveTo(re.right() - corner_size, re.top());
    //p.lineTo(re.right(), re.top() + corner_size);
    p.drawLine(re.right() - corner_size, re.top(), re.right(), re.top() + corner_size);
    
    if (fp != 0) {
      draw_poly(fp, a, UmlTransparent);
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n"
	      "</g>\n",
	      re.right() - corner_size, re.top(), re.right(), re.top() + corner_size);
    }
    
    p.setBackgroundColor(bckgrnd);
  }
  
  if (selected())
    show_mark(p, rect());
}
コード例 #13
0
ファイル: i830_metaops.c プロジェクト: Magister/x11rdp_xorg71
/**
 * Copy the window contents named by dPriv to the rotated (or reflected)
 * color buffer.
 * srcBuf is BUFFER_BIT_FRONT_LEFT or BUFFER_BIT_BACK_LEFT to indicate the source.
 */
void
i830RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
                 GLuint srcBuf)
{
   i830ContextPtr i830 = I830_CONTEXT( intel );
   intelScreenPrivate *screen = intel->intelScreen;
   const GLuint cpp = screen->cpp;
   drm_clip_rect_t fullRect;
   GLuint textureFormat, srcOffset, srcPitch;
   const drm_clip_rect_t *clipRects;
   int numClipRects;
   int i;

   int xOrig, yOrig;
   int origNumClipRects;
   drm_clip_rect_t *origRects;

   /*
    * set up hardware state
    */
   intelFlush( &intel->ctx );

   SET_STATE( i830, meta ); 
   set_initial_state( i830 ); 
   set_no_texture( i830 ); 
   set_vertex_format( i830 ); 
   set_no_depth_stencil_write( i830 );
   set_color_mask( i830, GL_FALSE );

   LOCK_HARDWARE(intel);

   /* save current drawing origin and cliprects (restored at end) */
   xOrig = intel->drawX;
   yOrig = intel->drawY;
   origNumClipRects = intel->numClipRects;
   origRects = intel->pClipRects;

   if (!intel->numClipRects)
      goto done;

   /*
    * set drawing origin, cliprects for full-screen access to rotated screen
    */
   fullRect.x1 = 0;
   fullRect.y1 = 0;
   fullRect.x2 = screen->rotatedWidth;
   fullRect.y2 = screen->rotatedHeight;
   intel->drawX = 0;
   intel->drawY = 0;
   intel->numClipRects = 1;
   intel->pClipRects = &fullRect;

   set_draw_region( i830, &screen->rotated );

   if (cpp == 4)
      textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
   else
      textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;

   if (srcBuf == BUFFER_BIT_FRONT_LEFT) {
      srcPitch = screen->front.pitch;   /* in bytes */
      srcOffset = screen->front.offset; /* bytes */
      clipRects = dPriv->pClipRects;
      numClipRects = dPriv->numClipRects;
   }
   else {
      srcPitch = screen->back.pitch;   /* in bytes */
      srcOffset = screen->back.offset; /* bytes */
      clipRects = dPriv->pBackClipRects;
      numClipRects = dPriv->numBackClipRects;
   }

   /* set the whole screen up as a texture to avoid alignment issues */
   set_tex_rect_source(i830,
                       srcOffset,
                       screen->width,
                       screen->height,
                       srcPitch,
                       textureFormat);

   enable_texture_blend_replace(i830);

   /*
    * loop over the source window's cliprects
    */
   for (i = 0; i < numClipRects; i++) {
      int srcX0 = clipRects[i].x1;
      int srcY0 = clipRects[i].y1;
      int srcX1 = clipRects[i].x2;
      int srcY1 = clipRects[i].y2;
      GLfloat verts[4][2], tex[4][2];
      int j;

      /* build vertices for four corners of clip rect */
      verts[0][0] = srcX0;  verts[0][1] = srcY0;
      verts[1][0] = srcX1;  verts[1][1] = srcY0;
      verts[2][0] = srcX1;  verts[2][1] = srcY1;
      verts[3][0] = srcX0;  verts[3][1] = srcY1;

      /* .. and texcoords */
      tex[0][0] = srcX0;  tex[0][1] = srcY0;
      tex[1][0] = srcX1;  tex[1][1] = srcY0;
      tex[2][0] = srcX1;  tex[2][1] = srcY1;
      tex[3][0] = srcX0;  tex[3][1] = srcY1;

      /* transform coords to rotated screen coords */

      for (j = 0; j < 4; j++) {
         matrix23TransformCoordf(&screen->rotMatrix,
                                 &verts[j][0], &verts[j][1]);
      }

      /* draw polygon to map source image to dest region */
      draw_poly(i830, 255, 255, 255, 255, 4, verts, tex);

   } /* cliprect loop */

   assert(!intel->prim.flush); 
   intelFlushBatchLocked( intel, GL_FALSE, GL_FALSE, GL_FALSE );

 done:
   /* restore original drawing origin and cliprects */
   intel->drawX = xOrig;
   intel->drawY = yOrig;
   intel->numClipRects = origNumClipRects;
   intel->pClipRects = origRects;

   UNLOCK_HARDWARE(intel);

   SET_STATE( i830, state );
}
コード例 #14
0
ファイル: gen_win.cpp プロジェクト: jakexie/micmac-archeos
void El_Window::draw_poly_ouv(const std::vector<Pt2dr> & aV,Line_St aLst)
{
    draw_poly(aV,aLst,false);
}
コード例 #15
0
ファイル: gen_win.cpp プロジェクト: jakexie/micmac-archeos
void El_Window::draw_poly_ferm(const std::vector<Pt2dr> & aV,Line_St aLst)
{
    draw_poly(aV,aLst,true);
}
コード例 #16
0
ファイル: NoteCanvas.cpp プロジェクト: harmegnies/douml
void NoteCanvas::draw(QPainter & p)
{
    if (! visible()) return;

    p.setRenderHint(QPainter::Antialiasing, true);
    QRect r = rect();
    QBrush brsh = p.brush();
    QColor bckgrnd = p.backgroundColor();
    QPen fgcolor = p.pen();
    Q3PointArray a(7);

    used_color = (itscolor == UmlDefaultColor)
                 ? the_canvas()->browser_diagram()->get_color(UmlNote)
                 : itscolor;

    QColor co = color(used_color);

    const int corner_size = (int)(NOTE_MARGIN * the_canvas()->zoom());

    a.setPoint(0, r.left(), r.top());
    a.setPoint(1, r.right() - corner_size, r.top());
    a.setPoint(2, r.right() - corner_size, r.top() + corner_size);
    a.setPoint(3, r.right(), r.top() + corner_size);
    a.setPoint(4, r.right(), r.bottom());
    a.setPoint(5, r.left(), r.bottom());
    a.setPoint(6, r.left(), r.top());

    FILE * fp = svg();

    if (fp != 0)
        fputs("<g>\n", fp);

    if (used_color == UmlTransparent) {
        p.setBackgroundMode(::Qt::TransparentMode);
        p.setBackgroundColor(co);
        p.drawPolyline(a);

        if (fp != 0)
            draw_poly(fp, a, UmlTransparent);
    }
    else {
        p.setBackgroundMode(::Qt::OpaqueMode);
        p.setBrush(co);
        p.drawPolygon(a, TRUE, 0, 6);
        p.setBrush(brsh);
        p.setBackgroundColor(co);

        if (fp != 0)
            draw_poly(fp, a, used_color);
    }

    p.drawLine(r.right() - corner_size, r.top(),
               r.right(), r.top() + corner_size);

    if (fp != 0)
        fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
                " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
                r.right() - corner_size, r.top(), r.right(), r.top() + corner_size);

    p.setFont(the_canvas()->get_font(itsfont));

    if (fg_c != UmlTransparent)
        p.setPen(color(fg_c));

    p.drawText(r.left() + corner_size, r.top() + corner_size,
               r.width() - 2 * corner_size, r.height() - 2 * corner_size,
               ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
               note);

    if (fp != 0) {
        draw_text(r.left() + corner_size, r.top() + corner_size,
                  r.width() - 2 * corner_size, r.height() - 2 * corner_size,
                  ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
                  note, p.font(), fp, fg_c);
        fputs("</g>\n", fp);
    }

    p.setFont(the_canvas()->get_font(UmlNormalFont));
    p.setBackgroundColor(bckgrnd);
    p.setPen(fgcolor);

    if (selected())
        show_mark(p, r);
}
コード例 #17
0
ファイル: DeploymentNodeCanvas.cpp プロジェクト: SciBoy/douml
void DeploymentNodeCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);

  const int three = (int) (3 * the_canvas()->zoom());  
  QColor bckgrnd = p.backgroundColor();
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(browser_node->get_data()->get_stereotype(), the_canvas()->zoom());
  
  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
    
    r.setTop(r.top() + px->height());
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
  }
  else {  
    UmlColor c;
    
    if (itscolor != UmlDefaultColor)
      c = itscolor;
    else {
      if (used_color == UmlDefaultColor)
	used_color = the_canvas()->browser_diagram()->get_color(UmlDeploymentNode);
      c = used_color;
    }
    
    QColor co = color(c);
    const int added = (int) (DEPLOYMENTNODE_CANVAS_ADDED * the_canvas()->zoom());
    Q3PointArray a(7);
    
    r.setTop(r.top() + added);
    r.setRight(r.right() - added);
    
    a.setPoint(0, r.left(), r.top());
    a.setPoint(1, r.left() + added, r.top() - added);
    a.setPoint(2, r.right() + added, r.top() - added);
    a.setPoint(3, r.right() + added, r.bottom() - added);
    a.setPoint(4, r.right(), r.bottom());
    a.setPoint(5, r.right(), r.top());
    a.setPoint(6, r.left(), r.top());
    
    if (c == UmlTransparent) {
      p.setBackgroundMode(::Qt::TransparentMode);
      p.setBackgroundColor(co);
      p.drawPolyline(a);
      
      if (fp != 0) {
	fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		r.x(), r.y(), r.width() - 1, r.height() - 1);
	draw_poly(fp, a, UmlTransparent);
      }
    }
    else {
      QBrush brsh = p.brush();
      
      p.setBackgroundMode(::Qt::OpaqueMode);
      p.fillRect(r, co);
      p.setBrush(co);
      p.drawPolygon(a, TRUE, 0, 6);
      p.setBrush(brsh);
      p.setBackgroundColor(co);
      
      if (fp != 0) {
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(c),
		r.x(), r.y(), r.width() - 1, r.height() - 1);
	draw_poly(fp, a, c);
      }
    }
    
    p.drawRect(r);
    p.drawLine(r.topRight(), a.point(2));
    
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.right(), r.top(), a.point(2).x(), a.point(2).y());
    
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    const char * st = browser_node->get_data()->get_short_stereotype();
    QString s;
    
    r.setTop(r.top() + three);
    p.setFont(the_canvas()->get_font(UmlNormalFont));  
    
    if (st[0]) {
      s = QString("<<") + toUnicode(st) + ">>";
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s);
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s, p.font(), fp);
      r.setTop(r.top() + fm.height() + three);
    }
  }
    
  QFontMetrics fm(p.font());
  
  if (horiz) {
    QString s = iname + ":" + browser_node->get_name();
    
    p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s);
    if (fp != 0)
      draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s, p.font(), fp);
  }
  else {
    QString s = iname + ":";
    
    p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s);
    if (fp != 0)
      draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s, p.font(), fp);
    r.setTop(r.top() + fm.height() + three);
    s = browser_node->get_name();
    p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s);
    if (fp != 0)
      draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, s, p.font(), fp);
  }
  
  p.setFont(the_canvas()->get_font(UmlNormalFont));  
  p.setBackgroundColor(bckgrnd);
  
  if (fp != 0)
    fputs("</g>\n", fp);
  
  if (selected())
    show_mark(p, rect());
}
コード例 #18
0
void StateActionCanvas::draw(QPainter & p) {
  if (! visible()) return;
  
  QRect r = rect();
  const BasicData * data = browser_node->get_data();
  double zoom = the_canvas()->zoom();
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(data->get_stereotype(),
				       the_canvas()->zoom());
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);
    
  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
  }
  else {
    QColor bckgrnd = p.backgroundColor();
    int mw = min_width;
    QBrush brsh = p.brush();
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    const char * st = data->get_short_stereotype();
    const int shadow = the_canvas()->shadow();
    
    QColor co = color(used_color);
    
    p.setBackgroundMode((used_color == UmlTransparent)
			? ::Qt::TransparentMode
			: ::Qt::OpaqueMode);

    p.setBackgroundColor(co);
    
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    
    if (!strcmp(st, "send-signal")) {
      QPointArray a(6);
      
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      const int hh = r.height()/2;
      
      a.setPoint(0, r.left(), r.top());
      a.setPoint(1, r.right() - hh, r.top());
      a.setPoint(2, r.right(), r.top() + hh);
      a.setPoint(3, r.right() - hh, r.bottom());
      a.setPoint(4, r.left(), r.bottom());
      a.setPoint(5, r.left(), r.top());
      
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.left() + shadow, r.top() + shadow);
	  b.setPoint(1, r.right() - hh + shadow, r.top() + shadow);
	  b.setPoint(2, r.right() + shadow, r.top() + hh + shadow);
	  b.setPoint(3, r.right() - hh + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.left() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.left() + shadow, r.top() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);
	  
	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);
	
	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      
      r.setRight(r.right() - hh);
      mw -= hh;
    }
    else if (!strcmp(st, "receive-signal")) {
      QPointArray a(6);
      
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      const int hh = r.height()/2;
      
      a.setPoint(0, r.left(), r.top());
      a.setPoint(1, r.right(), r.top());
      a.setPoint(2, r.right() - hh, r.top() + hh);
      a.setPoint(3, r.right(), r.bottom());
      a.setPoint(4, r.left(), r.bottom());
      a.setPoint(5, r.left(), r.top());
      
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.left() + shadow, r.top() + shadow);
	  b.setPoint(1, r.right() + shadow, r.top() + shadow);
	  b.setPoint(2, r.right() - hh + shadow, r.top() + hh + shadow);
	  b.setPoint(3, r.right() + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.left() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.left() + shadow, r.top() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);
	  
	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);
	
	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      
      r.setRight(r.right() - hh);
      mw -= hh;
    }
    else {
      if (used_color != UmlTransparent) {
	if (shadow != 0) {
	  r.setRight(r.right() - shadow);
	  r.setBottom(r.bottom() - shadow);
	  
	  p.fillRect (r.right(), r.top() + shadow,
		      shadow, r.height() - 1,
		      ::Qt::darkGray);
	  p.fillRect (r.left() + shadow, r.bottom(),
		      r.width() - 1, shadow,
		      ::Qt::darkGray);
	  
	  if (fp != 0) {
	    fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		    ::Qt::darkGray.rgb()&0xffffff,
		    r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);
	    
	    fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		    ::Qt::darkGray.rgb()&0xffffff,
		    r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	  }
	}
      }
      
      p.setBrush(co);
      p.drawRect(r);
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
      
      if (st[0] != 0) {
	r.setTop(r.top() + fm.height() / 2);
	p.drawText(r, ::Qt::AlignHCenter, QString("<<") + toUnicode(st) + ">>");
	if (fp != 0)
	  draw_text(r, ::Qt::AlignHCenter, QString("<<") + toUnicode(st) + ">>",
		    p.font(), fp);
	r.setTop(r.top() + 3*fm.height()/2);
      }
    }
    
    r.setLeft(r.left() + (r.width() + (int) (8 * zoom) - mw)/2 + 1);
    p.drawText(r, ::Qt::AlignVCenter, s);
    if (fp != 0) {
      draw_text(r, ::Qt::AlignVCenter, s,
		p.font(), fp);
      fputs("</g>\n", fp);
    }
      
    p.setBrush(brsh);
    p.setBackgroundColor(bckgrnd);
  }
  
  if (selected())
    show_mark(p, rect());
}
コード例 #19
0
void FragmentCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
  int w = fm.width((name.isEmpty()) ? QString("X") : name);
  int h = fm.height() / 2;  
  QRect r = rect();
  QRect rname = r;
  
  rname.setWidth(w + h);
  rname.setHeight(fm.height() + h);
  
  int h1 = (fm.height() + h)/2;
  int x1 = rname.right() + h1;
  int y1 = rname.bottom() - h1;
  
  QColor bckgrnd = p.backgroundColor();

  p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);
  
  p.setBackgroundColor(co);
  p.setFont(the_canvas()->get_font(UmlNormalFont));
  
  if (used_color != UmlTransparent)
    p.fillRect(r, co);
  else if (!name.isEmpty()) {
    Q3PointArray a(6);
    QBrush brsh = p.brush();
    
    a.setPoint(0, rname.left(), rname.top());
    a.setPoint(1, x1, rname.top());
    a.setPoint(2, x1, y1);
    a.setPoint(3, rname.right(), rname.bottom());
    a.setPoint(4, rname.left(), rname.bottom());
    a.setPoint(5, rname.left(), rname.top());

    p.setBrush(UmlWhiteColor);
    p.drawPolygon(a, TRUE, 0, 5);
    p.setBrush(brsh);
    
    if (fp != 0)
      draw_poly(fp, a, UmlWhite);
  }

  if (fp != 0)
    fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	    svg_color(used_color), 
	    r.x(), r.y(), r.width() - 1, r.height() - 1);
  
  p.drawRect(r);
  
  if (refer != 0) {
    QString s = refer->get_name() + form;
    QRect r2(r.left(), r.top() + 2*fm.height(),
	     r.width(), fm.height());

    p.drawText(r2, ::Qt::AlignCenter, s);
    
    if (fp != 0)
      draw_text(r2, ::Qt::AlignCenter, s,
		p.font(), fp);
  }
  
  if (!name.isEmpty())
    p.drawText(rname, ::Qt::AlignCenter, name);
  if (fp != 0)
    draw_text(rname, ::Qt::AlignCenter, name,
	      p.font(), fp);
  
  p.drawLine(rname.left(), rname.bottom(), rname.right(), rname.bottom());
  p.drawLine(rname.right(), rname.bottom(), x1, y1);
  p.drawLine(x1, y1, x1, rname.top());

  if (fp != 0) {
    fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	    " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	    rname.left(), rname.bottom(), rname.right(), rname.bottom());
    fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	    " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	    rname.right(), rname.bottom(), x1, y1);
    fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	    " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	    x1, y1, x1, rname.top());
    fputs("</g>\n", fp);
  }
	       
  p.setBackgroundColor(bckgrnd);
  
  if (selected())
    show_mark(p, r);
}
コード例 #20
0
ファイル: layer.cpp プロジェクト: keesj/repsnapper
void Layer::Draw(const Settings &settings)
{

#if 0
  // test single area expolys
  vector<ExPoly> expolys = Clipping::getExPolys(polygons);
  draw_polys(expolys, GL_LINE_LOOP, 1, 3, RED, 1);
  cerr << expolys.size() << endl;

  Infill exinf(this, 1.);
  exinf.setName("infill");
  double infilldistance = settings.GetInfillDistance(thickness,
						     settings.Slicing.InfillPercent);

  exinf.addPolys(Z, expolys, HexInfill,
		 infilldistance, infilldistance, 0.4);
  draw_polys(exinf.infillpolys, GL_LINE_LOOP, 1, 3,
	     (exinf.cached?BLUEGREEN:GREEN), 1);
  return;
#endif

  bool randomized = settings.get_boolean("Display","RandomizedLines");
  bool filledpolygons = settings.get_boolean("Display","DisplayFilledAreas");
  // glEnable(GL_LINE_SMOOTH);
  // glHint(GL_LINE_SMOOTH_HINT,  GL_NICEST);
  draw_polys(polygons, GL_LINE_LOOP, 1, 3, RED, 1, randomized);
  draw_polys(polygons, GL_POINTS,    1, 3, RED, 1, randomized);

  if(settings.get_boolean("Display","DrawCPOutlineNumbers"))
    for(size_t p=0; p<polygons.size();p++)
      {
	ostringstream oss;
	oss << p;
	Vector2d center = polygons[p].getCenter();
	Render::draw_string(Vector3d(center.x(), center.y(), Z), oss.str());
      }

  draw_poly(hullPolygon,    GL_LINE_LOOP, 3, 3, ORANGE,  0.5, randomized);
  draw_polys(skirtPolygons, GL_LINE_LOOP, 3, 3, YELLOW,  1, randomized);
  draw_polys(shellPolygons, GL_LINE_LOOP, 1, 3, YELLOW2, 1, randomized);
  draw_polys(thinPolygons,  GL_LINE_LOOP, 2, 3, YELLOW,  1, randomized);

  glColor4f(0.5,0.9,1,1);
  glLineWidth(1);
  double zs = Z;
  for(size_t s=0;s<skins;s++) {
    for(size_t p=0; p < skinPolygons.size();p++) {
      //cerr << s << ": " << p << " _ " << zs << endl;
      skinPolygons[p].draw(GL_LINE_LOOP, zs, randomized);
    }
    zs-=thickness/skins;
  }
  draw_polys(fillPolygons,         GL_LINE_LOOP, 1, 3, WHITE, 0.6, randomized);
  if (supportPolygons.size()>0) {
    if (filledpolygons)
      draw_polys_surface(supportPolygons,  Min, Max, Z, thickness/2., BLUE2, 0.4);
    draw_polys(supportPolygons,      GL_LINE_LOOP, 3, 3, BLUE2, 1,   randomized);
    if(settings.get_boolean("Display","DrawVertexNumbers"))
      for(size_t p=0; p<supportPolygons.size();p++)
	supportPolygons[p].drawVertexNumbers();
  } // else
    // draw_polys(toSupportPolygons,    GL_LINE_LOOP, 1, 1, BLUE2, 1,   randomized);
  draw_polys(bridgePolygons,       GL_LINE_LOOP, 3, 3, RED2,  0.7, randomized);
  draw_polys(fullFillPolygons,     GL_LINE_LOOP, 1, 1, GREY,  0.6, randomized);
  draw_polys(decorPolygons,        GL_LINE_LOOP, 1, 3, WHITE, 1,   randomized);
  draw_polys(skinFullFillPolygons, GL_LINE_LOOP, 1, 3, GREY,  0.6, randomized);
  if (filledpolygons) {
    draw_polys_surface(fullFillPolygons,  Min, Max, Z, thickness/2., GREEN, 0.5);
    draw_polys_surface(decorPolygons,  Min, Max, Z, thickness/2., GREY, 0.2);
  }
  if(settings.get_boolean("Display","DisplayinFill"))
    {
      if (filledpolygons)
	draw_polys_surface(fillPolygons,  Min, Max, Z, thickness/2., GREEN2, 0.25);
      bool DebugInfill = settings.get_boolean("Display","DisplayDebuginFill");
      if (normalInfill)
	draw_polys(normalInfill->infillpolys, GL_LINE_LOOP, 1, 3,
		   (normalInfill->cached?BLUEGREEN:GREEN), 1, randomized);
      if(DebugInfill && normalInfill->cached)
	draw_polys(normalInfill->getCachedPattern(Z), GL_LINE_LOOP, 1, 3,
		   ORANGE, 0.5, randomized);
      if (thinInfill)
	draw_polys(thinInfill->infillpolys, GL_LINE_LOOP, 1, 3,
		   GREEN, 1, randomized);
      if (fullInfill)
	draw_polys(fullInfill->infillpolys, GL_LINE_LOOP, 1, 3,
		   (fullInfill->cached?BLUEGREEN:GREEN), 0.8, randomized);
      if (skirtInfill)
	draw_polys(skirtInfill->infillpolys, GL_LINE_LOOP, 1, 3,
		   YELLOW, 0.6, randomized);
      if(DebugInfill && fullInfill->cached)
	draw_polys(fullInfill->getCachedPattern(Z), GL_LINE_LOOP, 1, 3,
		   ORANGE, 0.5, randomized);
      if (decorInfill)
	draw_polys(decorInfill->infillpolys, GL_LINE_LOOP, 1, 3,
		   (decorInfill->cached?BLUEGREEN:GREEN), 0.8, randomized);
      if(DebugInfill && decorInfill->cached)
	draw_polys(decorInfill->getCachedPattern(Z), GL_LINE_LOOP, 1, 3,
		   ORANGE, 0.5, randomized);
      uint bridgecount = bridgeInfills.size();
      if (bridgecount>0)
	for (uint i = 0; i<bridgecount; i++)
	  draw_polys(bridgeInfills[i]->infillpolys, GL_LINE_LOOP, 2, 3,
		     RED3,0.9, randomized);
      if (supportInfill)
	draw_polys(supportInfill->infillpolys, GL_LINE_LOOP, 1, 3,
		   (supportInfill->cached?BLUEGREEN:GREEN), 0.8, randomized);
      if(DebugInfill && supportInfill->cached)
	draw_polys(supportInfill->getCachedPattern(Z), GL_LINE_LOOP, 1, 3,
		   ORANGE, 0.5, randomized);
      for(size_t s=0;s<skinFullInfills.size();s++)
	draw_polys(skinFullInfills[s]->infillpolys, GL_LINE_LOOP, 1, 3,
		   (skinFullInfills[s]->cached?BLUEGREEN:GREEN), 0.6, randomized);
    }
  //draw_polys(GetInnerShell(), GL_LINE_LOOP, 2, 3, WHITE,  1);
  glLineWidth(1);
  if(settings.get_boolean("Display","DrawCPVertexNumbers")) // poly vertex numbers
    for(size_t p=0; p<polygons.size();p++)
      polygons[p].drawVertexNumbers();
      //polygons[p].drawVertexAngles();

  if(settings.get_boolean("Display","DrawCPLineNumbers"))  // poly line numbers
    for(size_t p=0; p<polygons.size();p++)
      polygons[p].drawLineNumbers();

  if(settings.get_boolean("Display","DrawVertexNumbers")) { // infill vertex numbers
    for(size_t p=0; p<fillPolygons.size();p++)
      fillPolygons[p].drawVertexNumbers();
    for(size_t p=0; p<fullFillPolygons.size();p++)
      fullFillPolygons[p].drawVertexNumbers();
    for(size_t p=0; p<decorPolygons.size();p++)
      decorPolygons[p].drawVertexNumbers();
    for(size_t p=0; p<shellPolygons.size();p++)
      for(size_t q=0; q<shellPolygons[p].size();q++)
	shellPolygons[p][q].drawVertexNumbers();
  }


  if (settings.get_boolean("Display","ShowLayerOverhang")) {
    draw_polys(bridgePillars,        GL_LINE_LOOP, 3, 3, YELLOW,0.7, randomized);
    if (previous!=NULL) {
      vector<Poly> overhangs = getOverhangs();
      draw_polys(overhangs, GL_LINE_LOOP, 1, 3, VIOLET, 0.8, randomized);
      //draw_polys_surface(overhangs, Min, Max, Z, thickness/5, VIOLET , 0.5);

      Cairo::RefPtr<Cairo::ImageSurface> surface;
      Cairo::RefPtr<Cairo::Context>      context;
      if (rasterpolys(overhangs, Min, Max, thickness/5, surface, context))
	if(surface!=0) {
	  glColor4f(RED[0],RED[1],RED[2], 0.5);
	  glDrawCairoSurface(surface, Min, Max, Z);
	  glColor4f(RED[0],RED[1],RED[2], 0.6);
	  glPointSize(3);
 	  glBegin(GL_POINTS);
 	  for (double x = Min.x(); x<Max.x(); x+=thickness)
	    for (double y = Min.y(); y<Max.y(); y+=thickness)
	      if (getCairoSurfaceDatapoint(surface, Min, Max, Vector2d(x,y))!=0)
	  	glVertex3d(x,y,Z);
	  glEnd();
	}
    }
  }

#if 0
  // test point-in-polygons
  const vector<Poly> *polys = GetOuterShell();
  glColor4f(RED[0],RED[1],RED[2], 0.6);
  glPointSize(3);
  glBegin(GL_POINTS);
  for (double x = Min.x(); x<Max.x(); x+=thickness/1)
    for (double y = Min.y(); y<Max.y(); y+=thickness/1) {
      bool inpoly = false;
      for (uint i=0; i<polys->size(); i++) {
	if ((*polys)[i].vertexInside(Vector2d(x,y))){
	  inpoly=true; break;
	}
      }
      if (inpoly)
	glVertex3d(x,y,Z);
      // else
      //   glColor4f(0.3,0.3,0.3, 0.6);
    }
  glEnd();
#endif

}
コード例 #21
0
void SdSelfMsgCanvas::draw(QPainter & p) {
    const QRect r = rect();
    int ah = (r.height() - 1 - 1 - 2 - 1 - 1)/2;
    int he = r.top() + 1 + 2 + ah + 1;
    FILE * fp = svg();
    p.setRenderHint(QPainter::Antialiasing, true);
    if (itsType == UmlSelfReturnMsg)
        p.setPen(::Qt::DotLine);

    p.drawLine(r.left() + 1, r.top() + 1, r.right() - 1, r.top() + 1);



    //p.lineTo(r.right() - 1, he);
    p.drawLine(r.right()-1, r.top() + 1, r.right() - 1, he);
    //p.lineTo(r.left() + 1, he);
    p.drawLine(r.right()-1, he, r.left() + 1, he);

    if (fp != 0) {
        fputs("<g>\n\t<path fill=\"none\" stroke=\"black\" stroke-opacity=\"1\"", fp);
        if (itsType == UmlSelfReturnMsg)
            fputs(" stroke-dasharray=\"4,4\"", fp);
        fprintf(fp, " d=\"M %d %d L %d %d L %d %d L %d %d\" />\n",
                r.left() + 1, r.top() + 1, r.right() - 1, r.top() + 1,
                r.right() - 1, he,
                r.left() + 1, he);
    }

    if (itsType == UmlSyncSelfMsg) {
        Q3PointArray poly(3);
        QBrush brsh = p.brush();

        p.setBrush(Qt::black);
        poly.setPoint(0, r.left() + 1, he);
        poly.setPoint(1, r.left() + 1 + ah, he + ah);
        poly.setPoint(2, r.left() + 1 + ah, he - ah);
        p.drawPolygon(poly/*, TRUE*/);
        p.setBrush(brsh);

        if (fp != 0) {
            draw_poly(fp, poly, UmlBlack, FALSE);
            fputs("</g>\n", fp);
        }
    }
    else {
        if (itsType == UmlSelfReturnMsg)
            p.setPen(::Qt::SolidLine);

        //p.lineTo(r.left() + 1 + ah, he + ah);
        p.drawLine(r.left()+1+ah, he - ah, r.left() + 1 + ah, he + ah); // assuming last call poly.setPoint
        p.drawLine(r.left() + 1, he, r.left() + 1 + ah, he - ah);

        if (fp != 0)
            fprintf(fp, "\t<path fill=\"none\" stroke=\"black\" stroke-opacity=\"1\""
                    " d=\"M %d %d L %d %d L %d %d\" />\n"
                    "</g>\n",
                    r.left() + 1 + ah, he + ah,
                    r.left() + 1, he,
                    r.left() + 1 + ah, he - ah);
    }

    if (selected())
        show_mark(p, r);
}
コード例 #22
0
void ActivityActionCanvas::draw(QPainter & p) {
  if (! visible()) return;
  
  QRect r = rect();
  QBrush brsh = p.brush();
  QColor bckgrnd = p.backgroundColor();
  
  p.setBackgroundMode((used_color == UmlTransparent)
		      ? ::Qt::TransparentMode
		      : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  
  p.setBackgroundColor(co);
  
  const ActivityActionData * data =
    (ActivityActionData *) browser_node->get_data();
  const int shadow = the_canvas()->shadow();
  int margin;
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);  
  
  switch (data->get_action_kind()) {
  case UmlAcceptEventAction:
    if (((AcceptEventAction *) data->get_action())->timeevent) {
      // don't draw shadow
      margin = (int) (21 * the_canvas()->zoom());
      
      int t = (r.y() + r.bottom() - margin)/2;
      
      p.setPen(::Qt::SolidLine);
      p.setBackgroundMode(::Qt::TransparentMode);
      p.drawLine(r.right() - margin, t, r.right() - 1, t);
      p.lineTo(r.right() - margin - 1, t + margin);
      p.lineTo(r.right() - 1, t + margin);
      p.lineTo(r.right() - margin - 1, t);

      if (fp != 0) {
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - margin, t, r.right() - 1, t);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - 1, t, r.right() - margin - 1, t + margin);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - margin - 1, t + margin, r.right() - 1, t + margin);
	fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		" x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		r.right() - 1, t + margin, r.right() - margin - 1, t);
      }

      r.setWidth(r.width() - margin - 1);
      margin = (int) (3 * the_canvas()->zoom());
    }
    else {
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4;
      
      QPointArray a(6);
      
      a.setPoint(0, r.x(), r.y());
      a.setPoint(1, r.right(), r.y());
      a.setPoint(2, r.right(), r.bottom());
      a.setPoint(3, r.x(), r.bottom());
      a.setPoint(4, r.x() + margin, (r.y() + r.bottom())/2);
      a.setPoint(5, r.x(), r.y());
  
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);

	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.x() + shadow, r.y() + shadow);
	  b.setPoint(1, r.right() + shadow, r.y() + shadow);
	  b.setPoint(2, r.right() + shadow, r.bottom() + shadow);
	  b.setPoint(3, r.x() + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.x() + margin + shadow, (r.y() + r.bottom())/2 + shadow);
	  b.setPoint(5, r.x() + shadow, r.y() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);

	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);

	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      r.setLeft(r.left() + margin);
      margin = (int) (6 * the_canvas()->zoom());
    }
    break;
  case UmlSendSignalAction:
  case UmlBroadcastSignalAction:
    {
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      margin = ((r.height() < r.width()) ? r.height() : r.width()) / 4;
      
      QPointArray a(6);
      
      a.setPoint(0, r.x(), r.y());
      a.setPoint(1, r.right() - margin, r.y());
      a.setPoint(2, r.right(), (r.y() + r.bottom())/2);
      a.setPoint(3, r.right() - margin, r.bottom());
      a.setPoint(4, r.x(), r.bottom());
      a.setPoint(5, r.x(), r.y());
  
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.x() + shadow, r.y() + shadow);
	  b.setPoint(1, r.right() - margin + shadow, r.y() + shadow);
	  b.setPoint(2, r.right() + shadow, (r.y() + r.bottom())/2 + shadow);
	  b.setPoint(3, r.right() - margin + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.x() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.x() + shadow, r.y() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);

	  if (fp != 0)
	    draw_shadow(fp, b);
	}
      
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);

	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      r.setWidth(r.width() - margin);
      margin = (int) (6 * the_canvas()->zoom());
    }
    break;
  default:      
    margin = (int) (9 * the_canvas()->zoom());
      
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
      p.setPen(::Qt::NoPen);
      p.setBrush(::Qt::darkGray);
      p.drawRoundRect(r.left() + shadow, r.top() + shadow, r.width(), r.height());
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n",
		::Qt::darkGray.rgb()&0xffffff,
		r.left() + shadow, r.top() + shadow, r.width() - 1, r.height() - 1);

      p.setPen(::Qt::SolidLine);
    }
    
    p.setBrush(co);
    p.drawRoundRect(r);

    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"10\" />\n",
	      svg_color(used_color),
	      r.left(), r.top(), r.width() - 1, r.height() - 1);
    
    if (data->get_action_kind() == UmlCallBehaviorAction) {
      BrowserNode * behavior =
	((CallBehaviorAction *) data->get_action())->behavior;
      
      if ((behavior != 0) && (behavior->get_type() == UmlActivity)) {
	int l = (int) (6 * the_canvas()->zoom());
	int lx = r.right() - margin - l;
	int ty = r.bottom() - margin - l;
	int mx = lx + l;
	int my = ty + l;
	int rx = mx + l;
	int by = my + l;
	
	p.drawLine(lx, my, rx, my);
	p.drawLine(mx, ty, mx, by);
	p.drawLine(lx, my, lx, by);
	p.drawLine(rx, my, rx, by);

	if (fp != 0) {
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  lx, my, rx, my);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  mx, ty, mx, by);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  lx, my, lx, by);
	  fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
		  " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
		  rx, my, rx, by);
	}
      }
    }
    break;
  }
  
  p.setFont(the_canvas()->get_font(UmlNormalFont));
  p.drawText(r.x() + margin,
	     r.y() + margin,
	     r.width() - margin - margin,
	     r.height() - margin - margin,
	     align, s);
  
  if (fp != 0) {
    fputs("</g>\n", fp);
    draw_text(r.x() + margin,
	      r.y() + margin,
	      r.width() - margin - margin,
	      r.height() - margin - margin,
	      align, s, p.font(), fp);
  }
  
  p.setBackgroundColor(bckgrnd);
  p.setBrush(brsh);
  
  if (selected())
    show_mark(p, rect());
}
コード例 #23
0
ファイル: graphics.c プロジェクト: justinzane/navit
void
graphics_redraw(struct container *co)
{
	int scale=transform_get_scale(co->trans);
	int i,slimit=255,tlimit=255,plimit=255;
	int bw[4],w[4],t[4];
	struct display_list **disp=co->disp;
	struct graphics *gra=co->gra;

#if 0
	printf("scale=%d center=0x%lx,0x%lx mercator scale=%f\n", scale, co->trans->center.x, co->trans->center.y, transform_scale(co->trans->center.y));
#endif
	
	display_free(co->disp, display_end);

	transform_setup_source_rect(co->trans);

	gra->draw_mode(gra, draw_mode_begin);
	for (i = 0 ; i < data_window_type_end; i++) {
		data_window_begin(co->data_window[i]);	
	}
	gra->gc_set_linewidth(gra->gc[GC_RAIL], 3);

	bw[0]=0;
	bw[1]=0;
	bw[2]=0;
	bw[3]=0;
	w[0]=1;
	w[1]=1;
	w[2]=1;
	w[3]=1;
	t[0]=0xf;
	t[1]=0xf;
	t[2]=0xf;
	t[3]=0xf;
	if (scale < 2) {
		tlimit=0xff;
		slimit=0xff;
		bw[0]=17;
		w[0]=15;
		bw[1]=19;
		w[1]=17;
		bw[2]=19;
		w[2]=17;
		bw[3]=21;
		w[3]=17;
	} else if (scale < 4) {
		tlimit=0xff;
		slimit=0xff;
		bw[0]=11;
		w[0]=9;
		bw[1]=13;
		w[1]=11;
		bw[2]=13;
		w[2]=11;
		bw[3]=15;
		w[3]=11;
	} else if (scale < 8) {
		tlimit=0xff;
		slimit=0xff;
		bw[0]=5;
		w[0]=3;
		bw[1]=11;
		w[1]=9;
		bw[2]=11;
		w[2]=9;
		bw[3]=13;
		w[3]=9;
		t[0]=0xa;
		t[1]=0xf;
	} else if (scale < 16) {
		tlimit=0xff;
		slimit=0xff;
		bw[1]=9;
		w[1]=7;
		bw[2]=9;
		w[2]=7;
		bw[3]=11;
		w[3]=7;
		t[0]=0x9;
		t[1]=0xe;
	} else if (scale < 32) {
		tlimit=0xff;
		slimit=0xff;
		bw[1]=5;
		w[1]=3;
		bw[2]=5;
		w[2]=3;
		bw[3]=5;
		w[3]=3;
		t[0]=0x8;
		t[1]=0xb;
	} else if (scale < 64) {
		tlimit=0xf;
		slimit=0x6;
		bw[1]=5;
		w[1]=3;
		bw[2]=5;
		w[2]=3;
		bw[3]=5;
		w[3]=3;
		t[0]=0x8;
		t[1]=0xa;
	} else if (scale < 128) {
		tlimit=0xc;
		slimit=0x6;
		plimit=0x1e;
		w[1]=3;
		w[2]=3;
		bw[3]=5;
		w[3]=3;
		t[0]=0x7;
		t[1]=0xa;
	} else if (scale < 256) {
		tlimit=0xb;
		slimit=0x5;
		plimit=0x1a;
		w[2]=3;
		bw[3]=5;
		w[3]=3;
		t[0]=0x7;
		t[1]=0x8;
	} else if (scale < 512) {
		tlimit=0x9;
		slimit=0x5;
		plimit=0x14;
		w[1]=0;
		w[2]=1;
		bw[3]=3;
		w[3]=1;
		t[0]=0x4;
		t[1]=0x7;
	} else if (scale < 1024) {
		tlimit=0x8;
		slimit=0x4;
		slimit=0x4;
		plimit=0x11;
		w[1]=0;
		w[2]=1;
		bw[3]=3;
		w[3]=1;
		t[0]=0x3;
		t[1]=0x5;
	} else if (scale < 2048) {
		tlimit=0x5;
		slimit=0x3;
		plimit=0x10;
		bw[3]=3;
		w[3]=1;
		t[0]=0x2;
		t[1]=0x4;
	} else if (scale < 4096) {
		bw[3]=3;
		w[3]=1;
		tlimit=0x4;
		slimit=0x2;
		plimit=0xf;
		t[0]=0x2;
		t[1]=0x3;
	} else if (scale < 8192) {
		bw[3]=3;
		w[3]=1;
		tlimit=0x3;
		slimit=0x2;
		plimit=0xf;
		t[0]=0x1;
		t[1]=0x2;
	} else {
		bw[3]=3;
		w[3]=1;
		tlimit=0x2;
		slimit=0x2;
		plimit=0xf;
		t[0]=0x1;
		t[1]=0x4;
	}
	gra->gc_set_linewidth(gra->gc[GC_STREET_SMALL], w[0]);
	gra->gc_set_linewidth(gra->gc[GC_STREET_NO_PASS], w[0]);
	gra->gc_set_linewidth(gra->gc[GC_STREET_SMALL_B], bw[0]);
	gra->gc_set_linewidth(gra->gc[GC_STREET_MID], w[1]);
	gra->gc_set_linewidth(gra->gc[GC_STREET_MID_B], bw[1]);
	gra->gc_set_linewidth(gra->gc[GC_STREET_BIG], w[2]);
	gra->gc_set_linewidth(gra->gc[GC_STREET_BIG_B], bw[2]);
	gra->gc_set_linewidth(gra->gc[GC_STREET_BIG2], w[3]);
	gra->gc_set_linewidth(gra->gc[GC_STREET_BIG2_B], bw[3]);
	gra->gc_set_linewidth(gra->gc[GC_STREET_ROUTE], w[3]+7+w[3]/2);

	profile_timer(NULL);
	graphics_draw(co->map_data, file_border_ply, co, display_rail, plimit, 48, poly_draw_block);
	graphics_draw(co->map_data, file_woodland_ply, co, display_wood, plimit, 48, poly_draw_block);
	graphics_draw(co->map_data, file_other_ply, co, display_other, plimit, 48, poly_draw_block);
	graphics_draw(co->map_data, file_town_twn, co, display_town, tlimit, 48, town_draw_block);
	graphics_draw(co->map_data, file_water_ply, co, display_water, plimit, 48, poly_draw_block);
	graphics_draw(co->map_data, file_sea_ply, co, display_sea, plimit, 48, poly_draw_block);
	/* todo height, tunnel, bridge, street_bti ??? */
#if 0
	graphics_draw(co->map_data, file_height_ply, co, display_other1, plimit, 48, poly_draw_block);
#endif
	if (scale < 256) {
		graphics_draw(co->map_data, file_rail_ply, co, display_rail, plimit, 48, poly_draw_block);
	}
	profile_timer("map_draw");
	plugin_call_draw(co);
	profile_timer("plugin");
#if 0
	draw_poly(map, &co->d_tunnel_ply, "Tunnel", 0, 11, plimit);
#endif
	graphics_draw(co->map_data, file_street_str, co, display_street, slimit, 7, street_draw_block);
  
	display_draw(disp[display_sea], gra, gra->gc[GC_WATER_FILL], NULL); 
	display_draw(disp[display_wood], gra, gra->gc[GC_WOOD], NULL); 
	display_draw(disp[display_other], gra, gra->gc[GC_TOWN_FILL], gra->gc[GC_TOWN_LINE]); 
	display_draw(disp[display_other1], gra, gra->gc[GC_BUILDING], NULL); 
	display_draw(disp[display_other2], gra, gra->gc[GC_BUILDING_2], NULL); 
	display_draw(disp[display_other3], gra, gra->gc[GC_PARK], NULL); 
	display_draw(disp[display_water], gra, gra->gc[GC_WATER_FILL], gra->gc[GC_WATER_LINE]); 
	display_draw(disp[display_rail], gra, gra->gc[GC_RAIL], NULL); 
	street_route_draw(co);
	display_draw(disp[display_street_route], gra, gra->gc[GC_STREET_ROUTE], NULL); 
	if (bw[0]) {
		display_draw(disp[display_street_no_pass], gra, gra->gc[GC_STREET_SMALL_B], NULL); 
		display_draw(disp[display_street], gra, gra->gc[GC_STREET_SMALL_B], NULL); 
	}
	if (bw[1]) 
		display_draw(disp[display_street1], gra, gra->gc[GC_STREET_MID_B], NULL); 
	if (bw[2])
		display_draw(disp[display_street2], gra, gra->gc[GC_STREET_BIG_B], NULL); 
	if (bw[3])
		display_draw(disp[display_street3], gra, gra->gc[GC_STREET_BIG2_B], NULL); 
	if (w[0]) {
		display_draw(disp[display_street_no_pass], gra, gra->gc[GC_STREET_NO_PASS], NULL); 
		display_draw(disp[display_street], gra, gra->gc[GC_STREET_SMALL], NULL); 
	}
	if (w[1]) 
		display_draw(disp[display_street1], gra, gra->gc[GC_STREET_MID], gra->gc[GC_BLACK]); 
	display_draw(disp[display_street2], gra, gra->gc[GC_STREET_BIG], gra->gc[GC_BLACK]); 
	display_draw(disp[display_street3], gra, gra->gc[GC_STREET_BIG2], gra->gc[GC_BLACK]); 
	if (w[3] > 1) 
		display_draw(disp[display_street3], gra, gra->gc[GC_STREET_BIG2_L], NULL); 

	display_draw(disp[display_poi], gra, gra->gc[GC_BLACK], NULL); 


	profile_timer("display_draw");

	if (scale < 2) {
		display_labels(disp[display_street], gra, gra->gc[GC_TEXT_FG], gra->gc[GC_TEXT_BG], gra->font[1]);
		display_labels(disp[display_street1], gra, gra->gc[GC_TEXT_FG], gra->gc[GC_TEXT_BG], gra->font[1]);
	}
	else {
		display_labels(disp[display_street], gra, gra->gc[GC_TEXT_FG], gra->gc[GC_TEXT_BG], gra->font[0]);
		display_labels(disp[display_street1], gra, gra->gc[GC_TEXT_FG], gra->gc[GC_TEXT_BG], gra->font[0]);
	}
	display_labels(disp[display_street2], gra, gra->gc[GC_TEXT_FG], gra->gc[GC_TEXT_BG], gra->font[0]);
	display_labels(disp[display_street3], gra, gra->gc[GC_TEXT_FG], gra->gc[GC_TEXT_BG], gra->font[0]);

	for (i = display_town+t[1] ; i < display_town+0x10 ; i++) 
		display_labels(disp[i], gra, gra->gc[GC_TEXT_FG], gra->gc[GC_TEXT_BG], gra->font[0]);
	for (i = display_town+t[0] ; i < display_town+t[1] ; i++) 
		display_labels(disp[i], gra, gra->gc[GC_TEXT_FG], gra->gc[GC_TEXT_BG], gra->font[1]);
	for (i = display_town ; i < display_town+t[0] ; i++) 
		display_labels(disp[i], gra, gra->gc[GC_TEXT_FG], gra->gc[GC_TEXT_BG], gra->font[2]);

	for (i = display_town ; i < display_town+0x10 ; i++) 
		display_draw(disp[i], gra, gra->gc[GC_BLACK], NULL); 
	display_draw(disp[display_bti], gra, gra->gc[GC_BLACK], NULL); 
	profile_timer("labels");
	gra->draw_mode(gra, draw_mode_end);
	for (i = 0 ; i < data_window_type_end; i++) {
		data_window_end(co->data_window[i]);	
	}
#if 0
	map_scrollbars_update(map);
#endif
}
コード例 #24
0
int main()
{
  /* request auto detection */
int gdriver = DETECT, gmode, errorcode;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)  /* an error occurred */
{
   printf("Graphics error: %s\n", grapherrormsg(errorcode));
   printf("Press any key to halt:");
   getch();
   exit(1); /* terminate with an error code */
}
int i;
clrscr();
cout<<"\nEnter no. of Sides:: ";
cin>>n;
cout<<"\nEnter the Co-ordinate of Vertices::";
for(i=0;i<n;i++)
{
    cout<<"\n"<<i+1<<"::";
    cin>>x[i]>>y[i];

}
   draw_poly();
   getch();
   cleardevice();

   clrscr();
   int k;
   do
   {
    clrscr();
    cleardevice();
    cout<<"\n1)Translate\n2)Rotate\n3)Scale\n4)Exit.";
    cout<<"\nEnter Ur Choice::";

    cin>>k;
    switch(k)
    {
        case 1:
            cout<<"\nFor x-axis::";
            cin>>x1;
            cout<<"\nFor y-axis::";
            cin>>y1;
            translate(x1,y1);
            draw_poly();
            getch();
            cleardevice();
            break;

        case 2:
            cout<<"\nEnter the Angle::";
            cin>>theta;
            rotate(theta);
            draw_poly();
            getch();
            cleardevice();
            break;

        case 3:
            cout<<"\nFor x-axis::";
            cin>>x1;
            cout<<"\nFor y-axis::";
            cin>>y1;
            scale(x1,y1);
            draw_poly();
            getch();
            cleardevice();
            break;

    }
    } while(k!=4);
   return 0;
}