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).
17 #include "AtmoConfig.h"
21 if somebody Adds new config option this has to be done in the following
24 AtmoConfig.h -- extend class definition!, and add get... and set... Methods!
25 so that the real variables are still hidden inside the class!
26 AtmoConfigRegistry.cpp --> SaveToRegistry();
27 AtmoConfigRegistry.cpp --> LoadFromRegistry();
28 AtmoConfig.cpp --> Assign( ... );
32 CAtmoConfig::CAtmoConfig()
34 // setup basic configruation structures...
35 m_IsShowConfigDialog = 0;
36 m_eAtmoConnectionType = actClassicAtmo;
38 m_ChannelAssignments[i] = NULL;
40 #if defined (_ATMO_VLC_PLUGIN_)
42 m_devicenames[0] = NULL;
43 m_devicenames[1] = NULL;
44 m_devicenames[2] = NULL;
46 // load all config values with there defaults
47 m_ZoneDefinitions = NULL;
48 m_AtmoZoneDefCount = -1;
49 m_DMX_BaseChannels = NULL;
51 m_chWhiteAdj_Red = NULL;
52 m_chWhiteAdj_Green = NULL;
53 m_chWhiteAdj_Blue = NULL;
58 CAtmoConfig::~CAtmoConfig() {
59 // and finally cleanup...
60 clearAllChannelMappings();
64 for(int zone=0; zone<m_AtmoZoneDefCount; zone++)
65 delete m_ZoneDefinitions[zone];
66 delete[] m_ZoneDefinitions;
67 m_ZoneDefinitions = NULL;
70 delete []m_chWhiteAdj_Red;
71 delete []m_chWhiteAdj_Green;
72 delete []m_chWhiteAdj_Blue;
74 free( m_DMX_BaseChannels );
76 #if defined (_ATMO_VLC_PLUGIN_)
78 free( m_devicenames[0] );
79 free( m_devicenames[1] );
80 free( m_devicenames[2] );
84 void CAtmoConfig::LoadDefaults() {
85 // m_eAtmoConnectionType = actSerialPort;
87 #if defined (_ATMO_VLC_PLUGIN_)
90 free( m_devicenames[0] );
91 free( m_devicenames[1] );
92 free( m_devicenames[2] );
95 m_devicenames[0] = NULL;
96 m_devicenames[1] = NULL;
97 m_devicenames[2] = NULL;
108 m_eEffectMode = emDisabled;
110 m_IgnoreConnectionErrorOnStartup = ATMO_FALSE;
112 m_UpdateEdgeWeightningFlag = 0;
114 m_Software_gamma_mode = agcNone;
115 m_Software_gamma_red = 10;
116 m_Software_gamma_green = 10;
117 m_Software_gamma_blue = 10;
118 m_Software_gamma_global = 10;
120 m_WhiteAdjustment_Red = 255;
121 m_WhiteAdjustment_Green = 255;
122 m_WhiteAdjustment_Blue = 255;
123 m_UseSoftwareWhiteAdj = 1;
125 m_WhiteAdjPerChannel = ATMO_FALSE;
126 m_chWhiteAdj_Count = 0;
128 delete []m_chWhiteAdj_Red;
129 delete []m_chWhiteAdj_Green;
130 delete []m_chWhiteAdj_Blue;
132 m_chWhiteAdj_Red = NULL;
133 m_chWhiteAdj_Green = NULL;
134 m_chWhiteAdj_Blue = NULL;
136 m_ColorChanger_iSteps = 50;
137 m_ColorChanger_iDelay = 25;
139 m_LrColorChanger_iSteps = 50;
140 m_LrColorChanger_iDelay = 25;
142 m_IsSetShutdownColor = 1;
143 m_ShutdownColor_Red = 0;
144 m_ShutdownColor_Green = 0;
145 m_ShutdownColor_Blue = 0;
147 m_StaticColor_Red = 127; // ??
148 m_StaticColor_Green = 192;
149 m_StaticColor_Blue = 255;
151 m_LiveViewFilterMode = afmCombined;
152 m_LiveViewFilter_PercentNew = 50;
153 m_LiveViewFilter_MeanLength = 300;
154 m_LiveViewFilter_MeanThreshold = 40;
155 m_show_statistics = ATMO_FALSE;
157 m_LiveView_EdgeWeighting = 8;
158 m_LiveView_BrightCorrect = 100;
159 m_LiveView_DarknessLimit = 5;
160 m_LiveView_HueWinSize = 3;
161 m_LiveView_SatWinSize = 3;
162 m_LiveView_WidescreenMode = 0;
164 m_LiveView_HOverscanBorder = 0;
165 m_LiveView_VOverscanBorder = 0;
166 m_LiveView_DisplayNr = 0;
167 m_LiveView_FrameDelay = 30;
168 m_LiveView_GDI_FrameRate = 25;
169 m_LiveView_RowsPerFrame = 0;
172 m_Hardware_global_gamma = 128;
173 m_Hardware_global_contrast = 100;
174 m_Hardware_contrast_red = 100;
175 m_Hardware_contrast_green = 100;
176 m_Hardware_contrast_blue = 100;
178 m_Hardware_gamma_red = 22;
179 m_Hardware_gamma_green = 22;
180 m_Hardware_gamma_blue = 22;
182 m_DMX_BaseChannels = strdup("0");
183 m_DMX_RGB_Channels = 5; // so wie atmolight
185 m_MoMo_Channels = 3; // default momo, there exists also a 4 ch version!
186 m_Fnordlicht_Amount = 2; // default fnordlicht, there are 2 fnordlicht's!
189 m_ZonesBottomCount = 1;
191 m_ZoneSummary = ATMO_FALSE;
194 clearAllChannelMappings();
195 m_CurrentChannelAssignment = 0;
196 CAtmoChannelAssignment *temp = new CAtmoChannelAssignment();
198 temp->setName( "Standard" );
199 this->m_ChannelAssignments[0] = temp;
201 UpdateZoneDefinitionCount();
204 void CAtmoConfig::Assign(CAtmoConfig *pAtmoConfigSrc) {
206 #if defined(_ATMO_VLC_PLUGIN_)
207 this->setSerialDevice(0, pAtmoConfigSrc->getSerialDevice(0));
208 this->setSerialDevice(1, pAtmoConfigSrc->getSerialDevice(1));
209 this->setSerialDevice(2, pAtmoConfigSrc->getSerialDevice(2));
210 this->setSerialDevice(3, pAtmoConfigSrc->getSerialDevice(3));
212 this->m_Comport = pAtmoConfigSrc->m_Comport;
213 this->m_Comports[0] = pAtmoConfigSrc->m_Comports[0];
214 this->m_Comports[1] = pAtmoConfigSrc->m_Comports[1];
215 this->m_Comports[2] = pAtmoConfigSrc->m_Comports[2];
218 this->m_eAtmoConnectionType = pAtmoConfigSrc->m_eAtmoConnectionType;
219 this->m_eEffectMode = pAtmoConfigSrc->m_eEffectMode;
221 this->m_WhiteAdjustment_Red = pAtmoConfigSrc->m_WhiteAdjustment_Red;
222 this->m_WhiteAdjustment_Green = pAtmoConfigSrc->m_WhiteAdjustment_Green;
223 this->m_WhiteAdjustment_Blue = pAtmoConfigSrc->m_WhiteAdjustment_Blue;
224 this->m_UseSoftwareWhiteAdj = pAtmoConfigSrc->m_UseSoftwareWhiteAdj;
226 this->m_WhiteAdjPerChannel = pAtmoConfigSrc->m_WhiteAdjPerChannel;
227 this->m_chWhiteAdj_Count = pAtmoConfigSrc->m_chWhiteAdj_Count;
228 delete []m_chWhiteAdj_Red;
229 delete []m_chWhiteAdj_Green;
230 delete []m_chWhiteAdj_Blue;
231 if(m_chWhiteAdj_Count > 0)
233 m_chWhiteAdj_Red = new int[ m_chWhiteAdj_Count ];
234 m_chWhiteAdj_Green = new int[ m_chWhiteAdj_Count ];
235 m_chWhiteAdj_Blue = new int[ m_chWhiteAdj_Count ];
236 memcpy(m_chWhiteAdj_Red, pAtmoConfigSrc->m_chWhiteAdj_Red, sizeof(int) * m_chWhiteAdj_Count);
237 memcpy(m_chWhiteAdj_Green, pAtmoConfigSrc->m_chWhiteAdj_Green, sizeof(int) * m_chWhiteAdj_Count);
238 memcpy(m_chWhiteAdj_Blue, pAtmoConfigSrc->m_chWhiteAdj_Blue, sizeof(int) * m_chWhiteAdj_Count);
240 m_chWhiteAdj_Red = NULL;
241 m_chWhiteAdj_Green = NULL;
242 m_chWhiteAdj_Blue = NULL;
245 this->m_IsSetShutdownColor = pAtmoConfigSrc->m_IsSetShutdownColor;
246 this->m_ShutdownColor_Red = pAtmoConfigSrc->m_ShutdownColor_Red;
247 this->m_ShutdownColor_Green = pAtmoConfigSrc->m_ShutdownColor_Green;
248 this->m_ShutdownColor_Blue = pAtmoConfigSrc->m_ShutdownColor_Blue;
250 this->m_ColorChanger_iSteps = pAtmoConfigSrc->m_ColorChanger_iSteps;
251 this->m_ColorChanger_iDelay = pAtmoConfigSrc->m_ColorChanger_iDelay;
253 this->m_LrColorChanger_iSteps = pAtmoConfigSrc->m_LrColorChanger_iSteps;
254 this->m_LrColorChanger_iDelay = pAtmoConfigSrc->m_LrColorChanger_iDelay;
256 this->m_StaticColor_Red = pAtmoConfigSrc->m_StaticColor_Red;
257 this->m_StaticColor_Green = pAtmoConfigSrc->m_StaticColor_Green;
258 this->m_StaticColor_Blue = pAtmoConfigSrc->m_StaticColor_Blue;
260 this->m_LiveViewFilterMode = pAtmoConfigSrc->m_LiveViewFilterMode;
261 this->m_LiveViewFilter_PercentNew = pAtmoConfigSrc->m_LiveViewFilter_PercentNew;
262 this->m_LiveViewFilter_MeanLength = pAtmoConfigSrc->m_LiveViewFilter_MeanLength;
263 this->m_LiveViewFilter_MeanThreshold = pAtmoConfigSrc->m_LiveViewFilter_MeanThreshold;
265 this->m_show_statistics = pAtmoConfigSrc->m_show_statistics;
267 this->m_LiveView_EdgeWeighting = pAtmoConfigSrc->m_LiveView_EdgeWeighting;
268 this->m_LiveView_BrightCorrect = pAtmoConfigSrc->m_LiveView_BrightCorrect;
269 this->m_LiveView_DarknessLimit = pAtmoConfigSrc->m_LiveView_DarknessLimit;
270 this->m_LiveView_HueWinSize = pAtmoConfigSrc->m_LiveView_HueWinSize;
271 this->m_LiveView_SatWinSize = pAtmoConfigSrc->m_LiveView_SatWinSize;
272 this->m_LiveView_WidescreenMode = pAtmoConfigSrc->m_LiveView_WidescreenMode;
274 this->m_LiveView_HOverscanBorder = pAtmoConfigSrc->m_LiveView_HOverscanBorder;
275 this->m_LiveView_VOverscanBorder = pAtmoConfigSrc->m_LiveView_VOverscanBorder;
276 this->m_LiveView_DisplayNr = pAtmoConfigSrc->m_LiveView_DisplayNr;
277 this->m_LiveView_FrameDelay = pAtmoConfigSrc->m_LiveView_FrameDelay;
278 this->m_LiveView_GDI_FrameRate = pAtmoConfigSrc->m_LiveView_GDI_FrameRate;
279 this->m_LiveView_RowsPerFrame = pAtmoConfigSrc->m_LiveView_RowsPerFrame;
281 this->m_ZonesTopCount = pAtmoConfigSrc->m_ZonesTopCount;
282 this->m_ZonesBottomCount = pAtmoConfigSrc->m_ZonesBottomCount;
283 this->m_ZonesLRCount = pAtmoConfigSrc->m_ZonesLRCount;
284 this->m_ZoneSummary = pAtmoConfigSrc->m_ZoneSummary;
287 this->m_Software_gamma_mode = pAtmoConfigSrc->m_Software_gamma_mode;
288 this->m_Software_gamma_red = pAtmoConfigSrc->m_Software_gamma_red;
289 this->m_Software_gamma_green = pAtmoConfigSrc->m_Software_gamma_green;
290 this->m_Software_gamma_blue = pAtmoConfigSrc->m_Software_gamma_blue;
291 this->m_Software_gamma_global = pAtmoConfigSrc->m_Software_gamma_global;
293 this->setDMX_BaseChannels( pAtmoConfigSrc->getDMX_BaseChannels() );
295 this->m_DMX_RGB_Channels = pAtmoConfigSrc->m_DMX_RGB_Channels;
297 this->m_MoMo_Channels = pAtmoConfigSrc->m_MoMo_Channels;
299 this->m_Fnordlicht_Amount = pAtmoConfigSrc->m_Fnordlicht_Amount;
301 this->m_CurrentChannelAssignment = pAtmoConfigSrc->m_CurrentChannelAssignment;
303 clearChannelMappings();
304 for(int i=1;i<pAtmoConfigSrc->getNumChannelAssignments();i++) {
305 CAtmoChannelAssignment *ta = pAtmoConfigSrc->m_ChannelAssignments[i];
307 CAtmoChannelAssignment *dest = this->m_ChannelAssignments[i];
309 dest = new CAtmoChannelAssignment();
310 this->m_ChannelAssignments[i] = dest;
312 // memcpy(dest, ta, sizeof(tChannelAssignment));
313 dest->setSize(ta->getSize());
314 dest->setName(ta->getName());
315 dest->system = ta->system;
316 for(int c=0;c<dest->getSize();c++)
317 dest->setZoneIndex(c, ta->getZoneIndex(c));
321 UpdateZoneDefinitionCount();
324 int CAtmoConfig::getNumChannelAssignments() {
326 for(int i=0;i<10;i++)
327 if(this->m_ChannelAssignments[i]!=NULL) z++;
331 void CAtmoConfig::clearChannelMappings() {
332 for(int i=1;i<10;i++) {
333 CAtmoChannelAssignment *ca = m_ChannelAssignments[i];
336 m_ChannelAssignments[i] = NULL;
340 void CAtmoConfig::clearAllChannelMappings() {
341 for(int i=0;i<10;i++) {
342 CAtmoChannelAssignment *ca = m_ChannelAssignments[i];
345 m_ChannelAssignments[i] = NULL;
349 void CAtmoConfig::AddChannelAssignment(CAtmoChannelAssignment *ta) {
350 for(int i=0;i<10;i++) {
351 if(m_ChannelAssignments[i] == NULL) {
352 m_ChannelAssignments[i] = ta;
358 void CAtmoConfig::SetChannelAssignment(int index, CAtmoChannelAssignment *ta) {
359 if(m_ChannelAssignments[index]!=NULL)
360 delete m_ChannelAssignments[index];
361 m_ChannelAssignments[index] = ta;
364 CAtmoZoneDefinition *CAtmoConfig::getZoneDefinition(int zoneIndex) {
367 if(zoneIndex >= m_AtmoZoneDefCount)
369 return m_ZoneDefinitions[zoneIndex];
373 void CAtmoConfig::UpdateZoneCount()
375 m_computed_zones_count = m_ZonesTopCount + m_ZonesBottomCount + 2 * m_ZonesLRCount;
377 m_computed_zones_count++;
380 int CAtmoConfig::getZoneCount()
382 return(m_computed_zones_count);
385 void CAtmoConfig::UpdateZoneDefinitionCount()
387 if( getZoneCount() != m_AtmoZoneDefCount)
389 // okay zonen anzahl hat sich geändert - wir müssen neu rechnen
391 if(m_ZoneDefinitions)
393 for(int zone=0; zone<m_AtmoZoneDefCount; zone++)
394 delete m_ZoneDefinitions[zone];
395 delete[] m_ZoneDefinitions;
396 m_ZoneDefinitions = NULL;
398 m_AtmoZoneDefCount = getZoneCount();
399 if(m_AtmoZoneDefCount > 0)
401 m_ZoneDefinitions = new CAtmoZoneDefinition*[m_AtmoZoneDefCount];
402 for(int zone=0; zone< m_AtmoZoneDefCount; zone++) {
403 m_ZoneDefinitions[zone] = new CAtmoZoneDefinition();
404 m_ZoneDefinitions[zone]->Fill(255);
410 #if defined(_ATMO_VLC_PLUGIN_)
412 char *CAtmoConfig::getSerialDevice(int i)
418 return m_devicenames[i];
422 void CAtmoConfig::setSerialDevice(int i,const char *pszNewDevice)
425 setSerialDevice(pszNewDevice);
428 free( m_devicenames[i] );
430 m_devicenames[i] = strdup(pszNewDevice);
432 m_devicenames[i] = NULL;
438 int CAtmoConfig::getComport(int i)
441 return this->m_Comport;
444 return this->m_Comports[i];
448 void CAtmoConfig::setComport(int i, int nr)
451 this->m_Comport = nr;
453 this->m_Comports[i-1] = nr;
459 void CAtmoConfig::setDMX_BaseChannels(char *channels)
461 free(m_DMX_BaseChannels);
462 m_DMX_BaseChannels = strdup(channels);
465 void CAtmoConfig::getChannelWhiteAdj(int channel,int &red,int &green,int &blue)
467 if(channel >= m_chWhiteAdj_Count)
475 red = m_chWhiteAdj_Red[ channel ];
476 green = m_chWhiteAdj_Green[ channel ];
477 blue = m_chWhiteAdj_Blue[ channel ];
482 void CAtmoConfig::setChannelWhiteAdj(int channel,int red,int green,int blue)
484 if(channel >= m_chWhiteAdj_Count)
486 int *tmp = new int[channel+1];
488 memcpy( tmp, m_chWhiteAdj_Red, m_chWhiteAdj_Count * sizeof(int) );
489 delete []m_chWhiteAdj_Red;
490 m_chWhiteAdj_Red = tmp;
492 tmp = new int[channel + 1];
493 if(m_chWhiteAdj_Green)
494 memcpy( tmp, m_chWhiteAdj_Green, m_chWhiteAdj_Count * sizeof(int) );
495 delete []m_chWhiteAdj_Green;
496 m_chWhiteAdj_Green = tmp;
498 tmp = new int[channel + 1];
499 if(m_chWhiteAdj_Blue)
500 memcpy( tmp, m_chWhiteAdj_Blue, m_chWhiteAdj_Count * sizeof(int) );
501 delete []m_chWhiteAdj_Blue;
502 m_chWhiteAdj_Blue = tmp;
504 m_chWhiteAdj_Count = channel + 1;
507 m_chWhiteAdj_Red[channel] = red;
508 m_chWhiteAdj_Green[channel] = green;
509 m_chWhiteAdj_Blue[channel] = blue;