| 1 |
/* |
| 2 |
Copyright (c) 1993-2008, Cognitive Technologies |
| 3 |
All rights reserved. |
| 4 |
|
| 5 |
Разрешается повторное распространение и использование как в виде исходного кода, |
| 6 |
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий: |
| 7 |
|
| 8 |
* При повторном распространении исходного кода должны оставаться указанное |
| 9 |
выше уведомление об авторском праве, этот список условий и последующий |
| 10 |
отказ от гарантий. |
| 11 |
* При повторном распространении двоичного кода в документации и/или в |
| 12 |
других материалах, поставляемых при распространении, должны сохраняться |
| 13 |
указанная выше информация об авторском праве, этот список условий и |
| 14 |
последующий отказ от гарантий. |
| 15 |
* Ни название Cognitive Technologies, ни имена ее сотрудников не могут |
| 16 |
быть использованы в качестве средства поддержки и/или продвижения |
| 17 |
продуктов, основанных на этом ПО, без предварительного письменного |
| 18 |
разрешения. |
| 19 |
|
| 20 |
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК |
| 21 |
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ, |
| 22 |
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ |
| 23 |
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ |
| 24 |
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ |
| 25 |
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ |
| 26 |
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ |
| 27 |
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ, |
| 28 |
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ |
| 29 |
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ, |
| 30 |
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ |
| 31 |
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ. |
| 32 |
|
| 33 |
Redistribution and use in source and binary forms, with or without modification, |
| 34 |
are permitted provided that the following conditions are met: |
| 35 |
|
| 36 |
* Redistributions of source code must retain the above copyright notice, |
| 37 |
this list of conditions and the following disclaimer. |
| 38 |
* Redistributions in binary form must reproduce the above copyright notice, |
| 39 |
this list of conditions and the following disclaimer in the documentation |
| 40 |
and/or other materials provided with the distribution. |
| 41 |
* Neither the name of the Cognitive Technologies nor the names of its |
| 42 |
contributors may be used to endorse or promote products derived from this |
| 43 |
software without specific prior written permission. |
| 44 |
|
| 45 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 46 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 47 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 48 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 49 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 50 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 51 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 52 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 53 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 54 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 55 |
*/ |
| 56 |
|
| 57 |
/********** Заголовок **********/ |
| 58 |
/* Автор : Александр Михайлов */ |
| 59 |
/* Редакция : 06.09.00 */ |
| 60 |
/* Файл : 'VL_Data.CPP' */ |
| 61 |
/* Содержание : Функции извлечения чужих и представления своих данных. */ |
| 62 |
/* Назначение : Обмен с другими библиотеками. */ |
| 63 |
/*----------------------------------------------------------------------------*/ |
| 64 |
#include <stdio.h> |
| 65 |
/*#include <windows.h>*/ |
| 66 |
/* interface our-other */ |
| 67 |
#include "cpage.h" |
| 68 |
#include "lnsdefs.h" |
| 69 |
#include "rline.h" |
| 70 |
#include "ccom.h" |
| 71 |
#include "ctiimage.h" |
| 72 |
#include "cline.h" |
| 73 |
/* interface our-my */ |
| 74 |
#include "rverline.h" |
| 75 |
/* interface my */ |
| 76 |
#include "am_err.h" |
| 77 |
#include "am_comm.h" |
| 78 |
#include "myraster.h" |
| 79 |
/* interface my-my */ |
| 80 |
#include "am_buff.h" |
| 81 |
/*------------own objects-----------------------------------------------------*/ |
| 82 |
FNCPAGE_GetBlockFirst GetBlockFirst; |
| 83 |
FNCPAGE_GetBlockNext GetBlockNext; |
| 84 |
FNCPAGE_GetBlockData GetBlockData; |
| 85 |
/*------------extern functions------------------------------------------------*/ |
| 86 |
void MyErrorNoMem (const char* str); |
| 87 |
void SetReturnCode_rverline (uint16_t rc); |
| 88 |
/*------------own functions---------------------------------------------------*/ |
| 89 |
Bool MyInit_CPage (); |
| 90 |
Bool MyGetLines (LinesTotalInfo *pLti, int MaxNumLin, Handle hCPage, uint32_t *pHoriType, uint32_t *pVertType, char *pStr); |
| 91 |
Bool MyGetComp (Handle hCCOM, Rect16 *pRc, int *nRC, int MyMaxC, int Filter); |
| 92 |
void Error_CPage (const char *str); |
| 93 |
Bool MyFormZhertvy (Handle hCCOM, void **vvZher, int *iZher, int nZher, int Filter); |
| 94 |
Bool MySetZher (void **vvZher, int nZher, Handle hCPage); |
| 95 |
Bool MyGetZher (void **vvZher, int *nZher, int MaxZher, Handle hCPage); |
| 96 |
Bool MyGetRaster (Handle hCPage, VL_I_TASK *pTask, uchar **ppData); |
| 97 |
/*----------------------------------------------------------------------------*/ |
| 98 |
Bool MyInit_CPage () |
| 99 |
{ |
| 100 |
Bool ret; |
| 101 |
ret = CPAGE_GetExportData (CPAGE_FNCPAGE_GetBlockFirst, &GetBlockFirst); |
| 102 |
if (!ret) |
| 103 |
{ |
| 104 |
Error_CPage ("[GetExportData][GetBlockFirst]"); |
| 105 |
return FALSE; |
| 106 |
} |
| 107 |
ret = CPAGE_GetExportData (CPAGE_FNCPAGE_GetBlockNext, &GetBlockNext); |
| 108 |
if (!ret) |
| 109 |
{ |
| 110 |
Error_CPage ("[GetExportData][GetBlockNext]"); |
| 111 |
return FALSE; |
| 112 |
} |
| 113 |
ret = CPAGE_GetExportData (CPAGE_FNCPAGE_GetBlockData, &GetBlockData); |
| 114 |
if (!ret) |
| 115 |
{ |
| 116 |
Error_CPage ("[GetExportData][GetBlockData]"); |
| 117 |
return FALSE; |
| 118 |
} |
| 119 |
return TRUE; |
| 120 |
} |
| 121 |
/*----------------------------------------------------------------------------*/ |
| 122 |
Bool MyGetLines (LinesTotalInfo *pLti, int MaxNumLin, Handle *hCPage, Handle *pHoriType, Handle *pVertType, char *pStr) |
| 123 |
{ |
| 124 |
int i; |
| 125 |
uint32_t err32, nTeor, nReal; |
| 126 |
Handle hBlockLine; |
| 127 |
Handle hBlockLineHor; |
| 128 |
Handle hBlockLineVer; |
| 129 |
Handle hBlockLinePrev; |
| 130 |
LineInfo *pLHor, *pLVer; |
| 131 |
/*** ***/ |
| 132 |
pLHor = pLti->Hor.Lns; |
| 133 |
pLVer = pLti->Ver.Lns; |
| 134 |
/*** Общая информация о линиях ***/ |
| 135 |
hBlockLine = CPAGE_GetBlockFirst (hCPage, RLINE_BLOCK_TYPE); |
| 136 |
if (!hBlockLine) |
| 137 |
{ |
| 138 |
sprintf (pStr, "Линии не выделялись."); |
| 139 |
return RV_EMPTY; |
| 140 |
} |
| 141 |
err32 = CPAGE_GetReturnCode (); |
| 142 |
if (err32!=0) |
| 143 |
{ |
| 144 |
Error_CPage ("[GetBlockFirst]"); |
| 145 |
return FALSE; |
| 146 |
} |
| 147 |
nTeor = sizeof (LinesTotalInfo); |
| 148 |
nReal = CPAGE_GetBlockData (hCPage, hBlockLine, RLINE_BLOCK_TYPE, (void *)pLti, nTeor); |
| 149 |
err32 = CPAGE_GetReturnCode (); |
| 150 |
if ((nReal!=nTeor)||(err32!=0)) |
| 151 |
{ |
| 152 |
Error_CPage ("[GetBlockData]"); |
| 153 |
return FALSE; |
| 154 |
} |
| 155 |
if (pLti->Hor.Cnt + pLti->Ver.Cnt >= MaxNumLin) |
| 156 |
{ |
| 157 |
sprintf (pStr, "Не хватило памяти под %d линии!", pLti->Hor.Cnt + pLti->Ver.Cnt); |
| 158 |
return RV_DOUBT; |
| 159 |
} |
| 160 |
if ((pLti->Hor.Cnt==0)&&(pLti->Ver.Cnt==0)) |
| 161 |
{ |
| 162 |
sprintf (pStr, "Линии выделялись, но ни одной не выделено."); |
| 163 |
return RV_EMPTY; |
| 164 |
} |
| 165 |
/*** Горизонтальные линии ***/ |
| 166 |
for (i=0; i<pLti->Hor.Cnt; i++) |
| 167 |
{ |
| 168 |
if (i==0) |
| 169 |
hBlockLineHor = CPAGE_GetBlockFirst (hCPage, (pLti->Hor.Lns)); |
| 170 |
else |
| 171 |
hBlockLineHor = CPAGE_GetBlockNext (hCPage, hBlockLinePrev, (pLti->Hor.Lns)); |
| 172 |
err32 = CPAGE_GetReturnCode (); |
| 173 |
if (err32!=0) |
| 174 |
{ |
| 175 |
if (i==0) |
| 176 |
Error_CPage ("[GetBlockFirst]"); |
| 177 |
else |
| 178 |
Error_CPage ("[GetBlockNext]"); |
| 179 |
return FALSE; |
| 180 |
} |
| 181 |
nTeor = sizeof (LineInfo); |
| 182 |
nReal = CPAGE_GetBlockData (hCPage, hBlockLineHor, (pLti->Hor.Lns), (void *)&(pLHor[i]), nTeor); |
| 183 |
err32 = CPAGE_GetReturnCode (); |
| 184 |
if ((nReal!=nTeor)||(err32!=0)) |
| 185 |
{ |
| 186 |
Error_CPage ("[GetBlockData]"); |
| 187 |
return FALSE; |
| 188 |
} |
| 189 |
hBlockLinePrev = hBlockLineHor; |
| 190 |
} |
| 191 |
/*** Вертикальные линии ***/ |
| 192 |
for (i=0; i<pLti->Ver.Cnt; i++) |
| 193 |
{ |
| 194 |
if (i==0) |
| 195 |
hBlockLineVer = CPAGE_GetBlockFirst (hCPage, (pLti->Ver.Lns)); |
| 196 |
else |
| 197 |
hBlockLineVer = CPAGE_GetBlockNext (hCPage, hBlockLinePrev, (pLti->Ver.Lns)); |
| 198 |
err32 = CPAGE_GetReturnCode (); |
| 199 |
if (err32!=0) |
| 200 |
{ |
| 201 |
if (i==0) |
| 202 |
Error_CPage ("[GetBlockFirst]"); |
| 203 |
else |
| 204 |
Error_CPage ("[GetBlockNext]"); |
| 205 |
return FALSE; |
| 206 |
} |
| 207 |
nTeor = sizeof (LineInfo); |
| 208 |
nReal = CPAGE_GetBlockData (hCPage, hBlockLineVer, (pLti->Ver.Lns), (void *)&(pLVer[i]), nTeor); |
| 209 |
err32 = CPAGE_GetReturnCode (); |
| 210 |
if ((nReal!=nTeor)||(err32!=0)) |
| 211 |
{ |
| 212 |
Error_CPage ("[GetBlockData]"); |
| 213 |
return FALSE; |
| 214 |
} |
| 215 |
hBlockLinePrev = hBlockLineVer; |
| 216 |
} |
| 217 |
/*** ***/ |
| 218 |
*pHoriType = pLti->Hor.Lns; |
| 219 |
*pVertType = pLti->Ver.Lns; |
| 220 |
pLti->Hor.Lns = pLHor; |
| 221 |
pLti->Ver.Lns = pLVer; |
| 222 |
return TRUE; |
| 223 |
} |
| 224 |
/*----------------------------------------------------------------------------*/ |
| 225 |
Bool MyGetLines (LinesTotalInfo *pLti, int MaxNumLin,CLINE_handle hCLINE,char *pStr) |
| 226 |
{ |
| 227 |
CLINE_handle hline; |
| 228 |
int count_hor=0; |
| 229 |
int count_ver=0; |
| 230 |
LineInfo *pLHor, *pLVer; |
| 231 |
int count=CLINE_GetLineCount(hCLINE); |
| 232 |
if(!count) |
| 233 |
{ |
| 234 |
sprintf (pStr, "Линии не выделялись."); |
| 235 |
return RV_EMPTY; |
| 236 |
} |
| 237 |
if (count>=MaxNumLin) |
| 238 |
{ |
| 239 |
sprintf (pStr, "Не хватило памяти под %d линии!", pLti->Hor.Cnt + pLti->Ver.Cnt); |
| 240 |
return RV_DOUBT; |
| 241 |
} |
| 242 |
|
| 243 |
/*** ***/ |
| 244 |
pLHor = pLti->Hor.Lns; |
| 245 |
pLVer = pLti->Ver.Lns; |
| 246 |
|
| 247 |
for(hline=CLINE_GetFirstLine(hCLINE);hline;hline=CLINE_GetNextLine(hline)) |
| 248 |
{ |
| 249 |
CPDLine cpdata=CLINE_GetLineData(hline); |
| 250 |
if(!cpdata) |
| 251 |
{ |
| 252 |
return FALSE; |
| 253 |
} |
| 254 |
//Andrey 05.09.01 |
| 255 |
if (cpdata->Flags&LI_Pointed) continue; |
| 256 |
|
| 257 |
if(cpdata->Dir==LD_Horiz) |
| 258 |
{ |
| 259 |
pLHor[count_hor].A.x=(int16_t)(cpdata->Line.Beg_X); |
| 260 |
pLHor[count_hor].A.y=(int16_t)(cpdata->Line.Beg_Y); |
| 261 |
pLHor[count_hor].B.x=(int16_t)(cpdata->Line.End_X); |
| 262 |
pLHor[count_hor].B.y=(int16_t)(cpdata->Line.End_Y); |
| 263 |
pLHor[count_hor].Thickness=cpdata->Line.Wid10/10; |
| 264 |
pLHor[count_hor].SegCnt=(int16_t)(cpdata->n_event); |
| 265 |
pLHor[count_hor].Quality=(cpdata->Dens*255)/100; |
| 266 |
pLHor[count_hor].Flags=cpdata->Flags; |
| 267 |
count_hor++; |
| 268 |
} |
| 269 |
else |
| 270 |
{ |
| 271 |
pLVer[count_ver].A.x=(int16_t)(cpdata->Line.Beg_X); |
| 272 |
pLVer[count_ver].A.y=(int16_t)(cpdata->Line.Beg_Y); |
| 273 |
pLVer[count_ver].B.x=(int16_t)(cpdata->Line.End_X); |
| 274 |
pLVer[count_ver].B.y=(int16_t)(cpdata->Line.End_Y); |
| 275 |
pLVer[count_ver].Thickness=cpdata->Line.Wid10/10; |
| 276 |
pLVer[count_ver].SegCnt=(int16_t)(cpdata->n_event); |
| 277 |
pLVer[count_ver].Quality=(cpdata->Dens*255)/100; |
| 278 |
pLVer[count_ver].Flags=cpdata->Flags; |
| 279 |
count_ver++; |
| 280 |
} |
| 281 |
|
| 282 |
} |
| 283 |
|
| 284 |
/*** ***/ |
| 285 |
pLti->Hor.Lns = pLHor; |
| 286 |
pLti->Ver.Lns = pLVer; |
| 287 |
pLti->Hor.Cnt = count_hor; |
| 288 |
pLti->Ver.Cnt = count_ver; |
| 289 |
return TRUE; |
| 290 |
} |
| 291 |
/*----------------------------------------------------------------------------*/ |
| 292 |
Bool MyReSetLines (void *vLti, int MaxNumLin, Handle hCPage, Handle HoriType, Handle VertType) |
| 293 |
{ |
| 294 |
int i; |
| 295 |
uint32_t err32, nTeor;//, nReal; |
| 296 |
Bool32 nReal;//differ |
| 297 |
Handle hBlockLine; |
| 298 |
Handle hBlockLineHor; |
| 299 |
Handle hBlockLineVer; |
| 300 |
Handle hBlockLinePrev; |
| 301 |
void *Hor, *Ver; |
| 302 |
LinesTotalInfo *pLti; |
| 303 |
pLti = (LinesTotalInfo *)vLti; |
| 304 |
/*** Общая информация о линиях ***/ |
| 305 |
Hor = pLti->Hor.Lns; |
| 306 |
Ver = pLti->Ver.Lns; |
| 307 |
pLti->Hor.Lns = (LineInfo *)HoriType; |
| 308 |
pLti->Ver.Lns = (LineInfo *)VertType; |
| 309 |
hBlockLine = CPAGE_GetBlockFirst (hCPage, RLINE_BLOCK_TYPE); |
| 310 |
err32 = CPAGE_GetReturnCode (); |
| 311 |
if (err32!=0) |
| 312 |
{ |
| 313 |
Error_CPage ("[GetBlockFirst]"); |
| 314 |
return FALSE; |
| 315 |
} |
| 316 |
nTeor = sizeof (LinesTotalInfo); |
| 317 |
nReal = CPAGE_SetBlockData (hCPage, hBlockLine, RLINE_BLOCK_TYPE, (void *)pLti, nTeor); |
| 318 |
err32 = CPAGE_GetReturnCode (); |
| 319 |
// if ((nReal!=nTeor)||(err32!=0)) |
| 320 |
if (!nReal||(err32!=0)) |
| 321 |
{ |
| 322 |
Error_CPage ("[SetBlockData]"); |
| 323 |
return FALSE; |
| 324 |
} |
| 325 |
pLti->Hor.Lns = (LineInfo *)Hor; |
| 326 |
pLti->Ver.Lns = (LineInfo *)Ver; |
| 327 |
/*** Горизонтальные линии ***/ |
| 328 |
for (i=0; i<pLti->Hor.Cnt; i++) |
| 329 |
{ |
| 330 |
if (i==0) |
| 331 |
hBlockLineHor = CPAGE_GetBlockFirst (hCPage, HoriType); |
| 332 |
else |
| 333 |
hBlockLineHor = CPAGE_GetBlockNext (hCPage, hBlockLinePrev, HoriType); |
| 334 |
err32 = CPAGE_GetReturnCode (); |
| 335 |
if (err32!=0) |
| 336 |
{ |
| 337 |
if (i==0) |
| 338 |
Error_CPage ("[GetBlockFirst]"); |
| 339 |
else |
| 340 |
Error_CPage ("[GetBlockNext]"); |
| 341 |
return FALSE; |
| 342 |
} |
| 343 |
nTeor = sizeof (LineInfo); |
| 344 |
if(pLti->Hor.Lns[i].Flags&LI_Pointed) |
| 345 |
pLti->Hor.Lns[i].Flags|=LI_IsTrue; |
| 346 |
nReal = CPAGE_SetBlockData (hCPage, hBlockLineHor, HoriType, (void *)&(pLti->Hor.Lns[i]), nTeor); |
| 347 |
err32 = CPAGE_GetReturnCode (); |
| 348 |
// if ((nReal!=nTeor)||(err32!=0)) |
| 349 |
if (!nReal||(err32!=0)) |
| 350 |
{ |
| 351 |
Error_CPage ("[SetBlockData]"); |
| 352 |
return FALSE; |
| 353 |
} |
| 354 |
hBlockLinePrev = hBlockLineHor; |
| 355 |
} |
| 356 |
/*** Вертикальные линии ***/ |
| 357 |
for (i=0; i<pLti->Ver.Cnt; i++) |
| 358 |
{ |
| 359 |
if (i==0) |
| 360 |
hBlockLineVer = CPAGE_GetBlockFirst (hCPage, VertType); |
| 361 |
else |
| 362 |
hBlockLineVer = CPAGE_GetBlockNext (hCPage, hBlockLinePrev, VertType); |
| 363 |
err32 = CPAGE_GetReturnCode (); |
| 364 |
if (err32!=0) |
| 365 |
{ |
| 366 |
if (i==0) |
| 367 |
Error_CPage ("[GetBlockFirst]"); |
| 368 |
else |
| 369 |
Error_CPage ("[GetBlockNext]"); |
| 370 |
return FALSE; |
| 371 |
} |
| 372 |
nTeor = sizeof (LineInfo); |
| 373 |
if(pLti->Ver.Lns[i].Flags&LI_Pointed) |
| 374 |
pLti->Ver.Lns[i].Flags|=LI_IsTrue; |
| 375 |
nReal = CPAGE_SetBlockData (hCPage, hBlockLineVer, VertType, (void *)&(pLti->Ver.Lns[i]), nTeor); |
| 376 |
err32 = CPAGE_GetReturnCode (); |
| 377 |
// if ((nReal!=nTeor)||(err32!=0)) |
| 378 |
if (!nReal||(err32!=0)) |
| 379 |
{ |
| 380 |
Error_CPage ("[SetBlockData]"); |
| 381 |
return FALSE; |
| 382 |
} |
| 383 |
hBlockLinePrev = hBlockLineVer; |
| 384 |
} |
| 385 |
return TRUE; |
| 386 |
} |
| 387 |
/*----------------------------------------------------------------------------*/ |
| 388 |
Bool MyReSetLines (void *vLti, int MaxNumLin, CLINE_handle hCLINE) |
| 389 |
{ |
| 390 |
LinesTotalInfo *pLti; |
| 391 |
pLti = (LinesTotalInfo *)vLti; |
| 392 |
CLINE_handle hline; |
| 393 |
DLine data; |
| 394 |
LineInfo* HorLine=pLti->Hor.Lns; |
| 395 |
LineInfo* VerLine=pLti->Ver.Lns; |
| 396 |
int count_hor=0; |
| 397 |
int count_ver=0; |
| 398 |
int size_dline=sizeof(DLine); |
| 399 |
|
| 400 |
for(hline=CLINE_GetFirstLine(hCLINE);hline;hline=CLINE_GetNextLine(hline)) |
| 401 |
{ |
| 402 |
CPDLine cpdata=CLINE_GetLineData(hline); |
| 403 |
if(!cpdata) |
| 404 |
{ |
| 405 |
return FALSE; |
| 406 |
} |
| 407 |
|
| 408 |
//Andrey 05.09.01 |
| 409 |
if (cpdata->Flags&LI_Pointed) |
| 410 |
continue; |
| 411 |
|
| 412 |
if(!CLINE_CopyData(&data,cpdata,size_dline)) |
| 413 |
return FALSE; |
| 414 |
|
| 415 |
if(cpdata->Dir==LD_Horiz) |
| 416 |
{ |
| 417 |
data.Flags=HorLine[count_hor].Flags; |
| 418 |
if(HorLine[count_hor].Flags&LI_Pointed) |
| 419 |
{ |
| 420 |
data.Flags|=LI_IsTrue; |
| 421 |
data.Type=NR_DT_LinePointed; |
| 422 |
} |
| 423 |
data.lns_data.Anew.x=HorLine[count_hor].Anew.x; |
| 424 |
data.lns_data.Anew.y=HorLine[count_hor].Anew.y; |
| 425 |
data.lns_data.Bnew.x=HorLine[count_hor].Bnew.x; |
| 426 |
data.lns_data.Bnew.y=HorLine[count_hor].Bnew.y; |
| 427 |
|
| 428 |
CLINE_SetLineData(hline,(CPDLine)(&data)); |
| 429 |
count_hor++; |
| 430 |
} |
| 431 |
else |
| 432 |
{ |
| 433 |
data.Flags=VerLine[count_ver].Flags; |
| 434 |
if(VerLine[count_ver].Flags&LI_Pointed) |
| 435 |
{ |
| 436 |
data.Flags|=LI_IsTrue; |
| 437 |
data.Type=NR_DT_LinePointed; |
| 438 |
} |
| 439 |
data.lns_data.Anew.x=VerLine[count_ver].Anew.x; |
| 440 |
data.lns_data.Anew.y=VerLine[count_ver].Anew.y; |
| 441 |
data.lns_data.Bnew.x=VerLine[count_ver].Bnew.x; |
| 442 |
data.lns_data.Bnew.y=VerLine[count_ver].Bnew.y; |
| 443 |
|
| 444 |
CLINE_SetLineData(hline,(CPDLine)(&data)); |
| 445 |
count_ver++; |
| 446 |
} |
| 447 |
|
| 448 |
} |
| 449 |
return TRUE; |
| 450 |
} |
| 451 |
/*----------------------------------------------------------------------------*/ |
| 452 |
void Error_CPage (const char *str) |
| 453 |
{ |
| 454 |
uchar err8; |
| 455 |
uint16_t Code; |
| 456 |
err8 = (uchar)ER_ROUGH_NORMAL; |
| 457 |
Code = (uint16_t)(err8<<8); |
| 458 |
err8 = (uchar)ER_DETAIL_FUNC_CPAGE; |
| 459 |
Code |= (uint16_t)err8; |
| 460 |
SetReturnCode_rverline (Code); |
| 461 |
AM_Console ("RVERLINE : Ошибка чужой библиотеки - [CPAGE]%s", str); |
| 462 |
} |
| 463 |
/*----------------------------------------------------------------------------*/ |
| 464 |
Bool CompIsGood (CCOM_comp * pcomp, int Filter) |
| 465 |
{ |
| 466 |
switch (Filter) |
| 467 |
{ |
| 468 |
case 0 : |
| 469 |
return TRUE; |
| 470 |
case 1 : |
| 471 |
if ((pcomp->upper<10)||(pcomp->left<10)) |
| 472 |
return FALSE; |
| 473 |
if ((pcomp->h<=4)&&(pcomp->w<=20)&&(pcomp->w>=10)) //тире |
| 474 |
return TRUE; |
| 475 |
if ((pcomp->w<7)||(pcomp->w>120)) |
| 476 |
return FALSE; |
| 477 |
if ((pcomp->h<10)||(pcomp->h>100)) |
| 478 |
return FALSE; |
| 479 |
if (pcomp->h > (int)(4.8*pcomp->w + .5)) |
| 480 |
return FALSE; |
| 481 |
if ((pcomp->h<20)&&(pcomp->w > (int)(2.1*pcomp->h + .5))) |
| 482 |
return FALSE; |
| 483 |
return TRUE; |
| 484 |
case 2 : |
| 485 |
if ((pcomp->h<=4)&&(pcomp->w<=4)) |
| 486 |
return FALSE; |
| 487 |
return TRUE; |
| 488 |
case 3 : |
| 489 |
if ((pcomp->h<=4)||(pcomp->w<=4)) |
| 490 |
return FALSE; |
| 491 |
return TRUE; |
| 492 |
default : |
| 493 |
return FALSE; |
| 494 |
} |
| 495 |
} |
| 496 |
/*----------------------------------------------------------------------------*/ |
| 497 |
Bool MyGetComp (Handle hCCOM, Rect16 *pRc, int *nRC, int MyMaxC, int Filter) |
| 498 |
{ |
| 499 |
CCOM_comp * pcomp; |
| 500 |
Bool GoodComp; |
| 501 |
pcomp = CCOM_GetFirst (hCCOM, NULL); |
| 502 |
*nRC = 0; |
| 503 |
GoodComp = CompIsGood (pcomp, Filter); |
| 504 |
if (GoodComp) |
| 505 |
{ |
| 506 |
pRc[*nRC].left = pcomp->left; |
| 507 |
pRc[*nRC].right = pcomp->left + pcomp->w - 1; |
| 508 |
pRc[*nRC].top = pcomp->upper; |
| 509 |
pRc[*nRC].bottom = pcomp->upper + pcomp->h - 1; |
| 510 |
(*nRC)++; |
| 511 |
} |
| 512 |
while (1) |
| 513 |
{ |
| 514 |
pcomp = CCOM_GetNext (pcomp, NULL); |
| 515 |
if (pcomp==NULL) |
| 516 |
break; |
| 517 |
GoodComp = CompIsGood (pcomp, Filter); |
| 518 |
if (!GoodComp) |
| 519 |
continue; |
| 520 |
if (*nRC>=MyMaxC) |
| 521 |
{ |
| 522 |
MyErrorNoMem ("коробки компонент"); |
| 523 |
return FALSE; |
| 524 |
} |
| 525 |
pRc[*nRC].left = pcomp->left; |
| 526 |
pRc[*nRC].right = pcomp->left + pcomp->w - 1; |
| 527 |
pRc[*nRC].top = pcomp->upper; |
| 528 |
pRc[*nRC].bottom = pcomp->upper + pcomp->h - 1; |
| 529 |
(*nRC)++; |
| 530 |
} |
| 531 |
return TRUE; |
| 532 |
} |
| 533 |
/*----------------------------------------------------------------------------*/ |
| 534 |
Bool MyFormZhertvy (Handle hCCOM, void **vvZher, int *iZher, int nZher, int Filter) |
| 535 |
{ |
| 536 |
CCOM_comp * pcomp; |
| 537 |
int nC, nX, i, nZ; |
| 538 |
Bool GoodComp; |
| 539 |
nC = 0, nX = 0, nZ = 0; |
| 540 |
while (1) |
| 541 |
{ |
| 542 |
if (nZ==nZher) |
| 543 |
break; |
| 544 |
if (nX==0) |
| 545 |
pcomp = CCOM_GetFirst (hCCOM, NULL); |
| 546 |
else |
| 547 |
pcomp = CCOM_GetNext (pcomp, NULL); |
| 548 |
if (pcomp==NULL) |
| 549 |
break; |
| 550 |
nX++; |
| 551 |
GoodComp = CompIsGood (pcomp, Filter); |
| 552 |
if (!GoodComp) |
| 553 |
continue; |
| 554 |
for (i=0; i<nZher; i++) |
| 555 |
{ |
| 556 |
if (nC!=iZher[i]) |
| 557 |
continue; |
| 558 |
vvZher[nZ] = (void *)pcomp; |
| 559 |
nZ++; |
| 560 |
} |
| 561 |
nC++; |
| 562 |
} |
| 563 |
if (nZ==nZher) |
| 564 |
return TRUE; |
| 565 |
else |
| 566 |
return FALSE; |
| 567 |
} |
| 568 |
/*----------------------------------------------------------------------------*/ |
| 569 |
Bool MySetZher (void **vvZher, int nZher, Handle hCPage) |
| 570 |
{ |
| 571 |
uint32_t err32, nTeor;//, nReal;//dwTableType |
| 572 |
Handle hBlockZher; |
| 573 |
int i; |
| 574 |
nTeor = sizeof (void *); |
| 575 |
for (i=0; i<nZher; i++) |
| 576 |
{ |
| 577 |
hBlockZher = CPAGE_CreateBlock |
| 578 |
(hCPage, RVERLINE_ZHERTVY_LINIY, 0, 0, (void *)&(vvZher[i]) , nTeor); |
| 579 |
err32 = CPAGE_GetReturnCode (); |
| 580 |
if ((hBlockZher==NULL)||(err32!=0)) |
| 581 |
{ |
| 582 |
Error_CPage ("[CreateBlock]"); |
| 583 |
return FALSE; |
| 584 |
} |
| 585 |
/* nReal = CPAGE_SetBlockData (hCPage, hBlockZher, RVERLINE_ZHERTVY_LINIY, (void *)&(vvZher[i]), nTeor); |
| 586 |
err32 = CPAGE_GetReturnCode (); |
| 587 |
// if ((nReal!=nTeor)||(err32!=0)) |
| 588 |
if (!nReal||(err32!=0)) |
| 589 |
{ |
| 590 |
Error_CPage ("[GetBlockData]"); |
| 591 |
return FALSE; |
| 592 |
}*/ |
| 593 |
} |
| 594 |
return TRUE; |
| 595 |
} |
| 596 |
/*----------------------------------------------------------------------------*/ |
| 597 |
Bool MyGetZher (void **vvZher, int *nZher, int MaxZher, Handle hCPage) |
| 598 |
{ |
| 599 |
uint32_t err32, nTeor, nReal; |
| 600 |
Handle hBlockZher; |
| 601 |
Handle hBlockPrev; |
| 602 |
int i; |
| 603 |
nTeor = sizeof (void *); |
| 604 |
i=0; |
| 605 |
while (1) |
| 606 |
{ |
| 607 |
if (i==0) |
| 608 |
hBlockZher = CPAGE_GetBlockFirst (hCPage, RVERLINE_ZHERTVY_LINIY); |
| 609 |
else |
| 610 |
hBlockZher = CPAGE_GetBlockNext (hCPage, hBlockPrev, RVERLINE_ZHERTVY_LINIY); |
| 611 |
err32 = CPAGE_GetReturnCode (); |
| 612 |
if (err32!=0) |
| 613 |
{ |
| 614 |
if (i==0) |
| 615 |
Error_CPage ("[GetBlockFirst]"); |
| 616 |
else |
| 617 |
Error_CPage ("[GetBlockNext]"); |
| 618 |
return FALSE; |
| 619 |
} |
| 620 |
if (!hBlockZher) |
| 621 |
break; |
| 622 |
if (i>=MaxZher) |
| 623 |
return FALSE; |
| 624 |
nReal = CPAGE_GetBlockData (hCPage, hBlockZher, RVERLINE_ZHERTVY_LINIY, (void *)&(vvZher[i]), nTeor); |
| 625 |
err32 = CPAGE_GetReturnCode (); |
| 626 |
// if ((nReal!=nTeor)||(err32!=0)) |
| 627 |
if (!nReal||(err32!=0)) |
| 628 |
{ |
| 629 |
Error_CPage ("[GetBlockData]"); |
| 630 |
return FALSE; |
| 631 |
} |
| 632 |
hBlockPrev = hBlockZher; |
| 633 |
i++; |
| 634 |
} |
| 635 |
*nZher = i; |
| 636 |
return TRUE; |
| 637 |
} |
| 638 |
/*----------------------------------------------------------------------------*/ |
| 639 |
Bool MyGetRaster (Handle hCPage, VL_I_TASK *pTask, uchar **ppData) |
| 640 |
{ |
| 641 |
PAGEINFO info = {0}; |
| 642 |
CIMAGEInfoDataInGet DataInto = {0}; |
| 643 |
CIMAGEInfoDataOutGet DataOut = {0}; |
| 644 |
uchar Name[256]; |
| 645 |
Bool ret; |
| 646 |
int i; |
| 647 |
/* 1. Подготовка к запросу части изображения. */ |
| 648 |
DataInto.dwHeight = (uint32_t)pTask->MyHeight; |
| 649 |
DataInto.dwWidth = pTask->MyExtrWidth; |
| 650 |
DataInto.wByteWidth = (int16_t)((pTask->MyExtrWidth+7)/8);//06.09.00 |
| 651 |
DataInto.dwX = pTask->MyLeft; |
| 652 |
DataInto.dwY = pTask->MyTop; |
| 653 |
DataInto.MaskFlag = 0x00; |
| 654 |
GetPageInfo(hCPage,&info); |
| 655 |
for (i=0; i<256; i++) |
| 656 |
Name[i] = info.szImageName[i]; |
| 657 |
DataOut.dwWidth = DataInto.dwWidth; |
| 658 |
DataOut.dwHeight = DataInto.dwHeight; |
| 659 |
DataOut.wByteWidth = DataInto.wByteWidth; |
| 660 |
DataOut.byBit = (uint16_t)info.BitPerPixel; |
| 661 |
DataOut.lpData = *ppData; |
| 662 |
/* 5. Чтение части изображения. */ |
| 663 |
ret = CIMAGE_GetData (Name, &DataInto, &DataOut); |
| 664 |
if (!ret) |
| 665 |
return FALSE; |
| 666 |
if (DataOut.lpData==NULL) |
| 667 |
return FALSE; |
| 668 |
*ppData = DataOut.lpData; |
| 669 |
return TRUE; |
| 670 |
} |
| 671 |
/*----------------------------------------------------------------------------*/ |