Logo Search packages:      
Sourcecode: caret version File versions  Download package

GuiDisplayControlDialog.cxx

/*LICENSE_START*/
/*
 *  Copyright 1995-2002 Washington University School of Medicine
 *
 *  http://brainmap.wustl.edu
 *
 *  This file is part of CARET.
 *
 *  CARET is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  CARET is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with CARET; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
/*LICENSE_END*/

#include <QGlobalStatic>
#ifdef Q_OS_WIN32
#define NOMINMAX 
#endif

#include <algorithm>
#include <iostream>
#include <set>

#include <QAction>
#include <QApplication>
#include <QButtonGroup>
#include <QCheckBox>
#include <QComboBox>
#include <QCursor>
#include <QDir>
#include <QDoubleSpinBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QInputDialog>
#include <QLayout>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QMenu>
#include <QMessageBox>
#include <QProgressDialog>
#include <QPushButton>
#include <QRadioButton>
#include <QScrollArea>
#include <QScrollBar>
#include <QSlider>
#include <QSpinBox>
#include <QStackedWidget>
#include <QTextEdit>
#include <QToolButton>
#include <QToolTip>
#include <QValidator>

#include "AreaColorFile.h"
#include "ArealEstimationFile.h"
#include "BorderColorFile.h"
#include "BorderFile.h"
#include "BrainModelBorderSet.h"
#include "BrainModelSurfaceAndVolume.h"
#include "BrainModelSurfaceNodeColoring.h"
#include "BrainModelVolume.h"
#include "BrainModelVolumeVoxelColoring.h"
#include "BrainSet.h"
#include "CellProjectionFile.h"
#include "CellColorFile.h"
#include "ContourCellColorFile.h"
#include "ContourCellFile.h"
#include "CocomacConnectivityFile.h"
#include "DebugControl.h"
#include "DeformationFieldFile.h"
#include "DisplaySettingsArealEstimation.h"
#include "DisplaySettingsBorders.h"
#include "DisplaySettingsCells.h"
#include "DisplaySettingsCoCoMac.h"
#include "DisplaySettingsContours.h"
#include "DisplaySettingsCuts.h"
#include "DisplaySettingsDeformationField.h"
#include "DisplaySettingsFoci.h"
#include "DisplaySettingsGeodesicDistance.h"
#include "DisplaySettingsImages.h"
#include "DisplaySettingsMetric.h"
#include "DisplaySettingsModels.h"
#include "DisplaySettingsSurface.h"
#include "DisplaySettingsPaint.h"
#include "DisplaySettingsProbabilisticAtlas.h"
#include "DisplaySettingsRgbPaint.h"
#include "DisplaySettingsScene.h"
#include "DisplaySettingsSection.h"
#include "DisplaySettingsStudyMetaData.h"
#include "DisplaySettingsSurfaceShape.h"
#include "DisplaySettingsVectors.h"
#include "DisplaySettingsTopography.h"
#include "DisplaySettingsVolume.h"
#include "DisplaySettingsWustlRegion.h"
#include "FileUtilities.h"
#include "FociColorFile.h"
#include "FociFile.h"
#include "FociProjectionFile.h"
#include "FociSearchFile.h"
#include "GeodesicDistanceFile.h"
#include "GuiBrainModelOpenGL.h"
#include "GuiBrainModelSelectionComboBox.h"
#include "GuiBrainModelSurfaceSelectionComboBox.h"
#include "GuiDataFileCommentDialog.h"
#include "GuiDisplayControlDialog.h"
#include "GuiDisplayControlSurfaceOverlayWidget.h"
#include "GuiFilesModified.h"
#include "GuiFociSearchWidget.h"
#include "GuiHistogramDisplayDialog.h"
#include "GuiIdentifyDialog.h"
#include "GuiMainWindow.h"
#include "GuiSpecAndSceneFileCreationDialog.h"
#include "GuiStudyMetaDataLinkCreationDialog.h"
#include "GuiToolBar.h"
#include "GuiTransformationMatrixSelectionControl.h"
#include "GuiVolumeFileSelectionComboBox.h"
#include "GuiVolumeResizingDialog.h"
#include "GuiNodeAttributeColumnSelectionComboBox.h"
#include "ImageFile.h"
#include "LatLonFile.h"
#include "MetricFile.h"
#include "PaintFile.h"
#include "ProbabilisticAtlasFile.h"
#include "QtListBoxSelectionDialog.h"
#include "QtMultipleInputDialog.h"
#include "QtRadioButtonSelectionDialog.h"
#include "WuQSaveWidgetAsImagePushButton.h"
#include "QtUtilities.h"
#include "QtTextEditDialog.h"
#include "RgbPaintFile.h"
#include "SceneFile.h"
#include "SectionFile.h"
#include "StringUtilities.h"
#include "SurfaceShapeFile.h"
#include "VectorFile.h"
#include "SystemUtilities.h"
#include "TopographyFile.h"
#include "TransformationMatrixFile.h"
#include "VtkModelFile.h"
#include "WuQDataEntryDialog.h"
#include "WuQFileDialog.h"
#include "WuQMessageBox.h"
#include "WuQWidgetGroup.h"
#include "WustlRegionFile.h"

#include "global_variables.h"


/**
 * The Constructor
 */
00163 GuiDisplayControlDialog::GuiDisplayControlDialog(QWidget* parent)
   : WuQDialog(parent)
{
   GuiBrainModelOpenGL::getPointSizeRange(minPointSize, maxPointSize);
   maxPointSize = 100000.0;
   GuiBrainModelOpenGL::getLineWidthRange(minLineSize, maxLineSize);
   
   pageOverlayUnderlaySurfaceNew = NULL;
   surfaceModelIndex = -1;
   
   creatingDialog = true;
   dataInfoDialog = NULL;
   
   setSizeGripEnabled(true);
   setWindowTitle("Display Control");
   
   //
   // Actions for back and forward tool buttons
   //
   QAction* pageBackToolButtonAction = new QAction(this);
   QAction* pageForwardToolButtonAction = new QAction(this);
   
   //
   // Create the combo box for selecting the individual pages
   //
   QLabel* pageSelLabel = new QLabel("Page Selection");
   pageBackToolButton = new QToolButton;
   pageBackToolButton->setToolTip("Go back to the \n"
                                  "previous page.");
   pageBackToolButton->setArrowType(Qt::LeftArrow);
   pageBackToolButton->setDefaultAction(pageBackToolButtonAction);
   QObject::connect(pageBackToolButton, SIGNAL(triggered(QAction*)),
                    this, SLOT(slotPageBackToolButtonPressed(QAction*)));
   pageForwardToolButton = new QToolButton;
   pageForwardToolButton->setToolTip("Go forward to the \n"
                                     "next page as a \n"
                                     "result of using \n"
                                     "the back arrow.");
   pageForwardToolButton->setArrowType(Qt::RightArrow);
   pageForwardToolButton->setDefaultAction(pageForwardToolButtonAction);
   QObject::connect(pageForwardToolButton, SIGNAL(triggered(QAction*)),
                    this, SLOT(slotPageForwardToolButtonPressed(QAction*)));
   pageComboBox = new QComboBox;
   QObject::connect(pageComboBox, SIGNAL(activated(int)),
                    this, SLOT(pageComboBoxSelection(int)));
   QHBoxLayout* pageSelLayout = new QHBoxLayout;
   pageSelLayout->addWidget(pageSelLabel);
   pageSelLayout->addWidget(pageBackToolButton);
   pageSelLayout->addWidget(pageForwardToolButton);
   pageSelLayout->addWidget(pageComboBox);
   pageSelLayout->setStretchFactor(pageSelLabel, 0);
   pageSelLayout->setStretchFactor(pageBackToolButton, 0);
   pageSelLayout->setStretchFactor(pageForwardToolButton, 0);
   pageSelLayout->setStretchFactor(pageComboBox, 100);
   
   //
   // Create the surface selection page
   //
   QLabel* surfaceModelLabel = new QLabel("Surface");
   surfaceModelIndexComboBox = new QComboBox;
   QObject::connect(surfaceModelIndexComboBox, SIGNAL(activated(int)),
                    this, SLOT(slotSurfaceModelIndexComboBox(int)));
   
   //
   // Overlay selection combo box
   //
   QLabel* overlayNumberLabel = new QLabel("Overlay");
   overlayNumberComboBox = new QComboBox;
   for (int i = 0; i < theMainWindow->getBrainSet()->getNumberOfSurfaceOverlays(); i++) {
      overlayNumberComboBox->addItem(theMainWindow->getBrainSet()->getSurfaceOverlay(i)->getName());
   }
   QObject::connect(overlayNumberComboBox, SIGNAL(activated(int)),
                    this, SLOT(slotOverlayNumberComboBox(int)));
   overlayNumberWidgetGroup = new WuQWidgetGroup(this);
   overlayNumberWidgetGroup->addWidget(overlayNumberLabel);
   overlayNumberWidgetGroup->addWidget(overlayNumberComboBox);
   updateOverlayNumberComboBox();
   
   //
   // Shape apply left/right named columns
   //
   shapeApplySelectionToLeftAndRightStructuresFlagCheckBox = new QCheckBox("Apply Shape L-to-L, R-to-R Matching to Coord Files");
   shapeApplySelectionToLeftAndRightStructuresFlagCheckBox->setToolTip("If checked and a surface shape column\n"
                                                          "is selected for display and the column\n"
                                                          "name contains left (right), the column\n"
                                                          "is assigned to all left surfaces and\n"
                                                          "if a column with right (left) in its\n"
                                                          "exists, it is applied to right (left)\n"
                                                          "surfaces.");
   QObject::connect(shapeApplySelectionToLeftAndRightStructuresFlagCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readShapeL2LR2R()));
   
   //
   // Metric apply left/right named columns
   //
   metricApplySelectionToLeftAndRightStructuresFlagCheckBox = new QCheckBox("Apply Metric L-to-L, R-to-R Matching to Coord Files");
   metricApplySelectionToLeftAndRightStructuresFlagCheckBox->setToolTip("If checked and a metric column\n"
                                                          "is selected for display and the column\n"
                                                          "name contains left (right), the column\n"
                                                          "is assigned to all left surfaces and\n"
                                                          "if a column with right (left) in its\n"
                                                          "exists, it is applied to right (left)\n"
                                                          "surfaces.");
   QObject::connect(metricApplySelectionToLeftAndRightStructuresFlagCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readMetricL2LR2R()));
   
   //
   // paint apply left/right named columns
   //
   paintApplySelectionToLeftAndRightStructuresFlagCheckBox = new QCheckBox("Apply Paint L-to-L, R-to-R Matching to Coord Files");
   paintApplySelectionToLeftAndRightStructuresFlagCheckBox->setToolTip("If checked and a paint column\n"
                                                          "is selected for display and the column\n"
                                                          "name contains left (right), the column\n"
                                                          "is assigned to all left surfaces and\n"
                                                          "if a column with right (left) in its\n"
                                                          "exists, it is applied to right (left)\n"
                                                          "surfaces.");
   QObject::connect(paintApplySelectionToLeftAndRightStructuresFlagCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readPaintL2LR2R()));
   
   //
   // RGB Paint apply left/right named columns
   //
   rgbApplySelectionToLeftAndRightStructuresFlagCheckBox = new QCheckBox("Apply RGB Paint L-to-L, R-to-R Matching to Coord Files");
   rgbApplySelectionToLeftAndRightStructuresFlagCheckBox->setToolTip("If checked and an RGB paint column\n"
                                                          "is selected for display and the column\n"
                                                          "name contains left (right), the column\n"
                                                          "is assigned to all left surfaces and\n"
                                                          "if a column with right (left) in its\n"
                                                          "exists, it is applied to right (left)\n"
                                                          "surfaces.");
   QObject::connect(rgbApplySelectionToLeftAndRightStructuresFlagCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readRgbPaintL2LR2R()));
   
   //
   // prob atlas apply left/right named columns
   //
   probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox = new QCheckBox("Apply Prob Atlas L-to-L, R-to-R Matching to Coord Files");
   probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox->setToolTip("If checked and a probabilistic atlas colum\n"
                                                                                  "name contains left (right), the column\n"
                                                                                  "is assigned to all left surfaces and\n"
                                                                                  "if a column with right (left) in its\n"
                                                                                  "exists, it is applied to right (left)\n"
                                                                                  "surfaces.");
   QObject::connect(probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readProbAtlasSurfaceL2LR2R()));
                    
   //
   // Group box for surface and overlay selection
   //
   surfaceModelGroupBox = new QGroupBox("Coloration Applies To");
   QGridLayout* surfaceModelGridLayout = new QGridLayout(surfaceModelGroupBox);
   surfaceModelGridLayout->addWidget(surfaceModelLabel, 0, 0);
   surfaceModelGridLayout->addWidget(surfaceModelIndexComboBox, 0, 1);
   surfaceModelGridLayout->addWidget(overlayNumberLabel, 1, 0);
   surfaceModelGridLayout->addWidget(overlayNumberComboBox, 1, 1);
   surfaceModelGridLayout->addWidget(shapeApplySelectionToLeftAndRightStructuresFlagCheckBox, 2, 0, 1, 2);
   surfaceModelGridLayout->addWidget(metricApplySelectionToLeftAndRightStructuresFlagCheckBox, 3, 0, 1, 2);
   surfaceModelGridLayout->addWidget(paintApplySelectionToLeftAndRightStructuresFlagCheckBox, 4, 0, 1, 2);
   surfaceModelGridLayout->addWidget(rgbApplySelectionToLeftAndRightStructuresFlagCheckBox, 5, 0, 1, 2);
   surfaceModelGridLayout->addWidget(probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox, 6, 0, 1, 2);
   //surfaceModelGroupBox->setMaximumHeight(surfaceModelGroupBox->sizeHint().height());
   surfaceModelGridLayout->setColumnStretch(0, 0);
   surfaceModelGridLayout->setColumnStretch(1, 1000);

   //
   // Scroll widget for widget stack containing all sub pages
   //
   widgetStackScrollArea = new QScrollArea;
   widgetStackScrollArea->setWidgetResizable(true);
   widgetStackScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
   widgetStackScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

   //
   // Widget stack for all sub pages
   //
   pageWidgetStack = new QStackedWidget;
   widgetStackScrollArea->setWidget(pageWidgetStack);

   //
   // Vertical box for all items in dialog
   //
   QVBoxLayout* dialogLayout = new QVBoxLayout(this);
   dialogLayout->setMargin(5);
   dialogLayout->setSpacing(5);
   dialogLayout->addLayout(pageSelLayout);
   dialogLayout->addWidget(surfaceModelGroupBox);
   dialogLayout->addWidget(widgetStackScrollArea);
   dialogLayout->setStretchFactor(pageSelLayout, 0);
   dialogLayout->setStretchFactor(surfaceModelGroupBox, 0);
   dialogLayout->setStretchFactor(widgetStackScrollArea, 100);
   //dialogLayout->addStretch();
   
   //
   // Volume Pages
   //
   pageVolumeSelection = NULL;
   pageVolumeSettings  = NULL;
   pageVolumeSurfaceOutline = NULL;
   
   pageArealEstimation = NULL;
   arealEstimationSelectionButtonGroup = NULL;
   arealEstimationSelectionGridLayout = NULL;
   
   borderNameButtonGroup  = NULL;
   borderNameGridLayout   = NULL;
   borderColorButtonGroup = NULL;
   borderColorGridLayout  = NULL;
   numValidBorderNames    = 0;
   numValidBorderColors   = 0;
   pageBorderMain = NULL;
   pageBorderColor = NULL;
   pageBorderName = NULL;
   
   cellColorButtonGroup = NULL;
   cellColorGridLayout  = NULL;
   cellClassButtonGroup = NULL;
   cellClassGridLayout  = NULL;
   numValidCellClasses  = 0;
   numValidCellColors   = 0;
   pageCellsMain = NULL;
   pageCellsClass = NULL;
   pageCellsColor = NULL;
   
   pageCocomacDisplay = NULL;
   pageCocomacInformation = NULL;
   
   contourCellColorButtonGroup = NULL;
   contourCellColorGridLayout  = NULL;
   contourCellClassButtonGroup = NULL;
   contourCellClassGridLayout  = NULL;
   numValidContourCellClasses  = 0;
   numValidContourCellColors   = 0;
   pageContourMain = NULL;
   pageContourClass = NULL;
   pageContourColor = NULL;
   
   pageDeformationField = NULL;
   
   fociColorButtonGroup = NULL;
   fociColorGridLayout  = NULL;
   fociClassButtonGroup = NULL;
   fociClassGridLayout  = NULL;
   //numValidFociClasses  = 0;
   //numValidFociColors   = 0;
   pageFociMain = NULL;
   pageFociClass = NULL;
   pageFociColor = NULL;
   pageFociKeyword = NULL;
   pageFociName = NULL;
   pageFociSearch = NULL;
   fociSearchWidget = NULL;
   pageFociTable = NULL;
   numberOfFociKeywordCheckBoxesShownInGUI = 0;
   numberOfFociTableCheckBoxesShownInGUI = 0;
   numberOfFociNameCheckBoxesShownInGUI = 0;
   numberOfFociClassCheckBoxesShownInGUI = 0;
   numberOfFociColorCheckBoxesShownInGUI = 0;
   fociShowKeywordsOnlyForDisplayedFociCheckBox = NULL;
   fociShowNamesOnlyForDisplayedFociCheckBox    = NULL;
   fociShowTablesOnlyForDisplayedFociCheckBox   = NULL;
   fociShowClassesOnlyForDisplayedFociCheckBox  = NULL;
   fociShowColorsOnlyForDisplayedFociCheckBox   = NULL;
   
   pageGeodesicMain = NULL;
   geodesicSelectionGridLayout = NULL;

   pageImages = NULL;
   
   latLonSelectionGridLayout = NULL;
   pageLatLonMain = NULL;
   
   metricViewButtonGroup = NULL;
   metricThresholdButtonGroup = NULL;
   metricCommentButtonGroup = NULL;
   metricSubPageSelectionsLayout = NULL;
   metricMetaDataButtonGroup = NULL;
   metricHistogramButtonGroup = NULL;
   numValidMetrics = 0;
   pageMetricMiscellaneous = NULL;
   pageMetricSettings = NULL;
   pageMetricSelection = NULL;
   
   modelSelectionGridWidgetLayout = NULL;
   numValidModels = 0;
   pageModelsMain = NULL;
   pageModelsSettings = NULL;
   
   paintColumnMetaDataButtonGroup = NULL;
   paintColumnSelectionGridLayout = NULL;
   pagePaintColumn = NULL;   
   pagePaintMain = NULL;
   pagePaintName = NULL;
   
   pageSectionMain = NULL;
   
   numValidProbAtlasSurfaceChannels   = 0;
   probAtlasSurfaceSubPageChannelLayout = NULL;
   probAtlasSurfaceChannelGridLayout = NULL;
   probAtlasSurfaceChannelButtonGroup = NULL;
   numValidProbAtlasSurfaceAreas   = 0;
   probAtlasSurfaceAreasGridLayout = NULL;
   probAtlasSurfaceSubPageAreaLayout = NULL;
   probAtlasSurfaceAreasButtonGroup = NULL;
   pageProbAtlasSurfaceMain = NULL;
   pageProbAtlasSurfaceChannel = NULL;
   pageProbAtlasSurfaceArea = NULL;
   
   numValidProbAtlasVolumeChannels   = 0;
   probAtlasVolumeChannelGridLayout       = NULL;
   probAtlasVolumeChannelButtonGroup = NULL;
   numValidProbAtlasVolumeAreas   = 0;
   probAtlasVolumeAreasGridLayout       = NULL;
   probAtlasVolumeAreasButtonGroup = NULL;
   pageProbAtlasVolumeMain = NULL;
   pageProbAtlasVolumeArea = NULL;
   pageProbAtlasVolumeChannel = NULL;
   
   pageRegionMain = NULL;
   
   pageRgbPaintMain = NULL;
   pageRgbPaintSelection = NULL;
   
   pageSceneMain = NULL;
   skipScenePageUpdate = false;
   
   surfaceShapeViewButtonGroup = NULL;
   surfaceShapeCommentButtonGroup = NULL;
   pageSurfaceShapeSelections = NULL;
   pageSurfaceShapeSettings = NULL;
   surfaceShapeSubSelectionsLayout = NULL;
   surfaceShapeMetaDataButtonGroup = NULL;
   surfaceShapeHistogramButtonGroup = NULL;
   numValidSurfaceShape = 0;
   
   pageSurfaceAndVolume = NULL;
   
   pageSurfaceMisc = NULL;

   pageVectorSelection = NULL;
   pageVectorSettings = NULL;
   
   pageTopography = NULL;

   pageSurfaceClipping = NULL;

   //
   // Layout for buttons
   //
   QHBoxLayout* buttonsLayout = new QHBoxLayout;
   buttonsLayout->setSpacing(5);
   dialogLayout->addLayout(buttonsLayout);

   //
   // Apply button
   //
   QPushButton* applyButton = new QPushButton("Apply");
   applyButton->setAutoDefault(false);
   buttonsLayout->addWidget(applyButton);
   QObject::connect(applyButton, SIGNAL(clicked()),
                    this, SLOT(applySelected()));   

   //
   // Save as image button
   //
   WuQSaveWidgetAsImagePushButton* saveAsImageButton =
              new WuQSaveWidgetAsImagePushButton("Save As Image...",
                                                this);
   saveAsImageButton->setAutoDefault(false);
   buttonsLayout->addWidget(saveAsImageButton);
   saveAsImageButton->hide();   // HIDE SAVE AS IMAGE BUTTON ***************
   
   //
   // Help button
   //
   QPushButton* helpButton = new QPushButton("Help");
   buttonsLayout->addWidget(helpButton);
   helpButton->setAutoDefault(false);
   QObject::connect(helpButton, SIGNAL(clicked()),
                    this, SLOT(slotHelpButton()));
                    
   //
   // Close button connects to QDialogs close() slot.   
   //
   QPushButton* closeButton = new QPushButton("Close");
   buttonsLayout->addWidget(closeButton);
   closeButton->setAutoDefault(false);
   QObject::connect(closeButton, SIGNAL(clicked()),
                    this, SLOT(close()));
  
   QtUtilities::makeButtonsSameSize(applyButton, saveAsImageButton, helpButton, closeButton);
 
   dialogDefaultSize = QDialog::sizeHint();
   if (DebugControl::getDebugOn()) {
      std::cout << "Initial D/C Size Hint: (" << dialogDefaultSize.width()
                << " " << dialogDefaultSize.height() << ")" << std::endl;
   }
   //07/06/2005setMinimumSize(dialogDefaultSize);
   //setMaximumSize(dialogDefaultSize);
   
   updateAllItemsInDialog(true, false);
   
   pagesVisitedIndex = -1;
   
   updatePageSelectionComboBox();
   if (pageComboBoxItems.empty() == false) {
      pageComboBoxSelection(0);
   }
   
   //surfaceModelGroupBox->setFixedWidth(pageOverlayUnderlaySurface->sizeHint().width());
   creatingDialog = false;
   
   //
   // Default to O/U Volume page if there are volumes and no surfaces
   //
   if (validSurfaceData) {
      showDisplayControlPage(PAGE_NAME_SURFACE_OVERLAY_UNDERLAY_NEW, false);
   }
   else if (validVolumeData) {
      showDisplayControlPage(PAGE_NAME_VOLUME_SELECTION, false);
   }
   else if (validContourData) {
      showDisplayControlPage(PAGE_NAME_CONTOUR_MAIN, false);
   }
   else {
      showDisplayControlPage(PAGE_NAME_SCENE, false);
   }

/*   
   //
   // Show scene page if no brain models but have scenes
   //
   if (theMainWindow->getBrainSet()->getNumberOfBrainModels() <= 0) {
      SceneFile* sf = theMainWindow->getBrainSet()->getSceneFile();
      if (sf->getNumberOfScenes() > 0) {
         showScenePage();
      }
   }
*/
   
   //07/06/05widgetStackScrollView->setMinimumHeight(pageWidgetStack->sizeHint().height());
   resize(585, 740);
}
   
/**
 * called when help button pressed.
 */
void 
00611 GuiDisplayControlDialog::slotHelpButton()
{
   theMainWindow->showHelpViewerDialog("dialogs/display_control_dialog.html");
}
      

/**
 * show the scene page.
 */
void 
00621 GuiDisplayControlDialog::showScenePage()
{
   showDisplayControlPage(PAGE_NAME_SCENE, true);
}
      
/**
 * override of parent method.
 */
void 
00630 GuiDisplayControlDialog::resizeEvent(QResizeEvent* re)
{
   QDialog::resizeEvent(re);

   if (DebugControl::getDebugOn()) {
      std::cout << "Display Control Dialog Resized: " << std::endl;
      std::cout << std::endl;
   }
}

/**
 * context menu event.
 */
void 
00644 GuiDisplayControlDialog::contextMenuEvent(QContextMenuEvent* /*e*/)
{
   //
   // Popup menu for selection of pages
   //
   QMenu menu(this);
   
   //
   // Add capture image of dialog to clipboard
   //
   addImageCaptureToMenu(&menu);
   menu.addSeparator();
   
   //
   // Page selection
   //
   QMenu* pageSelectionMenu = new QMenu("Page");
   QObject::connect(pageSelectionMenu, SIGNAL(triggered(QAction*)),
                    this, SLOT(slotPageSelectionPopupMenu(QAction*)));
   for (int i = 0; i < pageComboBox->count(); i++) {
      QAction* action = pageSelectionMenu->addAction(pageComboBox->itemText(i));
      action->setData(QVariant(i));
   }
   menu.addMenu(pageSelectionMenu);
   
   //
   // Add the overlay selection menus
   //
   BrainSet* brainSet = theMainWindow->getBrainSet();
   for (int m = (brainSet->getNumberOfSurfaceOverlays() -1); m >= 0; m--) {
      //
      // Get the overlay and its valid data types
      //
      const BrainModelSurfaceOverlay* bmsOverlay = brainSet->getSurfaceOverlay(m);
      std::vector<BrainModelSurfaceOverlay::OVERLAY_SELECTIONS> dataTypes;
      std::vector<QString> dataTypeNames;
      bmsOverlay->getDataTypesAndNames(dataTypes, dataTypeNames);
      const BrainModelSurfaceOverlay::OVERLAY_SELECTIONS selectedOverlay =
         bmsOverlay->getOverlay(getSurfaceModelIndex());
      const int numDataTypes = static_cast<int>(dataTypes.size());
      
      //
      // Create the menu
      //
      QMenu* overlayMenu = new QMenu(bmsOverlay->getName());
      QObject::connect(overlayMenu, SIGNAL(triggered(QAction*)),
                       this, SLOT(slotOverlaySelectionPopupMenu(QAction*)));
      for (int i = 0; i < numDataTypes; i++) {
         QAction* action = overlayMenu->addAction(dataTypeNames[i]);
         const int dataOverlayNumberAndItem = (m * 1000) + static_cast<int>(dataTypes[i]);
         action->setData(QVariant(dataOverlayNumberAndItem));
         if (selectedOverlay == dataTypes[i]) {
            action->setCheckable(true);
            action->setChecked(true);
         }
      }
      
      //
      // Add overlay selection to popup menu
      //
      menu.addMenu(overlayMenu);
   }
   
   //
   // Popup the menu
   //
   menu.exec(QCursor::pos());
}      

/**
 * override of sizeHint (limits width of dialog but user can stretch).
 */
/*
QSize 
GuiDisplayControlDialog::sizeHint() const
{
   //
   // Default size was set after dialog created but before data loaded
   //
   QSize sz(500, dialogDefaultSize.height());
   return sz;
}
*/

/**
 * get the name of a page.
 */
QString 
00732 GuiDisplayControlDialog::getPageName(const PAGE_NAME pageName) const
{
   QString s("Unknown");
   
   switch (pageName) {
      case PAGE_NAME_SURFACE_OVERLAY_UNDERLAY_NEW:
         s = "Overlay/Underlay - Surface";
         break;
      case PAGE_NAME_VOLUME_SETTINGS:
         s = "Volume Settings";
         break;
      case PAGE_NAME_VOLUME_SURFACE_OUTLINE:
         s = "Volume Surface Outline";
         break;
      case PAGE_NAME_VOLUME_SELECTION:
         s = "Overlay/Underlay - Volume";
         break;
      case PAGE_NAME_AREAL_ESTIMATION:
         s = "Areal Estimation";
         break;
      case PAGE_NAME_BORDER_MAIN:
         s = "Border Main";
         break;
      case PAGE_NAME_BORDER_COLOR:
         s = "Border Color";
         break;
      case PAGE_NAME_BORDER_NAME:
         s = "Border Name";
         break;
      case PAGE_NAME_CELL_MAIN:
         s = "Cell Main";
         break;
      case PAGE_NAME_CELL_CLASS:
         s = "Cell Class";
         break;
      case PAGE_NAME_CELL_COLOR:
         s = "Cell Color";
         break;
      case PAGE_NAME_COCOMAC_DISPLAY:
         s = "CoCoMac Display";
         break;
      case PAGE_NAME_COCOMAC_INFORMATION:
         s = "CoCoMac Information";
         break;
      case PAGE_NAME_CONTOUR_MAIN:
         s = "Contours";
         break;
      case PAGE_NAME_CONTOUR_CLASS:
         s = "Contour Cell Class";
         break;
      case PAGE_NAME_CONTOUR_COLOR:
         s = "Contour Cell Color";
         break;
      case PAGE_NAME_DEFORMATION_FIELD:
         s = "Deformation Field";
         break;
      case PAGE_NAME_FOCI_MAIN:
         s = "Foci Main";
         break;
      case PAGE_NAME_FOCI_CLASS:
         s = "Foci Class";
         break;
      case PAGE_NAME_FOCI_COLOR:
         s = "Foci Color";
         break;
      case PAGE_NAME_FOCI_KEYWORD:
         s = "Foci Keyword";
         break;
      case PAGE_NAME_FOCI_NAME:
         s = "Foci Name";
         break;
      case PAGE_NAME_FOCI_SEARCH:
         s = "Foci Search";
         break;
      case PAGE_NAME_FOCI_TABLE:
         s = "Foci Table";
         break;
      case PAGE_NAME_GEODESIC:
         s = "Geodesic";
         break;
      case PAGE_NAME_IMAGES:
         s = "Images";
         break;
      case PAGE_NAME_LATLON:
         s = "Lat/Lon";
         break;
      case PAGE_NAME_METRIC_MISCELLANEOUS:
         s = "Metric Miscellaneous";
         break;
      case PAGE_NAME_METRIC_SELECTION:
         s = "Metric Selection";
         break;
      case PAGE_NAME_METRIC_SETTINGS:
         s = "Metric Settings";
         break;
      case PAGE_NAME_MODELS_MAIN:
         s = "Models Main";
         break;
      case PAGE_NAME_MODELS_SETTINGS:
         s = "Models Settings";
         break;
      case PAGE_NAME_PAINT_COLUMN:
         s = "Paint Selection";
         break;
      case PAGE_NAME_PAINT_MAIN:
         s = "Paint Main";
         break;
      case PAGE_NAME_PAINT_NAMES:
         s = "Paint Names";
         break;
      case PAGE_NAME_PROB_ATLAS_SURFACE_MAIN:
         s = "Probabilistic Atlas - Surface Main";
         break;
      case PAGE_NAME_PROB_ATLAS_SURFACE_AREA:
         s = "Probabilistic Atlas - Surface Areas";
         break;
      case PAGE_NAME_PROB_ATLAS_SURFACE_CHANNEL:
         s = "Probabilistic Atlas - Surface Channels";
         break;
      case PAGE_NAME_PROB_ATLAS_VOLUME_MAIN:
         s = "Probabilistic Atlas - Volume Main";
         break;
      case PAGE_NAME_PROB_ATLAS_VOLUME_AREA:
         s = "Probabilistic Atlas - Volume Area";
         break;
      case PAGE_NAME_PROB_ATLAS_VOLUME_CHANNEL:
         s = "Probabilistic Atlas - Volume Channel";
         break;
      case PAGE_NAME_REGION:
         s = "Region";
         break;
      case PAGE_NAME_RGB_PAINT_MAIN:
         s = "RGB Paint Settings";
         break;
      case PAGE_NAME_RGB_PAINT_SELECTION:
         s = "RGB Paint Selection";
         break;
      case PAGE_NAME_SCENE:
         s = "Scene";
         break;
      case PAGE_NAME_SECTION_MAIN:
         s = "Section Main";
         break;
      case PAGE_NAME_SHAPE_SELECTION:
         s = "Surface Shape Selection";
         break;
      case PAGE_NAME_SHAPE_SETTINGS:
         s = "Surface Shape Settings";
         break;
      case PAGE_NAME_SURFACE_AND_VOLUME:
         s = "Surface and Volume";
         break;
      case PAGE_NAME_SURFACE_CLIPPING:
         s = "Surface Clipping";
         break;
      case PAGE_NAME_SURFACE_MISC:
         s = "Surface Miscellaneous";
         break;
      case PAGE_NAME_TOPOGRAPHY:
         s = "Topography";
         break;
      case PAGE_NAME_VECTOR_SELECTION:
         s = "Vector Selection";
         break;
      case PAGE_NAME_VECTOR_SETTINGS:
         s = "Vector Settings";
         break;
      case PAGE_NAME_INVALID:
         s = "Invalid";
         break;
   }
   
   return s;
}      

/**
 * update the data validity flag.
 */
void 
00911 GuiDisplayControlDialog::updateDataValidityFlags()      
{
   BrainSet* brainSet = theMainWindow->getBrainSet();
   bool haveSurfaceFlag = false;
   for (int i = 0; i < brainSet->getNumberOfBrainModels(); i++) {
      if (brainSet->getBrainModelSurface(i) != NULL) {
         haveSurfaceFlag = true;
         break;
      }
   }
   BrainModelBorderSet* bmbs = brainSet->getBorderSet();
   
   validSurfaceData = haveSurfaceFlag;
   validVolumeData = (brainSet->getBrainModelVolume() != NULL);
   validVolumeFunctionalData = (brainSet->getNumberOfVolumeFunctionalFiles() > 0);
   validArealEstimationData = (brainSet->getArealEstimationFile()->getNumberOfColumns() > 0);
   validBorderData = ((bmbs->getNumberOfBorders() > 0) ||
                             (theMainWindow->getBrainSet()->getVolumeBorderFile()->getNumberOfBorders() > 0));
   validCellData = ((theMainWindow->getBrainSet()->getCellProjectionFile()->getNumberOfCellProjections() > 0) ||
                       (theMainWindow->getBrainSet()->getVolumeCellFile()->empty() == false) ||
                       theMainWindow->getBrainSet()->getHaveTransformationDataCellFiles());
   validCocomacData = (brainSet->getCocomacFile()->empty() == false);
   validContourData = (brainSet->getBrainModelContours() != NULL);
   validDeformationFieldData = (brainSet->getDeformationFieldFile()->getNumberOfColumns() > 0);
   validFociData = ((theMainWindow->getBrainSet()->getFociProjectionFile()->getNumberOfCellProjections() > 0));
   validGeodesicData = (brainSet->getGeodesicDistanceFile()->getNumberOfColumns() > 0);
   validImageData = (brainSet->getNumberOfImageFiles() > 0);
   validLatLonData = (brainSet->getLatLonFile()->getNumberOfColumns() > 0);
   validMetricData = (brainSet->getMetricFile()->getNumberOfColumns() > 0);
   validModelData = (brainSet->getNumberOfVtkModelFiles() > 0);
   validPaintData = (brainSet->getPaintFile()->getNumberOfColumns() > 0);
   validProbAtlasSurfaceData = (brainSet->getProbabilisticAtlasSurfaceFile()->getNumberOfColumns() > 0);
   validProbAtlasVolumeData = (brainSet->getNumberOfVolumeProbAtlasFiles() > 0);
   const WustlRegionFile* wrf = theMainWindow->getBrainSet()->getWustlRegionFile();
   validRegionData = ((wrf->getNumberOfTimeCourses() > 0) &&
                      (brainSet->getNumberOfVolumePaintFiles() > 0));
   validRgbPaintData = (brainSet->getRgbPaintFile()->getNumberOfColumns() > 0);
   validSceneData = true;  // always valid
   validSectionData = (brainSet->getSectionFile()->getNumberOfColumns() > 0);
   validShapeData = (brainSet->getSurfaceShapeFile()->getNumberOfColumns() > 0);
   validSurfaceAndVolumeData = (brainSet->getBrainModelSurfaceAndVolume() != NULL);
   validVectorData = (brainSet->getNumberOfVectorFiles() > 0);
   validTopographyData = (brainSet->getTopographyFile()->getNumberOfColumns() > 0);
}

/**
 * Update the page selection combo box based upon enabled pages.
 */
void
00960 GuiDisplayControlDialog::updatePageSelectionComboBox()
{
   updateDataValidityFlags();
   
   PAGE_NAME currentPageName = PAGE_NAME_INVALID;
   if (pageComboBoxItems.empty() == false) {
      const int item = pageComboBox->currentIndex();
      if ((item >= 0) && (item < static_cast<int>(pageComboBoxItems.size()))) {
         currentPageName = pageComboBoxItems[item];
      }
   }
   
   pageComboBox->clear();
   pageComboBoxItems.clear();
   
   if (validSurfaceData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_SURFACE_OVERLAY_UNDERLAY_NEW));
      pageComboBoxItems.push_back(PAGE_NAME_SURFACE_OVERLAY_UNDERLAY_NEW);
   }
   if (validVolumeData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_VOLUME_SELECTION));
      pageComboBoxItems.push_back(PAGE_NAME_VOLUME_SELECTION);
   }
   if (validArealEstimationData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_AREAL_ESTIMATION));
      pageComboBoxItems.push_back(PAGE_NAME_AREAL_ESTIMATION);
   }
   if (validBorderData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_BORDER_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_BORDER_MAIN);
   }
   if (validBorderData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_BORDER_COLOR));
      pageComboBoxItems.push_back(PAGE_NAME_BORDER_COLOR);
   }
   if (validBorderData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_BORDER_NAME));
      pageComboBoxItems.push_back(PAGE_NAME_BORDER_NAME);
   }
   if (validCellData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_CELL_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_CELL_MAIN);
   }
   if (validCellData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_CELL_CLASS));
      pageComboBoxItems.push_back(PAGE_NAME_CELL_CLASS);
   }
   if (validCellData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_CELL_COLOR));
      pageComboBoxItems.push_back(PAGE_NAME_CELL_COLOR);
   }
   if (validCocomacData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_COCOMAC_DISPLAY));
      pageComboBoxItems.push_back(PAGE_NAME_COCOMAC_DISPLAY);
   }
   if (validCocomacData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_COCOMAC_INFORMATION));
      pageComboBoxItems.push_back(PAGE_NAME_COCOMAC_INFORMATION);
   }
   if (validContourData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_CONTOUR_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_CONTOUR_MAIN);
   }
   if (validContourData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_CONTOUR_CLASS));
      pageComboBoxItems.push_back(PAGE_NAME_CONTOUR_CLASS);
   }
   if (validContourData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_CONTOUR_COLOR));
      pageComboBoxItems.push_back(PAGE_NAME_CONTOUR_COLOR);
   }
   if (validDeformationFieldData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_DEFORMATION_FIELD));
      pageComboBoxItems.push_back(PAGE_NAME_DEFORMATION_FIELD);
   }
   if (validFociData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_FOCI_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_FOCI_MAIN);
   }
   if (validFociData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_FOCI_CLASS));
      pageComboBoxItems.push_back(PAGE_NAME_FOCI_CLASS);
   }
   if (validFociData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_FOCI_COLOR));
      pageComboBoxItems.push_back(PAGE_NAME_FOCI_COLOR);
   }
   if (validFociData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_FOCI_KEYWORD));
      pageComboBoxItems.push_back(PAGE_NAME_FOCI_KEYWORD);
   }
   if (validFociData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_FOCI_NAME));
      pageComboBoxItems.push_back(PAGE_NAME_FOCI_NAME);
   }
   if (validFociData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_FOCI_SEARCH));
      pageComboBoxItems.push_back(PAGE_NAME_FOCI_SEARCH);
   }
   if (validFociData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_FOCI_TABLE));
      pageComboBoxItems.push_back(PAGE_NAME_FOCI_TABLE);
   }
   if (validGeodesicData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_GEODESIC));
      pageComboBoxItems.push_back(PAGE_NAME_GEODESIC);
   }
   if (validImageData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_IMAGES));
      pageComboBoxItems.push_back(PAGE_NAME_IMAGES);
   }
   if (validLatLonData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_LATLON));
      pageComboBoxItems.push_back(PAGE_NAME_LATLON);
   }
   if (validMetricData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_METRIC_MISCELLANEOUS));
      pageComboBoxItems.push_back(PAGE_NAME_METRIC_MISCELLANEOUS);
   }
   if (validMetricData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_METRIC_SELECTION));
      pageComboBoxItems.push_back(PAGE_NAME_METRIC_SELECTION);
   }
   if (validMetricData || validVolumeFunctionalData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_METRIC_SETTINGS));
      pageComboBoxItems.push_back(PAGE_NAME_METRIC_SETTINGS);
   }
   if (validModelData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_MODELS_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_MODELS_MAIN);
   }
   if (validModelData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_MODELS_SETTINGS));
      pageComboBoxItems.push_back(PAGE_NAME_MODELS_SETTINGS);
   }
   if (validPaintData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_PAINT_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_PAINT_MAIN);
      pageComboBox->addItem(getPageName(PAGE_NAME_PAINT_COLUMN));
      pageComboBoxItems.push_back(PAGE_NAME_PAINT_COLUMN);
      pageComboBox->addItem(getPageName(PAGE_NAME_PAINT_NAMES));
      pageComboBoxItems.push_back(PAGE_NAME_PAINT_NAMES);
   }
   if (validProbAtlasSurfaceData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_PROB_ATLAS_SURFACE_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_PROB_ATLAS_SURFACE_MAIN);
   }
   if (validProbAtlasSurfaceData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_PROB_ATLAS_SURFACE_AREA));
      pageComboBoxItems.push_back(PAGE_NAME_PROB_ATLAS_SURFACE_AREA);
   }
   if (validProbAtlasSurfaceData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_PROB_ATLAS_SURFACE_CHANNEL));
      pageComboBoxItems.push_back(PAGE_NAME_PROB_ATLAS_SURFACE_CHANNEL);
   }
   if (validProbAtlasVolumeData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_PROB_ATLAS_VOLUME_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_PROB_ATLAS_VOLUME_MAIN);
   }
   if (validProbAtlasVolumeData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_PROB_ATLAS_VOLUME_AREA));
      pageComboBoxItems.push_back(PAGE_NAME_PROB_ATLAS_VOLUME_AREA);
   }
   if (validProbAtlasVolumeData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_PROB_ATLAS_VOLUME_CHANNEL));
      pageComboBoxItems.push_back(PAGE_NAME_PROB_ATLAS_VOLUME_CHANNEL);
   }
   if (validRegionData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_REGION));
      pageComboBoxItems.push_back(PAGE_NAME_REGION);
   }
   if (validRgbPaintData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_RGB_PAINT_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_RGB_PAINT_MAIN);
      pageComboBox->addItem(getPageName(PAGE_NAME_RGB_PAINT_SELECTION));
      pageComboBoxItems.push_back(PAGE_NAME_RGB_PAINT_SELECTION);
   }
   if (validSceneData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_SCENE));
      pageComboBoxItems.push_back(PAGE_NAME_SCENE);
   }
   if (validSectionData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_SECTION_MAIN));
      pageComboBoxItems.push_back(PAGE_NAME_SECTION_MAIN);
   }
   if (validShapeData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_SHAPE_SELECTION));
      pageComboBoxItems.push_back(PAGE_NAME_SHAPE_SELECTION);
   }
   if (validShapeData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_SHAPE_SETTINGS));
      pageComboBoxItems.push_back(PAGE_NAME_SHAPE_SETTINGS);
   }
   if (validSurfaceAndVolumeData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_SURFACE_AND_VOLUME));
      pageComboBoxItems.push_back(PAGE_NAME_SURFACE_AND_VOLUME);
   }
   if (validSurfaceData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_SURFACE_CLIPPING));
      pageComboBoxItems.push_back(PAGE_NAME_SURFACE_CLIPPING);
   }
   if (validSurfaceData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_SURFACE_MISC));
      pageComboBoxItems.push_back(PAGE_NAME_SURFACE_MISC);
   }
   if (validTopographyData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_TOPOGRAPHY));
      pageComboBoxItems.push_back(PAGE_NAME_TOPOGRAPHY);
   }
   if (validVectorData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_VECTOR_SELECTION));
      pageComboBoxItems.push_back(PAGE_NAME_VECTOR_SELECTION);
      pageComboBox->addItem(getPageName(PAGE_NAME_VECTOR_SETTINGS));
      pageComboBoxItems.push_back(PAGE_NAME_VECTOR_SETTINGS);
   }
   if (validVolumeData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_VOLUME_SETTINGS));
      pageComboBoxItems.push_back(PAGE_NAME_VOLUME_SETTINGS);
   }
   if (validVolumeData) {
      pageComboBox->addItem(getPageName(PAGE_NAME_VOLUME_SURFACE_OUTLINE));
      pageComboBoxItems.push_back(PAGE_NAME_VOLUME_SURFACE_OUTLINE);
   }
   
   int defaultItem = 0;
   for (int i = 0; i < static_cast<int>(pageComboBoxItems.size()); i++) {
      if (pageComboBoxItems[i] == currentPageName) {
         defaultItem = i;
         break;
      }
   }
   if (pageComboBoxItems.empty() == false) {
      pageComboBox->blockSignals(true);
      pageComboBox->setCurrentIndex(defaultItem);
      pageComboBox->blockSignals(false);
   }
}

/**
 * called when popup menu overlay selection is made.
 */
void 
01202 GuiDisplayControlDialog::slotOverlaySelectionPopupMenu(QAction* action)
{
   //
   // Get overlay number and selection
   //
   const int item = action->data().toInt();
   const int overlayNumber = item / 1000;
   const int dataTypeValue = item % 1000;
   
   //
   // Set the overlay
   //
   BrainModelSurfaceOverlay* bmsOverlay = 
      theMainWindow->getBrainSet()->getSurfaceOverlay(overlayNumber);
   const BrainModelSurfaceOverlay::OVERLAY_SELECTIONS dataType =
      static_cast<BrainModelSurfaceOverlay::OVERLAY_SELECTIONS>(dataTypeValue);
   bmsOverlay->setOverlay(getSurfaceModelIndex(),
                          dataType);
   
   //
   // Update the dialog
   //
   switch (bmsOverlay->getOverlay(dataType)) {
      case BrainModelSurfaceOverlay::OVERLAY_NONE:
         break;
      case BrainModelSurfaceOverlay::OVERLAY_AREAL_ESTIMATION:
         updateArealEstimationItems();
         break;
      case BrainModelSurfaceOverlay::OVERLAY_COCOMAC:
         updateCocomacItems();
         break;
      case BrainModelSurfaceOverlay::OVERLAY_METRIC:
         updateMetricSelectionPage();
         break;
      case BrainModelSurfaceOverlay::OVERLAY_PAINT:
         updatePaintColumnPage();
         break;
      case BrainModelSurfaceOverlay::OVERLAY_PROBABILISTIC_ATLAS:
         break;
      case BrainModelSurfaceOverlay::OVERLAY_RGB_PAINT:
         updateRgbPaintItems();
         break;
      case BrainModelSurfaceOverlay::OVERLAY_SECTIONS:
         updateSectionMainPage();
         break;
      case BrainModelSurfaceOverlay::OVERLAY_SHOW_CROSSOVERS:
         break;
      case BrainModelSurfaceOverlay::OVERLAY_SHOW_EDGES:
         break;
      case BrainModelSurfaceOverlay::OVERLAY_SURFACE_SHAPE:
         updateShapeSelections();
         break;
      case BrainModelSurfaceOverlay::OVERLAY_TOPOGRAPHY:
         updateTopographyItems();
         break;
      case BrainModelSurfaceOverlay::OVERLAY_GEOGRAPHY_BLENDING:
         break;
   }
   updateSurfaceOverlayWidgets();
   
   const int indx = pageComboBox->currentIndex();
   initializeSelectedOverlay(static_cast<PAGE_NAME>(pageComboBoxItems[indx]));
   //updateOverlayNumberComboBox();
   
   theMainWindow->getBrainSet()->getNodeColoring()->assignColors();
   GuiBrainModelOpenGL::updateAllGL();
}
      
/**
 * called when popup menu selection is made.
 */
void
01274 GuiDisplayControlDialog::slotPageSelectionPopupMenu(QAction* action)
{
   // get integer from action->data
   const int item = action->data().toInt();
   pageComboBoxSelection(item);
}

/**
 * called when page back tool button pressed.
 */
void 
01285 GuiDisplayControlDialog::slotPageBackToolButtonPressed(QAction*)
{
   pagesVisitedIndex--;
   if ((pagesVisitedIndex >= 0) &&
       (pagesVisitedIndex < static_cast<int>(pagesVisited.size()))) {
      showDisplayControlPage(pagesVisited[pagesVisitedIndex], false);
   }
}

/**
 * called when page forward tool button pressed.
 */
void 
01298 GuiDisplayControlDialog::slotPageForwardToolButtonPressed(QAction*)
{
   pagesVisitedIndex++;
   if ((pagesVisitedIndex >= 0) &&
       (pagesVisitedIndex < static_cast<int>(pagesVisited.size()))) {
      showDisplayControlPage(pagesVisited[pagesVisitedIndex], false);
   }
}
      
/**
 * show a display control page.
 */
void 
01311 GuiDisplayControlDialog::showDisplayControlPage(const PAGE_NAME pageName,
                                                const bool updatePagesVisited)
{
   bool enableSurfaceModelIndexComboBox = false;
   bool enableSurfaceModelOverlayNumberComboBox = false;
   pageComboBox->blockSignals(true);
   for (int i = 0; i < static_cast<int>(pageComboBoxItems.size()); i++) {
      if (pageComboBoxItems[i] == pageName) {
         pageComboBox->blockSignals(true);
         pageComboBox->setCurrentIndex(i);
         pageComboBox->blockSignals(false);
      }
   }
   pageComboBox->blockSignals(false);
   
   metricApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(true);
   shapeApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(true);
   paintApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(true);
   rgbApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(true);
   probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(true);
   
   switch(pageName) {
      case PAGE_NAME_SURFACE_OVERLAY_UNDERLAY_NEW:
         if (pageOverlayUnderlaySurfaceNew == NULL) {
            createOverlayUnderlaySurfacePageNew();
            updateAllItemsInDialog(true, false);
         }
         pageWidgetStack->setCurrentWidget(pageOverlayUnderlaySurfaceNew);
         enableSurfaceModelIndexComboBox = true;
         break;
      case PAGE_NAME_AREAL_ESTIMATION:
         if (pageArealEstimation == NULL) {
            createArealEstimationPage();
            updateArealEstimationItems();
         }
         pageWidgetStack->setCurrentWidget(pageArealEstimation);
         enableSurfaceModelIndexComboBox = true;
         enableSurfaceModelOverlayNumberComboBox = true;
         break;
      case PAGE_NAME_BORDER_MAIN:
         if (pageBorderMain == NULL) {
            createBorderMainPage();
            updateBorderMainPage();
         }
         pageWidgetStack->setCurrentWidget(pageBorderMain);
         break;
      case PAGE_NAME_BORDER_COLOR:
         if (pageBorderColor == NULL) {
            createBorderColorPage();
            updateBorderColorPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageBorderColor);
         break;
      case PAGE_NAME_BORDER_NAME:
         if (pageBorderName == NULL) {
            createBorderNamePage();
            updateBorderNamePage(true);
         }
         pageWidgetStack->setCurrentWidget(pageBorderName);
         break;
      case PAGE_NAME_CELL_MAIN:
         if (pageCellsMain == NULL) {
            createCellMainPage();
            updateCellMainPage();
         }
         pageWidgetStack->setCurrentWidget(pageCellsMain);
         break;
      case PAGE_NAME_CELL_CLASS:
         if (pageCellsClass == NULL) {
            createCellClassPage();
            updateCellClassPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageCellsClass);
         break;
      case PAGE_NAME_CELL_COLOR:
         if (pageCellsColor == NULL) {
            createCellColorPage();
            updateCellColorPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageCellsColor);
         break;
      case PAGE_NAME_COCOMAC_DISPLAY:
         if (pageCocomacDisplay == NULL) {
            createCocomacDisplayPage();
            updateCocomacDisplayPage();
         }
         pageWidgetStack->setCurrentWidget(pageCocomacDisplay);
         break;
      case PAGE_NAME_COCOMAC_INFORMATION:
         if (pageCocomacInformation == NULL) {
            createCocomacFileInformationPage();
            updateCocomacInformationPage();
         }
         pageWidgetStack->setCurrentWidget(pageCocomacInformation);
         break;
      case PAGE_NAME_CONTOUR_MAIN:
         if (pageContourMain == NULL) {
            createContourMainPage();
            updateContourMainPage();
         }
         pageWidgetStack->setCurrentWidget(pageContourMain);
         break;
      case PAGE_NAME_CONTOUR_CLASS:
         if (pageContourClass == NULL) {
            createContourClassPage();
            updateContourClassPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageContourClass);
         break;
      case PAGE_NAME_CONTOUR_COLOR:
         if (pageContourColor == NULL) {
            createContourColorPage();
            updateContourColorPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageContourColor);
         break;
      case PAGE_NAME_DEFORMATION_FIELD:
         if (pageDeformationField == NULL) {
            createDeformationFieldPage();
            updateDeformationFieldPage();
         }
         pageWidgetStack->setCurrentWidget(pageDeformationField);
         break;
      case PAGE_NAME_FOCI_MAIN:
         if (pageFociMain == NULL) {
            createFociMainPage();
            updateFociMainPage();
         }
         pageWidgetStack->setCurrentWidget(pageFociMain);
         break;
      case PAGE_NAME_FOCI_CLASS:
         if (pageFociClass == NULL) {
            createFociClassPage();
            updateFociClassPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageFociClass);
         break;
      case PAGE_NAME_FOCI_COLOR:
         if (pageFociColor == NULL) {
            createFociColorPage();
            updateFociColorPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageFociColor);
         break;
      case PAGE_NAME_FOCI_KEYWORD:
         if (pageFociKeyword == NULL) {
            createFociKeywordPage();
            updateFociKeywordPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageFociKeyword);
         break;
      case PAGE_NAME_FOCI_NAME:
         if (pageFociName == NULL) {
            createFociNamePage();
            updateFociNamePage(true);
         }
         pageWidgetStack->setCurrentWidget(pageFociName);
         break;
      case PAGE_NAME_FOCI_SEARCH:
         if (pageFociSearch == NULL) {
            createFociSearchPage();
            updateFociSearchPage(true);
         }
         pageFociSearch->updateGeometry();
         pageWidgetStack->setCurrentWidget(pageFociSearch);
         break;
      case PAGE_NAME_FOCI_TABLE:
         if (pageFociTable == NULL) {
            createFociTablePage();
            updateFociTablePage(true);
         }
         pageWidgetStack->setCurrentWidget(pageFociTable);
         break;
      case PAGE_NAME_GEODESIC:
         if (pageGeodesicMain == NULL) {
            createGeodesicPage();
            updateGeodesicItems();
         }
         pageWidgetStack->setCurrentWidget(pageGeodesicMain);
         break;
      case PAGE_NAME_IMAGES:
         if (pageImages == NULL) {
            createImagesPage();
            updateImagesItems();
         }
         pageWidgetStack->setCurrentWidget(pageImages);
         break;
      case PAGE_NAME_LATLON:
         if (pageLatLonMain == NULL) {
            createLatLonPage();
            updateLatLonItems();
         }
         pageWidgetStack->setCurrentWidget(pageLatLonMain);
         break;
      case PAGE_NAME_METRIC_MISCELLANEOUS:
         if (pageMetricMiscellaneous == NULL) {
            createMetricMiscellaneousPage();
            updateMetricMiscellaneousPage();
         }
         pageWidgetStack->setCurrentWidget(pageMetricMiscellaneous);
         break;
      case PAGE_NAME_METRIC_SELECTION:
         if (pageMetricSelection == NULL) {
            createMetricSelectionPage();
            updateMetricSelectionPage();
         }
         pageWidgetStack->setCurrentWidget(pageMetricSelection);
         enableSurfaceModelIndexComboBox = true;
         enableSurfaceModelOverlayNumberComboBox = true;
         metricApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(false);
         break;
      case PAGE_NAME_METRIC_SETTINGS:
         if (pageMetricSettings == NULL) {
            createMetricSettingsPage();
            updateMetricSettingsPage();
         }
         updateMetricSettingsThresholdColumnComboBox();
         pageWidgetStack->setCurrentWidget(pageMetricSettings);
         break;
      case PAGE_NAME_MODELS_MAIN:
         if (pageModelsMain == NULL) {
            createModelsMainPage();
            updateModelMainPage();
         }
         pageWidgetStack->setCurrentWidget(pageModelsMain);
         break;
      case PAGE_NAME_MODELS_SETTINGS:
         if (pageModelsSettings == NULL) {
            createModelsSettingsPage();
            updateModelSettingsPage();
         }
         pageWidgetStack->setCurrentWidget(pageModelsSettings);
         break;
      case PAGE_NAME_PAINT_MAIN:
         if (pagePaintMain == NULL) {
            createPaintMainPage();
            updatePaintMainPage();
         }
         pageWidgetStack->setCurrentWidget(pagePaintMain);
         break;
      case PAGE_NAME_PAINT_COLUMN:
         if (pagePaintColumn == NULL) {
            createPaintColumnPage();
            updatePaintColumnPage();
         }
         pageWidgetStack->setCurrentWidget(pagePaintColumn);
         enableSurfaceModelIndexComboBox = true;
         enableSurfaceModelOverlayNumberComboBox = true;
         paintApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(false);
         break;
      case PAGE_NAME_PAINT_NAMES:
         if (pagePaintName == NULL) {
            createPaintNamePage();
            updatePaintNamePage();
         }
         pageWidgetStack->setCurrentWidget(pagePaintName);
         break;
      case PAGE_NAME_PROB_ATLAS_SURFACE_MAIN:
         if (pageProbAtlasSurfaceMain == NULL) {
            createProbAtlasSurfaceMainPage();
            updateProbAtlasSurfaceMainPage();
         }
         pageWidgetStack->setCurrentWidget(pageProbAtlasSurfaceMain);
         enableSurfaceModelIndexComboBox = true;
         probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(false);
         break;
      case PAGE_NAME_PROB_ATLAS_SURFACE_AREA:
         if (pageProbAtlasSurfaceArea == NULL) {
            createProbAtlasSurfaceAreaPage();
            updateProbAtlasSurfaceAreaPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageProbAtlasSurfaceArea);
         break;
      case PAGE_NAME_PROB_ATLAS_SURFACE_CHANNEL:
         if (pageProbAtlasSurfaceChannel == NULL) {
            createProbAtlasSurfaceChannelPage();
            updateProbAtlasSurfaceChannelPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageProbAtlasSurfaceChannel);
         break;
      case PAGE_NAME_PROB_ATLAS_VOLUME_MAIN:
         if (pageProbAtlasVolumeMain == NULL) {
            createProbAtlasVolumeMainPage();
            updateProbAtlasVolumeMainPage();
         }
         pageWidgetStack->setCurrentWidget(pageProbAtlasVolumeMain);
         break;
      case PAGE_NAME_PROB_ATLAS_VOLUME_AREA:
         if (pageProbAtlasVolumeArea == NULL) {
            createProbAtlasVolumeAreaPage();
            updateProbAtlasVolumeAreaPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageProbAtlasVolumeArea);
         break;
      case PAGE_NAME_PROB_ATLAS_VOLUME_CHANNEL:
         if (pageProbAtlasVolumeChannel == NULL) {
            createProbAtlasVolumeChannelPage();
            updateProbAtlasVolumeChannelPage(true);
         }
         pageWidgetStack->setCurrentWidget(pageProbAtlasVolumeChannel);
         break;
      case PAGE_NAME_REGION:
         if (pageRegionMain == NULL) {
            createRegionPage();
            updateRegionItems();
         }
         pageWidgetStack->setCurrentWidget(pageRegionMain);
         break;
      case PAGE_NAME_RGB_PAINT_MAIN:
         if (pageRgbPaintMain == NULL) {
            createRgbPaintMainPage();
            updateRgbPaintMainPage();
         }
         pageWidgetStack->setCurrentWidget(pageRgbPaintMain);
         break;
      case PAGE_NAME_RGB_PAINT_SELECTION:
         if (pageRgbPaintSelection == NULL) {
            createRgbPaintSelectionPage();
            updateRgbPaintSelectionPage();
         }
         pageWidgetStack->setCurrentWidget(pageRgbPaintSelection);
         enableSurfaceModelIndexComboBox = true;
         enableSurfaceModelOverlayNumberComboBox = true;
         rgbApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(false);
         break;
      case PAGE_NAME_SCENE:
         if (pageSceneMain == NULL) {
            createScenePage();
            updateSceneItems();
         }
         sceneListBox->blockSignals(true);
         pageWidgetStack->setCurrentWidget(pageSceneMain);
         sceneListBox->blockSignals(false);
         break;
      case PAGE_NAME_SECTION_MAIN:
         if (pageSectionMain == NULL) {
            createSectionMainPage();
            updateSectionMainPage();
         }
         pageWidgetStack->setCurrentWidget(pageSectionMain);
         break;
      case PAGE_NAME_SHAPE_SELECTION:
         if (pageSurfaceShapeSelections == NULL) {
            createShapeSelectionPage();
            updateShapeSelections();
         }
         pageWidgetStack->setCurrentWidget(pageSurfaceShapeSelections);
         enableSurfaceModelIndexComboBox = true;
         enableSurfaceModelOverlayNumberComboBox = true;
         shapeApplySelectionToLeftAndRightStructuresFlagCheckBox->setHidden(false);
         break;
      case PAGE_NAME_SHAPE_SETTINGS:
         if (pageSurfaceShapeSettings == NULL) {
            createShapeSettingsPage();
            updateShapeSettings();
         }
         updateShapeSettingsColorMappingComboBox();
         pageWidgetStack->setCurrentWidget(pageSurfaceShapeSettings);
         break;
      case PAGE_NAME_SURFACE_AND_VOLUME:
         if (pageSurfaceAndVolume == NULL) {
            createSurfaceAndVolumePage();
            updateSurfaceAndVolumeItems();
         }
         pageWidgetStack->setCurrentWidget(pageSurfaceAndVolume);
         break;
      case PAGE_NAME_SURFACE_CLIPPING:
         if (pageSurfaceClipping == NULL) {
            createSurfaceClippingPage();
            updateSurfaceClippingPage();
         }
         pageWidgetStack->setCurrentWidget(pageSurfaceClipping);
         break;
      case PAGE_NAME_SURFACE_MISC:
         if (pageSurfaceMisc == NULL) {
            createSurfaceMiscPage();
            updateMiscItems();
         }
         pageWidgetStack->setCurrentWidget(pageSurfaceMisc);
         break;
      case PAGE_NAME_VECTOR_SELECTION:
         if (pageVectorSelection == NULL) {
            createVectorSelectionPage();
            updateVectorSelectionPage();
         }
         pageWidgetStack->setCurrentWidget(pageVectorSelection);
         break;
      case PAGE_NAME_VECTOR_SETTINGS:
         if (pageVectorSettings == NULL) {
            createVectorSettingsPage();
            updateVectorSettingsPage();
         }
         pageWidgetStack->setCurrentWidget(pageVectorSettings);
         break;
      case PAGE_NAME_TOPOGRAPHY:
         if (pageTopography == NULL) {
            createTopographyPage();
            updateTopographyItems();
         }
         pageWidgetStack->setCurrentWidget(pageTopography);
         enableSurfaceModelIndexComboBox = true;
         break;
      case PAGE_NAME_VOLUME_SELECTION:
         if (pageVolumeSelection == NULL) {
            createOverlayUnderlayVolumeSelectionPage();
            updateVolumeSelectionPage();
         }
         pageWidgetStack->setCurrentWidget(pageVolumeSelection);
         break;
      case PAGE_NAME_VOLUME_SETTINGS:
         if (pageVolumeSettings == NULL) {
            createOverlayUnderlayVolumeSettingsPage();
            updateVolumeSettingsPage();
         }
         pageWidgetStack->setCurrentWidget(pageVolumeSettings);
         break;
      case PAGE_NAME_VOLUME_SURFACE_OUTLINE:
         if (pageVolumeSurfaceOutline == NULL) {
            createOverlayUnderlayVolumeSurfaceOutlinePage();
            updateVolumeSurfaceOutlinePage();
         }
         pageWidgetStack->setCurrentWidget(pageVolumeSurfaceOutline);
         break;
      case PAGE_NAME_INVALID:
         break;
   }
   
   //
   // Should pages visited be updated
   //
   if (updatePagesVisited) {
      //
      // Remove any pages "forward" of the current page index
      //
      const int numPages = static_cast<int>(pagesVisited.size());
      if ((pagesVisitedIndex >= 0) &&
          (pagesVisitedIndex < (numPages - 1))) {
         pagesVisited.erase(pagesVisited.begin() + pagesVisitedIndex + 1,
                            pagesVisited.end());
      }
      
      //
      // Add new pages
      //
      pagesVisited.push_back(pageName);
      pagesVisitedIndex = static_cast<int>(pagesVisited.size() - 1);
   }
   
   if (DebugControl::getDebugOn()) {
      std::cout << "PAGES VISITED TRACKING" << std::endl;
      for (int i = 0; i < static_cast<int>(pagesVisited.size()); i++) {
         std::cout << i
                   << ": " 
                   << getPageName(pagesVisited[i]).toAscii().constData();
         if (pagesVisitedIndex == i) {
            std::cout << " <==== current page visited index";
         }
         std::cout << std::endl;
      }
      std::cout << std::endl;
   }


   surfaceModelGroupBox->setHidden((enableSurfaceModelIndexComboBox == false) &&
                                   (enableSurfaceModelOverlayNumberComboBox == false));
   overlayNumberWidgetGroup->setHidden(enableSurfaceModelOverlayNumberComboBox == false);
   
   //
   // Scroll to top of page and left
   //
   QScrollBar* vertScrollBar = widgetStackScrollArea->verticalScrollBar();
   vertScrollBar->setValue(vertScrollBar->minimum());
   QScrollBar* horizScrollBar = widgetStackScrollArea->horizontalScrollBar();
   horizScrollBar->setValue(horizScrollBar->minimum());
   
   //
   // Enable/Disable back and forward buttons
   //
   pageBackToolButton->setEnabled(pagesVisitedIndex > 0);
   pageForwardToolButton->setEnabled(pagesVisitedIndex 
                                     < static_cast<int>((pagesVisited.size() - 1)));
                                     
   if (enableSurfaceModelOverlayNumberComboBox) {
      initializeSelectedOverlay(pageName);
   }
}
      
/**
 * initialize the overlay for control be a page.
 */
void 
01802 GuiDisplayControlDialog::initializeSelectedOverlay(const PAGE_NAME pageName)
{
   BrainModelSurfaceOverlay::OVERLAY_SELECTIONS surfaceOverlay =
                          BrainModelSurfaceOverlay::OVERLAY_NONE;
   switch (pageName) {
      case PAGE_NAME_AREAL_ESTIMATION:
         surfaceOverlay = BrainModelSurfaceOverlay::OVERLAY_AREAL_ESTIMATION;
         break;
      case PAGE_NAME_BORDER_MAIN:
      case PAGE_NAME_BORDER_COLOR:
      case PAGE_NAME_BORDER_NAME:
      case PAGE_NAME_CELL_MAIN:
      case PAGE_NAME_CELL_CLASS:
      case PAGE_NAME_CELL_COLOR:
         break;
      case PAGE_NAME_COCOMAC_DISPLAY:
      case PAGE_NAME_COCOMAC_INFORMATION:
         surfaceOverlay = BrainModelSurfaceOverlay::OVERLAY_COCOMAC;
         break;
      case PAGE_NAME_CONTOUR_MAIN:
      case PAGE_NAME_CONTOUR_CLASS:
      case PAGE_NAME_CONTOUR_COLOR:
      case PAGE_NAME_DEFORMATION_FIELD:
      case PAGE_NAME_FOCI_MAIN:
      case PAGE_NAME_FOCI_CLASS:
      case PAGE_NAME_FOCI_COLOR:
      case PAGE_NAME_FOCI_KEYWORD:
      case PAGE_NAME_FOCI_NAME:
      case PAGE_NAME_FOCI_SEARCH:
      case PAGE_NAME_FOCI_TABLE:
      case PAGE_NAME_GEODESIC:
      case PAGE_NAME_IMAGES:
      case PAGE_NAME_LATLON:
         break;
      case PAGE_NAME_METRIC_MISCELLANEOUS:
      case PAGE_NAME_METRIC_SELECTION:
      case PAGE_NAME_METRIC_SETTINGS:
         surfaceOverlay = BrainModelSurfaceOverlay::OVERLAY_METRIC;
         break;
      case PAGE_NAME_MODELS_MAIN:
      case PAGE_NAME_MODELS_SETTINGS:
         break;
      case PAGE_NAME_PAINT_COLUMN:
      case PAGE_NAME_PAINT_MAIN:
      case PAGE_NAME_PAINT_NAMES:
         surfaceOverlay = BrainModelSurfaceOverlay::OVERLAY_PAINT;
         break;
      case PAGE_NAME_PROB_ATLAS_SURFACE_MAIN:
      case PAGE_NAME_PROB_ATLAS_SURFACE_AREA:
      case PAGE_NAME_PROB_ATLAS_SURFACE_CHANNEL:
         surfaceOverlay = BrainModelSurfaceOverlay::OVERLAY_PROBABILISTIC_ATLAS;
         break;
      case PAGE_NAME_PROB_ATLAS_VOLUME_MAIN:
      case PAGE_NAME_PROB_ATLAS_VOLUME_AREA:
      case PAGE_NAME_PROB_ATLAS_VOLUME_CHANNEL:
      case PAGE_NAME_REGION:
         break;
      case PAGE_NAME_RGB_PAINT_MAIN:
      case PAGE_NAME_RGB_PAINT_SELECTION:
         surfaceOverlay = BrainModelSurfaceOverlay::OVERLAY_RGB_PAINT;
         break;
      case PAGE_NAME_SCENE:
         break;
      case PAGE_NAME_SECTION_MAIN:
         surfaceOverlay = BrainModelSurfaceOverlay::OVERLAY_SECTIONS;
         break;
      case PAGE_NAME_SHAPE_SELECTION:
      case PAGE_NAME_SHAPE_SETTINGS:
         surfaceOverlay = BrainModelSurfaceOverlay::OVERLAY_SURFACE_SHAPE;
         break;
      case PAGE_NAME_SURFACE_CLIPPING:
      case PAGE_NAME_SURFACE_AND_VOLUME:
      case PAGE_NAME_SURFACE_MISC:
      case PAGE_NAME_SURFACE_OVERLAY_UNDERLAY_NEW:
         break;
      case PAGE_NAME_TOPOGRAPHY:
         surfaceOverlay = BrainModelSurfaceOverlay::OVERLAY_TOPOGRAPHY;
         break;
      case PAGE_NAME_VECTOR_SELECTION:
      case PAGE_NAME_VECTOR_SETTINGS:
      case PAGE_NAME_VOLUME_SELECTION:
      case PAGE_NAME_VOLUME_SETTINGS:
      case PAGE_NAME_VOLUME_SURFACE_OUTLINE:
      case PAGE_NAME_INVALID:
         break;
   }
   
   updateOverlayNumberComboBox();
   
   if (surfaceOverlay != BrainModelSurfaceOverlay::OVERLAY_NONE) {
      BrainSet* brainSet = theMainWindow->getBrainSet();
      int defaultItem = -1;
      for (int m = 0; m < brainSet->getNumberOfSurfaceOverlays(); m++) {
         const BrainModelSurfaceOverlay* bmsOverlay = brainSet->getSurfaceOverlay(m);
         if (bmsOverlay->getOverlay(getSurfaceModelIndex()) == surfaceOverlay) {
            defaultItem = m;
         }
      }
      
      if (defaultItem >= 0) {
         overlayNumberComboBox->setCurrentIndex(defaultItem);
         slotOverlayNumberComboBox(defaultItem);
      }
   }
}
      
/**
 * update the overlay number combo box.
 */
void 
01912 GuiDisplayControlDialog::updateOverlayNumberComboBox()
{
   for (int i = 0; i < theMainWindow->getBrainSet()->getNumberOfSurfaceOverlays(); i++) {
      BrainModelSurfaceOverlay* bmsOverlay = theMainWindow->getBrainSet()->getSurfaceOverlay(i);
      const QString text = (bmsOverlay->getName()
                            + " ==> "
                            + bmsOverlay->getDataTypeName(getSurfaceModelIndex()));
      overlayNumberComboBox->setItemText(i, text);
   }
}
      
/**
 * Called when a page is selected using the page combo box
 */
void
01927 GuiDisplayControlDialog::pageComboBoxSelection(int itemIn)
{
   if ((itemIn >= 0) &&
       (itemIn < static_cast<int>(pageComboBoxItems.size()))) {
      const int item = pageComboBoxItems[itemIn];
      showDisplayControlPage(static_cast<PAGE_NAME>(item), true);
   }
   else {
      std::cout << "PROGRAM ERROR: Display Control Dialog pageComboBox not properly set up."
                << std::endl;
   }
}

/**
 * create the overlay underlay volume selection page.
 */
void 
01944 GuiDisplayControlDialog::createOverlayUnderlayVolumeSelectionPage()
{
   QWidget* volSelQVBox = new QWidget;
   QVBoxLayout* volSelLayout = new QVBoxLayout(volSelQVBox);
   
   const int PRIMARY_COLUMN   = 0;
   const int SECONDARY_COLUMN = PRIMARY_COLUMN + 1;
   const int UNDERLAY_COLUMN  = SECONDARY_COLUMN + 1;
   const int NAME_COLUMN      = UNDERLAY_COLUMN + 1;
   const int INFO_COLUMN      = NAME_COLUMN + 1;
   const int METADATA_COLUMN  = INFO_COLUMN + 1;
   const int COMBO_COLUMN     = METADATA_COLUMN + 1;
   //const int NUM_COLUMNS      = COMBO_COLUMN + 1;
   
   //
   // Widget and grid layout for volume selections
   //
   QGroupBox* uoGroup = new QGroupBox("Overlay Underlay");
   volSelLayout->addWidget(uoGroup);
   QGridLayout* grid = new QGridLayout(uoGroup);
   int rowNumber = 0;
   
   //
   // column titles
   //
   grid->addWidget(new QLabel("Primary\nOverlay"),  rowNumber, PRIMARY_COLUMN, Qt::AlignHCenter); 
   grid->addWidget(new QLabel("Secondary\nOverlay"),  rowNumber, SECONDARY_COLUMN, Qt::AlignHCenter); 
   grid->addWidget(new QLabel("Underlay"), rowNumber, UNDERLAY_COLUMN, Qt::AlignHCenter); 
   grid->addWidget(new QLabel("Coloring"), rowNumber, NAME_COLUMN, Qt::AlignLeft);
   rowNumber++;
   
   //
   // Button groups to keep radio buttons set correctly
   //
   QButtonGroup* volumePrimaryOverlayButtonGroup = new QButtonGroup(this);
   volumePrimaryOverlayButtonGroup->setExclusive(true);
   QObject::connect(volumePrimaryOverlayButtonGroup, SIGNAL(buttonClicked(int)),
                    this, SLOT(volumePrimaryOverlaySelection(int)));
                    
   QButtonGroup* volumeSecondaryOverlayButtonGroup = new QButtonGroup(this);
   volumeSecondaryOverlayButtonGroup->setExclusive(true);
   QObject::connect(volumeSecondaryOverlayButtonGroup, SIGNAL(buttonClicked(int)),
                    this, SLOT(volumeSecondaryOverlaySelection(int)));
                    
   QButtonGroup* volumeUnderlayButtonGroup = new QButtonGroup(this);
   volumeUnderlayButtonGroup->setExclusive(true);
   QObject::connect(volumeUnderlayButtonGroup, SIGNAL(buttonClicked(int)),
                    this, SLOT(volumeUnderlaySelection(int)));
                    
   
   //
   // None selections
   //
   volumePrimaryOverlayNoneButton = new QRadioButton("");
   grid->addWidget(volumePrimaryOverlayNoneButton, rowNumber, PRIMARY_COLUMN, Qt::AlignHCenter);
   volumePrimaryOverlayButtonGroup->addButton(volumePrimaryOverlayNoneButton, BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_NONE);

   volumeSecondaryOverlayNoneButton = new QRadioButton("");
   grid->addWidget(volumeSecondaryOverlayNoneButton, rowNumber, SECONDARY_COLUMN, Qt::AlignHCenter);
   volumeSecondaryOverlayButtonGroup->addButton(volumeSecondaryOverlayNoneButton, BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_NONE);

   volumeUnderlayNoneButton = new QRadioButton("");
   grid->addWidget(volumeUnderlayNoneButton, rowNumber, UNDERLAY_COLUMN, Qt::AlignHCenter);
   volumeUnderlayButtonGroup->addButton(volumeUnderlayNoneButton, BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_NONE);
   grid->addWidget(new QLabel("No Coloring"), rowNumber, NAME_COLUMN);
   grid->addWidget(new QLabel(" "),    rowNumber, COMBO_COLUMN); 
   rowNumber++;
   
   //
   // This QString is added to each combo box prior to setting its fixed size so 
   // that it will display the number of characters in comboSize.  Changing the
   // number of characters in "comboSize" will change the sizes of the combo boxes
   // for the different data files.
   //
//#ifdef Q_OS_WIN32
//   const QString comboSize("                     ");
//#else
//   const QString comboSize("               ");
//#endif
   const int columnWidth = 500;
   
   //
   // Anatomy Selections
   //
   volumePrimaryOverlayAnatomyRadioButton = new QRadioButton;
   grid->addWidget(volumePrimaryOverlayAnatomyRadioButton, rowNumber, PRIMARY_COLUMN, Qt::AlignHCenter);
   volumePrimaryOverlayButtonGroup->addButton(volumePrimaryOverlayAnatomyRadioButton, 
                                     BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_ANATOMY);

   volumeSecondaryOverlayAnatomyRadioButton = new QRadioButton;
   grid->addWidget(volumeSecondaryOverlayAnatomyRadioButton, rowNumber, SECONDARY_COLUMN, Qt::AlignHCenter);
   volumeSecondaryOverlayButtonGroup->addButton(volumeSecondaryOverlayAnatomyRadioButton, 
                                       BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_ANATOMY);

   volumeUnderlayAnatomyRadioButton = new QRadioButton;
   grid->addWidget(volumeUnderlayAnatomyRadioButton, rowNumber, UNDERLAY_COLUMN, Qt::AlignHCenter);
   volumeUnderlayButtonGroup->addButton(volumeUnderlayAnatomyRadioButton, 
                               BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_ANATOMY);
   
   volumeAnatomyLabel = new QLabel("Anatomy");
   grid->addWidget(volumeAnatomyLabel, rowNumber, NAME_COLUMN); 
   
   volumeAnatomyInfoPushButton = new QPushButton("?");
   QSize infoButtonSize = volumeAnatomyInfoPushButton->sizeHint();
   infoButtonSize.setWidth(40);
   volumeAnatomyInfoPushButton->setAutoDefault(false);
   volumeAnatomyInfoPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeAnatomyInfoPushButton, rowNumber, INFO_COLUMN);
   volumeAnatomyInfoPushButton->setToolTip( "Press for Info About Anatomy Volume");
   QObject::connect(volumeAnatomyInfoPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeAnatomyInfoPushButtonSelection()));
                    
   volumeAnatomyMetaDataPushButton = new QPushButton("M");
   volumeAnatomyMetaDataPushButton->setAutoDefault(false);
   volumeAnatomyMetaDataPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeAnatomyMetaDataPushButton, rowNumber, METADATA_COLUMN);
   volumeAnatomyMetaDataPushButton->setToolTip( "Press to Edit Anatomy Volume Metadata.");
   QObject::connect(volumeAnatomyMetaDataPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeAnatomyMetaDataPushButtonSelection()));
                    
   volumeAnatomyComboBox = new QComboBox;
   //volumeAnatomyComboBox->insertItem(comboSize);
   //volumeAnatomyComboBox->setFixedSize(volumeAnatomyComboBox->sizeHint());
   volumeAnatomyComboBox->setMinimumWidth(columnWidth);
   grid->addWidget(volumeAnatomyComboBox, rowNumber, COMBO_COLUMN);
   volumeAnatomyComboBox->setToolTip( "Choose Anatomy File");
   QObject::connect(volumeAnatomyComboBox, SIGNAL(activated(int)),
                    this, SLOT(volumeAnatomySelection(int)));
   rowNumber++;
   
   //
   // Functional Selections
   //
   volumePrimaryOverlayFunctionalRadioButton = new QRadioButton;
   grid->addWidget(volumePrimaryOverlayFunctionalRadioButton, rowNumber, PRIMARY_COLUMN, Qt::AlignHCenter);
   volumePrimaryOverlayButtonGroup->addButton(volumePrimaryOverlayFunctionalRadioButton, 
                                     BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_FUNCTIONAL);

   volumeSecondaryOverlayFunctionalRadioButton = new QRadioButton;
   grid->addWidget(volumeSecondaryOverlayFunctionalRadioButton, rowNumber, SECONDARY_COLUMN, Qt::AlignHCenter);
   volumeSecondaryOverlayButtonGroup->addButton(volumeSecondaryOverlayFunctionalRadioButton, 
                                       BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_FUNCTIONAL);

   volumeUnderlayFunctionalRadioButton = new QRadioButton;
   grid->addWidget(volumeUnderlayFunctionalRadioButton, rowNumber, UNDERLAY_COLUMN, Qt::AlignHCenter);
   volumeUnderlayButtonGroup->addButton(volumeUnderlayFunctionalRadioButton, 
                               BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_FUNCTIONAL);
   
   volumeFunctionalViewLabel = new QLabel("Functional-View");
   grid->addWidget(volumeFunctionalViewLabel, rowNumber, NAME_COLUMN); 
   
   volumeFunctionalViewInfoPushButton = new QPushButton("?");
   volumeFunctionalViewInfoPushButton->setAutoDefault(false);
   volumeFunctionalViewInfoPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeFunctionalViewInfoPushButton, rowNumber, INFO_COLUMN);
   volumeFunctionalViewInfoPushButton->setToolTip( "Press for Info About Functional View Volume");
   QObject::connect(volumeFunctionalViewInfoPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeFunctionalViewInfoPushButtonSelection()));
                    
   volumeFunctionalViewMetaDataPushButton = new QPushButton("M");
   volumeFunctionalViewMetaDataPushButton->setAutoDefault(false);
   volumeFunctionalViewMetaDataPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeFunctionalViewMetaDataPushButton, rowNumber, METADATA_COLUMN);
   volumeFunctionalViewMetaDataPushButton->setToolTip( "Press to Edit Functional-View Volume Metadata.");
   QObject::connect(volumeFunctionalViewMetaDataPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeFunctionalViewMetaDataPushButtonSelection()));
                    
   volumeFunctionalViewComboBox = new QComboBox;
   //volumeFunctionalViewComboBox->insertItem(comboSize);
   //volumeFunctionalViewComboBox->setFixedSize(volumeFunctionalViewComboBox->sizeHint());
   volumeFunctionalViewComboBox->setMinimumWidth(columnWidth);
   grid->addWidget(volumeFunctionalViewComboBox, rowNumber, COMBO_COLUMN);
   volumeFunctionalViewComboBox->setToolTip("Choose Functional Viewing Volume");
   QObject::connect(volumeFunctionalViewComboBox, SIGNAL(activated(int)),
                    this, SLOT(volumeFunctionalViewSelection(int)));
   rowNumber++;
   
   volumeFunctionalThresholdLabel = new QLabel("Functional-Thresh");
   grid->addWidget(volumeFunctionalThresholdLabel, rowNumber, NAME_COLUMN);
   
   volumeFunctionalThreshInfoPushButton = new QPushButton("?");
   volumeFunctionalThreshInfoPushButton->setAutoDefault(false);
   volumeFunctionalThreshInfoPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeFunctionalThreshInfoPushButton, rowNumber, INFO_COLUMN);
   volumeFunctionalThreshInfoPushButton->setToolTip( "Press for Info About Functional Thresh Volume");
   QObject::connect(volumeFunctionalThreshInfoPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeFunctionalThreshInfoPushButtonSelection()));
                    
   volumeFunctionalThreshMetaDataPushButton = new QPushButton("M");
   volumeFunctionalThreshMetaDataPushButton->setAutoDefault(false);
   volumeFunctionalThreshMetaDataPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeFunctionalThreshMetaDataPushButton, rowNumber, METADATA_COLUMN);
   volumeFunctionalThreshMetaDataPushButton->setToolTip( "Press to Edit Functional-Thresh Volume Metadata.");
   QObject::connect(volumeFunctionalThreshMetaDataPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeFunctionalThreshMetaDataPushButtonSelection()));
                    
   volumeFunctionalThresholdComboBox = new QComboBox;
   //volumeFunctionalThresholdComboBox->insertItem(comboSize);
   //volumeFunctionalThresholdComboBox->setFixedSize(volumeFunctionalThresholdComboBox->sizeHint());
   volumeFunctionalThresholdComboBox->setMinimumWidth(columnWidth);
   grid->addWidget(volumeFunctionalThresholdComboBox, rowNumber, COMBO_COLUMN);
   volumeFunctionalThresholdComboBox->setToolTip( "Choose Functional Thresholding Volume");
   QObject::connect(volumeFunctionalThresholdComboBox, SIGNAL(activated(int)),
                    this, SLOT(volumeFunctionalThresholdSelection(int)));
   rowNumber++;
   
   //
   // Paint Selections
   //
   volumePrimaryOverlayPaintRadioButton = new QRadioButton;
   grid->addWidget(volumePrimaryOverlayPaintRadioButton, rowNumber, PRIMARY_COLUMN, Qt::AlignHCenter);
   volumePrimaryOverlayButtonGroup->addButton(volumePrimaryOverlayPaintRadioButton, 
                                     BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PAINT);

   volumeSecondaryOverlayPaintRadioButton = new QRadioButton;
   grid->addWidget(volumeSecondaryOverlayPaintRadioButton, rowNumber, SECONDARY_COLUMN, Qt::AlignHCenter);
   volumeSecondaryOverlayButtonGroup->addButton(volumeSecondaryOverlayPaintRadioButton, 
                                       BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PAINT);

   volumeUnderlayPaintRadioButton = new QRadioButton;
   grid->addWidget(volumeUnderlayPaintRadioButton, rowNumber, UNDERLAY_COLUMN, Qt::AlignHCenter);
   volumeUnderlayButtonGroup->addButton(volumeUnderlayPaintRadioButton, 
                               BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PAINT);
   
   volumePaintLabel = new QLabel("Paint");
   grid->addWidget(volumePaintLabel, rowNumber, NAME_COLUMN); 
   
   volumePaintInfoPushButton = new QPushButton("?");
   volumePaintInfoPushButton->setAutoDefault(false);
   volumePaintInfoPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumePaintInfoPushButton, rowNumber, INFO_COLUMN);
   volumePaintInfoPushButton->setToolTip( "Press for Info About Paint Volume");
   QObject::connect(volumePaintInfoPushButton, SIGNAL(clicked()),
                    this, SLOT(volumePaintInfoPushButtonSelection()));
                    
   volumePaintMetaDataPushButton = new QPushButton("M");
   volumePaintMetaDataPushButton->setAutoDefault(false);
   volumePaintMetaDataPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumePaintMetaDataPushButton, rowNumber, METADATA_COLUMN);
   volumePaintMetaDataPushButton->setToolTip( "Press to Edit Paint Volume Metadata.");
   QObject::connect(volumePaintMetaDataPushButton, SIGNAL(clicked()),
                    this, SLOT(volumePaintMetaDataPushButtonSelection()));
                    
   volumePaintComboBox = new QComboBox;
   //volumePaintComboBox->insertItem(comboSize);
   //volumePaintComboBox->setFixedSize(volumePaintComboBox->sizeHint());
   volumePaintComboBox->setMinimumWidth(columnWidth);
   grid->addWidget(volumePaintComboBox, rowNumber, COMBO_COLUMN);
   volumePaintComboBox->setToolTip( "Choose Paint Volume");
   QObject::connect(volumePaintComboBox, SIGNAL(activated(int)),
                    this, SLOT(volumePaintSelection(int)));
   rowNumber++;
   
   //
   // Prob atlas Selections
   //
   volumePrimaryOverlayProbAtlasRadioButton = new QRadioButton;
   grid->addWidget(volumePrimaryOverlayProbAtlasRadioButton, rowNumber, PRIMARY_COLUMN, Qt::AlignHCenter);
   volumePrimaryOverlayButtonGroup->addButton(volumePrimaryOverlayProbAtlasRadioButton, 
                                     BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PROB_ATLAS);

   volumeSecondaryOverlayProbAtlasRadioButton = new QRadioButton;
   grid->addWidget(volumeSecondaryOverlayProbAtlasRadioButton, rowNumber, SECONDARY_COLUMN, Qt::AlignHCenter);
   volumeSecondaryOverlayButtonGroup->addButton(volumeSecondaryOverlayProbAtlasRadioButton, 
                                       BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PROB_ATLAS);

   volumeUnderlayProbAtlasRadioButton = new QRadioButton;
   grid->addWidget(volumeUnderlayProbAtlasRadioButton, rowNumber, UNDERLAY_COLUMN, Qt::AlignHCenter);
   volumeUnderlayButtonGroup->addButton(volumeUnderlayProbAtlasRadioButton, 
                               BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PROB_ATLAS);
   
   volumeProbAtlasLabel = new QLabel("Prob Atlas");
   grid->addWidget(volumeProbAtlasLabel, rowNumber, NAME_COLUMN); 
   
   volumeProbAtlasInfoPushButton = new QPushButton("?");
   volumeProbAtlasInfoPushButton->setAutoDefault(false);
   volumeProbAtlasInfoPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeProbAtlasInfoPushButton, rowNumber, INFO_COLUMN);
   volumeProbAtlasInfoPushButton->setToolTip( "Press for Info About Prob Atlas Volume");
   QObject::connect(volumeProbAtlasInfoPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeProbAtlasInfoPushButtonSelection()));
       
   volumeProbAtlasInfoPushButton->hide(); // LOOK !!  BUTTON IS HIDDEN
   
   volumeProbAtlasMetaDataPushButton = new QPushButton("M");
   volumeProbAtlasMetaDataPushButton->setAutoDefault(false);
   volumeProbAtlasMetaDataPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeProbAtlasMetaDataPushButton, rowNumber, METADATA_COLUMN);
   volumeProbAtlasMetaDataPushButton->setToolTip( "Press to Edit Prob Atlas Volume Metadata.");
   QObject::connect(volumeProbAtlasMetaDataPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeProbAtlasVolumeStudyMetaDataPushButton()));
      
   volumeProbAtlasMetaDataPushButton->hide();  // LOOK !!  BUTTON IS HIDDEN
                                               // Uses button on Vol-Prob Atlas Main Page
   rowNumber++;
   
   //
   // RGB Selections
   //
   volumePrimaryOverlayRgbRadioButton = new QRadioButton;
   grid->addWidget(volumePrimaryOverlayRgbRadioButton, rowNumber, PRIMARY_COLUMN, Qt::AlignHCenter);
   volumePrimaryOverlayButtonGroup->addButton(volumePrimaryOverlayRgbRadioButton, 
                                     BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_RGB);

   volumeSecondaryOverlayRgbRadioButton = new QRadioButton;
   grid->addWidget(volumeSecondaryOverlayRgbRadioButton, rowNumber, SECONDARY_COLUMN, Qt::AlignHCenter);
   volumeSecondaryOverlayButtonGroup->addButton(volumeSecondaryOverlayRgbRadioButton, 
                                       BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_RGB);

   volumeUnderlayRgbRadioButton = new QRadioButton;
   grid->addWidget(volumeUnderlayRgbRadioButton, rowNumber, UNDERLAY_COLUMN, Qt::AlignHCenter);
   volumeUnderlayButtonGroup->addButton(volumeUnderlayRgbRadioButton, 
                               BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_RGB);
   
   volumeRgbLabel = new QLabel("RGB");
   grid->addWidget(volumeRgbLabel, rowNumber, NAME_COLUMN); 
   
   volumeRgbInfoPushButton = new QPushButton("?");
   volumeRgbInfoPushButton->setAutoDefault(false);
   volumeRgbInfoPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeRgbInfoPushButton, rowNumber, INFO_COLUMN);
   volumeRgbInfoPushButton->setToolTip( "Press for Info About RGB Volume");
   QObject::connect(volumeRgbInfoPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeRgbInfoPushButtonSelection()));
                    
   volumeRgbMetaDataPushButton = new QPushButton("M");
   volumeRgbMetaDataPushButton->setAutoDefault(false);
   volumeRgbMetaDataPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeRgbMetaDataPushButton, rowNumber, METADATA_COLUMN);
   volumeRgbMetaDataPushButton->setToolTip( "Press to Edit RGB Volume Metadata.");
   QObject::connect(volumeRgbMetaDataPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeRgbMetaDataPushButtonSelection()));
                    
   volumeRgbComboBox = new QComboBox;
   //volumeRgbComboBox->insertItem(comboSize);
   //volumeRgbComboBox->setFixedSize(volumeRgbComboBox->sizeHint());
   volumeRgbComboBox->setMinimumWidth(columnWidth);
   grid->addWidget(volumeRgbComboBox, rowNumber, COMBO_COLUMN);
   volumeRgbComboBox->setToolTip( "Choose RGB Volume");
   QObject::connect(volumeRgbComboBox, SIGNAL(activated(int)),
                    this, SLOT(volumeRgbSelection(int)));
   rowNumber++;
   
   //
   // Segmentation Selections
   //
   volumePrimaryOverlaySegmentationRadioButton = new QRadioButton;
   grid->addWidget(volumePrimaryOverlaySegmentationRadioButton, rowNumber, PRIMARY_COLUMN, Qt::AlignHCenter);
   volumePrimaryOverlayButtonGroup->addButton(volumePrimaryOverlaySegmentationRadioButton, 
                                     BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_SEGMENTATION);

   volumeSecondaryOverlaySegmentationRadioButton = new QRadioButton;
   grid->addWidget(volumeSecondaryOverlaySegmentationRadioButton, rowNumber, SECONDARY_COLUMN, Qt::AlignHCenter);
   volumeSecondaryOverlayButtonGroup->addButton(volumeSecondaryOverlaySegmentationRadioButton, 
                                       BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_SEGMENTATION);

   volumeUnderlaySegmentationRadioButton = new QRadioButton;
   grid->addWidget(volumeUnderlaySegmentationRadioButton, rowNumber, UNDERLAY_COLUMN, Qt::AlignHCenter);
   volumeUnderlayButtonGroup->addButton(volumeUnderlaySegmentationRadioButton, 
                               BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_SEGMENTATION);
   
   volumeSegmentationLabel = new QLabel("Segmentation");
   grid->addWidget(volumeSegmentationLabel, rowNumber, NAME_COLUMN); 
   
   volumeSegmentationInfoPushButton = new QPushButton("?");
   volumeSegmentationInfoPushButton->setAutoDefault(false);
   volumeSegmentationInfoPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeSegmentationInfoPushButton, rowNumber, INFO_COLUMN);
   volumeSegmentationInfoPushButton->setToolTip( "Press for Info About Segmentation Volume");
   QObject::connect(volumeSegmentationInfoPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeSegmentationInfoPushButtonSelection()));
                    
   volumeSegmentationMetaDataPushButton = new QPushButton("M");
   volumeSegmentationMetaDataPushButton->setAutoDefault(false);
   volumeSegmentationMetaDataPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeSegmentationMetaDataPushButton, rowNumber, METADATA_COLUMN);
   volumeSegmentationMetaDataPushButton->setToolTip( "Press to Edit Segmentation Volume Metadata.");
   QObject::connect(volumeSegmentationMetaDataPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeSegmentationMetaDataPushButtonSelection()));
                    
   volumeSegmentationComboBox = new QComboBox;
   volumeSegmentationComboBox->setMinimumWidth(columnWidth);
   grid->addWidget(volumeSegmentationComboBox, rowNumber, COMBO_COLUMN);
   volumeSegmentationComboBox->setToolTip( "Choose Segmentation Volume");
   QObject::connect(volumeSegmentationComboBox, SIGNAL(activated(int)),
                    this, SLOT(volumeSegmentationSelection(int)));
   rowNumber++;
   
   //
   // Vector Selections
   //
   volumePrimaryOverlayVectorRadioButton = new QRadioButton;
   grid->addWidget(volumePrimaryOverlayVectorRadioButton, rowNumber, PRIMARY_COLUMN, Qt::AlignHCenter);
   volumePrimaryOverlayButtonGroup->addButton(volumePrimaryOverlayVectorRadioButton, 
                                     BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_VECTOR);

   volumeSecondaryOverlayVectorRadioButton = new QRadioButton;
   grid->addWidget(volumeSecondaryOverlayVectorRadioButton, rowNumber, SECONDARY_COLUMN, Qt::AlignHCenter);
   volumeSecondaryOverlayButtonGroup->addButton(volumeSecondaryOverlayVectorRadioButton, 
                                       BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_VECTOR);

   volumeUnderlayVectorRadioButton = new QRadioButton;
   grid->addWidget(volumeUnderlayVectorRadioButton, rowNumber, UNDERLAY_COLUMN, Qt::AlignHCenter);
   volumeUnderlayButtonGroup->addButton(volumeUnderlayVectorRadioButton, 
                               BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_VECTOR);
   
   volumeVectorLabel = new QLabel("Vector");
   grid->addWidget(volumeVectorLabel, rowNumber, NAME_COLUMN); 
   
   volumeVectorInfoPushButton = new QPushButton("?");
   volumeVectorInfoPushButton->setAutoDefault(false);
   volumeVectorInfoPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeVectorInfoPushButton, rowNumber, INFO_COLUMN);
   volumeVectorInfoPushButton->setToolTip( "Press for Info About Vector Volume");
   QObject::connect(volumeVectorInfoPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeVectorInfoPushButtonSelection()));
                    
   volumeVectorMetaDataPushButton = new QPushButton("M");
   volumeVectorMetaDataPushButton->setAutoDefault(false);
   volumeVectorMetaDataPushButton->setFixedSize(infoButtonSize);
   grid->addWidget(volumeVectorMetaDataPushButton, rowNumber, METADATA_COLUMN);
   volumeVectorMetaDataPushButton->setToolTip( "Press to Edit Vector Volume Metadata.");
   QObject::connect(volumeVectorMetaDataPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeVectorMetaDataPushButtonSelection()));
                    
   volumeVectorComboBox = new QComboBox;
   volumeVectorComboBox->setMinimumWidth(columnWidth);
   grid->addWidget(volumeVectorComboBox, rowNumber, COMBO_COLUMN);
   volumeVectorComboBox->setToolTip( "Choose Vector Volume");
   QObject::connect(volumeVectorComboBox, SIGNAL(activated(int)),
                    this, SLOT(volumeVectorSelection(int)));
   rowNumber++;

   uoGroup->setFixedSize(uoGroup->sizeHint());

   //
   // Pushes selections to top of page
   //
   volSelLayout->addStretch();
   //volSelQVBox->setStretchFactor(new QLabel(" ", volSelQVBox), 100);
   
   pageVolumeSelection = volSelQVBox;
   pageWidgetStack->addWidget(pageVolumeSelection);
}

/**
 * create the overlay underlay volume setttings page.
 */
void 
02393 GuiDisplayControlDialog::createOverlayUnderlayVolumeSettingsPage()
{   
   //
   // Anatomy draw type
   //
   QHBoxLayout* anatomyDrawBoxLayout = new QHBoxLayout;
   anatomyDrawBoxLayout->addWidget(new QLabel("Draw Type  "));
   volumeAnatomyDrawTypeComboBox = new QComboBox;
   anatomyDrawBoxLayout->addWidget(volumeAnatomyDrawTypeComboBox);
   volumeAnatomyDrawTypeComboBox->setToolTip(
                 "0 to 255: \n"
                 "   Assumes voxels are within 0 to 255.\n"
                 "Min to Max\n"
                 "   Maps smallest voxel to black and\n"
                 "   the largest voxel to white.\n"
                 "2% to 98%\n"
                 "   Computes histogram of voxels.\n"
                 "   Voxels at 2% in histogram are mapped\n"
                 "   to black.  Voxels at 98% in histogram\n"
                 "   are mapped to white.\n");
   volumeAnatomyDrawTypeComboBox->insertItem(DisplaySettingsVolume::ANATOMY_COLORING_TYPE_0_255,
                                             "0 to 255");
   volumeAnatomyDrawTypeComboBox->insertItem(DisplaySettingsVolume::ANATOMY_COLORING_TYPE_MIN_MAX,
                                             "Min to Max");
   volumeAnatomyDrawTypeComboBox->insertItem(DisplaySettingsVolume::ANATOMY_COLORING_TYPE_2_98,
                                             "2% to 98%");
   QObject::connect(volumeAnatomyDrawTypeComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVolumeSettings()));
   anatomyDrawBoxLayout->addStretch();
   
   //
   // Brighness/Contrast
   //
   QLabel* brightnessLabel = new QLabel("Brightness ");
   volumeAnatomyBrightnessLabel = new QLabel("         ");
   volumeAnatomyBrightnessLabel->setFixedSize(volumeAnatomyBrightnessLabel->sizeHint());
   volumeAnatomyBrightnessSlider = new QSlider(Qt::Horizontal);
   volumeAnatomyBrightnessSlider->setMinimum(-150);
   volumeAnatomyBrightnessSlider->setMaximum(150);
   volumeAnatomyBrightnessSlider->setPageStep(1);
   volumeAnatomyBrightnessSlider->setValue(1);
   volumeAnatomyBrightnessSlider->setFixedWidth(251);
   QObject::connect(volumeAnatomyBrightnessSlider, SIGNAL(sliderReleased()),
                    this, SLOT(readVolumeSettings()));
   QObject::connect(volumeAnatomyBrightnessSlider, SIGNAL(sliderMoved(int)),
                    volumeAnatomyBrightnessLabel, SLOT(setNum(int)));

   QLabel* contrastLabel = new QLabel("Contrast ");
   volumeAnatomyContrastLabel = new QLabel("          ");
   volumeAnatomyContrastLabel->setFixedSize(volumeAnatomyContrastLabel->sizeHint());
   volumeAnatomyContrastSlider = new QSlider(Qt::Horizontal);
   volumeAnatomyContrastSlider->setMinimum(-99);
   volumeAnatomyContrastSlider->setMaximum(99);
   volumeAnatomyContrastSlider->setPageStep(1);
   volumeAnatomyContrastSlider->setValue(1);
   volumeAnatomyContrastSlider->setFixedWidth(251);
   QObject::connect(volumeAnatomyContrastSlider, SIGNAL(sliderReleased()),
                    this, SLOT(readVolumeSettings()));
   QObject::connect(volumeAnatomyContrastSlider, SIGNAL(sliderMoved(int)),
                    volumeAnatomyContrastLabel, SLOT(setNum(int)));
   QGridLayout* brightContrastGridLayout = new QGridLayout;
   brightContrastGridLayout->addWidget(brightnessLabel, 0, 0);
   brightContrastGridLayout->addWidget(volumeAnatomyBrightnessLabel, 0, 1);
   brightContrastGridLayout->addWidget(volumeAnatomyBrightnessSlider, 0, 2);
   brightContrastGridLayout->addWidget(contrastLabel, 1, 0);
   brightContrastGridLayout->addWidget(volumeAnatomyContrastLabel, 1, 1);
   brightContrastGridLayout->addWidget(volumeAnatomyContrastSlider, 1, 2);
   
   QPushButton* makeDefaultPushButton = new QPushButton("Make Default");
   makeDefaultPushButton->setAutoDefault(false);
   makeDefaultPushButton->setFixedSize(makeDefaultPushButton->sizeHint());
   makeDefaultPushButton->setToolTip( "Set default brightness/contrast\n"
                                        "to current entries.");
   QObject::connect(makeDefaultPushButton, SIGNAL(clicked()),
                    this, SLOT(slotDefaultVolumeContrastBrightness()));
   QPushButton* histoPushButton = new QPushButton("Histogram...");
   histoPushButton->setAutoDefault(false);
   histoPushButton->setFixedSize(histoPushButton->sizeHint());
   QObject::connect(histoPushButton, SIGNAL(clicked()),
                    this, SLOT(slotAnatomyVolumeHistogram()));
   QHBoxLayout* anatButtonLayout = new QHBoxLayout;
   anatButtonLayout->addWidget(makeDefaultPushButton);
   anatButtonLayout->addWidget(histoPushButton);
   
   //
   // Anatomy group box
   //
   QGroupBox* anatomyGroupBox = new QGroupBox("Anatomy Volume");
   QVBoxLayout* anatomyGroupLayout = new QVBoxLayout(anatomyGroupBox);
   anatomyGroupLayout->addLayout(anatomyDrawBoxLayout);
   anatomyGroupLayout->addLayout(brightContrastGridLayout);
   anatomyGroupLayout->addLayout(anatButtonLayout);
   anatomyGroupBox->setFixedSize(anatomyGroupBox->sizeHint());
   
   //
   // Display color bar check box
   //
   volumeFunctionalDisplayColorBarCheckBox = new QCheckBox("Display Color Bar");
   QObject::connect(volumeFunctionalDisplayColorBarCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readVolumeSettings()));
                    
   //
   // Functional volume group box
   //
   QGroupBox* functionalGroupBox = new QGroupBox("Functional Volume");
   QVBoxLayout* functionalGroupLayout = new QVBoxLayout(functionalGroupBox);
   functionalGroupLayout->addWidget(volumeFunctionalDisplayColorBarCheckBox);
   functionalGroupBox->setFixedSize(functionalGroupBox->sizeHint());
   
   //
   // Segmenation Volume draw type
   //
   volumeSegmentationDrawTypeComboBox = new QComboBox;
   volumeSegmentationDrawTypeComboBox->insertItem(DisplaySettingsVolume::SEGMENTATION_DRAW_TYPE_BLEND,
                                                  "Translucent");
   volumeSegmentationDrawTypeComboBox->insertItem(DisplaySettingsVolume::SEGMENTATION_DRAW_TYPE_SOLID,
                                                  "Opaque");
   volumeSegmentationDrawTypeComboBox->insertItem(DisplaySettingsVolume::SEGMENTATION_DRAW_TYPE_BOX,
                                                  "Outline");
   volumeSegmentationDrawTypeComboBox->insertItem(DisplaySettingsVolume::SEGMENTATION_DRAW_TYPE_CROSS,
                                                  "Cross");
   QObject::connect(volumeSegmentationDrawTypeComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVolumeSettings()));
   volumeSegmentationDrawTypeComboBox->setToolTip( 
                 "Selects drawing method \n"
                 "for segmentation voxels.");
  
   //
   // Segmentation Volume Translucency
   //
   QHBoxLayout* segTransHBoxLayout = new QHBoxLayout;
   segTransHBoxLayout->addWidget(new QLabel("Translucency"));
   volumeSegmentationTranslucencyDoubleSpinBox = new QDoubleSpinBox;
   volumeSegmentationTranslucencyDoubleSpinBox->setMinimum(0.0);
   volumeSegmentationTranslucencyDoubleSpinBox->setMaximum(1.0);
   volumeSegmentationTranslucencyDoubleSpinBox->setSingleStep(0.1);
   volumeSegmentationTranslucencyDoubleSpinBox->setDecimals(2);
   segTransHBoxLayout->addWidget(volumeSegmentationTranslucencyDoubleSpinBox);
   QObject::connect(volumeSegmentationTranslucencyDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVolumeSettings()));
                    

   //
   // Segmentation group box
   //
   QGroupBox* segmentGroupBox = new QGroupBox("Segmentation Volume");
   QVBoxLayout* segmentGroupLayout = new QVBoxLayout(segmentGroupBox);
   segmentGroupLayout->addWidget(volumeSegmentationDrawTypeComboBox);
   segmentGroupLayout->addLayout(segTransHBoxLayout);
   segmentGroupBox->setFixedSize(segmentGroupBox->sizeHint());
   
   //
   // Overlay opacity
   //
   volumeOverlayOpacityDoubleSpinBox = new QDoubleSpinBox;
   volumeOverlayOpacityDoubleSpinBox->setMinimum(0.0);
   volumeOverlayOpacityDoubleSpinBox->setMaximum(1.0);
   volumeOverlayOpacityDoubleSpinBox->setSingleStep(0.1);
   volumeOverlayOpacityDoubleSpinBox->setDecimals(2);
   volumeOverlayOpacityDoubleSpinBox->setToolTip(
                 "Values less than 1.0 will blend\n"
                 "the overlay and the underlay.");
   QObject::connect(volumeOverlayOpacityDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVolumeSettings()));
   QGroupBox* overlayOpacityGroupBox = new QGroupBox("Overlay Opacity");
   QVBoxLayout* overlayOpacityGroupLayout = new QVBoxLayout(overlayOpacityGroupBox);
   overlayOpacityGroupLayout->addWidget(volumeOverlayOpacityDoubleSpinBox);
   overlayOpacityGroupBox->setFixedSize(overlayOpacityGroupBox->sizeHint());
   
   //
   // start button
   //
   QPushButton* animateStartPushButton = new QPushButton("Start");
   animateStartPushButton->setFixedSize(animateStartPushButton->sizeHint());
   animateStartPushButton->setAutoDefault(false);
   QObject::connect(animateStartPushButton, SIGNAL(clicked()),
                    this, SLOT(slotVolumeAnimateStartPushButton()));

   //
   // stop button
   //
   QPushButton* animateStopPushButton = new QPushButton("Stop");
   animateStopPushButton->setFixedSize(animateStopPushButton->sizeHint());
   animateStopPushButton->setAutoDefault(false);
   QObject::connect(animateStopPushButton, SIGNAL(clicked()),
                    this, SLOT(slotVolumeAnimateStopPushButton()));
                   
   //
   // Horizontal box for direction
   //
   QLabel* volumeAnimateDirectionLabel = new QLabel("Direction ");
   volumeAnimateDirectionComboBox = new QComboBox;
   volumeAnimateDirectionComboBox->insertItem(VOLUME_ANIMATE_DIRECTION_INCREMENT,
                                              "Positive");
   volumeAnimateDirectionComboBox->insertItem(VOLUME_ANIMATE_DIRECTION_DECREMENT,
                                              "Negative");
   QHBoxLayout* animateDirectionLayout = new QHBoxLayout;
   animateDirectionLayout->addWidget(volumeAnimateDirectionLabel);
   animateDirectionLayout->addWidget(volumeAnimateDirectionComboBox);
   animateDirectionLayout->addStretch();

   //
   // Animation section
   //
   QGroupBox* animateGroupBox = new QGroupBox("Animation");
   QVBoxLayout* animateGroupLayout = new QVBoxLayout(animateGroupBox);
   animateGroupLayout->addWidget(animateStartPushButton);
   animateGroupLayout->addWidget(animateStopPushButton);
   animateGroupLayout->addLayout(animateDirectionLayout);
   animateGroupBox->setFixedSize(animateGroupBox->sizeHint());
   
   //
   // paint color key button
   //
   QPushButton* paintColorKeyPushButton = new QPushButton("Paint Color Key...");
   paintColorKeyPushButton->setFixedSize(paintColorKeyPushButton->sizeHint());
   paintColorKeyPushButton->setAutoDefault(false);
   QObject::connect(paintColorKeyPushButton, SIGNAL(clicked()),
                    theMainWindow, SLOT(displayVolumePaintColorKey()));

   //
   // prob atlas color key button
   //
   QPushButton* probAtlasColorKeyPushButton = new QPushButton("Prob Atlas Color Key...");
   probAtlasColorKeyPushButton->setFixedSize(probAtlasColorKeyPushButton->sizeHint());
   probAtlasColorKeyPushButton->setAutoDefault(false);
   QObject::connect(probAtlasColorKeyPushButton, SIGNAL(clicked()),
                    theMainWindow, SLOT(displayVolumeProbabilisticAtlasColorKey()));

   //
   // Color Key buttons
   //
   QGroupBox* colorKeyGroupBox = new QGroupBox("Color Keys");
   QVBoxLayout* colorKeyLayout = new QVBoxLayout(colorKeyGroupBox);
   colorKeyLayout->addWidget(paintColorKeyPushButton);
   colorKeyLayout->addWidget(probAtlasColorKeyPushButton);
   colorKeyGroupBox->setFixedSize(colorKeyGroupBox->sizeHint());
   
   //
   // Sparsity spin box
   //
   QLabel* sparsityLabel = new QLabel("Sparsity ");
   vectorVolumeSparsitySpinBox = new QSpinBox;
   vectorVolumeSparsitySpinBox->setMinimum(1);
   vectorVolumeSparsitySpinBox->setMaximum(100000);
   vectorVolumeSparsitySpinBox->setSingleStep(1);
   vectorVolumeSparsitySpinBox->setToolTip(
                 "Draw Vectors for\n"
                 "Every N Voxels");
   QObject::connect(vectorVolumeSparsitySpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readVolumeSettings()));
                    
   //
   // vector volume group box
   //
   vectorVolumeGroupBox = new QGroupBox("Vector Volume");
   QHBoxLayout* vectorVolumeGroupLayout = new QHBoxLayout(vectorVolumeGroupBox);
   vectorVolumeGroupLayout->addWidget(sparsityLabel);
   vectorVolumeGroupLayout->addWidget(vectorVolumeSparsitySpinBox);
   vectorVolumeGroupBox->setFixedSize(vectorVolumeGroupBox->sizeHint());
   
   //
   // montage rows spin box
   //
   QLabel* montageRowsLabel = new QLabel("Rows");
   volumeMontageRowsSpinBox = new QSpinBox;
   volumeMontageRowsSpinBox->setMinimum(1);
   volumeMontageRowsSpinBox->setMaximum(100);
   volumeMontageRowsSpinBox->setSingleStep(1);
   volumeMontageRowsSpinBox->setToolTip(
                 "Number of rows in\n"
                 "the montage.");
   QObject::connect(volumeMontageRowsSpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readVolumeSettings()));
                    
   //
   // columns spin box
   //
   QLabel* montageColumnsLabel = new QLabel("Columns");
   volumeMontageColumnsSpinBox = new QSpinBox;
   volumeMontageColumnsSpinBox->setMinimum(1);
   volumeMontageColumnsSpinBox->setMaximum(100);
   volumeMontageColumnsSpinBox->setSingleStep(1);
   volumeMontageColumnsSpinBox->setToolTip(
                 "Number of columns\n"
                 "in the montage.");
   QObject::connect(volumeMontageColumnsSpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readVolumeSettings()));
                    
   //
   // slices spin box
   //
   QLabel* montageIncrementLabel = new QLabel("Increment");
   volumeMontageSliceIncrementSpinBox = new QSpinBox;
   volumeMontageSliceIncrementSpinBox->setMinimum(1);
   volumeMontageSliceIncrementSpinBox->setMaximum(100);
   volumeMontageSliceIncrementSpinBox->setSingleStep(1);
   volumeMontageSliceIncrementSpinBox->setToolTip(
                 "Slices to skip between\n"
                 "each montage image.");
   QObject::connect(volumeMontageSliceIncrementSpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readVolumeSettings()));
   
   //
   // Montage group box
   //
   volumeMontageGroupBox = new QGroupBox("Montage");
   volumeMontageGroupBox->setCheckable(true);
   QObject::connect(volumeMontageGroupBox, SIGNAL(toggled(bool)),
                    this, SLOT(readVolumeSettings()));
   QGridLayout* volumeMontageGroupLayout = new QGridLayout(volumeMontageGroupBox);
   volumeMontageGroupLayout->addWidget(montageRowsLabel, 0, 0);
   volumeMontageGroupLayout->addWidget(volumeMontageRowsSpinBox, 0, 1);
   volumeMontageGroupLayout->addWidget(montageColumnsLabel, 1, 0);
   volumeMontageGroupLayout->addWidget(volumeMontageColumnsSpinBox, 1, 1);
   volumeMontageGroupLayout->addWidget(montageIncrementLabel, 2, 0);
   volumeMontageGroupLayout->addWidget(volumeMontageSliceIncrementSpinBox, 2, 1);
   volumeMontageGroupBox->setFixedSize(volumeMontageGroupBox->sizeHint());
   
   //
   // Show crosshairs check box
   //
   volumeShowCrosshairsCheckBox = new QCheckBox("Show Crosshairs");
   QObject::connect(volumeShowCrosshairsCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readVolumeSettings()));
   
   //
   // Show crosshair coordinates check box
   //
   volumeShowCrosshairCoordinatesCheckBox = new QCheckBox("Show Crosshair Coordinates");
   QObject::connect(volumeShowCrosshairCoordinatesCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readVolumeSettings()));
   
   //
   // crosshairs group box
   //
   QGroupBox* crosshairsGroupBox = new QGroupBox("Crosshairs");
   QVBoxLayout* crosshairsGroupLayout = new QVBoxLayout(crosshairsGroupBox);
   crosshairsGroupLayout->addWidget(volumeShowCrosshairsCheckBox);
   crosshairsGroupLayout->addWidget(volumeShowCrosshairCoordinatesCheckBox);
   crosshairsGroupBox->setFixedSize(crosshairsGroupBox->sizeHint());
   
   //
   // Oblique slice viewing
   //
   QLabel* obliqueViewLabel = new QLabel("View Matrix");
   obliqueVolumeSliceMatrixControl = new GuiTransformationMatrixSelectionControl(
                                            0,
                                            theMainWindow->getBrainSet()->getTransformationMatrixFile(),
                                            true);
   obliqueVolumeSliceMatrixControl->setNoneLabel("Main Window Oblique View Matrix");
   QObject::connect(obliqueVolumeSliceMatrixControl, SIGNAL(activated(int)),
                    this, SLOT(readVolumeSettings()));
   QLabel* obliqueSampleLabel = new QLabel("Slice Sampling");
   obliqueSlicesSamplingSizeDoubleSpinBox = new QDoubleSpinBox;
   obliqueSlicesSamplingSizeDoubleSpinBox->setMinimum(0.01);
   obliqueSlicesSamplingSizeDoubleSpinBox->setMaximum(100.0);
   obliqueSlicesSamplingSizeDoubleSpinBox->setSingleStep(0.1);
   obliqueSlicesSamplingSizeDoubleSpinBox->setDecimals(2);
   QObject::connect(obliqueSlicesSamplingSizeDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVolumeSettings()));
                    
   // Oblique View Matrix Selection
   //
   QGroupBox* obliqueGroupBox = new QGroupBox("Oblique Slices Viewing");
   QGridLayout* obliqueViewGrid = new QGridLayout(obliqueGroupBox);
   obliqueViewGrid->addWidget(obliqueViewLabel, 0, 0, Qt::AlignLeft);
   obliqueViewGrid->addWidget(obliqueVolumeSliceMatrixControl, 0, 1, Qt::AlignLeft);
   obliqueViewGrid->addWidget(obliqueSampleLabel, 1, 0, Qt::AlignLeft);
   obliqueViewGrid->addWidget(obliqueSlicesSamplingSizeDoubleSpinBox, 1, 1, Qt::AlignLeft);
   obliqueGroupBox->setFixedSize(obliqueGroupBox->sizeHint());
   
   //
   // Left column layout
   //
   QVBoxLayout* leftLayout = new QVBoxLayout;
   leftLayout->addWidget(functionalGroupBox);
   leftLayout->addWidget(segmentGroupBox);
   leftLayout->addWidget(colorKeyGroupBox);
   leftLayout->addWidget(animateGroupBox);
   
   //
   // Right column layout
   //
   QVBoxLayout* rightLayout = new QVBoxLayout;
   rightLayout->addWidget(volumeMontageGroupBox);
   rightLayout->addWidget(overlayOpacityGroupBox);
   rightLayout->addWidget(crosshairsGroupBox);
   rightLayout->addWidget(vectorVolumeGroupBox);
   
   //
   // left and right columns layout
   //
   QHBoxLayout* columnsLayout = new QHBoxLayout;
   columnsLayout->addLayout(leftLayout);
   columnsLayout->addLayout(rightLayout);
   columnsLayout->addStretch();
   
   //
   // The volume page and layout
   //
   QWidget* volumeSettingsWidget = new QWidget;
   QVBoxLayout* volumeSettingsLayout = new QVBoxLayout(volumeSettingsWidget);
   volumeSettingsLayout->addWidget(anatomyGroupBox);
   volumeSettingsLayout->addWidget(obliqueGroupBox);
   volumeSettingsLayout->addLayout(columnsLayout);
   volumeSettingsWidget->setFixedHeight(volumeSettingsWidget->sizeHint().height());
   
   pageVolumeSettings = volumeSettingsWidget;
   pageWidgetStack->addWidget(pageVolumeSettings);
   
   pageVolumeSettingsWidgetGroup = new WuQWidgetGroup(this);
   pageVolumeSettingsWidgetGroup->addWidget(volumeAnatomyDrawTypeComboBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeAnatomyBrightnessSlider);
   pageVolumeSettingsWidgetGroup->addWidget(volumeAnatomyContrastSlider);
   pageVolumeSettingsWidgetGroup->addWidget(volumeFunctionalDisplayColorBarCheckBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeSegmentationDrawTypeComboBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeSegmentationTranslucencyDoubleSpinBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeOverlayOpacityDoubleSpinBox);
   pageVolumeSettingsWidgetGroup->addWidget(vectorVolumeSparsitySpinBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeMontageGroupBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeMontageRowsSpinBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeMontageColumnsSpinBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeMontageSliceIncrementSpinBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeShowCrosshairsCheckBox);
   pageVolumeSettingsWidgetGroup->addWidget(volumeShowCrosshairCoordinatesCheckBox);
   pageVolumeSettingsWidgetGroup->addWidget(obliqueVolumeSliceMatrixControl);
   pageVolumeSettingsWidgetGroup->addWidget(obliqueSlicesSamplingSizeDoubleSpinBox);
}

/**
 * create the overlay underlay volume surface outline page.
 */
void 
02827 GuiDisplayControlDialog::createOverlayUnderlayVolumeSurfaceOutlinePage()
{
   pageVolumeSurfaceOutlineWidgetGroup = new WuQWidgetGroup(this);
   
   //
   // outline for fiducial surface Color combo box
   //
   for (int i = 0; i < DisplaySettingsVolume::MAXIMUM_OVERLAY_SURFACES; i++) {
      volumeOverlaySurfaceOutlineColorComboBox[i] = new QComboBox;
      volumeOverlaySurfaceOutlineColorComboBox[i]->insertItem(DisplaySettingsVolume::SURFACE_OUTLINE_COLOR_BLACK,
                                                    "Black");
      volumeOverlaySurfaceOutlineColorComboBox[i]->insertItem(DisplaySettingsVolume::SURFACE_OUTLINE_COLOR_BLUE,
                                                    "Blue");
      volumeOverlaySurfaceOutlineColorComboBox[i]->insertItem(DisplaySettingsVolume::SURFACE_OUTLINE_COLOR_GREEN,
                                                    "Green");
      volumeOverlaySurfaceOutlineColorComboBox[i]->insertItem(DisplaySettingsVolume::SURFACE_OUTLINE_COLOR_RED,
                                                    "Red");
      volumeOverlaySurfaceOutlineColorComboBox[i]->insertItem(DisplaySettingsVolume::SURFACE_OUTLINE_COLOR_WHITE,
                                                    "White");
      QObject::connect(volumeOverlaySurfaceOutlineColorComboBox[i], SIGNAL(activated(int)),
                       this, SLOT(readVolumeSurfaceOutline()));
      pageVolumeSurfaceOutlineWidgetGroup->addWidget(volumeOverlaySurfaceOutlineColorComboBox[i]);
      
      //
      // Fiducial Thickness float spin box
      //
      volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i] = new QDoubleSpinBox;
      volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i]->setMinimum(0.0);
      volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i]->setMaximum(1000.0);
      volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i]->setSingleStep(0.1);
      volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i]->setDecimals(2);
      QObject::connect(volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i], SIGNAL(valueChanged(double)),
                       this, SLOT(readVolumeSurfaceOutline()));
      pageVolumeSurfaceOutlineWidgetGroup->addWidget(volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i]);
   
      //
      // Show fiducial surface outline check box
      //
      volumeShowOverlaySurfaceOutlineCheckBox[i] = new QCheckBox("");
      QObject::connect(volumeShowOverlaySurfaceOutlineCheckBox[i], SIGNAL(toggled(bool)),
                       this, SLOT(readVolumeSurfaceOutline()));
      pageVolumeSurfaceOutlineWidgetGroup->addWidget(volumeShowOverlaySurfaceOutlineCheckBox[i]);
                       
      //
      // overlay surface selection
      //
      if (i > 0) {
         volumeOverlaySurfaceSelectionComboBox[i] = 
            new GuiBrainModelSelectionComboBox(false,
                                               true,
                                               false,
                                               "");
         QObject::connect(volumeOverlaySurfaceSelectionComboBox[i], SIGNAL(activated(int)),
                          this, SLOT(readVolumeSurfaceOutline()));
         pageVolumeSurfaceOutlineWidgetGroup->addWidget(volumeOverlaySurfaceSelectionComboBox[i]);
      }
      else {
         volumeOverlaySurfaceSelectionComboBox[i] = NULL;
      }
   }
   
   //
   // Surface outline section
   //
   QGroupBox* volumeShowSurfaceOutlineGroupBox = new QGroupBox("Surface Outline");
   QObject::connect(volumeShowSurfaceOutlineGroupBox, SIGNAL(toggled(bool)),
                    this, SLOT(readVolumeSurfaceOutline()));
   QGridLayout* volumeShowSurfaceOutlineGroupLayout = new QGridLayout(volumeShowSurfaceOutlineGroupBox);
   volumeShowSurfaceOutlineGroupLayout->addWidget(new QLabel("Show"), 0, 0);
   volumeShowSurfaceOutlineGroupLayout->addWidget(new QLabel("Color"), 0, 1);
   volumeShowSurfaceOutlineGroupLayout->addWidget(new QLabel("Thickness"), 0, 2); 
   volumeShowSurfaceOutlineGroupLayout->addWidget(new QLabel("Surface"), 0, 3);
   for (int i = 0; i < DisplaySettingsVolume::MAXIMUM_OVERLAY_SURFACES; i++) {
      volumeShowSurfaceOutlineGroupLayout->addWidget(volumeShowOverlaySurfaceOutlineCheckBox[i], i+1, 0);  
      volumeShowSurfaceOutlineGroupLayout->addWidget(volumeOverlaySurfaceOutlineColorComboBox[i], i+1, 1);
      volumeShowSurfaceOutlineGroupLayout->addWidget(volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i], i+1, 2);
      if (i > 0) {
         volumeShowSurfaceOutlineGroupLayout->addWidget(volumeOverlaySurfaceSelectionComboBox[i]);
      }
      else {
         volumeShowSurfaceOutlineGroupLayout->addWidget(new QLabel("Active Fiducial Surface"));
      }
      
       //
      // Connect some signals
      //   
      //QObject::connect(volumeShowOverlaySurfaceOutlineCheckBox[i], SIGNAL(toggled(bool)),
      //                 volumeOverlaySurfaceOutlineColorComboBox[i], SLOT(setEnabled(bool)));
      //QObject::connect(volumeShowOverlaySurfaceOutlineCheckBox[i], SIGNAL(toggled(bool)),
      //                 volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i], SLOT(setEnabled(bool)));
      if (i > 0) {
         //QObject::connect(volumeShowOverlaySurfaceOutlineCheckBox[i], SIGNAL(toggled(bool)),
         //                 volumeOverlaySurfaceSelectionComboBox[i], SLOT(setEnabled(bool)));
      }
   }
   volumeShowSurfaceOutlineGroupLayout->setColumnStretch(0, 0);
   volumeShowSurfaceOutlineGroupLayout->setColumnStretch(1, 0);
   volumeShowSurfaceOutlineGroupLayout->setColumnStretch(2, 0);
   volumeShowSurfaceOutlineGroupLayout->setColumnStretch(3, 100);
   volumeShowSurfaceOutlineGroupBox->setFixedHeight(volumeShowSurfaceOutlineGroupBox->sizeHint().height());
   
   QWidget* volumeSurfaceOutlineWidget = new QWidget;
   QVBoxLayout* volumeSurfaceOutlineLayout = new QVBoxLayout(volumeSurfaceOutlineWidget);
   volumeSurfaceOutlineLayout->addWidget(volumeShowSurfaceOutlineGroupBox);
   volumeSurfaceOutlineWidget->setFixedHeight(volumeSurfaceOutlineWidget->sizeHint().height());
   
   pageVolumeSurfaceOutline = volumeSurfaceOutlineWidget;
   pageWidgetStack->addWidget(pageVolumeSurfaceOutline);
}
      
/**
 * Called to use current brightness/contrast default for anatomy volume.
 */
void
02941 GuiDisplayControlDialog::slotDefaultVolumeContrastBrightness()
{
   PreferencesFile* pf = BrainSet::getPreferencesFile();
   pf->setAnatomyVolumeBrightness(volumeAnatomyBrightnessSlider->value());
   pf->setAnatomyVolumeContrast(volumeAnatomyContrastSlider->value());
   try {
      if (pf->getFileName().isEmpty() == false) {
         pf->writeFile(pf->getFileName());
      }
   }
   catch (FileException& /*e*/) {
   }
}

/**
 * Called to start the volume animation.
 */
void
02959 GuiDisplayControlDialog::slotVolumeAnimateStartPushButton()
{
   //
   // Make sure there is a brain model volume in the main window
   //
   BrainModelVolume* bmv = theMainWindow->getBrainModelVolume();
   if (bmv == NULL) {
      QMessageBox::warning(this, "No Volume in Main Window",
                           "There must be a volume slice displayed in the main window");
      return;
   }
   
   //
   // Find number of slices to animate through
   //
   const VolumeFile::VOLUME_AXIS axis = bmv->getSelectedAxis(0);
   int firstSlice = 0;
   int lastSlice = 0;
   int sliceIndex = -1;
   switch(axis) {
      case VolumeFile::VOLUME_AXIS_X:
         sliceIndex = 0;
         break;
      case VolumeFile::VOLUME_AXIS_Y:
         sliceIndex = 1;
         break;
      case VolumeFile::VOLUME_AXIS_Z:
         sliceIndex = 2;
         break;
      case VolumeFile::VOLUME_AXIS_ALL:
      case VolumeFile::VOLUME_AXIS_OBLIQUE:
      case VolumeFile::VOLUME_AXIS_OBLIQUE_X:
      case VolumeFile::VOLUME_AXIS_OBLIQUE_Y:
      case VolumeFile::VOLUME_AXIS_OBLIQUE_Z:
      case VolumeFile::VOLUME_AXIS_OBLIQUE_ALL:
      case VolumeFile::VOLUME_AXIS_UNKNOWN:
         QMessageBox::critical(this, "ERROR", "Animation of all or oblique slices not supported.");
         return;
         break;
   }
      
   //
   // Get the volume file
   //
   VolumeFile* vf = bmv->getMasterVolumeFile();
   if (vf != NULL) {
      //
      // Enable the animation
      //
      //
      // Get the main windows OpenGL widget
      //
      GuiBrainModelOpenGL* openGL = theMainWindow->getBrainModelOpenGL();
      
      // Get the volume's dimensions
      //
      int dim[3];
      vf->getDimensions(dim);
         
      //
      // Get the slices that have data
      //
      int extent[6];
      float voxelExtent[6];
      vf->getNonZeroVoxelExtent(extent, voxelExtent);
      
      //
      // Get the currently selected slices of the volume
      //
      int slices[3];
      bmv->getSelectedOrthogonalSlices(0, slices);
         
      //
      // First and last slices to show
      //
      firstSlice = extent[sliceIndex*2];
      lastSlice = extent[sliceIndex*2 + 1];
      
      //
      // while animation should be performed
      //   
      continueVolumeAnimation = true;
      while (continueVolumeAnimation) {
         //
         // set slices and update
         //
         if ((slices[sliceIndex] >= firstSlice) &&
             (slices[sliceIndex] <= lastSlice)) {
            bmv->setSelectedOrthogonalSlices(0, slices);
         }
         GuiToolBar::updateAllToolBars(false);
         GuiBrainModelOpenGL::updateAllGL(openGL);
          
         //
         // Get slice increment
         //
         int sliceDelta = 1;
         switch (static_cast<VOLUME_ANIMATE_DIRECTION>(volumeAnimateDirectionComboBox->currentIndex())) {
            case VOLUME_ANIMATE_DIRECTION_INCREMENT:
               sliceDelta = 1;
               break;
            case VOLUME_ANIMATE_DIRECTION_DECREMENT:
               sliceDelta = -1;
               break;
         }
         
         //
         // Update the slice
         //
         slices[sliceIndex] += sliceDelta;

         //
         // Switch directions if needed
         //
         if (slices[sliceIndex] > lastSlice) {
            slices[sliceIndex] = lastSlice;
            volumeAnimateDirectionComboBox->setCurrentIndex(VOLUME_ANIMATE_DIRECTION_DECREMENT);
         }
         else if (slices[sliceIndex] < firstSlice) {
            volumeAnimateDirectionComboBox->setCurrentIndex(VOLUME_ANIMATE_DIRECTION_INCREMENT);
         } 
         
         //
         // Allow events to process
         //
         qApp->processEvents();
      }
   }
}

/**
 * Called to stop the volume animation.
 */
void
03093 GuiDisplayControlDialog::slotVolumeAnimateStopPushButton()
{
   continueVolumeAnimation = false;
}

/**
 * Called to display a histogram of the anatomy volume
 */
void
03102 GuiDisplayControlDialog::slotAnatomyVolumeHistogram()
{
   BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
   if (bmv != NULL) {
      VolumeFile* vf = bmv->getSelectedVolumeAnatomyFile();
      if (vf != NULL) {
         QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
         const int numVoxels = vf->getTotalNumberOfVoxels();
         std::vector<float> values;
         for (int i = 0; i < numVoxels; i++) {
            values.push_back(vf->getVoxelWithFlatIndex(i));
         } 
         GuiHistogramDisplayDialog* ghd = new GuiHistogramDisplayDialog(theMainWindow, 
                                             FileUtilities::basename(vf->getFileName()),
                                             values,
                                             true,
                                             static_cast<Qt::WindowFlags>(Qt::WA_DeleteOnClose));
         ghd->show();
         QApplication::restoreOverrideCursor();
      }
   }
}

/**
 * Reads the volume selections
 */
void
03129 GuiDisplayControlDialog::readVolumeSelections()
{
   if (pageVolumeSelection == NULL) {
      return;
   }
   if (creatingDialog) {
      return;
   }
}

/**
 * reads the volume settings.
 */
void 
03143 GuiDisplayControlDialog::readVolumeSettings()
{
   if (pageVolumeSettings == NULL) {
      return;
   }
   if (creatingDialog) {
      return;
   }
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();

   dsv->setAnatomyVolumeBrightness(volumeAnatomyBrightnessSlider->value());
   dsv->setAnatomyVolumeContrast(volumeAnatomyContrastSlider->value());
   dsv->setVectorVolumeSparsity(vectorVolumeSparsitySpinBox->value());
   dsv->setMontageViewSelected(volumeMontageGroupBox->isChecked());
   dsv->setMontageViewSettings(volumeMontageRowsSpinBox->value(),
                               volumeMontageColumnsSpinBox->value(),
                               volumeMontageSliceIncrementSpinBox->value());
   dsv->setDisplayCrosshairCoordinates(volumeShowCrosshairCoordinatesCheckBox->isChecked());
   dsv->setDisplayCrosshairs(volumeShowCrosshairsCheckBox->isChecked());
   dsv->setAnatomyVolumeColoringType(
      static_cast<DisplaySettingsVolume::ANATOMY_COLORING_TYPE>(
                         volumeAnatomyDrawTypeComboBox->currentIndex()));
   dsv->setSegmentationDrawType(
      static_cast<DisplaySettingsVolume::SEGMENTATION_DRAW_TYPE>(
         volumeSegmentationDrawTypeComboBox->currentIndex()));
   dsv->setSegmentationTranslucency(volumeSegmentationTranslucencyDoubleSpinBox->value());
   dsv->setOverlayOpacity(volumeOverlayOpacityDoubleSpinBox->value());
   dsv->setDisplayColorBar(volumeFunctionalDisplayColorBarCheckBox->isChecked());
   dsv->setObliqueSlicesTransformationMatrix(obliqueVolumeSliceMatrixControl->getSelectedMatrix());
   dsv->setObliqueSlicesSamplingSize(obliqueSlicesSamplingSizeDoubleSpinBox->value());

   BrainModelVolumeVoxelColoring* voxelColoring = theMainWindow->getBrainSet()->getVoxelColoring();
   voxelColoring->setVolumeAnatomyColoringInvalid();
   GuiBrainModelOpenGL::updateAllGL();   
}

/**
 * reads the volume surface outline.
 */
void 
03183 GuiDisplayControlDialog::readVolumeSurfaceOutline()
{
   if (pageVolumeSurfaceOutline == NULL) {
      return;
   }
   if (creatingDialog) {
      return;
   }
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();

   for (int i = 0; i < DisplaySettingsVolume::MAXIMUM_OVERLAY_SURFACES; i++) {
      dsv->setDisplayOverlaySurfaceOutline(i, volumeShowOverlaySurfaceOutlineCheckBox[i]->isChecked());
      dsv->setOverlaySurfaceOutlineColor(i,
         static_cast<DisplaySettingsVolume::SURFACE_OUTLINE_COLOR>(
            volumeOverlaySurfaceOutlineColorComboBox[i]->currentIndex()));
      dsv->setOverlaySurfaceOutlineThickness(i, volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i]->value());
      if (i > 0) {
         dsv->setOverlaySurface(i, dynamic_cast<BrainModelSurface*>(volumeOverlaySurfaceSelectionComboBox[i]->getSelectedBrainModel()));
      }
   }
   GuiBrainModelOpenGL::updateAllGL();   
}
      
/**
 * Update the selected volume tooltips.
 */
void
03210 GuiDisplayControlDialog::updateVolumeToolTips()
{
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   
   if (theMainWindow->getBrainSet()->getNumberOfVolumeAnatomyFiles() > 0) {
      volumeAnatomyComboBox->setToolTip(
                     theMainWindow->getBrainSet()->getVolumeAnatomyFile(
                        dsv->getSelectedAnatomyVolume())->getDescriptiveLabel());
   }
   
   if (theMainWindow->getBrainSet()->getNumberOfVolumeFunctionalFiles() > 0) {
      volumeFunctionalViewComboBox->setToolTip(
                     theMainWindow->getBrainSet()->getVolumeFunctionalFile(
                        dsv->getSelectedFunctionalVolumeView())->getDescriptiveLabel());
      volumeFunctionalThresholdComboBox->setToolTip(
                     theMainWindow->getBrainSet()->getVolumeFunctionalFile(
                        dsv->getSelectedFunctionalVolumeThreshold())->getDescriptiveLabel());
   }
   
   if (theMainWindow->getBrainSet()->getNumberOfVolumePaintFiles() > 0) {
      volumePaintComboBox->setToolTip(
                    theMainWindow->getBrainSet()->getVolumePaintFile(
                        dsv->getSelectedPaintVolume())->getDescriptiveLabel());
   }
   
   if (theMainWindow->getBrainSet()->getNumberOfVolumeRgbFiles() > 0) {
      volumeRgbComboBox->setToolTip(
                    theMainWindow->getBrainSet()->getVolumeRgbFile(
                        dsv->getSelectedRgbVolume())->getDescriptiveLabel());
   }
   
   if (theMainWindow->getBrainSet()->getNumberOfVolumeSegmentationFiles() > 0) {
      volumeSegmentationComboBox->setToolTip( 
                    theMainWindow->getBrainSet()->getVolumeSegmentationFile(
                        dsv->getSelectedSegmentationVolume())->getDescriptiveLabel());
   }
}

/**
 * Update the volume items
 */
void
03252 GuiDisplayControlDialog::updateVolumeItems()
{
   updatePageSelectionComboBox();
   
   updateVolumeSelectionPage();
   updateVolumeSettingsPage();
   updateVolumeSurfaceOutlinePage();
}

/**
 * update volume selection page.
 */
void 
03265 GuiDisplayControlDialog::updateVolumeSelectionPage()
{
   if (pageVolumeSelection == NULL) {
      return;
   }

   pageVolumeSelection->setEnabled(validVolumeData); 
   BrainModelVolumeVoxelColoring* vvc = theMainWindow->getBrainSet()->getVoxelColoring();
   DisplaySettingsVolume* dsv         = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   //
   // Set the primary overlay radio buttons
   //
   switch(vvc->getPrimaryOverlay()) {
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_ANATOMY:
         volumePrimaryOverlayAnatomyRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_FUNCTIONAL:
         volumePrimaryOverlayFunctionalRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PAINT: 
         volumePrimaryOverlayPaintRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PROB_ATLAS: 
         volumePrimaryOverlayProbAtlasRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_RGB:
         volumePrimaryOverlayRgbRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_SEGMENTATION:
         volumePrimaryOverlaySegmentationRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_VECTOR:
         volumePrimaryOverlayVectorRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_NONE:   
         volumePrimaryOverlayNoneButton->setChecked(true);
         break;
   }

   //
   // set the secondary overlay radio buttons
   //
   switch(vvc->getSecondaryOverlay()) {
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_ANATOMY:
         volumeSecondaryOverlayAnatomyRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_FUNCTIONAL:
         volumeSecondaryOverlayFunctionalRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PAINT: 
         volumeSecondaryOverlayPaintRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PROB_ATLAS: 
         volumeSecondaryOverlayProbAtlasRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_RGB:
         volumeSecondaryOverlayRgbRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_SEGMENTATION:
         volumeSecondaryOverlaySegmentationRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_VECTOR:
         volumeSecondaryOverlayVectorRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_NONE:   
         volumeSecondaryOverlayNoneButton->setChecked(true);
         break;
   }
   //
   // set the underlay radio buttons
   //
   switch(vvc->getUnderlay()) {
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_ANATOMY:
         volumeUnderlayAnatomyRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_FUNCTIONAL:
         volumeUnderlayFunctionalRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PAINT: 
         volumeUnderlayPaintRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_PROB_ATLAS: 
         volumeUnderlayProbAtlasRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_RGB:
         volumeUnderlayRgbRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_SEGMENTATION:
         volumeUnderlaySegmentationRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_VECTOR:
         volumeUnderlayVectorRadioButton->setChecked(true);
         break;
      case BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_NONE:   
         volumeUnderlayNoneButton->setChecked(true);
         break;
   }
   
   //
   // update anatomy volume combo box
   //
   volumePrimaryOverlayAnatomyRadioButton->setEnabled(false);
   volumeSecondaryOverlayAnatomyRadioButton->setEnabled(false);
   volumeUnderlayAnatomyRadioButton->setEnabled(false);
   volumeAnatomyComboBox->setEnabled(false);
   volumeAnatomyLabel->setEnabled(false);
   volumeAnatomyInfoPushButton->setEnabled(false);
   volumeAnatomyMetaDataPushButton->setEnabled(false);
   volumeAnatomyComboBox->clear();
   if (theMainWindow->getBrainSet()->getNumberOfVolumeAnatomyFiles() > 0) {
      for (int i = 0; i < theMainWindow->getBrainSet()->getNumberOfVolumeAnatomyFiles(); i++) {
         volumeAnatomyComboBox->addItem(
            theMainWindow->getBrainSet()->getVolumeAnatomyFile(i)->getDescriptiveLabel());
      }
      volumeAnatomyComboBox->setCurrentIndex(dsv->getSelectedAnatomyVolume());
      
      volumePrimaryOverlayAnatomyRadioButton->setEnabled(true);
      volumeSecondaryOverlayAnatomyRadioButton->setEnabled(true);
      volumeUnderlayAnatomyRadioButton->setEnabled(true);
      volumeAnatomyComboBox->setEnabled(true);
      volumeAnatomyLabel->setEnabled(true);
      volumeAnatomyInfoPushButton->setEnabled(true);
      volumeAnatomyMetaDataPushButton->setEnabled(true);
   }
   
   //
   // update functional volume combo box
   //
   volumePrimaryOverlayFunctionalRadioButton->setEnabled(false);
   volumeSecondaryOverlayFunctionalRadioButton->setEnabled(false);
   volumeUnderlayFunctionalRadioButton->setEnabled(false);
   volumeFunctionalViewComboBox->setEnabled(false);
   volumeFunctionalThresholdComboBox->setEnabled(false);
   volumeFunctionalViewLabel->setEnabled(false);
   volumeFunctionalViewInfoPushButton->setEnabled(false);
   volumeFunctionalThreshInfoPushButton->setEnabled(false);
   volumeFunctionalViewMetaDataPushButton->setEnabled(false);
   volumeFunctionalThreshMetaDataPushButton->setEnabled(false);
   volumeFunctionalThresholdLabel->setEnabled(false);
   volumeFunctionalViewComboBox->clear();
   volumeFunctionalThresholdComboBox->clear();
   if (theMainWindow->getBrainSet()->getNumberOfVolumeFunctionalFiles() > 0) {
      for (int i = 0; i < theMainWindow->getBrainSet()->getNumberOfVolumeFunctionalFiles(); i++) {
         volumeFunctionalViewComboBox->addItem(
            theMainWindow->getBrainSet()->getVolumeFunctionalFile(i)->getDescriptiveLabel());
         volumeFunctionalThresholdComboBox->addItem(
            theMainWindow->getBrainSet()->getVolumeFunctionalFile(i)->getDescriptiveLabel());
      }
      volumeFunctionalViewComboBox->setCurrentIndex(dsv->getSelectedFunctionalVolumeView());
      volumeFunctionalThresholdComboBox->setCurrentIndex(dsv->getSelectedFunctionalVolumeThreshold());
      
      volumePrimaryOverlayFunctionalRadioButton->setEnabled(true);
      volumeSecondaryOverlayFunctionalRadioButton->setEnabled(true);
      volumeUnderlayFunctionalRadioButton->setEnabled(true);
      volumeFunctionalViewComboBox->setEnabled(true);
      volumeFunctionalViewLabel->setEnabled(true);
      volumeFunctionalThresholdComboBox->setEnabled(true);
      volumeFunctionalThresholdLabel->setEnabled(true);
      volumeFunctionalViewInfoPushButton->setEnabled(true);
      volumeFunctionalThreshInfoPushButton->setEnabled(true);
      volumeFunctionalViewMetaDataPushButton->setEnabled(true);
      volumeFunctionalThreshMetaDataPushButton->setEnabled(true);
   }

   //
   // update paint volume combo box
   //
   volumePrimaryOverlayPaintRadioButton->setEnabled(false);
   volumeSecondaryOverlayPaintRadioButton->setEnabled(false);
   volumeUnderlayPaintRadioButton->setEnabled(false);
   volumePaintComboBox->setEnabled(false);
   volumePaintLabel->setEnabled(false);
   volumePaintInfoPushButton->setEnabled(false);
   volumePaintMetaDataPushButton->setEnabled(false);
   volumePaintComboBox->clear();
   if (theMainWindow->getBrainSet()->getNumberOfVolumePaintFiles() > 0) {
      for (int i = 0; i < theMainWindow->getBrainSet()->getNumberOfVolumePaintFiles(); i++) {
         volumePaintComboBox->addItem(
            theMainWindow->getBrainSet()->getVolumePaintFile(i)->getDescriptiveLabel());
      }
      volumePaintComboBox->setCurrentIndex(dsv->getSelectedPaintVolume());
      
      volumePrimaryOverlayPaintRadioButton->setEnabled(true);
      volumeSecondaryOverlayPaintRadioButton->setEnabled(true);
      volumeUnderlayPaintRadioButton->setEnabled(true);
      volumePaintComboBox->setEnabled(true);
      volumePaintLabel->setEnabled(true);
      volumePaintInfoPushButton->setEnabled(true);
      volumePaintMetaDataPushButton->setEnabled(true);
   }

   //
   // update prob atlas volume combo box
   //
   volumePrimaryOverlayProbAtlasRadioButton->setEnabled(false);
   volumeSecondaryOverlayProbAtlasRadioButton->setEnabled(false);
   volumeUnderlayProbAtlasRadioButton->setEnabled(false);
   volumeProbAtlasLabel->setEnabled(false);
   volumeProbAtlasInfoPushButton->setEnabled(false);
   volumeProbAtlasMetaDataPushButton->setEnabled(false);
   if (theMainWindow->getBrainSet()->getNumberOfVolumeProbAtlasFiles() > 0) {
      volumePrimaryOverlayProbAtlasRadioButton->setEnabled(true);
      volumeSecondaryOverlayProbAtlasRadioButton->setEnabled(true);
      volumeUnderlayProbAtlasRadioButton->setEnabled(true);
      volumeProbAtlasLabel->setEnabled(true);
      volumeProbAtlasInfoPushButton->setEnabled(true);
      volumeProbAtlasMetaDataPushButton->setEnabled(true);
   }

   //
   // update rgb volume combo box
   //
   volumePrimaryOverlayRgbRadioButton->setEnabled(false);
   volumeSecondaryOverlayRgbRadioButton->setEnabled(false);
   volumeUnderlayRgbRadioButton->setEnabled(false);
   volumeRgbComboBox->setEnabled(false);
   volumeRgbLabel->setEnabled(false);
   volumeRgbComboBox->clear();
   volumeRgbInfoPushButton->setEnabled(false);
   volumeRgbMetaDataPushButton->setEnabled(false);
   if (theMainWindow->getBrainSet()->getNumberOfVolumeRgbFiles() > 0) {
      for (int i = 0; i < theMainWindow->getBrainSet()->getNumberOfVolumeRgbFiles(); i++) {
         volumeRgbComboBox->addItem(
            theMainWindow->getBrainSet()->getVolumeRgbFile(i)->getDescriptiveLabel());
      }
      volumeRgbComboBox->setCurrentIndex(dsv->getSelectedRgbVolume());
      
      volumePrimaryOverlayRgbRadioButton->setEnabled(true);
      volumeSecondaryOverlayRgbRadioButton->setEnabled(true);
      volumeUnderlayRgbRadioButton->setEnabled(true);
      volumeRgbComboBox->setEnabled(true);
      volumeRgbLabel->setEnabled(true);
      volumeRgbInfoPushButton->setEnabled(true);
      volumeRgbMetaDataPushButton->setEnabled(true);
   }

   //
   // update segmentation volume combo box
   //
   volumePrimaryOverlaySegmentationRadioButton->setEnabled(false);
   volumeSecondaryOverlaySegmentationRadioButton->setEnabled(false);
   volumeUnderlaySegmentationRadioButton->setEnabled(false);
   volumeSegmentationComboBox->setEnabled(false);
   volumeSegmentationLabel->setEnabled(false);
   volumeSegmentationInfoPushButton->setEnabled(false);
   volumeSegmentationMetaDataPushButton->setEnabled(false);
   volumeSegmentationComboBox->clear();
   if (theMainWindow->getBrainSet()->getNumberOfVolumeSegmentationFiles() > 0) {
      for (int i = 0; i < theMainWindow->getBrainSet()->getNumberOfVolumeSegmentationFiles(); i++) {
         volumeSegmentationComboBox->addItem(
            theMainWindow->getBrainSet()->getVolumeSegmentationFile(i)->getDescriptiveLabel());
      }
      volumeSegmentationComboBox->setCurrentIndex(dsv->getSelectedSegmentationVolume());
      
      volumePrimaryOverlaySegmentationRadioButton->setEnabled(true);
      volumeSecondaryOverlaySegmentationRadioButton->setEnabled(true);
      volumeUnderlaySegmentationRadioButton->setEnabled(true);
      volumeSegmentationComboBox->setEnabled(true);
      volumeSegmentationLabel->setEnabled(true);
      volumeSegmentationInfoPushButton->setEnabled(true);
      volumeSegmentationMetaDataPushButton->setEnabled(true);
   }
   
   //
   // update vector volume combo box
   //
   volumePrimaryOverlayVectorRadioButton->setEnabled(false);
   volumeSecondaryOverlayVectorRadioButton->setEnabled(false);
   volumeUnderlayVectorRadioButton->setEnabled(false);
   volumeVectorComboBox->setEnabled(false);
   volumeVectorLabel->setEnabled(false);
   volumeVectorInfoPushButton->setEnabled(false);
   volumeVectorMetaDataPushButton->setEnabled(false);
   volumeVectorComboBox->clear();
   if (theMainWindow->getBrainSet()->getNumberOfVolumeVectorFiles() > 0) {
      for (int i = 0; i < theMainWindow->getBrainSet()->getNumberOfVolumeVectorFiles(); i++) {
         volumeVectorComboBox->addItem(
            theMainWindow->getBrainSet()->getVolumeVectorFile(i)->getDescriptiveLabel());
      }
      volumeVectorComboBox->setCurrentIndex(dsv->getSelectedVectorVolume());
      
      volumePrimaryOverlayVectorRadioButton->setEnabled(true);
      volumeSecondaryOverlayVectorRadioButton->setEnabled(true);
      volumeUnderlayVectorRadioButton->setEnabled(true);
      volumeVectorComboBox->setEnabled(true);
      volumeVectorLabel->setEnabled(true);
      volumeVectorInfoPushButton->setEnabled(true);
      volumeVectorMetaDataPushButton->setEnabled(true);
      vectorVolumeSparsitySpinBox->setValue(dsv->getVectorVolumeSparsity());
   }

   updateVolumeToolTips();
   updateProbAtlasVolumeItems(true);
}

/**
 * update volume settings page.
 */
void 
03564 GuiDisplayControlDialog::updateVolumeSettingsPage()
{
   if (pageVolumeSettings == NULL) {
      return;
   }
   pageVolumeSettingsWidgetGroup->blockSignals(true);
   
   pageVolumeSettings->setEnabled(validVolumeData);
   
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();

   volumeSegmentationDrawTypeComboBox->setCurrentIndex(dsv->getSegmentationDrawType());
   volumeAnatomyDrawTypeComboBox->setCurrentIndex(dsv->getAnatomyVolumeColoringType());
   volumeSegmentationTranslucencyDoubleSpinBox->setValue(dsv->getSegmentationTranslucency());
   volumeOverlayOpacityDoubleSpinBox->setValue(dsv->getOverlayOpacity());
   volumeAnatomyBrightnessSlider->setValue(dsv->getAnatomyVolumeBrightness());
   volumeAnatomyContrastSlider->setValue(dsv->getAnatomyVolumeContrast());
   
   volumeAnatomyBrightnessLabel->setNum(volumeAnatomyBrightnessSlider->value());
   volumeAnatomyContrastLabel->setNum(volumeAnatomyContrastSlider->value());
   
   volumeFunctionalDisplayColorBarCheckBox->setChecked(dsv->getDisplayColorBar());
   
   volumeMontageGroupBox->setChecked(dsv->getMontageViewSelected());
   int rows, cols, slices;
   dsv->getMontageViewSettings(rows, cols, slices);
   volumeMontageRowsSpinBox->setValue(rows);
   volumeMontageColumnsSpinBox->setValue(cols);
   volumeMontageSliceIncrementSpinBox->setValue(slices);
   
   volumeShowCrosshairCoordinatesCheckBox->blockSignals(true);
   volumeShowCrosshairCoordinatesCheckBox->setChecked(dsv->getDisplayCrosshairCoordinates());
   volumeShowCrosshairCoordinatesCheckBox->blockSignals(false);
   volumeShowCrosshairsCheckBox->blockSignals(true);
   volumeShowCrosshairsCheckBox->setChecked(dsv->getDisplayCrosshairs());
   volumeShowCrosshairsCheckBox->blockSignals(false);
   obliqueVolumeSliceMatrixControl->updateControl();
   obliqueVolumeSliceMatrixControl->setSelectedMatrix(dsv->getObliqueSlicesTransformationMatrix());
   obliqueSlicesSamplingSizeDoubleSpinBox->setValue(dsv->getObliqueSlicesSamplingSize());
   continueVolumeAnimation = false;   
   
   vectorVolumeGroupBox->setEnabled(theMainWindow->getBrainSet()->getNumberOfVolumeVectorFiles() > 0);
   
   pageVolumeSettingsWidgetGroup->blockSignals(false);
}

/**
 * update volume surface outline page.
 */
void 
03614 GuiDisplayControlDialog::updateVolumeSurfaceOutlinePage()
{
   if (pageVolumeSurfaceOutline == NULL) {
      return;
   }
   pageVolumeSurfaceOutlineWidgetGroup->blockSignals(true);
   pageVolumeSurfaceOutline->setEnabled(validVolumeData);
   
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   for (int i = 0; i < DisplaySettingsVolume::MAXIMUM_OVERLAY_SURFACES; i++) {
      volumeShowOverlaySurfaceOutlineCheckBox[i]->blockSignals(true);
      volumeShowOverlaySurfaceOutlineCheckBox[i]->setChecked(dsv->getDisplayOverlaySurfaceOutline(i));
      volumeShowOverlaySurfaceOutlineCheckBox[i]->blockSignals(false);
      volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i]->blockSignals(true);
      volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i]->setValue(dsv->getOverlaySurfaceOutlineThickness(i));
      volumeOverlaySurfaceOutlineThicknessDoubleSpinBox[i]->blockSignals(false);
      volumeOverlaySurfaceOutlineColorComboBox[i]->blockSignals(true);
      volumeOverlaySurfaceOutlineColorComboBox[i]->setCurrentIndex(dsv->getOverlaySurfaceOutlineColor(i));
      volumeOverlaySurfaceOutlineColorComboBox[i]->blockSignals(false);
      if (i > 0) {
         volumeOverlaySurfaceSelectionComboBox[i]->blockSignals(true);
         volumeOverlaySurfaceSelectionComboBox[i]->updateComboBox();
         volumeOverlaySurfaceSelectionComboBox[i]->setSelectedBrainModel(dsv->getOverlaySurface(i));
         volumeOverlaySurfaceSelectionComboBox[i]->blockSignals(false);
      }
   }
   pageVolumeSurfaceOutlineWidgetGroup->blockSignals(false);
}
      
/**
 * called when a volume primary overlay is selected
 */
void 
03647 GuiDisplayControlDialog::volumePrimaryOverlaySelection(int n)
{
   BrainModelVolumeVoxelColoring* vvc = theMainWindow->getBrainSet()->getVoxelColoring();
   vvc->setPrimaryOverlay(static_cast<BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_TYPE>(n));
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
}

/**
 * called when a volume secondary overlay is selected
 */
void 
03659 GuiDisplayControlDialog::volumeSecondaryOverlaySelection(int n)
{
   BrainModelVolumeVoxelColoring* vvc = theMainWindow->getBrainSet()->getVoxelColoring();
   vvc->setSecondaryOverlay(static_cast<BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_TYPE>(n));
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
}

/**
 * called when a volume underlay is selected
 */
void 
03671 GuiDisplayControlDialog::volumeUnderlaySelection(int n)
{
   BrainModelVolumeVoxelColoring* vvc = theMainWindow->getBrainSet()->getVoxelColoring();
   vvc->setUnderlay(static_cast<BrainModelVolumeVoxelColoring::UNDERLAY_OVERLAY_TYPE>(n));
   GuiVolumeResizingDialog* volResizeDialog = theMainWindow->getVolumeResizingDialog(false);
   if (volResizeDialog != NULL) {
      volResizeDialog->updateDialog(false);
   }
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
}

/**
 * called to display comment info for volume.
 */
void 
03687 GuiDisplayControlDialog::volumeAnatomyInfoPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeAnatomyFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeAnatomyFile();
      GuiDataFileCommentDialog* dfcd = new GuiDataFileCommentDialog(theMainWindow, vf);
      dfcd->show();
   }
}

/**
 * called to display comment info for volume.
 */
void 
03701 GuiDisplayControlDialog::volumeFunctionalViewInfoPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeFunctionalFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeFunctionalViewFile();
      GuiDataFileCommentDialog* dfcd = new GuiDataFileCommentDialog(theMainWindow, vf);
      dfcd->show();
   }
}

/**
 * called to display comment info for volume.
 */
void 
03715 GuiDisplayControlDialog::volumeFunctionalThreshInfoPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeFunctionalFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeFunctionalThresholdFile();
      GuiDataFileCommentDialog* dfcd = new GuiDataFileCommentDialog(theMainWindow, vf);
      dfcd->show();
   }
}

/**
 * called to display comment info for volume.
 */
void 
03729 GuiDisplayControlDialog::volumePaintInfoPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumePaintFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumePaintFile();
      GuiDataFileCommentDialog* dfcd = new GuiDataFileCommentDialog(theMainWindow, vf);
      dfcd->show();
   }
}

/**
 * called to display comment info for volume.
 */
void 
03743 GuiDisplayControlDialog::volumeProbAtlasInfoPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeProbAtlasFiles() > 0) {
      if (theMainWindow->getBrainSet()->getNumberOfVolumeProbAtlasFiles() > 0) {
         VolumeFile* vf = theMainWindow->getBrainSet()->getVolumeProbAtlasFile(0);
         GuiDataFileCommentDialog* dfcd = new GuiDataFileCommentDialog(theMainWindow, vf);
         dfcd->show();
      }
   }
}

/** 
 * called to display comment info for volume.
 */
void 
03758 GuiDisplayControlDialog::volumeRgbInfoPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeRgbFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeRgbFile();
      GuiDataFileCommentDialog* dfcd = new GuiDataFileCommentDialog(theMainWindow, vf);
      dfcd->show();
   }
}

/** 
 * called to display comment info for segmentation volume.
 */
void 
03772 GuiDisplayControlDialog::volumeSegmentationInfoPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeSegmentationFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeSegmentationFile();
      GuiDataFileCommentDialog* dfcd = new GuiDataFileCommentDialog(theMainWindow, vf);
      dfcd->show();
   }
}
      
/** 
 * called to display comment info for vector volume.
 */
void 
03786 GuiDisplayControlDialog::volumeVectorInfoPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeVectorFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeVectorFile();
      GuiDataFileCommentDialog* dfcd = new GuiDataFileCommentDialog(theMainWindow, vf);
      dfcd->show();
   }
}
      
/**
 * called to display metadata info for anatomy volume.
 */
void 
03800 GuiDisplayControlDialog::volumeAnatomyMetaDataPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeAnatomyFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeAnatomyFile();
      StudyMetaDataLinkSet smdls = vf->getStudyMetaDataLinkSet();
      GuiStudyMetaDataLinkCreationDialog smdlcd(this);
      smdlcd.initializeSelectedLinkSet(smdls);
      if (smdlcd.exec() == GuiStudyMetaDataLinkCreationDialog::Accepted) {
         smdls = smdlcd.getLinkSetCreated();
         vf->setStudyMetaDataLinkSet(smdls);
      }
   }
}

/**
 * called to display metadata info for functional view volume.
 */
void 
03819 GuiDisplayControlDialog::volumeFunctionalViewMetaDataPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeFunctionalFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeFunctionalViewFile();
      StudyMetaDataLinkSet smdls = vf->getStudyMetaDataLinkSet();
      GuiStudyMetaDataLinkCreationDialog smdlcd(this);
      smdlcd.initializeSelectedLinkSet(smdls);
      if (smdlcd.exec() == GuiStudyMetaDataLinkCreationDialog::Accepted) {
         smdls = smdlcd.getLinkSetCreated();
         vf->setStudyMetaDataLinkSet(smdls);
      }
   }
}

/**
 * called to display metadata info for function threshold volume.
 */
void 
03838 GuiDisplayControlDialog::volumeFunctionalThreshMetaDataPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeFunctionalFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeFunctionalThresholdFile();
      StudyMetaDataLinkSet smdls = vf->getStudyMetaDataLinkSet();
      GuiStudyMetaDataLinkCreationDialog smdlcd(this);
      smdlcd.initializeSelectedLinkSet(smdls);
      if (smdlcd.exec() == GuiStudyMetaDataLinkCreationDialog::Accepted) {
         smdls = smdlcd.getLinkSetCreated();
         vf->setStudyMetaDataLinkSet(smdls);
      }
   }
}

/**
 * called to display metadata info for paint volume.
 */
void 
03857 GuiDisplayControlDialog::volumePaintMetaDataPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumePaintFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumePaintFile();
      StudyMetaDataLinkSet smdls = vf->getStudyMetaDataLinkSet();
      GuiStudyMetaDataLinkCreationDialog smdlcd(this);
      smdlcd.initializeSelectedLinkSet(smdls);
      if (smdlcd.exec() == GuiStudyMetaDataLinkCreationDialog::Accepted) {
         smdls = smdlcd.getLinkSetCreated();
         vf->setStudyMetaDataLinkSet(smdls);
      }
   }
}

/**
 * called to display metadata info for prob atlas volume.
 */
void 
03876 GuiDisplayControlDialog::volumeProbAtlasVolumeStudyMetaDataPushButton()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeProbAtlasFiles() > 0) {
      const int numFiles = theMainWindow->getBrainSet()->getNumberOfVolumeProbAtlasFiles();
      if (numFiles > 0) {
         VolumeFile* vf = theMainWindow->getBrainSet()->getVolumeProbAtlasFile(0);
         StudyMetaDataLinkSet smdls = vf->getStudyMetaDataLinkSet();
         GuiStudyMetaDataLinkCreationDialog smdlcd(this);
         smdlcd.initializeSelectedLinkSet(smdls);
         if (smdlcd.exec() == GuiStudyMetaDataLinkCreationDialog::Accepted) {
            smdls = smdlcd.getLinkSetCreated();
            for (int i = 0; i < numFiles; i++) {
               VolumeFile* vf = theMainWindow->getBrainSet()->getVolumeProbAtlasFile(i);
               vf->setStudyMetaDataLinkSet(smdls);
            }
         }
      }
   }
}

/** 
 * called to display metadata info for rgb volume.
 */
void 
03900 GuiDisplayControlDialog::volumeRgbMetaDataPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeRgbFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeRgbFile();
      StudyMetaDataLinkSet smdls = vf->getStudyMetaDataLinkSet();
      GuiStudyMetaDataLinkCreationDialog smdlcd(this);
      smdlcd.initializeSelectedLinkSet(smdls);
      if (smdlcd.exec() == GuiStudyMetaDataLinkCreationDialog::Accepted) {
         smdls = smdlcd.getLinkSetCreated();
         vf->setStudyMetaDataLinkSet(smdls);
      }
   }
}

/** 
 * called to display metadata info for segmentation volume.
 */
void 
03919 GuiDisplayControlDialog::volumeSegmentationMetaDataPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeSegmentationFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeSegmentationFile();
      StudyMetaDataLinkSet smdls = vf->getStudyMetaDataLinkSet();
      GuiStudyMetaDataLinkCreationDialog smdlcd(this);
      smdlcd.initializeSelectedLinkSet(smdls);
      if (smdlcd.exec() == GuiStudyMetaDataLinkCreationDialog::Accepted) {
         smdls = smdlcd.getLinkSetCreated();
         vf->setStudyMetaDataLinkSet(smdls);
      }
   }
}
      
/** 
 * called to display metadata info for vector volume.
 */
void 
03938 GuiDisplayControlDialog::volumeVectorMetaDataPushButtonSelection()
{
   if (theMainWindow->getBrainSet()->getNumberOfVolumeVectorFiles() > 0) {
      BrainModelVolume* bmv = theMainWindow->getBrainSet()->getBrainModelVolume();
      VolumeFile* vf = bmv->getSelectedVolumeVectorFile();
      StudyMetaDataLinkSet smdls = vf->getStudyMetaDataLinkSet();
      GuiStudyMetaDataLinkCreationDialog smdlcd(this);
      smdlcd.initializeSelectedLinkSet(smdls);
      if (smdlcd.exec() == GuiStudyMetaDataLinkCreationDialog::Accepted) {
         smdls = smdlcd.getLinkSetCreated();
         vf->setStudyMetaDataLinkSet(smdls);
      }
   }
}
      
/**
 * Called when a volume anatomy column is selected.
 */
void
03957 GuiDisplayControlDialog::volumeAnatomySelection(int n)
{
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   dsv->setSelectedAnatomyVolume(n);
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
   updateVolumeToolTips();
}

/**
 * Called when a volume functional view column is functional selected.
 */
void
03970 GuiDisplayControlDialog::volumeFunctionalViewSelection(int n)
{
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   dsv->setSelectedFunctionalVolumeView(n);
   dsv->setSelectedFunctionalVolumeThreshold(n);
   volumeFunctionalThresholdComboBox->setCurrentIndex(n);
   BrainModelSurfaceNodeColoring* bsnc = theMainWindow->getBrainSet()->getNodeColoring();
   bsnc->assignColors();
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
   updateVolumeToolTips();
}

/**
 * Called when a volume functional theshold column is functional selected.
 */
void
03987 GuiDisplayControlDialog::volumeFunctionalThresholdSelection(int n)
{
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   dsv->setSelectedFunctionalVolumeThreshold(n);
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
   updateVolumeToolTips();
}

/**
 * Called when a volume paint column is selected.
 */
void
04000 GuiDisplayControlDialog::volumePaintSelection(int n)
{
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   dsv->setSelectedPaintVolume(n);
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
   updateVolumeToolTips();
}

/**
 * Called when a volume rgb column is selected.
 */
void
04013 GuiDisplayControlDialog::volumeRgbSelection(int n)
{
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   dsv->setSelectedRgbVolume(n);
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
   updateVolumeToolTips();
}

/**
 * Called when a volume segmentation column is selected.
 */
void
04026 GuiDisplayControlDialog::volumeSegmentationSelection(int n)
{
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   dsv->setSelectedSegmentationVolume(n);
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
   updateVolumeToolTips();
}

/**
 * Called when a volume vector column is selected.
 */
void
04039 GuiDisplayControlDialog::volumeVectorSelection(int n)
{
   DisplaySettingsVolume* dsv = theMainWindow->getBrainSet()->getDisplaySettingsVolume();
   dsv->setSelectedVectorVolume(n);
   GuiBrainModelOpenGL::updateAllGL();
   GuiToolBar::updateAllToolBars(false);
   updateVolumeToolTips();
}

/**
 * Create the contour main page
 */
void
04052 GuiDisplayControlDialog::createContourClassPage()
{
   //
   // Vertical Box Layout for all contour items
   //
   pageContourClass = new QWidget;
   contourSubPageClassLayout = new QVBoxLayout(pageContourClass);
   
   //
   // All off and all on pushbuttons
   //
   QPushButton* contourClassAllOnButton = new QPushButton("All On");
   contourClassAllOnButton->setAutoDefault(false);
   QObject::connect(contourClassAllOnButton, SIGNAL(clicked()),
                    this, SLOT(contourCellClassAllOn()));
   QPushButton* contourClassAllOffButton = new QPushButton("All Off");
   contourClassAllOffButton->setAutoDefault(false);
   QObject::connect(contourClassAllOffButton, SIGNAL(clicked()),
                    this, SLOT(contourCellClassAllOff()));
   QHBoxLayout* allOnOffLayout = new QHBoxLayout;
   allOnOffLayout->addWidget(contourClassAllOnButton);
   allOnOffLayout->addWidget(contourClassAllOffButton);
   allOnOffLayout->addStretch();
   contourSubPageClassLayout->addLayout(allOnOffLayout);
   
   createAndUpdateContourCellClassCheckBoxes();

   pageWidgetStack->addWidget(pageContourClass);
}

/**
 * Create and update contour class checkboxes.  Because the number of contour cells may change,
 * this method may update and change the label on existing checkboxes, add new 
 * checkboxes, and hide existing checkboxes if the number of checkboxes is greater
 * than the number of contour cell classes.
 */
void
04089 GuiDisplayControlDialog::createAndUpdateContourCellClassCheckBoxes()
{
   ContourCellFile* cf = theMainWindow->getBrainSet()->getContourCellFile();
   numValidContourCellClasses = cf->getNumberOfCellClasses();
   
   const int numExistingCheckBoxes = static_cast<int>(contourCellClassCheckBoxes.size());
   
   if (contourCellClassGridLayout == NULL) {
      //
      // Scroll View for contour cell color checkboxes
      //
      QWidget* classWidget = new QWidget; 
      contourCellClassGridLayout = new QGridLayout(classWidget);
      const int rowStretchNumber    = 15000;
      contourCellClassGridLayout->addWidget(new QLabel(""),
                                           rowStretchNumber, 0, Qt::AlignLeft);
      contourCellClassGridLayout->setRowStretch(rowStretchNumber, 1000);
      
      contourSubPageClassLayout->addWidget(classWidget);
   }
   
   if (contourCellClassButtonGroup == NULL) {
      contourCellClassButtonGroup = new QButtonGroup(this);
      contourCellClassButtonGroup->setExclusive(false);
      QObject::connect(contourCellClassButtonGroup, SIGNAL(buttonClicked(int)),
                       this, SLOT(readContourClassPage()));
   }
   
   //
   // Update exising checkboxes
   //
   for (int i = 0; i < numExistingCheckBoxes; i++) {
      if (i < numValidContourCellClasses) {
         contourCellClassCheckBoxes[i]->setText(cf->getCellClassNameByIndex(i));
         contourCellClassCheckBoxes[i]->show();
      }
   }
   
   //
   // Add new checkboxes as needed
   //
   for (int j = numExistingCheckBoxes; j < numValidContourCellClasses; j++) {
      QCheckBox* cb = new QCheckBox(cf->getCellClassNameByIndex(j));
      contourCellClassCheckBoxes.push_back(cb);
      contourCellClassButtonGroup->addButton(cb, j);
      contourCellClassGridLayout->addWidget(cb, j, 0, 1, 1, Qt::AlignLeft);
      cb->show();
   }
   
   //
   // Hide existing checkboxes that are not needed.
   //
   for (int k = numValidContourCellClasses; k < numExistingCheckBoxes; k++) {
      contourCellClassCheckBoxes[k]->hide();
   }
}

/**
 * This slot is called when the contour class all on button is pressed.
 */
void
04150 GuiDisplayControlDialog::contourCellClassAllOn()
{
   ContourCellFile* cf = theMainWindow->getBrainSet()->getContourCellFile();
   if (cf != NULL) {
      cf->setAllCellClassStatus(true);
   }
   updateContourItems();
   readContourClassPage();
}

/**
 * This slot is called when the contour class all off button is pressed.
 */
void
04164 GuiDisplayControlDialog::contourCellClassAllOff()
{
   ContourCellFile* cf = theMainWindow->getBrainSet()->getContourCellFile();
   if (cf != NULL) {
      cf->setAllCellClassStatus(false);
   }
   updateContourItems();
   readContourClassPage();
}


/**
 * Create the contour main page
 */
void
04179 GuiDisplayControlDialog::createContourColorPage()
{
   //
   // Vertical Box Layout for all contour items
   //
   pageContourColor = new QWidget;
   contourSubPageColorLayout = new QVBoxLayout(pageContourColor);
   
   //
   // All off and all on pushbuttons
   //
   QPushButton* contourColorAllOnButton = new QPushButton("All On");
   contourColorAllOnButton->setAutoDefault(false);
   QObject::connect(contourColorAllOnButton, SIGNAL(clicked()),
                    this, SLOT(contourCellColorAllOn()));
   QPushButton* contourColorAllOffButton = new QPushButton("All Off");
   contourColorAllOffButton->setAutoDefault(false);
   QObject::connect(contourColorAllOffButton, SIGNAL(clicked()),
                    this, SLOT(contourCellColorAllOff()));
   QHBoxLayout* allOnOffLayout = new QHBoxLayout;
   allOnOffLayout->addWidget(contourColorAllOnButton);
   allOnOffLayout->addWidget(contourColorAllOffButton);
   allOnOffLayout->addStretch();
   contourSubPageColorLayout->addLayout(allOnOffLayout);
   
   createAndUpdateContourCellColorCheckBoxes();

   pageWidgetStack->addWidget(pageContourColor);
}

/**
 * Create and update contour color checkboxes.  Because the number of colors may change,
 * this method may update and change the label on existing checkboxes, add new 
 * checkboxes, and hide existing checkboxes if the number of checkboxes is greater
 * than the number of contour cell colors.
 */
void
04216 GuiDisplayControlDialog::createAndUpdateContourCellColorCheckBoxes()
{
   ContourCellColorFile* contourCellColors = theMainWindow->getBrainSet()->getContourCellColorFile();
   numValidContourCellColors = contourCellColors->getNumberOfColors();
   
   const int numExistingCheckBoxes = static_cast<int>(contourCellColorCheckBoxes.size());
   
   if (contourCellColorGridLayout == NULL) {
      QWidget* colorWidget = new QWidget; 
      contourCellColorGridLayout = new QGridLayout(colorWidget);
      const int rowStretchNumber    = 15000;
      contourCellColorGridLayout->addWidget(new QLabel(""),
                                           rowStretchNumber, 0, Qt::AlignLeft);
      contourCellColorGridLayout->setRowStretch(rowStretchNumber, 1000);
      
      contourSubPageColorLayout->addWidget(colorWidget);
   }
   
   if (contourCellColorButtonGroup == NULL) {
      contourCellColorButtonGroup = new QButtonGroup(this);
      contourCellColorButtonGroup->setExclusive(false);
      QObject::connect(contourCellColorButtonGroup, SIGNAL(buttonClicked(int)),
                       this, SLOT(readContourColorPage()));
   }
   
   //
   // Update exising checkboxes
   //
   for (int i = 0; i < numExistingCheckBoxes; i++) {
      if (i < numValidContourCellColors) {
         contourCellColorCheckBoxes[i]->setText(contourCellColors->getColorNameByIndex(i));
         contourCellColorCheckBoxes[i]->show();
      }
   }
   
   //
   // Add new checkboxes as needed
   //
   for (int j = numExistingCheckBoxes; j < numValidContourCellColors; j++) {
      QCheckBox* cb = new QCheckBox(contourCellColors->getColorNameByIndex(j));
      contourCellColorCheckBoxes.push_back(cb);
      contourCellColorButtonGroup->addButton(cb, j);
      contourCellColorGridLayout->addWidget(cb, j, 0, 1, 1, Qt::AlignLeft);
      cb->show();
   }
   
   //
   // Hide existing checkboxes that are not needed.
   //
   for (int k = numValidContourCellColors; k < numExistingCheckBoxes; k++) {
      contourCellColorCheckBoxes[k]->hide();
   }
}

/**
 * This slot is called when the contour cell color all on button is pressed.
 */
void
04274 GuiDisplayControlDialog::contourCellColorAllOn()
{
   ContourCellColorFile* contourCellColors = theMainWindow->getBrainSet()->getContourCellColorFile();
   contourCellColors->setAllSelectedStatus(true);
   updateContourItems();
   readContourColorPage();
}

/**
 * This slot is called when the contour color all off button is pressed.
 */
void
04286 GuiDisplayControlDialog::contourCellColorAllOff()
{
   ContourCellColorFile* contourCellColors = theMainWindow->getBrainSet()->getContourCellColorFile();
   contourCellColors->setAllSelectedStatus(false);
   updateContourItems();
   readContourColorPage();
}

/**
 * Create the contour main page
 */
void
04298 GuiDisplayControlDialog::createContourMainPage()
{
   //
   // origin cross
   //
   contourOriginCrossCheckBox = new QCheckBox("Show Cross at Origin");
   QObject::connect(contourOriginCrossCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readContourMainPage()));
                    
   //
   // draw as lines check box
   //
   QLabel* drawModeLabel = new QLabel("Draw Mode ");
   contourDrawModeComboBox = new QComboBox;
   contourDrawModeComboBox->insertItem(DisplaySettingsContours::DRAW_MODE_POINTS, "Points");
   contourDrawModeComboBox->insertItem(DisplaySettingsContours::DRAW_MODE_LINES, "Lines");
   contourDrawModeComboBox->insertItem(DisplaySettingsContours::DRAW_MODE_POINTS_AND_LINES, "Points and Lines");
   QObject::connect(contourDrawModeComboBox, SIGNAL(activated(int)),
                    this, SLOT(readContourMainPage()));
   QHBoxLayout* drawModeLayout = new QHBoxLayout;
   drawModeLayout->addWidget(drawModeLabel);
   drawModeLayout->addWidget(contourDrawModeComboBox);
   drawModeLayout->addStretch();
   
   //
   // Show end points check box
   //
   contourShowEndPointsCheckBox = new QCheckBox("Show First Point In Each Contour In Red");
   QObject::connect(contourShowEndPointsCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readContourMainPage()));
                                        
   //
   // point size
   //
   QLabel* pointSizeLabel = new QLabel("Point Size");
   contourPointSizeSpinBox = new QDoubleSpinBox;
   contourPointSizeSpinBox->setMinimum(0.5);
   contourPointSizeSpinBox->setMaximum(20.0);
   contourPointSizeSpinBox->setSingleStep(1.0);
   contourPointSizeSpinBox->setDecimals(2);
   QObject::connect(contourPointSizeSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readContourMainPage()));
   QHBoxLayout* pointSizeLayout = new QHBoxLayout;
   pointSizeLayout->addWidget(pointSizeLabel);
   pointSizeLayout->addWidget(contourPointSizeSpinBox);
   pointSizeLayout->addStretch();
   
   //
   // line size
   //
   QLabel* lineSizeLabel = new QLabel("Line Size");
   contourLineThicknessSpinBox = new QDoubleSpinBox;
   contourLineThicknessSpinBox->setMinimum(0.5);
   contourLineThicknessSpinBox->setMaximum(20.0);
   contourLineThicknessSpinBox->setSingleStep(1.0);
   contourLineThicknessSpinBox->setDecimals(2);
   QObject::connect(contourLineThicknessSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readContourMainPage()));
   QHBoxLayout* lineSizeLayout = new QHBoxLayout;
   lineSizeLayout->addWidget(lineSizeLabel);
   lineSizeLayout->addWidget(contourLineThicknessSpinBox);
   lineSizeLayout->addStretch();
   
   //
   // Show Contour Cells check box
   //
   contourShowCellsCheckBox = new QCheckBox("Show Contour Cells");
   QObject::connect(contourShowCellsCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readContourMainPage()));
                    
   //
   // Contour Cell Size
   //
   QLabel* cellSizeLabel = new QLabel("Cell Size ");
   contourCellSizeSpinBox = new QSpinBox;
   contourCellSizeSpinBox->setMinimum(1);
   contourCellSizeSpinBox->setMaximum(10);
   contourCellSizeSpinBox->setSingleStep(1);
   QObject::connect(contourCellSizeSpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readContourMainPage()));
   QHBoxLayout* cellSizeLayout = new QHBoxLayout;
   cellSizeLayout->addWidget(cellSizeLabel);
   cellSizeLayout->addWidget(contourCellSizeSpinBox);
   cellSizeLayout->addStretch();

   //
   // Widget for Contour items
   //
   pageContourMain = new QWidget;
   QVBoxLayout* contourMainPageLayout = new QVBoxLayout(pageContourMain);
   contourMainPageLayout->addWidget(contourOriginCrossCheckBox);
   contourMainPageLayout->addLayout(drawModeLayout);
   contourMainPageLayout->addLayout(pointSizeLayout);
   contourMainPageLayout->addLayout(lineSizeLayout);
   contourMainPageLayout->addWidget(contourShowEndPointsCheckBox);
   contourMainPageLayout->addWidget(contourShowCellsCheckBox);
   contourMainPageLayout->addLayout(cellSizeLayout);
   contourMainPageLayout->addStretch();

   pageWidgetStack->addWidget(pageContourMain);
}

/**
 * read the contour main page.
 */
void 
04404 GuiDisplayControlDialog::readContourMainPage()
{
   if (creatingDialog) {
      return;
   }
   if (pageContourMain == NULL) {
      return;
   }
   DisplaySettingsContours* dsc = theMainWindow->getBrainSet()->getDisplaySettingsContours();
   
   dsc->setDisplayCrossAtOrigin(contourOriginCrossCheckBox->isChecked());
   dsc->setDrawMode(static_cast<DisplaySettingsContours::DRAW_MODE>(contourDrawModeComboBox->currentIndex()));
   dsc->setShowEndPoints(contourShowEndPointsCheckBox->isChecked());
   dsc->setPointSize(contourPointSizeSpinBox->value());
   dsc->setLineThickness(contourLineThicknessSpinBox->value());
   dsc->setDisplayContourCells(contourShowCellsCheckBox->isChecked());
   dsc->setContourCellSize(contourCellSizeSpinBox->value());
   dsc->determineDisplayedContourCells();   
   GuiBrainModelOpenGL::updateAllGL(NULL);   
}

/**
 * read the contour class page.
 */
void 
04429 GuiDisplayControlDialog::readContourClassPage()
{
   if (creatingDialog) {
      return;
   }
   if (pageContourClass == NULL) {
      return;
   }
   ContourCellFile* cellFile = theMainWindow->getBrainSet()->getContourCellFile();
   const int numClasses = cellFile->getNumberOfCellClasses();
   if (numClasses == numValidContourCellClasses) {
      for (int i = 0; i < numValidContourCellClasses; i++) {
         cellFile->setCellClassSelectedByIndex(i, contourCellClassCheckBoxes[i]->isChecked());
      }
   }
   else {
      std::cerr << "Number of contour cell class checkboxes does not equal number of contour cell classes."
                << std::endl;
   }
   DisplaySettingsContours* dsc = theMainWindow->getBrainSet()->getDisplaySettingsContours();
   dsc->determineDisplayedContourCells();   
   GuiBrainModelOpenGL::updateAllGL(NULL);   
}

/**
 * read the contour color page.
 */
void 
04457 GuiDisplayControlDialog::readContourColorPage()
{
   if (creatingDialog) {
      return;
   }
   if (pageContourColor == NULL) {
      return;
   }
   ContourCellColorFile* contourCellColors = theMainWindow->getBrainSet()->getContourCellColorFile();
   const int numColors = contourCellColors->getNumberOfColors();
   if (numColors == numValidContourCellColors) {
      for (int i = 0; i < numValidContourCellColors; i++) {
         contourCellColors->setSelected(i, contourCellColorCheckBoxes[i]->isChecked());
      }
   }
   else {
      std::cerr << "Number of contour cell color checkboxes does not equal number of contour cell classes."
                << std::endl;
   }
   DisplaySettingsContours* dsc = theMainWindow->getBrainSet()->getDisplaySettingsContours();
   dsc->determineDisplayedContourCells();   
   GuiBrainModelOpenGL::updateAllGL(NULL);   
}
      
/**
 * update all contour main page in dialog.
 */
void 
04485 GuiDisplayControlDialog::updateContourMainPage()
{   
   if (pageContourMain == NULL) {
      return;
   }
   pageContourMain->setEnabled(validContourData);

   DisplaySettingsContours* dsc = theMainWindow->getBrainSet()->getDisplaySettingsContours();   
   contourOriginCrossCheckBox->setChecked(dsc->getDisplayCrossAtOrigin());
   contourDrawModeComboBox->setCurrentIndex(dsc->getDrawMode());
   contourShowEndPointsCheckBox->setChecked(dsc->getShowEndPoints());
   contourPointSizeSpinBox->setValue(dsc->getPointSize());
   contourLineThicknessSpinBox->setValue(dsc->getLineThickness());
   contourShowCellsCheckBox->setChecked(dsc->getDisplayContourCells());
   contourCellSizeSpinBox->setValue(static_cast<int>(dsc->getContourCellSize()));
}

/**
 * update all contour class page in dialog.
 */
void 
04506 GuiDisplayControlDialog::updateContourClassPage(const bool filesChanged)
{
   if (pageContourClass == NULL) {
      return;
   }
   pageContourClass->setEnabled(validContourData);

   if (filesChanged) {
      createAndUpdateContourCellClassCheckBoxes();
   }
   ContourCellFile* contourCellFile = theMainWindow->getBrainSet()->getContourCellFile();   
   const int numClasses = contourCellFile->getNumberOfCellClasses();
   if (numClasses == numValidContourCellClasses) {
      for (int i = 0; i < numValidContourCellClasses; i++) {
         contourCellClassCheckBoxes[i]->setChecked(contourCellFile->getCellClassSelectedByIndex(i));
      }
   }
   else {
      std::cerr << "Number of contour cell class checkboxes does not equal number of contour cell classes."
                << std::endl;
   }
}

/**
 * update all contour color page in dialog.
 */
void 
04533 GuiDisplayControlDialog::updateContourColorPage(const bool filesChanged)
{
   if (pageContourColor == NULL) {
      return;
   }
   pageContourColor->setEnabled(validContourData);
   
   if (filesChanged) {
      createAndUpdateContourCellColorCheckBoxes();
   }
   ContourCellColorFile* contourCellColorFile = theMainWindow->getBrainSet()->getContourCellColorFile();
   const int numColors = contourCellColorFile->getNumberOfColors();
   if (numColors == numValidContourCellColors) {
      for (int i = 0; i < numValidContourCellColors; i++) {
         contourCellColorCheckBoxes[i]->setChecked(contourCellColorFile->getSelected(i));
      }
   }
   else {
      std::cerr << "Number of contour cell color checkboxes does not equal number of contour cell colors."
                << std::endl;
   }
}
      
/**
 * Update the contour items
 */
void
04560 GuiDisplayControlDialog::updateContourItems(const bool filesChanged)
{
   updatePageSelectionComboBox();

   updateContourMainPage();
   updateContourClassPage(filesChanged);
   updateContourColorPage(filesChanged);
}

/**
 * Create the CoCoMac Display control sub page.
 */
void
04573 GuiDisplayControlDialog::createCocomacDisplayPage()
{
   //
   // Connection radio buttons
   //
   cocomacAfferentRadioButton = new QRadioButton("Afferent");
   cocomacEfferentRadioButton = new QRadioButton("Efferent");
   cocomacAfferentAndEfferentRadioButton = new QRadioButton("Afferent and Efferent");
   cocomacAfferentOrEfferentRadioButton = new QRadioButton("Afferent or Efferent");
   
   //
   // button group for connection display type
   //
   QButtonGroup* connBG = new QButtonGroup(this); 
   QObject::connect(connBG, SIGNAL(buttonClicked(int)),
                    this, SLOT(readCocomacDisplayPage()));
   connBG->addButton(cocomacAfferentRadioButton);
   connBG->addButton(cocomacEfferentRadioButton);
   connBG->addButton(cocomacAfferentAndEfferentRadioButton);
   connBG->addButton(cocomacAfferentOrEfferentRadioButton);
   
   //
   // Group box and layout for connection type buttons
   //
   QGroupBox* connGroupBox = new QGroupBox("View Connection");
   QVBoxLayout* connGroupLayout = new QVBoxLayout(connGroupBox);
   connGroupLayout->addWidget(cocomacAfferentRadioButton);
   connGroupLayout->addWidget(cocomacEfferentRadioButton);
   connGroupLayout->addWidget(cocomacAfferentAndEfferentRadioButton);
   connGroupLayout->addWidget(cocomacAfferentOrEfferentRadioButton);
   
   //
   // Paint column label and combo box
   //
   QLabel* paintLabel = new QLabel("Paint Column ");
   cocomacPaintColumnComboBox = new QComboBox;
   cocomacPaintColumnComboBox->setMinimumWidth(400);
   QObject::connect(cocomacPaintColumnComboBox, SIGNAL(activated(int)),
                    this, SLOT(readCocomacDisplayPage()));
   QHBoxLayout* paintLayout = new QHBoxLayout;
   paintLayout->addWidget(paintLabel);
   paintLayout->addWidget(cocomacPaintColumnComboBox);
   paintLayout->setStretchFactor(paintLabel, 0);
   paintLayout->setStretchFactor(cocomacPaintColumnComboBox, 100);

   //
   // Create the page and layout its widgets
   //
   pageCocomacDisplay = new QWidget; 
   QVBoxLayout* cocoLayout = new QVBoxLayout(pageCocomacDisplay);
   cocoLayout->addWidget(connGroupBox);
   cocoLayout->addLayout(paintLayout);
   cocoLayout->addStretch();

   pageWidgetStack->addWidget(pageCocomacDisplay);
}

/**
 * Create the CoCoMac File Info sub page.
 */
void
04634 GuiDisplayControlDialog::createCocomacFileInformationPage()
{
   //
   // CoCoMac version label
   //
   QString spaces("                                                                           ");
   cocomacVersionLabel = new QLabel(spaces);
   
   //
   // CoCoMac export date
   //
   cocomacExportDate = new QLabel(spaces);
   
   //
   //  CoCoMac data type
   //
   cocomacDataType = new QLabel(spaces);
   
   //
   // comments text area
   //
   cocomacCommentsTextEdit = new QTextEdit;
   cocomacCommentsTextEdit->setFixedSize(QSize(500, 150));
   
   //
   // Projections text area
   //
   cocomacProjectionsTextEdit = new QTextEdit;
   cocomacProjectionsTextEdit->setFixedSize(QSize(500, 300));
   
   //
   // Page and layout
   //
   pageCocomacInformation = new QWidget;
   QVBoxLayout* cocoLayout = new QVBoxLayout(pageCocomacInformation);
   cocoLayout->addWidget(cocomacVersionLabel);
   cocoLayout->addWidget(cocomacExportDate);
   cocoLayout->addWidget(cocomacDataType);
   cocoLayout->addWidget(cocomacCommentsTextEdit);
   cocoLayout->addWidget(cocomacProjectionsTextEdit);
   cocoLayout->addStretch();

   pageWidgetStack->addWidget(pageCocomacInformation);
}

/**
 * Read the CoCoMac selections.
 */
void
04683 GuiDisplayControlDialog::readCocomacDisplayPage()
{
   if (pageCocomacDisplay == NULL) {
      return;
   }
   DisplaySettingsCoCoMac* dsc = theMainWindow->getBrainSet()->getDisplaySettingsCoCoMac();
   
   if (cocomacAfferentRadioButton->isChecked()) {
      dsc->setConnectionDisplayType(DisplaySettingsCoCoMac::CONNECTION_DISPLAY_AFFERENT);
   }
   else if (cocomacEfferentRadioButton->isChecked()) {
      dsc->setConnectionDisplayType(DisplaySettingsCoCoMac::CONNECTION_DISPLAY_EFFERENT);
   }
   else if (cocomacAfferentAndEfferentRadioButton->isChecked()) {
      dsc->setConnectionDisplayType(DisplaySettingsCoCoMac::CONNECTION_DISPLAY_AFFERENT_AND_EFFERENT);
   }
   else if (cocomacAfferentOrEfferentRadioButton->isChecked()) {
      dsc->setConnectionDisplayType(DisplaySettingsCoCoMac::CONNECTION_DISPLAY_AFFERENT_OR_EFFERENT);
   }
   
   dsc->setSelectedPaintColumn(cocomacPaintColumnComboBox->currentIndex());
}

/**
 * update the cocomac display page.
 */
void 
04710 GuiDisplayControlDialog::updateCocomacDisplayPage()
{
   if (pageCocomacDisplay == NULL) {
      return;
   }
   DisplaySettingsCoCoMac* dsc = theMainWindow->getBrainSet()->getDisplaySettingsCoCoMac();
   CocomacConnectivityFile* cocomacFile = theMainWindow->getBrainSet()->getCocomacFile();
   
   switch(dsc->getConnectionDisplayType()) {
      case DisplaySettingsCoCoMac::CONNECTION_DISPLAY_AFFERENT:
         cocomacAfferentRadioButton->setChecked(true);
         break;
      case DisplaySettingsCoCoMac::CONNECTION_DISPLAY_EFFERENT:
         cocomacEfferentRadioButton->setChecked(true);
         break;
      case DisplaySettingsCoCoMac::CONNECTION_DISPLAY_AFFERENT_AND_EFFERENT:
         cocomacAfferentAndEfferentRadioButton->setChecked(true);
         break;
      case DisplaySettingsCoCoMac::CONNECTION_DISPLAY_AFFERENT_OR_EFFERENT:
         cocomacAfferentOrEfferentRadioButton->setChecked(true);
         break;
   }
   
   cocomacPaintColumnComboBox->clear();
   PaintFile* pf = theMainWindow->getBrainSet()->getPaintFile();
   for (int i = 0; i < pf->getNumberOfColumns(); i++) {
      cocomacPaintColumnComboBox->addItem(pf->getColumnName(i));
   }
   
   if (cocomacPaintColumnComboBox->count() > 0) {
      int num = dsc->getSelectedPaintColumn();
      if (num >= cocomacPaintColumnComboBox->count()) {
         num = 0;
         dsc->setSelectedPaintColumn(num);
      }
      cocomacPaintColumnComboBox->setCurrentIndex(num);
   }
   
   pageCocomacDisplay->setEnabled(cocomacFile->empty() == false);
}

/**
 * update the cocomac information page.
 */
void 
04755 GuiDisplayControlDialog::updateCocomacInformationPage()
{
   if (pageCocomacInformation == NULL) {
      return;
   }
   CocomacConnectivityFile* cocomacFile = theMainWindow->getBrainSet()->getCocomacFile();
   QString version("Version: ");
   version.append(cocomacFile->getVersion());
   cocomacVersionLabel->setText(version);
   
   QString exportDate("Export Date: ");
   exportDate.append(cocomacFile->getExportDate());
   cocomacExportDate->setText(exportDate);
   
   QString dataType("Data Type: ");
   dataType.append(cocomacFile->getDataType());
   cocomacDataType->setText(dataType);
   
   cocomacCommentsTextEdit->setPlainText(cocomacFile->getComments());
   
   QString projections;
   const int numProj = cocomacFile->getNumberOfCocomacProjections();
   for (int i = 0; i < numProj; i++) {
      CocomacProjection* proj = cocomacFile->getCocomacProjection(i);
      projections.append(proj->getSourceSite());
      projections.append(" ");
      projections.append(proj->getDensity());
      projections.append(" ");
      projections.append(proj->getTargetSite());
      projections.append("\n");
   }
   cocomacProjectionsTextEdit->setPlainText(projections);
   
   pageCocomacInformation->setEnabled(cocomacFile->empty() == false);
}

/**
 * Update the CoCoMac items in the dialog.
 */
void
04795 GuiDisplayControlDialog::updateCocomacItems()
{
   updatePageSelectionComboBox();

   updateCocomacDisplayPage();
   updateCocomacInformationPage();
}

/**
 * Create the surface and volume page
 */
void
04807 GuiDisplayControlDialog::createSurfaceAndVolumePage()
{
   //
   // Show surface check box
   //
   surfaceAndVolumeShowSurfaceCheckBox = new QCheckBox("Show Surface");
   QObject::connect(surfaceAndVolumeShowSurfaceCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
                                                       
   //
   // Group box for surface control
   //
   QGroupBox* surfaceGroupBox = new QGroupBox("Surface");
   QVBoxLayout* surfaceGroupLayout =  new QVBoxLayout(surfaceGroupBox);
   surfaceGroupLayout->addWidget(surfaceAndVolumeShowSurfaceCheckBox);
   surfaceGroupBox->setFixedSize(surfaceGroupBox->sizeHint());
   
   //
   // check box and spin box for horizontal slice
   //
   surfaceAndVolumeHorizontalSliceCheckBox = new QCheckBox("Horizontal Slice");
   QObject::connect(surfaceAndVolumeHorizontalSliceCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   surfaceAndVolumeHorizontalSliceSpinBox = new QSpinBox;
   surfaceAndVolumeHorizontalSliceSpinBox->setMinimum(1);
   surfaceAndVolumeHorizontalSliceSpinBox->setMaximum(10000);
   surfaceAndVolumeHorizontalSliceSpinBox->setSingleStep(1); 
   QObject::connect(surfaceAndVolumeHorizontalSliceSpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
    
   //
   // check box and spin box for parasagittal slice
   //
   surfaceAndVolumeParasagittalSliceCheckBox = new QCheckBox("Parasagittal Slice");
   QObject::connect(surfaceAndVolumeParasagittalSliceCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   surfaceAndVolumeParasagittalSliceSpinBox = new QSpinBox;
   surfaceAndVolumeParasagittalSliceSpinBox->setMinimum(1);
   surfaceAndVolumeParasagittalSliceSpinBox->setMaximum(10000);
   surfaceAndVolumeParasagittalSliceSpinBox->setSingleStep(1); 
   QObject::connect(surfaceAndVolumeParasagittalSliceSpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
    
   //
   // check box and spin box for coronal slice
   //
   surfaceAndVolumeCoronalSliceCheckBox = new QCheckBox("Coronal Slice");
   QObject::connect(surfaceAndVolumeCoronalSliceCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   surfaceAndVolumeCoronalSliceSpinBox = new QSpinBox;
   surfaceAndVolumeCoronalSliceSpinBox->setMinimum(1);
   surfaceAndVolumeCoronalSliceSpinBox->setMaximum(10000);
   surfaceAndVolumeCoronalSliceSpinBox->setSingleStep(1); 
   QObject::connect(surfaceAndVolumeCoronalSliceSpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
    
   surfaceAndVolumeAnatomyBlackCheckBox = new QCheckBox("Draw Black Voxels");
   QObject::connect(surfaceAndVolumeAnatomyBlackCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
                                                        
   //
   // Group box for anatomical slices
   //
   QGroupBox* anatomyGroupBox = new QGroupBox("Anatomy Volume");
   QGridLayout* anatomyGridLayout = new QGridLayout(anatomyGroupBox);
   anatomyGridLayout->addWidget(surfaceAndVolumeHorizontalSliceCheckBox, 0, 0);
   anatomyGridLayout->addWidget(surfaceAndVolumeHorizontalSliceSpinBox, 0, 1);
   anatomyGridLayout->addWidget(surfaceAndVolumeParasagittalSliceCheckBox, 1, 0);
   anatomyGridLayout->addWidget(surfaceAndVolumeParasagittalSliceSpinBox, 1, 1);
   anatomyGridLayout->addWidget(surfaceAndVolumeCoronalSliceCheckBox, 2, 0);
   anatomyGridLayout->addWidget(surfaceAndVolumeCoronalSliceSpinBox, 2, 1);
   anatomyGridLayout->addWidget(surfaceAndVolumeAnatomyBlackCheckBox, 3, 0);
   anatomyGroupBox->setFixedSize(anatomyGroupBox->sizeHint());
   
   
   //
   // show primary overlay on slices
   //
   surfaceAndVolumeShowPrimaryCheckBox = new QCheckBox("Show Primary Overlay");
   QObject::connect(surfaceAndVolumeShowPrimaryCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   
   //
   // show secondary overlay on slices
   //
   surfaceAndVolumeShowSecondaryCheckBox = new QCheckBox("Show Secondary Overlay");
   QObject::connect(surfaceAndVolumeShowSecondaryCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));

   //
   // Group box for overlay volume control
   //
   QGroupBox* surfaceAndVolumeOverlaysGroupBox = new QGroupBox("Volume Overlays");
   QVBoxLayout* surfaceAndVolumeOverlaysGroupBoxLayout = new QVBoxLayout(surfaceAndVolumeOverlaysGroupBox);
   surfaceAndVolumeOverlaysGroupBoxLayout->addWidget(surfaceAndVolumeShowPrimaryCheckBox);
   surfaceAndVolumeOverlaysGroupBoxLayout->addWidget(surfaceAndVolumeShowSecondaryCheckBox);
   surfaceAndVolumeOverlaysGroupBox->setFixedSize(surfaceAndVolumeOverlaysGroupBox->sizeHint());

   
  
   //
   // Show functional data cloud checkbox
   //
   surfaceAndVolumeShowFunctionalCloudCheckBox = new QCheckBox("Show Volume Cloud");
   QObject::connect(surfaceAndVolumeShowFunctionalCloudCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   
   //
   // Functional data cloud opacity check box and spin box
   //
   surfaceAndVolumeFunctionalCloudOpacityCheckBox = new QCheckBox("Opacity");
   QObject::connect(surfaceAndVolumeFunctionalCloudOpacityCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   surfaceAndVolumeFunctionalCloudOpacitySpinBox = new QDoubleSpinBox;
   surfaceAndVolumeFunctionalCloudOpacitySpinBox->setMinimum(0.0);
   surfaceAndVolumeFunctionalCloudOpacitySpinBox->setMaximum(1.0);
   surfaceAndVolumeFunctionalCloudOpacitySpinBox->setSingleStep(0.05);
   surfaceAndVolumeFunctionalCloudOpacitySpinBox->setDecimals(3);
   QObject::connect(surfaceAndVolumeFunctionalCloudOpacitySpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   QHBoxLayout* functionalVolumeLayout = new QHBoxLayout;
   functionalVolumeLayout->addWidget(surfaceAndVolumeFunctionalCloudOpacityCheckBox);
   functionalVolumeLayout->addWidget(surfaceAndVolumeFunctionalCloudOpacitySpinBox);
   
   //
   // Group box for functional volume control
   //
   surfaceAndVolumeFunctionalGroupBox = new QGroupBox("Functional Volume");
   QVBoxLayout* surfaceAndVolumeFunctionalGroupLayout = new QVBoxLayout(surfaceAndVolumeFunctionalGroupBox);
   surfaceAndVolumeFunctionalGroupLayout->addWidget(surfaceAndVolumeShowFunctionalCloudCheckBox);
   surfaceAndVolumeFunctionalGroupLayout->addLayout(functionalVolumeLayout);


   //
   // Distance threshold
   //
   surfaceAndVolumeFunctionalDistanceSpinBox = new QDoubleSpinBox;
   surfaceAndVolumeFunctionalDistanceSpinBox->setMinimum(0.0);
   surfaceAndVolumeFunctionalDistanceSpinBox->setMaximum(1000.0);
   surfaceAndVolumeFunctionalDistanceSpinBox->setSingleStep(10.0);
   surfaceAndVolumeFunctionalDistanceSpinBox->setDecimals(1);
   QObject::connect(surfaceAndVolumeFunctionalDistanceSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   surfaceAndVolumeFunctionalGroupBox->setFixedSize(surfaceAndVolumeFunctionalGroupBox->sizeHint());
   QGroupBox* distanceGroupBox = new QGroupBox("Distance Threshold");
   QVBoxLayout* distanceGroupLayout = new QVBoxLayout(distanceGroupBox);
   distanceGroupLayout->addWidget(surfaceAndVolumeFunctionalDistanceSpinBox);
   distanceGroupBox->setFixedSize(distanceGroupBox->sizeHint());
   distanceGroupBox->hide();
   
   
   //
   // Show segmentation data cloud checkbox
   //
   surfaceAndVolumeShowSegmentationCloudCheckBox = new QCheckBox("Show Volume Cloud");
   QObject::connect(surfaceAndVolumeShowSegmentationCloudCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   
   //
   // Group box for segmentation volume control
   //
   surfaceAndVolumeSegmentationGroupBox = new QGroupBox("Segmentation Volume");
   QVBoxLayout* surfaceAndVolumeSegmentationGroupLayout = new QVBoxLayout(surfaceAndVolumeSegmentationGroupBox);
   surfaceAndVolumeSegmentationGroupLayout->addWidget(surfaceAndVolumeShowSegmentationCloudCheckBox);
   surfaceAndVolumeSegmentationGroupBox->setFixedSize(surfaceAndVolumeSegmentationGroupBox->sizeHint());
   
   //
   // Show vector data cloud check box
   //
   surfaceAndVolumeShowVectorCloudCheckBox = new QCheckBox("Show Volume Cloud");
   QObject::connect(surfaceAndVolumeShowVectorCloudCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readSurfaceAndVolumeSelections()));
   surfaceAndVolumeVectorVBox = new QGroupBox("Vector Volume");
   QVBoxLayout* surfaceAndVolumeVectorLayout = new QVBoxLayout(surfaceAndVolumeVectorVBox);
   surfaceAndVolumeVectorLayout->addWidget(surfaceAndVolumeShowVectorCloudCheckBox);
   surfaceAndVolumeVectorVBox->setFixedSize(surfaceAndVolumeVectorVBox->sizeHint());

   //
   // Create page ang its layout
   //                    
   pageSurfaceAndVolume = new QWidget;
   pageWidgetStack->addWidget(pageSurfaceAndVolume); //, PAGE_NAME_SURFACE_AND_VOLUME);
   QVBoxLayout* surfaceAndVolumeLayout = new QVBoxLayout(pageSurfaceAndVolume);
   surfaceAndVolumeLayout->addWidget(surfaceGroupBox);
   surfaceAndVolumeLayout->addWidget(anatomyGroupBox);
   surfaceAndVolumeLayout->addWidget(surfaceAndVolumeOverlaysGroupBox);
   surfaceAndVolumeLayout->addWidget(surfaceAndVolumeFunctionalGroupBox);
   surfaceAndVolumeLayout->addWidget(distanceGroupBox);
   surfaceAndVolumeLayout->addWidget(surfaceAndVolumeSegmentationGroupBox);
   surfaceAndVolumeLayout->addWidget(surfaceAndVolumeVectorVBox);
   surfaceAndVolumeLayout->addStretch();
   
   pageSurfaceAndVolumeWidgetGroup = new WuQWidgetGroup(this);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeShowSurfaceCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeHorizontalSliceCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeParasagittalSliceCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeCoronalSliceCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeCoronalSliceSpinBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeAnatomyBlackCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeShowPrimaryCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeShowSecondaryCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeShowFunctionalCloudCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeFunctionalCloudOpacityCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeFunctionalCloudOpacitySpinBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeShowSegmentationCloudCheckBox);
   pageSurfaceAndVolumeWidgetGroup->addWidget(surfaceAndVolumeShowVectorCloudCheckBox);
}

/**
 * Read the selections on the surface and volume page.
 */
void
05019 GuiDisplayControlDialog::readSurfaceAndVolumeSelections()
{
   BrainModelSurfaceAndVolume* bmsv = theMainWindow->getBrainSet()->getBrainModelSurfaceAndVolume();
   if (bmsv != NULL) {
      //
      // Setting the checkboxes of volume slices in "updateSurfaceAndVolumeItems()" 
      // triggers QT signals which then call this method.  So see if items are
      // being updated in the dialog.
      //
      bmsv->setDisplaySurface(surfaceAndVolumeShowSurfaceCheckBox->isChecked());
      
      bmsv->setDisplayHorizontalSlice(surfaceAndVolumeHorizontalSliceCheckBox->isChecked());
      bmsv->setDisplayParasagittalSlice(surfaceAndVolumeParasagittalSliceCheckBox->isChecked());
      bmsv->setDisplayCoronalSlice(surfaceAndVolumeCoronalSliceCheckBox->isChecked());
      
      const int slices[3] = { surfaceAndVolumeParasagittalSliceSpinBox->value(),
                              surfaceAndVolumeCoronalSliceSpinBox->value(),
                              surfaceAndVolumeHorizontalSliceSpinBox->value() };
      bmsv->setSelectedSlices(slices);
      
      bmsv->setDisplayPrimaryOverlayVolumeOnSlices(surfaceAndVolumeShowPrimaryCheckBox->isChecked());
      bmsv->setDisplaySecondaryOverlayVolumeOnSlices(surfaceAndVolumeShowSecondaryCheckBox->isChecked());

      bmsv->setDisplayFunctionalVolumeCloud(surfaceAndVolumeShowFunctionalCloudCheckBox->isChecked());
      bmsv->setFunctionalVolumeCloudOpacityEnabled(surfaceAndVolumeFunctionalCloudOpacityCheckBox->isChecked());
      bmsv->setFunctionalVolumeCloudOpacity(surfaceAndVolumeFunctionalCloudOpacitySpinBox->value());
      bmsv->setFunctionalVolumeDistanceThreshold(surfaceAndVolumeFunctionalDistanceSpinBox->value());
      bmsv->setDisplaySegmentationVolumeCloud(surfaceAndVolumeShowSegmentationCloudCheckBox->isChecked());
      bmsv->setDisplayVectorVolumeCloud(surfaceAndVolumeShowVectorCloudCheckBox->isChecked());
      bmsv->setDrawAnatomyBlackVoxels(surfaceAndVolumeAnatomyBlackCheckBox->isChecked());
   }
   GuiBrainModelOpenGL::updateAllGL();
}

/**
 * update the surface and volume selections.
 */
void 
05057 GuiDisplayControlDialog::updateSurfaceAndVolumeItems()
{
   updatePageSelectionComboBox();
   if (pageSurfaceAndVolume == NULL) {
      return;
   }
   pageSurfaceAndVolumeWidgetGroup->blockSignals(true);
   
   BrainModelSurfaceAndVolume* bmsv = theMainWindow->getBrainSet()->getBrainModelSurfaceAndVolume();
   if (bmsv != NULL) {
      pageSurfaceAndVolume->setEnabled(validSurfaceAndVolumeData);
      
      surfaceAndVolumeShowSurfaceCheckBox->setChecked(bmsv->getDisplaySurface());
      
      surfaceAndVolumeHorizontalSliceCheckBox->setChecked(bmsv->getDisplayHorizontalSlice());
      surfaceAndVolumeParasagittalSliceCheckBox->setChecked(bmsv->getDisplayParasagittalSlice());
      surfaceAndVolumeCoronalSliceCheckBox->setChecked(bmsv->getDisplayCoronalSlice());
      
      int dim[3] = { 0, 0, 0 };
      VolumeFile* anatomyVolumeFile = bmsv->getAnatomyVolumeFile();
      if (anatomyVolumeFile != NULL) {
         anatomyVolumeFile->getDimensions(dim);
      }
      
      surfaceAndVolumeParasagittalSliceSpinBox->setMaximum(dim[0]);
      surfaceAndVolumeCoronalSliceSpinBox->setMaximum(dim[1]);
      surfaceAndVolumeHorizontalSliceSpinBox->setMaximum(dim[2]);

      int slices[3];
      bmsv->getSelectedSlices(slices);
      surfaceAndVolumeParasagittalSliceSpinBox->setValue(slices[0]);
      surfaceAndVolumeCoronalSliceSpinBox->setValue(slices[1]);
      surfaceAndVolumeHorizontalSliceSpinBox->setValue(slices[2]);

      surfaceAndVolumeShowPrimaryCheckBox->setChecked(bmsv->getDisplayPrimaryOverlayVolumeOnSlices());
      surfaceAndVolumeShowSecondaryCheckBox->setChecked(bmsv->getDisplaySecondaryOverlayVolumeOnSlices());
      
      if (bmsv->getFunctionalVolumeFile() != NULL) {
         surfaceAndVolumeFunctionalGroupBox->setEnabled(true);
         surfaceAndVolumeShowFunctionalCloudCheckBox->setChecked(bmsv->getDisplayFunctionalVolumeCloud());
         surfaceAndVolumeFunctionalCloudOpacityCheckBox->setChecked(bmsv->getFunctionalVolumeCloudOpacityEnabled());
         surfaceAndVolumeFunctionalCloudOpacitySpinBox->setValue(bmsv->getFunctionalVolumeCloudOpacity());
      }
      else {
         surfaceAndVolumeFunctionalGroupBox->setEnabled(false);
      }
      surfaceAndVolumeFunctionalDistanceSpinBox->setValue(bmsv->getFunctionalVolumeDistanceThreshold());

      if (bmsv->getSegmentationVolumeFile() != NULL) {
         surfaceAndVolumeSegmentationGroupBox->setEnabled(true);
         surfaceAndVolumeShowSegmentationCloudCheckBox->setChecked(bmsv->getDisplaySegmentationVolumeCloud());
      }
      else {
         surfaceAndVolumeSegmentationGroupBox->setEnabled(false);
      }
      surfaceAndVolumeAnatomyBlackCheckBox->setChecked(bmsv->getDrawAnatomyBlackVoxels());
      
      if (bmsv->getVectorVolumeFile() != NULL) {
         surfaceAndVolumeVectorVBox->setEnabled(true);
         surfaceAndVolumeShowVectorCloudCheckBox->setChecked(bmsv->getDisplayVectorVolumeCloud());
      }
      else {
         surfaceAndVolumeVectorVBox->setEnabled(false);
      }
   }
   else {
      pageSurfaceAndVolume->setEnabled(false);
   }
   
   updatePageSelectionComboBox();
   pageSurfaceAndVolumeWidgetGroup->blockSignals(false);
}      

/**
 * create the surface vector settings page.
 */
void 
05134 GuiDisplayControlDialog::createVectorSettingsPage()
{
   const int spinBoxMaxWidth = 200;

   //
   // Color Mode
   //
   QLabel* colorModeLabel = new QLabel("Coloring Mode");
   vectorColorModeComboBox = new QComboBox;
   vectorColorModeComboBox->insertItem(DisplaySettingsVectors::COLOR_MODE_VECTOR_COLORS,
                                       "Use Vector Colors");
   vectorColorModeComboBox->insertItem(DisplaySettingsVectors::COLOR_MODE_XYZ_AS_RGB,
                                       "Use XYZ as Red, Green, Blue");
   QObject::connect(vectorColorModeComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVectorSettingsPage()));

   //
   // Vector Type
   //
   QLabel* vectorTypeLabel = new QLabel("Vector Type");
   vectorTypeModeComboBox = new QComboBox;
   vectorTypeModeComboBox->insertItem(DisplaySettingsVectors::VECTOR_TYPE_BIDIRECTIONAL,
                                      "Bidirectional");
   vectorTypeModeComboBox->insertItem(DisplaySettingsVectors::VECTOR_TYPE_UNIDIRECTIONAL_ARROW,
                                      "Unidirectional (Arrow)");
   vectorTypeModeComboBox->insertItem(DisplaySettingsVectors::VECTOR_TYPE_UNIDIRECTIONAL_CYLINDER,
                                      "Unidirectional (Cylinder)");
   QObject::connect(vectorTypeModeComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVectorSettingsPage()));

   //
   // Sparse distance spin box
   //
   QLabel* sparseDistanceLabel = new QLabel("Sparse Index Skip");
   vectorSparseDistanceSpinBox = new QSpinBox;
   vectorSparseDistanceSpinBox->setMaximumWidth(spinBoxMaxWidth);
   vectorSparseDistanceSpinBox->setMinimum(0);
   vectorSparseDistanceSpinBox->setMaximum(100000);
   vectorSparseDistanceSpinBox->setSingleStep(1);
   QObject::connect(vectorSparseDistanceSpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readVectorSettingsPage()));
   vectorSparseDistanceSpinBox->setToolTip("Number of indices skipped when \n"
                                           "drawing vectors in a sparse mode.");

   //
   // Length multiplier
   //
   QLabel* lengthLabel = new QLabel("Length Multiplier ");
   vectorLengthMultiplierDoubleSpinBox = new QDoubleSpinBox;
   vectorLengthMultiplierDoubleSpinBox->setMaximumWidth(spinBoxMaxWidth);
   vectorLengthMultiplierDoubleSpinBox->setMinimum(0.0001);
   vectorLengthMultiplierDoubleSpinBox->setMaximum(1000.0);
   vectorLengthMultiplierDoubleSpinBox->setSingleStep(1.0);
   vectorLengthMultiplierDoubleSpinBox->setDecimals(3);
   vectorLengthMultiplierDoubleSpinBox->setValue(1.0);
   QObject::connect(vectorLengthMultiplierDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVectorSettingsPage()));
   vectorLengthMultiplierDoubleSpinBox->setToolTip("Scales the length of\n"
                                                   "vectors for display.");


   //
   // Drawing group box and layout
   //
   QGroupBox* drawingGroupBox = new QGroupBox("Drawing");
   QGridLayout* drawGridLayout = new QGridLayout(drawingGroupBox);
   drawGridLayout->addWidget(colorModeLabel, 0, 0);
   drawGridLayout->addWidget(vectorColorModeComboBox, 0, 1);
   drawGridLayout->addWidget(vectorTypeLabel, 1, 0);
   drawGridLayout->addWidget(vectorTypeModeComboBox, 1, 1);
   drawGridLayout->addWidget(sparseDistanceLabel, 2, 0);
   drawGridLayout->addWidget(vectorSparseDistanceSpinBox, 2, 1);
   drawGridLayout->addWidget(lengthLabel, 3, 0);
   drawGridLayout->addWidget(vectorLengthMultiplierDoubleSpinBox, 3, 1);
   drawingGroupBox->setFixedSize(drawingGroupBox->sizeHint());

   //===========================================================================

   //
   // Surface Symbol
   //
   QLabel* surfaceSymbolLabel = new QLabel("Symbol");
   vectorSurfaceSymbolComboBox = new QComboBox;
   vectorSurfaceSymbolComboBox->insertItem(DisplaySettingsVectors::SURFACE_SYMBOL_3D,
                                           "3D Symbol");
   vectorSurfaceSymbolComboBox->insertItem(DisplaySettingsVectors::SURFACE_SYMBOL_2D_LINE,
                                           "2D Line");
   QObject::connect(vectorSurfaceSymbolComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVectorSettingsPage()));

   //
   // Display mode surface
   //
   QLabel* displayModeSurfaceLabel = new QLabel("Display Mode");
   vectorDisplayModeSurfaceComboBox = new QComboBox;
   vectorDisplayModeSurfaceComboBox->insertItem(DisplaySettingsVectors::DISPLAY_MODE_ALL,
                                                "All");
   vectorDisplayModeSurfaceComboBox->insertItem(DisplaySettingsVectors::DISPLAY_MODE_NONE,
                                                "None");
   vectorDisplayModeSurfaceComboBox->insertItem(DisplaySettingsVectors::DISPLAY_MODE_SPARSE,
                                                "Sparse");
   QObject::connect(vectorDisplayModeSurfaceComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVectorSettingsPage()));
   
   //
   // Surface line width
   //
   float minLineWidth = 0.0, maxLineWidth = 10.0;
   BrainModelOpenGL::getMinMaxLineWidth(minLineWidth, maxLineWidth);
   QLabel* surfaceLineWidthLabel = new QLabel("Line Width");
   vectorSurfaceLineWidthSpinBox = new QDoubleSpinBox;
   vectorSurfaceLineWidthSpinBox->setMaximumWidth(spinBoxMaxWidth);
   vectorSurfaceLineWidthSpinBox->setMinimum(minLineWidth);
   vectorSurfaceLineWidthSpinBox->setMaximum(maxLineWidth);
   vectorSurfaceLineWidthSpinBox->setSingleStep(1.0);
   vectorSurfaceLineWidthSpinBox->setDecimals(2);
   QObject::connect(vectorSurfaceLineWidthSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVectorSettingsPage()));
   vectorSurfaceLineWidthSpinBox->setToolTip("Controls width of vectors drawn\n"
                                             "as lines in 2D on a surface.");

   //
   // Surface Display Layout
   //
   QGroupBox* surfaceDisplayGroupBox = new QGroupBox("Surface Display");
   QGridLayout* surfaceGridLayout = new QGridLayout(surfaceDisplayGroupBox);
   surfaceGridLayout->addWidget(displayModeSurfaceLabel, 0, 0);
   surfaceGridLayout->addWidget(vectorDisplayModeSurfaceComboBox, 0, 1);
   surfaceGridLayout->addWidget(surfaceSymbolLabel, 1, 0);
   surfaceGridLayout->addWidget(vectorSurfaceSymbolComboBox, 1, 1);
   surfaceGridLayout->addWidget(surfaceLineWidthLabel, 2, 0);
   surfaceGridLayout->addWidget(vectorSurfaceLineWidthSpinBox, 2, 1);
   surfaceDisplayGroupBox->setFixedSize(surfaceDisplayGroupBox->sizeHint());

   //===========================================================================

   //
   // Volume Display mode
   //
   QLabel* displayModeVolumeLabel = new QLabel("Display Mode");
   vectorDisplayModeVolumeComboBox = new QComboBox;
   vectorDisplayModeVolumeComboBox->insertItem(DisplaySettingsVectors::DISPLAY_MODE_ALL,
                                                "All");
   vectorDisplayModeVolumeComboBox->insertItem(DisplaySettingsVectors::DISPLAY_MODE_NONE,
                                                "None");
   vectorDisplayModeVolumeComboBox->insertItem(DisplaySettingsVectors::DISPLAY_MODE_SPARSE,
                                                "Sparse");
   QObject::connect(vectorDisplayModeVolumeComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVectorSettingsPage()));


   //
   // Volume slice above limit
   //
   QLabel* volumeSliceAboveLimitLabel = new QLabel("Slice Above Limit");
   vectorVolumeSliceAboveLimitSpinBox = new QDoubleSpinBox;
   vectorVolumeSliceAboveLimitSpinBox->setMaximumWidth(spinBoxMaxWidth);
   vectorVolumeSliceAboveLimitSpinBox->setMinimum(0.0);
   vectorVolumeSliceAboveLimitSpinBox->setMaximum(1000000.0);
   vectorVolumeSliceAboveLimitSpinBox->setSingleStep(0.1);
   vectorVolumeSliceAboveLimitSpinBox->setDecimals(2);
   QObject::connect(vectorVolumeSliceAboveLimitSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVectorSettingsPage()));
   vectorVolumeSliceAboveLimitSpinBox->setToolTip("Vectors within this distance above\n"
                                                 "a volume slice are drawn.");

   //
   // Volume slice below limit
   //
   QLabel* volumeSliceBelowLimitLabel = new QLabel("Slice Below Limit");
   vectorVolumeSliceBelowLimitSpinBox = new QDoubleSpinBox;
   vectorVolumeSliceBelowLimitSpinBox->setMaximumWidth(spinBoxMaxWidth);
   vectorVolumeSliceBelowLimitSpinBox->setMinimum(-1000000.0);
   vectorVolumeSliceBelowLimitSpinBox->setMaximum(0.0);
   vectorVolumeSliceBelowLimitSpinBox->setSingleStep(0.1);
   vectorVolumeSliceBelowLimitSpinBox->setDecimals(2);
   QObject::connect(vectorVolumeSliceBelowLimitSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVectorSettingsPage()));
   vectorVolumeSliceBelowLimitSpinBox->setToolTip("Vectors within this distance below\n"
                                                 "a volume slice are drawn.");

   QGroupBox* volumeDisplayGroupBox = new QGroupBox("Volume Display");
   QGridLayout* volumeDisplayGridLayout = new QGridLayout(volumeDisplayGroupBox);
   volumeDisplayGridLayout->addWidget(displayModeVolumeLabel, 0, 0);
   volumeDisplayGridLayout->addWidget(vectorDisplayModeVolumeComboBox, 0, 1);
   volumeDisplayGridLayout->addWidget(volumeSliceAboveLimitLabel, 1, 0);
   volumeDisplayGridLayout->addWidget(vectorVolumeSliceAboveLimitSpinBox, 1, 1);
   volumeDisplayGridLayout->addWidget(volumeSliceBelowLimitLabel, 2, 0);
   volumeDisplayGridLayout->addWidget(vectorVolumeSliceBelowLimitSpinBox, 2, 1);
   volumeDisplayGroupBox->setFixedSize(volumeDisplayGroupBox->sizeHint());

   //===========================================================================

   //
   // Magnitude Threshold
   //
   QLabel* magnitudeThresholdLabel = new QLabel("Threshold");
   vectorMagnitudeThresholdSpinBox = new QDoubleSpinBox;
   vectorMagnitudeThresholdSpinBox->setMaximumWidth(spinBoxMaxWidth);
   vectorMagnitudeThresholdSpinBox->setMinimum(0.0);
   vectorMagnitudeThresholdSpinBox->setMaximum(1000000.0);
   vectorMagnitudeThresholdSpinBox->setSingleStep(0.05);
   vectorMagnitudeThresholdSpinBox->setDecimals(3);
   QObject::connect(vectorMagnitudeThresholdSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVectorSettingsPage()));
   vectorMagnitudeThresholdSpinBox->setToolTip("Vectors with a magnitude less\n"
                                               "than this value are not displayed.");

   //
   // Draw with magnitude check box
   //
   vectorDrawWithMagnitudeCheckBox = new QCheckBox("Draw With Magnitude");
   QObject::connect(vectorDrawWithMagnitudeCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readVectorSettingsPage()));
   vectorDrawWithMagnitudeCheckBox->setToolTip("If selected, vectors are drawn using their\n"
                                               "magnitude as the vector length.  Otherwise, \n"
                                               "vectors are drawn with a length of 1.0.");

   //
   // Group box and layout for magnitude
   //
   QGroupBox* magnitudeGroupBox = new QGroupBox("Magnitude");
   QGridLayout* magnitudeGridLayout = new QGridLayout(magnitudeGroupBox);
   magnitudeGridLayout->addWidget(vectorDrawWithMagnitudeCheckBox, 0, 0, 1, 2);
   magnitudeGridLayout->addWidget(magnitudeThresholdLabel, 1, 0);
   magnitudeGridLayout->addWidget(vectorMagnitudeThresholdSpinBox, 1, 1);
   magnitudeGroupBox->setFixedSize(magnitudeGroupBox->sizeHint());

   //===========================================================================

   //
   // Segmentation mask controls
   //
   QLabel* segmentationVolumeLabel = new QLabel("Volume");
   vectorSegmentationMaskVolumeComboBox = 
           new GuiVolumeFileSelectionComboBox(VolumeFile::VOLUME_TYPE_SEGMENTATION);
   QObject::connect(vectorSegmentationMaskVolumeComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVectorSettingsPage()));

   //
   // Segmentation mask group box and layout
   //
   vectorSegmentationGroupBox = new QGroupBox("Segmentation Volume Masking");
   vectorSegmentationGroupBox->setCheckable(true);
   QObject::connect(vectorSegmentationGroupBox, SIGNAL(toggled(bool)),
                    this, SLOT(readVectorSettingsPage()));
   QGridLayout* segmentationGridLayout = new QGridLayout(vectorSegmentationGroupBox);
   segmentationGridLayout->setColumnStretch(0, 0);
   segmentationGridLayout->setColumnStretch(1, 100);
   segmentationGridLayout->addWidget(segmentationVolumeLabel, 0, 0);
   segmentationGridLayout->addWidget(vectorSegmentationMaskVolumeComboBox, 0, 1);

   //===========================================================================

   //
   // Functional mask controls
   //
   QLabel* vectorFunctionalMaskVolumeLabel = new QLabel("Volume");
   vectorFunctionalMaskVolumeComboBox =
           new GuiVolumeFileSelectionComboBox(VolumeFile::VOLUME_TYPE_FUNCTIONAL);
   QObject::connect(vectorFunctionalMaskVolumeComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVectorSettingsPage()));
   vectorFunctionalMaskVolumeNegThreshSpinBox = new QDoubleSpinBox;
   vectorFunctionalMaskVolumeNegThreshSpinBox->setMaximumWidth(spinBoxMaxWidth);
   vectorFunctionalMaskVolumeNegThreshSpinBox->setMinimum(-1.0E10);
   vectorFunctionalMaskVolumeNegThreshSpinBox->setMaximum(1.0E10);
   vectorFunctionalMaskVolumeNegThreshSpinBox->setSingleStep(1.0);
   vectorFunctionalMaskVolumeNegThreshSpinBox->setDecimals(3);
   QObject::connect(vectorFunctionalMaskVolumeNegThreshSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVectorSettingsPage()));
   vectorFunctionalMaskVolumePosThreshSpinBox = new QDoubleSpinBox;
   vectorFunctionalMaskVolumePosThreshSpinBox->setMaximumWidth(spinBoxMaxWidth);
   vectorFunctionalMaskVolumePosThreshSpinBox->setMinimum(-1.0E10);
   vectorFunctionalMaskVolumePosThreshSpinBox->setMaximum(1.0E10);
   vectorFunctionalMaskVolumePosThreshSpinBox->setSingleStep(1.0);
   vectorFunctionalMaskVolumePosThreshSpinBox->setDecimals(3);
   QObject::connect(vectorFunctionalMaskVolumePosThreshSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVectorSettingsPage()));
   QLabel* functionalMaskValueLabel = new QLabel("Neg/Pos Threshold");
   vectorFunctionalVolumeMaskGroupBox = new QGroupBox("Functional Volume Masking");
   vectorFunctionalVolumeMaskGroupBox->setCheckable(true);
   QObject::connect(vectorFunctionalVolumeMaskGroupBox, SIGNAL(toggled(bool)),
                    this, SLOT(readVectorSettingsPage()));
   QGridLayout* functionalMaskGridLayout = new QGridLayout(vectorFunctionalVolumeMaskGroupBox);
   functionalMaskGridLayout->setColumnStretch(0, 0);
   functionalMaskGridLayout->setColumnStretch(1, 0);
   functionalMaskGridLayout->setColumnStretch(2, 0);
   functionalMaskGridLayout->setColumnStretch(3, 100);
   functionalMaskGridLayout->addWidget(vectorFunctionalMaskVolumeLabel, 0, 0);
   functionalMaskGridLayout->addWidget(vectorFunctionalMaskVolumeComboBox, 0, 1, 1, 3);
   functionalMaskGridLayout->addWidget(functionalMaskValueLabel, 1, 0);
   functionalMaskGridLayout->addWidget(vectorFunctionalMaskVolumeNegThreshSpinBox, 1, 1);
   functionalMaskGridLayout->addWidget(vectorFunctionalMaskVolumePosThreshSpinBox, 1, 2);

   //===========================================================================

   //
   // Orientation combo box
   //
   QLabel* displayOrientationAxisLabel = new QLabel("Axis");
   vectorDisplayOrientationComboBox = new QComboBox;
   vectorDisplayOrientationComboBox->insertItem(DisplaySettingsVectors::DISPLAY_ORIENTATION_ANY,
                                      "Any");
   vectorDisplayOrientationComboBox->insertItem(DisplaySettingsVectors::DISPLAY_ORIENTATION_LEFT_RIGHT,
                                      "Left/Right");
   vectorDisplayOrientationComboBox->insertItem(DisplaySettingsVectors::DISPLAY_ORIENTATION_POSTERIOR_ANTERIOR,
                                      "Posterior/Anterior");;
   vectorDisplayOrientationComboBox->insertItem(DisplaySettingsVectors::DISPLAY_ORIENTATION_INFERIOR_SUPERIOR,
                                      "Inferior/Superior");
   QObject::connect(vectorDisplayOrientationComboBox, SIGNAL(activated(int)),
                    this, SLOT(readVectorSettingsPage()));

   //
   // Orientation angle
   //
   QLabel* orientationAngleLabel = new QLabel("Angle");
   vectorDisplayOrientationAngleSpinBox = new QDoubleSpinBox;
   vectorDisplayOrientationAngleSpinBox->setMaximumWidth(spinBoxMaxWidth);
   vectorDisplayOrientationAngleSpinBox->setMinimum(-90.0);
   vectorDisplayOrientationAngleSpinBox->setMaximum(90.0);
   vectorDisplayOrientationAngleSpinBox->setSingleStep(1.0);
   vectorDisplayOrientationAngleSpinBox->setDecimals(1);
   QObject::connect(vectorDisplayOrientationAngleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readVectorSettingsPage()));
   vectorDisplayOrientationAngleSpinBox->setToolTip("Angle of vectors from orientation.");

   //
   // Orientation layout
   //
   QGroupBox* vectorDisplayOrientationGroupBox = new QGroupBox("Orientation Filtering");
   QGridLayout* vectorDisplayOrientationGridLayout = new QGridLayout(vectorDisplayOrientationGroupBox);
   vectorDisplayOrientationGridLayout->addWidget(displayOrientationAxisLabel, 0, 0);
   vectorDisplayOrientationGridLayout->addWidget(vectorDisplayOrientationComboBox, 0, 1);
   vectorDisplayOrientationGridLayout->addWidget(orientationAngleLabel, 1, 0);
   vectorDisplayOrientationGridLayout->addWidget(vectorDisplayOrientationAngleSpinBox, 1, 1);
   vectorDisplayOrientationGroupBox->setFixedSize(vectorDisplayOrientationGroupBox->sizeHint());

   //===========================================================================

   //
   // Layout for surface and volume display
   //
   QHBoxLayout* displayLayouts = new QHBoxLayout;
   displayLayouts->addWidget(surfaceDisplayGroupBox);
   displayLayouts->addWidget(volumeDisplayGroupBox);
   displayLayouts->addStretch();

   //
   // Layout for orientation and magnitude
   //
   QHBoxLayout* orientationMagnitudeLayouts = new QHBoxLayout;
   orientationMagnitudeLayouts->addWidget(vectorDisplayOrientationGroupBox);
   orientationMagnitudeLayouts->addWidget(magnitudeGroupBox);
   orientationMagnitudeLayouts->addStretch();


   //
   // Box for settings page
   //
   pageVectorSettings = new QWidget;
   QVBoxLayout* vectorSettingsPageLayout = new QVBoxLayout(pageVectorSettings);
   vectorSettingsPageLayout->setSpacing(1);
   vectorSettingsPageLayout->addLayout(displayLayouts);
   vectorSettingsPageLayout->addWidget(drawingGroupBox);
   vectorSettingsPageLayout->addLayout(orientationMagnitudeLayouts);
   vectorSettingsPageLayout->addWidget(vectorFunctionalVolumeMaskGroupBox);
   vectorSettingsPageLayout->addWidget(vectorSegmentationGroupBox);
   vectorSettingsPageLayout->addStretch();
   pageVectorSettings->setFixedSize(pageVectorSettings->sizeHint());

   pageWidgetStack->addWidget(pageVectorSettings);

   //
   // Widget group for vector page items
   //
   vectorSettingsPageWidgetGroup = new WuQWidgetGroup(this);
   vectorSettingsPageWidgetGroup->addWidget(vectorColorModeComboBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorTypeModeComboBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorSurfaceSymbolComboBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorDisplayModeSurfaceComboBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorDisplayModeVolumeComboBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorSparseDistanceSpinBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorLengthMultiplierDoubleSpinBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorSurfaceLineWidthSpinBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorVolumeSliceAboveLimitSpinBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorVolumeSliceBelowLimitSpinBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorDrawWithMagnitudeCheckBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorMagnitudeThresholdSpinBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorSegmentationGroupBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorSegmentationMaskVolumeComboBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorDisplayOrientationComboBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorDisplayOrientationAngleSpinBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorFunctionalVolumeMaskGroupBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorFunctionalMaskVolumeComboBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorFunctionalMaskVolumeNegThreshSpinBox);
   vectorSettingsPageWidgetGroup->addWidget(vectorFunctionalMaskVolumePosThreshSpinBox);
}

/**
 * update surface vector settings page.
 */
void 
05536 GuiDisplayControlDialog::updateVectorSettingsPage()
{
   if (pageVectorSettings == NULL) {
      return;
   }
   vectorSettingsPageWidgetGroup->blockSignals(true);

   DisplaySettingsVectors* dssv = theMainWindow->getBrainSet()->getDisplaySettingsVectors();

   vectorColorModeComboBox->setCurrentIndex(dssv->getColorMode());
   vectorTypeModeComboBox->setCurrentIndex(dssv->getVectorType());
   vectorSurfaceSymbolComboBox->setCurrentIndex(dssv->getSurfaceSymbol());
   vectorDisplayModeSurfaceComboBox->setCurrentIndex(dssv->getDisplayModeSurface());
   vectorDisplayModeVolumeComboBox->setCurrentIndex(dssv->getDisplayModeVolume());
   vectorSparseDistanceSpinBox->setValue(dssv->getSparseDisplayDistance());
   vectorLengthMultiplierDoubleSpinBox->setValue(dssv->getLengthMultiplier());
   vectorSurfaceLineWidthSpinBox->setValue(dssv->getSurfaceVectorLineWidth());
   vectorVolumeSliceAboveLimitSpinBox->setValue(dssv->getVolumeSliceDistanceAboveLimit());
   vectorVolumeSliceBelowLimitSpinBox->setValue(dssv->getVolumeSliceDistanceBelowLimit());
   vectorDrawWithMagnitudeCheckBox->setChecked(dssv->getDrawWithMagnitude());
   vectorMagnitudeThresholdSpinBox->setValue(dssv->getMagnitudeThreshold());
   vectorSegmentationGroupBox->setChecked(dssv->getSegmentationMaskingVolumeEnabled());
   vectorSegmentationMaskVolumeComboBox->updateComboBox();
   vectorSegmentationMaskVolumeComboBox->setSelectedVolumeFile(dssv->getSegmentationMaskingVolumeFile());
   vectorDisplayOrientationAngleSpinBox->setValue(dssv->getDisplayOrientationAngle());
   vectorDisplayOrientationComboBox->setCurrentIndex(dssv->getDisplayOrientation());
   vectorFunctionalVolumeMaskGroupBox->setChecked(dssv->getFunctionalMaskingVolumeEnabled());
   vectorFunctionalMaskVolumeComboBox->updateComboBox();
   vectorFunctionalMaskVolumeComboBox->setSelectedVolumeFile(dssv->getFunctionalMaskingVolumeFile());
   vectorFunctionalMaskVolumeNegThreshSpinBox->setValue(dssv->getFunctionalMaskingVolumeNegativeThreshold());
   vectorFunctionalMaskVolumePosThreshSpinBox->setValue(dssv->getFunctionalMaskingVolumePositiveThreshold());
   pageVectorSettings->setEnabled(validVectorData);

   vectorSettingsPageWidgetGroup->blockSignals(false);
}

/**
 * update surface vector items in dialog.
 */
void 
05576 GuiDisplayControlDialog::updateVectorItems()
{
   updatePageSelectionComboBox();

   updateVectorSelectionPage();
   updateVectorSettingsPage();
}
      
/**
 * read the surface vector settings page.
 */
void 
05588 GuiDisplayControlDialog::readVectorSettingsPage()
{
   if (pageVectorSettings == NULL) {
      return;
   }
   DisplaySettingsVectors* dssv = theMainWindow->getBrainSet()->getDisplaySettingsVectors();
   
   //dssv->setSelectedColumn(surfaceModelIndex, vectorButtonGroup->checkedId());
   dssv->setColorMode(static_cast<DisplaySettingsVectors::COLOR_MODE>(
                          vectorColorModeComboBox->currentIndex()));
   dssv->setVectorType(static_cast<DisplaySettingsVectors::VECTOR_TYPE>(
                          vectorTypeModeComboBox->currentIndex()));
   dssv->setSurfaceSymbol(static_cast<DisplaySettingsVectors::SURFACE_SYMBOL>(
                            vectorSurfaceSymbolComboBox->currentIndex()));
   dssv->setDisplayModeSurface(static_cast<DisplaySettingsVectors::DISPLAY_MODE>(
                          vectorDisplayModeSurfaceComboBox->currentIndex()));
   dssv->setDisplayModeVolume(static_cast<DisplaySettingsVectors::DISPLAY_MODE>(
                          vectorDisplayModeVolumeComboBox->currentIndex()));
   dssv->setSurfaceVectorLineWidth(vectorSurfaceLineWidthSpinBox->value());
   dssv->setVolumeSliceDistanceAboveLimit(vectorVolumeSliceAboveLimitSpinBox->value());
   dssv->setVolumeSliceDistanceBelowLimit(vectorVolumeSliceBelowLimitSpinBox->value());
   dssv->setSparseDisplayDistance(vectorSparseDistanceSpinBox->value());
   dssv->setLengthMultiplier(vectorLengthMultiplierDoubleSpinBox->value());
   dssv->setDrawWithMagnitude(vectorDrawWithMagnitudeCheckBox->isChecked());
   dssv->setMagnitudeThreshold(vectorMagnitudeThresholdSpinBox->value());
   dssv->setSegmentationMaskingVolumeFile(vectorSegmentationMaskVolumeComboBox->getSelectedVolumeFile());
   dssv->setSegmentationMaskingVolumeEnabled(vectorSegmentationGroupBox->isChecked());
   dssv->setDisplayOrientationAngle(vectorDisplayOrientationAngleSpinBox->value());
   dssv->setDisplayOrientation(static_cast<DisplaySettingsVectors::DISPLAY_ORIENTATION>(
                                     vectorDisplayOrientationComboBox->currentIndex()));
   dssv->setFunctionalMaskingVolumeEnabled(vectorFunctionalVolumeMaskGroupBox->isChecked());
   dssv->setFunctionalMaskingVolumeFile(vectorFunctionalMaskVolumeComboBox->getSelectedVolumeFile());
   dssv->setFunctionalMaskingVolumeNegativeThreshold(vectorFunctionalMaskVolumeNegThreshSpinBox->value());
   dssv->setFunctionalMaskingVolumePositiveThreshold(vectorFunctionalMaskVolumePosThreshSpinBox->value());
   theMainWindow->getBrainSet()->clearAllDisplayLists();
   GuiBrainModelOpenGL::updateAllGL();
}

/**
 *  update vector selection page.
 */
void
05630 GuiDisplayControlDialog::updateVectorSelectionPage()
{
   if (pageVectorSelection == NULL) {
      return;
   }
   vectorSelectionPageWidgetGroup->blockSignals(true);

   BrainSet* bs = theMainWindow->getBrainSet();
   const int numVectorFiles = bs->getNumberOfVectorFiles();
   const int numCheckBoxes = static_cast<int>(vectorSelectionCheckBoxes.size());

   //
   // Add new check boxes
   //
   for (int i = numCheckBoxes; i < numVectorFiles; i++) {
      QCheckBox* cb = new QCheckBox("");
      cb->blockSignals(true);
      QObject::connect(cb, SIGNAL(toggled(bool)),
                       this, SLOT(readVectorSelectionPage()));
      vectorSelectionCheckBoxes.push_back(cb);
      vectorSelectionPageWidgetGroup->addWidget(cb);
      pageVectorSelectionLayout->addWidget(cb);
   }

   //
   // Hide unused checkboxes
   //
   for (int i = numVectorFiles; i < numCheckBoxes; i++) {
      vectorSelectionCheckBoxes[i]->hide();
   }

   //
   // Update valid checkboxes
   //
   DisplaySettingsVectors* dsv = bs->getDisplaySettingsVectors();
   for (int i = 0; i < numVectorFiles; i++) {
      vectorSelectionCheckBoxes[i]->show();
      vectorSelectionCheckBoxes[i]->setText(
         FileUtilities::basename(bs->getVectorFile(i)->getFileName()));
      vectorSelectionCheckBoxes[i]->setChecked(dsv->getDisplayVectorFile(i));
   }

   pageVectorSelection->setEnabled(validVectorData);
   pageVectorSelection->setFixedHeight(pageVectorSelection->sizeHint().height());

   vectorSelectionPageWidgetGroup->blockSignals(false);
}

/**
 *  create the vector selection page.
 */
void
05682 GuiDisplayControlDialog::createVectorSelectionPage()
{
   pageVectorSelection = new QWidget;
   pageWidgetStack->addWidget(pageVectorSelection);
   pageVectorSelectionLayout = new QVBoxLayout(pageVectorSelection);

   //
   // Widget group for vector page items
   //
   vectorSelectionPageWidgetGroup = new WuQWidgetGroup(this);
}

/**
 *  read the vector selection page.
 */
void
05698 GuiDisplayControlDialog::readVectorSelectionPage()
{
   if (pageVectorSelection == NULL) {
      return;
   }
   BrainSet* bs = theMainWindow->getBrainSet();
   int numVectorFiles = bs->getNumberOfVectorFiles();

   //
   // Determine files that are displayed
   //
   DisplaySettingsVectors* dsv = bs->getDisplaySettingsVectors();
   for (int i = 0; i < numVectorFiles; i++) {
      dsv->setDisplayVectorFile(i, vectorSelectionCheckBoxes[i]->isChecked());
   }

   bs->clearAllDisplayLists();
   GuiBrainModelOpenGL::updateAllGL();
}

/**
 * Create the misc tab page
 */
void
05722 GuiDisplayControlDialog::createSurfaceMiscPage()
{
   //
   // Display settings for nodes
   //
   DisplaySettingsSurface* dsn = theMainWindow->getBrainSet()->getDisplaySettingsSurface();
   
   //
   // Widget for misc items
   //
   pageSurfaceMisc = new QWidget;
   pageWidgetStack->addWidget(pageSurfaceMisc); //, PAGE_NAME_SURFACE_MISC);
   QVBoxLayout* miscVBoxLayout = new QVBoxLayout(pageSurfaceMisc);
   miscVBoxLayout->setSpacing(3);
   
   //
   // Grid layout for brighness, contrast, node size, link size
   //
   //
   int numRows = 0;
   const int LEFT_VOLUME_INTERACTION_ROW = numRows++;
   const int RIGHT_VOLUME_INTERACTION_ROW = numRows++;
   const int CEREBELLUM_VOLUME_INTERACTION_ROW = numRows++;
   const int FIDUCIAL_ROW     = numRows++;
   const int DRAW_MODE_ROW    = numRows++;
   const int PROJECTION_ROW   = numRows++;
   const int BRIGHTNESS_ROW = numRows++;
   const int CONTRAST_ROW   = numRows++;
   const int OPACITY_ROW = numRows++;
   const int NODE_SIZE_ROW  = numRows++;
   const int LINK_SIZE_ROW  = numRows++;
   const int IDENTIFY_COLOR_ROW = numRows++;
   
   const int maxWidth = 250;
   
   QGridLayout* gridLayout = new QGridLayout;
   gridLayout->setSpacing(2);
   miscVBoxLayout->addLayout(gridLayout);
   //gridLayout->setColumnMaximumWidth(1, 200);
   
   //
   // Fiducial volume interaction surface selection
   //
   gridLayout->addWidget(new QLabel("Left Fiducial Volume Interaction"), LEFT_VOLUME_INTERACTION_ROW, 0, Qt::AlignLeft);
   miscLeftFiducialVolumeInteractionComboBox = new GuiBrainModelSelectionComboBox(false, true, false,
                                                               "", 0, 
                                                               "miscLeftFiducialVolumeInteractionComboBox",
                                                               false,
                                                               true);
   miscLeftFiducialVolumeInteractionComboBox->setSurfaceStructureRequirement(Structure::STRUCTURE_TYPE_CORTEX_LEFT);
   gridLayout->addWidget(miscLeftFiducialVolumeInteractionComboBox, LEFT_VOLUME_INTERACTION_ROW, 1, 1, 2, Qt::AlignLeft);
   QObject::connect(miscLeftFiducialVolumeInteractionComboBox, SIGNAL(activated(int)),
                    this, SLOT(readMiscSelections()));
   gridLayout->addWidget(new QLabel("Right Fiducial Volume Interaction"), RIGHT_VOLUME_INTERACTION_ROW, 0, Qt::AlignLeft);
   miscRightFiducialVolumeInteractionComboBox = new GuiBrainModelSelectionComboBox(false, true, false,
                                                               "", 0, 
                                                               "miscRightFiducialVolumeInteractionComboBox",
                                                               false,
                                                               true);
   miscRightFiducialVolumeInteractionComboBox->setSurfaceStructureRequirement(Structure::STRUCTURE_TYPE_CORTEX_RIGHT);
   gridLayout->addWidget(miscRightFiducialVolumeInteractionComboBox, RIGHT_VOLUME_INTERACTION_ROW, 1, 1, 2, Qt::AlignLeft);
   QObject::connect(miscRightFiducialVolumeInteractionComboBox, SIGNAL(activated(int)),
                    this, SLOT(readMiscSelections()));
   gridLayout->addWidget(new QLabel("Cerebellum Fiducial Volume Interaction"), CEREBELLUM_VOLUME_INTERACTION_ROW, 0, Qt::AlignLeft);
   miscCerebellumFiducialVolumeInteractionComboBox = new GuiBrainModelSelectionComboBox(false, true, false,
                                                               "", 0, 
                                                               "miscCerebellumFiducialVolumeInteractionComboBox",
                                                               false,
                                                               true);
   miscCerebellumFiducialVolumeInteractionComboBox->setSurfaceStructureRequirement(Structure::STRUCTURE_TYPE_CEREBELLUM);
   gridLayout->addWidget(miscCerebellumFiducialVolumeInteractionComboBox, CEREBELLUM_VOLUME_INTERACTION_ROW, 1, 1, 2, Qt::AlignLeft);
   QObject::connect(miscCerebellumFiducialVolumeInteractionComboBox, SIGNAL(activated(int)),
                    this, SLOT(readMiscSelections()));
   
   //
   // Active fiducial surface selection
   //
   gridLayout->addWidget(new QLabel("Active Fiducial"), FIDUCIAL_ROW, 0, Qt::AlignLeft);
   miscActiveFiducialComboBox = new GuiBrainModelSelectionComboBox(false, true, false,
                                                               "", 0, 
                                                               "miscActiveFiducialComboBox",
                                                               false,
                                                               true);
   gridLayout->addWidget(miscActiveFiducialComboBox, FIDUCIAL_ROW, 1, 1, 2, Qt::AlignLeft);
   QObject::connect(miscActiveFiducialComboBox, SIGNAL(activated(int)),
                    this, SLOT(readMiscSelections()));
   
   //
   // Combo box for drawing mode
   //
   gridLayout->addWidget(new QLabel("Drawing Mode "), DRAW_MODE_ROW, 0, Qt::AlignLeft);
   miscDrawModeComboBox = new QComboBox;
   miscDrawModeComboBox->setMaximumWidth(maxWidth);
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_NODES,
                                    "Nodes");
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_LINKS,
                                    "Links");
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_LINK_HIDDEN_LINE_REMOVAL,
                                    "Links (No Backside)");
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_LINKS_EDGES_ONLY,
                                    "Links (Edges Only)");
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_NODES_AND_LINKS,
                                    "Nodes and Links");
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_TILES,
                                    "Tiles without Lighting");
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_TILES_WITH_LIGHT,
                                    "Tiles with Lighting (Default)");
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_TILES_WITH_LIGHT_NO_BACK,
                                    "Tiles with Lighting No Backfacing Tiles");
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_TILES_LINKS_NODES,
                                    "Tiles, Links, and Nodes (surface editing)");
   miscDrawModeComboBox->insertItem(DisplaySettingsSurface::DRAW_MODE_NONE,
                                    "Hide Surface");
   miscDrawModeComboBox->setFixedSize(miscDrawModeComboBox->sizeHint());
   gridLayout->addWidget(miscDrawModeComboBox, DRAW_MODE_ROW, 1, Qt::AlignLeft);
   miscDrawModeComboBox->setToolTip("Choose Drawing Mode");
   QObject::connect(miscDrawModeComboBox, SIGNAL(activated(int)),
                    this, SLOT(readMiscSelections()));
   
   //
   // Projection
   //
   gridLayout->addWidget(new QLabel("Projection"), PROJECTION_ROW, 0, Qt::AlignLeft);
   miscProjectionComboBox = new QComboBox;
   miscProjectionComboBox->setMaximumWidth(maxWidth);
   gridLayout->addWidget(miscProjectionComboBox, PROJECTION_ROW, 1, Qt::AlignLeft);
   QObject::connect(miscProjectionComboBox, SIGNAL(activated(int)),
                    this, SLOT(readMiscSelections()));
   miscProjectionComboBox->insertItem(DisplaySettingsSurface::VIEWING_PROJECTION_ORTHOGRAPHIC,
                                      "Orthographic");
   miscProjectionComboBox->insertItem(DisplaySettingsSurface::VIEWING_PROJECTION_PERSPECTIVE,
                                      "Perspective");
                                      
   //
   // Brightness line edit and label
   //
   gridLayout->addWidget(new QLabel("Brightness"), BRIGHTNESS_ROW, 0, Qt::AlignLeft);
   miscBrightnessDoubleSpinBox = new QDoubleSpinBox;
   miscBrightnessDoubleSpinBox->setMinimum(-10000);
   miscBrightnessDoubleSpinBox->setMaximum(10000);
   miscBrightnessDoubleSpinBox->setSingleStep(10.0);
   miscBrightnessDoubleSpinBox->setDecimals(2);
   miscBrightnessDoubleSpinBox->setMaximumWidth(maxWidth);
   gridLayout->addWidget(miscBrightnessDoubleSpinBox, BRIGHTNESS_ROW, 1, Qt::AlignLeft);
   miscBrightnessDoubleSpinBox->setValue(dsn->getNodeBrightness());
   QObject::connect(miscBrightnessDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
   
   //
   // Contrast line edit and label
   //
   gridLayout->addWidget(new QLabel("Contrast"), CONTRAST_ROW, 0, Qt::AlignLeft);
   miscContrastDoubleSpinBox = new QDoubleSpinBox;
   miscContrastDoubleSpinBox->setMaximumWidth(maxWidth);
   miscContrastDoubleSpinBox->setMinimum(-10000);
   miscContrastDoubleSpinBox->setMaximum(10000);
   miscContrastDoubleSpinBox->setSingleStep(0.1);
   miscContrastDoubleSpinBox->setDecimals(2);
   gridLayout->addWidget(miscContrastDoubleSpinBox, CONTRAST_ROW, 1, Qt::AlignLeft);
   miscContrastDoubleSpinBox->setValue(dsn->getNodeContrast());
   QObject::connect(miscContrastDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
   
   //
   // Opacity spin box and label
   //
   gridLayout->addWidget(new QLabel("Opacity"), OPACITY_ROW, 0, Qt::AlignLeft);
   opacityDoubleSpinBox = new QDoubleSpinBox;
   opacityDoubleSpinBox->setMinimum(0.0);
   opacityDoubleSpinBox->setMaximum(1.0);
   opacityDoubleSpinBox->setSingleStep(0.1);
   opacityDoubleSpinBox->setDecimals(2);
   opacityDoubleSpinBox->setMaximumWidth(maxWidth);
   gridLayout->addWidget(opacityDoubleSpinBox, OPACITY_ROW, 1, Qt::AlignLeft);
   QObject::connect(opacityDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
                    
   //
   // Node Size spin box and label
   //
   gridLayout->addWidget(new QLabel("Node Size"), NODE_SIZE_ROW, 0, Qt::AlignLeft);
   miscNodeSizeSpinBox = new QDoubleSpinBox;
   miscNodeSizeSpinBox->setMinimum(minPointSize);
   miscNodeSizeSpinBox->setMaximum(maxPointSize);
   miscNodeSizeSpinBox->setSingleStep(1.0);
   miscNodeSizeSpinBox->setDecimals(1);
   miscNodeSizeSpinBox->setMaximumWidth(maxWidth);
   gridLayout->addWidget(miscNodeSizeSpinBox, NODE_SIZE_ROW, 1, Qt::AlignLeft);
   miscNodeSizeSpinBox->setValue(dsn->getNodeSize());
   QObject::connect(miscNodeSizeSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
   
   //
   // Link Size spin box and label
   //
   gridLayout->addWidget(new QLabel("Link Size"), LINK_SIZE_ROW, 0, Qt::AlignLeft);
   miscLinkSizeSpinBox = new QDoubleSpinBox;
   miscLinkSizeSpinBox->setMinimum(minLineSize);
   miscLinkSizeSpinBox->setMaximum(maxLineSize);
   miscLinkSizeSpinBox->setSingleStep(1.0);
   miscLinkSizeSpinBox->setDecimals(1);
   miscLinkSizeSpinBox->setMaximumWidth(maxWidth);
   gridLayout->addWidget(miscLinkSizeSpinBox, LINK_SIZE_ROW, 1, Qt::AlignLeft);
   miscLinkSizeSpinBox->setValue(dsn->getLinkSize());
   QObject::connect(miscLinkSizeSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
   
   //
   // identify node color combo box
   //
   gridLayout->addWidget(new QLabel("Identify Color"), IDENTIFY_COLOR_ROW, 0, Qt::AlignLeft);
   miscIdentifyNodeColorComboBox = new QComboBox;
   miscIdentifyNodeColorComboBox->setMaximumWidth(maxWidth);
   gridLayout->addWidget(miscIdentifyNodeColorComboBox, IDENTIFY_COLOR_ROW, 1, Qt::AlignLeft);
   QObject::connect(miscIdentifyNodeColorComboBox, SIGNAL(activated(int)),
                    this, SLOT(readMiscSelections()));
   miscIdentifyNodeColorComboBox->insertItem(DisplaySettingsSurface::IDENTIFY_NODE_COLOR_BLACK, "Black");
   miscIdentifyNodeColorComboBox->insertItem(DisplaySettingsSurface::IDENTIFY_NODE_COLOR_BLUE, "Blue");
   miscIdentifyNodeColorComboBox->insertItem(DisplaySettingsSurface::IDENTIFY_NODE_COLOR_GREEN, "Green");
   miscIdentifyNodeColorComboBox->insertItem(DisplaySettingsSurface::IDENTIFY_NODE_COLOR_RED, "Red");
   miscIdentifyNodeColorComboBox->insertItem(DisplaySettingsSurface::IDENTIFY_NODE_COLOR_WHITE, "White");

   //
   // show normals check box
   //
   miscShowNormalsCheckBox = new QCheckBox("Show Normals");
   miscVBoxLayout->addWidget(miscShowNormalsCheckBox, 0, Qt::AlignLeft);
   miscShowNormalsCheckBox->setChecked(dsn->getShowNormals());
   QObject::connect(miscShowNormalsCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readMiscSelections()));
   
   //
   // total forces check box
   //
   miscTotalForcesCheckBox = new QCheckBox("Show Morphing Total Forces");
   miscVBoxLayout->addWidget(miscTotalForcesCheckBox, 0, Qt::AlignLeft);
   miscTotalForcesCheckBox->setChecked(dsn->getShowMorphingTotalForces());
   QObject::connect(miscTotalForcesCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readMiscSelections()));
   
   //
   // angular forces check box
   //
   miscAngularForcesCheckBox = new QCheckBox("Show Morphing Angular Forces");
   miscVBoxLayout->addWidget(miscAngularForcesCheckBox, 0, Qt::AlignLeft);
   miscAngularForcesCheckBox->setChecked(dsn->getShowMorphingAngularForces());
   QObject::connect(miscAngularForcesCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readMiscSelections()));
   
   //
   // linear forces check box
   //
   miscLinearForcesCheckBox = new QCheckBox("Show Morphing Linear Forces");
   miscVBoxLayout->addWidget(miscLinearForcesCheckBox, 0, Qt::AlignLeft);
   miscLinearForcesCheckBox->setChecked(dsn->getShowMorphingLinearForces());
   QObject::connect(miscLinearForcesCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readMiscSelections()));
   
   //
   // force vector length float spin box
   //
   QLabel* forceVectorLabel = new QLabel("Force Vector Length ");
   miscForceVectorLengthDoubleSpinBox = new QDoubleSpinBox;
   miscForceVectorLengthDoubleSpinBox->setMinimum(0.0);
   miscForceVectorLengthDoubleSpinBox->setMaximum(5000.0);
   miscForceVectorLengthDoubleSpinBox->setSingleStep(10.0);
   miscForceVectorLengthDoubleSpinBox->setDecimals(2);
   miscForceVectorLengthDoubleSpinBox->setValue(dsn->getForceVectorDisplayLength());
   QObject::connect(miscForceVectorLengthDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
   QHBoxLayout* forceHBoxLayout = new QHBoxLayout;
   miscVBoxLayout->addLayout(forceHBoxLayout);
   forceHBoxLayout->addWidget(forceVectorLabel);
   forceHBoxLayout->addWidget(miscForceVectorLengthDoubleSpinBox);
   forceHBoxLayout->addStretch();
   
   //
   // cartesian axes show letters check box
   //
   miscAxesShowLettersCheckBox = new QCheckBox("Show Orientation Labels");
   QObject::connect(miscAxesShowLettersCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readMiscSelections()));

   //
   // cartesian axesShow tick marks
   //
   miscAxesShowTickMarksCheckBox = new QCheckBox("Show Tick Marks");
   QObject::connect(miscAxesShowTickMarksCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readMiscSelections()));

   //
   // axes length
   //
   QLabel* miscSurfAxesLabel = new QLabel("Axes Length ");
   miscAxesLengthDoubleSpinBox = new QDoubleSpinBox;
   miscAxesLengthDoubleSpinBox->setMinimum(0.0);
   miscAxesLengthDoubleSpinBox->setMaximum(50000.0);
   miscAxesLengthDoubleSpinBox->setSingleStep(10.0);
   miscAxesLengthDoubleSpinBox->setDecimals(1);
   QObject::connect(miscAxesLengthDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
   QHBoxLayout* miscSurfAxesLayout = new QHBoxLayout; 
   miscSurfAxesLayout->addWidget(miscSurfAxesLabel);
   miscSurfAxesLayout->addWidget(miscAxesLengthDoubleSpinBox);
   miscSurfAxesLayout->addStretch();
   
   //
   // Axes offset 
   //
   QLabel* miscSurfAxesOffsetLabel = new QLabel("Axes Offset ");
   miscAxesOffsetDoubleSpinBox[0] = new QDoubleSpinBox;
   miscAxesOffsetDoubleSpinBox[0]->setMinimum(-1000000.0);
   miscAxesOffsetDoubleSpinBox[0]->setMaximum( 1000000.0);
   miscAxesOffsetDoubleSpinBox[0]->setSingleStep(10.0);
   miscAxesOffsetDoubleSpinBox[0]->setDecimals(2);
   QObject::connect(miscAxesOffsetDoubleSpinBox[0], SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
   miscAxesOffsetDoubleSpinBox[1] = new QDoubleSpinBox;
   miscAxesOffsetDoubleSpinBox[1]->setMinimum(-1000000.0);
   miscAxesOffsetDoubleSpinBox[1]->setMaximum( 1000000.0);
   miscAxesOffsetDoubleSpinBox[1]->setSingleStep(10.0);
   miscAxesOffsetDoubleSpinBox[1]->setDecimals(2);
   QObject::connect(miscAxesOffsetDoubleSpinBox[1], SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
   miscAxesOffsetDoubleSpinBox[2] = new QDoubleSpinBox;
   miscAxesOffsetDoubleSpinBox[2]->setMinimum(-1000000.0);
   miscAxesOffsetDoubleSpinBox[2]->setMaximum( 1000000.0);
   miscAxesOffsetDoubleSpinBox[2]->setSingleStep(10.0);
   miscAxesOffsetDoubleSpinBox[2]->setDecimals(2);
   QObject::connect(miscAxesOffsetDoubleSpinBox[2], SIGNAL(valueChanged(double)),
                    this, SLOT(readMiscSelections()));
   QHBoxLayout* miscSurfAxesOffsetLayout = new QHBoxLayout;
   miscSurfAxesOffsetLayout->addWidget(miscSurfAxesOffsetLabel);
   miscSurfAxesOffsetLayout->addWidget(miscAxesOffsetDoubleSpinBox[0]);
   miscSurfAxesOffsetLayout->addWidget(miscAxesOffsetDoubleSpinBox[1]);
   miscSurfAxesOffsetLayout->addWidget(miscAxesOffsetDoubleSpinBox[2]);
   miscSurfAxesOffsetLayout->addStretch();
   
   //
   // Surface axes group box
   //
   miscAxesGroupBox = new QGroupBox("Surface Cartesian Axes");
   miscAxesGroupBox->setCheckable(true);
   miscVBoxLayout->addWidget(new QLabel(" "));
   miscVBoxLayout->addWidget(miscAxesGroupBox);
   QVBoxLayout* miscAxesGroupLayout = new QVBoxLayout(miscAxesGroupBox);
   miscAxesGroupLayout->addWidget(miscAxesShowLettersCheckBox);
   miscAxesGroupLayout->addWidget(miscAxesShowTickMarksCheckBox);
   miscAxesGroupLayout->addLayout(miscSurfAxesLayout);
   miscAxesGroupLayout->addLayout(miscSurfAxesOffsetLayout);
   QObject::connect(miscAxesGroupBox, SIGNAL(toggled(bool)),
                    this, SLOT(readMiscSelections()));
   miscAxesGroupBox->setFixedSize(miscAxesGroupBox->sizeHint());
   
   //
   // Limit size of page
   //
   pageSurfaceMisc->setFixedSize(pageSurfaceMisc->sizeHint());
   
   //
   // Widget group for all items in surf misc page
   //
   surfaceMiscWidgetGroup = new WuQWidgetGroup(this);
   surfaceMiscWidgetGroup->addWidget(miscLeftFiducialVolumeInteractionComboBox);
   surfaceMiscWidgetGroup->addWidget(miscRightFiducialVolumeInteractionComboBox);
   surfaceMiscWidgetGroup->addWidget(miscCerebellumFiducialVolumeInteractionComboBox);
   surfaceMiscWidgetGroup->addWidget(miscActiveFiducialComboBox);
   surfaceMiscWidgetGroup->addWidget(miscDrawModeComboBox);
   surfaceMiscWidgetGroup->addWidget(miscProjectionComboBox);
   surfaceMiscWidgetGroup->addWidget(miscBrightnessDoubleSpinBox);
   surfaceMiscWidgetGroup->addWidget(miscContrastDoubleSpinBox);
   surfaceMiscWidgetGroup->addWidget(opacityDoubleSpinBox);
   surfaceMiscWidgetGroup->addWidget(miscNodeSizeSpinBox);
   surfaceMiscWidgetGroup->addWidget(miscLinkSizeSpinBox);
   surfaceMiscWidgetGroup->addWidget(miscIdentifyNodeColorComboBox);
   surfaceMiscWidgetGroup->addWidget(miscShowNormalsCheckBox);
   surfaceMiscWidgetGroup->addWidget(miscTotalForcesCheckBox);
   surfaceMiscWidgetGroup->addWidget(miscAngularForcesCheckBox);
   surfaceMiscWidgetGroup->addWidget(miscLinearForcesCheckBox);
   surfaceMiscWidgetGroup->addWidget(miscForceVectorLengthDoubleSpinBox);
   surfaceMiscWidgetGroup->addWidget(miscAxesShowLettersCheckBox);
   surfaceMiscWidgetGroup->addWidget(miscAxesShowTickMarksCheckBox);
   surfaceMiscWidgetGroup->addWidget(miscAxesLengthDoubleSpinBox);
   surfaceMiscWidgetGroup->addWidget(miscAxesOffsetDoubleSpinBox[0]);
   surfaceMiscWidgetGroup->addWidget(miscAxesOffsetDoubleSpinBox[1]);
   surfaceMiscWidgetGroup->addWidget(miscAxesOffsetDoubleSpinBox[2]);
   surfaceMiscWidgetGroup->addWidget(miscAxesGroupBox);
}

/**
 * Update the items on the misc page
 */
void
06115 GuiDisplayControlDialog::updateMiscItems()
{
   updatePageSelectionComboBox();
   if (pageSurfaceMisc == NULL) {
      return;
   }
   
   surfaceMiscWidgetGroup->blockSignals(true);
   
   //
   // Display settings for nodes
   //
   DisplaySettingsSurface* dsn = theMainWindow->getBrainSet()->getDisplaySettingsSurface();
 
   miscLeftFiducialVolumeInteractionComboBox->updateComboBox();
   miscLeftFiducialVolumeInteractionComboBox->setSelectedBrainModel(theMainWindow->getBrainSet()->getLeftFiducialVolumeInteractionSurface());
   miscRightFiducialVolumeInteractionComboBox->updateComboBox();
   miscRightFiducialVolumeInteractionComboBox->setSelectedBrainModel(theMainWindow->getBrainSet()->getRightFiducialVolumeInteractionSurface());
   miscCerebellumFiducialVolumeInteractionComboBox->updateComboBox();
   miscCerebellumFiducialVolumeInteractionComboBox->setSelectedBrainModel(theMainWindow->getBrainSet()->getCerebellumFiducialVolumeInteractionSurface());
   miscActiveFiducialComboBox->updateComboBox();
   miscActiveFiducialComboBox->setSelectedBrainModel(theMainWindow->getBrainSet()->getActiveFiducialSurface());
   miscDrawModeComboBox->setCurrentIndex(dsn->getDrawMode());
   miscProjectionComboBox->setCurrentIndex(dsn->getViewingProjection());
   miscBrightnessDoubleSpinBox->setValue(dsn->getNodeBrightness());
   miscContrastDoubleSpinBox->setValue(dsn->getNodeContrast());
   opacityDoubleSpinBox->setValue(dsn->getOpacity());
   miscNodeSizeSpinBox->setValue(dsn->getNodeSize());
   miscLinkSizeSpinBox->setValue(dsn->getLinkSize());
   miscShowNormalsCheckBox->setChecked(dsn->getShowNormals());
   miscTotalForcesCheckBox->setChecked(dsn->getShowMorphingTotalForces());
   miscAngularForcesCheckBox->setChecked(dsn->getShowMorphingAngularForces());
   miscLinearForcesCheckBox->setChecked(dsn->getShowMorphingLinearForces());
   miscForceVectorLengthDoubleSpinBox->setValue(dsn->getForceVectorDisplayLength());
   miscIdentifyNodeColorComboBox->setCurrentIndex(dsn->getIdentifyNodeColor());
   bool showAxes, showLetters, showHashMarks;
   float axesLength, offset[3];
   dsn->getSurfaceAxesInfo(showAxes, showLetters, showHashMarks, axesLength, offset);
   miscAxesGroupBox->setChecked(showAxes);
   miscAxesShowLettersCheckBox->setChecked(showLetters);
   miscAxesShowTickMarksCheckBox->setChecked(showHashMarks);
   miscAxesLengthDoubleSpinBox->setValue(axesLength);
   miscAxesOffsetDoubleSpinBox[0]->setValue(offset[0]);
   miscAxesOffsetDoubleSpinBox[1]->setValue(offset[1]);
   miscAxesOffsetDoubleSpinBox[2]->setValue(offset[2]);

   surfaceMiscWidgetGroup->blockSignals(false);
}

/**
 * Read the selections on the misc page
 */
void
06168 GuiDisplayControlDialog::readMiscSelections()
{
   if (creatingDialog) {
      return;
   }
   
   //
   // Update fiducial/volume interaction surfaces
   //
   theMainWindow->getBrainSet()->setLeftFiducialVolumeInteractionSurface(
      miscLeftFiducialVolumeInteractionComboBox->getSelectedBrainModelSurface());
   theMainWindow->getBrainSet()->setRightFiducialVolumeInteractionSurface(
      miscRightFiducialVolumeInteractionComboBox->getSelectedBrainModelSurface());
   theMainWindow->getBrainSet()->setCerebellumFiducialVolumeInteractionSurface(
      miscCerebellumFiducialVolumeInteractionComboBox->getSelectedBrainModelSurface());
      
   //
   // Update active fiducial surface
   //
   BrainModelSurface* active = miscActiveFiducialComboBox->getSelectedBrainModelSurface();
   if (active != NULL) {
      BrainModelSurface* currentActive = theMainWindow->getBrainSet()->getActiveFiducialSurface();
      if (currentActive != active) {
         theMainWindow->getBrainSet()->setActiveFiducialSurface(active);
      }
   }
   
   //
   // Display settings for nodes
   //
   DisplaySettingsSurface* dsn = theMainWindow->getBrainSet()->getDisplaySettingsSurface();
   
   dsn->setDrawMode(
      static_cast<DisplaySettingsSurface::DRAW_MODE>(miscDrawModeComboBox->currentIndex()));
   dsn->setViewingProjection(static_cast<DisplaySettingsSurface::VIEWING_PROJECTION>(
                       miscProjectionComboBox->currentIndex()));
   dsn->setNodeBrightness(miscBrightnessDoubleSpinBox->value());
   dsn->setNodeContrast(miscContrastDoubleSpinBox->value());
   dsn->setOpacity(opacityDoubleSpinBox->value());
   dsn->setNodeSize(miscNodeSizeSpinBox->value());
   dsn->setLinkSize(miscLinkSizeSpinBox->value());
   dsn->setShowNormals(miscShowNormalsCheckBox->isChecked());
   dsn->setShowMorphingTotalForces(miscTotalForcesCheckBox->isChecked());
   dsn->setShowMorphingAngularForces(miscAngularForcesCheckBox->isChecked());
   dsn->setShowMorphingLinearForces(miscLinearForcesCheckBox->isChecked());
   dsn->setForceVectorDisplayLength(miscForceVectorLengthDoubleSpinBox->value());
   dsn->setIdentifyNodeColor(static_cast<DisplaySettingsSurface::IDENTIFY_NODE_COLOR>(
                                       miscIdentifyNodeColorComboBox->currentIndex()));
                                       
   const float offset[3] = {
      miscAxesOffsetDoubleSpinBox[0]->value(),
      miscAxesOffsetDoubleSpinBox[1]->value(),
      miscAxesOffsetDoubleSpinBox[2]->value()
   };
   dsn->setSurfaceAxesInfo(miscAxesGroupBox->isChecked(),
                           miscAxesShowLettersCheckBox->isChecked(),
                           miscAxesShowTickMarksCheckBox->isChecked(),
                           miscAxesLengthDoubleSpinBox->value(),
                           offset);

   theMainWindow->getBrainSet()->getNodeColoring()->assignColors();
   GuiBrainModelOpenGL::updateAllGL(NULL); 
}

/**
 * Create the probabilistic atlas surface main page
 */
void
06236 GuiDisplayControlDialog::createProbAtlasSurfaceMainPage()
{
   //
   // Normal/Threshold buttons
   //
   probAtlasSurfaceNormalButton = new QRadioButton("Normal");
   probAtlasSurfaceThresholdButton = new QRadioButton("Threshold");

   //
   // Button group for probabilistic display type
   //
   QButtonGroup* probButtonGroup = new QButtonGroup(this);
   QObject::connect(probButtonGroup, SIGNAL(buttonClicked(int)),
                    this, SLOT(probAtlasSurfaceModeSelection(int)));
   probButtonGroup->addButton(probAtlasSurfaceNormalButton, 0);
   probButtonGroup->addButton(probAtlasSurfaceThresholdButton, 1);

   //
   // Group box for display mode
   //
   QGroupBox* displayModeGroupBox = new QGroupBox("Display Mode");
   QVBoxLayout* displayModeGroupLayout = new QVBoxLayout(displayModeGroupBox);
   displayModeGroupLayout->addWidget(probAtlasSurfaceNormalButton);
   displayModeGroupLayout->addWidget(probAtlasSurfaceThresholdButton);
   displayModeGroupBox->setFixedSize(displayModeGroupBox->sizeHint());
   
   //
   // Treat button
   //
   probAtlasSurfaceUnassignedButton = new QCheckBox("Treat name \"???\" as if it was name \"Unassigned\"");
   QObject::connect(probAtlasSurfaceUnassignedButton, SIGNAL(clicked()),
                    this, SLOT(readProbAtlasSurfaceMainPage()));
   //
   // Threshold ratio
   //
   QLabel* ratioLabel = new QLabel("Threshold Ratio  ");
   probAtlasSurfaceThresholdRatioDoubleSpinBox = new QDoubleSpinBox;
   probAtlasSurfaceThresholdRatioDoubleSpinBox->setMinimum(0.0);
   probAtlasSurfaceThresholdRatioDoubleSpinBox->setMaximum(1.0);
   probAtlasSurfaceThresholdRatioDoubleSpinBox->setSingleStep(0.1);
   probAtlasSurfaceThresholdRatioDoubleSpinBox->setDecimals(2);
   QObject::connect(probAtlasSurfaceThresholdRatioDoubleSpinBox, SIGNAL(valueChanged(double)),
                    this, SLOT(readProbAtlasSurfaceMainPage()));
   QHBoxLayout* ratioLayout = new QHBoxLayout;
   ratioLayout->addWidget(ratioLabel);
   ratioLayout->addWidget(probAtlasSurfaceThresholdRatioDoubleSpinBox);
   ratioLayout->addStretch();
   
   QLabel* questLabel = new QLabel("\nNote: Names \"???\", \"GYRAL\", and \"GYRUS\" are\n"
                                   "ignored when Threshold Display Mode is selected.");
              
                    
   //
   // Display color key button
   //
   QPushButton* colorKeyPushButton = new QPushButton("Display Color Key...");
   colorKeyPushButton->setFixedSize(colorKeyPushButton->sizeHint());
   colorKeyPushButton->setAutoDefault(false);
   QObject::connect(colorKeyPushButton, SIGNAL(clicked()),
                    theMainWindow, SLOT(displayProbabilisticAtlasColorKey()));
                    
   //
   // Set study metadata link button
   //
   QPushButton* studyMetaDataLinkPushButton = new QPushButton("Study Metadata Link...");
   studyMetaDataLinkPushButton->setFixedSize(studyMetaDataLinkPushButton->sizeHint());
   studyMetaDataLinkPushButton->setAutoDefault(false);
   QObject::connect(studyMetaDataLinkPushButton, SIGNAL(clicked()),
                    this, SLOT(volumeProbAtlasSurfaceStudyMetaDataPushButton()));
   
   //
   // Widget and layout
   //
   pageProbAtlasSurfaceMain = new QWidget;
   QVBoxLayout* probAtlasSurfaceLayout = new QVBoxLayout(pageProbAtlasSurfaceMain);
   probAtlasSurfaceLayout->addWidget(displayModeGroupBox);
   probAtlasSurfaceLayout->addWidget(probAtlasSurfaceUnassignedButton);
   probAtlasSurfaceLayout->addLayout(ratioLayout);
   probAtlasSurfaceLayout->addWidget(questLabel);
   probAtlasSurfaceLayout->addWidget(colorKeyPushButton);
   probAtlasSurfaceLayout->addWidget(studyMetaDataLinkPushButton);
   probAtlasSurfaceLayout->addStretch();

   pageWidgetStack->addWidget(pageProbAtlasSurfaceMain);
}

/**
 * called to set prob atlas surface study metadata link.
 */
void 
06326 GuiDisplayControlDialog::volumeProbAtlasSurfaceStudyMetaDataPushButton()
{
   ProbabilisticAtlasFile* paf = theMainWindow->getBrainSet()->getProbabilisticAtlasSurfaceFile();
   StudyMetaDataLinkSet smdls = paf->getStudyMetaDataLinkSet();
   GuiStudyMetaDataLinkCreationDialog smdlcd(this);
   smdlcd.initializeSelectedLinkSet(smdls);
   if (smdlcd.exec() == GuiStudyMetaDataLinkCreationDialog::Accepted) {
      smdls = smdlcd.getLinkSetCreated();
      paf->setStudyMetaDataLinkSet(smdls);
   }
}
      
/**
 * Slot for prob atlas mode selection.
 */
void
06342 GuiDisplayControlDialog::probAtlasSurfaceModeSelection(int num)
{
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   dspa->setDisplayType(
      static_cast<DisplaySettingsProbabilisticAtlas::PROBABILISTIC_DISPLAY_TYPE>(num));
   readProbAtlasSurfaceMainPage();
}

/**
 * Create prob atlas surface channel selection page
 */
void
06354 GuiDisplayControlDialog::createProbAtlasSurfaceChannelPage()
{
   //
   // widget and layout for chanel sub page
   //
   pageProbAtlasSurfaceChannel = new QWidget;
   pageProbAtlasSurfaceChannel->setFixedWidth(450);
   probAtlasSurfaceSubPageChannelLayout = new QVBoxLayout(pageProbAtlasSurfaceChannel);
   
   //
   // All off and all on pushbuttons
   //
   QPushButton* probAtlasSurfaceChannelAllOnButton = new QPushButton("All On");
   probAtlasSurfaceChannelAllOnButton->setAutoDefault(false);
   QObject::connect(probAtlasSurfaceChannelAllOnButton, SIGNAL(clicked()),
                    this, SLOT(probAtlasSurfaceChannelAllOn()));
   QPushButton* probAtlasSurfaceChannelAllOffButton = new QPushButton("All Off");
   probAtlasSurfaceChannelAllOffButton->setAutoDefault(false);
   QObject::connect(probAtlasSurfaceChannelAllOffButton, SIGNAL(clicked()),
                    this, SLOT(probAtlasSurfaceChannelAllOff()));
   QHBoxLayout* allOnOffButtonsLayout = new QHBoxLayout;         
   allOnOffButtonsLayout->addWidget(probAtlasSurfaceChannelAllOnButton);
   allOnOffButtonsLayout->addWidget(probAtlasSurfaceChannelAllOffButton);
   allOnOffButtonsLayout->addStretch();
   probAtlasSurfaceSubPageChannelLayout->addLayout(allOnOffButtonsLayout);
   
   createAndUpdateProbAtlasSurfaceChannelCheckBoxes();

   pageWidgetStack->addWidget(pageProbAtlasSurfaceChannel);
}

/**
 * This slot is called when the prob atlas surface channel all on button is pressed
 */
void
06389 GuiDisplayControlDialog::probAtlasSurfaceChannelAllOn()
{
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   dspa->setAllChannelsSelectedStatus(true);
   updateProbAtlasSurfaceItems();
   readProbAtlasSurfaceChannelPage();
}

/**
 * This slot is called when the prob atlas surfacechannel all off button is pressed
 */
void
06401 GuiDisplayControlDialog::probAtlasSurfaceChannelAllOff()
{
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   dspa->setAllChannelsSelectedStatus(false);
   updateProbAtlasSurfaceItems();
   readProbAtlasSurfaceChannelPage();
}

/**
 * caret prob atlas surface area selection page
 */
void
06413 GuiDisplayControlDialog::createProbAtlasSurfaceAreaPage()
{
   //
   // Vertical Box Layout for all items
   //
   pageProbAtlasSurfaceArea = new QWidget;
   pageProbAtlasSurfaceArea->setFixedWidth(450);
   probAtlasSurfaceSubPageAreaLayout = new QVBoxLayout(pageProbAtlasSurfaceArea);
   
   //
   // All off and all on pushbuttons
   //
   QPushButton* probAtlasSurfaceAreasAllOnButton = new QPushButton("All On");
   probAtlasSurfaceAreasAllOnButton->setAutoDefault(false);
   QObject::connect(probAtlasSurfaceAreasAllOnButton, SIGNAL(clicked()),
                    this, SLOT(probAtlasSurfaceAreasAllOn()));
   QPushButton* probAtlasSurfaceAreasAllOffButton = new QPushButton("All Off");
   probAtlasSurfaceAreasAllOffButton->setAutoDefault(false);
   QObject::connect(probAtlasSurfaceAreasAllOffButton, SIGNAL(clicked()),
                    this, SLOT(probAtlasSurfaceAreasAllOff()));
   QHBoxLayout* allOnOffButtonsLayout = new QHBoxLayout;
   allOnOffButtonsLayout->addWidget(probAtlasSurfaceAreasAllOnButton);
   allOnOffButtonsLayout->addWidget(probAtlasSurfaceAreasAllOffButton);
   allOnOffButtonsLayout->addStretch();
   probAtlasSurfaceSubPageAreaLayout->addLayout(allOnOffButtonsLayout);
   
   createAndUpdateProbAtlasSurfaceAreaNameCheckBoxes();

   pageWidgetStack->addWidget(pageProbAtlasSurfaceArea);
}

/**
 * This slot is called when the prob atlas surfce areas all on button is pressed
 */
void
06448 GuiDisplayControlDialog::probAtlasSurfaceAreasAllOn()
{
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   dspa->setAllAreasSelectedStatus(true);
   updateProbAtlasSurfaceItems();
   readProbAtlasSurfaceAreaPage();
}

/**
 * This slot is called when the prob atlas surface areas all off button is pressed
 */
void
06460 GuiDisplayControlDialog::probAtlasSurfaceAreasAllOff()
{
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   dspa->setAllAreasSelectedStatus(false);
   updateProbAtlasSurfaceItems();
   readProbAtlasSurfaceAreaPage();
}

/**
 * read the probabilistic atlas surface main page.
 */
void 
06472 GuiDisplayControlDialog::readProbAtlasSurfaceMainPage()
{
   if (pageProbAtlasSurfaceMain == NULL) {
      return;
   }
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   dspa->setTreatQuestColorAsUnassigned(probAtlasSurfaceUnassignedButton->isChecked());
   dspa->setThresholdDisplayTypeRatio(probAtlasSurfaceThresholdRatioDoubleSpinBox->value());  
    
   theMainWindow->getBrainSet()->getNodeColoring()->assignColors();
   GuiBrainModelOpenGL::updateAllGL(NULL); 
   theMainWindow->getBrainSet()->getNodeColoring()->assignColors();
   GuiBrainModelOpenGL::updateAllGL(NULL); 
}

/**
 * read the probabilistic atlas surface channel page.
 */
void 
06491 GuiDisplayControlDialog::readProbAtlasSurfaceChannelPage()
{
   if (pageProbAtlasSurfaceChannel == NULL) {
      return;
   }
   ProbabilisticAtlasFile* paf = theMainWindow->getBrainSet()->getProbabilisticAtlasSurfaceFile();
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   const int numChannels = paf->getNumberOfColumns();
   if (numChannels == numValidProbAtlasSurfaceChannels) {
      for (int i = 0; i < numChannels; i++)  {
         dspa->setChannelSelected(i, probAtlasSurfaceChannelCheckBoxes[i]->isChecked());
      }
   }
   else {
      std::cerr << "Number of prob atlas surfce channel checkboxes does not equal number of "
                << "prob atlas channels." << std::endl;
   }
   theMainWindow->getBrainSet()->getNodeColoring()->assignColors();
   GuiBrainModelOpenGL::updateAllGL(NULL); 
}

/**
 * read the probabilistic atlas surface area page.
 */
void 
06516 GuiDisplayControlDialog::readProbAtlasSurfaceAreaPage()
{
   if (pageProbAtlasSurfaceArea == NULL) {
      return;
   }
   ProbabilisticAtlasFile* paf = theMainWindow->getBrainSet()->getProbabilisticAtlasSurfaceFile();
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   const int numAreas = paf->getNumberOfPaintNames();
   if (numAreas == numValidProbAtlasSurfaceAreas) {
      for (int i = 0; i < numAreas; i++) {
         dspa->setAreaSelected(i, probAtlasSurfaceAreasCheckBoxes[i]->isChecked());
      }
   }
   else {
      std::cerr << "Number of prob atlas surface area checkboxes does not equal number of "
                << "prob atlas surface areas." << std::endl;
   }
   theMainWindow->getBrainSet()->getNodeColoring()->assignColors();
   GuiBrainModelOpenGL::updateAllGL(NULL); 
}
      
/**
 * Read the prob atlas surface selections.
 */
void 
06541 GuiDisplayControlDialog::readProbAtlasSurfaceL2LR2R()
{
   if (creatingDialog) {
      return;
   }
   
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   dspa->setApplySelectionToLeftAndRightStructuresFlag(probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox->isChecked());
   theMainWindow->getBrainSet()->getNodeColoring()->assignColors();
   GuiBrainModelOpenGL::updateAllGL(NULL); 
   displayOverlayLeftToLeftRightToRightMessage();
}

/**
 * create and update the check boxes for prob atlas surface channels
 */
void
06558 GuiDisplayControlDialog::createAndUpdateProbAtlasSurfaceChannelCheckBoxes()
{
   ProbabilisticAtlasFile* paf = theMainWindow->getBrainSet()->getProbabilisticAtlasSurfaceFile();
   numValidProbAtlasSurfaceChannels = paf->getNumberOfColumns();
   
   const int numExistingCheckBoxes = static_cast<int>(probAtlasSurfaceChannelCheckBoxes.size());
   
   if (probAtlasSurfaceChannelGridLayout == NULL) {
      //
      // Create the page and layout
      //
      QWidget* channelPage = new QWidget;
      probAtlasSurfaceChannelGridLayout = new QGridLayout(channelPage);
      const int rowStretchNumber    = 15000;
      probAtlasSurfaceChannelGridLayout->addWidget(new QLabel(""),
                                           rowStretchNumber, 0, 1, 1, Qt::AlignLeft);
      probAtlasSurfaceChannelGridLayout->setRowStretch(rowStretchNumber, 1000);
      
      probAtlasSurfaceSubPageChannelLayout->addWidget(channelPage);
   }
   
   if (probAtlasSurfaceChannelButtonGroup == NULL) {
      probAtlasSurfaceChannelButtonGroup = new QButtonGroup(this);
      probAtlasSurfaceChannelButtonGroup->setExclusive(false);
      QObject::connect(probAtlasSurfaceChannelButtonGroup, SIGNAL(buttonClicked(int)),
                       this, SLOT(readProbAtlasSurfaceChannelPage()));
   }
   
   //
   // update existing checkboxes
   //
   for (int i = 0; i < numExistingCheckBoxes; i++) {
      if (i < numValidProbAtlasSurfaceChannels) {
         probAtlasSurfaceChannelCheckBoxes[i]->setText(paf->getColumnName(i));
         probAtlasSurfaceChannelCheckBoxes[i]->show();
      }
   }
   
   //
   // Add new checkboxes as needed
   //
   for (int j = numExistingCheckBoxes; j < numValidProbAtlasSurfaceChannels; j++) {
      QCheckBox* cb = new QCheckBox(paf->getColumnName(j));
      probAtlasSurfaceChannelCheckBoxes.push_back(cb);
      probAtlasSurfaceChannelButtonGroup->addButton(cb, j);
      probAtlasSurfaceChannelGridLayout->addWidget(cb, j, 0, 1, 1, Qt::AlignLeft);
      cb->show();
   }
   
   //
   // Hide existing checkboxes that are not needed
   //
   for (int k = numValidProbAtlasSurfaceChannels; k < numExistingCheckBoxes; k++) {
      probAtlasSurfaceChannelCheckBoxes[k]->hide();
   }
}

/**
 * create and update the check boxes for prob atlas surface area names
 */
void
06619 GuiDisplayControlDialog::createAndUpdateProbAtlasSurfaceAreaNameCheckBoxes()
{
   ProbabilisticAtlasFile* paf = theMainWindow->getBrainSet()->getProbabilisticAtlasSurfaceFile();
   numValidProbAtlasSurfaceAreas = paf->getNumberOfPaintNames();
   
   const int numExistingCheckBoxes = static_cast<int>(probAtlasSurfaceAreasCheckBoxes.size());
   
   if (probAtlasSurfaceAreasGridLayout == NULL) {
      //
      QWidget* areasWidget = new QWidget; 
      probAtlasSurfaceAreasGridLayout = new QGridLayout(areasWidget);
      const int rowStretchNumber    = 15000;
      probAtlasSurfaceAreasGridLayout->addWidget(new QLabel(""),
                                           rowStretchNumber, 0, 1, 1, Qt::AlignLeft);
      probAtlasSurfaceAreasGridLayout->setRowStretch(rowStretchNumber, 1000);
      
      probAtlasSurfaceSubPageAreaLayout->addWidget(areasWidget);
   }
   
   if (probAtlasSurfaceAreasButtonGroup == NULL) {
      probAtlasSurfaceAreasButtonGroup = new QButtonGroup(this);
      probAtlasSurfaceAreasButtonGroup->setExclusive(false);
      QObject::connect(probAtlasSurfaceAreasButtonGroup, SIGNAL(buttonClicked(int)),
                       this, SLOT(readProbAtlasSurfaceAreaPage()));
   }
   
   //
   // update existing checkboxes
   //
   for (int i = 0; i < numExistingCheckBoxes; i++) {
      if (i < numValidProbAtlasSurfaceAreas) {
         probAtlasSurfaceAreasCheckBoxes[i]->setText(paf->getPaintNameFromIndex(i));
         probAtlasSurfaceAreasCheckBoxes[i]->show();
      }
   }
   
   //
   // Add new checkboxes as needed
   //
   for (int j = numExistingCheckBoxes; j < numValidProbAtlasSurfaceAreas; j++) {
      QCheckBox* cb = new QCheckBox(paf->getPaintNameFromIndex(j));
      probAtlasSurfaceAreasCheckBoxes.push_back(cb);
      probAtlasSurfaceAreasButtonGroup->addButton(cb, j);
      probAtlasSurfaceAreasGridLayout->addWidget(cb, j, 0, 1, 1, Qt::AlignLeft);
      cb->show();
   }
   
   //
   // Hide existing checkboxes that are not needed
   //
   for (int k = numValidProbAtlasSurfaceAreas; k < numExistingCheckBoxes; k++) {
      probAtlasSurfaceAreasCheckBoxes[k]->hide();
   }
}

/**
 * update prob atlas surface main page.
 */
void 
06678 GuiDisplayControlDialog::updateProbAtlasSurfaceMainPage()
{
   if (pageProbAtlasSurfaceMain == NULL) {
      return;
   }
   
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   probAtlasSurfaceUnassignedButton->setChecked(dspa->getTreatQuestColorAsUnassigned());
   
   switch(dspa->getDisplayType()) {
      case DisplaySettingsProbabilisticAtlas::PROBABILISTIC_DISPLAY_TYPE_NORMAL:
         probAtlasSurfaceNormalButton->setChecked(true);
         break;
      case DisplaySettingsProbabilisticAtlas::PROBABILISTIC_DISPLAY_TYPE_THRESHOLD:
         probAtlasSurfaceThresholdButton->setChecked(true);
         break;
   }
   probAtlasSurfaceThresholdRatioDoubleSpinBox->setValue(dspa->getThresholdDisplayTypeRatio());
   pageProbAtlasSurfaceMain->setEnabled(validProbAtlasSurfaceData);
}

/**
 * update prob atlas surface channel page.
 */
void 
06703 GuiDisplayControlDialog::updateProbAtlasSurfaceChannelPage(const bool filesWereChanged)
{
   if (pageProbAtlasSurfaceChannel == NULL) {
      return;
   }

   ProbabilisticAtlasFile* paf = theMainWindow->getBrainSet()->getProbabilisticAtlasSurfaceFile();
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();

   if (filesWereChanged) {
      createAndUpdateProbAtlasSurfaceChannelCheckBoxes();
   }
   const int numChannels = paf->getNumberOfColumns();
   if (numChannels == numValidProbAtlasSurfaceChannels) {
      for (int i = 0; i < numValidProbAtlasSurfaceChannels; i++) {
         probAtlasSurfaceChannelCheckBoxes[i]->setChecked(dspa->getChannelSelected(i));
      }
   }
   else {
      std::cerr << "Number of prob atlas surface channel checkboxes " << numValidProbAtlasSurfaceChannels
                << " does not equal number of prob "
                << "atlas surface channels" << numChannels << "." << std::endl;
   }
   pageProbAtlasSurfaceChannel->setEnabled(validProbAtlasSurfaceData);
}

/**
 * update prob atlas surface area page.
 */
void 
06733 GuiDisplayControlDialog::updateProbAtlasSurfaceAreaPage(const bool filesWereChanged)
{
   if (pageProbAtlasSurfaceArea == NULL) {
      return;
   }
   
   ProbabilisticAtlasFile* paf = theMainWindow->getBrainSet()->getProbabilisticAtlasSurfaceFile();
   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();

   if (filesWereChanged) {
      createAndUpdateProbAtlasSurfaceAreaNameCheckBoxes();
   }
   const int numAreas = paf->getNumberOfPaintNames();
   if (numAreas == numValidProbAtlasSurfaceAreas) {
      for (int i = 0; i < numValidProbAtlasSurfaceAreas; i++) {
         probAtlasSurfaceAreasCheckBoxes[i]->setChecked(dspa->getAreaSelected(i));
      }
   }
   else {
      std::cerr << "Number of prob atlas surface area checkboxes " << numValidProbAtlasSurfaceAreas
                << " does not equal number of prob "
                << "atlas surface areas" << numAreas << "." << std::endl;
   }
   pageProbAtlasSurfaceArea->setEnabled(validProbAtlasSurfaceData);
}

/**
 * update prob atlas surface overlay/underlay selection.
 */
void 
06763 GuiDisplayControlDialog::updateProbAtlasSurfaceOverlayUnderlaySelection()
{
}

/**
 * Update prob atlas surface items in dialog
 */
void 
06771 GuiDisplayControlDialog::updateProbAtlasSurfaceItems(const bool filesChanged)
{   
   updatePageSelectionComboBox();

   updateProbAtlasSurfaceOverlayUnderlaySelection();

   DisplaySettingsProbabilisticAtlas* dspa = theMainWindow->getBrainSet()->getDisplaySettingsProbabilisticAtlasSurface();
   
   probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox->blockSignals(true);
   probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox->setChecked(dspa->getApplySelectionToLeftAndRightStructuresFlag());
   probAtlasSurfaceApplySelectionToLeftAndRightStructuresFlagCheckBox->blockSignals(false);
   
   updateProbAtlasSurfaceMainPage();
   updateProbAtlasSurfaceChannelPage(filesChanged);
   updateProbAtlasSurfaceAreaPage(filesChanged);
}

/**
 * Create the topography page.
 */
void
06792 GuiDisplayControlDialog::createTopographyPage()
{  
   //
   // Eccentricity/Polar Angle.
   //
   topographyTypeEccentricityRadioButton = new QRadioButton("Eccentricity");
   topographyPolarAngleRadioButton = new QRadioButton("Polar Angle");
   
   //
   // Button group for eccentricity/polar angle buttons
   //
   QButtonGroup* topographyButtonGroup = new QButtonGroup(this);
   QObject::connect(topographyButtonGroup, SIGNAL(buttonClicked(int)),
                    this, SLOT(topographyTypeSelection(int)));
   topographyButtonGroup->addButton(topographyTypeEccentricityRadioButton,
      static_cast<int>(DisplaySettingsTopography::TOPOGRAPHY_DISPLAY_ECCENTRICITY));
   topographyButtonGroup->addButton(topographyPolarAngleRadioButton,
      static_cast<int>(DisplaySettingsTopography::TOPOGRAPHY_DISPLAY_POLAR_ANGLE));
   
   //
   //  Group box for display mode
   //
   QGroupBox* topographyGroup = new QGroupBox("Display Mode");
   QVBoxLayout* topographyGroupLayout = new QVBoxLayout(topographyGroup);
   topographyGroupLayout->addWidget(topographyTypeEccentricityRadioButton);
   topographyGroupLayout->addWidget(topographyPolarAngleRadioButton);
   topographyGroup->setFixedSize(topographyGroup->sizeHint());
   
   //
   // Topography page and layout
   //
   pageTopography = new QWidget;
   pageWidgetStack->addWidget(pageTopography); // adds to dialog
   QVBoxLayout* topographyLayout = new QVBoxLayout(pageTopography);
   topographyLayout->addWidget(topographyGroup);
   topographyLayout->addStretch();
}

/**
 * Read the topography selections.
 */
void 
06834 GuiDisplayControlDialog::readTopographySelections()
{
   updateSurfaceOverlayWidgets();
   theMainWindow->getBrainSet()->getNodeColoring()->assignColors();
   GuiBrainModelOpenGL::updateAllGL(NULL);   
}

/**
 * Update topography items in dialog
 */
void 
06845 GuiDisplayControlDialog::updateTopographyItems()
{
   updatePageSelectionComboBox();

   if (pageTopography == NULL) {
      return;
   }
   
   DisplaySettingsTopography* dst = theMainWindow->getBrainSet()->getDisplaySettingsTopography();
   
   switch(dst->getDisplayType()) {
      case DisplaySettingsTopography::TOPOGRAPHY_DISPLAY_ECCENTRICITY:
         topographyTypeEccentricityRadioButton->setChecked(true);
         break;
      case DisplaySettingsTopography::TOPOGRAPHY_DISPLAY_POLAR_ANGLE:
         topographyPolarAngleRadioButton->setChecked(true);
         break;
   }
      
   pageTopography->setEnabled(validTopographyData);
}

void
06868 GuiDisplayControlDialog::topographyTypeSelection(int typeSelected)
{
   DisplaySettingsTopography* dst = theMainWindow->getBrainSet()->getDisplaySettingsTopography();
   dst->setDisplayType(static_cast<DisplaySettingsTopography::TOPOGRAPHY_DISPLAY_TYPE>(
                                                                           typeSelected));
   
   readTopographySelections();   
}

/**
 * create the geodesic page.
 */
void 
06881 GuiDisplayControlDialog::createGeodesicPage()
{
   //
   // Widget for geodesic items
   //
   pageGeodesicMain = new QWidget;
   pageWidgetStack->addWidget(pageGeodesicMain);  // adds to dialog
   geodesicMainPageLayout = new QVBoxLayout(pageGeodesicMain);
   
   //
   // Enable geodesic check box
   //
   geodesicDistanceEnableCheckBox = new QCheckBox("Enable Geodesic Path For Identified Nodes");
   QObject::connect(geodesicDistanceEnableCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readGeodesicSelections()));
   geodesicMainPageLayout->addWidget(geodesicDistanceEnableCheckBox);
   
   //
   // Show root node check box
   //
   geodesicShowRootNodeCheckBox = new QCheckBox("Show Root Node");
   QObject::connect(geodesicShowRootNodeCheckBox, SIGNAL(toggled(bool)),
                    this, SLOT(readGeodesicSelections()));
   geodesicMainPageLayout->addWidget(geodesicShowRootNodeCheckBox);
                    
   //
   // Path width spin box
   //
   QLabel* pathLabel = new QLabel("Path Line Width ");
   float minWF, maxWF;
   GuiBrainModelOpenGL::getLineWidthRange(minWF, maxWF);
   const int minW = static_cast<int>(minWF);
   const int maxW = static_cast<int>(maxWF);
   geodesicPathLineWidthSpinBox = new QSpinBox;
   geodesicPathLineWidthSpinBox->setMinimum(minW);
   geodesicPathLineWidthSpinBox->setMaximum(maxW);
   geodesicPathLineWidthSpinBox->setSingleStep(1);
   QObject::connect(geodesicPathLineWidthSpinBox, SIGNAL(valueChanged(int)),
                    this, SLOT(readGeodesicSelections()));
   QHBoxLayout* pathLayout = new QHBoxLayout;
   pathLayout->addWidget(pathLabel);
   pathLayout->addWidget(geodesicPathLineWidthSpinBox);
   pathLayout->addStretch();
   geodesicMainPageLayout->addLayout(pathLayout);
   
   
   //
   // Selection button group
   //
   geodesicSelectionButtonGroup = new QButtonGroup(this);
   geodesicSelectionButtonGroup->setExclusive(true);
   QObject::connect(geodesicSelectionButtonGroup, SIGNAL(buttonClicked(int)),
                    this, SLOT(readGeodesicSelections()));
                    
   //
   // comment button group
   //
   geodesicCommentButtonGroup = new QButtonGroup(this);
   QObject::connect(geodesicCommentButtonGroup, SIGNAL(buttonClicked(int)),
                     this, SLOT(geodesicCommentColumnSelection(int)));
}

/**
 * Called to display comment information about a geodesic column.
 */
void
06947 GuiDisplayControlDialog::geodesicCommentColumnSelection(int column)
{
   GeodesicDistanceFile* gdf = theMainWindow->getBrainSet()->getGeodesicDistanceFile();
   if ((column >= 0) && (column < gdf->getNumberOfColumns())) {
      GuiDataFileCommentDialog* dfcd = new GuiDataFileCommentDialog(theMainWindow,
                                                                    gdf, column);
      dfcd->show();
   }
}

/**
 * Create and update the geodesic page.
 */
void
06961 GuiDisplayControlDialog::createAndUpdateGeodesicPage()
{
   GeodesicDistanceFile* gdf = theMainWindow->getBrainSet()->getGeodesicDistanceFile();
   numValidGeodesic = gdf->getNumberOfColumns();
   
   const int numExistingGeodesic = static_cast<int>(geodesicNameLineEdits.size());
   
   const int nameMinimumWidth = 400;

   if (geodesicSelectionGridLayout == NULL) {
      QWidget* geodesicSelectionWidget = new QWidget;
      geodesicSelectionGridLayout = new QGridLayout(geodesicSelectionWidget);
      geodesicSelectionGridLayout->setMargin(3);
      geodesicSelectionGridLayout->setSpacing(3);
      geodesicSelectionGridLayout->setColumnMinimumWidth(2, nameMinimumWidth+20);
      const int rowStretchNumber    = 15000;
      geodesicSelectionGridLayout->addWidget(new QLabel(""),
                                           rowStretchNumber, 3, 1, 1, Qt::AlignLeft);
      geodesicSelectionGridLayout->setColumnStretch(0, 1);
      geodesicSelectionGridLayout->setColumnStretch(1, 1);
      geodesicSelectionGridLayout->setColumnStretch(2, 1); //1000);
      geodesicSelectionGridLayout->setRowStretch(rowStretchNumber, 1000);
      
      geodesicMainPageLayout->addWidget(geodesicSelectionWidget, 10, Qt::AlignLeft);
   }
   
   //
   // Add radio buttons and text boxes
   //
   for (int i = numExistingGeodesic; i < numValidGeodesic; i++) {
      //
      // Selection button
      //
      QRadioButton* selectButton = new QRadioButton("");
      geodesicSelectionButtonGroup->addButton(selectButton, i);
      geodesicSelectionRadioButtons.push_back(selectButton);
      geodesicSelectionGridLayout->addWidget(selectButton, i, 0, Qt::AlignHCenter);
      
      //
      // Comment push button
      //
      QPushButton* commentPushButton = new QPushButton("?");
      commentPushButton->setAutoDefault(false);
      commentPushButton->setFixedWidth(40);
      geodesicColumnCommentPushButtons.push_back(commentPushButton);
      geodesicCommentButtonGroup->addButton(commentPushButton, i);
      geodesicSelectionGridLayout->addWidget(commentPushButton, i, 1, Qt::AlignHCenter);
      
      QLineEdit* le = new QLineEdit;
      le->setMinimumWidth(nameMinimumWidth);
      le->setMaximumWidth(1000);
      geodesicNameLineEdits.push_back(le);
      QObject::connect(le, SIGNAL(returnPressed()),
                       this, SLOT(readGeodesicSelections()));
      geodesicSelectionGridLayout->addWidget(le, i, 2, Qt::AlignLeft);
   }
   
   //
   // Update items already in the dialog
   //
   for (int i = 0; i < numValidGeodesic; i++) {
      geodesicSelectionRadioButtons[i]->show();
      geodesicColumnCommentPushButtons[i]->show();
      geodesicNameLineEdits[i]->setText(gdf->getColumnName(i));
      geodesicNameLineEdits[i]->home(false);
      geodesicNameLineEdits[i]->show();
   }
   
   //
   // Hide geodesic that are not needed
   //
   for (int i = numValidGeodesic; i < numExistingGeodesic; i++) {
      geodesicSelectionRadioButtons[i]->hide();
      geodesicColumnCommentPushButtons[i]->hide();
      geodesicNameLineEdits[i]->hide();
   }
}

/**
 * read the geodesic page.
 */
void 
07043 GuiDisplayControlDialog::readGeodesicSelections()
{
   if (creatingDialog) {
      return;
   }