Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
In Multivariate Local Geary's C Cluster Map, one cannot select multiple time points from a single group.
  • Loading branch information
lixun910 committed Jan 15, 2019
1 parent cec4cfd commit 84217a9
Show file tree
Hide file tree
Showing 8 changed files with 439 additions and 341 deletions.
6 changes: 6 additions & 0 deletions BuildTools/macosx/GeoDa.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
A10EF2F021273E7E00564FE1 /* AbstractCanvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A10EF2EE21273E7E00564FE1 /* AbstractCanvas.cpp */; };
A11B85BC1B18DC9C008B64EA /* Basemap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A11B85BB1B18DC9C008B64EA /* Basemap.cpp */; };
A11EF98E21ED569A00B77413 /* MultiVarSettingsDlg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A11EF98D21ED569A00B77413 /* MultiVarSettingsDlg.cpp */; };
A11F1B7F184FDFB3006F5F98 /* OGRColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A11F1B7D184FDFB3006F5F98 /* OGRColumn.cpp */; };
A11F1B821850437A006F5F98 /* OGRTableOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A11F1B801850437A006F5F98 /* OGRTableOperation.cpp */; };
A1230E5E212DF54D002AB30A /* switch-on.png in Resources */ = {isa = PBXBuildFile; fileRef = A1230E5C212DF54C002AB30A /* switch-on.png */; };
Expand Down Expand Up @@ -318,6 +319,8 @@
A10EF2EF21273E7E00564FE1 /* AbstractCanvas.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AbstractCanvas.hpp; sourceTree = "<group>"; };
A11B85BA1B18DC89008B64EA /* Basemap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Basemap.h; sourceTree = "<group>"; };
A11B85BB1B18DC9C008B64EA /* Basemap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Basemap.cpp; sourceTree = "<group>"; };
A11EF98C21ED569A00B77413 /* MultiVarSettingsDlg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MultiVarSettingsDlg.h; sourceTree = "<group>"; };
A11EF98D21ED569A00B77413 /* MultiVarSettingsDlg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MultiVarSettingsDlg.cpp; sourceTree = "<group>"; };
A11F1B7D184FDFB3006F5F98 /* OGRColumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OGRColumn.cpp; path = DataViewer/OGRColumn.cpp; sourceTree = "<group>"; };
A11F1B7E184FDFB3006F5F98 /* OGRColumn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OGRColumn.h; path = DataViewer/OGRColumn.h; sourceTree = "<group>"; };
A11F1B801850437A006F5F98 /* OGRTableOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OGRTableOperation.cpp; path = DataViewer/OGRTableOperation.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1225,6 +1228,8 @@
DD7974FE0F1D296F00496A84 /* DialogTools */ = {
isa = PBXGroup;
children = (
A11EF98D21ED569A00B77413 /* MultiVarSettingsDlg.cpp */,
A11EF98C21ED569A00B77413 /* MultiVarSettingsDlg.h */,
A4ED7D59209A6B81008685D6 /* HDBScanDlg.cpp */,
A4ED7D5A209A6B81008685D6 /* HDBScanDlg.h */,
A40A6A7D20226B3B003CDD79 /* PreferenceDlg.cpp */,
Expand Down Expand Up @@ -1761,6 +1766,7 @@
A4ED7D442097EC55008685D6 /* ANN.cpp in Sources */,
A1C9F3ED18B55EE000E14394 /* FieldNameCorrectionDlg.cpp in Sources */,
A43D31581E845C3D007488D9 /* LocalGearyMapNewView.cpp in Sources */,
A11EF98E21ED569A00B77413 /* MultiVarSettingsDlg.cpp in Sources */,
DD7975920F1D296F00496A84 /* SaveSelectionDlg.cpp in Sources */,
A194839D2118BAAA009A87A2 /* drawn.cpp in Sources */,
DD7975980F1D296F00496A84 /* VariableSettingsDlg.cpp in Sources */,
Expand Down
89 changes: 59 additions & 30 deletions DialogTools/AbstractClusterDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@
#include "AbstractClusterDlg.h"


AbstractClusterDlg::AbstractClusterDlg(wxFrame* parent_s, Project* project_s, wxString title)
: frames_manager(project_s->GetFramesManager()), table_state(project_s->GetTableState()),
wxDialog(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),
AbstractClusterDlg::AbstractClusterDlg(wxFrame* parent_s, Project* project_s,
wxString title)
: frames_manager(project_s->GetFramesManager()),
table_state(project_s->GetTableState()),
wxDialog(NULL, wxID_ANY, title, wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER),
validator(wxFILTER_INCLUDE_CHAR_LIST),
input_data(NULL), mask(NULL), weight(NULL), m_use_centroids(NULL),
m_weight_centroids(NULL), m_wc_txt(NULL), chk_floor(NULL),
Expand Down Expand Up @@ -208,44 +211,55 @@ bool AbstractClusterDlg::CheckConnectivity(GalWeight* gw)
return true;
}

void AbstractClusterDlg::AddSimpleInputCtrls(wxPanel *panel, wxBoxSizer* vbox, bool integer_only)
void AbstractClusterDlg::AddSimpleInputCtrls(wxPanel *panel, wxBoxSizer* vbox,
bool integer_only)
{
wxStaticText* st = new wxStaticText (panel, wxID_ANY, _("Select Variables"),
wxDefaultPosition, wxDefaultSize);

combo_var = new wxListBox(panel, wxID_ANY, wxDefaultPosition, wxSize(250,250), 0, NULL,
wxLB_MULTIPLE | wxLB_HSCROLL| wxLB_NEEDED_SB);
combo_var = new wxListBox(panel, wxID_ANY, wxDefaultPosition,
wxSize(250,250), 0, NULL,
wxLB_MULTIPLE | wxLB_HSCROLL| wxLB_NEEDED_SB);
InitVariableCombobox(combo_var, integer_only);

wxStaticBoxSizer *hbox0 = new wxStaticBoxSizer(wxVERTICAL, panel, _("Input:"));
wxStaticBoxSizer *hbox0 = new wxStaticBoxSizer(wxVERTICAL, panel,
_("Input:"));
hbox0->Add(st, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 10);
hbox0->Add(combo_var, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);

vbox->Add(hbox0, 1, wxEXPAND | wxTOP | wxLEFT, 10);
}

void AbstractClusterDlg::AddInputCtrls(wxPanel *panel, wxBoxSizer* vbox, bool show_auto_button)
void AbstractClusterDlg::AddInputCtrls(wxPanel *panel, wxBoxSizer* vbox,
bool show_auto_button)
{
wxStaticText* st = new wxStaticText (panel, wxID_ANY, _("Select Variables"),
wxDefaultPosition, wxDefaultSize);

combo_var = new wxListBox(panel, wxID_ANY, wxDefaultPosition, wxSize(250,250), 0, NULL,
wxLB_MULTIPLE | wxLB_HSCROLL| wxLB_NEEDED_SB);
combo_var = new wxListBox(panel, wxID_ANY, wxDefaultPosition,
wxSize(250,250), 0, NULL,
wxLB_MULTIPLE | wxLB_HSCROLL| wxLB_NEEDED_SB);
InitVariableCombobox(combo_var);

m_use_centroids = new wxCheckBox(panel, wxID_ANY, _("Use geometric centroids"));
m_use_centroids = new wxCheckBox(panel, wxID_ANY,
_("Use geometric centroids"));
auto_btn = new wxButton(panel, wxID_OK, _("Auto Weighting"));
auto_btn->Bind(wxEVT_BUTTON, &AbstractClusterDlg::OnAutoWeightCentroids, this);
auto_btn->Bind(wxEVT_BUTTON, &AbstractClusterDlg::OnAutoWeightCentroids,
this);
if (!show_auto_button) auto_btn->Hide();
wxBoxSizer *hbox_c = new wxBoxSizer(wxHORIZONTAL);
hbox_c->Add(m_use_centroids, 0);
hbox_c->Add(auto_btn, 0);

wxStaticText* st_wc = new wxStaticText (panel, wxID_ANY, _("Weighting:"), wxDefaultPosition, wxDefaultSize);
wxStaticText* st_wc = new wxStaticText (panel, wxID_ANY, _("Weighting:"),
wxDefaultPosition, wxDefaultSize);
wxStaticText* st_w0 = new wxStaticText (panel, wxID_ANY, "0");
wxStaticText* st_w1 = new wxStaticText (panel, wxID_ANY, "1");
m_weight_centroids = new wxSlider(panel, wxID_ANY, 100, 0, 100, wxDefaultPosition, wxSize(140, -1), wxSL_HORIZONTAL);
m_wc_txt = new wxTextCtrl(panel, wxID_ANY, "1", wxDefaultPosition, wxSize(40,-1), 0, validator);
m_weight_centroids = new wxSlider(panel, wxID_ANY, 100, 0, 100,
wxDefaultPosition, wxSize(140, -1),
wxSL_HORIZONTAL);
m_wc_txt = new wxTextCtrl(panel, wxID_ANY, "1", wxDefaultPosition,
wxSize(40,-1), 0, validator);
wxBoxSizer *hbox_w = new wxBoxSizer(wxHORIZONTAL);
hbox_w->Add(st_wc, 0, wxLEFT, 20);
hbox_w->Add(st_w0, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5);
Expand All @@ -254,7 +268,8 @@ void AbstractClusterDlg::AddInputCtrls(wxPanel *panel, wxBoxSizer* vbox, bool sh
hbox_w->Add(m_wc_txt, 0, wxALIGN_TOP|wxLEFT, 5);


wxStaticBoxSizer *hbox0 = new wxStaticBoxSizer(wxVERTICAL, panel, _("Input:"));
wxStaticBoxSizer *hbox0 = new wxStaticBoxSizer(wxVERTICAL, panel,
_("Input:"));
hbox0->Add(st, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 10);
hbox0->Add(combo_var, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);
hbox0->Add(hbox_c, 0, wxLEFT | wxRIGHT, 10);
Expand All @@ -268,8 +283,10 @@ void AbstractClusterDlg::AddInputCtrls(wxPanel *panel, wxBoxSizer* vbox, bool sh
m_weight_centroids->Disable();
m_wc_txt->Disable();
auto_btn->Disable();
m_use_centroids->Bind(wxEVT_CHECKBOX, &AbstractClusterDlg::OnUseCentroids, this);
m_weight_centroids->Bind(wxEVT_SLIDER, &AbstractClusterDlg::OnSlideWeight, this);
m_use_centroids->Bind(wxEVT_CHECKBOX,
&AbstractClusterDlg::OnUseCentroids, this);
m_weight_centroids->Bind(wxEVT_SLIDER,
&AbstractClusterDlg::OnSlideWeight, this);
m_wc_txt->Bind(wxEVT_TEXT, &AbstractClusterDlg::OnInputWeights, this);
}

Expand Down Expand Up @@ -481,8 +498,10 @@ void AbstractClusterDlg::AddMinBound(wxPanel *panel, wxFlexGridSizer* gbox,
hbox0->Add(txt_floor);

wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL);
slider_floor = new wxSlider(panel, wxID_ANY, 10, 0, 100, wxDefaultPosition, wxSize(150,-1), wxSL_HORIZONTAL);
txt_floor_pct = new wxTextCtrl(panel, wxID_ANY, "10%", wxDefaultPosition, wxSize(70,-1), 0, validator);
slider_floor = new wxSlider(panel, wxID_ANY, 10, 0, 100, wxDefaultPosition,
wxSize(150,-1), wxSL_HORIZONTAL);
txt_floor_pct = new wxTextCtrl(panel, wxID_ANY, "10%", wxDefaultPosition,
wxSize(70,-1), 0, validator);
hbox1->Add(slider_floor);
hbox1->Add(txt_floor_pct);

Expand Down Expand Up @@ -593,7 +612,8 @@ void AbstractClusterDlg::OnTypeMinBound(wxCommandEvent& event)
bool AbstractClusterDlg::CheckMinBound()
{
if (chk_floor->IsChecked()) {
if (combo_floor->GetSelection() < 0 || txt_floor->GetValue().Trim() == wxEmptyString) {
if ( combo_floor->GetSelection() < 0 ||
txt_floor->GetValue().Trim() == wxEmptyString) {
wxString err_msg = _("Please input minimum bound value.");
wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR);
dlg.ShowModal();
Expand All @@ -603,7 +623,8 @@ bool AbstractClusterDlg::CheckMinBound()
return true;
}

void AbstractClusterDlg::InitVariableCombobox(wxListBox* var_box, bool integer_only)
void AbstractClusterDlg::InitVariableCombobox(wxListBox* var_box,
bool integer_only)
{
combo_var->Clear();
var_items.Clear();
Expand All @@ -628,9 +649,9 @@ void AbstractClusterDlg::InitVariableCombobox(wxListBox* var_box, bool integer_o
var_items.Add(name);
}
}
if (!var_items.IsEmpty())
if (!var_items.IsEmpty()) {
var_box->InsertItems(var_items,0);

}
for (int i=0; i<select_vars.size(); i++) {
var_box->SetStringSelection(select_vars[i], true);
}
Expand Down Expand Up @@ -670,7 +691,9 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var)

int num_var = selections.size();
if (num_var < min_num_var && !use_centroids) {
wxString err_msg = wxString::Format(_("Please select at least %d variables."), min_num_var);
wxString err_msg =
wxString::Format(_("Please select at least %d variables."),
min_num_var);
wxMessageDialog dlg(NULL, err_msg, _("Info"), wxOK | wxICON_ERROR);
dlg.ShowModal();
return false;
Expand All @@ -680,7 +703,8 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var)
select_vars.clear();

if ((!use_centroids && num_var>0) ||
(use_centroids && m_weight_centroids && m_weight_centroids->GetValue() != 1))
(use_centroids && m_weight_centroids &&
m_weight_centroids->GetValue() != 1))
{
col_ids.resize(num_var);
var_info.resize(num_var);
Expand All @@ -693,7 +717,8 @@ bool AbstractClusterDlg::GetInputData(int transform, int min_num_var)
int col = table_int->FindColId(nm);
if (col == wxNOT_FOUND) {
wxString err_msg = wxString::Format(_("Variable %s is no longer in the Table. Please close and reopen this dialog to synchronize with Table data."), nm);
wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR);
wxMessageDialog dlg(NULL, err_msg, _("Error"),
wxOK | wxICON_ERROR);
dlg.ShowModal();
return false;
}
Expand Down Expand Up @@ -800,7 +825,8 @@ double* AbstractClusterDlg::GetWeights(int columns)
_weight[j] = 1;
}
if (m_weight_centroids && m_use_centroids) {
if (m_weight_centroids->GetValue() > 0 && m_use_centroids->IsChecked()) {
if ( m_weight_centroids->GetValue() > 0 &&
m_use_centroids->IsChecked()) {
double sel_wc = m_weight_centroids->GetValue();
wc = sel_wc / 100.0;
double n_var_cols = (double)(columns - 2);
Expand Down Expand Up @@ -864,7 +890,8 @@ wxNotebook* AbstractClusterDlg::AddSimpleReportCtrls(wxPanel *panel)
//
////////////////////////////////////////////////////////////////

double AbstractClusterDlg::CreateSummary(const vector<wxInt64>& clusters, bool show_print)
double AbstractClusterDlg::CreateSummary(const vector<wxInt64>& clusters,
bool show_print)
{
vector<vector<int> > solution;
vector<int> isolated;
Expand All @@ -880,7 +907,9 @@ double AbstractClusterDlg::CreateSummary(const vector<wxInt64>& clusters, bool s
return CreateSummary(solution, isolated, show_print);
}

double AbstractClusterDlg::CreateSummary(const vector<vector<int> >& solution, const vector<int>& isolated, bool show_print)
double AbstractClusterDlg::CreateSummary(const vector<vector<int> >& solution,
const vector<int>& isolated,
bool show_print)
{
// mean centers
vector<vector<double> > mean_centers = _getMeanCenters(solution);
Expand Down
Loading

0 comments on commit 84217a9

Please sign in to comment.