Ejemplo n.º 1
0
static void do_flatshade_line( struct brw_sf_compile *c )
{
    struct brw_compile *p = &c->func;
    struct intel_context *intel = &p->brw->intel;
    struct brw_reg ip = brw_ip_reg();
    GLuint nr = brw_count_bits(c->key.attrs & VERT_RESULT_COLOR_BITS);
    GLuint jmpi = 1;

    if (!nr)
        return;

    /* Already done in clip program:
     */
    if (c->key.primitive == SF_UNFILLED_TRIS)
        return;

    if (intel->gen == 5)
        jmpi = 2;

    brw_push_insn_state(p);

    brw_MUL(p, c->pv, c->pv, brw_imm_d(jmpi*(nr+1)));
    brw_JMPI(p, ip, ip, c->pv);
    copy_colors(c, c->vert[1], c->vert[0]);

    brw_JMPI(p, ip, ip, brw_imm_ud(jmpi*nr));
    copy_colors(c, c->vert[0], c->vert[1]);

    brw_pop_insn_state(p);
}
Ejemplo n.º 2
0
/* Clip a line against the viewport and user clip planes.
 */
static void
do_clip_line( struct draw_stage *stage,
	      struct prim_header *header,
	      unsigned clipmask )
{
   const struct clip_stage *clipper = clip_stage( stage );
   struct vertex_header *v0 = header->v[0];
   struct vertex_header *v1 = header->v[1];
   const float *pos0 = v0->clip;
   const float *pos1 = v1->clip;
   float t0 = 0.0F;
   float t1 = 0.0F;
   struct prim_header newprim;

   while (clipmask) {
      const unsigned plane_idx = ffs(clipmask)-1;
      const float *plane = clipper->plane[plane_idx];
      const float dp0 = dot4( pos0, plane );
      const float dp1 = dot4( pos1, plane );

      if (dp1 < 0.0F) {
	 float t = dp1 / (dp1 - dp0);
         t1 = MAX2(t1, t);
      } 

      if (dp0 < 0.0F) {
	 float t = dp0 / (dp0 - dp1);
         t0 = MAX2(t0, t);
      }

      if (t0 + t1 >= 1.0F)
	 return; /* discard */

      clipmask &= ~(1 << plane_idx);  /* turn off this plane's bit */
   }

   if (v0->clipmask) {
      interp( clipper, stage->tmp[0], t0, v0, v1 );

      if (clipper->flat)
	 copy_colors(stage, stage->tmp[0], v0);

      newprim.v[0] = stage->tmp[0];
   }
   else {
      newprim.v[0] = v0;
   }

   if (v1->clipmask) {
      interp( clipper, stage->tmp[1], t1, v1, v0 );
      newprim.v[1] = stage->tmp[1];
   }
   else {
      newprim.v[1] = v1;
   }

   stage->next->line( stage->next, &newprim );
}
static void flatshade_line_1( struct draw_stage *stage,
                              struct prim_header *header )
{
   struct prim_header tmp;

   tmp.v[0] = dup_vert(stage, header->v[0], 0);
   tmp.v[1] = header->v[1];

   copy_colors(stage, tmp.v[0], tmp.v[1]);
   
   stage->next->line( stage->next, &tmp );
}
Ejemplo n.º 4
0
void ArpTextControl::ParametersChanged(const ArpParamSet* params)
{
	if( params->GetChanges(parameters_textcontrol)&TEXTCTRL_COLOR_CHANGED ) {
		copy_colors((BView*)this);
		InvalidateView();
	}
	if( params->GetChanges(parameters_textcontrol)&TEXTCTRL_FONT_CHANGED ) {
		copy_font((BView*)this);
		InvalidateDimens();
	}
	inherited::ParametersChanged(params);
}
/* Need to use a computed jump to copy flatshaded attributes as the
 * vertices are ordered according to y-coordinate before reaching this
 * point, so the PV could be anywhere.
 */
static void do_flatshade_triangle( struct brw_sf_compile *c )
{
   struct brw_compile *p = &c->func;
   struct brw_reg ip = brw_ip_reg();
   GLuint nr = brw_count_bits(c->key.attrs & VERT_RESULT_COLOR_BITS);
   if (!nr)
      return;

   /* Already done in clip program:
    */
   if (c->key.primitive == SF_UNFILLED_TRIS)
      return;

   brw_push_insn_state(p);
   
   brw_MUL(p, c->pv, c->pv, brw_imm_ud(nr*2+1));
   brw_JMPI(p, ip, ip, c->pv);

   copy_colors(c, c->vert[1], c->vert[0]);
   copy_colors(c, c->vert[2], c->vert[0]);
   brw_JMPI(p, ip, ip, brw_imm_ud(nr*4+1));

   copy_colors(c, c->vert[0], c->vert[1]);
   copy_colors(c, c->vert[2], c->vert[1]);
   brw_JMPI(p, ip, ip, brw_imm_ud(nr*2));

   copy_colors(c, c->vert[0], c->vert[2]);
   copy_colors(c, c->vert[1], c->vert[2]);

   brw_pop_insn_state(p);
}
Ejemplo n.º 6
0
void ArpTextControl::copy_colors(BView* v)
{
	// Make no assumptions about the structure of the children.
	if( !v ) return;
	int32 num = v->CountChildren();
	for( int32 i=0; i<num; i++ ) {
		BView* child = v->ChildAt(i);
		if( child ) {
			copy_colors(child);
			BTextView* text = dynamic_cast<BTextView*>(child);
			if( text ) {
				text->SetFontAndColor(NULL, B_FONT_ALL, &PV_FillForeColor);
			}
			child->SetViewColor(PV_FillBackColor);
			child->SetLowColor(PV_FillBackColor);
			child->SetHighColor(PV_FillForeColor);
			child->Invalidate();
		}
	}
}
Ejemplo n.º 7
0
void execute(expr_list * ee)
{
    int verbose = isatty(2);
    expr_list *l;
    int count, n;

    setup_region();

    exprs = ee;
    G_add_error_handler(error_handler, NULL);

    for (l = ee; l; l = l->next) {
	expression *e = l->exp;
	const char *var;

	if (e->type != expr_type_binding && e->type != expr_type_function)
	    G_fatal_error("internal error: execute: invalid type: %d",
			  e->type);

	if (e->type != expr_type_binding)
	    continue;

	var = e->data.bind.var;

	if (!overwrite_flag && check_output_map(var))
	    G_fatal_error(_("output map <%s> exists. To overwrite, use the --overwrite flag"), var);
    }

    for (l = ee; l; l = l->next) {
	expression *e = l->exp;
	const char *var;
	expression *val;

	initialize(e);

	if (e->type != expr_type_binding)
	    continue;

	var = e->data.bind.var;
	val = e->data.bind.val;

	e->data.bind.fd = open_output_map(var, val->res_type);
    }

    setup_maps();

    count = rows * depths;
    n = 0;

    G_init_workers();

    for (current_depth = 0; current_depth < depths; current_depth++)
	for (current_row = 0; current_row < rows; current_row++) {
	    if (verbose)
		G_percent(n, count, 2);

	    for (l = ee; l; l = l->next) {
		expression *e = l->exp;
		int fd;

		evaluate(e);

		if (e->type != expr_type_binding)
		    continue;

		fd = e->data.bind.fd;
		put_map_row(fd, e->buf, e->res_type);
	    }

	    n++;
	}

    G_finish_workers();

    if (verbose)
	G_percent(n, count, 2);

    for (l = ee; l; l = l->next) {
	expression *e = l->exp;
	const char *var;
	expression *val;
	int fd;

	if (e->type != expr_type_binding)
	    continue;

	var = e->data.bind.var;
	val = e->data.bind.val;
	fd = e->data.bind.fd;

	close_output_map(fd);
	e->data.bind.fd = -1;

	if (val->type == expr_type_map) {
	    if (val->data.map.mod == 'M') {
		copy_cats(var, val->data.map.idx);
		copy_colors(var, val->data.map.idx);
	    }

	    copy_history(var, val->data.map.idx);
	}
	else
	    create_history(var, val);
    }

    G_unset_error_routine();
}
Ejemplo n.º 8
0
/* Clip a triangle against the viewport and user clip planes.
 */
static void
do_clip_tri( struct draw_stage *stage, 
	     struct prim_header *header,
	     unsigned clipmask )
{
   struct clip_stage *clipper = clip_stage( stage );
   struct vertex_header *a[MAX_CLIPPED_VERTICES];
   struct vertex_header *b[MAX_CLIPPED_VERTICES];
   struct vertex_header **inlist = a;
   struct vertex_header **outlist = b;
   unsigned tmpnr = 0;
   unsigned n = 3;
   unsigned i;
   boolean aEdges[MAX_CLIPPED_VERTICES];
   boolean bEdges[MAX_CLIPPED_VERTICES];
   boolean *inEdges = aEdges;
   boolean *outEdges = bEdges;

   inlist[0] = header->v[0];
   inlist[1] = header->v[1];
   inlist[2] = header->v[2];

   /*
    * Note: at this point we can't just use the per-vertex edge flags.
    * We have to observe the edge flag bits set in header->flags which
    * were set during primitive decomposition.  Put those flags into
    * an edge flags array which parallels the vertex array.
    * Later, in the 'unfilled' pipeline stage we'll draw the edge if both
    * the header.flags bit is set AND the per-vertex edgeflag field is set.
    */
   inEdges[0] = !!(header->flags & DRAW_PIPE_EDGE_FLAG_0);
   inEdges[1] = !!(header->flags & DRAW_PIPE_EDGE_FLAG_1);
   inEdges[2] = !!(header->flags & DRAW_PIPE_EDGE_FLAG_2);

   while (clipmask && n >= 3) {
      const unsigned plane_idx = ffs(clipmask)-1;
      const boolean is_user_clip_plane = plane_idx >= 6;
      const float *plane = clipper->plane[plane_idx];
      struct vertex_header *vert_prev = inlist[0];
      boolean *edge_prev = &inEdges[0];
      float dp_prev = dot4( vert_prev->clip, plane );
      unsigned outcount = 0;

      clipmask &= ~(1<<plane_idx);

      assert(n < MAX_CLIPPED_VERTICES);
      if (n >= MAX_CLIPPED_VERTICES)
         return;
      inlist[n] = inlist[0]; /* prevent rotation of vertices */
      inEdges[n] = inEdges[0];

      for (i = 1; i <= n; i++) {
	 struct vertex_header *vert = inlist[i];
         boolean *edge = &inEdges[i];

	 float dp = dot4( vert->clip, plane );

	 if (!IS_NEGATIVE(dp_prev)) {
            assert(outcount < MAX_CLIPPED_VERTICES);
            if (outcount >= MAX_CLIPPED_VERTICES)
               return;
            outEdges[outcount] = *edge_prev;
	    outlist[outcount++] = vert_prev;
	 }

	 if (DIFFERENT_SIGNS(dp, dp_prev)) {
	    struct vertex_header *new_vert;
            boolean *new_edge;

            assert(tmpnr < MAX_CLIPPED_VERTICES + 1);
            if (tmpnr >= MAX_CLIPPED_VERTICES + 1)
               return;
            new_vert = clipper->stage.tmp[tmpnr++];

            assert(outcount < MAX_CLIPPED_VERTICES);
            if (outcount >= MAX_CLIPPED_VERTICES)
               return;

            new_edge = &outEdges[outcount];
	    outlist[outcount++] = new_vert;

	    if (IS_NEGATIVE(dp)) {
	       /* Going out of bounds.  Avoid division by zero as we
		* know dp != dp_prev from DIFFERENT_SIGNS, above.
		*/
	       float t = dp / (dp - dp_prev);
	       interp( clipper, new_vert, t, vert, vert_prev );
	       
	       /* Whether or not to set edge flag for the new vert depends
                * on whether it's a user-defined clipping plane.  We're
                * copying NVIDIA's behaviour here.
		*/
               if (is_user_clip_plane) {
                  /* we want to see an edge along the clip plane */
                  *new_edge = TRUE;
                  new_vert->edgeflag = TRUE;
               }
               else {
                  /* we don't want to see an edge along the frustum clip plane */
                  *new_edge = *edge_prev;
                  new_vert->edgeflag = FALSE;
               }
	    }
            else {
	       /* Coming back in.
		*/
	       float t = dp_prev / (dp_prev - dp);
	       interp( clipper, new_vert, t, vert_prev, vert );

	       /* Copy starting vert's edgeflag:
		*/
	       new_vert->edgeflag = vert_prev->edgeflag;
               *new_edge = *edge_prev;
	    }
	 }

	 vert_prev = vert;
         edge_prev = edge;
	 dp_prev = dp;
      }

      /* swap in/out lists */
      {
	 struct vertex_header **tmp = inlist;
	 inlist = outlist;
	 outlist = tmp;
	 n = outcount;
      }
      {
         boolean *tmp = inEdges;
         inEdges = outEdges;
         outEdges = tmp;
      }

   }

   /* If flat-shading, copy provoking vertex color to polygon vertex[0]
    */
   if (n >= 3) {
      if (clipper->flat) {
         if (stage->draw->rasterizer->flatshade_first) {
            if (inlist[0] != header->v[0]) {
               assert(tmpnr < MAX_CLIPPED_VERTICES + 1);
               if (tmpnr >= MAX_CLIPPED_VERTICES + 1)
                  return;
               inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
               copy_colors(stage, inlist[0], header->v[0]);
            }
         }
         else {
            if (inlist[0] != header->v[2]) {
               assert(tmpnr < MAX_CLIPPED_VERTICES + 1);
               if (tmpnr >= MAX_CLIPPED_VERTICES + 1)
                  return;
               inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
               copy_colors(stage, inlist[0], header->v[2]);
            }
         }
      }
      
      /* Emit the polygon as triangles to the setup stage:
       */
      emit_poly( stage, inlist, inEdges, n, header );
   }
}
Ejemplo n.º 9
0
/* Clip a triangle against the viewport and user clip planes.
 */
static void
do_clip_tri( struct draw_stage *stage, 
	     struct prim_header *header,
	     unsigned clipmask )
{
   struct clipper *clipper = clipper_stage( stage );
   struct vertex_header *a[MAX_CLIPPED_VERTICES];
   struct vertex_header *b[MAX_CLIPPED_VERTICES];
   struct vertex_header **inlist = a;
   struct vertex_header **outlist = b;
   unsigned tmpnr = 0;
   unsigned n = 3;
   unsigned i;

   inlist[0] = header->v[0];
   inlist[1] = header->v[1];
   inlist[2] = header->v[2];

   while (clipmask && n >= 3) {
      const unsigned plane_idx = ffs(clipmask)-1;
      const float *plane = clipper->plane[plane_idx];
      struct vertex_header *vert_prev = inlist[0];
      float dp_prev = dot4( vert_prev->clip, plane );
      unsigned outcount = 0;

      clipmask &= ~(1<<plane_idx);

      inlist[n] = inlist[0]; /* prevent rotation of vertices */

      for (i = 1; i <= n; i++) {
	 struct vertex_header *vert = inlist[i];

	 float dp = dot4( vert->clip, plane );

	 if (!IS_NEGATIVE(dp_prev)) {
	    outlist[outcount++] = vert_prev;
	 }

	 if (DIFFERENT_SIGNS(dp, dp_prev)) {
	    struct vertex_header *new_vert = clipper->stage.tmp[tmpnr++];
	    outlist[outcount++] = new_vert;

	    if (IS_NEGATIVE(dp)) {
	       /* Going out of bounds.  Avoid division by zero as we
		* know dp != dp_prev from DIFFERENT_SIGNS, above.
		*/
	       float t = dp / (dp - dp_prev);
	       interp( clipper, new_vert, t, vert, vert_prev );
	       
	       /* Force edgeflag true in this case:
		*/
	       new_vert->edgeflag = 1;
	    } else {
	       /* Coming back in.
		*/
	       float t = dp_prev / (dp_prev - dp);
	       interp( clipper, new_vert, t, vert_prev, vert );

	       /* Copy starting vert's edgeflag:
		*/
	       new_vert->edgeflag = vert_prev->edgeflag;
	    }
	 }

	 vert_prev = vert;
	 dp_prev = dp;
      }

      {
	 struct vertex_header **tmp = inlist;
	 inlist = outlist;
	 outlist = tmp;
	 n = outcount;
      }
   }

   /* If flat-shading, copy color to new provoking vertex.
    */
   if (clipper->flat && inlist[0] != header->v[2]) {
      if (1) {
	 inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
      }

      copy_colors(stage, inlist[0], header->v[2]);
   }



   /* Emit the polygon as triangles to the setup stage:
    */
   if (n >= 3)
      emit_poly( stage, inlist, n, header );
}
Ejemplo n.º 10
0
int main(int argc, char *argv[])
{
    struct Options opts;
    struct ScaleRange iscale;	/* input file's data is scaled to this interval */
    struct ScaleRange oscale;	/* output file's scale */
    int iimg_fd;		/* input image's file descriptor */
    int oimg_fd;		/* output image's file descriptor */
    int ialt_fd = -1;		/* input elevation map's file descriptor */
    int ivis_fd = -1;		/* input visibility map's file descriptor */
    struct History hist;
    struct Cell_head orig_window;

    /* Define module */
    define_module();

    /* Define the different input options */
    opts = define_options();

    /**** Start ****/
    G_gisinit(argv[0]);
    if (G_parser(argc, argv) < 0)
	exit(EXIT_FAILURE);

    G_get_set_window(&orig_window);
    adjust_region(opts.iimg->answer);

    /* open input raster */
    if ((iimg_fd = Rast_open_old(opts.iimg->answer, "")) < 0)
	G_fatal_error(_("Unable to open raster map <%s>"), opts.iimg->answer);

    if (opts.ialt->answer) {
	if ((ialt_fd = Rast_open_old(opts.ialt->answer, "")) < 0)
	    G_fatal_error(_("Unable to open raster map <%s>"),
			  opts.ialt->answer);
    }

    if (opts.ivis->answer) {
	if ((ivis_fd = Rast_open_old(opts.ivis->answer, "")) < 0)
	    G_fatal_error(_("Unable to open raster map <%s>"),
			  opts.ivis->answer);
    }

    /* open a floating point raster or not? */
    if (opts.oint->answer) {
	if ((oimg_fd = Rast_open_new(opts.oimg->answer, CELL_TYPE)) < 0)
	    G_fatal_error(_("Unable to create raster map <%s>"),
			  opts.oimg->answer);
    }
    else {
	if ((oimg_fd = Rast_open_fp_new(opts.oimg->answer)) < 0)
	    G_fatal_error(_("Unable to create raster map <%s>"),
			  opts.oimg->answer);
    }

    /* read the scale parameters */
    read_scale(opts.iscl, iscale);
    read_scale(opts.oscl, oscale);

    /* initialize this 6s computation and parse the input conditions file */
    init_6S(opts.icnd->answer);

    InputMask imask = RADIANCE;	/* the input mask tells us what transformations if any
				   needs to be done to make our input values, reflectance
				   values scaled between 0 and 1 */
    if (opts.irad->answer)
	imask = REFLECTANCE;
    if (opts.etmbefore->answer)
	imask = (InputMask) (imask | ETM_BEFORE);
    if (opts.etmafter->answer)
	imask = (InputMask) (imask | ETM_AFTER);

    /* process the input raster and produce our atmospheric corrected output raster. */
    G_message(_("Atmospheric correction..."));
    process_raster(iimg_fd, imask, iscale, ialt_fd, ivis_fd,
		   oimg_fd, opts.oint->answer, oscale);


    /* Close the input and output file descriptors */
    Rast_short_history(opts.oimg->answer, "raster", &hist);
    Rast_close(iimg_fd);
    if (opts.ialt->answer)
	Rast_close(ialt_fd);
    if (opts.ivis->answer)
	Rast_close(ivis_fd);
    Rast_close(oimg_fd);

    Rast_command_history(&hist);
    Rast_write_history(opts.oimg->answer, &hist);

    /* Copy the colors of the input raster to the output raster.
       Scaling is ignored and color ranges might not be correct. */
    copy_colors(opts.iimg->answer, opts.oimg->answer);

    Rast_set_window(&orig_window);
    G_message(_("Atmospheric correction complete."));

    exit(EXIT_SUCCESS);
}
Ejemplo n.º 11
0
/*
 * Given an XEvent, process it if it pertains to a ColorBar, else do
 * nothing with it.
 * Input:  event - the X event
 * Output:  whichcb - which colorbar this event pertained to.
 * Return: 1 - if color table was changed.
 *         2 - if reset key was pressed
 *         3 - if <shift>+reset key was pressed
 *         0 - if no change
 */
static int colorbar_process( LUI_COLORBAR *cb, XEvent *event )
{
   static int p1 = 0, p2 = 0, p3 = 0, p4 = 0; /* red, green, blue, alpha */
   static int pentry;
   int i, modify, entry, result;
   static int move_marker;

   result = modify = 0;

   if (event->type==KeyPress) {
      char keybuf[50];
      KeySym key;
      XComposeStatus compose;
      int count;
      count = XLookupString( &event->xkey, keybuf, 50, &key, &compose );
      if (count==1) {
         if (keybuf[0]=='r') {
            /* Reset RGB */
            cb->params[DRAWFLAG] = 0.0;
            result = LUI_RGB_RESET;
         }
         else if (keybuf[0]=='R') {
            /* Reset alpha */
            result = LUI_ALPHA_RESET;
            cb->params[DRAWFLAG] = 0.0;
         }
         else if (keybuf[0]=='c' || keybuf[0]=='C') {
            /* Copy current colors to clipboard */
            copy_colors( cb );
         }
         else if (keybuf[0]=='p' || keybuf[0]=='P') {
            /* Paste clipboard colors to current color widget */
            paste_colors( cb );
            LUI_ColorBarRedraw( cb );
            result = LUI_RGB_CHANGE | LUI_ALPHA_CHANGE;
            cb->params[DRAWFLAG] = 0.0;
            result = LUI_RGB_CHANGE | LUI_ALPHA_CHANGE;
         }

/* WLH 7-18-96 */
         else if (keybuf[0]=='s' || keybuf[0]=='S') {
            /* save colors to a file */
            save_colors( cb );
         }
         else if (keybuf[0]=='l' || keybuf[0]=='L') {
            /* load colors from a file */
            load_colors( cb );
            LUI_ColorBarRedraw( cb );
            return 1;
         }

         else {
            /* if unused key, toggle help display */
            cb->helpflag = !cb->helpflag;
            LUI_ColorBarRedraw( cb );
         }
      }
      else if (key == XK_Left) {
         /* rotate left */
         cb->params[BIAS] -= 0.03/cb->params[CURVE];
         result = LUI_RGB_SHAPE;
         cb->params[DRAWFLAG] = 0.0;
      }
      else if (key == XK_Right) {
         /* rotate right */
         cb->params[BIAS] += 0.03/cb->params[CURVE];
         result = LUI_RGB_SHAPE;
         cb->params[DRAWFLAG] = 0.0;
      }
      else if (key == XK_Up) {
         /* expand color map */
         if (event->xkey.state & ANY_MODIFIER) {
            cb->params[ALPHAPOW] -= 0.1;
            if (cb->params[ALPHAPOW]<0.0)
              cb->params[ALPHAPOW] = 0.0;
            result = LUI_ALPHA_SHAPE;
            cb->params[DRAWFLAG] = 0.0;
         }
         else {
            cb->params[CURVE] -= 0.1;
            result = LUI_RGB_SHAPE;
            cb->params[DRAWFLAG] = 0.0;
         }
      }
      else if (key == XK_Down) {
         /* compress color map */
         if (event->xkey.state & ANY_MODIFIER) {
            cb->params[ALPHAPOW] += 0.1;
            result = LUI_ALPHA_SHAPE;
            cb->params[DRAWFLAG] = 0.0;
         }
         else {
            cb->params[CURVE] += 0.1;
            result = LUI_RGB_SHAPE;
            cb->params[DRAWFLAG] = 0.0;
         }
      }
   }
   else if (event->type==Expose && event->xexpose.count==0) {
      LUI_ColorBarRedraw( cb );
      result = 0;
   }
   else if (event->type==ConfigureNotify) {
/* MJK 4.15.99 */
      LUI_ColorBarSetSize( cb, event->xconfigure.width, event->xconfigure.height );
      result = 0;
   }
   else if (event->type==ButtonPress ) {
      if (event->xbutton.y<cb->wedge_y) {
         /* change color function */
         move_marker = 0;
      }
      else {
         /* change marker position */
         move_marker = 1;
      }
      /* determine which curve to modify */
      if (event->xbutton.state&ANY_MODIFIER) {
         p4 = 1;
      }
      else {
         if (event->xbutton.button==Button1)  p1 = 1;
         if (event->xbutton.button==Button2)  p2 = 1;
         if (event->xbutton.button==Button3)  p3 = 1;
      }
      pentry = x_to_index( cb, event->xbutton.x );
      modify = 1;
   }
   else if (event->type==ButtonRelease) {
      if (p1 || p2 || p3) {
         result = LUI_RGB_CHANGE;
      }
      else {
         result = LUI_ALPHA_CHANGE;
      }
      if (event->xbutton.button==Button1)  p1 = 0;
      if (event->xbutton.button==Button2)  p2 = 0;
      if (event->xbutton.button==Button3)  p3 = 0;
      p4 = 0;
   }
   else if (event->type==MotionNotify) {
      /* Flush extra MotionNotify events */
      while (QLength(LUI_Display)>0) {
         XEvent next;
         XPeekEvent(LUI_Display, &next);
         if (next.type!=MotionNotify)
            break;
         XNextEvent(LUI_Display, event);
      }
      modify = 1;
   }


   /* Modify one or more of the color curves */

   if (modify && (p1 || p2 || p3 || p4)) {
      /* calculate which entry in color table to change */
      entry = x_to_index( cb, event->xbutton.x );
      /* update */
      if (move_marker) {
         /* changing marker position */
         cb->markerpos = entry;
         redraw_marker( cb );
      }
      else {
         /* changing color graph */
         int a, b, value;

         value = y_to_intensity( cb, event->xbutton.y );

         if (pentry<=entry) {
            a = pentry;
            b = entry;
         }
         else {
            a = entry;
            b = pentry;
         }

         /* update entries from 'pentry' to 'entry' */
         for (i=a; i<=b; i++) {
            int red, green, blue, alpha;
            red = UNPACK_RED(cb->table[i]);
            green = UNPACK_GREEN(cb->table[i]);
            blue = UNPACK_BLUE(cb->table[i]);
            alpha = UNPACK_ALPHA(cb->table[i]);
            if (p1) {
               /* modify red */
               red = value;
            }
            if (p2) {
               /* modify green */
               green = value;
            }
            if (p3) {
               /* modify blue */
               blue = value;
            }
            if (p4) {
               /* modify alpha */
               alpha = value;
            }
            /* change the color table entry */
            cb->table[i] = PACK_COLOR(red,green,blue,alpha);
         } /* for */

         /* redraw the color curves */
         if (pentry<entry)
           redraw_range( cb, pentry-1, entry+1 );
         else
           redraw_range( cb, entry-1, pentry+1 );

         pentry = entry;

         if (p4) {
            /* update min,max alpha values */
            cb->minalpha = 256;
            cb->maxalpha = 0;
            for (i=0;i<cb->table_size;i++) {
               int a = UNPACK_ALPHA( cb->table[i] );
               if (a<cb->minalpha)  cb->minalpha = a;
               if (a>cb->maxalpha)  cb->maxalpha = a;
            }
         }

         if (p4) {
			  result = LUI_ALPHA_MODIFY;
			  /*
            result = LUI_ALPHA_CHANGE;
			  */
         }
         else {
            result = LUI_RGB_MODIFY;
				/*
            result = LUI_RGB_CHANGE;
				*/
         }
         cb->params[DRAWFLAG] = 1.0;
      }
   } /*modify*/


   if (result!=0 && cb->callback) {
      (*cb->callback)(cb, result);
   }

   return result;
}
Ejemplo n.º 12
0
void ArpTextControl::LayoutAttachedToWindow(void)
{
	copy_colors(this);
	copy_font(this);
}