Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1066 lines
27 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 27/04/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: Device.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of Device.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "ObjectFactory.h"
  16. #ifdef SETUP_LGS_PROJECT
  17. #include "Resource.h"
  18. #endif
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char THIS_FILE[]=__FILE__;
  22. #define new DEBUG_NEW
  23. #endif
  24. using namespace SETUP_LGS_NAMESPACE;
  25. /***************************************************************************
  26. ***************************************************************************/
  27. CPin::CPin()
  28. {
  29. m_Owner.nType = DT_NONE;
  30. m_Owner.nIndex = -1;
  31. m_Owner.nPin = -1;
  32. m_pDevice = NULL;
  33. m_nDeviceCount = 0;
  34. m_nDeviceMax = 0;
  35. m_nPinType = PT_NONE;
  36. m_nTruePinType = PT_NONE;
  37. m_Pos = CPoint( 0, 0 );
  38. m_Name = _T( "ERROR" );
  39. }
  40. CPin::~CPin()
  41. {
  42. if( m_pDevice )
  43. free( m_pDevice );
  44. }
  45. COLORREF CPin::GetColor()
  46. {
  47. switch( m_nPinType )
  48. {
  49. case PT_NONE:
  50. break;
  51. case PT_VIDEO_IN:
  52. case PT_VIDEO_OUT:
  53. return RGB( 0xFF,0xFF,0 );
  54. case PT_RABBIT_IN:
  55. case PT_RABBIT_OUT:
  56. return RGB( 0x7F,0x7F,0x7F );
  57. case PT_SOCKET_MD:
  58. return RGB( 0,0xFF,0 );
  59. case PT_SOCKET_PTZ:
  60. return RGB( 0xFF,0,0xFF );
  61. case PT_SOCKET_LGS:
  62. return RGB( 0,0x7F,0 );
  63. case PT_SOCKET_VM:
  64. return RGB( 0x7F,0,0x7F );
  65. }
  66. ASSERT( NULL ); // color definition should be for each pin type
  67. return 0;
  68. }
  69. void CPin::Initialize( int nOwnerType, int nOwnerPin, int nPinType, int nTruePinType, int nDeviceMax, CPoint pos, LPCTSTR pName )
  70. {
  71. ASSERT( m_nPinType == PT_NONE );
  72. ASSERT( m_nTruePinType == PT_NONE );
  73. m_Owner.nType = nOwnerType;
  74. m_Owner.nPin = nOwnerPin;
  75. m_nPinType = nPinType;
  76. m_nTruePinType = nTruePinType;
  77. m_nDeviceMax = nDeviceMax;
  78. m_Pos = pos;
  79. /*
  80. switch( m_nPinType )
  81. {
  82. case PT_NONE: ASSERT(NULL);
  83. break;
  84. case PT_VIDEO_IN:
  85. m_Name = _T("VIDEO IN");
  86. break;
  87. case PT_VIDEO_OUT:
  88. m_Name = _T("VIDEO OUT");
  89. break;
  90. case PT_RABBIT_IN:
  91. m_Name = _T("RABBIT IN");
  92. break;
  93. case PT_RABBIT_OUT:
  94. m_Name = _T("RABBIT OUT");
  95. break;
  96. case PT_SOCKET:
  97. m_Name = _T("SOCKET");
  98. break;
  99. }
  100. */
  101. m_Name = pName;
  102. }
  103. BOOL CPin::Connect( CPin *pPin )
  104. {
  105. ASSERT( m_nPinType != PT_NONE );
  106. ASSERT( m_nTruePinType != PT_NONE );
  107. ASSERT( pPin );
  108. ASSERT( pPin->m_nPinType != PT_NONE );
  109. ASSERT( pPin->m_nTruePinType != PT_NONE );
  110. ASSERT( m_Owner.nIndex != -1 );
  111. ASSERT( pPin->m_Owner.nIndex != -1 );
  112. if( pPin != this && // impossible to connect to itself
  113. m_nTruePinType == pPin->m_nPinType &&
  114. m_nPinType == pPin->m_nTruePinType && // possible to connect only compatible pins
  115. m_nDeviceCount <= m_nDeviceMax &&
  116. pPin->m_nDeviceCount <= pPin->m_nDeviceMax ) // possible to connect not more then "m_nDeviceMax" pins to pin
  117. {
  118. BOOL bFound = FALSE;
  119. for( int i = 0; i < m_nDeviceCount; i++ )
  120. {
  121. if( ( m_pDevice[i].nType == pPin->m_Owner.nType ) &&
  122. ( m_pDevice[i].nIndex == pPin->m_Owner.nIndex ) &&
  123. ( m_pDevice[i].nPin == pPin->m_Owner.nPin ) )
  124. bFound = TRUE;
  125. }
  126. if( !bFound )
  127. {
  128. m_pDevice = (DID*)realloc( m_pDevice, sizeof( DID ) * (m_nDeviceCount + 1) );
  129. m_pDevice[ m_nDeviceCount ] = pPin->m_Owner;
  130. m_nDeviceCount++;
  131. pPin->m_pDevice = (DID*)realloc( pPin->m_pDevice, sizeof( DID ) * (pPin->m_nDeviceCount + 1) );
  132. pPin->m_pDevice[ pPin->m_nDeviceCount ] = m_Owner;
  133. pPin->m_nDeviceCount++;
  134. return TRUE;
  135. }
  136. }
  137. return FALSE;
  138. }
  139. BOOL CPin::Disconnect( CPin *pPin )
  140. {
  141. ASSERT( m_nPinType != PT_NONE );
  142. ASSERT( m_nTruePinType != PT_NONE );
  143. ASSERT( m_Owner.nIndex != -1 );
  144. if( pPin )
  145. {
  146. ASSERT( pPin->m_nPinType != PT_NONE );
  147. ASSERT( pPin->m_nTruePinType != PT_NONE );
  148. ASSERT( pPin->m_Owner.nIndex != -1 );
  149. for( int i = 0; i < m_nDeviceCount; i++ )
  150. {
  151. if( ( m_pDevice[i].nType == pPin->m_Owner.nType ) &&
  152. ( m_pDevice[i].nIndex == pPin->m_Owner.nIndex ) &&
  153. ( m_pDevice[i].nPin == pPin->m_Owner.nPin ) )
  154. {
  155. m_nDeviceCount--;
  156. m_pDevice[i] = m_pDevice[ m_nDeviceCount ]; // move last to deleting position
  157. m_pDevice = (DID*)realloc( m_pDevice, sizeof( DID ) * m_nDeviceCount ); // deallocate unusable DID
  158. return TRUE;
  159. }
  160. }
  161. }
  162. else
  163. {
  164. for( int i = 0; i < m_nDeviceCount; i++ )
  165. {
  166. CDevice *pDevice = GetOF()->DeviceGet( m_pDevice[i].nIndex, m_pDevice[i].nType );
  167. CPin *pPin = pDevice->GetPin( m_pDevice[i].nPin );
  168. pPin->Disconnect( this );
  169. }
  170. if( m_pDevice )
  171. {
  172. free( m_pDevice );
  173. m_pDevice = NULL;
  174. }
  175. m_nDeviceCount = 0;
  176. }
  177. return FALSE;
  178. }
  179. void CPin::Serialize(CArchive& ar)
  180. {
  181. if (ar.IsStoring())
  182. {
  183. ar << m_Pos.x;
  184. ar << m_Pos.y;
  185. ar << m_nPinType;
  186. ar << m_nTruePinType;
  187. ar << m_Owner.nType;
  188. ar << m_Owner.nIndex;
  189. ar << m_Owner.nPin;
  190. ar << m_nDeviceCount;
  191. for( int i = 0; i < m_nDeviceCount; i++ )
  192. {
  193. ar << m_pDevice[i].nType;
  194. ar << m_pDevice[i].nIndex;
  195. ar << m_pDevice[i].nPin;
  196. }
  197. ar << m_Name;
  198. }
  199. else
  200. {
  201. ar >> m_Pos.x;
  202. ar >> m_Pos.y;
  203. ar >> m_nPinType;
  204. ar >> m_nTruePinType;
  205. ar >> m_Owner.nType;
  206. ar >> m_Owner.nIndex;
  207. ar >> m_Owner.nPin;
  208. ar >> m_nDeviceCount;
  209. m_pDevice = (DID*)realloc( m_pDevice, sizeof( DID ) * m_nDeviceCount );
  210. for( int i = 0; i < m_nDeviceCount; i++ )
  211. {
  212. ar >> m_pDevice[i].nType;
  213. ar >> m_pDevice[i].nIndex;
  214. ar >> m_pDevice[i].nPin;
  215. }
  216. ar >> m_Name;
  217. }
  218. }
  219. /***************************************************************************
  220. ***************************************************************************/
  221. CDevice::CDevice()
  222. {
  223. m_hIcon[0] = NULL;
  224. m_hIcon[1] = NULL;
  225. m_nIndex = -1;
  226. m_pPin = NULL;
  227. m_nPin = 0;
  228. m_Name = _T("UNKNOWN");
  229. m_pOF = NULL;
  230. }
  231. CDevice::~CDevice()
  232. {
  233. if( m_hIcon[0] )
  234. DeleteObject( m_hIcon[0] );
  235. if( m_hIcon[1] )
  236. DeleteObject( m_hIcon[1] );
  237. if( m_pPin )
  238. delete [] m_pPin;
  239. }
  240. void CDevice::CreatePins( PIN_DESC* pPinDesc, int nCount )
  241. {
  242. m_nPin = nCount;
  243. m_pPin = new CPin[nCount];
  244. for( int i = 0; i < nCount; i++ )
  245. m_pPin[i].Initialize( GetType(), i, pPinDesc[i].nPinType, pPinDesc[i].nTruePinType, pPinDesc[i].nDeviceMax, *pPinDesc[i].pPos, pPinDesc[i].pName );
  246. }
  247. CPin *CDevice::GetFreePin( int nType, int nIndex )
  248. {
  249. // ASSERT( nIndex < m_nPin );
  250. for( int i = nIndex; i < m_nPin; i++ )
  251. {
  252. if( m_pPin[i].GetType() == nType && m_pPin[i].IsFree() )
  253. {
  254. return &m_pPin[i];
  255. }
  256. }
  257. return NULL;
  258. }
  259. BOOL CDevice::IsPossibleToConnect( CDevice *pDevice )
  260. {
  261. if( pDevice )
  262. {
  263. for( int i = 0; i < m_nPin; i++ )
  264. {
  265. for( int j = 0; j < pDevice->m_nPin; j++ )
  266. {
  267. if( m_pPin[i].GetType() == pDevice->m_pPin[j].GetTrueType() &&
  268. m_pPin[i].IsFree() && pDevice->m_pPin[j].IsFree())
  269. return TRUE;
  270. }
  271. }
  272. }
  273. else
  274. {
  275. for( int i = 0; i < m_nPin; i++ )
  276. {
  277. if( m_pPin[i].IsFree() )
  278. return TRUE;
  279. }
  280. }
  281. return FALSE;
  282. }
  283. void CDevice::SetIndex( int nIndex )
  284. {
  285. m_nIndex = nIndex;
  286. for( int i = 0; i < GetPinCount(); i++ )
  287. {
  288. GetPin( i )->m_Owner.nIndex = nIndex;
  289. GetPin( i )->m_pOF = GetOF();
  290. }
  291. }
  292. void CDevice::Serialize(CArchive& ar)
  293. {
  294. if (ar.IsStoring())
  295. {
  296. ar << m_Pos.x;
  297. ar << m_Pos.y;
  298. ar << m_Name;
  299. }
  300. else
  301. {
  302. ar >> m_Pos.x;
  303. ar >> m_Pos.y;
  304. ar >> m_Name;
  305. }
  306. for( int i = 0; i < GetPinCount(); i++ )
  307. {
  308. GetPin(i)->Serialize( ar );
  309. GetPin(i)->m_pOF = GetOF();
  310. }
  311. }
  312. void CDevice::Draw( CDC *pDC, BOOL bActive, CPoint shift, double scale )
  313. {
  314. CPoint p( (int)(m_Pos.x * scale) - NORMAL_SIZE - shift.x,
  315. (int)(m_Pos.y * scale) - NORMAL_SIZE - shift.y );
  316. if( bActive )
  317. {
  318. pDC->DrawIcon( p, m_hIcon[1] );
  319. }
  320. else
  321. {
  322. pDC->DrawIcon( p, m_hIcon[0] );
  323. }
  324. }
  325. /***************************************************************************
  326. ***************************************************************************/
  327. CDeviceCamera::CDeviceCamera()
  328. {
  329. PIN_DESC pPD[] =
  330. {
  331. { PT_VIDEO_OUT, PT_VIDEO_IN, 1, &CPoint( 4,15 ), 0, _T("VIDEO OUT") }
  332. };
  333. CreatePins( pPD, sizeof(pPD) / sizeof(pPD[0]) );
  334. m_Name = _T("Fixed camera");
  335. }
  336. CDeviceCamera::~CDeviceCamera()
  337. {
  338. }
  339. /***************************************************************************
  340. ***************************************************************************/
  341. CDeviceLGS::CDeviceLGS()
  342. {
  343. PIN_DESC pPD[] =
  344. {
  345. { PT_SOCKET_MD, PT_SOCKET_MD, INT_MAX, &CPoint( 15,31 ), 0, _T("SOCKET MD") }
  346. };
  347. CreatePins( pPD, sizeof(pPD) / sizeof(pPD[0]) );
  348. m_Name = _T("Multi-drop LGS sensor");
  349. m_nSubType = ST_MULTI;
  350. m_nAddress = 0;
  351. }
  352. CDeviceLGS::~CDeviceLGS()
  353. {
  354. }
  355. void CDeviceLGS::Serialize( CArchive& ar )
  356. {
  357. CDevice::Serialize( ar );
  358. if (ar.IsStoring())
  359. {
  360. ar << m_nSubType;
  361. ar << m_nAddress;
  362. }
  363. else
  364. {
  365. ar >> m_nSubType;
  366. ar >> m_nAddress;
  367. }
  368. }
  369. void CDeviceLGS::ChangeSubType( int nSubType )
  370. {
  371. GetOF()->DeviceDisconnect( this );
  372. m_nSubType = nSubType;
  373. CPin *pPin = GetPin( 0 );
  374. switch( m_nSubType )
  375. {
  376. case ST_MULTI:
  377. pPin->m_nPinType = PT_SOCKET_MD;
  378. pPin->m_nTruePinType = PT_SOCKET_MD;
  379. pPin->m_nDeviceMax = INT_MAX;
  380. pPin->m_Name = _T("SOCKET MD");
  381. break;
  382. case ST_SINGLE:
  383. pPin->m_nPinType = PT_SOCKET_LGS;
  384. pPin->m_nTruePinType = PT_SOCKET_LGS;
  385. pPin->m_nDeviceMax = 1;
  386. pPin->m_Name = _T("SOCKET LGS");
  387. break;
  388. }
  389. }
  390. /***************************************************************************
  391. ***************************************************************************/
  392. CDeviceMigvan::CDeviceMigvan()
  393. {
  394. m_bAuto = FALSE;
  395. m_pHardwareID[0] = 0;
  396. m_pHardwareID[1] = 0;
  397. m_pHardwareID[2] = 0;
  398. m_pHardwareID[3] = 0;
  399. m_pHardwareID[4] = 0;
  400. }
  401. CDeviceMigvan::~CDeviceMigvan()
  402. {
  403. }
  404. void CDeviceMigvan::Serialize( CArchive& ar )
  405. {
  406. CDevice::Serialize( ar );
  407. if (ar.IsStoring())
  408. {
  409. ar << m_pHardwareID[0];
  410. ar << m_pHardwareID[1];
  411. ar << m_pHardwareID[2];
  412. ar << m_pHardwareID[3];
  413. ar << m_pHardwareID[4];
  414. ar << m_bAuto;
  415. }
  416. else
  417. {
  418. ar >> m_pHardwareID[0];
  419. ar >> m_pHardwareID[1];
  420. ar >> m_pHardwareID[2];
  421. ar >> m_pHardwareID[3];
  422. ar >> m_pHardwareID[4];
  423. ar >> m_bAuto;
  424. }
  425. }
  426. /***************************************************************************
  427. ***************************************************************************/
  428. CDeviceMigvanCameraPTZ::CDeviceMigvanCameraPTZ()
  429. {
  430. PIN_DESC pPD[] =
  431. {
  432. { PT_VIDEO_OUT, PT_VIDEO_IN, 1, &CPoint( 4,15 ), 0, _T("VIDEO OUT") },
  433. { PT_SOCKET_PTZ, PT_SOCKET_PTZ, INT_MAX, &CPoint( 15,31 ), 0, _T("SOCKET PTZ") }
  434. };
  435. CreatePins( pPD, sizeof(pPD) / sizeof(pPD[0]) );
  436. m_Name = _T("Migvan PTZ camera");
  437. }
  438. CDeviceMigvanCameraPTZ::~CDeviceMigvanCameraPTZ()
  439. {
  440. }
  441. /***************************************************************************
  442. ***************************************************************************/
  443. CDeviceMigvanVM8x4::CDeviceMigvanVM8x4()
  444. {
  445. PIN_DESC pPD[] =
  446. {
  447. { PT_VIDEO_OUT, PT_VIDEO_IN, 1, &CPoint( 5,11 ), 0, _T("VIDEO OUT 1") },
  448. { PT_VIDEO_OUT, PT_VIDEO_IN, 1, &CPoint( 5,14 ), 1, _T("VIDEO OUT 2") },
  449. { PT_VIDEO_OUT, PT_VIDEO_IN, 1, &CPoint( 5,17 ), 2, _T("VIDEO OUT 3") },
  450. { PT_VIDEO_OUT, PT_VIDEO_IN, 1, &CPoint( 5,20 ), 3, _T("VIDEO OUT 4") },
  451. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26, 5 ), 0, _T("VIDEO IN 1") },
  452. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26, 8 ), 1, _T("VIDEO IN 2") },
  453. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26,11 ), 2, _T("VIDEO IN 3") },
  454. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26,14 ), 3, _T("VIDEO IN 4") },
  455. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26,17 ), 4, _T("VIDEO IN 5") },
  456. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26,20 ), 5, _T("VIDEO IN 6") },
  457. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26,23 ), 6, _T("VIDEO IN 7") },
  458. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26,26 ), 7, _T("VIDEO IN 8") },
  459. { PT_SOCKET_VM, PT_SOCKET_VM, INT_MAX, &CPoint( 16,31 ), 0, _T("SOCKET VM") }
  460. };
  461. CreatePins( pPD, sizeof(pPD) / sizeof(pPD[0]) );
  462. m_Name = _T("Migvan video matrix");
  463. }
  464. CDeviceMigvanVM8x4::~CDeviceMigvanVM8x4()
  465. {
  466. }
  467. /***************************************************************************
  468. ***************************************************************************/
  469. CDeviceRabbit::CDeviceRabbit()
  470. {
  471. PIN_DESC pPD[] =
  472. {
  473. { PT_VIDEO_OUT, PT_VIDEO_IN, 1, &CPoint( 5,11 ), 0, _T("VIDEO OUT 1") },
  474. { PT_VIDEO_OUT, PT_VIDEO_IN, 1, &CPoint( 5,19 ), 1, _T("VIDEO OUT 2") },
  475. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26, 9 ), 0, _T("VIDEO IN 1-1") },
  476. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26,13 ), 1, _T("VIDEO IN 1-2") },
  477. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26,17 ), 2, _T("VIDEO IN 2-1") },
  478. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 26,21 ), 3, _T("VIDEO IN 2-2") },
  479. { PT_SOCKET_MD, PT_SOCKET_MD, INT_MAX, &CPoint( 16,31 ), 0, _T("SOCKET MD") },
  480. { PT_RABBIT_IN, PT_RABBIT_OUT, 1, &CPoint( 16,0 ), 0, _T("CONNECTION TO CAMERA") }
  481. };
  482. CreatePins( pPD, sizeof(pPD) / sizeof(pPD[0]) );
  483. m_Name = _T("Rabbit controller");
  484. m_nAddress = 0;
  485. }
  486. CDeviceRabbit::~CDeviceRabbit()
  487. {
  488. }
  489. void CDeviceRabbit::Serialize( CArchive& ar )
  490. {
  491. CDevice::Serialize( ar );
  492. if (ar.IsStoring())
  493. {
  494. ar << m_nAddress;
  495. }
  496. else
  497. {
  498. ar >> m_nAddress;
  499. }
  500. }
  501. /***************************************************************************
  502. ***************************************************************************/
  503. CDeviceRabbitCamera::CDeviceRabbitCamera()
  504. {
  505. PIN_DESC pPD[] =
  506. {
  507. { PT_VIDEO_OUT, PT_VIDEO_IN, 1, &CPoint( 4,15 ), 0, _T("VIDEO OUT") },
  508. { PT_RABBIT_OUT, PT_RABBIT_IN, 1, &CPoint( 15,31 ), 0, _T("CONNECTION TO RABBIT") }
  509. };
  510. CreatePins( pPD, sizeof(pPD) / sizeof(pPD[0]) );
  511. m_Name = _T("PTZ Migvan&Rabbit camera");
  512. }
  513. CDeviceRabbitCamera::~CDeviceRabbitCamera()
  514. {
  515. }
  516. /***************************************************************************
  517. ***************************************************************************/
  518. CDeviceSocket::CDeviceSocket()
  519. {
  520. PIN_DESC pPD[] =
  521. {
  522. { PT_SOCKET_MD, PT_SOCKET_MD, INT_MAX, &CPoint( 31,16 ), 0, _T("SOCKET MD") }
  523. };
  524. CreatePins( pPD, sizeof(pPD) / sizeof(pPD[0]) );
  525. m_Name = _T("Computer communication socket");
  526. m_nSubType = ST_MD;
  527. m_Port = _T("COM1");
  528. m_BaudRate = _T("19200");
  529. }
  530. CDeviceSocket::~CDeviceSocket()
  531. {
  532. }
  533. void CDeviceSocket::Serialize( CArchive& ar )
  534. {
  535. CDevice::Serialize( ar );
  536. if (ar.IsStoring())
  537. {
  538. ar << m_nSubType;
  539. ar << m_Port;
  540. ar << m_BaudRate;
  541. }
  542. else
  543. {
  544. ar >> m_nSubType;
  545. ar >> m_Port;
  546. ar >> m_BaudRate;
  547. }
  548. }
  549. void CDeviceSocket::ChangeSubType( int nSubType )
  550. {
  551. GetOF()->DeviceDisconnect( this );
  552. m_nSubType = nSubType;
  553. CPin *pPin = GetPin( 0 );
  554. switch( m_nSubType )
  555. {
  556. case ST_MD:
  557. pPin->m_nPinType = PT_SOCKET_MD;
  558. pPin->m_nTruePinType = PT_SOCKET_MD;
  559. pPin->m_nDeviceMax = INT_MAX;
  560. pPin->m_Name = _T("SOCKET MD");
  561. break;
  562. case ST_PTZ:
  563. pPin->m_nPinType = PT_SOCKET_PTZ;
  564. pPin->m_nTruePinType = PT_SOCKET_PTZ;
  565. pPin->m_nDeviceMax = INT_MAX;
  566. pPin->m_Name = _T("SOCKET PTZ");
  567. break;
  568. case ST_LGS:
  569. pPin->m_nPinType = PT_SOCKET_LGS;
  570. pPin->m_nTruePinType = PT_SOCKET_LGS;
  571. pPin->m_nDeviceMax = 1;
  572. pPin->m_Name = _T("SOCKET LGS");
  573. break;
  574. case ST_VM:
  575. pPin->m_nPinType = PT_SOCKET_VM;
  576. pPin->m_nTruePinType = PT_SOCKET_VM;
  577. pPin->m_nDeviceMax = INT_MAX;
  578. pPin->m_Name = _T("SOCKET VM");
  579. break;
  580. }
  581. }
  582. /***************************************************************************
  583. ***************************************************************************/
  584. CDeviceVideoIn::CDeviceVideoIn()
  585. {
  586. PIN_DESC pPD[] =
  587. {
  588. { PT_VIDEO_IN, PT_VIDEO_OUT, 1, &CPoint( 31, 16 ), 0, _T("VIDEO IN") }
  589. };
  590. CreatePins( pPD, sizeof(pPD) / sizeof(pPD[0]) );
  591. m_Name = _T("Computer video input");
  592. }
  593. CDeviceVideoIn::~CDeviceVideoIn()
  594. {
  595. }
  596. /***************************************************************************
  597. ***************************************************************************/
  598. CObjectFactory::CObjectFactory()
  599. {
  600. for( int i = 0; i < DT_COUNT; i++ )
  601. {
  602. m_pDevice[i].nCount = 0;
  603. m_pDevice[i].ppDevice = NULL;
  604. m_pDevice[i].nType = DT_FIRST + i;
  605. }
  606. m_Background = _T("");
  607. m_MapSize.cx = 1000;
  608. m_MapSize.cy = 1000;
  609. }
  610. CObjectFactory::~CObjectFactory()
  611. {
  612. for( int i = 0; i < DT_COUNT; i++ )
  613. {
  614. if( m_pDevice[i].ppDevice )
  615. {
  616. for( int j = 0; j < m_pDevice[i].nCount; j++ )
  617. delete m_pDevice[i].ppDevice[j];
  618. free( m_pDevice[i].ppDevice );
  619. }
  620. }
  621. }
  622. CDevice* CObjectFactory::ClassCreate(int nType)
  623. {
  624. CDevice *pDevice = NULL;
  625. switch( nType )
  626. {
  627. case DT_CAMERA: pDevice = new CDeviceCamera; break;
  628. case DT_CAMERA_PTZ: pDevice = new CDeviceMigvanCameraPTZ; break;
  629. case DT_CAMERA_RABBIT: pDevice = new CDeviceRabbitCamera; break;
  630. case DT_RABBIT: pDevice = new CDeviceRabbit; break;
  631. case DT_VM8X4: pDevice = new CDeviceMigvanVM8x4; break;
  632. case DT_SOCKET: pDevice = new CDeviceSocket; break;
  633. case DT_VIDEO_IN: pDevice = new CDeviceVideoIn; break;
  634. case DT_LGS: pDevice = new CDeviceLGS; break;
  635. }
  636. ASSERT( pDevice ); // check source code: requared class absent!!!
  637. #ifdef SETUP_LGS_PROJECT
  638. switch( nType )
  639. {
  640. case DT_CAMERA:
  641. pDevice->m_hIcon[0] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_CAMERA_1 );
  642. pDevice->m_hIcon[1] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_CAMERA_2 );
  643. break;
  644. case DT_CAMERA_PTZ:
  645. pDevice->m_hIcon[0] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_CAMERA_PTZ_1 );
  646. pDevice->m_hIcon[1] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_CAMERA_PTZ_2 );
  647. break;
  648. case DT_CAMERA_RABBIT:
  649. pDevice->m_hIcon[0] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_CAMERA_RABBIT_1 );
  650. pDevice->m_hIcon[1] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_CAMERA_RABBIT_2 );
  651. break;
  652. case DT_RABBIT:
  653. pDevice->m_hIcon[0] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_RABBIT_1 );
  654. pDevice->m_hIcon[1] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_RABBIT_2 );
  655. break;
  656. case DT_VM8X4:
  657. pDevice->m_hIcon[0] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_VM8X4_1 );
  658. pDevice->m_hIcon[1] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_VM8X4_2 );
  659. break;
  660. case DT_SOCKET:
  661. pDevice->m_hIcon[0] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_SOCKET_1 );
  662. pDevice->m_hIcon[1] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_SOCKET_2 );
  663. break;
  664. case DT_VIDEO_IN:
  665. pDevice->m_hIcon[0] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_VIDEO_IN_1 );
  666. pDevice->m_hIcon[1] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_VIDEO_IN_2 );
  667. break;
  668. case DT_LGS:
  669. pDevice->m_hIcon[0] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_LGS_MD_1 );
  670. pDevice->m_hIcon[1] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_LGS_MD_2 );
  671. break;
  672. case DT_CAMERA_LGS:
  673. pDevice->m_hIcon[0] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_CAMERA_LGS_1 );
  674. pDevice->m_hIcon[1] = LoadIcon( AfxGetInstanceHandle(), (LPCTSTR)IDI_CAMERA_LGS_2 );
  675. break;
  676. }
  677. #endif
  678. pDevice->m_pOF = this;
  679. return pDevice;
  680. }
  681. CDevice *CObjectFactory::DeviceGet( CRect &rect )
  682. {
  683. for( int i = 0; i < DT_COUNT; i++ )
  684. {
  685. for( int j = 0; j < m_pDevice[i].nCount; j++ )
  686. {
  687. if( rect.PtInRect( m_pDevice[i].ppDevice[j]->m_Pos ) )
  688. return m_pDevice[i].ppDevice[j];
  689. }
  690. }
  691. return NULL;
  692. }
  693. CDevice* CObjectFactory::DeviceAdd(double x, double y, int nType)
  694. {
  695. for( int i = 0; i < DT_COUNT; i++ )
  696. {
  697. if( m_pDevice[i].nType == nType )
  698. {
  699. m_pDevice[i].ppDevice = (CDevice**)realloc( m_pDevice[i].ppDevice, sizeof( CDevice* ) * ( m_pDevice[i].nCount + 1 ) );
  700. m_pDevice[i].ppDevice[ m_pDevice[i].nCount ] = ClassCreate( nType );
  701. m_pDevice[i].ppDevice[ m_pDevice[i].nCount ]->m_Pos.x = x;
  702. m_pDevice[i].ppDevice[ m_pDevice[i].nCount ]->m_Pos.y = y;
  703. m_pDevice[i].ppDevice[ m_pDevice[i].nCount ]->SetIndex( m_pDevice[i].nCount );
  704. return m_pDevice[i].ppDevice[ m_pDevice[i].nCount++ ];
  705. }
  706. }
  707. return NULL;
  708. }
  709. void CObjectFactory::DeviceDisconnect(CDevice *pDevice)
  710. {
  711. CDevice *pD1 = pDevice;
  712. for( int i = 0; i < pD1->GetPinCount(); i++ )
  713. {
  714. CPin *pP1 = pD1->GetPin( i );
  715. /* for( int j = 0; j < pP1->m_nDeviceCount; j++ )
  716. {
  717. CDevice *pD2 = DeviceGet( pP1->m_pDevice[j].nIndex, pP1->m_pDevice[j].nType );
  718. CPin *pP2 = pD2->GetPin( pP1->m_pDevice[j].nPin );
  719. pP2->Disconnect( pP1 ); // disconnect all pins from device
  720. }
  721. */
  722. pP1->Disconnect( NULL );
  723. }
  724. }
  725. int CObjectFactory::DeviceMove( CDevice *pDevice, int nIndex )
  726. {
  727. CDevice *pD1 = pDevice;
  728. for( int i = 0; i < pD1->GetPinCount(); i++ )
  729. {
  730. CPin *pP1 = pD1->GetPin( i );
  731. for( int j = 0; j < pP1->m_nDeviceCount; j++ )
  732. {
  733. CDevice *pD2 = DeviceGet( pP1->m_pDevice[j].nIndex, pP1->m_pDevice[j].nType );
  734. CPin *pP2 = pD2->GetPin( pP1->m_pDevice[j].nPin );
  735. for( int k = 0; k < pP2->m_nDeviceCount; k++ )
  736. {
  737. if( pP2->m_pDevice[k].nIndex == pD1->GetIndex() &&
  738. pP2->m_pDevice[k].nType == pD1->GetType() )
  739. {
  740. pP2->m_pDevice[k].nIndex = nIndex; // re-indexing
  741. }
  742. }
  743. }
  744. }
  745. pD1->SetIndex( nIndex ); // re-indexing itself
  746. return TRUE;
  747. }
  748. void CObjectFactory::DeviceDelete( CDevice *pDevice )
  749. {
  750. int nIndex = pDevice->GetIndex();
  751. int nType = pDevice->GetType();
  752. DeviceDisconnect( pDevice ); // disconnect from all pins
  753. delete pDevice; // delete device
  754. m_pDevice[ nType ].nCount--;
  755. if( m_pDevice[ nType ].nCount )
  756. {
  757. int nLast = m_pDevice[ nType ].nCount;
  758. DeviceMove( m_pDevice[ nType ].ppDevice[ nLast ], nIndex ); // re-indexing last element
  759. m_pDevice[ nType ].ppDevice[ nIndex ] = m_pDevice[ nType ].ppDevice[ nLast ]; // change element onto last element
  760. }
  761. m_pDevice[ nType ].ppDevice = (CDevice**)realloc( m_pDevice[ nType ].ppDevice, sizeof( CDevice* ) * m_pDevice[ nType ].nCount );
  762. }
  763. void CObjectFactory::DeviceDelete( int nIndex, int nType )
  764. {
  765. for( int i = 0; i < DT_COUNT; i++ )
  766. {
  767. if( m_pDevice[i].nType == nType )
  768. {
  769. DeviceDelete( m_pDevice[i].ppDevice[ nIndex ] );
  770. return;
  771. }
  772. }
  773. }
  774. CDevice *CObjectFactory::DeviceGet(int nIndex, int nType)
  775. {
  776. for( int i = 0; i < DT_COUNT; i++ )
  777. {
  778. if( m_pDevice[i].nType == nType )
  779. {
  780. return ( nIndex < m_pDevice[i].nCount ) ? m_pDevice[i].ppDevice[nIndex] : NULL;
  781. }
  782. }
  783. return NULL;
  784. }
  785. void CObjectFactory::DrawDevice( CDC *pDC, CDevice *pDevice, CPoint shift, double scale )
  786. {
  787. CDevice *pD1 = pDevice;
  788. for( int i = 0; i < pD1->GetPinCount(); i++ )
  789. {
  790. CPin *pP1 = pD1->GetPin( i );
  791. for( int j = 0; j < pP1->m_nDeviceCount; j++ )
  792. {
  793. CDevice *pD2 = DeviceGet( pP1->m_pDevice[j].nIndex, pP1->m_pDevice[j].nType );
  794. CPin *pP2 = pD2->GetPin( pP1->m_pDevice[j].nPin );
  795. DrawLine( pDC, pP1, pP2, FALSE, shift, scale );
  796. }
  797. }
  798. pD1->Draw( pDC, FALSE, shift, scale );
  799. }
  800. void CObjectFactory::Draw( CDC *pDC, CPoint shift, double scale )
  801. {
  802. CRect rect( -shift.x, -shift.y, -shift.x + (int)(m_MapSize.cx * scale), (int)(-shift.y + m_MapSize.cy * scale) );
  803. pDC->FillSolidRect( &rect, RGB( 0,0,0 ) );
  804. pDC->PlayMetaFile( m_MetaFile, rect );
  805. for( int i = 0; i < DT_COUNT; i++ )
  806. {
  807. for( int j = 0; j < m_pDevice[i].nCount; j++ )
  808. {
  809. DrawDevice( pDC, m_pDevice[i].ppDevice[j], shift, scale );
  810. }
  811. }
  812. }
  813. void CObjectFactory::DrawLine( CDC *pDC, CPin *pP1, CPin *pP2, BOOL bActive, CPoint shift, double scale )
  814. {
  815. CDevice *pD1 = DeviceGet( pP1->m_Owner.nIndex, pP1->m_Owner.nType );
  816. CDevice *pD2 = DeviceGet( pP2->m_Owner.nIndex, pP2->m_Owner.nType );
  817. CPoint sp1( (int)(pD1->m_Pos.x * scale), (int)(pD1->m_Pos.y * scale) );
  818. CPoint sp2( (int)(pD2->m_Pos.x * scale), (int)(pD2->m_Pos.y * scale) );
  819. CPoint p1( sp1 + pP1->m_Pos - CPoint( NORMAL_SIZE, NORMAL_SIZE ) - shift );
  820. CPoint p2( sp2 + pP2->m_Pos - CPoint( NORMAL_SIZE, NORMAL_SIZE ) - shift );
  821. CPen pen( PS_SOLID, bActive ? 3 : 0, pP1->GetColor() );
  822. CPen *pPen = (CPen*)pDC->SelectObject( &pen );
  823. pDC->MoveTo( p1 );
  824. pDC->LineTo( p2 );
  825. pDC->SelectObject( pPen );
  826. }
  827. // D C-D
  828. //p1 ----------------- p2
  829. // \ | /
  830. // \ | /
  831. // B \ | / A
  832. // \ /
  833. // p3
  834. static BOOL PtInLine( CPoint p1, CPoint p2, CPoint p3, int nQuality )
  835. {
  836. double C = sqrt( pow(p1.x-p2.x,2) + pow(p1.y-p2.y,2) );
  837. double B = sqrt( pow(p1.x-p3.x,2) + pow(p1.y-p3.y,2) );
  838. double A = sqrt( pow(p2.x-p3.x,2) + pow(p2.y-p3.y,2) );
  839. double D = ( pow(B,2) - pow(A,2) + pow(C,2) ) / (2*C);
  840. if( floor( fabs(D) - C ) > nQuality )
  841. return FALSE;
  842. double X = p1.x + (p2.x-p1.x) * D / C;
  843. double Y = p1.y + (p2.y-p1.y) * D / C;
  844. BOOL bInX = FALSE;
  845. BOOL bInY = FALSE;
  846. double X1, X2;
  847. if( p1.x < p2.x ) { X1 = p1.x - nQuality; X2 = p2.x + nQuality; }
  848. else { X1 = p2.x - nQuality; X2 = p1.x + nQuality; }
  849. double Y1, Y2;
  850. if( p1.y < p2.y ) { Y1 = p1.y - nQuality; Y2 = p2.y + nQuality; }
  851. else { Y1 = p2.y - nQuality; Y2 = p1.y + nQuality; }
  852. double R = sqrt( pow(p3.x-X,2) + pow(p3.y-Y,2) );
  853. return ( floor(R) <= nQuality ) && ( X1 <= X ) && ( X <= X2 ) &&
  854. ( Y1 <= Y ) && ( Y <= Y2 );
  855. }
  856. BOOL CObjectFactory::ConnectionGet( CDevice *pD, CPoint p, CPin **pPin1, CPin **pPin2, double scale )
  857. {
  858. CDevice *pD1 = pD;
  859. for( int i = 0; i < pD1->GetPinCount(); i++ )
  860. {
  861. CPin *pP1 = pD1->GetPin( i );
  862. CPoint sp1( (int)(pD1->m_Pos.x * scale), (int)(pD1->m_Pos.y * scale) );
  863. CPoint p1( sp1 + pP1->m_Pos - CPoint( NORMAL_SIZE, NORMAL_SIZE ) );
  864. for( int j = 0; j < pP1->m_nDeviceCount; j++ )
  865. {
  866. CDevice *pD2 = DeviceGet( pP1->m_pDevice[j].nIndex, pP1->m_pDevice[j].nType );
  867. CPin *pP2 = pD2->GetPin( pP1->m_pDevice[j].nPin );
  868. CPoint sp2( (int)(pD2->m_Pos.x * scale), (int)(pD2->m_Pos.y * scale) );
  869. CPoint p2( sp2 + pP2->m_Pos - CPoint( NORMAL_SIZE, NORMAL_SIZE ) );
  870. if( PtInLine( p1, p2, p, 1 ) )
  871. {
  872. *pPin1 = pP1;
  873. *pPin2 = pP2;
  874. return TRUE;
  875. }
  876. }
  877. }
  878. return FALSE;
  879. }
  880. BOOL CObjectFactory::ConnectionGet( CPoint p, CPin **pPin1, CPin **pPin2, double scale )
  881. {
  882. for( int i = 0; i < DT_COUNT; i++ )
  883. {
  884. for( int j = 0; j < m_pDevice[i].nCount; j++ )
  885. {
  886. if( ConnectionGet( m_pDevice[i].ppDevice[j], p, pPin1, pPin2, scale ) )
  887. return TRUE;
  888. }
  889. }
  890. return FALSE;
  891. }
  892. void CObjectFactory::Serialize(CArchive& ar)
  893. {
  894. if (ar.IsStoring())
  895. {
  896. ar << m_MapSize.cx;
  897. ar << m_MapSize.cy;
  898. ar << m_Background;
  899. for( int i = 0; i < DT_COUNT; i++ )
  900. {
  901. ar << m_pDevice[i].nCount;
  902. for( int j = 0; j < m_pDevice[i].nCount; j++ )
  903. m_pDevice[i].ppDevice[j]->Serialize( ar );
  904. }
  905. }
  906. else
  907. {
  908. ar >> m_MapSize.cx;
  909. ar >> m_MapSize.cy;
  910. ar >> m_Background;
  911. SetBackground( m_Background );
  912. for( int i = 0; i < DT_COUNT; i++ )
  913. {
  914. ar >> m_pDevice[i].nCount;
  915. m_pDevice[i].ppDevice = (CDevice**) malloc( m_pDevice[i].nCount * sizeof(CDevice*) );
  916. for( int j = 0; j < m_pDevice[i].nCount; j++ )
  917. {
  918. m_pDevice[i].ppDevice[j] = ClassCreate( m_pDevice[i].nType );
  919. m_pDevice[i].ppDevice[j]->SetIndex(j);
  920. m_pDevice[i].ppDevice[j]->Serialize( ar );
  921. }
  922. }
  923. }
  924. }
  925. void CObjectFactory::SetBackground(LPCTSTR pFileName)
  926. {
  927. m_Background = pFileName;
  928. m_MapSize.cx = 1000;
  929. if( m_MetaFile.Load( m_Background ) )
  930. m_MapSize.cy = m_MapSize.cx * m_MetaFile.GetSize().cy / m_MetaFile.GetSize().cx;
  931. else
  932. m_MapSize.cy = 1000;
  933. }