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

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

called to start the volume animation

Called to start the volume animation.

Definition at line 2959 of file GuiDisplayControlDialog.cxx.

References continueVolumeAnimation, VolumeFile::getDimensions(), BrainModelVolume::getMasterVolumeFile(), VolumeFile::getNonZeroVoxelExtent(), BrainModelVolume::getSelectedAxis(), BrainModelVolume::getSelectedOrthogonalSlices(), BrainModelVolume::setSelectedOrthogonalSlices(), GuiBrainModelOpenGL::updateAllGL(), GuiToolBar::updateAllToolBars(), VOLUME_ANIMATE_DIRECTION_DECREMENT, VOLUME_ANIMATE_DIRECTION_INCREMENT, VolumeFile::VOLUME_AXIS_ALL, VolumeFile::VOLUME_AXIS_OBLIQUE, VolumeFile::VOLUME_AXIS_OBLIQUE_ALL, VolumeFile::VOLUME_AXIS_OBLIQUE_X, VolumeFile::VOLUME_AXIS_OBLIQUE_Y, VolumeFile::VOLUME_AXIS_OBLIQUE_Z, VolumeFile::VOLUME_AXIS_UNKNOWN, VolumeFile::VOLUME_AXIS_X, VolumeFile::VOLUME_AXIS_Y, VolumeFile::VOLUME_AXIS_Z, and volumeAnimateDirectionComboBox.

Referenced by createOverlayUnderlayVolumeSettingsPage().

{
   //
   // 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();
      }
   }
}


Generated by  Doxygen 1.6.0   Back to index