Skip to content

Commit

Permalink
show selection and neighbors GeoDaCenter#1832
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Mar 9, 2019
1 parent 8b6f138 commit f15c045
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 25 deletions.
5 changes: 4 additions & 1 deletion Explore/CartogramNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,14 +686,17 @@ void CartogramNewCanvas::CreateAndUpdateCategories()
if (cat_classif_def.cat_classif_type != CatClassification::custom) {
CatClassification::ChangeNumCats(GetNumCats(), cat_classif_def);
}
bool useUndefinedCategory = true;
cat_classif_def.color_scheme =
CatClassification::GetColSchmForType(cat_classif_def.cat_classif_type);
CatClassification::PopulateCatClassifData(cat_classif_def,
cat_var_sorted,
var_undefs,
cat_data, map_valid,
map_error_message,
this->useScientificNotation);
this->useScientificNotation,
useUndefinedCategory,
this->category_disp_precision);
if (ref_var_index != -1) {
cat_data.SetCurrentCanvasTmStep(var_info[ref_var_index].time
- var_info[ref_var_index].time_min);
Expand Down
5 changes: 4 additions & 1 deletion Explore/ConditionalMapView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ void ConditionalMapCanvas::CreateAndUpdateCategories()
CatClassification::custom) {
CatClassification::ChangeNumCats(GetNumCats(), cat_classif_def_map);
}
bool useUndefinedCategory = true;
cat_classif_def_map.color_scheme =
CatClassification::GetColSchmForType(
cat_classif_def_map.cat_classif_type);
Expand All @@ -884,7 +885,9 @@ void ConditionalMapCanvas::CreateAndUpdateCategories()
cat_data,
map_valid,
map_error_message,
this->useScientificNotation);
this->useScientificNotation,
useUndefinedCategory,
this->category_disp_precision);
if (ref_var_index != -1) {
cat_data.SetCurrentCanvasTmStep(var_info[ref_var_index].time
- var_info[ref_var_index].time_min);
Expand Down
6 changes: 4 additions & 2 deletions Explore/ConditionalNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,8 @@ void ConditionalNewCanvas::CreateAndUpdateCategories(int var_id)
vert_cats_valid,
vert_cats_error_message,
this->useScientificNotation,
useUndefinedCategory);
useUndefinedCategory,
this->category_disp_precision);
else
CatClassification::PopulateCatClassifData(cat_classif_def_vert,
vert_str_var_sorted,
Expand All @@ -654,7 +655,8 @@ void ConditionalNewCanvas::CreateAndUpdateCategories(int var_id)
vert_cats_valid,
vert_cats_error_message,
this->useScientificNotation,
useUndefinedCategory);
useUndefinedCategory,
this->category_disp_precision);
int vt = var_info[var_id].time;
vert_num_cats = vert_cat_data.categories[vt].cat_vec.size();
CatClassification::ChangeNumCats(vert_num_cats, cat_classif_def_vert);
Expand Down
45 changes: 30 additions & 15 deletions Explore/MapNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ basemap_bm(0),
ref_var_index(-1),
tran_unhighlighted(GdaConst::transparency_unhighlighted),
print_detailed_basemap(false),
maplayer_state(project_s->GetMapLayerState())
maplayer_state(project_s->GetMapLayerState()),
is_updating(false)
{
wxLogMessage("MapCanvas::MapCanvas()");
is_hide = false;
Expand Down Expand Up @@ -445,10 +446,13 @@ void MapCanvas::UpdatePredefinedColor(const wxString& lbl, const wxColor& new_co
}
}

void MapCanvas::AddNeighborsToSelection(GalWeight* gal_weights, wxMemoryDC &dc)
vector<bool> MapCanvas::AddNeighborsToSelection(GalWeight* gal_weights, wxMemoryDC &dc)
{
vector<bool> new_hs(num_obs, false);

if (gal_weights == NULL)
return;
return new_hs;

int ts = cat_data.GetCurrentCanvasTmStep();
int num_obs = project->GetNumRecords();
HighlightState& hs = *project->GetHighlightState();
Expand All @@ -474,7 +478,6 @@ void MapCanvas::AddNeighborsToSelection(GalWeight* gal_weights, wxMemoryDC &dc)
}
}
if (dc.IsOk()) {
vector<bool> new_hs(num_obs, false);
for (it=ids_of_nbrs.begin(); it!= ids_of_nbrs.end(); it++) {
new_hs[*it] = true;
}
Expand Down Expand Up @@ -525,6 +528,7 @@ void MapCanvas::AddNeighborsToSelection(GalWeight* gal_weights, wxMemoryDC &dc)
}
}
}
return new_hs;
}

void MapCanvas::OnSize(wxSizeEvent& event)
Expand Down Expand Up @@ -1169,27 +1173,28 @@ void MapCanvas::DrawHighlighted(wxMemoryDC &dc, bool revert)
}
vector<bool>& hs = highlight_state->GetHighlight();
if (display_map_with_graph) {
if (use_category_brushes) {
bool highlight_only = true;
DrawSelectableShapes_dc(dc, highlight_only, revert,
GdaConst::use_cross_hatching);

} else {
for (int i=0, iend=selectable_shps.size(); i<iend; i++) {
if (hs[i] == !revert && _IsShpValid(i)) {
selectable_shps[i]->paintSelf(dc);
if (use_category_brushes) {
bool highlight_only = true;
DrawSelectableShapes_dc(dc, highlight_only, revert,
GdaConst::use_cross_hatching);

} else {
for (int i=0, iend=selectable_shps.size(); i<iend; i++) {
if (hs[i] == !revert && _IsShpValid(i)) {
selectable_shps[i]->paintSelf(dc);
}
}
}
}
}
// highlight connectivity objects and graphs
bool show_graph = display_weights_graph &&
boost::uuids::nil_uuid() != weights_id && !w_graph.empty();
std::vector<bool> new_hs;
if (display_map_with_graph && (show_graph || display_neighbors)) {
// draw neighbors of selection if needed
WeightsManInterface* w_man_int = project->GetWManInt();
GalWeight* gal_weights = w_man_int->GetGal(weights_id);
AddNeighborsToSelection(gal_weights, dc);
new_hs = AddNeighborsToSelection(gal_weights, dc);
}
if (show_graph) {
// draw connectivity graph if needed
Expand All @@ -1207,6 +1212,14 @@ void MapCanvas::DrawHighlighted(wxMemoryDC &dc, bool revert)
}
}
}
if (is_updating == false && (show_graph || display_neighbors)) {
highlight_timer->Stop();
std::vector<bool> old_hs = hs;
hs = new_hs;
highlight_state->SetEventType(HLStateInt::delta);
highlight_state->notifyObservers(this);
hs = old_hs;
}
}

void MapCanvas::SaveThumbnail()
Expand Down Expand Up @@ -2881,6 +2894,7 @@ void MapCanvas::SaveRates()

void MapCanvas::update(HLStateInt* o)
{
is_updating = true;
if (layer2_bm) {
ResetBrushing();

Expand All @@ -2902,6 +2916,7 @@ void MapCanvas::update(HLStateInt* o)

UpdateStatusBar();
}
is_updating = false;
}

void MapCanvas::UpdateStatusBar()
Expand Down
4 changes: 2 additions & 2 deletions Explore/MapNewView.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class MapCanvas : public TemplateCanvas, public CatClassifStateObserver,
void SetupColor();
void SetPredefinedColor(const wxString& lbl, const wxColor& new_color);
void UpdatePredefinedColor(const wxString& lbl, const wxColor& new_color);
void AddNeighborsToSelection(GalWeight* gal_weights, wxMemoryDC &dc);
vector<bool> AddNeighborsToSelection(GalWeight* gal_weights, wxMemoryDC &dc);
void SetLegendLabel(int cat, wxString label) {
cat_data.SetCategoryLabel(0, cat, label);
}
Expand Down Expand Up @@ -265,7 +265,7 @@ class MapCanvas : public TemplateCanvas, public CatClassifStateObserver,
list<GdaShape*> foreground_maps;

bool layerbase_valid; // if false, then needs to be redrawn

bool is_updating; // true: if triggered by other window
vector<GdaPolyLine*> w_graph;
IDataSource* p_datasource;
static bool has_thumbnail_saved;
Expand Down
5 changes: 4 additions & 1 deletion Explore/PCPNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,14 +770,17 @@ void PCPCanvas::CreateAndUpdateCategories()
if (cat_classif_def.cat_classif_type != CatClassification::custom) {
CatClassification::ChangeNumCats(GetNumCats(), cat_classif_def);
}
bool useUndefinedCategory = true;
cat_classif_def.color_scheme =
CatClassification::GetColSchmForType(cat_classif_def.cat_classif_type);
CatClassification::PopulateCatClassifData(cat_classif_def,
cat_var_sorted,
cat_var_undef,
cat_data, cats_valid,
cats_error_message,
this->useScientificNotation);
this->useScientificNotation,
useUndefinedCategory,
this->category_disp_precision);

if (ref_var_index != -1) {
cat_data.SetCurrentCanvasTmStep(var_info[ref_var_index].time
Expand Down
5 changes: 4 additions & 1 deletion Explore/ScatterNewPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,14 +1263,17 @@ void ScatterNewPlotCanvas::CreateAndUpdateCategories()
if (cat_classif_def.cat_classif_type != CatClassification::custom) {
CatClassification::ChangeNumCats(GetNumCats(), cat_classif_def);
}
bool useUndefinedCategory = true;
cat_classif_def.color_scheme =
CatClassification::GetColSchmForType(cat_classif_def.cat_classif_type);
CatClassification::PopulateCatClassifData(cat_classif_def,
cat_var_sorted,
cat_var_undef,
cat_data, cats_valid,
cats_error_message,
this->useScientificNotation);
this->useScientificNotation,
useUndefinedCategory,
this->category_disp_precision);

CreateZValArrays(num_time_vals, num_obs);
for (int t=0; t<num_time_vals; t++) {
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ namespace Gda {
const int version_major = 1;
const int version_minor = 12;
const int version_build = 1;
const int version_subbuild = 207;
const int version_subbuild = 209;
const int version_year = 2019;
const int version_month = 3;
const int version_day = 6;
const int version_day = 9;
const int version_night = 0;
const int version_type = 2; // 0: alpha, 1: beta, 2: release
}

0 comments on commit f15c045

Please sign in to comment.