Issue #19: Add LayerSettings Class
* Remove Command line and GUI rendering code * Add LayerSettings Class with all options * Prepare to remove mapping parser. Is now integrated in LayerSettings * Adopt all renderers to check if the supplied layer_info struct has to be rendered. Further todos: * Implement correct command line parsing. * Implement Layerselector and GUI to use new LayerSettings class
This commit is contained in:
@@ -33,32 +33,21 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
enum command_line_renderer {
|
||||
CMD_NONE = 0,
|
||||
CMD_EXTERNAL,
|
||||
CMD_CAIRO_SVG,
|
||||
CMD_CAIRO_PDF,
|
||||
CMD_LATEX,
|
||||
};
|
||||
|
||||
enum cmd_options {
|
||||
CMD_OPT_NONE = 0U,
|
||||
CMD_OPT_LATEX_STANDALONE = (1U<<0),
|
||||
CMD_OPT_LATEX_LAYERS = (1U<<1),
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief render output file according to command line parameters
|
||||
* @param gds_name Name of GDS file
|
||||
* @param cell_name Name of cell to render
|
||||
* @param output_file_name Output file name
|
||||
* @param so_file Shared object file to search external rendering function
|
||||
* @param renderer Type of output renderer
|
||||
* @param options Additional options for output renderer
|
||||
* @param scale Scale value
|
||||
* @brief Convert GDS according to command line parameters
|
||||
* @param gds_name Path to GDS File
|
||||
* @param cell_name Cell name
|
||||
* @param renderers Renderer ids
|
||||
* @param output_file_names Output file names
|
||||
* @param layer_file Layer mapping file
|
||||
* @param so_path Shared object path
|
||||
*/
|
||||
void command_line_convert_gds(const char *gds_name, const char *cell_name, const char *output_file_name, const char *layer_file,
|
||||
const char *so_file, enum command_line_renderer renderer, enum cmd_options options, double scale);
|
||||
void command_line_convert_gds(const char *gds_name,
|
||||
const char *cell_name,
|
||||
const char * const *renderers,
|
||||
const char * const *output_file_names,
|
||||
const char *layer_file,
|
||||
const char *so_path);
|
||||
|
||||
#endif /* _COMMAND_LINE_H_ */
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
|
||||
/**
|
||||
* @file layer-info.h
|
||||
* @brief Helper functions and definition of layer info struct
|
||||
* @brief LayerSettings class heade file
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
@@ -28,24 +28,92 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* @brief Layer information.
|
||||
*
|
||||
* This structs contains information on how to render a layer
|
||||
* @note You probably don't want to use this struct standalone but in combination
|
||||
* with a LayerSettings object.
|
||||
*/
|
||||
struct layer_info
|
||||
{
|
||||
int layer; /**< @brief Layer number */
|
||||
char *name; /**< @brief Layer name */
|
||||
char *name; /**< @brief Layer name. */
|
||||
int stacked_position; ///< @brief Position of layer in output @warning This parameter is not used by any renderer so far @note Lower is bottom, higher is top
|
||||
GdkRGBA color; /**< @brief RGBA color used to render this layer */
|
||||
int render; /**< @brief true: Render to output */
|
||||
};
|
||||
|
||||
G_DECLARE_FINAL_TYPE(LayerSettings, layer_settings, GDS_RENDER, LAYER_SETTINGS, GObject)
|
||||
|
||||
#define GDS_RENDER_TYPE_LAYER_SETTINGS (layer_settings_get_type())
|
||||
|
||||
/**
|
||||
* @brief Delete a layer_info struct
|
||||
* @param info Struct to be deleted.
|
||||
* @note The layer_info::name Element has to be freed manually
|
||||
* @brief Maximum length of a layer mapping CSV line
|
||||
*/
|
||||
void layer_info_delete_struct(struct layer_info *info);
|
||||
#define CSV_LINE_MAX_LEN (1024)
|
||||
|
||||
/**
|
||||
* @brief New LayerSettings object
|
||||
* @return New object
|
||||
*/
|
||||
LayerSettings *layer_settings_new();
|
||||
|
||||
/**
|
||||
* @brief layer_settings_append_layer_info
|
||||
* @param settings LayerSettings object.
|
||||
* @param info Info to append
|
||||
* @return Error code. 0 if successful
|
||||
* @note \p info is copied internally. You can free this struct afterwards.
|
||||
*/
|
||||
int layer_settings_append_layer_info(LayerSettings *settings, struct layer_info *info);
|
||||
|
||||
/**
|
||||
* @brief Clear all layers in this settings object
|
||||
* @param settings LayerSettings object
|
||||
*/
|
||||
void layer_settings_clear(LayerSettings *settings);
|
||||
|
||||
/**
|
||||
* @brief Remove a specific layer number from the layer settings.
|
||||
* @param settings LayerSettings object
|
||||
* @param layer Layer number
|
||||
* @return Error code. 0 if successful
|
||||
*/
|
||||
int layer_settings_remove_layer(LayerSettings *settings, int layer);
|
||||
|
||||
/**
|
||||
* @brief Get a GList with layer_info structs
|
||||
*
|
||||
* This function returns a GList with all layer_info structs in rendering order
|
||||
* (bottom to top) that shall be rendered.
|
||||
*
|
||||
* @param settings LayerSettings object
|
||||
* @return GList with struct layer_info elements.
|
||||
*/
|
||||
GList *layer_settings_get_layer_info_list(LayerSettings *settings);
|
||||
|
||||
/**
|
||||
* @brief Write layer settings to a CSV file
|
||||
* @param path
|
||||
* @return 0 if successful
|
||||
*/
|
||||
int layer_settings_to_csv(LayerSettings *settings, const char *path);
|
||||
|
||||
/**
|
||||
* @brief Load new layer Settings from CSV
|
||||
*
|
||||
* This function loads the layer information from a CSV file.
|
||||
* All data inside the \p settings is cleared beforehand.
|
||||
*
|
||||
* @param settings Settings to write to.
|
||||
* @param path CSV file path
|
||||
* @return 0 if successful
|
||||
*/
|
||||
int layer_settings_load_from_csv(LayerSettings *settings, const char *path);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // _LAYER_INFO_H_
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include <gds-render/widgets/layer-element.h>
|
||||
#include <gds-render/layer/layer-info.h>
|
||||
|
||||
/**
|
||||
* @brief Load a line from \p stream and parse try to parse it as layer information
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <gds-render/gds-utils/gds-types.h>
|
||||
#include <glib-object.h>
|
||||
#include <glib.h>
|
||||
#include <gds-render/layer/layer-info.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -52,9 +53,7 @@ struct _GdsOutputRendererClass {
|
||||
* @brief Virtual render output function. Overwritten by final class implementation
|
||||
*/
|
||||
int (*render_output)(GdsOutputRenderer *renderer,
|
||||
struct gds_cell *cell,
|
||||
GList *layer_infos,
|
||||
const char *output_file,
|
||||
struct gds_cell *cell,
|
||||
double scale);
|
||||
gpointer padding[4];
|
||||
};
|
||||
@@ -70,21 +69,64 @@ enum {
|
||||
*/
|
||||
GdsOutputRenderer *gds_output_renderer_new();
|
||||
|
||||
/**
|
||||
* @brief Create a new GdsOutputRenderer GObject with its properties
|
||||
* @param output_file Output file of the renderer
|
||||
* @param layer_settings Layer settings object
|
||||
* @return New object
|
||||
*/
|
||||
GdsOutputRenderer *gds_output_renderer_new_with_props(const char *output_file, LayerSettings *layer_settings);
|
||||
|
||||
/**
|
||||
* @brief gds_output_renderer_render_output
|
||||
* @param renderer Renderer object
|
||||
* @param cell Cell to render
|
||||
* @param layer_infos List of Layer information (@ref layer_info)
|
||||
* @param output_file Output file name
|
||||
* @param scale scale value. The output is scaled *down* by this value
|
||||
* @return 0 if successful
|
||||
*/
|
||||
int gds_output_renderer_render_output(GdsOutputRenderer *renderer,
|
||||
struct gds_cell *cell,
|
||||
GList *layer_infos,
|
||||
const char *output_file,
|
||||
double scale);
|
||||
|
||||
/**
|
||||
* @brief Convenience function for setting the "output-file" property
|
||||
* @param renderer Renderer object
|
||||
* @param file_name Output file path
|
||||
*/
|
||||
void gds_output_renderer_set_output_file(GdsOutputRenderer *renderer, const gchar *file_name);
|
||||
|
||||
/**
|
||||
* @brief Convenience function for getting the "output-file" property
|
||||
* @param renderer
|
||||
* @return Output file path. This must not be freed
|
||||
*/
|
||||
const char *gds_output_renderer_get_output_file(GdsOutputRenderer *renderer);
|
||||
|
||||
/**
|
||||
* @brief Get layer settings
|
||||
*
|
||||
* This is a convenience function for getting the
|
||||
* "layer-settings" property
|
||||
*
|
||||
* @param renderer Renderer
|
||||
* @return Layer settings object
|
||||
*/
|
||||
LayerSettings *gds_output_renderer_get_layer_settings(GdsOutputRenderer *renderer);
|
||||
|
||||
/**
|
||||
* @brief Set layer settings
|
||||
*
|
||||
* This is a convenience function for setting the
|
||||
* "layer-settings" property.
|
||||
*
|
||||
* If another Layer settings has previously been supplied,
|
||||
* it is unref'd.
|
||||
*
|
||||
* @param renderer Renderer
|
||||
* @param settings LayerSettings object
|
||||
*/
|
||||
void gds_output_renderer_set_layer_settings(GdsOutputRenderer *renderer, LayerSettings *settings);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _GDS_OUTPUT_RENDERER_H_ */
|
||||
|
Reference in New Issue
Block a user