Example #1
0
// This event is called by the graph_drawer widget when the user selects a node
void main_window::
on_node_selected (unsigned long n)
{
    // make a reference to the selected node
    node_type& node = graph_drawer.graph_node(n);


    // enable all the widgets related to the selected node
    selected_node_index = n;
    node_is_selected = true;
    tables.enable();
    sel_node_is_evidence.enable();
    sel_node_index.enable();
    sel_node_evidence_label.enable();
    sel_node_text_label.enable();
    sel_node_text.enable();
    sel_node_num_values_label.enable();
    sel_node_num_values.enable();

    // make sure the num_values field of the node's cpt is set to something valid. 
    // So default it to 2 if it isn't set already.
    if (node.data.table().num_values() < 2)
    {
        node.data.table().set_num_values(2);
        graph_modified_since_last_recalc = true;
    }

    // setup the evidence check box and input field
    sel_node_index.set_text("index: " + cast_to_string(n));
    if (graph_drawer.graph_node(n).data.is_evidence())
    {
        sel_node_is_evidence.set_checked();
        sel_node_evidence.enable();
        sel_node_evidence.set_text(cast_to_string(graph_drawer.graph_node(n).data.value()));
    }
    else
    {
        sel_node_is_evidence.set_unchecked();
        sel_node_evidence.disable();
        sel_node_evidence.set_text("");
    }

    sel_node_num_values.set_text(cast_to_string(node_num_values(graph_drawer.graph(),n)));

    sel_node_text.set_text(graph_drawer.node_label(n));

    load_selected_node_tables_into_cpt_grid();
    load_selected_node_tables_into_ppt_grid();
}