Skip to content

Floorplanning legend #2147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
814 changes: 814 additions & 0 deletions vpr/#main.ui#

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions vpr/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="drawPartitions">
<property name="label" translatable="yes">Draw Partitions</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down
4 changes: 4 additions & 0 deletions vpr/src/base/partition_region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ std::vector<Region> PartitionRegion::get_partition_region() {
return partition_region;
}

std::vector<Region> PartitionRegion::get_partition_region() const {
return partition_region;
}

void PartitionRegion::set_partition_region(std::vector<Region> pr) {
partition_region = pr;
}
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/partition_region.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PartitionRegion {
* @brief Return the union of regions
*/
std::vector<Region> get_partition_region();
std::vector<Region> get_partition_region() const;

/**
* @brief Set the union of regions
Expand Down
81 changes: 81 additions & 0 deletions vpr/src/draw/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "breakpoint.h"
#include "manual_moves.h"
#include "draw_noc.h"
#include "draw_floorplanning.h"

#include "move_utils.h"
#include "ui_setup.h"
Expand Down Expand Up @@ -126,6 +127,7 @@ static void setup_default_ezgl_callbacks(ezgl::application* app);
static void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
static void set_block_outline(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
static void set_block_text(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
static void set_draw_partitions(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
static void clip_routing_util(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
static void run_graphics_commands(std::string commands);

Expand Down Expand Up @@ -256,6 +258,11 @@ static void draw_main_canvas(ezgl::renderer* g) {

draw_noc(g);

if (draw_state->draw_partitions) {
highlight_all_regions(g);
draw_constrained_atoms(g);
}

if (draw_state->color_map) {
draw_color_map_legend(*draw_state->color_map, g);
draw_state->color_map.reset(); //Free color map in preparation for next redraw
Expand Down Expand Up @@ -1098,6 +1105,10 @@ static void setup_default_ezgl_callbacks(ezgl::application* app) {
// Connect Debug Button
GObject* debugger = app->get_object("debugButton");
g_signal_connect(debugger, "clicked", G_CALLBACK(draw_debug_window), NULL);

// Connect Draw Partitions Checkbox
GObject* draw_partitions = app->get_object("drawPartitions");
g_signal_connect(draw_partitions, "toggled", G_CALLBACK(set_draw_partitions), app);
}

// Callback function for Block Outline checkbox
Expand Down Expand Up @@ -1144,6 +1155,76 @@ static void clip_routing_util(GtkWidget* widget, gint /*response_id*/, gpointer
application.refresh_drawing();
}

static void on_dialog_response(GtkDialog* dialog, gint response_id, gpointer /* user_data*/) {
switch (response_id) {
case GTK_RESPONSE_ACCEPT:
std::cout << "GTK_RESPONSE_ACCEPT ";
break;
case GTK_RESPONSE_DELETE_EVENT:
std::cout << "GTK_RESPONSE_DELETE_EVENT (i.e. ’X’ button) ";
break;
case GTK_RESPONSE_REJECT:
std::cout << "GTK_RESPONSE_REJECT ";
break;
default:
std::cout << "UNKNOWN ";
break;
}

gtk_widget_destroy(GTK_WIDGET(dialog));
}

// Callback function for Draw Partitions checkbox
static void set_draw_partitions(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/) {
t_draw_state* draw_state = get_draw_state_vars();

GObject* window;
GtkWidget* dialog;

window = application.get_object(application.get_main_window_id().c_str());

dialog = gtk_dialog_new_with_buttons(
"Floorplanning Legend",
(GtkWindow*)window,
GTK_DIALOG_DESTROY_WITH_PARENT,
("CLOSE"),
GTK_RESPONSE_ACCEPT,
NULL);

GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
GtkWidget* content_tree = gtk_tree_view_new();
content_tree = setup_floorplanning_legend(content_tree);

gtk_container_add(GTK_CONTAINER(content_area), content_tree);

GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(content_tree));
g_signal_connect(selection,
"changed",
G_CALLBACK(highlight_selected_partition),
NULL);

// assign corresponding bool value to draw_state->draw_partitions
if (gtk_toggle_button_get_active((GtkToggleButton*)widget)) {
gtk_widget_show_all(dialog);

g_signal_connect(
GTK_DIALOG(dialog),
"response",
G_CALLBACK(on_dialog_response),
NULL);

draw_state->draw_partitions = true;

} else {
gtk_widget_destroy(GTK_WIDGET(dialog));
draw_state->draw_partitions = false;
}

//redraw
application.update_message(draw_state->default_message);
application.refresh_drawing();
}

static void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/) {
t_draw_state* draw_state = get_draw_state_vars();

Expand Down
Loading