void LimitCell::Draw(wxPoint point, int fontsize) { MathCell::Draw(point, fontsize); if (DrawThisCell(point) && InUpdateRegion()) { Configuration *configuration = Configuration::Get(); double scale = configuration->GetScale(); wxPoint base(point), under(point), name(point); name.x = point.x + MAX(m_name->GetFullWidth(scale), m_under->GetFullWidth(scale)) / 2 - m_name->GetFullWidth(scale) / 2; m_name->DrawList(name, fontsize); under.x = point.x + MAX(m_name->GetFullWidth(scale), m_under->GetFullWidth(scale)) / 2 - m_under->GetFullWidth(scale) / 2; under.y = point.y + m_name->GetMaxDrop() + m_under->GetMaxCenter(); m_under->DrawList(under, MAX(MIN_LIMIT_FONT_SIZE, fontsize - LIMIT_FONT_SIZE_DECREASE)); base.x += MAX(m_name->GetFullWidth(scale), m_under->GetFullWidth(scale)); m_base->DrawList(base, fontsize); } }
void LimitCell::Draw(CellParser& parser, wxPoint point, int fontsize, bool all) { if (DrawThisCell(parser, point)) { double scale = parser.GetScale(); wxPoint base(point), under(point), name(point); name.x = point.x + MAX(m_name->GetFullWidth(scale), m_under->GetFullWidth(scale)) / 2 - m_name->GetFullWidth(scale) / 2; m_name->Draw(parser, name, fontsize, true); under.x = point.x + MAX(m_name->GetFullWidth(scale), m_under->GetFullWidth(scale)) / 2 - m_under->GetFullWidth(scale) / 2; under.y = point.y + m_name->GetMaxDrop() + m_under->GetMaxCenter(); m_under->Draw(parser, under, MAX(MIN_LIMIT_FONT_SIZE, fontsize - LIMIT_FONT_SIZE_DECREASE), true); base.x += MAX(m_name->GetFullWidth(scale), m_under->GetFullWidth(scale)); m_base->Draw(parser, base, fontsize, true); } MathCell::Draw(parser, point, fontsize, all); }
int recup_liaison(t_e *e) { if (!under(e)) return (0); e->last_acq = e->last_acq->next; while (e->last_acq) { if (!under(e)) { e->donnee_error = 1; return (1); } e->last_acq = e->last_acq->next; } return (1); }
synfig::Rect Warp::get_full_bounding_rect(Context context)const { // return Rect::full_plane(); Point src_tl=param_src_tl.get(Point()); Point src_br=param_src_br.get(Point()); bool clip=param_clip.get(bool()); Rect under(context.get_full_bounding_rect()); if(clip) { under&=Rect(src_tl,src_br); } return get_transform()->perform(under); /* Rect under(context.get_full_bounding_rect()); Rect ret(Rect::zero()); if(under.area()==HUGE_VAL) return Rect::full_plane(); ret.expand( transform_backward( under.get_min() ) ); ret.expand( transform_backward( under.get_max() ) ); ret.expand( transform_backward( Vector( under.get_min()[0], under.get_max()[1] ) ) ); ret.expand( transform_backward( Vector( under.get_max()[0], under.get_min()[1] ) ) ); if(ret.area()==HUGE_VAL) return Rect::full_plane(); return ret; */ }
int is_infos(t_e *e, int i) { under(e, i); if (e->last_acq && e->last_acq->str[0] == '#') { e->last_acq = e->last_acq->next; if (e->end == 1) is_infos(e, 2); if (e->start == 1) is_infos(e, 1); } if (!e->last_acq) ft_print_error(e); return (1); }
QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount) { if (from.isNull() && to.isNull()) { return from; } if (qFuzzyCompare(amount + 1, qreal(1.0))) { return from; } QRect startRect(from.rect()); QRect targetRect(to.rect()); QSize pixmapSize = startRect.size().expandedTo(targetRect.size()); QRect toRect = QRect(QPoint(0,0), pixmapSize); targetRect.moveCenter(toRect.center()); startRect.moveCenter(toRect.center()); //paint to in the center of from QColor color; color.setAlphaF(amount); // If the native paint engine supports Porter/Duff compositing and CompositionMode_Plus QPaintEngine *paintEngine = from.paintEngine(); if (paintEngine && paintEngine->hasFeature(QPaintEngine::PorterDuff) && paintEngine->hasFeature(QPaintEngine::BlendModes)) { QPixmap startPixmap(pixmapSize); startPixmap.fill(Qt::transparent); QPixmap targetPixmap(pixmapSize); targetPixmap.fill(Qt::transparent); QPainter p; p.begin(&targetPixmap); p.drawPixmap(targetRect, to); p.setCompositionMode(QPainter::CompositionMode_DestinationIn); p.fillRect(targetRect, color); p.end(); p.begin(&startPixmap); p.drawPixmap(startRect, from); p.setCompositionMode(QPainter::CompositionMode_DestinationOut); p.fillRect(startRect, color); p.setCompositionMode(QPainter::CompositionMode_Plus); p.drawPixmap(targetRect, targetPixmap); p.end(); return startPixmap; } #if defined(Q_WS_X11) && defined(HAVE_XRENDER) // We have Xrender support else if (paintEngine && paintEngine->hasFeature(QPaintEngine::PorterDuff)) { // QX11PaintEngine doesn't implement CompositionMode_Plus in Qt 4.3, // which we need to be able to do a transition from one pixmap to // another. // // In order to avoid the overhead of converting the pixmaps to images // and doing the operation entirely in software, this function has a // specialized path for X11 that uses Xrender directly to do the // transition. This operation can be fully accelerated in HW. // // This specialization can be removed when QX11PaintEngine supports // CompositionMode_Plus. QPixmap source(targetPixmap), destination(startPixmap); source.detach(); destination.detach(); Display *dpy = QX11Info::display(); XRenderPictFormat *format = XRenderFindStandardFormat(dpy, PictStandardA8); XRenderPictureAttributes pa; pa.repeat = 1; // RepeatNormal // Create a 1x1 8 bit repeating alpha picture Pixmap pixmap = XCreatePixmap(dpy, destination.handle(), 1, 1, 8); Picture alpha = XRenderCreatePicture(dpy, pixmap, format, CPRepeat, &pa); XFreePixmap(dpy, pixmap); // Fill the alpha picture with the opacity value XRenderColor xcolor; xcolor.alpha = quint16(0xffff * amount); XRenderFillRectangle(dpy, PictOpSrc, alpha, &xcolor, 0, 0, 1, 1); // Reduce the alpha of the destination with 1 - opacity XRenderComposite(dpy, PictOpOutReverse, alpha, None, destination.x11PictureHandle(), 0, 0, 0, 0, 0, 0, destination.width(), destination.height()); // Add source * opacity to the destination XRenderComposite(dpy, PictOpAdd, source.x11PictureHandle(), alpha, destination.x11PictureHandle(), toRect.x(), toRect.y(), 0, 0, 0, 0, destination.width(), destination.height()); XRenderFreePicture(dpy, alpha); return destination; } #endif else { // Fall back to using QRasterPaintEngine to do the transition. QImage under(pixmapSize, QImage::Format_ARGB32_Premultiplied); under.fill(Qt::transparent); QImage over(pixmapSize, QImage::Format_ARGB32_Premultiplied); over.fill(Qt::transparent); QPainter p; p.begin(&over); p.drawPixmap(targetRect, to); p.setCompositionMode(QPainter::CompositionMode_DestinationIn); p.fillRect(over.rect(), color); p.end(); p.begin(&under); p.drawPixmap(startRect, from); p.setCompositionMode(QPainter::CompositionMode_DestinationOut); p.fillRect(startRect, color); p.setCompositionMode(QPainter::CompositionMode_Plus); p.drawImage(toRect.topLeft(), over); p.end(); return QPixmap::fromImage(under); } }
/* ---------------------------------------------------------------------- */ int sum_diffuse_layer (struct surface_charge *surface_charge_ptr1) /* ---------------------------------------------------------------------- */ { int i, j, count_g; LDBLE mass_water_surface; LDBLE molality, moles_excess, moles_surface; if (use.surface_ptr == NULL) return (OK); /* * Find position of component in list of components */ i = 0; for (j = 0; j < use.surface_ptr->count_charge; j++) { if (&(use.surface_ptr->charge[j]) == surface_charge_ptr1) { i = j; break; } } if (j >= use.surface_ptr->count_charge) { sprintf (error_string, "In sum_diffuse_layer, component not found, %s.", surface_charge_ptr1->name); error_msg (error_string, STOP); } /* * Loop through all surface components, calculate each H2O surface (diffuse layer), * H2O aq, and H2O bulk (diffuse layers plus aqueous). */ count_elts = 0; paren_count = 0; mass_water_surface = surface_charge_ptr1->mass_water; for (j = 0; j < count_s_x; j++) { if (s_x[j]->type > HPLUS) continue; molality = under (s_x[j]->lm); count_g = s_x[j]->diff_layer[i].count_g; #ifdef SKIP moles_excess = mass_water_bulk_x * /* s_x[j]->diff_layer[i].charge->g[count_g].g * molality; */ surface_charge_ptr1->g[count_g].g * molality; #endif moles_excess = mass_water_aq_x * molality * surface_charge_ptr1->g[count_g].g; moles_surface = mass_water_surface * molality + moles_excess; /* * Accumulate elements in diffuse layer */ add_elt_list (s_x[j]->next_elt, moles_surface); } add_elt_list (s_h2o->next_elt, mass_water_surface / gfw_water); if (count_elts > 0) { qsort (elt_list, (size_t) count_elts, (size_t) sizeof (struct elt_list), elt_list_compare); elt_list_combine (); } return (OK); }
void IntCell::Draw(CellParser& parser, wxPoint point, int fontsize, bool all) { if (DrawThisCell(parser, point)) { wxDC& dc = parser.GetDC(); double scale = parser.GetScale(); wxPoint base(point), under(point), over(point), var(point), sign(point); if (parser.CheckTeXFonts()) { SetForeground(parser); int fontsize1 = (int) ((fontsize * scale * 1.5 + 0.5)); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, false, false, false, parser.GetTeXCMEX())); dc.DrawText(wxT("\x5A"), sign.x, sign.y - m_signTop); } else { #if defined __WXMSW__ SetForeground(parser); int fontsize1 = (int) ((INTEGRAL_FONT_SIZE * scale + 0.5)); int m_signWCenter = m_signWidth / 2; dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, false, false, false, parser.GetSymbolFontName())); dc.DrawText(wxT(INTEGRAL_TOP), sign.x + m_signWCenter - m_charWidth / 2, sign.y - (m_signSize + 1) / 2); dc.DrawText(wxT(INTEGRAL_BOTTOM), sign.x + m_signWCenter - m_charWidth / 2, sign.y + (m_signSize + 1) / 2 - m_charHeight); int top, bottom; top = sign.y - (m_signSize + 1) / 2 + m_charHeight / 2; bottom = sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2; if (top <= bottom) { while (top < bottom) { dc.DrawText(wxT(INTEGRAL_EXTEND), point.x + m_signWCenter - m_charWidth / 2, top); top += (2*m_charHeight)/3; } dc.DrawText(wxT(INTEGRAL_EXTEND), point.x + m_signWCenter - m_charWidth / 2, sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2); } #else SetPen(parser); // top decoration int m_signWCenter = m_signWidth / 2; dc.DrawLine(sign.x + m_signWCenter, sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1, sign.x + m_signWCenter + SCALE_PX(3, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale)); dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(3, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale), sign.x + m_signWCenter + SCALE_PX(6, scale), sign.y - (m_signSize + 1) / 2); dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(6, scale), sign.y - (m_signSize + 1) / 2, sign.x + m_signWCenter + SCALE_PX(9, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale)); // bottom decoration dc.DrawLine(sign.x + m_signWCenter, sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1, sign.x + m_signWCenter - SCALE_PX(3, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale)); dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(3, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale), sign.x + m_signWCenter - SCALE_PX(6, scale), sign.y + (m_signSize + 1) / 2); dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(6, scale), sign.y + (m_signSize + 1) / 2, sign.x + m_signWCenter - SCALE_PX(9, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale)); // line dc.DrawLine(sign.x + m_signWCenter, sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1, sign.x + m_signWCenter, sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1); UnsetPen(parser); #endif } if (m_intStyle == INT_DEF) { under.x += m_signWidth; under.y = point.y + m_signSize / 2 + m_under->GetMaxCenter() + SCALE_PX(2, scale) - m_signSize / 3; m_under->Draw(parser, under, MAX(MC_MIN_SIZE, fontsize - 5), true); if (parser.CheckTeXFonts()) over.x += 2*m_signWidth; else over.x += m_signWidth; over.y = point.y - m_signSize / 2 - m_over->GetMaxDrop() - SCALE_PX(2, scale) + m_signSize / 3; m_over->Draw(parser, over, MAX(MC_MIN_SIZE, fontsize - 5), true); if (parser.CheckTeXFonts()) { base.x += m_signWidth + MAX(m_over->GetFullWidth(scale) + m_signWidth, m_under->GetFullWidth(scale)); } else base.x += m_signWidth + MAX(m_over->GetFullWidth(scale), m_under->GetFullWidth(scale)); } else if (parser.CheckTeXFonts()) base.x += 2*m_signWidth; else base.x += m_signWidth; m_base->Draw(parser, base, fontsize, true); var.x = base.x + m_base->GetFullWidth(scale); m_var->Draw(parser, var, fontsize, true); } MathCell::Draw(parser, point, fontsize, all); }
void IntCell::Draw(wxPoint point, int fontsize) { MathCell::Draw(point, fontsize); CellParser *parser = CellParser::Get(); if (DrawThisCell(point) && InUpdateRegion()) { wxDC& dc = parser->GetDC(); double scale = parser->GetScale(); wxPoint base(point), under(point), over(point), var(point), sign(point); if (parser->CheckTeXFonts()) { SetForeground(); int fontsize1 = (int) ((fontsize * scale * 1.5 + 0.5)); dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser->GetTeXCMEX())); dc.DrawText(wxT("\x5A"), sign.x, sign.y - m_signTop); } else { #if defined __WXMSW__ SetForeground(); int fontsize1 = (int) ((INTEGRAL_FONT_SIZE * scale + 0.5)); int m_signWCenter = m_signWidth / 2; dc.SetFont(wxFont(fontsize1, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, parser->GetSymbolFontName())); dc.DrawText(INTEGRAL_TOP, sign.x + m_signWCenter - m_charWidth / 2, sign.y - (m_signSize + 1) / 2); dc.DrawText(INTEGRAL_BOTTOM, sign.x + m_signWCenter - m_charWidth / 2, sign.y + (m_signSize + 1) / 2 - m_charHeight); int top, bottom; top = sign.y - (m_signSize + 1) / 2 + m_charHeight / 2; bottom = sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2; if (top <= bottom) { wxASSERT_MSG(m_charHeight>=2,_("Font issue: The char height is too small! Installing http://www.math.union.edu/~dpvc/jsmath/download/jsMath-fonts.html and checking \"Use JSmath fonts\" in the configuration dialogue should be a workaround.")); if(m_charHeight <= 2) m_charHeight = 2; while (top < bottom) { dc.DrawText(INTEGRAL_EXTEND, point.x + m_signWCenter - m_charWidth / 2, top); top += (2*m_charHeight)/3; } dc.DrawText(INTEGRAL_EXTEND, point.x + m_signWCenter - m_charWidth / 2, sign.y + (m_signSize + 1) / 2 - (3 * m_charHeight) / 2); } #else SetPen(); // top decoration int m_signWCenter = m_signWidth / 2; dc.DrawLine(sign.x + m_signWCenter, sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1, sign.x + m_signWCenter + SCALE_PX(3, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale)); dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(3, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale), sign.x + m_signWCenter + SCALE_PX(6, scale), sign.y - (m_signSize + 1) / 2); dc.DrawLine(sign.x + m_signWCenter + SCALE_PX(6, scale), sign.y - (m_signSize + 1) / 2, sign.x + m_signWCenter + SCALE_PX(9, scale), sign.y - (m_signSize + 1) / 2 + SCALE_PX(3, scale)); // bottom decoration dc.DrawLine(sign.x + m_signWCenter, sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1, sign.x + m_signWCenter - SCALE_PX(3, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale)); dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(3, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale), sign.x + m_signWCenter - SCALE_PX(6, scale), sign.y + (m_signSize + 1) / 2); dc.DrawLine(sign.x + m_signWCenter - SCALE_PX(6, scale), sign.y + (m_signSize + 1) / 2, sign.x + m_signWCenter - SCALE_PX(9, scale), sign.y + (m_signSize + 1) / 2 - SCALE_PX(3, scale)); // line dc.DrawLine(sign.x + m_signWCenter, sign.y - (m_signSize + 1) / 2 + SCALE_PX(12, scale) - 1, sign.x + m_signWCenter, sign.y + (m_signSize + 1) / 2 - SCALE_PX(12, scale) + 1); UnsetPen(); #endif } if (m_intStyle == INT_DEF) { under.x += m_signWidth; under.y = point.y + m_signSize / 2 + m_under->GetMaxCenter() + SCALE_PX(2, scale) - m_signSize / 3; m_under->DrawList(under, MAX(MC_MIN_SIZE, fontsize - 5)); if (parser->CheckTeXFonts()) over.x += 2*m_signWidth; else over.x += m_signWidth; over.y = point.y - m_signSize / 2 - m_over->GetMaxDrop() - SCALE_PX(2, scale) + m_signSize / 3; m_over->DrawList(over, MAX(MC_MIN_SIZE, fontsize - 5)); if (parser->CheckTeXFonts()) { base.x += m_signWidth + MAX(m_over->GetFullWidth(scale) + m_signWidth, m_under->GetFullWidth(scale)); } else base.x += m_signWidth + MAX(m_over->GetFullWidth(scale), m_under->GetFullWidth(scale)); } else if (parser->CheckTeXFonts()) base.x += 2*m_signWidth; else base.x += m_signWidth; m_base->DrawList(base, fontsize); var.x = base.x + m_base->GetFullWidth(scale); m_var->DrawList(var, fontsize); } }