MCPcopy Create free account
hub / github.com/GeoDaCenter/geoda / AddNeighborsToSelection

Method AddNeighborsToSelection

Project.cpp:1019–1063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1017}
1018
1019void Project::AddNeighborsToSelection(boost::uuids::uuid weights_id)
1020{
1021 wxLogMessage("Entering Project::AddNeighborsToSelection");
1022 if (!GetWManInt()) return;
1023 GalWeight* gal_weights = GetWManInt()->GetGal(weights_id);
1024 if (!gal_weights || !gal_weights->gal) {
1025 wxLogMessage("Warning: no current weight matrix found");
1026 return;
1027 }
1028
1029 // go through the list of all objects in current selection
1030 // for each selected object and add each of its neighbor to
1031 // the list so long as it isn't already selected.
1032
1033 HighlightState& hs = *highlight_state;
1034 std::vector<bool>& h = hs.GetHighlight();
1035 int nh_cnt = 0;
1036 std::vector<bool> add_elem(gal_weights->num_obs, false);
1037
1038 std::vector<int> new_highlight_ids;
1039
1040 for (int i=0; i<gal_weights->num_obs; i++) {
1041 if (h[i]) {
1042 GalElement& e = gal_weights->gal[i];
1043 for (int j=0, jend=e.Size(); j<jend; j++) {
1044 int obs = e[j];
1045 if (!h[obs] && !add_elem[obs]) {
1046 add_elem[obs] = true;
1047 new_highlight_ids.push_back(obs);
1048 }
1049 }
1050 }
1051 }
1052
1053 for (int i=0; i<(int)new_highlight_ids.size(); i++) {
1054 h[ new_highlight_ids[i] ] = true;
1055 nh_cnt ++;
1056 }
1057
1058 if (nh_cnt > 0) {
1059 hs.SetEventType(HLStateInt::delta);
1060 hs.notifyObservers();
1061 }
1062 wxLogMessage("Exiting Project::AddNeighborsToSelection");
1063}
1064
1065void Project::AddMeanCenters()
1066{

Callers 1

OnAddNeighsToSelClickMethod · 0.45

Calls 5

GetGalMethod · 0.80
SizeMethod · 0.45
sizeMethod · 0.45
SetEventTypeMethod · 0.45
notifyObserversMethod · 0.45

Tested by

no test coverage detected