-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCSettingsWindow.cp
More file actions
executable file
·679 lines (620 loc) · 25.5 KB
/
Copy pathCSettingsWindow.cp
File metadata and controls
executable file
·679 lines (620 loc) · 25.5 KB
1
//// =================================================================================// CSettingsWindow.cp // =================================================================================// CSettingsWindow.h #include "CSettingsWindow.h"#include <LCheckBox.h>#include <LCheckBoxGroupBox.h>#include <LEditText.h>#include <LPopupButton.h>#include <LMultiPanelView.h>#include "myLFileStream.h"// ---------------------------------------------------------------------------------// ¥ CSettingsWindow// ---------------------------------------------------------------------------------CSettingsWindow::CSettingsWindow(){ mCurrentPanel = nil; mPrefs = nil; mTheApp = nil; mCurrentPanel = nil; mTabPanel = nil; mPanelHost = nil; mCSDPanel = nil; mStatsPanel = nil; mEnvelopesPanel = nil; mOutputPanel = nil; mMiscPanel = nil; mShavePanel = nil;}// ---------------------------------------------------------------------------------// ¥ CSettingsWindow(LStream *)// ---------------------------------------------------------------------------------CSettingsWindow::CSettingsWindow( LStream *inStream ) : LWindow( inStream ){ mCurrentPanel = nil; mPrefs = nil; mTheApp = nil; mCurrentPanel = nil; mTabPanel = nil; mPanelHost = nil; mCSDPanel = nil; mStatsPanel = nil; mEnvelopesPanel = nil; mOutputPanel = nil; mMiscPanel = nil; mShavePanel = nil;}// ---------------------------------------------------------------------------------// ¥ ~CSettingsWindow// ---------------------------------------------------------------------------------CSettingsWindow::~CSettingsWindow(){ if (mPrefs) { delete mPrefs; mPrefs = nil; }}// ---------------------------------------------------------------------------------// ¥ FinishCreateSelf// ---------------------------------------------------------------------------------voidCSettingsWindow::FinishCreateSelf(){ // Find the tab panel so that we can get setup to // listen to it ThrowIfNil_(mTabPanel = (LTabsControl*) FindPaneByID ( item_TabsPanel )); ThrowIfNil_(mPanelHost = (LPlaceHolder*) FindPaneByID ( item_Placeholder )); if ( mTabPanel ) { mTabPanel->StartBroadcasting (); mTabPanel->AddListener ( this ); } // make all the panel views ThrowIfNil_(mCSDPanel = UReanimator::CreateView (rPPob_CSD, mPanelHost, this)); ThrowIfNil_(mStatsPanel = UReanimator::CreateView (rPPob_Stats, mPanelHost, this)); ThrowIfNil_(mEnvelopesPanel = UReanimator::CreateView (rPPob_Envelopes, mPanelHost, this)); ThrowIfNil_(mOutputPanel = UReanimator::CreateView (rPPob_Output, mPanelHost, this)); ThrowIfNil_(mMiscPanel = UReanimator::CreateView (rPPob_Misc, mPanelHost, this)); ThrowIfNil_(mShavePanel = UReanimator::CreateView (rPPob_Shave, mPanelHost, this)); // Make the MultiPanelView Listen to the Toggle button LCheckBox *theCB = (LCheckBox *) mShavePanel->FindPaneByID(item_AspectRatioToggle); theCB->AddListener(this); theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_InflateBBox); theCB->AddListener(this); theCB = (LCheckBox *) mShavePanel->FindPaneByID(item_ShaveSaveCB); theCB->AddListener(this); LCheckBoxGroupBox *theCBGB = (LCheckBoxGroupBox *) mShavePanel->FindPaneByID(item_DoShave); theCBGB->AddListener(this); theCB = (LCheckBox *) mOutputPanel->FindPaneByID(item_OutputSigmas); theCB->AddListener(this); LPopupButton *thePopup = (LPopupButton *) mStatsPanel->FindPaneByID(item_SampleShape); thePopup->AddListener(this); mTheXYZPopup = mShavePanel->FindPaneByID(item_XYZPopup); mMaxAR_ET = mShavePanel->FindPaneByID(item_MaxAspRatioET); mMaxAR_ST = mShavePanel->FindPaneByID(item_MaxAspRatioST); // Install the CSD panel into the tab panel mPanelHost->InstallOccupant(mCSDPanel); mCSDPanel->Show(); mTabPanel->Refresh(); // Setup our reference to the new sample panel mCurrentPanel = mCSDPanel; LControl *theCtrl = (LControl *) FindPaneByID(item_OK); theCtrl->AddListener(this); LPushButton *theBtn = (LPushButton *) FindPaneByID(item_OK); theCtrl = (LControl *) FindPaneByID(item_Cancel); theCtrl->AddListener(this); theCtrl = (LControl *) FindPaneByID(item_RestoreDefaults); theCtrl->AddListener(this); theCtrl = (LControl *) mMiscPanel->FindPaneByID(item_LoadHoles); theCtrl->AddListener(this); theCtrl = (LControl *) mMiscPanel->FindPaneByID(item_ResetHolesFile); theCtrl->AddListener(this); theCtrl = (LControl *) mOutputPanel->FindPaneByID(item_Confidence); theCtrl->AddListener(this);}// ---------------------------------------------------------------------------------// ¥ SetUp// ---------------------------------------------------------------------------------voidCSettingsWindow::SetUp(CReduceApp *inApp, CReducePrefs *inPrefsHolder, PrefStruct *inPrefs){ mTheApp = inApp; mPrefsHolder = inPrefsHolder; mPrefs = inPrefs; SetValues(mPrefs);}// ---------------------------------------------------------------------------------// ¥ SetValues(GraphPrefs *inPrefs)// ---------------------------------------------------------------------------------voidCSettingsWindow::SetValues(PrefStruct *inPrefs){ StopListening(); LCheckBox *theCB; LCheckBoxGroupBox *theCBGB; LEditText *theEF; LPopupButton *thePopup; LStr255 theLStr; // CSD Panel theCBGB = (LCheckBoxGroupBox *) mCSDPanel->FindPaneByID(item_MeanCSD); theCBGB->SetValue(inPrefs->includeMeanCSD); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_MeanNumClasses); theEF->SetValue(inPrefs->numClassesMeanCSD); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_MaxXValue); theEF->SetDescriptor(FltStr(inPrefs->maxValueMeanCSD, 3)); theCBGB = (LCheckBoxGroupBox *) mCSDPanel->FindPaneByID(item_MaxCSD); theCBGB->SetValue(inPrefs->includeMaxCSD); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_MaxNumClasses); theEF->SetValue(inPrefs->numClassesMaxCSD); theCBGB = (LCheckBoxGroupBox *) mCSDPanel->FindPaneByID(item_LogCSD); theCBGB->SetValue(inPrefs->includeLogCSD); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_LogNumClasses); theEF->SetValue(inPrefs->numClassesLogCSD); theCBGB = (LCheckBoxGroupBox *) mCSDPanel->FindPaneByID(item_RegCSD); theCBGB->SetValue(inPrefs->includeRegCSD); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_DeltaL); theEF->SetDescriptor(FltStr(inPrefs->deltaLRegCSD, 3)); // Other Stats Panel theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_DoOtherTests); theCB->SetValue(inPrefs->doOthers); theCBGB = (LCheckBoxGroupBox *) FindPaneByID(item_DoQuadrat); theCBGB->SetValue(inPrefs->doQuadrat); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_QuadratNumPlacings); theEF->SetValue(inPrefs->quadratNumPlacings); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_QuadratNumReps); theEF->SetValue(inPrefs->quadratNumReps); theCBGB = (LCheckBoxGroupBox *) FindPaneByID(item_DoRandomPt); theCBGB->SetValue(inPrefs->doRandomPt); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_RPNumPlacings); theEF->SetValue(inPrefs->RPNumPlacings); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_RPNumReps); theEF->SetValue(inPrefs->RPNumReps); theCBGB = (LCheckBoxGroupBox *) FindPaneByID(item_ImpingementCrxn); theCBGB->SetValue(inPrefs->doImpingement); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_MeanErrorTol); theEF->SetDescriptor(FltStr(inPrefs->impingementMeanErr, 3)); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_MaxErrorTol); theEF->SetDescriptor(FltStr(inPrefs->impingementMaxErr, 3)); theCBGB = (LCheckBoxGroupBox *) FindPaneByID(item_DoLMCFPCF); theCBGB->SetValue(inPrefs->doLMcfPcf); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_NumNNDist); theEF->SetValue(inPrefs->numNNDist); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_BandwidthOverlap); theEF->SetValue(inPrefs->overlap); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_NumCFOffsetVolPts); theEF->SetValue(inPrefs->numCFOffsetVolPts); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_CvalEpanecnikov); theEF->SetDescriptor(FltStr(inPrefs->EpanecnikovCVal, 3)); thePopup = (LPopupButton *) mStatsPanel->FindPaneByID(item_SampleShape); thePopup->SetValue(inPrefs->sampleShape); theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_InflateBBox); theCB->SetValue(inPrefs->inflateBBox); theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_DiscardNegs); theCB->SetValue(inPrefs->discardNegs); theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_UseRaeburn); theCB->SetValue(inPrefs->useRaeburn); theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_UseVolume); theCB->SetValue(inPrefs->useVolume); // Envelopes Panel theCBGB = (LCheckBoxGroupBox *) mEnvelopesPanel->FindPaneByID(item_matchVF); theCBGB->SetValue(inPrefs->matchVF); theEF = (LEditText *) mEnvelopesPanel->FindPaneByID(item_VFPercent); theEF->SetDescriptor(FltStr(inPrefs->VFPercent, 3)); theCB = (LCheckBox *) mEnvelopesPanel->FindPaneByID(item_matchPDF); theCB->SetValue(inPrefs->matchPDF); theCB = (LCheckBox *) mEnvelopesPanel->FindPaneByID(item_makeDCEnv); theCB->SetValue(inPrefs->makeDCEnv); theCBGB = (LCheckBoxGroupBox *) mEnvelopesPanel->FindPaneByID(item_ObservabiltyFilter); theCBGB->SetValue(inPrefs->observabilityFilter); theEF = (LEditText *) mEnvelopesPanel->FindPaneByID(item_Criterion1Factor); theEF->SetDescriptor(FltStr(inPrefs->crit1Factor, 3)); theEF = (LEditText *) mEnvelopesPanel->FindPaneByID(item_Criterion2Factor); theEF->SetDescriptor(FltStr(inPrefs->crit2Factor, 3)); theEF = (LEditText *) mEnvelopesPanel->FindPaneByID(item_NumEnvelopeRuns); theEF->SetValue(inPrefs->numEnvelopeRuns); // Output Panel theCB = (LCheckBox *) mOutputPanel->FindPaneByID(item_OutputRED3); theCB->SetValue(inPrefs->outputReduce); theCB = (LCheckBox *) mOutputPanel->FindPaneByID(item_IndXlData); theCB->SetValue(inPrefs->outputCrystals); theCB = (LCheckBox *) mOutputPanel->FindPaneByID(item_R3STT); theCB->SetValue(inPrefs->outputR3STT); theCB = (LCheckBox *) mOutputPanel->FindPaneByID(item_OutputSigmas); theCB->SetValue(inPrefs->outputSigmas); theEF = (LEditText *) mOutputPanel->FindPaneByID(item_Confidence); theEF->SetValue(inPrefs->confidence); // Misc Panel theEF = (LEditText *) mMiscPanel->FindPaneByID(item_RandomSeed); theEF->SetValue(inPrefs->seed); theEF = (LEditText *) mMiscPanel->FindPaneByID(item_MCReps); theEF->SetValue(inPrefs->MCReps); theCB = (LCheckBox *) mMiscPanel->FindPaneByID(item_TidyUp); theCB->SetValue(inPrefs->tidyUp); theCB = (LCheckBox *) mMiscPanel->FindPaneByID(item_Verbose); theCB->SetValue(inPrefs->verbose); // Shave Panel theCBGB = (LCheckBoxGroupBox *) mShavePanel->FindPaneByID(item_DoShave); theCBGB->SetValue(inPrefs->doShave); theCB = (LCheckBox *) mShavePanel->FindPaneByID(item_AspectRatioToggle); theCB->SetValue(inPrefs->keepAspectRatios); thePopup = (LPopupButton *) mShavePanel->FindPaneByID(item_XYZPopup); thePopup->SetValue(inPrefs->shaveXYZ); theEF = (LEditText *) mShavePanel->FindPaneByID(item_MaxAspRatioET); theEF->SetValue(inPrefs->maxAspectRatio); if (inPrefs->keepAspectRatios) { // if turning on mTheXYZPopup->Deactivate(); mMaxAR_ET->Deactivate(); mMaxAR_ST->Deactivate(); } else { mTheXYZPopup->Activate(); mMaxAR_ET->Activate(); mMaxAR_ST->Activate(); } theEF = (LEditText *) mShavePanel->FindPaneByID(item_IntervalET); theEF->SetValue(inPrefs->shaveIncrement); thePopup = (LPopupButton *) mShavePanel->FindPaneByID(item_DirectionPopup); thePopup->SetValue(inPrefs->direction); theEF = (LEditText *) mShavePanel->FindPaneByID(item_MaxPercentET); theEF->SetValue(inPrefs->minPercent); theEF = (LEditText *) mShavePanel->FindPaneByID(item_MinNumberXlsET); theEF->SetValue(inPrefs->minPopulation); thePopup = (LPopupButton *) mShavePanel->FindPaneByID(item_SmallerLargerPopup); thePopup->SetValue(inPrefs->smaller ? menuitem_Smaller : menuitem_Larger); theCB = (LCheckBox *) mShavePanel->FindPaneByID(item_ShaveSaveCB); theCB->SetValue(inPrefs->ShaveSave); CheckShaveSettings(); StartListening();}// ---------------------------------------------------------------------------// ¥ StoreWindowValues// ---------------------------------------------------------------------------voidCSettingsWindow::StoreWindowValues(PrefStruct *outPrefs){ LCheckBox *theCB; LCheckBoxGroupBox *theCBGB; LEditText *theEF; LPopupButton *thePopup; LStr255 theLStr; // CSD Panel theCBGB = (LCheckBoxGroupBox *) mCSDPanel->FindPaneByID(item_MeanCSD); outPrefs->includeMeanCSD = theCBGB->GetValue(); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_MeanNumClasses); outPrefs->numClassesMeanCSD = theEF->GetValue(); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_MaxXValue); theEF->GetDescriptor(theLStr); outPrefs->maxValueMeanCSD = (double)theLStr; theCBGB = (LCheckBoxGroupBox *) mCSDPanel->FindPaneByID(item_MaxCSD); outPrefs->includeMaxCSD = theCBGB->GetValue(); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_MaxNumClasses); outPrefs->numClassesMaxCSD = theEF->GetValue(); theCBGB = (LCheckBoxGroupBox *) mCSDPanel->FindPaneByID(item_LogCSD); outPrefs->includeLogCSD = theCBGB->GetValue(); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_LogNumClasses); outPrefs->numClassesLogCSD = theEF->GetValue(); theCBGB = (LCheckBoxGroupBox *) mCSDPanel->FindPaneByID(item_RegCSD); outPrefs->includeRegCSD = theCBGB->GetValue(); theEF = (LEditText *) mCSDPanel->FindPaneByID(item_DeltaL); theEF->GetDescriptor(theLStr); outPrefs->deltaLRegCSD = (double)theLStr; // Other Stats Panel theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_DoOtherTests); outPrefs->doOthers = theCB->GetValue(); theCBGB = (LCheckBoxGroupBox *) FindPaneByID(item_DoQuadrat); outPrefs->doQuadrat = theCBGB->GetValue(); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_QuadratNumPlacings); outPrefs->quadratNumPlacings = theEF->GetValue(); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_QuadratNumReps); outPrefs->quadratNumReps = theEF->GetValue(); theCBGB = (LCheckBoxGroupBox *) FindPaneByID(item_DoRandomPt); outPrefs->doRandomPt = theCBGB->GetValue(); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_RPNumPlacings); outPrefs->RPNumPlacings = theEF->GetValue(); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_RPNumReps); outPrefs->RPNumReps = theEF->GetValue(); theCBGB = (LCheckBoxGroupBox *) FindPaneByID(item_ImpingementCrxn); outPrefs->doImpingement = theCBGB->GetValue(); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_MeanErrorTol); theEF->GetDescriptor(theLStr); outPrefs->impingementMeanErr = (double)theLStr; theEF = (LEditText *) mStatsPanel->FindPaneByID(item_MaxErrorTol); theEF->GetDescriptor(theLStr); outPrefs->impingementMaxErr = (double)theLStr; theCBGB = (LCheckBoxGroupBox *) FindPaneByID(item_DoLMCFPCF); outPrefs->doLMcfPcf = theCBGB->GetValue(); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_NumNNDist); outPrefs->numNNDist = theEF->GetValue(); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_BandwidthOverlap); outPrefs->overlap = theEF->GetValue(); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_NumCFOffsetVolPts); outPrefs->numCFOffsetVolPts = theEF->GetValue(); theEF = (LEditText *) mStatsPanel->FindPaneByID(item_CvalEpanecnikov); theEF->GetDescriptor(theLStr); outPrefs->EpanecnikovCVal = (double)theLStr; thePopup = (LPopupButton *) mStatsPanel->FindPaneByID(item_SampleShape); outPrefs->sampleShape = thePopup->GetValue(); theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_InflateBBox); outPrefs->inflateBBox = theCB->GetValue(); theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_DiscardNegs); outPrefs->discardNegs = theCB->GetValue(); theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_UseRaeburn); outPrefs->useRaeburn = theCB->GetValue(); theCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_UseVolume); outPrefs->useVolume = theCB->GetValue(); // Envelopes Panel theCBGB = (LCheckBoxGroupBox *) mEnvelopesPanel->FindPaneByID(item_matchVF); outPrefs->matchVF = theCBGB->GetValue(); theEF = (LEditText *) mEnvelopesPanel->FindPaneByID(item_VFPercent); theEF->GetDescriptor(theLStr); outPrefs->VFPercent = (double)theLStr; theCB = (LCheckBox *) mEnvelopesPanel->FindPaneByID(item_makeDCEnv); outPrefs->makeDCEnv = theCB->GetValue(); theCB = (LCheckBox *) mEnvelopesPanel->FindPaneByID(item_matchPDF); outPrefs->matchPDF = theCB->GetValue(); theCBGB = (LCheckBoxGroupBox *) mEnvelopesPanel->FindPaneByID(item_ObservabiltyFilter); outPrefs->observabilityFilter = theCBGB->GetValue(); theEF = (LEditText *) mEnvelopesPanel->FindPaneByID(item_Criterion1Factor); theEF->GetDescriptor(theLStr); outPrefs->crit1Factor = (double)theLStr; theEF = (LEditText *) mEnvelopesPanel->FindPaneByID(item_Criterion2Factor); theEF->GetDescriptor(theLStr); outPrefs->crit2Factor = (double)theLStr; theEF = (LEditText *) mEnvelopesPanel->FindPaneByID(item_NumEnvelopeRuns); outPrefs->numEnvelopeRuns = theEF->GetValue(); // Output Panel theCB = (LCheckBox *) mOutputPanel->FindPaneByID(item_OutputRED3); outPrefs->outputReduce = theCB->GetValue(); theCB = (LCheckBox *) mOutputPanel->FindPaneByID(item_IndXlData); outPrefs->outputCrystals = theCB->GetValue(); theCB = (LCheckBox *) mOutputPanel->FindPaneByID(item_R3STT); outPrefs->outputR3STT = theCB->GetValue(); theCB = (LCheckBox *) mOutputPanel->FindPaneByID(item_OutputSigmas); outPrefs->outputSigmas = theCB->GetValue(); theEF = (LEditText *) mOutputPanel->FindPaneByID(item_Confidence); outPrefs->confidence = theEF->GetValue(); // Misc Panel theEF = (LEditText *) mMiscPanel->FindPaneByID(item_RandomSeed); outPrefs->seed = theEF->GetValue(); theEF = (LEditText *) mMiscPanel->FindPaneByID(item_MCReps); outPrefs->MCReps = theEF->GetValue(); theCB = (LCheckBox *) mMiscPanel->FindPaneByID(item_TidyUp); outPrefs->tidyUp = theCB->GetValue(); theCB = (LCheckBox *) mMiscPanel->FindPaneByID(item_Verbose); outPrefs->verbose = theCB->GetValue(); // Shave Panel theCBGB = (LCheckBoxGroupBox *) mShavePanel->FindPaneByID(item_DoShave); outPrefs->doShave = theCBGB->GetValue(); theCB = (LCheckBox *) mShavePanel->FindPaneByID(item_AspectRatioToggle); outPrefs->keepAspectRatios = theCB->GetValue(); if (!theCB->GetValue()) { // do change AR items thePopup = (LPopupButton *) mShavePanel->FindPaneByID(item_XYZPopup); outPrefs->shaveXYZ = thePopup->GetValue(); theEF = (LEditText *) mShavePanel->FindPaneByID(item_MaxAspRatioET); outPrefs->maxAspectRatio = theEF->GetValue(); } // set shared items theEF = (LEditText *) mShavePanel->FindPaneByID(item_IntervalET); outPrefs->shaveIncrement = theEF->GetValue(); thePopup = (LPopupButton *) mShavePanel->FindPaneByID(item_DirectionPopup); outPrefs->direction = thePopup->GetValue(); theEF = (LEditText *) mShavePanel->FindPaneByID(item_MaxPercentET); outPrefs->minPercent = theEF->GetValue(); theEF = (LEditText *) mShavePanel->FindPaneByID(item_MinNumberXlsET); outPrefs->minPopulation = theEF->GetValue(); thePopup = (LPopupButton *) mShavePanel->FindPaneByID(item_SmallerLargerPopup); outPrefs->smaller = (thePopup->GetValue() == menuitem_Smaller); theCB = (LCheckBox *) mShavePanel->FindPaneByID(item_ShaveSaveCB); outPrefs->ShaveSave = theCB->GetValue();}voidCSettingsWindow::CheckShaveSettings(){ LCheckBoxGroupBox *theCBGB = (LCheckBoxGroupBox *) mShavePanel->FindPaneByID(item_DoShave); LStaticText *theShaveNote = (LStaticText *) mShavePanel->FindPaneByID(item_ShaveNote); LPopupButton *theXYZPopup = (LPopupButton *) mShavePanel->FindPaneByID(item_XYZPopup); LCheckBox *theInflationCB = (LCheckBox *) mStatsPanel->FindPaneByID(item_InflateBBox); LPopupButton *thePrimPopup = (LPopupButton *) mStatsPanel->FindPaneByID(item_SampleShape); short value = thePrimPopup->GetValue(); // if Shape = Sides then disable Shave panel and post notice on panel // if Shape = RP/Cyl then enable Shave panel and remove notice switch (value) { case popup_RectPrism: case popup_Cylinder: { if (theInflationCB->GetValue() == Button_On) { theCBGB->Deactivate(); theShaveNote->SetDescriptor("\pShaving is incompatible with inflation (Stats Panel)."); } else { theCBGB->Activate(); theShaveNote->SetDescriptor("\p"); } theXYZPopup->Show(); } break; case popup_Sides: { theCBGB->SetValue(Button_Off); theCBGB->Deactivate(); theShaveNote->SetDescriptor("\pShaving is not possible with a Sides box (Stats Panel)."); } break; }}// ---------------------------------------------------------------------------// ¥ ListenToMessage// ---------------------------------------------------------------------------// Respond to messages from BroadcastersvoidCSettingsWindow::ListenToMessage( MessageT inMessage, void *ioParam){ long value = *((long *) ioParam); // these are for the OK and the Holes buttons OSType theTL[2]; theTL[0] = Text_fileType; theTL[1] = Integrate_bin_fileType; myLFileStream *tempInFile = nil; switch (inMessage) { case msg_OK: { Hide(); StoreWindowValues(mPrefs); mPrefsHolder->SavePreferences(); try { mTheApp->SetInputFileAndProcessData(); } catch (myLFileStream::CancelErr) { // user canceled file selection dialog; do nothing } catch (LProgressDialog::StopClicked theStopClickException) { theStopClickException.theThrower->Hide(); Show(); } catch (CReduceApp::SimulationErr) { ObeyCommand(cmd_Quit, nil); } } break; case msg_Cancel: { ObeyCommand(cmd_Quit, nil); Hide(); } break; case msg_RestoreDefaults: { ListenToMessage(msg_ResetHoles, ioParam); PrefStruct *theDefaults = mPrefsHolder->GetDefaultPreferencesPtr(); SetValues(theDefaults); Refresh(); } break; case msg_SampleShape: case msg_InflateBBox: { // Inflating is incompatible with shave CheckShaveSettings(); } break; case msg_LoadHoles: { try { tempInFile = new myLFileStream(theTL, 2); mTheApp->SetHolesFile(tempInFile); LPushButton *theHolesBtn = (LPushButton *) mMiscPanel->FindPaneByID(item_LoadHoles); theHolesBtn->SetDescriptor("\pChange Holes File"); LStaticText *theHolesCapt = (LStaticText *) mMiscPanel->FindPaneByID(item_HolesFile); FSSpec tempSpec = tempInFile->GetSpec(); theHolesCapt->SetDescriptor(tempSpec.name); delete tempInFile; } catch (myLFileStream::CancelErr) { // user canceled file selection dialog; do nothing } } break; case msg_ResetHoles: { mTheApp->SetHolesFile(nil); LPushButton *theHolesBtn = (LPushButton *) mMiscPanel->FindPaneByID(item_LoadHoles); theHolesBtn->SetDescriptor("\pLoad \"Holes\" File"); LStaticText *theHolesCapt = (LStaticText *) mMiscPanel->FindPaneByID(item_HolesFile); if (tempInFile != nil) { FSSpec tempSpec = tempInFile->GetSpec(); } theHolesCapt->SetDescriptor("\pNone Selected"); } break; case msg_AspectRatioToggle: { if (value) { // if turning on mTheXYZPopup->Deactivate(); mMaxAR_ET->Deactivate(); mMaxAR_ST->Deactivate(); } else { mTheXYZPopup->Activate(); mMaxAR_ET->Activate(); mMaxAR_ST->Activate(); } } break; case msg_OutputSigmas: { // if not doing sigmas, must specify confidence level LEditText *theET = (LEditText *) mOutputPanel->FindPaneByID(item_Confidence); if (value == Button_On) { // if turning on sigmas StopListening(); theET->Disable(); StartListening(); } else { // turning off inflate StopListening(); theET->Enable(); StartListening(); } } break; case msg_ShaveSaveCB: { // if we Shave & Save, then we don't do any statistics if (value == Button_On) { // if turning on shave & save mTabPanel->EnableTab(CSD_index, false); mTabPanel->EnableTab(Stats_index, false); mTabPanel->EnableTab(Envelopes_index, false); mTabPanel->EnableTab(Output_index, false); } else { // turning off shave & save mTabPanel->EnableTab(CSD_index, true); mTabPanel->EnableTab(Stats_index, true); mTabPanel->EnableTab(Envelopes_index, true); mTabPanel->EnableTab(Output_index, true); } } break; case item_TabsPanel: { // panel management SInt32 panelIndex = *(SInt32 *) ioParam; switch ( panelIndex ) { case CSD_index: UseNewPanel(mCSDPanel); break; case Stats_index: UseNewPanel(mStatsPanel); break; case Envelopes_index: UseNewPanel(mEnvelopesPanel); break; case Output_index: UseNewPanel(mOutputPanel); break; case Misc_index: UseNewPanel(mMiscPanel); break; case Shave_index: UseNewPanel(mShavePanel); break; } } break; }}// ---------------------------------------------------------------------------// ¥ HandleKeyPress// ---------------------------------------------------------------------------// Handles keyboard equivalents for hitting the Default and// Cancel Buttons.//// Default Button: Enter, Return// Cancel Button: Escape, Command-PeriodBooleanCSettingsWindow::HandleKeyPress( const EventRecord &inKeyEvent){ Boolean keyHandled = false; LControl *keyButton = nil; switch (inKeyEvent.message & charCodeMask) { case char_Enter: case char_Return: keyButton = (LControl*) FindPaneByID(item_OK); break; case char_Escape: if ((inKeyEvent.message & keyCodeMask) == vkey_Escape) { keyButton = (LControl*) FindPaneByID(item_Cancel); } break; default: if (UKeyFilters::IsCmdPeriod(inKeyEvent)) { keyButton = (LControl*) FindPaneByID(item_Cancel); } else { keyHandled = LWindow::HandleKeyPress(inKeyEvent); } break; } if (keyButton != nil) { keyButton->SimulateHotSpotClick(kControlButtonPart); keyHandled = true; } return keyHandled;}// ---------------------------------------------------------------------------// ¥ UseNewPanel// ---------------------------------------------------------------------------voidCSettingsWindow::UseNewPanel(LView *inView){ mCurrentPanel->Hide(); mPanelHost->InstallOccupant(inView); inView->Show(); mPanelHost->Refresh(); mCurrentPanel = inView;}