summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2015-05-18 17:16:39 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2015-05-18 17:16:39 +0200
commit9ae62324f4c48caacfb852881672408d25f4b15a (patch)
treefe50469eade9ee53b5050fd8d8c5de27dfbcac79
parent5a6bcb2c4de7d151b89d22a86e9836894882118f (diff)
Some fixes around TileFill
Change-Id: I8d0c0aa7f50b5749e9663cb231c6483ebb7b1521
-rw-r--r--src/lib/FHCollector.cpp18
-rw-r--r--src/lib/FHParser.cpp4
-rw-r--r--src/lib/FHTypes.h12
3 files changed, 19 insertions, 15 deletions
diff --git a/src/lib/FHCollector.cpp b/src/lib/FHCollector.cpp
index 5118875..f679424 100644
--- a/src/lib/FHCollector.cpp
+++ b/src/lib/FHCollector.cpp
@@ -408,7 +408,7 @@ void libfreehand::FHCollector::_getBBofPath(const FHPath *path, libfreehand::FHB
if (!m_fakeTransforms.empty())
fhPath.transform(m_fakeTransforms.top());
- FHBoundingBox tmpBBox(bBox);
+ FHBoundingBox tmpBBox;
fhPath.getBoundingBox(tmpBBox.m_xmin, tmpBBox.m_ymin, tmpBBox.m_xmax, tmpBBox.m_ymax);
bBox.merge(tmpBBox);
}
@@ -438,7 +438,7 @@ void libfreehand::FHCollector::_getBBofGroup(const FHGroup *group, libfreehand::
for (std::vector<unsigned>::const_iterator iterVec = elements->begin(); iterVec != elements->end(); ++iterVec)
{
- FHBoundingBox tmpBBox(bBox);
+ FHBoundingBox tmpBBox;
_getBBofSomething(*iterVec, tmpBBox);
bBox.merge(tmpBBox);
}
@@ -475,7 +475,7 @@ void libfreehand::FHCollector::_getBBofCompositePath(const FHCompositePath *comp
fhPath.setGraphicStyleId(compositePath->m_graphicStyleId);
}
}
- FHBoundingBox tmpBBox(bBox);
+ FHBoundingBox tmpBBox;
_getBBofPath(&fhPath, tmpBBox);
bBox.merge(tmpBBox);
}
@@ -507,7 +507,7 @@ void libfreehand::FHCollector::_getBBofSymbolInstance(const FHSymbolInstance *sy
const FHSymbolClass *symbolClass = _findSymbolClass(symbolInstance->m_symbolClassId);
if (symbolClass)
{
- FHBoundingBox tmpBBox(bBox);
+ FHBoundingBox tmpBBox;
_getBBofSomething(symbolClass->m_groupId, tmpBBox);
bBox.merge(tmpBBox);
}
@@ -521,7 +521,7 @@ void libfreehand::FHCollector::_getBBofSomething(unsigned somethingId, libfreeha
if (!somethingId)
return;
- FHBoundingBox tmpBBox(bBox);
+ FHBoundingBox tmpBBox;
_getBBofGroup(_findGroup(somethingId), tmpBBox);
_getBBofPath(_findPath(somethingId), tmpBBox);
_getBBofCompositePath(_findCompositePath(somethingId), tmpBBox);
@@ -1562,16 +1562,16 @@ void libfreehand::FHCollector::_appendTileFill(::librevenge::RVNGPropertyList &p
FHBoundingBox bBox;
_getBBofSomething(tileFill->m_groupId, bBox);
- if (!FH_ALMOST_ZERO(bBox.m_xmax - bBox.m_xmin) && !FH_ALMOST_ZERO(bBox.m_ymax - bBox.m_ymin))
+ if (bBox.isValid() && !FH_ALMOST_ZERO(bBox.m_xmax - bBox.m_xmin) && !FH_ALMOST_ZERO(bBox.m_ymax - bBox.m_ymin))
{
- FHTransform fakeTrafo(tileFill->m_stretchX, 0.0, 0.0, tileFill->m_stretchY, - bBox.m_xmin, -bBox.m_ymin);
+ FHTransform fakeTrafo(tileFill->m_scaleX, 0.0, 0.0, tileFill->m_scaleY, - bBox.m_xmin, -bBox.m_ymin);
m_fakeTransforms.push(fakeTrafo);
librevenge::RVNGStringVector svgOutput;
librevenge::RVNGSVGDrawingGenerator generator(svgOutput, "");
librevenge::RVNGPropertyList pList;
- pList.insert("svg:width", tileFill->m_stretchX * (bBox.m_xmax - bBox.m_xmin));
- pList.insert("svg:height", tileFill->m_stretchY * (bBox.m_ymax - bBox.m_ymin));
+ pList.insert("svg:width", tileFill->m_scaleX * (bBox.m_xmax - bBox.m_xmin));
+ pList.insert("svg:height", tileFill->m_scaleY * (bBox.m_ymax - bBox.m_ymin));
generator.startPage(pList);
_outputSomething(tileFill->m_groupId, &generator);
diff --git a/src/lib/FHParser.cpp b/src/lib/FHParser.cpp
index a27b2c5..09c62e8 100644
--- a/src/lib/FHParser.cpp
+++ b/src/lib/FHParser.cpp
@@ -2068,8 +2068,8 @@ void libfreehand::FHParser::readTileFill(librevenge::RVNGInputStream *input, lib
fill.m_xFormId = _readRecordId(input);
fill.m_groupId = _readRecordId(input);
input->seek(8, librevenge::RVNG_SEEK_CUR);
- fill.m_stretchX = _readCoordinate(input);
- fill.m_stretchY = _readCoordinate(input);
+ fill.m_scaleX = _readCoordinate(input);
+ fill.m_scaleY = _readCoordinate(input);
fill.m_offsetX = _readCoordinate(input);
fill.m_offsetY = _readCoordinate(input);
fill.m_angle = _readCoordinate(input);
diff --git a/src/lib/FHTypes.h b/src/lib/FHTypes.h
index ed9291e..333c163 100644
--- a/src/lib/FHTypes.h
+++ b/src/lib/FHTypes.h
@@ -337,13 +337,13 @@ struct FHTileFill
{
unsigned m_xFormId;
unsigned m_groupId;
- double m_stretchX;
- double m_stretchY;
+ double m_scaleX;
+ double m_scaleY;
double m_offsetX;
double m_offsetY;
double m_angle;
FHTileFill()
- : m_xFormId(0), m_groupId(0), m_stretchX(0.0), m_stretchY(0.0),
+ : m_xFormId(0), m_groupId(0), m_scaleX(0.0), m_scaleY(0.0),
m_offsetX(0.0), m_offsetY(0.0), m_angle(0.0) {}
};
@@ -372,7 +372,7 @@ struct FHBoundingBox
double m_ymin;
double m_xmax;
double m_ymax;
- FHBoundingBox() : m_xmin(DBL_MAX), m_ymin(DBL_MAX), m_xmax(DBL_MIN), m_ymax(DBL_MIN) {}
+ FHBoundingBox() : m_xmin(DBL_MAX), m_ymin(DBL_MAX), m_xmax(-DBL_MAX), m_ymax(-DBL_MAX) {}
FHBoundingBox(const FHBoundingBox &bBox)
: m_xmin(bBox.m_xmin), m_ymin(bBox.m_ymin), m_xmax(bBox.m_xmax), m_ymax(bBox.m_ymax) {}
void merge(const FHBoundingBox &bBox)
@@ -386,6 +386,10 @@ struct FHBoundingBox
if (m_ymax < bBox.m_ymax) m_ymax = bBox.m_ymax;
if (m_ymax < bBox.m_ymin) m_ymax = bBox.m_ymin;
}
+ bool isValid() const
+ {
+ return ((m_xmin < m_xmax) && (m_ymin < m_ymax));
+ }
};
} // namespace libfreehand