//------------------------------------------------------------------------------ // void OnCellClick(wxGridEvent& event) //------------------------------------------------------------------------------ void InteractiveMatlabDialog::OnCellClick(wxGridEvent& event) { unsigned int row = event.GetRow(); unsigned int col = event.GetCol(); if (event.GetEventObject() == inputGrid) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_PLOTTABLE, true, false, true); paramDlg.SetParamNameArray(inputStrings); paramDlg.ShowModal(); inputStrings = paramDlg.GetParamNameArray(); wxString cellValue = wxT(""); if (inputStrings.Count() > 0) { cellValue = cellValue + inputStrings[0]; for (unsigned int i=1; i<inputStrings.Count(); i++) { cellValue = cellValue + wxT(", ") + inputStrings[i]; } inputGrid->SetCellValue(row, col, cellValue); } else // no selections inputGrid->SetCellValue(row, col, wxT("")); } else if (event.GetEventObject() == outputGrid) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_PLOTTABLE, true, false, true); paramDlg.SetParamNameArray(outputStrings); paramDlg.ShowModal(); outputStrings = paramDlg.GetParamNameArray(); wxString cellValue = wxT(""); if (outputStrings.Count() > 0) { cellValue = cellValue + outputStrings[0]; for (unsigned int i=1; i<outputStrings.Count(); i++) { cellValue = cellValue + wxT(", ") + outputStrings[i]; } outputGrid->SetCellValue(row, col, cellValue); } else // no selections outputGrid->SetCellValue(row, col, wxT("")); } }
//------------------------------------------------------------------------------ // void AchievePanel::OnButtonClick(wxCommandEvent& event) //------------------------------------------------------------------------------ void AchievePanel::OnButtonClick(wxCommandEvent& event) { // show dialog to select parameter ParameterSelectDialog paramDlg(this, mObjectTypeList); paramDlg.ShowModal(); if (paramDlg.IsParamSelected()) { wxString newParamName = paramDlg.GetParamName(); if (event.GetEventObject() == mViewGoalButton) { mGoalNameTextCtrl->SetValue(newParamName); mGoalName = newParamName; mIsTextModified = true; } else if (event.GetEventObject() == mViewGoalValueButton) { mGoalValueTextCtrl->SetValue(newParamName); mGoalValue = newParamName; mIsTextModified = true; } else if (event.GetEventObject() == mViewToleranceButton) { mToleranceTextCtrl->SetValue(newParamName); mTolerance = newParamName; mIsTextModified = true; } EnableUpdate(true); } }
//------------------------------------------------------------------------------ void ForPanel::GetNewValue(Integer row, Integer col) { bool settableOnly = (col == INDEX_COL); ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_PLOTTABLE,0, false, false, true, true, true, true, "Spacecraft", true, settableOnly); paramDlg.ShowModal(); if (paramDlg.IsParamSelected()) { wxString newParamName = paramDlg.GetParamName(); if (newParamName == conditionGrid->GetCellValue(row, col)) return; conditionGrid->SetCellValue(row, col, newParamName); if (col == INDEX_COL) mIndexString = newParamName; else if (col == START_COL) mStartString = newParamName; else if (col == INCR_COL) mIncrString = newParamName; else if (col == END_COL) mEndString = newParamName; EnableUpdate(true); } }
//------------------------------------------------------------------------------ // void VaryPanel::OnButton(wxCommandEvent& event) //------------------------------------------------------------------------------ void VaryPanel::OnButton(wxCommandEvent& event) { if (event.GetEventObject() == mViewVarButton) { wxString objType = "ImpulsiveBurn"; if (theGuiManager->GetNumImpulsiveBurn() == 0) objType = "Spacecraft"; ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_PLOTTABLE, 0, false, false, true, true, true, true, objType, true, true, true); paramDlg.ShowModal(); if (paramDlg.IsParamSelected()) { wxString newParamName = paramDlg.GetParamName(); mVarNameTextCtrl->SetValue(newParamName); variableName = newParamName.c_str(); variableChanged = true; EnableUpdate(true); } } else event.Skip(); }
//------------------------------------------------------------------------------ // void OnButtonClick(wxCommandEvent& event) //------------------------------------------------------------------------------ void NonlinearConstraintPanel::OnButtonClick(wxCommandEvent& event) { if (event.GetEventObject() == mLeftChooseButton) { // show dialog to select parameter ParameterSelectDialog paramDlg(this, mObjectTypeList); paramDlg.ShowModal(); if (paramDlg.IsParamSelected()) { wxString newParamName = paramDlg.GetParamName(); if (event.GetEventObject() == mLeftChooseButton) { mLHSTextCtrl->SetValue(newParamName); } EnableUpdate(true); } } else if (event.GetEventObject() == mRightChooseButton) { // show dialog to select parameter ParameterSelectDialog paramDlg(this, mObjectTypeList); paramDlg.ShowModal(); if (paramDlg.IsParamSelected()) { wxString newParamName = paramDlg.GetParamName(); if (event.GetEventObject() == mRightChooseButton) { mRHSTextCtrl->SetValue(newParamName); } EnableUpdate(true); } } else { event.Skip(); } }
//------------------------------------------------------------------------------ // void OnCellRightClick(wxGridEvent& event) //------------------------------------------------------------------------------ void WhilePanel::OnCellRightClick(wxGridEvent& event) { int row = event.GetRow(); int col = event.GetCol(); if ( (row == COMMAND_COL) && (col == COMMAND_COL) ) return; if (col == COMMAND_COL) { wxString oldStr = conditionGrid->GetCellValue(row, col); wxString strArray[] = {wxT("&"), wxT("|")}; wxSingleChoiceDialog dialog(this, wxT("Logic Selection: \n"), wxT("WhileConditionDialog"), 2, strArray); dialog.SetSelection(0); if (dialog.ShowModal() == wxID_OK) { if (oldStr != dialog.GetStringSelection()) { conditionGrid->SetCellValue(row, col, dialog.GetStringSelection()); EnableUpdate(true); } } } else if (col == LHS_COL) { wxString oldStr = conditionGrid->GetCellValue(row, col); ParameterSelectDialog paramDlg(this, mObjectTypeList); paramDlg.ShowModal(); if (paramDlg.IsParamSelected()) { if (oldStr != paramDlg.GetParamName()) { conditionGrid->SetCellValue(row, col, paramDlg.GetParamName()); EnableUpdate(true); } } } else if (col == COND_COL) { wxString oldStr = conditionGrid->GetCellValue(row, col); wxString strArray[] = {wxT("=="), wxT("~="), wxT(">"), wxT("<"), wxT(">="), wxT("<=")}; wxSingleChoiceDialog dialog(this, wxT("Equality Selection: \n"), wxT("WhileConditionDialog"), 6, strArray); dialog.SetSelection(0); if (dialog.ShowModal() == wxID_OK) { if (oldStr != dialog.GetStringSelection()) { conditionGrid->SetCellValue(row, col, dialog.GetStringSelection()); EnableUpdate(true); } } } else if (col == RHS_COL) { wxString oldStr = conditionGrid->GetCellValue(row, col); ParameterSelectDialog paramDlg(this, mObjectTypeList); paramDlg.ShowModal(); if (paramDlg.IsParamSelected()) { if (oldStr != paramDlg.GetParamName()) { conditionGrid->SetCellValue(row, col, paramDlg.GetParamName()); EnableUpdate(true); } } } }
//------------------------------------------------------------------------------ // void OnCellDoubleLeftClick(wxGridEvent& event) //------------------------------------------------------------------------------ void DoWhilePanel::OnCellDoubleLeftClick(wxGridEvent& event) { if (event.GetEventObject() == conditionGrid) { int row = event.GetRow(); int col = event.GetCol(); if ( col == 0 ) { wxString strArray[] = { wxT("While") }; wxSingleChoiceDialog dialog(this, wxT("Condition: \n"), wxT("DoWhileConditionDialog"), 1, strArray); dialog.SetSelection(0); if (dialog.ShowModal() == wxID_OK) { if (dialog.GetStringSelection() != conditionGrid->GetCellValue(row, col)) { conditionGrid->SetCellValue(1, 0, dialog.GetStringSelection()); EnableUpdate(true); } } } else if ( (col == 1) || (col == 3)) { // show dialog to select parameter ParameterSelectDialog paramDlg(this); paramDlg.ShowModal(); if (paramDlg.IsParamSelected()) { wxString newParamName = paramDlg.GetParamName(); conditionGrid->SetCellValue(row, col, newParamName); EnableUpdate(true); } } else if (col == 2) { wxString strArray[] = { wxT("="), wxT(">"), wxT("<"), wxT(">="), wxT("<="), wxT("!=") }; wxSingleChoiceDialog dialog(this, wxT("Condition: \n"), wxT("DoWhileConditionDialog"), 6, strArray); dialog.SetSelection(0); if (dialog.ShowModal() == wxID_OK) { if (dialog.GetStringSelection() != conditionGrid->GetCellValue(row, col)) { conditionGrid->SetCellValue(row, col, dialog.GetStringSelection()); EnableUpdate(true); } } } } }
//------------------------------------------------------------------------------ // void OnButtonClick(wxCommandEvent& event) //------------------------------------------------------------------------------ void CallFunctionPanel::OnButtonClick(wxCommandEvent& event) { #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage (wxT("CallFunctionPanel::OnButtonClick() entered\n")); #endif wxString value = wxT(""); wxString delimiter = wxT(", "); if (event.GetEventObject() == theInputViewButton) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_REPORTABLE, true, true, true); paramDlg.SetParamNameArray(mInputWxStrings); paramDlg.ShowModal(); #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage (wxT(" Has new input selection made? %d\n"), paramDlg.HasSelectionChanged()); #endif if (paramDlg.HasSelectionChanged()) { EnableUpdate(true); mInputWxStrings = paramDlg.GetParamNameArray(); if (mInputWxStrings.Count() > 0) { value = value + mInputWxStrings[0]; for (unsigned int i=1; i<mInputWxStrings.Count(); i++) value = value + delimiter + mInputWxStrings[i]; theInputTextCtrl->SetValue(value); } else // no selections { theInputTextCtrl->SetValue(value); } } } else if (event.GetEventObject() == theOutputViewButton) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_REPORTABLE, true, true, true); paramDlg.SetParamNameArray(mOutputWxStrings); paramDlg.ShowModal(); #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage (wxT(" Has new output selection made? %d\n"), paramDlg.HasSelectionChanged()); #endif if (paramDlg.HasSelectionChanged()) { EnableUpdate(true); mOutputWxStrings = paramDlg.GetParamNameArray(); if (mOutputWxStrings.Count() > 0) { value = value + mOutputWxStrings[0]; for (unsigned int i=1; i<mOutputWxStrings.Count(); i++) value = value + delimiter + mOutputWxStrings[i]; theOutputTextCtrl->SetValue(value); } else // no selections { theOutputTextCtrl->SetValue(value); } } } }
//------------------------------------------------------------------------------ // void OnCellRightClick(wxGridEvent& event) //------------------------------------------------------------------------------ void CallFunctionPanel::OnCellRightClick(wxGridEvent& event) { #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage (wxT("CallFunctionPanel::OnCellRightClick() entered\n")); #endif unsigned int row = event.GetRow(); unsigned int col = event.GetCol(); #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage(wxT(" row = %d, col = %d\n"), row, col); #endif if (event.GetEventObject() == theInputGrid) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_REPORTABLE, true, true, true); theOutputGrid->DeselectRow(0); paramDlg.SetParamNameArray(mInputWxStrings); paramDlg.ShowModal(); #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage (wxT(" Has new input selection made? %d\n"), paramDlg.HasSelectionChanged()); #endif if (paramDlg.HasSelectionChanged()) { EnableUpdate(true); mInputWxStrings = paramDlg.GetParamNameArray(); wxString cellValue = wxT(""); wxString delimiter = wxT(", "); if (mInputWxStrings.Count() > 0) { cellValue = cellValue + mInputWxStrings[0]; for (unsigned int i=1; i<mInputWxStrings.Count(); i++) cellValue = cellValue + delimiter + mInputWxStrings[i]; theInputGrid->SetCellValue(row, col, cellValue); } else // no selections { theInputGrid->SetCellValue(row, col, wxT("")); } } } else if (event.GetEventObject() == theOutputGrid) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_REPORTABLE, true, true, true); theInputGrid->DeselectRow(0); paramDlg.SetParamNameArray(mOutputWxStrings); paramDlg.ShowModal(); #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage (wxT(" Has new output selection made? %d\n"), paramDlg.HasSelectionChanged()); #endif if (paramDlg.HasSelectionChanged()) { EnableUpdate(true); mOutputWxStrings = paramDlg.GetParamNameArray(); wxString cellValue = wxT(""); wxString delimiter = wxT(", "); if (mOutputWxStrings.Count() > 0) { cellValue = cellValue + mOutputWxStrings[0]; for (unsigned int i=1; i<mOutputWxStrings.Count(); i++) cellValue = cellValue + delimiter + mOutputWxStrings[i]; theOutputGrid->SetCellValue(row, col, cellValue); } else // no selections { theOutputGrid->SetCellValue(row, col, wxT("")); } } } }