
// $Id: monitorcal.h,v 1.12 2008/03/01 23:05:35 hvengel Exp $
//  Little cms Profiler
// Copyright (C) 2007 Hal Engel
//
// THIS SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
// EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
// WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
//
// IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
// INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
// OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
// WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
// LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
// OF THIS SOFTWARE.
//
// This program 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 3 of the License, or
// (at your option) any later version.
// 
// This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
//
// Version 1.11

#ifndef MONITORCAL_H
#define MONITORCAL_H

#include "ui_monitorcalbase.h"
extern "C"
{
#include "lcmsprf.h"
#include "inst.h"
}
#include <qdesktopwidget.h>
#include <QWaitCondition>
#include <QMutex>

typedef struct
  {
       double R, G, B;
  } RGBtype;

class  MonitorCal : public QDialog, private Ui::MonitorCalBase
{
  Q_OBJECT

public:
    MonitorCal(QWidget *parent = 0 );
    virtual ~MonitorCal();

private slots:
    void Go();
    void slotPosChanged();
    void slotSizeChanged();
    void slotStop();
    void slotHelpButton();
    void slotProcessEvents();

protected:    
    bool initInstrument();
    cmsCIEXYZ takeSpotReading(); // return XYZ value to caller
    cmsCIEXYZ setWhitePoint();
    LPGAMMATABLE createDesiredGammaCurve(int size);
    LPcmsCIExyYTRIPLE setPrimaries();
    void freeConversionProfiles();
    void setupConversionProfiles();
    RGBtype XYZ2RGBDbl(cmsCIEXYZ XYZ);
    void paintPatch(int R, int G, int B);
    void setDisplayWP();
    void calibrationReport();
    void bigCalibrationReport();
    void displayTemp(cmsCIEXYZ XYZ, cmsCIEXYZ targetXYZ);
    void setDisplayBL();
    void setDisplayWL();
    void setDisplayBP();
    void setupDialogLayout();
    void measureDisplay(const RGBtype rgb[], const int upperbound);
    void calibrateDisplay();
    void getCurrentVCGamma();
    void setVCGammaLinear();
    void setVCGamma();
    void restoreVCGamma();
    inst_code handleCalibrate(inst *deviceToCalibrate, 
                              inst_cal_type calibrationType, 
                              inst_cal_cond calibrationCondition);

    QDesktopWidget* desktop;

};

#endif
