Ejemplo n.º 1
0
void RangeSelectionDlg::OnSelUndefClick( wxCommandEvent& event )
{
	HighlightState& hs = *project->GetHighlightState();
	std::vector<bool>& h = hs.GetHighlight();
    bool selection_changed = false;

	if (m_field_choice->GetSelection() == wxNOT_FOUND) return;
	int mcol = GetSelColInt();
	int f_tm = GetSelColTmInt();
	
	std::vector<bool> undefined;
	table_int->GetColUndefined(mcol, f_tm, undefined);
	for (int i=0, iend=h.size(); i<iend; i++) {
        if (undefined[i]) {
            if (!h[i]) {
                h[i] = true;
                selection_changed = true;
            }
        } else {
            if (h[i]) {
                h[i] = false;
                selection_changed = true;
            }
        }
	}
	if (selection_changed) {
		hs.SetEventType(HLStateInt::delta);
		hs.notifyObservers();
	}
	m_selection_made = true;
	CheckApplySaveSettings();
}
Ejemplo n.º 2
0
RangeSelectionDlg::RangeSelectionDlg(wxWindow* parent, Project* _project,
									 FramesManager* _frames_manager,
									 TableState* _table_state,
									 const wxString& title, const wxPoint& pos)
: project(_project), frames_manager(_frames_manager),
table_state(_table_state), table_int(_project->GetTableInt()),
w_man_int(project->GetWManInt()), w_man_state(project->GetWManState()),
current_sel_mcol(wxNOT_FOUND),
m_field_choice(0), m_min_text(0), m_field_static_txt(0), m_field2_static_txt(0),
m_max_text(0), m_sel_range_button(0), m_sel_undef_button(0),
m_invert_sel_button(0), m_random_sel_button(0), m_clear_sel_button(0),
m_num_to_rand_sel_txt(0),
m_add_neighs_to_sel_button(0), m_weights_choice(0),
m_save_field_choice(0), m_sel_check_box(0),
m_sel_val_text(0), m_unsel_check_box(0), m_unsel_val_text(0),
m_apply_save_button(0), all_init(false), m_selection_made(false)
{
	SetParent(parent);
	RefreshColIdMap();
    CreateControls();
	all_init = true;
	SetTitle(title);
    Centre();
	InitSelectionVars();
	InitSaveVars();
	CheckRangeButtonSettings();
	CheckApplySaveSettings();
	RefreshWeightsIds();
	
	frames_manager->registerObserver(this);
	table_state->registerObserver(this);
	w_man_state->registerObserver(this);
}
Ejemplo n.º 3
0
void SaveSelectionDlg::OnSaveFieldChoice( wxCommandEvent& event )
{
    wxLogMessage("Click SaveSelectionDlg::OnSaveFieldChoice");
    
	EnableTimeField();
	CheckApplySaveSettings();
}
Ejemplo n.º 4
0
void RangeSelectionDlg::OnInvertSelClick( wxCommandEvent& event )
{
	HighlightState& hs = *project->GetHighlightState();
	hs.SetEventType(HLStateInt::invert);
	hs.notifyObservers();
	m_selection_made = true;
	CheckApplySaveSettings();
}
Ejemplo n.º 5
0
void RangeSelectionDlg::update(TableState* o)
{
	LOG_MSG("In RangeSelectionDlg::update(TableState* o)");
	RefreshColIdMap();
	InitSelectionVars();
	InitSaveVars();
	CheckRangeButtonSettings();
	CheckApplySaveSettings();
	Refresh();
}
Ejemplo n.º 6
0
void RangeSelectionDlg::OnAddField( wxCommandEvent& event )
{	
	DataViewerAddColDlg dlg(project, this, true, true, "SELECT",GdaConst::long64_type);
	if (dlg.ShowModal() != wxID_OK) return;
	int col = dlg.GetColId();
	if (table_int->GetColType(col) != GdaConst::long64_type &&
		table_int->GetColType(col) != GdaConst::double_type) return;

	// DataViewerAddColDlg will result in TableState::notify being
	// called upon success, which means RangeSelectionDlg::update
	// will have been called by this execution point.
	
	int sel = m_save_field_choice->FindString(table_int->GetColName(col));
	if (sel != wxNOT_FOUND) m_save_field_choice->SetSelection(sel);
	
	InitSaveVars(); // call again in case selection changed
	CheckApplySaveSettings();
}
Ejemplo n.º 7
0
void SaveSelectionDlg::OnSaveFieldChoiceTm( wxCommandEvent& event )
{
	if (!is_space_time) return;
	
	int prev_col = -1;
	if (m_save_field_choice->GetSelection() != wxNOT_FOUND) {
		prev_col = col_id_map[m_save_field_choice->GetSelection()];
	}
	
	InitField();
	
	if (prev_col != -1) {
		for (int i=0; i<col_id_map.size(); i++) {
			if (prev_col == col_id_map[i]) {
				m_save_field_choice->SetSelection(i);
			}
		}
	}
	CheckApplySaveSettings();
}
Ejemplo n.º 8
0
void SaveSelectionDlg::OnAddField( wxCommandEvent& event )
{	
	DataViewerAddColDlg dlg(grid_base, this, false, true, "SELECT");
	if (dlg.ShowModal() != wxID_OK) return;
	int col = dlg.GetColId();
	if (grid_base->GetColType(col) != GeoDaConst::long64_type &&
		grid_base->GetColType(col) != GeoDaConst::double_type) return;

	FillColIdMap();
	InitField();
	
	for (int i=0; i<col_id_map.size(); i++) {
		if (col == col_id_map[i]) {
			m_save_field_choice->SetSelection(i);
		}
	}
	
	EnableTimeField();
	CheckApplySaveSettings();
}
Ejemplo n.º 9
0
void RangeSelectionDlg::OnSelUnselTextChange( wxCommandEvent& event )
{
	CheckApplySaveSettings();
}
Ejemplo n.º 10
0
void RangeSelectionDlg::OnUnselCheckBox( wxCommandEvent& event )
{
	CheckApplySaveSettings();
}
Ejemplo n.º 11
0
void RangeSelectionDlg::OnSaveFieldChoiceTm( wxCommandEvent& event )
{
	InitSaveVars();
	CheckApplySaveSettings();
}
Ejemplo n.º 12
0
void RangeSelectionDlg::OnSelRangeClick( wxCommandEvent& event )
{
	LOG_MSG("Entering RangeSelectionDlg::OnApplySelClick");
	HighlightState& hs = *project->GetHighlightState();
	std::vector<bool>& h = hs.GetHighlight();
    
    int n = table_int->GetNumberRows();
	int nh_cnt = 0;
	int nuh_cnt = 0;
	if (m_field_choice->GetSelection() == wxNOT_FOUND) return;
	int mcol = GetSelColInt();
	int f_tm = GetSelColTmInt();

    bool no_hl = true;
    bool new_select = m_radio_newselect->GetValue();
    bool sub_select = m_radio_subselect->GetValue();
    bool append_select = !sub_select;

    if (new_select) {
        for (int i=0; i<n; i++) {
            h[i] = false;
        }
    }
    
    for (int i=0; i<n; i++) {
        if (h[i] == true) {
            no_hl = false;
            break;
        }
    }
    std::vector<bool> cur_sel(n);
    
	LOG(table_int->GetColName(mcol));
	double min_dval = 0;
	m_min_text->GetValue().ToDouble(&min_dval);
	double max_dval = 1;
	m_max_text->GetValue().ToDouble(&max_dval);
	std::vector<bool> undefined;
	table_int->GetColUndefined(mcol, f_tm, undefined);
	if (table_int->GetColType(mcol) == GdaConst::long64_type) {
		wxInt64 min_ival = ceil(min_dval);
		wxInt64 max_ival = floor(max_dval);
		std::vector<wxInt64> vec;
		table_int->GetColData(mcol, f_tm, vec);
		for (int i=0, iend=table_int->GetNumberRows(); i<iend; i++) {
			if (!undefined[i] && min_ival <= vec[i] && vec[i] <= max_ival) {
                cur_sel[i] = true;
			} else {
                cur_sel[i] = false;
            }
		}
	} else if (table_int->GetColType(mcol) == GdaConst::double_type) {
		std::vector<double> vec;
		table_int->GetColData(mcol, f_tm, vec);
		for (int i=0, iend=table_int->GetNumberRows(); i<iend; i++) {
			if (!undefined[i] && min_dval <= vec[i] && vec[i] <= max_dval) {
                cur_sel[i] = true;
			} else {
                cur_sel[i] = false;
			}
		}
	} else {
		wxString msg("Selected field is should be numeric.");
		wxMessageDialog dlg (this, msg, "Error", wxOK | wxICON_ERROR);
		dlg.ShowModal();
		return;
	}
    bool update_flag = false;
    for (int i=0; i<n; i++) {
        if (no_hl) {
            if (cur_sel[i] == true) {
                h[i] = true;
                update_flag = true;
            }
        } else {
            if (sub_select) {
                if (h[i] == true && cur_sel[i] == false) {
                    h[i] = false;
                    update_flag = true;
                }
            } else if (append_select) {
                if (h[i] == false && cur_sel[i] == true) {
                    h[i] = true;
                    update_flag = true;
                }
            }
        }
    }

	if (update_flag) {
		hs.SetEventType(HLStateInt::delta);
		hs.notifyObservers();
	}
	current_sel_mcol = mcol;
	m_selection_made = true;
	CheckApplySaveSettings();
	LOG_MSG("Exiting RangeSelectionDlg::OnApplySelClick");
}
Ejemplo n.º 13
0
void SaveSelectionDlg::OnSaveFieldChoice( wxCommandEvent& event )
{
	EnableTimeField();
	CheckApplySaveSettings();
}
Ejemplo n.º 14
0
void SaveSelectionDlg::OnSelUnselTextChange( wxCommandEvent& event )
{
    wxLogMessage("Click SaveSelectionDlg::OnSelUnselTextChange");
    
	CheckApplySaveSettings();
}
Ejemplo n.º 15
0
void SaveSelectionDlg::OnUnselCheckBox( wxCommandEvent& event )
{
    wxLogMessage("Click SaveSelectionDlg::OnUnselCheckBox");
    
	CheckApplySaveSettings();
}