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
;
47 m_chWhiteAdj_Red
= NULL
;
48 m_chWhiteAdj_Green
= NULL
;
49 m_chWhiteAdj_Blue
= NULL
;
54 CAtmoConfig::~CAtmoConfig() {
55 // and finally cleanup...
56 clearAllChannelMappings();
60 for(int zone
=0; zone
<m_AtmoZoneDefCount
; zone
++)
61 delete m_ZoneDefinitions
[zone
];
62 delete m_ZoneDefinitions
;
63 m_ZoneDefinitions
= NULL
;
66 delete []m_chWhiteAdj_Red
;
67 delete []m_chWhiteAdj_Green
;
68 delete []m_chWhiteAdj_Blue
;
70 free( m_DMX_BaseChannels
);
72 #if defined (_ATMO_VLC_PLUGIN_)
74 free( m_devicenames
[0] );
75 free( m_devicenames
[1] );
76 free( m_devicenames
[2] );
80 void CAtmoConfig::LoadDefaults() {
81 // m_eAtmoConnectionType = actSerialPort;
83 #if defined (_ATMO_VLC_PLUGIN_)
86 free( m_devicenames
[0] );
87 free( m_devicenames
[1] );
88 free( m_devicenames
[2] );
91 m_devicenames
[0] = NULL
;
92 m_devicenames
[1] = NULL
;
93 m_devicenames
[2] = NULL
;
104 m_eEffectMode
= emDisabled
;
106 m_IgnoreConnectionErrorOnStartup
= ATMO_FALSE
;
108 m_UpdateEdgeWeightningFlag
= 0;
110 m_Software_gamma_mode
= agcNone
;
111 m_Software_gamma_red
= 10;
112 m_Software_gamma_green
= 10;
113 m_Software_gamma_blue
= 10;
114 m_Software_gamma_global
= 10;
116 m_WhiteAdjustment_Red
= 255;
117 m_WhiteAdjustment_Green
= 255;
118 m_WhiteAdjustment_Blue
= 255;
119 m_UseSoftwareWhiteAdj
= 1;
121 m_WhiteAdjPerChannel
= ATMO_FALSE
;
122 m_chWhiteAdj_Count
= 0;
124 delete []m_chWhiteAdj_Red
;
125 delete []m_chWhiteAdj_Green
;
126 delete []m_chWhiteAdj_Blue
;
128 m_chWhiteAdj_Red
= NULL
;
129 m_chWhiteAdj_Green
= NULL
;
130 m_chWhiteAdj_Blue
= NULL
;
132 m_ColorChanger_iSteps
= 50;
133 m_ColorChanger_iDelay
= 25;
135 m_LrColorChanger_iSteps
= 50;
136 m_LrColorChanger_iDelay
= 25;
138 m_IsSetShutdownColor
= 1;
139 m_ShutdownColor_Red
= 0;
140 m_ShutdownColor_Green
= 0;
141 m_ShutdownColor_Blue
= 0;
143 m_StaticColor_Red
= 127; // ??
144 m_StaticColor_Green
= 192;
145 m_StaticColor_Blue
= 255;
147 m_LiveViewFilterMode
= afmCombined
;
148 m_LiveViewFilter_PercentNew
= 50;
149 m_LiveViewFilter_MeanLength
= 300;
150 m_LiveViewFilter_MeanThreshold
= 40;
151 m_show_statistics
= ATMO_FALSE
;
153 m_LiveView_EdgeWeighting
= 8;
154 m_LiveView_BrightCorrect
= 100;
155 m_LiveView_DarknessLimit
= 5;
156 m_LiveView_HueWinSize
= 3;
157 m_LiveView_SatWinSize
= 3;
158 m_LiveView_WidescreenMode
= 0;
160 m_LiveView_HOverscanBorder
= 0;
161 m_LiveView_VOverscanBorder
= 0;
162 m_LiveView_DisplayNr
= 0;
163 m_LiveView_FrameDelay
= 30;
164 m_LiveView_GDI_FrameRate
= 25;
165 m_LiveView_RowsPerFrame
= 0;
168 m_Hardware_global_gamma
= 128;
169 m_Hardware_global_contrast
= 100;
170 m_Hardware_contrast_red
= 100;
171 m_Hardware_contrast_green
= 100;
172 m_Hardware_contrast_blue
= 100;
174 m_Hardware_gamma_red
= 22;
175 m_Hardware_gamma_green
= 22;
176 m_Hardware_gamma_blue
= 22;
178 m_DMX_BaseChannels
= strdup("0");
179 m_DMX_RGB_Channels
= 5; // so wie atmolight
181 m_MoMo_Channels
= 3; // default momo, there exists also a 4 ch version!
182 m_Fnordlicht_Amount
= 2; // default fnordlicht, there are 2 fnordlicht's!
185 m_ZonesBottomCount
= 1;
187 m_ZoneSummary
= ATMO_FALSE
;
190 clearAllChannelMappings();
191 m_CurrentChannelAssignment
= 0;
192 CAtmoChannelAssignment
*temp
= new CAtmoChannelAssignment();
194 temp
->setName( "Standard" );
195 this->m_ChannelAssignments
[0] = temp
;
197 UpdateZoneDefinitionCount();
200 void CAtmoConfig::Assign(CAtmoConfig
*pAtmoConfigSrc
) {
202 #if defined(_ATMO_VLC_PLUGIN_)
203 this->setSerialDevice(0, pAtmoConfigSrc
->getSerialDevice(0));
204 this->setSerialDevice(1, pAtmoConfigSrc
->getSerialDevice(1));
205 this->setSerialDevice(2, pAtmoConfigSrc
->getSerialDevice(2));
206 this->setSerialDevice(3, pAtmoConfigSrc
->getSerialDevice(3));
208 this->m_Comport
= pAtmoConfigSrc
->m_Comport
;
209 this->m_Comports
[0] = pAtmoConfigSrc
->m_Comports
[0];
210 this->m_Comports
[1] = pAtmoConfigSrc
->m_Comports
[1];
211 this->m_Comports
[2] = pAtmoConfigSrc
->m_Comports
[2];
214 this->m_eAtmoConnectionType
= pAtmoConfigSrc
->m_eAtmoConnectionType
;
215 this->m_eEffectMode
= pAtmoConfigSrc
->m_eEffectMode
;
217 this->m_WhiteAdjustment_Red
= pAtmoConfigSrc
->m_WhiteAdjustment_Red
;
218 this->m_WhiteAdjustment_Green
= pAtmoConfigSrc
->m_WhiteAdjustment_Green
;
219 this->m_WhiteAdjustment_Blue
= pAtmoConfigSrc
->m_WhiteAdjustment_Blue
;
220 this->m_UseSoftwareWhiteAdj
= pAtmoConfigSrc
->m_UseSoftwareWhiteAdj
;
222 this->m_WhiteAdjPerChannel
= pAtmoConfigSrc
->m_WhiteAdjPerChannel
;
223 this->m_chWhiteAdj_Count
= pAtmoConfigSrc
->m_chWhiteAdj_Count
;
224 delete []m_chWhiteAdj_Red
;
225 delete []m_chWhiteAdj_Green
;
226 delete []m_chWhiteAdj_Blue
;
227 if(m_chWhiteAdj_Count
> 0)
229 m_chWhiteAdj_Red
= new int[ m_chWhiteAdj_Count
];
230 m_chWhiteAdj_Green
= new int[ m_chWhiteAdj_Count
];
231 m_chWhiteAdj_Blue
= new int[ m_chWhiteAdj_Count
];
232 memcpy(m_chWhiteAdj_Red
, pAtmoConfigSrc
->m_chWhiteAdj_Red
, sizeof(int) * m_chWhiteAdj_Count
);
233 memcpy(m_chWhiteAdj_Green
, pAtmoConfigSrc
->m_chWhiteAdj_Green
, sizeof(int) * m_chWhiteAdj_Count
);
234 memcpy(m_chWhiteAdj_Blue
, pAtmoConfigSrc
->m_chWhiteAdj_Blue
, sizeof(int) * m_chWhiteAdj_Count
);
236 m_chWhiteAdj_Red
= NULL
;
237 m_chWhiteAdj_Green
= NULL
;
238 m_chWhiteAdj_Blue
= NULL
;
241 this->m_IsSetShutdownColor
= pAtmoConfigSrc
->m_IsSetShutdownColor
;
242 this->m_ShutdownColor_Red
= pAtmoConfigSrc
->m_ShutdownColor_Red
;
243 this->m_ShutdownColor_Green
= pAtmoConfigSrc
->m_ShutdownColor_Green
;
244 this->m_ShutdownColor_Blue
= pAtmoConfigSrc
->m_ShutdownColor_Blue
;
246 this->m_ColorChanger_iSteps
= pAtmoConfigSrc
->m_ColorChanger_iSteps
;
247 this->m_ColorChanger_iDelay
= pAtmoConfigSrc
->m_ColorChanger_iDelay
;
249 this->m_LrColorChanger_iSteps
= pAtmoConfigSrc
->m_LrColorChanger_iSteps
;
250 this->m_LrColorChanger_iDelay
= pAtmoConfigSrc
->m_LrColorChanger_iDelay
;
252 this->m_StaticColor_Red
= pAtmoConfigSrc
->m_StaticColor_Red
;
253 this->m_StaticColor_Green
= pAtmoConfigSrc
->m_StaticColor_Green
;
254 this->m_StaticColor_Blue
= pAtmoConfigSrc
->m_StaticColor_Blue
;
256 this->m_LiveViewFilterMode
= pAtmoConfigSrc
->m_LiveViewFilterMode
;
257 this->m_LiveViewFilter_PercentNew
= pAtmoConfigSrc
->m_LiveViewFilter_PercentNew
;
258 this->m_LiveViewFilter_MeanLength
= pAtmoConfigSrc
->m_LiveViewFilter_MeanLength
;
259 this->m_LiveViewFilter_MeanThreshold
= pAtmoConfigSrc
->m_LiveViewFilter_MeanThreshold
;
261 this->m_show_statistics
= pAtmoConfigSrc
->m_show_statistics
;
263 this->m_LiveView_EdgeWeighting
= pAtmoConfigSrc
->m_LiveView_EdgeWeighting
;
264 this->m_LiveView_BrightCorrect
= pAtmoConfigSrc
->m_LiveView_BrightCorrect
;
265 this->m_LiveView_DarknessLimit
= pAtmoConfigSrc
->m_LiveView_DarknessLimit
;
266 this->m_LiveView_HueWinSize
= pAtmoConfigSrc
->m_LiveView_HueWinSize
;
267 this->m_LiveView_SatWinSize
= pAtmoConfigSrc
->m_LiveView_SatWinSize
;
268 this->m_LiveView_WidescreenMode
= pAtmoConfigSrc
->m_LiveView_WidescreenMode
;
270 this->m_LiveView_HOverscanBorder
= pAtmoConfigSrc
->m_LiveView_HOverscanBorder
;
271 this->m_LiveView_VOverscanBorder
= pAtmoConfigSrc
->m_LiveView_VOverscanBorder
;
272 this->m_LiveView_DisplayNr
= pAtmoConfigSrc
->m_LiveView_DisplayNr
;
273 this->m_LiveView_FrameDelay
= pAtmoConfigSrc
->m_LiveView_FrameDelay
;
274 this->m_LiveView_GDI_FrameRate
= pAtmoConfigSrc
->m_LiveView_GDI_FrameRate
;
275 this->m_LiveView_RowsPerFrame
= pAtmoConfigSrc
->m_LiveView_RowsPerFrame
;
277 this->m_ZonesTopCount
= pAtmoConfigSrc
->m_ZonesTopCount
;
278 this->m_ZonesBottomCount
= pAtmoConfigSrc
->m_ZonesBottomCount
;
279 this->m_ZonesLRCount
= pAtmoConfigSrc
->m_ZonesLRCount
;
280 this->m_ZoneSummary
= pAtmoConfigSrc
->m_ZoneSummary
;
283 this->m_Software_gamma_mode
= pAtmoConfigSrc
->m_Software_gamma_mode
;
284 this->m_Software_gamma_red
= pAtmoConfigSrc
->m_Software_gamma_red
;
285 this->m_Software_gamma_green
= pAtmoConfigSrc
->m_Software_gamma_green
;
286 this->m_Software_gamma_blue
= pAtmoConfigSrc
->m_Software_gamma_blue
;
287 this->m_Software_gamma_global
= pAtmoConfigSrc
->m_Software_gamma_global
;
289 this->setDMX_BaseChannels( pAtmoConfigSrc
->getDMX_BaseChannels() );
291 this->m_DMX_RGB_Channels
= pAtmoConfigSrc
->m_DMX_RGB_Channels
;
293 this->m_MoMo_Channels
= pAtmoConfigSrc
->m_MoMo_Channels
;
295 this->m_Fnordlicht_Amount
= pAtmoConfigSrc
->m_Fnordlicht_Amount
;
297 this->m_CurrentChannelAssignment
= pAtmoConfigSrc
->m_CurrentChannelAssignment
;
299 clearChannelMappings();
300 for(int i
=1;i
<pAtmoConfigSrc
->getNumChannelAssignments();i
++) {
301 CAtmoChannelAssignment
*ta
= pAtmoConfigSrc
->m_ChannelAssignments
[i
];
303 CAtmoChannelAssignment
*dest
= this->m_ChannelAssignments
[i
];
305 dest
= new CAtmoChannelAssignment();
306 this->m_ChannelAssignments
[i
] = dest
;
308 // memcpy(dest, ta, sizeof(tChannelAssignment));
309 dest
->setSize(ta
->getSize());
310 dest
->setName(ta
->getName());
311 dest
->system
= ta
->system
;
312 for(int c
=0;c
<dest
->getSize();c
++)
313 dest
->setZoneIndex(c
, ta
->getZoneIndex(c
));
317 UpdateZoneDefinitionCount();
320 int CAtmoConfig::getNumChannelAssignments() {
322 for(int i
=0;i
<10;i
++)
323 if(this->m_ChannelAssignments
[i
]!=NULL
) z
++;
327 void CAtmoConfig::clearChannelMappings() {
328 for(int i
=1;i
<10;i
++) {
329 CAtmoChannelAssignment
*ca
= m_ChannelAssignments
[i
];
332 m_ChannelAssignments
[i
] = NULL
;
336 void CAtmoConfig::clearAllChannelMappings() {
337 for(int i
=0;i
<10;i
++) {
338 CAtmoChannelAssignment
*ca
= m_ChannelAssignments
[i
];
341 m_ChannelAssignments
[i
] = NULL
;
345 void CAtmoConfig::AddChannelAssignment(CAtmoChannelAssignment
*ta
) {
346 for(int i
=0;i
<10;i
++) {
347 if(m_ChannelAssignments
[i
] == NULL
) {
348 m_ChannelAssignments
[i
] = ta
;
354 void CAtmoConfig::SetChannelAssignment(int index
, CAtmoChannelAssignment
*ta
) {
355 if(m_ChannelAssignments
[index
]!=NULL
)
356 delete m_ChannelAssignments
[index
];
357 m_ChannelAssignments
[index
] = ta
;
360 CAtmoZoneDefinition
*CAtmoConfig::getZoneDefinition(int zoneIndex
) {
363 if(zoneIndex
>= m_AtmoZoneDefCount
)
365 return m_ZoneDefinitions
[zoneIndex
];
369 void CAtmoConfig::UpdateZoneCount()
371 m_computed_zones_count
= m_ZonesTopCount
+ m_ZonesBottomCount
+ 2 * m_ZonesLRCount
;
373 m_computed_zones_count
++;
376 int CAtmoConfig::getZoneCount()
378 return(m_computed_zones_count
);
381 void CAtmoConfig::UpdateZoneDefinitionCount()
383 if( getZoneCount() != m_AtmoZoneDefCount
)
385 // okay zonen anzahl hat sich geändert - wir müssen neu rechnen
387 if(m_ZoneDefinitions
)
389 for(int zone
=0; zone
<m_AtmoZoneDefCount
; zone
++)
390 delete m_ZoneDefinitions
[zone
];
391 delete m_ZoneDefinitions
;
392 m_ZoneDefinitions
= NULL
;
394 m_AtmoZoneDefCount
= getZoneCount();
395 if(m_AtmoZoneDefCount
> 0)
397 m_ZoneDefinitions
= new CAtmoZoneDefinition
*[m_AtmoZoneDefCount
];
398 for(int zone
=0; zone
< m_AtmoZoneDefCount
; zone
++) {
399 m_ZoneDefinitions
[zone
] = new CAtmoZoneDefinition();
400 m_ZoneDefinitions
[zone
]->Fill(255);
406 #if defined(_ATMO_VLC_PLUGIN_)
408 char *CAtmoConfig::getSerialDevice(int i
)
414 return m_devicenames
[i
];
418 void CAtmoConfig::setSerialDevice(int i
,const char *pszNewDevice
)
421 setSerialDevice(pszNewDevice
);
424 free( m_devicenames
[i
] );
426 m_devicenames
[i
] = strdup(pszNewDevice
);
428 m_devicenames
[i
] = NULL
;
434 int CAtmoConfig::getComport(int i
)
437 return this->m_Comport
;
440 return this->m_Comports
[i
];
444 void CAtmoConfig::setComport(int i
, int nr
)
447 this->m_Comport
= nr
;
449 this->m_Comports
[i
-1] = nr
;
455 void CAtmoConfig::setDMX_BaseChannels(char *channels
)
457 free(m_DMX_BaseChannels
);
458 m_DMX_BaseChannels
= strdup(channels
);
461 void CAtmoConfig::getChannelWhiteAdj(int channel
,int &red
,int &green
,int &blue
)
463 if(channel
>= m_chWhiteAdj_Count
)
471 red
= m_chWhiteAdj_Red
[ channel
];
472 green
= m_chWhiteAdj_Green
[ channel
];
473 blue
= m_chWhiteAdj_Blue
[ channel
];
478 void CAtmoConfig::setChannelWhiteAdj(int channel
,int red
,int green
,int blue
)
480 if(channel
>= m_chWhiteAdj_Count
)
482 int *tmp
= new int[channel
+1];
484 memcpy( tmp
, m_chWhiteAdj_Red
, m_chWhiteAdj_Count
* sizeof(int) );
485 delete []m_chWhiteAdj_Red
;
486 m_chWhiteAdj_Red
= tmp
;
488 tmp
= new int[channel
+ 1];
489 if(m_chWhiteAdj_Green
)
490 memcpy( tmp
, m_chWhiteAdj_Green
, m_chWhiteAdj_Count
* sizeof(int) );
491 delete []m_chWhiteAdj_Green
;
492 m_chWhiteAdj_Green
= tmp
;
494 tmp
= new int[channel
+ 1];
495 if(m_chWhiteAdj_Blue
)
496 memcpy( tmp
, m_chWhiteAdj_Blue
, m_chWhiteAdj_Count
* sizeof(int) );
497 delete []m_chWhiteAdj_Blue
;
498 m_chWhiteAdj_Blue
= tmp
;
500 m_chWhiteAdj_Count
= channel
+ 1;
503 m_chWhiteAdj_Red
[channel
] = red
;
504 m_chWhiteAdj_Green
[channel
] = green
;
505 m_chWhiteAdj_Blue
[channel
] = blue
;