Difference between revisions of "CheatSheetForConvertingto2geom"
Verbalshadow (talk | contribs) m (correction) |
Johanengelen (talk | contribs) |
||
Line 12: | Line 12: | ||
What is the difference? | What is the difference? | ||
A Rect that has the coordinates | A Rect that has the coordinates of (1,2) - (2,6) contains points and has a non-zero area. | ||
A Rect that has the coordinates | A Rect that has the coordinates of (0,0) - (0,0) contains one point but has zero area. | ||
A | A Rect that has the coordinates of (0,0) - (10,0) contains points but has zero area. | ||
A Geom::OptRect that has not been defined with coordinates has neither points or area. | |||
If you need to define a rectangle, but are not sure whether it is always a valid rectangle, please use Geom::OptRect. It means "Optional Rect". A bounding box of a path could be an "invalid" rectangle for example, when the path has no fill or stroke. | |||
optrect.isEmpty() checks if optrect contains a valid rectangle NOT if the rect has zero area. rect.hasZeroArea() does that. | |||
==Items That you Can Switch NR:: for Geom::== | ==Items That you Can Switch NR:: for Geom::== |
Revision as of 22:12, 30 December 2008
Cheat Sheet For Converting to 2geom
If you are just starting I suggest you pick a header file and convert just one function at a time. That will give you a feel for the process as you get more comfortable do more at one time.
Lets talk about emptiness.
In Inkscape and in 2geom there are two types of emptiness for rectangles.
Rectangles with no coordinates. Rectangles with zero area.
What is the difference?
A Rect that has the coordinates of (1,2) - (2,6) contains points and has a non-zero area. A Rect that has the coordinates of (0,0) - (0,0) contains one point but has zero area. A Rect that has the coordinates of (0,0) - (10,0) contains points but has zero area. A Geom::OptRect that has not been defined with coordinates has neither points or area.
If you need to define a rectangle, but are not sure whether it is always a valid rectangle, please use Geom::OptRect. It means "Optional Rect". A bounding box of a path could be an "invalid" rectangle for example, when the path has no fill or stroke.
optrect.isEmpty() checks if optrect contains a valid rectangle NOT if the rect has zero area. rect.hasZeroArea() does that.
Items That you Can Switch NR:: for Geom::
NR::Matrix
NR::Rect
NR::Dim2
NR::L2
NR::Y
NR::X
NR::identify
NR::Coord
Things that need small adjustments or complete replacement
Error looks like | NR Function or Code | 2geom Replacement |
NR::scale
|
Geom::Scale (note the capital letter S)
| |
NR::translate
|
Geom::Translate (capital)
| |
nrrect.extent(NR::X)
|
geomrect.dimensions()[Geom::X] OR
| |
height = r->extent(NR::Y);
|
height = r->dimensions()[Geom::Y];
| |
NR::expansion(nrmatrix)
|
geommatrix.descrim()
| |
desktop.cpp:754: error: 'expand' is not a member of 'Geom' | NR::Rect const viewbox = NR::expand(canvas->getViewbox(), border);
|
Geom::Rect viewbox = canvas->getViewbox();
|
desktop.cpp:162: error: 'class Geom::Matrix' has no member named 'set_identity' | Mymatrix = set_identity (Nrmatrix)
|
identity(Nrmatrix) OR
|
desktop.cpp: In member function 'bool SPDesktop::isWithinViewport(SPItem*) const':
desktop.cpp:532: error: conversion from 'boost::optional<NR::Rect>' to non-scalar type 'boost::optional<Geom::D2<Geom::Interval> >' requested |
boost::optional<NR::Rect>
|
boost::optional<Geom::Rect>
|
desktop.cpp:1004: error: no matching function for call to 'Geom::D2<Geom::Interval>::isEmpty(double)' ./2geom/rect.h:105: note: candidates are: bool Geom::D2<Geom::Interval>::isEmpty() const | if ( !d || d->isEmpty(0.1) ) { return; } |
<nowiki> if ( !d || d->width() < 0.1 || d->height() < 0.1) { return; } |
display/nr-arena-item.cpp:734: error: ‘const class Geom::Matrix’ has no member named ‘test_identity’ | NR::matrix.test_identity()
|
local.isIdentity()
|
selection-chemistry.cpp:1424: error: no match for ‘operator[]’ in ‘center[X]’
center is a boost::optional<Geom::Point> |
you're missing the * | |
Geom::Rotate doesn't seem have a operator/ what is the trick for turning division in to multiplication, again
|
r1/r2
|
r1 * r2.inverse()
|
NR::Rect 's can be changed to Geom::Rect But it is better not to do this.
|
geomrect = to_2geom(nrrect)
| |
NR::union_bounds()
|
Geom::unify()
| |
sp-item.cpp:814: error: ‘expansionX’ is not a member of ‘Geom’ | dy0 *= NR::expansionY(i2d);
|
dy0 *= i2d.expansionY();
|
sp-item.cpp:1447: error: ‘const class Geom::Matrix’ has no member named ‘is_translation’ | !(!transform.is_translation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->getFilter())
|
!(!transform.isTranslation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->getFilter())
|
text-context.cpp:1610: error: no matching function for call to ‘to_2geom(boost::optional<Geom::D2<Geom::Interval> >)’ | boost::optional<Geom::Rect> frame_bbox = to_2geom(sp_item_bbox_desktop(frame));
|
boost::optional<Geom::Rect> frame_bbox = sp_item_bbox_desktop(frame);
|