![]() |
Mapper
0.9.0
API documentation
|
Functions | |
OCADObjectIndex * | ocad_objidx_first (OCADFile *pfile) |
Returns a pointer to the first object index block, or nullptr if the file isn't valid. More... | |
OCADObjectIndex * | ocad_objidx_next (OCADFile *pfile, OCADObjectIndex *current) |
Returns a pointer to the next object index block after the given one, or nullptr if there is none. More... | |
OCADObjectEntry * | ocad_object_entry_at (OCADFile *pfile, OCADObjectIndex *current, int index) |
Returns a pointer to the given object index entry, or nullptr if the file isn't valid. More... | |
OCADObjectEntry * | ocad_object_entry_new (OCADFile *pfile, u32 npts) |
Returns a pointer to the first empty object index entry large enough to fit an object with the given number of points. More... | |
void | ocad_object_entry_refresh (OCADFile *pfile, OCADObjectEntry *entry, OCADObject *object) |
Recalculates the bounding rectangle and updates the size and symbol fields in an object index entry. More... | |
int | ocad_object_remove (OCADFile *pfile, OCADObjectEntry *entry) |
Removes the object at the given object index entry. More... | |
bool | ocad_object_entry_iterate (OCADFile *pfile, OCADObjectEntryCallback callback, void *param) |
Iterates over all object entries in the file. More... | |
OCADObject * | ocad_object_at (OCADFile *pfile, OCADObjectIndex *current, int index) |
Returns a pointer to the object in the specified location within the index block, or nullptr if there is no such object. More... | |
OCADObject * | ocad_object (OCADFile *pfile, OCADObjectEntry *entry) |
Returns a pointer to an object, given a valid pointer to its index entry. More... | |
bool | ocad_object_iterate (OCADFile *pfile, OCADObjectCallback callback, void *param) |
Iterates over all objects in the file. More... | |
u32 | ocad_object_size (const OCADObject *object) |
Returns the storage size of an OCAD object, in bytes. More... | |
u32 | ocad_object_size_npts (u32 npts) |
Returns the storage size of an OCAD object, in bytes, given the number of points. More... | |
OCADObject * | ocad_object_alloc (const OCADObject *source) |
Allocates space for a temporary OCAD object, optionally copying it from an existing object. More... | |
OCADObject * | ocad_object_add (OCADFile *file, const OCADObject *object, OCADObjectEntry **out_entry) |
Adds a new object to the file. More... | |
OCADObject* ocad_object | ( | OCADFile * | pfile, |
OCADObjectEntry * | entry | ||
) |
Returns a pointer to an object, given a valid pointer to its index entry.
Returns nullptr if the file isn't valid or the index entry is empty.
OCADObject* ocad_object_add | ( | OCADFile * | file, |
const OCADObject * | object, | ||
OCADObjectEntry ** | out_entry | ||
) |
Adds a new object to the file.
The size field should be set correctly prior to calling this function. This method can be used either to add a new object created by ocad_object_alloc(), or to duplicate an object by passing a pointer to an object already in the file.
The provided object is copied into the file and is left unchanged by this call. A pointer to the new object is returned, or nullptr if the object could not be added.
OCADObject* ocad_object_alloc | ( | const OCADObject * | source | ) |
Allocates space for a temporary OCAD object, optionally copying it from an existing object.
The allocated space is the size of the largest object supported by the file format (32767 points). This object can then be manipulated with the ocad_object_* functions, and finally saved back into the file with ocad_object_add() or ocad_object_replace().
You may pass a nullptr parameter to create a new, empty object.
OCADObject* ocad_object_at | ( | OCADFile * | pfile, |
OCADObjectIndex * | current, | ||
int | index | ||
) |
Returns a pointer to the object in the specified location within the index block, or nullptr if there is no such object.
OCADObjectEntry* ocad_object_entry_at | ( | OCADFile * | pfile, |
OCADObjectIndex * | current, | ||
int | index | ||
) |
Returns a pointer to the given object index entry, or nullptr if the file isn't valid.
Also returns nullptr if the index is out of range, but always returns a valid pointer if the file, index block, and index are valid.
bool ocad_object_entry_iterate | ( | OCADFile * | pfile, |
OCADObjectEntryCallback | callback, | ||
void * | param | ||
) |
Iterates over all object entries in the file.
Returns a pointer to the first empty object index entry large enough to fit an object with the given number of points.
If no suitable object index entry is found, a new entry will be created. This method will only return nullptr if the file isn't valid or if there is a memory allocation problem.
The returned entry will have its ptr and npts fields set; the caller is responsible for writing the object into the location pointed to by ptr, and setting the symbol, min, and max fields in the index entry. ocad_object_entry_refresh provides an easy way to sync these extra fields with an existing object.
void ocad_object_entry_refresh | ( | OCADFile * | pfile, |
OCADObjectEntry * | entry, | ||
OCADObject * | object | ||
) |
Recalculates the bounding rectangle and updates the size and symbol fields in an object index entry.
The entry's pointer and size field are not affected, and the object passed to this function doesn't need to be the same as the object referenced by the entry (although it should end up that way). The extent of the object's symbol is included in the bounding rectangle.
You usually shouldn't need to call this method directly. It is implicitly used by ocad_object_add(), ocad_object_replace(), and ocad_file_compact(). However, it's made available in case you need to selectively repair a particular index entry.
bool ocad_object_iterate | ( | OCADFile * | pfile, |
OCADObjectCallback | callback, | ||
void * | param | ||
) |
Iterates over all objects in the file.
int ocad_object_remove | ( | OCADFile * | pfile, |
OCADObjectEntry * | entry | ||
) |
Removes the object at the given object index entry.
Returns 0 on success, -1 if the file isn't valid. The object's symbol number is set to zero, and the entry's symbol number is set to zero. The entry becomes eligible to be returned by a call to ocad_object_entry_new(), if it is large enough for the new object.
u32 ocad_object_size | ( | const OCADObject * | object | ) |
Returns the storage size of an OCAD object, in bytes.
Returns the storage size of an OCAD object, in bytes, given the number of points.
OCADObjectIndex* ocad_objidx_first | ( | OCADFile * | pfile | ) |
Returns a pointer to the first object index block, or nullptr if the file isn't valid.
Also returns nullptr if the file contains no object.
OCADObjectIndex* ocad_objidx_next | ( | OCADFile * | pfile, |
OCADObjectIndex * | current | ||
) |
Returns a pointer to the next object index block after the given one, or nullptr if there is none.