Skip to content

Commit

Permalink
show selection and neighbors GeoDaCenter#1832
Browse files Browse the repository at this point in the history
Add "show selection and neighbors" to bubble plot and 3D plot
  • Loading branch information
lixun910 committed Mar 19, 2019
1 parent 031ff49 commit b8b6ca8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 51 deletions.
27 changes: 7 additions & 20 deletions Explore/3DPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -645,8 +647,6 @@ void C3DPlotCanvas::SetCanvasBackgroundColor(wxColour color)

void C3DPlotCanvas::RenderScene()
{
std::vector<bool>& hs = highlight_state->GetHighlight();

int xt = var_info[0].time;
int yt = var_info[1].time;
int zt = var_info[2].time;
Expand Down Expand Up @@ -986,9 +986,6 @@ void C3DPlotCanvas::TimeChange()
}
}
SetCurrentTmStep(ref_time - ref_time_min);

//invalidateBms();
//PopulateCanvas();
Refresh();
}

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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();
}


Expand Down
4 changes: 2 additions & 2 deletions Explore/3DPlotView.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class C3DPlotCanvas: public wxGLCanvas, public HighlightStateObserver
void UpdateSelect();
void SelectByRect();
void InitGL(void);

bool isInit;

float m_ClearColorBlue;
Expand Down Expand Up @@ -122,7 +122,7 @@ class C3DPlotCanvas: public wxGLCanvas, public HighlightStateObserver
std::vector<d_array_type> data;
std::vector<b_array_type> data_undef;
std::vector<bool> all_undefs;

std::vector<bool> hs;
std::vector<d_array_type> scaled_d;
std::vector< std::vector<SampleStatistics> > data_stats;
std::vector<double> var_min; // min over time
Expand Down
23 changes: 10 additions & 13 deletions Explore/MapNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>& hs = GetSelBitVec();
if (hover_obs.empty()) {
//highlight_state->SetTotalHighlighted(0);
} else {
if (hover_obs.empty() == false) {
for (int i=0; i<hs.size(); i++) {
hs[i] = false;
}
hs[hover_obs[0]] = true;
highlight_state->SetTotalHighlighted(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();
}
Expand Down Expand Up @@ -455,8 +452,8 @@ vector<bool> MapCanvas::AddNeighborsToSelection(GalWeight* gal_weights, wxMemory

int ts = cat_data.GetCurrentCanvasTmStep();
int num_obs = project->GetNumRecords();
HighlightState& hs = *project->GetHighlightState();
std::vector<bool>& h = hs.GetHighlight();
//HighlightState& hs = *project->GetHighlightState();
std::vector<bool>& h = highlight_state->GetHighlight();
std::vector<bool> add_elem(gal_weights->num_obs, false);
std::set<int>::iterator it;
ids_of_nbrs.clear();
Expand Down Expand Up @@ -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<bool>& h = hs.GetHighlight();
std::vector<bool>& h = highlight_state->GetHighlight();
for (int i=0; i<h.size(); i++) {
h[i] = false;
}
Expand Down Expand Up @@ -1213,12 +1209,12 @@ void MapCanvas::DrawHighlighted(wxMemoryDC &dc, bool revert)
}
}
if (is_updating == false && (show_graph || display_neighbors)) {
highlight_timer->Stop();
highlight_timer->Stop(); // make linking start immediately
std::vector<bool> 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"
}
}

Expand Down Expand Up @@ -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;
}

Expand Down
10 changes: 7 additions & 3 deletions Explore/ScatterNewPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -95,6 +98,7 @@ void BubbleSizeSliderDlg::OnReset(wxCommandEvent& event )
slider->SetValue(0);
canvas->UpdateBubbleSize(1);
}

void BubbleSizeSliderDlg::OnSliderChange( wxScrollEvent & event )
{
wxLogMessage("In BubbleSizeSliderDlg::OnSliderChange()");
Expand Down
26 changes: 13 additions & 13 deletions TemplateCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -2328,7 +2328,7 @@ void TemplateCanvas::SelectAllInCategory(int category,

if ( selection_changed ) {
highlight_state->SetEventType(HLStateInt::delta);
highlight_state->notifyObservers();
highlight_state->notifyObservers(this);
}
}

Expand Down

0 comments on commit b8b6ca8

Please sign in to comment.