14#include "ns3/config.h"
15#include "ns3/pointer.h"
16#include "ns3/string.h"
26 GtkCellRenderer* renderer,
32 gtk_tree_model_get(model, iter,
COL_NODE, &node, -1);
41 g_object_set(renderer,
"text", str.Get().c_str(),
nullptr);
42 g_object_set(renderer,
"editable", TRUE,
nullptr);
46 g_object_set(renderer,
"text",
"",
nullptr);
47 g_object_set(renderer,
"editable", FALSE,
nullptr);
57 GtkCellRenderer* renderer,
63 gtk_tree_model_get(model, iter,
COL_NODE, &node, -1);
64 g_object_set(renderer,
"editable", FALSE,
nullptr);
73 g_object_set(renderer,
75 node->
object->GetInstanceTypeId().GetName().c_str(),
81 g_object_set(renderer,
"text", node->
name.c_str(),
nullptr);
84 std::stringstream oss;
86 g_object_set(renderer,
"text", oss.str().c_str(),
nullptr);
100 GtkTreeModel* model = GTK_TREE_MODEL(user_data);
102 gtk_tree_model_get_iter_from_string(model, &iter, path_string);
104 gtk_tree_model_get(model, &iter,
COL_NODE, &node, -1);
122 g_return_val_if_fail(col !=
nullptr, -1);
123 g_return_val_if_fail(gtk_tree_view_column_get_tree_view(col) !=
nullptr, -1);
124 cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(gtk_tree_view_column_get_tree_view(col)));
125 num = g_list_index(cols, (gpointer)col);
138 gboolean keyboard_tip,
144 GtkTreeViewColumn* column;
145 if (!gtk_tree_view_get_tooltip_context(GTK_TREE_VIEW(widget),
155 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
168 gtk_tree_model_get(model, &iter,
COL_NODE, &node, -1);
180 "This object is of type " + node->
object->GetInstanceTypeId().GetName();
181 gtk_tooltip_set_text(tooltip, tip.c_str());
191 "This object is of type " + ptr.
GetObject()->GetInstanceTypeId().GetName();
192 gtk_tooltip_set_text(tooltip, tip.c_str());
202 "This object is of type " + node->
object->GetInstanceTypeId().GetName();
203 gtk_tooltip_set_text(tooltip, tip.c_str());
225 gtk_tooltip_set_text(tooltip, tip.c_str());
232 tip =
"This attribute is of type " + checker->GetValueTypeName();
233 if (checker->HasUnderlyingTypeInformation())
235 tip +=
" " + checker->GetUnderlyingTypeInformation();
237 gtk_tooltip_set_text(tooltip, tip.c_str());
253 GtkTreeViewColumn* col;
254 GtkCellRenderer* renderer;
257 view = gtk_tree_view_new();
258 g_object_set(view,
"has-tooltip", TRUE,
nullptr);
261 gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(view), GTK_TREE_VIEW_GRID_LINES_BOTH);
264 col = gtk_tree_view_column_new();
265 gtk_tree_view_column_set_title(col,
"Object Attributes");
266 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
267 renderer = gtk_cell_renderer_text_new();
268 gtk_tree_view_column_pack_start(col, renderer, TRUE);
269 gtk_tree_view_column_set_cell_data_func(col,
274 g_object_set(renderer,
"editable", FALSE,
nullptr);
276 col = gtk_tree_view_column_new();
277 gtk_tree_view_column_set_title(col,
"Attribute Value");
278 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
279 renderer = gtk_cell_renderer_text_new();
281 gtk_tree_view_column_pack_start(col, renderer, TRUE);
282 gtk_tree_view_column_set_cell_data_func(col,
288 gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(model));
290 g_object_unref(model);
302 gtk_widget_hide(GTK_WIDGET(user_data));
312 gtk_widget_hide(GTK_WIDGET(user_data));
323 gtk_tree_model_get(GTK_TREE_MODEL(model), iter,
COL_NODE, &node, -1);
328 gtk_tree_store_set(GTK_TREE_STORE(model), iter,
COL_NODE,
nullptr, -1);
339 GtkCellRenderer* renderer,
345 gtk_tree_model_get(model, iter,
COL_TYPEID, &node, -1);
352 g_object_set(renderer,
"text", node->
defaultValue.c_str(),
nullptr);
353 g_object_set(renderer,
"editable", TRUE,
nullptr);
357 g_object_set(renderer,
"text",
"",
nullptr);
358 g_object_set(renderer,
"editable", FALSE,
nullptr);
367 GtkCellRenderer* renderer,
373 gtk_tree_model_get(model, iter,
COL_NODE, &node, -1);
374 g_object_set(renderer,
"editable", FALSE,
nullptr);
383 g_object_set(renderer,
"text", node->
tid.
GetName().c_str(),
nullptr);
386 g_object_set(renderer,
"text", node->
name.c_str(),
nullptr);
402 GtkTreeModel* model = GTK_TREE_MODEL(user_data);
404 gtk_tree_model_get_iter_from_string(model, &iter, path_string);
406 gtk_tree_model_get(model, &iter,
COL_NODE, &node, -1);
437 gboolean keyboard_tip,
443 GtkTreeViewColumn* column;
444 if (!gtk_tree_view_get_tooltip_context(GTK_TREE_VIEW(widget),
454 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
467 gtk_tree_model_get(model, &iter,
COL_NODE, &node, -1);
478 std::string tip =
"This object is of type " + node->
tid.
GetName();
479 gtk_tooltip_set_text(tooltip, tip.c_str());
488 gtk_tooltip_set_text(tooltip, tip.c_str());
494 tip =
"This attribute is of type " + checker->GetValueTypeName();
495 if (checker->HasUnderlyingTypeInformation())
497 tip +=
" " + checker->GetUnderlyingTypeInformation();
499 gtk_tooltip_set_text(tooltip, tip.c_str());
518 GtkWindow* parent_window = GTK_WINDOW(user_data);
520 GtkFileChooserNative* native;
521 GtkFileChooser* chooser;
522 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
525 native = gtk_file_chooser_native_new(
"Save File", parent_window, action,
"_Save",
"_Cancel");
526 chooser = GTK_FILE_CHOOSER(native);
528 gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
530 gtk_file_chooser_set_current_name(chooser, (
"config-defaults.txt"));
532 res = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
533 if (res == GTK_RESPONSE_ACCEPT)
537 filename = gtk_file_chooser_get_filename(chooser);
544 g_object_unref(native);
556 GtkWindow* parent_window = GTK_WINDOW(user_data);
557 GtkFileChooserNative* native;
558 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
561 native = gtk_file_chooser_native_new(
"Open File", parent_window, action,
"_Open",
"_Cancel");
563 res = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
564 if (res == GTK_RESPONSE_ACCEPT)
567 GtkFileChooser* chooser = GTK_FILE_CHOOSER(native);
568 filename = gtk_file_chooser_get_filename(chooser);
575 g_object_unref(native);
588 GtkWindow* parent_window = GTK_WINDOW(user_data);
590 GtkFileChooserNative* native;
591 GtkFileChooser* chooser;
592 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
595 native = gtk_file_chooser_native_new(
"Save File", parent_window, action,
"_Save",
"_Cancel");
596 chooser = GTK_FILE_CHOOSER(native);
598 gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
600 gtk_file_chooser_set_current_name(chooser, (
"config-attributes.txt"));
602 res = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
603 if (res == GTK_RESPONSE_ACCEPT)
607 filename = gtk_file_chooser_get_filename(chooser);
614 g_object_unref(native);
626 GtkWindow* parent_window = GTK_WINDOW(user_data);
627 GtkFileChooserNative* native;
628 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
631 native = gtk_file_chooser_native_new(
"Open File", parent_window, action,
"_Open",
"_Cancel");
633 res = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
634 if (res == GTK_RESPONSE_ACCEPT)
637 GtkFileChooser* chooser = GTK_FILE_CHOOSER(native);
638 filename = gtk_file_chooser_get_filename(chooser);
645 g_object_unref(native);
655 GtkTreeViewColumn* col;
656 GtkCellRenderer* renderer;
659 view = gtk_tree_view_new();
660 g_object_set(view,
"has-tooltip", TRUE,
nullptr);
663 gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(view), GTK_TREE_VIEW_GRID_LINES_BOTH);
666 col = gtk_tree_view_column_new();
667 gtk_tree_view_column_set_title(col,
"Object Attributes");
668 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
669 renderer = gtk_cell_renderer_text_new();
670 gtk_tree_view_column_pack_start(col, renderer, TRUE);
671 gtk_tree_view_column_set_cell_data_func(col,
676 g_object_set(renderer,
"editable", FALSE,
nullptr);
678 col = gtk_tree_view_column_new();
679 gtk_tree_view_column_set_title(col,
"Attribute Value");
680 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
681 renderer = gtk_cell_renderer_text_new();
683 gtk_tree_view_column_pack_start(col, renderer, TRUE);
684 gtk_tree_view_column_set_cell_data_func(col,
690 gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(model));
692 g_object_unref(model);
707 gtk_tree_model_get(GTK_TREE_MODEL(model), iter,
COL_TYPEID, &node, -1);
712 gtk_tree_store_set(GTK_TREE_STORE(model), iter,
COL_TYPEID,
nullptr, -1);
cairo_uint64_t x
_cairo_uint_96by64_32x64_divrem:
AttributeValue implementation for Pointer.
Ptr< Object > GetObject() const
Get the Object referenced by the PointerValue.
Smart pointer class similar to boost::intrusive_ptr.
A class to enable loading of configuration store from a raw text file.
void SetFilename(std::string filename) override
Set the file name.
void Attributes() override
Load or save the attributes values.
void Default() override
Load or save the default values.
A class to enable saving of configuration store in a raw text file.
void Attributes() override
Load or save the attributes values.
void SetFilename(std::string filename) override
Set the file name.
void Default() override
Load or save the default values.
Hold variables of type string.
a unique identifier for an interface.
bool HasParent() const
Check if this TypeId has a parent.
std::string GetAttributeFullName(std::size_t i) const
Get the Attribute name by index.
std::size_t GetAttributeN() const
Get the number of attributes.
TypeId GetParent() const
Get the parent of this TypeId.
TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
std::string GetName() const
Get the name.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void cell_data_function_col_1_config_default(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
This function writes data in the second column, this data is going to be editable if it is a NODE_ATT...
gboolean cell_tooltip_callback(GtkWidget *widget, gint x, gint y, gboolean keyboard_tip, GtkTooltip *tooltip, gpointer user_data)
This function displays the tooltip for an object, pointer, vector item or an attribute.
gboolean clean_model_callback(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Delete the tree model contents.
void cell_data_function_col_0_config_default(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
This function writes the attribute or typeid name in the column 0.
void cell_data_function_col_1(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
This function includes the name of the attribute or the editable value in the second column.
void cell_edited_callback(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer user_data)
This is the callback called when the value of an attribute is changed.
void save_clicked_attribute(GtkButton *button, gpointer user_data)
This is the action done when the user presses on the save button for the Attributes.
gboolean cell_tooltip_callback_config_default(GtkWidget *widget, gint x, gint y, gboolean keyboard_tip, GtkTooltip *tooltip, gpointer user_data)
This function is used to display a tooltip whenever the user puts the mouse over a type ID or an attr...
gboolean delete_event_callback(GtkWidget *widget, GdkEvent *event, gpointer user_data)
Exit the application.
void exit_clicked_callback(GtkButton *button, gpointer user_data)
Exit the window when exit button is pressed.
GtkWidget * create_view_config_default(GtkTreeStore *model)
This is the main view opening the widget, getting tooltips and drawing the tree of attributes.
gboolean clean_model_callback_config_default(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Delete the tree model contents.
int get_col_number_from_tree_view_column(GtkTreeViewColumn *col)
This function gets the column number 0 or 1 from the mouse click.
GtkWidget * create_view(GtkTreeStore *model)
This is the main view opening the widget, getting tooltips and drawing the tree of attributes....
void cell_data_function_col_0(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
This function includes the name of the object, pointer, vector or vector item in the first column.
void cell_edited_callback_config_default(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer user_data)
This functions is called whenever there is a change in the value of an attribute If the input value i...
void save_clicked_default(GtkButton *button, gpointer user_data)
This is the action done when the user presses on the save button for the Default attributes.
void load_clicked_default(GtkButton *button, gpointer user_data)
If the user presses the button load, it will load the config file into memory for the Default attribu...
void load_clicked_attribute(GtkButton *button, gpointer user_data)
If the user presses the button load, it will load the config file into memory for the Attributes.
A class used in the implementation of the GtkConfigStore.
Ptr< Object > object
the object
std::string name
node name
enum ns3::ModelNode::@353265371332124272263363322234150343123022342154 type
node type structure
A class used in the implementation of the GtkConfigStore.
uint32_t index
stores the index of the attribute in list of attributes for a given TypeId
TypeId tid
The TypeId object and if it is an attribute, it's the TypeId object of the attribute.
enum ns3::ModelTypeid::@372067002020026241074307157075166374022350367224 type
Whether the node represents an attribute or TypeId.
std::string defaultValue
TypeId default value.
std::string name
TypeId name.