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

void GuiDisplayControlDialog::metricAnimatePushButtonSelection (  )  [private, slot]

called when animate push button is selected

Called when animate pushbutton is pressed.

Definition at line 12445 of file GuiDisplayControlDialog.cxx.

References BrainModelSurfaceNodeColoring::assignColors(), DebugControl::getDebugOn(), PreferencesFile::getDisplayListsEnabled(), GuiBrainModelOpenGL::getMainWindowCaption(), BrainModelSurfaceNodeColoring::getNodeColor(), GiftiNodeDataFile::getNumberOfColumns(), GiftiNodeDataFile::getNumberOfNodes(), DisplaySettingsNodeAttributeFile::getSelectedThresholdColumn(), metricAnimateSpinBox, metricThresholdButtonGroup, metricViewButtonGroup, pageMetricSelection, PreferencesFile::setDisplayListsEnabled(), GuiBrainModelOpenGL::setMainWindowCaption(), BrainModelSurfaceNodeColoring::setNodeColor(), DisplaySettingsNodeAttributeFile::setSelectedDisplayColumn(), DisplaySettingsNodeAttributeFile::setSelectedThresholdColumn(), surfaceModelIndex, GuiBrainModelOpenGL::updateAllGL(), and updateSurfaceOverlayWidgets().

Referenced by createMetricMiscellaneousPage().

{
   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
   
   //
   // Save main window caption
   //   
   const QString savedMainWindowCaption = GuiBrainModelOpenGL::getMainWindowCaption();
   
   //
   // Turn off display lists during animation
   //
   PreferencesFile* pf = theMainWindow->getBrainSet()->getPreferencesFile();
   const bool displayListStatusFlag = pf->getDisplayListsEnabled();
   pf->setDisplayListsEnabled(false);
   theMainWindow->getBrainSet()->clearAllDisplayLists();
   
   MetricFile* mf = theMainWindow->getBrainSet()->getMetricFile();
   const int numMetrics = mf->getNumberOfColumns();
   DisplaySettingsMetric* dsm = theMainWindow->getBrainSet()->getDisplaySettingsMetric();
   const int numInterpolateFrames = metricAnimateSpinBox->value();
   BrainModelSurfaceNodeColoring* bsnc = theMainWindow->getBrainSet()->getNodeColoring();
   
   if (numInterpolateFrames > 0) {
      for (int i = 0; i < (numMetrics - 1); i++) {
         //
         // Set current metrics
         //
         dsm->setSelectedDisplayColumn(surfaceModelIndex, -1, i);
         dsm->setSelectedThresholdColumn(surfaceModelIndex, -1, i);         
         updateSurfaceOverlayWidgets();
         
         if (pageMetricSelection != NULL) {
            QRadioButton* rb = dynamic_cast<QRadioButton*>(metricViewButtonGroup->button(i));
            rb->setChecked(true);
            QRadioButton* rbt = dynamic_cast<QRadioButton*>(metricThresholdButtonGroup->button(
               dsm->getSelectedThresholdColumn(surfaceModelIndex, 0)));
            rbt->setChecked(true);
         }
         
         //
         // Assign colors with current metric and save the colors
         //
         bsnc->assignColors();
         const int numNodes = mf->getNumberOfNodes();
         const int colorSize = numNodes * 3;
         float* colors = new float[colorSize];
         for (int k = 0; k < numNodes; k++) {
            const unsigned char* c = bsnc->getNodeColor(surfaceModelIndex, k);
            colors[k * 3] = c[0];
            colors[k * 3 + 1] = c[1];
            colors[k * 3 + 2] = c[2];
         }
         
         //
         // Debugging information
         //
         if (DebugControl::getDebugOn()) {
            const int nodeNum = DebugControl::getDebugNodeNumber();
            if ((nodeNum >= 0) && (nodeNum < numNodes)) {
               const unsigned char* c = bsnc->getNodeColor(surfaceModelIndex, nodeNum);
               std::cout << "Node "
                         << nodeNum
                         << " color ("
                         << static_cast<int>(c[0])
                         << ","
                         << static_cast<int>(c[1])
                         << ","
                         << static_cast<int>(c[2])
                         << ")"
                         << std::endl;
            }
         }
         
         //
         // Assign colors with next metric and save the colors
         //
         dsm->setSelectedDisplayColumn(surfaceModelIndex, -1, i + 1);
         dsm->setSelectedThresholdColumn(surfaceModelIndex, -1, i + 1);
         bsnc->assignColors();
         float* colors2 = new float[colorSize];
         for (int k = 0; k < numNodes; k++) {
            const unsigned char* c = bsnc->getNodeColor(surfaceModelIndex, k);
            colors2[k * 3] = c[0];
            colors2[k * 3 + 1] = c[1];
            colors2[k * 3 + 2] = c[2];
         }
         
         //
         // Compute the delta of the colors
         //
         const float steps = numInterpolateFrames + 1.0;
         float* colorDelta = new float[colorSize];
         for (int k = 0; k < colorSize; k++) {
            colorDelta[k] = (colors2[k] - colors[k]) / steps;
         }
         
         for (int j = 0; j <= numInterpolateFrames; j++) {
            for (int m = 0; m < numNodes; m++) {
               //
               // Interpolate color deltas
               //
               const int m3 = m * 3;
               const float fj = j;
               const float rd = colorDelta[m3] * fj;
               const float gd = colorDelta[m3 + 1] * fj;
               const float bd = colorDelta[m3 + 2] * fj;
               
               //
               // Assign colors to the nodes
               //
               const float n255 = 255.0;
               unsigned char rgb[3];
               rgb[0] = static_cast<unsigned char>(std::min(colors[m3] + rd, n255));
               rgb[1] = static_cast<unsigned char>(std::min(colors[m3 + 1] + gd, n255));
               rgb[2] = static_cast<unsigned char>(std::min(colors[m3 + 2] + bd, n255));
               bsnc->setNodeColor(surfaceModelIndex, m, rgb);
               
               //
               // Debugging information
               //
               if (DebugControl::getDebugOn()) {
                  const int nodeNum = DebugControl::getDebugNodeNumber();
                  if (nodeNum == m) {
                     const unsigned char* c = bsnc->getNodeColor(surfaceModelIndex, nodeNum);
                     std::cout << "Node "
                               << nodeNum
                               << " color iteration "
                               << j
                               << " ("
                               << static_cast<int>(c[0])
                               << ","
                               << static_cast<int>(c[1])
                               << ","
                               << static_cast<int>(c[2])
                               << ")"
                               << std::endl;
                  }
               }
            }
            
            if (DebugControl::getDebugOn()) {
               const QString caption = 
                  ("column (1..N) = " 
                   + (QString::number(i + 1))
                   + " of "
                   + QString::number(numMetrics)
                   + " interpolation = "
                   + QString::number(j));
               GuiBrainModelOpenGL::setMainWindowCaption(caption);
               
            }
               
            //
            // Draw the surfaces
            //
            GuiBrainModelOpenGL::updateAllGL(NULL); 
         }
         
         delete[] colors;
         delete[] colors2;
         delete[] colorDelta;
      }
      //
      // Set to last metric and draw it
      //
      dsm->setSelectedDisplayColumn(surfaceModelIndex, -1, numMetrics - 1);
      dsm->setSelectedThresholdColumn(surfaceModelIndex, -1, numMetrics - 1);
      bsnc->assignColors();
      
      updateSurfaceOverlayWidgets();

      if (pageMetricSelection != NULL) {
         QRadioButton* rb = dynamic_cast<QRadioButton*>(metricViewButtonGroup->button(numMetrics - 1));
         rb->setChecked(true);
         QRadioButton* rb2 = dynamic_cast<QRadioButton*>(metricThresholdButtonGroup->button(dsm->getSelectedThresholdColumn(surfaceModelIndex, 0)));
         rb2->setChecked(true);
      }
      GuiBrainModelOpenGL::updateAllGL(NULL); 
   }
   else {
      for (int i = 0; i < numMetrics; i++) {
         dsm->setSelectedDisplayColumn(surfaceModelIndex, -1, i);
         dsm->setSelectedThresholdColumn(surfaceModelIndex, -1, i);
         
         updateSurfaceOverlayWidgets();
         
         if (pageMetricSelection != NULL) {
            QRadioButton* rb = dynamic_cast<QRadioButton*>(metricViewButtonGroup->button(i));
            rb->setChecked(true);
            QRadioButton* rb2 = dynamic_cast<QRadioButton*>(metricThresholdButtonGroup->button(dsm->getSelectedThresholdColumn(surfaceModelIndex, 0)));
            rb2->setChecked(true);
         }
         bsnc->assignColors();
         GuiBrainModelOpenGL::updateAllGL(NULL);   
      }
   }

   //
   // Restore main window caption
   //   
   GuiBrainModelOpenGL::setMainWindowCaption(savedMainWindowCaption);
   
   //
   // Draw the surfaces
   //
   GuiBrainModelOpenGL::updateAllGL(NULL); 

   //
   // Restore display list status
   //
   pf->setDisplayListsEnabled(displayListStatusFlag);
   
   QApplication::restoreOverrideCursor();
}


Generated by  Doxygen 1.6.0   Back to index