From b8b6ca889980514aa76ecab5656bf10d8eaf05a5 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Mon, 18 Mar 2019 21:20:52 -0700 Subject: [PATCH] show selection and neighbors #1832 Add "show selection and neighbors" to bubble plot and 3D plot --- Explore/3DPlotView.cpp | 27 +++++++-------------------- Explore/3DPlotView.h | 4 ++-- Explore/MapNewView.cpp | 23 ++++++++++------------- Explore/ScatterNewPlotView.cpp | 10 +++++++--- TemplateCanvas.cpp | 26 +++++++++++++------------- 5 files changed, 39 insertions(+), 51 deletions(-) diff --git a/Explore/3DPlotView.cpp b/Explore/3DPlotView.cpp index 7494d171e..44f053c27 100644 --- a/Explore/3DPlotView.cpp +++ b/Explore/3DPlotView.cpp @@ -65,7 +65,7 @@ scaled_d(v_info.size()), c3d_plot_frame(t_frame) { wxLogMessage("Open C3DPlotCanvas."); - + hs = highlight_state->GetHighlight(); m_context = new wxGLContext(this); selectable_fill_color = GdaConst::three_d_plot_default_point_colour; highlight_color = GdaConst::three_d_plot_default_highlight_colour; @@ -463,8 +463,9 @@ void C3DPlotCanvas::UpdateSelect() if (selection_changed) { highlight_state->SetEventType(HLStateInt::delta); - highlight_state->notifyObservers(); + highlight_state->notifyObservers(this); } + this->hs = hs; // update local hs for rendering } void C3DPlotCanvas::SelectByRect() @@ -579,8 +580,9 @@ void C3DPlotCanvas::SelectByRect() } if (selection_changed) { highlight_state->SetEventType(HLStateInt::delta); - highlight_state->notifyObservers(); + highlight_state->notifyObservers(this); } + this->hs = hs; // update local hs for rendering } void C3DPlotCanvas::InitGL(void) @@ -645,8 +647,6 @@ void C3DPlotCanvas::SetCanvasBackgroundColor(wxColour color) void C3DPlotCanvas::RenderScene() { - std::vector& hs = highlight_state->GetHighlight(); - int xt = var_info[0].time; int yt = var_info[1].time; int zt = var_info[2].time; @@ -986,9 +986,6 @@ void C3DPlotCanvas::TimeChange() } } SetCurrentTmStep(ref_time - ref_time_min); - - //invalidateBms(); - //PopulateCanvas(); Refresh(); } @@ -1016,8 +1013,6 @@ void C3DPlotCanvas::VarInfoAttributeChange() num_time_vals = (var_info[ref_var_index].time_max - var_info[ref_var_index].time_min) + 1; } - - //GdaVarTools::PrintVarInfoVector(var_info); } void C3DPlotCanvas::UpdateScaledData() @@ -1062,16 +1057,8 @@ void C3DPlotCanvas::TimeSyncVariableToggle(int var_index) that its state has changed. */ void C3DPlotCanvas::update(HLStateInt* o) { - HLStateInt::EventType type = highlight_state->GetEventType(); - if (type == HLStateInt::delta) { - - Refresh(); - } else { - // type == HLStateInt::unhighlight_all - // type == HLStateInt::invert - - Refresh(); - } + hs = highlight_state->GetHighlight(); + Refresh(); } diff --git a/Explore/3DPlotView.h b/Explore/3DPlotView.h index 5fa1c2d1e..625a6a813 100644 --- a/Explore/3DPlotView.h +++ b/Explore/3DPlotView.h @@ -72,7 +72,7 @@ class C3DPlotCanvas: public wxGLCanvas, public HighlightStateObserver void UpdateSelect(); void SelectByRect(); void InitGL(void); - + bool isInit; float m_ClearColorBlue; @@ -122,7 +122,7 @@ class C3DPlotCanvas: public wxGLCanvas, public HighlightStateObserver std::vector data; std::vector data_undef; std::vector all_undefs; - + std::vector hs; std::vector scaled_d; std::vector< std::vector > data_stats; std::vector var_min; // min over time diff --git a/Explore/MapNewView.cpp b/Explore/MapNewView.cpp index 676dece75..1d2ce461b 100644 --- a/Explore/MapNewView.cpp +++ b/Explore/MapNewView.cpp @@ -412,18 +412,15 @@ void MapCanvas::DetermineMouseHoverObjects(wxPoint pointsel) if (layer0_bm && display_neighbors && sel1.x==0 && sel1.y==0 && sel2.x==0 && sel2.y==0) { vector& hs = GetSelBitVec(); - if (hover_obs.empty()) { - //highlight_state->SetTotalHighlighted(0); - } else { + if (hover_obs.empty() == false) { for (int i=0; iSetTotalHighlighted(1); } - HighlightState& h_state = *project->GetHighlightState(); - h_state.SetEventType(HLStateInt::delta); - h_state.notifyObservers(); + //highlight_state->SetEventType(HLStateInt::delta); + //highlight_timer->Start(50); layer1_valid = false; DrawLayers(); } @@ -455,8 +452,8 @@ vector MapCanvas::AddNeighborsToSelection(GalWeight* gal_weights, wxMemory int ts = cat_data.GetCurrentCanvasTmStep(); int num_obs = project->GetNumRecords(); - HighlightState& hs = *project->GetHighlightState(); - std::vector& h = hs.GetHighlight(); + //HighlightState& hs = *project->GetHighlightState(); + std::vector& h = highlight_state->GetHighlight(); std::vector add_elem(gal_weights->num_obs, false); std::set::iterator it; ids_of_nbrs.clear(); @@ -535,8 +532,7 @@ void MapCanvas::OnSize(wxSizeEvent& event) { if (!ids_of_nbrs.empty() && (display_neighbors || display_weights_graph)) { // in case of display neighbors and weights graph, to prevent adding nbrs again when resizing window - HighlightState& hs = *project->GetHighlightState(); - std::vector& h = hs.GetHighlight(); + std::vector& h = highlight_state->GetHighlight(); for (int i=0; iStop(); + highlight_timer->Stop(); // make linking start immediately std::vector old_hs = hs; - hs = new_hs; + hs = new_hs; // set highlights to "current+neighbors" highlight_state->SetEventType(HLStateInt::delta); highlight_state->notifyObservers(this); - hs = old_hs; + hs = old_hs; // reset highlights to "current" } } @@ -2901,6 +2897,7 @@ void MapCanvas::update(HLStateInt* o) if (draw_sel_shps_by_z_val) { // force a full redraw layer0_valid = false; + DrawLayers(); return; } diff --git a/Explore/ScatterNewPlotView.cpp b/Explore/ScatterNewPlotView.cpp index 8fac4c466..bc6076835 100644 --- a/Explore/ScatterNewPlotView.cpp +++ b/Explore/ScatterNewPlotView.cpp @@ -79,13 +79,16 @@ BubbleSizeSliderDlg::BubbleSizeSliderDlg (ScatterNewPlotCanvas* _canvas, wxALIGN_CENTER_VERTICAL|wxALL); boxSizer->Add(subSizer); - resetBtn = new wxButton(this, XRCID("ID_RESET"), _("Reset"), wxDefaultPosition, wxSize(100, -1)); + resetBtn = new wxButton(this, XRCID("ID_RESET"), _("Reset"), + wxDefaultPosition, wxSize(100, -1)); topSizer->Add(resetBtn, 0, wxGROW|wxALL, 5); topSizer->Fit(this); - Connect(XRCID("ID_BUBBLE_SLIDER"), wxEVT_SLIDER, wxScrollEventHandler(BubbleSizeSliderDlg::OnSliderChange)); - Connect(XRCID("ID_RESET"), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BubbleSizeSliderDlg::OnReset)); + Connect(XRCID("ID_BUBBLE_SLIDER"), wxEVT_SLIDER, + wxScrollEventHandler(BubbleSizeSliderDlg::OnSliderChange)); + Connect(XRCID("ID_RESET"), wxEVT_COMMAND_BUTTON_CLICKED, + wxCommandEventHandler(BubbleSizeSliderDlg::OnReset)); } void BubbleSizeSliderDlg::OnReset(wxCommandEvent& event ) @@ -95,6 +98,7 @@ void BubbleSizeSliderDlg::OnReset(wxCommandEvent& event ) slider->SetValue(0); canvas->UpdateBubbleSize(1); } + void BubbleSizeSliderDlg::OnSliderChange( wxScrollEvent & event ) { wxLogMessage("In BubbleSizeSliderDlg::OnSliderChange()"); diff --git a/TemplateCanvas.cpp b/TemplateCanvas.cpp index 50c2a9129..65f41fb52 100644 --- a/TemplateCanvas.cpp +++ b/TemplateCanvas.cpp @@ -580,19 +580,19 @@ void TemplateCanvas::update(HLStateInt* o) if (draw_sel_shps_by_z_val) { // force a full redraw - layer0_valid = false; - return; - } - - HLStateInt::EventType type = o->GetEventType(); - if (type == HLStateInt::transparency) { - ResetFadedLayer(); + layer0_valid = false; + DrawLayers(); + } else { + HLStateInt::EventType type = o->GetEventType(); + if (type == HLStateInt::transparency) { + ResetFadedLayer(); + } + // re-paint highlight layer (layer1_bm) + layer1_valid = false; + DrawLayers(); + + UpdateStatusBar(); } - // re-paint highlight layer (layer1_bm) - layer1_valid = false; - DrawLayers(); - - UpdateStatusBar(); } } @@ -2328,7 +2328,7 @@ void TemplateCanvas::SelectAllInCategory(int category, if ( selection_changed ) { highlight_state->SetEventType(HLStateInt::delta); - highlight_state->notifyObservers(); + highlight_state->notifyObservers(this); } }