void GLFitDirector::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsFitMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandleFitMenu(selection->GetIndex()); } else if (sender == itsFitMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdateFitMenu(); } else if (sender == itsPrefsMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandlePrefsMenu(selection->GetIndex()); } else if (sender == itsHelpMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandleHelpMenu(selection->GetIndex()); } else if (sender == itsCurveList && message.Is(GLCurveNameList::kCurveSelected)) { const GLCurveNameList::CurveSelected* info = dynamic_cast<const GLCurveNameList::CurveSelected*>(&message); assert(info != NULL); JPlotDataBase& curve = itsPlot->GetCurve(info->GetIndex()); RemoveFit(); RemoveCurves(); itsParameterTable->ClearValues(); itsChiSq->SetText(""); // add new curve. itsFitPlot->AddCurve(&curve, kJFalse, itsPlot->GetCurveName(info->GetIndex())); itsFitPlot->ProtectCurve(1, kJTrue); } else if (sender == itsFitList && message.Is(GLFitDescriptionList::kFitSelected)) { const GLFitDescriptionList::FitSelected* info = dynamic_cast<const GLFitDescriptionList::FitSelected*>(&message); assert(info != NULL); const GLFitDescription& fd = GetFitManager()->GetFitDescription(info->GetIndex()); itsParameterTable->SetFitDescription(fd); RemoveFit(); itsChiSq->SetText(""); JFunction* f; if (JParseFunction(fd.GetFitFunctionString(), const_cast<GLFitDescription&>(fd).GetVarList(), &f)) { itsExprWidget->SetFunction(const_cast<GLFitDescription&>(fd).GetVarList(), f); itsExprWidget->Show(); } } else if (sender == itsFitList && message.Is(GLFitDescriptionList::kFitInitiated)) { const GLFitDescriptionList::FitInitiated* info = dynamic_cast<const GLFitDescriptionList::FitInitiated*>(&message); assert(info != NULL); const GLFitDescription& fd = GetFitManager()->GetFitDescription(info->GetIndex()); if (!itsParameterTable->BeginEditingStartValues()) { Fit(); AddHistoryText(); } } else if (sender == itsParameterTable && message.Is(GLFitParameterTable::kValueChanged)) { const GLFitParameterTable::ValueChanged* info = dynamic_cast<const GLFitParameterTable::ValueChanged*>(&message); assert(info != NULL); JIndex index; JBoolean ok = itsFitList->GetCurrentFitIndex(&index); assert(ok); GLFitDescription& fd = GetFitManager()->GetFitDescription(index); const JArray<JFloat>& parms = itsParameterTable->GetStartValues(); const JSize count = parms.GetElementCount(); for (JIndex i = 1; i <= count; i++) { fd.GetVarList()->SetValue(i + 1, parms.GetElement(i)); } GetWindow()->Refresh(); } else if (sender == itsNLFitDialog && message.Is(JXDialogDirector::kDeactivated)) { const JXDialogDirector::Deactivated* info = dynamic_cast<const JXDialogDirector::Deactivated*>(&message); assert(info != NULL); if (info->Successful()) { GLNonLinearFitDescription* fit = new GLNonLinearFitDescription(itsNLFitDialog->GetFitName(), itsNLFitDialog->GetFunctionString(), itsNLFitDialog->GetDerivativeString(), itsNLFitDialog->GetVarList().GetVariables()); assert(fit != NULL); GetFitManager()->AddFitDescription(fit); } itsNLFitDialog = NULL; } else if (sender == itsPolyFitDialog && message.Is(JXDialogDirector::kDeactivated)) { const JXDialogDirector::Deactivated* info = dynamic_cast<const JXDialogDirector::Deactivated*>(&message); assert(info != NULL); if (info->Successful()) { JArray<JIndex> powers; itsPolyFitDialog->GetPowers(&powers); GLPolyFitDescription* fit = new GLPolyFitDescription(itsPolyFitDialog->GetFitName(), powers); assert(fit != NULL); GetFitManager()->AddFitDescription(fit); } itsPolyFitDialog = NULL; } else if (sender == itsPrinter && message.Is(JPrinter::kPrintSetupFinished)) { const JPrinter::PrintSetupFinished* info = dynamic_cast<const JPrinter::PrintSetupFinished*>(&message); assert(info != NULL); if (info->Successful()) { Print(); } } else { JXWindowDirector::Receive(sender, message); } }
void GPMMainDirector::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsFileMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdateFileMenu(); } else if (sender == itsFileMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandleFileMenu(selection->GetIndex()); } else if (sender == itsProcessMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdateProcessMenu(); } else if (sender == itsProcessMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandleProcessMenu(selection->GetIndex()); } else if (sender == itsPrefsMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdatePrefsMenu(); } else if (sender == itsPrefsMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandlePrefsMenu(selection->GetIndex()); } else if (sender == itsHelpMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdateHelpMenu(); } else if (sender == itsHelpMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandleHelpMenu(selection->GetIndex()); } else if (sender == itsTimerTask && message.Is(JXTimerTask::kTimerWentOff)) { itsProcessList->Update(); } else if (sender == itsTabGroup->GetCardEnclosure() && message.Is(JXCardFile::kCardIndexChanged)) { JIndex index; const JBoolean ok = itsTabGroup->GetCurrentTabIndex(&index); assert( ok ); const GPMProcessEntry* entry; if (index == kListTabIndex && itsProcessTree->GetSelectedProcess(&entry)) { itsProcessTable->SelectProcess(*entry); } else if (index == kTreeTabIndex && itsProcessTable->GetSelectedProcess(&entry)) { itsProcessTree->SelectProcess(*entry); } } else { JXWindowDirector::Receive(sender, message); } }
void CMSourceDirector::Receive ( JBroadcaster* sender, const Message& message ) { if (IsMainSourceWindow() && sender == itsLink && message.Is(CMLink::kDebuggerStarted)) { ClearDisplay(); } else if (sender == itsLink && message.Is(CMLink::kPrepareToLoadSymbols)) { if (!itsCurrentFile.IsEmpty()) // reload file, in case it changed { const JString fileName = itsCurrentFile; const JIndex lineIndex = itsText->HasSelection() ? itsText->GetLineForChar(itsText->GetInsertionIndex()) : itsTable->GetCurrentLine(); itsCurrentFile.Clear(); // force reload DisplayFile(fileName, lineIndex); } } else if (IsMainSourceWindow() && sender == itsLink && message.Is(CMLink::kSymbolsLoaded)) { const CMLink::SymbolsLoaded* info = dynamic_cast<const CMLink::SymbolsLoaded*>(&message); assert( info != NULL ); UpdateWindowTitle(info->GetProgramName()); } else if (IsMainSourceWindow() && sender == itsLink && message.Is(CMLink::kProgramStopped)) { const CMLink::ProgramStopped* info = dynamic_cast<const CMLink::ProgramStopped*>(&message); assert( info != NULL); const CMLocation* loc; const JBoolean hasFile = info->GetLocation(&loc); if (itsType == kMainSourceType && hasFile) { DisplayFile(loc->GetFileName(), loc->GetLineNumber()); } else if (itsType == kMainAsmType && !loc->GetFunctionName().IsEmpty() && !loc->GetMemoryAddress().IsEmpty()) { DisplayDisassembly(*loc); } else if (itsType == kMainAsmType) { // wait for kProgramStopped2 } else { #ifdef _J_OLD_OSX itsTable->SetCurrentLine(0); // we get blank location the first time #else ClearDisplay(); (CMGetCommandDirector())->GetStackDir()->Activate(); #endif } } else if (itsType == kMainAsmType && sender == itsLink && message.Is(CMLink::kProgramStopped2)) { const CMLink::ProgramStopped2* info = dynamic_cast<const CMLink::ProgramStopped2*>(&message); assert( info != NULL); const CMLocation* loc; info->GetLocation(&loc); if (!loc->GetFunctionName().IsEmpty() && !loc->GetMemoryAddress().IsEmpty()) { DisplayDisassembly(*loc); } else { ClearDisplay(); } } else if (sender == itsLink && (message.Is(CMLink::kProgramFinished) || message.Is(CMLink::kCoreCleared) || message.Is(CMLink::kDetachedFromProcess))) { if (itsSrcMainCmd != NULL) { itsSrcMainCmd->CMCommand::Send(); } else if (itsType == kMainAsmType) { ClearDisplay(); } } else if (sender == itsFileMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdateFileMenu(); } else if (sender == itsFileMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandleFileMenu(selection->GetIndex()); } else if (sender == itsDebugMenu && message.Is(JXMenu::kNeedsUpdate)) { itsCommandDir->UpdateDebugMenu(itsDebugMenu, itsText, NULL); } else if (sender == itsDebugMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); itsCommandDir->HandleDebugMenu(itsDebugMenu, selection->GetIndex(), itsText, NULL); } else if (sender == itsPrefsMenu && message.Is(JXMenu::kNeedsUpdate)) { UpdatePrefsMenu(); } else if (sender == itsPrefsMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandlePrefsMenu(selection->GetIndex()); } else if (sender == itsHelpMenu && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); HandleHelpMenu(selection->GetIndex()); } else if (sender == CMGetPrefsManager() && message.Is(CMPrefsManager::kFileTypesChanged)) { UpdateFileType(); } else if (sender == CMGetPrefsManager() && message.Is(CMPrefsManager::kCustomCommandsChanged)) { itsCommandDir->AdjustDebugMenu(itsDebugMenu); } else { JXWindowDirector::Receive(sender,message); } }