Пример #1
0
/** Expose event handler.
 * @param event event info structure.
 * @return signal return value
 */
bool
SkillGuiGraphDrawingArea::on_expose_event(GdkEventExpose* event)
{
  update_translations();
  // This is where we draw on the window
  Glib::RefPtr<Gdk::Window> window = get_window();
  if(window) {
    //Gtk::Allocation allocation = get_allocation();
    //const int width = allocation.get_width();
    //const int height = allocation.get_height();
    
    // coordinates for the center of the window
    //int xc, yc;
    //xc = width / 2;
    //yc = height / 2;
    
    __cairo = window->create_cairo_context();
    __cairo->set_source_rgb(1, 1, 1);
    __cairo->paint();

    if (__graph) {
      Glib::Timer t;
      gvRender(__gvc, __graph, (char *)"skillguicairo", NULL);
      t.stop();
      //printf("Rendering took %f seconds\n", t.elapsed());
    }

    __cairo.clear();
  }
  return true;
}
Пример #2
0
bool guiRenderer2D::on_expose_event(GdkEventExpose* event) {

	Glib::RefPtr<Gdk::Window> window = get_window();
	if(window) {
		Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
		if(event) {
			// clip to the area indicated by the expose event so that we only
			// redraw the portion of the window that needs to be redrawn
			//printf("event->area.x: %d, event->area.y: %d, event->area.width: %d, event->area.height: %d\n", event->area.x, event->area.y, event->area.width, event->area.height );
			cr->rectangle(event->area.x, event->area.y,	event->area.width, event->area.height);
			cr->clip();
		}

		// Background
		// cr->set_source_rgb(0.0, 0.0, 0.0);
		cr->set_source_rgb(1.0, 1.0, 1.0);
		cr->paint();

		if(m_isRendering && m_layoutAvailable) {
			Gtk::Allocation allocation = get_allocation();
			int width = allocation.get_width();
			int height = allocation.get_height();

			if(width != m_widgetWidth || height != m_widgetHeight ) { // Allocation changed
				rescaleSensorLayout(width, height);
			}

			drawMatrices(cr, width, height, false);
		}
	}

	return true;
}
void ActivityDrawingArea::drawAxis() {
	// draw a reference axis and pod info
	Glib::RefPtr < Gdk::Window > window = get_window();
	Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();

	//draw axis
	cr->save();
	cr->set_line_width(2.0);
	this->setSourceRGB(cr, currentColourScheme.getAxisColour());
	cr->set_font_size(12);

	cr->move_to(0, height / 2);
	cr->line_to(width, height / 2);

	cr->move_to(190, 25 + height / 2);
	cr->show_text("20");
	cr->move_to(390, 25 + height / 2);
	cr->show_text("40");
	cr->move_to(590, 25 + height / 2);
	cr->show_text("60");
	cr->move_to(790, 25 + height / 2);
	cr->show_text("80");

	cr->stroke();
	cr->restore();
}
Пример #4
0
bool
ButtonWidget::on_expose_event(GdkEventExpose* event)
{
  Gtk::DrawingArea::on_expose_event(event);
  Glib::RefPtr<Gdk::Window> window = get_window();
  if(window)
    {
      Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();

      int w  = get_allocation().get_width()  - 10;
      int h  = get_allocation().get_height() - 10;

      cr->set_source_rgb(0.0, 0.0, 0.0);
      cr->set_line_width(1.0);
      cr->translate(5, 5);
      cr->rectangle(0, 0, w, h);
      
      if (down)
        cr->fill_preserve();

      cr->stroke();

      if (down)
        cr->set_source_rgb(1.0, 1.0, 1.0);

      // FIXME: There are better ways to center text
      if (name.size() == 2)
        cr->move_to(w/2-6, h/2+3);
      else
        cr->move_to(w/2-4, h/2+3);
      cr->show_text(name);
    }

  return true;
}
Пример #5
0
void
Renderer_BoneSetup::render_vfunc(const Glib::RefPtr<Gdk::Window>& drawable,
								 const Gdk::Rectangle& /*expose_area*/ )
{
	assert(get_work_area());
	if(!get_work_area())
		return;

	Cairo::RefPtr<Cairo::Context> cr = drawable->create_cairo_context();
	Canvas::Handle canvas(get_work_area()->get_canvas());

	// Print out the bonesetup
	{
		Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_work_area()->get_pango_context()));

		bool recursive(get_work_area()->get_type_mask() & Duck::TYPE_BONE_RECURSIVE);
		if (recursive)
		{
			int w, h;
			layout->set_text(_("Bone Recursive Scale Mode"));
			layout->get_size(w, h);
			get_work_area()->bonesetup_width = int(w*1.0/Pango::SCALE);
			get_work_area()->bonesetup_height = int(h*1.0/Pango::SCALE);
		}
		else
			get_work_area()->timecode_width = get_work_area()->timecode_height = 0;

		Gdk::RGBA c("#5f0000");
		cr->set_source_rgb(c.get_red(), c.get_green(), c.get_blue());
		cr->move_to(bonesetup_x, bonesetup_y);
		layout->show_in_cairo_context(cr);
	}
}
Пример #6
0
void
Renderer_Dragbox::render_vfunc(
	const Glib::RefPtr<Gdk::Window>& drawable,
	const Gdk::Rectangle& /*expose_area*/
)
{
	assert(get_work_area());
	if(!get_work_area())
		return;

	// const synfig::Vector focus_point(get_work_area()->get_focus_point());
	// Warning : Unused focus_point
	int drawable_w = drawable->get_width();
	int drawable_h = drawable->get_height();

	Cairo::RefPtr<Cairo::Context> cr = drawable->create_cairo_context();

	const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
	const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
	const float pw(get_pw()),ph(get_ph());

	const synfig::Point& curr_point(get_curr_point());
	const synfig::Point& drag_point(get_drag_point());

	{
		cr->save();
		cr->set_line_cap(Cairo::LINE_CAP_BUTT);
		cr->set_line_join(Cairo::LINE_JOIN_MITER);
		cr->set_antialias(Cairo::ANTIALIAS_NONE);

		cr->set_line_width(1.0);
		cr->set_source_rgb(0,0,0);
		std::valarray<double> dashes(2);
		dashes[0]=5.0;
		dashes[1]=5.0;
		cr->set_dash(dashes, 0);

		Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
		Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));

		tl[0]=(tl[0]-window_startx)/pw;
		tl[1]=(tl[1]-window_starty)/ph;
		br[0]=(br[0]-window_startx)/pw;
		br[1]=(br[1]-window_starty)/ph;
		if(tl[0]>br[0])
			swap(tl[0],br[0]);
		if(tl[1]>br[1])
			swap(tl[1],br[1]);

		cr->rectangle(
			tl[0],
			tl[1],
			br[0]-tl[0],
			br[1]-tl[1]
		);
		cr->stroke();

		cr->restore();
	}
}
Пример #7
0
bool CircuitWidget::on_expose_event(GdkEventExpose* event)
{

    (void)event; // placate compiler..
    Glib::RefPtr<Gdk::Window> window = get_window();
    if(window) {
        Gtk::Allocation allocation = get_allocation();
        const int width = allocation.get_width();
        const int height = allocation.get_height();
        double xc = width/2.0;
        double yc = height/2.0;

        Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
        circuitDrawer.renderCairo(cr->cobj());
        cr->rectangle(event->area.x, event->area.y,
                      event->area.width, event->area.height);
        cr->clip();
        cr->rectangle (0, 0, width, height);
        cr->set_source_rgb (1,1,1);
        cr->fill ();
        cr->translate (xc-ext.width/2.0-cx*scale, yc-ext.height/2.0-cy*scale);
        if (circuit) {
            rects = circuitDrawer.draw(*circuit, drawarch, drawparallel, ext, wirestart, wireend, scale, selections, ft_default, wirelabels);
            generate_layout_rects ();
        }
    }

    return true;
}
Пример #8
0
bool Canvas::on_expose_event(GdkEventExpose * evt) {
	Glib::RefPtr<Gdk::Window> window = get_window();
	if (!window) return false; // no window yet?

	if (!seen_first_expose_event) {
		seen_first_expose_event = true;
		main->controlsWindow().starting_position();
	}

	Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();

	if (!surface) return true; // Haven't rendered yet? Nothing we can do
	if (evt) {
		cr->rectangle(evt->area.x, evt->area.y, evt->area.width, evt->area.height);
		cr->clip();
	}

	cr->set_source(surface, 0, 0);
	cr->paint();

	if (main->dragrect.is_active() && main->dragrect.surface_valid()) {
		cr->save();
		cr->set_source(main->dragrect.get_surface(), 0, 0);
		cr->paint();
		cr->restore();
	}

	if (main->hud_active()) {
		Cairo::RefPtr<Cairo::Surface>& sfc = main->get_hud_surface();
		if (sfc)
			cr->set_source(sfc, 0, 0); // TODO HUD position
		cr->paint();
	}
	return true;
}
void ActivityDrawingArea::drawPoints(std::map<double, double> & ps, const double reference_line) {
	//std::cout<<"ActivityDrawingArea::drawPoints: " <<std::endl;
	// This is where we draw on the window
	Glib::RefPtr < Gdk::Window > window = get_window();
	Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
	cr->save();
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();

	cr->set_line_width(2.0);
	//  std::cout<<"ActivityDrawingArea::drawPoints: colour: "<<"("<<main_colour[0]<<","<<main_colour[1]<<","<< main_colour[2] <<std::endl;
	this->setSourceRGB(cr, currentColourScheme.getMainColour());

	//scale the drawing in x and y
	double maxy = 0;
	std::map<double, double>::iterator it_ps = ps.begin();
	while (it_ps != ps.end()) {
		if (it_ps->second < 0 && -(it_ps->second) > maxy) {
			maxy = -(it_ps->second);
		} else if (it_ps->second > 0 && (it_ps->second) > maxy) {
			maxy = (it_ps->second);
		}
		++it_ps;
	}

	double scaley = 0.2 * (double) ActivityDrawingArea::ACTIVITY_HEIGHT / maxy;
	double scalex = 10;

	it_ps = ps.begin();
	if (it_ps != ps.end()) {
		cr->move_to(scalex * it_ps->first, (0.5 * height) - (scaley * it_ps->second));
	} else {
		cr->move_to(0, height / 2);
	}
	while (it_ps != ps.end()) {
		//	std::cout<<"ActivityDrawingArea::drawPoints: " << it_ps->first <<","<<-it_ps->second<<std::endl;
		cr->line_to((scalex * it_ps->first), (0.5 * height) - (scaley * it_ps->second));
		++it_ps;
	}
	cr->stroke();

	// draw reference line if not zero
	if (reference_line>0.00001 || reference_line < -0.00001) {
		Gdk::Color temp_colour(currentColourScheme.getMainColour());
		this->setSourceRGB(cr, Gdk::Color("tomato"));
		cr->set_line_width(1.0);
		const std::vector<double> dashed= { 1.0 };
		cr->set_dash(dashed, 1);
		double scaled_reference_line = (0.5 * height) - (scaley * reference_line);
		double neg_scaled_reference_line = (0.5 * height) + (scaley * reference_line);
		cr->move_to(0, scaled_reference_line);
		cr->line_to(width, scaled_reference_line);
		cr->move_to(0, neg_scaled_reference_line);
			cr->line_to(width, neg_scaled_reference_line);
		cr->stroke();
	}
	cr->restore();
}
Пример #10
0
void
Renderer_BBox::render_vfunc(
	const Glib::RefPtr<Gdk::Window>& drawable,
	const Gdk::Rectangle& /*expose_area*/
)
{
	assert(get_work_area());
	if(!get_work_area())
		return;

	Cairo::RefPtr<Cairo::Context> cr = drawable->create_cairo_context();

	const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
	const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
	const float pw(get_pw()),ph(get_ph());

	const synfig::Point curr_point(get_bbox().get_min());
	const synfig::Point drag_point(get_bbox().get_max());
	if(get_bbox().area()<10000000000000000.0 && get_bbox().area()>0.00000000000000001)
	{
		Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
		Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));

		tl[0]=(tl[0]-window_startx)/pw;
		tl[1]=(tl[1]-window_starty)/ph;
		br[0]=(br[0]-window_startx)/pw;
		br[1]=(br[1]-window_starty)/ph;
		if(tl[0]>br[0])
			swap(tl[0],br[0]);
		if(tl[1]>br[1])
			swap(tl[1],br[1]);

		cr->save();
		cr->set_line_cap(Cairo::LINE_CAP_BUTT);
		cr->set_line_join(Cairo::LINE_JOIN_MITER);

		cr->set_line_width(1.0);
		cr->set_source_rgb(1.0,1.0,1.0);

		// Operator difference was added in Cairo 1.9.4
		// It currently isn't supported by Cairomm
#if CAIRO_VERSION >= 10904
		cairo_set_operator(cr->cobj(), CAIRO_OPERATOR_DIFFERENCE);
#else
		// Fallback: set color to black
        cr->set_source_rgb(0,0,0);
#endif

		cr->rectangle(
			int(tl[0])+0.5,
			int(tl[1])+0.5,
			int(br[0]-tl[0]+1),
			int(br[1]-tl[1]+1)
		);
		cr->stroke();

		cr->restore();
	}
}
Пример #11
0
bool AdvEnvGUIScope::on_expose_event(GdkEventExpose* event)
{
	Glib::RefPtr<Gdk::Window> window = get_window();
	if (window)
	{
		float len, x, y, xscale, yscale;

		Gtk::Allocation allocation = get_allocation();
		const int width = allocation.get_width();
		const int height = allocation.get_height();

		Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
		cr->set_line_width(2.0);
		cr->set_source_rgb(0.0, 0.0, 0.0);
		cr->paint();

		cr->set_source_rgb(0.0, 0.8, 0.0);

		cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
		cr->clip();

		cr->move_to(width, height);

		len = m_valueDelay + m_valueAttackTime1 + m_valueAttackTime2 + m_valueAttackTime3 + m_valueAttackTime4 + m_valueReleaseTime1 + m_valueReleaseTime2 + m_valueReleaseTime3 + SUSTAIN_LEN;
		xscale = (float) width / len;
		yscale = (float) (height - 6);

		x = m_valueDelay * xscale;
		cr->line_to((int) x, height);
		x += m_valueAttackTime1 * xscale;
		y = m_valueAttackLevel1 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueAttackTime2 * xscale;
		y = m_valueAttackLevel2 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueAttackTime3 * xscale;
		y = m_valueAttackLevel3 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueAttackTime4 * xscale;
		y = m_valueSustain * yscale;
		cr->line_to((int) x, height - (int) y);
		x += SUSTAIN_LEN * xscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueReleaseTime1 * xscale;
		y = m_valueReleaseLevel1 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueReleaseTime2 * xscale;
		y = m_valueReleaseLevel2 * yscale;
		cr->line_to((int) x, height - (int) y);
		x += m_valueReleaseTime3 * xscale;
		cr->line_to((int) x, height);
		x = m_valueDelay * xscale;
		cr->line_to((int) x, height);
		cr->stroke();
	}

	return true;
}
Пример #12
0
void ImageWidget::Update()
{
  if(HasImage())
	{
		Glib::RefPtr<Gdk::Window> window = get_window();
		if(window != 0 && get_width() > 0 && get_height() > 0)
			update(window->create_cairo_context(), get_width(), get_height());
	}
}
Пример #13
0
bool VistaDiagrama::on_expose_event(GdkEventExpose* event) {
	this->set_size_request(this->ancho, this->alto);

	// Gonzalo : TEST
	Glib::RefPtr<Gdk::Window> window = get_window();
	if (window) {
		Gtk::Allocation allocation = get_allocation();
		const int width = allocation.get_width();
		const int height = allocation.get_height();

		// coordinates for the center of the window
		int xc, yc;
		xc = width / 2;
		yc = height / 2;

		Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
		cr->set_line_width(10.0);

		// clip to the area indicated by the expose event so that we only redraw
		// the portion of the window that needs to be redrawn
		cr->rectangle(event->area.x, event->area.y, event->area.width,
				event->area.height);
		cr->clip();

		// draw red lines out from the center of the window
		cr->set_line_cap(Cairo::LINE_CAP_ROUND);
		cr->set_source_rgb(0.8, 0.0, 0.0);
		cr->move_to(20, 20);
		cr->line_to(xc, yc);
		cr->line_to(20, height - 20);

		cr->move_to(xc, yc);
		cr->line_to(width - 20, yc);
		cr->stroke();

		//RefPtr<Context> cr = this->get_window()->create_cairo_context();
		/*cr->set_source_rgba(1, 1, 1, 1); // white
		 cr->paint();
		 cr->set_source_rgba(0, 0, 0, 1); // negro

		 cr->move_to(0, 0);
		 cr->line_to(this->ancho, this->alto);

		 VistaEntidad * entidad = new VistaEntidad();

		 entidad->setposfin(10, 10);
		 entidad->setposfin(20, 20);

		 entidad->dibujar(cr);*/
	}

	//delete entidad;
	return true;
}
Пример #14
0
void ActivityDrawingArea::drawText() {

	// This is where we draw on the window
	Glib::RefPtr < Gdk::Window > window = get_window();
	Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
	cr->save();
	cr->set_line_width(2.0);
	this->setSourceRGB(cr, currentColourScheme.getAxisColour());
	cr->set_font_size(18);
	cr->move_to(0, 20);

	cr->restore();
}
Пример #15
0
	bool on_expose_event(GdkEventExpose* ev ){
		Glib::RefPtr< Gdk::Window > v = get_window();
		if (v) {
			Cairo::RefPtr< Cairo::Context > ctx = v->create_cairo_context();
			Gtk::Allocation alloc = get_allocation();
			const int altura = alloc.get_height();
			const int ancho = alloc.get_width();
			ctx->set_source_rgb(0.3, 0.1, 0.4);
			ctx->scale(ancho, altura);	
			ctx->rectangle(1.0 / 2.0, 1.0 / 4.0, 1.0 / 5.0, 1.0 / 5.0);
			ctx->fill();
		}
		return true;
	}
Пример #16
0
//-----------------------------------------------------------------------------
bool OverviewWindow::DrawEvent(GdkEventExpose* event)
{
    Glib::RefPtr<Gdk::Window> oWindow = m_pDrawingArea->get_window();
    if (oWindow) {
        Cairo::RefPtr<Cairo::Context> cr = oWindow->create_cairo_context();

        Gdk::Cairo::set_source_pixbuf(cr, opixbuf, 0, 0);

        cr->paint();

        Permute(m_aOverviewPixels, 200, 200);
    }

    return true;
}
bool ActivityDrawingArea::on_expose_event(GdkEventExpose* event) {
	//	std::cout<<"ActivityDrawingArea::on_expose_event: " <<std::endl;
	Glib::RefPtr < Gdk::Window > window = get_window();
	Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
	// background fill
	this->setSourceRGB(cr, currentColourScheme.getBackgroundColour());
	cr->paint();

	//this->update();
	drawPoints(points);
	drawAxis();
	// add text
	drawText();
	return true;
}
Пример #18
0
      virtual bool on_expose_event(GdkEventExpose* event) {
        Glib::RefPtr<Gdk::Window> window = get_window();

        if (!window || !m_surface)
          return true;

        Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
        cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
        cr->clip();

        cr->set_source(m_surface, 0, 0);
        cr->paint();

        return true;
      }
bool CompVis::on_expose_event(GdkEventExpose* event) {
    Glib::RefPtr<Gdk::Window> window = get_window();
    Allocation allocation = get_allocation();
    const int width = allocation.get_width();
    const int height = allocation.get_height();
            
    Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
        
    // clip to the area indicated by the expose event so that we only redraw
    // the portion of the window that needs to be redrawn
    cr->rectangle(event->area.x, event->area.y,
    event->area.width, event->area.height);
    cr->clip();
           
    rms_dB = 20*log10(rms);
    thresh_fraction = (threshold -  p_ports[p_threshold].min)/threshold_range;
    rms_dB_fraction = (rms_dB - p_ports[p_threshold].min)/threshold_range;

    // Draw the graph
    cr->set_source_rgb(0.5,0.1,0.1);
    cr->set_line_width(2);
    cr->move_to(0,height);

    if (rms_dB <= threshold) {
        cr->line_to(rms_dB_fraction*width, height-rms_dB_fraction*height);
        cr->line_to(rms_dB_fraction*width, height);
        cr->line_to(0,height);
    } else {
        cr->line_to(thresh_fraction*width, height-thresh_fraction*height);
        cr->line_to(rms_dB_fraction*width, height-(thresh_fraction*height + height*(rms_dB_fraction-thresh_fraction)/ratio));
        cr->line_to(rms_dB_fraction*width, height);
        cr->line_to(0,height);
    }
    cr->fill();

    // draw the compression curve:
    cr->set_source_rgb(0.1,0.1,0.1);
    cr->move_to(0, height);
    cr->line_to(thresh_fraction*width, height-thresh_fraction*height);
    cr->line_to(width, height-(thresh_fraction*height + height*(1-thresh_fraction)/ratio));
    cr->stroke();

    // Draw the gain
    cr->set_source_rgb(0.1,0.8,0.1);
    cr->rectangle(0,(float)height - (float)height*gain, 10, height);
    cr->fill();
    return true;
}
Пример #20
0
bool TrackOutput::on_expose_event(GdkEventExpose* event)
{
  // This is where we draw on the window
  Glib::RefPtr<Gdk::Window> window = get_window();
  
  if(window)    // Only run if Window does exist
  {
    // clip to the area indicated by the expose event so that we only redraw
    // the portion of the window that needs to be redrawn
    Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
    cr->rectangle(event->area.x, event->area.y,
            event->area.width, event->area.height);
    cr->clip();
    
    cr->rectangle(event->area.x, event->area.y,
        event->area.width, event->area.height);
    cr->set_source_rgb(0.1 , 0.1 , 0.1 );
    cr->fill();
    
    
    TrackOutputState* state = &stateStore->trackoutputState.at(ID);
    
    if ( state->selected )
      setColour(cr, COLOUR_GREY_3 );
    else
      setColour(cr, COLOUR_GREY_4 );
    
    cr->rectangle(0, 0, 74, 102);
    cr->fill();
    
    Dial(cr,true, 7,4,state->pan,DIAL_MODE_PAN); // pan
    Mute(cr, 9  , 41 , state->ID, state->mute ); // mute button
    Solo(cr, 9  , 68 , state->ID, state->solo ); // solo button
    Rec (cr, 9  , 85 , state->ID, state->recEnable); // rec button
    Fader(cr,46 , 4  , state->volume, state->rms, state->falloff ); // fader
    
    if ( state->selected )
    {
      cr->rectangle(0, -10, 74, 200);
      setColour( cr, COLOUR_PURPLE_1 );
      cr->set_line_width(1);
      cr->stroke();
    }
    
  }
  return true;
}
Пример #21
0
		bool on_expose_event(GdkEventExpose* ev) {
			Glib::RefPtr< Gdk::Window > window = get_window();
			if (window) {
				Cairo::RefPtr< Cairo::Context > ctx = window->create_cairo_context();
				Gtk::Allocation alloc = get_allocation();
				const int height = alloc.get_height();
				const int width = alloc.get_width();

				ctx->scale(width, height); //escala para que ocupe siempre toda la pantalla. Notar que es ancho y después alto.
				ctx->set_line_width(ANCHO_LINEA);
				
				// contorno
				ctx->move_to(0.0, 1.0); // muevo hacia el punto inicial, que arbitrariamente elegí que fuera el de la izquierda abajo
				ctx->line_to(0.0, 0.0); // línea hacia el punto de arriba a la izquierda
				ctx->line_to(1.0, 0.0); // línea hacia el punto de arriba a la derecha
				ctx->line_to(1.0, 1.0); // línea hacia el punto de abajo a la derecha
				ctx->close_path(); // cierro el camino
				ctx->save(); // salvo porque voy a cambiar el color
					ctx->set_source_rgb(1.0, 1.0, 1.0); // seteo el color al blanco
					ctx->fill_preserve(); // relleno todo el cuadrado, preservando el camino para dibujar el contorno
				ctx->restore();
				ctx->stroke(); // pinto el camino en negro

				// triángulo azul de abajo
				ctx->move_to(0.0, 1.0); // muevo hacia el punto inicial, que arbitrariamente elegí que fuera el de la izquierda
				ctx->line_to(0.5, 0.5); // línea hacia el punto del medio
				ctx->line_to(1.0, 1.0); // línea hacia el punto de abajo a la derecha
				ctx->close_path(); // cierro el camino
				ctx->save(); // salvo porque voy a cambiar el color
					ctx->set_source_rgb(0.0, 0.0, 1.0); // seteo el color al azul
					ctx->fill_preserve(); // relleno todo triángulo, preservando el camino para dibujar el contorno
				ctx->restore();
				ctx->stroke(); // pinto el camino en negro

				// triángulo azul de arriba
				ctx->move_to(0.0, 0.0); // muevo hacia el punto inicial, que arbitrariamente elegí que fuera el de la izquierda
				ctx->line_to(0.5, 0.5); // línea hacia el punto del medio
				ctx->line_to(1.0, 0.0); // línea hacia el punto de arriba a la derecha
				ctx->close_path(); // cierro el camino
				ctx->save(); // salvo porque voy a cambiar el color
					ctx->set_source_rgb(0.0, 0.0, 1.0); // seteo el color al azul
					ctx->fill_preserve(); // relleno todo triángulo, preservando el camino para dibujar el contorno
				ctx->restore();
				ctx->stroke(); // pinto el camino en negro				
			}
			return true;			
		}
Пример #22
0
    void drawMotionItem(const MotionItem2D& item){
      Glib::RefPtr<Gdk::Window> window = drawingAreaMain->get_window();
      if(window){
	int width;
	int height;
	
	drawingAreaMain->get_size_request(width,height);
	
	Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
      
	if (item.motion > 0){
	  cr->set_source_rgba(1.0, 0.0, 0.0,1.0);
	  cr->rectangle(item.area.x, item.area.y, item.area.width, item.area.height);
	  cr->stroke();
	}
      }
    }
Пример #23
0
/** Button press event handler.
 * @param event event data
 * @return true
 */
bool
LaserDrawingArea::on_button_press_event(GdkEventButton *event)
{
  __last_mouse_x = event->x;
  __last_mouse_y = event->y;

  double user_x = event->x;
  double user_y = event->y;
  Glib::RefPtr<Gdk::Window> window = get_window();
  Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
  cr->save();
  cr->translate(__xc, __yc);
  cr->rotate(0.5 * M_PI + __rotation);
  cr->scale(-__zoom_factor, __zoom_factor);
  cr->device_to_user(user_x, user_y);
  printf("Clicked at (%.3lf, %.3lf)\n", user_x, user_y);
  cr->restore();
  return true;
}
Пример #24
0
void Mediator::redraw()
{
  Glib::RefPtr<Gdk::Window> Window = mref_DrawingArea.get_window();

  if (Window)
  {
    Window->clear();

    if (!m_Layers.empty())
    {
      Cairo::RefPtr<Cairo::Context> Context = Window->create_cairo_context();
      Gtk::Allocation allocation = mref_DrawingArea.get_allocation();
      const int width = allocation.get_width();
      const int height = allocation.get_height();

      Context->rectangle(0, 0, width, height);
      Context->clip();
      Context->set_antialias(Cairo::ANTIALIAS_SUBPIXEL);
      Context->scale(mref_DrawingArea.getScale(), -mref_DrawingArea.getScale());
      Context->translate(-mref_DrawingArea.getXTranslate(),
          -mref_DrawingArea.getYTranslate());
      std::vector<Layer*>::reverse_iterator rit;
      for (rit = m_Layers.rbegin(); rit < m_Layers.rend(); ++rit)
      {
        if ((*rit)->getIsDisplay())
        {
          (*rit)->initialiseLayerContext(Context, mref_DrawingArea.getScale());
          if ((*rit)->getClassName() == m_SelectedClassName)
          {
            (*rit)->draw(Context, mref_DrawingArea.getScale(),
                m_SelectedUnitIds, (*rit)->getDisplayID());
          }
          else
          {
            std::set<int> tempVoidVector;
            (*rit)->draw(Context, mref_DrawingArea.getScale(), tempVoidVector,
                (*rit)->getDisplayID());
          }
        }
      }
    }
  }
}
void NodeActivityDrawingArea::drawText() {
	ActivityDrawingArea::drawText();
	// This is where we draw on the window
	Glib::RefPtr < Gdk::Window > window = get_window();
	Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	cr->save();
	cr->set_line_width(2.0);
	cr->set_source_rgb(1, 1, 1);
	cr->set_font_size(12);

	{
		cr->move_to(width / 5, 20);
		std::stringstream ss;
		ss << "ID";
		if (this->isPrimaryInput == true) {
			ss << " (PIN)";
		}
		if (this->isPrimaryOutput == true) {
			ss << " (POUT)";
		}
		ss<< ": " <<node->getUUIDString();
		cr->show_text(ss.str());
	}

	{
		std::stringstream ss;
		cr->move_to(width / 5, 40);
		int impulse_count = node->getImpulses().getSize();
		int inputs_count = node->getConnector().getInputs().size();
		int outputs_count = node->getConnector().getOutputs().size();
		double threshold = node->getActivityThreshold();

		ss << "Impulses: " << impulse_count;
		ss << " Inputs: " << inputs_count;
		ss << " Outputs: " << outputs_count;
		ss << " Threshold: " << threshold;
		cr->show_text(ss.str());
	}
	cr->restore();
}
Пример #26
0
    void drawMotion(const MotionItem2DSeq& motionSeq){
      Glib::RefPtr<Gdk::Window> window = drawingAreaMain->get_window();
      if(window){
	int width;
	int height;
	
	drawingAreaMain->get_size_request(width,height);
	
	Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
      
	// Store context
	//cr->save();
      
	// Draw the source image on the widget context
	//cr->set_source(pImpl->image_surface, 0.0, 0.0);
	//cr->rectangle(0.0, 0.0, imgBuff->get_width(), imgBuff->get_height());
	//cr->clip();
	//cr->paint();
      
      
	//cr->set_line_width(2.0);
      
	// clip to the area indicated by the expose event so that we only redraw
	// the portion of the window that needs to be redrawn
	// cr->rectangle(event->area.x, event->area.y,
	// 		    event->area.width, event->area.height);
	//cr->clip();
      
      
	MotionItem2DSeq::const_iterator m_it = motionSeq.begin();
	for (;m_it!=motionSeq.end(); m_it++){
	  if (m_it->motion > 0){
	    cr->set_source_rgba(1.0, 0.0, 0.0,1.0);
	    cr->rectangle(m_it->area.x, m_it->area.y, m_it->area.width, m_it->area.height);
	    cr->stroke();
	  }
	}
	// Restore context
	//cr->restore();
      }
    }
Пример #27
0
bool level_editor::tileset_display::on_expose_event(GdkEventExpose* event) {
  Glib::RefPtr<Gdk::Window> window = get_window();

  if (!window || !m_surface)
    return true;

  Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
  cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
  cr->clip();

  cr->set_source(m_surface, 0, 0);
  cr->paint();

  // Show selection rectangle when we are selecting
  if (m_selecting
      || ((m_select_x != m_select_end_x || m_select_y != m_select_end_y)
          && m_preferences.sticky_tile_selection)) {
    const int x = std::min(m_select_x, m_select_end_x) * m_tile_width;
    const int y = std::min(m_select_y, m_select_end_y) * m_tile_height;

    const int w = (std::abs(m_select_x - m_select_end_x))
                    * m_tile_width;
    const int h = (std::abs(m_select_y - m_select_end_y))
                    * m_tile_height;

    cr->save();
      cr->rectangle(x, y, w, h);
      // TODO: move selection color somewhere else (preferences?)
      cr->set_source_rgb(0.7, 1, 1);
      if (m_preferences.selection_background) {
        cr->stroke_preserve();
        cr->set_source_rgba(0.7, 1, 0, 0.2);
        cr->fill();
      } else {
        cr->stroke();
      }
    cr->restore();
  }

  return true;
}
Пример #28
0
/**
 * Layout's expose event: Drawing from the "backbuffer" to the screen happens here.
 **/
bool CGtkNfoViewCtrl::on_expose_event(GdkEventExpose* event)
{
	Glib::RefPtr<Gdk::Window> refWindow = this->get_bin_window();

	if(refWindow)
	{
		int l_visibleWidth, l_visibleHeight;
		refWindow->get_size(l_visibleWidth, l_visibleHeight); // inherited from Gdk::Drawable

		Cairo::RefPtr<Cairo::Context> l_cr = refWindow->create_cairo_context();

		if(event)
		{
			// set up a clip according to the invalidated area:
			l_cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
			l_cr->clip();
		}

		CNFORenderer* l_pRenderer = GetRenderer();

		// paint the background (important for where the control is not covered by the NFO contents):
		l_cr->set_source_rgb(S_COLOR_T_CAIRO(l_pRenderer->GetBackColor()));
		l_cr->paint();

		// paint actual NFO:
		if(l_pRenderer->HasNfoData())
		{
			int l_nfoWidth = (int)l_pRenderer->GetWidth(), l_nfoHeight = (int)l_pRenderer->GetHeight();
			int l_destx = 0;

			if(GetCenterNfo() && l_nfoWidth < l_visibleWidth)
				l_destx = (l_visibleWidth - l_nfoWidth) / 2;

			l_pRenderer->DrawToClippedHandle(l_cr->cobj(), l_destx, 0);
		}
	}

	return true;	
}
void ConnectionActivityDrawingArea::drawText() {
	ActivityDrawingArea::drawText();
	// This is where we draw on the window
	Glib::RefPtr < Gdk::Window > window = get_window();
	Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();
	cr->save();
	cr->set_line_width(2.0);
	cr->set_source_rgb(1, 1, 1);
	cr->set_font_size(12);

	{
		cr->move_to(width / 5, 20);
		std::stringstream ss;
		ss << "ID";
		if (this->isPrimaryInput == true) {
			ss << " (PIN)";
		}
		if (this->isPrimaryOutput == true) {
			ss << " (POUT)";
		}
		ss << ": " << connection->getUUIDString();
		cr->show_text(ss.str());
	}

	{
		std::stringstream ss;
		cr->move_to(width / 5, 40);
		ss << "Impulses: " << connection->getImpulses().getSize();
		//    	<<" compression: "<<fibril->getMutator().getCompression()
		//  	<<" delay: " <<fibril->getMutator().getDelay();
		cr->show_text(ss.str());
	}
	cr->restore();
}
void ConnectionActivityDrawingArea::drawBar(const double x, const double y, const int overlay_count,
		const Gdk::Color & colour) {
	Glib::RefPtr < Gdk::Window > window = get_window();
	Cairo::RefPtr < Cairo::Context > cr = window->create_cairo_context();
	cr->save();
	Gtk::Allocation allocation = get_allocation();
	const int width = allocation.get_width();
	const int height = allocation.get_height();

	cr->set_line_width(2.0);
	//  std::cout<<"ActivityDrawingArea::drawPoints: colour: "<<"("<<main_colour[0]<<","<<main_colour[1]<<","<< main_colour[2] <<std::endl;
	double r = colour.get_red_p();
	double g = colour.get_green_p();
	double b = colour.get_blue_p();
	double step = 0.1;
	//std::cout<<"ActivityDrawingArea::setSourceRGB: "<<"("<<r<<","<<g<<","<<b<<")"<<std::endl;
	for (int i = overlay_count; i > 0; i--) {
		if (r < 1) {
			r += step;
		} else if (g < 1) {
			g += step;
		} else if (b < 1) {
			b += step;
		}
	}
	cr->set_source_rgb(r, g, b);

	double scalex = width / connection->getActivityTimer()->getStartingDelay();

	//scale the drawing in x and y
	cr->move_to(x * scalex, height / 2);
	cr->line_to(x * scalex, y);
	//std::cout << "ConnectionActivityDrawingArea::drawBar: " << "(" << x * scalex << ", " << height / 2 << ")"
	//		<< std::endl;
	cr->stroke();
	cr->restore();
}