Example #1
0
void FITSHistogramCommand::undo()
{
    FITSView *image = tab->getView();
    FITSData *image_data = image->getImageData();

    QApplication::setOverrideCursor(Qt::WaitCursor);

    if (delta != NULL)
    {
       double min,max,stddev,average,median,snr;
       min      = image_data->getMin();
       max      = image_data->getMax();
       stddev   = image_data->getStdDev();
       average  = image_data->getMean();
       median   = image_data->getMedian();
       snr      = image_data->getSNR();

       reverseDelta();

       restoreStats();

       saveStats(min, max, stddev, average, median, snr);
    }
    else
    {
        switch (type)
        {
            case FITS_ROTATE_CW:
            image_data->applyFilter(FITS_ROTATE_CCW);
            break;
            case FITS_ROTATE_CCW:
            image_data->applyFilter(FITS_ROTATE_CW);
            break;
            case FITS_FLIP_H:
            case FITS_FLIP_V:
            image_data->applyFilter(type);
            break;
        default:
            break;
        }

    }

    if (histogram != NULL)
    {
        histogram->constructHistogram();

        if (tab->getViewer()->isStarsMarked())
            image_data->findStars();
    }

    image->popFilter();
    image->rescale(ZOOM_KEEP_LEVEL);
    image->updateFrame();

    QApplication::restoreOverrideCursor();

}
void FITSHistogramCommand::redo()
{

    FITSView *image = tab->getImage();
    FITSImage *image_data = image->getImageData();

    float *image_buffer = image_data->getImageBuffer();
    int width  = image_data->getWidth();
    int height = image_data->getHeight();

    memcpy(buffer, image_buffer, width * height * sizeof(float));


    switch (type)
    {
    case FITS_AUTO:
    case FITS_LINEAR:
        image_data->applyFilter(FITS_LINEAR, image_buffer, min, max);
        break;

    case FITS_LOG:
        image_data->applyFilter(FITS_LOG, image_buffer, min, max);
        break;

    case FITS_SQRT:
        image_data->applyFilter(FITS_SQRT, image_buffer, min, max);
        break;

    default:
       image_data->applyFilter(type, image_buffer);
       break;


    }

    if (histogram != NULL)
    {
        histogram->updateHistogram();

        if (tab->getViewer()->isStarsMarked())
            image_data->findStars();
    }

    image->rescale(ZOOM_KEEP_LEVEL);
    image->updateFrame();

}
void FITSHistogramCommand::undo()
{
    FITSView *image = tab->getImage();
    FITSImage *image_data = image->getImageData();
    memcpy( image_data->getImageBuffer(), buffer, image_data->getWidth() * image_data->getHeight() * sizeof(float));
    image_data->calculateStats(true);



    if (histogram != NULL)
    {
        histogram->updateHistogram();

        if (tab->getViewer()->isStarsMarked())
            image_data->findStars();
    }

    image->rescale(ZOOM_KEEP_LEVEL);
    image->updateFrame();

}
Example #4
0
void FITSHistogramCommand::redo()
{
    FITSView *image = tab->getView();
    FITSData *image_data = image->getImageData();

    uint8_t *image_buffer = image_data->getImageBuffer();
    unsigned int size = image_data->getSize();
    int channels = image_data->getNumOfChannels();
    int BBP = image_data->getBytesPerPixel();

    QApplication::setOverrideCursor(Qt::WaitCursor);

    if (delta != NULL)
    {
        double min,max,stddev,average,median,snr;
        min      = image_data->getMin();
        max      = image_data->getMax();
        stddev   = image_data->getStdDev();
        average  = image_data->getMean();
        median   = image_data->getMedian();
        snr      = image_data->getSNR();

        reverseDelta();

        restoreStats();

        saveStats(min, max, stddev, average, median, snr);
    }
    else
    {
        saveStats(image_data->getMin(), image_data->getMax(), image_data->getStdDev(), image_data->getMean(), image_data->getMedian(), image_data->getSNR());

        // If it's rotation of flip, no need to calculate delta
        if (type >= FITS_ROTATE_CW && type <= FITS_FLIP_V)
        {
            image_data->applyFilter(type, image_buffer);
        }
        else
        {
            uint8_t *buffer = new uint8_t[size * channels * BBP];
            if (buffer == NULL)
            {
                qWarning() << "Error! not enough memory to create image buffer in redo()" << endl;
                QApplication::restoreOverrideCursor();
                return;
            }

            memcpy(buffer, image_buffer, size * channels * BBP);
            float dataMin = min, dataMax = max;

            switch (type)
            {
            case FITS_AUTO:
            case FITS_LINEAR:
                image_data->applyFilter(FITS_LINEAR, NULL, &dataMin, &dataMax);
                break;

            case FITS_LOG:
                image_data->applyFilter(FITS_LOG, NULL, &dataMin, &dataMax);
                break;

            case FITS_SQRT:
                image_data->applyFilter(FITS_SQRT, NULL, &dataMin, &dataMax);
                break;

            default:
               image_data->applyFilter(type);
               break;
            }

            calculateDelta(buffer);
            delete [] buffer;
        }
    }

    if (histogram != NULL)
    {
        histogram->constructHistogram();

        if (tab->getViewer()->isStarsMarked())
            image_data->findStars();
    }

    image->pushFilter(type);
    image->rescale(ZOOM_KEEP_LEVEL);
    image->updateFrame();

    QApplication::restoreOverrideCursor();
}