2 * AtmoConfig.cpp: Class for holding all configuration values of AtmoWin - stores
3 * the values and retrieves its values from registry
5 * See the README.txt file for copyright information and how to reach the author(s).
13 #include "AtmoConfig.h"
17 if somebody Adds new config option this has to be done in the following
20 AtmoConfig.h -- extend class definition!, and add get... and set... Methods!
21 so that the real variables are still hidden inside the class!
22 AtmoConfigRegistry.cpp --> SaveToRegistry();
23 AtmoConfigRegistry.cpp --> LoadFromRegistry();
24 AtmoConfig.cpp --> Assign( ... );
28 CAtmoConfig::CAtmoConfig()
30 // setup basic configruation structures...
31 m_IsShowConfigDialog = 0;
32 m_eAtmoConnectionType = actClassicAtmo;
34 m_ChannelAssignments[i] = NULL;
36 #if defined (_ATMO_VLC_PLUGIN_)
38 m_devicenames[0] = NULL;
39 m_devicenames[1] = NULL;
40 m_devicenames[2] = NULL;
42 // load all config values with there defaults
43 m_ZoneDefinitions = NULL;
44 m_AtmoZoneDefCount = -1;
45 m_DMX_BaseChannels = NULL;
50 CAtmoConfig::~CAtmoConfig() {
51 // and finally cleanup...
52 clearAllChannelMappings();
56 for(int zone=0; zone<m_AtmoZoneDefCount; zone++)
57 delete m_ZoneDefinitions[zone];
58 delete m_ZoneDefinitions;
59 m_ZoneDefinitions = NULL;
62 free( m_DMX_BaseChannels );
64 #if defined (_ATMO_VLC_PLUGIN_)
66 free( m_devicenames[0] );
67 free( m_devicenames[1] );
68 free( m_devicenames[2] );
72 void CAtmoConfig::LoadDefaults() {
73 // m_eAtmoConnectionType = actSerialPort;
75 #if defined (_ATMO_VLC_PLUGIN_)
78 free( m_devicenames[0] );
79 free( m_devicenames[1] );
80 free( m_devicenames[2] );
83 m_devicenames[0] = NULL;
84 m_devicenames[1] = NULL;
85 m_devicenames[2] = NULL;
96 m_eEffectMode = emDisabled;
98 m_IgnoreConnectionErrorOnStartup = ATMO_FALSE;
100 m_UpdateEdgeWeightningFlag = 0;
104 m_Software_gamma_mode = agcNone;
105 m_Software_gamma_red = 10;
106 m_Software_gamma_green = 10;
107 m_Software_gamma_blue = 10;
108 m_Software_gamma_global = 10;
110 m_WhiteAdjustment_Red = 255;
111 m_WhiteAdjustment_Green = 255;
112 m_WhiteAdjustment_Blue = 255;
113 m_UseSoftwareWhiteAdj = 1;
115 m_ColorChanger_iSteps = 50;
116 m_ColorChanger_iDelay = 25;
118 m_LrColorChanger_iSteps = 50;
119 m_LrColorChanger_iDelay = 25;
121 m_IsSetShutdownColor = 1;
122 m_ShutdownColor_Red = 0;
123 m_ShutdownColor_Green = 0;
124 m_ShutdownColor_Blue = 0;
126 m_StaticColor_Red = 127; // ??
127 m_StaticColor_Green = 192;
128 m_StaticColor_Blue = 255;
130 m_LiveViewFilterMode = afmCombined;
131 m_LiveViewFilter_PercentNew = 50;
132 m_LiveViewFilter_MeanLength = 300;
133 m_LiveViewFilter_MeanThreshold = 40;
134 m_show_statistics = ATMO_FALSE;
136 m_LiveView_EdgeWeighting = 8;
137 m_LiveView_BrightCorrect = 100;
138 m_LiveView_DarknessLimit = 5;
139 m_LiveView_HueWinSize = 3;
140 m_LiveView_SatWinSize = 3;
141 m_LiveView_WidescreenMode = 0;
143 m_LiveView_HOverscanBorder = 0;
144 m_LiveView_VOverscanBorder = 0;
145 m_LiveView_DisplayNr = 0;
146 m_LiveView_FrameDelay = 30;
147 m_LiveView_GDI_FrameRate = 25;
150 m_Hardware_global_gamma = 128;
151 m_Hardware_global_contrast = 100;
152 m_Hardware_contrast_red = 100;
153 m_Hardware_contrast_green = 100;
154 m_Hardware_contrast_blue = 100;
156 m_Hardware_gamma_red = 22;
157 m_Hardware_gamma_green = 22;
158 m_Hardware_gamma_blue = 22;
160 m_DMX_BaseChannels = strdup("0");
161 m_DMX_RGB_Channels = 5; // so wie atmolight
163 m_MoMo_Channels = 3; // default momo, there exists also a 4 ch version!
166 m_ZonesBottomCount = 1;
168 m_ZoneSummary = ATMO_FALSE;
172 clearAllChannelMappings();
173 m_CurrentChannelAssignment = 0;
174 CAtmoChannelAssignment *temp = new CAtmoChannelAssignment();
176 temp->setName( "Standard" );
177 this->m_ChannelAssignments[0] = temp;
179 UpdateZoneDefinitionCount();
182 void CAtmoConfig::Assign(CAtmoConfig *pAtmoConfigSrc) {
184 #if defined(_ATMO_VLC_PLUGIN_)
185 this->setSerialDevice(0, pAtmoConfigSrc->getSerialDevice(0));
186 this->setSerialDevice(1, pAtmoConfigSrc->getSerialDevice(1));
187 this->setSerialDevice(2, pAtmoConfigSrc->getSerialDevice(2));
188 this->setSerialDevice(3, pAtmoConfigSrc->getSerialDevice(3));
190 this->m_Comport = pAtmoConfigSrc->m_Comport;
191 this->m_Comports[0] = pAtmoConfigSrc->m_Comports[0];
192 this->m_Comports[1] = pAtmoConfigSrc->m_Comports[1];
193 this->m_Comports[2] = pAtmoConfigSrc->m_Comports[2];
196 this->m_eAtmoConnectionType = pAtmoConfigSrc->m_eAtmoConnectionType;
197 this->m_eEffectMode = pAtmoConfigSrc->m_eEffectMode;
199 this->m_WhiteAdjustment_Red = pAtmoConfigSrc->m_WhiteAdjustment_Red;
200 this->m_WhiteAdjustment_Green = pAtmoConfigSrc->m_WhiteAdjustment_Green;
201 this->m_WhiteAdjustment_Blue = pAtmoConfigSrc->m_WhiteAdjustment_Blue;
202 this->m_UseSoftwareWhiteAdj = pAtmoConfigSrc->m_UseSoftwareWhiteAdj;
204 this->m_IsSetShutdownColor = pAtmoConfigSrc->m_IsSetShutdownColor;
205 this->m_ShutdownColor_Red = pAtmoConfigSrc->m_ShutdownColor_Red;
206 this->m_ShutdownColor_Green = pAtmoConfigSrc->m_ShutdownColor_Green;
207 this->m_ShutdownColor_Blue = pAtmoConfigSrc->m_ShutdownColor_Blue;
209 this->m_ColorChanger_iSteps = pAtmoConfigSrc->m_ColorChanger_iSteps;
210 this->m_ColorChanger_iDelay = pAtmoConfigSrc->m_ColorChanger_iDelay;
212 this->m_LrColorChanger_iSteps = pAtmoConfigSrc->m_LrColorChanger_iSteps;
213 this->m_LrColorChanger_iDelay = pAtmoConfigSrc->m_LrColorChanger_iDelay;
215 this->m_StaticColor_Red = pAtmoConfigSrc->m_StaticColor_Red;
216 this->m_StaticColor_Green = pAtmoConfigSrc->m_StaticColor_Green;
217 this->m_StaticColor_Blue = pAtmoConfigSrc->m_StaticColor_Blue;
219 this->m_LiveViewFilterMode = pAtmoConfigSrc->m_LiveViewFilterMode;
220 this->m_LiveViewFilter_PercentNew = pAtmoConfigSrc->m_LiveViewFilter_PercentNew;
221 this->m_LiveViewFilter_MeanLength = pAtmoConfigSrc->m_LiveViewFilter_MeanLength;
222 this->m_LiveViewFilter_MeanThreshold = pAtmoConfigSrc->m_LiveViewFilter_MeanThreshold;
224 this->m_show_statistics = pAtmoConfigSrc->m_show_statistics;
227 this->m_LiveView_EdgeWeighting = pAtmoConfigSrc->m_LiveView_EdgeWeighting;
228 this->m_LiveView_BrightCorrect = pAtmoConfigSrc->m_LiveView_BrightCorrect;
229 this->m_LiveView_DarknessLimit = pAtmoConfigSrc->m_LiveView_DarknessLimit;
230 this->m_LiveView_HueWinSize = pAtmoConfigSrc->m_LiveView_HueWinSize;
231 this->m_LiveView_SatWinSize = pAtmoConfigSrc->m_LiveView_SatWinSize;
232 this->m_LiveView_WidescreenMode = pAtmoConfigSrc->m_LiveView_WidescreenMode;
234 this->m_LiveView_HOverscanBorder = pAtmoConfigSrc->m_LiveView_HOverscanBorder;
235 this->m_LiveView_VOverscanBorder = pAtmoConfigSrc->m_LiveView_VOverscanBorder;
236 this->m_LiveView_DisplayNr = pAtmoConfigSrc->m_LiveView_DisplayNr;
237 this->m_LiveView_FrameDelay = pAtmoConfigSrc->m_LiveView_FrameDelay;
238 this->m_LiveView_GDI_FrameRate = pAtmoConfigSrc->m_LiveView_GDI_FrameRate;
240 this->m_ZonesTopCount = pAtmoConfigSrc->m_ZonesTopCount;
241 this->m_ZonesBottomCount = pAtmoConfigSrc->m_ZonesBottomCount;
242 this->m_ZonesLRCount = pAtmoConfigSrc->m_ZonesLRCount;
243 this->m_ZoneSummary = pAtmoConfigSrc->m_ZoneSummary;
246 this->m_Software_gamma_mode = pAtmoConfigSrc->m_Software_gamma_mode;
247 this->m_Software_gamma_red = pAtmoConfigSrc->m_Software_gamma_red;
248 this->m_Software_gamma_green = pAtmoConfigSrc->m_Software_gamma_green;
249 this->m_Software_gamma_blue = pAtmoConfigSrc->m_Software_gamma_blue;
250 this->m_Software_gamma_global = pAtmoConfigSrc->m_Software_gamma_global;
252 this->setDMX_BaseChannels( pAtmoConfigSrc->getDMX_BaseChannels() );
254 this->m_DMX_RGB_Channels = pAtmoConfigSrc->m_DMX_RGB_Channels;
256 this->m_MoMo_Channels = pAtmoConfigSrc->m_MoMo_Channels;
258 this->m_CurrentChannelAssignment = pAtmoConfigSrc->m_CurrentChannelAssignment;
260 clearChannelMappings();
261 for(int i=1;i<pAtmoConfigSrc->getNumChannelAssignments();i++) {
262 CAtmoChannelAssignment *ta = pAtmoConfigSrc->m_ChannelAssignments[i];
264 CAtmoChannelAssignment *dest = this->m_ChannelAssignments[i];
266 dest = new CAtmoChannelAssignment();
267 this->m_ChannelAssignments[i] = dest;
269 // memcpy(dest, ta, sizeof(tChannelAssignment));
270 dest->setSize(ta->getSize());
271 dest->setName(ta->getName());
272 dest->system = ta->system;
273 for(int c=0;c<dest->getSize();c++)
274 dest->setZoneIndex(c, ta->getZoneIndex(c));
278 UpdateZoneDefinitionCount();
283 int CAtmoConfig::getNumChannelAssignments() {
285 for(int i=0;i<10;i++)
286 if(this->m_ChannelAssignments[i]!=NULL) z++;
290 void CAtmoConfig::clearChannelMappings() {
291 for(int i=1;i<10;i++) {
292 CAtmoChannelAssignment *ca = m_ChannelAssignments[i];
295 m_ChannelAssignments[i] = NULL;
299 void CAtmoConfig::clearAllChannelMappings() {
300 for(int i=0;i<10;i++) {
301 CAtmoChannelAssignment *ca = m_ChannelAssignments[i];
304 m_ChannelAssignments[i] = NULL;
308 void CAtmoConfig::AddChannelAssignment(CAtmoChannelAssignment *ta) {
309 for(int i=0;i<10;i++) {
310 if(m_ChannelAssignments[i] == NULL) {
311 m_ChannelAssignments[i] = ta;
317 void CAtmoConfig::SetChannelAssignment(int index, CAtmoChannelAssignment *ta) {
318 if(m_ChannelAssignments[index]!=NULL)
319 delete m_ChannelAssignments[index];
320 m_ChannelAssignments[index] = ta;
323 CAtmoZoneDefinition *CAtmoConfig::getZoneDefinition(int zoneIndex) {
326 if(zoneIndex >= m_AtmoZoneDefCount)
328 return m_ZoneDefinitions[zoneIndex];
332 void CAtmoConfig::UpdateZoneCount()
334 m_computed_zones_count = m_ZonesTopCount + m_ZonesBottomCount + 2 * m_ZonesLRCount;
336 m_computed_zones_count++;
341 int CAtmoConfig::getZoneCount()
343 return(m_computed_zones_count);
346 void CAtmoConfig::UpdateZoneDefinitionCount()
348 if( getZoneCount() != m_AtmoZoneDefCount)
350 // okay zonen anzahl hat sich geändert - wir müssen neu rechnen
352 if(m_ZoneDefinitions)
354 for(int zone=0; zone<m_AtmoZoneDefCount; zone++)
355 delete m_ZoneDefinitions[zone];
356 delete m_ZoneDefinitions;
357 m_ZoneDefinitions = NULL;
359 m_AtmoZoneDefCount = getZoneCount();
360 if(m_AtmoZoneDefCount > 0)
362 m_ZoneDefinitions = new CAtmoZoneDefinition*[m_AtmoZoneDefCount];
363 for(int zone=0; zone< m_AtmoZoneDefCount; zone++) {
364 m_ZoneDefinitions[zone] = new CAtmoZoneDefinition();
365 m_ZoneDefinitions[zone]->Fill(255);
371 #if defined(_ATMO_VLC_PLUGIN_)
373 char *CAtmoConfig::getSerialDevice(int i)
379 return m_devicenames[i];
383 void CAtmoConfig::setSerialDevice(int i,const char *pszNewDevice)
386 setSerialDevice(pszNewDevice);
389 free( m_devicenames[i] );
391 m_devicenames[i] = strdup(pszNewDevice);
393 m_devicenames[i] = NULL;
399 int CAtmoConfig::getComport(int i)
402 return this->m_Comport;
405 return this->m_Comports[i];
409 void CAtmoConfig::setComport(int i, int nr)
412 this->m_Comport = nr;
414 this->m_Comports[i-1] = nr;
420 void CAtmoConfig::setDMX_BaseChannels(char *channels)
422 free(m_DMX_BaseChannels);
423 m_DMX_BaseChannels = strdup(channels);