Exemplo n.º 1
0
void
edit_select_rep::selection_get (selection& sel) {
  if (selection_active_table ()) {
    int row1, col1, row2, col2;
    path fp= selection_get_subtable (row1, col1, row2, col2);
    tree st= subtree (et, fp);

    int i, j;
    rectangle r (0, 0, 0, 0);
    for (i=row1; i<=row2; i++)
      for (j=col1; j<=col2; j++) {
	path cp= fp * ::table_search_cell (st, i, j);
	sel= eb->find_check_selection (cp * 0, cp * 1);
	if (sel->valid) {
	  rectangles rs= sel->rs;
	  if (r != rectangle (0, 0, 0, 0)) rs= rectangles (r, rs);
	  r= least_upper_bound (rs);
	}
      }
    sel= selection (rectangles (r), fp * 0, fp * 1);
  }
  else {
    path p_start, p_end;
    //cout << "Find " << start_p << " -- " << end_p << "\n";
    selection_correct (start_p, end_p, p_start, p_end);
    //cout << "Find " << p_start << " -- " << p_end << "\n";
    sel= eb->find_check_selection (p_start, p_end);
    //cout << "sel= " << sel << "\n";
  }
}
Exemplo n.º 2
0
static rectangles
requires_update (rectangles log) {
  rectangles rs;
  while (!is_nil (log)) {
    rectangle r1= log->item;
    rectangle r2= log->next->item;
    if (r1 == rectangle (0, 0, 0, 0)) rs= rectangles (r2, rs);
    else if (r2 == rectangle (0, 0, 0, 0)) rs= rectangles (r1, rs);
    else if (r1 != r2) rs= rectangles (r1, rectangles (r2, rs));
    log= log->next->next;
  }
  return reverse (rs);
}
Exemplo n.º 3
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_surface_set_fallback_resolution (cairo_get_target (cr), FALLBACK_RES_X, FALLBACK_RES_Y);

    rectangles (cr);
    cairo_translate (cr, 3*SIZE, 0);
    cairo_push_group (cr);
    rectangles (cr);
    cairo_pop_group_to_source (cr);
    cairo_paint (cr);

    return CAIRO_TEST_SUCCESS;
}
Exemplo n.º 4
0
void
edit_graphics_rep::invalidate_graphical_object () {
  SI gx1, gy1, gx2, gy2;
  if (find_graphical_region (gx1, gy1, gx2, gy2) && !is_nil (go_box)) {
    int i;
    rectangles rs;
    rectangle gr (gx1, gy1, gx2, gy2);
    for (i=0; i<go_box->subnr(); i++) {
      box b= go_box->subbox (i);
      rs= rectangles (rectangle (b->x3, b->y3, b->x4, b->y4), rs);
    }
    rs= rs & rectangles (gr);
    invalidate (rs);
  }
}
Exemplo n.º 5
0
void
edit_interface_rep::draw_with_stored (rectangle r) {
  renderer win= get_renderer (this);
  //cout << "Redraw " << (r/(sfactor*PIXEL)) << "\n";

  /* Verify whether the backing store is still valid */
  if (!is_nil (stored_rects)) {
    SI w1, h1, w2, h2;
    win   -> get_extents (w1, h1);
    stored -> get_extents (w2, h2);
    if (stored->ox != win->ox || stored->oy != win->oy ||
	w1 != w2 || h1 != h2) {
      // cout << "x"; cout.flush ();
      stored_rects= rectangles ();
    }
  }

  /* Either draw with backing store or regenerate */
  rectangle sr= r / sfactor;
  if (is_nil (rectangles (r) - stored_rects) && !is_nil (stored_rects)) {
    // cout << "*"; cout.flush ();
    win->new_shadow (shadow);
    win->get_shadow (shadow, sr->x1, sr->y1, sr->x2, sr->y2);
    shadow->put_shadow (stored, sr->x1, sr->y1, sr->x2, sr->y2);
    draw_post (shadow, r);
    win->put_shadow (shadow, sr->x1, sr->y1, sr->x2, sr->y2);
  }
  else {
    // cout << "."; cout.flush ();
    draw_with_shadow (r);
    if (!win->interrupted ()) {
      if (inside_active_graphics ()) {
	shadow->new_shadow (stored);
	shadow->get_shadow (stored, sr->x1, sr->y1, sr->x2, sr->y2);
	//stored_rects= /*stored_rects |*/ rectangles (r);
	stored_rects= simplify (rectangles (r, stored_rects));
	//cout << "Stored: " << stored_rects << "\n";
	//cout << "M"; cout.flush ();
      }
      draw_post (shadow, r);
      win->put_shadow (shadow, sr->x1, sr->y1, sr->x2, sr->y2);
    }
    else draw_post (win, r);
  }
}
Exemplo n.º 6
0
selection
box_rep::find_selection (path lbp, path rbp) {
  if (lbp == rbp)
    return selection (rectangles (),
		      find_tree_path (lbp), find_tree_path (rbp));
  else
    return selection (rectangle (x1, y1, x2, y2),
		      find_tree_path (path (0)), find_tree_path (path (1)));
}
Exemplo n.º 7
0
box
typesetter_rep::typeset (SI& x1b, SI& y1b, SI& x2b, SI& y2b) {
  x1= x1b; y1= y1b; x2=x2b; y2= y2b;
  box b= typeset ();
  // cout << "-------------------------------------------------------------\n";
  b->position_at (0, 0, change_log);
  change_log= requires_update (change_log);
  rectangle r (0, 0, 0, 0);
  if (!is_nil (change_log)) r= least_upper_bound (change_log);
  x1b= r->x1; y1b= r->y1; x2b= r->x2; y2b= r->y2;
  change_log= rectangles ();
  return b;
}
Exemplo n.º 8
0
void
edit_interface_rep::draw_with_shadow (rectangle r) {
  renderer win= get_renderer (this);
  rectangle sr= r / sfactor;
  win->new_shadow (shadow);
  win->get_shadow (shadow, sr->x1, sr->y1, sr->x2, sr->y2);
  renderer ren= shadow;

  rectangles l;
  win->set_shrinking_factor (sfactor);
  ren->set_shrinking_factor (sfactor);
  draw_pre (ren, r);
  draw_text (ren, l);
  ren->set_shrinking_factor (1);
  win->set_shrinking_factor (1);

  if (ren->interrupted ()) {
    ren->set_shrinking_factor (sfactor);
    l= l & rectangles (translate (r, ren->ox, ren->oy));
    simplify (l);
    copy_always= translate (copy_always, ren->ox, ren->oy);
    while (!is_nil (copy_always)) {
      l= rectangles (copy_always->item, l);
      copy_always= copy_always->next;
    }
    ren->set_shrinking_factor (1);

    draw_post (ren, r);
    while (!is_nil(l)) {
      SI x1= (l->item->x1)/sfactor - ren->ox - PIXEL;
      SI y1= (l->item->y1)/sfactor - ren->oy - PIXEL;
      SI x2= (l->item->x2)/sfactor - ren->ox + PIXEL;
      SI y2= (l->item->y2)/sfactor - ren->oy + PIXEL;
      ren->outer_round (x1, y1, x2, y2);
      win->put_shadow (ren, x1, y1, x2, y2);
      l= l->next;
    }
  }
}
Exemplo n.º 9
0
Arquivo: integ.c Projeto: Engil/Integ
static char	*integ(int f, double n)
{
  double a = 0.0;
  double b = 1.0;
  double h = (b - a) / n;
  char str[1024];

  sprintf(str, "%.1E\t\t%.1E\t\t%.1E",
	  rectangles(f, n, a, h),
	  trapezes(f, n, a, b, h),
	  simpson(f, n, a, b, h));
  return (strdup(str));
}
Exemplo n.º 10
0
//***************************************************************************************************
//The drawCurves() function draws the curves on top of the grid. We start by calling setClipRect() to
//set the QPainter's clip region to the rectangle that contains the curves (excluding the margins and
//the frame around the graph). QPainter will then ignore drawing operations on pixels outside the
//area.
//***************************************************************************************************
void ScatterView::drawCurves(QPainter *painter)
{
	if(!table)
		return;

	const int numColors = 5;
	//Yellow is reserved for selections!!!!
	QColor defaultColor[numColors] = {Qt::cyan, Qt::yellow, Qt::green, Qt::red, Qt::blue};

	QVector<QRect> rectangles( table->rowCount() );
	for (int row = 0; row < table->rowCount(); ++row) 
	{
		rectangles[row] = getObjectRect(row);

		//int c = table->GetValue(row,columnNumForColor).ToInt();
		int c = table->data(table->index(row, columnNumForColor, QModelIndex())).toInt();
		QColor myColor = defaultColor[ c % numColors ];

		painter->setPen(Qt::black);
		//painter->setPen(myColor);
		if(selection)
		{
			if(selection->isSelected( row ) )
			{
				continue;
			}
		}
		painter->setBrush(QBrush(myColor,Qt::SolidPattern));
		painter->drawRect(rectangles[row]);
	}
	for (int row = 0; row < table->rowCount(); ++row) 
	{
		QColor myColor = Qt::yellow;//Qt::yellow;
				painter->setPen(Qt::black);
				painter->setBrush(QBrush(myColor,Qt::SolidPattern));
		rectangles[row] = getObjectRect(row);

		//int c = table->GetValue(row,columnNumForColor).ToInt();
		//QColor myColor = defaultColor[ c % numColors ];

		//painter->setPen(Qt::black);
		//painter->setPen(myColor);
		if(selection)
		{
			if(selection->isSelected( row ) )
			{
				painter->drawRect(rectangles[row]);
			}
		}
	}
}
Exemplo n.º 11
0
void
x_window_rep::repaint_invalid_regions () {
  //if (!is_nil (invalid_regions)) cout << invalid_regions << "\n";
  //else { cout << "."; cout.flush (); }
  rectangles new_regions;
  if (!is_nil (invalid_regions)) {
    rectangle lub= least_upper_bound (invalid_regions);
    if (area (lub) < 1.2 * area (invalid_regions))
      invalid_regions= rectangles (lub);
  }
  while (!is_nil (invalid_regions)) {
    ren->set_origin (0, 0);
    rectangle r= copy (invalid_regions->item);
    r= thicken (r, 1, 1);
    ren->encode (r->x1, r->y1);
    ren->encode (r->x2, r->y2);
    ren->set_clipping (r->x1, r->y2, r->x2, r->y1);
    send_repaint (w, ren, r->x1, r->y2, r->x2, r->y1);
    if (gui_interrupted ())
      new_regions= rectangles (invalid_regions->item, new_regions);
    invalid_regions= invalid_regions->next;
  }
  invalid_regions= new_regions;
}
Exemplo n.º 12
0
static std::string calcul_integ(Fonction f, double n)
{
    double a = 0.0;
    double b = 1.0;
    double h = (b - a) / n;
    std::stringstream s;

    s.precision(1);
    s.flags(std::ios::scientific);

    s << rectangles(f, n, a, h) <<
    "\t\t" << trapezes(f, n, a, b, h) <<
    "\t\t" << simpson(f, n, a, b, h) << "\n";

    return s.str();
}
Exemplo n.º 13
0
    void RayTraceRenderPass::UploadToGPU(const Camera &cam) const
    {
        const auto primitivesUB = UniformBuffers::Get().Primitives();
		size_t offset = 0;
        primitivesUB.rectangles(mRectangles, offset);
		offset += mRectangles.size() * sizeof(RTRectangle);
        primitivesUB.boxes(mBoxes, offset);
		offset += mBoxes.size() * sizeof(RTBox);
		primitivesUB.spheres(mSpheres, offset);
		offset += mSpheres.size() * sizeof(RTSphere);
		primitivesUB.lights(mLights, offset);

		offset += mLights.size() * sizeof(RTLight);

		if (offset > PrimitivesUB::MAX_SIZE) {
			throw exception("PrimitivesUB size larger then max: " + offset);
		}
    }
Exemplo n.º 14
0
void
edit_interface_rep::draw_pre (renderer ren, rectangle r) {
  // draw surroundings
  tree bg= get_init_value (BG_COLOR);
  ren->set_background_pattern (bg);
  clear_pattern_rectangles (ren, rectangles (translate (r, ren->ox, ren->oy)));
  draw_surround (ren, r);

  // predraw cursor
  renderer win= get_renderer (this);
  draw_cursor (ren);
  rectangles l= copy_always;
  while (!is_nil (l)) {
    rectangle lr (l->item);
    win->put_shadow (ren, lr->x1, lr->y1, lr->x2, lr->y2);
    l= l->next;
  }
}
Exemplo n.º 15
0
void LinkedGridDrawer::draw(sf::RenderWindow& window)
{
    std::vector<sf::RectangleShape> rectangles(nodes.size(), sf::RectangleShape(RECTANGLE_SIZE));

    int centerXTransformed = centerX - RECTANGLE_SIZE_X / 2;
    int centerYTransformed = centerY - RECTANGLE_SIZE_Y / 2;

    for(unsigned int i = 0; i < nodes.size(); ++i) {
        rectangles[i].setPosition(centerXTransformed + nodes[i]->x * RECTANGLE_SIZE_X + OUTLINE_THICKNESS,
                                  centerYTransformed - nodes[i]->y * RECTANGLE_SIZE_Y + OUTLINE_THICKNESS);

        rectangles[i].setOutlineThickness(OUTLINE_THICKNESS);
        rectangles[i].setOutlineColor(sf::Color(255, 255, 255));

        rectangles[i].setFillColor(nodes[i]->getData()->color);

        window.draw(rectangles[i]);
    }
}
Exemplo n.º 16
0
void
x_window_rep::invalidate_event (int x1, int y1, int x2, int y2) {
  invalid_regions= invalid_regions | rectangles (rectangle (x1, y1, x2, y2));
}
Exemplo n.º 17
0
static void X_flush(aa_context * c)
{
    struct xdriverdata *d=c->driverdata;
    int x, y, attr;
    int xs = 0, ys = 0;
    int l, same;
    int s = 0;
    int pos;
    attr = AA_NORMAL;
    alloctables(d);
    drawed = 0;
    area = 0;
    nrectangles[0] = 0;
    nrectangles[1] = 0;
    nrectangles[2] = 0;
    nrectangles[3] = 0;
    if (d->previoust == NULL) {
	d->previoust = malloc(d->width * d->height);
	d->previousa = calloc(d->width * d->height, 1);
	memset(d->previoust, ' ', d->width * d->height);
    }
    for (y = 0; y < aa_scrheight(c); y++) {
	s = l = 0;
	xs = 0;
	ys = y;
	for (x = 0; x < aa_scrwidth(c); x++) {
	    pos = x + y * aa_scrwidth(c);
	    if (s > 5 || (c->attrbuffer[pos] != attr && (c->textbuffer[pos] != ' ' || Black[c->attrbuffer[pos]] || Black[attr]))) {
		if (l - s)
		    MyDrawString(d,attr, xs, ys,
			&c->textbuffer[xs + ys * aa_scrwidth(c)], l - s);
		attr = c->attrbuffer[pos];
		s = l = 0;
		xs = x;
		ys = y;
	    }
	    if ((d->previoust[pos] == c->textbuffer[pos] && d->previousa[pos] == c->attrbuffer[pos]) || (!Black[attr] && d->previoust[pos] == ' ' && c->textbuffer[pos] == ' ' && !Black[d->previousa[pos]]))
		same = 1;
	    else
		same = 0;
	    if (xs == x && same)
		xs++;
	    else {
		if (same)
		    s++;
		else
		    s = 0;
		l++;
	    }
	}
	if (l - s)
	    MyDrawString(d,attr, xs, ys,
			 &c->textbuffer[xs + ys * aa_scrwidth(c)], l - s);
    }
    if (drawed) {
	memcpy(d->previousa, c->attrbuffer, d->width * d->height);
	memcpy(d->previoust, c->textbuffer, d->width * d->height);
	if (nrectangles[0])
	    XFillRectangles(d->dp, dr, d->blackGC, &rectangles(0, 0), nrectangles[0]);
	if (nrectangles[1])
	    XFillRectangles(d->dp, dr, d->normalGC, &rectangles(1, 0), nrectangles[1]);
	if (nrectangles[2])
	    XFillRectangles(d->dp, dr, d->specialGC, &rectangles(2, 0), nrectangles[2]);
	if (d->cvisible)
	    XDrawLine(d->dp, dr, d->normalGC, d->Xpos * d->realfontwidth, (d->Ypos + 1) * d->fontheight - 1, (d->Xpos + 1) * d->realfontwidth - 1, (d->Ypos + 1) * d->fontheight - 1);

	for (y = 0; y < d->height; y++) {
	    for (x = 0; x < NATT; x++) {
		if (nitem[y][x]) {
		    X_setattr(d,x);
		    XDrawText(d->dp, dr, d->currGC, 0, (y + 1) * d->fontheight - d->font_s->descent, &texty(y, x, 0), nitem[y][x]);
		    if (x == 4)
			XDrawText(d->dp, dr, d->currGC, 1, (y + 1) * d->fontheight - d->font_s->descent, &texty(y, x, 0), nitem[y][x]);
		}
	    }
	}
	if (d->pixmapmode) {
	    if (nrectangles[3] && area < d->width*d->height/2 && nrectangles[3] < 5)
	      {
		int i;
	        /*fprintf (stderr, "%i %i\n",nrectangles[3], area);*/
		for (i = 0; i < nrectangles[3]; i++)
		  XClearArea (d->dp, d->wi, rectangles(3, i).x, rectangles(3,i).y,
			      rectangles(3,i).width, rectangles(3,i).height, 0);
	      }
	    else
	      XClearWindow(d->dp, d->wi);
	}
	/*if(!d->pixmapmode) */
	XSync(d->dp, 0);
    }
    freetables();
}
Exemplo n.º 18
0
static void MyDrawString(struct xdriverdata *d,int attr, int x, int y, unsigned char *c, int i)
{
    XTextItem *it;
    XRectangle *rect;
    int n, a;
    switch (attr) {
    case AA_NORMAL:
    case AA_DIM:
    case AA_BOLD:
    case AA_BOLDFONT:
    default:
	n = 0;
	break;
    case AA_REVERSE:
	n = 1;
	break;
    case AA_SPECIAL:
	n = 2;
	break;
    }
    switch (attr) {
    default:
    case AA_SPECIAL:
    case AA_NORMAL:
	a = 0;
	break;
    case AA_DIM:
	a = 1;
	break;
    case AA_BOLD:
	a = 2;
	break;
    case AA_REVERSE:
	a = 3;
	break;
    case AA_BOLDFONT:
	a = 4;
	break;
    }
    it = &texty(y, a, nitem[y][a]);
    it->delta = x * d->realfontwidth - startitem[y][a];
    if (!it->delta && x) {
	it--;
	it->nchars += i;
    } else {
	nitem[y][a]++;
	it->chars = (char *)c;
	it->nchars = i;
	it->font = d->font;
	drawed = 1;
    }
    startitem[y][a] = (x + i) * d->realfontwidth;
    rect = &rectangles(n, nrectangles[n]);
    rect->x = x * d->realfontwidth;
    rect->y = (y) * d->fontheight + 1;
    rect->width = i * d->realfontwidth;
    if (nrectangles[n] && (rect - 1)->y == rect->y &&
	(rect - 1)->x + (rect - 1)->width == rect->x)
	nrectangles[n]--, (--rect)->width += i * d->realfontwidth;
    rect->height = d->fontheight;
    nrectangles[n]++;
    rect = &rectangles(n, nrectangles[3]);
    rect->x = x * d->realfontwidth;
    rect->y = (y) * d->fontheight + 1;
    rect->width = i * d->realfontwidth;
    if (nrectangles[3] && (rect - 1)->y == rect->y &&
	(rect - 1)->x + (rect - 1)->width == rect->x)
	nrectangles[3]--, (--rect)->width += i * d->realfontwidth;
    rect->height = d->fontheight;
    nrectangles[3]++;
    area += i;
}