Skip to content

Commit

Permalink
Fix MST and order issue in HCluster (#2410)
Browse files Browse the repository at this point in the history
* fix MST; fix order in Hcluster result
* try to fix windows wxwidgets debug msg
* update boost 176
  • Loading branch information
lixun910 authored Mar 13, 2023
1 parent 5109e6b commit 0465201
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 113 deletions.
3 changes: 2 additions & 1 deletion BuildTools/macosx/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ echo $GEODA_HOME
CPUS=2

# Install boost 1.75
brew install boost
brew install [email protected]
ln -s /usr/local/opt/[email protected] /usr/local/opt/boost

# Install libgdal 3.6
brew install gdal
Expand Down
4 changes: 4 additions & 0 deletions BuildTools/macosx/install_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ def ProcessDependency(dir_path, dylib_name):
copyitem = '/usr/local/opt/icu4c/lib/libicuuc.70.dylib'
if item == '@loader_path/libicuuc.71.dylib':
copyitem = '/usr/local/opt/icu4c/lib/libicuuc.71.dylib'
if item == '@loader_path/libicuuc.72.dylib':
copyitem = '/usr/local/opt/icu4c/lib/libicuuc.72.dylib'
if item == '@loader_path/libicudata.70.dylib':
copyitem = '/usr/local/opt/icu4c/lib/libicudata.70.dylib'
if item == '@loader_path/libicudata.71.dylib':
copyitem = '/usr/local/opt/icu4c/lib/libicudata.71.dylib'
if item == '@loader_path/libicudata.72.dylib':
copyitem = '/usr/local/opt/icu4c/lib/libicudata.72.dylib'
if item == '@loader_path/libbrotlicommon.1.dylib':
copyitem = '/usr/local/opt/brotli/lib/libbrotlicommon.1.dylib'
if item == '@rpath/libIlmThread-3_1.30.dylib':
Expand Down
98 changes: 50 additions & 48 deletions DataViewer/TableFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,54 +281,56 @@ void TableFrame::DisplayPopupMenu( wxGridEvent& ev )

void TableFrame::SetEncodingCheckmarks(wxMenu* m, wxFontEncoding e)
{
m->FindItem(XRCID("ID_ENCODING_UTF8"))
->Check(e==wxFONTENCODING_UTF8);
m->FindItem(XRCID("ID_ENCODING_UTF16"))
->Check(e==wxFONTENCODING_UTF16LE);
m->FindItem(XRCID("ID_ENCODING_WINDOWS_1250"))
->Check(e==wxFONTENCODING_CP1250);
m->FindItem(XRCID("ID_ENCODING_WINDOWS_1251"))
->Check(e==wxFONTENCODING_CP1251);
m->FindItem(XRCID("ID_ENCODING_WINDOWS_1254"))
->Check(e==wxFONTENCODING_CP1254);
m->FindItem(XRCID("ID_ENCODING_WINDOWS_1255"))
->Check(e==wxFONTENCODING_CP1255);
m->FindItem(XRCID("ID_ENCODING_WINDOWS_1256"))
->Check(e==wxFONTENCODING_CP1256);
m->FindItem(XRCID("ID_ENCODING_WINDOWS_1258"))
->Check(e==wxFONTENCODING_CP1258);
m->FindItem(XRCID("ID_ENCODING_CP852"))
->Check(e==wxFONTENCODING_CP852);
m->FindItem(XRCID("ID_ENCODING_CP866"))
->Check(e==wxFONTENCODING_CP866);
m->FindItem(XRCID("ID_ENCODING_ISO_8859_1"))
->Check(e==wxFONTENCODING_ISO8859_1);
m->FindItem(XRCID("ID_ENCODING_ISO_8859_2"))
->Check(e==wxFONTENCODING_ISO8859_2);
m->FindItem(XRCID("ID_ENCODING_ISO_8859_3"))
->Check(e==wxFONTENCODING_ISO8859_3);
m->FindItem(XRCID("ID_ENCODING_ISO_8859_5"))
->Check(e==wxFONTENCODING_ISO8859_5);
m->FindItem(XRCID("ID_ENCODING_ISO_8859_7"))
->Check(e==wxFONTENCODING_ISO8859_7);
m->FindItem(XRCID("ID_ENCODING_ISO_8859_8"))
->Check(e==wxFONTENCODING_ISO8859_8);
m->FindItem(XRCID("ID_ENCODING_ISO_8859_9"))
->Check(e==wxFONTENCODING_ISO8859_9);
m->FindItem(XRCID("ID_ENCODING_ISO_8859_10"))
->Check(e==wxFONTENCODING_ISO8859_10);
m->FindItem(XRCID("ID_ENCODING_ISO_8859_15"))
->Check(e==wxFONTENCODING_ISO8859_15);
m->FindItem(XRCID("ID_ENCODING_GB2312"))
->Check(e==wxFONTENCODING_GB2312);
m->FindItem(XRCID("ID_ENCODING_BIG5"))
->Check(e==wxFONTENCODING_BIG5);
m->FindItem(XRCID("ID_ENCODING_KOI8_R"))
->Check(e==wxFONTENCODING_KOI8);
m->FindItem(XRCID("ID_ENCODING_SHIFT_JIS"))
->Check(e==wxFONTENCODING_SHIFT_JIS);
m->FindItem(XRCID("ID_ENCODING_EUC_JP"))->Check(e==wxFONTENCODING_EUC_JP);
m->FindItem(XRCID("ID_ENCODING_EUC_KR"))->Check(e==wxFONTENCODING_EUC_KR);
wxMenuItem* menu = m->FindItem(XRCID("ID_ENCODING_UTF8"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_UTF8);
menu = m->FindItem(XRCID("ID_ENCODING_UTF16"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_UTF16LE);
menu = m->FindItem(XRCID("ID_ENCODING_WINDOWS_1250"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_CP1250);
menu = m->FindItem(XRCID("ID_ENCODING_WINDOWS_1251"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_CP1251);
menu = m->FindItem(XRCID("ID_ENCODING_WINDOWS_1254"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_CP1254);
menu = m->FindItem(XRCID("ID_ENCODING_WINDOWS_1255"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_CP1255);
menu = m->FindItem(XRCID("ID_ENCODING_WINDOWS_1256"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_CP1256);
menu = m->FindItem(XRCID("ID_ENCODING_WINDOWS_1258"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_CP1258);
menu = m->FindItem(XRCID("ID_ENCODING_CP852"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_CP852);
menu = m->FindItem(XRCID("ID_ENCODING_CP866"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_CP866);
menu = m->FindItem(XRCID("ID_ENCODING_ISO_8859_1"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_ISO8859_1);
menu = m->FindItem(XRCID("ID_ENCODING_ISO_8859_2"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_ISO8859_2);
menu = m->FindItem(XRCID("ID_ENCODING_ISO_8859_3"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_ISO8859_3);
menu = m->FindItem(XRCID("ID_ENCODING_ISO_8859_5"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_ISO8859_5);
menu = m->FindItem(XRCID("ID_ENCODING_ISO_8859_7"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_ISO8859_7);
menu = m->FindItem(XRCID("ID_ENCODING_ISO_8859_8"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_ISO8859_8);
menu = m->FindItem(XRCID("ID_ENCODING_ISO_8859_9"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_ISO8859_9);
menu = m->FindItem(XRCID("ID_ENCODING_ISO_8859_10"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_ISO8859_10);
menu = m->FindItem(XRCID("ID_ENCODING_ISO_8859_15"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_ISO8859_15);
menu = m->FindItem(XRCID("ID_ENCODING_GB2312"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_GB2312);
menu = m->FindItem(XRCID("ID_ENCODING_BIG5"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_BIG5);
menu = m->FindItem(XRCID("ID_ENCODING_KOI8_R"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_KOI8);
menu = m->FindItem(XRCID("ID_ENCODING_SHIFT_JIS"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_SHIFT_JIS);
menu = m->FindItem(XRCID("ID_ENCODING_EUC_JP"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_EUC_JP);
menu = m->FindItem(XRCID("ID_ENCODING_EUC_KR"));
if (menu && menu->IsCheckable()) menu->Check(e==wxFONTENCODING_EUC_KR);
}

void TableFrame::OnRightClickEvent( wxGridEvent& ev )
Expand Down
9 changes: 2 additions & 7 deletions DialogTools/HClusterDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,6 @@ bool HClusterDlg::Run(vector<wxInt64>& clusters)
node2 = node2 < rows ? node2 : rows-node2-1;
node1 = node1 < rows ? node1 : rows-node1-1;

cout << i<< ":" << NN->node1 <<", " << NN->node2 << ", " << NN->dist <<endl;
//cout << i<< ":" << htree[i].left << ", " << htree[i].right << ", " << htree[i].distance <<endl;
htree[i].left = node1;
htree[i].right = node2;
htree[i].distance = Z2[i]->dist;
Expand Down Expand Up @@ -558,6 +556,8 @@ void HClusterDlg::OnOKClick(wxCommandEvent& event )

// draw dendrogram
m_panel->Setup(htree, rows, n_cluster, clusters, cutoffDistance);

OnClusterChoice(event);

saveButton->Enable();
}
Expand Down Expand Up @@ -685,7 +685,6 @@ void DendrogramPanel::OnEvent( wxMouseEvent& event )

split_line->move(pt, startPos);
int x = split_line->getX();
//std::cout << x << "," << pt.x << std::endl;
Refresh();
OnSplitLineChange(x);
startPos = pt;
Expand All @@ -702,7 +701,6 @@ void DendrogramPanel::OnEvent( wxMouseEvent& event )
select_box->Offset(event.GetPosition() - startPos);
} else {
select_box->SetBottomRight(event.GetPosition());
//std::cout <<select_box->width << select_box->height <<std::endl;
}
for (int i=0;i<end_nodes.size();i++) {
if (end_nodes[i]->intersects(*select_box)) {
Expand Down Expand Up @@ -867,9 +865,6 @@ void DendrogramPanel::OnSplitLineChange(int x)

if (all_nodes) nclusters = nelements;
if (cutoffDistance < minDistance) cutoffDistance = minDistance;

//std::cout << "x:" << x << ", cutoff:" << cutoffDistance << "nclusters:" << nclusters << std::endl;

if (nclusters > max_n_clusters) nclusters = max_n_clusters;

int* clusterid = new int[nelements];
Expand Down
2 changes: 1 addition & 1 deletion Explore/3DPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void C3DPlotCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
s << "Synchronize " << var_info[i].name << " with Time Control";
wxMenuItem* mi =
menu1->AppendCheckItem(GdaConst::ID_TIME_SYNC_VAR1+i, s, s);
mi->Check(var_info[i].sync_with_global_time);
if (mi && mi->IsCheckable()) mi->Check(var_info[i].sync_with_global_time);
}
}

Expand Down
8 changes: 4 additions & 4 deletions Explore/BoxNewPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ void BoxPlotCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
wxString s = wxString::Format(_("Synchronize %s with Time Control"), var_info[0].name);
wxMenuItem* mi =
menu1->AppendCheckItem(GdaConst::ID_TIME_SYNC_VAR1+0, s, s);
mi->Check(var_info[0].sync_with_global_time);
if (mi && mi->IsCheckable()) mi->Check(var_info[0].sync_with_global_time);
}

wxMenu* menu2 = new wxMenu(wxEmptyString);
{
wxString s= _("Fixed scale over time");
wxMenuItem* mi =
menu2->AppendCheckItem(GdaConst::ID_FIX_SCALE_OVER_TIME_VAR1, s, s);
mi->Check(var_info[0].fixed_scale);
if (mi && mi->IsCheckable()) mi->Check(var_info[0].fixed_scale);
}

wxMenu* menu3 = new wxMenu(wxEmptyString);
Expand All @@ -198,7 +198,7 @@ void BoxPlotCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
s << i+1;
wxMenuItem* mi =
menu3->AppendCheckItem(GdaConst::ID_PLOTS_PER_VIEW_1+i, s, s);
mi->Check(i+1 == cur_num_plots);
if (mi && mi->IsCheckable()) mi->Check(i+1 == cur_num_plots);
}
if (max_plots > 10) {
wxString s;
Expand All @@ -214,7 +214,7 @@ void BoxPlotCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
}
wxMenuItem* mi =
menu3->AppendCheckItem(GdaConst::ID_PLOTS_PER_VIEW_ALL, s, s);
mi->Check(cur_num_plots == max_plots);
if (mi && mi->IsCheckable()) mi->Check(cur_num_plots == max_plots);
}

menu->Prepend(wxID_ANY, _("Number of Box Plots"), menu3, _("Number of Box Plots"));
Expand Down
2 changes: 1 addition & 1 deletion Explore/CartogramNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void CartogramNewCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
s << "Synchronize " << var_info[i].name << " with Time Control";
wxMenuItem* mi =
menu1->AppendCheckItem(GdaConst::ID_TIME_SYNC_VAR1+i, s, s);
mi->Check(var_info[i].sync_with_global_time);
if (mi && mi->IsCheckable()) mi->Check(var_info[i].sync_with_global_time);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Explore/ConditionalNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void ConditionalNewCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
wxString s;
s << "Synchronize " << var_info[i].name << " with Time Control";
wxMenuItem* mi = menu1->AppendCheckItem(GdaConst::ID_TIME_SYNC_VAR1+i, s, s);
mi->Check(var_info[i].sync_with_global_time);
if (mi && mi->IsCheckable()) mi->Check(var_info[i].sync_with_global_time);
}
}
menu->AppendSeparator();
Expand Down
2 changes: 1 addition & 1 deletion Explore/HistogramView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void HistogramCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
s << "Synchronize " << var_info[0].name << " with Time Control";
wxMenuItem* mi =
menu1->AppendCheckItem(GdaConst::ID_TIME_SYNC_VAR1+0, s, s);
mi->Check(var_info[0].sync_with_global_time);
if (mi && mi->IsCheckable()) mi->Check(var_info[0].sync_with_global_time);
}
menu->AppendSeparator();
menu->Append(wxID_ANY, _("Time Variable Options"),
Expand Down
2 changes: 1 addition & 1 deletion Explore/LisaScatterPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void LisaScatterPlotCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
s = wxString::Format(s, var_info[i].name);
wxMenuItem* mi =
menu1->AppendCheckItem(GdaConst::ID_TIME_SYNC_VAR1+i, s, s);
mi->Check(var_info[i].sync_with_global_time);
if (mi && mi->IsCheckable()) mi->Check(var_info[i].sync_with_global_time);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Explore/MapLayerTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ void MapTree::OnRightClick(wxMouseEvent& event)

// check menu items
wxMenuItem* outline = popupMenu->FindItem(XRCID("MAPTREE_OUTLINE_VISIBLE"));
if (outline) {
if (outline && outline->IsCheckable()) {
outline->SetCheckable(true);
if (ml->GetPenSize() > 0) outline->Check();
}
Expand All @@ -861,7 +861,7 @@ void MapTree::OnRightClick(wxMouseEvent& event)
Connect(XRCID("MAPTREE_BOUNDARY_ONLY"), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(MapTree::OnShowMapBoundary));
wxMenuItem* boundary = popupMenu->FindItem(XRCID("MAPTREE_BOUNDARY_ONLY"));
if (boundary) {
if (boundary && boundary->IsCheckable()) {
boundary->SetCheckable(true);
if (ml->IsShowBoundary()) boundary->Check();
}
Expand Down
13 changes: 9 additions & 4 deletions Explore/MapNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ void MapCanvas::OnMSTMap(int menu_id)
display_mst = !display_mst;
if (display_mst) {
if (mst_map.Create(project) == false) {
wxString msg = _("Failed to create the Minimum Spanning Tree.");
wxMessageDialog dlg (this, msg, _("Information"),
wxOK | wxICON_INFORMATION);
dlg.ShowModal();
display_mst = false;
}
}
Expand Down Expand Up @@ -1453,7 +1457,7 @@ void MapCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
var_info[i].name);
wxMenuItem* mi;
mi = menu1->AppendCheckItem(GdaConst::ID_TIME_SYNC_VAR1+i, s, s);
mi->Check(var_info[i].sync_with_global_time);
if (mi && mi->IsCheckable()) mi->Check(var_info[i].sync_with_global_time);
}
}
menu->AppendSeparator();
Expand Down Expand Up @@ -3718,15 +3722,16 @@ void MapFrame::OnMapBasemap(wxCommandEvent& e)
items[j].name);
wxMenuItem* menu = popupMenu->FindItem(XRCID(xid));
if (current_item == items[j]) {
menu->Check(true);
if (menu && menu->IsCheckable()) menu->Check(true);
no_basemap = false;
} else {
menu->Check(false);
if (menu && menu->IsCheckable()) menu->Check(false);
}
}
}
if (no_basemap) {
popupMenu->FindItem(XRCID("ID_NO_BASEMAP"))->Check();
wxMenuItem* menu = popupMenu->FindItem(XRCID("ID_NO_BASEMAP"));
if (menu && menu->IsCheckable()) menu->Check();
}
PopupMenu(popupMenu, wxDefaultPosition);
}
Expand Down
6 changes: 0 additions & 6 deletions Explore/MapViewHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,6 @@ void MSTMapHelper::CreateDistMatrix(const std::vector<GdaPoint*>& points)

bool MSTMapHelper::Create(Project* project)
{
if (check_spatial_ref) {
bool cont = project->CheckSpatialProjection(check_spatial_ref);
if (cont == false) {
return false;
}
}
if (project == 0) return false;
if (mst_edges.empty() == false) return true; // already has a MST

Expand Down
2 changes: 1 addition & 1 deletion Explore/PCPNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void PCPCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
s << "Synchronize " << var_info[i].name << " with Time Control";
wxMenuItem* mi =
menu1->AppendCheckItem(GdaConst::ID_TIME_SYNC_VAR1+i, s, s);
mi->Check(var_info[i].sync_with_global_time);
if (mi && mi->IsCheckable()) mi->Check(var_info[i].sync_with_global_time);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Explore/ScatterNewPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void ScatterNewPlotCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
wxString s = _("Synchronize %s with Time Control");
s = wxString::Format(s, var_info[i].name);
wxMenuItem* mi = menu1->AppendCheckItem(GdaConst::ID_TIME_SYNC_VAR1+i, s, s);
mi->Check(var_info[i].sync_with_global_time);
if (mi && mi->IsCheckable()) mi->Check(var_info[i].sync_with_global_time);
}
}

Expand All @@ -364,13 +364,13 @@ void ScatterNewPlotCanvas::AddTimeVariantOptionsToMenu(wxMenu* menu)
wxString s = _("Fixed x-axis scale over time");
wxMenuItem* mi =
menu2->AppendCheckItem(GdaConst::ID_FIX_SCALE_OVER_TIME_VAR1, s, s);
mi->Check(var_info[0].fixed_scale);
if (mi && mi->IsCheckable()) mi->Check(var_info[0].fixed_scale);
}
if (var_info[1].is_time_variant) {
wxString s = _("Fixed y-axis scale over time");
wxMenuItem* mi =
menu2->AppendCheckItem(GdaConst::ID_FIX_SCALE_OVER_TIME_VAR2, s, s);
mi->Check(var_info[1].fixed_scale);
if (mi && mi->IsCheckable()) mi->Check(var_info[1].fixed_scale);
}

menu->Prepend(wxID_ANY, _("Scale Options"), menu2, _("Scale Options"));
Expand Down
Loading

0 comments on commit 0465201

Please sign in to comment.