issue/47-add-vertex-count-to-gui #48
105
cell-selector/cell-statistics-renderer.c
Normal file
105
cell-selector/cell-statistics-renderer.c
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* GDSII-Converter
|
||||
* Copyright (C) 2022 Mario Hüttel <mario.huettel@gmx.net>
|
||||
*
|
||||
* This file is part of GDSII-Converter.
|
||||
*
|
||||
* GDSII-Converter is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* GDSII-Converter is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cell-statistics-renderer.c
|
||||
* @brief CellStatisticsRenderer GObject Class
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup CellStatisticsRenderer
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <gds-render/cell-selector/cell-statistics-renderer.h>
|
||||
|
||||
G_DEFINE_TYPE(CellStatisticsRenderer, cell_statistics_renderer, GTK_TYPE_CELL_RENDERER_TEXT)
|
||||
|
||||
enum {
|
||||
PROP_CELL_STAT = 1,
|
||||
PROP_COUNT
|
||||
};
|
||||
|
||||
static void cell_statistics_renderer_set_property(GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GValue val = G_VALUE_INIT;
|
||||
GString *string;
|
||||
const struct gds_cell_statistics *cell_stat;
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_CELL_STAT:
|
||||
cell_stat = (const struct gds_cell_statistics *)g_value_get_pointer(value);
|
||||
g_value_init(&val, G_TYPE_STRING);
|
||||
string = g_string_new_len("", 5);
|
||||
if (cell_stat)
|
||||
g_string_printf(string, "%zu", cell_stat->vertex_count);
|
||||
g_value_set_string(&val, string->str);
|
||||
g_object_set_property(object, "text", &val);
|
||||
g_value_unset(&val);
|
||||
g_string_free(string, TRUE);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void cell_statistics_renderer_get_property(GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
(void)value;
|
||||
|
||||
switch (param_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static GParamSpec *properties[PROP_COUNT];
|
||||
|
||||
void cell_statistics_renderer_class_init(CellStatisticsRendererClass *klass)
|
||||
{
|
||||
GObjectClass *oclass = G_OBJECT_CLASS(klass);
|
||||
|
||||
oclass->set_property = cell_statistics_renderer_set_property;
|
||||
oclass->get_property = cell_statistics_renderer_get_property;
|
||||
|
||||
properties[PROP_CELL_STAT] = g_param_spec_pointer("cell-stat", "cell-stat",
|
||||
"Cell statistics", G_PARAM_WRITABLE);
|
||||
g_object_class_install_properties(oclass, PROP_COUNT, properties);
|
||||
}
|
||||
|
||||
void cell_statistics_renderer_init(CellStatisticsRenderer *self)
|
||||
{
|
||||
(void)self;
|
||||
}
|
||||
|
||||
GtkCellRenderer *cell_statistics_renderer_new(void)
|
||||
{
|
||||
return GTK_CELL_RENDERER(g_object_new(TYPE_GDS_RENDER_CELL_STAT_RENDERER, NULL));
|
||||
}
|
||||
|
||||
/** @} */
|
@ -37,6 +37,7 @@
|
||||
#include <gds-render/layer/layer-selector.h>
|
||||
#include <gds-render/widgets/activity-bar.h>
|
||||
#include <gds-render/cell-selector/lib-cell-renderer.h>
|
||||
#include <gds-render/cell-selector/cell-statistics-renderer.h>
|
||||
#include <gds-render/output-renderers/latex-renderer.h>
|
||||
#include <gds-render/output-renderers/cairo-renderer.h>
|
||||
#include <gds-render/widgets/conv-settings-dialog.h>
|
||||
@ -224,7 +225,7 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
self->cell_tree_store = gtk_tree_store_new(CELL_SEL_COLUMN_COUNT, G_TYPE_POINTER,
|
||||
G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_STRING);
|
||||
G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_POINTER);
|
||||
|
||||
/* Searching */
|
||||
self->cell_filter = GTK_TREE_MODEL_FILTER(
|
||||
@ -240,7 +241,7 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
|
||||
|
||||
render_cell = lib_cell_renderer_new();
|
||||
render_lib = lib_cell_renderer_new();
|
||||
render_vertex_count = gtk_cell_renderer_text_new();
|
||||
render_vertex_count = cell_statistics_renderer_new();
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Library"), render_lib, "gds-lib", CELL_SEL_LIBRARY, NULL);
|
||||
gtk_tree_view_append_column(self->cell_tree_view, column);
|
||||
@ -249,7 +250,7 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
|
||||
"error-level", CELL_SEL_CELL_ERROR_STATE, NULL);
|
||||
gtk_tree_view_append_column(self->cell_tree_view, column);
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Vertex Count"), render_vertex_count, "text", CELL_SEL_STAT,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Vertex Count"), render_vertex_count, "cell-stat", CELL_SEL_STAT,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(self->cell_tree_view, column);
|
||||
|
||||
@ -262,6 +263,10 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct gds_cell_statistics cc = {
|
||||
.vertex_count = 12,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Callback function of Load GDS button
|
||||
* @param button
|
||||
@ -360,6 +365,7 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
CELL_SEL_CELL, gds_c,
|
||||
CELL_SEL_CELL_ERROR_STATE, cell_error_level,
|
||||
CELL_SEL_LIBRARY, gds_c->parent_library,
|
||||
CELL_SEL_STAT, &cc,
|
||||
-1);
|
||||
} /* for cells */
|
||||
} /* for libraries */
|
||||
|
56
include/gds-render/cell-selector/cell-statistics-renderer.h
Normal file
56
include/gds-render/cell-selector/cell-statistics-renderer.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* GDSII-Converter
|
||||
* Copyright (C) 2022 Mario Hüttel <mario.huettel@gmx.net>
|
||||
*
|
||||
* This file is part of GDSII-Converter.
|
||||
*
|
||||
* GDSII-Converter is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* GDSII-Converter is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cell-statistics-renderer.h
|
||||
* @brief Header file for the CellStatisticsRenderer GObject Class
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup CellStatisticsRenderer
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _CELL_STATISTICS_RENDERER_H_
|
||||
#define _CELL_STATISTICS_RENDERER_H_
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gds-render/gds-utils/gds-statistics.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
G_DECLARE_FINAL_TYPE(CellStatisticsRenderer, cell_statistics_renderer, GDS_RENDER, CELL_STAT_RENDERER, GtkCellRendererText)
|
||||
#define TYPE_GDS_RENDER_CELL_STAT_RENDERER (cell_statistics_renderer_get_type())
|
||||
|
||||
typedef struct _CellStatisticsRenderer {
|
||||
GtkCellRendererText super;
|
||||
} CellStatisticsRenderer;
|
||||
|
||||
/**
|
||||
* @brief New Cell statistics renderer
|
||||
* @return GObject
|
||||
*/
|
||||
GtkCellRenderer *cell_statistics_renderer_new(void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _CELL_STATISTICS_RENDERER_H_ */
|
||||
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user