//--------------------------------------------------------------------------- #pragma hdrstop #include "DXF.h" #include "math.h" //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- CDXF *DXF; //--------------------------------------------------------------------------- #define DXF_ERR -1 #define SET_RECT \ \ data->First.x = MaxInt; data->First.y = MaxInt; \ data->Second.x = 0; data->Second.y = 0; \ for (int i = 0; i < data->nCount*3+1; i++) { \ if (data->First.x > data->pList[i].x) data->First.x = data->pList[i].x; \ if (data->First.y > data->pList[i].y) data->First.y = data->pList[i].y; \ if (data->Second.x < data->pList[i].x) data->Second.x = data->pList[i].x; \ if (data->Second.y < data->pList[i].y) data->Second.y = data->pList[i].y; \ } \ // Line°ú Curve¿¡¼­ First, Second´Â °¢°¢ÀÇ ÃÖ´ë, ÃÖ¼Ò Á¡ÀÌ µé¾î°£´Ù //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //======== DXF Format Load : CDXF Class ÇÔ¼ö //============================== //--------------------------------------------------------------------------- // Creation Date : 2003.11.26 // Programming by monkman //--------------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////// // DXF¿¡¼­ »ç¿ëÇÏ´Â 256 »ö»ó°ª ¼ÂÆÃ ////////////////////////////////////////////////////////////////////// COLORREF DXF_COLOR[256] = { RGB( 0, 0, 0), /* black */ RGB(255, 0, 0), /* red */ RGB(255, 255, 0), /* yellow */ RGB( 0, 255, 0), /* green */ RGB( 0, 255, 255), /* cyan */ RGB( 0, 0, 255), /* blue */ RGB(255, 0, 255), /* magenta */ RGB(255, 255, 255), /* white */ RGB(152, 152, 152), /* grey -- an educated guess */ RGB(192, 192, 192), /* light grey -- an educated guess */ RGB(255, 0, 0),RGB(255, 128, 128),RGB(166, 0, 0), RGB(166, 83, 83),RGB(128, 0, 0),RGB(128, 64, 64),RGB( 76, 0, 0), RGB( 76, 38, 38),RGB( 38, 0, 0),RGB( 38, 19, 19),RGB(255, 64, 0), RGB(255, 159, 128),RGB(166, 41, 0),RGB(166, 104, 83),RGB(128, 32, 0), RGB(128, 80, 64),RGB( 76, 19, 0),RGB( 76, 48, 38),RGB( 38, 10, 0), RGB( 38, 24, 19),RGB(255, 128, 0),RGB(255, 191, 128),RGB(166, 83, 0), RGB(166, 124, 83),RGB(128, 64, 0),RGB(128, 96, 64),RGB( 76, 38, 0), RGB( 76, 57, 38),RGB( 38, 19, 0),RGB( 38, 29, 19),RGB(255, 191, 0), RGB(255, 223, 128),RGB(166, 124, 0),RGB(166, 145, 83),RGB(128, 96, 0), RGB(128, 112, 64),RGB( 76, 57, 0),RGB( 76, 67, 38),RGB( 38, 29, 0), RGB( 38, 33, 19),RGB(255, 255, 0),RGB(255, 255, 128),RGB(166, 166, 0), RGB(166, 166, 83),RGB(128, 128, 0),RGB(128, 128, 64),RGB( 76, 76, 0), RGB( 76, 76, 38),RGB( 38, 38, 0),RGB( 38, 38, 19),RGB(191, 255, 0), RGB(223, 255, 128),RGB(124, 166, 0),RGB(145, 166, 83),RGB( 96, 128, 0), RGB(112, 128, 64),RGB( 57, 76, 0),RGB( 67, 76, 38),RGB( 29, 38, 0), RGB( 33, 38, 19),RGB(128, 255, 0),RGB(191, 255, 128),RGB( 83, 166, 0), RGB(124, 166, 83),RGB( 64, 128, 0),RGB( 96, 128, 64),RGB( 38, 76, 0), RGB( 57, 76, 38),RGB( 19, 38, 0),RGB( 29, 38, 19),RGB( 64, 255, 0), RGB(159, 255, 128),RGB( 41, 166, 0),RGB(104, 166, 83),RGB( 32, 128, 0), RGB( 80, 128, 64),RGB( 19, 76, 0),RGB( 48, 76, 38),RGB( 10, 38, 0), RGB( 24, 38, 19),RGB( 0, 255, 0),RGB(128, 255, 128),RGB( 0, 166, 0), RGB( 83, 166, 83),RGB( 0, 128, 0),RGB( 64, 128, 64),RGB( 0, 76, 0), RGB( 38, 76, 38),RGB( 0, 38, 0),RGB( 19, 38, 19),RGB( 0, 255, 64), RGB(128, 255, 159),RGB( 0, 166, 41),RGB( 83, 166, 104),RGB( 0, 128, 32), RGB( 64, 128, 80),RGB( 0, 76, 19),RGB( 38, 76, 48),RGB( 0, 38, 10), RGB( 19, 38, 24),RGB( 0, 255, 128),RGB(128, 255, 191),RGB( 0, 166, 83), RGB( 83, 166, 124),RGB( 0, 128, 64),RGB( 64, 128, 96),RGB( 0, 76, 38), RGB( 38, 76, 57),RGB( 0, 38, 19),RGB( 19, 38, 29),RGB( 0, 255, 191), RGB(128, 255, 223),RGB( 0, 166, 124),RGB( 83, 166, 145),RGB( 0, 128, 96), RGB( 64, 128, 112),RGB( 0, 76, 57),RGB( 38, 76, 67),RGB( 0, 38, 29), RGB( 19, 38, 33),RGB( 0, 255, 255),RGB(128, 255, 255),RGB( 0, 166, 166), RGB( 83, 166, 166),RGB( 0, 128, 128),RGB( 64, 128, 128),RGB( 0, 76, 76), RGB( 38, 76, 76),RGB( 0, 38, 38),RGB( 19, 38, 38),RGB( 0, 191, 255), RGB(128, 223, 255),RGB( 0, 124, 166),RGB( 83, 145, 166),RGB( 0, 96, 128), RGB( 64, 112, 128),RGB( 0, 57, 76),RGB( 38, 67, 76),RGB( 0, 29, 38), RGB( 19, 33, 38),RGB( 0, 128, 255),RGB(128, 191, 255),RGB( 0, 83, 166), RGB( 83, 124, 166),RGB( 0, 64, 128),RGB( 64, 96, 128),RGB( 0, 38, 76), RGB( 38, 57, 76),RGB( 0, 19, 38),RGB( 19, 29, 38),RGB( 0, 64, 255), RGB(128, 159, 255),RGB( 0, 41, 166),RGB( 83, 104, 166),RGB( 0, 32, 128), RGB( 64, 80, 128),RGB( 0, 19, 76),RGB( 38, 48, 76),RGB( 0, 10, 38), RGB( 19, 24, 38),RGB( 0, 0, 255),RGB(128, 128, 255),RGB( 0, 0, 166), RGB( 83, 83, 166),RGB( 0, 0, 128),RGB( 64, 64, 128),RGB( 0, 0, 76), RGB( 38, 38, 76),RGB( 0, 0, 38),RGB( 19, 19, 38),RGB( 64, 0, 255), RGB(159, 128, 255),RGB( 41, 0, 166),RGB(104, 83, 166),RGB( 32, 0, 128), RGB( 80, 64, 128),RGB( 19, 0, 76),RGB( 48, 38, 76),RGB( 10, 0, 38), RGB( 24, 19, 38),RGB(128, 0, 255),RGB(191, 128, 255),RGB( 83, 0, 166), RGB(124, 83, 166),RGB( 64, 0, 128),RGB( 96, 64, 128),RGB( 38, 0, 76), RGB( 57, 38, 76),RGB( 19, 0, 38),RGB( 29, 19, 38),RGB(191, 0, 255), RGB(223, 128, 255),RGB(124, 0, 166),RGB(145, 83, 166),RGB( 96, 0, 128), RGB(112, 64, 128),RGB( 57, 0, 76),RGB( 67, 38, 76),RGB( 29, 0, 38), RGB( 33, 19, 38),RGB(255, 0, 255),RGB(255, 128, 255),RGB(166, 0, 166), RGB(166, 83, 166),RGB(128, 0, 128),RGB(128, 64, 128),RGB( 76, 0, 76), RGB( 76, 38, 76),RGB( 38, 0, 38),RGB( 38, 19, 38),RGB(255, 0, 191), RGB(255, 128, 223),RGB(166, 0, 124),RGB(166, 83, 145),RGB(128, 0, 96), RGB(128, 64, 112),RGB( 76, 0, 57),RGB( 76, 38, 67),RGB( 38, 0, 29), RGB( 38, 19, 33),RGB(255, 0, 128),RGB(255, 128, 191),RGB(166, 0, 83), RGB(166, 83, 124),RGB(128, 0, 64),RGB(128, 64, 96),RGB( 76, 0, 38), RGB( 76, 38, 57),RGB( 38, 0, 19),RGB( 38, 19, 29),RGB(255, 0, 64), RGB(255, 128, 159),RGB(166, 0, 41),RGB(166, 83, 104),RGB(128, 0, 32), RGB(128, 64, 80),RGB( 76, 0, 19),RGB( 76, 38, 48),RGB( 38, 0, 10), RGB( 38, 19, 24),RGB( 84, 84, 84),RGB(118, 118, 118),RGB(152, 152, 152), RGB(187, 187, 187),RGB(221, 221, 221),RGB(255, 255, 255) }; //--------------------------------------------------------------------------- CDXF::CDXF() { SetSizeXY(0.0, 0.0); LTYPE = NULL; STYLE = NULL; BLOCK = NULL; LAYER = NULL; lcount=lycount=scount=bcount=0; // ÆÄÀÏÀ» Àаí ÀÖ´Â À§Ä¡¸¦ 0À¸·Î ÃʱâÈ­ÇÑ´Ù. SetCount(0); } //--------------------------------------------------------------------------- CDXF::~CDXF() { DeleteContents(); } //--------------------------------------------------------------------------- /* Å×À̺í(=±¸Á¶Ã¼ ¹è¿­)À» ÃʱâÈ­Çϰí, ¸Þ¸ð¸®¿¡ Å×ÀÌºí ¸¸Å­ÀÇ ¿µ¿ªÀ» È®º¸ÇÑ´Ù cout º¯¼öµéÀ» 0À¸·Î ÃʱâÈ­ÇÑ´Ù */ void __fastcall CDXF::AllocTable() { LTYPE = new tagLTYPE[10000]; STYLE = new tagSTYLE[10000]; BLOCK = new tagBLOCK[10000]; LAYER = new tagLAYER[20000]; /* memset(LPVOID(LTYPE), 0, sizeof(tagLTYPE)*50); memset(LPVOID(STYLE), 0, sizeof(tagSTYLE)*50); memset(LPVOID(BLOCK), 0, sizeof(tagBLOCK)*50); memset(LPVOID(LAYER), 0, sizeof(tagLAYER)*50); */ lcount=lycount=scount=bcount=0; } //--------------------------------------------------------------------------- void __fastcall CDXF::DeleteTable() // Å×À̺í ÃʱâÈ­ { if (LTYPE != NULL) { delete[] LTYPE; LTYPE = NULL; } if (STYLE != NULL) { delete[] STYLE; STYLE = NULL; } if (BLOCK != NULL) { delete[] BLOCK; BLOCK = NULL; } if (LAYER != NULL) { delete[] LAYER; LAYER = NULL; } lcount=lycount=scount=bcount=0; } //--------------------------------------------------------------------------- void __fastcall CDXF::DeleteContents() { // SetSizeXY´Â tagVSIZE ±¸Á¶Ã¼¾È¿¡ ÀÖ´Â cx, cy º¯¼ö¸¦ 0À¸·Î ÃʱâÈ­ÇÑ´Ù SetSizeXY(0.0, 0.0); DeleteTable(); } //--------------------------------------------------------------------------- /* µÎ ¶óÀÎÀ» Àд´٠ù ¹øÂ° ¶óÀÎÀ» Àоî Á¤¼öÇüÀ¸·Î º¯È¯ ÈÄ group_code¿¡ ´ëÀÔÇÑ´Ù µÎ ¹øÂ° ¶óÀÎÀ» Àоî Trim ½ÃŲ ÈÄ buf¿¡ ´ëÀÔÇÑ´Ù group_code¸¦ ¸®ÅÏÇѴ٠ù ¹øÂ° ¶óÀÎ(buf)Àº ±×·ìÄÚµå(group code)¿¡ ÇØ´çµÇ°í, µÎ ¹øÂ° ¶óÀÎÀº ±×·ì°ª(group value)¿¡ ÇØ´çµÈ´Ù */ int __fastcall CDXF::GetLine(TStringList *sf, String &buf) { int group_code; // while (sf->Strings[count] == NULL || sf->Strings[count] == "") // count++; if (sf->Strings[count] == NULL && sf->Strings[count] != "0") return DXF_ERR; buf = sf->Strings[count]; group_code = StrToInt(buf); count++; if (sf->Strings[count] == NULL && sf->Strings[count] != "0") return DXF_ERR; buf = sf->Strings[count]; buf.TrimLeft(); buf.TrimRight(); count++; return (group_code); } //--------------------------------------------------------------------------- /* ¿øÇÏ´Â ±×·ìÄÚµå À§Ä¡¸¦ ãÀ»¶§ »ç¿ëµÈ´Ù. ÇÔ¼ö¿¡ ÆÄ¶ó¹ÌÅÍ·Î ³Ñ±ä grp¿Í ÆÄÀÏ¿¡¼­ Àоî¿Â g_code(±×·ìÄÚµå) °°°í, ÇÔ¼ö¿¡ ÆÄ¶ó¹ÌÅÍ·Î ³Ñ±ä f_str°ú ÆÄÀÏ¿¡¼­ Àоî¿Â buf(±×·ì°ª)°¡ °°À¸¸é ÂüÀ» ¸®ÅÏÇÑ´Ù */ bool __fastcall CDXF::Find_Entry(TStringList *sf, int grp, Char * str) { String UniStr; UniStr = UniStr + str; int g_code; do { g_code = GetLine(sf, UniStr); if (grp == g_code && !_tcscmp(UniStr.c_str(), str)) return TRUE; } while(g_code != DXF_ERR); return FALSE; } //--------------------------------------------------------------------------- /* - HEADER Section : 1. ÀÌ sectionÀº µµ¸é°ú °ü·ÃµÈ º¯¼öµéÀÇ settingÀ» Æ÷ÇÔÇÑ´Ù. ÀÌ·¯ÇÑ º¯¼öµéÀº ´Ù¾çÇÑ ¸í·É¾îµé¿¡ ÀÇÇØ ¼³Á¤µÇ¸ç, status command¿¡ ÀÇÇØ displayµÇ´Â Á¤º¸ ÇüŸ¦ °¡Áø´Ù. 2. °¢ º¯¼öµéÀº º¯¼ö¸í ÁöÁ¤ÀÚÀÎ 9 group ´ÙÀ½¿¡ À§Ä¡Çϸç, ±× µÚ¿¡ º¯¼ö °ªÀ» °®´Â groupµéÀÌ ¿Â´Ù. -- °ü·Ã ÀÚ·á : ÅäÁöÁ¤º¸½Ã½ºÅÛ ±¸ÃàÀ» À§ÇÑ GISÀÚ·á¿¡ ´ëÇÑ ÀÌÇØ ¹Ú¹ÎÈ£ (¸ñÆ÷´ëÇб³ ÁöÀûÇаú) - °á°úÀûÀ¸·Î "0", "SECTION" µÎ ¹®ÀÚ¿­ÀÌ ¿¬¼ÓµÇ¾î ÀÖ´Â ¶óÀÎÀ» ã°í, "2", "HEADER" µÎ ¹®ÀÚ¿­ÀÌ ¿¬¼ÓµÇ¾î ÀÖ´Â ¶óÀÎÀ» ã´Â´Ù. (Çì´õºÎºÐÀ» ã±â À§ÇÑ °úÁ¤) ±×¸®°í, ÆÄÀÏÀÌ ³¡ÀÌ ¾Æ´ÑÁö.. ¼½¼ÇÀÇ ³¡ÀÌ ¾Æ´ÑÁö¸¦ °è¼Ó °Ë»çÇϸç "0", "$EXTMIN" µÎ ¹®ÀÚ¿­ÀÇ ¿¬¼ÓµÇ¾î ÀÖ´Â ¶óÀÎÀ» ã°í, ´ÙÀ½ ¶óÀÎÀÌ "10" ÀÌ¸é ±× ´ÙÀ½ ¶óÀÎÀÇ °ªÀ» min_x ´ëÀÔÇϰí, ´ÙÀ½ ¶óÀÎÀÌ "20" À̸é min_y¿¡ ´ëÀÔÇÑ´Ù. ¸¶Âù°¡Áö·Î, ÆÄÀÏÀÇ ³¡ÀÌ ¾È´ÏÁö.. ¼½¼ÇÀÇ ƒPÀÌ ¾Æ´ÑÁö¸¦ °è¼Ó °Ë»çÇϸç "0", "$EXTMAX" µÎ ¹®ÀÚ¿­ÀÇ ¿¬¼ÓµÇ¾î ÀÖ´Â ¶óÀÎÀ» ã°í, ´ÙÀ½ ¶óÀÎÀÌ "10" ÀÌ¸é ±× ´ÙÀ½ ¶óÀÎÀÇ °ªÀ» max_x ´ëÀÔÇϰí, ´ÙÀ½ ¶óÀÎÀÌ "20" À̸é max_y¿¡ ´ëÀÔÇÑ´Ù. ÆÄÀÏ ¾È¿¡¼­ "EOF"¸¦ ¸¸³ª¸é FALSE¸¦ ¹Ý³³Çϰí ENDSECÀ» ¸¸³ª¸é TRUE¸¦ ¹ÝȯÇϵÇ, ·çÇÁ¸¦ ¹þ¾î³­´Ù */ bool __fastcall CDXF::Find_Header(TStringList *sf, double &min_x, double &min_y, double &max_x, double &max_y) { String buf; int g_code; bool continue_flag; // HEADER SECTION if (Find_Entry(sf, 0, L"SECTION") == FALSE) return FALSE; if (Find_Entry(sf, 2, L"HEADER") == FALSE) return FALSE; continue_flag = TRUE; while (continue_flag) { g_code = GetLine(sf, buf); switch (g_code) { case DXF_ERR : return FALSE; case 0 : // file section mark if (buf == L"EOF") return FALSE; if (buf == L"ENDSEC") { continue_flag = FALSE; break; } break; case 9 : if (buf == L"$EXTMIN") { if (GetLine(sf, buf) != 10) return FALSE; min_x = StrToFloat(buf); if (GetLine(sf, buf) != 20) return FALSE; min_y = StrToFloat(buf); } else if (buf == L"$EXTMAX") { if (GetLine(sf, buf) != 10) return FALSE; max_x = StrToFloat(buf); if (GetLine(sf, buf) != 20) return FALSE; max_y = StrToFloat(buf); } break; } } return TRUE; } //--------------------------------------------------------------------------- /* - Table Section 1. ÀÌ sectionÀº ¸î °³ÀÇ tableÀ» Æ÷ÇÔÇϰí Àִµ¥, °¢ tableÀº entryÀÇ º¯¼ö °³¼ö¸¦ Æ÷ÇÔÇÑ´Ù. 2. tableÀÇ ¼ø¼­´Â º¯ÇÒ ¼ö ÀÖÁö¸¸ LTYPE tableÀº ¹Ýµå½Ã LAYER table ¾Õ¿¡ ¿Í¾ß ÇÑ´Ù. 3. °¢ tableÀº 0 group ´ÙÀ½¿¡ "TABLE"·Î ¼Ò°³µÇ´Âµ¥, ±× µÚ¿¡ tableÀÇ À̸§(LTYPE, LAYER, STYLE, VIEW, ...)À» ºÎ¿©ÇÏ´Â 2 group°ú table entryÀÇ ÃÖ´ë ¼ö¸¦ ÀúÀåÇÏ´Â 70 groupÀÌ µû¸¥´Ù. 4. table¿¡´Â »èÁ¦µÈ Ç׸ñÀÌ 70 group¿¡ Æ÷Ç﵃ ¼öµµ ÀÖÁö¸¸, À̵éÀº DXF ÆÄÀÏ¿¡ ÀúÀå µÇÁö ¾Ê´Â´Ù. µû¶ó¼­ table Çì´õ¿¡ µÚµû¸£´Â Ç׸ñÀÇ ½ÇÁ¦ ¼ö´Â 70 group¿¡¼­ ÁöÁ¤µÈ ¼öº¸´Ù ÀÛÀ» ¼öµµ ÀÖÀ¸¹Ç·Î, 70 groupÀÇ count´Â tableÀ» Àбâ À§ÇÑ ÁöÇ¥·Î »ç¿ëµÇ¸é ¾ÈµÈ´Ù. 70 groupÀÇ count´Â »ç¿ëÀÚ ÇÁ·Î±×·¥ÀÌ DXF¸¦ ÀÐÀ» ¶§, ±× µÚ¸¦ µû¸£´Â ¸ðµç Ç׸ñÀ» À¯ÁöÇϱ⿡ ÃæºÐÇÑ ¹è¿­À» ¹Ì¸® ÇÒ´çÇÒ ¼ö ÀÖµµ·Ï ÇØÁÖ±â À§ÇØ ¸¶·ÃµÈ´Ù. 5. °¢ table Çì´õ µÚ¿¡´Â table entry°¡ µû¸¥´Ù. °¢ table itemÀº item type(table name°ú °°À½)À» ½Äº°ÇÏ´Â 0 group, table entryÀÇ À̸§À» ºÎ¿©ÇÏ´Â 2 group, table entry¿¡ °ü°èµÇ´Â flag¸¦ ÁöÁ¤ÇÏ´Â 70 group ¹× table entryÀÇ °ªÀ» ÁÖ´Â Ãß°¡ÀûÀÎ groupÀ¸·Î ±¸¼ºµÈ´Ù. 6. °¢ tableÀÇ ³¡Àº 0 groupÀÇ °ª "ENDTAB"¿¡ ÀÇÇØ Ç¥½ÃµÈ´Ù. -- °ü·Ã ÀÚ·á : ÅäÁöÁ¤º¸½Ã½ºÅÛ ±¸ÃàÀ» À§ÇÑ GISÀÚ·á¿¡ ´ëÇÑ ÀÌÇØ ¹Ú¹ÎÈ£ (¸ñÆ÷´ëÇб³ ÁöÀûÇаú) */ bool __fastcall CDXF::Find_Table(TStringList *sf) { bool continue_flag, t_flag; int g_code, t_code, table; String buf; // TABLES SECTION lcount=0; lycount=0; scount=0; table = 0; t_flag = FALSE; continue_flag = TRUE; if (Find_Entry(sf, 0, L"SECTION") == FALSE) return FALSE; if (Find_Entry(sf, 2, L"TABLES") == FALSE) return FALSE; while (continue_flag) { g_code = GetLine(sf, buf); switch (g_code) { case DXF_ERR : return FALSE; case 0 : // file section mark if (buf == L"EOF") return FALSE; else if (buf == L"ENDSEC") { continue_flag = FALSE; break; } else if (buf == L"ENDTAB") { t_flag = FALSE; continue; } else if (buf == L"TABLE") { t_flag = TRUE; } else if (buf == L"LTYPE" && t_flag == TRUE && table == 1) { LTYPE[lcount].ID[0] = L'\0'; LTYPE[lcount].Kind = -1; do { t_code = GetLine(sf, buf); if (t_code == 2) { _tcscpy(LTYPE[lcount].ID, buf.c_str()); if (LTYPE[lcount].Kind != -1) { lcount++; break; } } else if (t_code == 73) { switch (StrToInt(buf)) { case 0 : LTYPE[lcount].Kind = PS_SOLID; break; case 1 : LTYPE[lcount].Kind = PS_DASH; break; case 2 : LTYPE[lcount].Kind = PS_DASHDOT; break; case 3 : LTYPE[lcount].Kind = PS_DOT; break; default: LTYPE[lcount].Kind = PS_SOLID; break; } if (LTYPE[lcount].ID[0]) { lcount++; break; } } else if (t_code == 0) break; } while (t_code != DXF_ERR); } else if (buf == L"LAYER" && t_flag == TRUE && table == 2) { LAYER[lycount].ID[0] = L'\0'; LAYER[lycount].color = 0; LAYER[lycount].line_type = -1; LAYER[lycount].onoff = -1; do { t_code = GetLine(sf, buf); if (t_code == 2) { _tcscpy(LAYER[lycount].ID, buf.c_str()); if ( LAYER[lycount].color && LAYER[lycount].line_type != -1 && LAYER[lycount].onoff != -1) { lycount++; break; } } else if (t_code == 6) { for (int i=0; iKind = V_CURVE; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; data->nCount = 1; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); pFst.x = (x-1); pFst.y = (y-1); pScd.x = (x+1); pScd.y = (y+1); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawLine(TStringList *sf, TVecData *data) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, sum = 4; double th = 1.0f; float sx, sy, ex, ey; unsigned long sf_pos; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_CURVE; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; data->nCount = 1; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawCircle(TStringList *sf, TVecData *data) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, sum = 3; double th = 1.0f; float x, y, r; unsigned long sf_pos; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->nCount = 4; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); double M = 0.55228474983; double dx = fabs(pFst.x-pScd.x)/2.0, dy = fabs(pFst.y-pScd.y)/2.0; double ddx = dx * M, ddy = dy * M; data->pList[0].DPoint((pFst.x+pScd.x)/2.0, pFst.y); data->pList[1].DPoint((pFst.x+pScd.x)/2.0-ddx, pFst.y); data->pList[2].DPoint(pFst.x, (pFst.y+pScd.y)/2.0-ddy); data->pList[3].DPoint(pFst.x, (pFst.y+pScd.y)/2.0); data->pList[4].DPoint(pFst.x, (pFst.y+pScd.y)/2+ddy); data->pList[5].DPoint((pFst.x+pScd.x)/2.0-ddx, pScd.y); data->pList[6].DPoint((pFst.x+pScd.x)/2.0, pScd.y); data->pList[7].DPoint((pFst.x+pScd.x)/2.0+ddx, pScd.y); data->pList[8].DPoint(pScd.x, (pFst.y+pScd.y)/2.0+ddy); data->pList[9].DPoint(pScd.x, (pFst.y+pScd.y)/2.0); data->pList[10].DPoint(pScd.x, (pFst.y+pScd.y)/2.0-ddy); data->pList[11].DPoint((pFst.x+pScd.x)/2.0+ddx, pFst.y); data->pList[12].DPoint((pFst.x+pScd.x)/2.0, pFst.y); data->bClosed = true; if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- // todo : DrawArc - Â÷ÈÄ ¾÷±×·¹À̵å ÁøÇà bool __fastcall CDXF::DrawArc(TStringList *sf, TVecData *data) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, sum = 5; double th = 1.0f; float x, y, r, x1, y1, x2, y2; double sd, ed; // int count; // double maxd, mind; unsigned long sf_pos; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iArc(x-r, y-r, x+r, y+r, x1, y1, x2, y2); x1 = (x+r*cos(sd*(atan(1)*4.0/180.0))); y1 = (y+r*sin(sd*(atan(1)*4.0/180.0))); x2 = (x+r*cos(ed*(atan(1)*4.0/180.0))); y2 = (y+r*sin(ed*(atan(1)*4.0/180.0))); pFst.x = x; pFst.y = y; pScd.x = x1; pScd.y = y1; data->Kind = V_CURVE; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; // maxd = max(sd, ed); // mind = min(sd, ed); // count = (int(maxd)/90) - (int(mind)/90) + 1; // if (maxd%90 == 0) count--; // if (mind%90 == 0) count data->nCount = count; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); // data->pList[0].DPoint(pFst.x, pFst.y); // data->pList[1].DPoint(pFst.x, pFst.y); // data->pList[2].DPoint(pScd.x, pScd.y); // data->pList[3].DPoint(pScd.x, pScd.y); if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawPolyline(TStringList *sf, TVecData *data) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, t_code, sum = 0; double th = 1.0f; float ox, oy, x, y; BOOL close_flag=false; unsigned long sf_pos; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; //data->Brush = PenManagerForm->PenShape->Pen->Color; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; } else if (t_code == 20 && sum == 4) { pScd.x = x; pScd.y = y; data->nCount = 1; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); } else if (t_code == 20 && sum > 4 && sum % 2 == 0) { pFst.x = pScd.x; pFst.y = pScd.y; pScd.x = x; pScd.y = y; data->nCount++; data->pList = (DPOINT *)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); data->pList[data->nCount*3 - 2].DPoint(pFst.x, pFst.y); data->pList[data->nCount*3 - 1].DPoint(pScd.x, pScd.y); data->pList[data->nCount*3].DPoint(pScd.x, pScd.y); } } while(buf != "SEQEND"); } } while(buf != "SEQEND"); // ÆÄÀÏÀ» Àаí ÀÖ´Â À§Ä¡¸¦ ¾ÕÀ¸·Î µ¹·ÁÁØ´Ù SetCount(sf_pos-2); if (close_flag) { pFst.x = pScd.x; pFst.y = pScd.y; pScd.x = ox; pScd.y = oy; data->nCount++; data->pList = (DPOINT *)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); data->pList[data->nCount*3 - 2].DPoint(pFst.x, pFst.y); data->pList[data->nCount*3 - 1].DPoint(pScd.x, pScd.y); data->pList[data->nCount*3].DPoint(pScd.x, pScd.y); data->bClosed = true; } if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawText(TStringList *sf, TVecData *data) { String buf, text; POINT pFst; unsigned long sf_pos; unsigned int al; String FontType = MainImageForm->iMainImage->Canvas->Font->Name; HDC hdc = MainImageForm->iMainImage->Canvas->Handle; TPItemImage *Image = MainImageForm->iMainImage; HFONT font = NULL, oldfont = NULL; RECT rc; int widthsum = 0, height; double angle; SIZE sz; Char *tempstr = L""; int i, type, color, g_code, h_align=-1, v_align=-1, sum = 4, o_flag=0, s_ort=0, c_ort=0; float x, y, x2, y2; double h=0.0, xf=0.0, t_h=0.0, xx=0.0, xx2=0.0, th = 1.0f; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_TEXT; data->First = pFst; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->nCount = text.Length(); // ÆùÆ®ÀÇ Å©±â¸¦ À½¼ö°ªÀ¸·Î ÁÖ¸é ¹®Á¦°¡ ¹ß»ýÇÑ´Ù data->Font.lfHeight = h; // ÀåÆòÀ» µû·Î ÁÖÁö ¾Ê°í ³ôÀÌ¿¡ µû¶ó ÀÏÁ¤ÇÏ°Ô ÁØ´Ù // data->Font.lfWidth = (h*xf); data->Font.lfWidth = 0; data->Font.lfEscapement = s_ort; data->Font.lfOrientation = c_ort; data->Font.lfWeight = th; data->Font.lfItalic = FALSE; data->Font.lfUnderline = FALSE; data->Font.lfStrikeOut = FALSE; data->Font.lfCharSet = DEFAULT_CHARSET; data->Font.lfOutPrecision = OUT_CHARACTER_PRECIS; data->Font.lfClipPrecision = CLIP_CHARACTER_PRECIS; data->Font.lfQuality = DEFAULT_QUALITY; data->Font.lfPitchAndFamily = FIXED_PITCH|FF_DONTCARE; // ±¼¸²Ã¼¸¦ ÁöÁ¤ÇØÁÙ °æ¿ì ¿µ¹® À©µµ¿ì¿¡¼­ ¹®Á¦°¡ ¹ß»ýÇÒ ¼ÒÁö°¡ ÀÖ´Ù // _tcscpy(data->Font.lfFaceName, "±¼¸²Ã¼"); data->TextString = text; for (int k = 0; k < data->nCount; k++) { tempstr[k] = Char(data->TextString[k+1]); } font = CreateFontIndirect(&data->Font); oldfont = (HFONT)SelectObject(hdc, font); SelectObject(hdc, font); GetTextExtentPoint32(hdc, tempstr, text.Length(), &sz); widthsum = sz.cx; SelectObject(hdc, oldfont); DeleteObject(font); font = NULL; height = data->Font.lfHeight; angle = 2*M_PI*data->Font.lfEscapement/10/360; data->Second.x = data->First.x + widthsum*cos(angle) - height*sin(angle); data->Second.y = data->First.y - widthsum*sin(angle) - height*cos(angle); // if (data->pList) // { // return TRUE; // } // else // { // return FALSE; // } return TRUE; } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawSolid(TStringList *sf, TVecData *data) { String buf; tagDPOINT pFst, pScd, pTrd, pFth; int i, color, g_code, sum = 8, type=1; double th = 1.0f; unsigned long sf_pos; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bSelected = false; data->nCount = 4; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); data->pList[4].DPoint(pScd.x, pScd.y); data->pList[5].DPoint(pTrd.x, pTrd.y); data->pList[6].DPoint(pTrd.x, pTrd.y); data->pList[7].DPoint(pTrd.x, pTrd.y); data->pList[8].DPoint(pFth.x, pFth.y); data->pList[9].DPoint(pFth.x, pFth.y); data->pList[10].DPoint(pFth.x, pFth.y); data->pList[11].DPoint(pFst.x, pFst.y); data->pList[12].DPoint(pFst.x, pFst.y); data->bClosed = true; if (data->Color != 0) { data->Brush = (TColor)DXF_COLOR[color]; data->bFill = true; } if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawSpline(TStringList *sf, TVecData *data) { String buf; tagDPOINT pFst; bool isFirst = true; bool isCorelDraw = true; int i, type=1, color, g_code, sum = 1000, cnt = 1, arrCnt = 0; double th = 1.0f; unsigned long sf_pos; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; ibClosed = false; break; case 1 : data->bClosed = true; break; // Illustrator (planar(Æò¸é)·Î ÀνÄ) case 8 : isCorelDraw = false; data->bClosed = false; break; default : data->bClosed = false; break; } } // Number of Control points else if (g_code == 73) { sum = StrToInt(buf); // CorelDraw¿¡¼­´Â g_code == 73ÀÌ 0ÀÎ °æ¿ìµµ ÀÖÀ¸¹Ç·Î ó¸®.. if (sum == 0) { // ¿¡·¯¸Þ½ÃÁö ó¸®.. (Á¤È®ÇÏ°Ô ºÒ·¯¿Ô´ÂÁö ¾Ë ¼ö´Â ¾ø´Ù..) //Application->MessageBox("The File has not been loaded properly", "TextStylist", MB_OK); return TRUE; } else { if (isCorelDraw) { // CorelDraw º¯È¯½Ã.. Illustrator º¯È¯À϶§ º¸´Ù Áߺ¹µÇ´Â ¼ö¸¦ ´õ »©Áà¾ßÇÑ´Ù.. // Áߺ¹µÇ´Â °ªÀº 4n+1 ¶§¸¶´Ù Çѹø¾¿ ³ªÅ¸³­´Ù.. data->nCount = ((sum - ((sum / 4 - 1) - 1)) / 3); } else { // Illustrator º¯È¯½Ã.. 3n+1 À̹ǷΠÁ¡ÀÇ ¼ö ¼ÂÆÃ data->nCount = (sum - 1) / 3; } //data->nCount = sum; sum = sum * 2; } } // Control Points X else if (g_code == 10) { pFst.x = (StrToFloat(buf)-min_x)*f; sum--; } // Control Points y else if (g_code == 20) { pFst.y = (max_y-StrToFloat(buf))*f; if (isCorelDraw) { if ((cnt % 4) != 1 || cnt == 1) { if (isFirst) { data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); isFirst = false; } data->pList[arrCnt++].DPoint(pFst.x, pFst.y); } } else { if (isFirst) { data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); isFirst = false; } data->pList[arrCnt++].DPoint(pFst.x, pFst.y); } cnt++; sum--; } } while(sum); // ÆÄÀÏÀ» Àаí ÀÖ´Â À§Ä¡¸¦ ¾ÕÀ¸·Î µ¹·ÁÁØ´Ù SetCount(sf_pos-2); data->Kind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->bFill = false; data->Bitmap = NULL; data->bSelected = false; // ùÁ¡°ú ¸¶Áö¸·Á¡ÀÇ À§Ä¡°¡ °°´Ù¸é ´ÝÈù µµÇüÀ̶ó°í ÆÇ´ÜÇÏ´Â ºÎºÐ // if (!isCorelDraw && data->pList[0].x == data->pList[arrCnt-1].x && // data->pList[0].y == data->pList[arrCnt-1].y) // { // data->bClosed = true; // } if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- // CorelDraw ¿ë.. bool __fastcall CDXF::DrawEllipse(TStringList *sf, TVecData *data) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, sum = 5; double th = 1.0f; float cx, cy, a, b, ratio; unsigned long sf_pos; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; i= b) { pFst.x = (cx-a); pFst.y = (cy-(a*ratio)); pScd.x = (cx+a); pScd.y = (cy+(a*ratio)); } // ¼¼·Î°¡ ÀåÃàÀÏ °æ¿ì (b) else if (a < b) { pFst.x = (cx-(b*ratio)); pFst.y = (cy-b); pScd.x = (cx+(b*ratio)); pScd.y = (cy+b); } data->Kind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->nCount = 4; data->bFill = false; data->Bitmap = NULL; data->bSelected = false; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); double M = 0.55228474983; double dx = fabs(pFst.x-pScd.x)/2.0, dy = fabs(pFst.y-pScd.y)/2.0; double ddx = dx * M, ddy = dy * M; data->pList[0].DPoint((pFst.x+pScd.x)/2.0, pFst.y); data->pList[1].DPoint((pFst.x+pScd.x)/2.0-ddx, pFst.y); data->pList[2].DPoint(pFst.x, (pFst.y+pScd.y)/2.0-ddy); data->pList[3].DPoint(pFst.x, (pFst.y+pScd.y)/2.0); data->pList[4].DPoint(pFst.x, (pFst.y+pScd.y)/2+ddy); data->pList[5].DPoint((pFst.x+pScd.x)/2.0-ddx, pScd.y); data->pList[6].DPoint((pFst.x+pScd.x)/2.0, pScd.y); data->pList[7].DPoint((pFst.x+pScd.x)/2.0+ddx, pScd.y); data->pList[8].DPoint(pScd.x, (pFst.y+pScd.y)/2.0+ddy); data->pList[9].DPoint(pScd.x, (pFst.y+pScd.y)/2.0); data->pList[10].DPoint(pScd.x, (pFst.y+pScd.y)/2.0-ddy); data->pList[11].DPoint((pFst.x+pScd.x)/2.0+ddx, pFst.y); data->pList[12].DPoint((pFst.x+pScd.x)/2.0, pFst.y); data->bClosed = true; if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawLWPolyline(TStringList *sf, TVecData *data) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, t_code, sum = -1, cnt = 0; double th = 1.0f; float ox, oy, x, y; BOOL close_flag=false; unsigned long sf_pos; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; i= 0) { if (cnt == 2) { pFst.x = x; pFst.y = y; data->Kind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; } else if (cnt == 4) { pScd.x = x; pScd.y = y; data->nCount = 1; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); // metaDC.LineTo(x, y); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); } else if (cnt > 4 && cnt % 2 == 0) { pFst.x = pScd.x; pFst.y = pScd.y; pScd.x = x; pScd.y = y; data->nCount++; data->pList = (DPOINT *)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); data->pList[data->nCount*3 - 2].DPoint(pFst.x, pFst.y); data->pList[data->nCount*3 - 1].DPoint(pScd.x, pScd.y); data->pList[data->nCount*3].DPoint(pScd.x, pScd.y); } } } while(sum); // ÆÄÀÏÀ» Àаí ÀÖ´Â À§Ä¡¸¦ ¾ÕÀ¸·Î µ¹·ÁÁØ´Ù SetCount(sf_pos-2); if (close_flag) { data->bClosed = true; } if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawMText(TStringList *sf, TVecData *data) { String buf, text; POINT pFst; unsigned long sf_pos; unsigned int al; String FontType = MainImageForm->iMainImage->Canvas->Font->Name; HDC hdc = MainImageForm->iMainImage->Canvas->Handle; TPItemImage *Image = MainImageForm->iMainImage; HFONT font = NULL, oldfont = NULL; RECT rc; int widthsum = 0, height; double angle; SIZE sz; Char *tempstr = L""; int i, type, color, g_code, align=1, sum = 4, o_flag=0, s_ort=0, c_ort=0; float x, y, x2, y2; double h=0.0, xf=0.0, t_h=0.0, xx=0.0, xx2=0.0, th = 1.0f; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; i 1) { Mode = 5; continue; } if (Mode == 1) { Font += text[j]; } if ((Mode == 2) && (text.Length() > j+2)) { if (text.SubString(j, 2) == "b0") { Bold = false; i+=1; } else if (text.SubString(j, 2) == "b1") { Bold = true; i+=1; } } if ((Mode == 3) && (text.Length() > j+2)) { if (text.SubString(j, 2) == "i0") { Italic = false; j+=1; } else if (text.SubString(j, 2) == "i1") { Italic = true; j+=1; } } if (Mode == 4) { Code += text[j]; } if (Mode == 5) { Temp = text.SubString(j, text.Length()-j+1); break; } } */ for (int j = text.Length(); j >= 0; j--) { if (text.SubString(j, 1).Compare(";") == 0) { text = text.SubString(j+1, text.Length()-j+1); break; } } al = 0; pFst.x = x; pFst.y = y-h; data->Kind = V_TEXT; data->First = pFst; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->nCount = text.Length(); // ÆùÆ®ÀÇ Å©±â¸¦ À½¼ö°ªÀ¸·Î ÁÖ¸é ¹®Á¦°¡ ¹ß»ýÇÑ´Ù data->Font.lfHeight = t_h; // ÀåÆòÀ» µû·Î ÁÖÁö ¾Ê°í ³ôÀÌ¿¡ µû¶ó ÀÏÁ¤ÇÏ°Ô ÁØ´Ù // data->Font.lfWidth = (h*xf); data->Font.lfWidth = 0; data->Font.lfEscapement = s_ort; data->Font.lfOrientation = c_ort; data->Font.lfWeight = th; data->Font.lfItalic = FALSE; data->Font.lfUnderline = FALSE; data->Font.lfStrikeOut = FALSE; data->Font.lfCharSet = DEFAULT_CHARSET; data->Font.lfOutPrecision = OUT_CHARACTER_PRECIS; data->Font.lfClipPrecision = CLIP_CHARACTER_PRECIS; data->Font.lfQuality = DEFAULT_QUALITY; data->Font.lfPitchAndFamily = FIXED_PITCH|FF_DONTCARE; // ±¼¸²Ã¼¸¦ Á÷Á¢ ÁöÁ¤ÇØÁÙ °æ¿ì ¿µ¹® À©µµ¿ì¿¡¼­ ¹®Á¦°¡ ¹ß»ýÇÒ ¼ÒÁö°¡ ÀÖ´Ù // _tcscpy(data->Font.lfFaceName, "±¼¸²Ã¼"); data->TextString = text; for (int k = 0; k < data->nCount; k++) { tempstr[k] = Char(data->TextString[k+1]); } font = CreateFontIndirect(&data->Font); oldfont = (HFONT)SelectObject(hdc, font); SelectObject(hdc, font); GetTextExtentPoint32(hdc, tempstr, text.Length(), &sz); widthsum = sz.cx; SelectObject(hdc, oldfont); DeleteObject(font); font = NULL; height = data->Font.lfHeight; angle = 2*M_PI*data->Font.lfEscapement/10/360; data->Second.x = data->First.x + widthsum*cos(angle) - height*sin(angle); data->Second.y = data->First.y - widthsum*sin(angle) - height*cos(angle); switch (align) { case 0 : al |= TA_LEFT; break; case 1 : al |= TA_CENTER; break; /* case 2 : al |= TA_RIGHT; x = x2; y = y2; break; case 3 : al |= TA_LEFT; x = x2; y = y2; break; case 4 : al |= TA_CENTER|TA_TOP; x = x2; y = y2; // h = ((xx2-xx)*2*f/text.Length()); // y += h/2.0; break; case 5 : al |= TA_LEFT; x = x2; y = y2; break; case 6 : al |= TA_CENTER; x = x2; y = y2; break; case 7 : al |= TA_RIGHT; x = x2; y = y2; break; case 8 : al |= TA_LEFT; x = x2; y = y2; break; case 9 : al |= TA_CENTER|TA_TOP; x = x2; y = y2; */ default : al |= TA_LEFT; break; } // if (data->pList) // { // return TRUE; // } // else // { // return FALSE; // } return TRUE; } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawInsert(TStringList *sf, TVecData *data) { String buf; tagPBLOCK block; unsigned long sf_pos, bk_pos; int i, g_code; block.color = -1; block.bx = 0; block.by = 0; block.mx = 0; block.my = 0; block.fx = 1; block.fy = 1; block.cx = 1; block.cy = 1; block.sx = 0; block.sy = 0; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; ipList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawBlockPoint(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, sum = 2; double th = 1.0f; float x, y; unsigned long sf_pos; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_CURVE; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; data->nCount = 1; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); pFst.x = (x-1); pFst.y = (y-1); pScd.x = (x+1); pScd.y = (y+1); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawBlockLine(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, sum = 4; double th = 1.0f; float sx, sy, ex, ey; unsigned long sf_pos; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_CURVE; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; data->nCount = 1; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawBlockCircle(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, sum = 3; double th = 1.0f; float x, y, r; unsigned long sf_pos; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->nCount = 4; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); double M = 0.55228474983; double dx = fabs(pFst.x-pScd.x)/2.0, dy = fabs(pFst.y-pScd.y)/2.0; double ddx = dx * M, ddy = dy * M; data->pList[0].DPoint((pFst.x+pScd.x)/2.0, pFst.y); data->pList[1].DPoint((pFst.x+pScd.x)/2.0-ddx, pFst.y); data->pList[2].DPoint(pFst.x, (pFst.y+pScd.y)/2.0-ddy); data->pList[3].DPoint(pFst.x, (pFst.y+pScd.y)/2.0); data->pList[4].DPoint(pFst.x, (pFst.y+pScd.y)/2+ddy); data->pList[5].DPoint((pFst.x+pScd.x)/2.0-ddx, pScd.y); data->pList[6].DPoint((pFst.x+pScd.x)/2.0, pScd.y); data->pList[7].DPoint((pFst.x+pScd.x)/2.0+ddx, pScd.y); data->pList[8].DPoint(pScd.x, (pFst.y+pScd.y)/2.0+ddy); data->pList[9].DPoint(pScd.x, (pFst.y+pScd.y)/2.0); data->pList[10].DPoint(pScd.x, (pFst.y+pScd.y)/2.0-ddy); data->pList[11].DPoint((pFst.x+pScd.x)/2.0+ddx, pFst.y); data->pList[12].DPoint((pFst.x+pScd.x)/2.0, pFst.y); data->bClosed = true; if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- // todo : DrawBlockArc Â÷ÈÄ ¾÷±×·¹À̵å ÁøÇà bool __fastcall CDXF::DrawBlockArc(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, sum = 5; double th = 1.0f; float x, y, r, x1, y1, x2, y2; double sd, ed; // int count; // double maxd, mind; unsigned long sf_pos; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iArc(x-r, y-r, x+r, y+r, x1, y1, x2, y2); x1 = (x+r*cos(sd*(atan(1)*4.0/180.0))); y1 = (y+r*sin(sd*(atan(1)*4.0/180.0))); x2 = (x+r*cos(ed*(atan(1)*4.0/180.0))); y2 = (y+r*sin(ed*(atan(1)*4.0/180.0))); pFst.x = x; pFst.y = y; pScd.x = x1; pScd.y = y1; data->Kind = V_CURVE; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; // maxd = max(sd, ed); // mind = min(sd, ed); // count = (int(maxd)/90) - (int(mind)/90) + 1; // if (maxd%90 == 0) count--; // if (mind%90 == 0) count data->nCount = count; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); // data->pList[0].DPoint(pFst.x, pFst.y); // data->pList[1].DPoint(pFst.x, pFst.y); // data->pList[2].DPoint(pScd.x, pScd.y); // data->pList[3].DPoint(pScd.x, pScd.y); if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawBlockPolyline(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, t_code, sum = 0; double th = 1.0f; float ox, oy, x, y; BOOL close_flag=false; unsigned long sf_pos; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; } else if (t_code == 20 && sum == 4) { pScd.x = x; pScd.y = y; data->nCount = 1; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); } else if (t_code == 20 && sum > 4 && sum % 2 == 0) { pFst.x = pScd.x; pFst.y = pScd.y; pScd.x = x; pScd.y = y; data->nCount++; data->pList = (DPOINT *)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); data->pList[data->nCount*3 - 2].DPoint(pFst.x, pFst.y); data->pList[data->nCount*3 - 1].DPoint(pScd.x, pScd.y); data->pList[data->nCount*3].DPoint(pScd.x, pScd.y); } } while(buf != "SEQEND"); } } while(buf != "SEQEND"); // ÆÄÀÏÀ» Àаí ÀÖ´Â À§Ä¡¸¦ ¾ÕÀ¸·Î µ¹·ÁÁØ´Ù SetCount(sf_pos-2); if (close_flag) { pFst.x = pScd.x; pFst.y = pScd.y; pScd.x = ox; pScd.y = oy; data->nCount++; data->pList = (DPOINT *)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); data->pList[data->nCount*3 - 2].DPoint(pFst.x, pFst.y); data->pList[data->nCount*3 - 1].DPoint(pScd.x, pScd.y); data->pList[data->nCount*3].DPoint(pScd.x, pScd.y); data->bClosed = true; } if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawBlockText(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf, text; POINT pFst; unsigned long sf_pos; unsigned int al; String FontType = MainImageForm->iMainImage->Canvas->Font->Name; HDC hdc = MainImageForm->iMainImage->Canvas->Handle; TPItemImage *Image = MainImageForm->iMainImage; HFONT font = NULL, oldfont = NULL; RECT rc; int widthsum = 0, height; double angle; SIZE sz; Char *tempstr = L""; int i, type, color, g_code, h_align=-1, v_align=-1, sum = 4, o_flag=0, s_ort=0, c_ort=0; double th = 1.0f; float x, y, x2, y2; double h=0.0, xf=0.0, t_h=0.0, xx=0.0, xx2=0.0; color = block.color; do { // ÇöÀç Àаí ÀÖ´Â ÆÄÀÏÀÇ À§Ä¡¸¦ ±â·ÏÇÑ´Ù sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_TEXT; data->First = pFst; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->nCount = text.Length(); // ÆùÆ®ÀÇ Å©±â¸¦ À½¼ö°ªÀ¸·Î ÁÖ¸é ¹®Á¦°¡ ¹ß»ýÇÑ´Ù data->Font.lfHeight = h; // ÀåÆòÀ» µû·Î ÁÖÁö ¾Ê°í ³ôÀÌ¿¡ µû¶ó ÀÏÁ¤ÇÏ°Ô ÁØ´Ù // data->Font.lfWidth = (h*xf); data->Font.lfWidth = 0; data->Font.lfEscapement = s_ort; data->Font.lfOrientation = c_ort; data->Font.lfWeight = th; data->Font.lfItalic = FALSE; data->Font.lfUnderline = FALSE; data->Font.lfStrikeOut = FALSE; data->Font.lfCharSet = DEFAULT_CHARSET; data->Font.lfOutPrecision = OUT_CHARACTER_PRECIS; data->Font.lfClipPrecision = CLIP_CHARACTER_PRECIS; data->Font.lfQuality = DEFAULT_QUALITY; data->Font.lfPitchAndFamily = FIXED_PITCH|FF_DONTCARE; // ±¼¸²Ã¼¸¦ Á÷Á¢ ÁöÁ¤ÇØÁÙ °æ¿ì ¿µ¹® À©µµ¿ì¿¡¼­ ¹®Á¦°¡ ¹ß»ýÇÒ ¼ÒÁö°¡ ÀÖ´Ù // _tcscpy(data->Font.lfFaceName, "±¼¸²Ã¼"); data->TextString = text; for (int k = 0; k < data->nCount; k++) { tempstr[k] = Char(data->TextString[k+1]); } font = CreateFontIndirect(&data->Font); oldfont = (HFONT)SelectObject(hdc, font); SelectObject(hdc, font); GetTextExtentPoint32(hdc, tempstr, text.Length(), &sz); widthsum = sz.cx; SelectObject(hdc, oldfont); DeleteObject(font); font = NULL; height = data->Font.lfHeight; angle = 2*M_PI*data->Font.lfEscapement/10/360; data->Second.x = data->First.x + widthsum*cos(angle) - height*sin(angle); data->Second.y = data->First.y - widthsum*sin(angle) - height*cos(angle); // if (data->pList) // { // return TRUE; // } // else // { // return FALSE; // } return TRUE; } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawBlockSolid(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf; tagDPOINT pFst, pScd, pTrd, pFth; int i, color, g_code, sum = 8, type=1; double th = 1.0f; unsigned long sf_pos; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iKind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bSelected = false; data->nCount = 4; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); data->pList[4].DPoint(pScd.x, pScd.y); data->pList[5].DPoint(pTrd.x, pTrd.y); data->pList[6].DPoint(pTrd.x, pTrd.y); data->pList[7].DPoint(pTrd.x, pTrd.y); data->pList[8].DPoint(pFth.x, pFth.y); data->pList[9].DPoint(pFth.x, pFth.y); data->pList[10].DPoint(pFth.x, pFth.y); data->pList[11].DPoint(pFst.x, pFst.y); data->pList[12].DPoint(pFst.x, pFst.y); data->bClosed = true; if (data->Color != 0) { data->Brush = (TColor)DXF_COLOR[color]; data->bFill = true; } if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawBlockSpline(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf; tagDPOINT pFst; bool isFirst = true; bool isCorelDraw = true; int i, type=1, color, g_code, sum = 1000, cnt = 1, arrCnt = 0; double th = 1.0f; unsigned long sf_pos; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; ibClosed = false; break; case 1 : data->bClosed = true; break; // Illustrator (planar(Æò¸é)·Î ÀνÄ) case 8 : isCorelDraw = false; data->bClosed = false; break; default : data->bClosed = false; break; } } // Number of Control points else if (g_code == 73) { sum = StrToInt(buf); // CorelDraw¿¡¼­´Â g_code == 73ÀÌ 0ÀÎ °æ¿ìµµ ÀÖÀ¸¹Ç·Î ó¸®.. if (sum == 0) { // ¿¡·¯¸Þ½ÃÁö ó¸®.. (Á¤È®ÇÏ°Ô ºÒ·¯¿Ô´ÂÁö ¾Ë ¼ö´Â ¾ø´Ù..) //Application->MessageBox("The File has not been loaded properly", "TextStylist", MB_OK); return TRUE; } else { if (isCorelDraw) { // CorelDraw º¯È¯½Ã.. Illustrator º¯È¯À϶§ º¸´Ù Áߺ¹µÇ´Â ¼ö¸¦ ´õ »©Áà¾ßÇÑ´Ù.. // Áߺ¹µÇ´Â °ªÀº 4n+1 ¶§¸¶´Ù Çѹø¾¿ ³ªÅ¸³­´Ù.. data->nCount = ((sum - ((sum / 4 - 1) - 1)) / 3); } else { // Illustrator º¯È¯½Ã.. 3n+1 À̹ǷΠÁ¡ÀÇ ¼ö ¼ÂÆÃ data->nCount = (sum - 1) / 3; } //data->nCount = sum; sum = sum * 2; } } // Control Points X else if (g_code == 10) { pFst.x = (block.bx+block.mx+StrToFloat(buf)-min_x)*f*block.fx; sum--; } // Control Points y else if (g_code == 20) { pFst.y = (max_y-block.my-StrToFloat(buf)-block.by)*f*block.fy; if (isCorelDraw) { if ((cnt % 4) != 1 || cnt == 1) { if (isFirst) { data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); isFirst = false; } data->pList[arrCnt++].DPoint(pFst.x, pFst.y); } } else { if (isFirst) { data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); isFirst = false; } data->pList[arrCnt++].DPoint(pFst.x, pFst.y); } cnt++; sum--; } } while(sum); // ÆÄÀÏÀ» Àаí ÀÖ´Â À§Ä¡¸¦ ¾ÕÀ¸·Î µ¹·ÁÁØ´Ù SetCount(sf_pos-2); data->Kind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; // ùÁ¡°ú ¸¶Áö¸·Á¡ÀÇ À§Ä¡°¡ °°´Ù¸é ´ÝÈù µµÇüÀ̶ó°í ÆÇ´ÜÇÏ´Â ºÎºÐ // if (!isCorelDraw && data->pList[0].x == data->pList[arrCnt-1].x && // data->pList[0].y == data->pList[arrCnt-1].y) // { // data->bClosed = true; // } if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- // CorelDraw ¿ë.. bool __fastcall CDXF::DrawBlockEllipse(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, sum = 5; double th = 1.0f; float cx, cy, a, b, ratio; //float startParam, endParam; unsigned long sf_pos; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; i= b) { pFst.x = (cy-a); pFst.y = (cx-(a*ratio)); pScd.x = (cy+a); pScd.y = (cx+(a*ratio)); } // ¼¼·Î°¡ ÀåÃàÀÏ °æ¿ì (b) else if (a < b) { pFst.x = (cx-(b*ratio)); pFst.y = (cy-b); pScd.x = (cx+(b*ratio)); pScd.y = (cy+b); } data->Kind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->nCount = 4; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); double M = 0.55228474983; double dx = fabs(pFst.x-pScd.x)/2.0, dy = fabs(pFst.y-pScd.y)/2.0; double ddx = dx * M, ddy = dy * M; data->pList[0].DPoint((pFst.x+pScd.x)/2.0, pFst.y); data->pList[1].DPoint((pFst.x+pScd.x)/2.0-ddx, pFst.y); data->pList[2].DPoint(pFst.x, (pFst.y+pScd.y)/2.0-ddy); data->pList[3].DPoint(pFst.x, (pFst.y+pScd.y)/2.0); data->pList[4].DPoint(pFst.x, (pFst.y+pScd.y)/2+ddy); data->pList[5].DPoint((pFst.x+pScd.x)/2.0-ddx, pScd.y); data->pList[6].DPoint((pFst.x+pScd.x)/2.0, pScd.y); data->pList[7].DPoint((pFst.x+pScd.x)/2.0+ddx, pScd.y); data->pList[8].DPoint(pScd.x, (pFst.y+pScd.y)/2.0+ddy); data->pList[9].DPoint(pScd.x, (pFst.y+pScd.y)/2.0); data->pList[10].DPoint(pScd.x, (pFst.y+pScd.y)/2.0-ddy); data->pList[11].DPoint((pFst.x+pScd.x)/2.0+ddx, pFst.y); data->pList[12].DPoint((pFst.x+pScd.x)/2.0, pFst.y); data->bClosed = true; if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- bool __fastcall CDXF::DrawBlockLWPolyline(TStringList *sf, TVecData *data, tagPBLOCK &block) { String buf; tagDPOINT pFst, pScd; int i, type=1, color, g_code, t_code, sum = -1, cnt = 0; double th = 1.0f; float ox, oy, x, y; BOOL close_flag=false; unsigned long sf_pos; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; i= 0) { if (cnt == 2) { pFst.x = x; pFst.y = y; data->Kind = V_CURVE; //data->First = pFst; //data->Second = pScd; data->PenThick = th; data->bRound = true; // ÇϾá»öÀÌ¸é °ËÀº»öÀ¸·Î ¹Ù²ãÁØ´Ù if (color == 7) color = 0; data->Color = (TColor)DXF_COLOR[color]; data->PenStyle = (EPenStyle)type; data->Bitmap = NULL; data->bFill = false; data->bSelected = false; } else if (cnt == 4) { pScd.x = x; pScd.y = y; data->nCount = 1; data->pList = (DPOINT *)HeapAlloc(GetProcessHeap(), 0, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapAlloc(GetProcessHeap(), 0, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); data->pList[0].DPoint(pFst.x, pFst.y); data->pList[1].DPoint(pFst.x, pFst.y); data->pList[2].DPoint(pScd.x, pScd.y); data->pList[3].DPoint(pScd.x, pScd.y); } else if (cnt > 4 && cnt % 2 == 0) { pFst.x = pScd.x; pFst.y = pScd.y; pScd.x = x; pScd.y = y; data->nCount++; data->pList = (DPOINT *)HeapReAlloc(GetProcessHeap(), 0, data->pList, sizeof(DPOINT)*(data->nCount*3+1)); data->pMask = (BYTE*)HeapReAlloc(GetProcessHeap(), 0, data->pMask, (data->nCount * 3 + 1) % 8 == 0 ? (data->nCount * 3 + 1) / 8 : (data->nCount * 3 + 1) / 8 + 1); HeapCompact(GetProcessHeap(), 0); data->pList[data->nCount*3 - 2].DPoint(pFst.x, pFst.y); data->pList[data->nCount*3 - 1].DPoint(pScd.x, pScd.y); data->pList[data->nCount*3].DPoint(pScd.x, pScd.y); } } } while(sum); // ÆÄÀÏÀ» Àаí ÀÖ´Â À§Ä¡¸¦ ¾ÕÀ¸·Î µ¹·ÁÁØ´Ù SetCount(sf_pos-2); if (close_flag) { data->bClosed = true; } if (data->pList) { SET_RECT; return TRUE; } else { return FALSE; } } //--------------------------------------------------------------------------- /* // todo : DrawBlockMTextÂ÷ÈÄ ¾÷±×·¹À̵å ÁøÇà bool __fastcall CDXF::DrawBlockMText(TStringList *sf, TVecData *data, tagPBLOCK &block) { unsigned int al; unsigned long sf_pos; TLogFont logfont; GetObject(Image.Canvas->Font->Handle, sizeof(TLogFont), &logfont); COLORREF OldColor; String buf, text; //TFont font, *pOldFont; int i, x, y, x2, y2, h=0, type, color, g_code, h_align=-1, v_align=-1, sum = 4, o_flag=0, s_ort=0, c_ort=0; double xf=0, t_h=0, xx, xx2, th = 1.0f; color = block.color; do { sf_pos = GetCount(); g_code = GetLine(sf, buf); if (g_code == 8) { for (i=0; iFont->Handle = CreateFontIndirect(&logfont); Image.Canvas->Font->Handle = &(LOGFONT)logfont; Image.Canvas->Font->Color = DXF_COLOR[color]; Image.Canvas->TextOutA(x, y, text); //metaDC.Font->Handle = &(LOGFONT)logfont; //font.CreateFontIndirect(&logfont); //OldColor = metaDC.SetTextColor(DXF_COLOR[color]); //pOldFont = (CFont *)metaDC.SelectObject(&font); //metaDC.SetTextAlign(al); //metaDC.TextOut(x, y, text); //metaDC.SelectObject(pOldFont); //font.DeleteObject(); //metaDC.SetTextColor(OldColor); if (data->pList) { return TRUE; } else { return FALSE; } } */ //---------------------------------------------------------------------------