/*
 * setup.c: The setup-class for the Atmolight-plugin
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */

#include <stdlib.h>

#include "defs.h"
#include "setup.h"

// --- cAtmoSetup ------------------------------------------------------------

cAtmoSetup::cAtmoSetup()
{
  output_arg = NULL;
  AtmoInput  = no_input;  // input device
  AtmoOutput = no_output; // output device

  atmo_on = false;
  DoWhiteCalibration = false; // white calibration off
  HasCmdLineArgs     = false; // no command line arguments given

  StartMode      = 0; // start mode = always on
  WidescreenMode = 0; // 1 = cut off top and bottom of the pic

  Mode           = live_picture_hsv; // atmolight-mode
  EdgeWeighting  = 8;   // weighting of distance to edge
  BrightCorrect  = 100; // brightness correction
  DarknessLimit  = 5;   // darkness limit
  HueWinSize     = 3;   // Windowing size for hue histogram building
  SatWinSize     = 3;   // Windowing size for sat histogram building

  DefaultColor   = black;
  StaticColor.channel[center].r = StaticColor.channel[center].g = StaticColor.channel[center].b = 255;
  StaticColor.channel[left] = StaticColor.channel[right] = StaticColor.channel[top] =
							  StaticColor.channel[bottom] = StaticColor.channel[center];
  // Filter
  Filter_Mode          = combined;
  Filter_MeanLength    = 300; // length of floating mean value filter
  Filter_MeanThreshold = 40;  // threshold of the mean value filter
  Filter_PercentNew    = 50;  // filter smoothness

  // Gamma
  Gamma_Mode = no_gamma;
  Gamma.r = Gamma.g = Gamma.b = 10;

  // White Calibration
  WhiteCalibration.r = WhiteCalibration.g = WhiteCalibration.b = 255;
}

void cAtmoSetup::SetDefault(tDefaultColors col)
{
  Mode = default_color;
  DefaultColor = col;
}

void cAtmoSetup::SetStatic(tPosition pos, tRGBColor col)
{
  Mode = static_color;
  switch (pos)
  {
    case center:
         StaticColor.channel[center] = col;
    break;

    case left:
         StaticColor.channel[left] = col;
    break;

    case right:
         StaticColor.channel[right] = col;
    break;

    case top:
         StaticColor.channel[top] = col;
    break;

    case bottom:
         StaticColor.channel[bottom] = col;
    break;

    default:
    case all:
         StaticColor.channel[center] = col;
         StaticColor.channel[left] = StaticColor.channel[right] = StaticColor.channel[top] =
                                     StaticColor.channel[bottom] = StaticColor.channel[center];
    break;
  }
}
