// $Id: SctDialog.cpp,v 1.319 2011/07/22 16:33:23 philw Exp $ // SCT 2.0 Qt Dialog Box -- Qt3 and Qt4 Implementation // SEE ALSO SctDialog.Handlers.cpp (GUI event handlers) // // class SctDialog : public BaseQtMainWin ... // // Private Visitor Classes, SctDialog:: // class FlagSetter : public SctSlotTstepSet::ForEachFunction // class ValueSetter : public SctSlotTstepSet::ForEachFunction // class ValueAdjuster : public SctSlotTstepSet::ForEachFunction // class OutputValueClearer : public SctSlotTstepSet::ForEachFunction // class NoteSetter : public SctSlotTstepSet::ForEachFunction // //--- // New Development static const bool ENA_INTERP_INPUTS (false); // New Development (beyond 5.3) // General internal configuration static const int INITIAL_SCT_WIDTH (700); static const int INITIAL_SCT_HEIGHT (300); static const int MIN_SCT_WIDTH (100); static const int MIN_SCT_HEIGHT (80); static const bool SHOW_FLAG_BUTS (true); static const char* SCT_TITLE_GENERIC ("SCT 2.0"); static const int MAX_ITEMS_PER_JUMP_MENU (20); static const bool DT_SPIN_USE_3LETTER_MONTHS (true); // NOTE: As per TVA e-mail (Rusty Myers, 11-4-2009), the newly added // Loaded RPL Set buttons (in the SCT status bar) AND the newly added // (RPL-) "Policy" menu are NOT to be shown. // static const bool SHOW_RPLSET_STATUSBAR_BUTTONS (false); // SEE NOTE static const bool SHOW_RPL_POLICY_MENU (false); // SEE NOTE //---------- #ifndef SctDialogINCLUDED #include "SctDialog.hpp" #endif #ifndef SctViewNoAggTHorzINCLUDED #include "SctViewNoAggTHorz.hpp" #endif #ifndef SctViewNoAggTVertINCLUDED #include "SctViewNoAggTVert.hpp" #endif #ifndef SctViewAggTHorzINCLUDED #include "SctViewAggTHorz.hpp" #endif #ifndef SctViewAggTVertINCLUDED #include "SctViewAggTVert.hpp" #endif #ifndef SlotListPanelINCLUDED #include "SlotListPanel.hpp" #endif #ifndef SctConfigINCLUDED #include "SctConfig.hpp" #endif #ifndef SctModelDataINCLUDED #include "SctModelData.hpp" #endif #ifndef SctSlotTstepSetINCLUDED #include "SctSlotTstepSet.hpp" #endif #ifndef SctFlagButtonPixmapsINCLUDED #include "SctFlagButtonPixmaps.hpp" #endif #ifndef SctCopySetINCLUDED #include "SctCopySet.hpp" #endif #ifndef SctSetSumFuncDlgINCLUDED #include "SctSetSumFuncDlg.hpp" #endif #ifndef DiagOutputDockWindowINCLUDED #include "DiagOutputDockWindow.hpp" #endif #ifndef DiagOutputDlgMgrINCLUDED #include "DiagOutputDlgMgr.hpp" #endif #ifndef RplPolicyMenuINCLUDED #include "RplPolicyMenu.hpp" #endif #ifndef RwQtSettingsINCLUDED #include "RwQtSettings.hpp" #endif #ifndef DmiMenuItemsINCLUDED #include "DmiMenuItems.hpp" #endif #ifndef DiagOutputMenuItemsINCLUDED #include "DiagOutputMenuItems.hpp" #endif #ifndef LoadSaveMgrINCLUDED #include "LoadSaveMgr.hpp" #endif #ifndef SimWorkspaceINCLUDED #include "SimWS.hpp" #endif #ifndef QGuiINCLUDED #include "QGui.hpp" #endif #ifndef RwQtUtilsIncluded #include "RwQtUtils.hpp" #endif #ifndef AdjustSlotValsDlgINCLUDED #include "AdjustSlotValsDlg.hpp" #endif #ifndef ConfirmDlgsINCLUDED #include "ConfirmDlgs.hpp" #endif #ifndef RwQPixmap16INCLUDED #include "RwQPixmap16.hpp" #endif #ifndef RunIconsINCLUDED #include "RunAnalIcons.hpp" #endif #ifndef RplIconsINCLUDED #include "RplIcons.hpp" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef DateTimeQtSpinner_INCLUDED #include "DateTimeQtSpinner.hpp" #endif #undef slots #ifndef AnnoMgrINCLUDED #include "AnnoMgr.hpp" #endif #ifndef cwEnvINCLUDED #include "cwEnv.hpp" #endif #ifndef mrmControlINCLUDED #include "mrmControl.hpp" #endif #ifndef RuleSetMgrINCLUDED #include "RuleSetMgr.hpp" #endif #ifndef OptSetMgrINCLUDED #include "OptSetMgr.hpp" #endif #ifndef SlotClipboardINCLUDED #include "SlotClipboard.hpp" #endif #ifndef MethodCbINCLUDED #include "MethodCb.hpp" #endif #ifndef UnitMgrINCLUDED #include "UnitMgr.hpp" #endif #ifndef ScaledUnitINCLUDED #include "ScaledUnit.hpp" #endif #ifndef RootSelectionINCLUDED #include "RootSelection.hpp" #endif #ifdef Q_WS_X11 #include #endif #ifndef rwErrorINCLUDED #include "rwError.hpp" //--- for rwAssert #endif #include "rwStr.hpp" #include #if !defined(CW_MSVC) #include "values.h" #else #include #endif // ************************************* // *** Static member initializations *** // ************************************* QString SctDialog::_chooserPath = ""; bool SctDialog::_defaultDirAlreadyApplied_Scts (false); bool SctDialog::_exportCopyInclRowHeaders (false); bool SctDialog::_exportCopyInclColHeaders (false); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // constructor 1 of 1 SctDialog::SctDialog ( QWidget* /* parent */, const char* name, Qt::WFlags fl) : BaseQtMainWin (NULL, //--- NULL parent is workaround for bug name, fl | Qt::WDestructiveClose), _sctCfg (NULL), _sctModelDat (NULL), _sctTabWidget (NULL), _sctViewStack (NULL), _scalarListPanel (NULL), _nonSeriesListPanel (NULL), _sctInitialFont (), _curView (NULL), _aggTimeHorzView (NULL), _aggTimeVertView (NULL), _noAggTimeHorzView (NULL), _noAggTimeVertView (NULL), _diagOutDockWindow (NULL), _aggDef (), _selSlotTstepSet (NULL), _copySlotTstepSet (NULL), _cachedRhSelSlotTstepSet (NULL), _sctTimestepAggCfgDialog (NULL), _sctSetSumFuncDialog (NULL), _sctLabelFnDlg (NULL), _sctCfgDlg (NULL), _sctClipboardExportDlg (NULL), _sctFindSlotDlg (NULL), _slotSelectionType (SCT_SLOT_APPEND), _slotSelectionIndex (-1), _gusSelector (NULL), _rootSelection (NULL), _shipGoingDown (false), _statusBarUpdateRequestPosted (false), _statusBarOnlyDataUpdateRequested (false), _dtimeSpinnerInternalChangeInProgress (false), _columnWidthAdjustRequireNewColSelect (false), _fitRowHeadersAfterNextRebuild (false), _isMultiRun (false), _singleRI (NULL), _multiRI (NULL), _multiCtlr (NULL), _missingSlotListPanelSlotCnt (0), _rbsRuleSetMgrCallback (NULL), _optSetMgrCallback (NULL), _fullRecompTimer (NULL), _sctMainLayout (NULL), _menubar (NULL), _menu_File (NULL), _menu_SctShow (NULL), _menu_SctReOpen (NULL), _menu_Edit (NULL), _menu_Slots (NULL), _menu_Slots_Insert_Above (NULL), _menu_Slots_Insert_Below (NULL), _menu_Slots_Append (NULL), _menu_Aggregation (NULL), _menu_View (NULL), _menu_AxisOrient (NULL), _menu_CellText (NULL), _menu_Config (NULL), _menu_Policy (NULL), _menu_Dmi (NULL), _menu_Run (NULL), _menu_Jump (NULL), _menu_Diagnostics (NULL), _dmiMenuItems (NULL), _diagOutputMenuItems (NULL), _newSCTAction (NULL), _openSCTAction (NULL), _loadSctFileAction (NULL), _saveAsAction (NULL), _saveAction (NULL), _saveConfirmAction (NULL), _openModelAction (NULL), _saveModelAction (NULL), _saveModelAsAction (NULL), _printSelectionAction (NULL), _printPageAction (NULL), _printFullSctAction (NULL), _showWorkspaceAction (NULL), _closeOtherSctsAction (NULL), _closeWindowAction (NULL), _copyCellsAction (NULL), _pasteCellsAction (NULL), _pasteCellsAsInputAction (NULL), _copyExportCellsAction (NULL), _pasteImportCellsAction (NULL), _clearOutputsSelAction (NULL), _clearOutputsSctAction (NULL), _setToInputAction (NULL), _setToOutputAction (NULL), _clearValuesAction (NULL), _setTargetOpAction (NULL), _clearTargetOpsAction (NULL), _setBestEfficiencyAction (NULL), _setMaxCapacityAction (NULL), _setDriftAction (NULL), _setRuleDummyAction (NULL), _setUnitValuesAction (NULL), _interpolateSelAction (NULL), _interpolateInputsAction (NULL), _adjustValuesAction (NULL), _sctLockedToggleAction (NULL), _plotSlotsAction (NULL), _openSlotsAction (NULL), _findSlotAction (NULL), _slotConfigAction (NULL), _enaDispatchingAction (NULL), _disDispatchingAction (NULL), _setLabelAction (NULL), _insertAboveNewSlotsAction (NULL), _insertBelowNewSlotsAction (NULL), _appendNewSlotsAction (NULL), _reassignSlotAction (NULL), _insertAboveNewSDividerAction (NULL), _insertBelowNewSDividerAction (NULL), _appendNewSDividerAction (NULL), _copySlotsAction (NULL), _cutSlotsAction (NULL), _insertCopiedSlotsAction (NULL), _appendCopiedSlotsAction (NULL), _removeSlotsAction (NULL), _configTstepAggAction (NULL), _setAggSumFuncsAction (NULL), _detailModeActionGroup (NULL), _userDetailsToggleAction (NULL), _detailsClosedToggleAction (NULL), _detailsOpenToggleAction (NULL), _detailsOnlyToggleAction (NULL), _axisOrientActionGroup (NULL), _tstepsHorzAction (NULL), _tstepsVertAction (NULL), _cellTextActionGroup (NULL), _cellTextValuesAction (NULL), _cellTextFlagsAction (NULL), _cellTextPriosAction (NULL), _toggleRowDetailAction (NULL), _showConfigDlgAction (NULL), _showDiagPanelAction (NULL), _setDataColWidthsAction (NULL), _fitDataColsToHeadAction (NULL), _growColsToDataAction (NULL), _fitColsToDataAction (NULL), _fitDataColsToAllAction (NULL), _fitRowHeadersAction (NULL), _applyDefault (NULL), _saveAsDefault (NULL), _clearDefault (NULL), _pageUpAction (NULL), _pageDownAction (NULL), _pageLeftAction (NULL), _pageRightAction (NULL), _nextSlotAction (NULL), _prevSlotAction (NULL), _refreshAction (NULL), _showRunCtrlDlgAction (NULL), _startRunAction (NULL), _runAnalAction (NULL), _viewModeActionGroup (NULL), _entryLineEdit (NULL), _entryLineEditTbarAction (NULL), _valueInfoLabel (NULL), _valueInfoLabelTbarAction (NULL), _dtimeSpinner (NULL), _dtimeSpinnerTbarAction (NULL), _sctToolbar (NULL), _swapAxisToolAction (NULL), _userDetailsToolAction (NULL), _detailsClosedToolAction (NULL), _detailsOpenToolAction (NULL), _detailsOnlyToolAction (NULL), _copyDataToolAction (NULL), _pasteDataToolAction (NULL), _plotSlotsToolAction (NULL), _openSlotsToolAction (NULL), _showRunCtrlToolAction (NULL), _startRunToolAction (NULL), _runAnalToolAction (NULL), _saveModelToolAction (NULL), _lockedToolAction (NULL), _sizeColsCurToolAction (NULL), _growColsDataToolAction (NULL), _sizeColsDataToolAction (NULL), _sizeColsAllToolAction (NULL), _showDiagWinToolAction (NULL), _flag_O_toolAction (NULL), _flag_I_toolAction (NULL), _flag_T_toolAction (NULL), _flag_B_toolAction (NULL), _flag_M_toolAction (NULL), _flag_D_toolAction (NULL), _flag_S_toolAction (NULL), _flag_R_toolAction (NULL), _flag_G_toolAction (NULL), _flag_U_toolAction (NULL), _statusBarWidgetPanel (NULL), _statusBarWidgetHBox (NULL), _rplButtonPanelWidget (NULL), _rplButtonPanelBox (NULL), _loadedRbsRplSetButton (NULL), _loadedOptRplSetButton (NULL), _statusBarWidgetStack (NULL), _statusBarVBox (NULL), _statusRow1 (NULL), _statusRow2 (NULL), _runStatusBar (NULL), _runStatusLeftFrame (NULL), _runStatusRightFrame (NULL), _runStatusRow1 (NULL), _runStatusRow2 (NULL), _runStatusDispatchButton (NULL), _runStatusRow1LabelMulti (NULL), _runStatusRow1LabelSingle (NULL), _runProgressBarMulti (NULL), _runProgressBarSingle (NULL), _runStatusDismissBut (NULL), _runStatusRow2Label (NULL) { SctDiag1 { std::cout << "$Id: SctDialog.cpp,v 1.319 2011/07/22 16:33:23 philw Exp $" << std::endl; } (void) statusBar(); if (!name) setName ("SctDialog"); // Compute initial font spec from initial font of the SctDialog widget. _sctInitialFont = font(); QString initFontSpec (_sctInitialFont.toString()); // Create empty SctConfig object _sctCfg = new SctConfig (); // Apply Default Configuration SctManagerInst->applyDefaultConfig (_sctCfg, initFontSpec); // Set font specifications _sctCfg->setInitialFontSpec (initFontSpec); _sctCfg->initCustomFontSpec (FONTA_FONT_SPEC_NAME, initFontSpec); _sctCfg->initCustomFontSpec (FONTB_FONT_SPEC_NAME, initFontSpec); applyCurrentFont (false); // don't makeAdjustments // Create connection to RiverWare model _sctModelDat = new SctModelData (this); _sctModelDat->setSctConfigRef (_sctCfg); _sctModelDat->recompModelData (); checkRefreshSize (); refreshTitle(); _singleRI = rwWorkspace->getRunInfo(); _multiRI = rwWorkspace->getMultiRunInfo(); _multiCtlr = dynamic_cast(_multiRI->getController()); // Set Window Icon, and Stuff. QGui::setWindowLogoIcon (this); setAttribute (Qt::WA_AlwaysShowToolTips); // ********************************* // *** Create SCT Dialog Widgets *** // ********************************* setCentralWidget (new QWidget (this, "qt_central_widget")); _sctMainLayout = new QVBoxLayout (centralWidget(), 5, 3, "_sctMainLayout"); // toolbar _sctToolbar = addToolBar (tr ("SCT Toolbar")); QLayout* toolbarLayout (_sctToolbar->layout()); if (rwAssert (toolbarLayout != NULL)) { toolbarLayout->setSpacing (1); } // Set preferred icon size. Icons smaller than this will not be enlarged. // This is hard coded to 16x16 pixels being that that is the size of // the QPixmaps set on the Toolbar Actions, from QtUtils/RwQPixmap16.hpp _sctToolbar->setIconSize (QSize (16,16)); // Tool Bar - Disable docking on sides // (it is really bad in vertical orientation) _sctToolbar->setMovable (false); createActionToolButtons (_sctToolbar); //--------------------------- _sctToolbar->addSeparator (); //--------------------------- createFlagToolButtons (_sctToolbar); //--------------------------- _sctToolbar->addSeparator (); //--------------------------- _entryLineEdit = new QLineEdit( _sctToolbar, "_entryLineEdit" ); _entryLineEdit->setLineWidth( 1 ); _entryLineEdit->setText( tr( "" ) ); _entryLineEdit->setDragEnabled( FALSE ); QToolTip::add (_entryLineEdit, tr ("Edit value for currently selected data cell(s)")); Q3WhatsThis::add (_entryLineEdit, tr ("Edit value for currently selected data cell(s)")); QFontMetrics lineEditFontMetrics = _entryLineEdit->fontMetrics(); int minLineEditWidth = lineEditFontMetrics.width (" -888888.88 "); _entryLineEdit->setMinimumWidth (minLineEditWidth); _entryLineEditTbarAction = _sctToolbar->addWidget (_entryLineEdit); _valueInfoLabel = new QLabel( _sctToolbar, "_valueInfoLabel" ); _valueInfoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); QFontMetrics valueInfoFontMetrics = _valueInfoLabel->fontMetrics(); int minValInfoWidth = valueInfoFontMetrics.width ("1000 acre-feet/month"); _valueInfoLabel->setMinimumWidth (minValInfoWidth); QToolTip::add (_valueInfoLabel, tr ("Units for data edit field")); Q3WhatsThis::add (_valueInfoLabel, tr ("Units for data edit field")); _valueInfoLabelTbarAction = _sctToolbar->addWidget (_valueInfoLabel); //--------------------------- _sctToolbar->addSeparator (); //--------------------------- _dtimeSpinner = new DateTimeQtSpinner (_sctToolbar, "SCT DateTime Spinner"); QToolTip::add (_dtimeSpinner, tr ("Navigate to specified Timestep")); Q3WhatsThis::add (_dtimeSpinner, tr ("Navigate to specified Timestep")); initDateTimeSpinner (false); // don't attempt to preserve current DateTime _dtimeSpinnerTbarAction = _sctToolbar->addWidget (_dtimeSpinner); _sctTabWidget = new QTabWidget (centralWidget(), "_sctTabWidget"); _sctViewStack = new QStackedWidget (_sctTabWidget); _sctViewStack->setFrameStyle (QFrame::Sunken); _scalarListPanel = new SlotListPanel (SlotListPanel::APP_SCALARS, this, _sctTabWidget, "_scalarListPanel"); _nonSeriesListPanel = new SlotListPanel (SlotListPanel::APP_DEFAULT, this, _sctTabWidget, "_nonSeriesListPanel"); _sctTabWidget->addTab (_sctViewStack, tr ("Series Slots")); _sctTabWidget->addTab (_scalarListPanel, tr ("Scalar Slots")); _sctTabWidget->addTab (_nonSeriesListPanel, tr ("Other Slots")); _sctMainLayout->addWidget (_sctTabWidget); //--------------- _statusBarWidgetPanel = new QWidget (statusBar()); _statusBarWidgetPanel->setObjectName ("_statusBarWidgetPanel"); _statusBarWidgetHBox = new QHBoxLayout (_statusBarWidgetPanel); _statusBarWidgetHBox->setObjectName ("_statusBarWidgetHBox"); _statusBarWidgetHBox->setSpacing (3); _statusBarWidgetHBox->setMargin (0); statusBar()->addWidget (_statusBarWidgetPanel, 1, true); // stretch _statusBarWidgetStack = new QStackedWidget (_statusBarWidgetPanel); _statusBarWidgetStack->setLineWidth (0); _statusBarWidgetHBox->addWidget (_statusBarWidgetStack, 1); // stretch // Status Bar: Selection Status Mode _statusBarVBox = new Q3VBox (_statusBarWidgetStack); _statusBarWidgetStack->addWidget (_statusBarVBox); _statusBarVBox->setFrameStyle(QFrame::NoFrame | QFrame::Plain); _statusBarVBox->setMargin(3); _statusBarVBox->setSpacing(2); _statusRow1 = new QLineEdit ("", _statusBarVBox); _statusRow1->setFrame(false); _statusRow1->setReadOnly(true); _statusRow1->setAutoFillBackground (true); _statusRow1->setPaletteBackgroundColor(paletteBackgroundColor()); _statusRow2 = new QLineEdit ("", _statusBarVBox); _statusRow2->setFrame(false); _statusRow2->setReadOnly(true); _statusRow2->setAutoFillBackground (true); _statusRow2->setPaletteBackgroundColor(paletteBackgroundColor()); // Status Bar: Run Status Mode _runStatusBar = new QWidget (_statusBarWidgetStack); _statusBarWidgetStack->addWidget (_runStatusBar); buildRunStatusBar (_runStatusBar); connect (_runStatusDispatchButton, SIGNAL (clicked()), this, SLOT (runStatusDispatchStat_ButHandler())); connect (_runStatusDismissBut, SIGNAL (clicked()), this, SLOT (runStatusDismiss_ButHandler())); updateRunTypeStatusControls(); _statusBarWidgetStack->setCurrentWidget (_statusBarVBox); // Rpl Button Panel (in Status Bar) _rplButtonPanelWidget = new QWidget (_statusBarWidgetPanel); _rplButtonPanelWidget->setObjectName ("_rplButtonPanelWidget"); _rplButtonPanelBox = new QVBoxLayout (_rplButtonPanelWidget); // or HBox? _rplButtonPanelBox->setSpacing (1); _rplButtonPanelBox->setObjectName ("_rplButtonPanelBox"); _rplButtonPanelBox->setContentsMargins (-1, 0, -1, 0); // l,t,r,b _loadedRbsRplSetButton = new QPushButton (_rplButtonPanelWidget); _loadedRbsRplSetButton->setObjectName ("_loadedRbsRplSetButton"); _loadedOptRplSetButton = new QPushButton (_rplButtonPanelWidget); _loadedOptRplSetButton->setObjectName ("_loadedOptRplSetButton"); updateLoadedRplSetButtons(); connect (_loadedRbsRplSetButton, SIGNAL (clicked()), SLOT (loadedRbsRplSetButton_clicked())); connect (_loadedOptRplSetButton, SIGNAL (clicked()), SLOT (loadedOptRplSetButton_clicked())); _rplButtonPanelBox->addWidget (_loadedRbsRplSetButton); _rplButtonPanelBox->addWidget (_loadedOptRplSetButton); _statusBarWidgetHBox->addWidget (_rplButtonPanelWidget); //--------------- _newSCTAction = new QAction (this, "_newSCTAction"); _newSCTAction->setText (tr ("&New SCT ...")); _openSCTAction = new QAction (this, "_openSCTAction"); _openSCTAction->setText (tr ("&Open SCT ...")); _loadSctFileAction = new QAction (this, "_loadSctFileAction"); _loadSctFileAction->setText (tr ("Load SCT ...")); _saveAction = new QAction (this, "_saveAction"); _saveAction->setText (tr ("&Save SCT")); _saveConfirmAction = new QAction (RwQPixmap16::saveModel(), tr ("Save SCT"), this); _saveAsAction = new QAction (this, "_saveAsAction"); _saveAsAction->setText (tr ("Save SCT &As ...")); _openModelAction = new QAction (this, "_openModelAction"); _openModelAction->setText (tr ("Open Model ...")); _saveModelAction = new QAction (this, "_saveModelAction"); _saveModelAction->setText (tr ("Save &Model")); _saveModelAsAction = new QAction (this, "_saveModelAsAction"); _saveModelAsAction->setText (tr ("Save M&odel As ...")); _printSelectionAction = new QAction (this, "_printSelectionAction"); _printSelectionAction->setText (tr ("&Selection")); _printPageAction = new QAction (this, "_printPageAction"); _printPageAction->setText (tr ("&Page")); _printFullSctAction = new QAction (this, "_printFullSctAction"); _printFullSctAction->setText (tr ("&Full SCT")); _showWorkspaceAction = new QAction (this, "_showWorkspaceAction"); _showWorkspaceAction->setText (tr ("Show Workspace ...")); _closeOtherSctsAction = new QAction (this, "_closeOtherSctsAction"); _closeOtherSctsAction->setText (tr ("Close all other SCTs")); _closeWindowAction = new QAction (this, "_closeWindowAction"); _closeWindowAction->setText (tr ("&Close Window")); _copyCellsAction = new QAction (this, "_copyCellsAction"); _copyCellsAction->setText (tr ("&Copy cells")); _pasteCellsAction = new QAction (this, "_pasteCellsAction"); _pasteCellsAction->setText (tr ("&Paste cells")); _pasteCellsAsInputAction = new QAction (this, "_pasteCellsAsInputAction"); _pasteCellsAsInputAction->setText (tr ("Paste cells as I&nput")); // "Clear Outputs" >> ... _clearOutputsSelAction = new QAction (this, "_clearOutputsSelAction"); _clearOutputsSelAction->setText (tr ("within Selection")); // "Clear Outputs" >> ... _clearOutputsSctAction = new QAction (this, "_clearOutputsSctAction"); _clearOutputsSctAction->setText (tr ("whole SCT")); _copyExportCellsAction = new QAction (this, "_copyExportCellsAction"); _copyExportCellsAction->setText (tr ("Export Copy ...")); _pasteImportCellsAction = new QAction (this, "_pasteImportCellsAction"); _pasteImportCellsAction->setText (tr ("Import Paste ...")); _setToInputAction = new QAction (this, "_setToInputAction"); _setToInputAction->setText (tr ("Set to &Input")); _setToOutputAction = new QAction (this, "_setToOutputAction"); _setToOutputAction->setText (tr ("Set to &Output")); _clearValuesAction = new QAction (this, "_clearValuesAction"); _clearValuesAction->setText (tr ("Clear Values")); _setTargetOpAction = new QAction (this, "_setTargetOpAction"); _setTargetOpAction->setText (tr ("&Target Operation")); _clearTargetOpsAction = new QAction (this, "_clearTargetOpsAction"); _clearTargetOpsAction->setText (tr ("Clear Target Operation")); _setBestEfficiencyAction = new QAction (this, "_setBestEfficiencyAction"); _setBestEfficiencyAction->setText (tr ("&Best Efficiency")); _setMaxCapacityAction = new QAction (this, "_setMaxCapacityAction"); _setMaxCapacityAction->setText (tr ("&Max Capacity")); _setDriftAction = new QAction (this, "_setDriftAction"); _setDriftAction->setText (tr ("&Drift")); _setRuleDummyAction = new QAction (this, "_setRuleDummyAction"); _setRuleDummyAction->setText (tr ("Set by Rule")); _setUnitValuesAction = new QAction (this, "_setUnitValuesAction"); _setUnitValuesAction->setText (tr ("Unit Values")); _interpolateSelAction = new QAction (this, "_interpolateSelAction"); _interpolateSelAction->setText (tr ("Interpolate Selection")); _interpolateInputsAction = new QAction (this, "_interpolateInputsAction"); _interpolateInputsAction->setText (tr ("Interpolate Selected Inputs")); _adjustValuesAction = new QAction (this, "_adjustValuesAction"); _adjustValuesAction->setText (tr ("Adjust Values ...")); _sctLockedToggleAction = new QAction (this, "_sctLockedToggleAction"); _sctLockedToggleAction->setText (tr ("Lock SCT Configuration")); _sctLockedToggleAction->setToggleAction (true); _plotSlotsAction = new QAction (this, "_plotSlotsAction"); _plotSlotsAction->setText (tr ("&Plot Slots ...")); _openSlotsAction = new QAction (this, "_openSlotsAction"); _openSlotsAction->setText (tr ("&Open Slots ...")); _findSlotAction = new QAction (this, "_findSlotAction"); _findSlotAction->setText (tr ("&Find Slot ...")); _slotConfigAction = new QAction (this, "_slotConfigAction"); _slotConfigAction->setText (tr ("Slot &Configuration ...")); _enaDispatchingAction = new QAction (this, "_enaDispatchingAction"); _enaDispatchingAction->setText (tr ("&Enable Dispatching")); _disDispatchingAction = new QAction (this, "_disDispatchingAction"); _disDispatchingAction->setText (tr ("&Disable Dispatching")); _setLabelAction = new QAction (this, "_setLabelAction"); _setLabelAction->setText (tr ("Set &Label / Function ...")); _insertAboveNewSlotsAction = new QAction (this, "_insertAboveNewSlotsAction"); _insertAboveNewSlotsAction->setText (tr ("&Insert Slots ...")); _insertBelowNewSlotsAction = new QAction (this, "_insertBelowNewSlotsAction"); _insertBelowNewSlotsAction->setText (tr ("Insert Slots ...")); _appendNewSlotsAction = new QAction (this, "_appendNewSlotsAction"); _appendNewSlotsAction->setText (tr ("&Append Slots ...")); _reassignSlotAction = new QAction (this, "_reassignSlotAction"); _reassignSlotAction->setText (tr ("&Reassign Slot ...")); _insertAboveNewSDividerAction = new QAction (this, "_insertAboveNewSDividerAction"); _insertAboveNewSDividerAction->setText (tr ("Insert Slot Divider")); _insertBelowNewSDividerAction = new QAction (this, "_insertBelowNewSDividerAction"); _insertBelowNewSDividerAction->setText (tr ("Insert Slot Divider")); _appendNewSDividerAction = new QAction (this, "_appendNewSDividerAction"); _appendNewSDividerAction->setText (tr ("Append Slot Divider")); _copySlotsAction = new QAction (this, "_copySlotsAction"); _copySlotsAction->setText (tr ("Cop&y Slots / Dividers")); _cutSlotsAction = new QAction (this, "_cutSlotsAction"); _cutSlotsAction->setText (tr ("C&ut Slots / Dividers")); _insertCopiedSlotsAction = new QAction (this, "_insertCopiedSlotsAction"); _insertCopiedSlotsAction->setText (tr ("&Insert Copied Slots / Divs")); _appendCopiedSlotsAction = new QAction (this, "_appendCopiedSlotsAction"); _appendCopiedSlotsAction->setText (tr ("&Append Copied Slots / Divs")); _removeSlotsAction = new QAction (this, "_removeSlotsAction"); _removeSlotsAction->setText (tr ("Remove Slots / Dividers")); _configTstepAggAction = new QAction (this, "_configTstepAggAction"); _configTstepAggAction->setText (tr ("Timestep Aggregation &Config ...")); _setAggSumFuncsAction = new QAction (this, "_setAggSumFuncsAction"); _setAggSumFuncsAction->setText (tr ("Set Summary &Functions ...")); //------------- _detailModeActionGroup = new QActionGroup (this); _detailModeActionGroup -> setExclusive (true); _userDetailsToggleAction = new QAction (this, "_userDetailsToggleAction"); _userDetailsToggleAction->setText (tr ("Show/Hide &Details")); _userDetailsToggleAction->setIcon (RwQPixmap16::userDetails()); _userDetailsToggleAction->setToggleAction (true); _detailsClosedToggleAction = new QAction (this, "_detailsClosedToggleAction"); _detailsClosedToggleAction->setText (tr ("&Hide All Details")); _detailsClosedToggleAction->setIcon (RwQPixmap16::detailsClosed()); _detailsClosedToggleAction->setToggleAction (true); _detailsOpenToggleAction = new QAction (this, "_detailsOpenToggleAction"); _detailsOpenToggleAction->setText (tr ("&Show All Details")); _detailsOpenToggleAction->setIcon (RwQPixmap16::detailsOpen()); _detailsOpenToggleAction->setToggleAction (true); _detailsOnlyToggleAction = new QAction (this, "_detailsOnlyToggleAction"); _detailsOnlyToggleAction->setText (tr ("&No Aggregation")); _detailsOnlyToggleAction->setIcon (RwQPixmap16::detailsOnly()); _detailsOnlyToggleAction->setToggleAction (true); _detailModeActionGroup->addAction (_userDetailsToggleAction); _detailModeActionGroup->addAction (_detailsClosedToggleAction); _detailModeActionGroup->addAction (_detailsOpenToggleAction); _detailModeActionGroup->addAction (_detailsOnlyToggleAction); //------------- _axisOrientActionGroup = new QActionGroup (this); _axisOrientActionGroup -> setExclusive (true); _tstepsHorzAction = new QAction (this, "_tstepsHorzAction"); _tstepsHorzAction->setText (tr ("Timesteps &Horizontal")); _tstepsHorzAction->setToggleAction (true); _tstepsVertAction = new QAction (this, "_tstepsVertAction"); _tstepsVertAction->setText (tr ("Timesteps &Vertical")); _tstepsVertAction->setToggleAction (true); _axisOrientActionGroup->addAction (_tstepsHorzAction); _axisOrientActionGroup->addAction (_tstepsVertAction); //------------- _cellTextActionGroup = new QActionGroup (this); _cellTextActionGroup -> setExclusive (true); _cellTextValuesAction = new QAction (this, "_cellTextValuesAction"); _cellTextValuesAction->setText (tr ("Values Only")); _cellTextValuesAction->setToggleAction (true); _cellTextValuesAction->setChecked (true); _cellTextFlagsAction = new QAction (this, "_cellTextFlagsAction"); _cellTextFlagsAction->setText (tr ("also Flag Letters")); _cellTextFlagsAction->setToggleAction (true); _cellTextPriosAction = new QAction (this, "_cellTextPriosAction"); _cellTextPriosAction->setText (tr ("also Priority Numbers")); _cellTextPriosAction->setToggleAction (true); _cellTextActionGroup->addAction (_cellTextValuesAction); _cellTextActionGroup->addAction (_cellTextFlagsAction); _cellTextActionGroup->addAction (_cellTextPriosAction); //------------- _toggleRowDetailAction = new QAction (this, "_toggleRowDetailAction"); _toggleRowDetailAction->setText (tr ("&Toggle Row Detail")); _showConfigDlgAction = new QAction (this, "_showConfigDlgAction"); _showConfigDlgAction->setText (tr ("SCT &Configuration ...")); _showDiagPanelAction = new QAction (this, "_showDiagPanelAction"); _showDiagPanelAction->setText (tr ("Show Diagnostics ...")); _setDataColWidthsAction = new QAction (this, "_setDataColWidthsAction"); _setDataColWidthsAction->setText (tr ("&Set Data Column Widths")); _fitDataColsToHeadAction = new QAction (this, "_fitDataColsToHeadAction"); _fitDataColsToHeadAction->setText (tr ("&Fit Data Columns to Headers")); _growColsToDataAction = new QAction (this, "_growColsToDataAction"); _growColsToDataAction->setText (tr ("&Grow Columns to Data")); _fitColsToDataAction = new QAction (this, "_fitColsToDataAction"); _fitColsToDataAction->setText (tr ("Fit Columns to &Data")); _fitDataColsToAllAction = new QAction (this, "_fitDataColsToAllAction"); _fitDataColsToAllAction->setText (tr ("Fit Data Columns &Both")); _fitRowHeadersAction = new QAction (this, "_fitRowHeadersAction"); _fitRowHeadersAction->setText (tr ("Fit Row &Header Columns")); _setDataColWidthsAction -> setIconSet (RwQPixmap16::sizeColsCurEna()); _fitDataColsToHeadAction -> setIconSet (RwQPixmap16::sizeColsHeadEna()); _growColsToDataAction -> setIconSet (RwQPixmap16::growColsDataEna()); _fitColsToDataAction -> setIconSet (RwQPixmap16::sizeColsDataEna()); _fitDataColsToAllAction -> setIconSet (RwQPixmap16::sizeColsAllEna()); _applyDefault = new QAction (this, "_applyDefault"); _applyDefault->setText (tr ("Apply Default Settings")); _saveAsDefault = new QAction (this, "_saveAsDefault"); _saveAsDefault->setText (tr ("Save Current Settings as Default")); _clearDefault = new QAction (this, "_clearDefault"); _clearDefault->setText (tr ("Clear Default Settings")); _pageUpAction = new QAction (this, "_pageUpAction"); _pageUpAction->setText (tr ("Page Up")); _pageDownAction = new QAction (this, "_pageDownAction"); _pageDownAction->setText (tr ("Page Down")); _pageLeftAction = new QAction (this, "_pageLeftAction"); _pageLeftAction->setText (tr ("Page Left")); _pageRightAction = new QAction (this, "_pageRightAction"); _pageRightAction->setText (tr ("Page Right")); _nextSlotAction = new QAction (this, "_nextSlotAction"); _nextSlotAction->setText (tr ("Next Slot")); _prevSlotAction = new QAction (this, "_prevSlotAction"); _prevSlotAction->setText (tr ("Previous Slot")); _refreshAction = new QAction (this, "_refreshAction"); _refreshAction->setText (tr ("&Refresh")); _configGeneralAction = new QAction (this, "_configGeneralAction"); _configGeneralAction->setText (tr ("&General")); _configHorzTimeAction = new QAction (this, "_configHorzTimeAction"); _configHorzTimeAction->setText (tr ("&Horz Time")); _configVertTimeAction = new QAction (this, "_configVertTimeAction"); _configVertTimeAction->setText (tr ("&Vert Time")); _configFontAction = new QAction (this, "_configFontAction"); _configFontAction->setText (tr ("&Font")); _configToolbarAction = new QAction (this, "_configToolbarAction"); _configToolbarAction->setText (tr ("&Toolbar")); _configSummaryAction = new QAction (this, "_configSummaryAction"); _configSummaryAction->setText (tr ("&Summary")); _configFlagsAction = new QAction (this, "_configFlagsAction"); _configFlagsAction->setText (tr ("F&lags/Colors")); _configColorAction = new QAction (this, "_configColorAction"); _configColorAction->setText (tr ("&Color")); _showRunCtrlDlgAction = new QAction (this, "_showRunCtrlDlgAction"); _showRunCtrlDlgAction->setText (tr ("Run Control &Dialog ...")); _showRunCtrlDlgAction->setIcon (RwQPixmap16::showRunCtrl()); _startRunAction = new QAction (this, "_startRunAction"); _startRunAction->setText (tr ("Start &Run ...")); _startRunAction->setIcon (RwQPixmap16::startRun()); _runAnalAction = new QAction (this, "_runAnalAction"); _runAnalAction->setText (tr ("Run &Analysis ...")); const RunAnalIcons& raIcons (RunAnalIcons::instance()); _runAnalAction->setIcon (raIcons.Ra15_NotDispatched); // Accelerators // NOTE: See definitions in /usr/local/qt/include/qnamespace.h _saveModelAction ->setAccel (QKeySequence (tr ("Ctrl+S"))); _saveModelAsAction ->setAccel (QKeySequence (tr ("Ctrl+Shift+S"))); _closeWindowAction ->setAccel (QKeySequence (tr ("Ctrl+W"))); _copyCellsAction ->setAccel (QKeySequence (tr ("Ctrl+C"))); _pasteCellsAction ->setAccel (QKeySequence (tr ("Ctrl+V"))); _pasteCellsAsInputAction ->setAccel (QKeySequence (tr ("Ctrl+N"))); _setToInputAction ->setAccel (QKeySequence (tr ("Ctrl+I"))); _setToOutputAction ->setAccel (QKeySequence (tr ("Ctrl+O"))); _clearValuesAction ->setAccel (QKeySequence (Qt::Key_Delete)); _setTargetOpAction ->setAccel (QKeySequence (tr ("Ctrl+T"))); _setBestEfficiencyAction ->setAccel (QKeySequence (tr ("Ctrl+B"))); _setMaxCapacityAction ->setAccel (QKeySequence (tr ("Ctrl+M"))); _setDriftAction ->setAccel (QKeySequence (tr ("Ctrl+Shift+~"))); _plotSlotsAction ->setAccel (QKeySequence (tr ("Ctrl+P"))); _toggleRowDetailAction ->setAccel (QKeySequence (tr ("Ctrl+D"))); _fitRowHeadersAction ->setAccel (QKeySequence (tr ("Ctrl+F"))); _growColsToDataAction ->setAccel (QKeySequence (tr ("Ctrl+G"))); _pageUpAction ->setAccel (QKeySequence (Qt::Key_PageUp)); _pageDownAction ->setAccel (QKeySequence (Qt::Key_PageDown)); _pageLeftAction ->setAccel (QKeySequence (Qt::ALT + Qt::Key_PageUp)); _pageRightAction ->setAccel (QKeySequence (Qt::ALT + Qt::Key_PageDown)); _nextSlotAction ->setAccel (QKeySequence (Qt::Key_Tab)); _prevSlotAction ->setAccel (QKeySequence (Qt::SHIFT + Qt::Key_Tab)); _showRunCtrlDlgAction ->setAccel (QKeySequence (tr ("Ctrl+R"))); _startRunAction ->setAccel (QKeySequence (tr ("Ctrl+Shift+R"))); // _menubar _menubar = menuBar(); // ***************** // *** File Menu *** // ***************** _menu_File = _menubar->addMenu (tr ("&File")); _menu_File -> addAction (_newSCTAction); _menu_File -> addAction (_openSCTAction); _menu_SctShow = _menu_File->addMenu (tr ("Show")); _menu_SctReOpen = _menu_File->addMenu (tr ("&Reopen")); _menu_File -> addSeparator (); //---------- _menu_File -> addAction (_loadSctFileAction); _menu_File -> addAction (_saveAction); _menu_File -> addAction (_saveAsAction); _menu_File -> addSeparator (); //---------- _menu_File -> addAction (_openModelAction); _menu_File -> addAction (_saveModelAction); _menu_File -> addAction (_saveModelAsAction); _menu_File -> addSeparator (); //---------- QMenu* printOpPopup = _menu_File->addMenu (tr ("Print")); printOpPopup -> addAction (_printSelectionAction); printOpPopup -> addAction (_printPageAction); printOpPopup -> addAction (_printFullSctAction); _menu_File -> addSeparator (); //---------- _menu_File -> addAction (_showWorkspaceAction); _menu_File -> addAction (_closeOtherSctsAction); _menu_File -> addAction (_closeWindowAction); // ***************** // *** Edit Menu *** // ***************** _menu_Edit = _menubar->addMenu (tr ("&Edit")); _menu_Edit -> addAction (_copyCellsAction); _menu_Edit -> addAction (_pasteCellsAction); _menu_Edit -> addAction (_pasteCellsAsInputAction); _menu_Edit -> addSeparator (); //---------- _menu_Edit -> addAction (_copyExportCellsAction); _menu_Edit -> addAction (_pasteImportCellsAction); _menu_Edit -> addSeparator (); //---------- QMenu* clearOutputsPopup = _menu_Edit -> addMenu (tr ("Clear Outputs")); clearOutputsPopup -> addAction (_clearOutputsSelAction); clearOutputsPopup -> addAction (_clearOutputsSctAction); _menu_Edit -> addSeparator (); //---------- _menu_Edit -> addAction (_setToInputAction); _menu_Edit -> addAction (_setToOutputAction); _menu_Edit -> addAction (_clearValuesAction); _menu_Edit -> addSeparator (); //---------- _menu_Edit -> addAction (_setTargetOpAction); _menu_Edit -> addAction (_clearTargetOpsAction); _menu_Edit -> addAction (_setBestEfficiencyAction); _menu_Edit -> addAction (_setMaxCapacityAction); _menu_Edit -> addAction (_setDriftAction); _menu_Edit -> addAction (_setUnitValuesAction); _menu_Edit -> addSeparator (); //---------- _menu_Edit -> addAction (_interpolateSelAction); _menu_Edit -> addAction (_interpolateInputsAction); _menu_Edit -> addAction (_adjustValuesAction); _menu_Edit -> addSeparator (); //---------- _menu_Edit -> addAction (_sctLockedToggleAction); // New Development (beyond 5.3) _interpolateInputsAction -> setVisible (ENA_INTERP_INPUTS); // ****************** // *** Slots Menu *** // ****************** _menu_Slots = _menubar->addMenu (tr ("&Slots")); _menu_Slots -> addAction (_plotSlotsAction); _menu_Slots -> addAction (_openSlotsAction); //--------------------------------------------------- // Note [Phil, 11-5-2003] We may decide to refrain // from supporting the following function. // // _menu_Slots -> addAction (_slotConfigAction); //--------------------------------------------------- _menu_Slots -> addSeparator (); //---------- _menu_Slots -> addAction (_enaDispatchingAction); _menu_Slots -> addAction (_disDispatchingAction); _menu_Slots -> addSeparator (); //---------- _menu_Slots -> addAction (_setLabelAction); _menu_Slots -> addSeparator (); //---------- // -------------------------------------------------------------------------- // _menu_Slots_Insert_Above = new QPopupMenu (this); // _menu_Slots -> insertItem (tr ("&Insert Before"), // _menu_Slots_Insert_Above); // // _menu_Slots_Insert_Below = new QPopupMenu (this); // _menu_Slots -> insertItem (tr ("Insert After"), // _menu_Slots_Insert_Below); // // _menu_Slots_Append = new QPopupMenu (this); // _menu_Slots -> insertItem (tr ("&Append"), // _menu_Slots_Append); // // _insertAboveNewSlotsAction -> addTo (_menu_Slots_Insert_Above); // _insertAboveNewSDividerAction -> addTo (_menu_Slots_Insert_Above); // // _insertBelowNewSlotsAction -> addTo (_menu_Slots_Insert_Below); // _insertBelowNewSDividerAction -> addTo (_menu_Slots_Insert_Below); // // _appendNewSlotsAction -> addTo (_menu_Slots_Append); // _appendNewSDividerAction -> addTo (_menu_Slots_Append); // Note: The Slot Selector is now configured to support a "Divider" button. _menu_Slots -> addAction (_insertAboveNewSlotsAction); _menu_Slots -> addAction (_appendNewSlotsAction); _menu_Slots -> addAction (_reassignSlotAction); _menu_Slots -> addSeparator (); //---------- _menu_Slots -> addAction (_insertAboveNewSDividerAction); _menu_Slots -> addAction (_appendNewSDividerAction); _menu_Slots -> addSeparator (); //---------- _menu_Slots -> addAction (_copySlotsAction); _menu_Slots -> addAction (_cutSlotsAction); _menu_Slots -> addAction (_insertCopiedSlotsAction); _menu_Slots -> addAction (_appendCopiedSlotsAction); _menu_Slots -> addAction (_removeSlotsAction); // ************************ // *** Aggregation Menu *** // ************************ _menu_Aggregation = _menubar->addMenu (tr ("&Aggregation")); _menu_Aggregation -> addAction (_configTstepAggAction); _menu_Aggregation -> addAction (_setAggSumFuncsAction); _menu_Aggregation -> addSeparator (); //---------- _menu_Aggregation -> addAction (_userDetailsToggleAction); _menu_Aggregation -> addAction (_detailsClosedToggleAction); _menu_Aggregation -> addAction (_detailsOpenToggleAction); _menu_Aggregation -> addAction (_detailsOnlyToggleAction); // ***************** // *** View Menu *** // ***************** _menu_View = _menubar->addMenu (tr ("&View")); // This was broken out to a distinct "Config" menu, with actions // for selecting the individual tabbed pages. See below. // _menu_View -> addAction (_showConfigDlgAction); // This is redundant with operations in the Diagnostics Menu. See below. // _menu_View -> addAction (_showDiagPanelAction); _menu_AxisOrient = _menu_View -> addMenu (tr ("Axis Orientation")); _menu_AxisOrient -> addAction (_tstepsHorzAction); _menu_AxisOrient -> addAction (_tstepsVertAction); _menu_CellText = _menu_View -> addMenu (tr ("Cell Text")); _menu_CellText -> addAction (_cellTextValuesAction); _menu_CellText -> addAction (_cellTextFlagsAction); _menu_CellText -> addAction (_cellTextPriosAction); _menu_View -> addSeparator (); //---------- _menu_View -> addAction (_toggleRowDetailAction); _menu_View -> addSeparator (); //---------- _menu_View -> addAction (_setDataColWidthsAction); _menu_View -> addAction (_fitDataColsToHeadAction); _menu_View -> addAction (_growColsToDataAction); _menu_View -> addAction (_fitColsToDataAction); _menu_View -> addAction (_fitDataColsToAllAction); _menu_View -> addAction (_fitRowHeadersAction); _menu_View -> addSeparator (); //---------- _menu_View -> addAction (_pageUpAction); _menu_View -> addAction (_pageDownAction); _menu_View -> addAction (_pageLeftAction); _menu_View -> addAction (_pageRightAction); _menu_View -> addSeparator (); //---------- _menu_View -> addAction (_nextSlotAction); _menu_View -> addAction (_prevSlotAction); _menu_View -> addSeparator (); //---------- _menu_View -> addAction (_refreshAction); // ******************* // *** Config Menu *** // ******************* _menu_Config = _menubar->addMenu (tr ("&Config")); _menu_Config -> addAction (_configGeneralAction); _menu_Config -> addAction (_configHorzTimeAction); _menu_Config -> addAction (_configVertTimeAction); _menu_Config -> addAction (_configFontAction); _menu_Config -> addAction (_configToolbarAction); _menu_Config -> addAction (_configSummaryAction); _menu_Config -> addAction (_configFlagsAction); _menu_Config -> addAction (_configColorAction); _menu_Config -> addSeparator (); //---------- QMenu* _menu_Defaults = _menu_Config->addMenu (tr ("Defaults")); _menu_Defaults -> addAction (_applyDefault); _menu_Defaults -> addAction (_saveAsDefault); _menu_Defaults -> addAction (_clearDefault); // ******************* // *** Policy Menu *** // ******************* if (SHOW_RPL_POLICY_MENU) // See note with definition [TVA request]. { _menu_Policy = RplPolicyMenu::addToMenuBar (_menubar, (tr ("&Policy"))); } // **************** // *** DMI Menu *** // **************** _menu_Dmi = _menubar->addMenu (tr ("&DMI")); _dmiMenuItems = new DmiMenuItems (_menu_Dmi); // **************** // *** Run Menu *** // **************** _menu_Run = _menubar->addMenu (tr ("&Run")); _showRunCtrlDlgAction -> addTo (_menu_Run); _startRunAction -> addTo (_menu_Run); _runAnalAction -> addTo (_menu_Run); // ************************ // *** Diagnostics Menu *** // ************************ _menu_Diagnostics = _menubar->addMenu (tr ("Diag&nostics")); _diagOutputMenuItems = new DiagOutputMenuItems ( this, _menu_Diagnostics); // *************************** // *** "Go To" (Jump) Menu *** // *************************** reBuildJumpMenu(); //----------------------- installSctView(); initConnections(); refreshControls(); if (!rwSystem->runIsAllowed()) { disableModelRun(); } if (!rwSystem->modelEditIsAllowed() || rwWorkspace->isBaselineModel()) { disableModelEdit(); } // Register with SCT Manager SctManagerInst->addOrUpdateDialog (this); // Register Dialog Callbacks addDialogCallbacks(); QTimer::singleShot (250, this, SLOT (delayedInit_timeout())); } SctDialog::~SctDialog() { SctDiag1 { std::cout << "SctDialog destructor" << std::endl; } // Remove Dialog Callbacks deleteDialogCallbacks(); // Cancel "Full Recomp" timer cancelFullRecomp(); // Drop SlotListPanel listener connections _scalarListPanel->registerListener (NULL); _nonSeriesListPanel->registerListener (NULL); // Un-Register with SCT Manager SctManagerInst->removeDialog (this); dropCellSets (); closeSubDialogs (); closeViews (); if (_sctModelDat) { delete _sctModelDat; _sctModelDat = NULL; } if (_sctCfg) { delete _sctCfg; _sctCfg = NULL; } closeGusSlotSelector(); if (_rootSelection != NULL) { delete _rootSelection; _rootSelection = NULL; } if (_dmiMenuItems != NULL) { delete _dmiMenuItems; _dmiMenuItems = NULL; } if (_diagOutputMenuItems != NULL) { delete _diagOutputMenuItems; _diagOutputMenuItems = NULL; } } okstat SctDialog::openSctFile (const char* fname, SctDialog::SctOpenType openType) { static const char (*mname) ("SctDialog::openSctFile"); // This method only handles loading sct files into the new // SCT dialog. if ((openType != SCT_OPEN_FILE2) && (openType != SCT_OPEN_FILE1_SCT2)) { return (okstat)false; //=======================>> } //--------------------------------- // Not Done: Check for need to Save //--------------------------------- dropCellSets (); // ******************************* // *** Delete unused SCT Views *** // ******************************* if (_aggTimeHorzView) { _aggTimeHorzView -> clearView (true); if (_aggTimeHorzView != _curView) { delete (_aggTimeHorzView); _aggTimeHorzView = NULL; } } if (_aggTimeVertView) { _aggTimeVertView -> clearView (true); if (_aggTimeVertView != _curView) { delete (_aggTimeVertView); _aggTimeVertView = NULL; } } if (_noAggTimeHorzView) { _noAggTimeHorzView -> clearView (true); if (_noAggTimeHorzView != _curView) { delete (_noAggTimeHorzView); _noAggTimeHorzView = NULL; } } if (_noAggTimeVertView) { _noAggTimeVertView -> clearView (true); if (_noAggTimeVertView != _curView) { delete (_noAggTimeVertView); _noAggTimeVertView = NULL; } } _aggDef.clearAggs (); if (_sctCfgDlg) { _sctCfgDlg->close (true); } SctConfig (*newConfig)(NULL); SctModelData (*newModelData)(NULL); // Load the test data okstat loadSuccess(false); // Load one of the real SCT files. if (openType == SCT_OPEN_FILE1_SCT2) { newConfig = SctConfig::createFromSct1File(fname, loadSuccess); } else if (openType == SCT_OPEN_FILE2) { newConfig = SctConfig::createFromFile(fname, loadSuccess); } if (loadSuccess.err()) { QMessageBox::warning(NULL, "RiverWare Warning", "The file \"" + QString(fname) + "\" cannot be loaded.\n" + loadSuccess.msg()); if (newConfig) { delete newConfig; } return loadSuccess; // error //=========================>> } newModelData = new SctModelData (this); QFileInfo fInfo (fname); newConfig->setSctName (fInfo.fileName()); setChooserPath(fInfo.filePath()); // Clear the current sct file structures and install the new ones if (_sctCfg) delete _sctCfg; _sctCfg = newConfig; if (_sctModelDat) delete _sctModelDat; _sctModelDat = newModelData; _sctModelDat->setSctConfigRef (_sctCfg); _sctModelDat->recompModelData (); // Populate the Slot List Panels, but undo the side-effect of // having the newly added Slot Items of becoming selected. loadSlotListPanelListsFromConfig(); if (_scalarListPanel) _scalarListPanel -> clearListSelection(); if (_nonSeriesListPanel) _nonSeriesListPanel -> clearListSelection(); if (_curView) { _curView->reConfigView (_sctCfg, _sctModelDat, SCT_RESCROLL_SLOT_BEGIN); } checkRefreshSize (); refreshTitle(); SctDetailMode dmode (detailMode()); if (dmode == SCT_DETAIL_MODE_UND) dmode = SCT_DETAIL_MODE_NO_SUMMARIES; setDetailMode (dmode); // Save initial Font QString initFontSpec (_sctInitialFont.toString()); _sctCfg->setInitialFontSpec (initFontSpec); // Set Font on SctDialog and all defined SctViews _sctCfg->initCustomFontSpec (FONTA_FONT_SPEC_NAME, initFontSpec); _sctCfg->initCustomFontSpec (FONTB_FONT_SPEC_NAME, initFontSpec); applyCurrentFont (false); // don't makeAdjustments refreshControls (); fullRecomp (SCT_RESCROLL_SLOT_BEGIN); QTimer::singleShot (250, this, SLOT (delayedInit_timeout())); return (okstat) true; } void SctDialog::rebuild (SctRescrollType scrollType /*=SCT_RESCROLL_PRESERVE*/) { static const char (*mname) ("SctDialog::rebuild"); // Populate the Slot List Panels, but undo the side-effect of // having the newly added Slot Items of becoming selected. loadSlotListPanelListsFromConfig(); if (_scalarListPanel) _scalarListPanel -> clearListSelection(); if (_nonSeriesListPanel) _nonSeriesListPanel -> clearListSelection(); fullRecomp (scrollType); // If a Slot was added since the last rebuild, select the Tab on which // that Slot appears. selectTabWithLastAddedSlot (true); // clearLastAddedInfo if (_fitRowHeadersAfterNextRebuild && currentTab_isSctView()) { // std::cout << mname << " fitRowHeaders" << std::endl; fitRowHeaders (false); // not grow only _fitRowHeadersAfterNextRebuild = false; } _sctTabWidget->update(); } void SctDialog::fitRowHeadersAfterNextRebuild() { _fitRowHeadersAfterNextRebuild = true; } bool SctDialog::isLoaded () const { return (_sctCfg && _sctCfg->isLoaded()); } void SctDialog::setLocked (bool locked) { if (_sctCfg) { _sctCfg->setConfigLocked(locked); refreshControls(); } } /* static */ SctDialog::SctOpenType SctDialog::getSctFnameVersion (QString &fnameRet, bool promptOld, QWidget *parent) { SctOpenType openRetVal (SCT_OPEN_CANCEL); QString fname (fnameRet); QString initDir ("./"); // tentative if (!_chooserPath.isEmpty()) { initDir = _chooserPath; } // Override the initial directory with the user-defined default directory // (via environment variable) if it is defined. But do so only once in // a RiverWare session. // if (!_defaultDirAlreadyApplied_Scts) { const QString userDefaultDir = LoadSaveMgr::defaultSctDir(); if (!userDefaultDir.isEmpty()) { initDir = userDefaultDir; } // Set the _defaultDirAlreadyApplied_Scts flag below only if the // user completes the SCT selection operation. } QString& selFilterRef (LoadSaveMgrInst->selFilterRef_scts()); const QString initSelFilter (selFilterRef); // If the given FileName path is empty, show the file selector. if (fname.isEmpty()) { fname = Q3FileDialog::getOpenFileName( initDir, SctFileFilterStr, // (defined in SctTypes.hpp) parent, // parent "Load SCT File", // name "Load SCT File", // caption &selFilterRef); } if (fname.isEmpty()) return openRetVal; //===================================>> // Prevent reuse of the user-defined default directory (via environment // variable) within this RiverWare session. _defaultDirAlreadyApplied_Scts = true; if (selFilterRef != initSelFilter) { LoadSaveMgrInst->saveSelectedFilters(); } // Determine whether this is the old Sct file format bool isSct1; if (SctConfig::isSct1Format(fname, isSct1).err()) { QMessageBox::warning(NULL, "Riverware Warning", "The file \"" + QString(fname) + "\" cannot be loaded.\n" + "It is not a valid SCT file."); return openRetVal; //=======================>> } // If this is the old format, ask the user whether they want to // open in the old or new Sct dialog. if (isSct1) { if (promptOld) { int userResp (QMessageBox::information (parent, "Riverware SCT", "This is an SCT 1.0 file. Would you like to migrate\n" "to the SCT 2.0 dialog or open this with the SCT 1.0 dialog?", "&SCT 2.0", "&SCT 1.0", "Cancel", 0, // Enter == button 0 2 )); // Escape == button 2 switch (userResp) { case 0: // New SCT selected openRetVal = SCT_OPEN_FILE1_SCT2; break; case 1: // Old SCT selected openRetVal = SCT_OPEN_FILE1_SCT1; break; case 2: // Cancel clicked openRetVal = SCT_OPEN_CANCEL; break; } } else { // Don't give the user an option, just open the // old file format in Sct 2. openRetVal = SCT_OPEN_FILE1_SCT2; } } else { openRetVal = SCT_OPEN_FILE2; } fnameRet = fname; return openRetVal; } /* static */ void SctDialog::setChooserPath (QString path) { SctDialog::_chooserPath = path; } SctOrientation SctDialog::curSctOrientation () const { // Refer to the SctConfig object if it exists if (_sctCfg) { return (_sctCfg->tstepAxisHorz() ? SCT_ORIENT_TIME_HORZ : SCT_ORIENT_TIME_VERT); } // Otherwise, use the current GUI state if (_swapAxisToolAction && _swapAxisToolAction->isChecked()) return (SCT_ORIENT_TIME_VERT); return (SCT_ORIENT_TIME_HORZ); } void SctDialog::showAppendSlotsQuery() { static const char (*mname) ("SctDialog::showAppendSlotsQuery"); // Don't bother if the workspace is empty if (!SctModelData::isWorkspaceEmpty()) { int userResponse = QMessageBox::information ( this, // parent widget "Add Slots to new SCT", // caption "To add Slots to this SCT, select one of the Insert or Append\n" "operations from the Slots menu, or click 'Add Slots' now:", "Add Slots", // button0 text "Cancel", // button1 text QString::null, // button2 text 1); // default button number switch (userResponse) { case 0: /* Add Slots */ addNewSlotsHandler(SCT_SLOT_APPEND); break; case 1: /* Cancel */ break; } } QTimer::singleShot (250, this, SLOT (delayedInit_timeout())); } void SctDialog::setDateTimeSpinner (const Date_Time& when, bool scrollToo /*=false*/) { if (_dtimeSpinner == NULL) return; //------------------------------>> // In case the spinner is not yet initialized ... initDateTimeSpinner (true); // Block scroll processing unless 'scrollToo' is requested const bool doBlock = (!scrollToo); //------------------------------------------------------------------ bool inProgressSave (_dtimeSpinnerInternalChangeInProgress); _dtimeSpinnerInternalChangeInProgress = (doBlock || inProgressSave); //------------------------------------------------------------------ _dtimeSpinner->setDateTime (when); //------------------------------------------------------------------ _dtimeSpinnerInternalChangeInProgress = inProgressSave; //------------------------------------------------------------------ } bool SctDialog::cellTextShowFlags() const { bool doShow (false); // tentative if (_cellTextActionGroup != NULL) { const QAction* cur = _cellTextActionGroup->checkedAction(); doShow = (cur == _cellTextFlagsAction) || (cur == _cellTextPriosAction); } return (doShow); } bool SctDialog::cellTextShowPrios() const { bool doShow (false); // tentative if (_cellTextActionGroup != NULL) { const QAction* cur = _cellTextActionGroup->checkedAction(); doShow = (cur == _cellTextPriosAction); } return (doShow); } void SctDialog::setShowFlagLetters (bool newChecked) { if (_cellTextFlagsAction != NULL) { const bool wasChecked = cellTextShowFlags(); if (wasChecked != newChecked) { _cellTextFlagsAction->setChecked (newChecked); } } } void SctDialog::setShowPriorities (bool newChecked) { if (_cellTextPriosAction != NULL) { const bool wasChecked = cellTextShowPrios(); if (wasChecked != newChecked) { _cellTextPriosAction->setChecked (newChecked); } } } // Virtual from BaseRWDlg void SctDialog::notifyAppFontChanged() { static const char (*mname) ("SctDialog::notifyAppFontChanged"); // std::cout << mname << std::endl; // Override Initial Font Spec _sctInitialFont = QApplication::font(); const QString initFontSpec (_sctInitialFont.toString()); if (_sctCfg) { _sctCfg->setInitialFontSpec (initFontSpec); } if (_sctCfgDlg) { _sctCfgDlg->notifyAppFontChanged (_sctCfg); } applyCurrentFont (true); // makeAdjustments } SctDetailMode SctDialog::detailMode () const { if (!_sctCfg) { return SCT_DETAIL_MODE_USER; } SctDetailMode mode (_sctCfg->detailMode()); if (mode == SCT_DETAIL_MODE_UND) { // Override constness of this method. SctDialog (*nonConstDlg) ((SctDialog*) this); nonConstDlg->setDetailMode (SCT_DETAIL_MODE_USER, false); return SCT_DETAIL_MODE_USER; } return mode; } void SctDialog::installSctView () { static const char (*mname) ("SctDialog::installSctView"); SctView* sctView (NULL); bool newViewCreated (false); // tentative if (curSctOrientation() == SCT_ORIENT_TIME_HORZ) { switch (detailMode()) { case SCT_DETAIL_MODE_NO_SUMMARIES: if (_noAggTimeHorzView == NULL) { newViewCreated = true; _noAggTimeHorzView = new SctViewNoAggTHorz (this, _sctViewStack); _noAggTimeHorzView->reConfigView (_sctCfg, _sctModelDat, SCT_RESCROLL_NOP); } sctView = _noAggTimeHorzView; break; case SCT_DETAIL_MODE_ALL_OPEN: case SCT_DETAIL_MODE_ALL_CLOSED: case SCT_DETAIL_MODE_USER: default: if (_aggTimeHorzView == NULL) { newViewCreated = true; _aggTimeHorzView = new SctViewAggTHorz (this, _sctViewStack); _aggTimeHorzView->reConfigView (_sctCfg, _sctModelDat, SCT_RESCROLL_NOP); } sctView = _aggTimeHorzView; break; } } else { switch (detailMode()) { case SCT_DETAIL_MODE_NO_SUMMARIES: if (_noAggTimeVertView == NULL) { newViewCreated = true; _noAggTimeVertView = new SctViewNoAggTVert (this, _sctViewStack); _noAggTimeVertView->reConfigView (_sctCfg, _sctModelDat, SCT_RESCROLL_NOP); } sctView = _noAggTimeVertView; break; case SCT_DETAIL_MODE_ALL_OPEN: case SCT_DETAIL_MODE_ALL_CLOSED: case SCT_DETAIL_MODE_USER: default: if (_aggTimeVertView == NULL) { newViewCreated = true; _aggTimeVertView = new SctViewAggTVert (this, _sctViewStack); _aggTimeVertView->reConfigView (_sctCfg, _sctModelDat, SCT_RESCROLL_NOP); } sctView = _aggTimeVertView; break; } } _curView = sctView; _columnWidthAdjustRequireNewColSelect = true; // refresh details open/close status even if the SctView hasn't // changed since the result is dependent also on the detail mode. if (_curView) { _curView->refreshAllShowDetails (false); // no redraw _sctViewStack->setCurrentWidget (_curView); if (currentTab_isSctView()) { _sctViewStack->show(); _curView->guiRefresh (); // Since the Qt4-compatibility port, switching to a vertical time // views resulted in an extremely overly-wide Row Header Table // (with lots of blank space). This fixes that. _curView->fitRowHeaderAndSplitter (false); // not growOnly if (newViewCreated) { // std::cout << mname << " newViewCreated" << std::endl; _curView->fitDataColsToDataText (true); // growOnly } QTimer::singleShot (250, this, SLOT (delayedInit_timeout())); } } refreshMenuSensitivity(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void SctDialog::buildRunStatusBar (QWidget* runStatusBar) { // QWidget* _runStatusLeftFrame; // QWidget* _runStatusRightFrame; // QWidget* _runStatusRow1; // QWidget* _runStatusRow2; // QPushButton* _runStatusDispatchButton; // QLabel* _runStatusRow1LabelMulti; // QLabel* _runStatusRow1LabelSingle; // QProgressBar* _runProgressBarMulti; // QProgressBar* _runProgressBarSingle; // QPushButton* _runStatusDismissBut; // QLabel* _runStatusRow2Label; QHBoxLayout* runStatMHBoxLayout = new QHBoxLayout (runStatusBar); runStatMHBoxLayout->setObjectName (tr ("runStatMHBoxLayout")); runStatMHBoxLayout->setContentsMargins (6, 4, 6, 3); // left, top, rgt, bot runStatMHBoxLayout->setSpacing (14); // ******************** // *** Left Frame *** // ******************** _runStatusLeftFrame = new QWidget (runStatusBar); _runStatusLeftFrame->setObjectName (tr ("_runStatusLeftFrame")); QHBoxLayout* leftFrameHboxLayout = new QHBoxLayout (_runStatusLeftFrame); leftFrameHboxLayout->setObjectName (tr ("leftFrameHboxLayout")); leftFrameHboxLayout->setContentsMargins (0, 0, 0, 0); leftFrameHboxLayout->setSpacing (2); _runStatusDispatchButton = new QPushButton (_runStatusLeftFrame); _runStatusDispatchButton->setObjectName (tr ("_runStatusDispatchButton")); leftFrameHboxLayout->addWidget (_runStatusDispatchButton); runStatMHBoxLayout->addWidget (_runStatusLeftFrame); // ********************* // *** Right Frame *** // ********************* _runStatusRightFrame = new QWidget (runStatusBar); _runStatusRightFrame->setObjectName (tr ("_runStatusRightFrame")); QVBoxLayout* rightFrameVboxLayout = new QVBoxLayout (_runStatusRightFrame); rightFrameVboxLayout->setSpacing (3); rightFrameVboxLayout->setObjectName (tr ("rightFrameVboxLayout")); rightFrameVboxLayout->setContentsMargins (0, 0, 0, 0); rightFrameVboxLayout->setSpacing (2); _runStatusRow1 = new QWidget (_runStatusRightFrame); _runStatusRow2 = new QWidget (_runStatusRightFrame); _runStatusRow1->setObjectName (tr ("_runStatusRow1")); _runStatusRow2->setObjectName (tr ("_runStatusRow2")); QHBoxLayout* row1HboxLayout = new QHBoxLayout (_runStatusRow1); row1HboxLayout->setObjectName (tr ("runStatMHBoxLayout2")); row1HboxLayout->setContentsMargins (0, 0, 0, 0); row1HboxLayout->setSpacing (2); QHBoxLayout* row2HboxLayout = new QHBoxLayout (_runStatusRow2); row2HboxLayout->setObjectName (tr ("row2HboxLayout")); row2HboxLayout->setContentsMargins (0, 0, 0, 0); row2HboxLayout->setSpacing (2); _runStatusRow1LabelMulti = new QLabel (_runStatusRow1); _runProgressBarMulti = new QProgressBar (_runStatusRow1); _runStatusRow1LabelSingle = new QLabel (_runStatusRow1); _runProgressBarSingle = new QProgressBar (_runStatusRow1); _runStatusDismissBut = new QPushButton (_runStatusRow1); _runStatusRow2Label = new QLabel (_runStatusRow2); _runStatusRow1LabelMulti->setObjectName (tr ("_runStatusRow1LabelMulti")); _runProgressBarMulti->setObjectName (tr ("_runProgressBarMulti")); _runStatusRow1LabelSingle->setObjectName (tr ("_runStatusRow1LabelSingle")); _runProgressBarSingle->setObjectName (tr ("_runProgressBarSingle")); _runStatusDismissBut->setObjectName (tr ("_runStatusDismissBut")); _runStatusRow2Label->setObjectName (tr ("_runStatusRow2Label")); row1HboxLayout->addWidget (_runStatusRow1LabelMulti); row1HboxLayout->addWidget (_runProgressBarMulti); row1HboxLayout->addWidget (_runStatusRow1LabelSingle); row1HboxLayout->addWidget (_runProgressBarSingle); row1HboxLayout->addStretch (15); // minimum width row1HboxLayout->addWidget (_runStatusDismissBut); row2HboxLayout->addWidget (_runStatusRow2Label); rightFrameVboxLayout->addWidget (_runStatusRow1); rightFrameVboxLayout->addWidget (_runStatusRow2); runStatMHBoxLayout->addWidget (_runStatusRightFrame); _runStatusRow1LabelMulti -> setText (tr ("Multi")); _runStatusRow1LabelSingle -> setText (tr ("Single")); _runStatusDismissBut -> setText (tr ("Dismiss")); _runStatusRow2Label -> setText (tr ("Status")); _runStatusDispatchButton -> setText (QString::null); _runStatusDispatchButton -> setContentsMargins (0,0,0,0); _runStatusDispatchButton -> setFixedSize (36, 36); _runStatusDispatchButton -> setIconSize (QSize (30, 30)); // Clear the Run StatusBar Dispatch Status Button Icon clearRunStatusDispatchButton(); _runStatusDispatchButton->setToolTip (tr ( "Show the Run Analysis Dialog\n" "Shift-Click: Dispatch Status Summary")); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void SctDialog::reBuildJumpMenu () { static const char (*mname) ("SctDialog::reBuildJumpMenu"); if (_menu_Jump == NULL) { _menu_Jump = _menubar->addMenu (tr ("&Go To")); } // remove previously created items _menu_Jump->clear(); if (_findSlotAction != NULL) { _findSlotAction -> addTo (_menu_Jump); _menu_Jump -> addSeparator (); //---------- } if (_sctCfg == NULL) return; //------------------------>> int divCnt (_sctCfg->slotDividerCnt()); int subMenusNeeded (0); int itemsPerJumpMenu (divCnt); // tentative bool useSubMenus (divCnt > MAX_ITEMS_PER_JUMP_MENU); if (useSubMenus) { subMenusNeeded = ((divCnt-1) / MAX_ITEMS_PER_JUMP_MENU) + 1; itemsPerJumpMenu = ((divCnt-1) / subMenusNeeded) + 1; } // std::cout << mname << ": divCnt: " << divCnt // << ", subMenusNeeded: " << subMenusNeeded // << ", itemsPerJumpMenu: " << itemsPerJumpMenu // << std::endl; int subMenuCnt (0); int subMenuItemCnt (0); QMenu *curSubMenu (NULL); int cfgSlotCnt (_sctCfg->slotCnt()); int jumpItemCnt (0); bool useNextSlotItem (false); int lastDivInx (-1); for (int slotInx = 0; slotInx < cfgSlotCnt; ++slotInx) { // Search for the next Slot Divider (type 'D'). const char itemType (_sctCfg->itemType (slotInx)); if ((itemType != 'D') && !useNextSlotItem) continue; //-------------------------------------------------- if (itemType == 'D') lastDivInx = slotInx; const QString slotItemLabel = (_sctCfg->slotLabel (slotInx)) .stripWhiteSpace(); if (slotItemLabel.isEmpty() || (slotItemLabel == "New Divider")) { useNextSlotItem = true; continue; //----------- } // cancel request to use subsequent Slot Item useNextSlotItem = false; QMenu* insertionMenuData (_menu_Jump); if (useSubMenus) { ++subMenuItemCnt; if ((curSubMenu == NULL) || (subMenuItemCnt > itemsPerJumpMenu)) { ++subMenuCnt; subMenuItemCnt = 1; QString subMenuLabel (QString::number (subMenuCnt)); curSubMenu = new QMenu (_menu_Jump); _menu_Jump->insertItem (subMenuLabel, curSubMenu); } insertionMenuData = curSubMenu; } insertionMenuData->insertItem ( slotItemLabel, // text string this, // QObject* receiver SLOT(jumpSlotItem_Handler(int)), // const char* member 0, // accel (none) lastDivInx); // int id ++jumpItemCnt; } if (jumpItemCnt == 0) { _menu_Jump->insertItem ( "Instructions ...", // text string this, // QObject* receiver SLOT(jumpSlotHelp_Handler(int)), // const char* member 0, // accel (none) 0); // int parm, not used yet. } } void SctDialog::createActionToolButtons (QToolBar* toolbar) { // *************************** // *** Create Tool Buttons *** // *************************** _saveModelToolAction = toolbar->addAction ( RwQPixmap16::saveModel(), tr ("Save Model")); _lockedToolAction = toolbar->addAction ( RwQPixmap16::lockedIconSet(), tr ("Lock SCT Config")); _lockedToolAction->setCheckable (true); //----------------------- toolbar->addSeparator (); //----------------------- _swapAxisToolAction = toolbar->addAction ( RwQPixmap16::swapAxis(), tr ("Swap Axis")); _swapAxisToolAction->setCheckable (true); _viewModeActionGroup = new QActionGroup (toolbar); _viewModeActionGroup->setExclusive (true); _userDetailsToolAction = toolbar->addAction ( RwQPixmap16::userDetails(), tr ("User Controlled Details")); _detailsClosedToolAction = toolbar->addAction ( RwQPixmap16::detailsClosed(), tr ("Summaries Only")); _detailsOpenToolAction = toolbar->addAction ( RwQPixmap16::detailsOpen(), tr ("All Details Open")); _detailsOnlyToolAction = toolbar->addAction ( RwQPixmap16::detailsOnly(), tr ("Details Only")); _userDetailsToolAction -> setCheckable (true); _detailsClosedToolAction -> setCheckable (true); _detailsOpenToolAction -> setCheckable (true); _detailsOnlyToolAction -> setCheckable (true); _viewModeActionGroup->addAction (_userDetailsToolAction); _viewModeActionGroup->addAction (_detailsClosedToolAction); _viewModeActionGroup->addAction (_detailsOpenToolAction); _viewModeActionGroup->addAction (_detailsOnlyToolAction); //----------------------- toolbar->addSeparator (); //----------------------- _copyDataToolAction = toolbar->addAction ( RwQPixmap16::copyDataIconSet(), tr ("Copy Data")); _pasteDataToolAction = toolbar->addAction ( RwQPixmap16::pasteDataIconSet(), tr ("Paste Data")); //----------------------- toolbar->addSeparator (); //----------------------- _plotSlotsToolAction = toolbar->addAction ( RwQPixmap16::plotSlots(), tr ("Plot Slots")); _openSlotsToolAction = toolbar->addAction ( RwQPixmap16::openSlots(), tr ("Open Slots")); _showDiagWinToolAction = toolbar->addAction ( DiagOutputDlgMgr::showDiagWinButtonPixmap16(), tr ("Show/Hide Diagnostics")); _showRunCtrlToolAction = toolbar->addAction ( RwQPixmap16::showRunCtrl(), tr ("Show Run Control")); _startRunToolAction = toolbar->addAction ( RwQPixmap16::startRun(), tr ("Start Run")); const RunAnalIcons& raIcons (RunAnalIcons::instance()); _runAnalToolAction = toolbar->addAction ( raIcons.Ra15_NotDispatched, tr ("Run Analysis")); //----------------------- toolbar->addSeparator (); //----------------------- _sizeColsCurToolAction = toolbar->addAction ( RwQPixmap16::sizeColsCurIconSet(), tr ("Resize Columns: Set All to Selected Column width")); _growColsDataToolAction = toolbar->addAction ( RwQPixmap16::growColsDataIconSet(), tr ("Grow Columns: Fit Data")); _sizeColsDataToolAction = toolbar->addAction ( RwQPixmap16::sizeColsDataIconSet(), tr ("Resize Columns: Fit Data")); _sizeColsAllToolAction = toolbar->addAction ( RwQPixmap16::sizeColsAllIconSet(), tr ("Resize Columns: Fit All")); connect (_lockedToolAction, SIGNAL (toggled (bool)), SLOT (sctLockedToggle_Handler(bool))); connect (_saveModelToolAction, SIGNAL (activated()), this, SLOT (saveModelConfirm_Handler())); connect (_swapAxisToolAction, SIGNAL (activated()), this, SLOT (swapAxis_ButHandler())); connect (_userDetailsToolAction, SIGNAL (activated()), this, SLOT (userDetails_ButHandler())); connect (_detailsClosedToolAction, SIGNAL (activated()), this, SLOT (detailsClosed_ButHandler())); connect (_detailsOpenToolAction, SIGNAL (activated()), this, SLOT (detailsOpen_ButHandler())); connect (_detailsOnlyToolAction, SIGNAL (activated()), this, SLOT (detailsOnly_ButHandler())); connect (_copyDataToolAction, SIGNAL (activated()), this, SLOT (copyCells_Handler())); connect (_pasteDataToolAction, SIGNAL (activated()), this, SLOT (pasteCells_Handler())); connect (_plotSlotsToolAction, SIGNAL (activated()), this, SLOT (plotSlots_Handler())); connect (_openSlotsToolAction, SIGNAL (activated()), this, SLOT (openSlots_Handler())); if (_showDiagWinToolAction) { connect (_showDiagWinToolAction, SIGNAL (activated()), this, SLOT (showDiagWin_Handler())); } connect (_showRunCtrlToolAction, SIGNAL (activated()), this, SLOT (showRunCtrlDlg_Handler())); connect (_startRunToolAction, SIGNAL (activated()), this, SLOT (startRun_Handler())); connect (_runAnalToolAction, SIGNAL (activated()), this, SLOT (runAnal_Handler())); connect (_sizeColsCurToolAction, SIGNAL (activated()), this, SLOT (setDataColWidths_Handler())); connect (_growColsDataToolAction, SIGNAL (activated()), this, SLOT (growColsToData_Handler())); connect (_sizeColsDataToolAction, SIGNAL (activated()), this, SLOT (fitColsToData_Handler())); connect (_sizeColsAllToolAction, SIGNAL (activated()), this, SLOT (fitDataColsToAll_Handler())); } void SctDialog::createFlagToolButtons (QToolBar* toolbar) { _flag_O_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('O', false), tr ("Output")); _flag_I_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('I', false), tr ("Input")); _flag_T_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('T', false), tr ("Target Operation")); _flag_B_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('B', false), tr ("Best Efficiency")); _flag_M_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('M', false), tr ("Max Capacity")); _flag_D_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('D', false), tr ("Drift")); _flag_R_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('R', false), tr ("Set by Rule")); _flag_S_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('S', false), tr ("Surcharge Release")); _flag_G_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('G', false), tr ("Regulation Discharge")); _flag_U_toolAction = toolbar->addAction ( _sctCfg->getFlagButtonPixmap ('U', false), tr ("Unit Values")); connect (_flag_O_toolAction, SIGNAL (activated()), this, SLOT (setToOutput_Handler())); connect (_flag_I_toolAction, SIGNAL (activated()), this, SLOT (setToInput_Handler())); connect (_flag_T_toolAction, SIGNAL (activated()), this, SLOT (setTargetOp_Handler())); connect (_flag_B_toolAction, SIGNAL (activated()), this, SLOT (setBestEfficiency_Handler())); connect (_flag_M_toolAction, SIGNAL (activated()), this, SLOT (setMaxCapacity_Handler())); connect (_flag_D_toolAction, SIGNAL (activated()), this, SLOT (setDrift_Handler())); connect (_flag_U_toolAction, SIGNAL (activated()), this, SLOT (setUnitValues_Handler())); } void SctDialog::initConnections() { if (_entryLineEdit) { connect (_entryLineEdit, SIGNAL (returnPressed()), this, SLOT (mainLineEditSet_Handler())); } connect (_menu_File, SIGNAL(aboutToShow()), this, SLOT (aboutToShowSctMenu())); connect (_menu_Diagnostics, SIGNAL(aboutToShow()), this, SLOT (aboutToDiagnosticsMenu())); if (_dtimeSpinner) { connect (_dtimeSpinner, SIGNAL(valueChanged(int)), this, SLOT (dateTimeSpinnerChanged_Handler(int))); connect (_dtimeSpinner, SIGNAL(returnPressed()), this, SLOT (dateTimeSpinnerReturnPressed_Handler())); } connect (_newSCTAction, SIGNAL (activated()), this, SLOT (newSct_Handler())); connect (_openSCTAction, SIGNAL (activated()), this, SLOT (openSct_Handler())); connect (_loadSctFileAction, SIGNAL (activated()), SLOT (loadSctFile_Handler())); connect (_saveAsAction, SIGNAL (activated()), SLOT (saveAs_Handler())); connect (_saveAction, SIGNAL (activated()), SLOT (save_Handler())); connect (_saveConfirmAction, SIGNAL (activated()), SLOT (saveModelConfirm_Handler())); connect (_openModelAction, SIGNAL (activated()), SLOT (openModel_Handler())); connect (_saveModelAction, SIGNAL (activated()), SLOT (saveModel_Handler())); connect (_saveModelAsAction, SIGNAL (activated()), SLOT (saveModelAs_Handler())); connect (_printSelectionAction, SIGNAL (activated()), SLOT (printSelection_Handler())); connect (_printPageAction, SIGNAL (activated()), SLOT (printPage_Handler())); connect (_printFullSctAction, SIGNAL (activated()), SLOT (printFullSct_Handler())); connect (_showWorkspaceAction, SIGNAL (activated()), SLOT (showWorkspace_Handler())); connect (_closeOtherSctsAction, SIGNAL (activated()), SLOT (closeOtherScts_Handler())); connect (_closeWindowAction, SIGNAL (activated()), SLOT (close())); connect (_copyCellsAction, SIGNAL (activated()), SLOT (copyCells_Handler())); connect (_pasteCellsAction, SIGNAL (activated()), SLOT (pasteCells_Handler())); connect (_pasteCellsAsInputAction, SIGNAL (activated()), SLOT (pasteCellsAsInput_Handler())); connect (_copyExportCellsAction, SIGNAL (activated()), SLOT (copyExportCells_Handler())); connect (_pasteImportCellsAction, SIGNAL (activated()), SLOT (pasteImportCells_Handler())); connect (_clearOutputsSelAction, SIGNAL (activated()), SLOT (clearOutputsSel_Handler())); connect (_clearOutputsSctAction, SIGNAL (activated()), SLOT (clearOutputsSct_Handler())); connect (_setToInputAction, SIGNAL (activated()), SLOT (setToInput_Handler())); connect (_setToOutputAction, SIGNAL (activated()), SLOT (setToOutput_Handler())); connect (_clearValuesAction, SIGNAL (activated()), SLOT (clearValues_Handler())); connect (_setTargetOpAction, SIGNAL (activated()), SLOT (setTargetOp_Handler())); connect (_clearTargetOpsAction, SIGNAL (activated()), SLOT (clearTargetOps_Handler())); connect (_setBestEfficiencyAction, SIGNAL (activated()), SLOT (setBestEfficiency_Handler())); connect (_setMaxCapacityAction, SIGNAL (activated()), SLOT (setMaxCapacity_Handler())); connect (_setDriftAction, SIGNAL (activated()), SLOT (setDrift_Handler())); connect (_setUnitValuesAction, SIGNAL (activated()), SLOT (setUnitValues_Handler())); connect (_interpolateSelAction, SIGNAL (activated()), SLOT (interpolateSel_Handler())); connect (_interpolateInputsAction, SIGNAL (activated()), SLOT (interpolateInputs_Handler())); connect (_adjustValuesAction, SIGNAL (activated()), SLOT (adjustValues_Handler())); connect (_sctLockedToggleAction, SIGNAL (toggled (bool)), SLOT (sctLockedToggle_Handler(bool))); connect (_plotSlotsAction, SIGNAL (activated()), SLOT (plotSlots_Handler())); connect (_openSlotsAction, SIGNAL (activated()), SLOT (openSlots_Handler())); connect (_findSlotAction, SIGNAL (activated()), SLOT (findSlot_Handler())); connect (_slotConfigAction, SIGNAL (activated()), SLOT (slotConfig_Handler())); connect (_enaDispatchingAction, SIGNAL (activated()), SLOT (enaDispatching_Handler())); connect (_disDispatchingAction, SIGNAL (activated()), SLOT (disDispatching_Handler())); connect (_setLabelAction, SIGNAL (activated()), SLOT (setLabel_Handler())); connect (_insertAboveNewSlotsAction, SIGNAL (activated()), SLOT (insertAboveNewSlots_Handler())); connect (_insertBelowNewSlotsAction, SIGNAL (activated()), SLOT (insertBelowNewSlots_Handler())); connect (_appendNewSlotsAction, SIGNAL (activated()), SLOT (appendNewSlots_Handler())); connect (_reassignSlotAction, SIGNAL (activated()), SLOT (reassignSlot_Handler())); connect (_insertAboveNewSDividerAction, SIGNAL (activated()), SLOT (insertAboveNewSDivider_Handler())); connect (_insertBelowNewSDividerAction, SIGNAL (activated()), SLOT (insertBelowNewSDivider_Handler())); connect (_appendNewSDividerAction, SIGNAL (activated()), SLOT (appendNewSDivider_Handler())); connect (_copySlotsAction, SIGNAL (activated()), SLOT (copySlots_Handler())); connect (_cutSlotsAction, SIGNAL (activated()), SLOT (cutSlots_Handler())); connect (_insertCopiedSlotsAction, SIGNAL (activated()), SLOT (insertCopiedSlots_Handler())); connect (_appendCopiedSlotsAction, SIGNAL (activated()), SLOT (appendCopiedSlots_Handler())); connect (_removeSlotsAction, SIGNAL (activated()), SLOT (removeSlots_Handler())); connect (_configTstepAggAction, SIGNAL (activated()), SLOT (configTstepAgg_Handler())); connect (_setAggSumFuncsAction, SIGNAL (activated()), SLOT (setAggSumFuncs_Handler())); connect (_detailModeActionGroup, SIGNAL (selected (QAction*)), SLOT (detailModeGroup_Handler(QAction*))); connect (_axisOrientActionGroup, SIGNAL (selected (QAction*)), SLOT (axisOrientGroup_Handler(QAction*))); connect (_cellTextActionGroup, SIGNAL (selected (QAction*)), SLOT (cellTextGroup_Handler (QAction*))); connect (_toggleRowDetailAction, SIGNAL (activated()), SLOT (toggleRowDetail_Handler())); connect (_showConfigDlgAction, SIGNAL (activated()), SLOT (showConfigDlg_Handler())); connect (_showDiagPanelAction, SIGNAL (activated()), SLOT (showDiagPanel_Handler())); connect (_setDataColWidthsAction, SIGNAL (activated()), SLOT (setDataColWidths_Handler())); connect (_fitDataColsToHeadAction, SIGNAL (activated()), SLOT (fitDataColsToHead_Handler())); connect (_growColsToDataAction, SIGNAL (activated()), SLOT (growColsToData_Handler())); connect (_fitColsToDataAction, SIGNAL (activated()), SLOT (fitColsToData_Handler())); connect (_fitDataColsToAllAction, SIGNAL (activated()), SLOT (fitDataColsToAll_Handler())); connect (_fitRowHeadersAction, SIGNAL (activated()), SLOT (fitRowHeaders_Handler())); connect (_applyDefault, SIGNAL (activated()), SLOT (applyDefault_Handler())); connect (_saveAsDefault, SIGNAL (activated()), SLOT (saveAsDefault_Handler())); connect (_clearDefault, SIGNAL (activated()), SLOT (clearDefault_Handler())); connect (_pageUpAction, SIGNAL (activated()), SLOT (pageUp_Handler())); connect (_pageDownAction, SIGNAL (activated()), SLOT (pageDown_Handler())); connect (_pageLeftAction, SIGNAL (activated()), SLOT (pageLeft_Handler())); connect (_pageRightAction, SIGNAL (activated()), SLOT (pageRight_Handler())); connect (_nextSlotAction, SIGNAL (activated()), SLOT (nextSlot_Handler())); connect (_prevSlotAction, SIGNAL (activated()), SLOT (prevSlot_Handler())); connect (_refreshAction, SIGNAL (activated()), SLOT (refresh_Handler())); connect (_configGeneralAction, SIGNAL (activated()), SLOT (configGeneral_Handler())); connect (_configHorzTimeAction, SIGNAL (activated()), SLOT (configHorzTime_Handler())); connect (_configVertTimeAction, SIGNAL (activated()), SLOT (configVertTime_Handler())); connect (_configFontAction, SIGNAL (activated()), SLOT (configFont_Handler())); connect (_configToolbarAction, SIGNAL (activated()), SLOT (configToolbar_Handler())); connect (_configSummaryAction, SIGNAL (activated()), SLOT (configSummary_Handler())); connect (_configFlagsAction, SIGNAL (activated()), SLOT (configFlags_Handler())); connect (_configColorAction, SIGNAL (activated()), SLOT (configColor_Handler())); connect (_showRunCtrlDlgAction, SIGNAL (activated()), SLOT (showRunCtrlDlg_Handler())); connect (_startRunAction, SIGNAL (activated()), SLOT (startRun_Handler())); connect (_runAnalAction, SIGNAL (activated()), SLOT (runAnal_Handler())); if (_sctTabWidget) { connect (_sctTabWidget, SIGNAL (currentChanged (QWidget*)), SLOT (sctTabWidget_currentChanged (QWidget*))); } if (_scalarListPanel) { _scalarListPanel->registerListener (this); connect (_scalarListPanel, SIGNAL (slotSelectionChanged (SlotColRef, const cwSlist&)), SLOT (scalarListPanel_slotSelectionChanged ( SlotColRef, const cwSlist&))); connect (_scalarListPanel, SIGNAL (slotListChangedByUser (SlotListPanel*)), SLOT (slotListPanel_slotListChangedByUser (SlotListPanel*))); connect (_scalarListPanel, SIGNAL (appendSlotsButtonClicked (SlotListPanel*)), SLOT (slotListPanel_appendSlotsButtonClicked (SlotListPanel*))); } if (_nonSeriesListPanel) { _nonSeriesListPanel->registerListener (this); connect (_nonSeriesListPanel, SIGNAL (slotSelectionChanged (SlotColRef, const cwSlist&)), SLOT (nonSeriesListPanel_slotSelectionChanged ( SlotColRef, const cwSlist&))); connect (_nonSeriesListPanel, SIGNAL (slotListChangedByUser (SlotListPanel*)), SLOT (slotListPanel_slotListChangedByUser (SlotListPanel*))); connect (_nonSeriesListPanel, SIGNAL (appendSlotsButtonClicked (SlotListPanel*)), SLOT (slotListPanel_appendSlotsButtonClicked (SlotListPanel*))); } } void SctDialog::initDateTimeSpinner (bool preserveCurrentDateTime) { if (_dtimeSpinner == NULL) return; //------------------------------>> //--------------------------------------------------------- bool inProgressSave (_dtimeSpinnerInternalChangeInProgress); _dtimeSpinnerInternalChangeInProgress = true; //--------------------------------------------------------- Date_Time saveDTime (*(_dtimeSpinner->getDateTime())); const int tstepCnt (_sctModelDat->tStepCnt()); DeltaTime tstepInterval (_sctModelDat->tstepInterval()); Date_Time beginDTime (_sctModelDat->dTimeOfTstepInx (0)); Date_Time endDTime (_sctModelDat->dTimeOfTstepInx ( std::max (0, tstepCnt-1))); Date_Time initDTime (preserveCurrentDateTime ? saveDTime : beginDTime); // Use the abridged format _dtimeSpinner->setDisplayFormat ( DT_SPIN_USE_3LETTER_MONTHS ? DateTimeQtSpinner::ABRIDGED_ABBRV_FMT : DateTimeQtSpinner::ABRIDGED_FMT); // Use the earliest and latest allowed riverware date_times const Date_Time earliestDate = *(Date_Time::getEarliestAllowedDateTime()); const Date_Time latestDate = *(Date_Time::getLatestAllowedDateTime()); // Initialize the internal dates for the date time spinner _dtimeSpinner->init (tstepInterval, // const DeltaTime& timeStep earliestDate, // const Date_Time& baseDateTime earliestDate, // const Date_Time& minDateTime latestDate, // const Date_Time& maxDateTime initDTime); // const Date_Time& currDateTime // Include this spinner in global scroll navigation _dtimeSpinner->setUsedForNavigation (true); //--------------------------------------------------------- _dtimeSpinnerInternalChangeInProgress = inProgressSave; //--------------------------------------------------------- } // virtual from BaseQtMainWin void SctDialog::buildDiagOutDockWindow() { if (_diagOutDockWindow != NULL) return; //----------------------------------->> int dlgHeight = height(); _diagOutDockWindow = new DiagOutputDockWindow (this, dlgHeight); _diagOutDockWindow-> setAllowedAreas (Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); // For TVA, hide the title bar of the QDockWidget. That thing appeared // in the Qt4 port. This action disabled the "floatablility" of the // DiagOutputDockWindow, but that's OK because in stand-alone mode // we don't actually make use of the DiagOutputDockWindow, but rather // we deploy the DiagOutputWidget in it's own QMainWindow. [Sept. 2008] // _diagOutDockWindow->installEmptyTitleBarWidget(); addDockWidget (Qt::BottomDockWidgetArea, _diagOutDockWindow); if (_diagOutputMenuItems) _diagOutputMenuItems->setDiagOutputDockWindow (_diagOutDockWindow); connect (_diagOutDockWindow, SIGNAL (destroyed()), this, SLOT (diagOutDockWindowDestroyed_Handler())); connect (_diagOutDockWindow, SIGNAL (dockLocationChanged (Qt::DockWidgetArea)), this, SLOT (diagOutDockWindowLocationChanged_Handler(Qt::DockWidgetArea))); connect (_diagOutDockWindow, SIGNAL (visibilityChanged (bool)), this, SLOT (diagOutDockWindowVisibilityChanged_Handler (bool))); } void SctDialog::disableModelRun (void) { _startRunAction->setEnabled(false); _startRunToolAction->setEnabled(false); } void SctDialog::disableModelEdit (void) { if (_entryLineEdit) _entryLineEdit->setReadOnly(true); } // ********************** // *** Event Handlers *** // ********************** // virtual from QWidget void SctDialog::showEvent (QShowEvent* evt) { static const char (*mname) ("SctDialog::showEvent"); static int callCnt (0); ++callCnt; // std::cout << mname << " [#" << callCnt << "]" << std::endl; // Call base class method BaseQtMainWin::showEvent (evt); QTimer::singleShot (250, this, SLOT (delayedShow_timeout())); } // virtual from QWidget void SctDialog::resizeEvent (QResizeEvent* evt) { if (evt != NULL) { const QSize oldSize (evt->oldSize()); const QSize newSize (evt->size()); if (_sctCfg) { _sctCfg->setWindowWidthField (newSize.width()); _sctCfg->setWindowHeightField (newSize.height()); } SctDiag2 { std::cout << "SctDialog::resizeEvent (" << newSize.width() << ", " << newSize.height() << ")" << std::endl; } } // call base class event handler BaseQtMainWin::resizeEvent (evt); } // ******************************************** // *** SctManager_Listener callback methods *** // ******************************************** // virtual void SctDialog::SctManListener_DlgSetChanged (int sctOrdinalInx) { static const char (*mname) ("SctDialog::SctManListener_DlgSetChanged"); int nameCnt (0); std::list sctNames (SctManagerInst->getSctNames()); std::list::const_iterator it; for (it = sctNames.begin(); it != sctNames.end(); ++it) { QString sctName (*it); SctDiag2 { std::cout << mname << " (" << sctOrdinalInx << ")" << " [" << ++nameCnt << "] " << qPrintable (sctName) << std::endl; } } } // virtual void SctDialog::SctManListener_NewCopyCellSet (int sctOrdinalInx) { static const char (*mname) ("SctDialog::SctManListener_NewCopyCellSet"); SctDiag2 { std::cout << mname << " (" << sctOrdinalInx << ")" << std::endl; } // Wipe out local Copy Cell Set if it is cleared, or some copy // set from some other SCT Dialog Box becomes active. const SctCopySet* copyCellSet (SctManagerInst->copyCellSet()); if (!copyCellSet || (copyCellSet->sourceDialog() != this)) { // Clear local Copy Cell Set (SctSlotTstepSet) if (_copySlotTstepSet != NULL) clearCopyCellSet (); } refreshMenuSensitivity(); } // virtual void SctDialog::SctManListener_NewCopySlotSet (int sctOrdinalInx) { static const char (*mname) ("SctDialog::SctManListener_NewCopySlotSet"); SctDiag2 { std::cout << mname << " (" << sctOrdinalInx << ")" << std::endl; } refreshMenuSensitivity(); } // virtual void SctDialog::SctManListener_ShipGoingDown (int sctOrdinalInx) { static const char (*mname) ("SctDialog::SctManListener_ShipGoingDown"); SctDiag2 { std::cout << mname << " (" << sctOrdinalInx << ")" << std::endl; } _shipGoingDown = true; cancelFullRecomp(); dropCellSets (); closeSubDialogs (); closeViews (); if (_sctModelDat) { delete _sctModelDat; _sctModelDat = NULL; } if (_sctCfg) { delete _sctCfg; _sctCfg = NULL; } close (true); // delete } // ********************************************** // *** SctModelData_Listener callback methods *** // ********************************************** void SctDialog::sctModelData_SlotDeleted (int slotInx) { static const char (*mname) ("SctDialog::sctModelData_SlotDeleted"); SctDiag2 { std::cout << mname << " (slotInx: " << slotInx << ")" << std::endl; } // Deleted Slots are not removed from the SCT, but rather // are drawn as inactive, unless inactive Slots are hidden. // Cause a redraw of the Slot Item -- (NOP if not visible); if (_selSlotTstepSet && _selSlotTstepSet->containsSlotInxAny (slotInx)) { dropSelectionCellSet (); } if (_copySlotTstepSet && _copySlotTstepSet->containsSlotInxAny (slotInx)) { dropCopyCellSet (); } const bool wsClearing = rwWorkspace->getWorkspaceIsClearing(); if (wsClearing) { // Skip updating the SCT View if the Workspace is currently clearing. // The processing of the WS_CLEARED notification cleans up the // current view. // // std::cout << mname << " WS CLEARING" << std::endl; } else // (Not wsClearing) { if (_curView) { _curView->updateSlotProperties (slotInx, true); // doAdjustHeaderHgt } } } void SctDialog::sctModelData_SlotPropertiesChanged (int slotInx) { static const char (*mname) ("SctDialog::sctModelData_SlotPropertiesChanged"); SctDiag2 { std::cout << mname << " (slotInx: " << slotInx << ")" << std::endl; } // Flags or Slot Name or something has changed // [Pass in false for bool doAdjustHeaderHeight parameter] if (_aggTimeHorzView) _aggTimeHorzView ->updateSlotProperties (slotInx, false); if (_aggTimeVertView) _aggTimeVertView ->updateSlotProperties (slotInx, false); if (_noAggTimeHorzView) _noAggTimeHorzView ->updateSlotProperties (slotInx, false); if (_noAggTimeVertView) _noAggTimeVertView ->updateSlotProperties (slotInx, false); if (_selSlotTstepSet && _selSlotTstepSet->containsSlotInxAny (slotInx)) { updateStatusBar (); } } void SctDialog::sctModelData_SlotPropertiesChangedWrapup() { static const char (*mname) ("SctDialog::sctModelData_SlotPropertiesChangedWrapup"); SctDiag2 { std::cout << mname << std::endl; } // Resize Value Info Label (at top, next to entry editor in toolbar) resizeValueInfoLabel(); // Adjust Headers in Time Vertical Views if (_aggTimeVertView) _aggTimeVertView ->adjustHeaderHeight(); if (_noAggTimeVertView) _noAggTimeVertView ->adjustHeaderHeight(); } void SctDialog::sctModelData_UnitSchemeChanged () { const int cfgSlotCnt (_sctCfg->slotCnt()); for (int slotInx = 0; slotInx < cfgSlotCnt; ++slotInx) { // Flags or Slot Name or something has changed // [Pass in false for bool doAdjustHeaderHeight parameter] if (_aggTimeHorzView) _aggTimeHorzView ->updateSlotProperties (slotInx, false); if (_aggTimeVertView) _aggTimeVertView ->updateSlotProperties (slotInx, false); if (_noAggTimeHorzView) _noAggTimeHorzView ->updateSlotProperties (slotInx, false); if (_noAggTimeVertView) _noAggTimeVertView ->updateSlotProperties (slotInx, false); } // Resize Value Info Label (at top, next to entry editor in toolbar) resizeValueInfoLabel(); // Adjust Headers in Time Vertical Views if (_aggTimeVertView) _aggTimeVertView ->adjustHeaderHeight(); if (_noAggTimeVertView) _noAggTimeVertView ->adjustHeaderHeight(); growDataColsToData(); fitRowHeaders (true); // growOnly if (_curView) { _curView->guiRefresh (); } updateStatusBar (); } void SctDialog::sctModelData_SlotDataChanged (int slotInx, int tStepInx) { static const char (*mname) ("SctDialog::sctModelData_SlotDataChanged"); SctDiag2 { std::cout << mname << " (slotInx: " << slotInx << ", tStepInx: " << tStepInx << ")" << std::endl; } // Wipe out Copy Set if it contains the changed value(s) // (unless a paste is in progress now). if (_copySlotTstepSet && !SctManagerInst->cellPasteIsInProgress()) { if (slotInx < 0) { // All (or many) slots being updated: Clear copy set SctManagerInst->clearCopyCellSet (true); // doNotify } else if (tStepInx >= 0) { // applies to single cell if (_copySlotTstepSet->contains (slotInx, tStepInx)) { SctManagerInst->clearCopyCellSet (true); // doNotify } } else { // applies to whole slot if (_copySlotTstepSet->containsSlotInxAny (slotInx)) SctManagerInst->clearCopyCellSet (true); // doNotify } } // Refresh Current View if (_curView) { if (slotInx < 0) _curView->guiRefresh (); else if (tStepInx >= 0) _curView->updateSlotValue (slotInx, tStepInx); else _curView->updateSlotValues (slotInx); } // If Selection contains changed value(s), update Status Bar if (_selSlotTstepSet) { if (tStepInx >= 0) { // applies to single cell if (_selSlotTstepSet->contains (slotInx, tStepInx)) { updateStatusBar (true); // dataChangeOnly } } else { // applies to whole slot if (_selSlotTstepSet->containsSlotInxAny (slotInx)) updateStatusBar (true); // dataChangeOnly } } } void SctDialog::sctModelData_ModelLoaded () { static const char (*mname) ("SctDialog::sctModelData_ModelLoaded"); SctDiag1 { std::cout << mname << std::endl; } // A new model was just loaded, so update everything. fullRecomp (SCT_RESCROLL_SLOT_BEGIN); // Populate the Slot List Panels with the slot lists saved for those // panels. Undo the side-effect of having the newly added Slot Items // of becoming selected. // loadSlotListPanelListsFromConfig(); if (_scalarListPanel) _scalarListPanel -> clearListSelection(); if (_nonSeriesListPanel) _nonSeriesListPanel -> clearListSelection(); } void SctDialog::sctModelData_ObjDispatchChanged (SimObj* /*simobj = NULL*/) { static const char (*mname) ("SctDialog::sctModelData_ObjDispatchChanged"); SctDiag1 { std::cout << mname << std::endl; } // Redraw so "Dispatch Disabled" crosshatching is updated if (_curView) { _curView->guiRefresh (); } } void SctDialog::sctModelData_ModelNamed () { static const char (*mname) ("SctDialog::sctModelData_ModelNamed"); SctDiag1 { std::cout << mname << std::endl; } // A new model was just loaded, so update everything. refreshTitle (); } void SctDialog::sctModelData_RunDatesChanged () { static const char (*mname) ("SctDialog::sctModelData_RunDatesChanged"); SctDiag1 { std::cout << mname << std::endl; } // The run duration changed, so update everything fullRecomp (SCT_RESCROLL_PRESERVE); if (_sctCfgDlg) { _sctCfgDlg->notifyRunDatesChanged(); } } void SctDialog::sctModelData_SlotRangeChanged () { static const char (*mname) ("SctDialog::sctModelData_SlotRangeChanged"); SctDiag1 { std::cout << mname << std::endl; } // A slot's range changed, if we're synchronizing our range to our // slots, then we need to rebuild. if (_sctCfg->slotBasedRange()) { schedFullRecomp(); } } void SctDialog::sctModelData_ModelRunning (bool isRunning) { static const char (*mname) ("SctDialog::sctModelData_ModelRunning"); SctDiag2 { std::cout << mname << " ( " << ((isRunning) ? "true" : "false") << " ) " << std::endl; } // If our range is based on our slots, our range might need to change // because slot ranges can change during a run. For now we just // always do a full recompute in this situation. if (!isRunning && _sctCfg->slotBasedRange()) { fullRecomp (SCT_RESCROLL_PRESERVE); } // If the model run started or stopped, update the menu items refreshMenuSensitivity(); } void SctDialog::sctModelData_ModelRunUpdate () { static const char (*mname) ("SctDialog::sctModelData_RunUpdate"); SctDiag1 { std::cout << mname << std::endl; } // Recompute model data after each timestep // (Series indices may have changed) recompModelData (); } void SctDialog::sctModelData_PleaseRedraw () { static const char (*mname) ("SctDialog::sctModelData_PleaseRedraw"); SctDiag1 { std::cout << mname << std::endl; } if (_curView) { _curView->guiRefresh (); } updateStatusBar (); } void SctDialog::sctModelData_PleaseGrowDataCols () { growDataColsToData(); } void SctDialog::sctModelData_RunAborted (int /*slotInx*/, int /*tinx*/) { static const char (*mname) ("SctDialog::sctModelData_RunAborted"); // std::cout << mname << " [" << slotInx << ", " << tinx << "]" // << std::endl; // Note [7-2009] Maybe doing an automatic time scroll to the aborted // timestep in the SCT is not a good idea. It's redundant with the // user "RiverWare Notice: The RiverWare run aborted" popup which // gives the user the option of doing a "Time Scroll" to the // "context time". Even though the user can choose to not have that // popup shown again (during the current RiverWare session), we // shouldn't provide this automatic "time scroll". In particular, // in the SCT, it causes a whole row (or column) of cells to become // selected -- and those cells will be modified on the next edit // operation (with no un-do). It may be dangerous. // //-- // Note: I'm not bothering taking into account the Slot because a //-- // relevant Slot reference doesn't seem to be available. See method: //-- // [SctModelData.Sim.cpp] SctModelData::processRunAbortEvent(). //-- // But if both Slot and Timestep were relevant (non-negative), it //-- // would be good to select the particular CELL for that Slot and //-- // Timestep, and scroll to it. //-- //-- static const bool selectToo (true); //-- scrollToTimeStep (tinx, selectToo); } // ****************************************************** // *** SctTimestepAggCfgDlg_Listener callback methods *** // ****************************************************** void SctDialog::sctTimestepAggCfgDlg_Ok (SctTimestepAggCfgDlg* dlg) { SctDiag2 { std::cout << "SctDialog::sctTimestepAggCfgDlg_Ok" << std::endl; } bool diff = dlg->anyChange(); // Close and delete dialog box if (_sctTimestepAggCfgDialog) { _sctTimestepAggCfgDialog->close(); delete _sctTimestepAggCfgDialog; _sctTimestepAggCfgDialog = NULL; } if (diff) { reConfigAggregatedViews (SCT_RESCROLL_PRESERVE); } } void SctDialog::sctTimestepAggCfgDlg_Cancel (SctTimestepAggCfgDlg*) { SctDiag2 { std::cout << "SctDialog::sctTimestepAggCfgDlg_Cancel" << std::endl; } // Close and delete dialog box if (_sctTimestepAggCfgDialog) { _sctTimestepAggCfgDialog->revertValues(); _sctTimestepAggCfgDialog->close(); delete _sctTimestepAggCfgDialog; _sctTimestepAggCfgDialog = NULL; } } void SctDialog::sctTimestepAggCfgDlg_Deleted (SctTimestepAggCfgDlg* dlg) { SctDiag2 { std::cout << "SctDialog::sctTimestepAggCfgDlg_Deleted" << std::endl; } if (_sctTimestepAggCfgDialog == dlg) { _sctTimestepAggCfgDialog = NULL; } } // *************************************************** // *** SctLabelFnDlg_Listener callback methods *** // *************************************************** void SctDialog::sctLabelFnDlg_Ok (SctLabelFnDlg* labelFnDlg) { SctDiag2 { std::cout << "SctDialog::sctLabelFnDlg_Ok" << std::endl; } if (!_sctCfg) return; //----------------->> // Set these new values in this slot SctLabelFnDlg_Data labelFnData(labelFnDlg->getData()); int slotIndex = labelFnData._slotInx; _sctCfg->setSlotLabel(slotIndex, labelFnData._rowString); _sctCfg->setSlotMultiLine(slotIndex, labelFnData._columnString); _sctCfg->setSumFuncSpec(slotIndex, labelFnData._sumFuncSpec); // MultiLine value must explicitly by set on the Sct Data Table // top QHeader columns. Other values are automatically retrieved // from the SctConfig object upon redrawing. // Refresh Slot in various views refreshSlot (slotIndex); // Close and delete dialog box if (_sctLabelFnDlg) { _sctLabelFnDlg->close(); delete _sctLabelFnDlg; _sctLabelFnDlg = NULL; } } void SctDialog::sctLabelFnDlg_Cancel (SctLabelFnDlg*) { SctDiag2 { std::cout << "SctDialog::sctLabelFnDlg_Cancel" << std::endl; } // Close and delete dialog box if (_sctLabelFnDlg) { _sctLabelFnDlg->close(); delete _sctLabelFnDlg; _sctLabelFnDlg = NULL; } } void SctDialog::sctLabelFnDlg_Deleted (SctLabelFnDlg* dlg) { SctDiag2 { std::cout << "SctDialog::sctLabelFnDlg_Deleted" << std::endl; } if (_sctLabelFnDlg == dlg) { _sctLabelFnDlg = NULL; } } void SctDialog::sctClipboardExportDlg_Copy (SctClipboardExportDlg* dlg) { static const char (*mname) ("SctDialog::sctClipboardExportDlg_Copy"); if (!_sctCfg) return; //----------------->> bool useModelPrecision (false); bool showNans (_sctCfg->displayNans()); bool want24 (true); // not yet implemented if (dlg) { useModelPrecision = dlg->useModelPrecision (); showNans = dlg->showNans (); _exportCopyInclRowHeaders = dlg->includeRowHeaders (); _exportCopyInclColHeaders = dlg->includeColHeaders (); dlg->hide(); } if (_curView == NULL) return; //------------------------->> int exportRows (0); int exportCols (0); QString exportStr ( _curView->getSlotTstepSetRowColExportStr ( _selSlotTstepSet, // null OK useModelPrecision, showNans, _exportCopyInclRowHeaders, _exportCopyInclColHeaders, want24, exportRows, exportCols )); // std::cout << mname << "... \n\"" << exportStr << "\"" << std::endl; RwQtUtils::setClipboardText (exportStr); } void SctDialog::sctClipboardExportDlg_Cancel (SctClipboardExportDlg* dlg) { // std::cout << "SctDialog::sctClipboardExportDlg_Cancel" << std::endl; // Note: The Clipboard Export Dialog will be deleted when the // SCTDialog is deleted. Keeping it around (and re-showing it when // needed) has the effect of preserving its location on the desktop. if (dlg) dlg->hide(); } void SctDialog::sctClipboardExportDlg_Deleted (SctClipboardExportDlg* dlg) { if (_sctClipboardExportDlg == dlg) { _sctClipboardExportDlg = NULL; } } bool SctDialog::SctFindSlotDialog_anyMatch (const QString& labelFirstChars, SctFindSlotOp op) const { static const char (*mname) ("SctDialog::SctFindSlotDialog_anyMatch"); // std::cout << mname << std::endl; int nextSlotInx (nextSlotInxOfLabel (labelFirstChars, op)); bool anyMatch (nextSlotInx >= 0); return (anyMatch); } void SctDialog::SctFindSlotDialog_nextClicked (const QString& matchPattern, SctFindSlotOp op) { static const char (*mname) ("SctDialog::SctFindSlotDialog_nextClicked"); // std::cout << mname << std::endl; int nextSlotInx (nextSlotInxOfLabel (matchPattern, op)); if (nextSlotInx >= 0) scrollToSlotInx (nextSlotInx, TRUE); // select Too } void SctDialog::SctFindSlotDialog_prevClicked (const QString& matchPattern, SctFindSlotOp op) { static const char (*mname) ("SctDialog::SctFindSlotDialog_prevClicked"); // std::cout << mname << std::endl; int prevSlotInx (nextSlotInxOfLabel (matchPattern, op, TRUE)); // reverse if (prevSlotInx >= 0) scrollToSlotInx (prevSlotInx, TRUE); // select Too } void SctDialog::SctFindSlotDialog_cancelClicked (SctFindSlotDialog* findDlg) { static const char (*mname) ("SctDialog::SctFindSlotDialog_cancelClicked"); // std::cout << mname << std::endl; if (rwAssert (_sctFindSlotDlg == findDlg)) _sctFindSlotDlg = NULL; if (findDlg != NULL) findDlg->close (true); // delete } void SctDialog::SctFindSlotDialog_deleted (SctFindSlotDialog* findDlg) { static const char (*mname) ("SctDialog::SctFindSlotDialog_deleted"); // std::cout << mname << std::endl; if (_sctFindSlotDlg == findDlg) _sctFindSlotDlg = NULL; } // ********************************************** // *** SctConfigDlg_Listener callback methods *** // ********************************************** void SctDialog::sctCfgDlg_Ok (SctConfigDlg* dlg) { static const char (*mname) ("SctDialog::sctCfgDlg_Ok"); SctDiag2 { std::cout << mname << std::endl; } sctCfgDlg_Apply (dlg); if (_sctCfgDlg) { _sctCfgDlg->close (true); // also delete // pointer cleared by destructor call to sctCfgDlg_Deleted(). } } void SctDialog::sctCfgDlg_Apply (SctConfigDlg* dlg) { static const char (*mname) ("SctDialog::sctCfgDlg_Apply"); SctDiag2 { std::cout << mname << std::endl; } bool fontAdjustmentsNeeded (false); // (tentative) if (dlg) { if (dlg->currFontChange()) { // Set Font on SctDialog and all defined SctViews applyCurrentFont (false); // don't makeAdjustments fontAdjustmentsNeeded = true; // (tentative) } if (dlg->reConfChange ()) { // Reconfigure Model Data and All Views fullRecomp (SCT_RESCROLL_PRESERVE); fontAdjustmentsNeeded = false; } else if (dlg->reInstalledViewChange ()) { // Install Different SctView installSctView (); } else if (dlg->reDrawChange ()) { // Redraw Installed View if (_curView) _curView->guiRefresh(); } if (fontAdjustmentsNeeded) { applyCurrentFont (true); // makeAdjustments } else { if (dlg->dataTimeColTextChange()) { if (_aggTimeHorzView) _aggTimeHorzView -> refreshDataColHeaders(); if (_noAggTimeHorzView) _noAggTimeHorzView -> refreshDataColHeaders(); } if (dlg->dataSlotColTextChange()) { if (_aggTimeVertView) _aggTimeVertView -> refreshDataColHeaders(); if (_noAggTimeVertView) _noAggTimeVertView -> refreshDataColHeaders(); } if (dlg->rowColSlotColShowChange()) { if (_aggTimeHorzView) _aggTimeHorzView -> fitRowHeaderAndSplitter(); if (_noAggTimeHorzView) _noAggTimeHorzView -> fitRowHeaderAndSplitter(); } if (dlg->rowColTimeColShowChange()) { if (_aggTimeVertView) _aggTimeVertView -> fitRowHeaderAndSplitter(); if (_noAggTimeVertView) _noAggTimeVertView -> fitRowHeaderAndSplitter(); } } if (dlg->guiCtrlChange()) { refreshControls (); } } // Resize Value Info Label (at top, entry editor in toolbar) // This is done at the same time as row resizing since it is // based on the same properties as some of the row header columns. resizeValueInfoLabel (); // Refresh Dialog Title (caption) Status Line refreshTitle(); updateStatusBar(); } void SctDialog::sctCfgDlg_Close (SctConfigDlg*) { static const char (*mname) ("SctDialog::sctCfgDlg_Close"); SctDiag2 { std::cout << mname << std::endl; } if (_sctCfgDlg) { _sctCfgDlg->close (true); // also delete // pointer cleared by destructor call to sctCfgDlg_Deleted(). } } void SctDialog::sctCfgDlg_Deleted (SctConfigDlg*) { static const char (*mname) ("SctDialog::sctCfgDlg_Deleted"); SctDiag2 { std::cout << mname << std::endl; } _sctCfgDlg = NULL; } void SctDialog::slotListPanelListener_computeMissingSlotCnt() { recomputeMissingSlotListPanelSlotCnt(); } int SctDialog::slotListPanelListener_getMissingSlotCnt() const { return _missingSlotListPanelSlotCnt; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Moved to SctDialog.hpp // struct SlotNameCol // { // QString _name; // int _col; //--- col is -1 for slots without a column // QString _label; // }; BaseRWDlg* SctDialog::createChildDlg (void* assocObj, int typeCode) { // std::cout << "SctDialog::createChildDlg (Type: " << typeCode << ")" // << std::endl; Root (*slotRootPtr) ((Root*) assocObj); if (slotRootPtr == NULL) return (NULL); //===================================>> BaseRWDlg *newChildDlg = BaseRWDlg::createChildSlotDlg ( slotRootPtr, (int) typeCode); if (newChildDlg == NULL) { QMessageBox::information (this, "RiverWare Notice", "The Slot Editor for this slot is not available " "from this dialog box."); } // NOTE: For now, we are not registering any callbacks. // BaseRWDlg::addChildSlotDlgSlotCallbacks (slotRootPtr); return newChildDlg; } void SctDialog::childDestroyedHandler (BaseRWDlg* child, void* dat) { // std::cout << "SctDialog::childDestroyedHandler, Child: " // << (child ? child->getDlgName() : "NULL") // << std::endl; // call base class method BaseRWDlg::childDestroyedHandler (child, dat); } //------------ void SctDialog::refreshMenuSensitivity() { static const char* mname ("SctDialog::refreshMenuSensitivity"); if (!_sctCfg) return; if (_shipGoingDown) return; //----------------------->> const bool isSctTab (currentTab_isSctView()); const bool isScalarTab (currentTab_isScalarListPanel()); const bool isOtherTab (currentTab_isNonSeriesListPanel()); const bool isListTab (isScalarTab || isOtherTab); const bool locked (_sctCfg->configLocked()); const bool emptyCopySlotSet (SctManagerInst->copySlotSetEmpty()); const bool emptySlotList (_sctCfg->slotCnt() == 0); const bool modelEdit (rwSystem->modelEditIsAllowed() && !rwWorkspace->isBaselineModel()); const bool singleSelCol (!_columnWidthAdjustRequireNewColSelect && _curView && (_curView->colIndexOfSingleSelectedCol() >= 0)); const int openSctCnt (SctManagerInst->openSctDialogCnt()); int slotCnt (0); int validSlotCnt (0); int wholeSlotCnt (0); int cellOnlyCnt (0); int slotUnitCnt (0); bool oneSlot (false); bool oneValidSlot (false); bool emptySel (true); // empty selection bool oneWholeSlot (false); bool oneCell (false); bool onlyWholeSlots (false); bool someSlots (false); bool someValSlots (false); bool someValidSimSlots (false); bool flagSupportI (false); bool flagSupportO (false); bool flagSupportT (false); bool flagSupportB (false); bool flagSupportM (false); bool flagSupportD (false); bool flagSupportR (false); bool flagSupportS (false); bool flagSupportG (false); bool flagSupportU (false); if (isSctTab && _selSlotTstepSet) { slotCnt = _selSlotTstepSet->allSlotCount (false); // not validOnly oneSlot = (slotCnt == 1); someSlots = (slotCnt >= 1); QList slots = _selSlotTstepSet->getAllValidSlotIndecies(); validSlotCnt = slots.count(); slotUnitCnt = SctSlotTstepSet::countSlotInxUnits (slots, _sctModelDat); oneValidSlot = (validSlotCnt == 1); someValSlots = (validSlotCnt >= 1); someValidSimSlots = _sctModelDat->anyNonAcctSlots (slots); emptySel = _selSlotTstepSet->isEmpty(); oneWholeSlot = _selSlotTstepSet->exactlyOneWholeSlot(); oneCell = _selSlotTstepSet->exactlyOneCell(); wholeSlotCnt = _selSlotTstepSet->wholeSlotCount(); cellOnlyCnt = _selSlotTstepSet->cellOnlyCount(); onlyWholeSlots = (wholeSlotCnt != 0) && (cellOnlyCnt == 0); flagSupportI = slotInxListSupportsFlag (slots, 'I'); flagSupportO = slotInxListSupportsFlag (slots, 'O'); flagSupportB = slotInxListSupportsFlag (slots, 'B'); flagSupportM = slotInxListSupportsFlag (slots, 'M'); flagSupportD = slotInxListSupportsFlag (slots, 'D'); flagSupportR = slotInxListSupportsFlag (slots, 'R'); flagSupportS = slotInxListSupportsFlag (slots, 'S'); flagSupportG = slotInxListSupportsFlag (slots, 'G'); flagSupportU = slotInxListSupportsFlag (slots, 'U'); flagSupportT = oneValidSlot && slotInxListSupportsFlag (slots, 'T'); } // end if (_selSlotTstepSet) bool isAggView (_curView && _curView->isAggregated()); bool userDetailMode (_sctCfg->detailMode() == SCT_DETAIL_MODE_USER); // Dependent on the SCT not displaying integer indexed slots. const bool intIndexed (_sctCfg->intIndexedSlots()); _configTstepAggAction -> setEnabled (isSctTab && !intIndexed); _setAggSumFuncsAction -> setEnabled (isSctTab && !intIndexed); _userDetailsToggleAction -> setEnabled (isSctTab && !intIndexed); _detailsClosedToggleAction -> setEnabled (isSctTab && !intIndexed); _detailsOpenToggleAction -> setEnabled (isSctTab && !intIndexed); _detailsOnlyToggleAction -> setEnabled (isSctTab && !intIndexed); _saveAsDefault -> setEnabled (!intIndexed); if (intIndexed) { _tstepsHorzAction->setText (tr ("Indices &Horizontal")); _tstepsVertAction->setText (tr ("Indices &Vertical")); _configHorzTimeAction->setText (tr ("&Horz Index")); _configVertTimeAction->setText (tr ("&Vert Index")); } else { _tstepsHorzAction->setText (tr ("Timesteps &Horizontal")); _tstepsVertAction->setText (tr ("Timesteps &Vertical")); _configHorzTimeAction->setText (tr ("&Horz Time")); _configVertTimeAction->setText (tr ("&Vert Time")); } // Dependent on SCT file being saved loaded _saveAction -> setEnabled (_sctCfg->isLoaded()); // Dependent on model File being saved/loaded _saveModelAction -> setEnabled (_sctModelDat->isModelLoaded()); // Dependent on SCT being non-empty _printPageAction -> setEnabled (isSctTab && !emptySlotList); _printFullSctAction -> setEnabled (isSctTab && !emptySlotList); // Dependent on cell Selection status _clearOutputsSelAction -> setEnabled (isSctTab && !emptySel && modelEdit); _clearValuesAction -> setEnabled (isSctTab && !emptySel && modelEdit); _printSelectionAction -> setEnabled (isSctTab && !emptySel); _copyExportCellsAction -> setEnabled (isSctTab && !emptySel); _pasteImportCellsAction -> setEnabled (isSctTab && !emptySel && !isAggView); _clearTargetOpsAction -> setEnabled (isSctTab && oneCell && flagSupportT && modelEdit); // Dependent on a single column being selected _setDataColWidthsAction -> setEnabled (isSctTab && singleSelCol); _sizeColsCurToolAction -> setEnabled (isSctTab && singleSelCol); bool selIsCopyable (SctCopySet::selectionIsCopyable(_selSlotTstepSet) && isSctTab && modelEdit); _copyCellsAction -> setEnabled (selIsCopyable); _copyDataToolAction -> setEnabled (selIsCopyable); bool copyCellSetPastable ( SctManagerInst->copyCellSetPastable (this, _selSlotTstepSet) && isSctTab && modelEdit); _pasteCellsAction -> setEnabled (copyCellSetPastable); _pasteCellsAsInputAction -> setEnabled (copyCellSetPastable); _pasteDataToolAction -> setEnabled (copyCellSetPastable); _setToInputAction -> setEnabled (flagSupportI && modelEdit); _setToOutputAction -> setEnabled (flagSupportO && modelEdit); _setTargetOpAction -> setEnabled (flagSupportT && modelEdit); _setBestEfficiencyAction -> setEnabled (flagSupportB && modelEdit); _setMaxCapacityAction -> setEnabled (flagSupportM && modelEdit); _setDriftAction -> setEnabled (flagSupportD && modelEdit); _setRuleDummyAction -> setEnabled (flagSupportR && modelEdit); _setUnitValuesAction -> setEnabled (flagSupportU && modelEdit); _flag_I_toolAction -> setEnabled (flagSupportI && modelEdit); _flag_O_toolAction -> setEnabled (flagSupportO && modelEdit); _flag_T_toolAction -> setEnabled (flagSupportT && modelEdit); _flag_B_toolAction -> setEnabled (flagSupportB && modelEdit); _flag_M_toolAction -> setEnabled (flagSupportM && modelEdit); _flag_D_toolAction -> setEnabled (flagSupportD && modelEdit); _flag_R_toolAction -> setEnabled (flagSupportR && modelEdit); _flag_S_toolAction -> setEnabled (flagSupportS && modelEdit); _flag_G_toolAction -> setEnabled (flagSupportG && modelEdit); _flag_U_toolAction -> setEnabled (flagSupportU && modelEdit); //---------- // Interpolate Selection const okstat interpSelOk = interpolateSelection (true); // testOnly !!! _interpolateSelAction -> setEnabled (bool (interpSelOk)); // // print the reason why operation is disabled. // std::cout << mname << " Interp Sel: " // << (interpSelOk ? "ENABLED" : qPrintable (interpSelOk.msg())) // << std::endl; //---------- if (ENA_INTERP_INPUTS) // New Development (beyond 5.3) { // Interpolate Inputs in Selection const okstat interpInpsOk = interpolateInputs (true); // testOnly !!! _interpolateInputsAction -> setEnabled (bool (interpInpsOk)); // // print the reason why operation is disabled. // std::cout << mname << " Interp Inputs: " // << (interpInpsOk ? "ENABLED" : qPrintable (interpInpsOk.msg())) // << std::endl; } //---------- // Adjust Values in Selection const okstat adjValsOk = adjustValuesInSelection (true); // testOnly !!! _adjustValuesAction -> setEnabled (bool (adjValsOk)); // // print the reason why operation is disabled. // std::cout << mname << " Adjust Vals: " // << (adjValsOk ? "ENABLED" : qPrintable (adjValsOk.msg())) // << std::endl; //---------- // Dependent on Slot Selection status bool plotEnabled (isSctTab && someValSlots && (slotUnitCnt <= 2)); _plotSlotsAction -> setEnabled (plotEnabled); _plotSlotsToolAction -> setEnabled (plotEnabled); bool openEnabled (isSctTab && someValSlots); // (someValidSimSlots); _openSlotsAction -> setEnabled (openEnabled); _openSlotsToolAction -> setEnabled (openEnabled); _findSlotAction -> setEnabled (isSctTab); _enaDispatchingAction -> setEnabled (isSctTab && someValSlots && modelEdit); _disDispatchingAction -> setEnabled (isSctTab && someValSlots && modelEdit); _setLabelAction -> setEnabled (isSctTab && oneSlot && !locked); bool insertSlotEna (isSctTab && (oneSlot || emptySlotList) && !locked); _insertAboveNewSlotsAction -> setEnabled (insertSlotEna); _insertBelowNewSlotsAction -> setEnabled (insertSlotEna); _insertCopiedSlotsAction -> setEnabled (insertSlotEna); _insertAboveNewSDividerAction -> setEnabled (insertSlotEna); _insertBelowNewSDividerAction -> setEnabled (insertSlotEna); _appendNewSlotsAction -> setEnabled (!locked); _appendCopiedSlotsAction -> setEnabled (isSctTab && !locked); _appendNewSDividerAction -> setEnabled (isSctTab && !locked); _reassignSlotAction -> setEnabled (isSctTab && oneSlot && !locked); _copySlotsAction -> setEnabled (isSctTab && someSlots); _cutSlotsAction -> setEnabled (isSctTab && someSlots && !locked); _removeSlotsAction -> setEnabled (isSctTab && someSlots && !locked); _copySlotsAction -> setEnabled (isSctTab && someSlots); _cutSlotsAction -> setEnabled (isSctTab && someSlots && !locked); _insertCopiedSlotsAction -> setEnabled (isSctTab && oneSlot && !emptyCopySlotSet && !locked); _appendCopiedSlotsAction -> setEnabled (isSctTab && !emptyCopySlotSet && !locked); _cellTextFlagsAction -> setEnabled (isSctTab); _cellTextPriosAction -> setEnabled (isSctTab); _toggleRowDetailAction -> setEnabled (isSctTab && isAggView && userDetailMode); // Dependent on the current SctView bool isVertTime = _curView && _curView->tstepAxisIsVertical(); bool isHorzTime = _curView && _curView->tstepAxisIsHorizontal(); _configVertTimeAction -> setEnabled (isVertTime); _configHorzTimeAction -> setEnabled (isHorzTime); // Dependent on the set of Open SCTs _closeOtherSctsAction -> setEnabled (openSctCnt > 1); // Other actions dependent on the SCT Tab being shown _pageLeftAction -> setEnabled (isSctTab); _pageRightAction -> setEnabled (isSctTab); _clearOutputsSelAction -> setEnabled (isSctTab); _clearOutputsSctAction -> setEnabled (isSctTab); _axisOrientActionGroup -> setEnabled (isSctTab); _cellTextActionGroup -> setEnabled (isSctTab); _fitRowHeadersAction -> setEnabled (isSctTab); // ************************************************************ // *** Unconditionally Disable Non-Yet-Implemented Features *** // ************************************************************ _slotConfigAction -> setEnabled (false); // ************************************************************** // *** Schedule Sensitivity Refresh of the Slot List Panels *** // ************************************************************** if (isScalarTab && _scalarListPanel) _scalarListPanel -> schedSensitize(); if (isOtherTab && _nonSeriesListPanel) _nonSeriesListPanel -> schedSensitize(); } void SctDialog::refreshTitle() { if (_sctCfg || _sctModelDat) { QString sctTitle ("SCT"); if (_sctCfg) { if (_sctCfg->intIndexedSlots()) { sctTitle = "Integer Indexed SCT:"; } else if (_sctCfg->stepOverrideOn()) { const DeltaTime step (_sctCfg->stepOverride()); sctTitle = SctConfigDlg::stepSizeStr (step); sctTitle += " SCT:"; } sctTitle += " "; sctTitle += _sctCfg->sctName(); } if (_sctModelDat) { sctTitle += " ("; sctTitle += _sctModelDat->modelName() + ")"; } setCaption (sctTitle); } else { setCaption (SCT_TITLE_GENERIC); } SctManagerInst->addOrUpdateDialog (this); } void SctDialog::refreshSlot (int slotInx) { // Update Data Column Headers in Vertical Timestep Views // (where columns correspond to Slots). // if (_aggTimeVertView) _aggTimeVertView -> guiRefreshSlot (slotInx); if (_noAggTimeVertView) _noAggTimeVertView -> guiRefreshSlot (slotInx); if ((_curView != NULL) && (_curView != _aggTimeVertView) && (_curView != _noAggTimeVertView) ) { _curView->guiRefreshSlot (slotInx); } // Since the set of Slot item labels may have changed, update the // enabledness of the "Next" and "Previous" buttons in the Find // Slot popup dialog. if (_sctFindSlotDlg) _sctFindSlotDlg->updateSensitivity(); // Since the Jump menu is built from Slot Label items, rebuilt it. reBuildJumpMenu(); } void SctDialog::refreshControls () { static const char (*mname) ("SctDialog::refreshControls"); if (!_sctCfg) return; //------------------>> const bool isSctTab (currentTab_isSctView()); const bool isScalarTab (currentTab_isScalarListPanel()); const bool isOtherTab (currentTab_isNonSeriesListPanel()); const bool isListTab (isScalarTab || isOtherTab); refreshMenuSensitivity (); if (_saveModelToolAction) _saveModelToolAction->setVisible (_sctCfg->toolbarSaveModel()); const bool configLocked = _sctCfg->configLocked(); if (_sctLockedToggleAction) _sctLockedToggleAction->setOn (configLocked); if (_lockedToolAction) _lockedToolAction->setOn (configLocked); if (_scalarListPanel) _scalarListPanel->lockConfig (configLocked); if (_nonSeriesListPanel) _nonSeriesListPanel->lockConfig (configLocked); const bool axisHorz = _sctCfg->tstepAxisHorz(); if (_swapAxisToolAction) { const bool axisIsOn = !axisHorz; // std::cout << mname << " axisOn: " << (axisIsOn ? "ON" : "off") // << std::endl; _swapAxisToolAction->setEnabled (isSctTab); _swapAxisToolAction->setChecked (!axisIsOn); _swapAxisToolAction->setVisible (_sctCfg->toolbarSwapAxis()); } if (_tstepsHorzAction) _tstepsHorzAction->setOn (axisHorz); if (_tstepsVertAction) _tstepsVertAction->setOn (!axisHorz); if (_swapAxisToolAction) _swapAxisToolAction->setOn (axisHorz); const SctDetailMode dm = _sctCfg->detailMode(); bool isDetailUser (dm == SCT_DETAIL_MODE_USER); bool isDetailHide (dm == SCT_DETAIL_MODE_ALL_CLOSED); bool isDetailShow (dm == SCT_DETAIL_MODE_ALL_OPEN); bool isDetailOnly (dm == SCT_DETAIL_MODE_NO_SUMMARIES); const bool db = (_sctCfg->toolbarDetailButs()); // show detail buttons? if (_userDetailsToolAction) { _userDetailsToolAction->setEnabled (isSctTab); _userDetailsToolAction->setOn (isDetailUser); _userDetailsToolAction->setVisible (db && _sctCfg->toolbarDetailUser()); } if (_detailsClosedToolAction) { _detailsClosedToolAction->setEnabled (isSctTab); _detailsClosedToolAction->setOn (isDetailHide); _detailsClosedToolAction->setVisible (db && _sctCfg->toolbarDetailHide()); } if (_detailsOpenToolAction) { _detailsOpenToolAction->setEnabled (isSctTab); _detailsOpenToolAction->setOn (isDetailShow); _detailsOpenToolAction->setVisible (db && _sctCfg->toolbarDetailShow()); } if (_detailsOnlyToolAction) { _detailsOnlyToolAction->setEnabled (isSctTab); _detailsOnlyToolAction->setOn (isDetailOnly); _detailsOnlyToolAction->setVisible (db && _sctCfg->toolbarDetailNoSum()); } if (_userDetailsToggleAction) _userDetailsToggleAction->setOn (isDetailUser); if (_detailsClosedToggleAction) _detailsClosedToggleAction->setOn (isDetailHide); if (_detailsOpenToggleAction) _detailsOpenToggleAction->setOn (isDetailShow); if (_detailsOnlyToggleAction) _detailsOnlyToggleAction->setOn (isDetailOnly); if (_plotSlotsToolAction) { _plotSlotsToolAction->setEnabled (isSctTab); _plotSlotsToolAction->setVisible (_sctCfg->toolbarPlotSlots()); } if (_openSlotsToolAction) _openSlotsToolAction->setVisible (_sctCfg->toolbarOpenSlots()); if (_showRunCtrlToolAction) _showRunCtrlToolAction->setVisible (_sctCfg->toolbarRunCtrl()); if (_startRunToolAction) _startRunToolAction->setVisible (_sctCfg->toolbarStartRun()); if (_runAnalToolAction) _runAnalToolAction->setVisible (_sctCfg->toolbarRunAnal()); const bool fbon = _sctCfg->toolbarFlags() && isSctTab; if (_flag_O_toolAction) _flag_O_toolAction->setVisible (fbon); if (_flag_I_toolAction) _flag_I_toolAction->setVisible (fbon); if (_flag_T_toolAction) _flag_T_toolAction->setVisible ( fbon && _sctCfg->isToolbarFlagShown ('T')); if (_flag_B_toolAction) _flag_B_toolAction->setVisible ( fbon && _sctCfg->isToolbarFlagShown ('B')); if (_flag_M_toolAction) _flag_M_toolAction->setVisible ( fbon && _sctCfg->isToolbarFlagShown ('M')); if (_flag_D_toolAction) _flag_D_toolAction->setVisible ( fbon && _sctCfg->isToolbarFlagShown ('D')); if (_flag_S_toolAction) _flag_S_toolAction->setVisible ( fbon && _sctCfg->isToolbarFlagShown ('S')); if (_flag_R_toolAction) _flag_R_toolAction->setVisible ( fbon && _sctCfg->isToolbarFlagShown ('R')); if (_flag_G_toolAction) _flag_G_toolAction->setVisible ( fbon && _sctCfg->isToolbarFlagShown ('G')); if (_flag_U_toolAction) _flag_U_toolAction->setVisible ( fbon && _sctCfg->isToolbarFlagShown ('U')); QToolBar* tb (_sctToolbar); _sctCfg->reApplyColorsToFlagButtonPixmaps (); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_O_toolAction, 'O'); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_I_toolAction, 'I'); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_T_toolAction, 'T'); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_B_toolAction, 'B'); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_M_toolAction, 'M'); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_D_toolAction, 'D'); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_R_toolAction, 'R'); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_S_toolAction, 'S'); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_G_toolAction, 'G'); _sctCfg->applyFlagPixmapToActionButton (tb, _flag_U_toolAction, 'U'); statusBar()->setShown (isSctTab); showStatusBarStatsRow (_sctCfg->showSelectionStats()); // Custom Status Bar Colors if (_statusBarVBox && _statusRow1 && _statusRow2) { const QColor fg (_sctCfg->colorStatusBarFg ()); const QColor bg (_sctCfg->colorStatusBarBg ()); // const QColor curBg (_statusRow1->paletteBackgroundColor ()); if (fg != bg) { _statusBarVBox -> setAutoFillBackground (true); _statusRow1 -> setAutoFillBackground (true); _statusRow2 -> setAutoFillBackground (true); _statusBarVBox -> setPaletteBackgroundColor (bg); _statusBarVBox -> setPaletteForegroundColor (fg); _statusRow1 -> setPaletteBackgroundColor (bg); _statusRow1 -> setPaletteForegroundColor (fg); _statusRow2 -> setPaletteBackgroundColor (bg); _statusRow2 -> setPaletteForegroundColor (fg); } } if (_dtimeSpinner) { const bool doShowDTimeSpinner (_sctCfg->toolbarDTimeSpinner()); _dtimeSpinner->setShown (doShowDTimeSpinner); _dtimeSpinner->setEnabled (isSctTab); _dtimeSpinnerTbarAction->setVisible (doShowDTimeSpinner); _dtimeSpinnerTbarAction->setEnabled (isSctTab); } if (_statusBarWidgetStack && !_sctCfg->showRunStatus()) { // "Show Run Status" is disabled, so put Status Bar // into Selection Status mode. _statusBarWidgetStack->setCurrentWidget (_statusBarVBox); } // *************************** // *** Disabled Features *** // *************************** if (_rplButtonPanelWidget) { _rplButtonPanelWidget->setVisible (SHOW_RPLSET_STATUSBAR_BUTTONS); } // ************************************************************** // *** Schedule Sensitivity Refresh of the Slot List Panels *** // ************************************************************** if (isScalarTab && _scalarListPanel) _scalarListPanel -> schedSensitize(); if (isOtherTab && _nonSeriesListPanel) _nonSeriesListPanel -> schedSensitize(); } void SctDialog::reConfigAggregatedViews (SctRescrollType scrollType, int scrollParm /* =0 */ ) { if (!_sctModelDat) return; //---------------------->> // *** Dropping here may not be necessary. // // if ( (_curView == _aggTimeHorzView) || // (_curView == _aggTimeVertView) ) // dropCellSets (); if (_aggTimeHorzView) _aggTimeHorzView -> reConfigView (_sctCfg, _sctModelDat, scrollType, scrollParm); if (_aggTimeVertView) _aggTimeVertView -> reConfigView (_sctCfg, _sctModelDat, scrollType, scrollParm); } void SctDialog::reConfigAllViews (SctRescrollType scrollType, int scrollParm /* =0 */ ) { if (!_sctModelDat) return; //---------------------->> dropCellSets (); if (_aggTimeHorzView) _aggTimeHorzView -> reConfigView (_sctCfg, _sctModelDat, scrollType, scrollParm); if (_aggTimeVertView) _aggTimeVertView -> reConfigView (_sctCfg, _sctModelDat, scrollType, scrollParm); if (_noAggTimeHorzView) _noAggTimeHorzView -> reConfigView (_sctCfg, _sctModelDat, scrollType, scrollParm); if (_noAggTimeVertView) _noAggTimeVertView -> reConfigView (_sctCfg, _sctModelDat, scrollType, scrollParm); } void SctDialog::fullRecomp (SctRescrollType scrollType, int scrollParm /* = 0 */ ) { dropCellSets (); if (_sctModelDat) { _sctModelDat->setSctConfigRef (_sctCfg); _sctModelDat->recompModelData (); } reConfigAllViews (scrollType, scrollParm); installSctView (); // Re-Initialize DateTime Spinner initDateTimeSpinner (true); // attempt to preserve current DateTime if (currentTab_isSctView() && (_curView != NULL)) _curView->guiRefresh(); // Resize Value Info Label (at top, next to entry editor in toolbar) resizeValueInfoLabel (); // Since the set of Slot item labels may have changed, update the // enabledness of the "Next" and "Previous" buttons in the Find // Slot popup dialog. if (_sctFindSlotDlg) { _sctFindSlotDlg->updateSensitivity(); } if (_sctSetSumFuncDialog) { _sctSetSumFuncDialog->recomputeSlotCounts(); } // Since the Jump menu is built from Slot Label items, rebuilt it. reBuildJumpMenu(); refreshControls (); // We might now be displaying integer indexed slots. refreshTitle(); refreshMenuSensitivity (); } void SctDialog::schedFullRecomp() { static const char* mname ("SctDialog::schedFullRecomp"); // std::cout << mname << std::endl; if (_shipGoingDown) return; //----------------------->> if (_fullRecompTimer == NULL) { _fullRecompTimer = new QTimer (this); _fullRecompTimer->setObjectName ("_fullRecompTimer"); connect (_fullRecompTimer, SIGNAL (timeout()), SLOT (fullRecomp_timeout())); } else { _fullRecompTimer->stop(); } _fullRecompTimer->setSingleShot (true); _fullRecompTimer->start (50); // [milliseconds] } void SctDialog::cancelFullRecomp() { if (_fullRecompTimer) { _fullRecompTimer->stop(); delete _fullRecompTimer; _fullRecompTimer = NULL; } } void SctDialog::growDataColsToData() { if (_aggTimeHorzView) _aggTimeHorzView -> fitDataColsToDataText (true); // growOnly if (_aggTimeVertView) _aggTimeVertView -> fitDataColsToDataText (true); // growOnly if (_noAggTimeHorzView) _noAggTimeHorzView -> fitDataColsToDataText (true); // growOnly if (_noAggTimeVertView) _noAggTimeVertView -> fitDataColsToDataText (true); // growOnly } void SctDialog::fitRowHeaders (bool growOnly) { // Wipe out manual setting of Slot Row Header Width // (Note, this is applicable only in Horizontal Timestep views). _sctCfg->setSlotLabelColFitMethod (SCT_COLFIT_METHOD_UND); _sctCfg->setSlotUnitsColFitMethod (SCT_COLFIT_METHOD_UND); if (_aggTimeVertView) _aggTimeVertView -> fitRowHeaderAndSplitter (growOnly); if (_aggTimeHorzView) _aggTimeHorzView -> fitRowHeaderAndSplitter (growOnly); if (_noAggTimeVertView) _noAggTimeVertView -> fitRowHeaderAndSplitter (growOnly); if (_noAggTimeHorzView) _noAggTimeHorzView -> fitRowHeaderAndSplitter (growOnly); // Resize Value Info Label (at top, next to the entry editor in toolbar) // This is done at the same time as row resizing since it is // based on the same properties as some of the row header columns. resizeValueInfoLabel (); } void SctDialog::recompModelData () { // Note: Call fullRecomp() instead if the Run Init Date // or Run duration have changed. dropCellSets (); if (_sctModelDat) { _sctModelDat->setSctConfigRef (_sctCfg); _sctModelDat->recompModelData (); } if (_curView) _curView->guiRefresh(); refreshMenuSensitivity (); } void SctDialog::checkRefreshSize () { if (_sctCfg) { int cfgWidth (_sctCfg->getWindowWidthField()); int cfgHeight (_sctCfg->getWindowHeightField()); if (cfgWidth <= 0) cfgWidth = INITIAL_SCT_WIDTH; if (cfgHeight <= 0) cfgHeight = INITIAL_SCT_HEIGHT; if (cfgWidth < MIN_SCT_WIDTH) cfgWidth = MIN_SCT_WIDTH; if (cfgHeight < MIN_SCT_HEIGHT) cfgHeight = MIN_SCT_HEIGHT; int sctWidth (size().width()); int sctHeight (size().height()); if ((sctWidth != cfgWidth) || (sctHeight != cfgHeight)) resize (cfgWidth, cfgHeight); } } void SctDialog::applyCurrentFont (bool makeAdjustments /*=true*/) { if (!_sctCfg) return; //----------------->> QString currFontSpec (_sctCfg->currentFontSpec()); if (currFontSpec.isEmpty()) return; //------------------------------->> QFont currFont; bool currFontOk (currFont.fromString (currFontSpec)); if (!currFontOk) return; //-------------------->> //--------------------------------- RwQtAutoWaitCursor waitInst (true); //--------------------------------- // Set font of whole SctDialog setFont (currFont); if (_statusBarVBox) _statusBarVBox->setFont (currFont); if (_aggTimeVertView) _aggTimeVertView -> fitRowHeaderAndSplitter(); if (_aggTimeHorzView) _aggTimeHorzView -> fitRowHeaderAndSplitter(); if (_noAggTimeVertView) _noAggTimeVertView -> fitRowHeaderAndSplitter(); if (_noAggTimeHorzView) _noAggTimeHorzView -> fitRowHeaderAndSplitter(); if (makeAdjustments) { if (_aggTimeVertView) { _aggTimeVertView -> adjustRowHeights(); _aggTimeVertView -> refreshDataColHeaders(); } if (_aggTimeHorzView) { _aggTimeHorzView -> adjustRowHeights(); _aggTimeHorzView -> refreshDataColHeaders(); } if (_noAggTimeVertView) { _noAggTimeVertView -> adjustRowHeights(); _noAggTimeVertView -> refreshDataColHeaders(); } if (_noAggTimeHorzView) { _noAggTimeHorzView -> adjustRowHeights(); _noAggTimeHorzView -> refreshDataColHeaders(); } } } void SctDialog::assignSlotToRow (int /* row */, const char* /* slotLabel */) { static const char (*mname) ("SctDialog::assignSlotToRow"); } void SctDialog::setDetailMode (SctDetailMode mode, bool doInstallView /*=true*/) { if (_sctCfg) _sctCfg->setDetailMode (mode); if (mode != SCT_DETAIL_MODE_NO_SUMMARIES) { _detailsOnlyToolAction->setOn (false); _detailsOnlyToggleAction->setOn (false); } if (mode != SCT_DETAIL_MODE_ALL_OPEN) { _detailsOpenToolAction->setOn (false); _detailsOpenToggleAction->setOn (false); } if (mode != SCT_DETAIL_MODE_ALL_CLOSED) { _detailsClosedToolAction->setOn (false); _detailsClosedToggleAction->setOn (false); } if (mode != SCT_DETAIL_MODE_USER) { _userDetailsToolAction->setOn (false); _userDetailsToggleAction->setOn (false); } switch (mode) { case SCT_DETAIL_MODE_NO_SUMMARIES: if (!_detailsOnlyToolAction->isOn()) _detailsOnlyToolAction->setOn (true); if (!_detailsOnlyToggleAction->isOn()) _detailsOnlyToggleAction->setOn (true); break; case SCT_DETAIL_MODE_ALL_OPEN: if (!_detailsOpenToolAction->isOn()) _detailsOpenToolAction->setOn (true); if (!_detailsOpenToggleAction->isOn()) _detailsOpenToggleAction->setOn (true); break; case SCT_DETAIL_MODE_ALL_CLOSED: if (!_detailsClosedToolAction->isOn()) _detailsClosedToolAction->setOn (true); if (!_detailsClosedToggleAction->isOn()) _detailsClosedToggleAction->setOn (true); break; case SCT_DETAIL_MODE_USER: if (!_userDetailsToolAction->isOn()) _userDetailsToolAction->setOn (true); if (!_userDetailsToggleAction->isOn()) _userDetailsToggleAction->setOn (true); break; } if (doInstallView) installSctView (); refreshMenuSensitivity(); } void SctDialog::addNewSlotsHandler (SlotSelectionType selectType) { if (!_sctCfg) return; //----------------->> int cfgSlotCnt (_sctCfg->slotCnt()); // // Set up for insert or append // if ((selectType == SCT_SLOT_APPEND) || (_sctCfg->slotCnt() == 0)) { // We are appending these slots. _slotSelectionIndex = (-1); _slotSelectionType = SCT_SLOT_APPEND; } else if (selectType == SCT_SLOT_INSERT_ABOVE) { if (!_selSlotTstepSet) return; if (!_selSlotTstepSet->exactlyOneSlot()) return; //-------------------------------------------->> // Get the slot to insert before _slotSelectionIndex = _selSlotTstepSet->firstSlot(); _slotSelectionType = SCT_SLOT_INSERT_ABOVE; } else if (selectType == SCT_SLOT_INSERT_BELOW) { if (!_selSlotTstepSet) return; if (!_selSlotTstepSet->exactlyOneSlot()) return; //-------------------------------------------->> int refSlotInx (_selSlotTstepSet->firstSlot()); if (refSlotInx >= cfgSlotCnt-1) { // After last Slot item: treat as Append _slotSelectionIndex = (-1); _slotSelectionType = SCT_SLOT_APPEND; } else { // Insert after selected reference slot _slotSelectionIndex = refSlotInx; _slotSelectionType = SCT_SLOT_INSERT_BELOW; } } // Show GUS Slot Selector showGusSlotSelector(); } // // The supported slot types that we want to see in the slot selectors // const int INCLUDE_SLOTS_FILTER ( Slot::SeriesSlotBit | Slot::AggSeriesSlotBit | Slot::SimObjMultiSlotBit | Slot::AccountMultiSlotBit | Slot::NoComputeMultiSlotBit | Slot::TableSeriesSlotBit ); void SctDialog::dropCellSets () { dropSelectionCellSet (); dropCopyCellSet (); } void SctDialog::print (int minX, int minY, int maxX, int maxY, bool showSelection, int maxPages) { okstat ok (false); QString docName; { // Gnats 4525: Qt4 Q3Canvas/Q3Table Printing Problems on Windows. // QPrinter printer(QPrinter::PrinterResolution); // Deprecated Qt4 QPrinter printer(QPrinter::ScreenResolution); SctManagerInst->initFromCachedPrinterSettings (printer); bool okPressed = printer.setup (this); if (okPressed) { SctManagerInst->cachePrinterSettings (printer); ok = _curView->print(&printer, minX, minY, maxX, maxY, showSelection, maxPages); docName = printer.docName(); } } //--- delete the QPrinter object, to send the job to the printer if (ok) { // We need to call this method after the print job has been sent to // the printer. QMessageBox::information(this, "Printing successful", "Successfully printed document \"" + docName + "\""); } } void SctDialog::dropSelectionCellSet () { if (_selSlotTstepSet) { delete _selSlotTstepSet; _selSlotTstepSet = NULL; } dropCachedRhSelSet (); if (_aggTimeHorzView) _aggTimeHorzView->clearQtSelection (false); if (_aggTimeVertView) _aggTimeVertView->clearQtSelection (false); if (_noAggTimeHorzView) _noAggTimeHorzView->clearQtSelection (false); if (_noAggTimeVertView) _noAggTimeVertView->clearQtSelection (false); updateStatusBar(); refreshMenuSensitivity(); } void SctDialog::dropCachedRhSelSet () { if (_cachedRhSelSlotTstepSet) { delete _cachedRhSelSlotTstepSet; _cachedRhSelSlotTstepSet = NULL; } } void SctDialog::dropCopyCellSet () { if (_copySlotTstepSet) { delete _copySlotTstepSet; _copySlotTstepSet = NULL; } } void SctDialog::closeSubDialogs () { if (_sctTimestepAggCfgDialog) { // Since _sctTimestepAggCfgDialog is a child (Qt), // delete is not necessary. _sctTimestepAggCfgDialog->hide(); _sctTimestepAggCfgDialog->close (true); _sctTimestepAggCfgDialog = NULL; } // Close and delete dialog box if (_sctSetSumFuncDialog) { _sctSetSumFuncDialog->close(); _sctSetSumFuncDialog = NULL; } if (_sctLabelFnDlg) { // Since _sctTimestepAggCfgDialog is a child (Qt), // delete is not necessary. _sctLabelFnDlg->hide(); _sctLabelFnDlg->close (true); _sctLabelFnDlg = NULL; } if (_sctCfgDlg) { // Since _sctCfgDlg is a child (Qt), // delete is not necessary. _sctCfgDlg->hide(); _sctCfgDlg->close (true); _sctCfgDlg = NULL; } if (_sctClipboardExportDlg) { // Since _sctClipboardExportDlg is a child (Qt), // delete is not necessary. _sctClipboardExportDlg->hide(); _sctClipboardExportDlg->clearListener(); _sctClipboardExportDlg->close (true); _sctClipboardExportDlg = NULL; } if (_sctFindSlotDlg) { // Since _sctFindSlotDlg is a child (Qt), // delete is not necessary. _sctFindSlotDlg->hide(); _sctFindSlotDlg->close (true); _sctFindSlotDlg = NULL; } // Grand Unified Selector (Gus) closeGusSlotSelector(); } void SctDialog::closeViews () { _curView = NULL; if (_aggTimeHorzView) { _aggTimeHorzView->reConfigView (NULL, NULL, SCT_RESCROLL_NOP); _aggTimeHorzView->close (true); _aggTimeHorzView = NULL; } if (_aggTimeVertView) { _aggTimeVertView->reConfigView (NULL, NULL, SCT_RESCROLL_NOP); _aggTimeVertView->close (true); _aggTimeVertView = NULL; } if (_noAggTimeHorzView) { _noAggTimeHorzView->reConfigView (NULL, NULL, SCT_RESCROLL_NOP); _noAggTimeHorzView->close (true); _noAggTimeHorzView = NULL; } if (_noAggTimeVertView) { _noAggTimeVertView->reConfigView (NULL, NULL, SCT_RESCROLL_NOP); _noAggTimeVertView->close (true); _noAggTimeVertView = NULL; } } QString SctDialog::sctName () const { if (_sctCfg) return (_sctCfg->sctName()); return ("unnamed SCT"); } QString SctDialog::sctFnamePath () const { if (_sctCfg) return (_sctCfg->sctFnamePath()); // return empty string for undefined file paths. return (""); } void SctDialog::setSctName (const QString& newName) { if (_sctCfg) _sctCfg->setSctName (newName.ascii()); refreshTitle(); } bool SctDialog::currentTab_isSctView() const { return (_sctViewStack && (_sctViewStack == _sctTabWidget->currentPage())); } bool SctDialog::currentTab_isScalarListPanel() const { return (_scalarListPanel && (_scalarListPanel == _sctTabWidget->currentPage())); } bool SctDialog::currentTab_isNonSeriesListPanel() const { return (_nonSeriesListPanel && (_nonSeriesListPanel == _sctTabWidget->currentPage())); } void SctDialog::selectTabWithLastAddedSlot (bool clearLastAddedInfo /*=true*/) { // If a Slot was added (since the last time the "Last Added Info" // has been cleared) select the Tab on which that Slot appears. bool lastAddedSlotWasSeries (false); bool lastAddedSlotWasNonSer (false); SctSlotColRefData lastNonSeriesAdded; _sctCfg->getLastSlotAddedInfo (lastAddedSlotWasSeries, // returned lastAddedSlotWasNonSer, // returned lastNonSeriesAdded); // returned if (clearLastAddedInfo) { _sctCfg->clearLastSlotAddedInfo(); } QWidget* tabPageToSelect (NULL); if (lastAddedSlotWasSeries) { tabPageToSelect = _sctViewStack; } else if (lastAddedSlotWasNonSer) { Slot* lastAddedSlotPtr = lastNonSeriesAdded.locateTopSlot(); const int lastAddedSlotCol = lastNonSeriesAdded.rwSlotCol(); if (lastAddedSlotPtr) { const SlotColRef scRef (lastAddedSlotPtr, lastAddedSlotCol); if (_scalarListPanel && _scalarListPanel->containsSlotColRef (scRef)) { tabPageToSelect = _scalarListPanel; } else if (_nonSeriesListPanel && _nonSeriesListPanel->containsSlotColRef (scRef)) { tabPageToSelect = _nonSeriesListPanel; } } } if (tabPageToSelect != NULL) { _sctTabWidget->setCurrentWidget (tabPageToSelect); } } void SctDialog::syncMainLineEdit(QLineEdit *inlineEditor) { rwAssert(inlineEditor); if (_entryLineEdit) { connect(inlineEditor, SIGNAL(textChanged(const QString &)), _entryLineEdit, SLOT(setText(const QString &))); _entryLineEdit->setText(inlineEditor->text()); } } void SctDialog::setMainLineEdit(const QString &str) { if (_entryLineEdit) { _entryLineEdit->setText(str); // scroll to first character _entryLineEdit->home (false); // no 'mark' (selection from cur pos) } } void SctDialog::setValueInfoLabel(const QString &str) { if (_valueInfoLabel) { _valueInfoLabel->setText(str); } } void SctDialog::resizeValueInfoLabel () { static const int EXTRA_PIX (8); if (_valueInfoLabel && _sctModelDat) { // Resize Value Info Label to widest Scale/Units in SCT int pixWidth (_sctModelDat->maxSctUnitsPixWidth (_valueInfoLabel, 5)); _valueInfoLabel->setMinimumWidth (pixWidth + EXTRA_PIX); _valueInfoLabel->setMaximumWidth (pixWidth + EXTRA_PIX); // TODO: cause recomputation instead of wiping out _valueInfoLabel->setText(""); } } // Received ownership of dynamically allocated SctSlotTstepSet void SctDialog::receiveNewSelection (SctSlotTstepSet* newSet, SctSlotTstepSet* rhSet) { static const char* mname ("SctDialog::receiveNewSelection"); // ********************************** // *** Row Header Selection Cache *** // ********************************** if (rhSet) { if (_cachedRhSelSlotTstepSet) { delete _cachedRhSelSlotTstepSet; } _cachedRhSelSlotTstepSet = rhSet; } // ************************* // *** New Selection Set *** // ************************* SctSlotTstepSet* saveSelSet = _selSlotTstepSet; _selSlotTstepSet = newSet; // std::cout << mname // << ": Old " << std::hex << (long) saveSelSet << std::dec // << "; New " << std::hex << (long) _selSlotTstepSet << std::dec // << std::endl; if (!saveSelSet) { // No old save set; just update cells for new selection updateGuiSlotTstepSet (_selSlotTstepSet); } else if (!_selSlotTstepSet) { // No new selection; just update cells from old selection updateGuiSlotTstepSet (saveSelSet); } else { // Both old and new selection exist. // Update the difference of individual cells // and the Union of the Whole Slots and Timesteps saveSelSet->cellDiffWholeMerge (*_selSlotTstepSet); updateGuiSlotTstepSet (saveSelSet); } // Delete old selection set if (saveSelSet) { delete saveSelSet; saveSelSet = NULL; } _columnWidthAdjustRequireNewColSelect = false; updateStatusBar(); refreshMenuSensitivity(); } void SctDialog::clearCachedRhSelection () { if (_cachedRhSelSlotTstepSet) { delete _cachedRhSelSlotTstepSet; _cachedRhSelSlotTstepSet = NULL; } } // Set Cell Copy Sets (local & global) void SctDialog::setCellCopySet (bool redraw) { static const char (*mname) ("SctDialog::setCellCopySet"); // Development Diagnostics [11-13-2003, Phil] // const char* copyStat (SctCopySet::copyableStateStr (_selSlotTstepSet)); // std::cout << mname << " " << copyStat << std::endl; // save the old copy set SctSlotTstepSet* saveOldCopySet = _copySlotTstepSet; _copySlotTstepSet = NULL; // if selection is copyable, transfer to copy set if (SctCopySet::selectionIsCopyable (_selSlotTstepSet)) { SctManagerInst->recordNewCopyCellSet (this, _selSlotTstepSet); if (_selSlotTstepSet) { _copySlotTstepSet = _selSlotTstepSet; _selSlotTstepSet = NULL; dropSelectionCellSet (); } } else // (selection is not copyable) { // Clear Copy Set SctManagerInst->clearCopyCellSet (true); // doNotify } if (redraw) { // Force refreshes of effected cells (old and new) if (!saveOldCopySet) { // No old save set; just update cells for new set updateGuiSlotTstepSet (_copySlotTstepSet); } else if (!_copySlotTstepSet) { // No new copy set; just update cells from old selection updateGuiSlotTstepSet (saveOldCopySet); } else { // Both old and new selection exist. // Update the union. saveOldCopySet->merge (*_copySlotTstepSet); updateGuiSlotTstepSet (saveOldCopySet); } } // Delete old copy set if (saveOldCopySet) { delete saveOldCopySet; saveOldCopySet = NULL; } updateStatusBar(); refreshMenuSensitivity(); } // Set the SlotData Copy Set void SctDialog::setSlotCopySet (bool redraw) { static const char (*mname) ("SctDialog::setSlotCopySet"); // Copy SLOT (row or column) Support: // For slots, we are copying SctConfig Slot Data records // (class SctConfigSlotData) -- not just the slot indicies. SctManagerInst->recordNewCopySlotSet (this, _selSlotTstepSet); // ************************************************ // *** Copy Slots to RiverWare Slot Clipboard *** // ************************************************ SlotClipboard::instance()->clearSlots(); if (_selSlotTstepSet && _sctModelDat) { QList slotInxs = _selSlotTstepSet->getAllSlotIndecies(); const int slotInxCnt = slotInxs.count(); for (int sItemInx = 0; sItemInx < slotInxCnt; ++sItemInx) { const int sinx = slotInxs [sItemInx]; _sctModelDat->addSlotToRwSlotClipboard (sinx); } } // If redraw is requested, also apply selection as CELL Copy Set // (In one case, redraw will be passed in as false when this // method is called to CUT SLOTs from the SCT). if (redraw) { setCellCopySet (true); // do redraw } } void SctDialog::clearCopyCellSet (bool redraw) { // save the old copy set SctSlotTstepSet* saveOldCopySet = _copySlotTstepSet; _copySlotTstepSet = NULL; // Force redraw of old cells if (redraw) { updateGuiSlotTstepSet (saveOldCopySet); } // Delete old copy set if (saveOldCopySet) { delete saveOldCopySet; saveOldCopySet = NULL; } refreshMenuSensitivity (); } void SctDialog::clearSctSelection (bool redraw) { // save the old selection set SctSlotTstepSet* saveSelSet = _selSlotTstepSet; _selSlotTstepSet = NULL; dropSelectionCellSet (); // Force redraw of old cells if (redraw) { updateGuiSlotTstepSet (saveSelSet); } // Delete old copy set if (saveSelSet) { delete saveSelSet; saveSelSet = NULL; } updateStatusBar(); refreshMenuSensitivity (); } void SctDialog::updateGuiSlotTstepSet ( SctSlotTstepSet* newSet, bool redundantSlotsToo /* =false */ ) { if (!newSet) return; if (!_curView) return; if (!_sctCfg) return; if (!_sctModelDat) return; //---------------------->> int cfgSlotCnt (_sctCfg->slotCnt()); // ******************************* // *** Update Individual Cells *** // ******************************* QList::ConstIterator it; for (it = newSet->begin(); it != newSet->end(); ++it) { int cellSlotInx = (*it)._slot; int cellTstepInx = (*it)._tstep; if (redundantSlotsToo && _sctModelDat->slotExists (cellSlotInx)) { for (int slotInx = 0; slotInx < cfgSlotCnt; ++slotInx) { if (_sctModelDat->slotPtrsMatch (slotInx, cellSlotInx)) _curView->updateSlotValue (slotInx, cellTstepInx); } } else { _curView->updateSlotValue (cellSlotInx, cellTstepInx); } } // ************************** // *** Update Whole Slots *** // ************************** int wholeSlotCnt (newSet->wholeSlotCount()); if (wholeSlotCnt == cfgSlotCnt) { // if all slots are included, just updated the whole view _curView->guiRefresh(); } else if (wholeSlotCnt > 0) { QList wholeSlots = newSet->getWholeSlotIndecies(); QList::ConstIterator slotIt; for (slotIt = wholeSlots.begin(); slotIt != wholeSlots.end(); ++slotIt) { int slotItemInx (*slotIt); if (redundantSlotsToo && _sctModelDat->slotExists (slotItemInx)) { for (int slotInx = 0; slotInx < cfgSlotCnt; ++slotInx) { if (_sctModelDat->slotPtrsMatch (slotInx, slotItemInx)) _curView->updateSlotValues (slotInx); } } else { _curView->updateSlotValues (slotItemInx); } } } // ****************************** // *** Update Whole Timesteps *** // ****************************** QList wholeTsteps = newSet->getWholeTstepIndecies(); int wholeTstepCnt = wholeTsteps.count(); if (wholeTstepCnt) { // Skip this operation if the set contains all the Slots if (wholeSlotCnt != _sctCfg->slotCnt()) { QList::ConstIterator tstepIt; for (tstepIt = wholeTsteps.begin(); tstepIt != wholeTsteps.end(); ++tstepIt) { _curView->updateTstepValues (*tstepIt); } } } } okstat SctDialog::interpolateSelection (bool testOnly) { static const QString errorTitle (tr ("Interpolation Selection Error")); if (_selSlotTstepSet == NULL) { static const QString msg1 = tr ("The Slot/Timestep cell selection is empty."); static const okstat err1 (msg1); if (!testOnly) QMessageBox::warning (NULL, errorTitle, msg1); return (err1); // (Failure) ----->> } // *************************************** // *** Compute Rectangular Selection *** // *************************************** int minSlotInx (0); int maxSlotInx (-1); int minTstepInx (0); int maxTstepInx (-1); bool slotExtremaAreValidVals (0); const okstat isRect = _selSlotTstepSet->isRectSelection ( minSlotInx, maxSlotInx, // returned minTstepInx, maxTstepInx, // returned &slotExtremaAreValidVals, // returned true ); // validSlotsOnly const int slotRangeCnt = maxSlotInx - minSlotInx + 1; const int tstepRangeCnt = maxTstepInx - minTstepInx + 1; if (!isRect) { static const QString msg2Fmt = tr ("The Slot/Timestep cell selection is not rectangular." " %1 [sinx %2..%3, tinx %4..%5]."); const QString msg2 = msg2Fmt .arg (isRect.msg()) .arg (minSlotInx) .arg (maxSlotInx) .arg (minTstepInx) .arg (maxTstepInx); if (!testOnly) QMessageBox::warning (NULL, errorTitle, msg2); return okstat (msg2); // (Failure) ----->> } if (slotRangeCnt < 1) { static const QString msg3 = tr ("The slot selection is empty."); static const okstat err3 (msg3); if (!testOnly) QMessageBox::warning (NULL, errorTitle, msg3); return (err3); // (Failure) ----->> } if (tstepRangeCnt < 3) { static const QString msg4FmtA = tr ("Only one timestep is selected. Must be at least 3."); static const QString msg4FmtB = tr ("Only %1 timesteps are selected. Must be at least 3."); const QString msg4 = (tstepRangeCnt == 1) ? msg4FmtA : msg4FmtB.arg (tstepRangeCnt); if (!testOnly) QMessageBox::warning (NULL, errorTitle, msg4); return okstat (msg4); // (Failure) ----->> } if (!slotExtremaAreValidVals) { static const QString msg5 = tr ("Not all slot values at the beginning and end of the" " timestep selection are defined."); static const okstat err5 (msg5); if (!testOnly) QMessageBox::warning (NULL, errorTitle, msg5); return (err5); // (Failure) ----->> } // ****************************************** // *** "Test Only" Processing Ends Here *** // ****************************************** if (testOnly) { // Just Testing Operation Validity (for enabling) -- GOOD ENOUGH return okstat (true); // (OK) ----->> //=================================== } // ************************************** // *** Check for Overwriting Inputs *** // ************************************** int inputCnt (0); if (_sctModelDat) { for (int slotInx = minSlotInx; slotInx <= maxSlotInx; ++slotInx) { const int slotInputCnt = _sctModelDat->inputsInTimeRange (slotInx, minTstepInx, maxTstepInx, false); // NOT inclusive inputCnt += slotInputCnt; } } if (inputCnt > 0) { const bool okToContinue = ConfirmInterpOverwriteInputsDlg::ok (inputCnt); if (!okToContinue) { // USER ABORT return okstat (true); //----------------->> } } //---------------------------------------------------------- bool doHold ((slotRangeCnt > 1) || (tstepRangeCnt > 100)); SctModelDataHoldSlotUpdatesSemaphore semInst (_sctModelDat, doHold); //---------------------------------------------------------- for (int slotInx = minSlotInx; slotInx <= maxSlotInx; ++slotInx) { // Note: SctModelData::interpolate method checks sufficient time // range and valid values for both beginning and end of range. // // These conditions have already been checked above, which prevents // the processing of ANY Slots if there are any selection / value // problems. okstat interpOk = _sctModelDat->interpolate (slotInx, minTstepInx, maxTstepInx); if (!interpOk) { const QString msg6 = QString ("[SctModelDat::interpolate] ") + interpOk.msg(); if (!testOnly) QMessageBox::warning (NULL, errorTitle, msg6); return okstat (msg6); // (Failure) ----->> } if (_curView) _curView->updateSlotValues (slotInx); } return okstat (true); // OK } okstat SctDialog::interpolateInputs (bool testOnly) { static const char* mname ("SctDialog::interpolateInputs"); static const QString errorTitle (tr ("Interpolation Inputs Error")); if (_selSlotTstepSet == NULL) { static const QString msg1 = tr ("The Slot/Timestep cell selection is empty."); static const okstat err1 (msg1); if (!testOnly) QMessageBox::warning (NULL, errorTitle, msg1); return (err1); // (Failure) ----->> } if (testOnly) { return okstat (true); // OK //=========================>> } // XXX TODO -- New Development (beyond 5.3) const QString NotImpMsg (QString (mname) + " not implemented."); if (!testOnly) QMessageBox::warning (NULL, errorTitle, NotImpMsg); return okstat (NotImpMsg); } okstat SctDialog::adjustValuesInSelection (bool testOnly) { static const char* mname ("SctDialog::adjustValuesInSelection"); static const QString errorTitle (tr ("Adjust Values Error")); if ((_selSlotTstepSet == NULL) || _selSlotTstepSet->isEmpty()) { static const QString msg1 = tr ("The Slot/Timestep cell selection is empty."); static const okstat err1 (msg1); if (!testOnly) QMessageBox::warning (NULL, errorTitle, msg1); return (err1); // (Failure) ----->> } if (testOnly) { return okstat (true); // OK //=========================>> } // **************************************** // *** Show Adjust Slot Values Dialog *** // **************************************** ScaledUnitPtr scUnitPtr (NULL); const bool absoluteOk = _selSlotTstepSet->exactlyOneScaledUnit (scUnitPtr); // set QString scaledUnitStr (""); unit_type unitType (NOUNITS); if (scUnitPtr) { unitType = scUnitPtr->getType(); const double scale = scUnitPtr->getScale(); if (isValid (scale) && (scale != 1.0)) { scaledUnitStr = QString::number (scale) + " "; } scaledUnitStr += scUnitPtr->getUsrUnit(); } // Get the amount by which to adjust the values from the user. AdjustSlotValsDlg dlg (this, absoluteOk, scaledUnitStr, true); // showOptions const int userResp = dlg.exec(); const QPoint dlgPos = dlg.pos(); if (userResp != QDialog::Accepted) { return okstat (true); // OK //------------------------>> } // ********************** // *** User Choices *** // ********************** // Get the adjustment value and whether or not it is an absolute // adjustment or percent. Because the dialog uses a numeric validator, // the shift value is guaranteed to be valid. // const bool isAbsolute = dlg.isValueAbsolute(); const double dlgUserValue = dlg.getValue(); const bool reportRequested = dlg.reportRequested(); double refVal (0.0); // Absolute Value (Std Units) OR Scaling Factor if (isAbsolute) { unitMgr->convertToStd ( dlgUserValue, // double usrValue refVal, // double& stdValue scUnitPtr ); // ScaledUnitPtr scaledUnit } else // (Percent Offset) { // Note: For non-absolute mode, the user enters a PERCENT OFFSET, // (where 0.0 is "no change"). But the implementation of this // feature uses the reference value as SCALING FACTOR (where 1.0 is // "no change"). Here's the math. refVal = (dlgUserValue / 100.0) + 1.0; // Scaling Factor } // ********************************* // *** Adjust Values Operation *** // ********************************* // std::cout << mname // << ": " << (!isAbsolute ? "SCALE" : "ADJUST") // << ", uTyp " << qPrintable (unitMgr->getUnitType (unitType)) // << ", val " << refVal // << std::endl; adjustValuesOnSlotTstepSet (_selSlotTstepSet, !isAbsolute, // bool doScale -- or absolute adjustment? unitType, // unit_type unitType -- for absolute adj. refVal, // double refVal -- doScale: factor; else: offset reportRequested, &dlgPos); // std::cout << mname << ": done." << std::endl; if (_curView) { // Force update of Selection stats and the Main Line Edit value _curView->processCurrentCell(); } return okstat (true); } void SctDialog::setFlagOnSlotTstepSet ( SctSlotTstepSet* stSet, char flagCh, bool onlyOnValidValues) { static const char (*mname) ("SctDialog::setFlagOnSlotTstepSet"); if (_sctModelDat && _sctCfg && stSet) { //------------------------------------------------------------ bool doHold ( (stSet->wholeSlotCount() > 0) || (stSet->wholeTstepCount() > 0) || (stSet->cellOnlyCount() > 100) ); SctModelDataHoldSlotUpdatesSemaphore semInst (_sctModelDat, doHold); //------------------------------------------------------------ FlagSetter fsetter (*_sctModelDat, flagCh, onlyOnValidValues); okstat ok = stSet->forEach (fsetter, *_sctCfg); if (!ok) { QString temp ("Problem Setting %1"); QString opStr (temp.arg (SctModelData::flagText2 (flagCh))); QMessageBox::information (this, opStr, ok.msg()); } } } void SctDialog::setValueOnSlotTstepSet (SctSlotTstepSet* stSet, double val) { static const char (*mname) ("SctDialog::setValueOnSlotTstepSet"); if (_sctModelDat && _sctCfg && stSet) { //------------------------------------------------------------ bool doHold ( (stSet->wholeSlotCount() > 0) || (stSet->wholeTstepCount() > 0) || (stSet->cellOnlyCount() > 100) ); SctModelDataHoldSlotUpdatesSemaphore semInst (_sctModelDat, doHold); //------------------------------------------------------------ ValueSetter valSetter (*_sctModelDat, val); okstat ok = stSet->forEach (valSetter, *_sctCfg); if (!ok) { QString opStr ("Problem Clearing Value(s)"); if (isValid (val)) { QString temp ("Problem Setting Value %1"); opStr = (temp.arg (val)); } QMessageBox::information (this, opStr, ok.msg()); } } } void SctDialog::adjustValuesOnSlotTstepSet ( SctSlotTstepSet* stSet, bool doScale, // or absolute adjustment? unit_type unitType, // unit type, for absolute adj. double refVal, // _doScale: factor; else: offset bool reportResults, // show popup reporting results const QPoint* dlgPos) /*=NULL*/ { static const char (*mname) ("SctDialog::adjustValueOnSlotTstepSet"); okstat adjustOk (true); // tentative QString statReportMinimal (""); QString statReportFull (""); int successCnt (0); if (_sctModelDat && _sctCfg && stSet) { //------------------------------------------------------------ bool doHold ( (stSet->wholeSlotCount() > 0) || (stSet->wholeTstepCount() > 0) || (stSet->cellOnlyCount() > 100) ); SctModelDataHoldSlotUpdatesSemaphore semInst (_sctModelDat, doHold); //------------------------------------------------------------ const QString valStr = isValid (refVal) ? QString::number (refVal) : QString ("NaN"); const int tstepCnt (_sctModelDat->tStepCnt()); // std::cout << mname << " valAdjuster" // << ": " << (doScale ? "SCALE" : "ADJUST") // << ", uTyp " << qPrintable (unitMgr->getUnitType (unitType)) // << ", val " << (qPrintable (valStr)) // << ", tsteps " << tstepCnt // << std::endl; ValueAdjuster valAdjuster (*_sctModelDat, doScale, unitType, refVal, tstepCnt); // (see processing in ValueAdjuster::processItem). adjustOk = stSet->forEach (valAdjuster, *_sctCfg); statReportMinimal = valAdjuster.statusReport (false); // not all counts statReportFull = valAdjuster.statusReport (true); // all counts successCnt = valAdjuster._successCnt; } // For testing error reporting. Not for actual operation! //-- adjustOk = okstat ("Simulated Error (Testing)"); if (!adjustOk || reportResults) { QMessageBox::Icon dlgIcon; QString titleStr (""); QString msgStr (""); if (!adjustOk) { static const QString errTitleStr (tr ("Problem Adjusting Values")); static const QString errFmt ("%1\n\n%2"); dlgIcon = QMessageBox::Warning; titleStr = errTitleStr; msgStr = errFmt .arg (adjustOk.msg()) .arg (statReportFull); } else { static const QString title0 (tr ("No Values Adjusted")); static const QString title1 (tr ("Values Adjusted")); dlgIcon = QMessageBox::Information; titleStr = (successCnt == 0) ? title0 : title1; msgStr = statReportMinimal; } QMessageBox msgDlg (dlgIcon, titleStr, msgStr, QMessageBox::Ok); if (dlgPos && (dlgPos->x() > 0)) { msgDlg.move (*dlgPos); } msgDlg.exec(); } } void SctDialog::clearOutputsOnSlotTstepSet (SctSlotTstepSet* stSet) { static const char (*mname) ("SctDialog::clearOutputsOnSlotTstepSet"); if (_sctModelDat && _sctCfg && stSet) { //------------------------------------------------------------ bool doHold ( (stSet->wholeSlotCount() > 0) || (stSet->wholeTstepCount() > 0) || (stSet->cellOnlyCount() > 100) ); SctModelDataHoldSlotUpdatesSemaphore semInst (_sctModelDat, doHold); //------------------------------------------------------------ OutputValueClearer outputClearer (*_sctModelDat); okstat ok = stSet->forEach (outputClearer, *_sctCfg); if (!ok) { QString opStr ("Problem Clearing Output(s)"); QMessageBox::information (this, opStr, ok.msg()); } } } void SctDialog::setNoteOnSlotTstepSet (SctSlotTstepSet* stSet, AnnoNoteID noteID) { static const char (*mname) ("SctDialog::setNoteOnSlotTstepSet"); if (_sctModelDat && _sctCfg && stSet) { //------------------------------------------------------------ bool doHold ( (stSet->wholeSlotCount() > 0) || (stSet->wholeTstepCount() > 0) || (stSet->cellOnlyCount() > 100) ); SctModelDataHoldSlotUpdatesSemaphore semInst (_sctModelDat, doHold); //------------------------------------------------------------ // Instead of allowing the generation of annotation callbacks // with every slot/timestep note assignment, generate a single // notification below. // static const bool doSendNotify_No (false); NoteSetter noteSetter (*_sctModelDat, noteID, doSendNotify_No); okstat ok = stSet->forEach (noteSetter, *_sctCfg); // Single notification for all note assignment ops. See note above. AnnoMgr* annoMgr = AnnoMgr::instance(); annoMgr->sendCallback_SlotsAdded(); if (!ok) { QString opStr ("Problem Setting Note(s)"); QMessageBox::information (this, opStr, ok.msg()); } } } // **************************** // *** Selection Predicates *** // **************************** bool SctDialog::selectionEmpty () const { return (!_selSlotTstepSet || _selSlotTstepSet->isEmpty()); } bool SctDialog::selectionHasExactlyOneCell () const { return (_selSlotTstepSet && _selSlotTstepSet->exactlyOneCell()); } bool SctDialog::selectionHasOnlyWholeSlots () const { return (_selSlotTstepSet && (_selSlotTstepSet->wholeSlotCount() != 0) && (_selSlotTstepSet->cellOnlyCount() == 0)); } bool SctDialog::selectionHasExactlyOneWholeSlot () const { return (_selSlotTstepSet && _selSlotTstepSet->exactlyOneWholeSlot()); } bool SctDialog::selectionHasExactlyOneWholeTstep () const { return (_selSlotTstepSet && _selSlotTstepSet->exactlyOneWholeTstep()); } bool SctDialog::selectionHas (int slotInx, int tstepInx) const { return (_selSlotTstepSet && _selSlotTstepSet->contains (slotInx, tstepInx)); } bool SctDialog::selectionHasRange (int slotInx, int tstepInx, int tstepCnt) const { return (_selSlotTstepSet && _selSlotTstepSet->containsRange (slotInx, tstepInx, tstepCnt)); } bool SctDialog::selectionHasCell (int slotInx, int tstepInx) const { return (_selSlotTstepSet && _selSlotTstepSet->containsCell (slotInx, tstepInx)); } bool SctDialog::selectionHasSlotInxAny (int slotInx) const { return (_selSlotTstepSet && _selSlotTstepSet->containsSlotInxAny (slotInx)); } bool SctDialog::selectionHasSlotInxWhole (int slotInx) const { return (_selSlotTstepSet && _selSlotTstepSet->containsSlotInxWhole (slotInx)); } bool SctDialog::selectionHasTstepInxAny (int tstepInx) const { return (_selSlotTstepSet && _selSlotTstepSet->containsTstepInxAny (tstepInx)); } bool SctDialog::selectionHasTstepInxWhole (int tstepInx) const { return (_selSlotTstepSet && _selSlotTstepSet->containsTstepInxWhole (tstepInx)); } bool SctDialog::selectionSupportsFlag (char flagCh) const { if (!_selSlotTstepSet) return false; bool isSupported(false); QList slots = _selSlotTstepSet->getAllSlotIndecies(); for (QList::iterator iter = slots.begin(); iter != slots.end(); iter++) { // Ignore slot dividers if (_sctCfg && (_sctCfg->itemType(*iter) == 'D')) continue; // If any of the slots do not support this flag return false if (!_sctModelDat->flagCanBeSetOnSlot(*iter, flagCh)) return false; //------------>> else isSupported = true; } // All slots in the set support this flag return isSupported; } bool SctDialog::slotInxListSupportsFlag (QList& slots, char flagCh) const { bool isSupported(false); for (QList::iterator iter = slots.begin(); iter != slots.end(); iter++) { // Ignore slot dividers if (_sctCfg && (_sctCfg->itemType(*iter) == 'D')) continue; // If any of the slots do not support this flag return false if (!_sctModelDat->flagCanBeSetOnSlot(*iter, flagCh)) return false; //------------>> else isSupported = true; } // All slots in the set support this flag return isSupported; } void SctDialog::propagateRhColumnWidthChange (SctView*) { //================================= static bool propagateActive (false); if (propagateActive) return; //------------------------>> propagateActive = true; //================================= // Only the Horizontal SCT Views have the Slot Label and // Units Columns if (_aggTimeHorzView) _aggTimeHorzView->fitRowHeaderAndSplitter(); if (_noAggTimeHorzView) _noAggTimeHorzView->fitRowHeaderAndSplitter(); // Resize Value Info Label (at top, next to entry editor in toolbar) // This is done at the same time as row resizing since it is // based on the same properties as some of the row header columns. resizeValueInfoLabel (); //================================= propagateActive = false; //================================= } int SctDialog::modifierState() { const int mstate (RwQtUtils::keyModifierState (this)); return (mstate); } void SctDialog::scrollToTimeStep (int tinx, bool selToo) { if (selToo) { dropSelectionCellSet (); } if (_aggTimeHorzView) { _aggTimeHorzView -> scrollToTimeStep (tinx, selToo && (_curView == _aggTimeHorzView)); } if (_aggTimeVertView) { _aggTimeVertView -> scrollToTimeStep (tinx, selToo && (_curView == _aggTimeVertView)); } if (_noAggTimeHorzView) { _noAggTimeHorzView -> scrollToTimeStep (tinx, selToo && (_curView == _noAggTimeHorzView)); } if (_noAggTimeVertView) { _noAggTimeVertView -> scrollToTimeStep (tinx, selToo && (_curView == _noAggTimeVertView)); } if (_curView) _curView->guiRefresh (); } void SctDialog::scrollToSlotInx (int sinx, bool selToo) { if (selToo) { dropSelectionCellSet (); } if (_aggTimeHorzView) { _aggTimeHorzView -> scrollToSlotInx (sinx, selToo && (_curView == _aggTimeHorzView)); } if (_aggTimeVertView) { _aggTimeVertView -> scrollToSlotInx (sinx, selToo && (_curView == _aggTimeVertView)); } if (_noAggTimeHorzView) { _noAggTimeHorzView -> scrollToSlotInx (sinx, selToo && (_curView == _noAggTimeHorzView)); } if (_noAggTimeVertView) { _noAggTimeVertView -> scrollToSlotInx (sinx, selToo && (_curView == _noAggTimeVertView)); } if (_curView) _curView->guiRefresh (); } int SctDialog::nextSlotInxOfLabel (const QString& matchPattern, SctFindSlotOp op, bool reverseDirection /*=false*/) const { if (matchPattern.isEmpty()) return (-1); if (_sctCfg == NULL) return (-1); //------------------------------------>> const int slotCnt (_sctCfg->slotCnt()); if (slotCnt <= 0) return (-1); //-------------------------->> int slotCursor (-1); if (_selSlotTstepSet) slotCursor = _selSlotTstepSet->firstSlot(); bool wildCardMode (false); QString pattern ("*"); switch (op) { case SctFindSlot_MatchStartsWith: wildCardMode = false; pattern = matchPattern; break; case SctFindSlot_MatchWildcard: wildCardMode = true; pattern = matchPattern; break; case SctFindSlot_MatchContains: default: wildCardMode = true; pattern += matchPattern; pattern += "*"; break; } static const bool caseSensitive (TRUE); QRegExp wildcardRegEx (pattern, caseSensitive, wildCardMode); int slotDownCounter; for (slotDownCounter = slotCnt; slotDownCounter > 0; --slotDownCounter) { if (reverseDirection) { // move to previous Slot item, with wraparound. if (--slotCursor < 0) slotCursor = (slotCnt - 1); } else { // move to subsequent Slot item, with wraparound. slotCursor = ((slotCursor + 1) % slotCnt); } const QString slotLab (_sctCfg->slotLabel(slotCursor).stripWhiteSpace()); if (slotLab.isEmpty()) continue; //------------------------------ bool matchFound = (wildCardMode ? wildcardRegEx.exactMatch (slotLab) : slotLab.startsWith (matchPattern, false)); // not CS if (matchFound) { return (slotCursor); //---------------->> } } return (-1); // not found } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void SctDialog::saveSlotListPanelListsToConfig() { static const char (*mname) ("SctDialog::saveSlotListPanelListsToConfig"); // std::cout << mname << std::endl; cwSlist scList; // Create a SlotColRef list from both Slot List Panels. static const bool doAppend (true); if (_scalarListPanel) _scalarListPanel->getSlotList (scList, doAppend); if (_nonSeriesListPanel) _nonSeriesListPanel->getSlotList (scList, doAppend); const int slotItemCnt = scList.size(); const int slotVecCnt = std::max (1, slotItemCnt); std::vector scVec (slotVecCnt); // Build an SctSlotColRefData vector from the SlotColRef list. int scVecCrs (0); cwIterator iter; for (iter = scList.first(); iter; iter = scList.next (iter)) { const SlotColRef scRef (scList.elem (iter)); const Slot* slotPtr (scRef.slot()); if (slotPtr) { scVec [scVecCrs++] = SctSlotColRefData (slotPtr->getCompleteName(), scRef.col()); } } scVec.resize (scVecCrs); _sctCfg->setSlotListPanelSlotData (scVec); // Clean Up scList.clear(); scVec.clear(); // Update the "Missing Slots" warning label in the Slot List Panels recomputeMissingSlotListPanelSlotCnt(); if (_scalarListPanel) _scalarListPanel -> schedSensitize(); if (_nonSeriesListPanel) _nonSeriesListPanel -> schedSensitize(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void SctDialog::loadSlotListPanelListsFromConfig() { // --------------------------------------------- // *** SIDE EFFECT: // *** Compute int _missingSlotListPanelSlotCnt; // --------------------------------------------- std::vector scVec; _sctCfg->getSlotListPanelSlotData (scVec); // Build non-Series Slot Lists -- to give to the Slot List Panels cwSlist scalarSlotList; cwSlist nonSerSlotList; _missingSlotListPanelSlotCnt = 0; const int scVecSize (scVec.size()); for (int i = 0; i < scVecSize; ++i) { Slot* slotPtr = scVec[i].locateTopSlot(); if (slotPtr == NULL) { ++_missingSlotListPanelSlotCnt; continue; //------------------- } const int slotCol = scVec[i].rwSlotCol(); const SlotColRef scRef (slotPtr, slotCol); const bool isScalarLike (scRef.isScalarLikeSlot()); if (isScalarLike) { scalarSlotList.append (scRef); } else if ((slotPtr->isA (Slot::TableSeriesSlotBit)) && (slotCol < 0)) { // Special Case: Allow TableSeriesSlots with an "All Columns" // indication to be included in the "Other" Slot List. This // can occur, for example, when All Slots are added to an SCT // from an Open Object Dialog. nonSerSlotList.append (scRef); } else if (!slotPtr->isA (Slot::SeriesSlotBit)) { // All other Slots (and not Series Slots): nonSerSlotList.append (scRef); } } if (_scalarListPanel) { // Send the Scalar Slots to the Scalar Slot List Panels _scalarListPanel->setSlotList (scalarSlotList); } if (_nonSeriesListPanel) { // Send the Scalar Slots to the Scalar Slot List Panels _nonSeriesListPanel->setSlotList (nonSerSlotList); } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void SctDialog::recomputeMissingSlotListPanelSlotCnt() { std::vector scVec; _sctCfg->getSlotListPanelSlotData (scVec); _missingSlotListPanelSlotCnt = 0; const int scVecSize (scVec.size()); for (int i = 0; i < scVecSize; ++i) { Slot* slotPtr = scVec[i].locateTopSlot(); if (slotPtr == NULL) { ++_missingSlotListPanelSlotCnt; } } scVec.clear(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void SctDialog::addDialogCallbacks() { static const char (*mname) ("SctDialog::addDialogCallbacks"); // ****************************** // *** Register for Callbacks *** // ****************************** // --------------- // RplSet Managers // --------------- if (rwAssert (_rbsRuleSetMgrCallback == NULL)) { // NOTE (10-30-2009): Is it really OK to force an instantiation of // the RuleSetMgr (i.e. if it hasn't already been instantiated)? // If not, this needs to be more elaborate. Registration for callbacks // on the RuleSetMgr would need to managed in parallel with the dynamic // lifecycle of the RuleSetMgr. // const bool rsMgrExisted = RuleSetMgr::instanceExists(); if (!rsMgrExisted) { // std::cout << mname << ": Instantiating RuleSetMgr !!!" // << std::endl; } RuleSetMgr* rsMgr = RuleSetMgr::instance(); if (rwAssert (rsMgr != NULL)) { MethodCb* rsCb = new MethodCb (this, &SctDialog::rbsRuleSetMgrCallbackHandler, ANY_CALLBACK_TYPE); rsMgr->addCCallback (ANY_CALLBACK_TYPE, rsCb); _rbsRuleSetMgrCallback = rsCb; } } if (rwAssert (_optSetMgrCallback == NULL)) { // NOTE (10-30-2009): Is it really OK to force an instantiation of // the OptSetMgr (i.e. if it hasn't already been instantiated)? // If not, this needs to be more elaborate. Registration for callbacks // on the OptSetMgr would need to managed in parallel with the dynamic // lifecycle of the OptSetMgr. // const bool optMgrExisted = OptSetMgr::instanceExists(); if (!optMgrExisted) { // std::cout << mname << ": Instantiating OptSetMgr !!!" // << std::endl; } OptSetMgr* optMgr = OptSetMgr::instance(); if (rwAssert (optMgr != NULL)) { MethodCb* optCb = new MethodCb (this, &SctDialog::optSetMgrCallbackHandler, ANY_CALLBACK_TYPE); optMgr->addCCallback (ANY_CALLBACK_TYPE, optCb); _optSetMgrCallback = optCb; } } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void SctDialog::deleteDialogCallbacks() { static const char (*mname) ("SctDialog::deleteDialogCallbacks"); if (_rbsRuleSetMgrCallback != NULL) { if (RuleSetMgr::instanceExists()) { RuleSetMgr* rsMgr = RuleSetMgr::instance(); rsMgr->deleteCallback (_rbsRuleSetMgrCallback); } _rbsRuleSetMgrCallback = NULL; } if (_optSetMgrCallback != NULL) { if (OptSetMgr::instanceExists()) { OptSetMgr* optMgr = OptSetMgr::instance(); optMgr->deleteCallback (_optSetMgrCallback); } _optSetMgrCallback = NULL; } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- int SctDialog::rbsRuleSetMgrCallbackHandler (CallbackType cbType, CallbackData*, void*) { static const char (*mname) ("SctDialog::rbsRuleSetMgrCallbackHandler"); // std::cout << mname << " " << callbackTypeStr (cbType) << std::endl; switch (cbType) { case RPL_SET_LOADED: case RPL_SET_UNLOADED: { updateLoadedRplSetButtons(); break; } case RBS_RPLSETMGR_DELETED: { // Drop Callback Pointer _rbsRuleSetMgrCallback = NULL; break; } } return 1; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- int SctDialog::optSetMgrCallbackHandler (CallbackType cbType, CallbackData*, void*) { static const char (*mname) ("SctDialog::optSetMgrCallbackHandler"); // std::cout << mname << " " << callbackTypeStr (cbType) << std::endl; switch (cbType) { case RPL_SET_LOADED: case RPL_SET_UNLOADED: { updateLoadedRplSetButtons(); break; } case OPT_RPLSETMGR_DELETED: { // Drop Callback Pointer _optSetMgrCallback = NULL; break; } } return 1; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // *************************** // *** Flag Setter Functor *** // *************************** // Fields: // SctModelData& _mdat; // const char _flagCh; // const bool _onlyOnValidValues; // virtual from SctSlotTstepSet::ForEachFunction okstat SctDialog::FlagSetter::processItem (int slotInx, int tstepInx) { if ( _onlyOnValidValues && !_mdat.isTstepValueValid (slotInx, tstepInx)) { return (okstat) true; // fail quietly } const okstat ok = _mdat.setSingleTstepFlag (slotInx, tstepInx, _flagCh); return (ok); } // **************************** // *** Value Setter Functor *** // **************************** // Fields: // SctModelData& _mdat; // const double _val; // virtual from SctSlotTstepSet::ForEachFunction okstat SctDialog::ValueSetter::processItem (int slotInx, int tstepInx) { const okstat ok = _mdat.setSingleTstepValue (slotInx, tstepInx, _val); return (ok); } // ****************************** // *** Value Adjuster Functor *** // ****************************** // Fields: // SctModelData& _mdat; // const bool _doScale; // or absolute adjustment? // const unit_type _unitType; // unit type, for absolute adjustment // const double _refVal; // _doScale: factor; else: offset (std value) // const int _tstepCnt; // number of timesteps in SCT // QMap _processedItems; // // int _alreadyProcCnt; // int _wrongUnitCnt; // int _successCnt; // int _nanCnt; // int _readOnlyCnt; // int _errorCnt; // virtual from SctSlotTstepSet::ForEachFunction okstat SctDialog::ValueAdjuster::processItem (int slotInx, int tstepInx) { static const char* mname ("ValueAdjuster::processItem"); // std::cout << mname << " (" << slotInx << "," << tstepInx << ")" // << std::endl; // NOTE: Make sure to process each cell only once. That's important // for the "Adjust Values" operation, otherwise redundantly represented // slot cell selections will cause redundant value adjustments. This can // happen here because any slot can appear in an SCT multiple times. const bool alreadyProcessed = checkAndSetItemProcessed (slotInx, tstepInx); if (alreadyProcessed) { // Multiply-selected Slot/Timesteps are not considered an error. ++_alreadyProcCnt; return okstat (true); //----------------->> } // absolute adjustments require a unit type match if (!_doScale && _mdat.getSlotUnitType (slotInx) != _unitType) { // The wrong unit type is not considered an error. ++_wrongUnitCnt; return okstat (true); //----------------->> } char resultCodeChar ('.'); const okstat adjustOk = _mdat.adjustSingleTstepValue ( slotInx, tstepInx, _doScale, // or absolute adjustment? _refVal, // if (doScale): scaler resultCodeChar); // s-success, n-NaN, r-readOnly, e-error switch (resultCodeChar) { case 's': ++_successCnt; break; case 'n': ++_nanCnt; break; case 'r': ++_readOnlyCnt; break; case 'e': ++_errorCnt; break; } // Note: In general, not adjusting the value (e.g. if the cell is // Read-Only) is not considered an error. return (adjustOk); } SctDialog::ValueAdjuster::~ValueAdjuster() { static const char* mname ("SctDialog::ValueAdjuster dtor"); int deleteCnt (0); QMap::const_iterator iter = _processedItems.constBegin(); for (; iter != _processedItems.constEnd(); ++iter) { SctBmap* bmapPtr = iter.value(); if (bmapPtr) { delete bmapPtr; ++deleteCnt; } } // std::cout << mname << ": deleteCnt " << deleteCnt << std::endl; _processedItems.clear(); } QString SctDialog::ValueAdjuster::statusReport (bool showAll) const { // Note: If 'showAll' is false, then certain unusual counts // are shown ONLY IF they are non-zero. int maxVal = 0; maxVal = std::max (maxVal, _successCnt); maxVal = std::max (maxVal, _nanCnt); maxVal = std::max (maxVal, _wrongUnitCnt); maxVal = std::max (maxVal, _readOnlyCnt); maxVal = std::max (maxVal, _alreadyProcCnt); maxVal = std::max (maxVal, _errorCnt); const int fieldWidth (1 + QString::number (maxVal) .length()); static const QString fmtSucc (tr ("%1: Modified Values \n")); static const QString fmtNan (tr ("%1: NaN Values (not modified) \n")); static const QString fmtROnly (tr ("%1: Read-Only Values \n")); static const QString fmtWUnit (tr ("%1: Values with Different Unit \n")); static const QString fmtAlrdy (tr ("%1: Redundant Values \n")); static const QString fmtError (tr ("%1: Errors \n")); QString str (""); str += fmtSucc .arg (_successCnt, fieldWidth); str += fmtNan .arg (_nanCnt, fieldWidth); str += fmtROnly .arg (_readOnlyCnt, fieldWidth); const bool shWrongUnit ((_wrongUnitCnt != 0) || showAll); const bool shAreadyProc ((_alreadyProcCnt != 0) || showAll); const bool shError ((_errorCnt != 0) || showAll); if (shWrongUnit) str += fmtWUnit .arg (_wrongUnitCnt, fieldWidth); if (shAreadyProc) str += fmtAlrdy .arg (_alreadyProcCnt, fieldWidth); if (shError) str += fmtError .arg (_errorCnt, fieldWidth); // remove trailing spaces and newlines while (!str.isEmpty() && str [str.length()-1] .isSpace()) { str.chop (1); // remove last characer } return (str); } bool SctDialog::ValueAdjuster::checkAndSetItemProcessed ( int slotInx, int tstepInx) { static const char* mname ("SctDialog::ValueAdjuster::checkAndSetItemProcessed"); // QMap _processedItems; if (!rwAssert (slotInx >= 0)) return (false); if (!rwAssert (tstepInx >= 0)) return (false); if (!rwAssert (tstepInx < _tstepCnt)) return (false); //-------------------------------------------------->> SlotColRef scRef = _mdat.getSlotColRef (slotInx); // Note: There's an ambiguity in the encoding of the column index which // prevents certain matches from being recognized. In this particular // mechanism, we don't want to distinguish a column index of (-1) // (which is sometimes used to indicate "All Columns" in a multiple- // column Slot) with a column index of (0), for the "First Column". // We'll ignore such differences in this context. // if (scRef.col() == (-1)) { scRef = SlotColRef (scRef.slot(), 0); } if (!_processedItems.contains (scRef)) { // Note: the new SctBmap must eventually be deleted. _processedItems.insert (scRef, new SctBmap (_tstepCnt)); } bool wasSet (false); SctBmap* bmap = _processedItems [scRef]; if (rwAssert (bmap != NULL)) { wasSet = bmap->checkAndSetFast (tstepInx); } // std::cout << mname << " [" << slotInx << "," << tstepInx << "] " // << std::hex << (long) scRef.root() << std::dec // << " [" << scRef.col() << "] " << (wasSet ? "WAS SET" : "") // << std::endl; return (wasSet); } // ************************************ // *** Output Value Clearer Functor *** // ************************************ // Fields: // SctModelData& _mdat; // virtual from SctSlotTstepSet::ForEachFunction okstat SctDialog::OutputValueClearer::processItem (int slotInx, int tstepInx) { const okstat ok = _mdat.clearOutputValue (slotInx, tstepInx); return (ok); } // *************************** // *** Note Setter Functor *** // *************************** // Fields: // SctModelData& _mdat; // const AnnoNoteID _noteID; // const bool _doNotify; // do send notifications? (callbacks) // virtual from SctSlotTstepSet::ForEachFunction okstat SctDialog::NoteSetter::processItem (int slotInx, int tstepInx) { const okstat ok = _mdat.setSingleNoteId (slotInx, tstepInx, _noteID, _doNotify); return (ok); } //--- (end SctDialog.cpp) ---