Skip to content

Commit

Permalink
Merge pull request #427 from lixun910/master
Browse files Browse the repository at this point in the history
1.8.7 GeoDa with bug fixes
  • Loading branch information
lixun910 committed May 9, 2016
2 parents 45dd87d + 17d00df commit e379daa
Show file tree
Hide file tree
Showing 25 changed files with 1,798 additions and 1,800 deletions.
Binary file modified BuildTools/CommonDistFiles/cache.sqlite
Binary file not shown.
81 changes: 51 additions & 30 deletions DataViewer/TableBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,70 +155,91 @@ bool TableBase::FromGridIsSelectedRow(int row)
/** Only wxGrid should call this */
void TableBase::FromGridSelectOnlyRow(int row)
{
int total_newly_selected = 0;
int total_newly_unselected = 0;
int hl_size = highlight_state->GetHighlightSize();

std::vector<bool>& hs = highlight_state->GetHighlight();
std::vector<int>& nh = highlight_state->GetNewlyHighlighted();
std::vector<int>& nuh = highlight_state->GetNewlyUnhighlighted();
bool selection_changed = false;
for (int i=0; i<hl_size; i++) {
if (i != row_order[row]) {
if (hs[i]) nuh[total_newly_unselected++] = i;
if (hs[i]) {
hs[i] = false;
selection_changed = true;
}
} else {
if (!hs[i]) nh[total_newly_selected++] = i;
if (!hs[i]) {
hs[i] = true;
selection_changed = true;
}
}
}
highlight_state->SetEventType(HLStateInt::delta);
highlight_state->SetTotalNewlyHighlighted(total_newly_selected);
highlight_state->SetTotalNewlyUnhighlighted(total_newly_unselected);
highlight_state->notifyObservers();

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

/** Only wxGrid should call this */
void TableBase::FromGridSelectRowRange(int first_row, int last_row)
{
int total_newly_selected = 0;
int total_newly_unselected = 0;
int hl_size = highlight_state->GetHighlightSize();
std::vector<bool>& hs = highlight_state->GetHighlight();
std::vector<int>& nh = highlight_state->GetNewlyHighlighted();
std::vector<int>& nuh = highlight_state->GetNewlyUnhighlighted();
bool selection_changed = false;
for (int i=0; i<hl_size; ++i) {
if (i < first_row || i > last_row) {
if (hs[row_order[i]]) nuh[total_newly_unselected++] = row_order[i];
if (hs[row_order[i]]) {
hs[i] = false;
selection_changed = true;
}
} else {
if (!hs[row_order[i]]) nh[total_newly_selected++] = row_order[i];
if (!hs[row_order[i]]) {
hs[i] = true;
selection_changed = true;
}
}
}
highlight_state->SetEventType(HLStateInt::delta);
highlight_state->SetTotalNewlyHighlighted(total_newly_selected);
highlight_state->SetTotalNewlyUnhighlighted(total_newly_unselected);
highlight_state->notifyObservers();

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

/** Only wxGrid should call this, others should use Select(int row) */
void TableBase::FromGridSelectRow(int row)
{
//LOG_MSG(wxString::Format("selecting %d", (int) row_order[row]));
int hl_size = highlight_state->GetHighlightSize();
std::vector<bool>& hs = highlight_state->GetHighlight();

hs[ row_order[row] ] = true;
/*
for (int i=0; i<hl_size; ++i) {
if (i == row_order[row]) {
hs[i] = true;
} else {
hs[i] = false;
}
}
*/

highlight_state->SetEventType(HLStateInt::delta);
std::vector<int>& nhl = highlight_state->GetNewlyHighlighted();
nhl[0] = row_order[row];
//highlight_state->SetNewlyHighlighted(0, row_order[row]);
highlight_state->SetTotalNewlyHighlighted(1);
highlight_state->SetTotalNewlyUnhighlighted(0);
highlight_state->notifyObservers();
}

/** Only wxGrid should call this, others should use Deselect(int row) */
void TableBase::FromGridDeselectRow(int row)
{
//LOG_MSG(wxString::Format("deselecting %d", (int) row_order[row]));

int hl_size = highlight_state->GetHighlightSize();
std::vector<bool>& hs = highlight_state->GetHighlight();

hs[ row_order[row] ] = false;

highlight_state->SetEventType(HLStateInt::delta);
std::vector<int>& nuhl = highlight_state->GetNewlyUnhighlighted();
nuhl[0] = row_order[row];
//highlight_state->SetNewlyUnhighlighted(0, row_order[row]);
highlight_state->SetTotalNewlyHighlighted(0);
highlight_state->SetTotalNewlyUnhighlighted(1);
highlight_state->notifyObservers();
}

Expand Down
16 changes: 7 additions & 9 deletions DialogTools/CalculatorDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,22 +585,20 @@ void CalculatorDlg::AssignOrSelect(bool assign)

HighlightState& hs = *project->GetHighlightState();
std::vector<bool>& h = hs.GetHighlight();
std::vector<int>& nh = hs.GetNewlyHighlighted();
std::vector<int>& nuh = hs.GetNewlyUnhighlighted();
int nh_cnt = 0;
int nuh_cnt = 0;
int total_obs = h.size();
bool selection_changed = false;

for (size_t i=0; i<obs; i++) {
bool sel = selected[i];
if (sel && !h[i]) {
nh[nh_cnt++] = i;
h[i] = true;
selection_changed = true;
} else if (!sel && h[i]) {
nuh[nuh_cnt++] = i;
h[i] = false;
selection_changed = true;

}
}
hs.SetEventType(HLStateInt::delta);
hs.SetTotalNewlyHighlighted(nh_cnt);
hs.SetTotalNewlyUnhighlighted(nuh_cnt);
hs.notifyObservers();

wxString s;
Expand Down
48 changes: 22 additions & 26 deletions DialogTools/CatClassifDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ void CatClassifHistCanvas::UpdateSelection(bool shiftdown, bool pointsel)
bool rect_sel = (!pointsel && (brushtype == rectangle));

std::vector<bool>& hs = highlight_state->GetHighlight();
std::vector<int>& nh = highlight_state->GetNewlyHighlighted();
std::vector<int>& nuh = highlight_state->GetNewlyUnhighlighted();
int total_newly_selected = 0;
int total_newly_unselected = 0;
bool selection_changed = false;

int total_sel_shps = selectable_shps.size();

Expand Down Expand Up @@ -212,30 +209,33 @@ void CatClassifHistCanvas::UpdateSelection(bool shiftdown, bool pointsel)
// unselect all in ival
for (std::list<int>::iterator it=ival_to_obs_ids[i].begin();
it != ival_to_obs_ids[i].end(); it++) {
nuh[total_newly_unselected++] = (*it);
hs[(*it)] = false;
selection_changed = true;
}
} else if (!all_sel && selected) {
// select currently unselected in ival
for (std::list<int>::iterator it=ival_to_obs_ids[i].begin();
it != ival_to_obs_ids[i].end(); it++) {
if (hs[*it]) continue;
nh[total_newly_selected++] = (*it);
hs[(*it)] = true;
selection_changed = true;
}
} else if (!selected && !shiftdown) {
// unselect all selected in ival
for (std::list<int>::iterator it=ival_to_obs_ids[i].begin();
it != ival_to_obs_ids[i].end(); it++) {
if (!hs[*it]) continue;
nuh[total_newly_unselected++] = (*it);
hs[(*it)] = false;
selection_changed = true;
}
}
}

if (total_newly_selected > 0 || total_newly_unselected > 0) {
highlight_state->SetTotalNewlyHighlighted(total_newly_selected);
highlight_state->SetTotalNewlyUnhighlighted(total_newly_unselected);
NotifyObservables();

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

UpdateStatusBar();
}

Expand Down Expand Up @@ -268,10 +268,6 @@ void CatClassifHistCanvas::update(HLStateInt* o)
{
LOG_MSG("Entering CatClassifHistCanvas::update");

int total = highlight_state->GetTotalNewlyHighlighted();
std::vector<int>& nh = highlight_state->GetNewlyHighlighted();

HLStateInt::EventType type = highlight_state->GetEventType();
layer0_valid = false;
layer1_valid = false;
layer2_valid = false;
Expand Down Expand Up @@ -491,17 +487,17 @@ void CatClassifHistCanvas::UpdateIvalSelCnts()
ival_obs_sel_cnt[i] = 0;
}
} else if (type == HLStateInt::delta) {
std::vector<int>& nh = highlight_state->GetNewlyHighlighted();
std::vector<int>& nuh = highlight_state->GetNewlyUnhighlighted();
int nh_cnt = highlight_state->GetTotalNewlyHighlighted();
int nuh_cnt = highlight_state->GetTotalNewlyUnhighlighted();

for (int i=0; i<nh_cnt; i++) {
ival_obs_sel_cnt[obs_id_to_ival[nh[i]]]++;
}
for (int i=0; i<nuh_cnt; i++) {
ival_obs_sel_cnt[obs_id_to_ival[nuh[i]]]--;
std::vector<bool>& hs = highlight_state->GetHighlight();

for (int i=0; i<cur_intervals; i++) {
ival_obs_sel_cnt[i] = 0;
}

for (int i=0; i< (int)hs.size(); i++) {
if (hs[i]) {
ival_obs_sel_cnt[obs_id_to_ival[i]]++;
}
}
} else if (type == HLStateInt::invert) {
for (int i=0; i<cur_intervals; i++) {
ival_obs_sel_cnt[i] =
Expand Down
21 changes: 10 additions & 11 deletions DialogTools/DataMovieDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ void DataMovieDlg::ChangePosNum(int new_pos_num)
return;
}
std::vector<bool>& hs = highlight_state->GetHighlight();
std::vector<int>& nh = highlight_state->GetNewlyHighlighted();
std::vector<int>& nuh = highlight_state->GetNewlyUnhighlighted();
int total_newly_selected = 0;
int total_newly_unselected = 0;
bool selection_changed = false;

// the passed-in new_pos_num refers to the observations starting
// from 1 to num_obs, rather than 0 to num_obs-1.
Expand All @@ -207,25 +204,27 @@ void DataMovieDlg::ChangePosNum(int new_pos_num)
for (int i=0; i<num_obs; i++) {
int id = data_sorted[i].second;
if (i > pos && hs[id]) {
nuh[total_newly_unselected++] = id;
hs[id] = false;
selection_changed = true;
} else if (i <= pos && !hs[id]) {
nh[total_newly_selected++] = id;
hs[id] = true;
selection_changed = true;
}
}
} else {
for (int i=0; i<num_obs; i++) {
int id = data_sorted[i].second;
if (hs[id] && i != pos) {
nuh[total_newly_unselected++] = id;
hs[id] = false;
selection_changed = true;
} else if (i == pos && !hs[id]) {
nh[total_newly_selected++] = id;
hs[id] = true;
selection_changed = true;
}
}
}
if (total_newly_selected > 0 || total_newly_unselected > 0) {
if (selection_changed) {
highlight_state->SetEventType(HLStateInt::delta);
highlight_state->SetTotalNewlyHighlighted(total_newly_selected);
highlight_state->SetTotalNewlyUnhighlighted(total_newly_unselected);
highlight_state->notifyObservers();
}
Refresh();
Expand Down
Loading

0 comments on commit e379daa

Please sign in to comment.