Skip to content

Commit 7144415

Browse files
committed
OcdFileImport: Factor-in setPointFlags
Preparation for improved state handling and bug fixes. No observable change of behavior intented.
1 parent 11b068b commit 7144415

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/fileformats/ocd_file_import.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,29 +2141,31 @@ void OcdFileImport::setPathHolePoint(OcdImportedPathObject *object, quint32 pos)
21412141
object->coords[pos].setHolePoint(true);
21422142
}
21432143

2144-
void OcdFileImport::setPointFlags(OcdImportedPathObject* object, quint32 pos, bool is_area, const Ocd::OcdPoint32& ocd_point)
2145-
{
2146-
// We can support CurveStart, HolePoint, DashPoint.
2147-
// CurveStart needs to be applied to the main point though, not the control point, and
2148-
// hole points need to bet set as the last point of a part of an area object instead of the first point of the next part
2149-
if (ocd_point.x & Ocd::OcdPoint32::FlagCtl1 && pos > 0)
2150-
object->coords[pos-1].setCurveStart(true);
2151-
if ((ocd_point.y & Ocd::OcdPoint32::FlagDash) || (ocd_point.y & Ocd::OcdPoint32::FlagCorner))
2152-
object->coords[pos].setDashPoint(true);
2153-
if (ocd_point.y & Ocd::OcdPoint32::FlagHole && pos > 1 && is_area)
2154-
setPathHolePoint(object, pos - 1);
2155-
}
2156-
21572144
/** Translates the OC*D path given in the last two arguments into an Object.
21582145
*/
21592146
void OcdFileImport::fillPathCoords(OcdImportedPathObject *object, bool is_area, quint32 num_points, const Ocd::OcdPoint32* ocd_points)
21602147
{
21612148
object->coords.resize(num_points);
21622149
for (auto i = 0u; i < num_points; i++)
21632150
{
2164-
object->coords[i] = convertOcdPoint(ocd_points[i]);
2165-
setPointFlags(object, i, is_area, ocd_points[i]);
2166-
}
2151+
const auto& ocd_point = ocd_points[i];
2152+
object->coords[i] = convertOcdPoint(ocd_point);
2153+
if ((ocd_point.y & Ocd::OcdPoint32::FlagDash) || (ocd_point.y & Ocd::OcdPoint32::FlagCorner))
2154+
{
2155+
object->coords[i].setDashPoint(true);
2156+
}
2157+
2158+
if (ocd_point.x & Ocd::OcdPoint32::FlagCtl1 && i > 0)
2159+
{
2160+
// CurveStart needs to be applied to the start point
2161+
object->coords[i-1].setCurveStart(true);
2162+
}
2163+
2164+
if (ocd_point.y & Ocd::OcdPoint32::FlagHole && is_area && i > 1)
2165+
{
2166+
setPathHolePoint(object, i - 1);
2167+
}
2168+
};
21672169

21682170
// For path objects, create closed parts where the position of the last point is equal to that of the first point
21692171
if (object->getType() == Object::Path)

src/fileformats/ocd_file_import.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,7 @@ class OcdFileImport : public Importer
317317

318318
// Some helper functions that are used in multiple places
319319

320-
void setPointFlags(OcdImportedPathObject* object, quint32 pos, bool is_area, const Ocd::OcdPoint32& ocd_point);
321-
322-
void setPathHolePoint(OcdFileImport::OcdImportedPathObject* object, quint32 pos);
320+
void setPathHolePoint(OcdImportedPathObject *object, quint32 pos);
323321

324322
void fillPathCoords(OcdFileImport::OcdImportedPathObject* object, bool is_area, quint32 num_points, const Ocd::OcdPoint32* ocd_points);
325323

0 commit comments

Comments
 (0)