示例#1
0
void ScopeHistogram::draw_point()
{
	if(drag_x >= 0)
	{
		set_inverse();
		set_color(0xffffff);
		set_line_width(2);
		draw_line(drag_x, 0, drag_x, get_h());
		set_line_width(1);
		set_opaque();
	}
}
示例#2
0
void ScopeWaveform::draw_point()
{
	if(drag_x >= 0)
	{
		set_inverse();
		set_color(0xffffff);
		set_line_width(2);
		draw_line(0, drag_y, get_w(), drag_y);
		draw_line(drag_x, 0, drag_x, get_h());
		set_line_width(1);
		set_opaque();
	}
}
// set up the graphics on the seperate CAVE displays
void CaveDisplayDevice::cave_gl_init_fn(void) {
  setup_initial_opengl_state();     // do all OpenGL setup/initialization now

  // follow up with mode settings
  aaAvailable = TRUE;               // enable antialiasing
  cueingAvailable = FALSE;          // disable depth cueing
  cullingAvailable = FALSE;         // disable culling 
  // XXX need to test this still
  // ext->hasstereo = CAVEInStereo();  // stereo availability test
  ext->hasstereo = TRUE;            // stereo is on initially
  ext->stereodrawforced = FALSE;    // no need for forced stereo draws
 
  glClearColor(0.0, 0.0, 0.0, 0.0); // set clear color to black

  aa_on();                          // force antialiasing on if possible
  cueing_off();                     // force depth cueing off

  // set default settings 
  set_sphere_mode(sphereMode);
  set_sphere_res(sphereRes);
  set_line_width(lineWidth);
  set_line_style(lineStyle);

  clear();                          // clear screen
  update();                         // swap buffers

  // we want the CAVE to be centered at the origin, and in the range -1, +1
  (transMat.top()).translate(0.0, 3.0, -2.0);
  (transMat.top()).scale(VMD_PI);

  doneGLInit = TRUE;                // only do this once
}
示例#4
0
void AspRegion::display(spAspCell_t cell, spAspTrace_t trace, spAspDataInfo_t dataInfo) {
	set_transparency_level(transparency);
	int roiColor,thick;
	setRoiColor(roiColor,thick);
/* 
// this replace sCoord[0].y with trace data 
        float *traceData = trace->getFirstDataPtr();
        if(!traceData) return;

	int maxpts = trace->getTotalpts();
	if(maxpts<1) return;

	int p1 = trace->val2dpt(sCoord[0].x);
	sCoord[0].y = (*(traceData+p1));
*/
	double cali = cell->getCali(VERT);
  	double yoff = (trace->vp)*cali*(dataInfo->getVoff());
	pCoord[0].x=cell->val2pix(HORIZ,sCoord[0].x);
	pCoord[0].y=cell->val2pix(VERT,sCoord[0].y) - yoff;
//Winfoprintf("region display %d %d %f %f %f %f",p1,maxpts,sCoord[0].x,sCoord[0].y,pCoord[0].x,pCoord[0].y);
	if(selected == HANDLE_SELECTED)
	   AspUtil::drawMark((int)pCoord[0].x,(int)pCoord[0].y,ACTIVE_COLOR,thick);
	else
	   AspUtil::drawMark((int)pCoord[0].x,(int)pCoord[0].y,roiColor,thick);
	return;

	set_spectrum_width(1);
        set_line_width(1);
	set_transparency_level(0);
}
示例#5
0
文件: node_ui.cpp 项目: rolfrm/pigame
 void draw(GLProgram &s){
   set_line_width(ceil(width*scale));
   bind_buffer_object(line_vbo,0);
   s.uniformf("pos",pos_start.x,pos_start.y); //Assume line attr = {(0,0),(1,1)}
   s.uniformf("size", pos_end.x - pos_start.x , pos_end.y - pos_start.y);
   s.uniformf("color",line_color.r,line_color.g,line_color.b,line_color.a);
   draw_buffers_line_loop(2);
 }
示例#6
0
int do_grid(void)
{
    double g, e1, e2;
    int j;

    if (PS.grid <= 0)
	return 1;

    /* set color and set line width to 1 */
    set_ps_color(&PS.grid_color);
    set_line_width(PS.grid_width);

    /* draw horizontal lines in 3 pieces -- lat-lon lines must not
     * extend more than half the globe
     * start with first grid line just south of the window north
     */
    e1 = (PS.w.east * 2 + PS.w.west) / 3;
    e2 = (PS.w.west * 2 + PS.w.east) / 3;

    g = floor(PS.w.north / PS.grid) * PS.grid;
    for (j = 0; g >= PS.w.south; j++, g -= PS.grid) {
	if (g == PS.w.north || g == PS.w.south)
	    continue;

	start_line(PS.w.east, g);
	sec_draw = 0;
	G_plot_line(PS.w.east, g, e1, g);
	fprintf(PS.fp, " D ");

	start_line(e1, g);
	sec_draw = 0;
	G_plot_line(e1, g, e2, g);
	fprintf(PS.fp, " D ");

	start_line(e2, g);
	sec_draw = 0;
	G_plot_line(e2, g, PS.w.west, g);
	fprintf(PS.fp, " D\n");
    }

    /* vertical lines */
    /* start with first grid line just west of the window east */
    g = floor(PS.w.east / PS.grid) * PS.grid;
    for (j = 0; g > PS.w.west; j++, g -= PS.grid) {
	if (g == PS.w.east || g == PS.w.west)
	    continue;
	start_line(g, PS.w.north);
	sec_draw = 0;
	G_plot_line(g, PS.w.north, g, PS.w.south);
	if (j & 1)
	    fprintf(PS.fp, " D\n");
	else
	    fprintf(PS.fp, " D ");
    }

    return 0;
}
示例#7
0
void ScopeVectorscope::draw_point()
{
	if(drag_radius > 0)
	{
		int radius = MIN(get_w() / 2, get_h() / 2);
		set_inverse();
		set_color(0xff0000);
		set_line_width(2);
		draw_circle(get_w() / 2 - drag_radius, 
			get_h() / 2 - drag_radius, 
			drag_radius * 2, 
			drag_radius * 2);
		
		draw_line(get_w() / 2, 
			get_h() / 2, 
			get_w() / 2 + radius * cos(drag_angle),
			get_h() / 2 + radius * sin(drag_angle));
		set_line_width(1);
		set_opaque();
	}
}
示例#8
0
文件: node_ui.cpp 项目: rolfrm/pigame
 void draw(GLProgram &s){
   bind_buffer_object(square_vbo,0);
   s.uniformf("pos",pos.x,pos.y);
   s.uniformf("size",size.x,size.y);
   s.uniformf("color",bg.r,bg.g,bg.b,bg.a);
   
   draw_buffers_triangle_fan(4);
   if(border.a != 0.0 && width > 0.0){
     set_line_width(ceil(width*scale));
     s.uniformf("color",border.r,border.g,border.b,border.a);
     draw_buffers_line_loop(4);
   }
 }
// init ... open a window and set initial default values
int OpenGLDisplayDevice::init(int argc, char **argv, VMDApp *app, int *size, int *loc) {
  vmdapp = app; // save VMDApp handle for use by drag-and-drop handlers

  // open the window
  if (open_window(name, size, loc, argc, argv) != 0) return FALSE;
  if (!have_window) return FALSE;

  // get screen size 
  // XXX There's no Win32 API to get the full multi-monitor desktop,
  //     so this code doesn't correctly handle multi-monitor systems yet.
  //     To correctly handle multiple monitors, we'd have to 
  //     walk the device tree, take into account monitor layout/positioning, 
  //     and compute the desktop dimensions from that.  Since these values
  //     are currently only used by do_reposition_window() method, we can
  //     live with primary-monitor values for the time being.
  screenX = GetSystemMetrics(SM_CXSCREEN);
  screenY = GetSystemMetrics(SM_CYSCREEN);

  // set flags for the capabilities of this display
  ext->hasmultisample = FALSE;      // no code for this extension yet
  ext->nummultisamples = 0;
  aaAvailable = FALSE;

  // set default settings
  if (ext->hasmultisample) {
    aa_on();  // enable fast multisample based antialiasing by default
              // other antialiasing techniques are slow, so only multisample
              // makes sense to enable by default.
  }

  cueingAvailable = TRUE;
  cueing_on(); // leave depth cueing on by default, despite the speed hit.

  cullingAvailable = TRUE;
  culling_off();

  set_sphere_mode(sphereMode);
  set_sphere_res(sphereRes);
  set_line_width(lineWidth);
  set_line_style(lineStyle);

  // reshape and clear the display, which initializes some other variables
  reshape();
  normal();
  clear();
  update();

  // successfully created window
  return TRUE;
}
示例#10
0
void cairo_context::add_text(text_path const& path,
                             cairo_face_manager & manager,
                             face_manager<freetype_engine> & font_manager,
                             double scale_factor)
{
    double sx = path.center.x;
    double sy = path.center.y;

    path.rewind();

    for (int iii = 0; iii < path.num_nodes(); iii++)
    {
        char_info_ptr c;
        double x, y, angle;

        path.vertex(&c, &x, &y, &angle);

        face_set_ptr faces = font_manager.get_face_set(c->format->face_name, c->format->fontset);
        double text_size = c->format->text_size * scale_factor;
        faces->set_character_sizes(text_size);

        glyph_ptr glyph = faces->get_glyph(c->c);

        if (glyph)
        {
            cairo_matrix_t matrix;
            matrix.xx = text_size * cos(angle);
            matrix.xy = text_size * sin(angle);
            matrix.yx = text_size * -sin(angle);
            matrix.yy = text_size * cos(angle);
            matrix.x0 = 0;
            matrix.y0 = 0;

            set_font_matrix(matrix);

            set_font_face(manager, glyph->get_face());

            glyph_path(glyph->get_index(), sx + x, sy - y);
            set_line_width(2.0 * c->format->halo_radius * scale_factor);
            set_line_join(ROUND_JOIN);
            set_color(c->format->halo_fill);
            stroke();
            set_color(c->format->fill);
            show_glyph(glyph->get_index(), sx + x, sy - y);
        }
    }
}
示例#11
0
int ps_outline(void)
{
    /* let user know what's happenning */
    G_message(_("Outlining areas in raster map <%s in %s> ..."),
	      PS.cell_name, PS.cell_mapset);

    /* set the outline color and width */
    set_ps_color(&PS.outline_color);
    set_line_width(PS.outline_width);

    /* create temporary vector map containing outlines */
    o_io_init();
    map_type = o_open_file(PS.cell_name);
    draw_outline();
    o_close_file();

    return 0;
}
int OpenGLPbufferDisplayDevice::init(int argc, char **argv, VMDApp *app, int *size, int *loc) {
  vmdapp = app; // save VMDApp handle for use by drag-and-drop handlers
                // and GPU memory management routines

  // open the window
  glxsrv.windowID = open_window(name, size, loc, argc, argv);
  if (!have_window) return FALSE;

  // set flags for the capabilities of this display
  // whether we can do antialiasing or not.
  if (ext->hasmultisample) 
    aaAvailable = TRUE;  // we use multisampling over other methods
  else
    aaAvailable = FALSE; // no non-multisample implementation yet

  // set default settings
  if (ext->hasmultisample) {
    aa_on();  // enable fast multisample based antialiasing by default
              // other antialiasing techniques are slow, so only multisample
              // makes sense to enable by default.
  } 

  cueingAvailable = TRUE;
  cueing_on(); // leave depth cueing on by default, despite the speed hit.

  cullingAvailable = TRUE;
  culling_off();

  set_sphere_mode(sphereMode);
  set_sphere_res(sphereRes);
  set_line_width(lineWidth);
  set_line_style(lineStyle);

  // reshape and clear the display, which initializes some other variables
  reshape();
  normal();
  clear();
  update();

  // We have a window, return success.
  return TRUE;
}
int OpenGLDisplayDevice::init(int argc, char **argv, VMDApp* app, int *size, int *loc) {

  // open the window
  sdlsrv.windowID = open_window(name, size, loc, argc, argv);
  if (!have_window) return FALSE;

  // set flags for the capabilities of this display
  // whether we can do antialiasing or not.
  if (ext->hasmultisample) 
    aaAvailable = TRUE;  // we use multisampling over other methods
  else
    aaAvailable = FALSE; // no non-multisample implementation yet

  cueingAvailable = TRUE;
  cullingAvailable = TRUE;
  cullingEnabled = FALSE;

  // set default settings
  if (ext->hasmultisample) {
    aa_on();  // enable fast multisample based antialiasing by default
              // other antialiasing techniques are slow, so only multisample
              // makes sense to enable by default.
  } 
  cueing_off(); // leave depth cueing off by default, since its a speed hit.

  set_sphere_mode(sphereMode);
  set_sphere_res(sphereRes);
  set_line_width(lineWidth);
  set_line_style(lineStyle);

  // reshape and clear the display, which initializes some other variables
  reshape();
  normal();
  clear();
  update();

  // successfully opened window.
  return TRUE;
}
void MapDrawingArea::redraw_from_db()
{
    auto cr = Cairo::Context::create(surface);
    cr->transform(matrix);
    cr->set_source_rgb(1, 1, 1);
    cr->paint();
    cr->set_line_width(0.005);
    cr->set_source_rgb(0.8, 0.8, 0.8);

    class DisplayElemPtrLess
    {
    public:
        bool operator()(std::shared_ptr<DisplayElement> a, std::shared_ptr<DisplayElement> b)
        {
            return *a < *b;
        }
    };
    std::set<std::shared_ptr<DisplayElement>, DisplayElemPtrLess> displayed;
    std::vector<std::shared_ptr<DisplayElement> > to_draw;
    for (auto it = dps.begin(); it != dps.end(); ++it)
    {
        auto els = it->second->get_display_elements();
        for (auto it2 = els.begin(); it2 != els.end(); ++it2)
        {
            if (displayed.find(*it2) == displayed.end())
            {
                to_draw.push_back(*it2);
                displayed.insert(*it2);
            }
        }
    }

    for (auto it = to_draw.rbegin(); it != to_draw.rend(); ++it)
    {
        (*it)->draw(cr, *proj);
    }

    invalidate();
}
示例#15
0
int do_grid_cross(void)
{
    double g_north, g_east;
    int j, k;

    if (PS.grid <= 0)
	return 1;

    /* set color and set line width to 1 */
    set_ps_color(&PS.grid_color);
    set_line_width(PS.grid_width);

    g_north = floor(PS.w.north / PS.grid) * PS.grid;
    g_east = floor(PS.w.east / PS.grid) * PS.grid;
    for (j = 0; g_north >= PS.w.south; j++, g_north -= PS.grid) {
	for (k = 0; g_east > PS.w.west; k++, g_east -= PS.grid) {

	    if (g_north == PS.w.north || g_north == PS.w.south)
		continue;
	    if (g_east == PS.w.east || g_east == PS.w.west)
		continue;

	    start_line(g_east - PS.grid_cross, g_north);
	    G_plot_line(g_east - PS.grid_cross, g_north,
			g_east + PS.grid_cross, g_north);
	    fprintf(PS.fp, " D ");
	    start_line(g_east, g_north - PS.grid_cross);
	    G_plot_line(g_east, g_north - PS.grid_cross, g_east,
			g_north + PS.grid_cross);
	    fprintf(PS.fp, " D ");
	}
	g_east = floor(PS.w.east / PS.grid) * PS.grid;
    }

    return 0;
}
示例#16
0
int main(int argc, char *argv[]) {     
    int fd;                      /* fd to Erlang node */
    unsigned char buf[BUFSIZE];  /* Buffer for incoming message */
    ErlMessage emsg;             /* Incoming message */
    int c_node;                   /* C-Node number */
    char cookie[EI_MAX_COOKIE_SIZE+1];  /* Shared cookie */
    short creation;              /* ?? */
    char *erlang_node;           /* Erlang node to connect to */
	 char *cookie_opt;				/* Where to source our cookie */
	 char *cookie_data;				/* Either the filename or literal cookie */
    ETERM *fromp, *msgp, *fnp, *argp, *resp;
    int received, loop = 1;
    
    if (argc < 5) {
        quit_with_error("invalid_args");
    }
    
    c_node = atoi(argv[1]);
    cookie_opt = argv[2];
	 cookie_data = argv[3];
    creation = 0;
    erlang_node = argv[4];
    
    erl_init(NULL, 0);

	 get_cookie(cookie_opt, cookie_data, cookie);
    
    if (!erl_connect_init(c_node, cookie, creation)) {
        quit_with_error("erl_connect_init");
    }
    
    if ((fd = erl_connect(erlang_node)) < 0) {
        quit_with_error("erl_connect"); 
    }
       
    while (loop) {
        received = erl_receive_msg(fd, buf, BUFSIZE, &emsg);

    if (received == ERL_TICK) {
        /* ignore */    
    } else if (received == ERL_ERROR) {
        loop = 0;
    } else {
        if (emsg.type == ERL_REG_SEND) {          
            fromp = erl_element(2, emsg.msg);
            msgp = erl_element(3, emsg.msg);
            fnp = erl_element(1, msgp);
            argp = erl_element(2, msgp);  
            
            if (is_function(fnp, "stop")) {
                loop = 0;
                resp = erl_format("{c_node, ~i, ok}", c_node);
            } else if (is_function(fnp, "new_image_blank")) { 
                resp = new_image_blank(argp, c_node); 
            } else if (is_function(fnp, "write_to_png")) {
                resp = write_to_png(argp, c_node);
            } else if (is_function(fnp, "close_image")) {
                resp = close_image(argp, c_node);
            } else if (is_function(fnp, "save")) {
                resp = save(argp, c_node);
            } else if (is_function(fnp, "restore")) {
                resp = restore(argp, c_node);
            } else if (is_function(fnp, "set_line_width")) {
                resp = set_line_width(argp, c_node);
            } else if (is_function(fnp, "set_source_rgba")) {
                resp = set_source_rgba(argp, c_node);	
	        } else if (is_function(fnp, "set_operator")) {
                resp = set_operator(argp, c_node);
            } else if (is_function(fnp, "move_to")) {
                resp = move_to(argp, c_node);
            } else if (is_function(fnp, "line_to")) {
                resp = line_to(argp, c_node);
            } else if (is_function(fnp, "curve_to")) {
                resp = curve_to(argp, c_node);
            } else if (is_function(fnp, "rel_move_to")) {
                resp = rel_move_to(argp, c_node);
            } else if (is_function(fnp, "rel_line_to")) {
                resp = rel_line_to(argp, c_node);
            } else if (is_function(fnp, "rel_curve_to")) {
                resp = rel_curve_to(argp, c_node);
            } else if (is_function(fnp, "rectangle")) {
                resp = rectangle(argp, c_node);
            } else if (is_function(fnp, "arc")) {
                resp = arc(argp, c_node);
            } else if (is_function(fnp, "arc_negative")) {
                resp = arc_negative(argp, c_node);
            } else if (is_function(fnp, "close_path")) {
                resp = close_path(argp, c_node);
            } else if (is_function(fnp, "paint")) {
                resp = paint(argp, c_node);
            } else if (is_function(fnp, "fill")) {
                resp = fill(argp, c_node);
            } else if (is_function(fnp, "fill_preserve")) {
                resp = fill_preserve(argp, c_node);
            } else if (is_function(fnp, "stroke")) {
                resp = stroke(argp, c_node);
            } else if (is_function(fnp, "stroke_preserve")) {
                resp = stroke_preserve(argp, c_node);
            } else if (is_function(fnp, "translate")) {
                resp = translate(argp, c_node);
            } else if (is_function(fnp, "scale")) {
                resp = scale(argp, c_node);
            } else if (is_function(fnp, "rotate")) {
                resp = rotate(argp, c_node);
            } else if (is_function(fnp, "select_font")) {
                resp = select_font_face(argp, c_node);
            } else if (is_function(fnp, "set_font_size")) {
                resp = set_font_size(argp, c_node);
            } else if (is_function(fnp, "show_text")) {
                resp = show_text(argp, c_node);
            } else if (is_function(fnp, "text_extents")) {
                resp = text_extents(argp, c_node);          
            } else if (is_function(fnp, "surface_create_from_png")) {
                resp = surface_create_from_png(argp, c_node);
            } else if (is_function(fnp, "surface_create_from_png_stream")) {
                resp = surface_create_from_png_stream(argp, c_node);
            } else if (is_function(fnp, "surface_get_width")) {
                resp = surface_get_width(argp, c_node);          
            } else if (is_function(fnp, "surface_get_height")) {
                resp = surface_get_height(argp, c_node);          
            } else if (is_function(fnp, "surface_destroy")) {
                resp = surface_destroy(argp, c_node);          
            } else if (is_function(fnp, "set_source_surface")) {
                resp = set_source_surface(argp, c_node);          
            } else if (is_function(fnp, "write_to_png_stream")) {
                resp = write_to_png_stream(argp, c_node);          
            } else {
                resp = erl_format("{c_node, ~i, {error, '~s'}}", c_node, "unknown command");
            }         
            erl_send(fd, fromp, resp);           
            erl_free_term(emsg.from); 
            erl_free_term(emsg.msg);
            erl_free_term(fromp); 
            erl_free_term(msgp);
            erl_free_term(fnp); 
            erl_free_term(argp);
            erl_free_term(resp);
      }
    }
  }
  exit(EXIT_SUCCESS);
}
示例#17
0
void GraphicCanvas::process(int buttonpress, int motion, int draw)
{
	int got_button = 0;
	int center_y = get_h() / 2;
	int out_of_order = 0;
	ArrayList<GraphicPoint*> *points;
	double *envelope;
	const int debug = 0;


	if(state == GraphicCanvas::NONE)
	{
		points = &plugin->config.points;
		envelope = plugin->envelope;
	}
	else
	{
		points = &temp_points;
		envelope = temp_envelope;
	}

	plugin->calculate_envelope(points, envelope);


// spectrogram
	if(draw)
	{
		clear_box(0, 0, get_w(), get_h());


		int niquist = plugin->PluginAClient::project_sample_rate / 2;
		int total_frames = plugin->get_gui_update_frames();
		GraphicGUIFrame *frame = (GraphicGUIFrame*)plugin->get_gui_frame();

		if(frame)
		{
			delete plugin->last_frame;
			plugin->last_frame = frame;
		}
		else
		{
			frame = plugin->last_frame;
		}

// Draw most recent frame
		if(frame)
		{
			set_color(MEGREY);
			int y1 = 0;
			int y2 = 0;


			for(int i = 0; i < get_w(); i++)
			{
				int freq = Freq::tofreq(i * TOTALFREQS / get_w());
				int index = (int64_t)freq * (int64_t)frame->window_size / 2 / niquist;
				if(index < frame->window_size / 2)
				{
					double magnitude = frame->data[index] / 
						frame->freq_max * 
						frame->time_max;
					y2 = (int)(get_h() - 
						(DB::todb(magnitude) - INFINITYGAIN) *
						get_h() / 
						-INFINITYGAIN);
					CLAMP(y2, 0, get_h() - 1);
					if(i > 0)
					{
						draw_line(i - 1, y1, i, y2);
//printf(" %.0f", frame->data[index]);
					}
					y1 = y2;
				}
			}
//printf( "\n");

			total_frames--;
		}






// Delete remaining frames
		while(total_frames > 0)
		{
			PluginClientFrame *frame = plugin->get_gui_frame();

			if(frame) delete frame;
			total_frames--;
		}
	}


// Determine if active point is out of order
	if(plugin->active_point_exists())
	{
		GraphicPoint *active_point = points->get(plugin->active_point);
		for(int i = 0; i < points->size(); i++)
		{
			if(i == plugin->active_point)
			{
				if(i < points->size() - 1 &&
					active_point->freq >= points->get(i + 1)->freq ||
					i > 0 &&
					active_point->freq <= points->get(i - 1)->freq)
				{
					out_of_order = 1;
				}
				break;
			}
		}
	}


	if(motion)
	{
		if(state == GraphicCanvas::DRAG_POINT)
		{
			int point_x = get_cursor_x() + x_diff;
			int point_y = get_cursor_y() + y_diff;
			CLAMP(point_x, 0, get_w());
			CLAMP(point_y, 0, get_h());
			
			int frequency = Freq::tofreq(point_x * TOTALFREQS / get_w());
			double magnitude_db = (double)(center_y - point_y) * MAXMAGNITUDE / center_y;
			int minfreq = Freq::tofreq(0);
			int maxfreq = Freq::tofreq(TOTALFREQS - 1);

			CLAMP(frequency, minfreq, maxfreq);
			CLAMP(magnitude_db, -MAXMAGNITUDE, MAXMAGNITUDE);
			if(plugin->active_point >= 0)
			{
				GraphicPoint *active_point = points->get(plugin->active_point);
				active_point->freq = frequency;
				active_point->value = magnitude_db;
			}

// Redraw with new value
			process(0, 0, 1);
			save_temps();
			plugin->send_configure_change();
			gui->update_textboxes();
			return;
		}
	}

// Magnitude bars
	if(draw)
	{
		set_color(GREEN);
		set_line_dashes(1);
		for(int i = 1; i < MAJOR_DIVISIONS; i++)
		{
			int y = i * get_h() / (MAJOR_DIVISIONS - 1);
			draw_line(0, y, get_w(), y);
		}
		set_line_dashes(0);
	}

	int y1 = 0;
	if(draw) set_color(WHITE);

// Control points, cursor change and control point selection
	int new_cursor = CROSS_CURSOR;
	for(int i = 0; i < points->size(); i++)
	{
		GraphicPoint *point = points->get(i);
		int x = Freq::fromfreq(point->freq) * get_w() / TOTALFREQS;
		int y = freq_to_y(point->freq, points, envelope);

		if(draw)
		{
			y1 = y;
// Draw point under cursor if out of order
			if(i == plugin->active_point && out_of_order) 
				y1 = get_cursor_y() + y_diff;

			if(i == plugin->active_point)
				draw_box(x - BOX_SIZE / 2, y1 - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
			else
				draw_rectangle(x - BOX_SIZE / 2, y1 - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
		}

		if(motion && 
			state == GraphicCanvas::NONE &&
			is_event_win() && 
			cursor_inside())
		{
			if(get_cursor_x() >= x - BOX_SIZE / 2 &&
				get_cursor_y() >= y - BOX_SIZE / 2 &&
				get_cursor_x() < x + BOX_SIZE / 2 &&
				get_cursor_y() < y + BOX_SIZE / 2)
			{
				new_cursor = UPRIGHT_ARROW_CURSOR;
			}
		}
		
		if(buttonpress &&
			state == GraphicCanvas::NONE &&
			is_event_win() && 
			cursor_inside() &&
			!got_button)
		{
			if(get_cursor_x() >= x - BOX_SIZE / 2 &&
				get_cursor_y() >= y - BOX_SIZE / 2 &&
				get_cursor_x() < x + BOX_SIZE / 2 &&
				get_cursor_y() < y + BOX_SIZE / 2)
			{
				plugin->active_point = i;
				state = GraphicCanvas::DRAG_POINT;
				new_temps();
				points = &temp_points;
				envelope = temp_envelope;

				x_diff = x - get_cursor_x();
				y_diff = y - get_cursor_y();
				got_button = 1;
				process(0, 0, 1);
				save_temps();
				plugin->send_configure_change();
				gui->update_textboxes();
			}
		}
	}

	if(motion && new_cursor != get_cursor())
	{
		set_cursor(new_cursor, 0, 1);
	}

// Envelope line;
	y1 = 0;
	set_line_width(2);
	for(int i = 0; i < get_w(); i++)
	{
		int y = freq_to_y(Freq::tofreq(i * TOTALFREQS / get_w()), 
			points, 
			envelope);

		if(draw)
		{
			if(i > 0) draw_line(i - 1, y1, i, y);
		}


		y1 = y;
	}
	set_line_width(1);

	if(buttonpress && !got_button)
	{
		if(is_event_win() && cursor_inside())
		{
			GraphicPoint *new_point = new GraphicPoint;
			new_point->freq = Freq::tofreq(get_cursor_x() * 
				TOTALFREQS / 
				get_w());
			new_point->value = (double)(center_y - get_cursor_y()) * 
				MAXMAGNITUDE / 
				center_y;
			state = GraphicCanvas::DRAG_POINT;
			new_temps();
			points = &temp_points;
			envelope = temp_envelope;

			insert_point(new_point);
			plugin->active_point = points->number_of(new_point);
			x_diff = 0;
			y_diff = 0;

// Redraw with new point
			process(0, 0, 1);
			save_temps();
			plugin->send_configure_change();
			gui->update_textboxes();
		}
	}


	if(draw) 
	{
		flash();
	}
}
示例#18
0
void cairo_context::add_text(glyph_positions const& pos,
                             cairo_face_manager & manager,
                             composite_mode_e comp_op,
                             composite_mode_e halo_comp_op,
                             double scale_factor)
{
    pixel_position const& base_point = pos.get_base_point();
    const double sx = base_point.x;
    const double sy = base_point.y;

    for (auto const& glyph_pos : pos)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        glyph.face->set_character_sizes(glyph.format->text_size * scale_factor);
    }

    //render halo
    double halo_radius = 0;
    set_operator(halo_comp_op);
    for (auto const& glyph_pos : pos)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        halo_radius = glyph.format->halo_radius * scale_factor;
        // make sure we've got reasonable values.
        if (halo_radius <= 0.0 || halo_radius > 1024.0) continue;
        double text_size = glyph.format->text_size * scale_factor;
        cairo_matrix_t matrix;
        matrix.xx = text_size * glyph_pos.rot.cos;
        matrix.xy = text_size * glyph_pos.rot.sin;
        matrix.yx = text_size * -glyph_pos.rot.sin;
        matrix.yy = text_size * glyph_pos.rot.cos;
        matrix.x0 = 0;
        matrix.y0 = 0;
        set_font_matrix(matrix);
        set_font_face(manager, glyph.face);
        pixel_position new_pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
        glyph_path(glyph.glyph_index, pixel_position(sx + new_pos.x, sy - new_pos.y));
        set_line_width(2.0 * halo_radius);
        set_line_join(ROUND_JOIN);
        set_color(glyph.format->halo_fill, glyph.format->halo_opacity);
        stroke();
    }
    set_operator(comp_op);
    for (auto const& glyph_pos : pos)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        double text_size = glyph.format->text_size * scale_factor;
        cairo_matrix_t matrix;
        matrix.xx = text_size * glyph_pos.rot.cos;
        matrix.xy = text_size * glyph_pos.rot.sin;
        matrix.yx = text_size * -glyph_pos.rot.sin;
        matrix.yy = text_size * glyph_pos.rot.cos;
        matrix.x0 = 0;
        matrix.y0 = 0;
        set_font_matrix(matrix);
        set_font_face(manager, glyph.face);
        pixel_position new_pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
        set_color(glyph.format->fill, glyph.format->text_opacity);
        show_glyph(glyph.glyph_index, pixel_position(sx + new_pos.x, sy - new_pos.y));
    }

}
示例#19
0
int do_scalebar(void)
{
    double scale_size;
    double length, width;
    double x, x1, x2, y1, y2, y3;
    int seg, i, j, lab;
    int margin;
    char num[50];

    /* get scale size */
    scale_size =
	METERS_TO_INCHES * distance(PS.w.east, PS.w.west) / scale(PS.scaletext);

    /* convert scale size to map inches */
    length = (sb.length / scale_size) *
	G_database_units_to_meters_factor() * METERS_TO_INCHES;

    /* if(sb.units == SB_UNITS_AUTO) { do nothing } */
    if(sb.units == SB_UNITS_METERS)
	    length /= G_database_units_to_meters_factor();
    else if(sb.units == SB_UNITS_KM)
	    length *= KILOMETERS_TO_METERS / G_database_units_to_meters_factor();
    else if(sb.units == SB_UNITS_FEET)
	    length *= FEET_TO_METERS / G_database_units_to_meters_factor();
    else if(sb.units == SB_UNITS_MILES)
	    length *= MILES_TO_METERS / G_database_units_to_meters_factor();
    else if(sb.units == SB_UNITS_NMILES)
	    length *= NAUT_MILES_TO_METERS / G_database_units_to_meters_factor();

    width = sb.height;
    seg = sb.segment;
    j = 0;
    lab = 0;

    margin = (int)(0.2 * (double)sb.fontsize + 0.5);
    if (margin < 2)
	margin = 2;
    fprintf(PS.fp, "/mg %d def\n", margin);
    x = sb.x - (length / 2.);
    set_font_size(sb.fontsize);
    set_line_width(sb.width);

    if (strcmp(sb.type, "f") == 0) {
	/* draw fancy scale bar */

	for (i = 0; i < seg; i++) {
	    /* draw a filled rectangle */
	    x1 = 72.0 * (x + (length / seg) * i) + 0.5;
	    y1 = 72.0 * (PS.page_height - sb.y);
	    x2 = 72.0 * (x + (length / seg) * (i + 1)) + 0.5;
	    y2 = (72.0 * (PS.page_height - sb.y)) + (width * 72.0);

	    /* Alternate black and white */
	    if (j == 0) {
		fprintf(PS.fp, "0.0 0.0 0.0 C\n");
		j = 1;
	    }
	    else {
		fprintf(PS.fp, "1.0 1.0 1.0 C\n");
		j = 0;
	    }
	    fprintf(PS.fp, "%.1f %.1f %.1f %.1f B\n", x1, y1, x2, y2);

	    /* set outline to black */
	    fprintf(PS.fp, "F 0.0 0.0 0.0 C\n");
	    fprintf(PS.fp, "D\n");

	    lab++;

	    /* do text */
	    if (i == 0 || lab == sb.numbers) {
		sprintf(num, "%s", nice_number((sb.length / sb.segment) * i));
		text_box_path(x1, y2 + margin, CENTER, LOWER, num,
			      sb.fontsize, 0);
		if (sb.bgcolor) {	/* TODO: take bg color, not just [white|none] */
		    set_rgb_color(WHITE);
		    fprintf(PS.fp, "F ");
		}
		set_rgb_color(BLACK);
		fprintf(PS.fp, "TIB\n");
		lab = 0;
	    }

	    if ((lab > 0 && i == seg - 1) ||
		(sb.numbers == 1 && i == seg - 1)) {
		/* special case for last label */
		sprintf(num, "%s", nice_number(sb.length));
		text_box_path(x2, y2 + margin, CENTER, LOWER, num,
			      sb.fontsize, 0);
		if (sb.bgcolor) {
		    set_rgb_color(WHITE);
		    fprintf(PS.fp, "F ");
		}
		set_rgb_color(BLACK);
		fprintf(PS.fp, "TIB\n");
	    }

	}

    }
    else {
	/* draw simple scalebar */

	x1 = 72.0 * x + 0.5;
	y1 = (72.0 * (PS.page_height - sb.y)) + (width * 72.0);
	x2 = 72.0 * x + 0.5;
	y2 = 72.0 * (PS.page_height - sb.y);

	fprintf(PS.fp, "%.1f %.1f %.1f %.1f L D\n", x1, y1, x2, y2);

	/* draw label */
	text_box_path(x1, y1 + margin, CENTER, LOWER, "0", sb.fontsize, 0);
	if (sb.bgcolor) {
	    set_rgb_color(WHITE);
	    fprintf(PS.fp, "F ");
	}
	set_rgb_color(BLACK);
	fprintf(PS.fp, "TIB\n");


	x1 = 72.0 * x + 0.5;
	y1 = 72.0 * (PS.page_height - sb.y);
	x2 = 72.0 * (x + length) + 0.5;
	y2 = 72.0 * (PS.page_height - sb.y);
	fprintf(PS.fp, "%.1f %.1f %.1f %.1f L D\n", x1, y1, x2, y2);

	x1 = 72.0 * (x + length) + 0.5;
	y2 = (72.0 * (PS.page_height - sb.y)) + (width * 72.0);
	x2 = 72.0 * (x + length) + 0.5;
	y1 = 72.0 * (PS.page_height - sb.y);
	fprintf(PS.fp, "%.1f %.1f %.1f %.1f L D\n", x1, y1, x2, y2);

	/* draw label */
	sprintf(num, "%s", nice_number(sb.length));
	text_box_path(x1, y2 + margin, CENTER, LOWER, num, sb.fontsize, 0);
	if (sb.bgcolor) {
	    set_rgb_color(WHITE);
	    fprintf(PS.fp, "F ");
	}
	set_rgb_color(BLACK);
	fprintf(PS.fp, "TIB\n");


	for (i = 1; i < seg; i++) {
	    x1 = 72.0 * (x + (length / seg) * i) + 0.5;
	    y1 = 72.0 * (PS.page_height - sb.y);
	    x2 = 72.0 * (x + (length / seg) * i) + 0.5;
	    y2 = (72.0 * (PS.page_height - sb.y)) + (width / 2. * 72.0);
	    y3 = (72.0 * (PS.page_height - sb.y)) + (width * 72.0);

	    fprintf(PS.fp, "%.1f %.1f %.1f %.1f L D\n", x1, y1, x2, y2);

	    lab++;

	    /* do text */
	    if (lab == sb.numbers) {
		sprintf(num, "%s", nice_number((sb.length / sb.segment) * i));

		text_box_path(x1, y3 + margin, CENTER, LOWER, num,
			      sb.fontsize, 0);
		if (sb.bgcolor) {
		    set_rgb_color(WHITE);
		    fprintf(PS.fp, "F ");
		}
		set_rgb_color(BLACK);
		fprintf(PS.fp, "TIB\n");
		lab = 0;
	    }

	}
    }


    /* draw units label */
    if (sb.units == SB_UNITS_AUTO)
	strcpy(num, G_database_unit_name(TRUE));
    else if(sb.units == SB_UNITS_METERS)
	strcpy(num, "meters");
    else if(sb.units == SB_UNITS_KM)
	strcpy(num, "kilometers");
    else if(sb.units == SB_UNITS_FEET)
	strcpy(num, "feet");
    else if(sb.units == SB_UNITS_MILES)
	strcpy(num, "miles");
    else if(sb.units == SB_UNITS_NMILES)
	strcpy(num, "nautical miles");
    
    text_box_path(72.0 * (x + length/2), 72.0 * (PS.page_height - (sb.y + 0.075)),
	CENTER, UPPER, num, sb.fontsize, 0);

    if (sb.bgcolor) {
	set_rgb_color(WHITE);
	fprintf(PS.fp, "F ");
    }
    set_rgb_color(BLACK);
    fprintf(PS.fp, "TIB\n");


    return 0;
}
示例#20
0
// constructor ... open a window and set initial default values
FltkOpenGLDisplayDevice::FltkOpenGLDisplayDevice(int argc, char **argv, 
  VMDApp *vmdapp_p, int *size, int *loc)
    : OpenGLRenderer((char *) "VMD " VMDVERSION " OpenGL Display") {

  vmdapp = vmdapp_p; // save VMDApp handle for use by drag-and-drop handlers, 
                     // and GPU memory management routines

  // set up data possible before opening window
  stereoNames = glStereoNameStr;
  stereoModes = OPENGL_STEREO_MODES;

  // GLSL is only available on MacOS X 10.4 and later.
  renderNames = glRenderNameStr;
  renderModes = OPENGL_RENDER_MODES;

  cacheNames = glCacheNameStr;
  cacheModes = OPENGL_CACHE_MODES;

  // open the window
  int SX = 100, SY = 100, W, H;

  W = size[0];
  H = size[1];
  if (loc) {
    SX = loc[0];
    SY = loc[1];
  }
  window = new myglwindow(SX, SY, W, H, name, this, vmdapp_p);

  ext->hasstereo = FALSE;         // stereo is off initially
  ext->stereodrawforced = FALSE;  // stereo not forced initially
  ext->hasmultisample = FALSE;    // multisample is off initially

  int rc=0;
// FLTK stereo support only started working for MacOS X at around version 1.1.7
#if (FL_MAJOR_VERSION >= 1) && (((FL_MINOR_VERSION >= 1) && (FL_PATCH_VERSION >= 7)) || ((FL_MINOR_VERSION >= 1) && (FL_PATCH_VERSION >= 7)))
  // find an appropriate visual and colormap ...
  if (getenv("VMDPREFERSTEREO") != NULL) {
    // Stereo limps along with FLTK 1.1.7 on MacOS X
    rc = window->mode(FL_RGB8 | FL_DOUBLE | FL_STENCIL | FL_STEREO);
    ext->hasstereo = TRUE;
#if defined(__APPLE__)
    ext->stereodrawforced = TRUE; // forced draw in stereo all the time when on
#endif
  // FLTK multisample antialiasing still doesn't actually work in 
  // MacOS X as of FLTK 1.1.10...
#if !defined(__APPLE__)
  //  } else if (getenv("VMDPREFERMULTISAMPLE") != NULL) {
  } else if (rc != 0) {
    rc = window->mode(FL_RGB8 | FL_DOUBLE | FL_STENCIL | FL_MULTISAMPLE);
    ext->hasmultisample = TRUE; // FLTK only does SGI multisample, no ARB yet
#endif
  } else {
    rc = window->mode(FL_RGB8 | FL_DOUBLE | FL_STENCIL);
  }
#else
  // find an appropriate visual and colormap ...
  rc = window->mode(FL_RGB8 | FL_DOUBLE | FL_STENCIL);
#endif

  window->show();
  // (7) bind the rendering context to the window
  window->make_current();

  // (8) actually request the window to be displayed
  screenX = Fl::w();
  screenY = Fl::h();  

  // (9) configure the rendering properly
  setup_initial_opengl_state();  // setup initial OpenGL state
  
  // set flags for the capabilities of this display
  // whether we can do antialiasing or not.
  if (ext->hasmultisample) 
    aaAvailable = TRUE;  // we use multisampling over other methods
  else
    aaAvailable = FALSE; // no non-multisample implementation yet

  // set default settings
  if (ext->hasmultisample) {
    aa_on();  // enable fast multisample based antialiasing by default
              // other antialiasing techniques are slow, so only multisample
              // makes sense to enable by default.
  } 

  cueingAvailable = TRUE;
  cueing_on(); // leave depth cueing on by default, despite the speed hit.

  cullingAvailable = TRUE;
  culling_off();

  set_sphere_mode(sphereMode);
  set_sphere_res(sphereRes);
  set_line_width(lineWidth);
  set_line_style(lineStyle);

  // reshape and clear the display, which initializes some other variables
  reshape();
  normal();
  clear();
  update();
}
示例#21
0
void AspInteg::display(spAspCell_t cell, spAspTrace_t trace, spAspDataInfo_t dataInfo, 
	int integFlag, double is, double off) {
	set_transparency_level(transparency);

	disFlag = integFlag;

        float *traceData = trace->getFirstDataPtr();
        if(!traceData) return;

	int maxpts = trace->getTotalpts();
	if(maxpts<1) return;

	absValue = trace->getInteg(sCoord[0].x,sCoord[1].x);

   double x1=pCoord[0].x=cell->val2pix(HORIZ,sCoord[0].x);
   double x2=pCoord[1].x=cell->val2pix(HORIZ,sCoord[1].x);

	// get integ data
	if(m_data) delete[] m_data;

        int p1 = trace->val2dpt(sCoord[0].x);                           
        int p2 = trace->val2dpt(sCoord[1].x);                
	m_datapts = p2-p1+1;
        m_data = new float[m_datapts];
        float sum = 0;
        int k=0;
        for(int i=p1;i<=p2;i++) {
          //sum += (*(traceData+i) - *(traceData+p1));
          sum += (*(traceData+i));
          (*(m_data+k)) = sum;
          k++;
        }

	double vcali = cell->getCali(VERT);

	m_scale = is/(double)maxpts;
	m_yoff = off*vcali;

	double vscale = dataInfo->getVscale();
	if(vscale == 0) vscale = 1.0;
	double scale = m_scale*vscale*vcali;

        // add vp
        double yoff = m_yoff + (dataInfo->getVpos())*vcali;

   double y1=pCoord[0].y=cell->val2pix(VERT,(*(m_data))*m_scale) - m_yoff;
   double y2=pCoord[1].y=cell->val2pix(VERT,(*(m_data+m_datapts-1))*m_scale) - m_yoff;
//AspUtil::drawMark((int)x1,(int)y1,ACTIVE_COLOR);
//AspUtil::drawMark((int)x2,(int)y2,ACTIVE_COLOR);

	// check x1, x2 boundary 
	double px,pw,py,ph,px2;
	cell->getPixCell(px,py,pw,ph);
	px2=px+pw;
	if(x1 < px && x2 < px) return;
	if(x1 > px2 && x2 > px2) return;
	if(x1 < px) x1=px;
	if(x2 > px2) x2=px2;
	 

        int roiColor;
 	if(selected == ROI_SELECTED) roiColor=ACTIVE_COLOR;
        else roiColor = INT_COLOR;
        
	char thickName[64];
        int thickness; // used by functions
        int thick=0; // use thickness set by functions
        string value; 
	if(integFlag & SHOW_INTEG) { 
	  getOptName(INTEG_LINE,thickName);
	  //AspUtil::getDisplayOption(string(thickName)+"Thickness",value); 
	  //thickness = atoi(value.c_str());
	  //set_spectrum_width(thickness);
          //set_line_width(thickness);
	  set_spectrum_thickness(thickName,thickName,1.0);
	  set_line_thickness(thickName);
	  cell->drawPolyline(m_data,m_datapts,1,x1,py,x2-x1,ph,roiColor,scale,yoff);
	  int i = selectedHandle-1;
     	  if(i>=0 && i < npts) {
        	AspUtil::drawMark((int)pCoord[i].x,(int)pCoord[i].y,ACTIVE_COLOR,thick);
	  }
	}
        labelX=labelY=labelW=labelH=0;
	if((integFlag & SHOW_LABEL)) {
	  if(integFlag & SHOW_VERT_LABEL) rotate = 1;
	  else rotate=0;
	  string labelStr;
	  getLabel(dataInfo,labelStr,labelW,labelH);
	  labelX=(int)(labelLoc.x+(x1+x2)/2) - labelW/2;
	  labelY=(int)(labelLoc.y+(y1+y2)/2) - labelH;
	  if(labelY<(py+labelH)) labelY = (int)py+labelH;
	  char fontName[64];
	  if(LABEL_SELECTED) {
	     int labelColor;		
	     setFont(labelColor);
     	     AspUtil::drawString((char *)labelStr.c_str(), labelX,labelY, labelColor, "", rotate);
	  } else {
	     getOptName(INTEG_LABEL,fontName); 
	     AspUtil::drawString((char *)labelStr.c_str(), labelX, labelY, -1, fontName,rotate);
	  }
	  labelY -= labelH;
	}
 	if(selected == ROI_SELECTED) roiColor=ACTIVE_COLOR;
	else roiColor = INTEG_MARK_COLOR;

	getOptName(INTEG_MARK,thickName);
	AspUtil::getDisplayOption(string(thickName)+"Thickness",value); 
	thickness = atoi(value.c_str());
	if(thickness < 1) thickness=1;
	//set_spectrum_width(thickness);
        //set_line_width(thickness);
	set_spectrum_thickness(thickName,thickName,1.0);
	set_line_thickness(thickName);

	if((integFlag & SHOW_VALUE) && (integFlag & SHOW_VERT_VALUE)) {
	  string labelStr;
          int cwd, cht, ascent, descent;
	  getValue(dataInfo,labelStr,cht,cwd);
	  // overwrite cht, cwd with fixed length
          char str[MAXSTR];
          sprintf(str,"%.2f",100.00);
          GraphicsWin::getTextExtents(str, 14, &ascent, &descent, &cht);
          cwd = ascent + descent;
	  double y = py + ph - cht - 5*thickness;  
	  Dpoint_t p1,p2;
	  p1.x=x1;
	  p2.x=x2;
	  p1.y=p2.y=y;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=x1;
	  p2.y=y-5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=x2;
	  p2.y=y-5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=0.5*(x1+x2);
	  p2.y=y+5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  char fontName[64];
	  getOptName(INTEG_NUM,fontName); 
	  y = py + ph - cwd/2;
	  AspUtil::drawString((char *)labelStr.c_str(), (int)p1.x-cwd/2, (int)y, -1, fontName,1);
	} else if(integFlag & SHOW_VALUE) {
	  string labelStr;
   	  int cwd, cht;
	  getValue(dataInfo,labelStr,cwd,cht);
	  double y = py + ph - cht - 15*thickness;  
	  Dpoint_t p1,p2;
	  p1.x=x1;
	  p2.x=x2;
	  p1.y=p2.y=y;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=x1;
	  p2.y=y-5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=x2;
	  p2.y=y-5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=0.5*(x1+x2);
	  p2.y=y+5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  char fontName[64];
	  getOptName(INTEG_NUM,fontName); 
	  y = py + ph - cht/2;
	  AspUtil::drawString((char *)labelStr.c_str(), (int)p1.x-cwd/2, (int)y, -1, fontName,0);
	}
	getOptName(SPEC_LINE_MIN,thickName);
	set_spectrum_width(1);
        set_line_width(1);
	set_transparency_level(0);
}
示例#22
0
void WMFUpdateState::SelectObject(int nIndex)
{
	ASSERT(nIndex < m_cpaGdiObjects.GetSize());
	if (nIndex != -1 && nIndex < m_cpaGdiObjects.GetSize())
	{
		CWMFGdiObject* pObject = (CWMFGdiObject*)m_cpaGdiObjects.GetAt(nIndex);
		ASSERT(pObject != NULL);
		if (pObject != NULL)
		{
			// We have an object.
			switch (pObject->m_nType)
			{
				case CWMFGdiObject::Brush:
				{
					m_DCState.m_nCurrentBrush = nIndex;
					CWMFBrushObject* pBrush = (CWMFBrushObject*)pObject;

					// Handle the interior style.
					switch (pBrush->m_LogBrush.lbStyle)
					{
						case BS_NULL:
						{
							set_interior_style(STYLE_Empty);
							break;
						}
						case BS_HATCHED:
						{
							set_interior_style(STYLE_Hatch);
//							set_hatch_index(?);
							break;
						}
						case BS_PATTERN:
						{
							set_interior_style(STYLE_Pattern);
							break;
						}
						default:
						case BS_SOLID:
						{
							set_interior_style(STYLE_Solid);
							break;
						}
					}

					// Handle the interior color.
					set_fill_color(RGBToOutlineColor(pBrush->m_LogBrush.lbColor));
					break;
				}
				case CWMFGdiObject::Pen:
				{
					m_DCState.m_nCurrentPen = nIndex;
					CWMFPenObject* pPen = (CWMFPenObject*)pObject;

					// Handle the edge visibility.
					set_edge_visibility(pPen->m_LogPen.lopnStyle != PS_NULL);

					// Handle the line/edge color.
					OUTLINE_COLOR Color = RGBToOutlineColor(pPen->m_LogPen.lopnColor);
					set_line_color(Color);
					set_edge_color(Color);

//					TRACE("Select Pen - Style: %u; Width: %d, %d; Color: %08lx\n",
//							pPen->m_LogPen.lopnStyle,
//							pPen->m_LogPen.lopnWidth.x,
//							pPen->m_LogPen.lopnWidth.y,
//							pPen->m_LogPen.lopnColor);

					// Handle the line/edge width.
					int nWidth = (pPen->m_LogPen.lopnWidth.y > pPen->m_LogPen.lopnWidth.x)
										? pPen->m_LogPen.lopnWidth.y : pPen->m_LogPen.lopnWidth.x;
					set_edge_width((short)nWidth);
					set_line_width((short)nWidth);
					break;
				}
				case CWMFGdiObject::Font:
				{
					m_DCState.m_nCurrentFont = nIndex;
					SetCurrentFont(((CWMFFontObject*)pObject)->m_LogFont);

					break;
				}
				case CWMFGdiObject::Palette:
				{
					m_DCState.m_nCurrentPalette = nIndex;
					SetCurrentPalette(((CWMFPaletteObject*)pObject)->m_pPalette);

					break;
				}
				default:
				{
					// Invalid GDI object type.
					ASSERT(FALSE);
					break;
				}
			}
		}
	}
}