AtmoConfig.cpp
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:8k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*
  2.  * AtmoConfig.cpp: Class for holding all configuration values of AtmoWin - stores
  3.  * the values and retrieves its values from registry
  4.  *
  5.  * See the README.txt file for copyright information and how to reach the author(s).
  6.  *
  7.  * $Id: 5e1fdf74ff16176cdcc40d81926024a75892f597 $
  8.  */
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include "AtmoConfig.h"
  12. /* Import Hint
  13.    if somebody Adds new config option this has to be done in the following
  14.    files and includes!
  15.    AtmoConfig.h  -- extend class definition!, and add get... and set... Methods!
  16.                     so that the real variables are still hidden inside the class!
  17.    AtmoConfigRegistry.cpp --> SaveToRegistry();
  18.    AtmoConfigRegistry.cpp --> LoadFromRegistry();
  19.    AtmoConfig.cpp --> Assign( ... );
  20. */
  21. CAtmoConfig::CAtmoConfig()
  22. {
  23.   // setup basic configruation structures...
  24.   m_IsShowConfigDialog = 0;
  25.   m_eAtmoConnectionType = actSerialPort;
  26.   for(int i=0;i<10;i++)
  27.       m_ChannelAssignments[i] = NULL;
  28. #if defined (_ATMO_VLC_PLUGIN_)
  29.   m_devicename = NULL;
  30. #endif
  31.   // load all config values with there defaults
  32.   LoadDefaults();
  33.   //   CAtmoZoneDefinition *m_ZoneDefinitions[ATMO_NUM_CHANNELS];
  34.   // generate default channel parameters which may be loaded later from .bmp files
  35.   for(int i=0;i<ATMO_NUM_CHANNELS;i++) {
  36.       m_ZoneDefinitions[i] = new CAtmoZoneDefinition();
  37.       m_ZoneDefinitions[i]->setZoneNumber(i);
  38.       switch(i) {
  39.           case 0:  // summary channel
  40.               m_ZoneDefinitions[i]->Fill(255);
  41.               break;
  42.           case 1: // left channel
  43.               m_ZoneDefinitions[i]->FillGradientFromLeft();
  44.               break;
  45.           case 2: // right channel
  46.               m_ZoneDefinitions[i]->FillGradientFromRight();
  47.               break;
  48.           case 3: // top channel
  49.               m_ZoneDefinitions[i]->FillGradientFromTop();
  50.               break;
  51.           case 4: // bottom channel
  52.               m_ZoneDefinitions[i]->FillGradientFromBottom();
  53.               break;
  54.       }
  55.   }
  56. }
  57. CAtmoConfig::~CAtmoConfig() {
  58.    // and finally cleanup...
  59.    clearAllChannelMappings();
  60. #if !defined (WIN32)
  61.    if(m_devicename)
  62.       free(m_devicename);
  63. #endif
  64. }
  65. void CAtmoConfig::LoadDefaults() {
  66.     //    m_eAtmoConnectionType = actSerialPort;
  67.     //    m_Comport
  68.     m_eEffectMode = emDisabled;
  69.     m_WhiteAdjustment_Red    = 255;
  70.     m_WhiteAdjustment_Green  = 255;
  71.     m_WhiteAdjustment_Blue   = 255;
  72. m_UseSoftwareWhiteAdj    = 1;
  73. m_ColorChanger_iSteps    = 50;
  74. m_ColorChanger_iDelay    = 25;
  75. m_LrColorChanger_iSteps  = 50;
  76. m_LrColorChanger_iDelay  = 25;
  77.     m_IsSetShutdownColor     = 1;
  78. m_ShutdownColor_Red      = 0;
  79. m_ShutdownColor_Green    = 0;
  80. m_ShutdownColor_Blue     = 0;
  81.     m_StaticColor_Red        = 127; // ??
  82.     m_StaticColor_Green      = 192;
  83.     m_StaticColor_Blue       = 255;
  84.     m_LiveViewFilterMode         = afmCombined;
  85.     m_LiveViewFilter_PercentNew  = 50;
  86.     m_LiveViewFilter_MeanLength  = 300;
  87.     m_LiveViewFilter_MeanThreshold   = 40;
  88.     m_LiveView_EdgeWeighting  = 8;
  89.     m_LiveView_BrightCorrect  = 100;
  90.     m_LiveView_DarknessLimit  = 5;
  91.     m_LiveView_HueWinSize     = 3;
  92.     m_LiveView_SatWinSize     = 3;
  93.     m_LiveView_WidescreenMode = 0;
  94.     m_LiveView_HOverscanBorder  = 0;
  95.     m_LiveView_VOverscanBorder  = 0;
  96.     m_LiveView_DisplayNr        = 0;
  97.     m_LiveView_FrameDelay       = 0;
  98.     m_Hardware_global_gamma    = 128;
  99.     m_Hardware_global_contrast = 100;
  100.     m_Hardware_contrast_red    = 100;
  101.     m_Hardware_contrast_green  = 100;
  102.     m_Hardware_contrast_blue   = 100;
  103.     m_Hardware_gamma_red       = 22;
  104.     m_Hardware_gamma_green     = 22;
  105.     m_Hardware_gamma_blue      = 22;
  106.     clearAllChannelMappings();
  107.     m_CurrentChannelAssignment = 0;
  108.     tChannelAssignment* temp = new tChannelAssignment;
  109.     temp->system = true;
  110.     for(int i=0;i<ATMO_NUM_CHANNELS;i++)
  111.         temp->mappings[i] = i;
  112.     strcpy(temp->name,"Standard");
  113.     this->m_ChannelAssignments[0] =  temp;
  114. }
  115. void CAtmoConfig::Assign(CAtmoConfig *pAtmoConfigSrc) {
  116. #if defined(_ATMO_VLC_PLUGIN_)
  117.     this->setSerialDevice(pAtmoConfigSrc->getSerialDevice());
  118. #else
  119.     this->m_Comport                  = pAtmoConfigSrc->m_Comport;
  120. #endif
  121.     this->m_eAtmoConnectionType      = pAtmoConfigSrc->m_eAtmoConnectionType;
  122.     this->m_eEffectMode              = pAtmoConfigSrc->m_eEffectMode;
  123.     this->m_WhiteAdjustment_Red      = pAtmoConfigSrc->m_WhiteAdjustment_Red;
  124.     this->m_WhiteAdjustment_Green    = pAtmoConfigSrc->m_WhiteAdjustment_Green;
  125.     this->m_WhiteAdjustment_Blue     = pAtmoConfigSrc->m_WhiteAdjustment_Blue;
  126.     this->m_UseSoftwareWhiteAdj      = pAtmoConfigSrc->m_UseSoftwareWhiteAdj;
  127.     this->m_IsSetShutdownColor       = pAtmoConfigSrc->m_IsSetShutdownColor;
  128.     this->m_ShutdownColor_Red        = pAtmoConfigSrc->m_ShutdownColor_Red;
  129.     this->m_ShutdownColor_Green      = pAtmoConfigSrc->m_ShutdownColor_Green;
  130.     this->m_ShutdownColor_Blue       = pAtmoConfigSrc->m_ShutdownColor_Blue;
  131.     this->m_ColorChanger_iSteps      = pAtmoConfigSrc->m_ColorChanger_iSteps;
  132.     this->m_ColorChanger_iDelay      = pAtmoConfigSrc->m_ColorChanger_iDelay;
  133.     this->m_LrColorChanger_iSteps    = pAtmoConfigSrc->m_LrColorChanger_iSteps;
  134.     this->m_LrColorChanger_iDelay    = pAtmoConfigSrc->m_LrColorChanger_iDelay;
  135.     this->m_StaticColor_Red          = pAtmoConfigSrc->m_StaticColor_Red;
  136.     this->m_StaticColor_Green        = pAtmoConfigSrc->m_StaticColor_Green;
  137.     this->m_StaticColor_Blue         = pAtmoConfigSrc->m_StaticColor_Blue;
  138.     this->m_LiveViewFilterMode             = pAtmoConfigSrc->m_LiveViewFilterMode;
  139.     this->m_LiveViewFilter_PercentNew      = pAtmoConfigSrc->m_LiveViewFilter_PercentNew;
  140.     this->m_LiveViewFilter_MeanLength      = pAtmoConfigSrc->m_LiveViewFilter_MeanLength;
  141.     this->m_LiveViewFilter_MeanThreshold   = pAtmoConfigSrc->m_LiveViewFilter_MeanThreshold;
  142.     this->m_LiveView_EdgeWeighting  =  pAtmoConfigSrc->m_LiveView_EdgeWeighting;
  143.     this->m_LiveView_BrightCorrect  =  pAtmoConfigSrc->m_LiveView_BrightCorrect;
  144.     this->m_LiveView_DarknessLimit  =  pAtmoConfigSrc->m_LiveView_DarknessLimit;
  145.     this->m_LiveView_HueWinSize     =  pAtmoConfigSrc->m_LiveView_HueWinSize;
  146.     this->m_LiveView_SatWinSize     =  pAtmoConfigSrc->m_LiveView_SatWinSize;
  147.     this->m_LiveView_WidescreenMode =  pAtmoConfigSrc->m_LiveView_WidescreenMode;
  148.     this->m_LiveView_HOverscanBorder  = pAtmoConfigSrc->m_LiveView_HOverscanBorder;
  149.     this->m_LiveView_VOverscanBorder  = pAtmoConfigSrc->m_LiveView_VOverscanBorder;
  150.     this->m_LiveView_DisplayNr        = pAtmoConfigSrc->m_LiveView_DisplayNr;
  151.     this->m_LiveView_FrameDelay       = pAtmoConfigSrc->m_LiveView_FrameDelay;
  152.     clearChannelMappings();
  153.     for(int i=1;i<pAtmoConfigSrc->getNumChannelAssignments();i++) {
  154.         tChannelAssignment *ta = pAtmoConfigSrc->m_ChannelAssignments[i];
  155.         if(ta!=NULL) {
  156.             tChannelAssignment *dest = this->m_ChannelAssignments[i];
  157.             if(dest == NULL) {
  158.                dest = new tChannelAssignment;
  159.                this->m_ChannelAssignments[i] = dest;
  160.             }
  161.             memcpy(dest, ta, sizeof(tChannelAssignment));
  162.         }
  163.     }
  164. }
  165. int CAtmoConfig::getNumChannelAssignments() {
  166.     int z=0;
  167.     for(int i=0;i<10;i++)
  168.         if(this->m_ChannelAssignments[i]!=NULL) z++;
  169.     return z;
  170. }
  171. void CAtmoConfig::clearChannelMappings() {
  172.     for(int i=1;i<10;i++) {
  173.         tChannelAssignment *ca = m_ChannelAssignments[i];
  174.         if(ca!=NULL)
  175.            delete ca;
  176.         m_ChannelAssignments[i] = NULL;
  177.     }
  178. }
  179. void CAtmoConfig::clearAllChannelMappings() {
  180.     for(int i=0;i<10;i++) {
  181.         tChannelAssignment *ca = m_ChannelAssignments[i];
  182.         if(ca!=NULL)
  183.            delete ca;
  184.         m_ChannelAssignments[i] = NULL;
  185.     }
  186. }
  187. void CAtmoConfig::AddChannelAssignment(tChannelAssignment *ta) {
  188.     for(int i=0;i<10;i++) {
  189.         if(m_ChannelAssignments[i] == NULL) {
  190.            m_ChannelAssignments[i] = ta;
  191.            break;
  192.         }
  193.     }
  194. }
  195. void CAtmoConfig::SetChannelAssignment(int index, tChannelAssignment *ta) {
  196.      if(m_ChannelAssignments[index]!=NULL)
  197.         delete m_ChannelAssignments[index];
  198.      m_ChannelAssignments[index] = ta;
  199. }
  200. CAtmoZoneDefinition *CAtmoConfig::getZoneDefinition(int zoneIndex) {
  201.     if(zoneIndex < 0)
  202.        return NULL;
  203.     if(zoneIndex >= ATMO_NUM_CHANNELS)
  204.        return NULL;
  205.     return m_ZoneDefinitions[zoneIndex];
  206. }