Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
34 changes: 33 additions & 1 deletion src/view/src/rocprofvis_event_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "icons/rocprovfis_icon_defines.h"
#include "rocprofvis_event_manager.h"
#include "rocprofvis_settings_manager.h"
#include "rocprofvis_timeline_selection.h"
#include "rocprofvis_utils.h"
#include "spdlog/spdlog.h"
#include "widgets/rocprofvis_notification_manager.h"
Expand All @@ -22,7 +23,7 @@ constexpr const char* ID_COLUMN_NAME = "__uuid";
constexpr const char* EVENT_ID_COLUMN_NAME = "id";
constexpr const char* NAME_COLUMN_NAME = "name";

EventSearch::EventSearch(DataProvider& dp)
EventSearch::EventSearch(DataProvider& dp, std::shared_ptr<TimelineSelection> timeline_selection)
: InfiniteScrollTable(dp, TableType::kEventSearchTable)
, m_should_open(false)
, m_should_close(false)
Expand All @@ -32,6 +33,7 @@ EventSearch::EventSearch(DataProvider& dp)
, m_searched(false)
, m_width(1000.0f)
, m_text_input("\0")
, m_timeline_selection(timeline_selection)
{
m_widget_name = GenUniqueName("Event Search Table");
}
Expand Down Expand Up @@ -193,6 +195,10 @@ EventSearch::Clear()
m_text_input[0] = '\0';
m_searched = false;
m_should_close = true;
if(m_timeline_selection)
{
m_timeline_selection->ClearSearchHighlights();
}
}

void
Expand Down Expand Up @@ -306,6 +312,32 @@ EventSearch::RowSelected(const ImGuiMouseButton mouse_button)
{
SelectedRowNavigateEvent(m_important_column_idxs[kTrackId],
m_important_column_idxs[kStreamId]);

if(m_timeline_selection && m_selected_row >= 0)
{
const std::vector<std::vector<std::string>>& table_data =
m_data_provider.DataModel().GetTables().GetTableData(m_table_type);
if(m_selected_row < static_cast<int>(table_data.size()))
{
uint64_t uuid = INVALID_UINT64_INDEX;
uint64_t track_id = SelectedRowToTrackID(
m_important_column_idxs[kTrackId],
m_important_column_idxs[kStreamId]);
if(m_important_column_idxs[kUUId] != INVALID_UINT64_INDEX &&
m_important_column_idxs[kUUId] < table_data[m_selected_row].size())
{
uuid = std::stoull(
table_data[m_selected_row][m_important_column_idxs[kUUId]]);
}
if(uuid != INVALID_UINT64_INDEX && track_id != INVALID_UINT64_INDEX)
{
m_timeline_selection->UnselectAllEvents();
m_timeline_selection->ClearSearchHighlights();
m_timeline_selection->SearchHighlightEvent(track_id, uuid);
}
}
}

m_should_close = true;
}
else if(mouse_button == ImGuiMouseButton_Right)
Expand Down
7 changes: 6 additions & 1 deletion src/view/src/rocprofvis_event_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@

#include "imgui.h"
#include "widgets/rocprofvis_infinite_scroll_table.h"
#include <memory>
#include <vector>

namespace RocProfVis
{
namespace View
{

class TimelineSelection;

class EventSearch : public InfiniteScrollTable
{
public:
EventSearch(DataProvider& dp);
EventSearch(DataProvider& dp, std::shared_ptr<TimelineSelection> timeline_selection);
void Update() override;
void Render() override;

Expand Down Expand Up @@ -48,6 +51,8 @@ class EventSearch : public InfiniteScrollTable
float m_width;

char m_text_input[256];

std::shared_ptr<TimelineSelection> m_timeline_selection;
};

} // namespace View
Expand Down
47 changes: 47 additions & 0 deletions src/view/src/rocprofvis_flame_track_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ FlameTrackItem::ExtractPointsFromData()
const TraceEvent& event = events_data[i];
m_chart_items[i].event = event;
m_chart_items[i].selected = m_timeline_selection->EventSelected(event.m_id.uuid);
m_chart_items[i].search_highlighted = m_timeline_selection->EventSearchHighlighted(event.m_id.uuid);
if(m_chart_items[i].event.m_child_count > 1)
{
m_chart_items[i].name_hash =
Expand Down Expand Up @@ -294,6 +295,7 @@ FlameTrackItem::HandleTimelineSelectionChanged(std::shared_ptr<RocEvent> e)
for(ChartItem& item : m_chart_items)
{
item.selected = m_timeline_selection->EventSelected(item.event.m_id.uuid);
item.search_highlighted = m_timeline_selection->EventSearchHighlighted(item.event.m_id.uuid);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Search highlight state should be handled in a dedicated event

}
}
Expand Down Expand Up @@ -364,6 +366,11 @@ FlameTrackItem::DrawBox(ImVec2 start_position, int color_index, ChartItem& chart
if(ImGui::IsMouseClicked(ImGuiMouseButton_Right))
{
TimelineFocusManager::GetInstance().SetRightClickLayer(Layer::kGraphLayer);
m_timeline_selection->ClearSearchHighlights();
for(ChartItem& item : m_chart_items)
{
item.search_highlighted = false;
}
}

// Select on click
Expand All @@ -382,6 +389,11 @@ FlameTrackItem::DrawBox(ImVec2 start_position, int color_index, ChartItem& chart
true; // Ensure only one click is handled per render cycle
chart_item.selected = !chart_item.selected;

m_timeline_selection->ClearSearchHighlights();
for(ChartItem& item : m_chart_items)
{
item.search_highlighted = false;
}

//Control to multiselect
const ImGuiIO& io = ImGui::GetIO();
Expand Down Expand Up @@ -410,6 +422,10 @@ FlameTrackItem::DrawBox(ImVec2 start_position, int color_index, ChartItem& chart
{
m_selected_chart_items.push_back(chart_item);
}
if(chart_item.search_highlighted)
{
m_search_highlighted_chart_items.push_back(chart_item);
}
}

void
Expand Down Expand Up @@ -681,6 +697,37 @@ FlameTrackItem::RenderChart(float graph_width)
}

m_selected_chart_items.clear();

for(ChartItem& item : m_search_highlighted_chart_items)
{
ImVec2 container_pos = ImGui::GetWindowPos();
double normalized_start =
container_pos.x + m_tpt->RawTimeToPixel(item.event.m_start_ts);

double normalized_duration =
std::max(item.event.m_duration * m_tpt->GetPixelsPerNs(), 1.0);

ImVec2 start_position;
float rounding = 2.0f;
start_position = ImVec2(static_cast<float>(normalized_start),
Comment on lines +703 to +712
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract rendering logic into a RenderBoxFrame(frame_color) method and use for both selection and highlight

item.event.m_level * m_level_height);

ImVec2 cursor_position = ImGui::GetCursorScreenPos();
ImVec2 content_size = ImGui::GetContentRegionAvail();

ImVec2 rectMin = ImVec2(start_position.x - HIGHLIGHT_THICKNESS_HALF,
start_position.y + cursor_position.y +
HIGHLIGHT_THICKNESS_HALF - ANTI_ALIASING_WORKAROUND);
ImVec2 rectMax =
ImVec2(start_position.x + static_cast<float>(normalized_duration) +
HIGHLIGHT_THICKNESS_HALF,
start_position.y + m_level_height + cursor_position.y -
HIGHLIGHT_THICKNESS_HALF + ANTI_ALIASING_WORKAROUND);
draw_list->AddRect(rectMin, rectMax, m_settings.GetColor(Colors::kSearchHighlight),
rounding, 0, HIGHLIGHT_THICKNESS);
}

m_search_highlighted_chart_items.clear();
m_deferred_click_handled = false;

ImGui::EndChild();
Expand Down
2 changes: 2 additions & 0 deletions src/view/src/rocprofvis_flame_track_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class FlameTrackItem : public TrackItem
{
TraceEvent event;
bool selected;
bool search_highlighted;
size_t name_hash;
std::vector<ChildEventInfo> child_info;
};
Expand Down Expand Up @@ -109,6 +110,7 @@ class FlameTrackItem : public TrackItem
bool m_deferred_click_handled;
bool m_has_drawn_tool_tip;
std::vector<ChartItem> m_selected_chart_items;
std::vector<ChartItem> m_search_highlighted_chart_items;
EventManager::SubscriptionToken m_timeline_event_selection_changed_token;
ImVec2 m_tooltip_size;

Expand Down
2 changes: 2 additions & 0 deletions src/view/src/rocprofvis_settings_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ constexpr std::array DARK_THEME_COLORS = {
IM_COL32(52, 54, 58, 255), // kTableRowBg
IM_COL32(58, 60, 64, 255), // kTableRowBgAlt
IM_COL32(0, 200, 255, 160), // kEventHighlight
IM_COL32(255, 160, 40, 180), // kSearchHighlight
IM_COL32(235, 235, 240, 69), // kLineChartColor
IM_COL32(100, 100, 110, 255), // kButton
IM_COL32(130, 130, 140, 255), // kButtonHovered
Expand Down Expand Up @@ -127,6 +128,7 @@ constexpr std::array LIGHT_THEME_COLORS = {
IM_COL32(255, 253, 250, 255), // Colors::kTableRowBg
IM_COL32(252, 250, 248, 255), // Colors::kTableRowBgAlt
IM_COL32(0, 140, 200, 180), // Colors::kEventHighlight
IM_COL32(220, 130, 20, 200), // Colors::kSearchHighlight
IM_COL32(0, 0, 0, 69), // Colors::kLineChartColor
IM_COL32(230, 230, 230, 255), // Colors::kButton
IM_COL32(210, 210, 210, 255), // Colors::kButtonHovered
Expand Down
1 change: 1 addition & 0 deletions src/view/src/rocprofvis_settings_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ enum class Colors
kTableRowBg,
kTableRowBgAlt,
kEventHighlight,
kSearchHighlight,
kLineChartColor,
kButton,
kButtonHovered,
Expand Down
30 changes: 30 additions & 0 deletions src/view/src/rocprofvis_timeline_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,35 @@ TimelineSelection::HasSelectedEvents() const
return !m_selected_event_ids.empty();
}

void
TimelineSelection::SearchHighlightEvent(uint64_t track_id, uint64_t event_id)
{
m_search_highlighted_event_ids.clear();
m_search_highlighted_event_ids.insert(event_id);
SendEventSelectionChanged(event_id, track_id, true);
}
Comment on lines +214 to +216
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlight needs it own event(s). It should not piggy back off of event selection events. As is highlighting an event will clear / alter selection


void
TimelineSelection::ClearSearchHighlights()
{
if(!m_search_highlighted_event_ids.empty())
{
m_search_highlighted_event_ids.clear();
SendEventSelectionChanged(INVALID_SELECTION_ID, INVALID_SELECTION_ID, false, true);
}
}

bool
TimelineSelection::EventSearchHighlighted(uint64_t event_id) const
{
return m_search_highlighted_event_ids.count(event_id) > 0;
}

bool
TimelineSelection::HasSearchHighlightedEvents() const
{
return !m_search_highlighted_event_ids.empty();
}

} // namespace View
} // namespace RocProfVis
6 changes: 6 additions & 0 deletions src/view/src/rocprofvis_timeline_selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class TimelineSelection
bool HasSelectedEvents() const;
bool GetSelectedEventsTimeRange(double& start_ts_out, double& end_ts_out) const;

void SearchHighlightEvent(uint64_t track_id, uint64_t event_id);
void ClearSearchHighlights();
bool EventSearchHighlighted(uint64_t event_id) const;
bool HasSearchHighlightedEvents() const;

static constexpr double INVALID_SELECTION_TIME =
std::numeric_limits<double>::lowest();
static constexpr uint64_t INVALID_SELECTION_ID = std::numeric_limits<uint64_t>::max();
Expand All @@ -61,6 +66,7 @@ class TimelineSelection
double m_selected_range_end;

std::unordered_set<uint64_t> m_selected_event_ids;
std::unordered_set<uint64_t> m_search_highlighted_event_ids;
};

} // namespace View
Expand Down
2 changes: 1 addition & 1 deletion src/view/src/rocprofvis_trace_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ TraceView::CreateView()
m_track_topology = std::make_shared<TrackTopology>(m_data_provider);
m_timeline_view = std::make_shared<TimelineView>(m_data_provider,
m_timeline_selection, m_annotations);
m_event_search = std::make_shared<EventSearch>(m_data_provider);
m_event_search = std::make_shared<EventSearch>(m_data_provider, m_timeline_selection);
m_summary_view = std::make_shared<SummaryView>(m_data_provider);
m_minimap = std::make_shared<Minimap>(m_data_provider, m_timeline_view.get());
auto m_histogram_widget = std::make_shared<RocCustomWidget>(
Expand Down