void showcounter(int x,int y,int i)
{
 int col;

 switch(i)
 {
  case 0:col=BLUE;
	 break;
  case 1:col=YELLOW;
	 break;
  case 2:col=GREEN;
	 break;
  case 3:col=MAGENTA;
	 break;
 }

 setlinestyle(0,0,1);
 setfillstyle(1,col);
 fillellipse(x*48+24,y*48+24,20,20);
 settextstyle(3,0,2);
 settextjustify(1,1);
 setcolor(RED);
 outtextxy(x*48+24,y*48+24,pini[i]);
}
void drawFeature(unsigned i, char mini)
{
    t_point* featurePoints;
    if(mini)
    {
        allLargeFeatures[i].updatepolyMiniPoints();
        featurePoints = allLargeFeatures[i].getpolyPoints();
        i = allLargeFeatures[i].getID();
    } else {
        featurePoints = allFeatures[i].getpolyPoints();
    }
    
    //closed features are polygons
    if (allFeatures[i].isClosed())
    {
        setcolor(colorScheme[allFeatures[i].getcolorID()][colorMode]);
        fillpoly(featurePoints, allFeatures[i].getnPoints());

    } else { //open features are lines
        setcolor(colorScheme[allFeatures[i].getcolorID()][colorMode]);
        if(mini)
        {
            for (unsigned j = 0; j < allFeatures[i].getnPoints() - 1; j ++) {
                drawline(featurePoints[j],featurePoints[j+1]);
            }
        } else {
            setlinewidth(floor(allFeatures[i].getlineWidth()/trueScreen.get_width()));
            setlinestyle(allFeatures[i].getlineStyle());
            for (unsigned j = 0; j < allFeatures[i].getnPoints() - 1; j ++) {
                drawline(featurePoints[j],featurePoints[j+1]);
                fillarc(featurePoints[j].x,featurePoints[j].y,allFeatures[i].getlineWidth()/2200,0,360);
            }
            fillarc(featurePoints[allFeatures[i].getnPoints() - 1].x,featurePoints[allFeatures[i].getnPoints() - 1].y,allFeatures[i].getlineWidth()/2200,0,360);
        }           
    }
}
Exemple #3
0
/* main call for drawing a single NLA-strip */
static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, View2D *v2d, float yminc, float ymaxc)
{
	short nonSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0);
	float color[3];
	
	/* get color of strip */
	nla_strip_get_color_inside(adt, strip, color);
	
	/* draw extrapolation info first (as backdrop)
	 *	- but this should only be drawn if track has some contribution
	 */
	if ((strip->extendmode != NLASTRIP_EXTEND_NOTHING) && (nonSolo == 0)) {
		/* enable transparency... */
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
		
		switch (strip->extendmode) {
			/* since this does both sides, only do the 'before' side, and leave the rest to the next case */
			case NLASTRIP_EXTEND_HOLD: 
				/* only need to draw here if there's no strip before since 
				 * it only applies in such a situation 
				 */
				if (strip->prev == NULL) {
					/* set the drawing color to the color of the strip, but with very faint alpha */
					glColor4f(color[0], color[1], color[2], 0.15f);
					
					/* draw the rect to the edge of the screen */
					glBegin(GL_QUADS);
					glVertex2f(v2d->cur.xmin, yminc);
					glVertex2f(v2d->cur.xmin, ymaxc);
					glVertex2f(strip->start, ymaxc);
					glVertex2f(strip->start, yminc);
					glEnd();
				}
				/* fall-through */

			/* this only draws after the strip */
			case NLASTRIP_EXTEND_HOLD_FORWARD: 
				/* only need to try and draw if the next strip doesn't occur immediately after */
				if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end) == 0)) {
					/* set the drawing color to the color of the strip, but this time less faint */
					glColor4f(color[0], color[1], color[2], 0.3f);
					
					/* draw the rect to the next strip or the edge of the screen */
					glBegin(GL_QUADS);
					glVertex2f(strip->end, yminc);
					glVertex2f(strip->end, ymaxc);
						
					if (strip->next) {
						glVertex2f(strip->next->start, ymaxc);
						glVertex2f(strip->next->start, yminc);
					}
					else {
						glVertex2f(v2d->cur.xmax, ymaxc);
						glVertex2f(v2d->cur.xmax, yminc);
					}
					glEnd();
				}
				break;
		}
		
		glDisable(GL_BLEND);
	}
	
	
	/* draw 'inside' of strip itself */
	if (nonSolo == 0) {
		/* strip is in normal track */
		glColor3fv(color);
		UI_draw_roundbox_corner_set(UI_CNR_ALL); /* all corners rounded */
		
		UI_draw_roundbox_shade_x(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1);
	}
	else {
		/* strip is in disabled track - make less visible */
		glColor4f(color[0], color[1], color[2], 0.1f);
		
		glEnable(GL_BLEND);
		glRectf(strip->start, yminc, strip->end, ymaxc);
		glDisable(GL_BLEND);
	}
	
	
	/* draw strip's control 'curves'
	 *	- only if user hasn't hidden them...
	 */
	if ((snla->flag & SNLA_NOSTRIPCURVES) == 0)
		nla_draw_strip_curves(strip, yminc, ymaxc);
	
	
	/* draw strip outline 
	 *	- color used here is to indicate active vs non-active
	 */
	if (strip->flag & NLASTRIP_FLAG_ACTIVE) {
		/* strip should appear 'sunken', so draw a light border around it */
		glColor3f(0.9f, 1.0f, 0.9f); // FIXME: hardcoded temp-hack colors
	}
	else {
		/* strip should appear to stand out, so draw a dark border around it */
		glColor3f(0.0f, 0.0f, 0.0f);
	}
	
	/* - line style: dotted for muted */
	if (strip->flag & NLASTRIP_FLAG_MUTED)
		setlinestyle(4);
		
	/* draw outline */
	UI_draw_roundbox_shade_x(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1);
	
	/* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */
	if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f) == 0) {
		float repeatLen = (strip->actend - strip->actstart) * strip->scale;
		int i;
		
		/* only draw lines for whole-numbered repeats, starting from the first full-repeat
		 * up to the last full repeat (but not if it lies on the end of the strip)
		 */
		for (i = 1; i < strip->repeat; i++) {
			float repeatPos = strip->start + (repeatLen * i);
			
			/* don't draw if line would end up on or after the end of the strip */
			if (repeatPos < strip->end)
				fdrawline(repeatPos, yminc + 4, repeatPos, ymaxc - 4);
		}
	}
	/* or if meta-strip, draw lines delimiting extents of sub-strips (in same color as outline, if more than 1 exists) */
	else if ((strip->type == NLASTRIP_TYPE_META) && (strip->strips.first != strip->strips.last)) {
		NlaStrip *cs;
		float y = (ymaxc - yminc) / 2.0f + yminc;
		
		/* only draw first-level of child-strips, but don't draw any lines on the endpoints */
		for (cs = strip->strips.first; cs; cs = cs->next) {
			/* draw start-line if not same as end of previous (and only if not the first strip) 
			 *	- on upper half of strip
			 */
			if ((cs->prev) && IS_EQF(cs->prev->end, cs->start) == 0)
				fdrawline(cs->start, y, cs->start, ymaxc);
				
			/* draw end-line if not the last strip
			 *	- on lower half of strip
			 */
			if (cs->next) 
				fdrawline(cs->end, yminc, cs->end, y);
		}
	}
	
	/* reset linestyle */
	setlinestyle(0);
} 
Exemple #4
0
void Bunches::draw_all(Logic_Nim &nim) {
	setlinestyle(0, 0, 1);
	for (int i = 0; i < Logic_Nim::num_of_bunches; i++)
		Bunches::draw_bunch(i, nim);
}
Exemple #5
0
/* Draw indicators which show the value calculated from the driver, 
 * and how this is mapped to the value that comes out of it. This
 * is handy for helping users better understand how to interpret
 * the graphs, and also facilitates debugging. 
 */
static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
{
	ChannelDriver *driver = fcu->driver;
	View2D *v2d = &ac->ar->v2d;
	short mapping_flag = ANIM_get_normalization_flags(ac);
	float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag);
	
	/* for now, only show when debugging driver... */
	//if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0)
	//	return;
	
	/* No curve to modify/visualise the result? 
	 * => We still want to show the 1-1 default... 
	 */
	if ((fcu->totvert == 0) && BLI_listbase_is_empty(&fcu->modifiers)) {
		float t;
		
		/* draw with thin dotted lines in style of what curve would have been */
		glColor3fv(fcu->color);
		
		setlinestyle(20);
		glLineWidth(2.0f);
		
		/* draw 1-1 line, stretching just past the screen limits 
		 * NOTE: we need to scale the y-values to be valid for the units
		 */
		glBegin(GL_LINES);
			t = v2d->cur.xmin;
			glVertex2f(t, t * unitfac);
			
			t = v2d->cur.xmax;
			glVertex2f(t, t * unitfac); 
		glEnd();
		
		/* cleanup line drawing */
		setlinestyle(0);
		glLineWidth(1.0f);
	}
	
	/* draw driver only if actually functional */
	if ((driver->flag & DRIVER_FLAG_INVALID) == 0) {
		/* grab "coordinates" for driver outputs */
		float x = driver->curval;
		float y = fcu->curval * unitfac;
		
		/* only draw indicators if the point is in range*/
		if (x >= v2d->cur.xmin) {
			float co[2];
			
			/* draw dotted lines leading towards this point from both axes ....... */
			glColor3f(0.9f, 0.9f, 0.9f);
			setlinestyle(5);
			
			glBegin(GL_LINES);
				/* x-axis lookup */
				co[0] = x;
				
				if (y >= v2d->cur.ymin) {
					co[1] = v2d->cur.ymin - 1.0f;
					glVertex2fv(co);
					
					co[1] = y;
					glVertex2fv(co);
				}
				
				/* y-axis lookup */
				co[1] = y;
				
				co[0] = v2d->cur.xmin - 1.0f;
				glVertex2fv(co);
				
				co[0] = x;
				glVertex2fv(co);
			glEnd();
			
			setlinestyle(0);
			
			/* x marks the spot .................................................... */
			/* -> outer frame */
			glColor3f(0.9f, 0.9f, 0.9f);
			glPointSize(7.0);
			
			glBegin(GL_POINTS);
				glVertex2f(x, y);
			glEnd();
			
			/* inner frame */
			glColor3f(0.9f, 0.0f, 0.0f);
			glPointSize(3.0);
			
			glBegin(GL_POINTS);
				glVertex2f(x, y);
			glEnd();
			
			glPointSize(1.0f);
		}
	}
}
static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *arg)
{
	Scene *scene = CTX_data_scene(C);
	UnitSettings *unit = &scene->unit;
	RulerItem *ruler_item;
	RulerInfo *ruler_info = arg;
	RegionView3D *rv3d = ruler_info->ar->regiondata;
//	ARegion *ar = ruler_info->ar;
	const float cap_size = 4.0f;
	const float bg_margin = 4.0f * U.pixelsize;
	const float bg_radius = 4.0f * U.pixelsize;
	const float arc_size = 64.0f * U.pixelsize;
#define ARC_STEPS 24
	const int arc_steps = ARC_STEPS;
	int i;
	//unsigned int color_act = 0x666600;
	unsigned int color_act = 0xffffff;
	unsigned int color_base = 0x0;
	unsigned char color_back[4] = {0xff, 0xff, 0xff, 0x80};
	unsigned char color_text[3];
	unsigned char color_wire[3];

	/* anti-aliased lines for more consistent appearance */
	glEnable(GL_LINE_SMOOTH);

	BLF_enable(blf_mono_font, BLF_ROTATION);
	BLF_size(blf_mono_font, 14 * U.pixelsize, U.dpi);
	BLF_rotation(blf_mono_font, 0.0f);

	UI_GetThemeColor3ubv(TH_TEXT, color_text);
	UI_GetThemeColor3ubv(TH_WIRE, color_wire);

	for (ruler_item = ruler_info->items.first, i = 0; ruler_item; ruler_item = ruler_item->next, i++) {
		const bool is_act = (i == ruler_info->item_active);
		float dir_ruler[2];
		float co_ss[3][2];
		int j;

		/* should these be checked? - ok for now not to */
		for (j = 0; j < 3; j++) {
			ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP);
		}

		glEnable(GL_BLEND);

		cpack(is_act ? color_act : color_base);

		if (ruler_item->flag & RULERITEM_USE_ANGLE) {
			glBegin(GL_LINE_STRIP);
			for (j = 0; j < 3; j++) {
				glVertex2fv(co_ss[j]);
			}
			glEnd();
			cpack(0xaaaaaa);
			setlinestyle(3);
			glBegin(GL_LINE_STRIP);
			for (j = 0; j < 3; j++) {
				glVertex2fv(co_ss[j]);
			}
			glEnd();
			setlinestyle(0);

			/* arc */
			{
				float dir_tmp[3];
				float co_tmp[3];
				float arc_ss_coords[ARC_STEPS + 1][2];

				float dir_a[3];
				float dir_b[3];
				float quat[4];
				float axis[3];
				float angle;
				const float px_scale = (ED_view3d_pixel_size(rv3d, ruler_item->co[1]) *
				                        min_fff(arc_size,
				                                len_v2v2(co_ss[0], co_ss[1]) / 2.0f,
				                                len_v2v2(co_ss[2], co_ss[1]) / 2.0f));

				sub_v3_v3v3(dir_a, ruler_item->co[0], ruler_item->co[1]);
				sub_v3_v3v3(dir_b, ruler_item->co[2], ruler_item->co[1]);
				normalize_v3(dir_a);
				normalize_v3(dir_b);

				cross_v3_v3v3(axis, dir_a, dir_b);
				angle = angle_normalized_v3v3(dir_a, dir_b);

				axis_angle_to_quat(quat, axis, angle / arc_steps);

				copy_v3_v3(dir_tmp, dir_a);

				glColor3ubv(color_wire);

				for (j = 0; j <= arc_steps; j++) {
					madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale);
					ED_view3d_project_float_global(ar, co_tmp, arc_ss_coords[j], V3D_PROJ_TEST_NOP);
					mul_qt_v3(quat, dir_tmp);
				}

				glEnableClientState(GL_VERTEX_ARRAY);
				glVertexPointer(2, GL_FLOAT, 0, arc_ss_coords);
				glDrawArrays(GL_LINE_STRIP, 0, arc_steps + 1);
				glDisableClientState(GL_VERTEX_ARRAY);
			}

			/* text */
			{
				char numstr[256];
				float numstr_size[2];
				float pos[2];
				const int prec = 2;  /* XXX, todo, make optional */

				ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec);

				BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]);

				pos[0] = co_ss[1][0] + (cap_size * 2.0f);
				pos[1] = co_ss[1][1] - (numstr_size[1] / 2.0f);

				/* draw text (bg) */
				glColor4ubv(color_back);
				uiSetRoundBox(UI_CNR_ALL);
				uiRoundBox(pos[0] - bg_margin,                  pos[1] - bg_margin,
				           pos[0] + bg_margin + numstr_size[0], pos[1] + bg_margin + numstr_size[1],
				           bg_radius);
				/* draw text */
				glColor3ubv(color_text);
				BLF_position(blf_mono_font, pos[0], pos[1], 0.0f);
				BLF_rotation(blf_mono_font, 0.0f);
				BLF_draw(blf_mono_font, numstr, sizeof(numstr));
			}

			/* capping */
			{
				float rot_90_vec_a[2];
				float rot_90_vec_b[2];
				float cap[2];

				sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[1]);
				rot_90_vec_a[0] = -dir_ruler[1];
				rot_90_vec_a[1] =  dir_ruler[0];
				normalize_v2(rot_90_vec_a);

				sub_v2_v2v2(dir_ruler, co_ss[1], co_ss[2]);
				rot_90_vec_b[0] = -dir_ruler[1];
				rot_90_vec_b[1] =  dir_ruler[0];
				normalize_v2(rot_90_vec_b);

				glEnable(GL_BLEND);

				glColor3ubv(color_wire);

				glBegin(GL_LINES);

				madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size);
				glVertex2fv(cap);
				madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, -cap_size);
				glVertex2fv(cap);

				madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, cap_size);
				glVertex2fv(cap);
				madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, -cap_size);
				glVertex2fv(cap);

				/* angle vertex */
				glVertex2f(co_ss[1][0] - cap_size, co_ss[1][1] - cap_size);
				glVertex2f(co_ss[1][0] + cap_size, co_ss[1][1] + cap_size);
				glVertex2f(co_ss[1][0] - cap_size, co_ss[1][1] + cap_size);
				glVertex2f(co_ss[1][0] + cap_size, co_ss[1][1] - cap_size);
				glEnd();

				glDisable(GL_BLEND);
			}
		}
		else {
			glBegin(GL_LINE_STRIP);
			for (j = 0; j < 3; j += 2) {
				glVertex2fv(co_ss[j]);
			}
			glEnd();
			cpack(0xaaaaaa);
			setlinestyle(3);
			glBegin(GL_LINE_STRIP);
			for (j = 0; j < 3; j += 2) {
				glVertex2fv(co_ss[j]);
			}
			glEnd();
			setlinestyle(0);

			sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[2]);

			/* text */
			{
				char numstr[256];
				float numstr_size[2];
				const int prec = 6;  /* XXX, todo, make optional */
				float pos[2];

				ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec);

				BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]);

				mid_v2_v2v2(pos, co_ss[0], co_ss[2]);

				/* center text */
				pos[0] -= numstr_size[0] / 2.0f;
				pos[1] -= numstr_size[1] / 2.0f;

				/* draw text (bg) */
				glColor4ubv(color_back);
				uiSetRoundBox(UI_CNR_ALL);
				uiRoundBox(pos[0] - bg_margin,                  pos[1] - bg_margin,
				           pos[0] + bg_margin + numstr_size[0], pos[1] + bg_margin + numstr_size[1],
				           bg_radius);
				/* draw text */
				glColor3ubv(color_text);
				BLF_position(blf_mono_font, pos[0], pos[1], 0.0f);
				BLF_draw(blf_mono_font, numstr, sizeof(numstr));
			}

			/* capping */
			{
				float rot_90_vec[2] = {-dir_ruler[1], dir_ruler[0]};
				float cap[2];

				normalize_v2(rot_90_vec);

				glEnable(GL_BLEND);
				glColor3ubv(color_wire);

				glBegin(GL_LINES);
				madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size);
				glVertex2fv(cap);
				madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, -cap_size);
				glVertex2fv(cap);

				madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, cap_size);
				glVertex2fv(cap);
				madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, -cap_size);
				glVertex2fv(cap);
				glEnd();

				glDisable(GL_BLEND);
			}
		}
	}

	glDisable(GL_LINE_SMOOTH);

	BLF_disable(blf_mono_font, BLF_ROTATION);

#undef ARC_STEPS

	/* draw snap */
	if ((ruler_info->snap_flag & RULER_SNAP_OK) && (ruler_info->state == RULER_STATE_DRAG)) {
		ruler_item = ruler_item_active_get(ruler_info);
		if (ruler_item) {
			/* size from drawSnapping */
			const float size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
			float co_ss[3];
			ED_view3d_project_float_global(ar, ruler_item->co[ruler_item->co_index], co_ss, V3D_PROJ_TEST_NOP);

			cpack(color_act);
			circ(co_ss[0], co_ss[1], size * U.pixelsize);
		}
	}

}
Exemple #7
0
/* draw grease-pencil datablock */
static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag)
{
	bGPDlayer *gpl, *actlay=NULL;
	
	/* reset line drawing style (in case previous user didn't reset) */
	setlinestyle(0);
	
	/* turn on smooth lines (i.e. anti-aliasing) */
	glEnable(GL_LINE_SMOOTH);
	
	/* turn on alpha-blending */
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);
		
	/* loop over layers, drawing them */
	for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
		bGPDframe *gpf;
		
		short debug = (gpl->flag & GP_LAYER_DRAWDEBUG) ? 1 : 0;
		short lthick= gpl->thickness;
		float color[4], tcolor[4];
		
		/* don't draw layer if hidden */
		if (gpl->flag & GP_LAYER_HIDE) 
			continue;
		
		/* if layer is active one, store pointer to it */
		if (gpl->flag & GP_LAYER_ACTIVE)
			actlay= gpl;
		
		/* get frame to draw */
		gpf= gpencil_layer_getframe(gpl, cfra, 0);
		if (gpf == NULL) 
			continue;
		
		/* set color, stroke thickness, and point size */
		glLineWidth(lthick);
		QUATCOPY(color, gpl->color); // just for copying 4 array elements
		QUATCOPY(tcolor, gpl->color); // additional copy of color (for ghosting)
		glColor4f(color[0], color[1], color[2], color[3]);
		glPointSize((float)(gpl->thickness + 2));
		
		/* draw 'onionskins' (frame left + right) */
		if (gpl->flag & GP_LAYER_ONIONSKIN) {
			/* drawing method - only immediately surrounding (gstep = 0), or within a frame range on either side (gstep > 0)*/			
			if (gpl->gstep) {
				bGPDframe *gf;
				float fac;
				
				/* draw previous frames first */
				for (gf=gpf->prev; gf; gf=gf->prev) {
					/* check if frame is drawable */
					if ((gpf->framenum - gf->framenum) <= gpl->gstep) {
						/* alpha decreases with distance from curframe index */
						fac= (float)(gpf->framenum - gf->framenum) / (float)gpl->gstep;
						tcolor[3] = color[3] - fac;
						gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor);
					}
					else 
						break;
				}
				
				/* now draw next frames */
				for (gf= gpf->next; gf; gf=gf->next) {
					/* check if frame is drawable */
					if ((gf->framenum - gpf->framenum) <= gpl->gstep) {
						/* alpha decreases with distance from curframe index */
						fac= (float)(gf->framenum - gpf->framenum) / (float)gpl->gstep;
						tcolor[3] = color[3] - fac;
						gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor);
					}
					else 
						break;
				}	
				
				/* restore alpha */
				glColor4f(color[0], color[1], color[2], color[3]);
			}
			else {
				/* draw the strokes for the ghost frames (at half of the alpha set by user) */
				if (gpf->prev) {
					tcolor[3] = (color[3] / 7);
					gp_draw_strokes(gpf->prev, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor);
				}
				
				if (gpf->next) {
					tcolor[3] = (color[3] / 4);
					gp_draw_strokes(gpf->next, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor);
				}
				
				/* restore alpha */
				glColor4f(color[0], color[1], color[2], color[3]);
			}
		}
		
		/* draw the strokes already in active frame */
		tcolor[3]= color[3];
		gp_draw_strokes(gpf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor);
		
		/* Check if may need to draw the active stroke cache, only if this layer is the active layer
		 * that is being edited. (Stroke buffer is currently stored in gp-data)
		 */
		if ((G.f & G_GREASEPENCIL) && (gpl->flag & GP_LAYER_ACTIVE) &&
			(gpf->flag & GP_FRAME_PAINT)) 
		{
			/* Buffer stroke needs to be drawn with a different linestyle to help differentiate them from normal strokes. */
			gp_draw_stroke_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag);
		}
	}
	
	/* turn off alpha blending, then smooth lines */
	glDisable(GL_BLEND); // alpha blending
	glDisable(GL_LINE_SMOOTH); // smooth lines
		
	/* restore initial gl conditions */
	glLineWidth(1.0);
	glPointSize(1.0);
	glColor4f(0, 0, 0, 1);
}
void drawConstraint(TransInfo *t)
{
	TransCon *tc = &(t->con);

	if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE))
		return;
	if (!(tc->mode & CON_APPLY))
		return;
	if (t->flag & T_USES_MANIPULATOR)
		return;
	if (t->flag & T_NO_CONSTRAINT)
		return;

	/* nasty exception for Z constraint in camera view */
	// TRANSFORM_FIX_ME
//	if ((t->flag & T_OBJECT) && G.vd->camera==OBACT && G.vd->persp==V3D_CAMOB)
//		return;

	if (tc->drawExtra) {
		tc->drawExtra(t);
	}
	else {
		if (tc->mode & CON_SELECT) {
			float vec[3];
			char col2[3] = {255, 255, 255};
			int depth_test_enabled;

			convertViewVec(t, vec, (t->mval[0] - t->con.imval[0]), (t->mval[1] - t->con.imval[1]));
			add_v3_v3(vec, t->center_global);

			drawLine(t, t->center_global, tc->mtx[0], 'X', 0);
			drawLine(t, t->center_global, tc->mtx[1], 'Y', 0);
			drawLine(t, t->center_global, tc->mtx[2], 'Z', 0);

			glColor3ubv((GLubyte *)col2);

			depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
			if (depth_test_enabled)
				glDisable(GL_DEPTH_TEST);

			setlinestyle(1);
			glBegin(GL_LINE_STRIP);
			glVertex3fv(t->center_global);
			glVertex3fv(vec);
			glEnd();
			setlinestyle(0);

			if (depth_test_enabled)
				glEnable(GL_DEPTH_TEST);
		}

		if (tc->mode & CON_AXIS0) {
			drawLine(t, t->center_global, tc->mtx[0], 'X', DRAWLIGHT);
		}
		if (tc->mode & CON_AXIS1) {
			drawLine(t, t->center_global, tc->mtx[1], 'Y', DRAWLIGHT);
		}
		if (tc->mode & CON_AXIS2) {
			drawLine(t, t->center_global, tc->mtx[2], 'Z', DRAWLIGHT);
		}
	}
}
void main()
{
int gd=VGA,gm=VGAHI,errorcode,area,i,j,play=1,rndplay,rac,r,ch,chh,n=1,speed=151,sp=1,si=1,carx,cary,gear=0,aspeed,booster=100,drumx,drumy,drumv,drumx1,drumy1,spp,coin=200;
int life_=10;
int fire=20;
char info[4];
int soun;
char *buff;
char *fir;
char *boost;
int mouse=23;
int x,y,button;


char *tyre1;
float feul=100;
char *car1buf;
char *pcar4buf;
char *fcar5buf;

int recsize;
FILE *fp;
struct record
{
int coins;
int lifes;
float feuls;
int speeds;
int boosters;
int gear_;
int fire_;
}rec;

recsize=sizeof(rec);

initgraph(&gd,&gm,"c:\bagger");
errorcode = graphresult();
if (errorcode != grOk)
{
   printf("Graphics error: %s\n", grapherrormsg(errorcode));
   printf("Press any key to halt:");
   getch();

   exit(1);
}
fp=fopen("c:\\rruunn.r4l","r");
fread(&rec,recsize,1,fp);
coin=rec.coins;
feul=rec.feuls;
speed=rec.speeds;
booster=rec.boosters;
gear=rec.gear_;
fire=rec.fire_;
life_=rec.lifes;
fclose(fp);
remove("c:\\rruunn.r4l");

if(coin>0 && feul>0 && life_>0)
{

//geting car's image*****************************************

  setcolor(RED);
  settextstyle(8,1,4);
  outtextxy(100,100+60,"You have :  ");

  car(125,75);
  area=imagesize(85,15,165,405);
  buff=malloc(area);
  getimage(85,15,165,405,buff);
  putimage(85,15,buff,XOR_PUT);




setcolor(8);
setfillstyle(1,8);
bar((getmaxx()/2)-130,0,(getmaxx()/2)+130,getmaxy());
roadstru();
basicstructure1();
sean1();
gears(5);
speedgrp(151-speed);
feulgrp(100);
coingrp(200);
boostergrp(100);
firee(20);
lifee(10);
car(250,400);
setcolor(WHITE);
setfillstyle(1,WHITE);
for(i=-2000;i<+25000;i+=100)
bar((getmaxx()/2)-5,i,(getmaxx()/2)+5,i+80);

delay(1000);

setcolor(getbkcolor());
setfillstyle(1,getbkcolor());
for(i=1;i<320;i++)
{
bar(getmaxx()/2,0,(getmaxx()/2)-i,getmaxy());
bar(getmaxx()/2,0,(getmaxx()/2)+i,getmaxy());
delay(5);
}

delay(1000);



setcolor(YELLOW);
settextstyle(7,0,15);
outtextxy(100-20,100,"R");

settextstyle(7,0,15);
outtextxy(495-20,100,"E");

setcolor(LIGHTBLUE);
settextstyle(7,0,7);
outtextxy(198-20,130,"UN   LIF");

setcolor(BLUE);
setlinestyle(0,0,3);
line(275,155,385,155);
line(275-2,160,385-2,160);
line(275-4,165,385-4,165);
line(275-6,170,385-6,170);
line(275-8,175,385-8,175);
line(275-9,180,385-9,180);
line(275-10,185,385-10,185);
line(275-12,190,385-12,190);

setcolor(YELLOW);
settextstyle(10,0,7);
outtextxy(295,95,"4");


setcolor(LIGHTBLUE);
for(i=1;i<=465;i++)
{
line(80,228,80+i,228);
delay(5);
}
for(i=1;i<20;i++)
{
line(80,228+i,545,228+i);
delay(7);
}
delay(500);
setcolor(LIGHTRED);
settextstyle(8,0,5);
setusercharsize(2,1,1,2);
textdisp1(80,225,"Run For Life",RED,LIGHTRED);

setcolor(LIGHTRED);
settextstyle(8,0,6);
setusercharsize(2,1,1,1);
textdisp1(80,325,"Stage Clear !!!",LIGHTBLUE,BLUE);

delay(2000);
setcolor(getbkcolor());
setfillstyle(1,getbkcolor());
for(i=1;i<=getmaxx();i++)
{
bar(0,0,0+i,getmaxy());
delay(5);
}



for(i=1;i<450;i+=10)
{
putimage(50,getmaxy()-i,buff,XOR_PUT);
delay(5);
putimage(50,getmaxy()-i,buff,XOR_PUT);
}
putimage(50,getmaxy()-450,buff,XOR_PUT);

	setcolor(YELLOW);
	settextstyle(8,0,2);
	outtextxy(200,200,"Coin left : ");
	outtextxy(220,240,"Life left : ");
	outtextxy(200,280,"Fuel left : ");
	outtextxy(220,320,"Booster left : ");
	outtextxy(200,360,"Fire left : ");

	for(i=1;i<=coin;i++)
	{
	setcolor(getbkcolor());
	setfillstyle(1,getbkcolor());
	bar(350,200,400,250);
	setcolor(YELLOW);
	sprintf(info,"%d",i);
	outtextxy(350,200,info);
	sound(500);
	delay(50);
	nosound();
	}
	for(i=1;i<=life_;i++)
	{
	setcolor(getbkcolor());
	setfillstyle(1,getbkcolor());
	bar(400,240,450,290);
	setcolor(YELLOW);
	sprintf(info,"%d",i);
	outtextxy(400,240,info);
	sound(400);
	delay(50);
	nosound();
	}
	for(i=1;i<=feul;i++)
	{
	setcolor(getbkcolor());
	setfillstyle(1,getbkcolor());
	bar(350,280,400,330);
	setcolor(YELLOW);
	sprintf(info,"%d",i);
	outtextxy(350,280,info);
	sound(500);
	delay(50);
	nosound();
	}
	for(i=1;i<=booster;i++)
	{
	setcolor(getbkcolor());
	setfillstyle(1,getbkcolor());
	bar(400,320,450,370);
	setcolor(YELLOW);
	sprintf(info,"%d",i);
	outtextxy(400,320,info);
	sound(400);
	delay(50);
	nosound();
	}
	for(i=1;i<=fire;i++)
	{
	setcolor(getbkcolor());
	setfillstyle(1,getbkcolor());
	bar(350,360,400,410);
	setcolor(YELLOW);
	sprintf(info,"%d",i);
	outtextxy(350,360,info);
	sound(500);
	delay(50);
	nosound();
	}
	setcolor(LIGHTBLUE);
	setfillstyle(1,LIGHTBLUE);
	for(i=1;i<400;i++)
	{
	bar(200,50,200+i,150);
	delay(2);
	}
	setcolor(YELLOW);
	rectangle(200,50,600,150);
	setcolor(LIGHTRED);
	rectangle(200+5,50+5,600-5,150-5);
	setcolor(RED);
	settextstyle(3,0,3);
	textdisp(220,60,"Do u accept the next challange");
	setcolor(LIGHTRED);
	rectangle(215,110,400,135);
	rectangle(410,110,585,135);
	setcolor(RED);
	rectangle(215+2,110+2,400-2,135-2);
	rectangle(410+2,110+2,585-2,135-2);
	settextstyle(8,0,1);
	outtextxy(235,106,"Yes, I accept !!!");
	outtextxy(435,106,"No, I Quit");

	change(c);
	show();

	while(mouse==23)
	{
	show();
	moupos(&button,&x,&y);
	if((button & 1)==1)
	{
	if(x>410 && x<585 && y>110 && y<135)
	{
	setcolor(getbkcolor());
	setfillstyle(1,getbkcolor());
	for(i=1;i<=getmaxx();i++)
	{
	bar(0,0,0+i,getmaxy());
	delay(5);
	}
	hide();
	//one step here
	setcolor(RED);
	settextstyle(4,0,8);
	outtextxy(180,200,"Looser !!!");
	coin=0;
	feul=0;
	speed=0;
	booster=0;
	gear=0;
	fire=0;
	life_=0;
	mouse=0;
	delay(1000);
	//************************************************************************
setfillstyle(8,WHITE);            //background color and style
bar(1,1,getmaxx(),getmaxy());

setfillstyle(7,YELLOW);      //bagger plate
bar(150,5,500,55);

setcolor(BLUE);
for(i=1;i<=5;i++)
{                          //border of bagger plate
setfillstyle(1,BLUE);
rectangle(150-i,5-i,500+i,55+i);
}

settextstyle(1,0,5);
setcolor(WHITE);          // the bagger writen
outtextxy(200,3,"Run 4 Life");


setcolor(WHITE);          //work place designed
setfillstyle(1,WHITE);
bar(100,100,550,350);


setcolor(BLUE);
for(i=1;i<=5;i++)
{                           //work place border
rectangle(100-i,100-i,550+i,350+i);
}


setcolor(getbkcolor());                 //man's face
ellipse(300,190,0,360,35,40);

setfillstyle(1,getbkcolor());        //man's hat
for(i=1;i<=33;i++)
{
arc(300,172,0,180,i);
}


for(i=1;i<=12;i+=2)
{
 setlinestyle(0,0,0);                    //his hair
 arc(322-i,195,150,200,50);
}
for(i=1;i<=10;i+=5)                    //his hair
{
 setlinestyle(0,0,3);
 arc(322-i,195,150,200,50);
}


for(i=1;i<=12;i+=2)
{
 setlinestyle(0,0,0);                    //his hair
 arc(277+i,195,338,30,50);
}
for(i=1;i<=10;i+=5)                    //his hair
{
 setlinestyle(0,0,3);
  arc(277+i,195,338,30,50);
}

fillellipse(285,185,18,10);   //his eye masks
fillellipse(315,185,18,10);

setcolor(WHITE);           //his eye
setfillstyle(1,WHITE);
fillellipse(285,185,5,1);
fillellipse(315,185,5,1);

setcolor(getbkcolor());
setfillstyle(1,getbkcolor());
fillellipse(285,185,1,1);    //his eye ball
fillellipse(315,185,1,1);

 setlinestyle(0,0,0);   //his nose
line(295,192,292,205);
line(302,192,304,205);
line(292,205,304,205);

for(i=1;i<6;i+=1)             //his mooch
arc(300,232,60,120,20+i);

 setlinestyle(0,0,3);
line(288,210,280,225);       //his mooch
line(311,210,318,225);

setlinestyle(0,0,0);
arc(300,205,230,310,12);     //his mouth
arc(300,227,60,120,13);

setlinestyle(0,0,3);
for(i=1;i<=10;i+=4)         //his dadhi
line(295+i,220,295+i,230);



setlinestyle(0,0,0);
line(285,227,285,240);  //his neck
line(315,227,315,240);

setlinestyle(0,0,3);
line(285,240,235,249);    //his  coat base and right hand
line(315,240,342,249);
line(230,255,250,320);
arc(237,255,90,180,6);
line(250,320,340,310);
line(270,270,275,290);
line(275,290,330,285);
setlinestyle(0,0,3);
line(330,285,340,310);
line(325,285,335,310);
setlinestyle(0,0,0);


setlinestyle(0,0,0);
arc(340,330,70,100,40);
arc(340,335,70,90,40);
arc(340,340,70,90,40);     //his finger
arc(340,345,70,90,40);
arc(340,350,70,90,40);
arc(315,305,350,20,40);
setlinestyle(0,0,3);

line(342,200,342,290);
line(365,200,350,290);
arc(355,232,71,110,35); //his stick
line(342,310,340,320);
line(347,310,349,320);
line(340,320,349,320);

line(285,240,320,250);//his left hand
line(315,240,305,245);
line(320,250,323,285);
circle(310,260,2);
circle(311,270,2);
circle(312,280,2);
line(356,252,360,253);
line(360,253,365,328);
line(330,270,333,290);
line(365,328,280,318);


setcolor(getbkcolor());
setlinestyle(0,0,3);
delay(1000);
for(j=1;j<=250;j++)
{
for(i=1;i<450;i+=30)
{
line(100+i,100,100+i,100+j);
line(103+i,100,103+i,100+j);
}
delay(5);
}
delay(1000);
setcolor(BLUE);
settextstyle(10,0,3);
outtextxy(200,200,"Arrested");
rectangle(190,210,390,250);
delay(1500);
setcolor(getbkcolor());
setlinestyle(0,0,3);
for(i=1;i<=450;i++)
{
line(100,220,100+i,220);
delay(5);
}
for(i=1;i<120;i++)
{
line(100,220-i,550,220-i);
line(100,220+i,550,220+i);
delay(20);
}
setcolor(getbkcolor());
setfillstyle(1,getbkcolor());
bar(100,340,550,350);
settextstyle(8,0,5);
setcolor(RED);
textdisp(150,200,"You Loose");

delay(1000);
setcolor(getbkcolor());
setfillstyle(1,getbkcolor());
for(i=1;i<350;i++)
{
bar(getmaxx()/2,0,(getmaxx()/2)-i,getmaxy());
bar(getmaxx()/2,0,(getmaxx()/2)+i,getmaxy());
delay(5);
}
	//**************************************************************************
	}
	else if(x>215 && x<400 && y>110 && y<135)
	{
	setcolor(getbkcolor());
	setfillstyle(1,getbkcolor());
	for(i=1;i<=getmaxx();i++)
	{
	bar(0,0,0+i,getmaxy());
	delay(5);
	}
	hide();
	setcolor(LIGHTGREEN);
	settextstyle(4,0,8);
	outtextxy(180,200,"Bravo !!!");
	mouse=0;
	}
	}
	}

}
//*********************************************************************************************
rec.coins=coin;
rec.feuls=feul;
rec.speeds=speed;
rec.gear_=gear;
rec.lifes=life_;
rec.fire_=fire;
rec.boosters=booster;
fp=fopen("c:\\rruunn.r4l","w");
fwrite(&rec,recsize,1,fp);
fclose(fp);
//closegraph();
delay(1500);
}
Exemple #10
0
void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
{
	ColorBand *coba;
	CBData *cbd;
	float x1, y1, sizex, sizey;
	float v3[2], v1[2], v2[2], v1a[2], v2a[2];
	int a;
	float pos, colf[4] = {0, 0, 0, 0}; /* initialize in case the colorband isn't valid */
	struct ColorManagedDisplay *display = NULL;

	coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin);
	if (coba == NULL) return;

	if (but->block->color_profile)
		display = ui_block_display_get(but->block);

	x1 = rect->xmin;
	y1 = rect->ymin;
	sizex = rect->xmax - x1;
	sizey = rect->ymax - y1;

	/* first background, to show tranparency */

	glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
	glRectf(x1, y1, x1 + sizex, y1 + sizey);
	glEnable(GL_POLYGON_STIPPLE);
	glColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255);
	glPolygonStipple(checker_stipple_sml);
	glRectf(x1, y1, x1 + sizex, y1 + sizey);
	glDisable(GL_POLYGON_STIPPLE);

	glShadeModel(GL_FLAT);
	glEnable(GL_BLEND);
	
	cbd = coba->data;
	
	v1[0] = v2[0] = x1;
	v1[1] = y1;
	v2[1] = y1 + sizey;
	
	glBegin(GL_QUAD_STRIP);
	
	glColor4fv(&cbd->r);
	glVertex2fv(v1);
	glVertex2fv(v2);

	for (a = 1; a <= sizex; a++) {
		pos = ((float)a) / (sizex - 1);
		do_colorband(coba, pos, colf);
		if (display)
			IMB_colormanagement_scene_linear_to_display_v3(colf, display);
		
		v1[0] = v2[0] = x1 + a;
		
		glColor4fv(colf);
		glVertex2fv(v1);
		glVertex2fv(v2);
	}
	
	glEnd();
	glShadeModel(GL_FLAT);
	glDisable(GL_BLEND);
	
	/* outline */
	glColor4f(0.0, 0.0, 0.0, 1.0);
	fdrawbox(x1, y1, x1 + sizex, y1 + sizey);
	
	/* help lines */
	v1[0] = v2[0] = v3[0] = x1;
	v1[1] = y1;
	v1a[1] = y1 + 0.25f * sizey;
	v2[1] = y1 + 0.5f * sizey;
	v2a[1] = y1 + 0.75f * sizey;
	v3[1] = y1 + sizey;
	
	
	cbd = coba->data;
	glBegin(GL_LINES);
	for (a = 0; a < coba->tot; a++, cbd++) {
		v1[0] = v2[0] = v3[0] = v1a[0] = v2a[0] = x1 + cbd->pos * sizex;
		
		if (a == coba->cur) {
			glColor3ub(0, 0, 0);
			glVertex2fv(v1);
			glVertex2fv(v3);
			glEnd();
			
			setlinestyle(2);
			glBegin(GL_LINES);
			glColor3ub(255, 255, 255);
			glVertex2fv(v1);
			glVertex2fv(v3);
			glEnd();
			setlinestyle(0);
			glBegin(GL_LINES);
			
#if 0
			glColor3ub(0, 0, 0);
			glVertex2fv(v1);
			glVertex2fv(v1a);
			glColor3ub(255, 255, 255);
			glVertex2fv(v1a);
			glVertex2fv(v2);
			glColor3ub(0, 0, 0);
			glVertex2fv(v2);
			glVertex2fv(v2a);
			glColor3ub(255, 255, 255);
			glVertex2fv(v2a);
			glVertex2fv(v3);
#endif
		}
		else {
			glColor3ub(0, 0, 0);
			glVertex2fv(v1);
			glVertex2fv(v2);
			
			glColor3ub(255, 255, 255);
			glVertex2fv(v2);
			glVertex2fv(v3);
		}
	}
	glEnd();

}
Exemple #11
0
void main()
{int gdriver=DETECT,gmode=DETECT;
randomize();
initgraph(&gdriver,&gmode,"");
setbkcolor(BLACK);
clrscr();
cleardevice();
load();
x=random(640);
y=random(480);
//c=random(16);
color();
//setfillstyle(1,c);
setlinestyle(random(6),random(10),random(5));
settextstyle(3,HORIZ_DIR,1);
while(ch!='q')
{//cleardevice();
//outtextxy(30,40," Q   W   E  or arrow key ");
init();
show();
while(!kbhit())
{
check();
//gotoxy(4,2);
//cout<<"\n\n\tX = "<<mx<<"   Y = "<<my<<"  B = "<<b;
if(ch=='w'){cleardevice();ch='A';}
if(x<0||x>640||y<0||y>480||ch=='e')
{ch='A';

x=random(640);
y=random(480);
color();
setlinestyle(random(6),random(10),random(5));
setfillstyle(random(10),random(16));
//c=random(16);
setcolor(c);
}
//change();
mchange();
//if(((m%4000)>200&&(m%4000)<400)||((m%4000)>1000&&(m%4000)<1500)){
//sound((m%4000)+3000);
//}
//if((m%4000)==400||(m%4000)==1500)nosound();
//putpixel(x,y,c);
// Uncomment any one of these and watch
//circle(x+random(20),y+random(20),random(10));
//rectangle(x-random(2),y-random(2),x+random(2),y+random(2));
//line(x,y,320,240);
//line(x,y,(x*y)%100,(x*y)%100);
//line(x-y%40,y,x,x^2);
//line(x-y%40,y,x,(y+(x^2))%480);
//line(y,x,x,y);
//line(x*2,y/2,x/2,y*2);
//circle(x+random(50),y+random(50),(x*y)%10);
//ellipse(x+random(60),y+random(60),0,random(360),random(30),random(30));
//floodfill(x,y,c);
//ellipse(x+random(400),y+random(400),0,random(360),random(100),random(100));
//ellipse(x,y,0,360,5,5);
//ellipse(x-random(640),y-random(480),0,random(360),random(100),random(100));
//bar3d(x-random(3),y-random(3),x+random(3),y+random(3),random(3),1);
//linerel(x,y);
//lineto(x,y);
button();
draw();
//arc(x,y,0,random(360),random(40));
//x=random(640);
//y=random(480);
delay(1);
}
ch=getch();
key();
}
closegraph();
}
Exemple #12
0
/* function to draw markers */
static void draw_marker(
        View2D *v2d, const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int flag,
        /* avoid re-calculating each time */
        const float ypixels, const float xscale, const float yscale)
{
	const float xpos = marker->frame * xscale;
	int icon_id;

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	/* vertical line - dotted */
#ifdef DURIAN_CAMERA_SWITCH
	if ((marker->camera) || (flag & DRAW_MARKERS_LINES))
#else
	if (flag & DRAW_MARKERS_LINES)
#endif
	{
		setlinestyle(3);
		
		if (marker->flag & SELECT)
			glColor4ub(255, 255, 255, 96);
		else
			glColor4ub(0, 0, 0, 96);
		
		glBegin(GL_LINES);
		glVertex2f(xpos + 0.5f, 12.0f);
		glVertex2f(xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
		glEnd();
		
		setlinestyle(0);
	}
	
	/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
	if (flag & DRAW_MARKERS_LOCAL) {
		icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
		          (marker->flag & SELECT) ? ICON_PMARKER_SEL :
		          ICON_PMARKER;
	}
	else {
		icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT :
		          ICON_MARKER;
	}
	
	UI_icon_draw(xpos - 0.45f * UI_DPI_ICON_SIZE, UI_DPI_ICON_SIZE, icon_id);
	
	glDisable(GL_BLEND);
	
	/* and the marker name too, shifted slightly to the top-right */
	if (marker->name[0]) {
		float x, y;

		/* minimal y coordinate which wouldn't be occluded by scroll */
		int min_y = 17.0f * UI_DPI_FAC;
		
		if (marker->flag & SELECT) {
			UI_ThemeColor(TH_TEXT_HI);
			x = xpos + 4.0f * UI_DPI_FAC;
			y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
			y = max_ii(y, min_y);
		}
		else {
			UI_ThemeColor(TH_TEXT);
			if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) {
				x = xpos + 8.0f * UI_DPI_FAC;
				y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
				y = max_ii(y, min_y);
			}
			else {
				x = xpos + 8.0f * UI_DPI_FAC;
				y = 17.0f * UI_DPI_FAC;
			}
		}

#ifdef DURIAN_CAMERA_SWITCH
		if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) {
			float col[4];
			glGetFloatv(GL_CURRENT_COLOR, col);
			col[3] = 0.4;
			glColor4fv(col);
		}
#endif

		UI_fontstyle_draw_simple(fstyle, x, y, marker->name);
	}
}
Exemple #13
0
 /*NP*/ void
wind_barb (float wdir, float wspd, short x, short y, short siz)
	/*************************************************************/
	/*  WIND_BARB                                                */
	/*  John Hart  NSSFC KCMO                                    */
	/*                                                           */
	/*  Plots wind barb at location (x,y) for given wind.        */
	/*************************************************************/
{
  short x1, y1, x2, y2, x3, y3, sped, maxsiz = 3;
  float dx, dy, spcx, spcy, wid, hgt;

  dx = (ucomp (wdir, 10) * (float) siz) / 1.5F;
  dy = (vcomp (wdir, 10) * (float) siz) / 1.5F;

  x1 = x;
  y1 = y;
  x2 = x1 + (short) dx;
  y2 = y1 - (short) dy;

  /* ----- Draw backbone of wind barb, along with origin dot ----- */
  if (siz > maxsiz)
    {
      setlinestyle (1, 2);
    }
  else
    {
      setlinestyle (1, 1);
    }

  rectangle (0, x1 - 1, y1 - 1, x1 + 1, y1 + 1);
  moveto (x1, y1);
  lineto (x2, y2);

  sped = (short) wspd;
  x1 = x2;
  y1 = y2;

  wid = 5;			/* Number of flags that will fit */
  spcx = dx / wid;
  spcy = dy / wid;
  x1 = x1 + (short) spcx;
  y1 = y1 - (short) spcy;

  /* ----- Draw wind flags (increments of 50kt) ----- */
  while (sped > 47)
    {
      x1 = x1 - (short) spcx;
      y1 = y1 + (short) spcy;

      hgt = .5F;		/* Heigth of flags */
      x2 = x1 + (short) (dy * hgt);
      y2 = y1 + (short) (dx * hgt);

      x3 = x1 - (short) spcx;
      y3 = y1 + (short) spcy;

      moveto (x1, y1);
      lineto (x2, y2);
      lineto (x3, y3);

      x2 = (x1 + x2 + x3) / 3;
      y2 = (y1 + y2 + y3) / 3;

      sped -= 50;
      x1 = x3;
      y1 = y3;
    }

  /* ----- Draw wind barbs (increments of 5kt) ----- */
  while (sped > 7)
    {
      hgt = .5F;		/* Heigth of flags */
      x2 = x1 + (short) (dy * hgt);
      y2 = y1 + (short) (dx * hgt);

      x3 = x1 - (short) spcx;
      y3 = y1 + (short) spcy;

      moveto (x3, y3);
      lineto (x2, y2);

      sped -= 10;
      x1 = x3;
      y1 = y3;
    }

  /* ----- Draw short barb ----- */
  if (sped > 3)
    {
      hgt = .5F;		/* Heigth of flags */
      x2 = x1 + (short) (dy * hgt);
      y2 = y1 + (short) (dx * hgt);

      x3 = x1 - (short) spcx;
      y3 = y1 + (short) spcy;

      dx = (x3 - x2) / 2;
      dy = (y3 - y2) / 2;

      x2 = x3 - (short) dx;
      y2 = y3 - (short) dy;

      moveto (x3, y3);
      lineto (x2, y2);
    }
}
Exemple #14
0
void
draw_hodo (void)
	/*************************************************************/
	/*  DRAW_HODO                                                */
	/*  John Hart  NSSFC KCMO                                    */
	/*                                                           */
	/*  Draws a standard Hodograph display.                      */
	/*************************************************************/
{
  short x1, y1, x2, y2, i, y3;
  float wdir, wspd, mnu, mnv, ix1, ix2, ix3, ix4;
  char st[10];

  setcolor (0, draw_reg, gc);
  rectangle (1, 1, 1, hov.brx + 14, hov.bry + 14);
  setcolor (1, draw_reg, gc);
  set_font (2);
  setcliprgn (hov.tlx, hov.tly, hov.brx, hov.bry, draw_reg, gc);
  setlinestyle (1, 1);
  rectangle (0, hov.tlx, hov.tly, hov.brx, hov.bry);

  /* ----- Plot crosshairs ----- */
  setcolor (31, draw_reg, gc);
  hodo_to_pix (180.0F, 60.0F, &x1, &y1);
  moveto (x1, hov.tly);
  lineto (x1, hov.bry);

  setcolor (31, draw_reg, gc);
  hodo_to_pix (270.0F, 60.0F, &x1, &y1);
  moveto (hov.tlx, y1);
  lineto (hov.brx, y1);

  /* ----- Plot Radius circles ----- */
  setcolor (24, draw_reg, gc);
  setlinestyle (2, 1);
  hodo_to_pix (0.0F, 0.0F, &x1, &y1);
  x2 = x1;
  y2 = y1;
  for (i = hov.scale; i <= hov.hodomag; i = i + hov.scale)
    {
      hodo_to_pix (0.0F, (float) i, &x1, &y1);
      y3 = (y1 - y2);
      ellipse (0, x2 - y3, y2 - y3, x2 + y3, y2 + y3);
    }

  setcolor (1, draw_reg, gc);
  /* ----- Plot X-Coord hash marks ----- */
  for (i = hov.scale; i <= hov.hodomag; i = i + hov.scale)
    {
      hodo_to_pix (180.0F, (float) i, &x1, &y1);
      moveto (x1 - 3, y1);
      lineto (x1 + 3, y1);
      itoa (i, st, 10);
      outgtext (st, x1 - getgtextextent (st) - 4, y1 - 5);

      hodo_to_pix (360.0F, (float) i, &x1, &y1);
      moveto (x1 - 3, y1);
      lineto (x1 + 3, y1);
      itoa (i, st, 10);
      outgtext (st, x1 - getgtextextent (st) - 4, y1 - 5);
    }

  /* ----- Plot Y-Coord hash marks ----- */
  setcolor (1, draw_reg, gc);
  for (i = hov.scale; i <= hov.hodomag; i = i + hov.scale)
    {
      hodo_to_pix (90.0F, (float) i, &x1, &y1);
      moveto (x1, y1 - 3);
      lineto (x1, y1 + 3);
      itoa (i, st, 10);
      outgtext (st, x1 - (getgtextextent (st) / 2), y1 + 5);

      hodo_to_pix (270.0F, (float) i, &x1, &y1);
      moveto (x1, y1 - 3);
      lineto (x1, y1 + 3);
      itoa (i, st, 10);
      outgtext (st, x1 - (getgtextextent (st) / 2), y1 + 5);
    }

  /* ----- Plot Hodograph (Shear Vectors) ----- */
  setcolor (2, draw_reg, gc);
  setlinestyle (1, 2);

  if ((sndgp != NULL) && (sndgp->numlev > 0))
    {
      trace_hodo (3);

      /* ----- Plot Mean Wind Vector ----- */
      setcolor (5, draw_reg, gc);
      mean_wind (-1.0F, -1.0F, &mnu, &mnv, &wdir, &wspd);
      hodo_to_pix (wdir, wspd, &x1, &y1);
      moveto (x1, y1);
      rectangle (0, (short) (x1 - 4), (short) (y1 - 4), (short) (x1 + 4),
		 (short) (y1 + 4));


      /* ----- Plot 30/75 Storm Motion Vector ----- */
      mean_wind (sndgp->sndg[sfc ()].pres, i_pres (msl (6000.0F)), &ix1, &ix2,
		 &ix3, &ix4);
      setcolor (11, draw_reg, gc);
      setlinestyle (1, 1);
      ix4 *= .75F;
      ix3 += 30.0F;
      if (ix3 > 360.0F)
	ix3 -= 360.0F;
      hodo_to_pix (ix3, ix4, &x1, &y1);
      moveto (x1 - 3, y1);
      lineto (x1 + 3, y1);
      moveto (x1, y1 - 3);
      lineto (x1, y1 + 3);
      ellipse (0, x1 - 3, y1 - 3, x1 + 3, y1 + 3);


      /* ----- Plot 15/85 Storm Motion Vector ----- */
      mean_wind (sndgp->sndg[sfc ()].pres, i_pres (msl (6000.0F)), &ix1, &ix2,
		 &ix3, &ix4);
      setcolor (12, draw_reg, gc);
      setlinestyle (1, 1);
      ix4 *= .85F;
      ix3 += 15.0F;
      if (ix3 > 360.0F)
	ix3 -= 360.0F;
      hodo_to_pix (ix3, ix4, &x1, &y1);
      moveto (x1 - 3, y1);
      lineto (x1 + 3, y1);
      moveto (x1, y1 - 3);
      lineto (x1, y1 + 3);
      ellipse (0, x1 - 3, y1 - 3, x1 + 3, y1 + 3);


      /* ----- Plot Current Storm Motion Vector ----- */
      setcolor (31, draw_reg, gc);
      setlinestyle (1, 1);
      hodo_to_pix (sndgp->st_dir, sndgp->st_spd, &x1, &y1);
      moveto (x1 - 6, y1);
      lineto (x1 + 6, y1);
      moveto (x1, y1 - 6);
      lineto (x1, y1 + 6);
      ellipse (0, x1 - 6, y1 - 6, x1 + 6, y1 + 6);

      /* ----- Display Hodograph Inset ----- */
      draw_hoinset ();

      setcolor (1, draw_reg, gc);
      set_font (1);
      outgtext (sndgp->title, skv.tlx, 1);
    }


  /* ----- Draw final outline of hodograph ----- */
  setcolor (1, draw_reg, gc);
  setlinestyle (1, 1);
  rectangle (0, hov.tlx, hov.tly, hov.brx, hov.bry);

  /* reset clip region */
  setcliprgn (1, 1, xwdth, xhght, draw_reg, gc);

  XCopyArea (XtDisplay (draw_reg), canvas, XtWindow (draw_reg),
	     gc, 0, 0, xwdth, xhght, 0, 0);
}
Exemple #15
0
void draw_skewt (void)
/*************************************************************/
/*  DRAW_SKEWT                                               */
/*  John Hart  NSSFC KCMO                                    */
/*                                                           */
/*  Draws a standard Skew-T/LogP diagram.                    */
/*************************************************************/
{
  short i;
  float thta;
  float ix1, ix2, ix3, ix4, ix5, ix6, ix7;
  float lvl[] =
    { 1050.0F, 1000.0F, 850.0F, 700.0F, 500.0F, 300.0F, 200.0F, 100.0F };
  char rtitle[200];

  setcliprgn (1, 1, xwdth, xhght, draw_reg, gc);
  setcolor (0, draw_reg, gc);
  rectangle (1, 1, 1, skv.brx + 14, skv.bry + skv.tly + 14);
  setcolor (1, draw_reg, gc);
  set_font (2);
  setcliprgn (skv.tlx, skv.tly, skv.brx, skv.bry, draw_reg, gc);
  setlinestyle (1, 1);
  rectangle (0, skv.tlx, skv.tly, skv.brx, skv.bry);

/* ----- Draw Skewed Temperature Lines ----- */
  setcolor (24, draw_reg, gc);
  setlinestyle (2, 1);
  for (i = (-160); i <= 50; i = i + 10)
    {
      isotherm ((float) i);
    }

/* ----- Draw Dry Adiabats ----- */
  setcolor (24, draw_reg, gc);
  setlinestyle (1, 1);
  for (thta = (-70.0F); thta <= 350.0F; thta = thta + 20.0F)
    {
      dry_adiabat (thta);
    };

/* ----- Draw Horizontal Pressure Lines ----- */
  setcolor (1, draw_reg, gc);
  setlinestyle (1, 1);
  for (i = 1; i < 8; i++)
    {
      isobar (lvl[i], 0);
    }
  for (i = 100; i <= 1050; i = i + 50)
    {
      isobar ((float) i, 1);
    }

/* ----- Draw OPC Horizontal Stability Lines ----- *
 ************************************************************************
 *  OPC MODIFICATION - J. Morgan 5/12/05				*
 *  Draws:								*
 *	 Lowest Inversion Height					*
 *	 Layer Based Mixing Height					*
 *	 Surface Based Mixing Height					*
 *  Calls:								*
 *	 xwvid.c: void isobar_nolabel ()				*
 *	skparams.c: void low_inv ()					* 
 *	 skparams.c: void mix_height ()					*
 ***********************************************************************/

  low_inv( &ix1, &ix2 );
  setcolor (5, draw_reg, gc);
  setlinestyle (1, 1);
  isobar_nolabel (ix1);

  mix_height( &ix1, &ix2, &ix3, &ix4, &ix5, &ix6, &ix7, 1);
  setcolor (6, draw_reg, gc);
  setlinestyle (2, 1);
  isobar_nolabel (ix1);

  mix_height( &ix1, &ix2, &ix3, &ix4, &ix5, &ix6, &ix7, 0);
  setcolor (7, draw_reg, gc);
  setlinestyle (4, 1);
  isobar_nolabel (ix1);	

/* Draw frame boarder */
  setcolor (1, draw_reg, gc);
  rectangle (0, skv.tlx, skv.tly, skv.brx, skv.bry);

  if (sndgp != NULL)
    {

      /* ----- Plot old sounding if exists ----- */
      setcolor (28, draw_reg, gc);
      if ((overlay_previous == 1) && (sndgp->ovrlev > 0))
	{
	  trace_temp2 (3);
	  trace_dwpt2 (3);
	}

      if (sndgp->numlev > 0)
	{
	  /* ----- Plot Environmental Temperature Data ----- */
	  setcolor (2, draw_reg, gc);
	  trace_temp (sndgp, 3);

	  /* ----- Plot Environmental Dew Point Data ----- */
	  setcolor (3, draw_reg, gc);
	  trace_dwpt (sndgp, 3);

	  /* ----- Plot Environmental Virtual Temperature Data ----- */
	  setcolor (2, draw_reg, gc);
	  trace_vtmp (1);

	  /* ----- Plot Environmental Wetbulb Temperature Data ----- */
	  setcolor (6, draw_reg, gc);
	  setlinestyle (1, 1);
	  trace_wetbulb (1);

	  /* ----- Plot Wind Barbs ----- */
	  setcolor (5, draw_reg, gc);
	  setlinestyle (1, 1);
	  plot_barbs ();

	  /* ----- If Available, plot VVEL profile ----- */
	  vvel_profile ();
	}




      /* ----- Display Skew-T Inset ----- */
      draw_skinset ();

      setcliprgn (1, 1, xwdth, xhght, draw_reg, gc);
      setcolor (1, draw_reg, gc);
      set_font (1);

      sprintf (rtitle, "%s (%s)", sndgp->title, raob_type);
      outgtext (rtitle, skv.tlx, 1);

      update_text_values ();
    }

  XCopyArea (XtDisplay (draw_reg), canvas, XtWindow (draw_reg),
	     gc, 0, 0, xwdth, xhght, 0, 0);
}
 void Circle::erase()
 {
     setfillcolor(BLACK);
	 setlinestyle(style, width);
	fillcircle (cen.x,cen.y, radius);
 }
 void Circle::draw()
 {
	 setfillcolor(Incol);
	 setlinestyle(style, width);
	fillcircle (cen.x,cen.y, radius);
}
void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay)
{
	struct Main *bmain = CTX_data_main(C);
	struct ImBuf *ibuf = NULL;
	struct ImBuf *scope = NULL;
	struct View2D *v2d = &ar->v2d;
	/* int rectx, recty; */ /* UNUSED */
	float viewrectx, viewrecty;
	float render_size = 0.0;
	float proxy_size = 100.0;
	float col[3];
	GLuint texid;
	GLuint last_texid;
	void *display_buffer;
	void *cache_handle = NULL;
	const int is_imbuf = ED_space_sequencer_check_show_imbuf(sseq);
	int format, type;
	bool glsl_used = false;

	if (G.is_rendering == FALSE && (scene->r.seq_flag & R_SEQ_GL_PREV) == 0) {
		/* stop all running jobs, except screen one. currently previews frustrate Render
		 * needed to make so sequencer's rendering doesn't conflict with compositor
		 */
		WM_jobs_kill_type(CTX_wm_manager(C), WM_JOB_TYPE_COMPOSITE);

		if ((scene->r.seq_flag & R_SEQ_GL_PREV) == 0) {
			/* in case of final rendering used for preview, kill all previews,
			 * otherwise threading conflict will happen in rendering module
			 */
			WM_jobs_kill_type(CTX_wm_manager(C), WM_JOB_TYPE_RENDER_PREVIEW);
		}
	}

	render_size = sseq->render_size;
	if (render_size == 0) {
		render_size = scene->r.size;
	}
	else {
		proxy_size = render_size;
	}
	if (render_size < 0) {
		return;
	}

	viewrectx = (render_size * (float)scene->r.xsch) / 100.0f;
	viewrecty = (render_size * (float)scene->r.ysch) / 100.0f;

	/* rectx = viewrectx + 0.5f; */ /* UNUSED */
	/* recty = viewrecty + 0.5f; */ /* UNUSED */

	if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
		viewrectx *= scene->r.xasp / scene->r.yasp;
		viewrectx /= proxy_size / 100.0f;
		viewrecty /= proxy_size / 100.0f;
	}

	if (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
		UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col);
		glClearColor(col[0], col[1], col[2], 0.0);
		glClear(GL_COLOR_BUFFER_BIT);
	}

	/* without this colors can flicker from previous opengl state */
	glColor4ub(255, 255, 255, 255);

	UI_view2d_totRect_set(v2d, viewrectx + 0.5f, viewrecty + 0.5f);
	UI_view2d_curRect_validate(v2d);

	/* only initialize the preview if a render is in progress */
	if (G.is_rendering)
		return;

	ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs);
	
	if (ibuf == NULL)
		return;

	if (ibuf->rect == NULL && ibuf->rect_float == NULL)
		return;

	if (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0) {
		SequencerScopes *scopes = &sseq->scopes;

		sequencer_check_scopes(scopes, ibuf);

		switch (sseq->mainb) {
			case SEQ_DRAW_IMG_IMBUF:
				if (!scopes->zebra_ibuf) {
					ImBuf *display_ibuf = IMB_dupImBuf(ibuf);

					if (display_ibuf->rect_float) {
						IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
						                                             &scene->display_settings);
					}
					scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra);
					IMB_freeImBuf(display_ibuf);
				}
				scope = scopes->zebra_ibuf;
				break;
			case SEQ_DRAW_IMG_WAVEFORM:
				if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) {
					if (!scopes->sep_waveform_ibuf)
						scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf);
					scope = scopes->sep_waveform_ibuf;
				}
				else {
					if (!scopes->waveform_ibuf)
						scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf);
					scope = scopes->waveform_ibuf;
				}
				break;
			case SEQ_DRAW_IMG_VECTORSCOPE:
				if (!scopes->vector_ibuf)
					scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf);
				scope = scopes->vector_ibuf;
				break;
			case SEQ_DRAW_IMG_HISTOGRAM:
				if (!scopes->histogram_ibuf)
					scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf);
				scope = scopes->histogram_ibuf;
				break;
		}

		scopes->reference_ibuf = ibuf;
	}

	/* setting up the view - actual drawing starts here */
	UI_view2d_view_ortho(v2d);

	/* only draw alpha for main buffer */
	if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
		if (sseq->flag & SEQ_USE_ALPHA) {
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

			fdrawcheckerboard(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax);
			glColor4f(1.0, 1.0, 1.0, 1.0);
		}
	}

	if (scope) {
		IMB_freeImBuf(ibuf);
		ibuf = scope;

		if (ibuf->rect_float && ibuf->rect == NULL) {
			IMB_rect_from_float(ibuf);
		}

		display_buffer = (unsigned char *)ibuf->rect;
		format = GL_RGBA;
		type = GL_UNSIGNED_BYTE;
	}
	else {
		bool force_fallback = false;

		force_fallback |= (U.image_draw_method != IMAGE_DRAW_METHOD_GLSL);
		force_fallback |= (ibuf->dither != 0.0f);

		if (force_fallback) {
			/* Fallback to CPU based color space conversion */
			glsl_used = false;
			format = GL_RGBA;
			type = GL_UNSIGNED_BYTE;
			display_buffer = NULL;
		}
		else if (ibuf->rect_float) {
			display_buffer = ibuf->rect_float;

			if (ibuf->channels == 4) {
				format = GL_RGBA;
			}
			else if (ibuf->channels == 3) {
				format = GL_RGB;
			}
			else {
				BLI_assert(!"Incompatible number of channels for float buffer in sequencer");
				format = GL_RGBA;
				display_buffer = NULL;
			}

			type = GL_FLOAT;

			if (ibuf->float_colorspace) {
				glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->float_colorspace, true);
			}
			else {
				glsl_used = IMB_colormanagement_setup_glsl_draw_ctx(C, true);
			}
		}
		else if (ibuf->rect) {
			display_buffer = ibuf->rect;
			format = GL_RGBA;
			type = GL_UNSIGNED_BYTE;

			glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->rect_colorspace, false);
		}
		else {
			format = GL_RGBA;
			type = GL_UNSIGNED_BYTE;
			display_buffer = NULL;
		}

		/* there's a data to be displayed, but GLSL is not initialized
		 * properly, in this case we fallback to CPU-based display transform
		 */
		if ((ibuf->rect || ibuf->rect_float) && !glsl_used) {
			display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
			format = GL_RGBA;
			type = GL_UNSIGNED_BYTE;
		}
	}

	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glColor4f(1.0, 1.0, 1.0, 1.0);

	last_texid = glaGetOneInteger(GL_TEXTURE_2D);
	glEnable(GL_TEXTURE_2D);
	glGenTextures(1, (GLuint *)&texid);

	glBindTexture(GL_TEXTURE_2D, texid);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

	if (type == GL_FLOAT)
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, ibuf->x, ibuf->y, 0, format, type, display_buffer);
	else
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, format, type, display_buffer);

	glBegin(GL_QUADS);

	if (draw_overlay) {
		if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
			rctf tot_clip;
			tot_clip.xmin = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmin);
			tot_clip.ymin = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymin);
			tot_clip.xmax = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax);
			tot_clip.ymax = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax);

			glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin);
			glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax);
			glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmax, tot_clip.ymax);
			glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmax, tot_clip.ymin);
		}
		else if (sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
			glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
			glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
			glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax);
			glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
		}
	}
	else {
		glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin);
		glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax);
		glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax);
		glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin);
	}
	glEnd();
	glBindTexture(GL_TEXTURE_2D, last_texid);
	glDisable(GL_TEXTURE_2D);
	if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA)
		glDisable(GL_BLEND);
	glDeleteTextures(1, &texid);

	if (glsl_used)
		IMB_colormanagement_finish_glsl_draw();

	if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {

		float x1 = v2d->tot.xmin;
		float y1 = v2d->tot.ymin;
		float x2 = v2d->tot.xmax;
		float y2 = v2d->tot.ymax;

		/* border */
		setlinestyle(3);

		UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0);

		glBegin(GL_LINE_LOOP);
		glVertex2f(x1 - 0.5f, y1 - 0.5f);
		glVertex2f(x1 - 0.5f, y2 + 0.5f);
		glVertex2f(x2 + 0.5f, y2 + 0.5f);
		glVertex2f(x2 + 0.5f, y1 - 0.5f);
		glEnd();

		/* safety border */
		if ((sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) {
			float fac = 0.1;

			float a = fac * (x2 - x1);
			x1 += a;
			x2 -= a;

			a = fac * (y2 - y1);
			y1 += a;
			y2 -= a;

			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

			uiSetRoundBox(UI_CNR_ALL);
			uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);

			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

		}

		setlinestyle(0);
	}
	
	if (sseq->flag & SEQ_SHOW_GPENCIL) {
		if (is_imbuf) {
			/* draw grease-pencil (image aligned) */
			draw_gpencil_2dimage(C);
		}
	}

	if (!scope)
		IMB_freeImBuf(ibuf);
	
	/* ortho at pixel level */
	UI_view2d_view_restore(C);
	
	if (sseq->flag & SEQ_SHOW_GPENCIL) {
		if (is_imbuf) {
			/* draw grease-pencil (screen aligned) */
			draw_gpencil_view2d(C, 0);
		}
	}


	/* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not,
	 * for now just disable drawing since the strip frame will likely be offset */

	//if (sc->mode == SC_MODE_MASKEDIT) {
	if (0 && sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
		Mask *mask = BKE_sequencer_mask_get(scene);

		if (mask) {
			int width, height;
			float aspx = 1.0f, aspy = 1.0f;
			// ED_mask_get_size(C, &width, &height);

			//Scene *scene = CTX_data_scene(C);
			width = (scene->r.size * scene->r.xsch) / 100;
			height = (scene->r.size * scene->r.ysch) / 100;

			ED_mask_draw_region(mask, ar,
			                    0, 0,  /* TODO */
			                    width, height,
			                    aspx, aspy,
			                    FALSE, TRUE,
			                    NULL, C);
		}
	}

	if (cache_handle)
		IMB_display_buffer_release(cache_handle);
}
Exemple #19
0
int main()
{
	int gd=DETECT,gm;
	initgraph(&gd,&gm,"c://TC/bgi");
	setbkcolor(BROWN);
	setlinestyle(SOLID_LINE,1,3);
	GetVertices();
	GetEdges();
      //	getch();
	edgecost();
       getch();
	Redraw(adj);
   //PRIMS ALGO
    Vertex *v;
	int min_edge=MAX_NUM;
   int min_x, min_y,k,l,z;

   for(z=0;z<vcount;z++) //create near
	 near1[z]=-1;

   for(k=0;k<vcount;k++) //near array fill
     {
	for(l=0;l<vcount;l++)
	  {
		if(adj[k][l]<min_edge)
		    {min_edge=adj[k][l];
		      min_x=k;
		      min_y=l;
		     }
	    }
	}

    mincost=0;
   mincost+=min_edge;
  // int m=MAX_VERT;
   //int t[m][2];
   t[0][0]=min_x;
   t[0][1]=min_y;

   Edge_fill(&v[min_x],&v[min_y],RED,TRUE);
   getch();
    extra[min_x][min_y]=1;
    extra[min_y][min_x]=1;

   for(z=0;z<vcount;z++)   //near array update
   {
	if(adj[z][min_x]<adj[z][min_y])
	       near1[z]=min_x;
	else
		 near1[z]=min_y;
   }

   near1[min_x]=near1[min_y]=-1;
  // int k;
   int min_j;
   //prims algorithm
   for( z =1;z<vcount-1;z++)
   {  min_j=MAX_NUM;

	     for(int j=0;j<vcount;j++) //choose nearest vertex
	      {
		if(adj[j][near1[j]]<min_j && near1[j]!=-1)
		    min_j=j;
		    }

	t[z][0]=min_j;
	   t[z][1]=near1[min_j];

	 mincost+=adj[min_j][near1[min_j]];

	 extra[min_j][near1[min_j]]=1;
	  extra[near1[min_j]][min_j]=1;

	 near1[min_j]=-1;

	 for(k=0;k<vcount;k++)
	 {
		if(near1[k]!=-1 && adj[k][near1[k]]>adj[k][min_j])
		    near1[k]=min_j;

	}
}
      getch();
	Redraw(extra);
	gotoxy(2,4);

	printf("Minimum Cost of this spaning tree is : %d",mincost);

	getch();

	closegraph();
	return 0;
}
Exemple #20
0
void PontoGrafico::exibe(int x1, int y1, int, int) const
{
  setlinestyle(0, 0, this->c_grossura);
  putpixel(this->c_x + x1, this->c_y + y1, this->c_cor);
  setlinestyle(0, 0, 1);
}
//***************
void Line3D(int x1,int y1, int x2, int y2){
  setlinestyle(0,0,1);setcolor(8);
  line(x1,y1,x2,y2);
  setlinestyle(0,0,1);setcolor(15);
  line(x1,y1+1,x2,y1+1);
}
Exemple #22
0
void PintaFun::desenha_ponto(const COORDENADA& x1, const COORDENADA& y1,
                             const COORDENADA& x2, const COORDENADA& y2,
                             MouseFun& mouse, MOUSE_EVENTO* evento)
{
  BOLEANO pinta = FALSO;
  COORDENADA antx, anty;

  if (*evento == MOUSE_DOWN)
    pinta = VERDADEIRO;
  else
    if (*evento == MOUSE_UP)
    {
      if (pinta)
      {
        PontoGrafico* ponto = new PontoGrafico(mouse.x() - this->x1(), mouse.y() - this->y1());
        c_lista.ins(ponto);
        ponto->exibe(this->x1(), this->y1(),
                     this->x2(), this->y2());
        //putpixel(mouse.x(), mouse.y(), 15);
        pinta = FALSO;
      }
    }
    else
      if (*evento == MOUSE_UP_DIREITO)
        return;

  while (mouse.verifica(x1, y1, x2, y2))
  {
    {
      COORDENADA ax, ay;
      ax = mouse.x();
      ay = mouse.y();

      setcolor(7);
      setlinestyle(1, 0, 0);
      setwritemode(XOR_PUT);
      line(ax, this->y1(), ax, this->y2());
      line(this->x1(), ay, this->x2(), ay);

      *evento = mouse.evento_pause();

      line(ax, this->y1(), ax, this->y2());
      line(this->x1(), ay, this->x2(), ay);
      setwritemode(COPY_PUT);
      setlinestyle(SOLID_LINE, 0, 0);
    }

    if (*evento == MOUSE_DOWN)
      pinta = VERDADEIRO;
    else
      if (*evento == MOUSE_UP)
      {
        if (pinta)
        {
          PontoGrafico* ponto = new PontoGrafico(mouse.x() - this->x1(), mouse.y() - this->y1());
          c_lista.ins(ponto);
          ponto->exibe(this->x1(), this->y1(),
                       this->x2(), this->y2());
          //putpixel(mouse.x(), mouse.y(), 15);
          pinta = FALSO;
        }
      }
      else
        if (*evento == MOUSE_UP_DIREITO)
          return;
  }
}
Exemple #23
0
/* function to draw markers */
static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
{
	float xpos, ypixels, xscale, yscale;
	int icon_id= 0;
	
	xpos = marker->frame;
	
	/* no time correction for framelen! space is drawn with old values */
	ypixels= v2d->mask.ymax-v2d->mask.ymin;
	UI_view2d_getscale(v2d, &xscale, &yscale);
	
	glScalef(1.0f/xscale, 1.0f, 1.0f);
	
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);			
	
	/* vertical line - dotted */
	// NOTE: currently only used for sequencer 
	if (flag & DRAW_MARKERS_LINES) {
		setlinestyle(3);
		
		if (marker->flag & SELECT)
			glColor4ub(255, 255, 255, 96);
		else
			glColor4ub(0, 0, 0, 96);
		
		glBegin(GL_LINES);
			glVertex2f((xpos*xscale)+0.5f, 12.0f);
			glVertex2f((xpos*xscale)+0.5f, 34.0f*yscale); /* a bit lazy but we know it cant be greater then 34 strips high */
		glEnd();
		
		setlinestyle(0);
	}
	
	/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
	if (flag & DRAW_MARKERS_LOCAL) {
		icon_id= (marker->flag & ACTIVE) ? ICON_PMARKER_ACT : 
		(marker->flag & SELECT) ? ICON_PMARKER_SEL : 
		ICON_PMARKER;
	}
	else {
		icon_id= (marker->flag & SELECT) ? ICON_MARKER_HLT : 
		ICON_MARKER;
	}
	
	UI_icon_draw(xpos*xscale-5.0f, 16.0f, icon_id);
	
	glBlendFunc(GL_ONE, GL_ZERO);
	glDisable(GL_BLEND);
	
	/* and the marker name too, shifted slightly to the top-right */
	if (marker->name && marker->name[0]) {
		float x, y;
		
		if (marker->flag & SELECT) {
			UI_ThemeColor(TH_TEXT_HI);
			x= xpos*xscale + 4.0f;
			y= (ypixels <= 39.0f)? (ypixels-10.0f) : 29.0f;
		}
		else {
			UI_ThemeColor(TH_TEXT);
			if((marker->frame <= cfra) && (marker->frame+5 > cfra)) {
				x= xpos*xscale + 4.0f;
				y= (ypixels <= 39.0f)? (ypixels - 10.0f) : 29.0f;
			}
			else {
				x= xpos*xscale + 4.0f;
				y= 17.0f;
			}
		}
		UI_DrawString(x, y, marker->name);
	}
	
	glScalef(xscale, 1.0f, 1.0f);
}
Exemple #24
0
void PintaFun::desenha_linha(const COORDENADA& x1, const COORDENADA& y1,
                             const COORDENADA& x2, const COORDENADA& y2,
                             MouseFun& mouse, MOUSE_EVENTO* evento)
{
  BOLEANO pinta = FALSO;
  COORDENADA antx, anty;

  while (mouse.verifica(x1, y1, x2, y2))
  {
    {
      COORDENADA ax = mouse.x(), ay = mouse.y();

      setcolor(7);
      setlinestyle(1, 0, 0);
      setwritemode(XOR_PUT);

      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      if (pinta)
      {
        setcolor(12);
        setlinestyle(1, 0, 0);
        line(antx, anty, ax, ay);
      }

      *evento = mouse.evento_pause();

      if (pinta)
        line(antx, anty, ax, ay);

      setcolor(7);
      setlinestyle(1, 0, 0);
      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      setwritemode(COPY_PUT);
      setlinestyle(SOLID_LINE, 0, 0);
    }

    if (*evento == MOUSE_DOWN)
    {
      mouse.area(x1, y1, x2, y2);
      pinta = VERDADEIRO;
      antx = mouse.x();
      anty = mouse.y();
    }
    else
      if (*evento == MOUSE_UP)
      {
        if (pinta)
        {
          /*
          setcolor(15);
          line(antx, anty, mouse.x(), mouse.y());
          */
          LinhaGrafico* linha = new LinhaGrafico(antx - this->x1(), anty - this->y1(),
                                                 mouse.x() - this->x1(), mouse.y() - this->y1());
          c_lista.ins(linha);
          linha->exibe(this->x1(), this->y1(),
                       this->x2(), this->y2());

          mouse.area(0, 0, getmaxx(), getmaxy());

          pinta = FALSO;
        }
      }
      else
        if (*evento == MOUSE_UP_DIREITO)
          return;
  }
}
Exemple #25
0
/* This is called twice from space_graph.c -> graph_main_area_draw()
 * Unselected then selected F-Curves are drawn so that they do not occlude each other.
 */
void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid *grid, short sel)
{
	ListBase anim_data = {NULL, NULL};
	bAnimListElem *ale;
	int filter;
	
	/* build list of curves to draw */
	filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
	filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL));
	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
		
	/* for each curve:
	 *	draw curve, then handle-lines, and finally vertices in this order so that 
	 *  the data will be layered correctly
	 */
	for (ale = anim_data.first; ale; ale = ale->next) {
		FCurve *fcu = (FCurve *)ale->key_data;
		FModifier *fcm = find_active_fmodifier(&fcu->modifiers);
		AnimData *adt = ANIM_nla_mapping_get(ac, ale);
		
		/* map keyframes for drawing if scaled F-Curve */
		if (adt)
			ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); 
		
		/* draw curve:
		 *	- curve line may be result of one or more destructive modifiers or just the raw data,
		 *	  so we need to check which method should be used
		 *	- controls from active modifier take precedence over keyframes
		 *	  (XXX! editing tools need to take this into account!)
		 */
		 
		/* 1) draw curve line */
		{
			/* set color/drawing style for curve itself */
			if (BKE_fcurve_is_protected(fcu)) {
				/* protected curves (non editable) are drawn with dotted lines */
				setlinestyle(2);
			}
			if (((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) || (fcu->flag & FCURVE_MUTED)) {
				/* muted curves are drawn in a grayish hue */
				/* XXX should we have some variations? */
				UI_ThemeColorShade(TH_HEADER, 50);
			}
			else {
				/* set whatever color the curve has set 
				 *	- unselected curves draw less opaque to help distinguish the selected ones
				 */
				glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], fcurve_display_alpha(fcu));
			}
			
			/* draw active F-Curve thicker than the rest to make it stand out */
			if (fcu->flag & FCURVE_ACTIVE) {
				glLineWidth(2.0);
			}
			
			/* anti-aliased lines for less jagged appearance */
			if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
			glEnable(GL_BLEND);
			
			/* draw F-Curve */
			if ((fcu->modifiers.first) || (fcu->flag & FCURVE_INT_VALUES)) {
				/* draw a curve affected by modifiers or only allowed to have integer values 
				 * by sampling it at various small-intervals over the visible region 
				 */
				draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid);
			}
			else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
				/* just draw curve based on defined data (i.e. no modifiers) */
				if (fcu->bezt)
					//draw_fcurve_curve_bezts(ac, ale->id, fcu, &ar->v2d);
					draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid);  // XXX: better to do an optimised integration here instead, but for now, this works
				else if (fcu->fpt)
					draw_fcurve_curve_samples(ac, ale->id, fcu, &ar->v2d);
			}
			
			/* restore settings */
			setlinestyle(0);
			glLineWidth(1.0);
			
			if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
			glDisable(GL_BLEND);
		}
		
		/* 2) draw handles and vertices as appropriate based on active 
		 *	- if the option to only show controls if the F-Curve is selected is enabled, we must obey this
		 */
		if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) {
			if (fcurve_are_keyframes_usable(fcu) == 0) {
				/* only draw controls if this is the active modifier */
				if ((fcu->flag & FCURVE_ACTIVE) && (fcm)) {
					switch (fcm->type) {
						case FMODIFIER_TYPE_ENVELOPE: /* envelope */
							draw_fcurve_modifier_controls_envelope(fcm, &ar->v2d);
							break;
					}
				}
			}
			else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) {
				short mapping_flag = ANIM_get_normalization_flags(ac);
				float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag);

				glPushMatrix();
				glScalef(1.0f, unit_scale, 1.0f);

				if (fcu->bezt) {
					int do_handles = draw_fcurve_handles_check(sipo, fcu);
					
					if (do_handles) {
						/* only draw handles/vertices on keyframes */
						glEnable(GL_BLEND);
						draw_fcurve_handles(sipo, fcu);
						glDisable(GL_BLEND);
					}
					
					draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY), unit_scale);
				}
				else {
					/* samples: only draw two indicators at either end as indicators */
					draw_fcurve_samples(sipo, ar, fcu);
				}

				glPopMatrix();
			}
		}
		
		/* 3) draw driver debugging stuff */
		if ((ac->datatype == ANIMCONT_DRIVERS) && (fcu->flag & FCURVE_ACTIVE)) {
			graph_draw_driver_debug(ac, ale->id, fcu);
		}
		
		/* undo mapping of keyframes for drawing if scaled F-Curve */
		if (adt)
			ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); 
	}
	
	/* free list of curves */
	BLI_freelistN(&anim_data);
}
Exemple #26
0
void PintaFun::desenha_circulo(const COORDENADA& x1, const COORDENADA& y1,
                               const COORDENADA& x2, const COORDENADA& y2,
                               MouseFun& mouse, MOUSE_EVENTO* evento)
{
  BOLEANO pinta = FALSO;
  COORDENADA antx, anty;
  ConversorFun conv;
  int raio;

  while (mouse.verifica(x1, y1, x2, y2) || pinta)
  {
    {
      COORDENADA ax = mouse.x(), ay = mouse.y();

      if (pinta)
      {
        double r, a;
        conv.converte(mouse.x(), mouse.y(), &a, &r, antx, anty);
        raio = (int) r;
      }

      setcolor(7);
      setlinestyle(1, 0, 0);
      setwritemode(XOR_PUT);

      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      if (pinta)
      {
        setcolor(10);
        setlinestyle(0, 0, 0);
        circulo(x1, y1, x2, y2, antx, anty, raio);
      }

      *evento = mouse.evento_pause();

      if (pinta)
        circulo(x1, y1, x2, y2, antx, anty, raio);

      setcolor(7);
      setlinestyle(1, 0, 0);
      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      setwritemode(COPY_PUT);
      setlinestyle(SOLID_LINE, 0, 0);
    }

    if (*evento == MOUSE_DOWN)
    {
      pinta = VERDADEIRO;
      antx = mouse.x();
      anty = mouse.y();
    }
    else
      if (*evento == MOUSE_UP)
      {
        if (pinta)
        {
          /*
          setcolor(15);
          setviewport(x1, y1, x2, y2, 1);*/
          //circle(antx - x1/*12*/, anty - y1/*26*/, raio);
          //setviewport(0, 0, getmaxx(), getmaxy(), 0);

          CirculoGrafico* cir = new CirculoGrafico(antx - this->x1() /* - 5*/,
                                                   anty - this->y1() /*- 20*/,
                                                   raio);
          c_lista.ins(cir);
          cir->exibe(this->x1(), this->y1(), this->x2(), this->y2());

          pinta = FALSO;
        }
      }
      else
        if (*evento == MOUSE_UP_DIREITO)
          return;
  }
}
/* function to draw markers */
static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
{
	float xpos, ypixels, xscale, yscale;
	int icon_id = 0;
	
	xpos = marker->frame;
	
	/* no time correction for framelen! space is drawn with old values */
	ypixels = BLI_rcti_size_y(&v2d->mask);
	UI_view2d_getscale(v2d, &xscale, &yscale);
	
	glScalef(1.0f / xscale, 1.0f, 1.0f);
	
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	/* vertical line - dotted */
#ifdef DURIAN_CAMERA_SWITCH
	if ((marker->camera) || (flag & DRAW_MARKERS_LINES))
#else
	if (flag & DRAW_MARKERS_LINES)
#endif
	{
		setlinestyle(3);
		
		if (marker->flag & SELECT)
			glColor4ub(255, 255, 255, 96);
		else
			glColor4ub(0, 0, 0, 96);
		
		glBegin(GL_LINES);
		glVertex2f((xpos * xscale) + 0.5f, 12.0f);
		glVertex2f((xpos * xscale) + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
		glEnd();
		
		setlinestyle(0);
	}
	
	/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
	if (flag & DRAW_MARKERS_LOCAL) {
		icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
		          (marker->flag & SELECT) ? ICON_PMARKER_SEL :
		          ICON_PMARKER;
	}
	else {
		icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT :
		          ICON_MARKER;
	}
	
	UI_icon_draw(xpos * xscale - 0.45f * UI_DPI_ICON_SIZE, UI_DPI_ICON_SIZE, icon_id);
	
	glDisable(GL_BLEND);
	
	/* and the marker name too, shifted slightly to the top-right */
	if (marker->name && marker->name[0]) {
		float x, y;

		/* minimal y coordinate which wouldn't be occluded by scroll */
		int min_y = 17.0f * UI_DPI_FAC;
		
		if (marker->flag & SELECT) {
			UI_ThemeColor(TH_TEXT_HI);
			x = xpos * xscale + 4.0f * UI_DPI_FAC;
			y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
			y = max_ii(y, min_y);
		}
		else {
			UI_ThemeColor(TH_TEXT);
			if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) {
				x = xpos * xscale + 8.0f * UI_DPI_FAC;
				y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
				y = max_ii(y, min_y);
			}
			else {
				x = xpos * xscale + 8.0f * UI_DPI_FAC;
				y = 17.0f * UI_DPI_FAC;
			}
		}

#ifdef DURIAN_CAMERA_SWITCH
		if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) {
			float col[4];
			glGetFloatv(GL_CURRENT_COLOR, col);
			col[3] = 0.4;
			glColor4fv(col);
		}
#endif

		UI_DrawString(x, y, marker->name);
	}
	
	glScalef(xscale, 1.0f, 1.0f);
}
Exemple #28
0
/* draws uv's in the image space */
static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
{
	ToolSettings *ts;
	Mesh *me= obedit->data;
	EditMesh *em;
	EditFace *efa, *efa_act;
	MTFace *tf, *activetf = NULL;
	DerivedMesh *finaldm, *cagedm;
	char col1[4], col2[4];
	float pointsize;
	int drawfaces, interpedges, lastsel, sel;
	Image *ima= sima->image;
 	
	em= BKE_mesh_get_editmesh(me);
	activetf= EM_get_active_mtface(em, &efa_act, NULL, 0); /* will be set to NULL if hidden */

	ts= scene->toolsettings;

	drawfaces= draw_uvs_face_check(scene);
	if(ts->uv_flag & UV_SYNC_SELECTION)
		interpedges= (ts->selectmode & SCE_SELECT_VERTEX);
	else
		interpedges= (ts->uv_selectmode == UV_SELECT_VERTEX);
	
	/* draw other uvs */
	if(sima->flag & SI_DRAW_OTHER)
		draw_uvs_other(sima, scene, obedit, activetf);

	/* 1. draw shadow mesh */
	
	if(sima->flag & SI_DRAWSHADOW) {
		/* first try existing derivedmesh */
		if(!draw_uvs_dm_shadow(em->derivedFinal)) {
			/* create one if it does not exist */
			cagedm = editmesh_get_derived_cage_and_final(scene, obedit, em, &finaldm, CD_MASK_BAREMESH|CD_MASK_MTFACE);

			/* when sync selection is enabled, all faces are drawn (except for hidden)
			 * so if cage is the same as the final, theres no point in drawing this */
			if(!((ts->uv_flag & UV_SYNC_SELECTION) && (cagedm == finaldm)))
				draw_uvs_dm_shadow(finaldm);
			
			/* release derivedmesh again */
			if(cagedm != finaldm) cagedm->release(cagedm);
			finaldm->release(finaldm);
		}
	}
	
	/* 2. draw colored faces */
	
	if(sima->flag & SI_DRAW_STRETCH) {
		draw_uvs_stretch(sima, scene, em, activetf);
	}
	else if(me->drawflag & ME_DRAWFACES) {
		/* draw transparent faces */
		UI_GetThemeColor4ubv(TH_FACE, col1);
		UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
		
		for(efa= em->faces.first; efa; efa= efa->next) {
			tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
			
			if(uvedit_face_visible(scene, ima, efa, tf)) {
				efa->tmp.p = tf;
				if(tf==activetf) continue; /* important the temp pointer is set above */

				if(uvedit_face_selected(scene, efa, tf))
					glColor4ubv((GLubyte *)col2);
				else
					glColor4ubv((GLubyte *)col1);
					
				glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
					glVertex2fv(tf->uv[0]);
					glVertex2fv(tf->uv[1]);
					glVertex2fv(tf->uv[2]);
					if(efa->v4) glVertex2fv(tf->uv[3]);
				glEnd();
			}
			else {
				if(tf == activetf)
					activetf= NULL;
				efa->tmp.p = NULL;
			}
		}
		glDisable(GL_BLEND);
	}
	else {
		/* would be nice to do this within a draw loop but most below are optional, so it would involve too many checks */
		for(efa= em->faces.first; efa; efa= efa->next) {
			tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);

			if(uvedit_face_visible(scene, ima, efa, tf)) {		
				efa->tmp.p = tf;
			}
			else {
				if(tf == activetf)
					activetf= NULL;
				efa->tmp.p = NULL;
			}
		}
		
	}
	
	/* 3. draw active face stippled */

	if(activetf) {
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		UI_ThemeColor4(TH_EDITMESH_ACTIVE);

		glEnable(GL_POLYGON_STIPPLE);
		glPolygonStipple(stipple_quarttone);

		glBegin(efa_act->v4? GL_QUADS: GL_TRIANGLES);
			glVertex2fv(activetf->uv[0]);
			glVertex2fv(activetf->uv[1]);
			glVertex2fv(activetf->uv[2]);
			if(efa_act->v4) glVertex2fv(activetf->uv[3]);
		glEnd();

		glDisable(GL_POLYGON_STIPPLE);
		glDisable(GL_BLEND);
	}
	
	/* 4. draw edges */

	if(sima->flag & SI_SMOOTH_UV) {
		glEnable(GL_LINE_SMOOTH);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}
	
	switch(sima->dt_uv) {
		case SI_UVDT_DASH:
			for(efa= em->faces.first; efa; efa= efa->next) {
				tf= (MTFace *)efa->tmp.p; /* visible faces cached */

				if(tf) {
					cpack(0x111111);

					glBegin(GL_LINE_LOOP);
						glVertex2fv(tf->uv[0]);
						glVertex2fv(tf->uv[1]);
						glVertex2fv(tf->uv[2]);
						if(efa->v4) glVertex2fv(tf->uv[3]);
					glEnd();
				
					setlinestyle(2);
					cpack(0x909090);

					glBegin(GL_LINE_STRIP);
						glVertex2fv(tf->uv[0]);
						glVertex2fv(tf->uv[1]);
					glEnd();
		
					glBegin(GL_LINE_STRIP);
						glVertex2fv(tf->uv[0]);
						if(efa->v4) glVertex2fv(tf->uv[3]);
						else glVertex2fv(tf->uv[2]);
					glEnd();
		
					glBegin(GL_LINE_STRIP);
						glVertex2fv(tf->uv[1]);
						glVertex2fv(tf->uv[2]);
						if(efa->v4) glVertex2fv(tf->uv[3]);
					glEnd();

					setlinestyle(0);
				}
			}
			break;
		case SI_UVDT_BLACK: /* black/white */
		case SI_UVDT_WHITE: 
			if(sima->dt_uv==SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f);
			else glColor3f(0.0f, 0.0f, 0.0f);

			for(efa= em->faces.first; efa; efa= efa->next) {
				tf= (MTFace *)efa->tmp.p; /* visible faces cached */

				if(tf) {
					glBegin(GL_LINE_LOOP);
						glVertex2fv(tf->uv[0]);
						glVertex2fv(tf->uv[1]);
						glVertex2fv(tf->uv[2]);
						if(efa->v4) glVertex2fv(tf->uv[3]);
					glEnd();
				}
			}
			break;
		case SI_UVDT_OUTLINE:
			glLineWidth(3);
			cpack(0x0);
			
			for(efa= em->faces.first; efa; efa= efa->next) {
				tf= (MTFace *)efa->tmp.p; /* visible faces cached */

				if(tf) {
					glBegin(GL_LINE_LOOP);
						glVertex2fv(tf->uv[0]);
						glVertex2fv(tf->uv[1]);
						glVertex2fv(tf->uv[2]);
						if(efa->v4) glVertex2fv(tf->uv[3]);
					glEnd();
				}
			}
			
			glLineWidth(1);
			col2[0] = col2[1] = col2[2] = 192; col2[3] = 255;
			glColor4ubv((unsigned char *)col2); 
			
			if(me->drawflag & ME_DRAWEDGES) {
				UI_GetThemeColor4ubv(TH_VERTEX_SELECT, col1);
				lastsel = sel = 0;

				if(interpedges) {
					glShadeModel(GL_SMOOTH);

					for(efa= em->faces.first; efa; efa= efa->next) {
						tf= (MTFace *)efa->tmp.p; /* visible faces cached */

						if(tf) {
							glBegin(GL_LINE_LOOP);
							sel = (uvedit_uv_selected(scene, efa, tf, 0)? 1 : 0);
							if(sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
							glVertex2fv(tf->uv[0]);
							
							sel = uvedit_uv_selected(scene, efa, tf, 1)? 1 : 0;
							if(sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
							glVertex2fv(tf->uv[1]);
							
							sel = uvedit_uv_selected(scene, efa, tf, 2)? 1 : 0;
							if(sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
							glVertex2fv(tf->uv[2]);
							
							if(efa->v4) {
								sel = uvedit_uv_selected(scene, efa, tf, 3)? 1 : 0;
								if(sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
								glVertex2fv(tf->uv[3]);
							}
							
							glEnd();
						}
					}

					glShadeModel(GL_FLAT);
				}
				else {
					for(efa= em->faces.first; efa; efa= efa->next) {
						tf= (MTFace *)efa->tmp.p; /* visible faces cached */

						if(tf) {
							glBegin(GL_LINES);
							sel = (uvedit_edge_selected(scene, efa, tf, 0)? 1 : 0);
							if(sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
							glVertex2fv(tf->uv[0]);
							glVertex2fv(tf->uv[1]);
							
							sel = uvedit_edge_selected(scene, efa, tf, 1)? 1 : 0;
							if(sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
							glVertex2fv(tf->uv[1]);
							glVertex2fv(tf->uv[2]);
							
							sel = uvedit_edge_selected(scene, efa, tf, 2)? 1 : 0;
							if(sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
							glVertex2fv(tf->uv[2]);
							
							if(efa->v4) {
								glVertex2fv(tf->uv[3]);

								sel = uvedit_edge_selected(scene, efa, tf, 3)? 1 : 0;
								if(sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
								glVertex2fv(tf->uv[3]);
							}

							glVertex2fv(tf->uv[0]);
							
							glEnd();
						}
					}
				}
			}
			else {
				/* no nice edges */
				for(efa= em->faces.first; efa; efa= efa->next) {
					tf= (MTFace *)efa->tmp.p; /* visible faces cached */

					if(tf) {
						glBegin(GL_LINE_LOOP);
							glVertex2fv(tf->uv[0]);
							glVertex2fv(tf->uv[1]);
							glVertex2fv(tf->uv[2]);
							if(efa->v4) glVertex2fv(tf->uv[3]);
						glEnd();
					}
				}
			}
			
			break;
	}

	if(sima->flag & SI_SMOOTH_UV) {
		glDisable(GL_LINE_SMOOTH);
		glDisable(GL_BLEND);
	}

	/* 5. draw face centers */

	if(drawfaces) {
		float cent[2];
		
		pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE);
		glPointSize(pointsize); // TODO - drawobject.c changes this value after - Investigate!
		
	    /* unselected faces */
		UI_ThemeColor(TH_WIRE);

		bglBegin(GL_POINTS);
		for(efa= em->faces.first; efa; efa= efa->next) {
			tf= (MTFace *)efa->tmp.p; /* visible faces cached */

			if(tf && !uvedit_face_selected(scene, efa, tf)) {
				uv_center(tf->uv, cent, efa->v4 != NULL);
				bglVertex2fv(cent);
			}
		}
		bglEnd();

		/* selected faces */
		UI_ThemeColor(TH_FACE_DOT);

		bglBegin(GL_POINTS);
		for(efa= em->faces.first; efa; efa= efa->next) {
			tf= (MTFace *)efa->tmp.p; /* visible faces cached */

			if(tf && uvedit_face_selected(scene, efa, tf)) {
				uv_center(tf->uv, cent, efa->v4 != NULL);
				bglVertex2fv(cent);
			}
		}
		bglEnd();
	}

	/* 6. draw uv vertices */
	
	if(drawfaces != 2) { /* 2 means Mesh Face Mode */
	    /* unselected uvs */
		UI_ThemeColor(TH_VERTEX);
		pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
		glPointSize(pointsize);
	
		bglBegin(GL_POINTS);
		for(efa= em->faces.first; efa; efa= efa->next) {
			tf= (MTFace *)efa->tmp.p; /* visible faces cached */

			if(tf) {
				if(!uvedit_uv_selected(scene, efa, tf, 0))
					bglVertex2fv(tf->uv[0]);
				if(!uvedit_uv_selected(scene, efa, tf, 1))
					bglVertex2fv(tf->uv[1]);
				if(!uvedit_uv_selected(scene, efa, tf, 2))
					bglVertex2fv(tf->uv[2]);
				if(efa->v4 && !uvedit_uv_selected(scene, efa, tf, 3))
					bglVertex2fv(tf->uv[3]);
			}
		}
		bglEnd();
	
		/* pinned uvs */
		/* give odd pointsizes odd pin pointsizes */
	    glPointSize(pointsize*2 + (((int)pointsize % 2)? (-1): 0));
		cpack(0xFF);
	
		bglBegin(GL_POINTS);
		for(efa= em->faces.first; efa; efa= efa->next) {
			tf= (MTFace *)efa->tmp.p; /* visible faces cached */

			if(tf) {
				if(tf->unwrap & TF_PIN1)
					bglVertex2fv(tf->uv[0]);
				if(tf->unwrap & TF_PIN2)
					bglVertex2fv(tf->uv[1]);
				if(tf->unwrap & TF_PIN3)
					bglVertex2fv(tf->uv[2]);
				if(efa->v4 && (tf->unwrap & TF_PIN4))
					bglVertex2fv(tf->uv[3]);
			}
		}
		bglEnd();
	
		/* selected uvs */
		UI_ThemeColor(TH_VERTEX_SELECT);
	    glPointSize(pointsize);
	
		bglBegin(GL_POINTS);
		for(efa= em->faces.first; efa; efa= efa->next) {
			tf= (MTFace *)efa->tmp.p; /* visible faces cached */

			if(tf) {
				if(uvedit_uv_selected(scene, efa, tf, 0))
					bglVertex2fv(tf->uv[0]);
				if(uvedit_uv_selected(scene, efa, tf, 1))
					bglVertex2fv(tf->uv[1]);
				if(uvedit_uv_selected(scene, efa, tf, 2))
					bglVertex2fv(tf->uv[2]);
				if(efa->v4 && uvedit_uv_selected(scene, efa, tf, 3))
					bglVertex2fv(tf->uv[3]);
			}
		}
		bglEnd();	
	}

	glPointSize(1.0);
	BKE_mesh_end_editmesh(obedit->data, em);
}
void main()
{
int gd=VGA,gm=VGAHI,errorcode,area,i,j,play=1,rndplay,rac,r,ch,chh,n=1,speed=151,sp=1,si=1,carx,cary,gear=0,aspeed,booster=100,drumx,drumy,drumv,drumx1,drumy1,spp,coin=200;
int life_=10;
int fire=20;
char info[4];
int soun;
char *buff;
char *fir;
char *boost;
int mouse=23;
int x,y,button;


char *tyre1;
float feul=100;
char *car1buf;
char *pcar4buf;
char *fcar5buf;

int recsize;
FILE *fp;
struct record
{
int coins;
int lifes;
float feuls;
int speeds;
int boosters;
int gear_;
int fire_;
}rec;

recsize=sizeof(rec);

initgraph(&gd,&gm,"c:\bagger");
errorcode = graphresult();
if (errorcode != grOk)
{
   printf("Graphics error: %s\n", grapherrormsg(errorcode));
   printf("Press any key to halt:");
   getch();

   exit(1);
}
	start=ptr=tune;
	sp_off=inportb(97);
	sp_on=sp_off|3;
	duration=0;

setcolor(YELLOW);
settextstyle(7,0,15);
outtextxy(100-20,100,"R");

settextstyle(7,0,15);
outtextxy(495-20,100,"E");

setcolor(LIGHTBLUE);
settextstyle(7,0,7);
outtextxy(198-20,130,"UN   LIF");

setcolor(BLUE);
setlinestyle(0,0,3);
line(275,155,385,155);
line(275-2,160,385-2,160);
line(275-4,165,385-4,165);
line(275-6,170,385-6,170);
line(275-8,175,385-8,175);
line(275-9,180,385-9,180);
line(275-10,185,385-10,185);
line(275-12,190,385-12,190);

setcolor(YELLOW);
settextstyle(10,0,7);
outtextxy(295,95,"4");


setcolor(LIGHTBLUE);
for(i=1;i<=465;i++)
{
line(80,228,80+i,228);
delay(5);
}
for(i=1;i<20;i++)
{
line(80,228+i,545,228+i);
delay(7);
}
delay(500);
setcolor(LIGHTRED);
settextstyle(8,0,5);
setusercharsize(2,1,1,2);
textdisp1(80,225,"Run For Life",RED,LIGHTRED);


settextstyle(8,0,6);
setusercharsize(2,1,1,1);
setcolor(YELLOW);
outtextxy(235,285,"_By_");
setcolor(LIGHTRED);
textdisp1(10,325,"Rishabh Tripathi",LIGHTBLUE,BLUE);

cleardevice();
setcolor(LIGHTRED);
settextstyle(8,0,5);
textdisp(10,200,"What happened next...?");
settextstyle(8,0,5);
setusercharsize(2,1,1,1);
textdisp(15,250,"...Comming Soon");
textdisp1(15,250,"...Comming Soon",RED,LIGHTRED);
delay(2000);
cleardevice();
settextstyle(2,0,5);
outtextxy(100,50,"Programmed by : Rishabh Tripathi");
outtextxy(100,70,"Dedicated to my family...");
outtextxy(100,90,"Specially thanks to Shishir, Anurag and Neeraj");
outtextxy(100,120,"Your feedback are neccessary for us...");
outtextxy(100,150,"Contect me on...");
outtextxy(100,170,"*****@*****.**");
outtextxy(100,200,"Thanks for playing...");
	playtune();
      nosound();
delay(1000);
cleardevice();
}
Exemple #30
0
void 
xlinax() {
	char ktemp[9];
	int lpower;
	int ia, ib, igdlog, jdiv, jpower, jstep, jtick, 
	 mds, nds, ndsu, ntick, nxdivu;
	float divlog, divtry, factor, grdlog, power, skfudge, 
	 value, valuei, xdivu, xgrdmn, xgrdmx, xref, xrefi, xtick, xticki, 
	 xvpmax, xvpmin, yloc, ypow, yvpmax, yvpmin;
	static char kvalue[17] = "                ";
	static char kpower[9] = "        ";


	/*=====================================================================
	 * PURPOSE:  To produce a linearly-scaled axis at the bottom and/or
	 *           top of the current plot window.
	 *=====================================================================
	 * MODULE/LEVEL:  gem/4
	 *=====================================================================
	 * GLOBAL INPUT:
	 *    MACH:    VSMALL
	 *    GEM:     LXDIV, XDIV, LNXDIV, NXDIV, CHHT, CHWID, LXREV,
	 *             XPMNU, XPMXU, XIMNZ, XIMXZ,
	 *             LBOTAX, LBOTTC, LTOPAX, LTOPTC,
	 *             IHORZ, IVERT, XMPIP1, XMPIP2,
	 *             LXGRD, IXGRD, IWIDTH, ISKWIDTH, ITHIN, SKDEVFUDGE
	 *=====================================================================
	 * GLOBAL OUTPUT:
	 *    GEM:     AXWBOT, AXWTOP
	 *=====================================================================
	 * SUBROUTINES CALLED:
	 *    SACLIB:  CNVITA, LJUST, SETLINESTYLE, LINE, PLTEXT, CNVFTA, 
	 *             SETTEXTJUST, SETLINEWIDTH, GETVPORT
	 *=====================================================================
	 * LOCAL VARIABLES:
	 *    xdivu:   Divison spacing used.
	 *    lpower:  Set to .TRUE. if there is a multiplying scale factor.
	 *    power:   Multiplying scale factor.
	 *    kpower:  Character string containing formatted scale factor.
	 *    ypow:    Y location in plot coordinates of scale factor.
	 *    divtry:  Trial division spacing.
	 *    jstep:   Integer trial step size (constrained to be 10, 5 or 2).
	 *    xgrdmn:  Minimum labeled grid value (including scale factor).
	 *    xgrdmx:  Maximum labeled grid value (including scale factor).
	 *    value:   Labeled grid value excluding scale factor.
	 *    valuei:  Increment in VALUE.
	 *    kvalue:  Character string containing formatted label value.
	 *    xref:    Location of labeled grid value in plot coordinates.
	 *    xrefi:   Increment in XREF.
	 *=====================================================================
	 * ASSUMPTIONS:
	 * - plmap has set up world to plot coordiate mapping.
	 * - Text orientation is horizontal.
	 *=====================================================================
	 * MODIFICATION HISTORY:
	 *    920526:  Added line-width. TEXT is always line-width THIN!
	 *    830929:  Added secondary tick marks.
	 *    830927:  Moved grid drawing logic into its own do loop.
	 *    830223:  Fixed logic in computing annotation format.
	 *    820928:  Cleaned up and documented.
	 *    810120:  Original PRIME version.
	 *===================================================================== */
	/* PROCEDURE: */
         settextangle(TEXT_HORIZONTAL);

	/* - Determine division spacing.  There are three possibilities:
	 *   (1) The division spacing is set by user (LXDIV=.TRUE.).
	 *   (2) The (approximate) number of divsions is set (LNXDIV=.TRUE.).
	 *   (3) "Nice" division spacings are calculated. */
	if( cmgem.xdiv_spacing_on ){
          xdivu = cmgem.xdiv_spacing;
          power = log10( xdivu );
          if( power < 0. )
            power = power - 1.;
          jpower = power;
        } else {
          if( cmgem.xdiv_number_on ){
            nxdivu = cmgem.xdiv_number;
          } else {
            nxdivu = (fabs( cmgem.uplot.xmax - cmgem.uplot.xmin )/(FDIVSP*cmgem.chht)) + .001;
            if( nxdivu < 5 )
              nxdivu = 5;
          }
          divtry = (cmgem.zdata.xmax - cmgem.zdata.xmin)/nxdivu;
          if( divtry > 0. ){
            power = log10( divtry );
          } else {
            power = 0.;
          }
          if( power < 0. )
            power = power - 1.;
          jpower = power;
          
          /* -- Limit divison spacings to steps of 10, 5, or 2 [cases (2) and (3)]. */
          jstep = divtry*(powi(10.,-jpower));
          if( jstep > 5 ){
            jstep = 1;
            jpower = jpower + 1;
            /* power = power + 1.; */
          } else if( jstep > 2 ) {
            jstep = 5;
          } else {
            jstep = 2;
          }
          xdivu = jstep*(powi(10.,jpower));
        }

	/* - Determine "nice-numbered" starting and ending values. */

	ia = cmgem.zdata.xmin/xdivu;
	xgrdmn = xdivu*ia;
	if( xgrdmn < cmgem.zdata.xmin ){
		ia = ia + 1;
		xgrdmn = xgrdmn + xdivu;
		}
	ib = cmgem.zdata.xmax/xdivu;
	xgrdmx = xdivu*ib;
	if( xgrdmx > cmgem.zdata.xmax ){
		ib = ib - 1;
		xgrdmx = xgrdmx - xdivu;
		}
	nxdivu = ib - ia + 1;

	/* - Determine the format (Fn.m) of the labels.
	 *   The variable NDS assumes the role of "n" and MDS the role of "m". */

	/* - The "magic numbers" used in this algorithm  generate good division
	 *   spacings almost all of the time.  Modify them at your own risk. */

	grdlog = log10( fmax( fabs( xgrdmn ), fabs( xgrdmx ) ) + 0.001 );
	if( grdlog >= 0. ){
		grdlog = grdlog + 1.001;
		}
	else{
		grdlog = grdlog - 0.999;
		}
	divlog = log10( xdivu );
	if( divlog >= 0. ){
		divlog = divlog + 1.001;
		}
	else{
		divlog = divlog - 0.999;
		}
	lpower = FALSE;
	factor = 1.;
	if( grdlog*divlog >= 0. ){
		if( grdlog < 0. ){
			igdlog = grdlog;
			}
		else{
			igdlog = divlog;
			}
		if( labs( igdlog ) >= 3 && cmgem.lxpowr ){
			mds = 0;
			nds = max( 4, (int)( grdlog ) - (int)( divlog ) + 2 );
			cnvita( jpower, ktemp,9 );
			ljust( ktemp,9 );
			if( jpower >= 0 ){
                                fstrncpy( kpower, 8, "X 10+", 5);
                                fstrncpy( kpower+5, 8-5, ktemp, strlen(ktemp));
				}
			else{
                                fstrncpy( kpower, 8, "X 10", 4);
                                fstrncpy( kpower+4, 8-4, ktemp, strlen(ktemp));
				}
			factor = powi(10.,-jpower);
			lpower = TRUE;
			}
		else{
			mds = labs( minfi( 0., divlog ) );
			nds = maxfi( 1., grdlog );
			if( mds > 0 )
				nds = nds + mds + 2;
			}
		}
	else{
		mds = labs( minfi( 0., divlog ) );
		nds = maxfi( 0., grdlog );
		if( mds > 0 )
			nds = nds + mds + 2;
		}

	/* - Determine axes fudge factor for thick axes lines. */
	getvport( &xvpmin, &xvpmax, &yvpmin, &yvpmax );
	skfudge = cmgem.skdevfudge*((yvpmin - yvpmax)/(xvpmin - xvpmax));

	/* - Draw the bottom axis. */

	setlinestyle( LINE_STYLE_SOLID );
	setlinewidth( cmgem.iskwidth );

	if( cmgem.axis[BOTTOM].annotate || cmgem.axis[BOTTOM].ticks ){

		/* -- Bottom Axes line. */
		if( cmgem.iskwidth > LINE_WIDTH_THIN ){
			line( cmgem.uplot.xmin - cmgem.iskwidth*skfudge, cmgem.uplot.ymin, 
			 cmgem.uplot.xmax + cmgem.iskwidth*skfudge, cmgem.uplot.ymin );
			}
		else{
			line( cmgem.uplot.xmin, cmgem.uplot.ymin, cmgem.uplot.xmax, cmgem.uplot.ymin );
			}

		/* -- Label for multiplying scale factor. */
		if( lpower && cmgem.axis[BOTTOM].annotate ){
			ypow = fmax( cmgem.uplot.ymin - 2.2*cmgem.chht, 0.1*cmgem.chht );
			if( cmgem.lxrev ){
				settextjust( "RIGHT", "BOTTOM" );
				}
			else{
				settextjust( "LEFT", "BOTTOM" );
				}
			pltext( kpower,9, cmgem.uplot.xmin, ypow );
			setlinewidth( cmgem.iskwidth );
			}

		/* -- Calculate constants for labeled tick marks. */
		value = xgrdmn*factor;
		xref = xgrdmn*cmgem.xmpip1 + cmgem.xmpip2;
		valuei = xdivu*factor;
		xrefi = xdivu*cmgem.xmpip1;
		strcpy( kvalue, "                " );

		/* -- Draw secondary tick marks before first labeled one. */
		ntick = 1;
		if( xrefi >= 0.10 ){
			ntick = 3;
			if( jstep == 5 )
				ntick = 4;
			}
		if( xrefi >= 0.25 )
			ntick = 9;
		xticki = xrefi/(float)( ntick + 1 );
		xtick = xref - xrefi;
		for( jtick = 1; jtick <= ntick; jtick++ ){
			xtick = xtick + xticki;
			if( xtick >= cmgem.uplot.xmin ){
				line( xtick, cmgem.uplot.ymin, xtick, cmgem.uplot.ymin + 
				 0.5*cmgem.chwid );
				}
			}

		/* -- Loop on labeled tick marks. */
		for( jdiv = 1; jdiv <= nxdivu; jdiv++ ){
			line( xref, cmgem.uplot.ymin, xref, cmgem.uplot.ymin + 
			 cmgem.chwid );
			if( cmgem.axis[BOTTOM].annotate ){
				if( value >= 0 ){
					ndsu = nds;
					}
				else{
					ndsu = nds + 1;
					}
				cnvfta( value, ndsu, mds, kvalue,17 );
				ljust( kvalue,17 );
				yloc = cmgem.uplot.ymin - 0.1*cmgem.chht;
				settextjust( "CENTER", "TOP" );
				pltext( kvalue,17, xref, yloc );
				setlinewidth( cmgem.iskwidth );
				}
			/* --- Loop on secondary tick marks. */
			xtick = xref;
			for( jtick = 1; jtick <= ntick; jtick++ ){
				xtick = xtick + xticki;
				if( xtick <= cmgem.uplot.xmax ){
					line( xtick, cmgem.uplot.ymin, xtick, cmgem.uplot.ymin + 
					 0.5*cmgem.chwid );
					}
				}
			value = value + valuei;
			xref = xref + xrefi;
			}

		/* -- Save axes widths. */
		if( cmgem.axis[BOTTOM].annotate ){
			cmgem.axis[BOTTOM].width = 1.1*cmgem.chht;
			if( lpower )
				cmgem.axis[BOTTOM].width = cmgem.uplot.ymin - ypow;
			}
		else{
			cmgem.axis[BOTTOM].width = 0.;
			}

		}

	/* - Top axis: */

	if( cmgem.axis[TOP].annotate || cmgem.axis[TOP].ticks ){

		/* -- Top Axes line. */
		if( cmgem.iskwidth > LINE_WIDTH_THIN ){
			line( cmgem.uplot.xmin - cmgem.iskwidth*skfudge, cmgem.uplot.ymax, 
			 cmgem.uplot.xmax + cmgem.iskwidth*skfudge, cmgem.uplot.ymax );
			}
		else{
			line( cmgem.uplot.xmin, cmgem.uplot.ymax, cmgem.uplot.xmax, cmgem.uplot.ymax );
			}

		/* -- Label for multiplying scale factor. */
		if( lpower && cmgem.axis[TOP].annotate ){
			ypow = fmin( cmgem.uplot.ymax + 2.2*cmgem.chht, cmgem.view.ymax - 
			 0.1*cmgem.chht );
			if( cmgem.lxrev ){
				settextjust( "RIGHT", "TOP" );
				}
			else{
				settextjust( "LEFT", "TOP" );
				}
			pltext( kpower,9, cmgem.uplot.xmin, ypow );
			setlinewidth( cmgem.iskwidth );
			}

		/* -- Calculate constants for labeled tick marks. */
		value = xgrdmn*factor;
		xref = xgrdmn*cmgem.xmpip1 + cmgem.xmpip2;
		valuei = xdivu*factor;
		xrefi = xdivu*cmgem.xmpip1;
		strcpy( kvalue, "                " );

		/* -- Draw secondary tick marks before first labeled one. */
		ntick = 1;
		if( xrefi >= 0.10 ){
			ntick = 3;
			if( jstep == 5 )
				ntick = 4;
			}
		if( xrefi >= 0.25 )
			ntick = 9;
		xticki = xrefi/(float)( ntick + 1 );
		xtick = xref - xrefi;
		for( jtick = 1; jtick <= ntick; jtick++ ){
			xtick = xtick + xticki;
			if( xtick >= cmgem.uplot.xmin ){
				line( xtick, cmgem.uplot.ymax, xtick, cmgem.uplot.ymax - 
				 0.5*cmgem.chwid );
				}
			}

		/* -- Loop on labeled tick marks. */
		for( jdiv = 1; jdiv <= nxdivu; jdiv++ ){
			line( xref, cmgem.uplot.ymax, xref, cmgem.uplot.ymax - 
			 cmgem.chwid );
			if( cmgem.axis[TOP].annotate ){
				if( value >= 0. ){
					ndsu = nds;
					}
				else{
					ndsu = nds + 1;
					}
				cnvfta( value, ndsu, mds, kvalue,17 );
				ljust( kvalue,17 );
				yloc = cmgem.uplot.ymax + 0.1*cmgem.chht;
				settextjust( "CENTER", "BOTTOM" );
				pltext( kvalue,17, xref, yloc );
				setlinewidth( cmgem.iskwidth );
				}
			/* --- Loop on secondary tick marks. */
			xtick = xref;
			for( jtick = 1; jtick <= ntick; jtick++ ){
				xtick = xtick + xticki;
				if( xtick <= cmgem.uplot.xmax ){
					line( xtick, cmgem.uplot.ymax, xtick, cmgem.uplot.ymax - 
					 0.5*cmgem.chwid );
					}
				}
			value = value + valuei;
			xref = xref + xrefi;
			}

		/* -- Save axes widths. */
		if( cmgem.axis[TOP].annotate ){
			cmgem.axis[TOP].width = 1.1*cmgem.chht;
			if( lpower )
				cmgem.axis[TOP].width = ypow - cmgem.uplot.ymax;
			}
		else{
			cmgem.axis[TOP].width = 0.;
			}

		}

	/* - Grid lines. */

	if( cmgem.lxgrd ){
		setlinewidth( LINE_WIDTH_THIN );
		xref = xgrdmn*cmgem.xmpip1 + cmgem.xmpip2;
		xrefi = xdivu*cmgem.xmpip1;
		setlinestyle( cmgem.ixgrd );
		for( jdiv = 1; jdiv <= nxdivu; jdiv++ ){
			line( xref, cmgem.uplot.ymin, xref, cmgem.uplot.ymax );
			xref = xref + xrefi;
			}
		setlinestyle( LINE_STYLE_SOLID );
		setlinewidth( cmgem.iskwidth );
		}

       

	return;

} /* end of function */