Skip to content

Commit

Permalink
OcdFileExport: Set color in object index entry
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt committed Sep 13, 2018
1 parent fca6986 commit 6d5d317
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/fileformats/ocd_file_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2500,16 +2500,17 @@ void OcdFileExport::exportObjects(OcdFile<Format>& file)
* Object setup which depends on the type features, not on minor type variations of members.
*/
template< class OcdObject >
void handleObjectExtras(OcdObject& ocd_object, typename OcdObject::IndexEntryType& entry)
void OcdFileExport::handleObjectExtras(const Object* object, OcdObject& ocd_object, typename OcdObject::IndexEntryType& entry)
{
// Extra entry members since V9
entry.type = ocd_object.type;
entry.status = Ocd::ObjectNormal;
entry.color = convertColor(object->getSymbol()->guessDominantColor());
}


template< >
void handleObjectExtras<Ocd::ObjectV8>(Ocd::ObjectV8& ocd_object, typename Ocd::ObjectV8::IndexEntryType& /*entry*/)
void OcdFileExport::handleObjectExtras<Ocd::ObjectV8>(const Object* /*object*/, Ocd::ObjectV8& ocd_object, typename Ocd::ObjectV8::IndexEntryType& /*entry*/)
{
switch (ocd_object.type)
{
Expand Down Expand Up @@ -2599,7 +2600,7 @@ void OcdFileExport::exportPathObject(OcdFile<Format>& file, const PathObject* pa

exported_ocd_object.symbol = entry.symbol = decltype(entry.symbol)(breakdown->number);
exported_ocd_object.type = decltype(exported_ocd_object.type)(breakdown->type);
handleObjectExtras(exported_ocd_object, entry); // update entry.type if it exists
handleObjectExtras(path, exported_ocd_object, entry); // update entry.type if it exists
file.objects().insert(data, entry);
}

Expand Down Expand Up @@ -2673,7 +2674,7 @@ QByteArray OcdFileExport::exportObjectCommon(const Object* object, OcdObject& oc

entry.bottom_left_bound = convertPoint(MapCoord(object->getExtent().bottomLeft()));
entry.top_right_bound = convertPoint(MapCoord(object->getExtent().topRight()));
handleObjectExtras(ocd_object, entry);
handleObjectExtras(object, ocd_object, entry);

auto header_size = int(sizeof(OcdObject) - sizeof(Ocd::OcdPoint32));
auto items_size = int((ocd_object.num_items + ocd_object.num_text) * sizeof(Ocd::OcdPoint32));
Expand Down
3 changes: 3 additions & 0 deletions src/fileformats/ocd_file_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ class OcdFileExport : public Exporter
template< class Format >
void exportObjects(OcdFile<Format>& file);

template< class OcdObject >
void handleObjectExtras(const Object* object, OcdObject& ocd_object, typename OcdObject::IndexEntryType& entry);

template< class OcdObject >
QByteArray exportPointObject(const PointObject* point, typename OcdObject::IndexEntryType& entry);

Expand Down

0 comments on commit 6d5d317

Please sign in to comment.