From 89c27f4f2731018fe81f0f0b60fc3b7954de7f64 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Mon, 6 Feb 2017 14:11:37 -0600 Subject: [PATCH] #584 add conditional map to local cluster maps --- BuildTools/macosx/build-express.sh | 9 ++- DialogTools/ConnectDatasourceDlg.cpp | 4 +- DialogTools/DatasourceDlg.cpp | 10 ++- DialogTools/DatasourceDlg.h | 4 +- Explore/ConditionalClusterMapView.cpp | 104 ++++++++++++-------------- Explore/ConditionalClusterMapView.h | 33 ++++---- Explore/GetisOrdMapNewView.cpp | 6 +- Explore/LisaMapNewView.cpp | 4 +- 8 files changed, 93 insertions(+), 81 deletions(-) diff --git a/BuildTools/macosx/build-express.sh b/BuildTools/macosx/build-express.sh index f8040050c..dbc6bd7d2 100755 --- a/BuildTools/macosx/build-express.sh +++ b/BuildTools/macosx/build-express.sh @@ -125,10 +125,10 @@ fi ######################################################################### # install wxWidgets library ######################################################################### -LIB_NAME=wxWidgets-3.0.2 -LIB_URL=https://dl.dropboxusercontent.com/u/145979/geoda_libraries/wxWidgets-3.0.2.tar.bz2 +LIB_NAME=wxWidgets-3.1.0 +LIB_URL=https://dl.dropboxusercontent.com/u/145979/geoda_libraries/wxWidgets-3.1.0.tar.bz2 LIB_FILENAME=$(basename "$LIB_URL" ".tar") -LIB_CHECKER=libwx_baseu-3.0.a +LIB_CHECKER=libwx_baseu-3.1.a echo $LIB_FILENAME cd $DOWNLOAD_HOME @@ -144,7 +144,8 @@ if ! [ -f "$PREFIX/lib/$LIB_CHECKER" ] ; then cd $LIB_NAME cp -rf $GEODA_HOME/dep/$LIB_NAME/* . make clean - ./configure --with-cocoa --disable-shared --enable-mediactrl=no --disable-monolithic --with-opengl --enable-postscript --enable-textfile --without-liblzma --enable-webview --enable-compat28 --disable-mediactrl --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk --prefix=$PREFIX + ./configure --with-cocoa --disable-shared --enable-mediactrl=no --disable-monolithic --with-opengl --enable-postscript --enable-textfile --without-liblzma --enable-webview --enable-compat28 --disable-mediactrl -prefix=$PREFIX + #./configure CFLAGS="$GDA_CFLAGS" CXXFLAGS="$GDA_CXXFLAGS" LDFLAGS="$GDA_LDFLAGS" OBJCFLAGS="-arch x86_64" OBJCXXFLAGS="-arch x86_64" --with-cocoa --disable-shared --disable-monolithic --with-opengl --enable-postscript --enable-textfile --without-liblzma --enable-webview --enable-compat28 --prefix=$PREFIX $MAKER make install cd .. diff --git a/DialogTools/ConnectDatasourceDlg.cpp b/DialogTools/ConnectDatasourceDlg.cpp index a01a2c84b..9175c081a 100644 --- a/DialogTools/ConnectDatasourceDlg.cpp +++ b/DialogTools/ConnectDatasourceDlg.cpp @@ -375,6 +375,8 @@ BEGIN_EVENT_TABLE( ConnectDatasourceDlg, wxFrame ) //EVT_BUTTON(XRCID("ID_BTN_LOOKUP_WSLAYER"), ConnectDatasourceDlg::OnLookupWSLayerBtn) EVT_BUTTON(wxID_OK, ConnectDatasourceDlg::OnOkClick ) EVT_BUTTON(wxID_CANCEL, ConnectDatasourceDlg::OnCancelClick ) + EVT_BUTTON(wxID_EXIT, ConnectDatasourceDlg::OnCancelClick ) + EVT_MENU(wxID_EXIT, ConnectDatasourceDlg::OnCancelClick ) END_EVENT_TABLE() @@ -382,7 +384,7 @@ ConnectDatasourceDlg::ConnectDatasourceDlg(wxWindow* parent, const wxPoint& pos, const wxSize& size, bool showCsvConfigure_, bool showRecentPanel_) -:datasource(0), scrl(0), recent_panel(0), showCsvConfigure(showCsvConfigure_), +:DatasourceDlg(), datasource(0), scrl(0), recent_panel(0), showCsvConfigure(showCsvConfigure_), showRecentPanel(showRecentPanel_) { base_xrcid_recent_thumb = 7000; diff --git a/DialogTools/DatasourceDlg.cpp b/DialogTools/DatasourceDlg.cpp index f4177a453..1e463fc06 100644 --- a/DialogTools/DatasourceDlg.cpp +++ b/DialogTools/DatasourceDlg.cpp @@ -53,7 +53,7 @@ using namespace std; DatasourceDlg::DatasourceDlg() : is_ok_clicked(false), eventLoop(NULL) { - + Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(DatasourceDlg::OnExit) ); } DatasourceDlg::~DatasourceDlg() @@ -71,6 +71,9 @@ int DatasourceDlg::ShowModal() // mow to stop execution start a event loop eventLoop = new wxEventLoop; + if (eventLoop == NULL) + return wxID_CANCEL; + eventLoop->Run(); if (is_ok_clicked) @@ -90,6 +93,11 @@ void DatasourceDlg::OnCancelClick( wxCommandEvent& event ) EndDialog(); } +void DatasourceDlg::OnExit(wxCloseEvent& e) +{ + EndDialog(); +} + void DatasourceDlg::Init() { m_ds_menu = NULL; diff --git a/DialogTools/DatasourceDlg.h b/DialogTools/DatasourceDlg.h index 03beb397d..373052c48 100644 --- a/DialogTools/DatasourceDlg.h +++ b/DialogTools/DatasourceDlg.h @@ -49,7 +49,9 @@ class DatasourceDlg : public wxFrame DatasourceDlg(); virtual ~DatasourceDlg(); virtual void OnOkClick( wxCommandEvent& event ) = 0; - + + void OnExit(wxCloseEvent& e); + wxFileName ds_file_path; protected: diff --git a/Explore/ConditionalClusterMapView.cpp b/Explore/ConditionalClusterMapView.cpp index d7c7fbe04..4c55f7bec 100644 --- a/Explore/ConditionalClusterMapView.cpp +++ b/Explore/ConditionalClusterMapView.cpp @@ -61,6 +61,7 @@ ConditionalClusterMapCanvas(wxWindow *parent, Project* project_s, const vector& v_info, const vector& col_ids, + const wxString& ttl, const wxPoint& pos, const wxSize& size) : ConditionalNewCanvas(parent, t_frame, project_s, v_info, col_ids, true, true, pos, size), @@ -68,7 +69,8 @@ num_categories(1),bin_bm(0), bin_bg_map_pen(wxColor(200,200,200)), bin_bg_map_brush(wxColor(200,200,200)), cc_state_map(0), -full_map_redraw_needed(true) +full_map_redraw_needed(true), +title(ttl) { } @@ -117,7 +119,10 @@ void ConditionalClusterMapCanvas::DisplayRightClickMenu(const wxPoint& pos) wxMenu* optMenu = wxXmlResource::Get()-> LoadMenu("ID_COND_MAP_VIEW_MENU_OPTIONS"); - + + wxMenuItem* first_map_menu_item = optMenu->FindItemByPosition(0); + optMenu->Delete(first_map_menu_item); + AddTimeVariantOptionsToMenu(optMenu); TemplateCanvas::AppendCustomCategories(optMenu, project->GetCatClassifManager()); @@ -136,6 +141,21 @@ void ConditionalClusterMapCanvas::OnScrollChanged(wxScrollWinEvent& event) event.Skip(); } +wxString ConditionalClusterMapCanvas::GetCategoriesTitle() +{ + return title; +} + +wxString ConditionalClusterMapCanvas::GetCanvasTitle() +{ + wxString v; + v << "Conditional Map - "; + v << "x: " << GetNameWithTime(HOR_VAR); + v << ", y: " << GetNameWithTime(VERT_VAR); + v << ", " << title; + return v; +} + void ConditionalClusterMapCanvas::SetCheckMarks(wxMenu* menu) { @@ -746,8 +766,7 @@ ConditionalClusterMapFrame(wxFrame *parent, Project* project, LisaCoordinator* lisa_coord, const wxString& title, const wxPoint& pos, const wxSize& size, const long style) -: ConditionalNewFrame(parent, project, var_info, col_ids, title, pos, - size, style) +: ConditionalNewFrame(parent, project, var_info, col_ids, title, pos,size, style) { wxLogMessage("Open ConditionalNewFrame -- LISA."); @@ -762,10 +781,11 @@ ConditionalClusterMapFrame(wxFrame *parent, Project* project, wxPanel* rpanel = new wxPanel(splitter_win); template_canvas = new ConditionalLISAClusterMapCanvas(rpanel, this, project, - var_info, col_ids, - lisa_coord, - wxDefaultPosition, - wxDefaultSize); + var_info, col_ids, + lisa_coord, + title, + wxDefaultPosition, + wxDefaultSize); SetTitle(template_canvas->GetCanvasTitle()); template_canvas->SetScrollRate(1,1); wxBoxSizer* rbox = new wxBoxSizer(wxVERTICAL); @@ -796,6 +816,7 @@ ConditionalClusterMapFrame(wxFrame *parent, Project* project, const vector& var_info, const vector& col_ids, GStatCoordinator* g_coord, + bool is_gi, bool is_perm, const wxString& title, const wxPoint& pos, const wxSize& size, const long style) : ConditionalNewFrame(parent, project, var_info, col_ids, title, pos, @@ -814,10 +835,11 @@ ConditionalClusterMapFrame(wxFrame *parent, Project* project, wxPanel* rpanel = new wxPanel(splitter_win); template_canvas = new ConditionalGClusterMapCanvas(rpanel, this, project, - var_info, col_ids, - g_coord, - wxDefaultPosition, - wxDefaultSize); + var_info, col_ids, + g_coord, is_gi, is_perm, + title, + wxDefaultPosition, + wxDefaultSize); SetTitle(template_canvas->GetCanvasTitle()); template_canvas->SetScrollRate(1,1); wxBoxSizer* rbox = new wxBoxSizer(wxVERTICAL); @@ -864,10 +886,12 @@ void ConditionalClusterMapFrame::MapMenus() // Map Options Menus wxMenu* optMenu = wxXmlResource::Get()-> LoadMenu("ID_COND_MAP_VIEW_MENU_OPTIONS"); - ((ConditionalClusterMapCanvas*) template_canvas)-> - AddTimeVariantOptionsToMenu(optMenu); - TemplateCanvas::AppendCustomCategories(optMenu, - project->GetCatClassifManager()); + + wxMenuItem* first_map_menu_item = optMenu->FindItemByPosition(0); + optMenu->Delete(first_map_menu_item); + + ((ConditionalClusterMapCanvas*) template_canvas)->AddTimeVariantOptionsToMenu(optMenu); + TemplateCanvas::AppendCustomCategories(optMenu, project->GetCatClassifManager()); ((ConditionalClusterMapCanvas*) template_canvas)->SetCheckMarks(optMenu); GeneralWxUtils::ReplaceMenu(mb, "Options", optMenu); UpdateOptionMenuItems(); @@ -988,9 +1012,10 @@ ConditionalLISAClusterMapCanvas(wxWindow *parent, TemplateFrame* t_frame, const vector& var_info, const vector& col_ids, LisaCoordinator* lisa_coordinator, + const wxString& title, const wxPoint& pos, const wxSize& size) -: ConditionalClusterMapCanvas(parent, t_frame, project, var_info, col_ids, pos, size), +: ConditionalClusterMapCanvas(parent, t_frame, project, var_info, col_ids, title, pos, size), lisa_coord(lisa_coordinator) { Init(size); @@ -1001,23 +1026,6 @@ ConditionalLISAClusterMapCanvas::~ConditionalLISAClusterMapCanvas() } -wxString ConditionalLISAClusterMapCanvas::GetCategoriesTitle() -{ - wxString v; - v << "LISA Cluster Map: " << lisa_coord->var_info[0].name; - return v; -} - -wxString ConditionalLISAClusterMapCanvas::GetCanvasTitle() -{ - wxString v; - v << "Conditional Map - "; - v << "x: " << GetNameWithTime(HOR_VAR); - v << ", y: " << GetNameWithTime(VERT_VAR); - v << ", LISA:" << lisa_coord->var_info[0].name; - return v; -} - void ConditionalLISAClusterMapCanvas::CreateAndUpdateCategories() { cat_var_sorted.clear(); @@ -1218,10 +1226,13 @@ ConditionalGClusterMapCanvas(wxWindow *parent, TemplateFrame* t_frame, const vector& var_info, const vector& col_ids, GStatCoordinator* g_coordinator, + bool is_gi_, + bool is_perm_, + const wxString& title, const wxPoint& pos, const wxSize& size) -: ConditionalClusterMapCanvas(parent, t_frame, project, var_info, col_ids, pos, size), -g_coord(g_coordinator) +: ConditionalClusterMapCanvas(parent, t_frame, project, var_info, col_ids, title, pos, size), +g_coord(g_coordinator), is_gi(is_gi_), is_perm(is_perm_) { Init(size); } @@ -1231,23 +1242,6 @@ ConditionalGClusterMapCanvas::~ConditionalGClusterMapCanvas() } -wxString ConditionalGClusterMapCanvas::GetCategoriesTitle() -{ - wxString v; - v << "LISA Cluster Map: " << g_coord->var_info[0].name; - return v; -} - -wxString ConditionalGClusterMapCanvas::GetCanvasTitle() -{ - wxString v; - v << "Conditional Map - "; - v << "x: " << GetNameWithTime(HOR_VAR); - v << ", y: " << GetNameWithTime(VERT_VAR); - v << ", LISA:" << g_coord->var_info[0].name; - return v; -} - void ConditionalGClusterMapCanvas::CreateAndUpdateCategories() { cat_var_sorted.clear(); @@ -1271,8 +1265,6 @@ void ConditionalGClusterMapCanvas::CreateAndUpdateCategories() cat_var_sorted[t].resize(num_obs); cat_var_undef[t].resize(num_obs); vector cluster; - bool is_gi = false; - bool is_perm = false; g_coord->FillClusterCats(t, is_gi, is_perm, cluster); for (int i=0; i cluster; - bool is_gi = false; - bool is_perm = false; g_coord->FillClusterCats(t, is_gi, is_perm, cluster); for (int i=0, iend=g_coord->num_obs; i& var_info, const vector& col_ids, + const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); virtual ~ConditionalClusterMapCanvas(); - - virtual wxString GetCategoriesTitle() = 0; - virtual wxString GetCanvasTitle() = 0; virtual void CreateAndUpdateCategories() = 0; virtual void TimeSyncVariableToggle(int var_index) = 0; + + virtual wxString GetCategoriesTitle(); + virtual wxString GetCanvasTitle(); void Init(const wxSize& size); virtual void DisplayRightClickMenu(const wxPoint& pos); @@ -84,6 +85,7 @@ class ConditionalClusterMapCanvas : public ConditionalNewCanvas { virtual void UpdateStatusBar() = 0; virtual void PopulateCanvas(); + wxString title; CatClassifState* cc_state_map; int num_categories; // current number of categories vector cat_var_sorted; @@ -127,6 +129,7 @@ class ConditionalClusterMapFrame : public ConditionalNewFrame { const vector& var_info, const vector& col_ids, GStatCoordinator* g_coord, + bool is_gi, bool is_perm, const wxString& title = _("Conditional GetisOrd Map"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -159,7 +162,7 @@ class ConditionalClusterMapFrame : public ConditionalNewFrame { CatClassification::CatClassifType new_cat_theme, int num_categories, const wxString& custom_classif_title = wxEmptyString); - + DECLARE_EVENT_TABLE() }; @@ -178,13 +181,12 @@ class ConditionalLISAClusterMapCanvas : public ConditionalClusterMapCanvas { const vector& var_info, const vector& col_ids, LisaCoordinator* lisa_coordinator, + const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); virtual ~ConditionalLISAClusterMapCanvas(); - virtual wxString GetCategoriesTitle(); - virtual wxString GetCanvasTitle(); virtual void CreateAndUpdateCategories(); virtual void TimeSyncVariableToggle(int var_index); @@ -203,20 +205,23 @@ class ConditionalGClusterMapCanvas : public ConditionalClusterMapCanvas { public: ConditionalGClusterMapCanvas(wxWindow *parent, TemplateFrame* t_frame, - Project* project, - const vector& var_info, - const vector& col_ids, - GStatCoordinator* g_coordinator, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize); + Project* project, + const vector& var_info, + const vector& col_ids, + GStatCoordinator* g_coordinator, + bool is_gi, + bool is_perm, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize); virtual ~ConditionalGClusterMapCanvas(); - virtual wxString GetCategoriesTitle(); - virtual wxString GetCanvasTitle(); virtual void CreateAndUpdateCategories(); virtual void TimeSyncVariableToggle(int var_index); protected: + bool is_perm; + bool is_gi; GStatCoordinator* g_coord; virtual void UpdateStatusBar(); }; diff --git a/Explore/GetisOrdMapNewView.cpp b/Explore/GetisOrdMapNewView.cpp index bf5f328d7..4a10112e8 100644 --- a/Explore/GetisOrdMapNewView.cpp +++ b/Explore/GetisOrdMapNewView.cpp @@ -861,10 +861,12 @@ void GetisOrdMapFrame::OnShowAsConditionalMap(wxCommandEvent& event) return; } + GetisOrdMapCanvas* lc = (GetisOrdMapCanvas*) template_canvas; + wxString title = lc->GetCanvasTitle(); ConditionalClusterMapFrame* subframe = new ConditionalClusterMapFrame(this, project, - dlg.var_info, dlg.col_ids, gs_coord, - _("Conditional G Cluster Map"), wxDefaultPosition, + dlg.var_info, dlg.col_ids, gs_coord, is_gi, is_perm, + title, wxDefaultPosition, GdaConst::cond_view_default_size); } diff --git a/Explore/LisaMapNewView.cpp b/Explore/LisaMapNewView.cpp index 274a439a4..f9333cbdc 100644 --- a/Explore/LisaMapNewView.cpp +++ b/Explore/LisaMapNewView.cpp @@ -857,10 +857,12 @@ void LisaMapFrame::OnShowAsConditionalMap(wxCommandEvent& event) return; } + LisaMapCanvas* lc = (LisaMapCanvas*) template_canvas; + wxString title = lc->GetCanvasTitle(); ConditionalClusterMapFrame* subframe = new ConditionalClusterMapFrame(this, project, dlg.var_info, dlg.col_ids, lisa_coord, - _("Conditional LISA Map"), wxDefaultPosition, + title, wxDefaultPosition, GdaConst::cond_view_default_size); }